kelseye commited on
Commit
6918b34
·
verified ·
1 Parent(s): eb3b012

Upload folder using huggingface_hub (part 4)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. md/dev/slHNW9yRie0/slHNW9yRie0.md +441 -0
  2. md/dev/t877958UGZ/t877958UGZ.md +465 -0
  3. md/dev/tDw7Mmat8co/tDw7Mmat8co.md +668 -0
  4. md/dev/tGHi1HFNBx1/tGHi1HFNBx1.md +0 -0
  5. md/dev/tGbpgz6yOrI/tGbpgz6yOrI.md +334 -0
  6. md/dev/tHK5ntjp-5K/tHK5ntjp-5K.md +445 -0
  7. md/dev/tZXaHWfsXB/tZXaHWfsXB.md +376 -0
  8. md/dev/tZmqS73_07/tZmqS73_07.md +574 -0
  9. md/dev/taQ64d2KBX/taQ64d2KBX.md +530 -0
  10. md/dev/td6xbEOPLr/td6xbEOPLr.md +392 -0
  11. md/dev/ti6fH3EhFkv/ti6fH3EhFkv.md +283 -0
  12. md/dev/tjFaqsSK2I3/tjFaqsSK2I3.md +233 -0
  13. md/dev/to3qCB3tOh9/to3qCB3tOh9.md +0 -0
  14. md/dev/toR64fsPir/toR64fsPir.md +496 -0
  15. md/dev/tq_J_MqB3UB/tq_J_MqB3UB.md +337 -0
  16. md/dev/tro0_OqIVde/tro0_OqIVde.md +306 -0
  17. md/dev/tyrJsbKAe6/tyrJsbKAe6.md +0 -0
  18. md/dev/u03xn1COsO/u03xn1COsO.md +0 -0
  19. md/dev/u3vEuRr08MT/u3vEuRr08MT.md +364 -0
  20. md/dev/u6Xv3FuF8N/u6Xv3FuF8N.md +332 -0
  21. md/dev/uCXNOeL0TG/uCXNOeL0TG.md +444 -0
  22. md/dev/uKiE0VIluA-/uKiE0VIluA-.md +0 -0
  23. md/dev/uLYc4L3C81A/uLYc4L3C81A.md +418 -0
  24. md/dev/uRTW_PgXvc7/uRTW_PgXvc7.md +306 -0
  25. md/dev/uYLFoz1vlAC/uYLFoz1vlAC.md +0 -0
  26. md/dev/ubgdInLSF9/ubgdInLSF9.md +386 -0
  27. md/dev/ubzNoJjOKj/ubzNoJjOKj.md +479 -0
  28. md/dev/ucASPPD9GKN/ucASPPD9GKN.md +0 -0
  29. md/dev/ucNDIDRNjjv/ucNDIDRNjjv.md +237 -0
  30. md/dev/uloenYmLCAo/uloenYmLCAo.md +305 -0
  31. md/dev/um2BxfgkT2_/um2BxfgkT2_.md +316 -0
  32. md/dev/unb1wyXf-aC/unb1wyXf-aC.md +470 -0
  33. md/dev/upJ3vrFKaL/upJ3vrFKaL.md +302 -0
  34. md/dev/uu6Oq7MN7g/uu6Oq7MN7g.md +490 -0
  35. md/dev/uuUQraD4XX/uuUQraD4XX.md +461 -0
  36. md/dev/uxxFrDwrE7Y/uxxFrDwrE7Y.md +366 -0
  37. md/dev/uy602F8cTrh/uy602F8cTrh.md +213 -0
  38. md/dev/uytgM9N0vlR/uytgM9N0vlR.md +301 -0
  39. md/dev/v54eUIayFh/v54eUIayFh.md +520 -0
  40. md/dev/vGQiU5sqUe3/vGQiU5sqUe3.md +401 -0
  41. md/dev/vKBdabh_WV/vKBdabh_WV.md +652 -0
  42. md/dev/vSVLM2j9eie/vSVLM2j9eie.md +443 -0
  43. md/dev/vSix3HPYKSU/vSix3HPYKSU.md +635 -0
  44. md/dev/vaRCHVj0uGI/vaRCHVj0uGI.md +420 -0
  45. md/dev/vbPsD-BhOZ/vbPsD-BhOZ.md +388 -0
  46. md/dev/vcNjibzV3P/vcNjibzV3P.md +466 -0
  47. md/dev/vdKncX1WclT/vdKncX1WclT.md +361 -0
  48. md/dev/vfsRB5MImo9/vfsRB5MImo9.md +0 -0
  49. md/dev/vhFu1Acb0xb/vhFu1Acb0xb.md +438 -0
  50. md/dev/vhKaBdOOobB/vhKaBdOOobB.md +292 -0
md/dev/slHNW9yRie0/slHNW9yRie0.md ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # COLD DIFFUSION: INVERTING ARBITRARY IMAGE TRANSFORMS WITHOUT NOISE
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Standard diffusion models involve an image transform – adding Gaussian noise – and an image restoration operator that inverts this degradation. We observe that the generative behavior of diffusion models is not strongly dependent on the choice of image degradation, and in fact an entire family of generative models can be constructed by varying this choice. Even when using completely deterministic degradations (e.g., blur, masking, and more), the training and test-time update rules that underlie diffusion models can be easily generalized to create generative models. The success of these fully deterministic models calls into question the community’s understanding of diffusion models, which relies on noise in either gradient Langevin dynamics or variational inference, and paves the way for generalized diffusion models that invert arbitrary processes.
8
+
9
+ ![](images/1eb391fa3973b43618811285c2093ac9fbda9931dc7342cee650287550d689ba.jpg)
10
+ Figure 1: Demonstration of the forward and backward processes for both hot and cold diffusions. While standard diffusions are built on Gaussian noise (top row), we show that generative models can be built on arbitrary and even noiseless/cold image transforms, including the ImageNet-C snowification operator, and an animorphosis operator that adds a random animal image from AFHQ.
11
+
12
+ # 1 INTRODUCTION
13
+
14
+ Diffusion models have recently emerged as powerful tools for generative modeling (Ramesh et al., 2022). Diffusion models come in many flavors, but all are built around the concept of random noise removal; one trains an image restoration/denoising network that accepts an image contaminated with Gaussian noise, and outputs a denoised image. At test time, the denoising network is used to convert pure Gaussian noise into a photo-realistic image using an update rule that alternates between applying the denoiser and adding Gaussian noise. When the right sequence of updates is applied, complex generative behavior is observed.
15
+
16
+ The origins of diffusion models, and also our theoretical understanding of these models, are strongly based on the role played by Gaussian noise during training and generation. Diffusion has been understood as a random walk around the image density function using Langevin dynamics (SohlDickstein et al., 2015; Song & Ermon, 2019), which requires Gaussian noise in each step. The walk begins in a high temperature (heavy noise) state, and slowly anneals into a “cold” state with little if any noise. Another line of work derives the loss for the denoising network using variational inference with a Gaussian prior (Ho et al., 2020; Song et al., 2021a; Nichol & Dhariwal, 2021).
17
+
18
+ In this work, we examine the need for Gaussian noise, or any randomness at all, for diffusion models to work in practice. We consider generalized diffusion models that live outside the confines of the theoretical frameworks from which diffusion models arose. Rather than limit ourselves to models built around Gaussian noise, we consider models built around arbitrary image transformations like blurring, downsampling, etc. We train a restoration network to invert these deformations using a simple $\ell _ { p }$ loss. When we apply a sequence of updates at test time that alternate between the image restoration model and the image degradation operation, generative behavior emerges, and we obtain photo-realistic images.
19
+
20
+ The existence of cold diffusions that require no Gaussian noise (or any randomness) during training or testing raises questions about the limits of our theoretical understanding of diffusion models. It also unlocks the door for potentially new types of generative models with very different properties than conventional diffusion seen so far.
21
+
22
+ # 2 BACKGROUND
23
+
24
+ Both the Langevin dynamics and variational inference interpretations of diffusion models rely on properties of the Gaussian noise used in the training and sampling pipelines. From the scorematching generative networks perspective (Song & Ermon, 2019; Song et al., 2021b), noise in the training process is critically thought to expand the support of the low-dimensional training distribution to a set of full measure in ambient space. The noise is also thought to act as data augmentation to improve score predictions in low density regions, allowing for mode mixing in the stochastic gradient Langevin dynamics (SGLD) sampling. The gradient signal in low-density regions can be further improved during sampling by injecting large magnitudes of noise in the early steps of SGLD and gradually reducing this noise in later stages.
25
+
26
+ Kingma et al. (2021) propose a method to learn a noise schedule that leads to faster optimization. Using a classic statistical result, Kadkhodaie & Simoncelli (2021) show the connection between removing additive Gaussian noise and the gradient of the log of the noisy signal density in deterministic linear inverse problems. Here, we shed light on the role of noise in diffusion models through theoretical and empirical results in applications to inverse problems and image generation.
27
+
28
+ Iterative neural models have been used for various inverse problems (Romano et al., 2016; Metzler et al., 2017). Recently, diffusion models have been applied to them (Song et al., 2021b) for the problems of deblurring, denoising, super-resolution, and compressive sensing (Whang et al., 2021; Kawar et al., 2021; Saharia et al., 2021; Kadkhodaie & Simoncelli, 2021).
29
+
30
+ Although not their focus, previous works on diffusion models have included experiments with deterministic image generation (Song et al., 2021a; Dhariwal & Nichol, 2021; Karras et al., 2022) and in selected inverse problems (Kawar et al., 2022). Recently, Rissanen et al. (2022) use a combination of Gaussian noise and blurring as a forward process for diffusion. Though they show the feasibility of a different degradation, here we show definitively that noise is not a necessity in diffusion models, and we observe the effects of removing noise for a number of inverse problems.
31
+
32
+ Despite prolific work on generative models in recent years, methods to probe the properties of learned distributions and measure how closely they approximate the real training data are by no means closed fields of investigation.
33
+
34
+ Indirect feature space similarity metrics such as Inception Score (Salimans et al., 2016), Mode Score (Che et al., 2016), Frechet inception distance (FID) (Heusel et al., 2017), and Kernel inception distance (KID) (Binkowski et al., 2018) have been proposed and adopted to some extent, but they ´ have notable limitations (Barratt & Sharma, 2018). To adopt a popular frame of reference, we will use FID as the feature similarity metric for our experiments.
35
+
36
+ # 3 GENERALIZED DIFFUSION
37
+
38
+ Standard diffusion models are built around two components. First, there is an image degradation operator that contaminates images with Gaussian noise. Second, a trained restoration operator is created to perform denoising. The image generation process alternates between the application of these two operators. In this work, we consider the construction of generalized diffusions built around arbitrary degradation operations. These degradations can be randomized (as in the case of standard diffusion) or deterministic.
39
+
40
+ # 3.1 MODEL COMPONENTS AND TRAINING
41
+
42
+ Given an image $\boldsymbol { x } _ { 0 } \in \mathbb { R } ^ { N }$ , consider the degradation of $x _ { 0 }$ by operator $D$ with severity $t$ , denoted $x _ { t } = D ( x _ { 0 } , t )$ . The output distribution $D ( x _ { 0 } , t )$ of the degradation should vary continuously in $t$ , and the operator should satisfy $D ( x _ { 0 } , 0 ) = x _ { 0 }$ .
43
+
44
+ In the standard diffusion framework, $D$ adds Gaussian noise with variance proportional to $t$ . In our generalized formulation, we choose $D$ to perform various other transformations such as blurring, masking out pixels, downsampling, and more, with severity that depends on $t$ . We explore a range of choices for $D$ in Section 4.
45
+
46
+ We also require a restoration operator $R$ that (approximately) inverts $D$ . This operator has the property that $R ( x _ { t } , t ) \approx x _ { 0 }$ . In practice, this operator is implemented via a neural network parameterized by $\theta$ . The restoration network is trained via the minimization problem
47
+
48
+ $$
49
+ \operatorname* { m i n } _ { \theta } \mathbb { E } _ { x \sim \mathcal { X } } \| R _ { \theta } ( D ( x , t ) , t ) - x \| ,
50
+ $$
51
+
52
+ where $x$ denotes a random image sampled from distribution $\mathcal { X }$ and $\| \cdot \|$ denotes a norm, which we take to be $\ell _ { 1 }$ in our experiments. We have so far used the subscript $R _ { \theta }$ to emphasize the dependence of $R$ on $\theta$ during training, but we will omit this symbol for simplicity in the discussion below.
53
+
54
+ # 3.2 SAMPLING FROM THE MODEL
55
+
56
+ After choosing a degradation $D$ and training a model $R$ to perform the restoration, these operators can be used in tandem to invert severe degradations by using standard methods borrowed from the diffusion literature. For small degradations $\left( t \approx 0 \right)$ ), a single application of $R$ can be used to obtain a restored image in one shot. However, because $R$ is typically trained using a simple convex loss, it yields blurry results when used with large $t$ . Rather, diffusion models (Song et al., 2021a; Ho et al., 2020) perform generation by iteratively applying the denoising operator and then adding noise back to the image, with
57
+
58
+ <table><tr><td>Algorithm 1 Naive Sampling Input: A degraded sample xt</td></tr><tr><td>for s=t,t-1,...,1 do xo←R(xs,s) xs-1= D(xo,s-1) end for</td></tr><tr><td>Return: xo Algorithm 2 Transformation Agnostic Cold Sampling</td></tr><tr><td>Input: A degraded sample xt fors=t,t-1,...,1do</td></tr></table>
59
+
60
+ the level of added noise decreasing over time. This is the standard update sequence in Algorithm 1.
61
+
62
+ When the restoration operator is perfect, i.e. when $R ( D ( x _ { 0 } , t ) , t ) = x _ { 0 }$ for all $t$ , one can easily see that Algorithm 1 produces exact iterates of the form $x _ { s } = D ( x _ { 0 } , s )$ . But what happens for imperfect restoration operators? In this case, errors can cause the iterates $x _ { s }$ to wander away from $D ( x _ { 0 } , s )$ , and inaccurate reconstruction may occur.
63
+
64
+ We find that the standard sampling approach in Algorithm 1 (explained further in A.8) works well for noise-based diffusion, possibly because the restoration operator $R$ has been trained to correct (random Gaussian) errors in its inputs. However, we find that it yields poor results in the case of cold diffusions with smooth/differentiable degradations as demonstrated for a deblurring model in
65
+
66
+ Figure 2. We propose Transformation Agnostic Cold Sampling (TACoS) in Algorithm 2, which we find to be superior for inverting smooth, cold degradations.
67
+
68
+ This sampler has important mathematical properties that enable it to recover high quality results. Specifically, for a class of linear degradation operations, it can be shown to produce exact reconstruction (i.e. $x _ { s } = D ( x _ { 0 } , s ) )$ ) even when the restoration operator $R$ fails to perfectly invert $D$ . We discuss this in the following section.
69
+
70
+ # 3.3 PROPERTIES OF TACOS
71
+
72
+ It is clear from inspection that both Algorithms 1 and 2 perfectly reconstruct the iterate $x _ { s } ~ = ~ D ( x _ { 0 } , s )$ for all $s \ < \ t$ if the restoration operator is a perfect inverse for the degradation operator. In this section, we analyze the stability of these algorithms to errors in the restoration operator.
73
+
74
+ For small values of $x$ and $s$ , TACoS as described in 2 is tolerant of error in the restoration operator $R$ .To see why, consider a model problem with a linear degradation function of the form $D ( x , s ) \approx x { \bar { + } } s \cdot e$ for
75
+
76
+ ![](images/33818f76daac3efec172adcb5ad1b32c3b4db43c35bc5f370d1286455ff0a099.jpg)
77
+ Figure 2: Comparison of sampling methods for unconditional generation using cold diffusion on the CelebA dataset. Iterations 2, 4, 8, 16, 32, 64, 128, 192, and 256 are presented. Top: Algorithm 1 produces compounding artifacts and fails to generate a new image. Bottom: TACoS succeeds in sampling a high quality image without noise.
78
+
79
+ a constant vector $e$ . We chose this ansatz because the Taylor expansion of any smooth degradation $D ( x , s )$ around $x = x _ { 0 } , s = 0$ has the form $D ( x , s ) \approx x + s \cdot e ( x ) + { \mathrm { H O T } }$ where HOT denotes higher order terms. Note, however, the analysis below requires $e$ to be a constant that does not depend on $x$ . The constant/zeroth-order term in this Taylor expansion is zero because we assumed above that the degradation operator satisfies $D ( x , 0 ) = { \overset { \cdot } { x } }$ .
80
+
81
+ For a degradation $D ( x , s )$ and any restoration operator $R$ , the term $x _ { s - 1 }$ in TACoS becomes
82
+
83
+ $$
84
+ \begin{array} { r l } & { x _ { s } - D ( R ( x _ { s } , s ) , s ) + D ( R ( x _ { s } , s ) , s - 1 ) = D ( x _ { 0 } , s ) - D ( R ( x _ { s } , s ) , s ) + D ( R ( x _ { s } , s ) , s - 1 ) } \\ & { \ = x _ { 0 } + s \cdot e - R ( x _ { s } , s ) - s \cdot e + R ( x _ { s } , s ) + ( s - 1 ) \cdot e = x _ { 0 } + ( s - 1 ) = D ( x _ { 0 } , s - 1 ) } \end{array}
85
+ $$
86
+
87
+ By induction, we see that the algorithm produces the value $x _ { s } = D ( x _ { 0 } , s )$ for all $s < t$ , regardless of the choice of $R$ . In other words, for any choice of $R$ , the iteration behaves the same as it would when $R$ is a perfect inverse for the degradation $D$ .
88
+
89
+ By contrast, Algorithm 1 does not enjoy this behavior even for small values of $s$ . In fact, when $R$ is not a perfect inverse for $D$ , $x _ { 0 }$ is not a fixed point of the update rule in Algorithm 1 because $x _ { 0 } \neq D ( \bar { R ( x , 0 ) } , 0 ) = R ( x , 0 )$ and hence compounds errors. If $R$ does not perfectly invert $D$ we should expect Algorithm 1 to incur errors, even for small values of $s$ . Meanwhile, for small values of $s$ , the behavior of $D$ approaches its first-order Taylor expansion and Algorithm 2 becomes immune to errors in $R$ . Figure 2 demonstrates the stability of TACoS described in Algorithm 2 vs Algorithm 1 for a deblurring model. Note that our analysis is not meant to be a complete convergence theory, rather to highlight a desirable theoretical property of our method that a naive sampler lacks.
90
+
91
+ # 4 GENERALIZED DIFFUSIONS WITH VARIOUS TRANSFORMATIONS
92
+
93
+ In this section, we take the first step towards cold diffusion by reversing different degradations and hence performing conditional generation. We will extend our methods to perform unconditional (i.e. from scratch) generation in Section 5. We emprically evaluate generalized diffusion models trained on different degradations with TACoS proposed in Algorithm 2. We perform experiments on the vision tasks of deblurring, inpainting, super-resolution, and the unconventional task of synthetic snow removal. We perform our experiments on MNIST (LeCun et al., 1998), CIFAR-10 (Krizhevsky, 2009), and CelebA (Liu et al., 2015). In each of these tasks, we gradually remove the information from the clean image, creating a sequence of images such that $D ( x _ { 0 } , t )$ retains less information than $D ( x _ { 0 } , t - 1 )$ . For these different tasks, we present both qualitative and quantitative results on a held-out testing dataset and demonstrate the importance of the sampling technique described in Algorithm 2. For all quantitative results in this section, the Frechet inception distance (FID) scores (Heusel et al., 2017) for degraded and reconstructed images are measured with respect to the testing data. Additional information about the quantitative results, convergence criteria, hyperparameters, and architecture of the models presented below can be found in the appendix.
94
+
95
+ # 4.1 DEBLURRING
96
+
97
+ We consider a generalized diffusion based on a Gaussian blur operation (as opposed to Gaussian noise) in which an image at step $t$ has more blur than at $t - 1$ . The forward process given the Gaussian kernels $\{ G _ { s } \}$ and the image $x _ { t - 1 }$ at step $t - 1$ can thus be written as
98
+
99
+ $$
100
+ x _ { t } = G _ { t } * x _ { t - 1 } = G _ { t } * \ldots * G _ { 1 } * x _ { 0 } = { \bar { G } } _ { t } * x _ { 0 } = D ( x _ { 0 } , t ) ,
101
+ $$
102
+
103
+ where $^ *$ denotes the convolution operator, which blurs an image using a kernel.
104
+
105
+ We train a deblurring model by minimizing the loss equation 1, and then use TACoS to invert this blurred diffusion process for which we trained a DNN to predict the clean image $\scriptstyle { \hat { x } } _ { 0 }$ . Qualitative results are shown in Figure 3 and quantitative results in Table 1. Qualitatively, we can see that images created using the sampling process are sharper and in some cases completely different as compared to the direct reconstruction of the clean image. Quantitatively we can see that the reconstruction metrics such as RMSE and PSNR get worse when we use the sampling process, but on the other hand FID with respect to held-out test data improves. The qualitative improvements and decrease in FID show the benefits of the generalized sampling routine, which brings the learned distribution closer to the true data manifold.
106
+
107
+ In the case of blur operator, the sampling routine can be thought of adding frequencies at each step. This is because the sampling routine involves the term $D ( \hat { x _ { 0 } } , t ) - D ( \hat { x _ { 0 } } , t - \mathbf { \bar { 1 } } )$ which in the case of blur becomes ${ \bar { G } } _ { t } * x _ { 0 } - { \bar { G } } _ { t - 1 } * x _ { 0 }$ . This results in a difference of Gaussians, which is a band pass filter and contains frequencies that were removed at step $t$ . Thus, in the sampling process, we sequentially add the frequencies that were removed during the degradation process.
108
+
109
+ ![](images/7374b17fa61b4fb9dfe001a2869705b4fa78d331cec6e81b367a6aa105bc579e.jpg)
110
+ Figure 3: Deblurring models trained on the MNIST, CIFAR-10, and CelebA datasets. Left to right: degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
111
+
112
+ Table 1: Quantitative metrics for quality of image reconstruction using deblurring models.
113
+
114
+ <table><tr><td rowspan="2">Dataset</td><td colspan="3">Degraded</td><td colspan="3">Sampled</td><td colspan="3">Direct</td></tr><tr><td>FID</td><td>SSIM</td><td>RMSE</td><td>FID</td><td>SSIM</td><td>RMSE</td><td>FID</td><td>SSIM</td><td>RMSE</td></tr><tr><td>MNIST</td><td>438.59</td><td>0.287</td><td>0.287</td><td>4.69</td><td>0.718</td><td>0.154</td><td>5.10</td><td>0.757</td><td>0.142</td></tr><tr><td>CIFAR-10</td><td>298.60</td><td>0.315</td><td>0.136</td><td>80.08</td><td>0.773</td><td>0.075</td><td>83.69</td><td>0.775</td><td>0.071</td></tr><tr><td>CelebA</td><td>382.81</td><td>0.254</td><td>0.193</td><td>26.14</td><td>0.568</td><td>0.093</td><td>36.37</td><td>0.607</td><td>0.083</td></tr></table>
115
+
116
+ # 4.2 INPAINTING
117
+
118
+ We define a schedule of transforms that progressively grays-out pixels from the input image. We remove pixels using a Gaussian mask as follows: For input images of size $n \times n$ we start with a 2D Gaussian curve of variance $\beta$ , discretized into an $n \times n$ array. We normalize so the peak of the curve has value 1, and subtract the result from 1 so the center of the mask as value 0. We randomize the location of the Gaussian mask for MNIST and CIFAR-10, but keep it centered for CelebA. We denote the final mask by $z _ { \beta }$ .
119
+
120
+ Input images $x _ { 0 }$ are iteratively masked for $T$ steps via multiplication with a sequence of masks $\{ z _ { \beta _ { i } } \}$ with increasing $\beta _ { i }$ . We can control the amount of information removed at each step by tuning the $\beta _ { i }$ parameter. In the language of Section 3, $\begin{array} { r } { D ( x _ { 0 } , t ) = x _ { 0 } \cdot \prod _ { i = 1 } ^ { t } z _ { \beta _ { i } } } \end{array}$ , where the operator $\cdot$ denotes entry-wise multiplication.
121
+
122
+ Figure 4 presents results on test images and compares the output of the inpainting model to the original image. The reconstructed images display reconstructed features qualitatively consistent with the context provided by the unperturbed regions of the image. We quantitatively assess the effectiveness of the inpainting models on each of the datasets by comparing distributional similarity metrics before and after the reconstruction. Our results are summarized in Table 2. Note, the FID scores here are computed with respect to the held-out validation set.
123
+
124
+ ![](images/a79ad5589e6263344c81f149014a3ba3ce0f8b618378dbab4e299af63b23929e.jpg)
125
+ Figure 4: Inpainting models trained on the MNIST, CIFAR-10, and CelebA datasets. Left to right: Degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
126
+
127
+ Table 2: Quantitative metrics for quality of image reconstruction using inpainting models.
128
+
129
+ <table><tr><td>Dataset</td><td colspan="3">Degraded</td><td colspan="3">Sampled</td><td colspan="3">Direct</td></tr><tr><td></td><td>FID</td><td>SSIM</td><td>RMSE</td><td>FID</td><td>SSIM</td><td>RMSE</td><td>FID</td><td>SSIM</td><td>RMSE</td></tr><tr><td>MNIST</td><td>108.48</td><td>0.490</td><td>0.262</td><td>1.61</td><td>0.941</td><td>0.068</td><td>2.24</td><td>0.948</td><td>0.060</td></tr><tr><td>CIFAR-10</td><td>40.83</td><td>0.615</td><td>0.143</td><td>8.92</td><td>0.859</td><td>0.068</td><td>9.97</td><td>0.869</td><td>0.063</td></tr><tr><td>CelebA</td><td>127.85</td><td>0.663</td><td>0.155</td><td>5.73</td><td>0.917</td><td>0.043</td><td>7.74</td><td>0.922</td><td>0.039</td></tr></table>
130
+
131
+ # 4.3 SUPER-RESOLUTION
132
+
133
+ For this task, the degradation operator downsamples the image by a factor of two in each direction. The final resolution of $x _ { T }$ is $4 \times 4$ for MNIST and CIFAR-10 and $2 \times 2$ in the case of Celeb-A. After each down-sampling, the lower-resolution image is resized to the original image size, using nearestneighbor interpolation. More details are available in Appendix A.3
134
+
135
+ Figure 5 presents example testing data inputs for all datasets and compares the output of the superresolution model to the original image. Though the reconstructed images are not perfect for the more challenging datasets, the reconstructed features are qualitatively consistent with the context provided by the low resolution image. Table 3 compares the distributional similarity metrics between degraded/reconstructed images and test samples.
136
+
137
+ ![](images/32d94cc6baaa2c1327a238725971a8191c688dbaa185c1aa434b546135cea566.jpg)
138
+ Figure 5: Superresolution models trained on the MNIST, CIFAR-10, and CelebA datasets. Left to right: degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
139
+
140
+ Table 3: Quantitative metrics for quality of image reconstruction using super-resolution models.
141
+
142
+ <table><tr><td rowspan="2">Dataset</td><td colspan="3">Degraded</td><td colspan="3">Sampled</td><td colspan="3">Direct</td></tr><tr><td>FID</td><td>SSIM</td><td>RMSE</td><td>FID</td><td>SSIM</td><td>RMSE</td><td>FID</td><td>SSIM</td><td>RMSE</td></tr><tr><td>MNIST</td><td>368.56</td><td>0.178</td><td>0.231</td><td>4.33</td><td>0.820</td><td>0.115</td><td>4.05</td><td>0.823</td><td>0.114</td></tr><tr><td>CIFAR-10</td><td>358.99</td><td>0.279</td><td>0.146</td><td>152.76</td><td>0.411</td><td>0.155</td><td>169.94</td><td>0.420</td><td>0.152</td></tr><tr><td>CelebA</td><td>349.85</td><td>0.335</td><td>0.225</td><td>96.92</td><td>0.381</td><td>0.201</td><td>112.84</td><td>0.400</td><td>0.196</td></tr></table>
143
+
144
+ # 4.4 SNOWIFICATION
145
+
146
+ Apart from traditional degradations, we additionally provide results for the task of synthetic snow removal using the offical implementation of the snowification transform from ImageNet-C (Hendrycks & Dietterich, 2019). The purpose of this experiment is to demonstrate that generalized diffusion can succeed even with exotic transforms that lack the scale-space and compositional properties of blur operators. Similar to other tasks, we degrade the images by adding snow, such that the level of snow increases with step $t$ . We provide more implementation details in Appendix.
147
+
148
+ We illustrate our desnowification results in Figure 6. We present testing examples, as well as their snowified images, from all the datasets, and compare the desnowified results with the original images. The desnowified images feature near-perfect reconstruction results for CIFAR-10 examples with lighter snow, and exhibit visually distinctive restoration for Celeb-A examples with heavy snow. We provide quantitative results in Table 4.
149
+
150
+ ![](images/254a085d4eb1e1fc1982654d6e1706c8034a9f31796972f04a7975575551f238.jpg)
151
+ Figure 6: Desnowification models trained on the CIFAR-10, and CelebA datasets. Left to right: degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
152
+
153
+ Table 4: Quantitative metrics for quality of image reconstruction using desnowification models.
154
+
155
+ <table><tr><td>Dataset</td><td>FID</td><td>Degraded Image SSIM</td><td>RMSE</td><td>FID</td><td>Reconstruction SSIM</td><td>RMSE</td></tr><tr><td>CIFAR-10</td><td>125.63</td><td>0.419</td><td>0.327</td><td>31.10</td><td>0.074</td><td>0.838</td></tr><tr><td>CelebA</td><td>398.31</td><td>0.338</td><td>0.283</td><td>27.09</td><td>0.033</td><td>0.907</td></tr></table>
156
+
157
+ # 5 COLD GENERATION
158
+
159
+ Diffusion models can successfully learn the underlying distribution of training data, and thus generate diverse, high quality images (Song et al., 2021a; Dhariwal & Nichol, 2021; Jolicoeur-Martineau et al., 2021; Ho et al., 2022). We will first discuss deterministic generation using Gaussian noise and then discuss in detail unconditional generation using deblurring. Finally, we provide a proof of concept that the TACoS described in Algorithm 2 can be extended to other degradations.
160
+
161
+ # 5.1 GENERATION USING DETERMINISTIC NOISE DEGRADATION
162
+
163
+ Here we discuss image generation using a noise-based degradation presented in our notation from Section 3, which we will later prove is equivalent to DDIM (Song et al., 2021a). We use the following degradation operator: $D ( \dot { x _ { , } } t ) = \sqrt { \dot { \alpha _ { t } } } x + \sqrt { 1 - \alpha _ { t } } z$ .
164
+
165
+ $D$ is an interpolation between the data point $x$ and a sampled noise pattern $z \in \mathcal { N } ( 0 , 1 )$ . During training, $D$ is applied once and thus $z$ is sampled once for every image in every batch. However, sampling involves iterative applications of the degradation operator $D$ , which poses the question of how to pick $z$ for the sequence of degradations $D$ applied in a single image generation.
166
+
167
+ There are three possible choices for $z$ . The first would be to resample $z$ for each application of $D$ , but this would make the sampling process nondeterministic for a fixed starting point. Another option is to sample a noise pattern $z$ once for each separate image generation and reuse it in each application of $D$ . In Table 5 we refer to this approach as Fixed Noise. Finally, one can calculate the noise vector $z$ to be used in step $t$ of reconstruction by using the formula
168
+
169
+ $$
170
+ \widehat { z } ( x _ { t } , t ) = \frac { x _ { t } - \sqrt { \alpha _ { t } } R ( x _ { t } , t ) } { \sqrt { 1 - \alpha _ { t } } } .
171
+ $$
172
+
173
+ This method denoted Estimated Noise in Table 5 turns out to be equivalent to the deterministic sampling proposed in Song et al. (2021a). We discuss this equivalence in detail in Appendix A.6.
174
+
175
+ # 5.2 IMAGE GENERATION USING BLUR
176
+
177
+ The forward diffusion process in noise-based diffusion models has the advantage that the degraded image distribution at the final step $T$ is simply an isotropic Gaussian. One can therefore perform (unconditional) generation by first drawing a sample from the isotropic Gaussian, and sequentially denoising it with backward diffusion.
178
+
179
+ When using blur as a degradation, the fully degraded images do not form a nice closed-form distribution that we can sample from. They do, however, form a simple enough distribution that can be modeled with simple methods. Note that every image $x _ { 0 }$ degenerates to an $x _ { T }$ that is constant (i.e., every pixel is the same color) for large $T$ . Furthermore, the constant value is exactly the channelwise mean of the RGB image $x _ { 0 }$ , and can be represented with a 3-vector. This 3-dimensional distribution is easily represented using a Gaussian mixture model (GMM). This GMM can be sampled to produce the random pixel values of a severely blurred image, which can be deblurred using cold diffusion to create a new image.
180
+
181
+ Our generative model uses a blurring schedule where we progressively blur each image with a Gaussian kernel of size $2 7 \times 2 7$ over 300 steps. The standard deviation of the kernel starts at 1 and increases exponentially at the rate of 0.01. We then fit a simple GMM with one component to the distribution of channel-wise means. To generate an image from scratch, we sample the channel-wise mean from the GMM, expand the 3D vector into a $1 2 8 \times 1 2 8$ image with three channels, and then apply TACoS.
182
+
183
+ Empirically, the presented pipeline generates images with high fidelity but low diversity, as reflected quantitatively by comparing the perfect symmetry column with results from hot diffusion in Table 5. We attribute this to the perfect correlation between pixels of $x _ { T }$ sampled from the channel-wise mean Gaussian mixture model. To break the symmetry between pixels, we add a small amount of Gaussian noise (of standard deviation 0.002) to each sampled $x _ { T }$ . As shown in Table 5, the simple trick drastically improves the quality of generated images. We also present the qualitative results for cold diffusion using blur transformation in Figure 7, and further discuss the necessity of TACoS proposed in Algorithm 2 for generation in Appendix A.7.
184
+
185
+ Table 5: FID scores for CelebA and AFHQ datasets using hot (noise) and cold diffusion (blur transformation). Breaking the symmetry within pixels of the same channel further improves FID.
186
+
187
+ <table><tr><td></td><td colspan="2">Hot Diffusion</td><td colspan="2">Cold Diffusion</td></tr><tr><td>Dataset</td><td>Fixed Noise</td><td>Estimated Noise</td><td>Perfect symmetry</td><td>Broken symmetry</td></tr><tr><td>CelebA</td><td>59.91</td><td>23.11</td><td>97.00</td><td>49.45</td></tr><tr><td>AFHQ</td><td>25.62</td><td>20.59</td><td>93.05</td><td>54.68</td></tr></table>
188
+
189
+ ![](images/a2bd8c349ce00a5e7bddb2f498a55eccd56baa748bf89354e5cc857c7b3a7633.jpg)
190
+ Figure 7: Examples of generated samples from $1 2 8 \times 1 2 8$ CelebA and AFHQ datasets using cold diffusion with blur transformation
191
+
192
+ # 5.3 GENERATION USING OTHER TRANSFORMATIONS
193
+
194
+ In this section, we provide a proof of concept that generation can be extended to other transformations. Specifically, we show preliminary results on inpainting, super-resolution, and animorphosis.
195
+
196
+ Inspired by the simplicity of the degraded image distribution for the blurring routine presented in the previous section, we use degradation routines with predictable final distributions here as well.
197
+
198
+ To use the Gaussian mask transformation for generation, we modify the masking routine so the final degraded image is completely devoid of information. One might think a natural option is to send all of the images to a completely black image $x _ { T }$ , but this would not allow for any diversity in generation. To get around this maximally non-injective property, we instead make the mask turn all pixels to a random, solid color. This still removes all of the information from the image, but it allows us to recover different samples from the learned distribution via Algorithm 2 by starting off with different color images. More formally, a Gaussian mask $\begin{array} { r } { G _ { t } = \prod _ { i = 1 } ^ { t } \bar { z } _ { \beta _ { i } } } \end{array}$ is created in a similar way as discussed in the Section 4.2, but instead of multiplying it directly to the image $x _ { 0 }$ , we create $x _ { t }$ as $G _ { t } \cdot x _ { 0 } + ( 1 - G _ { t } ) \cdot c$ , where $c$ is an image of a randomly sampled color.
199
+
200
+ For super-resolution, the routine down-samples to a resolution of $2 \times 2$ , or 4 values in each channel. These degraded images can be represented as one-dimensional vectors, and their distribution is modeled using one Gaussian distribution. Using the same methods described for generation using blurring described above, we sample from this Gaussian-fitted distribution of the lower-dimensional degraded image space and pass this sampled point through the generation process trained on superresolution data to create one output.
201
+
202
+ Additionally to show one can invert nearly any transformation, we include a new transformation deemed animorphosis, where we iteratively transform a human face from CelebA to an animal face from AFHQ. Though we chose CelebA and AFHQ for our experimentation, in principle such interpolation can be done for any two initial data distributions.
203
+
204
+ More formally, given an image √ $x$ and a random image $z$ sampled from the AFHQ manifold, $x _ { t }$ can be written as $\begin{array} { r } { \dot { x _ { t } } = \sqrt { \alpha _ { t } } x + \dot { \sqrt { 1 - \alpha _ { t } } } z } \end{array}$ . Note this is essentially the same as the noising procedure, but instead of adding noise we are adding a progressively higher weighted AFHQ image. In order to sample from the learned distribution, we sample a random image of an animal and use TACoS.
205
+
206
+ We present results for the CelebA dataset, and hence the quantitative results in terms of FID scores for inpainting, super-resolution and animorphosis are 90.14, 92.91 and 48.51 respectively. We further show some qualitative samples in Figure 8, and in Figure 1.
207
+
208
+ ![](images/35eeb6fb2c914d6ec97b9f6439e9075e47667178071698fe8a40d6654e7fed85.jpg)
209
+ Figure 8: Preliminary demonstration of the generative abilities of other cold diffusins on the $1 2 8 \times$ 128 CelebA dataset. The top row is with animorphosis models, the middle row is with inpainting models, and the bottom row exhibits super-resolution models.
210
+
211
+ # 6 CONCLUSION
212
+
213
+ Existing diffusion models rely on Gaussian noise for both forward and reverse processes. In this work, we find that the random noise can be removed entirely from the diffusion model framework, and replaced with arbitrary transforms. In doing so, our generalization of diffusion models and their sampling procedures allows us to restore images afflicted by deterministic degradations such as blur, inpainting and downsampling. This framework paves the way for a more diverse landscape of diffusion models beyond the Gaussian noise paradigm. The different properties of these diffusions may prove useful for a range of applications, including image generation and beyond.
214
+
215
+ # REPRODUCIBILITY STATEMENT
216
+
217
+ We provided our full code base as supplementary material, which is a modified version of the traditional diffusion database found at https://github.com/lucidrains/denoising-diffusion-pytorch. To facilitate the reproducibility of our results, we have included detailed hyperparameters for training each of our cold diffusion models in Appendices A.1-A.5. Due to space constraints in the main body, we opted to present a relatively small number of qualitative results. Many more examples of both conditionally and unconditionally generated images can be found in the Appendix.
218
+
219
+ # REFERENCES
220
+
221
+ Shane Barratt and Rishi Sharma. A note on the inception score. arXiv preprint arXiv:1801.01973, 2018.
222
+
223
+ Mikołaj Binkowski, Danica J Sutherland, Michael Arbel, and Arthur Gretton. Demystifying mmd ´ gans. arXiv preprint arXiv:1801.01401, 2018.
224
+
225
+ Tong Che, Yanran Li, Athul Paul Jacob, Yoshua Bengio, and Wenjie Li. Mode regularized generative adversarial networks. arXiv preprint arXiv:1612.02136, 2016.
226
+
227
+ Prafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat gans on image synthesis. volume 34, 2021.
228
+
229
+ Dan Hendrycks and Thomas G. Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations, ICLR 2019. OpenReview.net, 2019.
230
+
231
+ 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.
232
+
233
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 32, 2020.
234
+
235
+ Jonathan Ho, Chitwan Saharia, William Chan, David J. Fleet, Mohammad Norouzi, and Tim Salimans. Cascaded diffusion models for high fidelity image generation. J. Mach. Learn. Res., 23, 2022.
236
+
237
+ Alexia Jolicoeur-Martineau, Remi Pich ´ e-Taillefer, Ioannis Mitliagkas, and Remi Tachet des ´ Combes. Adversarial score matching and improved sampling for image generation. International Conference on Learning Representations, 2021.
238
+
239
+ Zahra Kadkhodaie and Eero Simoncelli. Stochastic solutions for linear inverse problems using the prior implicit in a denoiser. Advances in Neural Information Processing Systems, 34, 2021.
240
+
241
+ Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the design space of diffusionbased generative models. arXiv preprint arXiv:2206.00364, 2022.
242
+
243
+ Bahjat Kawar, Gregory Vaksman, and Michael Elad. Stochastic image denoising by sampling from the posterior distribution. International Conference on Computer Vision Workshops, 2021.
244
+
245
+ Bahjat Kawar, Michael Elad, Stefano Ermon, and Jiaming Song. Denoising diffusion restoration models. arXiv preprint arXiv:2201.11793, 2022.
246
+
247
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
248
+
249
+ Diederik P. Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. On density estimation with diffusion models. Advances in Neural Information Processing Systems, 34, 2021.
250
+
251
+ Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, 2009.
252
+
253
+ Yann LeCun, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to´ document recognition. Proc. IEEE, 86(11):2278–2324, 1998.
254
+
255
+ Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015.
256
+
257
+ Christopher A. Metzler, Ali Mousavi, and Richard G. Baraniuk. Learned D-AMP: principled neural network based compressive image recovery. Advances in Neural Information Processing Systems, 30, 2017.
258
+
259
+ Alexander Quinn Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. In Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pp. 8162–8171, 2021.
260
+
261
+ Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
262
+
263
+ Severi Rissanen, Markus Heinonen, and Arno Solin. Generative modelling with inverse heat dissipation. arXiv preprint arXiv:2206.13397, 2022.
264
+
265
+ Yaniv Romano, Michael Elad, and Peyman Milanfar. The little engine that could: Regularization by denoising (RED). arXiv preprint arXiv:1611.02862, 2016.
266
+
267
+ Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J. Fleet, and Mohammad Norouzi. Image super-resolution via iterative refinement. arXiv preprint arXiv:2104.07636, 2021.
268
+
269
+ Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. Advances in neural information processing systems, 29, 2016.
270
+
271
+ Jascha Sohl-Dickstein, Eric A. Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, volume 37 of JMLR Workshop and Conference Proceedings, 2015.
272
+
273
+ Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. International Conference on Learning Representations, 2021a.
274
+
275
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019.
276
+
277
+ Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. International Conference on Learning Representations, 2021b.
278
+
279
+ Jay Whang, Mauricio Delbracio, Hossein Talebi, Chitwan Saharia, Alexandros G. Dimakis, and Peyman Milanfar. Deblurring via stochastic refinement. arXiv preprint arXiv:2112.02475, 2021.
280
+
281
+ # A APPENDIX
282
+
283
+ # A.1 DEBLURRING
284
+
285
+ For the deblurring experiments, we train the models on different datasets for 700,000 gradient steps. We use the Adam (Kingma & Ba, 2014) optimizer with learning rate $2 \times 1 0 ^ { - 5 }$ . The training was done on the batch size of 32, and we accumulate the gradients every 2 steps. Our final model is an Exponential Moving Average of the trained model with decay rate 0.995 which is updated after every 10 gradient steps.
286
+
287
+ For the MNIST dataset, we blur recursively 40 times, with a discrete Gaussian kernel of size 11x11 and a standard deviation 7. In the case of CIFAR-10, we recursively blur with a Gaussian kernel of fixed size 11x11, but at each step $t$ , the standard deviation of the Gaussian kernel is given by $0 . 0 1 * t + 0 . 3 5$ . The blur routine for CelebA dataset involves blurring images with a Gaussian kernel of 15x15 and the standard deviation of the Gaussian kernel grows exponentially with time $t$ at the rate of 0.01.
288
+
289
+ ![](images/e7c9f69965cce37cedf756203a0cae3d185a6edddcf11b8b33e43ecb79bf8c3e.jpg)
290
+ Figure 9 shows an additional nine images for each of MNIST, CIFAR-10 and CelebA. Figures 19 and 20 show the iterative sampling process using a deblurring model for ten example images from each dataset. We further show 400 random images to demonstrate the qualitative results in the Figure 21.
291
+ Figure 9: Additional examples from deblurring models trained on the MNIST, CIFAR-10, and CelebA datasets. Left to right: degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
292
+
293
+ # A.2 INPAINTING
294
+
295
+ For the inpainting transformation, models were trained on different datasets with 60,000 gradient steps. The models were trained using Adam (Kingma & Ba, 2014) optimizer with learning rate $2 \times$ $1 0 ^ { \div { 5 } }$ . We use batch size 64, and the gradients are accumulated after every 2 steps. The final model is an Exponential Moving Average of the trained model with decay rate 0.995. This EMA model is updated after every 10 gradient steps. For all our inpainting experiments we use a randomized Gaussian mask and $T = 5 0$ with $\beta _ { 1 } = 1$ and $\beta _ { i + 1 } = \beta _ { i } + 0 . 1$ .
296
+
297
+ To avoid potential leakage of information due to floating point computation of the Gaussian mask, we discretize the masked image before passing it through the inpainting model. This was done by rounding all pixel values to the eight most significant digits.
298
+
299
+ Figure 11 shows nine additional inpainting examples on each of the MNIST, CIFAR-10, and CelebA datasets. Figure 10 demonstrates an example of the iterative sampling process of an inpainting model for one image in each dataset.
300
+
301
+ # A.3 SUPER-RESOLUTION
302
+
303
+ We train the super-resolution model per Section 3.1 for 700,000 iterations. We use the Adam (Kingma & Ba, 2014) optimizer with learning rate $2 \times 1 0 ^ { - 5 }$ . The batch size is 32, and we accumulate the gradients every 2 steps. Our final model is an Exponential Moving Average of the trained model with decay rate 0.995. We update the EMA model every 10 gradient steps.
304
+
305
+ The number of time-steps depends on the size of the input image and the final image. For MNIST and for CIFAR10, the number of time steps is 3, as it takes three steps of halving the resolution to reduce the initial image down to $4 \times 4$ . For CelebA, the number of time steps is 6 to reduce the initial image down to $2 \times 2$ . For CIFAR10, we apply random crop and random horizontal flip for regularization.
306
+
307
+ Figure 13 shows an additional nine super-resolution examples on each of the MNIST, CIFAR-10, and CelebA datasets. Figure 12 shows one example of the progressive increase in resolution achieved with the sampling process using a super-resolution model for each dataset.
308
+
309
+ # A.4 COLORIZATION
310
+
311
+ Here we provide results for the additional task of colorization. Starting with the original RGBimage $x _ { 0 }$ , we realize colorization by iteratively desaturating for $T$ steps until the final image $x _ { T }$ is a fully gray-scale image. We use a series of three-channel $1 \times 1$ convolution filters ${ \mathbf z } ( \alpha ) \ : = \ : $ $\{ z ^ { 1 } ( \alpha ) , \bar { z } ^ { 2 } ( \alpha ) , z ^ { 3 } ( \alpha ) \}$ with the form
312
+
313
+ $$
314
+ \begin{array} { c } { { z ^ { 1 } ( \alpha ) = \alpha \left( \frac 1 3 \frac 1 3 \frac 1 3 \right) + \left( 1 - \alpha \right) ( 1 0 0 ) } } \\ { { z ^ { 2 } ( \alpha ) = \alpha \left( \frac 1 3 \frac 1 3 \frac 1 3 \right) + ( 1 - \alpha ) ( 0 1 0 ) } } \\ { { z ^ { 3 } ( \alpha ) = \alpha \left( \frac 1 3 \frac 1 3 \frac 1 3 \right) + ( 1 - \alpha ) ( 0 0 1 ) } } \end{array}
315
+ $$
316
+
317
+ and obtain $D ( x , t ) = \mathbf { z } ( \alpha _ { t } ) * x$ via a schedule defined as $\alpha _ { 1 } , \ldots , \alpha _ { t }$ for each respective step. Notice that a gray image is obtained when $x _ { T } = { \bf z } ( 1 ) * x _ { 0 }$ .
318
+
319
+ We can tune the ratio $\alpha _ { t }$ to control the amount of information removed in each step. For our experiment, we schedule the ratio such that for every $t$ we have
320
+
321
+ $$
322
+ x _ { t } = \mathbf { z } ( \alpha _ { t } ) * \ldots * \mathbf { z } ( \alpha _ { 1 } ) * x _ { 0 } = \mathbf { z } ( \frac { t } { T } ) * x _ { 0 } .
323
+ $$
324
+
325
+ This schedule ensures that color information lost between steps is smaller in earlier stage of the diffusion and becomes larger as $t$ increases.
326
+
327
+ We train the models on different datasets for 700,000 gradient steps. We use Adam (Kingma & Ba, 2014) optimizer with learning rate $2 \times 1 0 ^ { - 5 }$ . We use batch size 32, and we accumulate the gradients every 2 steps. Our final model is an exponential moving average of the trained model with decay rate 0.995. We update the EMA model every 10 gradient steps. For CIFAR-10 we use $T = 5 0$ and for CelebA we use $T = 2 0$ .
328
+
329
+ ![](images/53fae5179cd767d845061739046119c2c525e23ec5c815c25a269ff29ab65298.jpg)
330
+ Figure 10: Progressive inpainting of selected masked MNIST, CIFAR-10, and CelebA images.
331
+
332
+ ![](images/5f686abf312883354851ccde77329612aee7401ccec462ab076a03867f2c53d4.jpg)
333
+ Figure 11: Additional examples from inpainting models trained on the MNIST, CIFAR-10, and CelebA datasets. Left to right: degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
334
+
335
+ ![](images/d2e7b9f06cc69adeffb543b92fef72968d86afdb115f11deee8b28ba91d749b6.jpg)
336
+ Figure 12: Progressive upsampling of selected downsampled MNIST, CIFAR-10, and CelebA images. The original image is at the left for each of these progressive upsamplings.
337
+
338
+ We illustrate our recolorization results in Figure 14. We present testing examples, as well as their grey scale images, from all the datasets, and compare the recolorization results with the original images. The recolored images feature correct color separation between different regions, and feature various and yet semantically correct colorization of objects. Our sampling technique still yields minor differences in comparison to the direct reconstruction, although the change is not visually apparent. We attribute this to the shape restriction of colorization task, as human perception is rather insensitive to minor color change. We also provide quantitative measurement for the effectiveness of our recolorization results in terms of different similarity metrics, and summarize the results in Table 6.
339
+
340
+ Table 6: Quantitative metrics for quality of image reconstruction using recolorization models for all three channel datasets.
341
+
342
+ <table><tr><td></td><td colspan="3">Degraded Image</td><td colspan="3">Reconstruction</td></tr><tr><td>Dataset</td><td>FID</td><td>SSIM</td><td>RMSE</td><td>FID</td><td>SSIM</td><td>RMSE</td></tr><tr><td>CIFAR-10</td><td>97.39</td><td>0.937</td><td>0.078</td><td>45.74</td><td>0.942</td><td>0.069</td></tr><tr><td>CelebA</td><td>41.20</td><td>0.942</td><td>0.089</td><td>17.50</td><td>0.973</td><td>0.042</td></tr></table>
343
+
344
+ ![](images/846887c5faa76e942eceed002cdd2dd7b3b19582b59455cf20a6b83a0e6de3b5.jpg)
345
+ Figure 13: Additional examples from super-resolution models trained on the MNIST, CIFAR-10, and CelebA datasets. Left to right: degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
346
+
347
+ ![](images/2b6a3edfc403cc24c01705384baef83b7ef5843fc6f94a63c621993cd684b2b6.jpg)
348
+ Figure 14: Recolorization models trained on the CIFAR-10 and CelebA datasets. Left to right: degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
349
+
350
+ # A.5 IMAGE SNOW
351
+
352
+ Here we provide results for the additional task of snowification, which is a direct adaptation of the offical implementation of ImageNet-C snowification process (Hendrycks & Dietterich, 2019). To determine the snow pattern of a given image $\boldsymbol { x } _ { 0 } \in \mathbb { R } ^ { \boldsymbol { \dot { C } } \times \boldsymbol { H } \times \boldsymbol { W } }$ , we first construct a seed matrix $S _ { A } \in \mathbb { R } ^ { H \times W }$ where each entry is sampled from a Gaussian distribution $N ( \mu , \sigma )$ . The upper-left corner of $S _ { A }$ is then zoomed into another matrix $S _ { B } \in \mathbb { R } ^ { H \times W }$ with spline interpolation. Next, we create a new matrix $S _ { C }$ by filtering each value of $S _ { B }$ with a given threshold $c _ { 1 }$ as
353
+
354
+ $$
355
+ \begin{array} { r } { S _ { C } [ i ] [ j ] = \left\{ \begin{array} { l l } { 0 , } & { S _ { B } [ i ] [ j ] \le c _ { 1 } } \\ { S _ { B } [ i ] [ j ] , } & { S _ { B } [ i ] [ j ] > c _ { 1 } } \end{array} \right. } \end{array}
356
+ $$
357
+
358
+ and clip each entry of $S _ { C }$ into the range $[ 0 , 1 ]$ . We then convolve $S _ { C }$ using a motion blur kernel with standard deviation $c _ { 2 }$ to create the snow pattern $S$ and its up-side-down rotation $S ^ { \prime }$ . The direction of the motional blur kernel is randomly chosen as either vertical or horizontal. The final snow image is created by again clipping each value of $x _ { 0 } + S + S ^ { \prime }$ into the range $[ 0 , 1 ]$ . For simplicity, we abstract the process as a function $h ( x _ { 0 } , S _ { A } , c _ { 0 } , c _ { 1 } )$ .
359
+
360
+ ![](images/f30af456b4ed5d4abfa1bd8cbfc1059a259f3fd1b4460746498cb077083b14bd.jpg)
361
+ Figure 15: Additional examples from Desnowification models trained on the CIFAR-10 and CelebA datasets. Left to right: degraded inputs $D ( x _ { 0 } , T )$ , direct reconstruction $R ( D ( x _ { 0 } , T ) )$ , sampled reconstruction with TACoS described in Algorithm 2, and original image.
362
+
363
+ To create a series of between $[ c _ { 0 } ^ { \mathrm { s t a r t } } , c _ { 0 } ^ { \mathrm { e n d } } ]$ and $T$ images with increasing snowification, we linearly interpolate $[ c _ { 1 } ^ { \mathrm { s t a r f } } , c _ { 1 } ^ { \mathrm { e n d } } ]$ respectively, to create $c _ { 0 } ( t )$ and $c _ { 1 } ( t )$ , $t = 1 , \dots , T$ . Then for $c _ { 0 }$ and $c _ { 1 }$ each $x _ { 0 }$ , a seed matrix $S _ { x }$ is sampled, the motion blur direction is randomized, and we construct each related $x _ { t }$ by $x _ { t } = h ( x _ { 0 } , S _ { x } , c _ { 0 } ( t ) , c _ { 1 } ( t ) )$ . Visually, $c _ { 0 } ( t )$ dictates the severity of the snow, while $c _ { 1 } ( t )$ determines how “windy” the snowified image seems.
364
+
365
+ For both CIFAR-10 and Celeb-A, we use the same Gaussian distribution with parameters $\mu = 0 . 5 5$ and $\sigma = 0 . 3$ to generate the seed matrix. For CIFAR-10, we choose $c _ { 0 } ^ { \mathrm { s t a r t } } = 1 . 1 5$ , $c _ { 0 } ^ { \mathrm { e n d } } = 0 . 7$ , $c _ { 1 } ^ { \mathrm { s t a r t } } = 0 . 0 5$ and $c _ { 1 } ^ { \mathrm { e n d } } = 1 6$ 0 0 , which generates a visually lighter snow. For Celeb-A, we choose $c _ { 0 } ^ { \mathrm { s t a r t } } = 1 . 1 5$ , $c _ { 0 } ^ { \mathrm { e n d } } = 0 . 5 5$ , $c _ { 1 } ^ { \mathrm { s t a r t } } = 0 . 0 5$ and $c _ { 1 } ^ { \mathrm { e n d } } = 2 0 $ , which generates a visually heavier snow.
366
+
367
+ We train the models on different datasets for 700,000 gradient steps. We use Adam (Kingma & Ba, 2014) optimizer with learning rate $2 \times 1 0 ^ { - 5 }$ . We use batch size 32, and we accumulate the gradients every 2 steps. Our final model is an exponential moving average of the trained model with decay rate 0.995. We update the EMA model every 10 gradient steps. For CIFAR-10 we use $T = 2 0 0$ and for CelebA we use $T = 2 0 0$ . We note that the seed matrix is resampled for each individual training batch, and hence the snow pattern varies across the training stage.
368
+
369
+ # A.6 GENERATION USING NOISE : FURTHER DETAILS
370
+
371
+ Here we show the equivalence between the sampling method proposed in Algorithm 2 and the deterministic sampling in DDIM (Song et al., 2021a). Given the image $x _ { t }$ at step $t$ , we have the restored clean image $\hat { x _ { 0 } }$ from the diffusion model. Hence given the estimated $\hat { x _ { 0 } }$ and $x _ { t }$ , we can estimate the noise $z ( x _ { t } , t )$ (or $\hat { z }$ ) as
372
+
373
+ $$
374
+ z ( x _ { t } , t ) = \frac { x _ { t } - \sqrt { \alpha _ { t } } \hat { x _ { 0 } } } { \sqrt { 1 - \alpha _ { t } } } ,
375
+ $$
376
+
377
+ Thus, the $D ( \hat { x _ { 0 } } , t )$ and $D ( \hat { x _ { 0 } } , t - 1 )$ can be written as
378
+
379
+ $$
380
+ D ( \hat { x _ { 0 } } , t ) = \sqrt { \alpha _ { t } } \hat { x _ { 0 } } + \sqrt { 1 - \alpha _ { t } } \hat { z } ,
381
+ $$
382
+
383
+ $$
384
+ D ( \hat { x _ { 0 } } , t - 1 ) = \sqrt { \alpha _ { t - 1 } } \hat { x _ { 0 } } + \sqrt { 1 - \alpha _ { t - 1 } } \hat { z } ,
385
+ $$
386
+
387
+ using which the sampling process in Algorithm 2 to estimate $x _ { t - 1 }$ can be written as,
388
+
389
+ $$
390
+ \begin{array} { r l } & { x _ { t - 1 } = x _ { t } - D ( \hat { x _ { 0 } } , t ) + D ( \hat { x _ { 0 } } , t - 1 ) } \\ & { \qquad = x _ { t } - \big ( \sqrt { \alpha _ { t } } \hat { x _ { 0 } } + \sqrt { 1 - \alpha _ { t } } \hat { z } \big ) + \big ( \sqrt { \alpha _ { t - 1 } } \hat { x _ { 0 } } + \sqrt { 1 - \alpha _ { t - 1 } } \hat { z } \big ) } \\ & { \qquad = \sqrt { \alpha _ { t - 1 } } \hat { x _ { 0 } } + \sqrt { 1 - \alpha _ { t - 1 } } \hat { z } } \end{array}
391
+ $$
392
+
393
+ which is same as the sampling method as described in (Song et al., 2021a). The only difference from the original (Song et al., 2021a) is the order for estimating $\hat { x _ { 0 } }$ and $\hat { z }$ . The original (Song et al., 2021a) paper estimated $\hat { z }$ first and then used this to predict clean image $\hat { x _ { 0 } }$ , while we first predict the clean image $\hat { x _ { 0 } }$ and then estimate the noise $\hat { z }$ .
394
+
395
+ # A.7 GENERATION USING BLUR TRANSFORMATION: FURTHER DETAILS
396
+
397
+ ![](images/dfee8095b19fe3b0976b64ba7e12c3fd7b97f27893230026285cd327a150f728.jpg)
398
+ Figure 16: Examples of generated samples from $1 2 8 \times 1 2 8$ CelebA and AFHQ datasets using Method 2 with perfect symmetry.
399
+
400
+ The Figure 16, shows the generation without breaking any symmetry within each channel are quite promising as well.
401
+
402
+ Necessity of Algorithm 2: In the case of unconditional generation, we observe a marked superiority in quality of the sampled reconstruction using Algorithm 2 over any other method considered. For example, in the broken symmetry case, the FID of the directly reconstructed images is 257.69 for CelebA and 214.24 for AFHQ, which are far worse than the scores of 49.45 and 54.68 from Table 5. In Figure 17, we also give a qualitative comparison of this difference. We can also clearly see from Figure 18 that Algorithm 1, the method used in Song et al. (2021b) and Ho et al. (2020), completely fails to produce an image close to the target data distribution.
403
+
404
+ # A.8 ALGORITHM 1 IS SAME AS DDIM/DDPM SAMPLING
405
+
406
+ The sampling method proposed in Song et al. (2021a) in it’s equation 12 is given as
407
+
408
+ $$
409
+ x _ { t - 1 } = \sqrt { \alpha _ { t - 1 } } \cdot \mathrm { \ " { s p r e d i c t e d } } x _ { 0 } \mathrm { \ " { ~ , ~ } } + \sqrt { 1 - \alpha _ { t - 1 } - \sigma _ { t } ^ { 2 } } \epsilon _ { \theta } ( x _ { t } ) + \sigma _ { t } \epsilon _ { t }
410
+ $$
411
+
412
+ where $\epsilon _ { \theta } ( x _ { t } )$ is the noise predicted by the diffusion model given $x _ { t }$ and $t$ . The term “predicted $x _ { 0 }$ ” or $\hat { x _ { 0 } }$ can be computed directly given $x _ { t }$ and $\epsilon _ { \theta } ( x _ { t } )$ as
413
+
414
+ $$
415
+ \hat { x _ { 0 } } = \frac { x _ { t } - \sqrt { 1 - \alpha _ { t } } \epsilon _ { \theta } ( x _ { t } ) } { \sqrt { \alpha _ { t } } } ,
416
+ $$
417
+
418
+ Hence using $\hat { z }$ instead of $\epsilon _ { \theta } ( x _ { t } )$ and $\hat { x _ { 0 } }$ to indicate predicted clean image, we have
419
+
420
+ $$
421
+ x _ { t - 1 } = \sqrt { \alpha _ { t - 1 } } \cdot \hat { x _ { 0 } } + \sqrt { 1 - \alpha _ { t - 1 } - \sigma _ { t } ^ { 2 } } \hat { z } + \sigma _ { t } \epsilon _ { t }
422
+ $$
423
+
424
+ Thus, the sampling step can interpreted as follows: At each step $t$ , we start with a noisy image $x _ { t }$ and use the diffusion model to estimate the clean image $\hat { x _ { 0 } }$ and the noise $\hat { z }$ that was added to this clean image $\hat { x _ { 0 } }$ to get the noisy image $x _ { t }$ . In order to move to lesser noisy image $x _ { t - 1 }$ , one “adds back” lesser noise to the the “predicted clean image” $\hat { x _ { 0 } }$ . Now one can add back noise in 2 ways, either the noise which was added to the clean image $\hat { x _ { 0 } }$ which is $\hat { z }$ or sample a new uncorrelated noise $\epsilon _ { t }$ . Infact both of these noise can be added using $\sigma _ { t }$ as the hyperparameter that weighs the amount of each noise added. This $\sigma _ { t }$ is placed in the equation such that for any choice of $\sigma _ { t }$ , the standard deviation of noise added back is $\sqrt { 1 - \alpha _ { t - 1 } }$ . For $\sigma _ { t } = 0$ , we only add back the estimated noise $\hat { z }$ and no uncorrelated noise $\epsilon _ { t }$ which is infact the DDIM sampling. While for $\sigma _ { t } = \sqrt { ( 1 - \alpha _ { t - 1 } ) / ( 1 - \alpha _ { t } ) } \sqrt { 1 - \alpha _ { t } / \alpha _ { t - 1 } }$ we get the sampling method described in DDPM.
425
+
426
+ Nevertheless, for any choice of $\sigma _ { t }$ , the sampling method involves a denoising operation which is shown as $R ( x _ { s } , s )$ in Algorithm 1 and adding back noise shown as $x _ { s - 1 } = D ( \hat { x _ { 0 } } , s - 1 )$ in Algorithm 1. The only difference between different sampling methods explained in DDPM or DDIM is how one degrades the image back.
427
+
428
+ ![](images/715394f6dca04c49b937c458e0674dced6f73c4fe2f2c72febfc67bb2c928a9d.jpg)
429
+ Figure 17: Comparison of direct reconstruction with sampling using TACoS described in Algorithm 2 for generation with blur transformation and broken symmetry. Left-hand column is the initial cold images generated using the simple Gaussian model. Middle column has images generated in one step (i.e. direct reconstruction). Right-hand column are the images sampled with TACoS described in Algorithm 2. We present results for both CelebA (top) and AFHQ (bottom) with resolution $1 2 8 \times 1 2 8$ .
430
+
431
+ ![](images/e2f5864ab2e4307ab324bd5169b528dc972ea8470193602a66f166bb9bbe2e75.jpg)
432
+ Figure 18: Comparison of Algorithm 1 (top row) and Algorithm 2 (bottom row) for generation with Method 2 and broken symmetry on $1 2 8 \times 1 2 8$ CelebA dataset. We demonstrate that Algorithm 1 fails completely to generate a new image.
433
+
434
+ ![](images/b8d77482ec10a2dca472bf79cf6526912ed04869e58a7fd4f0da9d4dd2518df7.jpg)
435
+ Figure 19: Progressive deblurring of selected blurred MNIST and CIFAR-10 images.
436
+
437
+ ![](images/dd271833367bac55d74ac0cd8e55ce90524e1c9d12715110ae0704f55f99b752.jpg)
438
+ Figure 20: Progressive deblurring of selected blurred CelebA images.
439
+
440
+ ![](images/62d99ee7ed2f1b6dff74a4f9426c4c2305b8c46d3cfe064eceac7d6e81ccd810.jpg)
441
+ Figure 21: Deblurred Cifar10 images
md/dev/t877958UGZ/t877958UGZ.md ADDED
@@ -0,0 +1,465 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Cheap and Quick: Efficient Vision-Language Instruction Tuning for Large Language Models
2
+
3
+ Gen Luo13, Yiyi Zhou12, Tianhe Ren1, Shengxin Chen1, Xiaoshuai Sun12, Rongrong $\mathbf { J i ^ { 1 2 3 * } }$
4
+ 1Key Laboratory of Multimedia Trusted Perception and Efficient Computing, Ministry of Education of China, School of Informatics, Xiamen University, 361005, P.R. China.
5
+ 2Institute of Artificial Intelligence, Xiamen University, 361005, P.R. China.
6
+ 3 Peng Cheng Laboratory, Shenzhen, 518000, China. {luogen,chenshengxin,rentianhe}@stu.xmu.edu.cn, {zhouyiyi,xssun,rrji}@xmu.edu.cn
7
+
8
+ # Abstract
9
+
10
+ Recently, growing interest has been aroused in extending the multimodal capability of large language models (LLMs), e.g., vision-language (VL) learning, which is regarded as the next milestone of artificial general intelligence. However, existing solutions are prohibitively expensive, which not only need to optimize excessive parameters, but also require another large-scale pre-training before VL instruction tuning. In this paper, we propose a novel and affordable solution for the effective VL adaption of LLMs, called Mixture-of-Modality Adaptation (MMA). Instead of using large neural networks to connect the image encoder and LLM, MMA adopts lightweight modules, i.e., adapters, to bridge the gap between LLMs and VL tasks, which also enables the joint optimization of the image and language models. Meanwhile, MMA is also equipped with a routing algorithm to help LLMs achieve an automatic shift between single- and multi-modal instructions without compromising their ability of natural language understanding. To validate MMA, we apply it to a recent LLM called LLaMA and term this formed large visionlanguage instructed model as LaVIN. To validate MMA and LaVIN, we conduct extensive experiments under two setups, namely multimodal science question answering and multimodal dialogue. The experimental results not only demonstrate the competitive performance and the superior training efficiency of LaVIN than existing multimodal LLMs, but also confirm its great potential as a general-purpose chatbot. More importantly, the actual expenditure of LaVIN is extremely cheap, e.g., only 1.4 training hours with 3.8M trainable parameters, greatly confirming the effectiveness of MMA. Our project is released at https://luogen1996. github.io/lavin.
11
+
12
+ # 1 Introduction
13
+
14
+ In recent years, large language models (LLMs) [3, 37, 5, 52, 38] have continuously pushed the upper limit of natural language understanding with ever increasing parameter sizes and pre-training data scales. The introduction of instruction tuning [30, 31, 35] also enables LLMs to engage in human-like conversations and handle various natural language processing (NLP) tasks [29, 44, 45], approaching artificial general intelligence, e.g., GPT-3.5 [33]. The next milestone is often regarded to extend these LLMs with multimodal capabilities, e.g., vision-language (VL) learning, making LLMs applicable to more real-world application scenarios. Such a target has been recently realized by GPT-4 [34], which is likely to adopt a large-scale vision-language corpus to directly train a multimodal GPT.
15
+
16
+ ![](images/340c69a40a4d3e710a9eb49ac867041ced129c5a5efbad8c52d5a78f7bb58a86.jpg)
17
+
18
+ ![](images/6944d9e8fee85891ef15363dbae9a7ae3d8bb6ef4775c8dda2ffcaf66e19bf91.jpg)
19
+ Stage-2: Instruction Tuning
20
+
21
+ ![](images/192e637425e5d62aff0bebbb8ce2c0387677f1d62b47de6d4c4d4a51f299abd0.jpg)
22
+ Stage-1: VL Alignment
23
+ (a) Expert System
24
+ (b) Modular Training Scheme
25
+
26
+ ![](images/b4382854c5451139ab79487fdfbdb05bb282887ed3807b8c9eef8096fa6166a3.jpg)
27
+ (c) Mixture-of-Modality Adaptation
28
+ Figure 1: Comparison of different multimodal adaptation schemes for LLMs. In the expert system, LLMs play a role of controller, while the ensemble of LLM and vision models is expensive in terms 点:of computation and storage overhead. The modular training regime (b) requires an additional large 计算效率低,参数低效 1. 计算效率高(单张A100可训练),参数高效(2~4 M)neck branch and another large-scale pre-training for cross-modal alignment, which is inefficient in 多阶段优化进一步增大了计算量,同时优化效率低 2. 单阶段联合优化(Training from scratch )training and performs worse in previous NLP tasks. In contrast, the proposed Mixture-of-Modality Adaption (MMA) (c) is an end-to-end optimization scheme, which is cheap in training and superior in the automatic shift between text-only and image-text instructions.
29
+
30
+ However, the training regime of GPT-4 [34] is prohibitively expensive, and recent endeavors [49, 50, 1, 8, 56, 4] are still keen to efficient VL adaptions of LLMs. As shown in Fig. 1, the existing multimodal solutions for LLMs can be roughly divided into two main categories, i.e., the expert system and the modular training ones, respectively. In the expert system solution [49, 50, 41], LLMs usually serve as a manager to interpret different natural language instructions, and then call the corresponding vision models to handle the input image, e.g., image captioning [18, 27], visual question answering [55, 28] or text-to-image generation [39]. The advantage of this solution is that it does not require the re-training of LLMs and can make full use of existing vision models. However, the ensemble of LLMs and various vision models still exhibits significant redundancy in terms of computation and parameters, leading to excessive memory footprints. Meanwhile, the joint optimization of LLMs and vision models is still an obstacle.
31
+
32
+ In this case, increasing attention has been paid to the modular training of LLMs [17, 21, 56, 15, 56]. As illustrated in Fig. 1, this paradigm often requires LLMs to deploy an additional neck branch to connect the visual encoders, and then performs another pre-training on numerous image-text pairs for cross-modal alignment. Afterwards, the neck branch and LLM are jointly tuned via VL instructions. Despite the effectiveness, the required VL pre-training is still expensive for a quick adaptation of LLMs. For instance, the pre-training of BLIP2 [17] consumes more than 100 GPU hours on 129 millions of image-text pairs. In addition, this paradigm often requires to update most parameters of LLM, limiting the efficiency of VL instruction tuning. For example, LLaVA-13B [21] fully fine-tunes the entire LLM during VL instruction tuning, resulting in significant increases in training time and intermediate storage overhead2. More importantly, these fine-tune schemes will inevitably undermine the NLP capabilities of LLMs due to the drastic changes in their parameter spaces. For instance, the existing multimodal LLMs, such as BLIP2 [17] and miniGPT4 [56], do not support text-only instructions, greatly hindering their applications.
33
+
34
+ In this paper, we propose a novel and efficient solution for vision-language instruction tuning, termed Mixture-of-Modality Adaptation (MMA). Different from existing modular training scheme [17, 21], MMA is an end-to-end optimization regime. By connecting the image encoder and LLM with lightweight adapters, MMA can jointly optimize the entire multimodal LLM via a small number of parameters, saving more than thousands times of storage overhead compared with existing solutions [21, 56, 17]. To obtain a quick shift between text-only and image-text instructions, MMA equips the inserted adapters with a routing scheme, which can dynamically choose the suitable adaptation path for the inputs of different modalities, thereby well preserving the NLP capability of LLMs. To validate MMA, we apply it to a recently proposed LLM called LLaMA [43], and term this new large vision-language instructed model as LaVIN. With the help of MMA, LaVIN can achieve cheap and quick adaptations on VL tasks without the requirement of another large-scale pre-training.
35
+
36
+ To validate LaVIN, we first conduct quantitative experiments on ScienceQA [24]. Experimental results show that LaVIN can achieve on-par performance with the advanced multimodal LLMs, e.g., LLaVA [21], while reducing up to $7 1 . 4 \%$ training time and $9 9 . 9 \%$ storage costs. Notably, fine-tuning
37
+
38
+ LaVIN on ScienceQA only takes 1.4 hours with 8 A100 GPUs, and the updated parameters are only 3.8M. In addition, we also extend LaVIN to a multimodal chatbot via tuning on $5 2 k$ text-only instructions [42] and $1 5 2 k$ text-image pairs [21]. The qualitative comparisons show that LaVIN can accurately execute various types of human instructions, e.g., coding, math and image captioning, while yielding superior vision-language understanding than existing multimodal chatbots [56, 17, 50].
39
+
40
+ In summary, our contributions are three folds:
41
+
42
+ • We present a novel and efficient solution for vision-language instruction tuning, namely Mixture-of-Modality Adaptation (MMA), which does not require the expensive VL pretraining and can maintain the NLP capabilities of LLMs. • Based on MMA, we propose a new multimodal LLM, namely LaVIN. Experimental results show the superior efficiency and competitive performance of LaVIN against existing multimodal LLMs, and also confirm its great potential as a general-purpose chatbot. • We release the source code and pre-trained checkpoints associated with this paper. We believe that our project can well facilitate the development of multimodal LLM.
43
+
44
+ # 2 Related Work
45
+
46
+ # 2.1 Parameter-Efficient Transfer Learning
47
+
48
+ Since large language models have ever-increasing parameter sizes, parameter-efficient transfer learning (PETL) [13, 19, 25, 14, 22, 12] has gained increasing attention to reduce training and storage overhead of LLMs. PETL aims to insert or fine-tune a small number of parameters into LLMs, thereby achieving the adaption on downstream tasks. In early efforts [13, 12], a small MLP network, known as Adapter [13], is inserted into LLMs to project their hidden features to the semantic spaces of downstream tasks. Based on Adapter, numerous PETL methods [19, 46, 25, 14, 22, 12] have been proposed to further enhance adaptation capabilities [19, 46, 25, 22, 12] and inference speed [14]. Among them, AdaMix [46] is a method relatively close to our MMA, which also includes a set of candidate adapters for downstream task routing. However, AdaMix is static and task-dependent, of which routing path is fixed after training. In contrast, our MMA is a dynamic method based on the input modality embeddings. Moreover, AdaMix is still an unimodal module and hard to adaptively adjust the adaptions of different modalities. Driven by the great success in NLP, PETL has also achieved significant progresses in large vision models [26, 2, 54], e.g., ViT [7] and CLIP [36]. Despite the effectiveness, PETL for multimodal LLMs still lacks explorations. A very recent PETL method [51] is proposed for multimodal LLMs , but its performance still lags behind full fine-tuning.
49
+
50
+ # 2.2 Multimodal Instruction-following LLMs
51
+
52
+ Instruction tuning [30, 31, 35, 47, 48] aims to fine-tune LLMs on natural language corpus describing diverse NLP tasks. This simple and effective method has been successfully applied to various wellknown LLMs, such as InstructGPT [35] and FLAN-T5 [6], greatly improving their performance and generalization ability. Motivated by this success, numerous efforts have been devoted to constructing multimodal instruction-following LLMs. Existing works can be categorized into two groups, e.g., the expert systems [49, 50, 41] and modular training ones [17, 21, 56, 15, 56], respectively. The representative expert systems, such as Visual ChatGPT [49] and MMREACT [50], employ LLMs as the controller to invoke various vision models to accomplish the VL instructions. Despite the effectiveness, this heavy system also incurs non-negligible burdens in terms of storage and computation. Recently, modular training models [17, 21, 56, 15, 56] as proposed as more efficient alternatives. Among them, Flamingo [1] is the first large-scale multimodal LLM that pre-trains on numerous image-text pairs, which demonstrates strong zero-shot ability on diverse tasks. The following works, including BLIP-2 [17], FROMAGe [16], PaLM-E [8], KOSMOS-1 [15] and LLaVA [21], not only optimize the model architecture [17, 16, 8, 15] but also improve the quality of VL instruction data [21]. Despite their effectiveness, most multimodal LLMs require expensive training costs and perform worse on text-only instructions.
53
+
54
+ Response: The image features a small brown dog running across a grassy field, with its tongue out and ears flapping. The dog appears to be enjoying itself as it runs through the open space. In the background, there are several trees scattered across the field, adding to the natural setting.
55
+
56
+ ![](images/ca9e2a02931ae3cea7f3c46c984db7063ab615d82ac1336f36c6174ef35e8498.jpg)
57
+ Figure 2: The overview of the Mixture-of-Modality Adaptation (MMA) and the architecture of LaVIN. In LaVIN, the novel Mixture-of-Modality Adapters are employed to process the instructions of different modalities. During instruction tuning, LaVIN is optimized by Mixture of Modality Training (MMT) in an end-to-end manner.
58
+
59
+ # 3 Method
60
+
61
+ # 3.1 Mixture-of-Modality Adaptation
62
+
63
+ In this paper, we propose a novel learning regime for the vision-language adaption of LLMs, which is called Mixture-of-Modality Adaptation (MMA). As shown in Fig. 2, MMA includes two novel designs, namely Mixture-of-Modality Adapter (MM-Adapter) and Mixture-of-Modality Training (MMT). Specifically, MM-Adapter extends LLMs with multimodal abilities via lightweight adapters, which also realizes the automatic shift between single- and multi-modal instructions. Afterwards, the entire multimodal LLM is jointly optimized via MMT, which is cheap in training time and storage.
64
+
65
+ Mixture-of-Modality Adapter (MM-Adapter). As shown in Fig. 2, we connect the LLM with the image encoder with a set of lightweight adaptation modules. In the image encoder, these modules can be the common adapters [13, 26]. In the LLM, unimodal adaptation modules are inferior in handling single- and multi-modal instructions simultaneously.
66
+
67
+ In particular, we first introduce a modality token $t _ { m } \in \mathbb { R } ^ { c }$ to indicate the input modality, which is defined by
68
+
69
+ $$
70
+ t _ { m } = m E _ { m } .
71
+ $$
72
+
73
+ Here, $E _ { m } \in \mathbb { R } ^ { 2 \times c }$ is the modality embedding. $m \in \mathbb { R } ^ { 2 }$ is a one-hot vector to represent the input modality. Based on the modality token $t _ { m }$ , MM-Adapter can dynamically adjust the adaptations for the input features $Z \in \mathbb { R } ^ { \tilde { n } \times c }$ . In practice, $Z$ can be the single- or multi-modal features, which will be introduced in Sec 3.2. Thus, MM-Adapter can be defined by
74
+
75
+ $$
76
+ Z ^ { \prime } = Z + s \cdot r o u t e r { \left( f _ { a _ { 1 } } ( Z ) , f _ { a _ { 2 } } ( Z ) ; f _ { w } ( t _ { m } ) \right) } .
77
+ $$
78
+
79
+ Here, $f _ { a _ { 1 } }$ and $f _ { a _ { 2 } }$ are RepAdapters [26] in our paper. $s$ is the scale factor, and router $\cdot ( \cdot )$ is a routing function to decide the routing path of two adapters. To further reduce the parameter costs, the downsampling projection of two adapters are shared.
80
+
81
+ ![](images/c799801861aced7f1da25e815a61ab0563d2c722141539638e3f13eb8089b6b7.jpg)
82
+ Figure 3: Illustration of the Mixture-of-Modality Adapter (MMA). MMA can dynamically select the appropriate adapter according to the input modalities.
83
+
84
+ As shown in Fig. 3, the key to realize the dynamic adaptations lies in the design of the routing function router $( \cdot )$ , which is formulated as
85
+
86
+ $$
87
+ \begin{array} { r l } & { r o u t e r { \left( f _ { a _ { 1 } } ( Z ) , f _ { a _ { 2 } } ( Z ) \right) } = \hat { w } _ { 0 } \cdot f _ { a _ { 1 } } ( Z ) + \hat { w } _ { 1 } \cdot f _ { a _ { 2 } } ( Z ) , } \\ & { \mathrm { w h e r e } \quad \hat { w } = f _ { w } ( t _ { m } ) = \mathrm { s o f t m a x } ( \frac { t _ { m } W _ { m } + b _ { m } } { \tau } ) . } \end{array}
88
+ $$
89
+
90
+ Here, $W _ { m } \in \mathbb { R } ^ { c \times 2 }$ and $b _ { m } \in \mathbb { R } ^ { 2 }$ are the weight matrix and bias, respectively. $\hat { w }$ denotes the routing weights, and $\tau$ is the temperature of the softmax. Based on Eq. 2 and 3, MM-Adapter can select the best adaption path according to the modalities of input instructions. More importantly, the process of MM-Adapter only introduces a few of additional parameters, which is still efficient. In practice, MM-Adapter can be used as the unimodal adapter to improve the adaptation ability, thus we also apply it to the image encoder.
91
+
92
+ Mixture-of-Modality Training (MMT). Based on MM-Adapter, the target of MMT is to freeze the large image encoder and LLM, and only fine-tune the inserted adapters. In this case, the entire multimodal LLM can be jointly optimized in an end-to-end manner. Specifically, the end-to-end optimization objective can be formulated by
93
+
94
+ $$
95
+ \arg \operatorname* { m i n } _ { { } } \mathcal { L } ( f _ { \phi } ( Z ) , R ; \theta _ { a } ) .
96
+ $$
97
+
98
+ Here, $R$ and $\mathcal { L } ( \cdot )$ denote the ground-truth response [24] and the objective loss function, respectively. $f _ { \phi }$ is the LLM, and $\theta _ { a }$ denotes the adaptation parameters. $I \in \mathbb { R } ^ { h \times w \times 3 }$ and $T \in \mathbb { R } ^ { l }$ denote the input image and text instruction, respectively.
99
+
100
+ During training, we construct a mini training batch randomly sampled from text-only and text-image instructions. In this case, the overall training objective $\mathcal { L }$ can be defined by
101
+
102
+ $$
103
+ \mathcal { L } = \sum _ { i = 1 } ^ { m } \sum _ { s = 1 } ^ { S + 1 } \log p ( R _ { s } ^ { i } | Z ^ { i } , R _ { 0 : s - 1 } ^ { i } ; \theta _ { a } ) .
104
+ $$
105
+
106
+ Here, $m$ denotes the batch size, and $S$ is the length of the response. After MMT, the multimodal LLM can effectively execute the input instructions of different modalities.
107
+
108
+ In our training scheme, the number of optimized parameters is still kept at a very small scale, e.g., $3 { \sim } 5 \mathbf { M }$ , which greatly reduces the training time and the storage cost. Compared to existing modular training paradigm, MMA does not require additional VL pre-training and can optimize the entire model end-to-end, further improving the training efficiency.
109
+
110
+ # 3.2 Large Vision-language Instructed Model
111
+
112
+ To validate MMA, we apply it to an LLM called LLaMA [43] and adopt CLIP-ViT [36] as the image encoder. Here, we term this new large vision-language instructed model as LaVIN.
113
+
114
+ Given the input image $\boldsymbol { I } \in \mathbb { R } ^ { h \times w \times 3 }$ , we use the [cls] tokens from every fourth layer of ViT [7] as the visual feature, denoted as $\ b { X } \in \mathbb { R } ^ { n \times d }$ . In the image encoder, we insert the adapters before the multi-head attention modules. We represent the text instruction with word embeddings, denoted as $Y \in \mathbb { R } ^ { l \times c }$ . Then, a simple visual adapter is used to transform the visual features to the same dimension with the LLM, which is defined by
115
+
116
+ $$
117
+ X ^ { \prime } = \sigma ( X W _ { d } + b _ { d } ) W _ { u } + b _ { u } .
118
+ $$
119
+
120
+ Here, $W _ { d } \in \mathbb { R } ^ { d \times d _ { h } }$ and $W _ { u } \in \mathbb { R } ^ { d _ { h } \times c }$ denote the weight matrices, while $W _ { d } \in \mathbb { R } ^ { d _ { h } }$ and $b _ { u } \in \mathbb { R } ^ { c }$ are the bias terms. $\sigma$ is the SwiGLU activation function [40]. In practice, $d _ { h }$ is much smaller than $d$ and $c$ , so the input of LLM can be defined by
121
+
122
+ $$
123
+ Z = { \left\{ \begin{array} { l l } { [ t _ { m } , X ^ { \prime } , Y ] } & { t e x t - i m a g e , } \\ { [ t _ { m } , Y ] } & { t e x t o n l y . } \end{array} \right. }
124
+ $$
125
+
126
+ Here, $[ \cdot ]$ denotes the concatenation. Based on the multimodal input, LLM can predict the next token step by step, which can be formulated by
127
+
128
+ $$
129
+ p _ { t } = \prod _ { s = 1 } ^ { S + 1 } p ( R _ { s } | Z , R _ { 0 : s - 1 } ; \theta _ { l } , \theta _ { a } )
130
+ $$
131
+
132
+ Here, $p _ { t } \in \mathbb { R } ^ { m }$ denotes the probabilities of the predicted word and $m$ is the length of the word embeddings. $\theta _ { l }$ and $\theta _ { a }$ denote the parameters of LLM and adaptation modules, respectively.
133
+
134
+ Compared with previous works [17, 56, 21], the architecture of LaVIN is much simpler and more lightweight, which is also easier to optimize. For example, the visual neck of LaVIN is 6 times smaller than that of LLaVA [21], but the performance of two models is close.
135
+
136
+ Table 1: Comparison on ScienceQA test set. Question classes: $\mathbf { N A T } =$ natural science, $\mathrm { S O C = }$ social science, $\mathrm { L A N } =$ language science, TXT $=$ text context, IMG $=$ image context, ${ \mathrm { N O } } =$ no context, G1-6 $=$ grades 1-6, $G 7 - 1 2 =$ grades 7-12. $\dagger$ denotes that LaVIN is trained with 40 epochs. #T-Params denotes that the number of trainable parameters.
137
+
138
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">#T-Param</td><td rowspan="2">LLM</td><td colspan="3">Subject</td><td colspan="3">Context Modality</td><td colspan="2">Grade</td><td rowspan="2">Average</td></tr><tr><td>NAT</td><td>sOC</td><td>LAN</td><td>TXT</td><td>IMG</td><td>NO</td><td>G1-6</td><td>G7-12</td></tr><tr><td colspan="10">Zero-&amp; few-shot methods</td><td></td><td></td><td></td></tr><tr><td>Human [24]</td><td></td><td></td><td>90.23</td><td>84.97</td><td>87.48</td><td>89.60</td><td>87.50</td><td>88.10</td><td>91.59</td><td>82.42</td><td></td><td>88.40</td></tr><tr><td>GPT-3.5 [24]</td><td></td><td>X</td><td>74.64</td><td>69.74</td><td>76.00</td><td>74.44</td><td>67.28</td><td></td><td>77.42</td><td>76.80</td><td>68.89</td><td>73.97</td></tr><tr><td>GPT-3.5 (CoT) [24]</td><td></td><td>√</td><td>75.44</td><td>70.87</td><td>78.09</td><td>74.68</td><td></td><td>67.43</td><td>79.93</td><td>78.23</td><td>69.68</td><td>75.17</td></tr><tr><td>GPT-4 [34]</td><td>-</td><td>√</td><td>84.06</td><td>73.45</td><td>87.36</td><td>81.87</td><td></td><td>70.75</td><td>90.73</td><td>84.69</td><td>79.10</td><td>82.69</td></tr><tr><td colspan="3">Representative&amp;SoTA models</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>UnifiedQA [24]</td><td>223M</td><td>X</td><td>71.00</td><td>76.04</td><td>78.91</td><td>66.42</td><td>66.53</td><td></td><td>81.81</td><td>77.06</td><td>68.82</td><td>74.11</td></tr><tr><td>MM-CoTBase [53]</td><td>223M</td><td>X</td><td>87.52</td><td>77.17</td><td>85.82</td><td>87.88</td><td></td><td>82.90</td><td>86.83</td><td>84.65</td><td>85.37</td><td>84.91</td></tr><tr><td>MM-CoTLarge [53]</td><td>738M</td><td>×</td><td>95.91</td><td>82.00</td><td>90.82</td><td>95.26</td><td></td><td>88.80</td><td>92.89</td><td>92.44</td><td>90.31</td><td>91.68</td></tr><tr><td>LLaVA [21]</td><td>13B</td><td>√</td><td>90.36</td><td>95.95</td><td>88.00</td><td>89.49</td><td></td><td>88.00</td><td>90.66</td><td>90.93</td><td>90.90</td><td>90.92</td></tr><tr><td colspan="3">Parameter-efficientmethods</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LLaMA-Adapter [51]</td><td>1.8M</td><td>√</td><td>84.37</td><td>88.30</td><td>84.36</td><td>83.72</td><td></td><td>80.32</td><td>86.90</td><td>85.83</td><td>84.05</td><td>85.19</td></tr><tr><td>LaVIN-7B (ours)</td><td>3.8M</td><td>√</td><td>89.25</td><td>94.94</td><td>85.24</td><td></td><td>88.51</td><td>87.46</td><td>88.08</td><td>90.16</td><td>88.07</td><td>89.41</td></tr><tr><td>LaVIN-13B (ours)</td><td>5.4M</td><td>√</td><td>90.32</td><td>94.38</td><td>87.73</td><td></td><td>89.44</td><td>87.65</td><td>90.31</td><td>91.19</td><td>89.26</td><td>90.50</td></tr><tr><td>LaVIN-13B† (ours)</td><td>5.4M</td><td>√</td><td>89.88</td><td>94.49</td><td>89.82</td><td></td><td>88.95</td><td>87.61</td><td>91.85</td><td>91.45</td><td>89.72</td><td>90.83</td></tr></table>
139
+
140
+ <table><tr><td>Settings</td><td>#T-Params</td><td>NAT</td><td>SOC</td><td>LAN</td><td>TXT</td><td>IMG</td><td>NO</td><td>G1-6</td><td>G7-12</td><td>Avg.</td></tr><tr><td>Text Only</td><td>1.8M</td><td>82.86</td><td>82.56</td><td>82.28</td><td>81.23</td><td>75.81</td><td>86.06</td><td>83.26</td><td>81.54</td><td>82.65(+0.00)</td></tr><tr><td>+ Vision Modality (MMT)</td><td>2.4M</td><td>85.97</td><td>90.66</td><td>83.55</td><td>84.90</td><td>83.59</td><td>86.41</td><td>88.14</td><td>83.06</td><td>86.32(+3.67)</td></tr><tr><td>+ Joint Opt. (MMT)</td><td>2.5M</td><td>86.59</td><td>94.71</td><td>82.91</td><td>85.63</td><td>84.98</td><td>86.41</td><td>88.62</td><td>85.04</td><td>87.34(+4.69)</td></tr><tr><td>+ Stronger Image Enc.</td><td>2.9M</td><td>88.01</td><td>94.94</td><td>83.64</td><td>87.15</td><td>86.81</td><td>87.04</td><td>89.87</td><td>85.56</td><td>88.33(+5.68)</td></tr><tr><td>+ MM-Adapter</td><td>3.8M</td><td>89.25</td><td>94.94</td><td>85.24</td><td>88.51</td><td>87.46</td><td>88.08</td><td>90.16</td><td>88.07</td><td>89.41(+6.76)</td></tr><tr><td>+ Larger LLM (13B)</td><td>5.4M</td><td>90.32</td><td>94.38</td><td>87.73</td><td>89.44</td><td>87.65</td><td>90.31</td><td>91.19</td><td>89.26</td><td>90.50(+7.85)</td></tr></table>
141
+
142
+ Table 2: Ablation studies on ScienceQA test set. For the text-only baseline, we use the image caption to prompt the model. ViT-B/16 and LLaMA-7B are used as the default image encoder and LLM. “Joint Opt” denotes the joint optimization of image encoder and LLM. The Mixture-of-Modality Training (MMT) is ablated with the settings of “Vision Modality” and “Joint Opt.”.
143
+
144
+ # 4 Experiments
145
+
146
+ # 4.1 Datasets and Metrics
147
+
148
+ ScienceQA. ScienceQA [24] is the large-scale multimodal dataset for science question answering, which covers various domains, including 3 subjects, 26 topics, 127 categories and 379 skills. ScienceQA consists of text-only and text-image examples in three splits namely train, val and test, with 12,726, 4,241 and 4,241 examples, respectively. We evaluate our model using average accuracy.
149
+
150
+ Alphaca-52k & LLaVA-158k. Alphaca-52k [42] contains 52k text-only instruction-following data generated by GPT-3.5 [3]. LLaVA-158k [21] is a large-scale text-image instruction-following dataset, where the answer is automatically generated by GPT-4 [34]. Following LLaVA [21], GPT-4 is employed to evaluate the quality of the chatbot’s responses, which will assign higher scores to superior responses within a range of 1 to 10.
151
+
152
+ # 4.2 Implementation Details
153
+
154
+ We employ the ViT-L/14 [7] of the pre-trained CLIP [36] as the image encoder. The visual features consist of six [cls] tokens extracted from every fourth layer of ViT-L/14. For LLM, LLaMA7B [43] and LLaMA-13B [43] are used. The default dimension of the visual neck is set to 128. The dimension of MM-Adapter is 8, and the temperature is set to 10 for LaVIN-7B and 5 for LaVIN-13B. For text-only baseline, the image encoder is removed, and MM-Adapter is replaced with RepAdapter [26]. We adopt AdamW [23] as the optimizer, and train the model for 20 epochs with a cosine decay learning rate schedule. The batch size, learning rate and weight decay are set to 32, 9e-3 and 0.02, respectively. During the generation stage, the decoding uses top- $p$ sampling with a temperature of 0.1 and a top- $p$ value of 0.75, respectively. For the experiments of multimodal chatbot, all hyperparameters remain the same, except for the training epochs, which are reduced to 15.
155
+
156
+ # 4.3 Experimental Results
157
+
158
+ # 4.3.1 Quantitative Experiments
159
+
160
+ Results on ScienceQA. In Tab. 1, We first compare LaVIN with the state-of-the-art methods on ScienceQA. From this table, the first observation is that the few-shot LLMs, such as GPT-4, still perform worse than human, suggesting the great challenge of ScienceQA. In contrast, existing supervised methods [21, 51, 53] yield better results. In particular, MM-CoTLarge [53] achieves the best performance, e.g., 91.68. However, MM-CoT mainly focuses on the multimodal chain-of-thought for language models, of which contribution is orthogonal to our approach. In particular, LLaVA [21] is an end-to-end multimodal LLM, which is more close to our work.
161
+
162
+ The results show that LLaVA remains competitive performance against MM-CoTLarge[53], especially in the category of SOC. Despite the effectiveness, its number of trainable parameters is still large, leading to higher training overhead. LLaMA-Adapter [51] adopts a parameterefficient scheme to reduce the training overhead, but its performance still greatly lags behind LLaVA. Compared to these approaches, LaVIN achieves the better trade-offs between performance and training efficiency. For exam
163
+
164
+ <table><tr><td>Methods</td><td>#T-Params</td><td>Accuracy</td></tr><tr><td>LLaVA [21]</td><td>13B</td><td>85.81</td></tr><tr><td>LLaMA-Adapter [51]</td><td>1.8M</td><td>85.19</td></tr><tr><td>LaVIN-7B</td><td>3.8M</td><td>89.41 (+4.22)</td></tr><tr><td>LaVIN-13B</td><td> 5.4M</td><td>90.83 (+5.02)</td></tr></table>
165
+
166
+ Table 3: Results of LaVIN and existing multimodal LLMs without the pre-training stage. We report the average accuracy on ScienceQA test set.
167
+
168
+ ple, LaVIN-7B consumes a similar scale of trainable parameters as LLaMA-Adapter [51], while outperforming it by $+ 4 . 2 2$ gains. When scaling up to 13B, LaVIN can obtain more significant performance gains, i.e., $+ 5 . 6 4$ . Compared to LLaVA, LaVIN-13B also achieves comparable performance and even performs better in some question classes, e.g., LAN and NO. Considering the much lower training costs than LLaVA, such competitive performance greatly confirms the efficiency and designs of LaVIN.
169
+
170
+ In Tab. 3, we compare LaVIN with existing methods without VL pretraining. From this table, we observe that both LLaVA [21] and LLaMAAdapter achieve the similar performance, i.e., 85.81 vs. 85.19. In particular, LLaVA [21] and LLaMAAdapter [51] freeze the image backbone, and the entire multimodal LLM is not jointly optimized, which hinders the learning of visual content. Moreover, the adaptation module in LLaMA-Adapter does not consider
171
+
172
+ <table><tr><td>Methods</td><td>PT Data</td><td>#T-Params</td><td>BLEU-4</td><td>CIDEr</td></tr><tr><td>ClipCap [32]</td><td>0</td><td>-</td><td>33.5</td><td>113.1</td></tr><tr><td>LLaMA-Adapter V2 [11]</td><td>0</td><td>14M</td><td>36.2</td><td>122.2</td></tr><tr><td>BLIP [18]</td><td>14M</td><td>583M</td><td>40.4</td><td>136.7</td></tr><tr><td>BLIP-2 [17]</td><td>129M</td><td>188M</td><td>43.7</td><td>145.3</td></tr><tr><td> LaVIN (ours)</td><td>0</td><td> 5.4M</td><td>36.4</td><td>126.9</td></tr><tr><td> LaVIN (ours)</td><td>0.6M</td><td> 5.4M</td><td>37.8</td><td>131.7</td></tr></table>
173
+
174
+ Table 4: Fine-tuning results of LaVIN and existing multimodal LLMs on COCO captioning. We report performance on Karpathy test split.
175
+
176
+ the modality gap in the input instructions, greatly limiting its performance upper bound. In contrast, with the help of MMA, LaVIN significantly outperforms these approaches, e.g., $+ 5 . 0 2$ gains over LLaVA. These results validate the proposed MMA towards the effective and efficient VL adaption, and confirm the designs of LaVIN.
177
+
178
+ Results on COCO Captioning. In Tab 4, we compare LaVIN with existing methods on the task of image captioning. From these results, we can still observe the competitive performance of LaVIN. As a parameter-efficient tuning method, LaVIN outperforms LLaMA-Adapter v2 [11] by a large margin, e.g., up to $+ 9 . 5$ of CIDEr. Compared with large-scale pre-training models, e.g., BLIP and BLIP-2, the performance of LaVIN is still comparable, while the expenditure is much cheaper. For instance, with only $0 . 6 \mathbf { M }$ pre-training data and 5.4M updated parameters, LAVIN can achieve 131.7 CIDEr on COCO Captioning. Notably, our tuning only takes 4 GPU hours on 8 A100s, while BLIP-2 requires more than 300 GPU hours on 16 A100s. These results further validate the effectiveness and training efficiency of MMA and LaVIN.
179
+
180
+ Zero-shot evaluation on NLP and multimodal benchmarks. In Tab. 5, we evaluate the zero-shot ability of LaVIN and existing methods on TruthfulQA [20] and MME [10]. On TruthfulQA [20], we observe that the zero-shot performance of existing multimodal LLMs is obviously inferior to the original LLaMA. In stark contrast, LaVIN can further improve the performance by $+ 9 . 2 \%$ than LLaMA-Base [43] through its mixture-of-modality adaptation. On MME [10], a challenging benchmark for multimodal evaluation, LaVIN still demonstrates competitive performance against existing multimodal LLMs. Expect for BLIP-2 [17], which is pre-trained on numerous data, the other methods perform similarly to or worse than LaVIN, e.g., 866.5 of MiniGPT-4 vs. 963.6 of LaVIN on MME-C. These results confirm the strong generalization ability of LaVIN, and also validate that the NLP capabilities are well preserved by MMA during VL instruction tuning.
181
+
182
+ Ablation study. To gain deep insights into MMA and LaVIN, we conduct comprehensive ablation studies in Tab. 2. From this table, we can see that each design of MMA and LaVIN greatly contributes to the final performance. As shown in Tab. 2, the mixture-of-modality training (MMT) brings the most significant gains, e.g., $+ 4 . 6 9$ . In MMT, the joint training with the vision modality provides up to $+ 3 . 6 7$ performance gains for LaVIN. With the joint optimization of the image encoder and LLM, the performance of LaVIN further boosts from 86.32 to 87.34, suggesting the significance of the joint optimization for multimodal LLMs. With the help of MMT, LaVIN already surpasses the ex
183
+
184
+ Table 5: Zero-shot results on NLP and multimodal benchmarks. “Mc1_targets” setup is used on TruthfulQA [20]. “MME-C” and “MME-P” denote the splits of Cognition and Perception on MME benchmark [10], respectively.
185
+
186
+ <table><tr><td colspan="4">Methods TruthfulQA MME-C MME-P</td></tr><tr><td>LLaMA-Base [43]</td><td>38.7</td><td>=</td><td>=</td></tr><tr><td>LLaMA-Adapter V2 [11]</td><td>24.4</td><td>972.6</td><td>248.9</td></tr><tr><td>LLaVA [21]</td><td>16.4</td><td>502.8</td><td>214.6</td></tr><tr><td>BLIP-2 [17]</td><td>-</td><td>1293.8</td><td>290.0</td></tr><tr><td>MiniGPT-4 [56]</td><td>1</td><td>866.5</td><td>292.1</td></tr><tr><td>LaVIN (ours)</td><td>47.9</td><td>963.6</td><td>249.6</td></tr></table>
187
+
188
+ isting parameter-efficient method, i.e., LLaMA-Adapter. Additionally, the stronger image encoder, i.e., ViT-L/14, also improves the average accuracy by 0.99. An interesting observation is that a better image encoder provides noticeable performance gains for both image-based and text-based questions. When adopting MM-Adapter to LaVIN, we observe $+ 1 . 0 8$ gains on average accuracy. Such an improvement only requires extra 0.9M parameters, which is very lightweight. Meanwhile, the performance of $\mathrm { L a V I N }$ is significantly improved by MM-Adapter on more challenging metrics like G7-12, i.e., $+ 2 . 5 1$ . After scaling up LLM to 13B, the performance of LaVIN is further improved by $+ 1 . 0 9$ . Overall, these ablations well validate the significance of MMA in adapting multimodal LLM, and also confirm the effectiveness of LaVIN.
189
+
190
+ Comparison of training efficiency. In Tab. 6, we compare the training expenditures of LaVIN, LLaVA [21] and BLIP2 [17]. The first observation is that the pre-training cost of BLIP2 is actually expensive, which requires more than 200 hours. Meanwhile, LLaVA cannot be trained on common machines with the default training settings3. Thus, it requires some GPU memorysaving techniques [9] to avoid out of memory (OOM). However, its training time and storage requirement are still significant. For example, it still takes up to 26GB space to store the updated parameters of the LLM. In contrast, LaVIN demonstrates superior training efficiency with the help of MMA. Compared to LLaVA,
191
+
192
+ Table 6: Training costs of LaVIN and existing multimodal LLMs on ScienceQA. $^ \ddag$ denotes that GPU memory-saving techniques are used. “OOM” denotes out of GPU memory. All results are evaluated on 8 A100 GPUs.
193
+
194
+ <table><tr><td>Methods</td><td>#T-Params Memory</td><td></td><td>Time</td><td>#Storage</td></tr><tr><td>BLIP2 [17]</td><td>188M</td><td>1</td><td> &gt;200 hours</td><td>1</td></tr><tr><td>LLaVA [21]</td><td>13B</td><td>OOM</td><td>N/A</td><td>N/A</td></tr><tr><td>LLaVA‡ [21]</td><td>13B</td><td>36.8G</td><td>7 hours</td><td>26GB</td></tr><tr><td>LaVIN-7B</td><td>3.8M</td><td>33.9G</td><td> 1.4 hours</td><td>15M</td></tr><tr><td>LaVIN-13B</td><td>5.4M</td><td>55.9G</td><td>2 hours</td><td>20M</td></tr></table>
195
+
196
+ LaVIN-7B and LaVIN-13B reduce about $80 \%$ and $7 1 . 4 \%$ training time, respectively. In terms of GPU memory and storage cost, our approach can save more than $40 \%$ GPU memory and $9 9 . 9 \%$ disk storage. Overall, these results greatly confirm the training efficiency of MMA.
197
+
198
+ # 4.3.2 Qualitative Experiments
199
+
200
+ Examples of different instruction-following tasks. In Fig 4, we compare LaVIN with existing methods [51, 21] on single- and multi-modal instruction-following tasks, e.g., math, coding and image captioning. Compared to LLaVA [21] and LLaMA-Adapter [51], LaVIN achieves overall better responses across multiple tasks. In Fig.4 (a), LaVIN correctly answers the math problem with a result of 28.8, whereas LLaMA-Adapter [43] provides an incorrect answer. In example (d), LaVIN generates accurate code for the request of “print prime numbers up to 100”. In contrast, the
201
+
202
+ If a toy costs $\$ 24$ and the price is increased by $20 \%$ , what is the new price of the toy?
203
+
204
+ Translate the following Chinese into English :生如夏 花之绚烂死如秋叶之静美.
205
+
206
+ I mix water with water, do I get thin water or thick water?
207
+
208
+ Write a python code that: Print out all prime numbers up to 100.
209
+
210
+ LaVIN (ours): foriinrange(1,101):
211
+
212
+ # LaVIN (ours):
213
+
214
+ The new price of the toy is \$28.80.
215
+
216
+ # LaVIN (ours):
217
+
218
+ Life is like a summer flower, death is like a autumn leaf, quiet and beautiful.
219
+
220
+ # LaVIN (ours):
221
+
222
+ You will get the same type of water, just a mixture of the two.
223
+
224
+ # LLaMA-Adapter:
225
+
226
+ # LLaMA-Adapter:
227
+
228
+ The new price of the toy is $\$ 28.40$ .
229
+
230
+ # LLaMA-Adapter:
231
+
232
+ Born like summer flowers, die like autumn leaves.
233
+
234
+ LLaMA-Adapter: Thin water.
235
+
236
+ 1 def prime_numbers(n): foriin range(2,n): $\mathrm { ~ i ~ } = = \mathrm { ~ 0 ~ }$ print(i) prime_numbers(100) (d) Coding
237
+
238
+ # (a) Math
239
+
240
+ (b) Translation
241
+
242
+ # (c) Question Answering
243
+
244
+ How many food containers are there in the image?
245
+
246
+ Describe the Image.
247
+
248
+ ![](images/8f7b6e724c5812f7e4f1f2eaad1bcc5ea0c9a7c3ac36459378c48829079cc394.jpg)
249
+
250
+ ![](images/cd54236976bc261ab0e8c950614cda609781c2c273232649cd5aa487a18ee313.jpg)
251
+
252
+ The boy's clothes in the image are wet, is it because of the rain?
253
+
254
+ # LaVIN (ours)
255
+
256
+ : In the image, there are two food containers on the dining table. One container holds a sandwich, and the other holds a plate of broccoli. The sandwich appears to be cut in half, and the broccoli is served on a separate plate.
257
+
258
+ # LLaVA
259
+
260
+ : There are three food containers in the image: a bowl, a plate, and a sandwich.
261
+
262
+ ![](images/6deacb50a233ee170b248b15aec205ba36e774e2f62e26ffdd9f90ba6f600596.jpg)
263
+ Figure 4: Comparison between LaVIN-13B and existing methods on single- and multi-modal instructions. The noteworthy aspects of the responses are highlighted in green, whereas the illogical portions are marked in red. More tasks and examples are given in appendix.
264
+
265
+ # LaVIN (ours)
266
+
267
+ # LaVIN (ours)
268
+
269
+ : The image features a beach scene with a large number of kites flying in the sky.
270
+
271
+ : No, the boy's clothes are wet because he is surfing in the ocean
272
+
273
+ # LLaVA
274
+
275
+ : The image captures a lively beach scene with several people enjoying kite flying near the ocean.
276
+
277
+ # LLaVA
278
+
279
+ : Yes, it is likely that the boy's clothes are wet due to the rain.
280
+
281
+ (e) Visual Question Answering (f) Image Captioning (g) Multimodal Reasoning
282
+
283
+ code written by LLaMA-Adapter is to check prime numbers, which does not produce any output during execution. Meanwhile, LaVIN presents a clear and concise coding behavior, acting more like a professional programmer. In Fig 4 (e)-(g), LaVIN demonstrates remarkable visual reasoning ability in accomplishing various multimodal tasks. In Fig.4 (e), LaVIN accurately answers the complex questions about the number of food containers in the image and provides a detailed description about the complex scene. The same observation can also be witnessed in Fig.4 (g), where LaVIN infers a correct reason for the wetness of the boy’s clothes. Overall, these examples show the superior reasoning ability of LaVIN in executing single- and multi-modal instructions, while also confirming the significance of MMA in adapting LLMs to multi-modal tasks.
284
+
285
+ Examples of multimodal dialogue In Fig. 5, we compare LaVIN with existing multimodal LLMs in multi-turn conversations, and use GPT4 [34] to evaluate the quality of their responses. From the results, we can see that LaVIN has higher GPT4 scores among all compared models, suggesting superior ability in multimodal dialogue. Meanwhile, we also observe different response styles of these multimodal LLMs. In particular, BLIP2 [17] tends to produce brief responses, which lack detailed explanations. In contrast, the responses of MiniGPT4 [56] are the longest among all models, but their content is often redundant and repetitive. Compared to them, LaVIN and LLaVA [21] can generate more accurate responses. Particularly, LaVIN performs better than the other methods, mainly due to its more logical and detailed descriptions. As illustrated in the first question, LaVIN not only provides the correct answer, but also explains the reason behind it. In the second question, LaVIN and LLaVA are required to judge whether the man will get wet, and LaVIN answers “yes" while LLaVA considers “no". It can be seen that the reason of LaVIN is more comprehensive, logical and persuasive than LLaVA, which considers the situation of “the overhand may not provide the complete protection”. Overall, these examples confirm that MMA equips LLMs with excellent multi-modal ability, requiring no pre-training on large-scale image-text data.
286
+
287
+ # 5 Limitations and Broader Impact
288
+
289
+ We observe two primary limitations of LaVIN. Firstly, LaVIN may generate incorrect or fabricate responses, similar to existing multimodal LLMs. Secondly, LaVIN can not identify extremely fine
290
+
291
+ # : If it rains now, will the man get wet?
292
+
293
+ # : What is the baby doing in the image?
294
+
295
+ ![](images/2978d1deb486e920023c89afaf0ddf3d6c339af761c07b98b0417c77d2af9e27.jpg)
296
+ : What is the weather in the image now?
297
+
298
+ # : What color is the baby's clothes?
299
+
300
+ # LaVIN (ours)
301
+
302
+ :The weather in the image appears to be sunny, as the man is holding a baby in his arms outside, and there are no visible signs of rain or stormy conditions. The presence of a horse in the scene suggests that the location might be a farm or a rural area, where sunny weather is more common. GPT4 Score: 9
303
+
304
+ # LaVIN (ours)
305
+
306
+ : Yes, if it rains now, the man will get wet. In the image, the man is holding a baby and petting a brown horse, and they are both standing under an overhang. If it starts raining, the overhang will not provide complete protection from the rain, and the man will get wet as he continues to interact with the horse and the baby.
307
+
308
+ # LaVIN (ours)
309
+
310
+ : In the image, the baby is being held by a man, who is also holding a horse's nose. The baby is reaching out to touch the horse's nose, likely experiencing the horse for the first time. This interaction between the baby and the horse creates a moment of connection and curiosity for the child.
311
+
312
+ # LaVIN (ours)
313
+
314
+ : The baby's clothes are white. In the image, the man is holding the baby while the horse is nuzzling the baby's face. The baby is wearing a white onesie, which stands out against the man's brown shirt and the horse's color.
315
+
316
+ # GPT4 Score: 8
317
+
318
+ BLIP2 : Yes. PT4 Score: 6
319
+
320
+ # GPT4 Score: 9
321
+
322
+ # GPT4 Score: 9
323
+
324
+ BLIP2: Petting the horse. GPT4 Score: 7
325
+
326
+ BLIP2 : Blue. GPT4 Score: 2
327
+
328
+ BLIP2 : It is a sunny day. GPT4 Score: 7
329
+
330
+ # LLaVA
331
+
332
+ : The weather in the image is sunny.
333
+ GPT4 Score: 7
334
+
335
+ # LLaVA
336
+
337
+ : No, the man will not get wet if it starts raining, as he is already inside the stable with the horse. The stable provides shelter from the rain, keeping both the man and the horse dry.
338
+
339
+ # LLaVA
340
+
341
+ : The baby is touching the horse, reaching out to pet it while being held by the man.
342
+
343
+ # LLaVA
344
+
345
+ : The baby is wearing white clothes.
346
+
347
+ # GPT4 Score: 7
348
+
349
+ # GPT4 Score: 8
350
+
351
+ # GPT4 Score: 7
352
+
353
+ # MiniGPT4
354
+
355
+ :It is not possible to determine the current weather in the location depicted in the image, as the image does not provide any information about the weather conditions. The image shows a man, a baby, and a horse standing in front of a building with a thatched roof, but it does not provide any information about the weather or the environment in the area.
356
+
357
+ GPT4 Score: 4
358
+
359
+ # MiniGPT4
360
+
361
+ :It is not possible to determine whether the man in the image would get wet if it starts raining, as the image does not provide any information about the current weather conditions or the environment in the area. The image shows a man holding a baby, but it does not provide any information about the weather or the environment in the area.
362
+
363
+ # MiniGPT4
364
+
365
+ :In the image, the baby is reaching out to touch the horse’s nose. The baby is held up by the man, who is standing next to the horse, and the baby is reaching out with one hand to touch the horse’s nose. The baby is smiling and seems to be enjoying the interaction with the horse.
366
+
367
+ # MiniGPT4
368
+
369
+ :The baby in the image is not wearing any clothes.
370
+
371
+ # GPT4 Score: 5
372
+
373
+ GPT4 Score: 9
374
+
375
+ GPT4 Score: 2
376
+
377
+ Figure 5: Comparison of LaVIN-13B and existing multimodal LLMs in multi-turn conversations. GPT-4 assigns a score ranging from 1 to 10 to evaluate the quality of a response, with a higher score indicating superior performance. The noteworthy aspects of the responses are highlighted in green, whereas the illogical portions are marked in red.
378
+
379
+ grained visual content, such as text characters. We believe that the recognition ability of LaVIN still has a large room to improve, which will be left in our future work.
380
+
381
+ # 6 Conclusions
382
+
383
+ In this paper, we propose a novel and affordable solution for vision-language instruction tuning, namely Mixture-of-Modality Adaptation (MMA). Particularly, MMA is an end-to-end optimization regime, which connects the image encoder and LLM via lightweight adapters. With the help of MMA, the entire multimodal LLM can be jointly optimized via a small number of parameters, greatly reducing the training costs. Meanwhile, we also propose a novel routing algorithm in MMA, which can help the model automatically shifts the reasoning paths for single- and multimodal instructions. Based on MMA, we develop a large vision-language instructed model called LaVIN, which demonstrates a superior reasoning ability than existing multimodal LLMs in various instruction-following tasks.
384
+
385
+ Acknowledgements. This work was supported by National Key R&D Program of China (No.2022ZD0118201) , the National Science Fund for Distinguished Young Scholars (No.62025603), the National Natural Science Foundation of China (No. U21B2037, No. U22B2051, No. 62176222, No. 62176223, No. 62176226, No. 62072386, No. 62072387, No. 62072389, No. 62002305 and No. 62272401), the Natural Science Foundation of Fujian Province of China (No.2021J01002, No.2022J06001), and the China Fundamental Research Funds for the Central Universities (Grant No. 20720220068). We also thank Dr. Mingbao Lin for his valuable suggestions.
386
+
387
+ References
388
+ [1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. Advances in Neural Information Processing Systems, 35:23716–23736, 2022.
389
+ [2] Shoufa Chen, Chongjian Ge, Zhan Tong, Jiangliu Wang, Yibing Song, Jue Wang, and Ping Luo. Adaptformer: Adapting vision transformers for scalable visual recognition. CoRR, abs/2205.13535, 2022.
390
+ [3] Ting Chen, Simon Kornblith, Kevin Swersky, Mohammad Norouzi, and Geoffrey E Hinton. Big selfsupervised models are strong semi-supervised learners. Advances in neural information processing systems (NeurIPS), 33:22243–22255, 2020.
391
+ [4] Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E. Gonzalez, Ion Stoica, and Eric P. Xing. Vicuna: An open-source chatbot impressing gpt-4 with $9 0 \% *$ chatgpt quality, March 2023.
392
+ [5] 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.
393
+ [6] Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph, Yi Tay, William Fedus, Eric Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, et al. Scaling instruction-finetuned language models. arXiv preprint arXiv:2210.11416, 2022.
394
+ [7] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021.
395
+ [8] Danny Driess, Fei Xia, Mehdi SM Sajjadi, Corey Lynch, Aakanksha Chowdhery, Brian Ichter, Ayzaan Wahid, Jonathan Tompson, Quan Vuong, Tianhe Yu, et al. Palm-e: An embodied multimodal language model. arXiv preprint arXiv:2303.03378, 2023.
396
+ [9] FairScale authors. Fairscale: A general purpose modular pytorch library for high performance and large scale training. https://github.com/facebookresearch/fairscale, 2021.
397
+ [10] Chaoyou Fu, Peixian Chen, Yunhang Shen, Yulei Qin, Mengdan Zhang, Xu Lin, Zhenyu Qiu, Wei Lin, Jinrui Yang, Xiawu Zheng, et al. Mme: A comprehensive evaluation benchmark for multimodal large language models. arXiv preprint arXiv:2306.13394, 2023.
398
+ [11] Peng Gao, Jiaming Han, Renrui Zhang, Ziyi Lin, Shijie Geng, Aojun Zhou, Wei Zhang, Pan Lu, Conghui He, Xiangyu Yue, et al. Llama-adapter v2: Parameter-efficient visual instruction model. arXiv preprint arXiv:2304.15010, 2023.
399
+ [12] Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. In ICLR, 2022.
400
+ [13] Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin de Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for NLP. In ICML, 2019.
401
+ [14] Edward J Hu, yelong shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. In ICLR, 2022.
402
+ [15] Shaohan Huang, Li Dong, Wenhui Wang, Yaru Hao, Saksham Singhal, Shuming Ma, Tengchao Lv, Lei Cui, Owais Khan Mohammed, Qiang Liu, et al. Language is not all you need: Aligning perception with language models. arXiv preprint arXiv:2302.14045, 2023.
403
+ [16] Jing Yu Koh, Ruslan Salakhutdinov, and Daniel Fried. Grounding language models to images for multimodal generation. arXiv preprint arXiv:2301.13823, 2023.
404
+ [17] Junnan Li, Dongxu Li, Silvio Savarese, and Steven Hoi. Blip-2: Bootstrapping language-image pre-training with frozen image encoders and large language models. arXiv preprint arXiv:2301.12597, 2023.
405
+ [18] Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi. Blip: Bootstrapping language-image pre-training for unified vision-language understanding and generation. In International Conference on Machine Learning, pages 12888–12900. PMLR, 2022.
406
+
407
+ [19] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In ACL/IJCNLP, 2021.
408
+
409
+ [20] Stephanie Lin, Jacob Hilton, and Owain Evans. Truthfulqa: Measuring how models mimic human falsehoods. arXiv preprint arXiv:2109.07958, 2021.
410
+
411
+ [21] Haotian Liu, Chunyuan Li, Qingyang Wu, and Yong Jae Lee. Visual instruction tuning. arXiv preprint arXiv:2304.08485, 2023.
412
+
413
+ [22] Xiao Liu, Kaixuan Ji, Yicheng Fu, Zhengxiao Du, Zhilin Yang, and Jie Tang. P-tuning v2: Prompt tuning can be comparable to fine-tuning universally across scales and tasks. CoRR, abs/2110.07602, 2021.
414
+
415
+ [23] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
416
+
417
+ [24] Pan Lu, Swaroop Mishra, Tanglin Xia, Liang Qiu, Kai-Wei Chang, Song-Chun Zhu, Oyvind Tafjord, Peter Clark, and Ashwin Kalyan. Learn to explain: Multimodal reasoning via thought chains for science question answering. Advances in Neural Information Processing Systems, 35:2507–2521, 2022.
418
+
419
+ [25] Yuning Lu, Jianzhuang Liu, Yonggang Zhang, Yajing Liu, and Xinmei Tian. Prompt distribution learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
420
+
421
+ [26] Gen Luo, Minglang Huang, Yiyi Zhou, Xiaoshuai Sun, Guannan Jiang, Zhiyu Wang, and Rongrong Ji. Towards efficient visual adaption via structural re-parameterization. arXiv preprint arXiv:2302.08106, 2023.
422
+
423
+ [27] Gen Luo, Yiyi Zhou, Xiaoshuai Sun, Yan Wang, Liujuan Cao, Yongjian Wu, Feiyue Huang, and Rongrong Ji. Towards lightweight transformer via group-wise transformation for vision-and-language tasks. IEEE Transactions on Image Processing, 31:3386–3398, 2022.
424
+
425
+ [28] Gen Luo, Yiyi Zhou, Xiaoshuai Sun, Yongjian Wu, Yue Gao, and Rongrong Ji. Towards language-guided visual recognition via dynamic convolutions. International Journal of Computer Vision, pages 1–19, 2023.
426
+
427
+ [29] Todor Mihaylov, Peter Clark, Tushar Khot, and Ashish Sabharwal. Can a suit of armor conduct electricity? a new dataset for open book question answering. Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2018.
428
+
429
+ [30] Swaroop Mishra, Daniel Khashabi, Chitta Baral, Yejin Choi, and Hannaneh Hajishirzi. Reframing instructional prompts to gptk’s language. ACL Findings, 2021.
430
+
431
+ [31] Swaroop Mishra, Arindam Mitra, Neeraj Varshney, Bhavdeep Sachdeva, Peter Clark, Chitta Baral, and Ashwin Kalyan. Numglue: A suite of fundamental yet challenging mathematical reasoning tasks. The 60th Annual Meeting of the Association for Computational Linguistics (ACL), 2022.
432
+
433
+ [32] Ron Mokady, Amir Hertz, and Amit H Bermano. Clipcap: Clip prefix for image captioning. arXiv preprint arXiv:2111.09734, 2021.
434
+
435
+ [33] OpenAI. Chatgpt, 2023.
436
+
437
+ [34] OpenAI. Gpt-4 technical report, 2023.
438
+
439
+ [35] 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.
440
+
441
+ [36] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. In ICML, Proceedings of Machine Learning Research, 2021.
442
+
443
+ [37] 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.
444
+
445
+ [38] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21:140:1–140:67, 2020.
446
+
447
+ [39] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10684–10695, 2022.
448
+
449
+ [40] Noam Shazeer. Glu variants improve transformer. arXiv preprint arXiv:2002.05202, 2020.
450
+ [41] Yongliang Shen, Kaitao Song, Xu Tan, Dongsheng Li, Weiming Lu, and Yueting Zhuang. Hugginggpt: Solving ai tasks with chatgpt and its friends in huggingface. arXiv preprint arXiv:2303.17580, 2023.
451
+ [42] 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.
452
+ [43] 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.
453
+ [44] Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. arXiv preprint arXiv:1804.07461, 2018.
454
+ [45] Yan Wang, Xiaojiang Liu, and Shuming Shi. Deep neural solver for math word problems. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 845–854, 2017.
455
+ [46] Yaqing Wang, Subhabrata Mukherjee, Xiaodong Liu, Jing Gao, Ahmed Hassan Awadallah, and Jianfeng Gao. Adamix: Mixture-of-adapter for parameter-efficient tuning of large language models. arXiv preprint arXiv:2205.12410, 2022.
456
+ [47] 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.
457
+ [48] Yizhong Wang, Swaroop Mishra, Pegah Alipoormolabashi, Yeganeh Kordi, Amirreza Mirzaei, Anjana Arunkumar, Arjun Ashok, Arut Selvan Dhanasekaran, Atharva Naik, David Stap, et al. Benchmarking generalization via in-context instructions on $1 { , } 6 0 0 { + }$ language tasks. arXiv preprint arXiv:2204.07705, 2022.
458
+ [49] Chenfei Wu, Shengming Yin, Weizhen Qi, Xiaodong Wang, Zecheng Tang, and Nan Duan. Visual chatgpt: Talking, drawing and editing with visual foundation models. arXiv preprint arXiv:2303.04671, 2023.
459
+ [50] Zhengyuan Yang, Linjie Li, Jianfeng Wang, Kevin Lin, Ehsan Azarnasab, Faisal Ahmed, Zicheng Liu, Ce Liu, Michael Zeng, and Lijuan Wang. Mm-react: Prompting chatgpt for multimodal reasoning and action. arXiv preprint arXiv:2303.11381, 2023.
460
+ [51] Renrui Zhang, Jiaming Han, Aojun Zhou, Xiangfei Hu, Shilin Yan, Pan Lu, Hongsheng Li, Peng Gao, and Yu Qiao. Llama-adapter: Efficient fine-tuning of language models with zero-init attention. arXiv preprint arXiv:2303.16199, 2023.
461
+ [52] 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.
462
+ [53] 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.
463
+ [54] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. In CVPR, 2022.
464
+ [55] Yiyi Zhou, Rongrong Ji, Xiaoshuai Sun, Jinsong Su, Deyu Meng, Yue Gao, and Chunhua Shen. Plenty is plague: Fine-grained learning for visual question answering. IEEE transactions on pattern analysis and machine intelligence, 44(2):697–709, 2019.
465
+ [56] Deyao Zhu, Jun Chen, Xiaoqian Shen, Xiang Li, and Mohamed Elhoseiny. Minigpt-4: Enhancing vision-language understanding with advanced large language models. arXiv preprint arXiv:2304.10592, 2023.
md/dev/tDw7Mmat8co/tDw7Mmat8co.md ADDED
@@ -0,0 +1,668 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TOWARDS SAFE REINFORCEMENT LEARNING VIA CONSTRAINING CONDITIONAL VALUE-AT-RISK
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Though deep reinforcement learning (DRL) has obtained substantial success, it may encounter catastrophic failures due to the intrinsic uncertainty caused by stochasticity in both environments and policies. Existing safe reinforcement learning methods are often based on transforming the optimization criterion and adopting the variance of the return as a measure of uncertainty. However, the return variance introduces a bias for penalizing both positive and negative risk equally, deviated from the purpose of safe reinforcement learning to penalize negative ones only. To address this issue, we propose to use the conditional value-at-risk (CVaR) as an assessment of risk, which guarantees that the probability for reaching a catastrophic state is below a desired threshold. Furthermore, we present a novel reinforcement learning framework of CVaR-Proximal-Policy-Optimization (CPPO) which formalizes the risk-sensitive constrained optimization problem by keeping its CVaR under a given threshold. To evaluate the robustness of policies, we theoretically prove that performance degradation under observation disturbance and transition disturbance depends on the gap of value function between the best state and the worst state. We also show that CPPO can generate more robust policies under disturbance. Experimental results show that CPPO achieves higher cumulative reward and exhibits stronger robustness against observation disturbance and transition disturbance on a series of continuous control tasks in MuJoCo.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Deep reinforcement learning (DRL) has achieved enormous success on a variety of tasks, ranging from playing Atari games (Mnih et al., 2013; 2015; 2016), Go (Silver et al., 2016) to manipulating complex robotics in the real world (Kendall et al., 2019). However, due to the intrinsic stochasticity in both environments and policies, these methods may result in catastrophic failures (Heger, 1994; Coraluppi & Marcus, 1999) and the agent may receive significantly negative outcomes. Several factors can be associated with this phenomenon. One is that traditional DRL only aims at cumulative reward maximization without considering the stochasticity of the environment (Garcıa & Fernandez ´ , 2015), which may lead to serious consequences with a certain probability and expose our policies to risk. This can be illustrated briefly in the case of self-driving, where the agent might try to achieve the highest reward by acting dangerously, e.g. agents may drive along the edge of a curve for reaching the end with a short time ignoring the danger in driving. Also, the usage of deep neural networks to construct complicated mappings from a high-dimensional state space $s$ to an action space $\mathcal { A }$ in DRL algorithms can make them vulnerable to adversarial attacks (Huang et al., 2017).
12
+
13
+ Various efforts have been made on safe reinforcement learning (safe RL) (Heger, 1994; Coraluppi & Marcus, 1999; Garcıa & Fernandez ´ , 2015). Garcıa & Fernandez ´ (2015) conduct a comprehensive survey on safe RL and argue that an array of methods in this area are based on transforming the optimization criterion by considering the risk of the return. For example, $\hat { Q }$ -Learning (Heger, 1994) uses a lower bound to estimate the Q-target in $Q$ -Learning for avoiding the risk; and Geibel & Wysotzki (2005) propose the expected-value-minus-variance-criterion that subtracts the variance of the return from the cumulative reward. However, due to the consideration of the worst-case outcomes (Heger, 1994), one major drawback of those transformed optimization criteria is that they may lead to overly pessimistic policies, which will focus too much on the worst case and own poor average performance. Moreover, although variance is a standard measure of the risk of the policy (Gosavi, 2009; Tamar et al., 2012), it does not distinguish between positive and negative risk and penalizes both equally (Szego¨, 2002), deviated form the purpose of safe RL to only penalize negative ones.
14
+
15
+ To address the shortcomings of the worst-case outcomes as well as the variance of the return used in previous objective-modification methods of safe RL (Garcıa & Fernandez ´ , 2015; Geibel & Wysotzki, 2005; Heger, 1994), we propose to use conditional value-at-risk (CVaR) for evaluating the risk of policies. CVaR is a well established metric in economic uncertainty analysis (Alexander & Baptista, 2004; Alexander et al., 2006) and captures the expectation of the random variable to be an outlier with a given threshold. Unlike variance, CVaR can only capture negative trajectories with relatively low return. Considering to use CVaR to capture the respectively low return of the trajectory, we naturally propose to improve the robustness of the on-policy algorithms by CVaR. By integrating CVaR with Proximal Policy Optimization (PPO) (Schulman et al., 2017), we present a new algorithm called CVaR-Proximal-Policy-Optimization (CPPO) and notionally analyze policies’ robustness against different kinds of disturbance. We show that although the observation disturbance and transition disturbance are structurally different, the performance degradation resulted from each of them is theoretically dependent on the Value Function Range (VFR), which is introduced as the value function gap between the best and worst states in this paper. We further show that CPPO can improve the robustness of policies against observation disturbance and transition disturbance since CVaR can control the value function of states with relatively low value and further control the VFR value. Empirically, we compare CPPO to multiple on-policy baselines as well as some previous CVaR-based methods on various continuous control tasks in MuJoCo (Todorov et al., 2012). Our results show that CPPO achieves higher cumulative reward in the training stage and exhibits stronger robustness when we apply perturbations to these environments.
16
+
17
+ In summary, our contributions are:
18
+
19
+ • We analyze the advantages of choosing CVaR as the metric for evaluating the risk of policy compared with the worst-case outcome as well as the variance of the return. Furthermore, we propose a constrained optimization problem in order to maximize the cumulative reward as well as controlling the risk, which can be solved by our CPPO algorithm; • We theoretically analyze the performance of trained policies under observation and transition disturbance, and build a theoretical connection of these two types of structurally different disturbance. This analysis indicates that our CPPO can improve the robustness of policies; • We empirically demonstrate that our method exhibits stronger robustness under observation/transition perturbations than other common on-policy RL algorithms and previous CVaR-based RL algorithms in MuJoCo simulator.
20
+
21
+ # 2 BACKGROUND
22
+
23
+ In this section, we briefly introduce safe reinforcement learning (safe RL) and conditional value-at-risk (CVaR), which motivate us to adopt CVaR as a metric of risk in safe RL.
24
+
25
+ # 2.1 SAFE RL
26
+
27
+ In standard RL setting, the agent interacts with an unknown environment and learns to achieve the highest long-term return. The task is modeled as a Markov decision process (MDP) of $\mathcal { M } =$ $( S , \bar { \mathcal { A } } , \mathcal { R } , \mathcal { P } , \gamma )$ , where $s$ and $\mathcal { A }$ represent the state space and the action space, respectively; $\mathcal { P }$ : $S \times { \mathcal { A } } \times { \mathcal { S } } [ 0 , 1 ]$ denotes the transition probability that captures the dynamics of the environment; $\mathcal { R } : \mathcal { S } \times \mathcal { A } [ - \mathrm { \bar { \it { R } } _ { \mathrm { { m a x } } } } , { \boldsymbol { R } _ { \mathrm { { m a x } } } } ]$ represents the reward function; and $\gamma$ is a discount factor. We use $\pi _ { \theta }$ to represent the policy of the agent with parameter $\theta$ , which is a mapping from $s$ to $\mathcal { A }$ . At any time step $t$ , the agent perceives current state $s _ { t } \in S$ , chooses its action $a _ { t } \in \mathcal A$ sampled from the distribution $\pi _ { \boldsymbol { \theta } } ( \cdot | s _ { t } )$ and obtains a reward $r _ { t }$ . All these timesteps consist of a trajectory $\tau = ( s _ { 0 } , a _ { 0 } , r _ { i } , s _ { 1 } , a _ { 1 } , \ldots )$ . Given an MDP $\mathcal { M }$ , the goal of RL is to find the optimal policy $\pi _ { \theta ^ { \ast } }$ with the highest expected cumulative reward as
28
+
29
+ $$
30
+ \operatorname* { m a x } _ { \theta } J ( \pi _ { \theta } ) \triangleq \mathbb { E } \left[ D ( \pi _ { \theta } ) \triangleq \sum _ { t = 1 } ^ { \infty } \gamma ^ { t } r _ { t } \Big \vert \pi _ { \theta } \right] ,
31
+ $$
32
+
33
+ where $D ( \pi _ { \theta } )$ represents the return of the policy $\pi _ { \theta }$ , and $J ( \pi _ { \theta } )$ is the expectation of $D ( \pi _ { \theta } )$
34
+
35
+ However, problem (1) only focuses on cumulative reward without considering the risk of the policy, which may cause catastrophic results (Heger, 1994; Coraluppi & Marcus, 1999). To address this problem, an array of safe RL methods tend to change the objective in problem (1) in order to eliminate the uncertainty and avoid the danger. In general, uncertainty can be categorized into two types, namely, inherent uncertainty and parameter uncertainty (Garcıa & Fernandez ´ , 2015). The inherent uncertainty of RL refers to the transition dynamics in MDP. For example the agent might end up in completely different situations when repeating its actions from the same starting state. Previous works (Heger, 1994; Gaskett, 2003) choose the worst-case criterion to address the issue as
36
+
37
+ $$
38
+ \operatorname* { m a x } _ { \theta } J _ { i n h } ( \pi _ { \theta } ) \triangleq \operatorname* { m a x } _ { \theta } \operatorname* { m i n } _ { \tau \sim \pi _ { \theta } } \left[ D ( \tau ) \triangleq \sum _ { t = 1 } ^ { \infty } \gamma ^ { t } r _ { t } \right] .
39
+ $$
40
+
41
+ As a counterpart of $Q$ -Learning, Heger (1994) proposes $\hat { Q }$ -Learning with the implementation of (2), and Gaskett (2003) presents $\beta$ -pessimistic $Q$ -Learning, which adds a parameter $\beta$ to control the pessimistic level.
42
+
43
+ There are also various studies that assess the effectiveness of variance for acquiring safe policies (Sato et al., 2001; Gosavi, 2009; Tamar et al., 2012). Some previous work (Howard & Matheson, 1972) considers exponential utility function and formalizes it as the combination of cumulative reward and the variance of the return $\dot { V } a r ( D ( \pi _ { \theta } ) )$ as
44
+
45
+ $$
46
+ \operatorname* { m a x } _ { \theta } \delta ^ { - 1 } \log \mathbb { E } _ { \pi } \left[ \exp ( \delta D ( \pi _ { \theta } ) ) \right] = \operatorname* { m a x } _ { \theta } \left[ J ( \pi _ { \theta } ) + \frac { \delta } { 2 } V a r ( D ( \pi _ { \theta } ) ) + O ( \delta ^ { 2 } ) \right] .
47
+ $$
48
+
49
+ As for the parameter uncertainty of RL, it denotes scenarios where the parameters of the MDP are unknown or there is a gap between the training and testing environments. Studies conducted by Nilim & El Ghaoui (2005) and Tamar et al. (2013) assume that the actual transition belongs to a set $\hat { \mathcal { P } }$ and consider the following problem as
50
+
51
+ $$
52
+ \operatorname* { m a x } _ { \theta } \operatorname* { m i n } _ { \mathcal { P } \in \hat { \mathcal { P } } } J _ { p a r } ( \pi _ { \theta } , \mathcal { P } ) \triangleq \mathbb { E } \left[ D ( \pi _ { \theta } ) \triangleq \sum _ { t = 1 } ^ { \infty } \gamma ^ { t } r _ { t } \Big \vert \pi _ { \theta } \right] .
53
+ $$
54
+
55
+ However, previous safe RL methods suffer from serious drawbacks. First, both (2) and (3) are maxmin problems, which do not have general effective solutions and usually have a high computational complexity. Second, focusing on the worst trajectories may cause over-pessimistic behaviors. For example, $\hat { Q }$ -Learning aims to improve the performance under the worst scenario, which can lead to extremely conservative actions (Heger, 1994). Finally, the direct usage of variance to evaluate risk is another potential concern because it will penalize not only the possibility of particularly bad trajectories, but also the good ones, yielding a drop in the agent’s performance (Szego¨, 2002).
56
+
57
+ # 2.2 CVAR
58
+
59
+ Value-at-risk (VaR) and conditional value-at-risk (CVaR) are well-established metrics for measuring risk in economy (Alexander & Baptista, 2004; Alexander et al., 2006). First, we will give the definition of VaR and CVaR (Chow & Ghavamzadeh, 2014):
60
+
61
+ Definition 1 (VaR and CVaR). For a bounded-mean random variable $Z$ , the value-at-risk (VaR) of confidence level $\alpha \in ( 0 , 1 )$ is defined as:
62
+
63
+ $$
64
+ \operatorname { V a R } _ { \alpha } ( Z ) = \operatorname* { m i n } \{ z | F ( z ) \geq \alpha \} ,
65
+ $$
66
+
67
+ where $F ( z ) = P ( Z \leq z )$ is the cumulative distribution function $( C D F )$ ; and the condition valueat-risk (CVaR) of confidence level $\alpha$ is defined as the expectation of the $\alpha$ -tail distribution of $Z$ as
68
+
69
+ $$
70
+ \operatorname { C V a R } _ { \alpha } ( Z ) = \mathbb { E } _ { z \sim Z } \{ z | z \geq \operatorname { V a R } _ { \alpha } ( Z ) \} .
71
+ $$
72
+
73
+ It is easy to prove that (Chow et al., 2015):
74
+
75
+ $$
76
+ \operatorname* { l i m } _ { \alpha \to 1 ^ { - } } \operatorname { C V a R } _ { \alpha } ( Z ) = \operatorname* { m a x } ( Z ) .
77
+ $$
78
+
79
+ Previous works have attempted to use CVaR to analyze the risk-MDP, which considers cost function $\mathcal { C }$ rather than reward function $\mathcal { R }$ . Chow & Ghavamzadeh (2014) and Chow et al. (2017) propose gradient-based methods like policy gradient and actor critic to optimize loss of MDP as well as keeping the CVaR under certain value. They also propose methods based on value iteration and Bellman equation to deal with the optimization of risk-MDP with CVaR (Chow et al., 2015). However, these works ignore the reward in MDP and thus cannot be directly used in RL settings.
80
+
81
+ # 3 METHODOLOGY
82
+
83
+ We now present our method that maximizes the expected reward while restricting the risk of the policy. We focus on increasing the agent’s performance on relatively worse trajectories, which loosens the max-min problem to an constrained optimization problem. Moreover, we can make our policy less conservative by modifying the parameter $\alpha$ in CVaR. Compared with variance, CVaR is a better metric for measuring risk, because it, by definition, captures only bad trajectories.
84
+
85
+ # 3.1 PROBLEM FORMULATION
86
+
87
+ In standard RL, what we receive is the reward signal rather than the risk signal, thus we can only evaluate the risk of a trajectory by its return. For simplicity, we suppose there exists a decreasing smoothing function $f : \mathbb { R } \to \mathbb { R }$ with its inverse function $f ^ { - 1 }$ and the risk of a trajectory $\tau$ is $f ( D ( \tau ) \bar { ) }$ For example, the most simple case is that we can use the opposite number of the return to define the risk of the trajectory, i.e. $\dot { f ( D ( \tau ) ) } = - D ( \tau )$ .
88
+
89
+ First we propose Theorem 1 as below to calculate VaR and CVaR of $f ( D ( \tau ) )$ :
90
+
91
+ Theorem 1. For any given policy $\pi _ { \theta }$ and its cumulative reward $D ( \pi _ { \theta } )$ , we have:
92
+
93
+ $$
94
+ \begin{array} { r l } & { \mathrm { \mathrm { \mathrm { \mathrm { V a R } } } } _ { \alpha } ( f ( D ( \pi _ { \theta } ) ) ) = \operatorname* { m i n } \{ z | F _ { D ( \pi _ { \theta } ) } ( f ^ { - 1 } ( z ) ) \le 1 - \alpha \} } \\ & { \mathrm { \mathrm { C V a R } } _ { \alpha } ( f ( D ( \pi _ { \theta } ) ) ) = \mathbb { E } _ { z \sim D ( \pi _ { \theta } ) } \{ f ( z ) | f ( z ) \ge \mathrm { \mathrm { V a R } } _ { \alpha } ( f ( D ( \pi _ { \theta } ) ) \} . } \end{array}
95
+ $$
96
+
97
+ Specially, we consider to take the opposite number of the return of a trajectory as its risk, i.e. $\dot { f } ( D ( \pi _ { \theta } \dot { ) } ) = - D ( \pi _ { \theta } )$ and we can prove that
98
+
99
+ $$
100
+ \begin{array} { r l } & { \quad \quad - \mathrm { V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) = \operatorname* { m a x } \{ z | F _ { D ( \pi _ { \theta } ) } ( z ) \leq 1 - \alpha \} , } \\ & { \quad \quad - \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) = \mathbb { E } _ { z \sim D ( \pi _ { \theta } ) } \{ z | z \leq - \mathrm { V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) \} . } \end{array}
101
+ $$
102
+
103
+ Based on equation (6), we have:
104
+
105
+ $$
106
+ \operatorname* { l i m } _ { \alpha \to 1 ^ { - } } - \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) = \operatorname* { m i n } ( D ( \pi _ { \theta } ) ) ,
107
+ $$
108
+
109
+ and if we assume that $- \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) \ge \beta $ , then we have:
110
+
111
+ $$
112
+ P ( D ( \pi _ { \theta } ) \leq \beta ) \leq 1 - \alpha .
113
+ $$
114
+
115
+ The proof of Theorem 1 is in Appendix B.1. By this theorem, we can use $- \mathrm { C V a R } _ { \alpha } \bigl ( - D ( \pi _ { \theta } ) \bigr )$ to represent the expected reward of the trajectories generated by $\pi _ { \theta }$ with relatively lower reward.
116
+
117
+ As mentioned in Section 2.1, some safe RL objectives, such as problems (2) and (3), are intractable max-min problems. However, with the property in Eq. (7) of CVaR, we can equally transform problem (2) as
118
+
119
+ $$
120
+ \operatorname* { m a x } _ { \theta } J _ { i n h } ( \pi _ { \theta } ) = \operatorname* { m a x } _ { \theta } \operatorname* { l i m } _ { \alpha 1 ^ { - } } [ - \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) ] .
121
+ $$
122
+
123
+ We can further loosen problem (8) by assigning $\alpha$ a fixed value, which reforms the original max-min problem into a solvable optimization problem. Furthermore, to address the pessimism in safe RL, we balance between the standard RL objective (1) and the safe RL objective (8) after relaxation, which yields the constrained optimization problem as
124
+
125
+ $$
126
+ \begin{array} { l } { \displaystyle \operatorname* { m a x } _ { \theta } J ( \pi _ { \theta } ) } \\ { \displaystyle s . t . - \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) \ge \beta , } \end{array}
127
+ $$
128
+
129
+ where $\alpha , \beta$ are hyper-parameters and we denote the best policy of problem (9) as $\pi _ { c } ( \alpha , \beta )$
130
+
131
+ Now we discuss some properties of $\pi _ { c } ( \alpha , \beta )$ . Since $\pi _ { c } ( \alpha , \beta )$ is the optimal solution of (9) and satisfies the constraints. By Theorem 1, we naturally have
132
+
133
+ $$
134
+ P ( D ( \pi _ { c } ( \alpha , \beta ) ) \leq \beta ) \leq 1 - \alpha ,
135
+ $$
136
+
137
+ which means that we can guarantee the probability of policy $\pi _ { c } ( \alpha , \beta )$ generating low-reward trajectories is below a desired threshold.
138
+
139
+ Compared with the best policy $\pi _ { s }$ of the standard RL problem (1), $\pi _ { c } ( \alpha , \beta )$ is the policy that maximizes the expected total reward in a restricted region related to hyper-parameters $\alpha , \beta$ . Obviously we have $J ( \pi _ { c } ( \tilde { \alpha , \beta } ) ) \le J ( \pi _ { s } )$ . However, we can also give a lower bound of $J ( \pi _ { c } ( \alpha , \beta ) )$ as follows:
140
+
141
+ Theorem 2. Assume there exists a constant $M > 0$ and every trajectory $\tau = ( S _ { 0 } , A _ { 0 } , R _ { 1 } , S _ { 1 } , A _ { 1 } , \ldots )$ satisfies $\textstyle \sum _ { t = 1 } ^ { \infty } \gamma ^ { t } R _ { t } \leq M$ , we have
142
+
143
+ $$
144
+ J ( \pi _ { c } ( \alpha , \beta ) ) \geq \frac { J ( \pi _ { s } ) - \alpha M } { 1 - \alpha } .
145
+ $$
146
+
147
+ The key of the proof is to consider whether $\pi _ { s }$ satisfies our constraint and the detailed proof of Theorem 2 can be found in Appendix B.2. Therefore, although $\pi _ { c } ( \alpha , \beta )$ is in a restricted region, its expected cumulative reward will be no worse than the lower bound we prove in Theorem 2.
148
+
149
+ # 3.2 OPTIMIZATION AND ALGORITHM
150
+
151
+ We now simplify the constrained problem (9) to an unconstrained one. First, with properties of CVaR, we can equivalently reformulate problem (9) as
152
+
153
+ $$
154
+ \begin{array} { l } { \displaystyle \operatorname* { m i n } _ { \theta , \nu } - J ( \pi _ { \theta } ) } \\ { \displaystyle s . t . \ - \nu + \frac { 1 } { 1 - \alpha } \mathbb { E } [ ( - D ( \pi _ { \theta } ) + \nu ) ^ { + } ] \leq - \beta . } \end{array}
155
+ $$
156
+
157
+ The deviation is provided in Appendix B.3. Then, by using Lagrangian relaxation method (Bertsekas, 1997), we need to solve the saddle point of the function $\bar { L } ( \theta , \bar { \nu } , \lambda )$ as
158
+
159
+ $$
160
+ \operatorname* { m a x } _ { \lambda \geq 0 } \operatorname* { m i n } _ { \theta , \nu } L ( \theta , \nu , \lambda ) \triangleq - J ( \pi _ { \theta } ) + \lambda \left( - \nu + \frac { 1 } { 1 - \alpha } \mathbb { E } [ ( - D ( \pi _ { \theta } ) + \nu ) ^ { + } ] + \beta \right) .
161
+ $$
162
+
163
+ For solving problem (11), we will extend Proximal Policy Optimization (PPO) (Schulman et al., 2017) with CVaR and propose our algorithm named CVaR Proximal Policy Optimization (CPPO). In particular, the key point of Policy Gradient methods is to evaluate the gradient (Sutton et al., 2000) of the objective. Here, we use methods in (Chow & Ghavamzadeh, 2014) to compute the gradient of our objective function (11) with respected to $\nu , \theta , \lambda$ as below:
164
+
165
+ $$
166
+ \partial _ { \nu } L ( \theta , \nu , \lambda ) = - \lambda + \frac { \lambda } { 1 - \alpha } \mathbb { E } _ { \xi \sim \pi _ { \theta } } \mathbf { 1 } \{ \nu \geq D ( \xi ) \} )
167
+ $$
168
+
169
+ $$
170
+ \begin{array} { l } { { \nabla _ { \theta } L ( \theta , \nu , \lambda ) = - \mathbb { E } _ { \xi \sim \pi _ { \theta } } ( \nabla _ { \theta } \log P _ { \theta } ( \xi ) ) \left( D ( \xi ) - \displaystyle \frac { \lambda } { 1 - \alpha } ( - D ( \xi ) + \nu ) ^ { + } \right) } } \\ { { \nabla _ { \lambda } L ( \theta , \nu , \lambda ) = - \nu + \displaystyle \frac { 1 } { 1 - \alpha } \mathbb { E } _ { \xi \sim \pi _ { \theta } } ( - D ( \xi ) + \nu ) ^ { + } + \beta . } } \end{array}
171
+ $$
172
+
173
+ The key of the deviation is to deform the objective in problem (11) as the integration of trajectories and the detailed calculation is in Appendix B.4. Moreover, with the increasing of policies’ performance during training, it’s unreasonable to fix $\beta$ to constrain the risk of the policy. Thus we consider to modify $\beta$ as a function of the risk of trajectories in the current epoch. Based on PPO and the algorithm by Chow & Ghavamzadeh (2014), we can use the gradient given above to develop an on-policy algorithm called CPPO (see Algorithm 1 in Appendix A).
174
+
175
+ # 4 THEORETICAL ANALYSIS
176
+
177
+ In this section, we analyze the robustness of policies against observation and transition perturbations, and explain why CVaR can improve the robustness of policies.
178
+
179
+ # 4.1 PERFORMANCE AGAINST OBSERVATION DISTURBANCE
180
+
181
+ For any MDP $\mathcal { M }$ and given policy $\pi$ , we denote its expected cumulative reward and value function as $J _ { \mathcal { M } } ( \pi )$ and $V _ { \mathcal { M } , \pi }$ , respectively. We define the Value Function Range (VFR) to capture the gap of the value function between the best state and the worst state as following.
182
+
183
+ Definition 2 (Value Function Range). For MDP $\mathcal { M }$ , we define the Value Function Range (VFR) of policy $\pi$ as
184
+
185
+ $$
186
+ \hat { V } _ { M , \pi } = \operatorname* { m a x } _ { s } V _ { M , \pi } ( s ) - \operatorname* { m i n } _ { s } V _ { M , \pi } ( s ) ,
187
+ $$
188
+
189
+ where $V _ { \mathcal { M } , \pi }$ is the value function (Sutton & Barto, 2018) of policy $\pi$ in MDP $\mathcal { M }$ .
190
+
191
+ Moreover, for every state $s \in \mathcal { M }$ , we can define its discounted future state distribution as $d _ { \mathcal { M } } ^ { \pi } ( s ) =$ $\begin{array} { r } { ( 1 - \gamma ) \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } \dot { P ( s _ { t } = s | \pi , { \mathcal { M } } ) } } \end{array}$ M . First, we will consider the situation of observation disturbance. Similar to the setting of SA-MDP (Zhang et al., 2020), we introduce adversary $\nu : \mathcal { S } \mathcal { S }$ to describe the disturbance of state and denote the policy disturbed by adversary $\nu$ as $\hat { \pi } _ { \nu }$ , which means ${ \hat { \pi } } _ { \nu } ( \cdot | s ) = \pi ( \cdot | \nu ( s ) )$ . We can theoretically calculate and bound the difference of performance between $\pi$ and $\hat { \pi } _ { \nu }$ in Theorem 3 as below:
192
+
193
+ Theorem 3. For any policy $\pi$ and any adversary $\nu$ , the reduction of expected cumulative reward of $\pi$ against the observation disturbance of $\nu$ is:
194
+
195
+ $$
196
+ \begin{array} { c } { { J _ { \mathcal { M } } ( \pi ) - J _ { \mathcal { M } } ( \hat { \pi } _ { \nu } ) = \displaystyle \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } } } \mathbb { E } _ { a \sim \pi ( \cdot \vert \nu ( s ) ) } \left( 1 - \displaystyle \frac { \pi ( a \vert s ) } { \pi ( a \vert \nu ( s ) ) } \right) \mathbb { E } _ { s ^ { \prime } \sim P } V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) } } \\ { { + \displaystyle \frac { 1 } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } } } \mathbb { E } _ { a \sim \pi ( \cdot \vert \nu ( s ) ) } \left( 1 - \displaystyle \frac { \pi ( a \vert s ) } { \pi ( a \vert \nu ( s ) ) } \right) R ( s , a ) . } } \end{array}
197
+ $$
198
+
199
+ Furthermore, an upper bound of it is as follows:
200
+
201
+ $$
202
+ \begin{array} { r l } & { | J _ { \mathcal M } ( \pi ) - J _ { \mathcal M } ( \hat { \pi } _ { \nu } ) | \le \displaystyle \frac { \gamma } { 1 - \gamma } \operatorname* { m a x } _ { s } D _ { T V } \big ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) \big ) \hat { V } _ { \mathcal M , \pi } } \\ & { \qquad + \displaystyle \frac { 2 } { 1 - \gamma } \operatorname* { m a x } _ { s } D _ { T V } \big ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) \operatorname* { m a x } _ { s , a } | R ( s , a ) | . } \end{array}
203
+ $$
204
+
205
+ The key of the proof is to analyze the relations of $V _ { \mathcal { M } , \hat { \pi } _ { \nu } } - V _ { \mathcal { M } , \pi }$ with different states and the complete proof of Theorem 3 is in Appendix B.5, resembling the proof by Kakade & Langford (2002). Moreover, for the upper bound, Theorem 3 provides a structurally homologous, but tighter bound than the bound provided in Zhang et al. (2020) since our VFR can be bounded by $\operatorname* { m a x } _ { s , a } | R ( s , a ) |$ , which is also proven in Appendix B.5. Compared with the victim policy $\pi$ for given MDP $\mathcal { M }$ , the factors mainly affect the performance of the disturbed policy $\pi _ { \nu }$ are Total Variation distance $\begin{array} { r } { \operatorname* { m a x } _ { s } D _ { T V } ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) } \end{array}$ and the VFR $\hat { V } _ { \mathcal { M } , \pi }$ . The former one, TV distance, depends on the victim policy $\pi$ as well as the disturbance $\nu$ and reflects the robustness of the victim policy and the adversarial ability of the adversary both. However, independent of the adversary, the latter one, VFR of the policy, only depends on the value functions of $\pi$ in $\mathcal { M }$ , reflecting the robustness of the victim policy. Thus we can improve the robustness under observation disturbance of the policy by controlling VFR of the policy.
206
+
207
+ # 4.2 PERFORMANCE AGAINST TRANSITION DISTURBANCE
208
+
209
+ Now, we consider the situation of transition disturbance. We assume that the transition $\mathcal { P }$ is disturbed to $\hat { \mathcal { P } }$ and attempt to evaluate the reduction of cumulative reward against the disturbance. Similar to Theorem 3, we can also theoretically show a similar result as below:
210
+
211
+ Theorem 4. For any policy $\pi$ in MDP $\mathcal { M } = ( S , \mathcal { A } , \mathcal { P } , \mathcal { R } , \gamma )$ and any disturbed environment $\hat { \mathcal { M } } = ( S , \mathcal { A } , \hat { \mathcal { P } } , \mathcal { R } , \gamma )$ , the reduction of cumulative reward against the transition disturbance is:
212
+
213
+ $$
214
+ J _ { \mathcal { M } } ( \pi ) - J _ { \hat { \mathcal { M } } } ( \pi ) = \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \hat { \mathcal { M } } } ^ { \pi } } \mathbb { E } _ { a \sim \pi } \mathbb { E } _ { s ^ { \prime } \sim \hat { P } } \left( 1 - \frac { P ( s ^ { \prime } | s , a ) } { \hat { P } ( s ^ { \prime } | s , a ) } \right) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) .
215
+ $$
216
+
217
+ Furthermore, an upper bound of the reduction is:
218
+
219
+ $$
220
+ J _ { \mathcal { M } } ( \pi ) - J _ { \hat { \mathcal { M } } } ( \pi ) \leq \frac { 2 \gamma } { 1 - \gamma } \operatorname* { m a x } _ { s , a } D _ { T V } ( P ( \cdot | s , a ) , \hat { P } ( \cdot | s , a ) ) \hat { V } _ { \mathcal { M } , \pi } .
221
+ $$
222
+
223
+ The proof of Theorem 4 is similar to that of Theorem 3 and is also deferred to Appendix B.5. Similarly, compared with the victim policy $\pi$ for a given MDP $\mathcal { M }$ , the factors that mainly affect the performance of $\pi$ in disturbed environment $\hat { \mathcal { M } }$ are TV distance $\begin{array} { r } { \operatorname* { m a x } _ { s , a } D _ { T V } ( P ( \cdot | s , a ) , \hat { P } ( \cdot | s , a ) ) } \end{array}$ and the VFR $\hat { V } _ { \mathcal { M } , \pi }$ . The former one, TV distance, depends on the range of transition disturbance and reflect the adversarial ability of the adversary, which cannot be controlled by safe RL. Nevertheless, the latter one VFR only depends on the value functions of $\pi$ in $\mathcal { M }$ and is an intrinsic property of the victim policy. Therefore, we can improve the robustness of the victim under transition disturbance policy by controlling $\hat { V } _ { \mathcal { M } , \pi }$ .
224
+
225
+ # 4.3 CONNECTION BETWEEN THE OBSERVATION AND TRANSITION DISTURBANCE
226
+
227
+ Observation disturbance and transition disturbance are structurally different, as they affect observation of the policy and MDP respectively. Although existing literature usually considers them separately, by Theorem 3 and Theorem 4, we can find out that the effects of them on cumulative reward are similarly depending on the VFR $\hat { V } _ { \mathcal { M } , \pi }$ , which is an inherent property of $\pi$ and independent of the adversary. Thus we can improve the robustness of the policy under observation disturbance as well as transition disturbance by controlling its VFR.
228
+
229
+ Moreover, we will discuss the connection between controlling the VFR $\hat { V } _ { \mathcal { M } , \pi }$ and CVaR-based RL. For controlling $\hat { V } _ { \mathcal { M } , \pi }$ , it’s more reasonable to maximize $\mathrm { m i n } _ { s } V _ { \mathcal { M } , \pi } ( s )$ rather than minimize $\operatorname* { m a x } _ { s } V _ { \mathcal { M } , \pi } ( s )$ . However, as mentioned in Sec 3.1, directly maximizing the value function of the worst state may cause our policy to be over conservative. Thus it’s more reasonable to loosen $\mathrm { m i n } _ { s } V _ { \mathcal { M } , \pi } ( s )$ to $- \mathrm { C V a R } _ { \alpha } ( - V ( s ) )$ , here $s \sim \mu ( \cdot )$ obeys the initial distribution of the environment. Our CVaR-based objective (9) imposes a constraint on $\dot { - } \mathrm { C V a R } _ { \alpha } ( - D ( \tau ) )$ since we can prove that
230
+
231
+ Theorem 5. For any $\alpha ~ \in ~ [ 0 , 1 ]$ , We can prove that $- \mathrm { C V a R } _ { \alpha } ( - D ( \tau ) )$ is a lower bound of $- \mathrm { C V a R } _ { \alpha } ( - V ( s ) )$ , i.e.
232
+
233
+ $$
234
+ - \operatorname { C V a R } _ { \alpha } ( - D ( \tau ) ) \leq - \operatorname { C V a R } _ { \alpha } ( - V ( s ) )
235
+ $$
236
+
237
+ The proof of Theorem 5 is deferred to Appendix B.6. Therefore, our CVaR-based methods consider to constrain $- \mathrm { C V a R } _ { \alpha } ( - D ( \tau ) )$ for improving VFR of the policy and further improve the robustness of the policy against observation disturbance as well as transition disturbance.
238
+
239
+ # 5 EXPERIMENTS
240
+
241
+ In this section, we empirically evaluate the performance and the robustness under observation disturbance and transition disturbance of our method CPPO in a series of continuous control tasks in MuJoCo (Todorov et al., 2012) against other common on-policy RL algorithms.
242
+
243
+ # 5.1 EXPERIMENT SETUP
244
+
245
+ Environments. We choose MuJoCo (Todorov et al., 2012) as our experiments environment. As a robotic locomotion simulator, MuJoCo has an array of different continuous control tasks such as Ant, Walker2d, HalfCheetah, Hopper, Swimmer and so on, which are widely used for the evaluation of RL algorithms.
246
+
247
+ Baselines and Codes. We will compare our algorithm with the common on-policy algorithms and previous CVaR-based algorithms. For the former, we choose Vanilla Policy Gradient (VPG) (Sutton et al., 2000), Trust Region Policy Optimization (TRPO) (Schulman et al., 2015) and PPO (Schulman et al., 2017). For the latter, we implement PG-CMDP (Chow & Ghavamzadeh, 2014) with deep neural network. And we use Adam (Kingma & Ba, 2015) to optimize all the parameters. The implementation of all codes, including CPPO and baselines, are based on SpinningUp (Achiam, 2018).
248
+
249
+ Evaluations. First, we compare the cumulative reward of each algorithm in the training process and their performance after convergence. For the trained models, in order to measure their robustness and safety, we compare their performance under transition disturbance and observation disturbance respectively. For observation disturbance, we apply Gaussian disturbance to the agent’s observation to study the relationship between the agent’s performance and the magnitude of the disturbance. For transition perturbation, since MuJoCo is a physical simulation engine and its transition is depend on its physics parameters, we choose to modify the mass of the agent to change the transition dynamics, and study the relationship between the the agent’s performance and the mass of the agent.
250
+
251
+ # 5.2 PERFORMANCE IN TRAINING STAGE
252
+
253
+ In this part, we compare the performance of our CPPO against common on-policy algorithms as well as the previous CVaR-based algorithm in MuJoCo environments such as Ant, Halfcheetah, Walker2d, Swimmer and Hopper. For each algorithm in each task, we train 10 policies with different random seeds since the environment and environments and policies are stochastic. Table 1 shows the mean and variance of the cumulative reward of 10 policies trained by each algorithm in each environment and we bold the highest cumulative reward over all algorithms. For each algorithm in each task, we also plot the mean and variance of the ten policies as a function of timesteps in the training stage as shown in Figure 1. The four subgraphs represent the experimental results on Halfcheetah, Walker2d, Swimmer and Hopper respectively. The solid line represents the average reward of 10 strategies, and the part with lighter color represents the variance of them. As we can see from the figure, CPPO represented by pink has achieved significant performance improvement on HalfCheetah, Swimmer and Hopper against all baselines. We can also find that our CPPO gain higher cumulative reward of the worst-case outcome than other baselines on Walker2d.
254
+
255
+ Table 1: The cumulative reward (mean $\pm$ one std) of best policy trained by VPG, TRPO, PPO and CPPO in different MuJoCo games. In each column we bold the best performance over all algorithms.
256
+
257
+ <table><tr><td>Env Method</td><td>Ant-v3</td><td>HalfCheetah-v3</td><td>Walker2d-v3</td><td>Swimmer-v3</td><td>Hopper-v3</td></tr><tr><td>VPG</td><td>12.8± 0.0</td><td>896.9± 531.1</td><td>628.6± 229.4</td><td>48.3±11.3</td><td>888.4± 209.5</td></tr><tr><td>TRPO</td><td>1625.4± 356.4</td><td>2073.8± 741.3</td><td>2005.6± 398.7</td><td>101.2± 29.3</td><td>2391.4± 455.3</td></tr><tr><td>PPO</td><td>3372.2± 301.4</td><td>3245.4± 947.3</td><td>2946.3± 944.3</td><td>122.0± 7.9</td><td>2726.0± 886.0</td></tr><tr><td>PG-CMDP</td><td>7.4± 3.6</td><td>928.7± 562.9</td><td>596.7± 219.9</td><td>55.4±18.8</td><td>1039.2± 21.1</td></tr><tr><td>CPPO(ours)</td><td>3514.7± 247.2</td><td>3680.5± 1121.3</td><td>3194.0± 648.2</td><td>182.5± 46.0</td><td>3144.6± 158.4</td></tr></table>
258
+
259
+ ![](images/fa57bb7185adf70d242296aa3c9813877e682d3359fe59ab054f52023811c0fc.jpg)
260
+ Figure 1: Cumulative reward curves for VPG, TRPO, PPO and our CPPO. The x-axes indicate the number of steps interacting with the environment, and the y-axes indicate the performance of the agent, including average rewards with standard deviations.
261
+
262
+ # 5.3 ROBUSTNESS AGAINST OBSERVATION DISTURBANCE IN TEST STAGE
263
+
264
+ Trained agents may failed in the test stage because of the gap between the observation and the true state. Consequently, for evaluating the robustness of each algorithm, we add standard Gaussian disturbance to the observation in the test stage. For this purpose, we plot the performance of the trained policies under observation disturbance in Figure 2. In each subfigure, the solid line and the part with lighter color represent the average reward and the variance of 10 strategies respectively. From the figure, we can found that the performance degradation is positively related to the size of disturbance, which is shown in Theorem 3. Moreover, since the value function of all states in these policies are relatively low and VFR of these policies is low, we can discover that VPG and PG-CMDP stay robustness under observation disturbance, which is shown in Theorem 3. As shown in the figure, CPPO has made significant progress in Swimmer and Hopper than baselines. Therefore, our CPPO enables to keep robustness under observation disturbance.
265
+
266
+ # 5.4 ROBUSTNESS AGAINST TRANSITION DISTURBANCE IN TEST STAGE
267
+
268
+ Trained agents may also fail in testing stage because of the transition gap between the simulator and the true environment. Therefore, we evaluate the performance of all algorithms under the transition disturbance for measuring their robustness and safety. Since MuJoCo is a physics simulator modeled on the physical world, we can disturb the transition by modifying environment parameters. For this purpose, we choose to modify the mass of the robot and the default mass of environment HalfCheetah,
269
+
270
+ ![](images/f4822a83cf93c271b13703604ab937eedb96ad06eec90440e125e24636abb006.jpg)
271
+ Figure 2: Cumulative reward curves for VPG, TRPO, PPO and our CPPO under observation disturbance. The $\mathbf { X }$ -axes indicate the range of the disturbance, and the y-axes indicate the average performance of the algorithm under the state disturbance.
272
+
273
+ ![](images/8e55fd023f0b068eba0fc38e573d92c258c04a403d5f03ca4efe811d8b1296d7.jpg)
274
+ Figure 3: Cumulative reward curves for VPG, TRPO, PPO and our CPPO under transition disturbance. The $\mathbf { X }$ -axes indicate the mass of the agent, and the y-axes indicate the average performance of the algorithm when the mass changes.
275
+
276
+ Walker2d, Swimmer and Hopper are 6.36, 3.53, 34.6 and 3.53 respectively. Therefore, we draw Figure 3 to describe the results of agents, which are trained under standard mass condition and tested under different mass conditions. The solid line represents the average reward of 10 strategies, and the part with lighter color represents the variance of them. As seen in this figure, the performance of all algorithms decreases to a certain extent with the change of agent quality (whether it becomes larger or smaller) and the degree of decline is positively correlated with the quality change, which is consistent with our theoretical analysis in Theorem 4, that is, the upper bound of the performance difference of the algorithm is related to the size of the transition disturbance. Similar to the result under observation disturbance, we can can discover that VPG and PG-CMDP stay robustness under transition disturbance since their VFR is low, which is also shown in Theorem 4. At the same time, we can also see that CPPO achieve higher outcome in different tasks, specially in Swimmer and Hopper. It indicates that our method can improve the robustness of policies under transition disturbance.
277
+
278
+ # 6 CONCLUSIONS
279
+
280
+ In this paper, we analyze the advantages of CVaR for evaluating the risk of policy compared with the worst-case outcome as well as the variance of the return. Furthermore, we consider a risk-sensitive optimization objective and propose CPPO to solve it. Moreover, we provide theoretical connection of policies’ robustness against observation disturbance and transition disturbance, which are structurally different. By introducing the notion of value function range (VFR), we indicate that our CPPO can improve the robustness of policies. Finally, we evaluate our algorithms in various MuJoCo tasks and show that CPPO obtains better performance as well as stronger robustness than various strong competitors.
281
+
282
+ # REPRODUCIBILITY STATEMENT
283
+
284
+ We ensure the reproducibility of our paper from two aspects. (1) Experiment: The implementation and result of our experiment are described in Sec. 5. (2) Theory and Method: We provide the pseudo code of our algorithm in Appendix A. We also provide complete proofs of all the theoretical results mentioned in the paper in Appendix B.
285
+
286
+ # ETHICS STATEMENT
287
+
288
+ Deep reinforcement learning may encounter catastrophic failures due to the stochasticity. It is very imperative to develop safe reinforcement learning algorithms. This paper proposes a CPPO method to improve the robustness under observation and transition disturbance. Also, this paper provides theoretical analysis of the connection between observation and transition disturbance. It may promote the development of safe and reliable reinforcement learning algorithms in the future.
289
+
290
+ # REFERENCES
291
+
292
+ Joshua Achiam. Spinning Up in Deep Reinforcement Learning. 2018. 5.1
293
+
294
+ Gordon J Alexander and Alexandre M Baptista. A comparison of var and cvar constraints on portfolio selection with the mean-variance model. Management Science, 50(9):1261–1273, 2004. 1, 2.2
295
+
296
+ Siddharth Alexander, Thomas F Coleman, and Yuying Li. Minimizing cvar and var for a portfolio of derivatives. Journal of Banking & Finance (JBF), 30(2):583–605, 2006. 1, 2.2
297
+
298
+ Dimitri P Bertsekas. Nonlinear programming. Journal of the Operational Research Society (JORS), 48(3):334–334, 1997. 3.2
299
+
300
+ Yinlam Chow and Mohammad Ghavamzadeh. Algorithms for cvar optimization in mdps. In Proceedings of the 27th International Conference on Neural Information Processing Systems (NeurIPS), pp. 3509–3517, 2014. 2.2, 2.2, 3.2, 3.2, 5.1, B.4
301
+
302
+ Yinlam Chow, Aviv Tamar, Shie Mannor, and Marco Pavone. Risk-sensitive and robust decisionmaking: a cvar optimization approach. Advances in Neural Information Processing Systems (NeurIPS), 28:1522–1530, 2015. 2.2, 2.2, B.3
303
+
304
+ Yinlam Chow, Mohammad Ghavamzadeh, Lucas Janson, and Marco Pavone. Risk-constrained reinforcement learning with percentile risk criteria. The Journal of Machine Learning Research (JMLR), 18(1):6070–6120, 2017. 2.2
305
+
306
+ Stefano P Coraluppi and Steven I Marcus. Risk-sensitive and minimax control of discrete-time, finite-state markov decision processes. Automatica, 35(2):301–309, 1999. 1, 2.1
307
+
308
+ Javier Garcıa and Fernando Fernandez. A comprehensive survey on safe reinforcement learning. ´ Journal of Machine Learning Research (JMLR), 16(1):1437–1480, 2015. 1, 2.1
309
+
310
+ Chris Gaskett. Reinforcement learning under circumstances beyond its control. Proceedings of the International Conference on Computational Intelligence for Modelling Control and Automation, 2003. 2.1, 2.1
311
+
312
+ Peter Geibel and Fritz Wysotzki. Risk-sensitive reinforcement learning applied to control under constraints. Journal of Artificial Intelligence Research (JAIR), 24:81–108, 2005. 1
313
+
314
+ Abhijit Gosavi. Reinforcement learning for model building and variance-penalized control. In Proceedings of the 2009 Winter Simulation Conference (WSC), pp. 373–379. IEEE, 2009. 1, 2.1
315
+
316
+ Matthias Heger. Consideration of risk in reinforcement learning. In Machine Learning Proceedings 1994, pp. 105–111. Elsevier, 1994. 1, 2.1, 2.1, 2.1
317
+
318
+ Ronald A Howard and James E Matheson. Risk-sensitive markov decision processes. Management Science, 18(7):356–369, 1972. 2.1
319
+
320
+ Sandy Huang, Nicolas Papernot, Ian Goodfellow, Yan Duan, and Pieter Abbeel. Adversarial attacks on neural network policies. arXiv preprint arXiv:1702.02284, 2017. 1
321
+
322
+ Sham Kakade and John Langford. Approximately optimal approximate reinforcement learning. In In Proc. 19th International Conference on Machine Learning (ICML). Citeseer, 2002. 4.1
323
+
324
+ Alex Kendall, Jeffrey Hawke, David Janz, Przemyslaw Mazur, Daniele Reda, John-Mark Allen, Vinh-Dieu Lam, Alex Bewley, and Amar Shah. Learning to drive in a day. In 2019 International Conference on Robotics and Automation (ICRA), pp. 8248–8254. IEEE, 2019. 1
325
+
326
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015. URL http://arxiv.org/abs/ 1412.6980. 5.1
327
+
328
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013. 1
329
+
330
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A. Rusu, Joel Veness, Marc G. Bellemare, Alex Graves, Martin A. Riedmiller, Andreas Fidjeland, Georg Ostrovski, Stig Petersen, Charles Beattie, Amir Sadik, Ioannis Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra, Shane Legg, and Demis Hassabis. Human-level control through deep reinforcement learning. Nature, 518(7540):529–533, 2015. URL https://doi.org/10.1038/nature14236. 1
331
+
332
+ Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International conference on machine learning (ICML), pp. 1928–1937. PMLR, 2016. 1
333
+
334
+ Arnab Nilim and Laurent El Ghaoui. Robust control of markov decision processes with uncertain transition matrices. Operations Research, 53(5):780–798, 2005. 2.1
335
+
336
+ R Tyrrell Rockafellar, Stanislav Uryasev, et al. Optimization of conditional value-at-risk. B.3
337
+
338
+ Makoto Sato, Hajime Kimura, and Shibenobu Kobayashi. Td algorithm for the variance of return and mean-variance reinforcement learning. Transactions of the Japanese Society for Artificial Intelligence (JSAI), 16(3):353–362, 2001. 2.1
339
+
340
+ John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In International conference on machine learning (ICML), pp. 1889–1897. PMLR, 2015. 5.1
341
+
342
+ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017. 1, 3.2, 5.1
343
+
344
+ David Silver, Aja Huang, Chris J. Maddison, Arthur Guez, Laurent Sifre, George van den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Vedavyas Panneershelvam, Marc Lanctot, Sander Dieleman, Dominik Grewe, John Nham, Nal Kalchbrenner, Ilya Sutskever, Timothy P. Lillicrap, Madeleine Leach, Koray Kavukcuoglu, Thore Graepel, and Demis Hassabis. Mastering the game of go with deep neural networks and tree search. Nature, 529(7587):484–489, 2016. URL https://doi.org/10.1038/nature16961. 1
345
+
346
+ Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018. 2
347
+
348
+ Richard S Sutton, David A McAllester, Satinder P Singh, and Yishay Mansour. Policy gradient methods for reinforcement learning with function approximation. In Advances in neural information processing systems (NeurIPS), pp. 1057–1063, 2000. 3.2, 5.1
349
+
350
+ Giorgio Szego. Measures of risk. ¨ Journal of Banking & finance (JBF), 26(7):1253–1272, 2002. 1, 2.1
351
+
352
+ Aviv Tamar, Dotan Di Castro, and Shie Mannor. Policy gradients with variance related risk criteria. In Proceedings of the 29th International Coference on International Conference on Machine Learning (ICML), pp. 1651–1658, 2012. 1, 2.1
353
+
354
+ Aviv Tamar, Huan Xu, and Shie Mannor. Scaling up robust mdps by reinforcement learning. arXiv preprint arXiv:1306.6189, 2013. 2.1
355
+
356
+ 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, pp. 5026–5033. IEEE, 2012. 1, 5, 5.1
357
+
358
+ Huan Zhang, Hongge Chen, Chaowei Xiao, Bo Li, Mingyan Liu, Duane Boning, and Cho-Jui Hsieh. Robust deep reinforcement learning against adversarial perturbations on state observations. Advances in Neural Information Processing Systems (NeurIPS), 33:21024–21037, 2020. 4.1, 4.1, B.5
359
+
360
+ # A PSEUDO CODE OF CPPO
361
+
362
+ Algorithm 1 CVaR Proximal Policy Optimization(CPPO)
363
+
364
+ Require: confidence level $\alpha$ and reward tolerance $\beta$ , learning rate $l r _ { \eta } , l r _ { \theta } , l r _ { \lambda } , l r _ { \phi }$
365
+
366
+ Ensure: $\theta$ of parameterized policy $\pi _ { \theta }$ (always be random policy), $\phi$ of parameterized value function $V _ { \phi }$ .
367
+
368
+ for $k = 1 , 2 , . . . , N _ { i t e r }$ do
369
+
370
+ Generate $N$ trajectories $\mathcal { D } _ { k } = \{ \xi _ { i } \} _ { i = 1 } ^ { N }$ by following the current policy $\pi _ { \theta }$ .
371
+
372
+ Compute reward $\hat { R } _ { i } ^ { t }$ of each state $s _ { i , t }$ in each trajectory $\xi _ { i }$ and the cumulative reward $D ( \xi _ { i } )$
373
+
374
+ Compute advantage estimates $\hat { A } _ { i } ^ { t }$ of each state $s _ { i , t }$ in each trajectory $\xi _ { i }$
375
+
376
+ Update parameters respectively:
377
+
378
+ $$
379
+ \begin{array} { l } { \displaystyle \eta \gets \eta - l r _ { 0 } \left( - \lambda + \frac { \lambda } { N ( 1 - \alpha ) } \sum _ { i = 1 } ^ { N } \{ \{ \eta \geq D ( \xi _ { i } ) \} \} \right) } \\ { \displaystyle \theta \gets \theta + l r _ { 0 } \frac { 1 } { N T } \sum _ { i = 1 } ^ { N } \sum _ { t = 1 } ^ { T } \nabla _ { \theta } \operatorname* { m i n } \left( \frac { \pi _ { \theta } ( \alpha _ { i } ^ { t } | \xi _ { i } ^ { t } ) } { \pi _ { \theta } ( \alpha _ { i } ^ { t } | \alpha _ { i } ^ { t } | \xi _ { i } ^ { t } ) } \mathring { A } _ { t } ^ { t } , g ( \epsilon , \hat { A } _ { i } ^ { t } ) \right) } \\ { \displaystyle \qquad - l r _ { \theta } \frac { 1 } { N } \sum _ { i = 1 } ^ { N } ( \nabla _ { \theta } \log P _ { \theta } ( \xi _ { i } ) ) \frac { 1 } { 1 - \alpha } ( - D ( \xi _ { i } ) + \eta ) \mathbf { 1 } \{ \eta \geq D ( \xi _ { i } ) \} } \\ { \displaystyle \lambda \gets \lambda + l r _ { \lambda } \left( - \eta + \frac { \sum _ { i = 1 } ^ { N } ( - D ( \xi _ { i } ) + \eta ) ^ { + } } { N ( 1 - \alpha ) } + \beta \right) } \\ { \displaystyle \phi \gets \phi + l r _ { \theta } \left( \frac { 1 } { N T } \sum _ { i = 1 } ^ { N } \sum _ { t = 1 } ^ { T } ( \zeta _ { \zeta } ( s _ { i , t } ) - \hat { R } _ { i } ^ { t } ) \nabla _ { \theta } \nu _ { \theta } ( s _ { i , t } ) \right) } \end{array}
380
+ $$
381
+
382
+ Modify $\beta$ as a function of the return of current trajectories:
383
+
384
+ $$
385
+ \beta g ( \xi _ { 1 } , \xi _ { 2 } , . . . , \xi _ { N } )
386
+ $$
387
+
388
+ # end for
389
+
390
+ # B PROOFS OF THEOREMS
391
+
392
+ In this section, we will provide the proofs of theorems proposed in the paper.
393
+
394
+ # B.1 THE PROOF OF THEOREM 1
395
+
396
+ Proof. By definition of VaR and CVaR, we have:
397
+
398
+ $$
399
+ F _ { f ( D ( \pi _ { \theta } ) ) } ( z ) = P ( f ( D ( \pi _ { \theta } ) ) \leq z ) = P ( D ( \pi _ { \theta } ) \geq f ^ { - 1 } ( z ) ) = 1 - F _ { D ( \pi _ { \theta } ) } ( f ^ { - 1 } ( z ) ) ,
400
+ $$
401
+
402
+ $$
403
+ \begin{array} { r l } & { \mathrm { V a R } _ { \alpha } ( f ( D ( \pi _ { \theta } ) ) ) = \operatorname* { m i n } \{ z | F _ { f ( D ( \pi _ { \theta } ) ) } ( z ) \ge \alpha \} } \\ & { \quad \quad \quad = \operatorname* { m i n } \{ z | 1 - F _ { D ( \pi _ { \theta } ) } ( f ^ { - 1 } ( z ) ) \ge \alpha \} } \\ & { \quad \quad \quad = \operatorname* { m i n } \{ z | F _ { D ( \pi _ { \theta } ) } ( f ^ { - 1 } ( z ) ) \le 1 - \alpha \} , } \end{array}
404
+ $$
405
+
406
+ $$
407
+ \begin{array} { r l } & { \mathrm { C V a R } _ { \alpha } ( f ( D ( \pi _ { \theta } ) ) ) = \mathbb { E } _ { w \sim f ( D ( \pi _ { \theta } ) ) } \{ w | w \ge \mathrm { V a R } _ { \alpha } ( f ( D ( \pi _ { \theta } ) ) ) \} } \\ & { \quad \quad \quad = \mathbb { E } _ { z \sim D ( \pi _ { \theta } ) } \{ f ( z ) | f ( z ) \ge \mathrm { V a R } _ { \alpha } ( f ( D ( \pi _ { \theta } ) ) \} . } \end{array}
408
+ $$
409
+
410
+ When we set $f ( Z ) = - Z$ , we can naturally prove that
411
+
412
+ $$
413
+ \begin{array} { r l } & { - \mathrm { V a R } _ { \alpha } ( - Z ) = - \operatorname* { m i n } \{ z | F _ { Z } ( - z ) \le 1 - \alpha \} } \\ & { \qquad = - \operatorname* { m i n } \{ z | 1 - F _ { Z } ( - z ) \ge \alpha \} } \\ & { \qquad = \operatorname* { m a x } \{ - z | 1 - F _ { Z } ( - z ) \ge \alpha \} } \\ & { \qquad = \operatorname* { m a x } \{ z | F _ { Z } ( z ) \le 1 - \alpha \} , } \end{array}
414
+ $$
415
+
416
+ $$
417
+ \begin{array} { r l } & { - \mathrm { C V a R } _ { \alpha } ( - Z ) = - \mathbb { E } _ { z \sim Z } \{ - z | - z \ge \mathrm { V a R } _ { \alpha } ( - Z ) \} . } \\ & { \qquad = \mathbb { E } _ { z \sim Z } \{ z | - z \ge \mathrm { V a R } _ { \alpha } ( - Z ) \} } \\ & { \qquad = \mathbb { E } _ { z \sim Z } \{ z | z \le - \mathrm { V a R } _ { \alpha } ( - Z ) \} . } \end{array}
418
+ $$
419
+
420
+ If we assume that $- \mathrm { C V a R } _ { \alpha } ( - Z ) \geq \beta$ , then we have:
421
+
422
+ $$
423
+ \begin{array} { r l } & { P ( Z \leq \beta ) \leq P ( Z \leq - \mathrm { C V a R } _ { \alpha } ( - Z ) ) } \\ & { \qquad = P ( Z \leq \mathbb { E } _ { w \sim Z } \{ w | w \leq - \mathrm { V a R } _ { \alpha } ( - Z ) \} ) } \\ & { \qquad = P ( Z \leq - \mathrm { V a R } _ { \alpha } ( - Z ) ) } \\ & { \qquad = P ( Z \leq \operatorname* { m a x } \{ z | F _ { Z } ( z ) \leq 1 - \alpha \} ) } \\ & { \qquad = 1 - \alpha . } \end{array}
424
+ $$
425
+
426
+ So we have proven it.
427
+
428
+ # B.2 THE PROOF OF THEOREM 2
429
+
430
+ Proof. Since we assume $M$ is the upper bound of the total reward of every trajectory, we have $J ( \pi _ { s } ) \le M$ . We consider two scenarios.
431
+
432
+ In the first case, if $\pi _ { s }$ satisfies that $- C V a R _ { \alpha } ( - D ( \pi _ { s } ) ) \ge \beta$ . Obviously, we have $\pi _ { c } ( \alpha , \beta ) = \pi _ { s }$ thus
433
+
434
+ $$
435
+ J ( \pi _ { c } ( \alpha , \beta ) ) = J ( \pi _ { s } ) \ge \frac { J ( \pi _ { s } ) - \alpha M } { 1 - \alpha } .
436
+ $$
437
+
438
+ Otherwise, we assume that $- \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { s } ) ) < \beta$ , Since $- \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { c } ( \alpha , \beta ) ) ) \ge \beta$ , we set $B = - V a R _ { \alpha } ( - D ( \pi _ { c } ( \alpha , \beta ) ) )$ and have:
439
+
440
+ $$
441
+ \begin{array} { r l } & { J ( \pi _ { c } ( \alpha , \beta ) ) = \displaystyle \int _ { \tau \sim \pi _ { c } ( \alpha , \beta ) } p ( \tau ) D ( \tau ) d \tau } \\ & { \quad \quad \quad = \displaystyle \int _ { D ( \tau ) \leq B } p ( \tau ) D ( \tau ) d \tau + \displaystyle \int _ { D ( \tau ) > B } p ( \tau ) D ( \tau ) d \tau } \\ & { \quad \quad \quad \geq - \alpha C V a R ( - D ( \pi _ { c } ( \alpha , \beta ) ) ) + \displaystyle \int _ { D ( \tau ) > B } p ( \tau ) B d \tau } \\ & { \quad \quad \quad \geq A \alpha + A ( 1 - \alpha ) } \\ & { \quad \quad = \beta . } \end{array}
442
+ $$
443
+
444
+ By the similar way, we set:
445
+
446
+ $$
447
+ \begin{array} { r } { A = - \operatorname { V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) = \operatorname* { m a x } \{ z | F _ { D ( \pi _ { \theta } ) } ( z ) \le 1 - \alpha \} , } \end{array}
448
+ $$
449
+
450
+ thus
451
+
452
+ $$
453
+ \begin{array} { r l } { J ( \pi _ { s } ) = \displaystyle \int _ { \tau \sim \pi _ { s } } p ( \tau ) D ( \tau ) d \tau } \\ { \displaystyle } & { \phantom { = } = \displaystyle \int _ { D ( \tau ) \leq A } p ( \tau ) D ( \tau ) d \tau + \displaystyle \int _ { D ( \tau ) > A } p ( \tau ) D ( \tau ) d \tau } \\ { \displaystyle } & { \phantom { = } = \displaystyle \int _ { D ( \tau ) \leq A } p ( \tau ) A d \tau + \displaystyle \int _ { D ( \tau ) > A } p ( \tau ) M d \tau } \\ { \displaystyle } & { \phantom { = } = A ( 1 - \alpha ) + M \alpha } \\ { \displaystyle } & { \phantom { = } < \beta ( 1 - \alpha ) + M \alpha } \\ { \displaystyle } & { \leq J ( \pi _ { c } ( \alpha , \beta ) ) ( 1 - \alpha ) + M \alpha . } \end{array}
454
+ $$
455
+
456
+ So we have proven J(πc(α, β)) ≥ J(πs)−αM1−α .
457
+
458
+ # B.3 THE PROOF OF EQUIVALENTLY DEFORMING PROBLEM (9)
459
+
460
+ In this part, we will equivalently deforming problem (9) as
461
+
462
+ $$
463
+ \begin{array} { r l } { \underset { \theta } { \operatorname* { m a x } } J ( \pi _ { \theta } ) } & { s . t . - \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) \geq \beta } \\ { \Leftrightarrow \underset { \theta } { \operatorname* { m i n } } - J ( \pi _ { \theta } ) } & { s . t . \mathrm { C V a R } _ { \alpha } ( - D ( \pi _ { \theta } ) ) \leq - \beta } \\ { \overset { 1 } { \Leftrightarrow } \underset { \theta } { \operatorname* { m i n } } - J ( \pi _ { \theta } ) } & { s . t . \underset { \nu \in R } { \operatorname* { m i n } } \{ \nu + \frac { 1 } { 1 - \alpha } \mathbb { E } [ ( - D ( \pi _ { \theta } ) - \nu ) ^ { + } ] \} \leq - \beta } \\ { \Leftrightarrow \underset { \theta } { \operatorname* { m i n } } - J ( \pi _ { \theta } ) } & { s . t . \underset { \nu \in R } { \operatorname* { m i n } } \{ - \nu + \frac { 1 } { 1 - \alpha } \mathbb { E } [ ( - D ( \pi _ { \theta } ) + \nu ) ^ { + } ] \} \leq - \beta } \\ { \Leftrightarrow \underset { \theta , \nu } { \operatorname* { m i n } } - J ( \pi _ { \theta } ) } & { s . t . - \nu + \frac { 1 } { 1 - \alpha } \mathbb { E } [ ( - D ( \pi _ { \theta } ) + \nu ) ^ { + } ] \leq - \beta . } \end{array}
464
+ $$
465
+
466
+ Here we derive a formula 1 since CVaR owns the property (Rockafellar et al.; Chow et al., 2015):
467
+
468
+ $$
469
+ \operatorname { C V a R } _ { \alpha } ( Z ) = \operatorname* { m i n } _ { \eta \in R } \left\{ \eta + { \frac { 1 } { 1 - \alpha } } \mathbb { E } [ ( Z - \eta ) ^ { + } ] \right\} .
470
+ $$
471
+
472
+ So we have proven it.
473
+
474
+ # B.4 CALCULATING THE GRADIENT OF $L ( \theta , \nu , \lambda )$
475
+
476
+ In this part, we will calculate the gradient $\partial _ { \nu } L ( \theta , \nu , \lambda ) , \bigtriangledown _ { \theta } L ( \theta , \nu , \lambda )$ and $\bigtriangledown \lambda L ( \theta , \nu , \lambda )$ of the function $L ( \bar { \theta } , \nu , \lambda )$ by using the methods in (Chow $\&$ Ghavamzadeh, 2014):
477
+
478
+ $$
479
+ L ( \theta , \nu , \lambda ) = - J ( \pi _ { \theta } ) + \lambda ( - \nu + { \frac { 1 } { 1 - \alpha } } \mathbb { E } [ ( - D ( \pi _ { \theta } ) + \nu ) ^ { + } ] + \beta ) .
480
+ $$
481
+
482
+ First we can expand the expectation as
483
+
484
+ $$
485
+ \begin{array} { l } { { \displaystyle { \cal L } ( \theta , \nu , \lambda ) = - J ( \pi _ { \theta } ) + \lambda ( - \nu + \frac { 1 } { 1 - \alpha } \mathbb { E } [ ( - D ( \pi _ { \theta } ) + \nu ) ^ { + } ] + \beta ) } } \\ { { \displaystyle ~ = - \sum _ { \xi } P _ { \theta } ( \xi ) D ( \xi ) - \lambda \nu + \frac { \lambda } { 1 - \alpha } \sum _ { \xi } P _ { \theta } ( \xi ) ( - D ( \xi ) + \nu ) ^ { + } + \lambda \beta . } } \end{array}
486
+ $$
487
+
488
+ We can see that $P _ { \theta } ( \xi )$ will only depend on $\theta$ and $\xi$ , so we have easily calculate the gradient of $\lambda$ as
489
+
490
+ $$
491
+ \begin{array} { l } { \nabla _ { \lambda } L ( \theta , \nu , \lambda ) = - \nu + \displaystyle \frac { 1 } { 1 - \alpha } \sum _ { \xi } P _ { \theta } ( \xi ) ( - D ( \xi ) + \nu ) ^ { + } + \beta } \\ { = - \nu + \displaystyle \frac { 1 } { 1 - \alpha } \mathbb { E } _ { \xi \sim \pi _ { \theta } } ( - D ( \xi ) + \nu ) ^ { + } + \beta . } \end{array}
492
+ $$
493
+
494
+ Then we calculate the gradient of $\nu$ . Since $( D ( \xi ) - \nu ) ^ { + }$ isn’t differentiable to $\nu$ at the point of $\nu = D ( \xi )$ , so we consider its semi gradient as
495
+
496
+ $$
497
+ \partial _ { \nu } ( - D ( \xi ) + \nu ) ^ { + } = \left\{ \begin{array} { l l } { 0 } & { \nu < D ( \xi ) } \\ { q ( 0 \le q \le 1 ) } & { \nu = D ( \xi ) } \\ { 1 } & { \nu > D ( \xi ) } \end{array} \right.
498
+ $$
499
+
500
+ And we can calculate the gradient of $\nu$ as below:
501
+
502
+ $$
503
+ \begin{array} { l } { { \displaystyle \partial _ { \nu } L ( \theta , \nu , \lambda ) = - \lambda + \frac { \lambda } { 1 - \alpha } \sum _ { \xi } P _ { \theta } ( \xi ) \partial _ { \nu } ( - D ( \xi ) + \nu ) ^ { + } } } \\ { { \displaystyle \qquad = - \lambda + \frac { \lambda } { 1 - \alpha } \sum _ { \xi } P _ { \theta } ( \xi ) \mathbf { 1 } \{ \nu > D ( \xi ) \} + \frac { \lambda q } { 1 - \alpha } \sum _ { \xi } P _ { \theta } ( \xi ) \mathbf { 1 } \{ \nu = D ( \xi ) \} } } \\ { { \displaystyle \qquad = - \lambda + \frac { \lambda } { 1 - \alpha } \sum _ { \xi } P _ { \theta } ( \xi ) \mathbf { 1 } \{ \nu \geq D ( \xi ) \} \quad ( l e t q = 1 ) } } \\ { { \displaystyle \qquad = - \lambda + \frac { \lambda } { 1 - \alpha } \mathbb { E } _ { \xi \sim \pi _ { \theta } } \mathbf { 1 } \{ \nu \geq D ( \xi ) \} ) . } } \end{array}
504
+ $$
505
+
506
+ Finally, we will calculate the gradient of $\theta$ as
507
+
508
+ $$
509
+ \begin{array} { l } { \displaystyle \nabla _ { \theta } L ( \theta , \nu , \lambda ) = - \sum _ { \xi } \nabla _ { \theta } P _ { \theta } ( \xi ) D ( \xi ) + \frac { \lambda } { 1 - \alpha } \sum _ { \xi } \nabla _ { \theta } P _ { \theta } ( \xi ) ( - D ( \xi ) + \nu ) ^ { + } } \\ { \displaystyle = \sum _ { \xi } \nabla _ { \theta } P _ { \theta } ( \xi ) ( - D ( \xi ) + \frac { \lambda } { 1 - \alpha } ( - D ( \xi ) + \nu ) \mathbf { 1 } \{ \nu \geq D ( \xi ) \} ) } \\ { \displaystyle = \sum _ { \xi } ( \nabla _ { \theta } \log P _ { \theta } ( \xi ) ) P _ { \theta } ( \xi ) ( - D ( \xi ) + \frac { \lambda } { 1 - \alpha } ( - D ( \xi ) + \nu ) \mathbf { 1 } \{ \nu \geq D ( \xi ) \} ) } \\ { \displaystyle = - \sum _ { \xi } ( \nabla _ { \theta } \log P _ { \theta } ( \xi ) ) P _ { \theta } ( \xi ) D ( \xi ) + \sum _ { \xi } ( \nabla _ { \theta } \log P _ { \theta } ( \xi ) ) P _ { \theta } ( \xi ) \frac { \lambda ( \nu - D ( \xi ) ) } { 1 - \alpha } \mathbf { 1 } \{ \nu \geq D ( \xi ) \} } \\ { \displaystyle = - \sum _ { \xi } \nabla _ { \theta } \log P _ { \theta } ( \xi ) ( \xi ) \frac { \lambda } { 1 - \alpha } \left( \frac { \lambda } { 1 - \alpha } ( - D ( \xi ) + \nu ) ^ { + } \right) . } \end{array}
510
+ $$
511
+
512
+ So we have calculated these three gradient.
513
+
514
+ # B.5 THE PROOF OF THEOREM 3 AND THEOREM 4
515
+
516
+ Before proving Theorem 3 and Theorem 4, we first examine a property of $d _ { \mathcal { M } } ^ { \pi }$ :
517
+
518
+ Lemma 1. For any state $s \in S$ , we have:
519
+
520
+ $$
521
+ d _ { \mathcal { M } } ^ { \pi } ( s ) = ( 1 - \gamma ) P ( s _ { 0 } = s ) + \gamma \sum _ { s ^ { \prime } } d _ { \mathcal { M } } ^ { \pi } ( s ^ { \prime } ) \sum _ { a } \pi ( a | s ) P ( s ^ { \prime } | s , a ) .
522
+ $$
523
+
524
+ Proof. Here we’ll prove this lemma. By the definition of $d _ { \mathcal { M } } ^ { \pi } ( s )$ , we have:
525
+
526
+ $$
527
+ \begin{array} { r l } { \displaystyle } & { d _ { \mathbf { A } } ^ { \kappa } ( s ) - ( 1 - \gamma ) P ^ { \kappa } ( s _ { 0 } = s ) } \\ & { = ( 1 - \gamma ) \displaystyle \sum _ { \ell = 1 } ^ { \infty } \sum _ { s ^ { \prime } } \gamma ^ { \ell } P ( s _ { \ell - 1 } = s ^ { \prime } , s _ { \ell } = s | \pi , M ) } \\ & { = ( 1 - \gamma ) \displaystyle \sum _ { \ell = 0 } ^ { \infty } \sum _ { s ^ { \prime } } \gamma ^ { \ell + 1 } P ( s _ { \ell } = s ^ { \prime } | \pi , M ) P ( s _ { \ell + 1 } = s | s _ { \ell } = s ^ { \prime } , \pi , M ) } \\ & { = \gamma \displaystyle \sum _ { s ^ { \prime } } \left[ ( 1 - \gamma ) \displaystyle \sum _ { \ell = 1 } ^ { \infty } \gamma ^ { \ell } P ( s _ { \ell } = s ^ { \prime } | \pi , M ) \right] P ( s _ { 1 } = s | s _ { 0 } = s ^ { \prime } , \pi , M ) } \\ & { = \gamma \displaystyle \sum _ { s ^ { \prime } } d _ { M } ^ { \kappa } ( s ^ { \prime } ) P ( s _ { 1 } = s | s _ { 0 } = s ^ { \prime } , \pi , M ) } \\ & { = \gamma \displaystyle \sum _ { s ^ { \prime } } d _ { M } ^ { \kappa } ( s ^ { \prime } ) \sum _ { s ^ { \prime } } \pi ( \boldsymbol { a } | s ) P ( s ^ { \prime } | s , \boldsymbol { a } ) . } \end{array}
528
+ $$
529
+
530
+ Thus we have proven it.
531
+
532
+ Now we will prove Theorem 3.
533
+
534
+ Theorem 3. For any policy $\pi$ and any adversary $\nu$ , we can calculate the reduction of expected cumulative reward of $\pi$ against the observation disturbance of $\nu$ as
535
+
536
+ $$
537
+ \begin{array} { l } { { J _ { \mathcal { M } } ( \pi ) - J _ { \mathcal { M } } ( \hat { \pi } _ { \nu } ) = \displaystyle \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } } } \mathbb { E } _ { a \sim \pi ( \cdot \vert \nu ( s ) ) } \left( 1 - \displaystyle \frac { \pi ( a \vert s ) } { \pi ( a \vert \nu ( s ) ) } \right) \mathbb { E } _ { s ^ { \prime } \sim P } V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) } } \\ { { \displaystyle \qquad + \frac { 1 } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } } } \mathbb { E } _ { a \sim \pi ( \cdot \vert \nu ( s ) ) } \left( 1 - \displaystyle \frac { \pi ( a \vert s ) } { \pi ( a \vert \nu ( s ) ) } \right) R ( s , a ) . } } \end{array}
538
+ $$
539
+
540
+ Furthermore, we can give an upper bound of it:
541
+
542
+ $$
543
+ \begin{array} { r l } & { | J _ { \mathcal M } ( \pi ) - J _ { \mathcal M } ( \hat { \pi } _ { \nu } ) | \leq \displaystyle \frac { \gamma } { 1 - \gamma } \operatorname* { m a x } _ { s } D _ { T V } ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) ) \hat { V } _ { \mathcal M , \pi } } \\ & { \qquad + \displaystyle \frac { 2 } { 1 - \gamma } \operatorname* { m a x } _ { s } D _ { T V } ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) \operatorname* { m a x } _ { s , a } | R ( s , a ) | . } \end{array}
544
+ $$
545
+
546
+ Proof. Considering the bellman equation of value function of $\pi , \hat { \pi } _ { \nu }$ in $\mathcal { M }$ , we have:
547
+
548
+ $$
549
+ \begin{array} { l } { { \displaystyle V _ { \mathcal { M } , \pi } ( s ) = \sum _ { a } \pi ( a | s ) [ R ( s , a ) + \gamma \sum _ { s ^ { \prime } } P ( s ^ { \prime } | s , a ) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) ] } , } \\ { { \displaystyle V _ { \mathcal { M } , \hat { \pi } _ { \nu } } ( s ) = \sum _ { a } \pi ( a | \nu ( s ) ) [ R ( s , a ) + \gamma \sum _ { s ^ { \prime } } P ( s ^ { \prime } | s , a ) V _ { \mathcal { M } , \hat { \pi } _ { \nu } } ( s ^ { \prime } ) ] . } } \end{array}
550
+ $$
551
+
552
+ By subtracting two value functions, we can deduce:
553
+
554
+ $$
555
+ \begin{array} { l } { { \displaystyle V _ { \mathcal { M } , \hat { \pi } _ { \nu } } ( s ) - V _ { \mathcal { M } , \pi } ( s ) = \gamma \sum _ { a } ( \pi ( a | \nu ( s ) ) - \pi ( a | s ) ) \sum _ { s ^ { \prime } } P ( s ^ { \prime } | s , a ) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) } } \\ { { \displaystyle \qquad + \gamma \sum _ { a } \pi ( a | \nu ( s ) ) \sum _ { s ^ { \prime } } P ( s ^ { \prime } | s , a ) ( V _ { \mathcal { M } , \hat { \pi } _ { \nu } } ( s ^ { \prime } ) - V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) ) } } \\ { { \displaystyle \qquad + \sum _ { a } [ \pi ( a | \nu ( s ) ) - \pi ( a | s ) ] R ( s , a ) . } } \end{array}
556
+ $$
557
+
558
+ uation (26) satisfies for every state : $s$ , thus we calculate the expectation of equation (26) for $s \sim d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } }$
559
+
560
+ $$
561
+ \begin{array} { r l } & { \quad \sum _ { k } ^ { \ell } d _ { k , k } ^ { \ell + 1 } ( \delta ) | V _ { M , k , \ell } ( e ) - V _ { M , \tau } ( s ) | } \\ & { = \gamma \sum _ { k } ^ { \ell } d _ { M , k } ^ { \ell + 1 } ( s ) \sum _ { \ell } ^ { \ell } ( \alpha ( \iota ( y ( s ) ) ) - \tau ( \iota ( s ) ) ) \sum _ { k } ^ { \ell } P ( \ell ^ { \prime } | s , \alpha ) | V _ { M , \tau } ( s ^ { \prime } ) } \\ & { + \gamma \sum _ { k } ^ { \ell } d _ { M , k } ^ { \ell + 1 } ( s ) \sum _ { \ell } ^ { \ell - 1 } ( \alpha ( \iota ( y ( s ) ) ) \sum _ { k } ^ { \ell } P ( \ell ^ { \prime } | s , \alpha ) | V _ { M , \ell } ( s ^ { \prime } ) - V _ { M , \alpha } ( \ell ^ { \prime } ) ) } \\ & { + \sum _ { k } ^ { \ell } d _ { M , k } ^ { \ell + 1 } ( s ) \sum _ { \ell } ^ { \ell } ( \alpha ( \iota ( y ( s ) ) ) - \tau ( \iota ( s ) ) | H ( s , \alpha ) | } \\ & { - \gamma \sum _ { k } ^ { \ell } d _ { M , \ell } ^ { \ell + 1 } ( s ) \sum _ { \ell } ^ { \ell } ( \alpha ( \iota ( y ( s ) ) ) - \tau ( \iota ( s ) ) ) \sum _ { \ell } ^ { \ell } P ( \ell ^ { \prime } | s , \alpha ) | V _ { M , \tau } ( s ^ { \prime } ) } \\ & { + \sum _ { k } ^ { \ell } ( \delta ) _ { M , k , \ell } ( s ^ { \prime } ) - V _ { M , \ell } ( s ^ { \prime } ) | [ \gamma _ { 2 } \sum _ { \ell } ^ { \ell } d _ { M , \ell } ^ { \ell + 1 } ( s ) \sum _ { \ell } ^ { \ell } ( \ell ^ { \prime } | s , \alpha ) ] } \\ & { + \sum _ { k } ^ { \ell } d _ { M , k , \ell } ^ { \ell + 1 } ( s ) \sum _ { \ell } ^ { \ell } ( \alpha | H ( s ) ) - \tau ( \iota ( s ) ) \sum _ { \ell } ^ { \ell + 1 } d _ { M , \ell } ^ { \ell + 1 } ( s ) \sum _ { \ell } ^ { \ell + 1 } ( \ell ^ { \prime } | s , \alpha ) | P ( s ^ { \prime } | s , \alpha ) ) } \\ & + \sum _ { k } ^ \end{array}
562
+ $$
563
+
564
+ By Lemma 1, we have:
565
+
566
+ $$
567
+ \begin{array} { l } { { { \displaystyle \sum _ { s } d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } } ( s ) [ V _ { M , \hat { \pi } _ { \nu } } ( s ) - V _ { M , \pi } ( s ) ] } } } \\ { { { \displaystyle = \gamma \sum _ { s } d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } } ( s ) \sum _ { a } ( \pi ( a | \nu ( s ) ) - \pi ( a | s ) ) \sum _ { s ^ { \prime } } P ( s ^ { \prime } | s , a ) V _ { M , \pi } ( s ^ { \prime } ) } } } \\ { { { \displaystyle + \sum _ { s ^ { \prime } } ( V _ { M , \hat { \pi } _ { \nu } } ( s ^ { \prime } ) - V _ { M , \pi } ( s ^ { \prime } ) ) \left[ d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } } ( s ^ { \prime } ) - ( 1 - \gamma ) P ( s _ { 0 } = s ^ { \prime } ) \right] } } } \\ { { { \displaystyle + \sum _ { s } d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } } ( s ) \sum _ { a } [ \pi ( a | \nu ( s ) ) - \pi ( a | s ) ] R ( s , a ) . } } } \end{array}
568
+ $$
569
+
570
+ By moving the second term of the right part in (28) to the left part, we can deduce:
571
+
572
+ $$
573
+ \begin{array} { c } { { ( 1 - \gamma ) \displaystyle \sum _ { s ^ { \prime } } ( V _ { M , \hat { \pi } _ { \nu } } ( s ^ { \prime } ) - V _ { M , \pi } ( s ^ { \prime } ) ) P ( s _ { 0 } = s ^ { \prime } ) } } \\ { { \displaystyle = \gamma \sum _ { s } d _ { { \mathcal M } } ^ { \hat { \pi } _ { \nu } } ( s ) \sum _ { a } ( \pi ( a | \nu ( s ) ) - \pi ( a | s ) ) \sum _ { s ^ { \prime } } P ( s ^ { \prime } | s , a ) V _ { M , \pi } ( s ^ { \prime } ) } } \\ { { + \sum _ { s } d _ { { \mathcal M } } ^ { \hat { \pi } _ { \nu } } ( s ) \sum _ { a } [ \pi ( a | \nu ( s ) ) - \pi ( a | s ) ] R ( s , a ) , } } \end{array}
574
+ $$
575
+
576
+ thus:
577
+
578
+ $$
579
+ \begin{array} { r l } { ( 1 - \gamma ) ( J _ { M } ( \hat { \pi } _ { \nu } ) - J _ { M } ( \pi ) ) = ( 1 - \gamma ) \displaystyle \sum _ { s ^ { \prime } } ( V _ { M , \hat { \pi } _ { \nu } } ( s ^ { \prime } ) - V _ { M , \pi } ( s ^ { \prime } ) ) P ( s _ { 0 } = s ^ { \prime } ) } & { } \\ { = \gamma \displaystyle \sum _ { s } d _ { M } ^ { \hat { \pi } _ { \nu } } ( s ) \displaystyle \sum _ { a } ( \pi ( a | \nu ( s ) ) - \pi ( a | s ) ) \displaystyle \sum _ { s ^ { \prime } } P ( s ^ { \prime } | s , a ) V _ { M , \pi } ( s ^ { \prime } ) } & { } \\ { + \displaystyle \sum _ { s } d _ { M } ^ { \hat { \pi } _ { \nu } } ( s ) \displaystyle \sum _ { a } \{ \pi ( a | \nu ( s ) ) - \pi ( a | s ) \} H ( s , a ) } & { } \\ { = \gamma \mathbb { E } _ { s \sim d _ { M } ^ { \nu _ { \nu } } } \mathbb { E } _ { a \sim \pi ( \cdot | \nu ( s ) ) } \left( 1 - \displaystyle \frac { \pi ( a | s ) } { \pi ( a | \nu ( s ) ) } \right) \mathbb { E } _ { s ^ { \prime } \sim P ( \cdot | s , a ) } V _ { M , \pi } ( s ^ { \prime } ) } & { } \\ { + \mathbb { E } _ { s \sim d _ { M } ^ { \nu _ { \nu } } } \mathbb { E } _ { a \sim \pi ( \cdot | \nu ( s ) ) } \left( 1 - \displaystyle \frac { \pi ( a | s ) } { \pi ( a | \nu ( s ) ) } \right) R ( s , a ) . } & { } \end{array}
580
+ $$
581
+
582
+ And we can prove:
583
+
584
+ $$
585
+ \begin{array} { c } { { J _ { \mathcal M } ( \pi ) - J _ { \mathcal M } ( \hat { \pi } _ { \nu } ) = \displaystyle \frac { \gamma } { 1 - \gamma } \mathbb E _ { s \sim d _ { \mathcal M } ^ { \hat { \pi } _ { \nu } } } \mathbb E _ { a \sim \pi ( \cdot \vert \nu ( s ) ) } \left( 1 - \displaystyle \frac { \pi ( a \vert s ) } { \pi ( a \vert \nu ( s ) ) } \right) \mathbb E _ { s ^ { \prime } \sim P ( \cdot \vert s , a ) } V _ { \mathcal M , \pi } ( s ^ { \prime } ) } } \\ { { + \displaystyle \frac { 1 } { 1 - \gamma } \mathbb E _ { s \sim d _ { \mathcal M } ^ { \hat { \pi } _ { \nu } } } \mathbb E _ { a \sim \pi ( \cdot \vert \nu ( s ) ) } \left( 1 - \displaystyle \frac { \pi ( a \vert s ) } { \pi ( a \vert \nu ( s ) ) } \right) R ( s , a ) . } } \end{array}
586
+ $$
587
+
588
+ Since $\begin{array} { r } { \mathbb { E } _ { a \sim \pi ( \cdot | \nu ( s ) ) } \left( 1 - \frac { \pi ( a | s ) } { \pi ( a | \nu ( s ) ) } \right) = 0 } \end{array}$ , we can subtract a benchmark, which will not affect its value. Specially, we consider VFR $\begin{array} { r } { \hat { V } _ { M , \pi } = \operatorname* { m a x } _ { s ^ { \prime } } V _ { M , \pi } ( s ^ { \prime } ) - \operatorname* { m i n } _ { s ^ { \prime } } V _ { M , \pi } ( s ^ { \prime } ) } \end{array}$ and we have $| V _ { M , \pi } ( s ) -$ $\begin{array} { r } { \hat { V } _ { M , \pi } | \leq \frac { \hat { V } _ { M , \pi } } { 2 } } \end{array}$ VˆM,π2 for every state s, thus we can prove that
589
+
590
+ $$
591
+ \begin{array} { r l } { \mathcal { J } _ { \boldsymbol { A } \boldsymbol { A } } ( \boldsymbol { \tilde { x } } ) - \mathcal { J } _ { \boldsymbol { A } \boldsymbol { A } } ( \boldsymbol { \tilde { x } } , \boldsymbol { \tilde { x } } ) | \leq \frac { \gamma } { 1 - \frac { \gamma } { 2 } } \sum _ { t = - \frac { \gamma } { 2 } } ^ { \boldsymbol { \kappa } } \sum _ { w \leq t \leq t } \delta _ { t \leq t \leq t } | w | \boldsymbol { x } | | - \frac { \gamma \cdot \zeta ^ { 2 } \cdot \delta ^ { 2 } } { 4 ( \boldsymbol { \mu } ( t - \boldsymbol { \tilde { \mu } } ) ) } | \mathbb { E } _ { w \leq t - \frac { \gamma } { 2 } \cdot \boldsymbol { \tau } ( s , t ) } \delta ^ { t } M _ { \boldsymbol { A } , w } | \delta ^ { t } - \delta ^ { t } \cdot \boldsymbol { x } _ { w , t } | } \\ & { + \frac { \gamma } { 1 - \frac { \gamma } { 2 } } \mathbb { E } _ { w \leq t \leq t } \sum _ { w \leq t \leq t } | w | \delta ^ { t } - \boldsymbol { \tau } _ { w \leq t \leq t } | \delta ^ { t } \cdot \boldsymbol { w } | } \\ & { \leq \frac { \gamma } { 1 - \frac { \gamma } { 2 } } \frac { \gamma } { 6 } \sum _ { t = - \frac { \gamma } { 2 } } ^ { \boldsymbol { \kappa } } \delta _ { t \leq t \leq t } ^ { 2 } \exp | \delta ^ { t } - \frac { \gamma \cdot \zeta ^ { 2 } \cdot \delta ^ { 2 } } { 4 ( \boldsymbol { \mu } ( t - \boldsymbol { \tilde { \mu } } ) ) } | \frac { \prod ( \delta ^ { t } ) \cdot \delta ^ { 2 } \cdot \boldsymbol { x } _ { w , t } } { 2 } } \\ & + \frac { \gamma } { 1 - \frac { \gamma } { 2 } } \frac { \gamma } { 6 } \sum _ { s \leq t \leq t } \delta ^ { t } \frac { \gamma } { 6 } \exp | \delta ^ { t } - \frac { \gamma \cdot \zeta ^ { 2 } \cdot \delta ^ { 2 } } { 4 ( \boldsymbol { \mu } ( t - \boldsymbol { \tilde { \mu } } ) ) } | \frac { \prod ( \delta ^ { t } ) \cdot \zeta ^ { 2 } \cdot \delta ^ { 2 } } { 2 ( \boldsymbol { \mu } ( t - \boldsymbol { \tilde { \mu } } ) ) } \\ & + \frac { \gamma } { 1 - \frac { \gamma } { 2 } } \sum _ { t = - \frac { \gamma } { 2 } } ^ \ \end{array}
592
+ $$
593
+
594
+ Thus we have proven Theorem 3.
595
+
596
+ Furthermore, we will prove that our bound is tighter than the bound in Zhang et al. (2020):
597
+
598
+ $$
599
+ \begin{array} { r l } { \bigl | J _ { M } ( \pi ) - J _ { M } ( \hat { \pi } _ { \nu } ) \bigr | \leq \displaystyle \frac { \gamma } { 1 - \gamma } \underset { s } { \operatorname* { m a x } } D _ { T V } \bigl ( \pi \cdot | s ) , \pi ( \cdot | \nu ( s ) ) \bigr ) \hat { V } _ { M , \pi } } & { } \\ & { \qquad + \displaystyle \frac { 2 } { 1 - \gamma } \underset { s } { \operatorname* { m a x } } D _ { T V } \bigl ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) \underset { s , a } { \operatorname* { m a x } } | R ( s , a ) | } \\ & { \qquad \leq \displaystyle \frac { 2 \gamma } { 1 - \gamma } \underset { s } { \operatorname* { m a x } } D _ { T V } \bigl ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) \bigr ) \underset { s , a } { \operatorname* { m a x } } | V _ { M , \pi } ( s ) | } \\ & { \qquad + \displaystyle \frac { 2 } { 1 - \gamma } \underset { s } { \operatorname* { m a x } } D _ { T V } \bigl ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) \underset { s , a } { \operatorname* { m a x } } | R ( s , a ) | } \\ & { \qquad \leq \Bigl ( \displaystyle \frac { 2 \gamma } { ( 1 - \gamma ) ^ { 2 } } + \frac { 2 } { 1 - \gamma } \Bigr ) \underset { s } { \operatorname* { m a x } } D _ { T V } \bigl ( \pi ( \cdot | s ) , \pi ( \cdot | \nu ( s ) ) \bigr ) \underset { s , a } { \operatorname* { m a x } } | R ( s , a ) | . } \end{array}
600
+ $$
601
+
602
+ Finally, we will prove Theorem 4 by using the similar method of Theorem 3.
603
+
604
+ Theorem 4. For any policy $\pi$ in MDP $\mathcal { M } = ( S , \mathcal { A } , \mathcal { P } , \mathcal { R } , \gamma )$ and any disturbed environment $\hat { \mathcal { M } } = ( S , \mathcal { A } , \hat { \mathcal { P } } , \mathcal { R } , \gamma )$ , the reduction of cumulative reward against the transition disturbance is
605
+
606
+ $$
607
+ J _ { \mathcal { M } } ( \pi ) - J _ { \hat { \mathcal { M } } } ( \pi ) = \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \hat { \mathcal { M } } } ^ { \pi } } \mathbb { E } _ { a \sim \pi } \mathbb { E } _ { s ^ { \prime } \sim \hat { P } } \left( 1 - \frac { P ( s ^ { \prime } | s , a ) } { \hat { P } ( s ^ { \prime } | s , a ) } \right) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) .
608
+ $$
609
+
610
+ Furthermore, we can give a upper bound of the reduction is therefore
611
+
612
+ $$
613
+ J _ { \mathcal { M } } ( \pi ) - J _ { \hat { \mathcal { M } } } ( \pi ) \leq \frac { 2 \gamma } { 1 - \gamma } \operatorname* { m a x } _ { s , a } D _ { T V } ( P ( \cdot | s , a ) , \hat { P } ( \cdot | s , a ) ) \hat { V } _ { \mathcal { M } , \pi } .
614
+ $$
615
+
616
+ Proof. Similarly, considering the bellman equation of value function of $\pi$ in $\mathcal { M } , \hat { \mathcal { M } }$ , we have
617
+
618
+ $$
619
+ \begin{array} { l } { { \displaystyle V _ { \mathcal { M } , \pi } ( s ) = \sum _ { a } \pi ( a | s ) [ R ( s , a ) + \gamma \sum _ { s ^ { \prime } } P ( s ^ { \prime } | s , a ) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) ] } , } \\ { { \displaystyle V _ { \hat { \mathcal { M } } , \pi } ( s ) = \sum _ { a } \pi ( a | s ) [ R ( s , a ) + \gamma \sum _ { s ^ { \prime } } \hat { P } ( s ^ { \prime } | s , a ) V _ { \hat { \mathcal { M } } , \pi } ( s ^ { \prime } ) ] . } } \end{array}
620
+ $$
621
+
622
+ By subtracting them, we have
623
+
624
+ $$
625
+ \begin{array} { r l r } & { } & { { \cal V } _ { \hat { \mathcal M } , \pi } ( s ) - { \cal V } _ { \mathcal M , \pi } ( s ) = \gamma \displaystyle \sum _ { a } \pi ( a \vert s ) \sum _ { s ^ { \prime } } ( \hat { P } ( s ^ { \prime } \vert s , a ) - P ( s ^ { \prime } \vert s , a ) ) { \cal V } _ { \mathcal M , \pi } ( s ^ { \prime } ) } \\ & { } & { \quad \quad \quad + \gamma \displaystyle \sum _ { a } \pi ( a \vert s ) \sum _ { s ^ { \prime } } \hat { P } ( s ^ { \prime } \vert s , a ) ( { \cal V } _ { \hat { \mathcal M } , \pi } ( s ^ { \prime } ) - { \cal V } _ { \mathcal M , \pi } ( s ^ { \prime } ) ) . } \end{array}
626
+ $$
627
+
628
+ Since equation (26) satisfies for every state $s$ , thus we calculate the expectation of equation (26) for $s \sim d _ { \mathcal { M } } ^ { \hat { \pi } _ { \nu } }$ and use Lemma 1:
629
+
630
+ $$
631
+ \begin{array} { r l } & { \quad \sum _ { \nu } d _ { \mathcal { M } } ^ { \nu } ( s ) [ F _ { A , \nu } ( s ) - V _ { M , \tau } ( \hat { s } ) ] } \\ & { = \gamma \sum _ { \nu } d _ { \mathcal { M } , \nu } ^ { \nu } \langle s \rangle \sum _ { \alpha } ( \alpha ) | s \rangle \sum _ { \nu } ^ { \nu } \left( \hat { P } ( s ) | s , \alpha ) - P ( s ^ { \nu } | s , \alpha ) | V _ { A , \alpha } ( s ^ { \nu } ) \right. } \\ & { \quad + \gamma \sum _ { \nu } \sum _ { \alpha } d _ { \mathcal { M } ^ { \nu } } ^ { \nu } \langle s \rangle \sum _ { \alpha } \pi ( s ) | s \rangle \sum _ { \nu } ^ { \nu } \hat { P } ( s ^ { \nu } | s , \alpha ) | V _ { A , \alpha } ( s ^ { \nu } ) - V _ { M , \tau } ( s ^ { \nu } ) \ } \\ & { \quad \left. = \gamma \sum _ { \nu } \frac { d _ { \mathcal { M } ^ { \nu } } ^ { \nu } ( s ) } { d _ { \mathcal { M } } ^ { \nu } ( s ) } \sum _ { \alpha } \pi ( s ) | s \rangle \sum _ { \nu } ^ { \nu } \left( \hat { P } ( s ^ { \nu } | s , \alpha ) - P ( s ^ { \nu } | s , \alpha ) | V _ { A , \alpha } ( s ^ { \nu } ) \right. \right. } \\ & { \quad \left. + \sum _ { \nu } ( V _ { A , \alpha } ( s ^ { \nu } ) - V _ { M , \tau } ( s ^ { \nu } ) ) \sum _ { \alpha } e ^ { - \alpha \int _ { \alpha } ^ { \tau } ( s ^ { \nu } ) } \sum _ { \nu } \pi ( s ) | s \rangle \sum _ { \alpha } \pi ( s ) | s \rangle \hat { P } ( s ^ { \nu } | s , \alpha ) \right) } \\ & { \quad \times \sum _ { \nu } \hat { Q } _ { K , \alpha } ^ { \nu } ( s ^ { \nu } ) - V _ { M , \tau } ( s ^ { \nu } ) \sum _ { \nu } \hat { Q } _ { K , \alpha } ^ { \nu } ( s ) \sum _ { \alpha } \pi ( s ) | s \rangle \sum _ { \alpha } \hat { Q } ( s ^ { \nu } ) | s \rangle \hat { Q } ( s ^ { \nu } | s , \alpha ) \hat { Q } ( s ^ { \nu } ) } \\ & \quad \times \sum _ { \nu } \hat { Q } _ { K , \alpha } ^ { \nu } ( s ) \sum _ { \alpha } \pi ( \end{array}
632
+ $$
633
+
634
+ Similarly, by moving the second term of the right part in (37) to the left part, we can deduce that
635
+
636
+ $$
637
+ \begin{array} { r l r } { { ( 1 - \gamma ) \sum _ { s ^ { \prime } } ( V _ { \hat { \mathcal { M } } , \pi } ( s ^ { \prime } ) - V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) ) P ( s _ { 0 } = s ^ { \prime } ) } } \\ & { } & { \quad = \gamma \sum _ { s } d _ { \hat { \mathcal { M } } } ^ { \pi } ( s ) \sum _ { a } \pi ( a | s ) \sum _ { s ^ { \prime } } ( \hat { P } ( s ^ { \prime } | s , a ) - P ( s ^ { \prime } | s , a ) ) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) , } \end{array}
638
+ $$
639
+
640
+ thus:
641
+
642
+ $$
643
+ \begin{array}{c} ( 1 - \gamma ) ( J _ { \hat { \mathcal { M } } } ( \pi ) - J _ { \mathcal { M } } ( \pi ) ) = ( 1 - \gamma ) \sum _ { s ^ { \prime } } ( V _ { \hat { \mathcal { M } } , \pi } ( s ^ { \prime } ) - V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) ) P ( s _ { 0 } = s ^ { \prime } ) \\ { = \gamma \sum _ { s } d _ { \hat { \mathcal { M } } } ^ { \pi } ( s ) \sum _ { a } \pi ( a | s ) \sum _ { s ^ { \prime } } ( \hat { P } ( s ^ { \prime } | s , a ) - P ( s ^ { \prime } | s , a ) ) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) } \\ { = \gamma \mathbb { E } _ { s \sim d _ { \hat { \mathcal { M } } } ^ { \pi } } \mathbb { E } _ { a \sim \pi ( \cdot | s ) } \mathbb { E } _ { s ^ { \prime } \sim \hat { P } ( \cdot | s , a ) } \left( 1 - \frac { P ( s ^ { \prime } | s , a ) } { \hat { P } ( s ^ { \prime } | s , a ) } \right) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) . } \end{array}
644
+ $$
645
+
646
+ Thus we have proven:
647
+
648
+ $$
649
+ J _ { \mathcal { M } } ( \pi ) - J _ { \hat { \mathcal { M } } } ( \pi ) = \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \hat { \mathcal { M } } } ^ { \pi } } \mathbb { E } _ { a \sim \pi ( \cdot \vert s ) } \mathbb { E } _ { s ^ { \prime } \sim \hat { P } ( \cdot \vert s , a ) } \left( 1 - \frac { P ( s ^ { \prime } \vert s , a ) } { \hat { P } ( s ^ { \prime } \vert s , a ) } \right) V _ { \mathcal { M } , \pi } ( s ^ { \prime } ) .
650
+ $$
651
+
652
+ Similarly, we consider VFR $\begin{array} { r } { \hat { V } _ { M , \pi } = \operatorname* { m a x } _ { s ^ { \prime } } V _ { M , \pi } ( s ^ { \prime } ) - \operatorname* { m i n } _ { s ^ { \prime } } V _ { M , \pi } ( s ^ { \prime } ) } \end{array}$ and we have $| V _ { M , \pi } ( s ) -$ $\begin{array} { r } { \hat { V } _ { M , \pi } | \leq \frac { \hat { V } _ { M , \pi } } { 2 } } \end{array}$ VˆM,π for every state s, thus we can prove:
653
+
654
+ $$
655
+ \begin{array} { r l } & { \displaystyle | J _ { M } ( \pi ) - J _ { M } ( \hat { \pi } _ { \nu } ) | \leq \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \bar { M } } ^ { \pi } } \mathbb { E } _ { a \sim \pi \left( \cdot \vert s \rangle \right) } \mathbb { E } _ { s ^ { \prime } \sim \hat { P } ( \cdot \vert s , a ) } \left. 1 - \frac { P \left( s ^ { \prime } \vert s , a \right) } { \hat { P } \left( s ^ { \prime } \vert s , a \right) } \right. \left. V _ { M , \pi } ( s ^ { \prime } ) - \hat { V } _ { M , \pi } \right. } \\ & { \qquad \leq \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \bar { M } } ^ { \pi } } \mathbb { E } _ { a \sim \pi \left( \cdot \vert s \rangle \right) } \mathbb { E } _ { s ^ { \prime } \sim \hat { P } ( \cdot \vert s , a ) } \left. 1 - \frac { P \left( s ^ { \prime } \vert s , a \right) } { \hat { P } \left( s ^ { \prime } \vert s , a \right) } \right. \frac { \hat { V } _ { M , \pi } } { 2 } } \\ & { \displaystyle = \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \bar { M } } ^ { \pi } } \mathbb { E } _ { a \sim \pi \left( \cdot \vert s \rangle \right) } \sum _ { s ^ { \prime } } \left. \hat { P } \left( s ^ { \prime } \vert s , a \right) - P ( s ^ { \prime } \vert s , a ) \right. \frac { \hat { V } _ { M , \pi } } { 2 } } \\ & { \displaystyle = \frac { \gamma } { 1 - \gamma } \mathbb { E } _ { s \sim d _ { \bar { M } } ^ { \pi } } \mathbb { E } _ { a \sim \pi \left( \cdot \vert s \rangle \right) } D _ { T V } ( P ( \cdot \vert s , a ) , \hat { P } ( \cdot \vert s , a ) ) \hat { V } _ { M , \pi } . } \end{array}
656
+ $$
657
+
658
+ Thus we have proven Theorem 4.
659
+
660
+ # B.6 THE PROOF OF THEOREM 5
661
+
662
+ By Theorem 1, we have
663
+
664
+ $$
665
+ \begin{array} { r l } & { - \mathrm { C V a R } _ { \alpha } ( - V ( s ) ) = \mathbb { E } _ { z \sim V ( s ) } \{ z | z \le - \mathrm { V a R } _ { \alpha } ( - V ( s ) ) \} } \\ & { \quad \quad \quad \quad = \mathbb { E } _ { \tau } \{ D ( \tau ) | V ( s _ { 0 } ) \le - \mathrm { V a R } _ { \alpha } ( - V ( s ) ) \} } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \ge \mathbb { E } _ { \tau } \{ D ( \tau ) | D ( \tau ) \le - \mathrm { V a R } _ { \alpha } ( - D ( \tau ) ) \} } \\ & { \quad \quad \quad \quad = - \mathrm { C V a R } _ { \alpha } ( - D ( \tau ) ) . } \end{array}
666
+ $$
667
+
668
+ Here the inequality holds since $P ( V ( s _ { 0 } ) \leq - \mathrm { V a R } _ { \alpha } ( - V ( s ) ) ) = P ( D ( \tau ) \leq - \mathrm { V a R } _ { \alpha } ( - D ( \tau ) ) ) =$ $\alpha$ . Thus we have proven Theorem 5.
md/dev/tGHi1HFNBx1/tGHi1HFNBx1.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/tGbpgz6yOrI/tGbpgz6yOrI.md ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # R3M: A Universal Visual Representation for Robot Manipulation
2
+
3
+ Suraj $\mathbf { N a i r ^ { 1 , * } }$ , Aravind Rajeswaran2, Vikash Kumar2, Chelsea $\mathbf { F i n n ^ { 1 } }$ , Abhinav Gupta2
4
+
5
+ 1Stanford University, 2Meta AI
6
+
7
+ Abstract: We study how visual representations pre-trained on diverse human video data can enable data-efficient learning of downstream robotic manipulation tasks. Concretely, we pre-train a visual representation using the Ego4D human video dataset using a combination of time-contrastive learning, video-language alignment, and an L1 penalty to encourage sparse and compact representations. The resulting representation, R3M, can be used as a frozen perception module for downstream policy learning. Across a suite of 12 simulated robot manipulation tasks, we find that R3M improves task success by over $2 0 \%$ compared to training from scratch and by over $1 0 \%$ compared to state-of-the-art visual representations like CLIP and MoCo. Furthermore, R3M enables a Franka Emika Panda arm to learn a range of manipulation tasks in a real, cluttered apartment given just 20 demonstrations.
8
+
9
+ Keywords: Visual Representation Learning, Robotic Manipulation
10
+
11
+ # 1 Introduction
12
+
13
+ How do we train a robot to complete a manipulation task from images? A standard and widely used approach is to train an end-to-end model from scratch using data from the same domain [1]. However, this can be prohibitively data intensive and severely limits generalization. In contrast, computer vision and natural language processing (NLP) have recently taken a major departure from this “tabula rasa” paradigm. These fields have focused on using diverse, large-scale datasets to build reusable, pre-trained representations. Such models have become ubiquitous; for example, visual representations from ImageNet [2] can be reused for tasks like cancer detection [3], and pre-trained language embeddings like BERT [4] have been used for everything from medical coding [5] to visual question answering [6]. Such an equivalent of an ImageNet [2] or BERT [4] model for robotics, that can be readily downloaded and used for any downstream simulation or real-world manipulation task, has remained elusive.
14
+
15
+ Why have we struggled in building this universal representation for robotics? Our conjecture is that we haven’t converged on using the appropriate datasets for robotics. Collecting large and diverse datasets of robots interacting with the physical world can be costly, even without human annotation. Recent attempts at creating such datasets [7, 8, 9, 10], consist of a limited number of tasks in at most a handful of different environments. This lack of diversity and scale makes it difficult to learn representations that are broadly applicable. At the same time, the recent history of computer vision and NLP suggests an alternate route for robotics. The best representations in these fields did not arise out of task-specific and carefully curated datasets, but rather the use of abundant in-the-wild data [4, 11, 12, 13]. Analogously, for robotics and motor control, we have access to videos of humans interacting in semantically interesting ways with their environments [14, 15, 16]. This data is large and diverse, spanning scenes across the globe, and tasks ranging from folding clothes to cooking a meal. While the embodiment present in this data differs from most robots, prior work [17, 18] has found that such human video data can still be useful for learning reward functions. Furthermore, domain gap has not been a major barrier for using pre-trained representations in traditional vision and NLP tasks. In this backdrop, we ask the pertinent question: can visual representations pre-trained on diverse human videos enable efficient downstream learning of robotic manipulation skills?
16
+
17
+ ![](images/a27b2b5e1fbf16cfc1be41aa6486a67ba25e3b2c09ecf54fc9edf13aa8f1f7ee.jpg)
18
+ Figure 1: Pre-Training Reusable Representations for Robot Manipulation (R3M): We pre-train a visual representation using diverse human video datasets like Ego4D [16], and study its effectiveness for downstream robot manipulation tasks. Our representation model, R3M, is trained using a combination of time-contrastive learning, video-language alignment, and an L1 sparsity penalty. We find that R3M enables data efficient imitation learning across several simulated and real-world robot manipulation tasks.
19
+
20
+ We hypothesize that a good representation for vision-based robotic manipulation consists of three components. First, it should contain information necessary for physical interaction, and thus should capture the temporal dynamics of the scene (i.e. how states might transition to other states). Second, it should have a prior over semantic relevance, and should focus on task relevant features like objects and their relationships. Finally, it should be compact, and not include features irrelevant to the above criteria (e.g. backgrounds). Towards satisfying these three criteria, we study a representation learning approach that combines (1) time contrastive learning [19] to learn a representation that captures temporal dynamics, (2) video-language alignment to capture semantically relevant features of the scene, and (3) L1 and L2 penalties to encourage sparsity. Our experimental evaluation in Section 4.4 finds that all three components are important for training highly performant representations.
21
+
22
+ In this work we empirically demonstrate that representations pre-trained on diverse human video datasets like Ego4D [16] can enable efficient downstream policy learning for robotic manipulation. Our core contribution is an artifact – the pre-trained vision model – that can be used readily in other work. Concretely, we pre-train a reusable representation for robotic manipulation (R3M), which can be used as a frozen perception module for downstream policy learning in simulated and real robot manipulation tasks. We demonstrate this via extensive experimental results across three existing benchmark simulation environments (Adroit [20], Franka-Kitchen [21], and MetaWorld [22]) as well as real robot experiments in a cluttered apartment setting. R3M features outperform a wide range of visual representations like CLIP [12], (supervised) ImageNet [2], MoCo [23, 24], and learning from scratch by over $10 \%$ when evaluated across 12 tasks, 9 viewpoints, and 3 different simulation environments. On a Franka Emika Panda robot, R3M enables learning challenging tasks like putting lettuce in a pan and folding a towel with a $50 \%$ average success rate, given less than 10 minutes of human demonstrations (see Figure 1), which is nearly double the success rate compared to CLIP features. Overall, on the basis of these results, we believe that R3M has the potential to become a standard vision model for robot manipulation, which can be simply downloaded and used off-the-shelf for any robot manipulation task or environment. See https: //sites.google.com/view/robot-r3m for pre-trained models and code.
23
+
24
+ # 2 Related Work
25
+
26
+ Representation Learning for Robotics. Our work is certainly not the first to study the problem of learning general representations for robotics. One line of work focuses on learning representations from in-domain data, that is, using data from the target environment and task for training the representation. Such methods include contrastive learning with data augmentation [25, 26, 27, 28], dynamics prediction [29, 30], bi-simulation [31], temporal or goal distance [32, 33], or domain specific information [34]. However, because they are trained on data exclusively from the target domain and task, the learned representations fail to generalize and cannot be re-used to enable faster learning in unseen tasks and environments.
27
+
28
+ Recently, there has been growing interest in learning more general representations for motor control from large-scale out-of-domain data like images from the web. This includes the use of CLIP, supervised MS-COCO, supervised ImageNet, MoCo ImageNet features, or data from different robots [35, 36, 37, 38, 23, 39]. In contrast to prior work, we pre-train the representation using diverse human video and language data, as opposed to static frames and/or class labels. Further, in our experimental evaluation, we observe that our pre-trained representation outperforms prior work significantly on a comprehensive evaluation suite. Concurrently, Xiao et al. [40] also explore the use of human interaction data to pre-train visual representations for motor control. However their learned representation only uses static frames from these videos and does not utilize temporal or semantic information like R3M. Furthermore, our evaluation focuses on data efficient imitation learning, and enables real-world learning in cluttered environments with just $\sim 1 0$ minutes of demonstration data.
29
+
30
+ Leveraging Human Videos for Robot Learning. Several prior works have explored using human video data in robot learning, for example to acquire goals [41, 42, 43], to learn visual dynamics models [44, 45, 46, 47], or to learn representations and rewards [19, 48, 49, 50, 51, 52]. However, these prior works typically focus on a small dataset of human videos closely resembling the robot environment. In contrast, our work leverages diverse human video data like Ego4D [16] to learn visual reusable visual representations that generalize broadly.
31
+
32
+ Natural Language and Robotic Manipulation. Prior works have explored the use of natural language in robot manipulation, primarily as a means of task specification [53, 54, 36, 55] or reward learning [56]. In contrast, we use diverse human video data and language annotations to learn reusable visual representations for control. Prior work has also found visual representations informed by language, like CLIP [12], to be effective for control [36, 37]. Through empirical evaluations, we find that our R3M representation substantially outperforms CLIP for robot manipulation.
33
+
34
+ Learning from Diverse Robot Data. Towards robots that generalize more broadly, there are a number of works that study how to scale up the size and diversity of data robots learn from. Many of these works focus on collecting and learning from robot data itself [57, 58, 7, 8, 9, 10, 59]. However, these works often contain at most a handful of different environments, making generalization across a range of unseen scenes difficult. While we also aim to enable generalization by learning from diverse data, our focus is instead on (1) learning from human video data and hence a larger distribution of environments and tasks, and (2) pre-training a visual representation, as opposed to policies or models.
35
+
36
+ Representation Learning from Videos. Finally, there is a rich literature of works that study learning image representations from videos [60, 61, 19, 62, 63, 64] outside of the context of robotics. Additionally, there are a number of works that use language to learn representations from videos [65, 66]. Critically, unlike all of these works, the main contribution of this work is not to propose a novel representation learning approach, but rather in studying if representations trained on diverse video and language of human interaction can enable more efficient learning of robotic manipulation.
37
+
38
+ # 3 R3M: Reusable Representations for Robotic Manipulation
39
+
40
+ Our goal is to use diverse human video data to pre-train a single reusable visual representation for motor control, particularly robotic manipulation, that can enable efficient downstream learning in previously unseen environments and tasks. In this section, we cover the different components of our approach, beginning by describing our problem formulation in Section 3.1, the data sources we use in Section 3.2, and our training objective in Section 3.3.
41
+
42
+ # 3.1 Preliminaries
43
+
44
+ Formally, we assume that we have access to a dataset $\mathcal { D }$ of $N$ videos, where each video consists of a sequence of RGB frames $[ I _ { 0 } , I _ { 1 } , . . . , I _ { T } ]$ . Additionally, we assume that each video is paired with a natural language description $l$ , that describes what task is being completed in the video. From this data, our goal is to learn a single image encoder $\mathcal { F } _ { \phi }$ , that maps images to a deterministic, continuous embedding, that is $z = \mathcal { F } _ { \phi } ( I )$ . Once trained, we want to be able to repeatedly reuse $\mathcal { F }$ for downstream policy learning. Specifically, the downstream problem will involve an agent sequentially choosing actions given image observations $I$ , and instead of using raw images as input, the agent will use the pre-trained ${ \mathcal { F } } _ { \phi } ( I )$ as a state representation.
45
+
46
+ ![](images/4ff39fbcdeffd4b029e257b88a5411828ad47288a77ce7e56a2d711d54a0a8bc.jpg)
47
+ Figure 2: Ego4D [16] Video and Language (left). Sample frames and associated language from Grauman et al. [16] used for training R3M. R3M Training (right). We train R3M with time contrastive learning, encouraging states closer in time to be closer in embedding space and video-language alignment to encourage the embeddings to capture semantically relevant features.
48
+
49
+ # 3.2 Data Sources
50
+
51
+ For our learned representation $\mathcal { F } _ { \phi }$ to be useful in a wide range of downstream tasks and environments, it should (1) be trained on data that is diverse enough to facilitate generalization, and (2) provide a useful signal for features relevant to robotic manipulation. One approach would be to be use natural images off the web (e.g. ImageNet [2]). While diverse, these images tend to focus on one particular object, and do not capture an agent interacting with multiple objects in a scene. Alternatively, data of humans interacting in the world [14, 65, 16] is both diverse and contains useful interaction in scenes similar to those we would like robots to interact in. Of the many human video datasets, we leverage the Ego4D dataset [16] due to it’s diversity and size, although in principle our method can be used on any suitable video dataset. Ego4D contains videos of people engaging in a wide range of tasks from cooking to socializing to assembling objects from more than 70 locations across the globe, and in total contains more than 3500 hours of data. Each video clip also contains a natural language annotation describing the behavior of the person in the video (See Figure 2 (left)).
52
+
53
+ # 3.3 Training R3M
54
+
55
+ What should a good representation for robotic manipulation from human video data capture? We propose three key components: (1) it should capture temporal dynamics, as the agent will be sequentially interacting in the environment to accomplish tasks, (2) it should capture semantically relevant features, and (3) it should be compact. We next describe how we use time contrastive learning to capture (1), video-language alignment for (2), and the use of L1 regularization to encourage (3). See Figure 2 (right) for an overview of our training objective.
56
+
57
+ Time Contrastive Learning. To encourage $\mathcal { F } _ { \phi }$ to capture features relevant to physical interaction and sequential decision making, the first part of our objective is a time contrastive loss [61]. Given a batch of videos we train the encoder to produce a representation such that the distance between images closer in time is smaller than for images farther in time or from different videos. Specifically, we sample a batch of sequences of frames $[ I _ { i } , I _ { j > i } , I _ { k > j } ] ^ { 1 : B }$ , then minimize the InfoNCE loss [67]:
58
+
59
+ $$
60
+ \mathcal { L } _ { t c n } = - \sum _ { b \in B } \log \frac { e ^ { S ( z _ { i } ^ { b } , z _ { j } ^ { b } ) } } { e ^ { S ( z _ { i } ^ { b } , z _ { j } ^ { b } ) } + e ^ { S ( z _ { i } ^ { b } , z _ { k } ^ { b } ) } + e ^ { S ( z _ { i } ^ { b } , z _ { i } ^ { \ne b } ) } }
61
+ $$
62
+
63
+ where $z = \mathcal { F } _ { \phi } ( I )$ , and $z _ { i } ^ { \neq b }$ is a negative example sampled from a different video in the batch. $s$
64
+ denotes a measure of similarity, which in our case is implemented as the negative L2 distance.
65
+
66
+ Video-Language Alignment. To encourage $\mathcal { F } _ { \phi }$ to capture semantically relevant features, we train a language prediction module from the embedding outputted by $\mathcal { F } _ { \phi }$ . Essentially, by capturing features predictive of language, like “putting the apple on the plate”, the learned representation should capture semantically relevant parts of the scene like the plate and apple state, that are likely relevant to downstream manipulation tasks. Following Nair et al. [56], we train a model $\mathcal { G } _ { \theta } ( \mathcal { F } _ { \phi } ( I _ { 0 } ) , \mathcal { F } _ { \phi } ( I _ { i } ) , l )$ that takes in an initial image $I _ { 0 }$ , a future image $I _ { i }$ , language $l$ and outputs a score corresponding to if transitioning from $I _ { 0 }$ to $I _ { i }$ completes the language $l$ . We train the model under the objective that (1) the score should increase over the course of the video, and (2) the score should be higher for correct pairings of video/language than for incorrect pairings. Again we sample a video clip and paired language $[ I _ { i } , I _ { j > i } , l ] ^ { 1 : B }$ , and then train for this objective directly with a contrastive loss, that is:
67
+
68
+ $$
69
+ \mathcal { L } _ { l a n g u a g e } = - \sum _ { b \in B } \log \frac { e ^ { \mathcal { G } _ { \theta } ( z _ { 0 } ^ { b } , z _ { j > i } ^ { b } , l ^ { b } ) } } { e ^ { \mathcal { G } _ { \theta } ( z _ { 0 } ^ { b } , z _ { j > i } ^ { b } , l ^ { b } ) } + e ^ { \mathcal { G } _ { \theta } ( z _ { 0 } ^ { b } , z _ { i } ^ { b } , l ^ { b } ) } + e ^ { \mathcal { G } _ { \theta } ( z _ { 0 } ^ { \ne b } , z _ { j > i } ^ { \ne b } , l ^ { b } ) } }
70
+ $$
71
+
72
+ where again $z = \mathcal { F } _ { \phi } ( I )$ , and $z ^ { \neq b }$ is a negative example sampled from a different video in the batch (that does not match the language instruction $l ^ { b }$ ).
73
+
74
+ Regularization. Finally, we hypothesize that sparse and compact representations benefit control, particularly in low data imitation learning. State-distribution shift is a well studied failure mode in imitation learning [68], where policies trained with behavior cloning drift off the expert state distribution. Reducing the effective dimensionality of the state space (which we implement with a simple L1 and L2 penalty) can help mitigate this issue, as we demonstrate in Section 4.4.
75
+
76
+ R3M Summary $\pmb { \& }$ Implementation. The final objective for training R3M is the weighted sum:
77
+
78
+ $$
79
+ \mathcal { L } ( \phi , \theta ) = \mathbb { E } _ { I _ { 0 } ^ { 1 ; B } , \theta , \boldsymbol { k } \sim \mathcal { D } } [ \lambda _ { 1 } \mathcal { L } _ { t c n } + \lambda _ { 2 } \mathcal { L } _ { l a n g u a g e } + \lambda _ { 3 } | | \mathcal { F } _ { \phi } ( I _ { i } ) | | _ { 1 } + \lambda _ { 4 } | | \mathcal { F } _ { \phi } ( I _ { i } ) | | _ { 2 } ]
80
+ $$
81
+
82
+ In principle, R3M can be implemented on top of any encoding architecture for $\mathcal { F } _ { \phi }$ . In our experiments we focus on the ResNet50 architecture, and we release pre-trained R3M models with ResNet18, ResNet34, and ResNet50 architectures [69], as well as the accompanying training code. During training, $\phi$ and $\theta$ are trained with an Adam optimizer to minimize Equation 3. Lastly, R3M also trains with random cropping, applied at the video level (that is, within a batch all frames from the same video are cropped identically). Please see the appendix for further implementation details.
83
+
84
+ # 4 Experiments
85
+
86
+ In our experiments, we aim to study how the pre-trained R3M representation can be re-used for multiple downstream robot learning tasks. First, we study if R3M enables more data efficient imitation learning on unseen environments and tasks compared to existing visual representations and learning from scratch. Second, again in the data efficient imitation learning setting, we ablate the different components of the R3M training objective and observe that all components are important for final performance. Third, we study if R3M can enable efficient real robot learning in a visually rich household setting. Finally, in the appendix, we take a deeper look at task performance of R3M and prior methods with different amounts of data, different camera viewpoints, and different tasks.
87
+
88
+ # 4.1 Imitation Learning Evaluation Framework
89
+
90
+ Our evaluation methodology is loosely inspired by Parisi et al. [23]. We focus on evaluating visual representations as frozen perception modules for downstream policy learning with behavior cloning. Given a pretrained visual representation $\mathcal { F } _ { \phi }$ , we form the state representation as a concatenation of the visual embedding $z _ { t } = \mathcal { F } _ { \phi } ( I _ { t } )$ and the robot proprioceptive (e.g. joint positions and velocities) reading $p _ { t }$ . The policy, $\pi$ , is trained with a standard behavior cloning loss $| | a _ { t } - \pi ( [ z _ { t } , p _ { t } ] ) | | _ { 2 } ^ { 2 }$ . We parameterize $\pi$ as a two-layer MLP preceded by a BatchNorm at the input. We train the agent for 20,000 steps, evaluate it online in the environment every 1000 steps, and report the best success rate achieved. For each visual representation and each task, we run 3 seeds of behavior cloning. The final success rate reported on a task is the average over multiple seeds, viewpoints, and demo dataset sizes.
91
+
92
+ Comparisons and Baselines. We compare our R3M model to three existing visual representations that have been shown to be effective for control: CLIP [12] which trains image representations to be aligned with paired natural language through contrastive learning and has been shown to be useful for some manipulation [36] and navigation tasks [37], ImNet Supervised which uses features pre-trained for ImageNet classification task [2] and has been shown to be effective for reinforcement learning [38], and MoCo (345) (PVR) [23], which compresses and fuses the third, fourth, and fifth convolutional layers of a ResNet-50 model trained with MoCo [24] on ImageNet, and has been shown to be effective for imitation learning [23]. We note here that our usage of the Moco (345) model differs from the setup in Parisi et al. [23] in aspects like propreoception features, frame stacking etc. As a result, the numerical results are not directly comparable across the two works. At the same time, we emphasize that all visual representations are used in the same way within our evaluation protocol.
93
+
94
+ ![](images/79a21c838d560defeb4a965972e1188e57d21a2e6be3a512c7254c7e8cd2b130.jpg)
95
+ Figure 3: Simulated Evaluation Environments. We consider a comprehensive set of manipulation tasks in simulation (left), including 5 tasks with a Sawyer from MetaWorld [22], 5 tasks from a Franka operating over a Kitchen [21], and 2 dexterous manipulation tasks from Adroit [20], with multiple views per environment (right).
96
+
97
+ # 4.2 Simulation Environments
98
+
99
+ Next, we describe the environments and tasks used in our evaluations. For a comprehensive evaluation, we use three robot manipulation domains: MetaWorld [22], the Franka Kitchen environment [21], and Adroit [20] (See Figure 3). Note these environments are only used for downstream learning, and these environments and tasks are never seen during R3M training. In the MetaWorld environment we consider the tasks of assembling a ring onto a peg, picking and placing a block between bins, pushing a button, opening a drawer, and hammering a nail. In Franka Kitchen, we learn the tasks of sliding the right door open, opening the left door, turning on the light, turning the stove top knob, and opening the microwave. Finally, in Adroit we consider the tasks of reorienting the pen to the specified position, and picking and moving the ball to specified position. In all tasks, the agent is provided with image observations, as well as proprioceptive data of the robot (end-effector pose, joint positions, etc.) that is concatenated to the encoded image. All tasks involve variation, either by varying the position of the target object in MetaWorld, the positioning of the desk in Franka Kitchen, or the chosen goals in Adroit. For a robust evaluation, we consider multiple views for each environment (See Figure 3), and 3 dataset sizes: [5, 10, 25] in MetaWorld and Franka Kitchen, and [25, 50, 100] in the more challenging Adroit environments. Our comparisons measure performance for each environment and task, averaged over view, dataset size, and object or goal positions.
100
+
101
+ # 4.3 Exp. 1: Does R3M enable efficient imitation on unseen environments and tasks?
102
+
103
+ In this first experiment, we measure the success rate of downstream imitation learning using different visual representations. In Figure 4, we first notice that R3M is overall able to learn these vision based manipulation tasks in an extremely low data regime with ${ \approx } 6 2 \%$ success rate, despite never seeing any data from the target environments in training the representation, while outperforming learning from scratch by more than $20 \%$ . Moreover, we observe that R3M outperforms all prior representations by more than $10 \%$ on average across all 12 tasks. By training on diverse interactive video data, and with objectives that capture temporal structure and language relevance, R3M is the best performing method in all 3 environments, and on 11/12 of the tasks (See appendix for performance breakdown by task). The best two performing comparisons are CLIP and MoCo (345) (PVR), with CLIP performing better on MetaWorld, and MoCo (345) (PVR) performing better on Franka Kitchen and Adroit. Unsurprisingly, learning from scratch performs poorly in the low-data regime we study. Ultimately, we conclude that pre-trained visual representations are essential to good performance in the low-data imitation learning regime, and using R3M with diverse human video data is especially effective for learning representations useful for robotic manipulation.
104
+
105
+ ![](images/a16beebd0a9d2dddef3f5253dfafb27355ef1299f637f58e63b50fe980bb2a2f.jpg)
106
+ Figure 4: Data Efficient Imitation Learning in Unseen Environments/Tasks. We report the success rates of downstream imitation learning with standard error bars. We observe that across 12 tasks R3M outperforms baselines like MoCo (345) (PVR), CLIP, Supervised ImageNet features, and training from scratch.
107
+
108
+ In this experiment, we seek to understand the different components of R3M, beginning with the objective. Specifically, we compare the full R3M with R3M(-Aug), which does not use crop augmentations, R3M(-L1), which does not include $L 1$ regularization, and R3M(-Lang), which does not include include the
109
+
110
+ 4.4 Exp. 2: Which components of R3M are important?
111
+
112
+ <table><tr><td rowspan="2">Environment</td><td colspan="3">Supervised</td><td rowspan="2">Self-Supervised R3M(-Lang)</td></tr><tr><td>R3M</td><td>R3M(-Aug)</td><td>R3M(-L1)</td></tr><tr><td>Franka Kitchen</td><td>53.1 ±2.7%</td><td>51.1 ±2.7%</td><td>46.7 ±2.7%</td><td>47.2±2.9%</td></tr><tr><td>MetaWorld</td><td>69.2 ±2.0%</td><td>68.9 ±2.1%</td><td>65.0 ±2.4%</td><td>67.0±2.0%</td></tr><tr><td>Adroit</td><td>65.0 ±1.7%</td><td>61.3 ±2.1%</td><td>66.5 ±1.6%</td><td>45.6 ±3.3%</td></tr><tr><td>All Domains</td><td>62.4 ±1.3%</td><td>60.4 ±1.4%</td><td>59.4 ±1.5%</td><td>53.2 ±1.5%</td></tr></table>
113
+
114
+ Table 1: Ablating Components of R3M. We see report success rate of downstream imitation learning on variants of R3M. We observe that on average, removing the L1 penalty have a negative impact, particularly on the Franka Kitchen and MetaWorld environments. Lastly, removing language grounding has the most significant drop in performance, particularly on the Adroit tasks.
115
+
116
+ video-language alignment loss. In Table 1, we report success rates per environment and averaged over all environments. First, we notice that on average across the three environments, we see a drop in performance of ${ \approx } 2 \%$ from removing crop augmentation or from removing the $L 1$ regularization. Interestingly, the impact of removing the sparsity regularization depends on the environment. In Franka Kitchen and MetaWorld, sparsity is helpful, while in Adroit removing sparsity actually helps performance slightly. We suspect this is partly due to the Adroit environment using more demonstrations, mitigating the state distribution shift issue.
117
+
118
+ We see that across all environments, removing video-language alignment loss has the largest negative impact on performance, particularly in the Adroit environment. We hypothesize that language alignment plays an important role in better capturing semantic features that might be predictive of objects and useful for object manipulation. Nevertheless, we note that even in the fully self-supervised regime, our R3M model still outperforms prior state of the art visual representations like ImageNet trained MoCo (345) (PVR) [23] and CLIP [12] by a significant margin.
119
+
120
+ Next, we seek to answer the question: How important is the data? To do so we include comparisons that disentangles the role of the dataset and the training objective. In particular, we have trained a MoCo model on the exact same frames of the Ego4D dataset used to train our R3M model (See Table 2). Additionally we compare to the MVP model [70], which trains a ViT-B masked auto-encoder on the Ego-soup dataset, which comprises of Ego4D and other egocentric video datasets.. We evaluate these comparisons on the Franka Kitchen and Adroit environments, and find that the MoCo-Ego4D model, which uses the same data and compute as R3M, gets an average success rate $\sim 1 0 \%$ lower than R3M in both environments. Moreover, we find the MVP models performs $\sim 2 0 \%$ worse than R3M. This suggests that while there is indeed a large benefit coming from diverse human video data compared to static ImageNet images $34 \% $ $42 \%$ on Franka), the data is not the only source of improvement, and the R3M objective provides an additional $\sim 1 0 \%$ boost in success rate.
121
+
122
+ Table 2: Importance of Data vs. Algorithm. We find that the MoCo-Ego4D and MVP models, which leverage the same or more data and compute as R3M perform more than $10 \%$ worse.
123
+
124
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Franka</td><td rowspan=1 colspan=1>Adroit</td></tr><tr><td rowspan=1 colspan=1>R3M</td><td rowspan=1 colspan=1>53.1(2.7)</td><td rowspan=1 colspan=1>65.0 (1.7)</td></tr><tr><td rowspan=1 colspan=1>MoCo-Ego4D</td><td rowspan=1 colspan=1>42.0 (2.8)</td><td rowspan=1 colspan=1>54.9 (2.7)</td></tr><tr><td rowspan=1 colspan=1>MVP([70])</td><td rowspan=1 colspan=1>27.0 (2.6)</td><td rowspan=1 colspan=1>51.4 (2.7)</td></tr></table>
125
+
126
+ ![](images/f81cc6e7a3927b360d7d61cf04c55603b59e5429a88c4145efe9098aa30e2d85.jpg)
127
+ Figure 5: Real World Robot Learning with R3M. With R3M we are able to learn challenging tasks like putting lettuce in the pan, pushing the cup to the goal, and folding the towel from just 20 demonstrations. See appendix for more examples of real robot tasks and details about the robot setup.
128
+
129
+ # 4.5 Exp. 3: Does R3M enable data efficient learning in real world environments?
130
+
131
+ Finally, we test if R3M can enable data-efficient robot learning in cluttered real-world environments. To do so, we bring a Franka Emika Panda robot into a real graduate student apartment, and aim to learn household tasks from pixels with just 20 demonstrations per task, using the pre-trained R3M representation. We have the robot complete five tasks: (1) closing a dresser drawer, (2) picking a face mask placed randomly on a desk and placing it in the dresser drawer, (3) picking up lettuce randomly placed on a cutting board and putting in a cooking pan, (4) pushing a mug to a goal location, and (5) folding a towel (See Figure 5). Like in our simulation experiments, we collect a small number of demonstrations and do simple behavior cloning with the pre-trained representation.
132
+
133
+ In Table 3, we report the success rates comparing R3M and CLIP, one of the stronger baselines from our evaluations in simulation. We observe that while the two perform similarly on the easier task of closing the drawer, R3M consistently performs better on the other four tasks (See Figure 5), which require more precise visual representations, yielding nearly double the success rate on average.
134
+
135
+ # 5 Limitations and Future Work
136
+
137
+ <table><tr><td>Success out of 10 trials</td><td>R3M</td><td>CLIP</td></tr><tr><td>Closing Drawer Putting Mask in Dresser</td><td>80% 30%</td><td>70% 10%</td></tr><tr><td>Putting Lettuce in Pan Pushing Mug to Goal</td><td>60% 70%</td><td>0% 40%</td></tr><tr><td>Folding Towel</td><td>40%</td><td>0%</td></tr><tr><td>Average</td><td>56%</td><td>24%</td></tr></table>
138
+
139
+ Table 3: Real World Success Rates. R3M outperforms CLIP on the challenging real world manipulation tasks.
140
+
141
+ In this work, we set out to study if pre-training visual representations on diverse human videos can enable efficient learning of downstream robotic manipulation tasks. While we were excited by strong results on a wide set of simulated and real robotic tasks, a number of important limitations remain. Our current evaluation is limited to imitation learning, specifically behavior cloning, with a small number of task demonstrations. While we would hope to see R3M be equally beneficial for other robotic learning settings like reinforcement learning, it could be the case that a good pretrained representation for RL is not the same as a good pre-trained representation for imitation. Studying how R3M performs in RL settings, and changes that may need to made to improve its performance is an exciting next step. The current R3M model also only provides a single-frame state representation. In principle, pre-training on human videos should be able to go beyond state representations (e.g. reward learning and task specification). Studying if R3M embeddings or the language grounding module can provide a useful reward signal is an interesting direction for future work.
142
+
143
+ # Acknowledgments
144
+
145
+ The authors would like to thank the Ego4D team at Meta AI for assistance in using the dataset. We’d also like to thank Karl Pertsch, Simone Parisi, Sidd Karamcheti, and numerous members of Meta AI and the IRIS labs for valuable discussions. This work is in part supported by ONR grant N00014-22-1-2621. Finally, the authors would also like to thank Evan Coleman for assistance with the robot.
146
+
147
+ # References
148
+
149
+ [1] S. Levine, C. Finn, T. Darrell, and P. Abbeel. End-to-end training of deep visuomotor policies. The Journal of Machine Learning Research, 17(1):1334–1373, 2016.
150
+ [2] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. ImageNet: A Large-Scale Hierarchical Image Database. In CVPR09, 2009.
151
+ [3] D. Mzurikwao, M. Khan, O. Samuel, J. Cinatl, M. Wass, M. Michaelis, G. Marcelli, and C. S. Ang. Towards image-based cancer cell lines authentication using deep neural networks. Scientific Reports, 10, 11 2020. doi:10.1038/s41598-020-76670-6.
152
+ [4] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT), Minneapolis, Minnesota, June 2019. Association for Computational Linguistics.
153
+ [5] Z. Zhang, J. Liu, and N. Razavian. BERT-XML: Large scale automated ICD coding using BERT pretraining. In Proceedings of the 3rd Clinical Natural Language Processing Workshop, pages 24–34, Online, Nov. 2020. Association for Computational Linguistics. doi:10.18653/v1/ 2020.clinicalnlp-1.3. URL https://aclanthology.org/2020.clinicalnlp-1.3.
154
+ [6] Z. Yang, N. Garcia, C. Chu, M. Otani, Y. Nakashima, and H. Takemura. Bert representations for video question answering. In 2020 IEEE Winter Conference on Applications of Computer Vision (WACV), pages 1545–1554, 2020. doi:10.1109/WACV45572.2020.9093596.
155
+ [7] S. Dasari, F. Ebert, S. Tian, S. Nair, B. Bucher, K. Schmeckpeper, S. Singh, S. Levine, and C. Finn. Robonet: Large-scale multi-robot learning. In Conference on Robot Learning, 2019.
156
+ [8] A. Mandlekar, J. Booher, M. Spero, A. Tung, A. Gupta, Y. Zhu, A. Garg, S. Savarese, and L. Fei-Fei. Scaling robot supervision to hundreds of hours with roboturk: Robotic manipulation dataset through human reasoning and dexterity. In 2019 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 1048–1055. IEEE, 2019.
157
+ [9] S. Young, D. Gandhi, S. Tulsiani, A. Gupta, P. Abbeel, and L. Pinto. Visual imitation made easy. In CoRL, 2020.
158
+ [10] F. Ebert, Y. Yang, K. Schmeckpeper, B. Bucher, G. Georgakis, K. Daniilidis, C. Finn, and S. Levine. Bridge data: Boosting generalization of robotic skills with cross-domain datasets. ArXiv, abs/2109.13396, 2021.
159
+ [11] T. B. Brown et al. Language models are few-shot learners. arXiv:2005.14165, 2020.
160
+ [12] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, G. Krueger, and I. Sutskever. Learning transferable visual models from natural language supervision. In ICML, 2021.
161
+ [13] P. Goyal, Q. Duval, I. Seessel, M. Caron, I. Misra, L. Sagun, A. Joulin, and P. Bojanowski. Vision models are more robust and fair when pretrained on uncurated images without supervision. ArXiv, abs/2202.08360, 2022.
162
+ [14] R. Goyal, S. Ebrahimi Kahou, V. Michalski, J. Materzynska, S. Westphal, H. Kim, V. Haenel, I. Fruend, P. Yianilos, M. Mueller-Freitag, et al. The” something something” video database for learning and evaluating visual common sense. In Proceedings of the IEEE International Conference on Computer Vision, pages 5842–5850, 2017.
163
+ [15] D. Damen, H. Doughty, G. M. Farinella, S. Fidler, A. Furnari, E. Kazakos, D. Moltisanti, J. Munro, T. Perrett, W. Price, and M. Wray. Scaling egocentric vision: The epic-kitchens dataset. In European Conference on Computer Vision (ECCV), 2018.
164
+ [16] K. Grauman et al. Ego4D: Around the World in 3,000 Hours of Egocentric Video, 2021.
165
+ [17] L. Shao, T. Migimatsu, Q. Zhang, K. Yang, and J. Bohg. Concept2robot: Learning manipulation concepts from instructions and human demonstrations. In Proceedings of Robotics: Science and Systems (RSS), 2020.
166
+ [18] A. S. Chen, S. Nair, and C. Finn. Learning generalizable robotic reward functions from ”in-the-wild” human videos. ArXiv, abs/2103.16817, 2021.
167
+ [19] P. Sermanet, C. Lynch, Y. Chebotar, J. Hsu, E. Jang, S. Schaal, and S. Levine. Time-contrastive networks: Self-supervised learning from video. Proceedings of International Conference in Robotics and Automation (ICRA), 2018.
168
+ [20] A. Rajeswaran, V. Kumar, A. Gupta, J. Schulman, E. Todorov, and S. Levine. Learning complex dexterous manipulation with deep reinforcement learning and demonstrations. ArXiv, abs/1709.10087, 2018.
169
+ [21] A. Gupta, V. Kumar, C. Lynch, S. Levine, and K. Hausman. Relay policy learning: Solving long-horizon tasks via imitation and reinforcement learning. In CoRL, 2019.
170
+ [22] T. Yu, D. Quillen, Z. He, R. Julian, K. Hausman, C. Finn, and S. Levine. Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In Conference on Robot Learning, 2020.
171
+ [23] S. Parisi, A. Rajeswaran, S. Purushwalkam, and A. K. Gupta. The unsurprising effectiveness of pre-trained vision models for control. 2022.
172
+ [24] K. He, H. Fan, Y. Wu, S. Xie, and R. B. Girshick. Momentum contrast for unsupervised visual representation learning. 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 9726–9735, 2020.
173
+ [25] M. Laskin, K. Lee, A. Stooke, L. Pinto, P. Abbeel, and A. Srinivas. Reinforcement learning with augmented data. ArXiv, abs/2004.14990, 2020.
174
+ [26] A. Srinivas, M. Laskin, and P. Abbeel. Curl: Contrastive unsupervised representations for reinforcement learning. In ICML, 2020.
175
+ [27] I. Kostrikov, D. Yarats, and R. Fergus. Image augmentation is all you need: Regularizing deep reinforcement learning from pixels. ArXiv, abs/2004.13649, 2021.
176
+ [28] J. Pari, N. M. M. Shafiullah, S. P. Arunachalam, and L. Pinto. The surprising effectiveness of representation learning for visual imitation. ArXiv, abs/2112.01511, 2021.
177
+ [29] C. Gelada, S. Kumar, J. Buckman, O. Nachum, and M. G. Bellemare. Deepmdp: Learning continuous latent space models for representation learning. ArXiv, abs/1906.02736, 2019.
178
+ [30] D. Hafner, T. P. Lillicrap, J. Ba, and M. Norouzi. Dream to control: Learning behaviors by latent imagination. ArXiv, abs/1912.01603, 2020.
179
+ [31] A. Zhang, R. McAllister, R. Calandra, Y. Gal, and S. Levine. Learning invariant representations for reinforcement learning without reconstruction. ArXiv, abs/2006.10742, 2021.
180
+ [32] S. Nair, S. Savarese, and C. Finn. Goal-aware prediction: Learning to model what matters. ArXiv, abs/2007.07170, 2020.
181
+ [33] M. Hong, K. Lee, M. Kang, W. Jung, and S. Oh. Dynamics-aware metric embedding: Metric learning in a latent space for visual planning. IEEE Robotics and Automation Letters, 2022.
182
+ [34] R. Jonschkowski and O. Brock. Learning state representations with robotic priors. Autonomous Robots, 39:407–428, 10 2015. doi:10.1007/s10514-015-9459-7.
183
+ [35] Y.-C. Lin, A. Zeng, S. Song, P. Isola, and T.-Y. Lin. Learning to see before learning to act: Visual pre-training for manipulation. 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 7286–7293, 2020.
184
+ [36] M. Shridhar, L. Manuelli, and D. Fox. Cliport: What and where pathways for robotic manipulation. In CoRL, 2021.
185
+ [37] A. Khandelwal, L. Weihs, R. Mottaghi, and A. Kembhavi. Simple but effective: Clip embeddings for embodied ai. ArXiv, abs/2111.09888, 2021.
186
+ [38] R. Shah and V. Kumar. Rrl: Resnet as representation for reinforcement learning. ArXiv, abs/2107.03380, 2021.
187
+ [39] Y. Seo, K. Lee, S. James, and P. Abbeel. Reinforcement learning with action-free pre-training from videos. ArXiv, abs/2203.13880, 2022.
188
+ [40] T. Xiao, I. Radosavovic, T. Darrell, and J. Malik. Masked visual pre-training for motor control. 2022.
189
+ [41] Y. Liu, A. Gupta, P. Abbeel, and S. Levine. Imitation from observation: Learning to imitate behaviors from raw video via context translation. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pages 1118–1125. IEEE, 2018.
190
+ [42] P. Sharma, D. Pathak, and A. Gupta. Third-person visual imitation learning via decoupled hierarchical controller. In NeurIPS, 2019.
191
+ [43] L. Smith, N. Dhawan, M. Zhang, P. Abbeel, and S. Levine. AVID: Learning Multi-Stage Tasks via Pixel-Level Translation of Human Videos. In Proceedings of Robotics: Science and Systems, Corvalis, Oregon, USA, July 2020.
192
+ [44] T. Yu, C. Finn, S. Dasari, A. Xie, T. Zhang, P. Abbeel, and S. Levine. One-shot imitation from observing humans via domain-adaptive meta-learning. In Proceedings of Robotics: Science and Systems, Pittsburgh, Pennsylvania, June 2018.
193
+ [45] K. Schmeckpeper, A. Xie, O. Rybkin, S. Tian, K. Daniilidis, S. Levine, and C. Finn. Learning predictive models from observation and interaction. In ECCV, 2020.
194
+ [46] A. D. Edwards and C. L. Isbell. Perceptual values from observation. arXiv preprint arXiv:1905.07861, 2019.
195
+ [47] K. Schmeckpeper, O. Rybkin, K. Daniilidis, S. Levine, and C. Finn. Reinforcement learning with videos: Combining offline observations with interaction. In CoRL, 2020.
196
+ [48] R. Scalise, J. Thomason, Y. Bisk, and S. Srinivasa. Improving robot success detection using static object data. In Proceedings of the 2019 IEEE/RSJ International Conference on Intelligent Robots and Systems, 2019.
197
+ [49] S. Pirk, M. Khansari, Y. Bai, C. Lynch, and P. Sermanet. Online object representations with contrastive learning, 2019.
198
+ [50] H. Xiong, Q. Li, Y.-C. Chen, H. Bharadhwaj, S. Sinha, and A. Garg. Learning by watching: Physical imitation of manipulation skills from human videos, 2021.
199
+ [51] N. Das, S. Bechtle, T. Davchev, D. Jayaraman, A. Rai, and F. Meier. Model-based inverse reinforcement learning from visual demonstrations, 2021.
200
+ [52] K. Zakka, A. Zeng, P. Florence, J. Tompson, J. Bohg, and D. Dwibedi. Xirl: Cross-embodiment inverse reinforcement learning, 2021.
201
+ [53] S. Stepputtis, J. Campbell, M. Phielipp, S. Lee, C. Baral, and H. B. Amor. Language-conditioned imitation learning for robot manipulation tasks. ArXiv, abs/2010.12083, 2020.
202
+ [54] C. Lynch and P. Sermanet. Grounding language in play. ArXiv, abs/2005.07648, 2020.
203
+ [55] Y. Cui, S. Niekum, A. Gupta, V. Kumar, and A. Rajeswaran. Can Foundation Models Perform Zero-Shot Task Specification For Robot Manipulation? In L4DC, 2022.
204
+ [56] S. Nair, E. Mitchell, K. Chen, B. Ichter, S. Savarese, and C. Finn. Learning language-conditioned robot behavior from offline data and crowd-sourced annotation. In CoRL, 2021.
205
+ [57] L. Pinto and A. Gupta. Supersizing self-supervision: Learning to grasp from 50k tries and 700 robot hours. In IEEE international conference on robotics and automation (ICRA), 2016.
206
+ [58] P. Sharma, L. Mohan, L. Pinto, and A. K. Gupta. Multiple interactions made easy (mime): Large scale demonstrations data for imitation. In CoRL, 2018.
207
+ [59] E. Jang, A. Irpan, M. Khansari, D. Kappler, F. Ebert, C. Lynch, S. Levine, and C. Finn. Bcz: Zero-shot task generalization with robotic imitation learning. In A. Faust, D. Hsu, and G. Neumann, editors, Proceedings of the 5th Conference on Robot Learning, volume 164 of Proceedings of Machine Learning Research, pages 991–1002. PMLR, 08–11 Nov 2022. URL https://proceedings.mlr.press/v164/jang22a.html.
208
+ [60] X. Wang and A. K. Gupta. Unsupervised learning of visual representations using videos. 2015 IEEE International Conference on Computer Vision (ICCV), pages 2794–2802, 2015.
209
+ [61] P. Sermanet, K. Xu, and S. Levine. Unsupervised perceptual rewards for imitation learning. Proceedings of Robotics: Science and Systems (RSS), 2017.
210
+ [62] X. Wang, A. Jabri, and A. A. Efros. Learning correspondence from the cycle-consistency of time. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 2561–2571, 2019.
211
+ [63] A. Jabri, A. Owens, and A. A. Efros. Space-time correspondence as a contrastive random walk. ArXiv, abs/2006.14613, 2020.
212
+ [64] M. Goyal, S. Modi, R. Goyal, and S. Gupta. Human hands as probes for interactive object understanding. In Computer Vision and Pattern Recognition (CVPR), 2022.
213
+ [65] A. Miech, D. Zhukov, J.-B. Alayrac, M. Tapaswi, I. Laptev, and J. Sivic. Howto100m: Learning a text-video embedding by watching hundred million narrated video clips. 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pages 2630–2640, 2019.
214
+ [66] H. Xu, G. Ghosh, P.-Y. Huang, D. Okhonko, A. Aghajanyan, and F. M. L. Z. C. Feichtenhofer. Videoclip: Contrastive pre-training for zero-shot video-text understanding. ArXiv, abs/2109.14084, 2021.
215
+ [67] A. van den Oord, Y. Li, and O. Vinyals. Representation learning with contrastive predictive coding. ArXiv, abs/1807.03748, 2018.
216
+ [68] S. Ross, G. J. Gordon, and J. A. Bagnell. A reduction of imitation learning and structured prediction to no-regret online learning. In AISTATS, 2011.
217
+ [69] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 770–778, 2016.
218
+ [70] I. Radosavovic, T. Xiao, S. James, P. Abbeel, J. Malik, and T. Darrell. Real-world robot learning with masked visual pre-training. CoRL, 2022.
219
+ [71] V. Sanh, L. Debut, J. Chaumond, and T. Wolf. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. ArXiv, abs/1910.01108, 2019.
220
+
221
+ # A R3M Training Details
222
+
223
+ # A.1 Data Preprocessing
224
+
225
+ The Ego4D dataset consists of several hour long videos within a certain scene. Within each scene, there are many sub-clips, each with a natural language annotation. R3M trains with these shorter video clips paired with language annotations.
226
+
227
+ For faster training R3M parses each video clip into frames (Resized and cropped to $2 2 4 \mathbf { x } 2 2 4 )$ and samples frames from a video clip individually. See the codebase for more details on the implementation of sampling the videos.
228
+
229
+ # A.2 Training Architecture and Hyper-Parameters
230
+
231
+ R3M can in principle be trained with any visual encoding architecture for $\mathcal { F } _ { \phi }$ . We train with off the shelf ResNet18, 34, and 50 [69], as implemented by torchvision.models.
232
+
233
+ The language prediction head is implemented as an 5 layer MLP with sizes $[ 2 ^ { * } E + L$ , 1024, 1024, 1024, 1024] and output a scalar score, where $E$ is the output dimension of $\mathcal { F } _ { \phi }$ and $L$ is the output dimension of the DistilBERT [71] sentence encoder (768) from HuggingFace transformers.
234
+
235
+ During training of R3M, we use batch sizes of 16 video clips (where 5 frames are samples from each video clip: an initial image, final image, and sequence of 3 frames). The initial and final frames are sampled from the first and last $20 \%$ of the video clip.
236
+
237
+ R3M models are trained for one million steps in our experiments, and for 1.5 million steps in our released models, with a learning rate of 0.0001.
238
+
239
+ For the training objective in Equation 3, we use hyperparameters $\lambda _ { 1 } ~ = ~ 1 , \lambda _ { 2 } ~ = ~ 1 , \lambda _ { 3 } ~ =$ $0 . 0 0 0 0 1 , \lambda _ { 4 } = 0 . 0 0 0 0 1$ .
240
+
241
+ # A.3 Additional Implementation Details
242
+
243
+ In practice, we use more than one negative video example in training Equations 1 and 2. Instead we use 3 negative examples, sampled from different videos in the batch.
244
+
245
+ Additionally in training for Equation 2, we consider the following positive pairs within a single batch element: Initial and Final Frames $( I _ { 0 } , I _ { g } )$ , $\left( I _ { 0 } , I _ { j > i } \right)$ , and $\left( I _ { 0 } , I _ { k > j } \right)$ , with corresponding negatives $( I _ { 0 } , I _ { 0 } )$ , $( I _ { 0 } , I _ { i } )$ , and $( I _ { 0 } , I _ { j } )$ respectively. Using a larger number of positive examples from a single video and multiple negative examples from different videos stabilizes training.
246
+
247
+ # A.4 Example Usage
248
+
249
+ Using R3M is simple. The codebase is located at https://github.com/facebookresearch/r3m. Simply clone the repo and install via pip install -e . Then R3M can be loaded by running:
250
+
251
+ from r3m import load_r3m 2 r3m $=$ load_r3m (" resnet50 ") # resnet18 , resnet34 3 r3m . eval ()
252
+
253
+ # B Evaluation Details
254
+
255
+ # B.1 Simulation Environments
256
+
257
+ We focus on three simulation environments: Franka Kitchen, MetaWorld, and Adroit.
258
+
259
+ Franka Kitchen. The Franka Kitchen environments used in this paper are modified from the original environment; specifically, we add additional randomization to the scene. We randomly change the position of the kitchen between episodes, making the task significantly more challenging both in perception and control.
260
+
261
+ The 5 tasks in the Franka Kitchen involve opening the left door, opening the sliding door, turning on the light, turning the knob, and opening the microwave. All Franka tasks include proprioceptive data of the arm joint positions and gripper positions. The horizon for all Franka tasks is 50 steps, and our imitation experiments use either 5, 10, or 25 demos.
262
+
263
+ ![](images/3b7ced0832de197b999498df4d487e291caf9cea608c36ac3e4808a43e0ce415.jpg)
264
+ Figure 6: Real World Robot Learning with R3M. With R3M we are able to learn challenging tasks like closing the drawer, putting the mask in the dresser, putting lettuce in the pan, pushing the cup to the goal, and folding the towel from just 20 demonstrations.
265
+
266
+ MetaWorld. The MetaWorld environments are the standard V2 Button Pressing, Bin Picking, Drawer Opening, Hammer, and Assembly environments available in MetaWorld [22]. In all tasks, the target object (drawer, peg, block, etc.) position is randomized between episodes.
267
+
268
+ All MetaWorld tasks include proprioceptive data of the gripper end effector pose and gripper open/- close. The horizon for all MetaWorld tasks is 500 steps, and our imitation experiments use either 5, 10, or 25 demos.
269
+
270
+ Adroit. We use the standard Pen and Relocate tasks in the Adroit hand manipulation suite. The goal position of the pen and the goal position of the ball are randomized between episodes, and specified visually.
271
+
272
+ All Adroit tasks include proprioceptive data of the hand joints, and in the Relocate task also includes the global position of the hand. The horizon for the Pen task is 100 steps and for the Relocate task is 200 steps. Our imitation experiments use either 25, 50, or 100 demos.
273
+
274
+ # B.2 Real World Environments
275
+
276
+ Our real world experiments involve bringing a Franka Emika Panda robot into a real graduate student apartment. The tasks involve putting lettuce in a pan in the kitchen, pushing a mug to a goal position on a dining table, closing a drawer, putting a mask in a drawer, and folding a towel (See Figure 6). All tasks involve randomization (e.g. the towel/lettuce/mug/mask position or drawer position). The initial state of the gripper is also randomized each episode.
277
+
278
+ ![](images/789191667ec3f87a5dc905d3b8489fb17f9b44264a3662234df19f530713515f.jpg)
279
+ Figure 7: Real Robot Camera Viewpoints. Camera view used for learning each of the real robot tasks.
280
+
281
+ The robot observation includes RGB images froma USB webcam, positioned differently for each task (See Figure 7). The robot end effector position is also concatenated with the image embedding during imitation learning.
282
+
283
+ # B.3 Demo Data Collection
284
+
285
+ In the Franka Kitchen and Adroit tasks, expert data is generated by training a state based agent with model free RL [20]. The state based trajectories are then replayed and rendered with image observations.
286
+
287
+ In the MetaWorld environment, a heuristic policy using state information is used to generate expert data, which is then replayed and rendered with image observations.
288
+
289
+ On the real robot, demonstrations are collected by a human tele-operator with a PlayStation controller. The control is applied directly in the end effector Cartesian space, and the demo trajectories are directly saved with visual observations.
290
+
291
+ # B.4 Comparisons
292
+
293
+ In all experiments all models use a ResNet50 base architecture.
294
+
295
+ CLIP: The CLIP comparison uses the of the shelf CLIP RN50 model available at https://github.
296
+ com/openai/CLIP.
297
+
298
+ ImNet Supervised: This comparison uses the default ResNet architecture available from torchvision.models with pretrained $\cdot ^ { = }$ True.
299
+
300
+ MoCo (345): This comparison uses a pre-trained MoCo model on Imagenet which fuses the third, fourth, and fifth convolutional layers as proposed in [23].
301
+
302
+ Note that our usage of the Moco (345) model differs from the setup in Parisi et al. [23] in aspects like proprioception features, frame stacking etc. As a result, the numerical results are not directly comparable across the two works.
303
+
304
+ Scratch: uses the default ResNet architecture available from torchvision.models with pretrained $\equiv$ False. Additionally, it lets gradients from the behavior cloning MSE loss pass into the visual encoder.
305
+
306
+ MoCo-Ego4D: This comparison uses a pre-trained MoCo model on the samed data as R3M from the Ego4D dataset.
307
+
308
+ MVP: This comparison uses a pretrained MVP [40, 70] model, which trains an MAE with a ViT-B architecture on the Ego-Soup dataset, which consists of Ego4D and other egocentric human video datasets.
309
+
310
+ # B.5 Behavior Cloning Hyperparameters
311
+
312
+ The downstream policy is a 2 layer MLP with hidden sizes [256,256] preceded by a BatchNorm. The input to the policy is the concatenated visual embedding and proprioceptive data, and the output is
313
+
314
+ ![](images/f7a1c5a5f61715b2ab56840e2bcc414d37baf35815ccf41900561354230647f6.jpg)
315
+ Figure 8: Performance over different views/dataset sizes. We report the success rate of R3M and baseline across each view (left) and dataset size (right). We see that the performance improvement from R3M is consistent across all views. We also observe that while absolute performance increases with more demos, the performance improvement from R3M is consistent across all demo sizes.
316
+
317
+ the action. The policy is trained with a learning rate of 0.001, and a batch size of 32 for 20000 steps, evaluating every 1000.
318
+
319
+ # C Additional Results
320
+
321
+ # C.1 How does performance vary across viewpoint and demo dataset size?
322
+
323
+ In our next experiment, we take a closer look at R3M performance compared to prior methods across viewpoints and dataset sizes. In Figure 8, we plot the average success rate of each method across each dataset size and viewpoint. We observe that the performance improvement of R3M is consistent across all viewpoints, and it is the highest performing representation in all cases. Interestingly, we see that the same does not hold amongst the prior methods, where the ranking between MoCo (345) and CLIP changes based on the chosen viewpoint.
324
+
325
+ Additionally, we also study the impact of dataset size for imitation learning. Again, we observe that the performance improvement from R3M is consistent, outperforming the baselines across every environment and demo dataset size. We observe that in the Franka Kitchen and Adroit environments, the performance gain from R3M stays consistent with increase in dataset size, even as the absolute performance of all methods improves. Overall, we clearly observe that the performance benefit of R3M is not tied to a specific viewpoint or dataset size.
326
+
327
+ # C.2 Performance Breakdown By Task
328
+
329
+ In Figure 9 we report the success rate on each task individually. Note each success rate for each method is still the average over 3 views, 3 demo sizes, and 3 seeds. We observe that on 11/12 tasks R3M is the highest performing method.
330
+
331
+ ![](images/19f22ab8667bc2542e959c946f96a8f6adc68e026fea187148f6dfa6449e439f.jpg)
332
+ Assembly, Bin Picking, Button Pressing, Drawer Opening, Hammering
333
+ Sliding Door, Turning Light On, Opening Door, Turning Knob, Opening Microwave
334
+ Figure 9: Per task Success Rate. We observe that R3M is the highest performing method on 11/12 tasks.
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/tZXaHWfsXB/tZXaHWfsXB.md ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Transcending Scaling Laws with $0 . 1 \%$ Extra Compute
2
+
3
+ Yi Tay† Jason Wei† Hyung Won Chung† Vinh Q. Tran David R. $\mathbf { S _ { 0 } } _ { } ^ { \dagger }$ Siamak Shakeri Xavier Garcia Huaixiu Steven Zheng Jinfeng Rao† Aakanksha Chowdhery Denny Zhou Donald Metzler Slav Petrov Neil Houlsby Quoc V. Le Mostafa Dehghani Google {vqtran,dehghani}@google.com
4
+
5
+ # Abstract
6
+
7
+ Scaling language models improves performance but comes with significant computational costs. This paper proposes UL2R, a method that substantially improves existing language models and their scaling curves with a relatively tiny amount of extra compute. The key idea is to continue training a state-of-theart large language model on a few more steps with UL2’s mixture-of-denoiser objective. We show that, with almost negligible extra computational costs and no new sources of data, we are able to substantially improve the scaling properties of large language models on downstream metrics. In this paper, we continue training a baseline language model, PaLM, with UL2R, introducing a new set of models at 8B, 62B, and 540B scale which we call UPaLM. Impressively, at 540B scale, we show an approximately 2x computational savings rate where U-PaLM achieves the same performance as the final PaLM 540B model at around half its computational budget (i.e., saving ${ \sim } 4 . 4$ million TPUv4 hours). We further show that this improved scaling curve leads to “emergent abilities” on challenging BIG-Bench tasks—for instance, U-PaLM does much better on some tasks or demonstrates better quality at much smaller scale (62B as opposed to 540B). Overall, we show that U-PaLM outperforms PaLM on many few-shot setups, including reasoning tasks with chain-of-thought (e.g., GSM8K), multilingual tasks (MGSM, TydiQA), MMLU and challenging BIG-Bench tasks.
8
+
9
+ # 1 Introduction
10
+
11
+ There has been significant interest in scaling of language models [Rae et al., 2021, Chowdhery et al., 2022, Brown et al., 2020]. Scaling has inspired new research across multiple fronts, e.g., scaling laws [Kaplan et al., 2020, Hoffmann et al., 2022, Tay et al., 2022a], emergent abilities [Wei et al., 2022a, Ganguli et al., 2022], reasoning capabilities [Wei et al., 2022b, Lewkowycz et al., 2022], inter alia. Generally, scaling laws predict a continued improvement in language model quality as we continue to scale up the computational budget (e.g., bigger models or more data). To date, most large language models that form the basis of scaling law research are trained almost exclusively as left-to-right causal language models [Kaplan et al., 2020, Hoffmann et al., 2022].
12
+
13
+ ![](images/dba9c2509b52640057f41a29191caed53155bc95d61b08546cc4068d75bdc7d9.jpg)
14
+ Figure 1: Compute (training flops) versus Quality (average of $^ { 2 0 + }$ NLP zero and few-shot tasks listed in Appendix 11.2). The black dotted line shows the path from initialization from a PaLM checkpoint and training further with UL2R.
15
+
16
+ This paper proposes a new method to dramatically improve the scaling curves of large language models on downstream performance with a relatively tiny amount of additional computation cost. The key idea is to continue training an existing causal language model [Chowdhery et al., 2022] with a mixture of new objectives—specifically, the UL2 training objective mixture [Tay et al., 2022b]. This restoration is expected to only cost roughly $0 . 1 \%$ to $1 \%$ of the original training FLOPs and requires no new data sources, making it highly efficient and convenient. We call this approach UL2R or UL2Restore.
17
+
18
+ The UL2 objective combines prefix language modeling and long-short span corruption (e.g., infilling) tasks [Raffel et al., 2019] that can be controlled at inference time using a mode switching prompt. Training a large language model with UL2 can be interpreted as teaching it to leverage bidirectional attention (i.e., PrefixLM) or leverage infilling-style pretraining that have been the foundation of language understanding (e.g., T5 [Raffel et al., 2019]). To this end, we postulate that imbuing a state-of-theart large language model such as PaLM [Chowdhery et al., 2022] with these diverse pretraining schemes as a complement to the original language model objective, enables the model to perform significantly better. Moreover, the UL2 objective enables new prompting capabilities in PaLM which allows it to perform infilling based prompting.
19
+
20
+ We show that adapting PaLM with UL2R not only results in significantly better scaling laws on well-established few-shot NLP tasks, but also, in our scaling experiments on downstream few-shot tasks, we show that UL2R is two times more efficient (computation savings of approximately 2x) at 540B scale - reaching the performance of the final PaLM 540B model with only half the computation, saving up to 4.4 million TPUv4 hours.
21
+
22
+ In addition to competitive performance across a range of well-established NLP [Wang et al., 2019], multilingual [Clark et al., 2020a, Shi et al., 2022], and reasoning [Cobbe et al., 2021] benchmarks, we also study the impact of UL2R on a suite of challenging BigBench tasks from Wei et al. [2022a]. Notably, a subset of tasks are described as ‘emergent‘ because PaLM’s performance remains flat up to model scale of 62B and only becomes better than non-random at 540B scale. On these set of tasks, we find that UL2R enables (1) doing significantly better at tasks that PaLM struggles at (e.g., navigate, geometric shapes, hyperbaton) and (2) elicits emergent behavior at a smaller scale such as 62B or 8B (e.g., crass ai, vitaminc fact verification). On top of that, U-PaLM strongly outperforms PaLM on some challenging BigBench tasks.
23
+
24
+ Emergence within the context of large language models is a nascent research area. As the Nobel prize-winning physicist Philip Anderson put it, ‘More is different.‘ [Anderson, 1972] which describes unpredictable phenomena at different scales. In our context and with mixture-of-denoisers in UL2, we would like to think of this phenomena as ‘More is different, but different can also more’ since different pretraining objectives can improve language model quality or elicit new emergent abilities. This work shows that diversity and richer training paradigms can be key to learning new capabilities that were previously hard to acquire with only causal language modeling.
25
+
26
+ Finally, in addition to emergent task performance and overall improved scaling curves, we show that U-PaLM is also practically more useful since it is equipped with a secondary mode of prompting, i.e., bidirectional infilling. Specifically, UL2R enables a secondary capability for prompting U-PaLM which can be used to fill in more than one blanks in the input prompt. Interestingly, we find that only a small amount of UL2R (e.g., $0 . 1 \%$ tokens or FLOPs) is sufficient to imbue the model with this new capability.
27
+
28
+ # 2 U-PaLM
29
+
30
+ This section introduces the technical details of UPaLM (i.e., $\mathbf { P a L M + U L 2 R }$ ). U-PaLM is initialized from PaLM and leverages the same architecture. This section describes the training procedures of UL2R and how they are applied to continue training PaLM. We refer the reader to Section 10 in the Appendix for a comprehensive review of related work.
31
+
32
+ # 2.1 Training Data
33
+
34
+ To keep things consistent, we train this model with the same data mixture as PaLM and do not rely on additional sources of data (labeled or unlabeled).
35
+
36
+ There are three main reasons for this choice. Firstly, we did not want to introduce new tokens to our training process which could conflate findings. Secondly, we did not want to over-index on scaling studies that only measure impact on upstream cross entropy [Hernandez et al., 2022] which claims that repeating data in small quantities could be dis-proportionally harmful. Since the empirical results we obtained are strong, we postulate that repeating tokens could perhaps be not harmful at smaller quantities after all. This is also backed by the continued training of PaLM 62B in [Chowdhery et al., 2022] which showed that repeated data could result in small gains, albeit not as strong as fresh tokens. Thirdly, we consider our data transformation (via UL2) on the training data sufficiently unique and therefore prevents us from explicitly training on the same data with the exact objective or suffering from any memorization issues.
37
+
38
+ # 2.2 Prefix Language Model Architecture
39
+
40
+ We train U-PaLM using the prefix language model (PrefixLM) architecture, also sometimes known as a non-causal decoder-only model. The PrefixLM architecture keeps a non-causal mask in its prefix (or inputs) and applies bidirectional attention to input tokens.
41
+
42
+ In this architecture, we use a total combined sequence length of 2048 (e.g., PaLM’s sequence length) which is then split to 1024 inputs and 1024 targets. In the original UL2 paper and infrastructure, an artifact of its preprocessing pipeline applies padding tokens first before combining inputs and targets. For decoder-only language models, this is inefficient since we would end up with a concatenation of [prefix] [prefix’s padding] [target].
43
+
44
+ In this work, we optimize the Prefix padding by forcing the model to concatenate prefix and target before applying any additional padding. Packing, trimming and padding is then subsequently applied later after the prefix has been concatenated with the targets. Through this prefix optimization, we are able to improve example-level sample efficiency of the model.
45
+
46
+ # 2.3 Loss Objectives
47
+
48
+ This section describes the setting for the UL2 mixture-of-denoisers that we use in UL2R. The UL2 mixture-of-denoiser objective comprises of three types of denoisers.
49
+
50
+ • Regular denoising whereby the noise is sampled as spans, replaced with sentinel tokens. This is also the standard span corruption task used in Raffel et al. [2019]. Spans are typically uniformly sampled with a mean of 3 and a corruption rate of $1 5 \%$ .
51
+
52
+ • Extreme denoising whereby the noise is increased to relatively ‘extreme‘ amounts in either a huge percentage of the original text or being very long in nature. Spans are typically uniformly sampled with a mean length of $\mathbf { 3 2 0 R }$ a corruption rate of up to $5 0 \%$ .
53
+
54
+ • Sequential denoising whereby the noise is always sampled from the start of the text to a randomly sampled point in the text. This is also known as the PrefixLM objective (not to be confused with the architecture).
55
+
56
+ We kept this simple since many ablations were already explored in Tay et al. [2022b]. We kept the original 7 denoisers as the initial version but later found that a mixture of only three tasks, e.g., $5 0 \%$ PrefixLM, $2 5 \%$ Long (extreme) span corruption, and $2 5 \%$ regular span corruption to be quite simple and efficient for the setup of continued training. We kept the original mode prompting tokens in the original UL2 design. We used [S2S] for S-denoisers (PrefixLM), [NLU] for R-denosiers and [NLG] for X-denoisers. The 540B U-PaLM model was mainly trained with $50 \%$ S-denoiser (PrefixLM), $25 \%$ R-denoisers, and $2 5 \%$ X-denoisers.
57
+
58
+ # 2.4 Training
59
+
60
+ We train the 540B model for a total of $2 0 \mathrm { k }$ steps with a batch size of 32. We mildly ablate these settings in early experiments with 62B and 8B models but keep them capped within a certain ballpark (e.g., 128 batch size for 50k steps). As a result, this is more similar to ‘finetuning’ as compared to full pretraining. The number of additional tokens is therefore very negligible compared to the original pretraining run often coming in at around or less than $0 . 1 \%$ additional compute. The total number of extra tokens we train on for the 540B model is approximately 1.3 billion which constitutes $0 . 1 6 \%$ extra computation, as the original PaLM model was pretrained on 780B tokens. We use a cosine learning rate decay schedule that anneals the learning rate from $1 0 ^ { - 4 }$ to $1 0 ^ { - 6 }$ . Notably, we also tried a low constant learning rate and found them to perform quite identically. Our U-PaLM 8B and 62B models are trained using 64 TPUv4 chips. Training an U-PaLM 540B model only consumes 512 TPUv4 chips and finishes in about 5 days which is considered to be lightweight.
61
+
62
+ # 3 Experiments
63
+
64
+ # 3.1 Improved Scaling Properties on Few-shot Learning
65
+
66
+ In this experiment, we show improved scaling curves from small amounts of UL2R training on top of both PaLM 8B and PaLM 540B. We use downstream metrics and few-shot evaluation since (1) this is closer to usability of these models and (2) loss with UL2 and causal language modeling is not comparable. We initialized and trained multiple U-PaLM models using different PaLM intermediate checkpoints. On the 8B model, we repeated this 7 times at different intervals. Given that the 540B model was more computationally demanding, we only managed to fit 3 points. For evaluation, we use the average score of NLU and NLG tasks from the GPT-3 suite [Brown et al., 2020]. In total we use 26 tasks (e.g., TriviaQA, NaturalQuestions, SuperGLUE, PIQA, OpenbookQA, ANLI etc). Detailed scores for Figure 2 can be found in the Appendix.
67
+
68
+ ![](images/af74d8103b8c8ed0e4bc33b4f832746eee305e4daccc1d0e525783b6e3590e96.jpg)
69
+ Figure 2: Computation cost (training flops) [Dehghani et al., 2021] versus Quality (average of $2 0 { + } \mathrm { N L P }$ zero and few-shot tasks). The dotted line shows the path from initialization from a PaLM checkpoint and training further with UL2R. These plots also present pairs of PaLM and U-PaLM models with comparable/similar performance along with the ratio of PaLM computation cost vs the corresponding U-PaLM computation cost. For example, PaLM 540B trained for $\sim 2 5 0 0$ zFLOPs (right most point) took $\sim 2 . 3 5$ times of the computation cost of U-PaLM 540B trained for $\sim 1 0 7 5$ zFLOPs, while both models are comparable in terms of performance on zero/few shot on NLP tasks.
70
+
71
+ ![](images/0fc73e3f4457bc5c1db632d1ff0cd54a420f6e70a8eeb9154d72e431628c7336.jpg)
72
+ Figure 3: Break down scores of individual zero-shot and one-shot NLP tasks for PaLM and U-PaLM 540B trained for 780B tokens. U-PaLM outperforms PaLM 540B and achieves SOTA on 21 out of 26 tasks.
73
+
74
+ Figure 2 shows that U-PaLM substantially outperforms the original PaLM models both at 8B scale and 540B scale. Note that the dotted lines represent a pathway before and after UL2R training, we show that UL2R training improves the scaling curve of PaLM substantially, i.e., UL2R provides a more compute-efficient performance improvement compared to training the original PaLM models for longer with the standard causal language modeling objective.
75
+
76
+ 8B versus 540B Generally, UL2R consistently improves the underlying PaLM models. Nevertheless, we observe different behaviors on the 8B and 540B models. The gap seems to narrow as the performance of PaLM 8B starts to plateau, i.e., the largest gains are near to the middle of training. As for 540B, the gain continues to grow even at 780B tokens. We believe that this is due to the fact that PaLM 540B still has significant headroom beyond 780B tokens.
77
+
78
+ Savings Rate At a certain stage of training, we have an option to continue training for K more steps using the standard causal language modeling objective OR applying UL2R for a small amount of steps. Here we discuss the counterfactual savings rate of choosing UL2R as opposed to continue training with caussal language modeling. For the 540B model, the saving rates at the middle checkpoint is approximately $2 \mathbf { x }$ . This is equivalent to about 4.4 million TPUv4 hours for the 540B model. For the 8B model, the saving rate tend to be lowest at both the start and convergence of the model. It seems to be higher at middle stages of training (relative to convergence) which shows that the utility of UL2R changes with respect to the amount of causal language modeling training already done. For the 540B model, since the PaLM model was not trained to convergence and the number of tokens to parameters ratio is relatively low, the savings rate could still be increasing even beyond $2 . 3 5 \mathrm { x }$ . Overall, the amount of savings is quite proportionate to the point of training and stage of convergence of the model and can probably be predicted by standard scaling laws [Kaplan et al., 2020, Hoffmann et al., 2022].
79
+
80
+ Table 1: List of challenging tasks in the BigBench emergent suite (BBES) and corresponding scores of PaLM 540B and U-PaLM 540B. All results are reported with standard 5-shot prompting.
81
+
82
+ <table><tr><td>task</td><td>task /reasoning type</td><td>PaLM540B</td><td>U-PaLM540B</td></tr><tr><td>navigate</td><td>arithmetic,logical</td><td>55.3</td><td>67.0 (+21.2%)</td></tr><tr><td>strategyqa</td><td>multi-step</td><td>73.9</td><td>78.3 (+6.0%)</td></tr><tr><td>crass_ai</td><td>commonsense</td><td>97.7</td><td>100 (+2.4%)</td></tr><tr><td>logical_sequence</td><td>commonsense</td><td>92.3</td><td>86.5 (-6.7%)</td></tr><tr><td>vitaminc_fact_verification</td><td>contextual, commonsense</td><td>70.2</td><td>73.9 (+5.3%)</td></tr><tr><td>understanding_fables</td><td>commonsense</td><td>75.7</td><td>78.4 (+3.6%)</td></tr><tr><td>identify_odd_metaphor</td><td>analogical</td><td>87.2</td><td>87.5 (+0.3%)</td></tr><tr><td>hyperbaton</td><td>contextual QA</td><td>54.2</td><td>59.9 (+10.5%)</td></tr><tr><td>causal_judgment</td><td>causal and commonsense</td><td>65.3</td><td>68.4 (+4.7 %)</td></tr><tr><td>english_proverbs</td><td>commonsense,contextual QA</td><td>91.2</td><td>87.5 (-4.2%)</td></tr><tr><td>geometric_shapes</td><td>algorithmic,visual</td><td>44.0</td><td>49.3 (+12.0%)</td></tr><tr><td>physics_questions</td><td>logical, physics,math</td><td>7.6</td><td>12.5 (+64.5%)</td></tr><tr><td>snarks</td><td>commmonsense</td><td>69.1</td><td>86.1 (+24.6%)</td></tr><tr><td>analogical_similarity</td><td>analogical</td><td>36.5</td><td>37.5 (+2.7%)</td></tr><tr><td>international_phonetic_alphabet_nli</td><td>reading comprehension</td><td>65.9</td><td>68.0 (+3.2%)</td></tr><tr><td>movie_dialog_same_or_different</td><td>commonsense,reading compre.</td><td>64.8</td><td>68.8 (+6.2%)</td></tr><tr><td>timedial</td><td>commonsense,logical</td><td>78.3</td><td>81.2 (+3.7%)</td></tr><tr><td>question_selection</td><td>reading comprehension</td><td>54.8</td><td>59.8 (+9.1%)</td></tr><tr><td>logical_fallacy_detection</td><td>logical reasoning</td><td>80.3</td><td>81.4 (+1.4%)</td></tr><tr><td>unit_interpretation</td><td>arithmetic,logical</td><td>47.0</td><td>51.0 (+8.5%)</td></tr><tr><td>language_identification</td><td>multilingual</td><td>36.0</td><td>38.9 (+8.1%)</td></tr><tr><td>average (21 tasks)</td><td></td><td>64.3</td><td>67.7 (+5.3%)</td></tr></table>
83
+
84
+ ![](images/3b70250d3efbf549c452ca75608b8fb9108764740be2b1511ac9df5402019406.jpg)
85
+ Figure 4: Scaling plots on BIG-Bench emergent suite (BBES) for different sizes of PaLM, U-PaLM, Gopher, and GPT-3 as a function of training FLOPs. Scores are normalized scores where zero denotes more or less random performance. X-axis is in log-scale.
86
+
87
+ Breakdown on individual tasks Figure 3 reports the individual scores on each zero and one-shot task in the mixture. We show that U-PaLM 540B outperforms PaLM 540B on 21 out of 26 tasks. Given that PaLM is the SOTA language model on these tasks, this makes U-PaLM the new state-of-the-art on these tasks.
88
+
89
+ # 3.2 BigBench Emergent Suite
90
+
91
+ We select a suite of challenging tasks from BigBench based on a criterion that performance on PaLM on these tasks remain relatively flat-lined at 8B and 62B scale but suddenly unlocks at 540B. We also consider tasks that are difficult for PaLM 540B to solve (near random performance). We call these suite of tasks EMERGENT suite of BigBench tasks (BBES) as inspired by the criterion set by Wei et al. [2022a]. Note that while these set of tasks overlap but are not entirely identical to BBH [Suzgun et al., 2022]. Moreover, BBES uses the default prompting and templates as BIG-Bench and do not use chain-of-thought prompting. Hence, they are not entirely comparable. BBH results can be found later in section 11.1.3.
92
+
93
+ Table 2: Results on finetuning on SuperGLUE and TydiQA dev sets.
94
+
95
+ <table><tr><td></td><td>PaLM 8B</td><td>U-PaLM8B</td><td>PaLM 62B</td><td>U-PaLM 62B</td></tr><tr><td>SuperGLUE (Avg)</td><td>83.4</td><td>86.1(+3.2%)</td><td>89.5</td><td>91.4 (+2.1%)</td></tr><tr><td>TydiQA (EM/F1)</td><td>75.7/85.2</td><td>77.5 (+2.3%)/86.7(+1.7%)</td><td>78.3/87.3</td><td>78.4 (+0.1%)/88.5 (+2.1%)</td></tr></table>
96
+
97
+ Table 3: Results on Massively Multi-Task Language Understanding (MMLU) test set.
98
+
99
+ <table><tr><td>Method</td><td>Accuracy</td></tr><tr><td>Random</td><td>25.0%</td></tr><tr><td>Average Human Rater</td><td>34.5%</td></tr><tr><td>GPT-3 5-shot</td><td>43.9%</td></tr><tr><td>Gopher 5-shot</td><td>60.0%</td></tr><tr><td>Chinchilla 5-shot</td><td>67.6%</td></tr><tr><td>PaLM540B 5shot U-PaLM540B 5-shot</td><td>69.3 % 70.7 % (+2.0%)</td></tr></table>
100
+
101
+ # 3.2.1 BIG-Bench Results
102
+
103
+ Table 1 reports the results of PaLM 540B and U-PaLM 540B on the BigBench emergent suite. We also describe the task and reasoning task for each task. Note that some tasks require a conjunction of various ‘skills’ to excel at. For example, the navigate task is a combination of spatial reasoning and arithmetic (counting).
104
+
105
+ Overall results and Scaling Plots We observe that U-PaLM outperforms PaLM on 19 out of the 21 tasks at 540B scale. Moreover, the gains on certain tasks are substantial (e.g., $5 5 . 3 \% \to 6 7 . 0 \%$ ) on navigate and $6 9 . 1 \% \to 8 6 . 1 \%$ on snarks). On average, there is a $+ 5 . 4 \%$ relative quality gain on the un-normalized aggregated average across all 21 tasks which we consider to be pretty strong results. Figure 4 which shows the scaling plots of U-PaLM relative to other models. Whenever possible, we also include baselines such as GPT-3 or Gopher from the official BIG-Bench repository.
106
+
107
+ UL2R unlocks emergent task performance at smaller scales Scale (e.g., scaling to 540B) is known to be one factor that results in emergent task performance [Wei et al., 2022a]. We show that UL2R is able to elicit emergent abilities at smaller scales. For example, the quality on certain tasks such as crass_ai, vitaminc, identify_odd_metaphors are tasks where performance starts to spike at 62B scale (as opposed to only at 540B with the PaLM model. In rarer occasions, the performance of U-PaLM 8B is even higher than PaLM 62B (e.g., snarks, understanding_fables). Overall, these results show that there are strong evidence that inductive bias (e.g., combinations of prefix language modeling, span corruption based pretraining in UL2) could be crucial when it comes to unraveling new abilities in large language models.
108
+
109
+ # 3.2.2 MMLU Results
110
+
111
+ We compare PaLM and U-PaLM on the Massively Multi-Task Language Understanding (MMLU) benchmark [Hendrycks et al., 2020]. Table 3 reports our results on MMLU’s test set. Prior results are reported from [Hoffmann et al., 2022]. Our results show that U-PaLM outperforms PaLM on this task in the 5-shot setup by $2 . 0 \%$ relative gain.
112
+
113
+ # 3.3 Finetuning
114
+
115
+ We conduct experiments on SuperGLUE [Wang et al., 2019] and TydiQA [Clark et al., 2020a] finetuning. We conduct experiments at 8B and 62B scale1. Fine-tuning is conducted with a constant learning rate for $1 0 0 k$ steps with a batch size of 32. Table 2 reports finetuning results. We observe that there is substantial improvement in fine-tuning especially at the 8B scale. The gains diminish slightly at 62B scale but are still modest in general. We note that PaLM’s fine-tuning performance can be generally considered weaker than expected. For instance, PaLM 8B is generally outperformed by a T5.1.1 large model on the SuperGLUE dev average. We postulate that training PaLM on UL2 and span corruption tasks in complement to causal language modeling can ameliorate some of its flaws. Our results ascertains this by showing that U-PaLM strongly improves quality especially at smaller (8B) scales.
116
+
117
+ ![](images/7f4b18317cb8a03354610336885d5ab9f3be72ee5201369d172de11c25f033db.jpg)
118
+ Figure 5: An example of a prompt that is improved by rephrasing to use U-PaLM’s infilling capabilities.
119
+
120
+ # 3.4 Additional Results & Analysis
121
+
122
+ We conduct additional, extensive, evaluation and analysis of our approach. Due to space constraints we refer the reader to Section 11 in the Appendix. There we provide results for zero-shot and few-shot NLP tasks including commonsense reasoning, closed book QA & reading comprehension, reasoning & chain-of-thought, and few-shot multilingual tasks. We find that the improvements from U-PaLM over PaLM generally hold across these additional tasks, with major improvements on certain tasks such as GSM8K $( + 6 . 6 \% )$ [Cobbe et al., 2021], BIG-Bench Hard $( + 1 0 . 7 \% )$ [Suzgun et al., 2022], and MGSM $( + 8 . 7 \% )$ [Shi et al., 2022]. We also include analysis of BBES performance, scaling curves for few-shot experiments, and additional discussion of our methods.
123
+
124
+ in. Notably, with U-PaLM it is possible to query both the infill style and the traditional style via the usage of extra ID tokens (as it is used in denoising) or without, respectively.
125
+
126
+ In Figure 5, we include example outputs for PaLM, U-PaLM with traditional prompting, as well as U-PaLM with infill prompting. We phrase this particular prompt in two ways: one as a question that is suitable for traditional prompting via PaLM and one leveraging U-PaLM’s infill capabilities. In the traditional phrasing, both PaLM and U-PaLM do not produce the correct answer. With the infill phrasing, PaLM ignores the infill token (extra ID token) as PaLM has not seen it during training, and instead produces the rest of the steps after step 4. U-PaLM correctly infills the second step in this example. Finally, a third example is included to demonstrate U-PaLM’s ability to infill multiple slots. These examples demonstrate that, with only a small amount of additional training, we are able to expand the functionality of PaLM to serve an entirely new class of queries.
127
+
128
+ # 4 Qualitative Analysis: New Prompting Capabilities
129
+
130
+ # 4.1 Infilling Ability
131
+
132
+ Left-to-right casual language model pretraining has typically allowed models to provide meaningful continuations of prompts. With U-PaLM we observe that, by extending pretraining with a small amount of UL2 denoising steps, the model is also able to pick up infilling abilities – where the model is given a location in the middle of a prompt to fill
133
+
134
+ # 4.2 Leveraging Specific Pretraining Modes
135
+
136
+ Recall that via the UL2 objective, R-, X-, and S-denoisers are associated with the [NLU], [NLG], and [S2S] mode tokens respectively. S-denoisers are essentially the PrefixLM objective, while R- and X-denoisers are variations of span corruption, and thus are also associated with extra ID tokens which we can use during prompting for infill (as shown above.) Given this unique setup, we can control the mode token during inference to gain access to specific knowledge that might have been acquired in one mode but not another. This effectively provides us with more options in how to answer prompts, without the need to make any changes to the learned model or its inference algorithm.
137
+
138
+ ![](images/19273124304d46ecdd635cea5dd1a670fecb9344d5d8e956858e4531fbe81053.jpg)
139
+ Figure 6: An example of a prompt that works only when querying a specific pretraining mode.
140
+
141
+ ![](images/f4d4819fcf623cb3609db28699e717f8ec88e7e4122b8328a736535eeee95fec.jpg)
142
+ Figure 7: Querying U-PaLM for diverse outputs by using different prompt mode token and LM/infill combinations.
143
+
144
+ In Figure 6, we include a challenging example where we ask the model to do zero-shot cross-lingual question answering from an English question into a Vietnamese answer. For PaLM and U-PaLM default, we pass the input as-is to the model. For the rest, we prepend one of [S2S], [NLU], or [NLG] to the beginning of the input, and in the case of [NLU] and [NLG], we add the infill token at the end of the input, as typical for these modes. Interestingly, U-PaLM in [S2S] mode is the only variant that returns the correct answer in Vietnamese. Regular PaLM produces the correct answer, but ignores the Vietnamese request, while U-PaLM with default prompting (no mode, no infill) produces a roughly correct answer but could be more specific (’xanh’ encompasses both greens and blues). This example shows how accessing specific mode tokens may work well for some prompts more so than others, giving us a powerful technique to serve a larger variety of prompts.
145
+
146
+ Even though [NLU] and [NLG] modes typically coincide during pretraining with span corruption (involving extra ID tokens, infilling), we can still use [NLU] and [NLG] mode tokens with no infilling at all. Similarly we can use infilling but with no mode tokens. The variety of ways to prompt U-PaLM results in a useful technique to increase the diversity of the outputs we can get from the model, without resorting to alternative decoding techniques (e.g. sampling). This is particularly useful for more open-ended prompts.
147
+
148
+ In Figure 7, we ask PaLM and all variants of querying U-PaLM to write a haiku about "a cat baking a cake on a lake" - a very random prompt that the model is unlikely to see during training, yet requires very structured output. All outputs use greedy decoding here, and surprisingly all models generate reasonable haikus about the topic, although not all follow a strict 5-7-5 syllable structure. PaLM’s haiku repeats the first and last line, which is somewhat less interesting. We can see that the different combinations of querying U-PaLM results in pleasantly varying poems.
149
+
150
+ # 4.3 Improved Diversity for Open-ended Generation
151
+
152
+ Beyond improving the scaling behavior of PaLM, we find that the small amount of continued training applied in UL2R is sufficient to imbue PaLM with new prompting abilities introduced by the UL2 objective. Namely, the use of denoising in UL2 allows PaLM to acquire infilling abilities. Infilling allows U-PaLM to have a second approach to tackling prompts, which we observe to be very useful. In addition, with U-PaLM we can also supply mode tokens to gain access to specific pretraining objectives. This gives us a powerful tool to control the model without making any updates to the model or its inference. In this section we provide some examples of situations where U-PaLM’s expanded prompting capabilities prove to be useful.
153
+
154
+ # 8 Acknowledgements
155
+
156
+ We thank Le Hou and Oliver Bousquet for their advice and feedback on the paper. We thank Barret Zoph and William Fedus for early discussions about this paper. We thank Adam Roberts for feedback on prior work.
157
+
158
+ # 5 Conclusion
159
+
160
+ We proposed UL2R for continued training of PaLM. We show that with only ${ \approx } 0 . 1 \%$ additional FLOPs (or compute), we are able to improve the scaling curve and properties of PaLM on many downstream tasks and metrics. Notably, UL2R enables a 4.4 million TPUv4 savings at 540B scale. The resulting model which we call U-PaLM outperforms PaLM on English NLP tasks (e.g., commonsense reasoning and closed-book question answering), reasoning tasks with chain-of-thought, multilingual reasoning, MMLU and a suite of challenging BIG-Bench tasks.
161
+
162
+ # 6 Limitations
163
+
164
+ In this work we show the effectiveness of continued training of a 540B PaLM model with UL2R over conditional language modeling alone. We only demonstrate this for the PaLM model and pretraining corpus. Our study is only a demonstration of what is possible with an example near state-of-the-art system, and we do not provide results on what would happen if the underlying model and pretraining corpus were to differ from the one studied here. For example, what would happen if we applied ULR2 to a model that was trained to saturation on a corpus already? Would we observe similar improvements? What would happen if we use a weaker underlying model? This paper also only studies models with $^ { 8 \mathrm { B + } }$ parameters, and does not provide insight on how UL2R would perform on smaller models and compute regions. We leave these investigations for future work, and this work should not be interpreted as a comprehensive study of continued pretraining or model reuse.
165
+
166
+ # References
167
+
168
+ Armen Aghajanyan, Anchit Gupta, Akshat Shrivastava, Xilun Chen, Luke Zettlemoyer, and Sonal Gupta. Muppet: Massive multi-task representations with prefinetuning. arXiv preprint arXiv:2101.11038, 2021.
169
+
170
+ Philip W Anderson. More is different: broken symmetry and the nature of the hierarchical structure of science. Science, 177(4047):393–396, 1972.
171
+
172
+ Vamsi Aribandi, Yi Tay, Tal Schuster, Jinfeng Rao, Huaixiu Steven Zheng, Sanket Vaibhav Mehta, Honglei Zhuang, Vinh Q. Tran, Dara Bahri, Jianmo Ni, Jai Prakash Gupta, Kai Hui, Sebastian Ruder, and Donald Metzler. Ext5: Towards extreme multi-task scaling for transfer learning. ICLR, 2022. URL https://arxiv.org/abs/2111.10952.
173
+
174
+ Yonatan Bisk, Rowan Zellers, Jianfeng Gao, Yejin Choi, et al. Piqa: Reasoning about physical commonsense in natural language. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pages 7432–7439, 2020.
175
+
176
+ 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.
177
+
178
+ 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.
179
+
180
+ Hyung Won Chung, Longpre Shayne Hou, Le and, Barret Zoph, Yi Tay, William Fedus, and et al. Scaling instruction-finetuned language models. arXiv preprint, 2022.
181
+
182
+ # 7 Ethics Statement
183
+
184
+ As this work continues training PaLM, we defer discussion of ethical considerations with respect to large language models to the original PaLM paper [Chowdhery et al., 2022]. We do note though that this work presents a way of improving large language models without training from scratch, and all the different types of cost (e.g. environmental) that that might entail.
185
+
186
+ Christopher Clark, Kenton Lee, Ming-Wei Chang, Tom Kwiatkowski, Michael Collins, and Kristina Toutanova. Boolq: Exploring the surprising difficulty of natural yes/no questions. In NAACL, 2019.
187
+
188
+ Jonathan H Clark, Eunsol Choi, Michael Collins, Dan Garrette, Tom Kwiatkowski, Vitaly Nikolaev, and Jennimaria Palomaki. Tydi qa: A benchmark for information-seeking question answering in typologically diverse languages. Transactions of the Association for Computational Linguistics, 8: 454–470, 2020a.
189
+
190
+ Kevin Clark, Minh-Thang Luong, Quoc V Le, and Christopher D Manning. Electra: Pre-training text encoders as discriminators rather than generators. arXiv preprint arXiv:2003.10555, 2020b.
191
+
192
+ 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.
193
+
194
+ Mostafa Dehghani, Yi Tay, Anurag Arnab, Lucas Beyer, and Ashish Vaswani. The efficiency misnomer. In International Conference on Learning Representations, 2021.
195
+
196
+ 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.
197
+
198
+ Andrew Drozdov, Nathanael Schärli, Ekin Akyürek, Nathan Scales, Xinying Song, Xinyun Chen, Olivier Bousquet, and Denny Zhou. Compositional semantic parsing with large language models. arXiv preprint arXiv:2209.15003, 2022.
199
+
200
+ Deep Ganguli, Danny Hernandez, Liane Lovitt, Nova DasSarma, Tom Henighan, Andy Jones, Nicholas Joseph, Jackson Kernion, Ben Mann, Amanda Askell, et al. Predictability and surprise in large generative models. arXiv preprint arXiv:2202.07785, 2022. URL https://arxiv.org/abs/2202.07785.
201
+
202
+ Mor Geva, Daniel Khashabi, Elad Segal, Tushar Khot, Dan Roth, and Jonathan Berant. Did aristotle use a laptop? a question answering benchmark with implicit reasoning strategies. Transactions of the Association for Computational Linguistics, 9: 346–361, 2021.
203
+
204
+ Dan Hendrycks, Collin Burns, Steven Basart, Andy Zou, Mantas Mazeika, Dawn Song, and Jacob Steinhardt. Measuring massive multitask language understanding. arXiv preprint arXiv:2009.03300, 2020.
205
+
206
+ Danny Hernandez, Tom Brown, Tom Conerly, Nova DasSarma, Dawn Drain, Sheer El-Showk, Nelson Elhage, Zac Hatfield-Dodds, Tom Henighan, Tristan Hume, et al. Scaling laws and interpretability of learning from repeated data. arXiv preprint arXiv:2205.10487, 2022.
207
+
208
+ 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 computeoptimal large language models. arXiv preprint arXiv:2203.15556, 2022.
209
+
210
+ Mandar Joshi, Eunsol Choi, Daniel S Weld, and Luke Zettlemoyer. Triviaqa: A large scale distantly supervised challenge dataset for reading comprehension. arXiv preprint arXiv:1705.03551, 2017.
211
+
212
+ Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
213
+
214
+ Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Matthew Kelcey, Jacob Devlin, Kenton Lee, Kristina N. Toutanova, Llion Jones, Ming-Wei Chang, Andrew Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. Natural questions: a benchmark for question answering research. Transactions of the Association of Computational Linguistics, 2019.
215
+
216
+ Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. arXiv preprint arXiv:2104.08691, 2021.
217
+
218
+ 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.
219
+
220
+ 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. URL https://arxiv.org/abs/2203.02155.
221
+
222
+ Denis Paperno, Germ’an Kruszewski, Angeliki Lazaridou, Ngoc Quan Pham, Raffaella Bernardi, Sandro Pezzelle, Marco Baroni, Gemma Boleda, and Raquel Fern’andez. The LAMBADA dataset: Word prediction requiring a broad discourse context. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1525–1534, Berlin, Germany, August 2016. Association for Computational Linguistics. doi: 10.18653/v1/P16-1144. URL https://www.aclweb.org/anthology/P16-1144.
223
+
224
+ 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.
225
+
226
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.
227
+
228
+ Adam Roberts, Colin Raffel, and Noam Shazeer. How much knowledge can you pack into the parameters of a language model? arXiv preprint arXiv:2002.08910, 2020.
229
+
230
+ Keisuke Sakaguchi, Ronan Le Bras, Chandra Bhagavatula, and Yejin Choi. Winogrande: An adversarial winograd schema challenge at scale. arXiv preprint arXiv:1907.10641, 2019.
231
+
232
+ Victor Sanh, Albert Webson, Colin Raffel, Stephen Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Teven Le Scao, Arun Raja, et al. Multitask prompted training enables zero-shot task generalization. ICLR, 2022. URL https: //openreview.net/forum?id=9Vrb9D0WI4.
233
+
234
+ 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. arXiv preprint arXiv:2210.03057, 2022.
235
+
236
+ Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R Brown, Adam Santoro, Aditya Gupta, Adrià Garriga-Alonso, et al. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. arXiv preprint arXiv:2206.04615, 2022.
237
+
238
+ Jacob Steinhardt. Future ml systems will be qualitatively different, 2022. Accessed May 20, 2022.
239
+
240
+ Mirac Suzgun, Nathan Scales, Nathanael Scharli, Sebastian Gehrmann, Yi Tay, Hyung Won Chung, Aakanksha Chowdhery, Quoc V. Le, Ed H. Chi, Denny Zhou, and Jason Wei. Challenging big-bench tasks and whether chain-of-thought can solve them. arXiv preprint, 2022.
241
+
242
+ 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, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1421. URL https://aclanthology.org/N19-1421.
243
+
244
+ Yi Tay, Mostafa Dehghani, Jinfeng Rao, William Fedus, Samira Abnar, Hyung Won Chung, Sharan Narang, Dani Yogatama, Ashish Vaswani, and Donald Metzler. Scale efficiently: Insights from pre-training and fine-tuning transformers. arXiv preprint arXiv:2109.10686, 2021.
245
+
246
+ Yi Tay, Mostafa Dehghani, Samira Abnar, Hyung Won Chung, William Fedus, Jinfeng Rao, Sharan Narang, Vinh Q Tran, Dani Yogatama, and Donald Metzler. Scaling laws vs model architectures: How does inductive bias influence scaling? arXiv preprint arXiv:2207.10551, 2022a.
247
+
248
+ Yi Tay, Mostafa Dehghani, Vinh Q Tran, Xavier Garcia, Dara Bahri, Tal Schuster, Huaixiu Steven
249
+
250
+ Zheng, Neil Houlsby, and Donald Metzler. Unifying language learning paradigms. arXiv preprint arXiv:2205.05131, 2022b.
251
+
252
+ Yi Tay, Vinh Q Tran, Mostafa Dehghani, Jianmo Ni, Dara Bahri, Harsh Mehta, Zhen Qin, Kai Hui, Zhe Zhao, Jai Gupta, et al. Transformer memory as a differentiable search index. arXiv preprint arXiv:2202.06991, 2022c.
253
+
254
+ 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.
255
+
256
+ Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R Bowman. Superglue: A stickier benchmark for general-purpose language understanding systems. arXiv preprint arXiv:1905.00537, 2019.
257
+
258
+ Thomas Wang, Adam Roberts, Daniel Hesslow, Teven Le Scao, Hyung Won Chung, Iz Beltagy, Julien Launay, and Colin Raffel. What language model architecture and pretraining objective work best for zero-shot generalization? arXiv preprint arXiv:2204.05832, 2022a.
259
+
260
+ Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. Self-consistency improves chain of thought reasoning in language models. arXiv preprint arXiv:2203.11171, 2022b.
261
+
262
+ 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.
263
+
264
+ Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. Emergent abilities of large language models. Transactions on Machine Learning Research (TMLR), 2022a.
265
+
266
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. Conference on Neural Information Processing Systems (NeurIPS), 2022b.
267
+
268
+ Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Russ R Salakhutdinov, and Quoc V Le. Xlnet: Generalized autoregressive pretraining for language understanding. Advances in neural information processing systems, 32, 2019.
269
+
270
+ Jiahui Yu, Yuanzhong Xu, Jing Yu Koh, Thang Luong, Gunjan Baid, Zirui Wang, Vijay Vasudevan, Alexander Ku, Yinfei Yang, Burcu Karagol Ayan, et al. Scaling autoregressive models for contentrich text-to-image generation. arXiv preprint arXiv:2206.10789, 2022.
271
+
272
+ Rowan Zellers, Ari Holtzman, Yonatan Bisk, Ali Farhadi, and Yejin Choi. Hellaswag: Can a machine really finish your sentence? arXiv preprint arXiv:1905.07830, 2019.
273
+
274
+ Denny Zhou, Nathanael Schärli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Olivier Bousquet, Quoc Le, and Ed Chi. Least-tomost prompting enables complex reasoning in large language models. arXiv preprint arXiv:2205.10625, 2022.
275
+
276
+ Barret Zoph, Irwan Bello, Sameer Kumar, Nan Du, Yanping Huang, Jeff Dean, Noam Shazeer, and William Fedus. St-moe: Designing stable and transferable sparse expert models, 2022. URL https://arxiv.org/abs/2202.08906.
277
+
278
+ # 9 Appendix
279
+
280
+ # 10 Related Work
281
+
282
+ Large language models Scaling and improving large language models is one of the most impactful research areas in modern artificial intelligence [Chowdhery et al., 2022]. To this end, large language models not only continue to improve as we scale in terms of data or computational budget [Hoffmann et al., 2022, Kaplan et al., 2020] but also acquire new abilities [Wei et al., 2022a]. The impact of large language models has been ubiquitous and pervasive, unlocking breakthroughs across many fields, e.g., reasoning [Wei et al., 2022b, Wang et al., 2022b, Zhou et al., 2022, Drozdov et al., 2022], math [Lewkowycz et al., 2022], dialog [Thoppilan et al., 2022], multimodal applications [Yu et al., 2022], retrieval [Tay et al., 2022c] inter alia.
283
+
284
+ While there have been many paradigms and self-supervision methods proposed to train these models [Devlin et al., 2018, Clark et al., 2020b, Yang et al., 2019, Raffel et al., 2019], to this date most large language models (i.e., more than 100B parameters) are trained as decoder-only casual language models. For example, flagship large language models such as GPT-3 [Brown et al., 2020], Gopher [Rae et al., 2021] and PaLM [Chowdhery et al., 2022] are all trained as causal language models. Meanwhile, bidirectional models (e.g., BERT [Devlin et al., 2018], T5 [Raffel et al., 2019], ST-MoE [Zoph et al., 2022]) have also been very popular as the goto model of choice, especially in smaller computational regimes (e.g., less than 30B parameters and often times in the ranges of hundred of millions of parameters).
285
+
286
+ Scaling laws of large language models Kaplan et al. [2020] investigated scaling laws of Transformer language models and first showed the scaling laws are predictive of future performance. The authors found that model size (and not shape) correlates strongly with model quality, i.e., upstream cross entropy. Tay et al. [2021] studied the scaling properties of encoder-decoder models and their impact on upstream and downstream finetuning tasks. Generally, Tay et al. [2021] found that upstream perplexity and downstream quality does not always correlate. As a follow up, Tay et al. [2022a] studied the scaling laws of different model architectures and found that inductive bias does significantly impact the scaling behavior of the model. Finally, Hoffmann et al. [2022] proposed compute-optimal models that popularized the ‘chinchilla’ scaling laws - an approach that aims to be predictive of the optimal amount of data given the number of model parameters. In this work, we mainly consider scaling laws over downstream performance largely because this is more reflective of a language model’s usability. Since downstream performance is more important than upstream cross entropy, we advocate for future scaling studies to always incorporate downstream evaluation (and metrics) as opposed to only using cross entropy loss.
287
+
288
+ Emergent Abilities New behaviors that arise due to scaling language models have been increasingly referred to as emergent abilities [Steinhardt, 2022, Ganguli et al., 2022, Wei et al., 2022a]. For instance, Wei et al. [2022a] define emergent abilities as “abilities that are not present in smaller models but as present in larger models.” For a few-shot prompted task, this would look like a flat scaling curve (random performance) until a certain critical threshold, during which performance increases to substantially above random. This type of phenomena has been observed across dozens of tasks in the BIG-Bench benchmark [Srivastava et al., 2022]. Although such emergent abilities are typically observed as a function of scale, increasing model scale to induce emergent abilities is computationally expensive. In this paper we show how UL2R unlocks emergence without increasing the number of model parameters.
289
+
290
+ Continued Training of Language Models The paradigm of continue to train (or finetune) a language model on more data or tasks is commonly known as adaptation. A range of prior work has shown that finetuning language models on a collection of NLP tasks can improve downstream performance on a broad range of downstream tasks [Aghajanyan et al., 2021, Aribandi et al., 2022, Wei et al., 2021, Sanh et al., 2022, Ouyang et al., 2022, inter alia]. The majority of this prior work, however, requires additional data such as aggregating dozens or hundreds of NLP datasets [Raffel et al., 2019, Aghajanyan et al., 2021, Aribandi et al., 2022], writing additional templates of instructions [Wei et al., 2021, Sanh et al., 2022], or finetuning on human-labeled annotations [Ouyang et al., 2022]. UL2R does not require new data since it simply re-uses the pre-training data, which makes it orthogonal to continued training methods that leverage large collections of NLP datasets. Adapting a pretrained language model with a new self-supervised objective has been explored. For example, a model trained with a language modeling objective can be adapted by further training with the masked language modeling objective [Wang et al., 2022a]. The other direction is also possible; a model trained with a masked language objective can be adapted with the causal language modeling objective [Wang et al., 2022a, Lester et al., 2021]. UL2R follows a similar idea but uptrains a language model with a set of diverse and new preordaining tasks from mixture-of-denoisers, even after a vast amounts of standard pretraining and demonstrates a very rapid improvement on variety of setups and tasks.
291
+
292
+ Unified language learner (UL2) The UL2 [Tay et al., 2022b] model is a state-of-the-art model that bridges both generative causal language models and bidirectional language models. UL2 proposes a mixture-of-denoiser objective that mixes prefix (non-causal) language modeling and infilling (span corruption) within the same model and leverages mode prompts to switch between modes during downstream tasks. UL2 is architecture agnostic in which the authors argue that the choice of decoderonly versus encoder-decoder models is largely an efficiency trade-off. In [Tay et al., 2022b], the final UL2 model was trained as a 20B encoder-decoder model, which achieves very compelling performance on both finetuning and in-context learning.
293
+
294
+ # 11 Additional Results & Analysis
295
+
296
+ # 11.0.1 Analyzing individual task performance on BIG-Bench
297
+
298
+ This section dives into individual task performance and attempts to understand quality on different types of BIG-Bench tasks.
299
+
300
+ Spatial or Visual Reasoning Tasks The first category of tasks that U-PaLM does extremely well on are tasks that require some form of spatial or visual reasoning (e.g., navigate or geometric_shapes). In both of these tasks, U-PaLM 8B outperforms PaLM 540B. We postulate that this is due to the prefix language model architecture and additional PrefixLM training that U-PaLM undergoes. To give a better illustration, consider the following examples from these tasks.
301
+
302
+ • In the navigate task, an example is as follows: ‘Turn right. Take 1 step. Turn right. Take 6 steps. Turn right. Take 1 step. Turn right. Take 2 steps. Take 4 steps.‘ and the task is a binary classification task that determines if the agent returns to the starting point.
303
+
304
+ • In the geometric_shapes task, the goal is to predict the shape given an SVG path, e.g., given ‘M $3 I , 2 9 L 3 4 , 7 6 L 8 2 , I 6 L 3 I , 2 9 ^ { \circ }$ the model should predict triangle.
305
+
306
+ Here, it is worth noting that both tasks can be improved intuitively by having bidirectional attention and being trained using a PrefixLM like objective. This could explain why U-PaLM could outperform PaLM 540B even at 8B because it was given the right inductive bias.
307
+
308
+ Commonsense and Knowledge Tasks A reasonable portion out of the 21 tasks require some form of commonsense or language-based knowledge in order to do well. It is worth noting that U-PaLM does not train on any new unique tokens (or new data) and therefore, has no access to no new ‘knowledge’ compared to vanilla PaLM. Hence, gains here are expected to be milder compared to tasks that rely more on algorithmic or other types of reasoning. However, we observe some relatively smaller gains in certain tasks (e.g., understanding_fables or movie_dialog_same_or_different). Amongst the tasks in this category, one exception is the snarks task which involves detecting sarcasm in natural language. It is worth noting that the only 2 out of 21 tasks where U-PaLM underperforms PaLM belongs to this category (e.g., logical_sequence and english_proverbs). We think this is reasonable since we do not completely expect UL2R to always improve upon this category of tasks given that it does not actually process new data tokens.
309
+
310
+ Context Reasoning or Reading Comprehension Tasks Some tasks require some understanding of context and then requires the language model to answer questions based on this context. An example of this is the vitaminc_fact_verficiation task which tries to determine the veracity of a claim given external evidence (context). Another example is the understanding_fables task where the goal is to determine the ‘morale of the story’ given context (passage or story). It is worth noting that U-PaLM exhibits emergence at 62B scale on these two tasks even though the final 540B model performance is relatively similar. We postulate that this is due to the architectural (and pretraining) advantage of PrefixLM which aids the model in performing much better even at smaller scales. Intuitively, being able to bidirectionally reason with context (prefix) could be important in context reasoning tasks.
311
+
312
+ Table 4: Results on zero-shot commonsense reasoning.
313
+
314
+ <table><tr><td>Task /Model Size FLOPS (ZFLOPS)</td><td>PaLM 62B 295.7</td><td>U-PaLM 62B 298.7</td><td>Chinchilla 70B</td><td>Gopher 280B</td><td>PaLM 540B 2527.2</td><td>U-PaLM 540B</td></tr><tr><td>BoolQ 0-shot</td><td>84.8</td><td>85.4</td><td>588 83.7</td><td>504 81.8</td><td>88.0</td><td>2529.7 88.8(+0.9%)</td></tr><tr><td>PIQA 0-shot</td><td>80.5</td><td>81.4</td><td>81.8</td><td>81.8</td><td>82.3</td><td>84.1(+2.2%)</td></tr><tr><td>HellaSwag 0-shot</td><td>79.7</td><td>79.7</td><td>80.8</td><td>79.7</td><td>83.4</td><td>84.1(+0.8%)</td></tr><tr><td>Winogrande 0-shot</td><td>77.0</td><td>76.2</td><td>74.9</td><td>70.1</td><td>81.1</td><td>82.6 (+1.8%)</td></tr><tr><td>Avg. Commonsense</td><td>80.5</td><td>80.7</td><td>80.3</td><td>78.2</td><td>83.7</td><td>84.9 (+1.4%)</td></tr></table>
315
+
316
+ Multi-step Reasoning, Analogical Reasoning and Arithmetic tasks We observe that there are some performance improvements on analogical reasoning task (e.g., analogical_similarity) or multi-step reasoning tasks (strategyqa) at 540B scale. However, unlike context reasoning tasks, the performance on these class of tasks tend to follow similar scaling patterns albeit with slightly better performance. For example, based on Figure 4, we note that strategyqa follows relatively similar scaling curves to PaLM.
317
+
318
+ # 11.1 Zero-shot and Few-shot NLP
319
+
320
+ In this section, we evaluate our models on various well-established NLP tasks. These tasks test a spectrum of zero and few-shot abilities of U-PaLM.
321
+
322
+ # 11.1.1 Commonsense Reasoning
323
+
324
+ We conduct experiments on four zero-shot commonsense reasoning benchmarks. Specifically, following [Hoffmann et al., 2022], we use BoolQ [Clark et al., 2019], PIQA [Bisk et al., 2020], HellaSWAG [Zellers et al., 2019] and Winogrande [Sakaguchi et al., 2019]. Aside from PaLM 62B and PaLM 540B which we use for direct comparisons with U-PaLM, we also compare with Chinchilla 70B [Hoffmann et al., 2022] and Gopher 280B [Rae et al., 2021]. Table 4 reports the results on zero-shot commonsense reasoning.
325
+
326
+ We show that U-PaLM 540B outperforms PaLM 540B on all four tasks with an average of $( + 1 . 4 \% )$ relative improvement and attains the best performance across all models.
327
+
328
+ # 11.1.2 Question Answering and Reading Comprehension
329
+
330
+ We evaluate zero-shot and few-shot closed book question answering (CBQA) tasks [Kwiatkowski et al., 2019, Joshi et al., 2017, Roberts et al., 2020] along with the zero-shot Lambada reading comprehension task [Paperno et al., 2016]. Table 5 reports the results of our experiments. We compare with PaLM 62B, PaLM 540B, Chinchilla 70B and
331
+
332
+ Table 5: Results on closed book QA and reading comprehension.
333
+
334
+ <table><tr><td>Task/Model Size FLOPS (ZFLOPS)</td><td>PaLM 62B 295.7</td><td>U-PaLM 62B 298.7</td><td>Chinchilla 70B 588</td><td>Gopher 280B 504</td><td>PaLM 540B 2527.2</td><td>U-PaLM 540B 2529.7</td></tr><tr><td>TriviaQA 0-shot</td><td>67.3</td><td>68.3</td><td>67.0</td><td>52.8</td><td>76.9</td><td>76.4 (-0.7%)</td></tr><tr><td>TriviaQA few-shot</td><td>72.7</td><td>73.6</td><td>73.2</td><td>63.6</td><td>81.4</td><td>82.0 (+0.7%)</td></tr><tr><td>Natural Questions 0-shot</td><td>18.1</td><td>18.7</td><td>16.6</td><td>10.1</td><td>21.2</td><td>21.7 (+2.4%)</td></tr><tr><td>Natural Questions few-shot</td><td>27.6</td><td>30.5</td><td>31.5</td><td>24.5</td><td>36.0</td><td>40.1 (+11.4%)</td></tr><tr><td>Lambada 0-shot</td><td>75.4</td><td>79.7</td><td>77.2</td><td>74.5</td><td>77.9</td><td>80.5 (+3.3%)</td></tr><tr><td>Avg. QA/RC</td><td>52.2</td><td>54.3</td><td>53.0</td><td>45.1</td><td>58.7</td><td>60.1(+2.3%)</td></tr></table>
335
+
336
+ Table 6: Experiment results on reasoning and chain-ofthought reasoning experiments.
337
+
338
+ <table><tr><td>Task /Model</td><td>Minerva 540B</td><td>PaLM540B</td><td>U-PaLM540B</td></tr><tr><td>GSM8K</td><td>57.8</td><td>54.9</td><td>58.5 (+6.6%)</td></tr><tr><td>BBH</td><td>37.2</td><td>44.8</td><td>49.6 (+10.7%)</td></tr><tr><td>StrategyQA</td><td>61.9</td><td>76.4</td><td>76.6(+0.2%)</td></tr><tr><td>CSQA</td><td>72.2</td><td>76.9</td><td>80.1(+4.2%)</td></tr></table>
339
+
340
+ Gopher 280B. Overall, on few-shot CBQA and reading comprehension, we observe that U-PaLM 540B outperforms PaLM 540B by $+ 2 . 3 \%$ on average and up to $+ 1 1 . 4 \%$ on few-shot natural questions. Meanwhile, the gain at 62B scale is also strong (i.e., $+ 2 . 1 \%$ on average).
341
+
342
+ # 11.1.3 Reasoning and Chain-of-thought Experiments
343
+
344
+ We conduct experiments on reasoning and CoT and compare U-PaLM 540B with PaLM 540B and Minerva 540B. We use the GSM8K [Cobbe et al., 2021], BBH [Suzgun et al., 2022], StrategyQA [Geva et al., 2021] and CommonsenseQA [Talmor et al., 2019] benchmarks. All tasks are run with chain-of-thought (CoT) prompting. Table 6 reports results on reasoning and CoT benchmarks. U-PaLM 540B outperforms both PaLM 540B and Minverva 540B. Notably, the gains on GSM8K and BBH are relatively strong. This shows that U-PaLM does well on reasoning and is well-suited for chain-of-thought reasoning.
345
+
346
+ # 11.1.4 Multilingual Few-shot Reasoning and Question Answering Tasks
347
+
348
+ We conduct experiments on few-shot multilingual reasoning and question answering tasks. We use the MGSM (multilingual grade school math) benchmark proposed in [Shi et al., 2022]. For multilingual question answering, we use the well-established TydiQA [Clark et al., 2020a] benchmark. In our experiments, both PaLM 540B and U-PaLM 540B uses chain-of-thought prompting [Wei et al., 2022b]. Table 7 reports our results on MGSM and TydiQA. Our results show that U-PaLM outperform PaLM by a considerable margin $( + 3 . 2 \%$ on TydiQA and $+ 8 . 7 \%$ on MGSM).
349
+
350
+ Table 7: Experiments on Multilingual GSM (MGSM) [Shi et al., 2022] and TydiQA [Clark et al., 2020a]
351
+
352
+ <table><tr><td>Task /Model</td><td>PaLM540B</td><td>U-PaLM540B</td></tr><tr><td>TydiQA</td><td>52.9</td><td>54.6(+3.2%)</td></tr><tr><td>MGSM</td><td>45.9</td><td>49.9 (+8.7%)</td></tr></table>
353
+
354
+ Table 8: Results of PaLM vs U-PaLM at different FLOPs (# tokens) at 540B scale.
355
+
356
+ <table><tr><td rowspan="2">Model Task/#Tokens</td><td colspan="3">PaLM540B</td><td colspan="3">U-PaLM540B</td></tr><tr><td>182B</td><td>329B</td><td>780B</td><td>182B+</td><td>329B+</td><td>780B+</td></tr><tr><td>TriviaQA 1shot</td><td>73.4</td><td>74.4</td><td>81.4</td><td>73.3</td><td>75.6</td><td>82.0</td></tr><tr><td>NQA 1shot</td><td>23.2</td><td>25.6</td><td>29.3</td><td>24.4</td><td>28.1</td><td>30.7</td></tr><tr><td>WebQA 1shot</td><td>21.6</td><td>19.9</td><td>22.6</td><td>21.0</td><td>21.7</td><td>23.4</td></tr><tr><td>BoolQ</td><td>82.4</td><td>85.6</td><td>88.0</td><td>85.8</td><td>88.2</td><td>88.8</td></tr><tr><td>ReCORD</td><td>91.5</td><td>92.7</td><td>92.9</td><td>91.5</td><td>92.6</td><td>93.0</td></tr><tr><td>COPA</td><td>92.0</td><td>93.0</td><td>93.0</td><td>94.0</td><td>93.0</td><td>96.0</td></tr><tr><td>RTE</td><td>68.6</td><td>67.2</td><td>72.9</td><td>73.7</td><td>71.5</td><td>75.5</td></tr><tr><td>WIC</td><td>50.8</td><td>53.8</td><td>59.1</td><td>52.2</td><td>58.0</td><td>62.2</td></tr><tr><td>WSC</td><td>88.1</td><td>86.7</td><td>89.1</td><td>87.0</td><td>88.1</td><td>87.4</td></tr><tr><td>CB</td><td>57.1</td><td>48.2</td><td>51.8</td><td>69.6</td><td>71.4</td><td>69.6</td></tr><tr><td>MultiRC</td><td>76.7</td><td>81.1</td><td>83.5</td><td>78.4</td><td>81.7</td><td>83.8</td></tr><tr><td>Winogrande</td><td>89.4</td><td>88.3</td><td>90.1</td><td>87.9</td><td>89.7</td><td>88.3</td></tr><tr><td>Winograd</td><td>76.9</td><td>79.6</td><td>81.1</td><td>78.2</td><td>79.3</td><td>82.6</td></tr><tr><td>ANLIR1</td><td>44.3</td><td>49.4</td><td>48.4</td><td>50.3</td><td>50.6</td><td>55.3</td></tr><tr><td>ANLIR2</td><td>41.3</td><td>42.7</td><td>44.2</td><td>43.5</td><td>45.2</td><td>47.8</td></tr><tr><td>ANLIR3</td><td>43.8</td><td>42.8</td><td>45.7</td><td>46.7</td><td>49.3</td><td>57.0</td></tr><tr><td>PIQA</td><td>81.0</td><td>81.9</td><td>82.3</td><td>80.8</td><td>82.0</td><td>84.1</td></tr><tr><td>StoryCloze</td><td>82.7</td><td>83.9</td><td>84.6</td><td>83.7</td><td>84.2</td><td>87.0</td></tr><tr><td>HellaSwag</td><td>79.1</td><td>81.8</td><td>83.4</td><td>79.5</td><td>82.3</td><td>84.1</td></tr><tr><td>ArcE</td><td>74.8</td><td>72.8</td><td>76.6</td><td>74.6</td><td>76.3</td><td>85.9</td></tr><tr><td>ArcC</td><td>48.0</td><td>46.9</td><td>53.0</td><td>48.6</td><td>50.4</td><td>60.3</td></tr><tr><td>RaceM</td><td>63.6</td><td>67.3</td><td>68.1</td><td>63.2</td><td>67.1</td><td>67.2</td></tr><tr><td>OpenbookQA</td><td>50.2</td><td>51.2</td><td>53.4</td><td>50.2</td><td>51.2</td><td>53.6</td></tr><tr><td>RaceH</td><td>45.3</td><td>48.5</td><td>49.1</td><td>45.5</td><td>48.5</td><td>51.3</td></tr><tr><td>Lambada 1shot</td><td>75.4</td><td>77.5</td><td>81.8</td><td>74.3</td><td>79.9</td><td>80.0</td></tr><tr><td>SquadV2 1shot</td><td>70.5</td><td>71.3</td><td>78.7</td><td>71.8</td><td>70.3</td><td>78.2</td></tr><tr><td>Average</td><td>62.7</td><td>63.8</td><td>66.5</td><td>64.1</td><td>66.2</td><td>69.4</td></tr></table>
357
+
358
+ # 11.2 Details of Scaling Curves for Few-shot Experiments
359
+
360
+ We compute a mean aggregated score of the following tasks. We use 21 zero-shot rank classification tasks, i.e., BoolQ, Record, COPA, RTE, WiC, WSC, CB, MultiRC, Winograd, Winogrande, ANLI R1, ANLI R2, ANLI R3, PIQA, StoryCloze, HellaSwag, Arc-E, Arc-C, RaceM, RaceH, OpenbookQA. We use 5 one-shot generative tasks, i.e., TriviaQA, NaturalQuestions, WebQuestions,SQuaDV2 and Lambada. All tasks use the accuracy (or exact match) metric except MultiRC which reports f1a following [Brown et al., 2020]. In total, the aggregated metric is a mean over all 26 tasks. We list the scores that correspond to Figure 2’s 540B scaling plot below.
361
+
362
+ # 11.3 Details of Vocab and Sentinel Tokens
363
+
364
+ For U-PaLM, we had to train on span corruption or infilling task. We use the same setup as UL2 and T5 where we inject sentinel tokens, e.g., <extra_id_ $\smash { { O > } }$ into the masked positions. In T5, sentinel ids are added as 100 additional vocab tokens at the end of the sentencepiece (vocab). In PaLM, since we restart from an existing PaLM checkpoints, it was quite cumbersome to initialize 100 new embeddings in the vocab. Hence, we opt to simply use the last 100 subwords as sentinel tokens. Finally, we also use eos symbols in the vocab when training the model.
365
+
366
+ # 11.4 Details of Prompt Templates
367
+
368
+ As stated in Section 3.2, BBES uses the default prompting and templates a BIG-Bench and do not use chain-of-thought prompting. For full BBH and MMLU results, we use the same set of prompts as [Chung et al., 2022], which we refer the reader to for more details. However, our 5-shot MMLU prompts do not use chain-of-thought, only directly stating the answer option, e.g. "Answer: (C)". Prompts for our zero-shot and few-shot NLP evaluations in Section 10.1 use the same basic templates as [Brown et al., 2020].
369
+
370
+ # 11.5 Additional Discussion
371
+
372
+ In this section, we delve into some additional topics and discussions.
373
+
374
+ # 11.5.1 What about training from scratch?
375
+
376
+ We address the elephant in the room. There are multiple perspectives to this question. The first is that UL2R can be thought as a form of ‘UL2 schedule‘ that sets a single causal language model objective from 0 to $N$ steps and then doing the UL2 mixture from $N$ to $N + \epsilon$ . In this sense, if we wanted to train from scratch, this would require modifying the mixture to have significantly more causal language modeling. The second perspective is that UL2R introduces a natural curriculum where the model spents a large fraction of training acquiring basic language modeling before moving on to tasks like infilling or learning how to leverage bidirectional receptive fields. Whether there is a taxonomy or hierarchical of pretraining tasks is still an open question which we hope to answer in future work. The third perspective is simply the practical aspect of U-PaLM. Training a PaLM 540B model from scratch is incredibly costly and we would like to reuse our existing models (or components) as much as possible to design new models for new tasks. U-PaLM is an instance of this type of research. Finally, given that many language models are trained as causal language models, we believe that UL2R presents great opportunity for improving existing models with only a small amount of compute.
md/dev/tZmqS73_07/tZmqS73_07.md ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 3D MOLECULAR GENERATION BY VIRTUAL DYNAMICS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Structure-based drug design, i.e., finding molecules with high affinities to the target protein pocket, is one of the most critical tasks in drug discovery. Traditional solutions, like virtual screening, require exhaustively searching on a large molecular database, which are inefficient and cannot get novel molecules beyond the database. The pocket-based 3D molecular generation model, i.e., directly generating a molecule with a 3D structure and binding position in the pocket, is a new promising way to address this issue. However, the method is very challenging due to the complexity brought by the huge continuous 3D space in the pocket cavity. Herein, inspired by Molecular Dynamics, we propose a novel pocket-based 3D molecular generation framework VD-Gen. VD-Gen consists of a Virtual Dynamics mechanism and several carefully designed stages to generate fine-grained 3D molecules with binding positions in the pocket cavity end-to-end. Rather than directly generating or sampling atoms with 3D positions in the pocket like in early attempts, in VD-Gen, we first randomly scatter many virtual particles in the pocket; then with the proposed Virtual Dynamics mechanism, a deep model, acting like a "force field", iteratively moves these virtual particles to positions that are highly possible to contain real atoms. After virtual particles are stabilized in 3D space, we extract the atoms from them. Finally, we further refine the 3D positions of atoms by Virtual Dynamics again, to get a fine-grained 3D molecule. Extensive experiment results on pocket-based molecular generation demonstrate that VD-Gen can generate novel 3D molecules to fill the target pocket cavity with high binding affinities, significantly outperforming previous baselines.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Structure-based (pocket-based) drug design, i.e., finding a molecule to fill the cavity of the protein pocket with a high binding affinity [1; 2; 3; 4], is one of the most critical tasks in drug discovery. The most widely used method is virtual screening [5; 6; 7]. Virtual screening iteratively places molecules from a molecular database into the target pocket cavity and evaluates molecules with good binding based on rules such as energy estimation [8; 9; 10; 11]. However, virtual screening is inefficient for the exhaustive search and is infeasible to generate new molecules that are not in the database. Recently, molecular generative models have become a potential solution to address the problem as they could generate novel molecules in an efficient way. The early attempts focused on ligand-based molecular generation[12; 13; 14], which trains models to learn the underlying distribution of the molecules in training data and generate similar molecules. However, those methods didn’t consider conditional information, such as the shape of the pocket. Therefore, the generated molecules could hardly fit well with a given pocket in practice. Later, more efforts were paid to studying how to leverage the information of protein pockets for molecular generation. Some pocket-based generative models simply generate molecules in the form of SMILES or graphs [15; 16], without considering the 3D geometric position of the molecule and pocket, which is closely related to binding affinity.
12
+
13
+ However, directly generating pocket-based molecules in the 3D space is not trivial. Given the 3D structure of a pocket, the ultimate goal of the task is to generate 3D molecules which contain a set of atoms, each with an atom type and the corresponding 3D position. The biggest challenge here is the large space of continuous 3D positions. In most existing generative models (in images/texts), the space of position is usually small and discrete, like an image with $2 2 4 \times 2 2 4$ pixels. To address that, there are some early attempts, which can be roughly categorized into two classes, molecular 3D density grid generation [17] and auto-regressive 3D generation [18; 19; 20]. In 3D density grid generation, similar to images, pockets and molecules are converted to 3D density grids with coarse-grained positions. 3D convolutional models could be used here. But it compresses the information of the pocket structure and is hard to generate accurate (fine-grained) molecules due to the coarse-grained grid positions. In auto-regressive 3D generation, an atom (with a 3D position and an atom type) is sampled (or generated) at each time step. But it is very inefficient due to the large sampling space of 3D positions. Besides, using sequential generation for 3D molecules is not reasonable since we do not know which atoms should be generated first.
14
+
15
+ ![](images/14c19fffe530a4e961dc35dd16456721b595ab8e97a74e297abd9fe6bc8e33b8.jpg)
16
+ Figure 1: The framework of VD-Gen, which consists of 4 stages, for generating fine-grained 3D molecules with binding positions in the pocket end-to-end. In Equilibrium and Refinement, the proposed Virtual Dynamics is used to iteratively move the virtual particles.
17
+
18
+ In short, existing models did not fully tackle the challenges in pocket-based 3D molecular generation. The ideal models should be able to generate fine-grained 3D molecules efficiently, in a one-shot (non-auto-regressive) fashion. To achieve that, we proposed a novel 3D molecular generation framework, VD-Gen, based on a Virtual Dynamics (VD) mechanism. Inspired by the Molecular Dynamics [21; 22], VD contains a deep model, which acts like a "force field", iteratively moving the random scattered "virtual particles" (VPs) to positions that are highly possible to contain real atoms. Based on VD , as illustrated in Fig. 1, VD-Gen framework contains 4 stages to directly generate 3D molecules in the pocket end-to-end. 1) Equilibrium. To cover the pocket cavity space as much as possible, many VPs are first randomly placed. Then the VPs are iteratively moved by VD until equilibrium. Ideally, the VPs will be moved into several clusters, each representing a possible atom. 2) Extraction. We want to extract atoms from equilibrious VPs in this stage. First, a success rate will be predicted for each VP, a higher success rate means that VP is more close to its target, and the VPs with low success rates will be filtered. Then, a model is used to predict the clustering of VPs, by a pair-wise fashion, and the VPs in the same cluster will be merged into one atom. With the merged atoms, we can get a molecule with a 3D structure. 3) Refinement. Although a 3D molecule could be generated in Extraction stage, it may be inaccurate due to the error in merging multiple VPs. To get a more accurate 3D molecule, the atoms are iteratively moved by VD again in this step. 4) Confidence. A confidence score for the generated 3D molecule will be provided by the model in this stage. The confidence score is instrumental when selecting or ranking from multiple generated results.
19
+
20
+ # Our contributions can be summarized as follows:
21
+
22
+ • We propose Virtual Dynamics (VD) mechanism, which implicitly simulates Molecular Dynamics by a deep model, iteratively moving the particles to positions that highly possibly contain atoms. We design several strategies, like least-action target assignment and iterative movement, to make the training of VD feasible. • Although VD can generate rough shapes (densities of particles) of 3D molecules, it is hard to extract molecules from the shapes. To address the problem, we further propose a novel pocket-based 3D molecular generation framework VD-Gen, which end-to-end extracts a 3D molecule from many particles, then refines it by VD again, and predicts a confidence score used for selecting or ranking. • Under VD-Gen, to tackle the limited data in pocket-based 3D molecular generation, we design a self-partial-generation pretraining task and successfully use it to further improve performance. • Multiple evaluation metrics, such as Vina [23], MM-PBSA [24], 3D Similarity [25], are used to benchmark VD-Gen thoroughly. Experiments results demonstrate that VD-Gen can generate diverse drug-like molecules with high binding affinities, significantly outperforming all baselines. Ablation studies and case studies are designed to further demonstrate the effectiveness of VD-Gen.
23
+
24
+ # 2 METHOD
25
+
26
+ The problem of pocket-based 3D molecular generation could be denoted as $\mathbf { M } = h ( \mathbf { P } ; \pmb { \theta } )$ , where $h ( \cdot ; \theta )$ is the model with learnable parameter $\pmb { \theta }$ , $\mathbf { P } = \{ ( \pmb { x } _ { i } ^ { p } , \pmb { y } _ { i } ^ { p } ) \} _ { i = 1 } ^ { u }$ is the set of $u$ atoms in the pocket, $\pmb { x } _ { i } ^ { p } \in \mathbb { R } ^ { t }$ and $\pmb { y } _ { i } ^ { p } \in \mathbb { R } ^ { 3 }$ are the $i$ -th pocket atom’s type (one-hot) and coordinate, respectively, $t$ is the number of atom types, and $\mathbf { M } = \{ ( \pmb { x } _ { i } , \pmb { y } _ { i } ) \} _ { i = 1 } ^ { m }$ is the set of $m$ atoms of the generated molecule.
27
+
28
+ ![](images/c8d8cda2b6f0d9e6d0a1a2aba4472300e5f00b7a8440c784465404ad73cbc2ad.jpg)
29
+ Figure 2: The backbone model used in VD-Gen. Details are in Appendix A.1.1 and Alg. 2.
30
+
31
+ # 2.1 VIRTUAL DYNAMICS
32
+
33
+ As aforementioned, directly generating M is challenging due to the large space of 3D positions. Therefore, inspired by Molecular dynamics (MD), we propose Virtual Dynamics (VD), which iteratively refines the particles from a random state, rather than direct generation. MD is a Newtonian Mechanics based computational simulation to move atoms or other microscopic particles. In MD, what determines how atoms move is the molecular force field, a physical model that defines the interactions between atoms. The potential energy surface (PES) [26; 27], a function of energy based on atomic positions, is used to describe the energy landscape of the system. Each minimal energy on PES corresponds to a physical stable state, in which the atoms prefer to stay in particular positions.
34
+
35
+ Virtual Dynamics (VD) contains a deep model, acting like a "force field", implicitly predicting the preferred positions of ligand molecular atoms in the pocket cavity by moving the "virtual particles"(VPs) toward those positions. Formally, VD could be denoted as ${ \bf V } _ { r } = h ( { \bf V } _ { 0 } , { \bf P } , r ; \theta )$ , where $r$ is the number of rounds, $\mathbf { V } _ { r } = \{ ( \boldsymbol { { \mathbf { \mathit { x } } } } _ { i } ^ { r } , \boldsymbol { { \mathbf { \mathit { y } } } } _ { i } ^ { r } ) \} _ { i = 1 } ^ { n }$ is the set of $n$ VPs that are generated at the $r$ -th round. Here we define the VPs as particles without fixed atom types. Besides, VD can generate more VPs than the real atoms, i.e., $n = | \mathbf { V } _ { r } ^ { n } |$ can be larger than $m = | M |$ , and VPs can overlap with each other. To train a model to achieve effective movement of VPs, VD consists of 4 parts: 1) Backbone Model, a SE(3) model takes $\mathbf { V } _ { r }$ as input and outputs the refined $\mathbf { V } _ { r + 1 }$ ; 2) Target Assignment, a method to assign targets for VPs during training; 3) Iterative Movement, a strategy to update positions of VPs iteratively like MD; 4) Training Objectives, effective objective functions to train VD .
36
+
37
+ Backbone Model We can denote the model as $\mathbf { V } _ { r + 1 } = f ( \mathbf { V } _ { r } , \mathbf { P } ; \theta )$ . To predict the coordinates effectively, the model $f$ should be SE(3)-equivariance. We mainly follow the design of the efficient SE(3)-equivariance Transformer proposed in Uni-Mol [28] and Graphormer-3D [29]. However, they did not consider the interaction between pocket and molecule. Therefore, as illustrated in Fig. 2, we extend the model by adding an additional pocket encoder, and a particle-pocket attention layer to capture the interactions between pocket atoms and VPs. In particular, the key/value in the particle-pocket attention is from the node representation of the last layer in the pocket encoder. Besides, to encode the 3D spatial interactions between the pocket and VPs, the pair distance between pocket atoms and VPs is used for particle-pocket spatial position encoding. For efficiency purposes, particle-pocket attention is only used in every 4-layer, not in all layers.
38
+
39
+ To encode 3D positions, we follow Uni-Mol and use SE(3)-invariant Gaussian kernel to encode the pair-wise Euclidean distances, as shown in Fig. 2. To predict 3D positions directly, the SE(3)- equivariance coordinate head in Uni-Mol [28] is used. Besides, to predict the atom types of particles after movement, an atom type prediction head is introduced. Due to space restrictions, we leave the details of the above components in Appendix A.1.1.
40
+
41
+ Target Assignment The goal of model $f$ is to move the VPs to the preferred positions of ligand molecular atoms. To achieve this, we can directly assign a real atom as the training target for each VP. Formally, given the ground-truth atoms $\mathbf { G } = \{ ( \boldsymbol { { \mathbf { x } } } _ { i } ^ { g } , \boldsymbol { { \mathbf { y } } } _ { i } ^ { g } ) \} _ { i = 1 } ^ { m }$ and the random initialized VPs $\mathbf { V } _ { 0 }$
42
+
43
+ # Algorithm 1 Iterative Movement
44
+
45
+ Require: R: max rounds, P: pocket atoms, $\mathbf { V } _ { 0 }$ : random initialized virtual particles
46
+ 1: $r \gets \mathrm { u n i f o r m } ( 1 , R )$ if training else $R$ ▷ Sampling is only enabled at training
47
+ 2: disable_gradient() ▷ Disable gradient calculation globally
48
+ 3: for $k \in [ 1 , . . . , r - 1 )$ do ▷ Iterative updates without gradients
49
+ 4: $\mathbf { V } _ { k } f ( \mathbf { V } _ { k - 1 } , \mathbf { P } ; \boldsymbol { \theta } )$ ▷ backbone model $f$ predict the types and positions
50
+ 5: enable_gradient() ▷ Enable gradient calculation globally
51
+ 6: $\mathbf { V } _ { r } \gets f ( \mathbf { V } _ { r - 1 } , \mathbf { P } ; \theta )$ $\triangleright$ update with gradients
52
+ 7: return $\mathbf { V } _ { r }$ ▷ Return the positions and types of particles
53
+
54
+ there are $n ^ { m }$ possible assignments. Following the principle of least action [30], the assignment with minimal moving distance is favored. That is to optimize $\begin{array} { r } { \mathbf { M i n } \sum _ { i = 1 } ^ { n } \| \pmb { y } _ { i } ^ { 0 } - \pmb { y } _ { a _ { i } } ^ { g } \| _ { 2 } } \end{array}$ , where $\mathbf { \boldsymbol { x } } _ { i } ^ { 0 }$ is the initial position and $a _ { i } \in \mathbb { N }$ is the assigned target for $i$ -th VP. This optimization problem is easy to solve: for each VP, assign its nearest real atom as the training target, i.e., $a _ { i } = \arg \operatorname* { m i n } _ { \mathbf { \mu } _ { - } , \mathbf { \bar { \mu } } _ { - } = 1 } ^ { m } \| \pmb { y } _ { i } ^ { 0 } - \pmb { y } _ { j } ^ { g } \| _ { 2 }$ However, by this method, some real atoms may not be assigned as targets when VPs are closer to other real atoms. To increase the coverage, there are two methods. The first is taking the coverage as a constraint in the above optimization problem; the second is using more VPs to cover the pocket cavity as possible. Although the former is more favorable from the algorithm perspective, it increases the learning difficulty of VP movement since the constrained assignment breaks the principle of least action 1. Therefore, in VD , we take the latter one, using more VPs to ensure coverage. Besides, we propose an algorithm to determine the pocket cavity, and VPs are only initialized inside the detected cavity. In particular, we use a breadth-first search algorithm, from a given position in the cavity, to detect the cavity space. Details are in Appendix A.1.2.
55
+
56
+ Iterative Movement Since VPs are scattered randomly in the pocket cavity, there is a wide range of distances between each VP and its target. As a result, it is not realistic that every VP can be moved to the right target position in one step. Therefore, VD takes a strategy that iteratively moves the VPs and predicts their types with multiple rounds. In particular, at each round, the model will take the VPs’ positions and types from the previous round as inputs, and output the new positions and types for them. In the first few rounds, the VPs that are close to the target positions will soonly approach their target positions. But for the VPs that are far away from the target positions, it may take more rounds to approach. In short, with iterative movement, more VPs could reach their target positions.
57
+
58
+ However, training the model with multiple rounds is not efficient in both speed and memory consumption. To reduce the training cost, we adopt the stochastic iteration in AlphaFold2 [31]. In particular, during training, the number of rounds $r$ is uniformly sampled between 1 and $R$ , where $R$ is the max round. Then, the model is run on the forward-only mode in the first $r - 1$ rounds, without loss calculation and gradient backward. Finally, the gradient and backward are enabled at the $r$ -th round. During inference, the sampling on rounds is not used. The above algorithm is shown in Alg. 1.
59
+
60
+ In addition, we propose two technologies to improve training stability. First, the SE(3) coordinate head is initialized to predict the zero delta positions; thus, the predicted movements of VPs are nearly zeros at the beginning of training, and gradually increase. Second, to avoid moving too fast in each round, a regularization of the delta distance between the input and output positions is used during training.
61
+
62
+ Training Objectives With assigned targets $( a _ { i } = \arg \operatorname* { m i n } _ { j = 1 } ^ { m } \| y _ { i } ^ { 0 } - y _ { j } ^ { g } \| _ { 2 } )$ , the training of VD is straightforward. First, a clip L2 loss is used for the coordinate prediction, clipping is for the training stability. Second, as aforementioned, a regularization of the moving distance of iterative movement is introduced to avoid moving too fast and improve training stability. Third, a negative log likelihood loss is used for the particle type prediction. Finally, two auxiliary L1 losses are used for the particle-particle pair distance prediction and particle-pocket pair distance prediction, respectively. The final training objective loss function could be denoted as:
63
+
64
+ $$
65
+ \begin{array} { l } { \displaystyle \mathcal { L } _ { \mathcal { V D } } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \big ( \mathrm { c l i p } ( | | \boldsymbol { y } _ { i } ^ { r } - \boldsymbol { y } _ { a _ { i } } ^ { g } | | _ { 2 } , \boldsymbol { \tau } ) + \operatorname* { m a x } ( | | \boldsymbol { y } _ { i } ^ { r } - \boldsymbol { y } _ { i } ^ { r - 1 } | | _ { 2 } - \delta , 0 ) + \mathrm { N L } ( \bar { \boldsymbol { x } } _ { i } ^ { r } , \boldsymbol { x } _ { a _ { i } } ^ { g } ) } \\ { \displaystyle \qquad + \frac { 1 } { n } \sum _ { j = 1 } ^ { n } | | d _ { i j } ^ { r } - d _ { a _ { i } , a _ { j } } ^ { g } | | _ { 1 } + \frac { 1 } { u } \sum _ { j = 1 } ^ { u } | | c _ { i j } ^ { r } - c _ { a _ { i } , j } ^ { g } | | _ { 1 } \bigg ) , } \end{array}
66
+ $$
67
+
68
+ where $r$ is the number of rounds, $\bar { \pmb x } _ { i } ^ { r }$ is the predicted atom type distribution of $i$ -th particle, $d _ { i j } ^ { r }$ $( d _ { a _ { i } , a _ { j } } ^ { g } )$ is the predicted (ground-truth) distance of the $i$ -th and $j$ -th particle pair, $c _ { i j } ^ { r } \ ( c _ { a _ { i } , j } ^ { g } )$ is the predicted (ground-truth) distance of the $i$ -th particle and the $j$ -th pocket atom.
69
+
70
+ # 2.2 VD-GEN FRAMEWORK
71
+
72
+ With VD , a rough shape (density of VPs) of the 3D molecule could be formed by the VPs after iterative movement. We may use some rule-based solutions, like clustering by distances, to extract 3D molecules from the VPs. However, rule-based solutions are not end-to-end and could fail in various scenarios. Therefore, to better leverage VD , we further develop an end-to-end pocket-based 3D molecular generation framework, called VD-Gen, with the following 4 stages, illustrated in Fig 1.
73
+
74
+ Equilibrium This stage is exactly the same as the VD . Many VPs are first uniformly scattered in the pocket. Then, VPs iteratively move toward their target positions. Finally, VPs will reach a stable state.
75
+
76
+ Extraction With the equilibrious VPs, a rough shape of the 3D molecule could be got, and we want to extract a 3D molecule from it. For the end-to-end purpose, we propose a deep model based solution to extract atoms. Formally, the model can be denoted as ${ \bf W } _ { 0 } = h _ { e x } ( { \bf V } _ { r } , { \bf P } ; \theta _ { e x } )$ , where $\theta _ { e x }$ is learnable parameters, $\mathbf { W } _ { 0 } = \{ ( \hat { \pmb { x } } _ { i } ^ { 0 } , \hat { \pmb { y } } _ { i } ^ { 0 } ) \} _ { i = 1 } ^ { m }$ is the set of $m$ VPs after extraction. The model reduces VPs from $n$ to $m$ by two steps, filter and merge. First, as some VPs may fail to approach their target positions, we want to filter out them. A binary classification head is used to predict the success rates of VPs, and the training targets are "success" if the distances between VPs and their target positions after Equilibrium are smaller than a threshold. And we filter out the VPs based on the predicted success rate.
77
+
78
+ Second, we want to merge the remaining VPs into atoms. Based on the pair representation of VPs, we use another binary classification head to predict whether a VP pair should be merged or not. Ideally, the VPs with the same target atom should be merged, thus training label for a VP pair with the same atom target is set to "true". When there are $n$ VPs and $m$ real atoms, the ratio of "true" class is about m×(n/m)2 $\begin{array} { r } { { \frac { m \times ( n / m ) ^ { 2 } } { n ^ { 2 } } } = { \frac { 1 } { m } } } \end{array}$ . As $m$ ranges from dozens to hundreds, the binary classification task here is very unbalanced. Thus, we introduce a focal loss [32] to balance the classes. With the predicted pair-wise merge probability matrix, we can use a threshold to get a binary merge matrix and merge VPs into clusters according to the matrix. However, it is hard to decide a threshold since the training of pair-wise merge is unbalanced. To tackle that, we further introduce a prediction task for the number of ligand molecular atoms, based on pocket atom representation. During inference, we use binary search to find a merging threshold that satisfies the predicted atom number, details are in Appendix A. There will be several (ideally $m$ ) merge clusters, and we denote ${ \pmb w } _ { i }$ as the set of the indices of $i$ -th cluster’s VPs. Then, to initialize $\mathbf { W } _ { 0 }$ , we use $\hat { \pmb { x } } _ { i } ^ { 0 } = \mathrm { U n i f o r m } ( \{ \pmb { x } _ { j } ^ { r } | j \in \pmb { w } _ { i } \} )$ ) and $\hat { \pmb { y } } _ { i } ^ { 0 } = \mathrm { M e a n } ( \{ \pmb { y } _ { j } ^ { r } | j \in \pmb { w } _ { i } \} )$ , to sample an atom type and get an average coordinate respectively.
79
+
80
+ Refinement After Extraction, a 3D molecule with a set of VPs $( \mathbf { W } _ { 0 } )$ ) could be formed. However, due to the possible error in Extraction, the predicted 3D molecule may not be very accurate. To get a more accurate 3D molecule $( \mathbf { W } _ { r } )$ , we use VD again, with different model weights, to iteratively move these VPs to their target positions. Different with Equilibrium, the training target assignment of the $i$ -th VP is the most frequent target atom in the cluster ${ \pmb w } _ { i }$ , not its nearest atom.
81
+
82
+ Confidence Abundant molecules are usually generated in real-world tasks. We want to select or rank the molecules according to binding affinities. Although we can use computational simulations or wet experiments to examine the generated molecules, they are too costly, especially for a large number of molecules. To further improve the usability of ${ \tt V D - G e n }$ and reduce the extra cost of selecting good molecules, we explicitly train a task to learn the confidence scores for the generated molecules. In particular, following AlphaFold [31], we compute the LDDT score [33] of the generated molecule and ground-truth molecule, and a pLDDT(predict LDDT) head is used to learn the LDDT score. During inference, the output of pLDDT head is used as the confidence score of the generated molecule.
83
+
84
+ The loss functions in the above 4 stages are combined, and the entire VD-Gen framework is trained end-to-end. Due to space restrictions, we leave the details of the above loss functions in Appendix A.
85
+
86
+ # 2.3 PRE-TRAINING FOR VD-GEN
87
+
88
+ Due to the limited protein-ligand binding data for the supervised training, VD-Gen may fail to train or overfit the small training data. Therefore, to improve the model ability, we pretrain the pocket encoder and the VP encoder by large-scale unlabeled data, respectively. The pretrained pocket encoder is directly taken from the pretrained one from Uni-Mol [28]. For the VP encoder, the pretraining is mostly the same as the VD-Gen framework, except that pocket is not involved. In particular, the pocket related components, like particle-pocket attention, are all removed. Nevertheless, without pocket as a condition, the training of VD-Gen is infeasible. So we design a self-partial-generation pretraining task, by using a part of the molecule as the known condition and generating the unknown part. To be more consistent with finetuning, only a few atoms, about $20 \%$ to $30 \%$ , are kept as a condition. To have a continuous 3D space for VPs to generate, we randomly remove the atoms in the continuous region. We use a greedy recursive algorithm to find a cluster of atoms to remove, and then, the VPs are randomly scattered in the continuous region of these removed atoms.
89
+
90
+ During finetuning, the backbone model in VD-Gen loads the weights from two pretrained models. For the VP encoder, the weights in the particle-pocket attention layers are not pretrained and are randomly initialized. Gated layers, initialized as zeros, are used in the residual connections of particle-pocket attention layers. Therefore, the outputs of random initialized particle-pocket attention layers will not affect the pretrained encoders at the beginning of finetuning.
91
+
92
+ # 2.4 EXTENDING VD-GEN TO POCKET-BASED 3D MOLECULAR OPTIMIZATION
93
+
94
+ Molecular optimization is also an important task in real-world drug design. In molecular optimization, rather than generating from scratch, the goal is to replace a part of the given molecule, like a fragment, and to get a molecule with better binding affinity. Here, we extend VD-Gen to the pocket-based 3D molecular optimization. In particular, as illustrated in Fig. 8, we first randomly remove a fragment of the given molecule, and the model is learned to generate it, with the pocket and the remaining atoms in the molecule as conditions. In this way, although it is not trained to optimize molecules directly, the model learns how to remove-then-fill a fragment of a molecule, and thus could be used in molecular optimization tasks. The benchmark results of molecular optimization are left to Appendix B.8.
95
+
96
+ # 3 EXPERIMENTS
97
+
98
+ # 3.1 SETTINGS
99
+
100
+ Evaluation metrics There is not a golden metric to evaluate the generated molecules, so we use multiple metrics to have a comprehensive evaluation. 1) 3D Similarity. As the pocket-based 3D generation models are trained by the 3D structures of the pockets and molecules, the most direct metric to examine the models’ generative ability is to evaluate the 3D similarity between the generated molecule and the ground-truth one. Here we use LIGSIFT [25] to calculate the overlapping ratio in 3D space between two molecules. 2) Vina. Docking scores, like Vina [23], are widely used in previous pocket-based generation works, for they are easy to compute. To be consistent with previous works, we also use Vina as a metric. However, previous works usually relied on Vina’s re-docking, in which the molecular conformation and binding pose may be largely changed by docking tools. Thus, to directly evaluate the 3D molecules generated by model, we add an additional Vina\* score that does not use re-docking. 3) MM-PBSA. Although docking scores are easy and fast to compute, they are proposed to recall the possible hits in the large-scale virtual screening, not for ranking. Thus, docking scores are not good metrics to compare the binding affinities for different models [34], and we further use the slower but more accurate MM-PBSA (Molecular Mechanics Poisson–Boltzmann Surface Area) [35] as a metric. Based on MM-PBSA, we add two additional metrics. MM-PBSA B.T. (MM-PBSA Better than Target), which computes the percentage of generated molecules with better MM-PBSA scores than ground-truth. MM-PBSA Rank, which computes the average rankings of different models among different complexes. Due to MM-PBSA scores varying largely in different complexes, MM-PBSA Rank can better compare different models. The details of the above metrics are described in Appendix B.2.
101
+
102
+ Data We use 3D molecular conformations from Uni-Mol [28] to pretrain VP encoder. PDBBind 2020 dataset [36; 37], containing 19,443 protein-ligand complexes crystal structures, are used to finetune the VD-Gen. Although the cross-docked data [38] used in the previous works is much larger, it is built by docking tools and thus is not accurate as PDBBind, so we do not use it. For the test set, we use 100 protein-ligand complex crystal structures from [24], on which MM-PBSA was validated to be effective. To avoid leakage, we remove the training data’s complexes whose protein sequences are similar to the ones in the test set. In particular, two protein sequences are identified as similar if their e-value from BLAST [39] search results is larger than 0.4. There are 18,413 training complexes after filtering.
103
+
104
+ Training We leave the detailed hyper-parameters used in training to Appendix B.1.
105
+
106
+ # 3.2 MOLECULE GENERATION PERFORMANCE
107
+
108
+ Baselines We compare VD-Gen with several previous 3D pocket-base molecular generation models: the 3D density generation model LiGAN [17], and the auto-regressive 3D generation models
109
+
110
+ Table 1: Performance on pocket-based 3D molecular generation.
111
+
112
+ <table><tr><td>Model</td><td>3D Sim(↑)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>MM-PBSA(↓)</td><td>MM-PBSA- Rank(↓)</td><td>MM-PBSA- B.T.(%↑)</td></tr><tr><td>LiGAN[17]</td><td>0.356</td><td>-6.724</td><td>-5.372</td><td>-17.865</td><td>2.57</td><td>0.3</td></tr><tr><td>3DSBDD[18]</td><td>0.365</td><td>-8.662</td><td>-7.227</td><td>-30.221</td><td>2.26</td><td>3.2</td></tr><tr><td>GraphBP[19]</td><td>0.333</td><td>-8.710</td><td>-3.689</td><td>-5.130</td><td>3.98</td><td>0</td></tr><tr><td>Pocket2Mol[20]</td><td>0.352</td><td>-8.332</td><td>-6.525</td><td>-7.823</td><td>3.49</td><td>0</td></tr><tr><td>VD-Gen</td><td>0.414</td><td>-9.047</td><td>-7.444</td><td>-51.258</td><td>1.18</td><td>13.5</td></tr></table>
113
+
114
+ Table 2: Ablation study on pretraining.
115
+
116
+ <table><tr><td>Setting</td><td></td><td>|no pretrain|pretrain pocket encoder only|pretrain VP encoder only |pretrain</td><td></td><td></td></tr><tr><td>3D Similarity (↑) |</td><td>0.361</td><td>0.379</td><td>0.402</td><td>0.414</td></tr></table>
117
+
118
+ GraphBP [19], 3DSBDD [18], and Pocket2Mol [20]. For all models, we generate 500 results for each pocket, and then select 100 from them. For 3DSBDD and Pocket2Mol, beam search is used and the top 100 results are selected. For VD-Gen, the selection is based on the confidence score. For LiGAN and GraphBP, random 100 results are selected due to they did not implement beam search.
119
+
120
+ Results As we pay more attention to the generated molecules with high binding affinities, we report the top 5-th percentile result for Vina, Vina\*, and MM-PBSA. MM-PBSA-Rank is calculated based on the top 5-th percentile MM-PBSA result. The 10-th, 25-th, and 50-th percentile results are in Appendix B.3.
121
+
122
+ From the results in Table 1, it is easy to conclude: 1) VD-Gen significantly outperforms all other baselines in all metrics, with top-1 MM-PBSA Rank, demonstrating the superior performance of the proposed VD-Gen. 2) MM-PBSA B.T shows that VD-Gen can generate more molecules with better MM-PBSA scores than the ground-truth ones, while baseline hardly can. 3) In 3D Similarity results, VD-Gen also largely outperforms baselines, indicating that VD-Gen effectively learned the pocket-based 3D molecular generation and can generalize to unseen pockets. 4) Although some baselines achieve good performance on Vina scores, like GraphBP and Pocket2Mol, their Vina\* and MM-PBSA scores are very poor. We believe the re-docking in Vina fixes their generated 3D structures and then a good Vina score could be obtained. This result indicates that the previously widely used Vina score is not a good metric for pocket-based 3D molecular generation.
123
+
124
+ # 3.3 ABLATION STUDY
125
+
126
+ Pocket coverage As discussed in Sec. 2.1, Virtual Dynamics requires many VPs to cover the pocket cavity as much as possible. And we study how the number of VPs affects the final performance, the results are shown in Fig. 3(a). From the result, it is clear that the number of VPs will affect the performance, and the results with more VPs are better.
127
+
128
+ Effectiveness of Refinement stage The Refinement stage is used to further refine the 3D molecule after Extraction. To examine how Refinement affects the final performance, we benchmarked different movement iterations in Refinement. As shown in Fig. 3(c), we can find the results with more iterations are better. The result indicates the necessity of the Refinement stage.
129
+
130
+ Iterative Movement ronuds Iterative Movement is critical in the Virtual Dynamics. From the result in Fig. 3(c), we can find the results with more rounds are better. We also benchmark the effectiveness of Iterative Movement in Equilibrium stage. And we reduce the movement iterations to $2 5 \%$ in Refinement stage, to better show the impact brought by Equilibrium stage. As shown in Fig. 3(b), we can find more iteration rounds in Equilibrium also improves the final performance.
131
+
132
+ Effectiveness of Confidence stage The pLDDT score is outputted at Confidence stage, and used for selecting or ranking molecules, and we want to check its effectiveness. In particular, we calculate the correlation between 3D similarity and the pLDDT for the generated molecules on a pocket (PDBID 1I7Z), and the result is shown in Fig. 3(d). It is clear that with a larger pLDDT score, the corresponding 3D Similarity is better. This result indicates that the confidence score provided by VD-Gen is effective to select or rank the generated molecules.
133
+
134
+ Effectiveness of pretraining We also benchmark the performance brought by pretraining. In particular, we add three additional models, one without any pretraining, one only with pocket pretraining, and one only with particle pretraining. From the results shown in Table 2, we can easily conclude that pretraining indeed boosts the performance of VD-Gen.
135
+
136
+ ![](images/90a32e7d173250f8d016ff9a3e3b0174b4658fefd15d67493c2ac6f4af6e6dd0.jpg)
137
+
138
+ ![](images/a1084a842878d6d0788dd1367e459758b56f22364b85e1d2a666868c1dec08f3.jpg)
139
+ Figure 3: Ablation studies for VD-Gen.
140
+
141
+ ![](images/69b3139be3dd316aacb20dc492abb5648f3c6fc4691a3d73a83dfea665916375.jpg)
142
+ Figure 4: Generated molecules with high 3D similarity to the reference molecular and high PBSA scores for three protein pockets. Gray surfaces are the protein pockets. Green molecules are the ground truth molecules. Purple molecules are the molecules generated by ${ \tt V D - G e n }$ . Lower Vina score, lower PBSA score and higher 3D similarity indicate higher binding affinity.
143
+
144
+ # 3.4 CASE STUDY
145
+
146
+ Here, we selected three protein pockets from the test set to visualize the generated results of VD-Gen on pocket-based generation tasks. As shown in Fig 4, for each pocket, 3 molecules (purple molecules in the middle column) with the top MM-PBSA scores are selected for display. These molecules are shown as they as, without any structural post-processing. Green molecules are the ground truth molecules, and the rightmost column is the spatial overlapping of the generated molecules and the original molecule.
147
+
148
+ In the first case (PDBID: 2XBW), the protein pocket has a pit deep inside the protein (bottom left of the image), the volume of which can accommodate about one benzene ring. It is a challenging task due to the small size of the pit and the long distance from the center of the whole pocket. We can see that the molecules generated by VD-Gen have successfully grown fragments within the pit. On the other hand, the three generated molecules have good 3D similarity with the original molecules, and the MM-PBSA score is good, the Vina scores of the original molecule are much better than those of the three generated molecules. If we only use Vina to pick molecules, It may lead to not picking good molecules.
149
+
150
+ In the second case (PDBID: 1BHX), the protein pocket is bulky, which requires the generation of protein-interacting fragments at both ends of the protein pocket, and connecting the two ends together by a molecular backbone, we can see the original molecule is long and distorted, making it a challenging prediction task. We see that the molecules generated by VD-Gen replicate the shape of the original molecules well, filling the uneven protein pockets well. All three molecules have good 3D similarity and MM-PBSA scores.
151
+
152
+ In the third case (PDBID: 2BRM), the protein pocket is flat, which requires that the molecular backbone of the ligand bound to it should be close to a planar structure, such as composed of conjugated aromatic rings. We can see that the molecules generated by VD-Gen are the same as the original molecular structures, whose molecular backbone is a planar structure composed of conjugated aromatic rings, and the part toward the outside of the pocket is flexible. We can see that in this case, Vina scoring, MM-PBSA scoring, and 3D similarity all show good agreements.
153
+
154
+ From these three cases in Fig 4, we can see that VD-Gen has demonstrated good generation capabilities on different types of challenging molecular generation tasks. For example, the generated molecules can fill deep pockets, follow the trend of large pockets, or match the special structure of the pockets, and the 3D similarity between the generated molecule and the molecule in the original crystal structure is high. On the other hand, we can see that the MM-PBSA score and 3D similarity maintain good consistency in evaluating the quality of generated molecules, while the Vina score fails in some cases, which indicates that it is unreasonable to select molecules based on the Vina score alone.
155
+
156
+ # 4 RELATED WORK
157
+
158
+ Ligand-Based Molecular Generation Early works focused on ligand-based molecular generation, took a set of molecules as training data, and generated molecules based on the learned distribution of training data. And these methods mainly represented molecules as 1D SMILES strings and 2D molecular graphs, and used VAEs [12; 13; 14; 40; 41; 42], GANs [43; 44], flow models [45] for oneshot generation, RNNs [46; 47; 48; 49], reinforcement learning approaches[50; 51] for step-by-step generation. And some works [52; 53; 54] tried to preserve structural features like molecular scaffolds, or physicochemical properties like QED, to gain better generated molecules compared to randomly generation. However, those methods did not take the binding affinity against a specific protein pocket as a target directly thus the generated molecules hardly worked well in real-world tasks. Some recent works [55; 56; 57; 58] also tried the ligand-based 3D molecular generation.
159
+
160
+ Pocket-Based Molecular Generation Due to the importance of binding affinity in drug design, recent works involved the information of protein pockets for molecular generation. Early attempts [15; 16] encoded pocket information and took it as a condition to generate molecules in SMILES strings or molecular graphs. However, since the binding affinity depends on the spatial positions of pocket and molecule, the latter works paid more effort in generating molecules with 3D spatial structures. Some works [17], recognized as molecular 3D density grid generation, converted pockets and molecules into 3D density grids, and applied 3D convolutional models like processing images. But as the pocket cavity is large, the positions of pockets and molecules are coarse-grained in 3D density grids and it leads to information loss and hard to generate fine-grained molecules. Besides, it is not end-to-end since the conversion from 3D density to 3D coordinates is required and usually causes additional accuracy loss. Some other works [18; 19; 20], recognized as auto-regressive 3D molecular generation, sampled/generated atoms in 3D space one by one to form a molecule. Suffering from the large space of continuous 3D positions, it is quite inefficient. Besides, unlike the sequential nature in text, the atoms in a molecule do not have a sequential order. That is, we do not know which atoms should be generated first, and thus, using auto-regressive generation for 3D molecules is not reasonable.
161
+
162
+ # 5 CONCLUSION
163
+
164
+ In this paper, we propose VD-Gen, a novel pocket-based 3D molecular generation framework, which consists of a Virtual Dynamics mechanism and several stages, to generate fine-grained 3D molecules with good binding affinities against the pocket end-to-end. In particular, with Virtual Dynamics, many virtual particles are first randomly scattered in the pocket cavity, and are iteratively moved to positions that are highly possible to contain real atoms. Then, a coarse-grained 3D molecule could be extracted by deep models from these particles. Next, the 3D molecule is continued refined by Virtual Dynamics again, and a fine-grained 3D molecule could be obtained. Finally, a confidence score will be calculated for the generated molecule for the need of selecting or ranking. Several strategies are proposed to make the training of VD-Gen feasible. Experiment results demonstrate that VD-Gen can generate molecules with higher binding affinities to protein pockets and more accurate 3D binding structures than other baselines. Several case studies also demonstrate the effectiveness of VD-Gen.
165
+
166
+ REFERENCES
167
+ [1] Hugo Kubinyi. 3D QSAR in drug design: volume 1: theory methods and applications, volume 1. Springer Science & Business Media, 1993.
168
+ [2] Renee L DesJarlais, Robert P Sheridan, George L Seibel, J Scott Dixon, Irwin D Kuntz, and R Venkataraghavan. Using shape complementarity as an initial screen in designing ligands for a receptor binding site of known three-dimensional structure. Journal of medicinal chemistry, 31(4):722–729, 1988.
169
+ [3] Robert S DeWitte, Alexey V Ishchenko, and Eugene I Shakhnovich. Smog: de novo design method based on simple, fast, and accurate free energy estimates. 2. case studies in molecular design. Journal of the American Chemical Society, 119(20):4608–4617, 1997.
170
+ [4] Robert S DeWitte and Eugene I Shakhnovich. Smog: de novo design method based on simple, fast, and accurate free energy estimates. 1. methodology and supporting evidence. Journal of the American Chemical Society, 118(47):11733–11744, 1996.
171
+ [5] W Patrick Walters, Matthew T Stahl, and Mark A Murcko. Virtual screening—an overview. Drug discovery today, 3(4):160–178, 1998.
172
+ [6] Brian K Shoichet. Screening in a spirit haunted world. Drug discovery today, 11(13-14):607– 615, 2006.
173
+ [7] Brian K Shoichet. Virtual screening of chemical libraries. Nature, 432(7019):862–865, 2004.
174
+ [8] Anita de Ruiter and Chris Oostenbrink. Free energy calculations of protein–ligand interactions. Current opinion in chemical biology, 15(4):547–552, 2011.
175
+ [9] Christophe Chipot and Andrew Pohorille. Free energy calculations, volume 86. Springer, 2007.
176
+ [10] Clara D Christ, Alan E Mark, and Wilfred F Van Gunsteren. Basic ingredients of free energy calculations: a review. Journal of computational chemistry, 31(8):1569–1582, 2010.
177
+ [11] Julien Michel and Jonathan W Essex. Prediction of protein–ligand binding affinity by free energy simulations: assumptions, pitfalls and expectations. Journal of computer-aided molecular design, 24(8):639–658, 2010.
178
+ [12] Matt J Kusner, Brooks Paige, and José Miguel Hernández-Lobato. Grammar variational autoencoder. In International conference on machine learning, pages 1945–1954. PMLR, 2017.
179
+ [13] Hanjun Dai, Yingtao Tian, Bo Dai, Steven Skiena, and Le Song. Syntax-directed variational autoencoder for structured data. arXiv preprint arXiv:1802.08786, 2018.
180
+ [14] Robin Winter, Floriane Montanari, Andreas Steffen, Hans Briem, Frank Noé, and Djork-Arné Clevert. Efficient multi-objective molecular optimization in a continuous latent space. Chemical science, 10(34):8016–8024, 2019.
181
+ [15] Miha Skalic, Davide Sabbadin, Boris Sattarov, Simone Sciabola, and Gianni De Fabritiis. From target to drug: generative modeling for the multimodal structure-based ligand design. Molecular pharmaceutics, 16(10):4282–4291, 2019.
182
+ [16] Mingyuan Xu, Ting Ran, and Hongming Chen. De novo molecule design through the molecular generative model conditioned by 3d information of protein binding sites. Journal of Chemical Information and Modeling, 61(7):3240–3254, 2021.
183
+ [17] Matthew Ragoza, Tomohide Masuda, and David Ryan Koes. Generating 3d molecules conditional on receptor binding sites with deep generative models. Chemical science, 13(9):2701– 2713, 2022.
184
+ [18] Shitong Luo, Jiaqi Guan, Jianzhu Ma, and Jian Peng. A 3d molecule generative model for structure-based drug design. arXiv preprint arXiv:2203.10446, 2022.
185
+ [19] Meng Liu, Youzhi Luo, Kanji Uchino, Koji Maruhashi, and Shuiwang Ji. Generating 3d molecules for target protein binding. arXiv preprint arXiv:2204.09410, 2022.
186
+
187
+ [20] Xingang Peng, Shitong Luo, Jiaqi Guan, Qi Xie, Jian Peng, and Jianzhu Ma. Pocket2mol: Efficient molecular sampling based on 3d protein pockets. arXiv preprint arXiv:2205.07249, 2022.
188
+
189
+ [21] Berni J Alder and Thomas Everett Wainwright. Studies in molecular dynamics. i. general method. The Journal of Chemical Physics, 31(2):459–466, 1959.
190
+
191
+ [22] Berni Julian Alder and Thomas Everett Wainwright. Studies in molecular dynamics. ii. behavior of a small number of elastic spheres. The Journal of Chemical Physics, 33(5):1439–1451, 1960.
192
+
193
+ [23] Oleg Trott and Arthur J Olson. Autodock vina: improving the speed and accuracy of docking with a new scoring function, efficient optimization, and multithreading. Journal of computational chemistry, 31(2):455–461, 2010.
194
+
195
+ [24] Maohua Yang, Dongdong Wang, and Hang Zheng. Uni-gbsa: An automatic workflow to perform $\mathrm { { m m / g b ( p b ) s a } }$ calculations for virtual screening. ChemRxiv, 2022.
196
+
197
+ [25] Ambrish Roy and Jeffrey Skolnick. Ligsift: an open-source tool for ligand structural alignment and virtual screening. Bioinformatics, 31(4):539–544, 2015.
198
+
199
+ [26] Alan D McNaught, Andrew Wilkinson, et al. Compendium of chemical terminology, volume 1669. Blackwell Science Oxford, 1997.
200
+
201
+ [27] Shin Sato. On a new method of drawing the potential energy surface. The Journal of chemical physics, 23(3):592–593, 1955.
202
+
203
+ [28] Gengmo Zhou, Zhifeng Gao, Qiankun Ding, Hang Zheng, Hongteng Xu, Zhewei Wei, Linfeng Zhang, and Guolin Ke. Uni-mol: A universal 3d molecular representation learning framework. 2022.
204
+
205
+ [29] Yu Shi, Shuxin Zheng, Guolin Ke, Yifei Shen, Jiacheng You, Jiyan He, Shengjie Luo, Chang Liu, Di He, and Tie-Yan Liu. Benchmarking graphormer on large-scale molecular modeling datasets. arXiv preprint arXiv:2203.04810, 2022.
206
+
207
+ [30] Richard Feynman. The Character of Physical Law, with new foreword. MIT press, 2017.
208
+
209
+ [31] John Jumper, Richard Evans, Alexander Pritzel, Tim Green, Michael Figurnov, Olaf Ronneberger, Kathryn Tunyasuvunakool, Russ Bates, Augustin Žídek, Anna Potapenko, et al. Highly accurate protein structure prediction with alphafold. Nature, 596(7873):583–589, 2021.
210
+
211
+ [32] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. Focal loss for dense object detection. In Proceedings of the IEEE international conference on computer vision, pages 2980–2988, 2017.
212
+
213
+ [33] Valerio Mariani, Marco Biasini, Alessandro Barbato, and Torsten Schwede. lddt: a local superposition-free score for comparing protein structures and models using distance difference tests. Bioinformatics, 29(21):2722–2728, 2013.
214
+
215
+ [34] Tiejun Cheng, Xun Li, Yan Li, Zhihai Liu, and Renxiao Wang. Comparative assessment of scoring functions on a diverse test set. Journal of chemical information and modeling, 49(4):1079–1093, 2009.
216
+
217
+ [35] Samuel Genheden and Ulf Ryde. The mm/pbsa and mm/gbsa methods to estimate ligand-binding affinities. Expert opinion on drug discovery, 10(5):449–461, 2015.
218
+
219
+ [36] Renxiao Wang, Xueliang Fang, Yipin Lu, and Shaomeng Wang. The pdbbind database: Collection of binding affinities for protein- ligand complexes with known three-dimensional structures. Journal of medicinal chemistry, 47(12):2977–2980, 2004.
220
+
221
+ [37] 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.
222
+
223
+ [38] Paul G Francoeur, Tomohide Masuda, Jocelyn Sunseri, Andrew Jia, Richard B Iovanisci, Ian Snyder, and David R Koes. Three-dimensional convolutional neural networks and a crossdocked data set for structure-based drug design. Journal of Chemical Information and Modeling, 60(9):4200–4215, 2020.
224
+
225
+ [39] Christiam Camacho, George Coulouris, Vahram Avagyan, Ning Ma, Jason Papadopoulos, Kevin Bealer, and Thomas L Madden. Blast+: architecture and applications. BMC bioinformatics, 10(1):1–9, 2009.
226
+
227
+ [40] Ryan-Rhys Griffiths and José Miguel Hernández-Lobato. Constrained bayesian optimization for automatic chemical design using variational autoencoders. Chemical science, 11(2):577–586, 2020.
228
+
229
+ [41] Orion Dollar, Nisarg Joshi, David AC Beck, and Jim Pfaendtner. Attention-based generative models for de novo molecular design. Chemical Science, 12(24):8362–8372, 2021.
230
+
231
+ [42] André F Oliveira, Juarez LF Da Silva, and Marcos G Quiles. Molecular property prediction and molecular design using a supervised grammar variational autoencoder. Journal of Chemical Information and Modeling, 62(4):817–828, 2022.
232
+
233
+ [43] Gabriel Lima Guimaraes, Benjamin Sanchez-Lengeling, Carlos Outeiral, Pedro Luis Cunha Farias, and Alán Aspuru-Guzik. Objective-reinforced generative adversarial networks (organ) for sequence generation models. arXiv preprint arXiv:1705.10843, 2017.
234
+
235
+ [44] Benjamin Sanchez-Lengeling, Carlos Outeiral, Gabriel L Guimaraes, and Alan Aspuru-Guzik. Optimizing distributions over molecular space. an objective-reinforced generative adversarial network for inverse-design chemistry (organic). 2017.
236
+
237
+ [45] Chence Shi, Minkai Xu, Zhaocheng Zhu, Weinan Zhang, Ming Zhang, and Jian Tang. Graphaf: a flow-based autoregressive model for molecular graph generation. arXiv preprint arXiv:2001.09382, 2020.
238
+
239
+ [46] Marcus Olivecrona, Thomas Blaschke, Ola Engkvist, and Hongming Chen. Molecular de-novo design through deep reinforcement learning. Journal of cheminformatics, 9(1):1–14, 2017.
240
+
241
+ [47] Esben Jannik Bjerrum and Richard Threlfall. Molecular generation with recurrent neural networks (rnns). arXiv preprint arXiv:1705.04612, 2017.
242
+
243
+ [48] Marwin HS Segler, Thierry Kogej, Christian Tyrchan, and Mark P Waller. Generating focused molecule libraries for drug discovery with recurrent neural networks. ACS central science, 4(1):120–131, 2018.
244
+
245
+ [49] Daniel Flam-Shepherd, Kevin Zhu, and Alán Aspuru-Guzik. Keeping it simple: Language models can learn complex molecular distributions. arXiv preprint arXiv:2112.03041, 2021.
246
+
247
+ [50] Jiaxuan You, Bowen Liu, Zhitao Ying, Vijay Pande, and Jure Leskovec. Graph convolutional policy network for goal-directed molecular graph generation. Advances in neural information processing systems, 31, 2018.
248
+
249
+ [51] Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Multi-objective molecule generation using interpretable substructures. In International conference on machine learning, pages 4849–4859. PMLR, 2020.
250
+
251
+ [52] Yibo Li, Jianxing Hu, Yanxing Wang, Jielong Zhou, Liangren Zhang, and Zhenming Liu. Deepscaffold: a comprehensive tool for scaffold-based de novo drug discovery using deep learning. Journal of chemical information and modeling, 60(1):77–91, 2019.
252
+
253
+ [53] Jaechang Lim, Sang-Yeon Hwang, Seokhyun Moon, Seungsu Kim, and Woo Youn Kim. Scaffold-based molecular design with a graph generative model. Chemical science, 11(4):1153– 1164, 2020.
254
+
255
+ [54] Rafael Gómez-Bombarelli, Jennifer N Wei, David Duvenaud, José Miguel Hernández-Lobato, Benjamín Sánchez-Lengeling, Dennis Sheberla, Jorge Aguilera-Iparraguirre, Timothy D Hirzel, Ryan P Adams, and Alán Aspuru-Guzik. Automatic chemical design using a data-driven continuous representation of molecules. ACS central science, 4(2):268–276, 2018.
256
+
257
+ [55] Vitali Nesterov, Mario Wieser, and Volker Roth. 3dmolnet: a generative network for molecular structures. arXiv preprint arXiv:2010.06477, 2020.
258
+ [56] Gregor Simm, Robert Pinsler, and José Miguel Hernández-Lobato. Reinforcement learning for molecular design guided by quantum mechanics. In International Conference on Machine Learning, pages 8959–8969. PMLR, 2020.
259
+ [57] Emiel Hoogeboom, Victor Garcia Satorras, Clément Vignac, and Max Welling. Equivariant diffusion for molecule generation in 3d. In International Conference on Machine Learning, pages 8867–8887. PMLR, 2022.
260
+ [58] Lemeng Wu, Chengyue Gong, Xingchao Liu, Mao Ye, and Qiang Liu. Diffusion-based molecule generation with informative prior bridges. arXiv preprint arXiv:2209.00865, 2022.
261
+ [59] 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.
262
+ [60] Chia-Tche Chang, Bastien Gorissen, and Samuel Melchior. Fast oriented bounding box optimization on the rotation group so (3, r). ACM Transactions on Graphics (TOG), 30(5):1–16, 2011.
263
+ [61] Jerome Eberhardt, Diogo Santos-Martins, Andreas F Tillack, and Stefano Forli. Autodock vina 1.2. 0: New docking methods, expanded force field, and python bindings. Journal of Chemical Information and Modeling, 61(8):3891–3898, 2021.
264
+ [62] Alexey Onufriev, Donald Bashford, and David A Case. Exploring protein native states and large-scale conformational changes with a modified generalized born model. Proteins: Structure, Function, and Bioinformatics, 55(2):383–394, 2004.
265
+ [63] Yong Duan, Chun Wu, Shibasish Chowdhury, Mathew C Lee, Guoming Xiong, Wei Zhang, Rong Yang, Piotr Cieplak, Ray Luo, Taisung Lee, et al. A point-charge force field for molecular mechanics simulations of proteins based on condensed-phase quantum mechanical calculations. Journal of computational chemistry, 24(16):1999–2012, 2003.
266
+ [64] Araz Jakalian, Bruce L Bush, David B Jack, and Christopher I Bayly. Fast, efficient generation of high-quality atomic charges. am1-bcc model: I. method. Journal of computational chemistry, 21(2):132–146, 2000.
267
+ [65] Harrison Green and Jacob D Durrant. Deepfrag: An open-source browser app for deep-learning lead optimization. Journal of chemical information and modeling, 61(6):2523–2529, 2021.
268
+
269
+ A VD-GEN DETAILS
270
+
271
+ Table 3: Symbol in VD-Gen.
272
+
273
+ <table><tr><td>Symbol</td><td>Meaning</td></tr><tr><td>P</td><td>the set of atoms in the pocket</td></tr><tr><td>Vr</td><td>the set of virtual particles (VPs) that are generated at the r-th round in Equilibrium</td></tr><tr><td>Wr</td><td>the set of virtual particles (VPs) that are generated at the r-th round in Refinement</td></tr><tr><td>G</td><td>the set of ground-truth atoms</td></tr><tr><td></td><td>the i-th pocket atom&#x27;s type (one-hot)</td></tr><tr><td></td><td>the i-th pocket atom&#x27;s coordinate</td></tr><tr><td></td><td>the i-th ground-truth atom&#x27;s type (one-hot)</td></tr><tr><td></td><td>the i-th ground-truth atom&#x27;s coordinate</td></tr><tr><td></td><td>the i-th VP&#x27;s type (one-hot) at the r-th round in Equilibrium</td></tr><tr><td></td><td>the i-th VP&#x27;s coordinate at the r-th round in Equilibrium</td></tr><tr><td></td><td>predicted atom type distribution of i-th VP at the r-th round</td></tr><tr><td>ai</td><td>The index of assigned target atom for the i-th VP</td></tr><tr><td>di</td><td>the predicted distance of the i-th and j-th VP pair at the r-th round</td></tr><tr><td></td><td>the ground-truth distance of the i-th and j-th VP pair</td></tr><tr><td></td><td>the predicted (ground-truth) distance of the i-th VP and the j-th pocket atom at the r-th round</td></tr><tr><td></td><td>the ground-truth distance of the i-th VP and the j-th pocket atom.</td></tr><tr><td>xr</td><td>the i-th VP&#x27;s type (one-hot) at the r-th round in Refinement</td></tr><tr><td>yi</td><td>the i-th VP&#x27;s coordinate at the r-th round in in Refinement</td></tr><tr><td></td><td>the pair representation of VP pair</td></tr><tr><td></td><td>the pair representation of VP pair at l-th layer</td></tr><tr><td></td><td>the pair representation of pocket atom pair</td></tr><tr><td></td><td>the pair representation of VP and pocket pair</td></tr><tr><td></td><td>the predicted probability distribution of &quot;success or&quot; not for VP</td></tr><tr><td>r</td><td>predicted probability of merging type of VP pair</td></tr><tr><td>n</td><td>the predicted atom number</td></tr><tr><td>Wi</td><td>The indices of VPs in the i-th cluster in Extraction</td></tr><tr><td>h</td><td>the node representation of VP</td></tr><tr><td>h</td><td>the node representation of VP at l-th layer</td></tr><tr><td>hV</td><td>the node representation of VP in Equilibrium</td></tr><tr><td>qV</td><td>the pair representation of VP pair in Equilibrium</td></tr><tr><td>hW</td><td>the node representation of VP in Refinement</td></tr><tr><td>94</td><td>the pair representation of VP pair in Refinement</td></tr><tr><td>hP</td><td>the node representation of pocket atom</td></tr><tr><td>0eq</td><td>the model parameter in Equilibrium</td></tr><tr><td>0ex</td><td>the model parameter in Extraction</td></tr><tr><td>0re</td><td>the model parameter in Refinement</td></tr><tr><td>0co</td><td>the model parameter in Confidence</td></tr><tr><td>f</td><td>the SE(3) backbone model, return VP types and coordinates</td></tr><tr><td>L</td><td>the number of layers</td></tr></table>
274
+
275
+ # A.1 VIRTUAL DYNAMICS
276
+
277
+ # A.1.1 DETAILS OF THE BACKBONE MODEL
278
+
279
+ In Fig 2 we show the structure of our backbone model, "Repr.", "Attn." and "Dist." are the abbreviations of "Representation", "Attention" and "Distance", respectively. On the left is the pocket encoder, which first uses an atom-type embedding to encode the pocket atom type and a Gaussian kernel to encode the pair-wise distances between pocket atom pairs. In each layer of the pocket encoder, a self-attention layer is used. On the right is the VP encoder, which also uses an atom-type embedding and a Gaussian kernel to encode the particle type and the pair-wise distances between VPs. To interact with the pocket encoder, another Gaussian kernel is used to encode the pair-wise distances between VPs and pocket atoms. In each layer of the VP encoder, before the self-attention layer, a particle-pocket attention layer is used to interact with the pocket encoder.
280
+
281
+ We describe the components in the backbone model in the following paragraphs. Besides, we also describe the overall pipeline of the backbone model in the Alg. 2. For simplicity, layer normalization is not shown in the equations and algorithms.
282
+
283
+ Gaussian kernel The pair-type aware Gaussian kernel [59; 28] is denoted as:
284
+
285
+ $$
286
+ p _ { i j } = \{ \mathcal { G } ( A ( d _ { i j } , t _ { i j } ; a , b ) , \mu ^ { k } , \sigma ^ { k } ) | k \in [ 1 , D ] \} , \quad \mathcal { A } ( d , r ; a , b ) = a _ { r } d + b _ { r } ,
287
+ $$
288
+
289
+ where $\begin{array} { r } { \mathcal { G } ( d , \mu , \sigma ) = \frac { 1 } { \sigma \sqrt { 2 \pi } } e ^ { - \frac { ( d - \mu ) ^ { 2 } } { 2 \sigma ^ { 2 } } } } \end{array}$ is a Gaussian density function with parameters $\mu$ and $\sigma , d _ { i j }$ is the Euclidean distance of atom pair $i j$ , and $t _ { i j }$ is the pair-type of atom pair $i j$ . $\mathcal { A } ( d _ { i j } , t _ { i j } ; \pmb { a } , \pmb { b } )$ is the affine transformation with parameters $\textbf { \em a }$ and $^ { b }$ , it affines $d _ { i j }$ corresponding to its pair-type $t _ { i j }$ .
290
+
291
+ Pair representation Pair representation [28] is used to further enhance the 3D spatial encoding.
292
+ The update of pair representation is via the multi-head Query-Key product results in self-attention.
293
+
294
+ $$
295
+ { \pmb q } _ { i j } ^ { l + 1 } = { \pmb q } _ { i j } ^ { l } + \{ \frac { { \pmb h } _ { i } ^ { l } { \pmb W } _ { l , h } ^ { Q } ( { \pmb h } _ { j } ^ { l } { \pmb W } _ { l , h } ^ { K } ) ^ { T } } { \sqrt { d } } | h \in [ 1 , H ] \} ,
296
+ $$
297
+
298
+ where $h _ { i } ^ { l }$ is the atom/node representation of the $i$ -th atom at $l$ -th layer, $\pmb { q } _ { i j } ^ { l }$ is the pair representation of atom pair $i j$ in $l$ -th layer, $H$ is the number of attention heads, $d$ is the dimension of hidden representations, and $W _ { l , h } ^ { Q } ( W _ { l , h } ^ { K } )$ is the projection for Query (Key) of the $l$ -th layer $h$ -th head.
299
+
300
+ To leverage 3D information in the atom representation, pair representation is used in self-attention.
301
+
302
+ $$
303
+ \begin{array} { r l } & { \pmb { h } _ { i } ^ { l + 1 , h } = \mathrm { s o f t m a x } ( \frac { h _ { i } ^ { l } W _ { l , h } ^ { Q } ( h _ { j } ^ { l } W _ { l , h } ^ { K } ) ^ { T } } { \sqrt { d } } + \pmb { q } _ { i j } ^ { l , h } ) \pmb { h } _ { j } ^ { l } W _ { l , h } ^ { V } , } \\ & { \quad \pmb { h } _ { i } ^ { l + 1 } = \mathrm { c o n c a t } _ { h } ( \pmb { h } _ { i } ^ { l + 1 , h } ) , } \end{array}
304
+ $$
305
+
306
+ where ${ W } _ { l , h } ^ { V }$ is the projection of Value of the $l$ -th layer $h$ -th head.
307
+
308
+ Particle-Pocket Attention The Particle-Pocket Attention can be denoted as the following:
309
+
310
+ $$
311
+ \begin{array} { r l } & { { \pmb h } _ { i } ^ { l + 1 , h } = \mathrm { s o f t m a x } ( \frac { h _ { i } ^ { l } { \pmb W } _ { l , h } ^ { P , Q } ( { \pmb h } _ { j } ^ { P } { \pmb W } _ { l , h } ^ { P , K } ) ^ { T } } { \sqrt { d } } + { \pmb q } _ { i j } ^ { C , l , h } ) { \pmb h } _ { j } ^ { P } { \pmb W } _ { l , h } ^ { P , V } , } \\ & { { \pmb h } _ { i } ^ { l + 1 } = \mathrm { c o n c a t } _ { h } ( { \pmb h } _ { i } ^ { l + 1 , h } ) , } \\ & { { \pmb h } _ { i } ^ { l + 1 } = { \pmb h } _ { i } ^ { l } + g _ { 1 } \cdot { \pmb h } _ { i } ^ { l + 1 } + g _ { 2 } \cdot \mathrm { { M L P } } ( { \pmb h } _ { i } ^ { l + 1 } ) , } \end{array}
312
+ $$
313
+
314
+ where $g _ { 1 }$ and $g _ { 2 }$ are learned parameters with initialized value 0, $h _ { j } ^ { P }$ is the representation of the $j$ -th pocket atom, qC,ij $\mathbf { \mathfrak { q } } _ { i j } ^ { C , l , h }$ is the pair representation of particle-pocket pair $i j$ in $l$ -th layer $h$ -th head, MLP is a full-connected network with one hidden layer. W P,Ql,h , W P,Kl,h , and W P,Vl,h are learnable projections for Query, Key and Value.
315
+
316
+ SE(3)-equivariance coordinate Following [28], the head could be denoted as:
317
+
318
+ $$
319
+ \pmb { y } _ { i } ^ { r + 1 } = \pmb { y } _ { i } ^ { r } + \sum _ { j = 1 } ^ { n } \frac { ( \pmb { y } _ { i } ^ { r } - \pmb { y } _ { j } ^ { r } ) z _ { i j } } { n } , \quad z _ { i j } = \mathrm { R e L U } ( ( \pmb { q } _ { i j } ^ { L } - \pmb { q } _ { i j } ^ { 0 } ) U _ { 1 } ) U _ { 2 } ,
320
+ $$
321
+
322
+ where $n$ is the number of total atoms, $L$ is the number of layers in model, $\pmb { y } _ { i } ^ { r } \in \mathbb { R } ^ { 3 }$ is the input coordinate of $i$ -th atom, and $\pmb { y } _ { i } ^ { r + 1 } \in \mathbb { R } ^ { 3 }$ is the output coordinate of $i$ -th atom, $U _ { 1 } \in \mathbb { R } ^ { H \times H }$ and $U _ { 2 } \in \mathbb { R } ^ { H \times 1 }$ are the projection matrices to convert pair representation to scalar.
323
+
324
+ Atom Type Prediction Head We use a non-linear head with two layers to predict the atom type based on the atom representation in the last layer of the particle encoder:
325
+
326
+ $$
327
+ \bar { \mathbf { x } } _ { i } = \mathbf { M L P } ( h _ { i } ^ { L } )
328
+ $$
329
+
330
+ where $ { \boldsymbol { h } } _ { i } ^ { L }$ is the atom representation, $L$ is the number of layers of the particle encoder,
331
+
332
+ # Algorithm 2 Backbone_Update
333
+
334
+ Require: P: pocket atoms, ${ \mathbf V } _ { r }$ : virtual particles
335
+ 1: ${ \boldsymbol { h } } ^ { P , 0 } \gets$ rAtom_Type_Embedding $( \mathbf { P } )$ a ▷ Embeddings from atom types
336
+ 2: $\pmb q ^ { P , 0 } \gets$ Gaussian_Kernel(Dist_Matrix(P, P)) ▷ Get invariant spatial positional embedding
337
+ 3: for $l \in [ 1 , . . . , L )$ do ▷ Update Pocket Encoder
338
+ 4: $\pmb { h } ^ { P , l } , \pmb { q } ^ { P , l } \gets \mathrm { S e l f \_ A t t n } ( \pmb { h } ^ { P , l - 1 } , \pmb { q } ^ { P , l - 1 } ) )$ ▷ Update by self attention
339
+ 5: $\boldsymbol { h } ^ { P , l } \gets \mathrm { M L P } ( \boldsymbol { h } ^ { P , l } )$ ▷ Update by Feed-Forward-Network
340
+ 6: ${ h ^ { P } h ^ { P , L } }$
341
+ 7: ${ \mathbf { } } h ^ { 0 } $ Atom_Type_Embedding $\left( \mathbf { V } _ { r } \right)$ ▷ Embeddings from atom types
342
+ 8: $q ^ { 0 } \gets$ Gaussian_Kernel(Dist_Matrix(V0, V0)) $\triangleright$ Get invariant spatial positional embedding
343
+ 9: $\pmb q ^ { C , 0 } \gets$ Gaussian_Kernel(Dist_Matrix $( \mathbf { V } _ { 0 } , \mathbf { P } ) )$ ▷ Get invariant spatial positional embedding of
344
+ particle-pocket pairs
345
+ 10: for $l \in [ 1 , . . . , L )$ do ▷ Update Particle Encoder
346
+ 11: $\pmb { h } ^ { l } , \pmb { q } ^ { l } \gets \mathrm { S e l f \_ A t t n } ( \pmb { h } ^ { l - 1 } , \pmb { q } ^ { l - 1 } ) )$ ▷ Update by self attention
347
+ 12: $\pmb { h } ^ { l } \gets \mathrm { M L P } ( \pmb { h } ^ { l } )$ ▷ Update by Feed-Forward-Network
348
+ 13: if l mod $4 = = 0$ then ▷ Only enabled at every 4-layer
349
+ 14: h l , $\pmb q ^ { C , l } \gets$ Particle_Pocket_Attn(hl, hP , qC,l−1)) ▷ Update by Particle-Pocket Attention
350
+ 15: $\bar { \pmb { x } } ^ { r + 1 } \mathrm { A t o m \_ T y p e \_ H e a d } ( \pmb { h } ^ { L } )$ $\triangleright$ Atom Type Prediction
351
+ 16: $\pmb { x } ^ { r + 1 } \mathrm { s a m p l e } ( \bar { \pmb { x } } ^ { r + 1 } )$ ▷ Sample an atom type based on predicted probability
352
+ 17: $\pmb { y } ^ { r + 1 } \gets \mathrm { S E } ( 3 ) \_ \mathrm { H e a d } ( \pmb { y } ^ { r } , \pmb { q } ^ { L } )$ $\triangleright$ Coordinate update
353
+ 18: return $\mathbf { V } _ { r + 1 } = \{ \pmb { x } ^ { r + 1 } , \pmb { y } ^ { r + 1 } \} , \pmb { h } ^ { L } , \pmb { q } ^ { L } , \pmb { h } ^ { P }$
354
+
355
+ ![](images/7a6bdcc3c94fe7907f10ecc633410829aadc6ba7f21f73551bd1450db05726a4.jpg)
356
+ Figure 5: A case to show the detected pocket cavity.
357
+
358
+ # A.1.2 POCKET CAVITY DISCOVERY
359
+
360
+ Pocket cavity discovery is an essential component in ${ \tt V D - G e n }$ , as VPs need to scatter into the cavity. To find the pocket cavity, we first use OBB (oriented bounding box) [60] to determine a cubic box, denote as $\boldsymbol { B }$ , based on the pocket’s residue atoms. Then, we enlarge the box a little bit, increased by $4 \mathring \mathrm { A }$ . Then, we make the 3D grids with resolution $2 \textup { \AA }$ , for the whole protein, including the pocket, and mark the grids that contain protein atoms as "used". Then, starting from a given grid inside the cavity, a breadth-first search is used to find the grids inside the cavity. In particular, the grids marked as "used" or are not in $\boldsymbol { B }$ are not considered. We show an example in Fig 5, where the purple region indicates the pocket cavity we find.
361
+
362
+ # A.2 EXTRACTION
363
+
364
+ # Filtering Loss
365
+
366
+ $$
367
+ { \mathcal { L } } _ { F i l t e r } = { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } { \mathrm { N L L } } ( { \bar { s } } _ { i } , s _ { i } )
368
+ $$
369
+
370
+ where $n$ is the number of virtual particles, $\bar { s } _ { i }$ is the predicted probability distribution of success or not, $\mathbf { \boldsymbol { s } } _ { i }$ is the target label. The target label is marked as "success" if the distances between VPs and their target positions after Equilibrium are smaller than $2 . 5 \mathring \mathrm { \ A }$ .
371
+
372
+ # Merging Loss
373
+
374
+ $$
375
+ \mathcal { L } _ { M e r g e } = \frac { 1 } { l ^ { 2 } } \sum _ { i = 1 } ^ { l } \sum _ { j = 1 } ^ { l } \sum _ { k = 1 } ^ { 2 } - { r } _ { i j } ^ { k } \log \bar { { r } } _ { i j } ^ { k } \alpha _ { k } ( 1 - \bar { { r } } _ { i j } ^ { k } ) ^ { \gamma } ,
376
+ $$
377
+
378
+ where $l$ is the number of virtual particles predicted to be "success", $\boldsymbol { r } _ { i j }$ is the target merging type, $\bar { r } _ { i j }$ is the predicted probability of merging type, the blue part is from focal loss [32], and $\alpha _ { k }$ and $\gamma$ are
379
+
380
+ hyper-parameters to balance classes. Here $\gamma$ is set to 2, the subscript 1 of $\alpha$ represents the True type and $\alpha _ { 1 }$ is set 10 while $\alpha _ { 0 }$ is set to 1.
381
+
382
+ Atom number loss For atom number prediction, we bucket the number of atoms into different bins and transform the numerical problem into a classification problem to make the training more stable.
383
+
384
+ $$
385
+ \mathcal { L } _ { a t o m \_ n u m } = \mathrm { N L L } ( \bar { o } , o )
386
+ $$
387
+
388
+ where $\bar { \bf o }$ is the predicted probability distribution of bins, and $^ o$ represents the one-hot vector of the target bin.
389
+
390
+ During inference, the predicted atomic number can be calculated from the predicted distribution over bins.
391
+
392
+ $$
393
+ \sum _ { k = 1 } ^ { n _ { b i n } } ( b i n _ { - } v a l _ { k } ) \bar { \pmb { o } } _ { k } ,
394
+ $$
395
+
396
+ where $b i n \_ v a l _ { k }$ is the bin value of the $k$ -th bin, $n _ { \mathrm { b i n } }$ is the number of bins, $l$ is the size of each bin and $\bar { o } _ { k }$ is the predicted probability of the $k$ -th bin. Notably, the bin value is not the bin boundary value, it is the average of left and right boundaries.
397
+
398
+ Merge algorithm The detail of merging VPs into atoms are shown in Alg 3. In particular, a binary search is used to find a merging threshold. During training, teacher-forcing merging is used for reducing the training cost (without binary search). This is, rather than predicting pair-wise merge probabilities and the atom number, we directly used their ground truth values. During inference, the binary search is used. Besides, considering the error in atom number prediction, we try a range $( \pm 1 0 )$ of atom numbers, and select from them based on their confidence scores.
399
+
400
+ # A.3 CONFIDENCE
401
+
402
+ The confidence score is based on LDDT metric [33]:
403
+
404
+ $$
405
+ \begin{array} { l } { { \displaystyle { \mathrm { L D D T } } = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \sum _ { j \neq i } \frac { 1 } { 4 } ( ( \operatorname { e r r } _ { i j } < 0 . 5 ) + ( \operatorname { e r r } _ { i j } < 1 . 0 ) + ( \operatorname { e r r } _ { i j } < 2 . 0 ) + ( \operatorname { e r r } _ { i j } ) < 4 . 0 ) , } } \\ { { \displaystyle \operatorname { e r r } _ { i j } = \mathrm { L } 1 ( \| \hat { y } _ { i } ^ { r } - \hat { y } _ { j } ^ { r } \| _ { 2 } , \| \hat { y } _ { i } ^ { g } - \hat { y } _ { j } ^ { g } \| _ { 2 } ) , } } \end{array}
406
+ $$
407
+
408
+ where $\hat { \mathbf { \pmb { y } } } _ { i } ^ { r }$ is the predicted coordinate of $i$ -th particle after Refinement, and $\hat { \pmb y } _ { i } ^ { g }$ is its ground truth coordinate. Then, a task is trained to predict the LDDT score. Here, we use the binning trick for training stability, bucketing the error of each VP into different bins, and using cross-entropy loss to train the task:
409
+
410
+ $$
411
+ { \mathcal { L } } _ { C o n f i d e n c e } = { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } { \mathrm { N L L } } ( { \bar { e } } _ { i } , e _ { i } )
412
+ $$
413
+
414
+ where $\bar { e } _ { i }$ is the predicted error’s probability distribution of $i$ -th VP and $e _ { i }$ represents the one-hot vector of the real error.
415
+
416
+ # A.4 PRETRAIN
417
+
418
+ During pretraining, we remove atoms in a continuous spatial region, and VPs are initialized in the region. To find the atoms in a continuous region, we design a greedy algorithm. First, we initialize an empty atom set, then we randomly select an atom in the molecular to join the set. Starting from the atom set, we choose an atom closest to the atoms in the set and join it to the set. We repeat the process until the number of atoms in the set meets the requirements. And we use OBB (oriented bounding box) [60] to determine a cubic box by the removed atoms, and VPs are initialized inside the cubic box.
419
+
420
+ # A.5 VD-GEN OVERALL ALGORITHM
421
+
422
+ We also summarize the overall inference pipeline of VD-Gen in the Alg. 4. The algorithm mainly relies on the function "VD", which iteratively moves the VPs. Both Equilibrium and Refinement use
423
+
424
+ # Algorithm 3 Filter_Merge_VPs
425
+
426
+ <table><tr><td>ability</td><td></td><td>Require: VR = {(xR,y)}ε=1: virtual particles at R-th rounds, n: the predicted atom num, r =</td><td></td></tr><tr><td>1: for iin [.,..,n] do 2:</td><td></td><td> Set the merge type between particles with the particle to be filtered to O</td><td></td></tr><tr><td>Si←argmax(si)</td><td></td><td></td><td>Get the filtering type</td></tr><tr><td>3:</td><td>if si=Othen</td><td></td><td>If the i-th particle should be filtered</td></tr><tr><td>4:</td><td>r[:,i]←0</td><td></td><td>Set{ri,j=1 to0 n</td></tr><tr><td>5:</td><td>r[i,:]←0</td><td></td><td>Set{rj=1to0 n</td></tr><tr><td>6:</td><td>high←max({((rij)}1,j=1) nxn</td><td></td><td></td></tr><tr><td></td><td>7: low ←min({(Tij)}²=i,j=1) nxn</td><td></td><td></td></tr><tr><td>8:mid ←low+high</td><td></td><td></td><td></td></tr><tr><td>9:</td><td>2 while low high do</td><td></td><td>&gt;using the binary search to find the threshold</td></tr><tr><td>10:</td><td>Tij←rij &gt;mid</td><td></td><td></td></tr><tr><td>11:</td><td>Wo↑,ω←[,m←0</td><td></td><td></td></tr><tr><td>12:</td><td>foriin random_perm(1,n) do</td><td></td><td>Greedy merge based a random order</td></tr><tr><td>13:</td><td>W←,</td><td></td><td></td></tr><tr><td>14:</td><td>for j in[1,..,n] do</td><td></td><td></td></tr><tr><td>15:</td><td>if rij= True then</td><td></td><td> the j-th particle should be merged</td></tr><tr><td>16:</td><td>r[:,j]←False</td><td></td><td> the merged particle will not be merged again</td></tr><tr><td>17:</td><td>Wi.add(j)</td><td></td><td>add the particle indices into the i-th cluster</td></tr><tr><td>18:</td><td>if len(wi)&gt;O then</td><td></td><td></td></tr><tr><td>19:</td><td></td><td></td><td>&gt; Sample atom type from the merging list</td></tr><tr><td>20:</td><td>m←Mean({ylk∈wi})</td><td>&gt; the average position is atom position after merging</td><td></td></tr><tr><td>21:</td><td>Wo.add((xm,ym))</td><td></td><td>add the atom to the set</td></tr><tr><td>22:</td><td>m←m+1</td><td></td><td>Count the number of clusters</td></tr><tr><td>23:</td><td>if m=n then</td><td></td><td> find the threshold</td></tr><tr><td>24:</td><td>break</td><td></td><td></td></tr><tr><td>25:</td><td>else</td><td></td><td></td></tr><tr><td>26:</td><td>ifm&lt;nthen</td><td>V too many particles are merged, the threshold needs to be increased</td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>27:</td><td>low←mid</td><td></td><td></td></tr><tr><td>28:</td><td>else</td><td></td><td></td></tr><tr><td>29: return Wo</td><td>high ←mid</td><td>&gt;Too few particles are merged, the threshold needs to be lowered</td><td>Return particle set after merging</td></tr></table>
427
+
428
+ "VD". In Extraction, several heads are used to predict the filtered probability, the pair merge probability, and the number of atoms of the ligand molecule. Based on these predictions, "Filter_Merge_VPs" is used to extract the merged VPs.
429
+
430
+ The training pipeline is very similar, except for the following differences:
431
+
432
+ • For efficiency purposes, $R _ { 1 }$ and $R _ { 2 }$ are sampled during training, and the gradient backward is only enabled in the last round.
433
+ • For efficiency purposes, in "Filter_Merge_VPs", teacher-forcing merging (without binary search) is used during training. This is, rather than predicting pair-wise merge probabilities and the atom number, we directly used their ground truth values.
434
+ • The loss functions are enabled to get gradients to train models.
435
+
436
+ # B EXPERIMENT DETAILS AND MORE RESULTS
437
+
438
+ # B.1 TRAINING DETAILS
439
+
440
+ The detailed configurations of VD-Gen are listed in Table 4. We did not tune these hyper-parameters for now, a better performance could be achieved with well-tuned hyper-parameters.
441
+
442
+ # B.2 EVALUATION MERTIC
443
+
444
+ • $3 D$ similarity. We use LIGSIFT [25] to calculate 3D similarity. However, by default, LIGSIFT will align the input molecules before calculating 3D similarity. But we want to evaluate the generated
445
+
446
+ # Algorithm 4 VD-Gen Framework during Inference
447
+
448
+ Require: $R _ { 1 }$ , $R _ { 2 }$ : max rounds in Equilibrium and Refinement, P: pocket atoms with types and positions, $_ n$ :
449
+ number of VPs, $\pmb { \theta } _ { e q }$ , $\pmb { \theta } _ { e x }$ , $\pmb { \theta } _ { r e }$ , $\pmb { \theta } _ { c o }$ : model parameters in different stages
450
+ 1:
451
+ 2: # Virtual dynamics mechanism
452
+ 3: def $\mathrm { V D } ( R , { \bf V } _ { 0 } , { \bf P } , \theta )$ : ▷ Virtual dynamics mechanism
453
+ 4: for $k \in [ 1 , . . . , R ]$ do $\triangleright$ Iterative updates without gradients
454
+ 5: $\mathbf { V } _ { k } , h ^ { L } , q ^ { L } , h ^ { P } \longleftarrow \mathrm { B a c k b o n e \underline { { \mathbf { U } } } p d a t e } ( \mathbf { V } _ { k - 1 } , \mathbf { P } ; \theta )$ ▷ backbone model update as in Alg. 2
455
+ return ${ \mathbf V } _ { R } , { \hbar } ^ { L } , { q } ^ { L } , { \hbar } ^ { P }$
456
+ 6:
457
+ 7: # Initialize VPs
458
+ 8: $\tilde { P } = \mathrm { C a v i t y \_ D i s c o v e r y } ( { \bf P } )$ ▷ Get the pocket cavity as in Appendix A.1.2
459
+ 9: for $i$ in [1,...,n] do
460
+ 10: $\pmb { x } _ { i } ^ { 0 } \gets \mathrm { o n e \_ h o t ( \mathrm { I M A S K } ] ) }$ ▷ The types of VPs are initialized as a meaningless [MASK] type
461
+ 11: ${ \pmb y } _ { i } ^ { 0 } \gets \mathrm { U n i f o r m } ( \tilde { P } )$ ▷ The initial coordinates of VPs are uniformly sampled from the cavity
462
+ 12: $\mathbf { V } _ { 0 } = \{ ( { \mathbf { x } } _ { i } ^ { 0 } , { \mathbf { y } } _ { i } ^ { 0 } ) \} _ { i = 1 } ^ { n }$
463
+ 13:
464
+ 14: # Equilibrium stage
465
+ 15: ${ \bf V } _ { R } \dot { \bf \Delta } _ { } h ^ { V } , \pmb { q } ^ { V } , \pmb { h } ^ { P ^ { \angle } } \nabla \mathrm { D } ( R _ { 1 } , { \bf V } _ { 0 } , { \bf P } , \pmb { \theta } _ { e q } )$ ▷ Predict coordinates and types with VD
466
+ 16:
467
+ 17: # Extraction stage
468
+ 18: $\bar { 3 } \mathrm { F i l t e r \_ H e a d } ( h ^ { V } ; \pmb \theta _ { e x } )$ ▷ Predict to filter the "not success" particles
469
+ 19: $\bar { r } \gets \mathsf { M e r g e \_ H e a d } ( \pmb { q } ^ { V } ; \pmb { \theta } _ { e x } )$ ▷ Predict merging matrix
470
+ 20: $\bar { n } \mathrm { A t o m \_ N u m \_ H e a d } ( h ^ { P } ; \pmb \theta _ { e x } )$ ▷ Predict the atom number
471
+ 21: ${ \bf W } _ { 0 } \gets \mathrm { F i l t e r \_ M e r g e \_ V P s } ( { \bf V } _ { R } , \bar { n } , \bar { r } , \bar { s } )$
472
+ 22: ▷ Filter and Merge VPs as in Alg. 3 using predicted merging matrix, atom number and filtering type
473
+ 23:
474
+ 24: # Refinement stage
475
+ 25: $\mathbf { W } _ { R } ^ { \check { \mathbf { \alpha } } } , \mathbf { \Phi } _ { } \mathbf { \Phi } _ { } \mathbf { \Phi } _ { } \mathbf { q } ^ { W } , \check { \mathbf { \alpha } } \check { h } ^ { P } \gets \mathrm { V D } ( R _ { 2 } , \mathbf { W } _ { 0 } , \mathbf { P } ; \mathbf { \theta } _ { r e } )$ ▷ Refine the coordinates and types
476
+ 26: # Confidence stage
477
+ 27: Pred_LDDT Confidence_Head(hW , θco) ▷ Predict LDDT
478
+ 28:
479
+ 29: return $\mathbf { W } _ { R }$ , Pred_LDDT ▷ Return the final positions and types, and the confidence score
480
+
481
+ 3D structure directly, to examine the end-to-end performance. Therefore, we remove the alignment in LIGSIFT.
482
+
483
+ • Vina. We use AutoDock Vina1.2 [61] to get Vina score. In particular, the re-docking will be applied. That is, the binding pose and the conformation of the ligand molecule generated by the model will be ignored, and a new binding pose and a new molecular conformation will be re-calculated by AutoDock Vina1.2. We believe the re-docking in Vina cannot reflect the actual performance of the pocket-based 3D molecular generation. But to be consistent with previous works, we still use it as one of the metrics.
484
+
485
+ • Vina\*. Vina\* is Vina without re-docking. In particular, we use the built-in energy optimization process based on Vina scoring function in AutoDock Vina1.2 [61] to minimize the energy of the binding pose of generated molecules, and then use the Vina scoring function to score the energy-minimized binding pose to get Vina\* score.
486
+
487
+ • MM-PBSA. We take the default settings of parameters (i.e., solvation mode: GB-2[62], protein forcefield: amber03[63], ligand charge method: bcc[64], dielectric constant: 4.0) and workflow (i.e., force field building, structure optimization by energy minimization, MM/GB(PB)SA calculation) of [24] to calculate MM-PBSA score. Since the crystal structure indicates the preferred binding pose against a specific target, we filtered the generated molecules by 3D similarity to the molecule in crystal structure and take the molecules whose 3D similarity score is over 0.4 as effective molecules, and we only calculate the MM-PBSA score for the effective molecules. In Table 6 we show MM-PBSA S.R. (success rate), which calculates the proportion of effective MM-PBSA of the generated molecules. For MM-PBSA B.T. and MM-PBSA Rank we have:
488
+
489
+ $$
490
+ \begin{array} { r l } & { \displaystyle \mathbf { M M } \mathbf { \mathrm { \mathrm { - } P B S A } } \mathbf { \mathrm { B . T } } _ { - } = \frac { 1 } { n _ { p } } \displaystyle \sum _ { i = 1 } ^ { n _ { p } } \frac { \left| \left\{ g \in \mathcal { G } \big | \mathbf { M M } \mathbf { \mathrm { - } P B S A } ( g ) < \mathbf { M M } \mathbf { \mathrm { - } P B S A } ( \overline { { m } } _ { i } ) \right\} \right| } { | \mathcal { G } | } , } \\ & { \displaystyle \mathbf { M M } \mathbf { \mathrm { \mathrm { - } P B S A } } \mathbf { \mathrm { R a n k } } = \frac { 1 } { n _ { p } } \displaystyle \sum _ { i = 1 } ^ { n _ { p } } \mathbf { \mathrm { r a n k } } _ { i } , } \end{array}
491
+ $$
492
+
493
+ where $n _ { p }$ is the number of proteins in the test set, $\mathcal { G }$ represents the generated molecular set, $\overline { { m } } _ { i }$ represents the molecular in the crystal structure of the $i$ -th protein and $\mathrm { r a n k } _ { i }$ represents the ranking index of the current model among all of the compared models under the $i$ -th protein which is ranked by MM-PBSA.
494
+
495
+ • Metric for ablation studies. We use 3D similarity between the generated molecules and the ground truth as the metric in ablation studies since it reflects the generative ability based on the pocket structure and there is a strong correlation between 3D similarity and binding affinity according to Table 1.
496
+
497
+ Table 4: Settings for VD-Gen.
498
+
499
+ <table><tr><td colspan="2">Pretrain</td></tr><tr><td>VP encoder layers Peak learning rate</td><td>12 1e-4</td></tr><tr><td>Batch size</td><td>128</td></tr><tr><td>Max training steps</td><td>1M</td></tr><tr><td>Warmup steps Attention heads</td><td>10K</td></tr><tr><td>FFN dropout</td><td>64</td></tr><tr><td>Attention dropout</td><td>0.1</td></tr><tr><td>Embedding dropout</td><td>0.1 0.1</td></tr><tr><td>Weight decay</td><td>1e-4</td></tr><tr><td>Embedding dim</td><td>512</td></tr><tr><td>FFN hidden dim Gaussian kernel channels</td><td>2048</td></tr><tr><td>Activation function</td><td>128</td></tr><tr><td>Learning rate decay</td><td>GELU Linear</td></tr><tr><td>Adams ∈</td><td>1e-6</td></tr><tr><td>Adams(βi, β2)</td><td>(0.9,0.99)</td></tr><tr><td>Gradient clip norm</td><td>1.0</td></tr><tr><td>Particle type prediction weight</td><td>1.0</td></tr><tr><td>Loss Weight forLvD of Equilibrium</td><td>1.0</td></tr><tr><td>Loss weight for LvD of Refinement</td><td>1.0</td></tr><tr><td>Loss weight for LFilter</td><td>1.0</td></tr><tr><td>Loss weight for LMerge Loss weight for Latom_num</td><td>5.0</td></tr><tr><td>Loss weight for Confidence</td><td>1.0</td></tr><tr><td>R,max round of iterative movement of Equilibrium and Refinement</td><td>1.0</td></tr><tr><td>numbers of virtual particles</td><td>4</td></tr><tr><td>T,the clip value for coordinate loss</td><td>8 ~ 9 times of the number of real atoms</td></tr><tr><td>δ,the threshold for coordinate regularization</td><td>2</td></tr><tr><td>Finetune</td><td>1</td></tr><tr><td>Batch size</td><td></td></tr><tr><td>Max training steps</td><td>64</td></tr><tr><td>R1,max round of iterative movement of Equilibrium</td><td>100K</td></tr><tr><td></td><td>4</td></tr><tr><td>R2,max round of iterative movement of Refinement</td><td>4</td></tr><tr><td>numbers of virtual particles Inference</td><td>16 ~18 times of the number of real atoms</td></tr><tr><td colspan="2">R1,max round of iterativemovement of Equilibrium 4</td></tr><tr><td>R2,max round of iterative movement of Refinement</td><td>16</td></tr><tr><td>n,numbers of VPs</td><td>512</td></tr><tr><td></td><td></td></tr></table>
500
+
501
+ # B.3 MORE RESULTS
502
+
503
+ In Table 5, we report more percentile results for Vina, Vina\*. In Table 6, we report more percentile MM-PBSA results and MM-PBSA S.R. scores. The MM-PBSA S.R. scores in many baselines are very low. Thus, there are not enough effective MM-PBSA results to calculate percentile results in some baselines. Therefore, in each pocket, we replace the failed MM-PBSA result with the worst one generated by that baseline. And we calculated the percentile results after the replacement.
504
+
505
+ Table 5: More results on Vina and Vina\*.
506
+
507
+ <table><tr><td>Model</td><td colspan="2">5-th</td><td colspan="2">10-th</td><td colspan="2">25-th</td><td colspan="2">50-th</td></tr><tr><td></td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td></tr><tr><td>LiGAN[17]</td><td>-6.724</td><td>-5.372</td><td>-6.324</td><td>-4.922</td><td>-5.740</td><td>-4.215</td><td>-5.065</td><td>-3.49</td></tr><tr><td>3DSBDD[18]</td><td>-8.662</td><td>-7.227</td><td>-8.296</td><td>-6.664</td><td>-7.557</td><td>-5.633</td><td>-6.474</td><td>-4.078</td></tr><tr><td>GraphBP[19]</td><td>-8.710</td><td>-3.689</td><td>-7.832</td><td>-2.774</td><td>-6.765</td><td>-1.169</td><td>-5.625</td><td>-1.2</td></tr><tr><td>Pocket2Mol[20]</td><td>-8.332</td><td>-6.525</td><td>-8.015</td><td>-5.399</td><td>-7.467</td><td>-3.513</td><td>-6.837</td><td>-1.808</td></tr><tr><td>VD-Gen</td><td>-9.047</td><td>-7.444</td><td>-8.652</td><td>-6.848</td><td>-7.958</td><td>-5.825</td><td>-7.146</td><td>-4.621</td></tr></table>
508
+
509
+ Table 6: More MM-PBSA results.
510
+ B.4 COMPARED WITH IMAGE GENERATION AND SOME EARLY ATTEMPTS
511
+
512
+ <table><tr><td>Model</td><td>5-th MM-PBSA(↓)</td><td>10-th MM-PBSA(↓)</td><td>25-th MM-PBSA(↓)</td><td>50-th MM-PBSA (↓)</td><td>MM-PBSA- S.R.(%↑)</td></tr><tr><td>LiGAN[17]</td><td>-17.865</td><td>-13.374</td><td>-8.775</td><td>-7.418</td><td>11.9</td></tr><tr><td>3DSBDD[18]</td><td>-30.221</td><td>-23.623</td><td>-13.544</td><td>-7.739</td><td>12.9</td></tr><tr><td>GraphBP[19]</td><td>-5.130</td><td>-4.894</td><td>-4.894</td><td>-4.894</td><td>0.2</td></tr><tr><td>Pocket2Mol[20]</td><td>-7.823</td><td>-5.945</td><td>-5.398</td><td>-5.398</td><td>1.8</td></tr><tr><td>VD-Gen</td><td>-51.258</td><td>-47.247</td><td>-39.984</td><td>-21.140</td><td>42.7</td></tr></table>
513
+
514
+ ![](images/0074e2edc13693600e234b33895b847a636ee9d66c2c43fcf2dc4bcffb40d215.jpg)
515
+ Figure 6: Comparison for different training frameworks. "1:1 VD" is our early attempt, which is directly based on Virtual Dynamics, with 1:1 particle-atom assignment, and without the 4 stages in VD-Gen. The result indicates the effectiveness of the proposed VD-Gen framework.
516
+
517
+ During inference, VD iteratively moves particles to more precious positions from random initialized positions. A similar idea of "coarse-to-fine" generation is widely used in image generative models, and images could be iteratively refined from noises.
518
+
519
+ From this view, VD looks similar to the "coarse-to-fine" image generation. However, the training of VD is more challenging and very different from "coarse-to-fine" image generation.
520
+
521
+ • In image generation, the training target for each pixel is straightforward to assign, since input pixels’ positions are the same as the ground-truth pixels’ position, i.e. there is a 1-to-1 mapping between input and ground-truth. For example, in an image with $3 2 \mathrm { x } 3 2 $ pixels, for an input pixel located at position $i , j$ , we can directly use the ground-truth pixel located at position $i , j$ as its training target. With the 1-to-1 assignment, the training of image generation is straightforward. • However, in the 3D molecular generation, the 1-to-1 assignment cannot simply be used, as the randomly initialized 3D positions of input particles are far different from the ground-truth atoms’ positions, so it is hard to have 1-to-1 mapping. Besides, the number of ground-truth atoms is unknown, which further increases the difficulty of 3D molecular generation.
522
+
523
+ Table 7: Inference Efficiency.
524
+
525
+ <table><tr><td>Model</td><td>3DSBDD</td><td>GraphBP</td><td>Pocket2Mol</td><td>VD-Gen</td></tr><tr><td>Time(s)(↓)</td><td>14.153</td><td>1.660</td><td>3.476</td><td>3.678</td></tr></table>
526
+
527
+ • In our early attempts, we also tried some 1-to-1 assignment methods (assuming the ground truth of the number of atoms is given). We first tried the random assignment, and found model training is hard to converge. We then optimized it by considering the total moving distance of all input particles in the target assignment. We call this method "1:1 VD", details are in the following paragraph. In particular, we assign each particle a unique target atom, by sub-optimal assignment (optimal assignment is NP-hard) to minimize the total moving distance. It is much better than random assignment, but the performance is still not good, and we think the reason is due to the large difficulty of the training task.
528
+
529
+ • To further reduce the difficulty of the training task, we propose to use the many-to-1 assignment. That is, we first use many random-scattered particles to the pocket cavity, then for each particle, assign its nearest ground-truth atom as the training target. With this solution, the learning of movement is much easier, since particles only consider their nearest atoms. Besides, the unknown atom number is not a problem.
530
+
531
+ • Besides, VD-Gen is not just VD. Simply using VD, we can only get a 3D density-like shape (formed by the positions of particles) of a 3D molecule. We may use some rule-based solutions, like clustering by distances, to extract 3D molecules from the shape. However, rule-based solutions are not end-to-end and could fail in various scenarios. To address this, we further propose VD-Gen, a more reliable framework with additional Extraction, Refinement and Confidence stages.
532
+
533
+ 1:1 VD In our early attempt, we tried a simple solution: use the same number of VPs as real atoms, and randomly scatter them; then, make an assignment so that each atom has a paired VP, and each VP has a paired atom. The optimal assignment with minimal moving distance is NP-hard, and we use a greedy algorithm to find a sub-optimal assignment. With the 1-to-1 assignment, the Extraction stage is not needed, since the number of VPs is the same as real atoms. We called this method "1:1 VD". For a fair comparison, pretraining is also used in "1:1 VD". We conduct the experiment to compare VD-Gen with "1:1 VD", the results are shown in Fig. 6. From the result, we find that VD-Gen largely outperforms "1:1 VD". Although its simplicity, the learning of "1:1 VD" is challenging, due to the ambiguous target assignment which violates the least action principle. As for VD-Gen, although it looks complicated with multiple stages, these stages are necessary for generating accurate 3D molecules end-to-end.
534
+
535
+ # B.5 INFERENCE EFFICIENCY
536
+
537
+ Experiment results have demonstrated the effectiveness of the proposed ${ \tt V D - G e n }$ , and we also check its efficiency here. In particular, we benchmark the inference speed of generating one molecule for 3DSDBB, GraphBP, Pocket2Mol, and our VD-Gen. The results are summarized the Table 7. 3DSBDD is the slowest one, due to the inefficient MCMC sampling. Although GraphBP is the fastest one, its generated molecules are the worst. VD-Gen and Pocket2Mol are similar in efficiency. But VD-Gen significantly outperforms Pocket2Mol in effectiveness. Due to the large number of VPs and several movement rounds, it is expected that VD-Gen is not the fastest one. We leave the efficiency improvement to future work.
538
+
539
+ # B.6 ILLUSTRATION OF VPS’ MOVEMENT
540
+
541
+ We show an example of VPs’ spatial position during the inference of VD-Gen in Fig 7. In the initial stage, the coordinates of VPs are randomly initialized. In Equilibrium stage, with the increase of movement rounds $\mathrm { { . 1 \sim 4 } }$ , VPs gradually gather together. Then in Extraction stage, after clustering, fewer VPs are extracted from gathered VPs. Then in Refinement stage, the extracted VPs continue the iterative movement, toward positions with better pLDDT scores.
542
+
543
+ ![](images/e09eb3effaa0e475c97cc6e50584b7c60765f9f6ee757131b654e7f0a9d4df36.jpg)
544
+ Figure 7: An example to show how the VPs moves at each iteration in Equilibrium and Refinement, r indicates the moving iterations and pLDDT can reflect the change of coordinates.
545
+
546
+ Table 8: Training on CrossDocked Dataset.
547
+
548
+ <table><tr><td>Model</td><td>LiGAN</td><td>3DSBDD</td><td>GraphBP</td><td>Pocket2Mol</td><td>VD-Gen</td></tr><tr><td>3D Similarity(↑)</td><td>0.356</td><td>0.365</td><td>0.333</td><td>0.352</td><td>0.39</td></tr></table>
549
+
550
+ # B.7 TRAINING ON THE CROSSDOCKED DATASET
551
+
552
+ Since the baselines use the cross-docked dataset as training data, to analyze our model effect without pretrain, we conduct experiments on the cross-docked dataset. Results are shown in Table 8. We can see VD-Gen achieves 3D similarity with 0.39, outperforming other baselines. Besides, compared to VD-Gen with particle encoder pertaining in Table 2, the performance of using the cross-docked dataset is worse (0.39 v.s. 0.402). This result also indicates that pretraining is better than data augmentation in the cross-docked dataset.
553
+
554
+ # B.8 MOLECULAR OPTIMIZATION TASK
555
+
556
+ ![](images/cc8ff4ccb2572d3a736eb17935ca6c77e72c5b393ffa46be67bbe2d62f964b09.jpg)
557
+ Figure 8: Extending VD-Gen to molecular optimization.
558
+
559
+ Difference in training molecular optimization models To train the molecular optimization model, we make the following changes.
560
+
561
+ • The remove ratio in pretraining is much smaller, only $2 5 \%$ to $40 \%$ are removed.
562
+ • Rather than removing the whole molecule, during finetuning, only $2 5 \%$ to $40 \%$ of atoms are removed, like the pretraining.
563
+ • During training, the number of VPs is also much smaller, only 8 times of the real atoms.
564
+ • The VPs are not scattered in the whole pocket cavity, but scattered around the removed atoms.
565
+
566
+ Experiment We compare our model with a traditional molecular fragments optimization model DeepFrag [65]. DeepFrag can replace molecular fragments based on SMILES, which is a 1D model without pocket information. The results are shown in Table 9 and Table 10. From them, it is clear that VD-Gen can outperform the baseline in molecular optimization.
567
+
568
+ Table 9: Full percentile results on Vina and Vina\*, in molecular optimization tasks.
569
+
570
+ <table><tr><td>Model</td><td colspan="2">5-th</td><td colspan="2">10-th</td><td colspan="2">25-th</td><td colspan="2">50-th</td></tr><tr><td></td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td><td>Vina(↓)</td><td>Vina*(↓)</td></tr><tr><td>DeepFrag[65]</td><td>-8.357</td><td>1</td><td>-8.132</td><td>-</td><td>-7.775</td><td>-</td><td>-7.372</td><td>1</td></tr><tr><td>VD-Gen</td><td>-9.040</td><td>-8.30</td><td>-8.775</td><td>-8.020</td><td>-8.333</td><td>-7.507</td><td>-7.880</td><td>-6.946</td></tr></table>
571
+
572
+ Table 10: Full percentile results on MM-PBSA, in molecular optimization tasks.
573
+
574
+ <table><tr><td>Model</td><td>5-th MM-PBSA(↓)</td><td>10-th MM-PBSA(↓)</td><td>25-th MM-PBSA(↓)</td><td>50-th MM-PBSA (↓)</td><td>MM-PBSA B.T.(↑)</td></tr><tr><td>DeepFrag[65]</td><td>-51.783</td><td>-48.959</td><td>-39.786</td><td>-34.485</td><td>23.9</td></tr><tr><td>VD-Gen</td><td>-53.799</td><td>-52.120</td><td>-46.707</td><td>-41.788</td><td>38.3</td></tr></table>
md/dev/taQ64d2KBX/taQ64d2KBX.md ADDED
@@ -0,0 +1,530 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Learning Dynamical Systems from Noisy Data with Inverse-Explicit Integrators
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 We introduce the mean inverse integrator (MII), a novel approach to increase the
11
+ 2 accuracy when training neural networks to approximate vector fields of dynamical
12
+ 3 systems from noisy data. This method can be used to average multiple trajectories
13
+ 4 obtained by numerical integrators such as Runge–Kutta methods. We show that the
14
+ 5 class of mono-implicit Runge–Kutta methods (MIRK) has particular advantages
15
+ 6 when used in connection with MII. When training vector field approximations,
16
+ 7 explicit expressions for the loss functions are obtained when inserting the training
17
+ 8 data in the MIRK formulae, unlocking symmetric and high order integrators that
18
+ 9 would otherwise be implicit for initial value problems. The combined approach
19
+ 10 of applying MIRK within MII yields a significantly lower error compared to the
20
+ 11 plain use of the numerical integrator without averaging the trajectories. This is
21
+ 12 demonstrated with experiments using data from several (chaotic) Hamiltonian
22
+ 13 systems. Additionally, we perform a sensitivity analysis of the loss functions under
23
+ 14 normally distributed perturbations, supporting the favourable performance of MII.
24
+
25
+ # 15 1 Introduction
26
+
27
+ 16 Recently, many deep learning methodologies have been introduced to increase the efficiency and
28
+ 17 quality of scientific computations [1, 2, 3, 4]. In physics-informed machine learning, deep neural
29
+ 18 networks are purposely built so to enforce physical laws. As an example, Hamiltonian neural networks
30
+ 19 (HNNs) [5] aim at learning the Hamiltonian function from temporal observations. The Hamiltonian
31
+ 20 formalism was derived within classical mechanics for modelling a wide variety of physical systems.
32
+ 21 The temporal evolution of such systems is fully determined when the Hamiltonian function is known,
33
+ 22 and it is characterized by geometric properties such as the preservation of energy, the symplectic
34
+ 23 structure and the time-reversal symmetry of the flow [6, 7].
35
+ 24 Numerical integrators that compute solutions preserving such properties are studied in the field of
36
+ 25 geometric numerical integration $\boxed { 7 } \boxed { 8 } \boxed { }$ . Thus, deep learning, classical mechanics and geometric
37
+ 26 numerical integration are all relevant to the development of HNNs. In this work, we try to identify
38
+ 27 the optimal strategy for using numerical integrators when constructing loss functions for HNNs that
39
+ 28 are trained on noisy and sparse data.
40
+ 29 Generally, we aim at learning autonomous systems of first-order ordinary differential equations
41
+ 30 (ODE)
42
+
43
+ $$
44
+ { \frac { d } { d t } } y = f ( y ( t ) ) , \quad y : [ 0 , T ] \to \mathbb { R } ^ { n } .
45
+ $$
46
+
47
+ 31 In the traditional setting, solving an initial value problem (IVP) means computing approximated
48
+ 32 solutions $y _ { n } \approx y ( t _ { n } )$ when the vector field $f ( y )$ and an initial value $y ( t _ { 0 } ) \stackrel { = } { = } y _ { 0 }$ are known. The
49
+ 33 focus of our study is the corresponding inverse problem; assuming knowledge of multiple noisy
50
+ 34 samples of the solution, $S _ { N } = \{ \tilde { y } _ { n } \} _ { n = 0 } ^ { N }$ , the aim is to approximate the vector field $f$ with a neural
51
+
52
+ 35 network model $f _ { \theta }$ . We will assume that the observations originate from a (canonical) Hamiltonian system, with a Hamiltonian 36 $H : \mathbb { R } ^ { 2 d } \mathbb { R }$ , where the vector field is given by
53
+
54
+ $$
55
+ f ( y ) = J \nabla H ( y ( t ) ) , \quad J : = \left[ \begin{array} { l l } { 0 } & { I } \\ { - I } & { 0 } \end{array} \right] \in \mathbb { R } ^ { 2 d \times 2 d } .
56
+ $$
57
+
58
+ 37 This allows for learning the Hamiltonian function directly by setting $f _ { \theta } ( y ) = J \nabla H _ { \theta } ( y )$ , as proposed
59
+ 38 initially in $ { \mathbb { I } } ^ { { \left[ 5 \right] } }$ .
60
+ 39 Recently, many works highlight the benefit of using symplectic integrators when learning Hamiltonian
61
+ 40 neural networks [9, 10, 11, 12]. Here, we study what happens if, instead of using symplectic methods,
62
+ 41 efficient and higher-order MIRK methods are applied for inverse problems. We develop different
63
+ 42 approaches and apply them to learn highly oscillatory and chaotic dynamical systems from noisy data.
64
+ 43 The methods are general, they are not limited to separable Hamiltonian systems, and could indeed be
65
+ 44 used to learn any first-order ODE. However we focus our study on Hamiltonian systems, in order to
66
+ 45 build on the latest research on HNNs. Specifically, we compare our methods to the use of symplectic
67
+ 46 integrators to train Hamiltonian neural networks. Our contributions can be summarized as follows:
68
+
69
+ • We introduce the mean inverse integrator (MII), which efficiently averages trajectories of MIRK methods in order to increase accuracy when learning vector fields from noisy data (Definition 5.1).
70
+ • We present an analysis of the sensitivity of the loss function to perturbations giving insight into when the MII method yields improvement over a standard one-step scheme (Theorem 5.2).
71
+ • We show that symplectic MIRK methods have at most order $p = 2$ (Theorem $\textcircled { 4 . 4 }$ . Particularly, the second-order implicit midpoint method is the symplectic MIRK method with minimal number of stages.
72
+
73
+ 56 Finally, numerical experiments on several Hamiltonian systems benchmark MII against one-step
74
+ 57 training and symplectic recurrent neural networks (SRNN) $\mathbb { \ m }$ , which rely on the Störmer–Verlet
75
+ 58 integrator. The structural difference between these three approached is presented in Figure $\mathscr { L }$ Ad
76
+ 59 ditionally, we demonstrate that substituting Störmer–Verlet with the classic Runge–Kutta method
77
+ 60 (RK4) in the SRNN framework yields significant reduction in error and allows accurate learning of
78
+ 61 non-separable Hamiltonian systems.
79
+
80
+ # 62 2 Related work
81
+
82
+ 63 Hamiltonian neural networks was introduced in [5]. The numerical integration of Hamiltonian ODEs
83
+ 64 and the preservation of the symplectic structure of the ODE flow under numerical discretization
84
+ 65 have been widely studied over several decades [8, 7]. The symplecticity property is key and could
85
+ 66 inform the neural network architecture $\mathbb { \lVert \lambda \rVert }$ or guide the choice of numerical integrator, yielding a
86
+ 67 theoretical guarantee that the learning target is actually a (modified) Hamiltonian vector field [14, 9],
87
+ 68 building on the backward error analysis framework $\pmb { \mathbb { B } } ] \mathbf { l }$ . Discrete gradients is an approach to numerical
88
+ 69 integration that guarantees exact preservation of the (learned) Hamiltonian, and an algorithm for
89
+ 70 training Hamiltonian neural networks using discrete gradient integrators is developed in $\mathbb { \lVert 1 5 \rVert }$ and
90
+ 71 extended to higher order in $\mathbb { \left[ \left[ 1 6 \right] \right] }$ .
91
+ 72 Since we for the inverse problem want to approximate the time-derivative of the solution, $f$ , using
92
+ 73 only ${ \tilde { y } } _ { n }$ , we need to use a numerical integrator when specifying the neural network loss function.
93
+ 74 For learning dynamical systems from data, explicit methods such as RK4 are much used $\boxed { 5 } \boxed { 1 7 } \boxed { 1 8 }$ .
94
+ 75 However, explicit methods cannot in general preserve time-symmetry or symplecticity, and they often
95
+ 76 have worse stability properties compared to implicit methods [19]. Assuming that the underlying
96
+ 77 Hamiltonian is separable allows for explicit integration with the symplectic Störmer–Verlet method,
97
+ 78 which is exploited in $\mathbb { n o , 2 o }$ . Symplecticity could be achieved without the limiting assumption
98
+ 79 of separability by training using the implicit midpoint method $[ \mathbb { 1 2 } ]$ . As pointed out in $\mathbb { \lVert 1 2 \rVert }$ , this
99
+ 80 integrator could be turned into an explicit method in training by inserting sequential training data ${ \tilde { y } } _ { n }$
100
+ 81 and $\tilde { y } _ { n + 1 }$ . In fact, the MIRK class $\pm 2 1 1 2 2 1 1$ contains all Runge–Kutta (RK) methods (including the
101
+ 82 midpoint method) that could be turned into explicit schemes when inserting the training data. This
102
+ 83 is exploited in $\dot { \left[ \left| 2 3 \right| \right] }$ , where high-order MIRK methods are used to train HNNs, achieving accurate
103
+ 84 interpolation and extrapolation of a single trajectory with large step size, few samples and assuming
104
+ 85 zero noise.
105
+ 86 The assumption of noise-free data limits the potential of learning from physical measurements
106
+ 87 or applications on data sets from industry. This issue is addressed in $\mathbb { m }$ , presenting symplectic
107
+ 88 recurrent neural networks (SRNN). Here, Störmer–Verlet is used to integrate multiple steps and is
108
+ 89 combined with initial state optimization (ISO) before computing the loss. ISO is applied after training
109
+ 90 $f _ { \theta }$ a given number of epochs and aims at finding the optimal initial value $\hat { y } _ { 0 }$ , such that the distance
110
+ 91 to the subsequent observed points $\tilde { y } _ { 1 } , \dots , \tilde { y } _ { N }$ is minimized when integrating over $f _ { \theta }$ . While $\mathbb { \ m }$ i s
111
+ 92 limited by only considering separable systems, $\mathbb { \left[ \left[ 2 4 \right] \right] }$ aims at identifying the optimal combination of
112
+ 93 third order polynomial basis functions to approximate a cubic non-separable Hamiltonian from noisy
113
+ 94 data, using a Bayesian framework.
114
+
115
+ # 95 3 Background on numerical integration
116
+
117
+ 96 Some necessary and fundamental concepts on numerical integration and the geometry of Hamiltonian
118
+ 97 systems are presented below to inform the discussion on which integrators to use in inverse problems.
119
+ 98 Further details could be found in Appendix C.
120
+ 99 Fundamental concepts: An important subclass of the general first-order ODEs $( 1 )$ is the class of
121
+ 100 Hamiltonian systems, as given by $( 2 )$ . Often, the solution is partitioned into the coordinates $y ( t ) =$
122
+ 101 $[ q ( t ) , p ( t ) ] ^ { T }$ , with $q ( t ) , p ( t ) \in { \mathbb { R } } ^ { d }$ . A separable Hamiltonian system is one where the Hamiltonian
123
+ 102 could be written as the sum of two scalar functions, often representing the kinetic and potential
124
+ 103 energy, that depend only on $q$ and $p$ respectively, this means we have $H ( q , p ) = H _ { 1 } ( q ) + H _ { 2 } ( p )$ .
125
+
126
+ The 104 $h$ flow of an ODE is a map $\varphi _ { h , f } : \mathbb { R } ^ { n } \mathbb { R } ^ { n }$ sending an initial value $y ( t _ { 0 } )$ to the solution 105 of the ODE at time $t _ { 0 } + h$ , given by $\varphi _ { h , f } ( y ( t _ { 0 } ) ) : = y ( t _ { 0 } + h )$ . A numerical integration method 106 $\Phi _ { h , f } : \mathbb { R } ^ { n } \mathbb { R } ^ { n }$ is a map approximating the exact flow of the ODE, so that
127
+
128
+ $$
129
+ y ( t _ { 1 } ) \approx y _ { 1 } = \Phi _ { h , f } ( y _ { 0 } ) .
130
+ $$
131
+
132
+ 107 Here, $y ( t _ { n } )$ represents the exact solution and we denote with $y _ { n }$ the approximation at time $t _ { n } =$
133
+ 108 $t _ { 0 } + n h$ . It should be noted that the flow map satisfies the following group property:
134
+
135
+ $$
136
+ \begin{array} { r } { \varphi _ { h _ { 1 } , f } \circ \varphi _ { h _ { 2 } , f } \bigl ( y ( t _ { 0 } ) \bigr ) = \varphi _ { h _ { 1 } , f } \bigl ( y ( t _ { 0 } + h _ { 2 } ) \bigr ) = \varphi _ { h _ { 1 } + h _ { 2 } , f } \bigl ( y ( t _ { 0 } ) \bigr ) . } \end{array}
137
+ $$
138
+
139
+ 109 In other words, a composition of two flows with step sizes $h _ { 1 } , h _ { 2 }$ is equivalent to the flow map over $f$
140
+ 110 with step size $h _ { 1 } + h _ { 2 }$ . This property is not shared by numerical integrators for general vector fields.
141
+ 111 The order of a numerical integrator $\Phi _ { h , f }$ characterizes how the error after one step depends on the
142
+ 112 step size $h$ and is given by the integer $p$ such that the following holds:
143
+
144
+ $$
145
+ \left\| y _ { 1 } - y ( t _ { 0 } + h ) \right\| = \| \Phi _ { h , f } ( y _ { 0 } ) - \varphi _ { h , f } ( y ( t _ { 0 } ) ) \| = \mathcal { O } ( h ^ { p + 1 } ) .
146
+ $$
147
+
148
+ 113 Mono-implicit Runge–Kutta methods: Given vectors $b , v \in \mathbb { R } ^ { s }$ and a strictly lower triangular
149
+ 114 matrix $D \in \mathbb { R } ^ { s \times s }$ , a MIRK method is a Runge–Kutta method where $A = D + v \dot { b } ^ { T } \mathbb { \lVert } 2 5 \mathbb { , } \mathbb { \lVert } 2 6 \rVert$ and we
150
+ 115 assume that $[ A ] _ { i j } = a _ { i j }$ is the stage-coefficient matrix. This implies that the MIRK method can be
151
+ 116 written on the form
152
+
153
+ $$
154
+ \begin{array} { c } { { y _ { n + 1 } = y _ { n } + h \displaystyle \sum _ { i = 1 } ^ { s } b _ { i } k _ { i } , } } \\ { { { } } } \\ { { k _ { i } = f \big ( y _ { n } + v _ { i } ( y _ { n + 1 } - y _ { n } ) + h \displaystyle \sum _ { j = 1 } ^ { s } d _ { i j } k _ { j } \big ) . } } \end{array}
155
+ $$
156
+
157
+ 117 Specific MIRK methods and further details on Runge–Kutta schemes is discussed in Appendix C.2.
158
+
159
+ 118 Symplectic methods: The flow map of a Hamiltonian system is symplectic, meaning that its Jacobian
160
+ 119 $\begin{array} { r } { \dot { \Upsilon _ { \varphi } } : = \frac { \partial } { \partial y } \varphi _ { h , f } ( y ) } \end{array}$ satisfies $\Upsilon _ { \varphi } ^ { T } J \Upsilon _ { \varphi } = J$ , where $J$ is the same matrix as in $\textcircled { 2 }$ . As explained in $\mathbb { B } ,$ Ch.
161
+ 120 VI.2], this is equivalent to the preservation of a projected area in the phase space of $[ q , p ] ^ { T }$ . Similarly,
162
+ 121 a numerical integrator is symplectic if its Jacobian ⌥ := @@yn $\begin{array} { r } { \Upsilon _ { \Phi } : = \frac { \partial } { \partial y _ { n } } \Phi _ { h , f } ( y _ { n } ) } \end{array}$ satisfies $\Upsilon _ { \Phi } ^ { T } J \Upsilon _ { \Phi } = J$ . It is
163
+ 122 possible to prove $\mathbb { B } ,$ Ch. VI.4] that a Runge–Kutta method is symplectic if and only if the coeffients
164
+ 123 satisfy
165
+
166
+ $$
167
+ b _ { i } a _ { i j } + b _ { j } a _ { j i } - b _ { i } b _ { j } = 0 , \quad i , j = 1 , \ldots , s .
168
+ $$
169
+
170
+ 125 We will now consider different ways to use numerical integrators when training Hamiltonian neural
171
+ 126 networks and present important properties of MIRK methods, a key component of the MII that is
172
+ 127 presented in Chapter 5.
173
+ 128 Inverse ODE problems in Hamiltonian form: We assume to have potentially noisy samples
174
+ 129 $S _ { N } = \{ \tilde { y } \} _ { n = 0 } ^ { N }$ of the solution of an ODE with vector field $f$ . The inverse problem can be formulated
175
+ 130 as the following optimization problem:
176
+
177
+ $$
178
+ \underset { \theta } { \arg \operatorname* { m i n } } \sum _ { n = 0 } ^ { N - 1 } \bigg \| \tilde { y } _ { n + 1 } - \Phi _ { h , f _ { \theta } } ( \tilde { y } _ { n } ) \bigg \| ,
179
+ $$
180
+
181
+ 131 where $\begin{array} { r l r } { f _ { \theta } } & { { } = } & { J \nabla H _ { \theta } } \end{array}$ is a neural network approximation with parameters $\theta$ of a Hamiltonian vector field 132 $f$ , and $\Phi _ { h , f _ { \theta } }$ is a one-step integration method with step length $h$
182
+
183
+ 133 In the setting of inverse ODE problems, the availabil
184
+ 134 ity of sequential points $S _ { N }$ could be exploited when
185
+ 135 a numerical method is used to form interpolation
186
+ 136 conditions, for $f _ { \theta } \approx f$ for each $n$ in the optimiza
187
+ 137 tion problem $\textcircled{6}$ . For example, ${ \tilde { y } } _ { n }$ and $\tilde { y } _ { n + 1 }$ could
188
+ 138 be inserted in the implicit midpoint method, turning
189
+ 139 a method that is implicit for IVPs into an explicit
190
+ 140 method for inverse problems:
191
+
192
+ $$
193
+ \Phi _ { h , f _ { \theta } } ( \tilde { y } _ { n } , \tilde { y } _ { n + 1 } ) = \tilde { y } _ { n } + h f _ { \theta } \big ( \frac { \tilde { y } _ { n } + \tilde { y } _ { n + 1 } } { 2 } \big ) .
194
+ $$
195
+
196
+ 141 We denote this as the inverse injection, which defines
197
+ 142 an inverse explicit property for numerical integrators.
198
+
199
+ Definition 4.1 (Inverse injection). Assume that $\tilde { y } _ { n } , \tilde { y } _ { n + 1 } \in \ S _ { N }$ . Let the inverse injection for the integrator $\Phi _ { h , f } \mathopen { } \mathclose \bgroup \left( y _ { n } , y _ { n + 1 } \aftergroup \egroup \right)$ be given by the substitution $( { \tilde { y } } _ { n } , { \tilde { y } } _ { n + 1 } ) ( y _ { n } , y _ { n + 1 } )$ such that
200
+
201
+ ![](images/53b3998f7025750f90ab99eb8db53e68916235106e89ecae55860aa4e871d355.jpg)
202
+ Figure 1: Venn diagram of Runge–Kutta (RK) subclasses: explicit RK (ERK), symplectic RK (SympRK), mono-implicit RK (MIRK) and symmetric RK (SymRK).
203
+
204
+ $$
205
+ \hat { y } _ { n + 1 } = \Phi _ { h , f } ( \tilde { y } _ { n } , \tilde { y } _ { n + 1 } ) .
206
+ $$
207
+
208
+ 143 Definition 4.2 (Inverse explicit). A numerical one-step method $\Phi$ is called inverse explicit if it is
209
+ 144 explicit under the inverse injection.
210
+ 145 This procedure is utilized successfully by several authors when learning dynamical systems from
211
+ 146 data, see e.g. $\mathbb { \oplus 1 2 , \bigstar \bigstar }$ . However, this work is the first attempt at systematically exploring numerical
212
+ 147 integrators under the inverse injection, by identifying the MIRK methods as the class consisting of
213
+ 148 inverse explicit Runge–Kutta methods.
214
+
215
+ 149 Proposition 4.3. MIRK-methods are inverse explicit.
216
+
217
+ 150 Proof. Since the matrix $D$ in $( 4 )$ is strictly lower triangular, the stages are given by
218
+
219
+ $$
220
+ \begin{array} { l } { { k _ { 1 } = f \big ( y _ { n } + v _ { i } \big ( y _ { n + 1 } - y _ { n } \big ) \big ) } } \\ { { k _ { 2 } = f \big ( y _ { n } + v _ { i } \big ( y _ { n + 1 } - y _ { n } \big ) + h d _ { 2 1 } k _ { 1 } \big ) } } \\ { { \ } } \\ { { \quad \vdots } } \\ { { k _ { s } = f \big ( y _ { n } + v _ { i } \big ( y _ { n + 1 } - y _ { n } \big ) + h \displaystyle \sum _ { j = 1 } ^ { s - 1 } d _ { s j } k _ { j } \big ) } } \end{array}
221
+ $$
222
+
223
+ meaning that if 151 $y _ { n }$ and $y _ { n + 1 }$ are known, all stages, and thus the next step $\begin{array} { r } { \hat { y } _ { n + 1 } = y _ { n } + h \sum _ { i = 1 } ^ { s } b _ { i } k _ { i } } \end{array}$ , 152 could be computed explicitly. □
224
+
225
+ 153 Because of their explicit nature when applied to inverse ODE problems, MIRK methods are an
226
+ 154 attractive alternative to explicit Runge–Kutta methods; in contrast to explicit RK methods, they
227
+ 155 can be symplectic or symmetric, or both, without requiring the solution of systems of nonlinear
228
+ 156 equations, even when the Hamiltonian is non-separable. Figure $^ 1$ illustrates the relation between
229
+ 157 various subclasses and the specific methods are described in Table $\perp$ in Appendix $\boxed { \mathbf { C } }$ In addition,
230
+ 158 for $s$ -stage MIRK methods, it is possible to construct methods of order $p = s + 1 \ P \ 2 \|$ . This is
231
+ 159 in general higher order than what is possible to obtain with $s$ -stage explicit Runge–Kutta methods.
232
+ 160 Further computational gains could also be made by reusing evaluations of the vector field between
233
+ 161 multiple steps, which using MIRK methods allow for, as explained in Appendix $\mathrm { I } .$ The dependency
234
+ 162 structure on the data $S _ { N }$ of explicit RK (ERK) methods, MIRK methods and the SRNN method $\bar { \mathbb { m } }$
235
+ 163 is illustrated in Figure 2.
236
+ 164 Maximal order of symplectic MIRK methods: From the preceding discussion, it is clear that
237
+ 165 symplectic MIRK methods are of interest when learning Hamiltonian systems from data, since they
238
+ 166 combine computational efficiency with the ability to preserve useful, geometric properties. Indeed,
239
+ 167 symplectic integrators in the training of HNNs have been considered in [9, 10, 11, 12, 13]. The
240
+ 168 subclass of symplectic MIRK methods is represented by the middle, dark blue field in the Venn
241
+ 169 diagram of Figure $\bigstar$ The next result gives an order barrier for symplectic MIRK methods that was, to
242
+ 170 the best of our knowledge, not known up to this point.
243
+
244
+ ![](images/6b65896d5d6aac488f2bc3b6239d98bc4a51894deb19445ccb0f70ce2b8b11a0.jpg)
245
+ Figure 2: Differences of observation dependency, assuming $N = 2$ for explicit and mono-implicit one-step training, and explicit multi-step training with initial state optimization (green node $\hat { y } _ { 0 }$ ).
246
+
247
+ Theorem 4.4. The maximum order of a symplectic MIRK method is $p = 2$ .
248
+
249
+ 172 Proof. This is a shortened version of the full proof, which can be found in Appendix $\mathrm { F } .$ A MIRK
250
+ 173 method is a Runge–Kutta method with coefficients $a _ { i j } = d _ { i j } + v _ { i } b _ { j }$ . Requiring $d _ { i j } , { \overline { { b _ { i } } } }$ and $v _ { i }$ to
251
+ 174 satisfy the symplecticity conditions of $( 5 )$ in addition to $D$ being strictly lower triangular, yields the
252
+ 175 following restrictions
253
+
254
+ $$
255
+ \begin{array} { r } { b _ { i } d _ { i j } + b _ { i } b _ { j } ( v _ { j } + v _ { i } - 1 ) = 0 , \quad \mathrm { i f ~ } i \neq j , } \\ { b _ { i } = 0 \mathrm { o r } v _ { i } = \cfrac { 1 } { 2 } , \quad \mathrm { i f ~ } i = j , } \\ { d _ { i j } = 0 , \quad \mathrm { i f ~ } i > j . } \end{array}
256
+ $$
257
+
258
+ 176 These restrictions result in an RK method that could be reduced to choosing a coefficient vector
259
+ 177 $b \in \mathbb { R } ^ { s }$ and choosing stages on the form $\begin{array} { r } { k _ { i } = f \big ( y _ { n } + \frac { h } { 2 } \sum _ { j } ^ { s } b _ { j } k _ { j } \big ) } \end{array}$ for $i = 1 , \dots , s$ . It is then trivial
260
+ 178 to check that this method can only be of up to order $p = 2$ . Note that for $s = 1$ and $b _ { 1 } = 1$ we get the
261
+ 179 midpoint method. □
262
+ 180 Numerical integrators outside the RK class: While this paper is mainly concerned with MIRK
263
+ 181 methods, several other types of numerical integrators could be of interest for inverse problems.
264
+ 182 Partitioned Runge–Kutta methods are an extension and not a subclass of RK methods, and can
265
+ 183 be symplectic and symmetric, while also being explicit for separable Hamiltonian systems. The
266
+ 184 Störmer–Verlet integrator of order $p = 2$ is one example. Higher order methods of this type are
267
+ 185 derived in $\lVert \rVert$ and used for learning Hamiltonian systems in [29, 30]. Discrete gradient methods
268
+ 186 [31, $\textcircled { 3 2 } \textcircled { }$ are inverse explicit and well suited to train Hamiltonian neural networks using a modified
269
+ 187 automatic differentiation algorithm $\mathbb { \left. \boldsymbol { \cdot } \boldsymbol { \cdot } \right. }$ . This method could be extended to higher order methods as
270
+ 188 shown in $\mathbb { \lVert 1 6 \rVert }$ . In contrast to symplectic methods, discrete gradient methods preserve the Hamiltonian
271
+ 189 exactly up to machine precision. A third option is elementary differential Runge–Kutta methods $\pmb { \Vert 3 3 } \Vert$ ,
272
+ 190 where for instance $\bar { \big \| } \bar { 3 4 } \bar { \big \| }$ show how to use backward error analysis to construct higher order methods
273
+ 191 from modifications to the midpoint method. This topic is discussed further in Appendix $\mathbb { H } ,$ where we
274
+ 192 also present a novel, symmetric discrete gradient method of order $p = 4$ .
275
+
276
+ # 5 Mean inverse integrator for handling noisy data
277
+
278
+ 94 Noisy ODE sample: It is often the case that the samples $S _ { N }$ are not exact measurements of the
279
+ 95 system, but perturbed by noise. In this paper, we model the noise as independent, normally distributed
280
+
281
+ $$
282
+ \tilde { y } _ { n } = y ( t _ { n } ) + \delta _ { n } , \quad \delta _ { n } \sim \mathcal { N } ( 0 , \sigma ^ { 2 } I ) ,
283
+ $$
284
+
285
+ 197 where ${ \mathcal { N } } ( 0 , \sigma ^ { 2 } I )$ represents the multivariate normal distribution. With this assumption, a standard
286
+ 198 result from statistics tells us that the variance of a sample-mean estimator with $N$ samples converges
287
+ 199 to zero at the rate of $\textstyle { \frac { 1 } { N } }$ . That is, assuming that we have $N$ samples $\tilde { y } _ { n } ^ { ( 1 ) } , \dots , \tilde { y } _ { n } ^ { ( N ) }$ , then
288
+
289
+ $$
290
+ \mathrm { V a r } [ \overline { { y } } _ { n } ] = \mathrm { V a r } \bigg [ \frac { 1 } { N } \sum _ { j = 1 } ^ { N } \tilde { y } _ { n } ^ { ( j ) } \bigg ] = \frac { \sigma ^ { 2 } } { N } .
291
+ $$
292
+
293
+ 200 Using the inverse injection with the midpoint method, the vector field is evaluated in the average of
294
+ 201 ${ \tilde { y } } _ { n }$ and $\tilde { y } _ { n + 1 }$ , reducing the variance of the perturbation by a factor of two, compared to evaluating the
295
+ 202 vector field in ${ \tilde { y } } _ { n }$ , as is done in all explicit RK methods. Furthermore, considering the whole data
296
+ 203 trajectory $S _ { N }$ , multiple independent approximations to the same point $y ( t _ { n } )$ can enable an even more
297
+ 204 accurate estimate. This is demonstrated in the analysis presented in Theorem $\underline { { \boldsymbol { \mathsf { F } } . 2 } }$ and in Figure 4.
298
+ 205 Averaging multiple trajectories: In the inverse ODE problem, we assume that there exists an exact
299
+ 206 vector field $f$ whose flow interpolates the discrete trajectories $S _ { N }$ , and the flow of this vector field
300
+ 207 satisfies the group property $( 3 )$ . The numerical flow $\Phi _ { h , f }$ for a method of order $p$ satisfies this
301
+ 208 property only up to an error $\mathcal { O } ( h ^ { p + 1 } )$ over one step. In the presence of noisy data, compositions of
302
+ 209 one-step methods can be used to obtain multiple different approximations to the same point $y ( t _ { n } )$ ,
303
+ 210 by following the numerical flow from different nearby initial values ${ \tilde { y } } _ { j } , j \neq n$ , and thus reduce the
304
+ 211 noise by averaging over these multiple approximations. Accumulation of the local truncation error is
305
+ 212 expected when relying on points further away from $t _ { n }$ . However, for sufficiently small step sizes $h$
306
+ 213 compared to the size of the noise $\sigma$ , one can expect increased accuracy when averaging over multiple
307
+ 214 noisy samples.
308
+ 215 As an example, assume that we know the points $\{ \tilde { y } _ { 0 } , \tilde { y } _ { 1 } , \tilde { y } _ { 2 } , \tilde { y } _ { 3 } \}$ . Then $y ( t _ { 2 } )$ can be approximated by
309
+ 216 computing the mean of the numerical flows $\Phi _ { h , f }$ starting from different initial values:
310
+
311
+ $$
312
+ \begin{array} { r l r } { { \overline { { y } } _ { 2 } = \frac { 1 } { 3 } \big ( \Phi _ { h , f } ( \tilde { y } _ { 1 } ) + \Phi _ { h , f } \circ \Phi _ { h , f } ( \tilde { y } _ { 0 } ) + \Phi _ { - h , f } ^ { * } ( \tilde { y } _ { 3 } ) \big ) } } \\ & { } & { \approx \frac { 1 } { 3 } \big ( \tilde { y } _ { 0 } + \tilde { y } _ { 1 } + \tilde { y } _ { 3 } + h ( \Psi _ { 0 , 1 } + 2 \Psi _ { 1 , 2 } - \Psi _ { 2 , 3 } ) \big ) , } \end{array}
313
+ $$
314
+
315
+ where we by 217 $\Phi ^ { * }$ mean the adjoint method of $\Phi$ , as defined in $\pmb { \Vert 8 }$ Ch. V], and we let $\Psi _ { n , n + 1 }$ be the 218 increment of an inverse-explicit numerical integrator, so that
316
+
317
+ $$
318
+ \Phi _ { h , f } ( \tilde { y } _ { n } , \tilde { y } _ { n + 1 } ) = \tilde { y } _ { n } + h \Psi _ { n , n + 1 } .
319
+ $$
320
+
321
+ 219 For example, for the midpoint method, we have that $\begin{array} { r } { \Psi _ { n , n + 1 } = f ( \frac { \tilde { y } _ { n } + \tilde { y } _ { n + 1 } } { 2 } ) } \end{array}$ . When stepping in
322
+ 220 negative time in $( 1 0 )$ , we use the adjoint method in order to minimize the number of vector field
323
+ 221 evaluations, also when non-symmetric methods are used (which implies that we always use e.g. $\Psi _ { 1 , 2 }$
324
+ 222 and not $\Psi _ { 2 , 1 } )$ . Note that in order to derive the approximation in $\mathbf { \bar { \rho } } ( 1 0 )$ , repeated use of the inverse
325
+ 223 injection allows the known points ${ \tilde { y } } _ { n }$ to form an explicit integration procedure, where composition
326
+ 224 of integration steps are approximated by summation over increments $\Psi _ { n , n + 1 }$ . This approximation
327
+ 225 procedure is presented in greater detail in Appendix D.
328
+ 226 Mean inverse integrator: The mean approximation over the whole trajectory ${ \overline { { y } } } _ { n }$ , for $n = 0 , \ldots , N$ ,
329
+ 227 could be computed simultaneously, reusing multiple vector field evaluations in an efficient manner.
330
+ 228 This leads to what we call the mean inverse integrator. For example, when $N = 3$ we get
331
+
332
+ $$
333
+ \left[ \begin{array} { c } { \overline { { y } } _ { 0 } } \\ { \overline { { y } } _ { 1 } } \\ { \overline { { y } } _ { 2 } } \\ { \overline { { y } } _ { 3 } } \end{array} \right] = \frac { 1 } { 3 } \left[ \begin{array} { c c c c } { 0 } & { 1 } & { 1 } & { 1 } \\ { 1 } & { 0 } & { 1 } & { 1 } \\ { 1 } & { 1 } & { 0 } & { 1 } \\ { 1 } & { 1 } & { 1 } & { 0 } \end{array} \right] \left[ \begin{array} { c } { \widetilde { y } _ { 0 } } \\ { \widetilde { y } _ { 1 } } \\ { \widetilde { y } _ { 2 } } \\ { \widetilde { y } _ { 3 } } \end{array} \right] + \frac { h } { 3 } \left[ \begin{array} { c c c c } { - 3 } & { - 2 } & { - 1 } \\ { 1 } & { - 2 } & { - 1 } \\ { 1 } & { 2 } & { - 1 } \\ { 1 } & { 2 } & { 3 } \end{array} \right] \left[ \begin{array} { c } { \Psi _ { 0 , 1 } } \\ { \Psi _ { 1 , 2 } } \\ { \Psi _ { 2 , 3 } } \end{array} \right] ,
334
+ $$
335
+
336
+ 229 and the same structure is illustrated in Figure 3.
337
+
338
+ 230 Definition 5.1 (Mean inverse integrator). For a sample $S _ { N }$ and an inverse-explicit integrator $\Psi _ { n , n + 1 }$ ,
339
+ 231 the mean inverse integrator is given by
340
+
341
+ $$
342
+ \overline { { Y } } = \frac { 1 } { N } \bigg ( U \tilde { Y } + h W \Psi \bigg )
343
+ $$
344
+
345
+ $$
346
+ \tilde { Y } : = [ \tilde { y } _ { 0 } , \dotsc , \tilde { y } _ { N } ] ^ { T } \in \mathbb { R } ^ { ( N + 1 ) \times m } , \Psi : = [ \Psi _ { 0 , 1 } , \dotsc , \Psi _ { N - 1 , N } ] ^ { T } \in \mathbb { R } ^ { N \times m } .
347
+ $$
348
+
349
+ Finally, 233 $U \in \mathbb { R } ^ { ( N + 1 ) \times ( N + 1 ) }$ and $W \in \mathbb { R } ^ { ( N + 1 ) \times N }$ are given by
350
+
351
+ $$
352
+ [ U ] _ { i j } : = \left\{ \begin{array} { l l } { 0 } & { \mathrm { i f } \quad i = j } \\ { 1 } & { \mathrm { e l s e } } \end{array} \right. \qquad \mathrm { a n d } \qquad [ W ] _ { i j } : = \left\{ \begin{array} { l l } { j - 1 - N } & { \mathrm { i f } \quad j \geq i } \\ { j } & { \mathrm { e l s e } } \end{array} \right. .
353
+ $$
354
+
355
+ 234 By substituting the known vector field $f$ with a neural network $f _ { \theta }$ and denoting the matrix containing
356
+ 235 vector field evaluations by $\Psi _ { \theta }$ such that $\begin{array} { r } { \overline { { Y } } _ { \theta } : = \frac { 1 } { N } ( U \tilde { Y } + h W \Psi _ { \theta } ) } \end{array}$ , we can formulate an analogue to
357
+ 236 the inverse problem $( 6 )$ by
358
+
359
+ $$
360
+ \operatorname { a r g m i n } _ { \theta } { \big \| } { \tilde { Y } } - { \overline { { Y } } } _ { \theta } { \big \| } .
361
+ $$
362
+
363
+ 237 Analysis of sensitivity to noise: Consider the optimiza
364
+ 238 tion problems using integrators either as one-step methods
365
+ 239 or MII by $( 6 )$ resp. $( 1 \bar { 2 } )$ . We want to investigate how
366
+ 240 uncertainty in the data ${ \tilde { y } } _ { n }$ introduces uncertainty in the op
367
+ 241 timization problem. Assume, for the purpose of analysis,
368
+ 242 that the underlying vector field $f ( y )$ is known. Let
369
+
370
+ $$
371
+ \begin{array} { r l } & { \mathcal { T } _ { n } ^ { \mathrm { O S } } : = \tilde { y } _ { n } - \Phi _ { h , f } ( \tilde { y } _ { n - 1 } , \tilde { y } _ { n } ) , } \\ & { \mathcal { T } _ { n } ^ { \mathrm { M I I } } : = \tilde { y } _ { n } - [ \overline { { Y } } ] _ { n } } \end{array}
372
+ $$
373
+
374
+ 243 be the optimization target or the expression one aims to
375
+ 244 minimize using a one-step method (OS) and the MII,
376
+ 245 where $\overline { { Y } }$ is given by Definition $\boxed { 5 . 1 }$ For a matrix $A$
377
+ 246 with eigenvalues $\lambda _ { i } ( A )$ , the spectral radius is given by
378
+
379
+ ![](images/bafdc96c0a5fd49bd6ed26a445f781441756df29fe10177addd3e1366e622653.jpg)
380
+ Figure 3: Illustration of the structure of the mean inverse integrator for $N = 3$ .
381
+
382
+ $\rho ( A ) : = \operatorname* { m a x } _ { i } | \lambda _ { i } ( A ) |$ . An analytic expression that approximates $\rho ( \mathcal { T } _ { n } ^ { \mathrm { o s } } )$ and $\rho ( \mathcal { T } _ { n } ^ { \mathrm { M I I } } )$ by linearization of $f$ for a general MIRK method is provided below.
383
+
384
+ 249 Theorem 5.2. Let $S _ { N } = \{ \tilde { y } _ { n } \} _ { n = 0 } ^ { N }$ be a set of noisy samples, equidistant in time with step size $h$
385
+ 250 with Gaussian perturbations as defined by $\textcircled { 9 }$ with variance $\sigma ^ { 2 }$ . Assume that a MIRK integrator
386
+ 251 $\Phi _ { h , f }$ is used as a one-step method. Then the spectral radius is approximated by
387
+
388
+ $$
389
+ \begin{array} { r l } & { \rho _ { n } ^ { o s } : = \rho \bigg ( V a r \big [ \mathcal { T } _ { n } ^ { o s } \big ] \bigg ) \approx \sigma ^ { 2 } \bigg \| 2 I + h b ^ { T } \big ( \mathbb { 1 } - 2 v \big ) \big ( f ^ { \prime } + f ^ { \prime T } \big ) + h ^ { 2 } Q ^ { o s } \bigg \| _ { 2 } , } \\ & { \rho _ { n } ^ { M I I } : = \rho \bigg ( V a r \big [ \mathcal { T } _ { n } ^ { M I I } \big ] \bigg ) \approx \frac { \sigma ^ { 2 } } { N } \bigg \| ( 1 + N ) I + h P _ { n n } + \frac { h } { N } \displaystyle \sum _ { j = 0 } ^ { s } P _ { n j } + \frac { h ^ { 2 } } { N } Q ^ { M I I } \bigg \| _ { 2 } , } \end{array}
390
+ $$
391
+
392
+ where 252 $f ^ { \prime } : = f ^ { \prime } ( y _ { n } )$ and $P _ { n j } , Q ^ { o s }$ and $Q ^ { M I I }$ (defined in (24) in Appendix G) are matrices independent 253 of the step size $h$ .
393
+
394
+ 254 The proof is found in Appendix $\boxed { \mathbf { G } }$ Let $\alpha : = b ^ { T } ( \mathbb { 1 } ^ { } -$
395
+ 255 $2 v$ ) denote the coefficients of the first order term in $h$
396
+ 256 of Equation $\textcircled { 1 3 }$ . For any explicit RK method we have
397
+ 257 that $v = 0$ and since $b ^ { T } \bar { 1 } = \bar { 1 }$ (method of at least order
398
+ 258 one) we find that $\alpha _ { \mathrm { E R K } } = 1$ . Considering the Butcher
399
+ 259 tableau of MIRK4 in Figure $9$ we find that $\alpha _ { \mathrm { M I R K 4 } } = 0$
400
+ 260 Thus, as $h 0$ we would expect quadratic convergence
401
+ 261 !of MIRK4 and linear convergence of RK4 for $\rho _ { n } ^ { \mathrm { { O S } } }$ to $2 \sigma ^ { 2 }$
402
+ 262 Considering MII $( 1 4 )$ one would expect linear convergence
403
+ 263 for $\rho _ { n } ^ { \mathrm { M I I } }$ to $\bar { \sigma } ^ { 2 }$ if $N$ is large, as $h 0$ .
404
+ 64 A numerical approximation of $\rho _ { n } ^ { \mathrm { { O S } } }$ and $\rho _ { n } ^ { \mathrm { M I I } }$ could be real
405
+ 65 ized by a Monte-Carlo estimate. We compute the spectral
406
+ 66 67 ${ \mathcal { T } } _ { n } ^ { \mathrm { M I I } }$ s b $\hat { \rho } _ { n }$ of the eampling $5 { \cdot } \mathrm { \dot { 1 } 0 ^ { 3 } }$ cal covariance matrix of normally distributed pert $\mathcal { T } _ { n } ^ { \mathrm { { 0 s } } }$ andtions
407
+ 268 $\delta _ { n }$ with $\sigma ^ { 2 } = 2 { \bar { . } } 5 \cdot 1 0 ^ { - 3 }$ to each point $y _ { n }$ in a trajectory
408
+ 69 of $N + 1$ points and step size $h$ . We then compute the
409
+ 270 trajectory average $\begin{array} { r } { \overline { { \rho } } = \frac { 1 } { N + 1 } \sum _ { n = 0 } ^ { N } \hat { \rho } _ { n } } \end{array}$ , fix the end time $T = 2 . 4$ , repeat the approximations for
410
+ 271 decreasing step sizes $h$ and increasing $N$ and compute the average of $\overline { \rho }$ for 10 randomly sampled
411
+ 272 trajectories $S _ { N }$ from the double pendulum system. The plot in Figure $^ 4$ corresponds well with what
412
+ 273 one would expect from Theorem $5 . 2$ and confirms that first MIRK (with $v \neq 0$ ) and secondly MII
413
+ 274 reduces the sensitivity to noise in the optimization target.
414
+
415
+ ![](images/c446ae40f8016eb3e40c3253f78063a4ae4f1bfea3b67cf71a1a822212d49217.jpg)
416
+ Figure 4: Average of $\overline { { \rho } }$ over 10 trajectories. Shaded area represent one standard deviation.
417
+
418
+ # 6 Experiments
419
+
420
+ Methods and test problems: We train HNNs using different integrators and methods in the inverse problem $\textcircled{6}$ . We use MIRK4 together with the MII method and compare to the implicit midpoint method, RK4 and MIRK4 applied as one-step methods, as well as ISO followed by Störmer–Verlet and RK4 integrated over multiple time-steps. The latter strategy, illustrated in Figure $\bigtriangledown ,$ was suggested in [10], where Störmer–Verlet is used. Separable networks $H _ { \theta } ( q , p ) = H _ { 1 , \theta } ( q ) + H _ { 2 , \theta } ( p )$ are trained on data from the Fermi–Pasta–Ulam–Tsingou (FPUT) problem and the Hénon–Heiles system. For the double pendulum, which is non-separable, a fully connected Flow roll-out H´enon-Hnetwork is used for all methods except Störmer– Flow roll-out H´enon-Heiles h = 0.1, FVerlet, which requires separability in order to be explicit. The Hamiltonians are described in Appendix 0.2 0.0A and all systems have solutions $y ( t ) \not \in \mathbb { R } ^ { 4 }$ .
421
+
422
+ 0.2 0.0 0.0After using the specified integrators in training, a
423
+ 294 0.0 0.2proximated solutions are computed for each learned
424
+ 295 vector field $f _ { \theta }$ 0.2 0.4using the Scikit-learn implementation
425
+ 296 0.2 0.6of DOP853 [35], which is also used to generate
426
+ 297 0.0 2.5 5.0 7.5 training data. The error is averaged over $M = { \mathfrak { M } } =$
427
+ 298 0.0 2.5 5.0 7.5 10.0 12.5 15.0 17points and we find what we call the flow error by
428
+
429
+ ![](images/50db40a36323ab3154c21c034d8ecfcdadda8d4b60a4dca12b3f299b7b07b58e.jpg)
430
+
431
+ ![](images/1113aa898fe679cb4aabd72073b5de305540ae1b431015c375fb736aa4253a9e.jpg)
432
+ Flow roll-out Double pendulum $h = 0 . 1 .$ , $\sigma = 0 . 0 5$
433
+
434
+ ISO RK4 MII MIRK4 Given datagure 5: Roll-out in time obtained by inteMIRK4MII MIRK4 Exact flowrating over the learned vector fields when Exact flow.0 12.5 15.0 17.5 20.0training on data from the double pendulum .0 17.5 20.05.0 7.5 10.0 tHamiltonian.
435
+
436
+ $$
437
+ \begin{array} { l } { \displaystyle { e \big ( f _ { \theta } \big ) = \frac { 1 } { M } \sum _ { n = 1 } ^ { M } \| \hat { y } _ { n } - y ( t _ { n } ) \| _ { 2 } , \quad y ( t _ { n } ) \in S _ { M } ^ { \mathrm { t e s t } } , } } \\ { \displaystyle { \hat { y } _ { n + 1 } = \Phi _ { h , f _ { \theta } } \big ( y _ { n } \big ) } . } \end{array}
438
+ $$
439
+
440
+ 299 Trathat 300 g data is g. The data $N _ { 2 } = 3 0 0$ random initial values nd by integrating the $y _ { 0 }$ requiringtial values
441
+ $0 . 3 \leq \| y _ { 0 } \| _ { 2 } \leq 0 . 6 .$ $S _ { N _ { 1 } , N _ { 2 } } = \bar { \{ y _ { n } ^ { ( j ) } \} } _ { n = 0 , j = 0 } ^ { N _ { 1 } , N _ { 2 } }$
442
+ 301 with DOP853 with a tolerance of $1 0 ^ { - 1 5 }$ for the following step sizes and number of steps: $\left( h , N _ { 1 } \right) =$
443
+ 302 (0.4, 4), (0.2, 8), (0.1, 16). The points in the flow are perturbed by noise where $\sigma \in \{ 0 , 0 . 0 5 \}$ . Error
444
+ 303 is measured in $M = 1 0$ random points in the flow, within the same domain as the initial values.
445
+ 304 Furthermore, experiments are repeated with a new random seed for the generation of data and
446
+ 305 initialization of neural network parameters five times in order to compute the standard deviation of
447
+ 306 the flow error. The flow error is shown in Figure $6 .$ Additional results are presented in Appendix B.
448
+
449
+ Neural network architecture and optimization: For all test problems, the neural networks have 3 layers with a width of 200 neurons and tanh(·) as the activation function. The algorithms are implemented using PyTorch $\pmb { \mathbb { B } } 6 \|$ and the code for performing ISO is a modification of the implementation by $\mathbb { \underline { { \sf { I I O } } } } ! .$ Training is done using the quasi-Newton L-BFGS algorithm $\textcircled { 1 3 7 }$ for 20 epochs without batching. This optimization algorithm is often used to train physics-informed neural networks [1] and in this setting it proved to yield superior results in comparison to the often used Adam optimizer. Further details are provided in Appendix E.
450
+
451
+ Results: As observed in Figure $\boxed { 6 }$ and supported by the analytical result illustrated in Figure $\boxed { 4 }$ the MII approach facilitates more accurate training from from noisy data than one-step methods. However, training with multiple integration steps in combination with ISO yields lower error when RK4 is used for the Hénon–Heiles problem and similar performance as MII on the double pendulum. We notice that the SRNN approach, i.e. ISO with Störmer–Verlet, is improved when switching to RK4, which means sacrificing symplecticity to achieve higher order. The results for FPUT stand out in Figure $6 ,$ since both ISO methods have large errors here. The roll-out in time of the learned vector fields is presented in Figure $8$ in Appendix $\boxed { \mathbf { B } }$ where the same can be observed. As also could be seen here, the FPUT Hamiltonian gives rise to highly oscillatory trajectories, and the errors observed in Figure 6 might indicate that ISO is ill-suited for this kind of dynamical systems.
452
+
453
+ ![](images/7c1ebc9ccecfbb8a2bc71b2dbbb6eaa052bc270f84169a16e75d5ed798abd790.jpg)
454
+ Figure 6: The flow error when learning vector fields using one-step methods directly (Midpoint, RK4 and MIRK4), ISO and multiple time-steps (ISO Störmer and ISO RK4) and MII (MII MIRK4). The error bars display the standard deviation after rerunning 5 experiments on data with $\sigma = 0 . 0 5$ . The right subplot shows the computational time used in training against the flow error.
455
+
456
+ Two observations could be made regarding the one-step methods without averaging or ISO. First, it is likely that the midpoint method has weaker performance for large step sizes due to its lower order, compared to both RK4 and MIRK4, despite the fact that it is a symplectic method. The same is clear from Figure $\perp$ in Appendix $\bigstar _ { \mathbf { B } } \bigstar _ { \mathbf { \theta } }$ which display the flow error when training on data without noise. Secondly, building on the sensitivity analysis, we observe that MIRK4 consistently attains higher accuracy than RK4, as expected from the Monte-Carlo simulation found in Figure 4.
457
+
458
+ # 7 Conclusion
459
+
460
+ In this work we present the mean inverse integrator, which allows both chaotic and oscillatory dynamical systems to be learned with high accuracy from noisy data. Within this method, integrators of the MIRK class are a key component. To analyse how noise is propagated when training with MII and MIRK, compared to much used explicit methods such as RK4, we developed a sensitivity analysis that is verified both by a Monte-Carlo approximation and reflected in the error of the learned vector fields. Finally, we build on the SRNN $\mathbb { m }$ by replacing Störmer–Verlet with RK4, and observer increased performance. When also considering the weak performance of the implicit midpoint method, this tells us that order might be of greater importance than preserving the symplectic structure when training HNNs. Both the MIRK methods, the mean inverse integrator and initial state optimization form building blocks that could be combined to form novel approaches for solving inverse problems and learning from noisy data.
461
+
462
+ Limitations: The experiments presented here assume that both the generalized coordinates $q _ { n }$ and the generalized momenta $p _ { n }$ could be observed. In a setting where HNNs are to model real and not simulated data, the observations might lack generalized momenta $\left[ \left[ 3 8 \right] \right]$ or follow Cartesian coordinates, requiring the enforcement of constraints $\boxed { 1 7 } \boxed { 3 9 }$ . Combining approaches that are suitable for data that is both noisy and follow less trivial coordinate systems is a subject for future research.
463
+
464
+ References
465
+ [1] Maziar Raissi, Paris Perdikaris, and George E Karniadakis. Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational physics, 378:686–707, 2019.
466
+ [2] Christopher Rackauckas, Yingbo Ma, Julius Martensen, Collin Warner, Kirill Zubov, Rohit Supekar, Dominic Skinner, Ali Ramadhan, and Alan Edelman. Universal differential equations for scientific machine learning. Aug 2020.
467
+ [3] Ricky TQ Chen, Yulia Rubanova, Jesse Bettencourt, and David K Duvenaud. Neural ordinary differential equations. Advances in neural information processing systems, 31, 2018.
468
+ [4] Zongyi Li, Nikola Kovachki, Kamyar Azizzadenesheli, Burigede Liu, Kaushik Bhattacharya, Andrew Stuart, and Anima Anandkumar. Fourier neural operator for parametric partial differential equations. arXiv preprint arXiv:2010.08895, 2020.
469
+ [5] Sam Greydanus, Misko Dzamba, and Jason Yosinski. Hamiltonian neural networks. CoRR, abs/1906.01563, 2019.
470
+ [6] Herbert Goldstein, Charles Poole, and John Safko. Classical Mechanics. Addison Wesley, 3 edition, 2001.
471
+ [7] Benedict Leimkuhler and Sebastian Reich. Simulating Hamiltonian Dynamics. Cambridge Monographs on Applied and Computational Mathematics. Cambridge University Press, 2005.
472
+ [8] Ernst Hairer, Christian Lubich, and Gerhard Wanner. Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations; 2nd ed. Springer, Dordrecht, 2006.
473
+ [9] Christian Offen and Sina Ober-Blöbaum. Symplectic integration of learned Hamiltonian systems. Chaos: An Interdisciplinary Journal of Nonlinear Science, 32(1):013122, 2022.
474
+ [10] Zhengdao Chen, Jianyu Zhang, Martin Arjovsky, and Léon Bottou. Symplectic recurrent neural networks. In International Conference on Learning Representations, 2020.
475
+ [11] Aiqing Zhu, Pengzhan Jin, and Yifa Tang. Deep Hamiltonian networks based on symplectic integrators. arXiv preprint arXiv:2004.13830, 2020.
476
+ [12] Marco David and Florian Méhats. Symplectic learning for Hamiltonian neural networks. arXiv preprint arXiv:2106.11753, 2021.
477
+ [13] Pengzhan Jin, Zhen Zhang, Aiqing Zhu, Yifa Tang, and George Em Karniadakis. SympNets: Intrinsic structure-preserving symplectic networks for identifying Hamiltonian systems. Neural Networks, 132:166–179, 2020.
478
+ [14] Aiqing Zhu, Pengzhan Jin, Beibei Zhu, and Yifa Tang. Inverse modified differential equations for discovery of dynamics. arXiv preprint arXiv:2009.01058, 2020.
479
+ [15] Takashi Matsubara, Ai Ishikawa, and Takaharu Yaguchi. Deep energy-based modeling of discrete-time physics. Advances in Neural Information Processing Systems, 33:13100–13111, 2020.
480
+ [16] Sølve Eidnes. Order theory for discrete gradient methods. BIT, 62(4):1207–1255, 2022.
481
+ [17] Elena Celledoni, Andrea Leone, Davide Murari, and Brynjulf Owren. Learning Hamiltonians of constrained mechanical systems. J. Comput. Appl. Math., 417:Paper No. 114608, 12, 2023.
482
+ [18] Alvaro Sanchez-Gonzalez, Victor Bapst, Kyle Cranmer, and Peter Battaglia. Hamiltonian Graph Networks with ODE Integrators.
483
+ [19] Gerhard Wanner and Ernst Hairer. Solving ordinary differential equations II, volume 375. Springer Berlin Heidelberg, 1996.
484
+ [20] Senwei Liang, Zhongzhan Huang, and Hong Zhang. Stiffness-aware neural network for learning Hamiltonian systems. 2022.
485
+ [21] Jeff R Cash. A class of implicit Runge–Kutta methods for the numerical integration of stiff ordinary differential equations. Journal of the ACM (JACM), 22(4):504–511, 1975.
486
+ [22] K Burrage, FH Chipman, and Paul H Muir. Order results for mono-implicit Runge–Kutta methods. SIAM journal on numerical analysis, 31(3):876–891, 1994.
487
+ [23] Håkon Noren. Learning Hamiltonian systems with mono-implicit Runge–Kutta methods. arXiv preprint, arXiv:2303.03769, 2023.
488
+ [24] Harsh Sharma, Nicholas Galioto, Alex A Gorodetsky, and Boris Kramer. Bayesian identification of nonseparable Hamiltonian systems using stochastic dynamic models. In 2022 IEEE 61st Conference on Decision and Control (CDC), pages 6742–6749. IEEE, 2022.
489
+ [25] W. M. G. van Bokhoven. Efficient higher order implicit one-step methods for integration of stiff differential equations. BIT, 20(1):34–43, 1980.
490
+ [26] J. R. Cash and A. Singhal. Mono-implicit Runge–Kutta formulae for the numerical integration of stiff differential systems. IMA J. Numer. Anal., 2(2):211–227, 1982.
491
+ [27] Sølve Eidnes, Alexander J Stasik, Camilla Sterud, Eivind Bøhn, and Signe Riemer-Sørensen. Pseudo-Hamiltonian neural networks with state-dependent external forces. arXiv preprint, arXiv:2206.02660, 2022.
492
+ [28] Haruo Yoshida. Construction of higher order symplectic integrators. Physics letters A, 150(5- 7):262–268, 1990.
493
+ [29] Shaan A Desai, Marios Mattheakis, and Stephen J Roberts. Variational integrator graph networks for learning energy-conserving dynamical systems. Physical Review E, 104(3):035310, 2021.
494
+ [30] Daniel DiPietro, Shiying Xiong, and Bo Zhu. Sparse symplectically integrated neural networks. Advances in Neural Information Processing Systems, 33:6074–6085, 2020.
495
+ [31] GRW Quispel and Grant S Turner. Discrete gradient methods for solving ODEs numerically while preserving a first integral. Journal of Physics A: Mathematical and General, 29(13):L341, 1996.
496
+ [32] Robert I McLachlan, G Reinout W Quispel, and Nicolas Robidoux. Geometric integration using discrete gradients. Philosophical Transactions of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences, 357(1754):1021–1045, 1999.
497
+ [33] Ander Murua. Métodos simplécticos desarrollables en $P$ -series. PhD thesis, PhD thesis. Valladolid: Universidad de Valladolid, 1995.
498
+ [34] Philippe Chartier, Ernst Hairer, and Gilles Vilmart. Numerical integrators based on modified differential equations. Mathematics of Computation, 76(260):1941–1953, October 2007.
499
+ [35] 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.
500
+ [36] 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.
501
+ [37] Jorge Nocedal and Stephen J Wright. Numerical optimization. Springer, 1999.
502
+ [38] Yuhan Chen, Takashi Matsubara, and Takaharu Yaguchi. Neural symplectic form: learning hamiltonian equations on general coordinate systems. Advances in Neural Information Processing Systems, 34:16659–16670, 2021.
503
+ [39] Marc Finzi, Ke Alexander Wang, and Andrew Gordon Wilson. Simplifying Hamiltonian and Lagrangian neural networks via explicit constraints. arXiv preprint arXiv:2010.13581, 2020.
504
+ [40] Enrico Fermi, P Pasta, Stanislaw Ulam, and Mary Tsingou. Studies of the nonlinear problems. Technical report, Los Alamos National Lab.(LANL), Los Alamos, NM (United States), 1955.
505
+
506
+ 439 [41] E. Hairer, S. P. Nørsett, and G. Wanner. Solving ordinary differential equations. I, volume 8 of
507
+ 440 Springer Series in Computational Mathematics. Springer-Verlag, Berlin, second edition, 1993.
508
+ 441 Nonstiff problems.
509
+ 442 [42] P. H. Muir. Optimal discrete and continuous mono-implicit Runge-Kutta schemes for BVODEs.
510
+ 443 Adv. Comput. Math., 10(2):135–167, 1999.
511
+ 444 [43] J. R. Cash and D. R. Moore. A high order method for the numerical solution of two-point
512
+ 445 boundary value problems. BIT, 20(1):44–52, 1980.
513
+ 446 [44] Philippe Chartier. Symmetric Methods. In Björn Engquist, editor, Encyclopedia of Applied and
514
+ 447 Computational Mathematics, pages 1439–1448. Springer, Berlin, Heidelberg, 2015.
515
+ 448 [45] J. R. Cash and A. Singhal. High order methods for the numerical solution of two-point boundary
516
+ 449 value problems. BIT, 22(2):184–199, 1982.
517
+ 450 [46] Pauli Virtanen, Ralf Gommers, Travis E. Oliphant, Matt Haberland, Tyler Reddy, David
518
+ 451 Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, Stéfan J.
519
+ 452 van der Walt, Matthew Brett, Joshua Wilson, K. Jarrod Millman, Nikolay Mayorov, Andrew
520
+ 453 R. J. Nelson, Eric Jones, Robert Kern, Eric Larson, C J Carey, ˙ Ilhan Polat, Yu Feng, Eric W.
521
+ 454 Moore, Jake VanderPlas, Denis Laxalde, Josef Perktold, Robert Cimrman, Ian Henriksen, E. A.
522
+ 455 Quintero, Charles R. Harris, Anne M. Archibald, Antônio H. Ribeiro, Fabian Pedregosa, Paul
523
+ 456 van Mulbregt, and SciPy 1.0 Contributors. SciPy 1.0: Fundamental Algorithms for Scientific
524
+ 457 Computing in Python. Nature Methods, 17:261–272, 2020.
525
+ 458 [47] Philippe Chartier, Ernst Hairer, and Gilles Vilmart. Numerical integrators based on modified
526
+ 459 differential equations. Math. Comp., 76(260):1941–1953, 2007.
527
+ 460 [48] Ge Zhong and Jerrold E. Marsden. Lie-Poisson Hamilton-Jacobi theory and Lie-Poisson
528
+ 461 integrators. Phys. Lett. A, 133(3):134–139, 1988.
529
+ 462 [49] Takashi Matsubara and Takaharu Yaguchi. FINDE: Neural differential equations for finding
530
+ 463 and preserving invariant quantities. arXiv preprint, arXiv:2210.00272, 2022.
md/dev/td6xbEOPLr/td6xbEOPLr.md ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FATE: Fairness Attacks on Graph Learning
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 We study fairness attacks on graph learning to answer the following question: How
11
+ 2 can we achieve poisoning attacks on a graph learning model to exacerbate the
12
+ 3 bias? We answer this question via a bi-level optimization problem and propose a
13
+ 4 meta learning-based attacking framework named FATE. The proposed framework
14
+ 5 is broadly applicable with respect to various fairness definitions and graph learning
15
+ 6 models,as well as arbitrary choices of manipulation operations.We further instanti
16
+ 7 ate FATE to attack statistical parity and individual fairness on graph neural networks.
17
+ 8 We conduct extensive experimental evaluations on real-world datasets in the task
18
+ 9 of semi-supervised node classification. The experimental results demonstrate that
19
+ 10 FATE could amplify the bias of graph neural networks with or without fairness
20
+ 11 consideration while maintaining the utility on the downstream task.We hope this
21
+ 12 paper provides insights into the adversarial robustness of fair graph learning and
22
+ 13 can shed light on designing robust and fair graph learning in future studies.
23
+
24
+ # 141Introduction
25
+
26
+ 15 Algorithmic fairness in graph learning has received much research attention [5,20,24]. Despite
27
+ 16 its substantial progress,existing studies mostly assume the benevolence of input graphs and aim
28
+ 17 to ensure that the bias would not be perpetuated or amplified in the learning process.However,
29
+ 18 malicious activities in the real world are commonplace.For example,consider a financial fraud
30
+ 19 detection system which utilizes a transaction network to classify whether a bank account is fraudulent
31
+ 20 or not [49,45]. An adversary may manipulate the transaction network (e.g., malicious banker with
32
+ 21 access to the transaction data,theft of bank accounts to make malicious transactions), so that the
33
+ 22 graph-based fraud detection model would exhibit unfair classification results with respect to people
34
+ 23 of different demographic groups. Consequently,a biased fraud detection model may infringe civil
35
+ 24 liberty to certain financial activities and impact the well-being of an individual negatively [6]. It
36
+ 25 would also make the graph learning model fail to provide the same quality of service to people of
37
+ 26 certain demographic groups,causing the financial institutions to lose business in the communities
38
+ 27 of the corresponding demographic groups. Thus, it is critical to understand how resilient a graph
39
+ 28 learning model is with respect to adversarial attcks on fairness, which we term as fairness attacks.
40
+ 29 To date,fairness attack has not been well studied. Sporadic literature often follows two strategies:
41
+ 30 (1) adversarial data point injection, which is often designed for tabular data rather than graphs [38,
42
+ 31 33,8,44] or (2) adversarial edge injection, which only atacks the group fairness of a graph neural
43
+ 32 network [19]. It is thus crucial to study how to attck different fairness definitions for a variety of
44
+ 33 graph learning models.
45
+ 34 To achieve this goal, we study the Fairness attacks on graph learning (FATE) problem.We formulate
46
+ 35 it as a bi-level optimization, where the lower-level problem optimizes a task-specific loss function
47
+ 36 to make the fairness attacks deceptive and the upper-level problem leverages the supervision signal
48
+ 37 to modify the input graph and maximize the bias function corresponding to a user-defined fairness
49
+ 38 definition. To solve the bi-level optimization problem, we propose a meta learning-based solver
50
+ 39 (FATE),whose key idea is to compute the meta-gradient of the upper-level bias function with respect
51
+ 40 to the input graph to guide the fairness attacks. Compared with existing works,our proposed
52
+ 41 FATE framework has two major advantages.First, it is capable of attacking any fairness definition
53
+ 42 on any graph learning model,as long as the corresponding bias function and the task-specific loss
54
+ 43 function are differentiable.Second, it is equipped with the ability for either continuous or discretized
55
+ 44 poisoning atacks on the graph topology. We also briefly discuss its ability for poisoning attacks on
56
+ 45 node features in a later section.
57
+
58
+ 46The major contributions of this paper are summarized as follows.
59
+
60
+ 17· Problem definition. We formally define the problem of fairness attacks on graph learning (the
61
+ 18 FATE problem). Based on the definition, we formulate it as a bi-level optimization problem, whose
62
+ 19 key idea is to maximize a bias function in the upper level while minimizing a task-specific loss
63
+ 0 function for a graph learning task.
64
+
65
+ · Attacking framework. We propose an end-to-end attcking framework named FATE. It learns a perturbed graph topology via meta learning,such that the bias with respect to the learning results trained with the perturbed graph will be amplified.
66
+
67
+ · Empirical evaluation. We conduct experiments on three benchmark datasets to demonstrate the efficacy of our proposed FATE framework in amplifying the bias while being the most deceptive method (i.e.,achieving the highest micro F1 score) on semi-supervised node classification.
68
+
69
+ # 572Preliminaries and Problem Definition
70
+
71
+ A - Notations. Throughout the paper, we use bold upper-case letter for matrix (e.g.,A), bold lower-case letter for vector (e.g., x) and calligraphic letter for set (e.g., $\mathcal { G }$ ). We use superscript T to denote the transpose of a matrix/vector (e.g., $\mathbf { x } ^ { T }$ is the transpose of $\mathbf { x }$ ).Regarding matrix/vector indexing, we use conventions similar to NumPy in Python. For example, $\mathbf { A } [ i , j ]$ is the entry of $\mathbf { A }$ at the $i$ -th row and $j$ -th column; $\mathbf { x } [ i ]$ is the $i$ -th entry of x; $\mathbf { A } [ i , : ]$ and $\mathbf { A } [ j , : ]$ are the $i$ -th row and $j$ -th column of A, respectively.
72
+
73
+ 4 B- Algorithmic fairness. The general principle of algorithmic fairness is to ensure the learning
74
+ 5 results would not favor one side or another.1 Among several fairness definitions that follow this
75
+ 6 principle, group fairness [16,18] and individual fairness[15] are the most widely studied ones. Group
76
+ 7 fairness splits the entire population into multiple demographic groups by a sensitive attribute (e.g.,
77
+ 8 gender) and ensure the parity of a statistical property among learning results of those groups.For
78
+ 9 example,statistical parity,a classic group fairness definition, guarantees the statistical independence
79
+ 70 between the learning results (e.g., predicted labels of a classification algorithm) and the sensitive
80
+ 71 atribute [16]. Individual fairness suggests that similar individuals should be treated similarly. It is
81
+ 2 often formulated as a Lipschitz inequality such that distance between the learning results of two data
82
+ 73 points should be no larger than the difference between these two data points [15].
83
+ 74 C- Problem definition. Existing work [19] for fairness attacks on graphs randomly injects adversar
84
+ 75 ial edges so that the disparity between the learning results of two diferent demographic groups would
85
+ 76 be amplified.However, it suffers from three major limitations.(1) First, it only attacks statistical
86
+ 77 parity while overlooking other fairness definitions (e.g.,individual fairness [15]).(2) Second, it only
87
+ 78 considers adversarial edge injection, excluding other manipulations like edge deletion or reweighting.
88
+ 79 Hence, it is essential to investigate the possibility to attck other fairness definitions on real-world
89
+ 80 graphs with an arbitrary choice of manipulation operations. (3) Third, it does not consider the utility
90
+ 81 of graph learning models while achieving the fairness attacks,resulting in performance degradation
91
+ 82 in the downstream tasks. However, an institution that applies the graph learning models are often
92
+ 83 utility-maximizing [28,2]. Thus,a performance degradation in the utility would make the fairness
93
+ 84 attacks not deceptive from the perspective of a utility-maximizing institution.
94
+
95
+ In this paper, we seek to overcome the aforementioned limitations.To be specific, given an input graph,an optimization-based graph learning model,and a user-defined fairness definition, we aim to learn a modified graph such that a bias function of the corresponding fairness definition would be maximized for effective fairness attacks, while minimizing the task-specific loss function with respect to the graph learning model for deceptive fairness attacks. Formally, we define the problem of fairness attacks on graph learning,which is referred to as the FATE problem.
96
+
97
+ 92 Given: (1) An undirected graph $\mathcal { G } = \{ \mathbf { A } , \mathbf { X } \}$ ; (2) a task-specific loss function $l ( \mathcal { G } , \mathcal { V } , \Theta , \theta )$ where $\mathcal { V }$
98
+ 93 is the graph learning results, $\Theta$ is the set of learnable variables and $\theta$ is the set of hyperparameters; (3)
99
+ 94 a bias function $b ( \mathbf { Y } , \Theta ^ { * } , \mathbf { F } , \theta )$ where $\Theta ^ { * } = \arg \operatorname* { m i n } _ { \Theta } l ( \mathcal { G } , \mathcal { V } , \Theta , \theta )$ and $\mathbf { F }$ is the matrix that contains
100
+ 95 auxiliary fairness-related information (e.g., sensitive attribute values of all nodes in $\mathcal { G }$ for group
101
+ 96 fairness,pairwise node similarity matrix for individual fairness); (4) an integer budget $B$
102
+ 97Find: a poisoned graph $\widetilde { \mathcal { G } } = \{ \widetilde { \bf A } , \widetilde { \bf X } \}$ which satisfies the following properties: (1) $d ( \mathcal { G } , \widetilde { \mathcal { G } } ) \leq B$
103
+ 98 where $d ( \mathcal { G } , \widetilde { \mathcal { G } } )$ is the distance between the input graph $\mathcal { G }$ and the poisoned graph $\widetilde { \mathcal G }$ (e.g., $\| \mathbf { A } , \widetilde { \mathbf { A } } \| _ { 1 , 1 } )$
104
+ 99 (2) the bias function $b \left( \mathbf { Y } , \Theta ^ { * } , \mathbf { F } \right)$ is maximized for effectiveness; (3) the task-specific loss function
105
+ 00 $l \left( \widetilde { \mathcal { G } } , \mathcal { Y } , \Theta , \theta \right)$ is minimized for deceptiveness.
106
+
107
+ # 3Methodology
108
+
109
+ In this section, we first formulate Problem 1 as a bi-level optimization problem,followed by a generic meta learning-based solver named FATE.
110
+
111
+ # 3.1Problem Formulation
112
+
113
+ 5 Given an input graph $\mathcal { G } = \{ { \bf A } , { \bf X } \}$ with adjacency matrix A and node feature matrix $\mathbf { X }$ , an attacker
114
+ 6aims to learn a poisoned graph $\widetilde { \mathcal { G } } = \{ \widetilde { \bf A } , \widetilde { \bf X } \}$ such that the graph learning model will be maximally
115
+ 7biased when trained on $\widetilde { \mathcal G }$ . In this work, we consider the following settings for the attacker.
116
+ 08 The goal of the attacker. The atacker aims to amplify the bias of the graph learning results output
117
+ 09 by a victim graph learning model. And the bias to be amplifed is a choice made by the attacker based
118
+ 10on which fairness definition the attacker aims to attack.
119
+ 111 The knowledge of the attacker. Following similar settings in [19], we assume the attacker has
120
+ 112 access to the adjacency matrix,the feature matrix of the input graph,and the sensitive attribute of
121
+ 113 all nodes in the graph. For a (semi-)supervised learning problem, we assume that the ground-truth
122
+ 114 labels of the training nodes are also available to the atacker. For example,for a graph-based financial
123
+ 115 fraud detection problem, the malicious banker may have access to the demographic information (i.e,
124
+ 116 sensitive atribute)of the account holders and also know whether some bank accounts are fraudulent
125
+ 117 or not, which are the ground-truth labels for training nodes.Similar to [51,52,19], the attacker has
126
+ 118 no knowledge about the parameters of the victim model. Instead, the attcker will perform a gray-box
127
+ 119 attack by attacking a surrogate graph learning model.
128
+
129
+ oThe capabilitiy of the attacker. The attacker is able to perturb up to $B$ edges/features in the graph 1 (i.e., $\| \mathbf { A } - \widetilde { \mathbf { A } } \| _ { 1 , 1 } \leq B$ 0r $\| \mathbf { X } - \widetilde { \mathbf { X } } \| _ { 1 , 1 } \leq B )$ :
130
+
131
+ 122Based on that, we formulate Problem 1 as a bi-level optimization problem as follows.
132
+
133
+ $$
134
+ \begin{array} { r l } & { \widetilde { \mathcal { G } } = \arg \operatorname* { m a x } _ { \mathcal { G } } b \left( \mathbf { Y } , \boldsymbol { \Theta } ^ { * } , \mathbf { F } \right) } \\ & { \quad \quad \mathrm { s . t . } \quad \boldsymbol { \Theta } ^ { * } = \arg \underset { \boldsymbol { \Theta } } { \operatorname* { m i n } } l \left( \mathcal { G } , \mathbf { Y } , \boldsymbol { \Theta } , \boldsymbol { \theta } \right) , d \left( \mathcal { G } , \widetilde { \mathcal { G } } \right) \leq B } \end{array}
135
+ $$
136
+
137
+ 123 where the lower-level problem learns an optimal surrogate graph learning model $\Theta ^ { * }$ by minimizing
138
+ 124 $l \left( { \mathcal { G } } , \mathbf { Y } , \Theta , \theta \right)$ , the upper-level problem finds a poisoned graph $\widetilde { \mathcal { G } }$ that could maximize a bias function
139
+ 125 $b \left( \mathbf { Y } , \Theta ^ { * } , \mathbf { F } \right)$ for the victim graph learning model and the distance between the input graph and the
140
+ 126 poisoned graph $d \left( \mathcal { G } , \widetilde { \mathcal { G } } \right)$ is constrained to satisfy the seting about the budgeted attack. Note hat
141
+ 127 Eq. (1) is applicable to attack any fairness definition on any graph learning model,as long as the bias
142
+ 128 function $b \left( { \bar { \mathbf { Y } } } , \Theta ^ { * } , \mathbf { F } \right)$ and the loss function $l \left( { \mathcal { G } } , \mathbf { Y } , \Theta , \theta \right)$ are differentiable.
143
+ 129 A -Lower-level optimization problem. A wide spectrum of graph learning models are essentially
144
+ 130 solving an optimization problem. Take the graph convolutional network (GCN) [26] as an example.
145
+ 131 It learns the node representation by aggregating information from its neighborhood, i.e., message
146
+ 132 passing. Mathematically, for an $L$ -layer GCN,the hidden representation at $k$ -th layer can be
147
+ 133 represented as $\mathbf { E } ^ { ( k ) } = \sigma \left( \widehat { \mathbf { A } } \mathbf { E } ^ { ( k - 1 ) } \mathbf { W } ^ { ( k ) } \right)$ where $\sigma$ is a nonlinearactivation function (e.g.,ReLU),
148
+ 134 $\widehat { \mathbf { A } } = \mathbf { D } ^ { - 1 / 2 } \left( \mathbf { A } + \mathbf { I } \right) \mathbf { D } ^ { - 1 / 2 }$ with $\mathbf { D }$ being the degree matrix of $( \mathbf { A } + \mathbf { I } )$ and $\mathbf { W } ^ { ( k ) }$ is the learnable
149
+ 135 weight matrix of the $k$ -th layer. Then the lower-level optimization problem aims to learn the set
150
+ 136 of parameters $\boldsymbol { \Theta } ^ { * } = \{ \mathbf { W } ^ { ( k ) } | k = 1 , \dots , L \}$ that could minimize a task-specific loss function (e.g.,
151
+ 137 cross-entropy loss for semi-supervised node classification). For more examples of graph learning
152
+ 138 models from the optimization perspective, please refers to Appendix A.
153
+
154
+ B - Upper-level optimization problem. To atack the fairness aspect of a graph learning model, we aim to maximize a differentiable bias function $b \left( \mathbf { Y } , \Theta ^ { * } , \mathbf { F } \right)$ with respect to a user-defined fairness definition in the upper-level optimization problem. For example,for statistical parity[16], the fairnessrelated auxiliary information matrix $\mathbf { F }$ can be defined as the one-hot demographic membership matrix, where $\mathbf { F } [ i , j ] = 1$ if and only if node $i$ belongs to $j$ -th demographic group. Then the statistical parity is equivalent to the statistical independence between the learning results $\mathbf { Y }$ and $\mathbf { F }$ .Based on that, existing studies propose several differentiable measurements of the statistical dependence between $\mathbf { Y }$ and $\mathbf { F }$ as the bias function. For example, Bose et al. [5] use mutual information $I ( \mathbf { Y } ; \mathbf { F } )$ as the bias function; Prost et al. [35] define the bias function as the Maximum Mean Discrepancy MMD $( \mathsf { y } _ { 0 } , \mathsf { y } _ { 1 } )$ (202 between the learning results of two different demographic groups $\mathcal { V } _ { 0 }$ and $\mathcal { \mathrm { V } } _ { 1 }$ :
155
+
156
+ # 3.2The FATE Framework
157
+
158
+ 150 To solve Eq.(1), we propose a generic attcking framework named FATE to learn the poisoned graph.
159
+ 151 The key idea is to view Eq. (1) as a meta learning problem, which aims to find suitable hyperparameter
160
+ 152 setings for a learning task [3],and treat the graph $\mathcal { G }$ as a hyperparameter. With that, we learn the
161
+ 153 poisoned graph $\widetilde { \mathcal G }$ using the meta-gradient of the bias function $b \left( \mathbf { Y } , \Theta ^ { * } , \mathbf { F } \right)$ with respect to $\mathcal { G }$ . In the
162
+ 154 following, we introduce two key parts of FATE in details, including meta-gradient computation and
163
+ 155 graph poisoning with meta-gradient.
164
+ 156 A -Meta-gradient computation. The key term to learn the poisoned graph is the meta-gradient of
165
+ 157 the bias function with respect to the graph $\mathcal { G }$ . Before computing the meta-gradient, we assume that
166
+ 158 the lower-level optimization problem converges in $T$ epochs. Thus,we first pre-train the lower-level
167
+ 159 optimization problem by $T$ epochs to obtain the optimal model $\Theta ^ { * } = \Theta ^ { ( \bar { T } ) }$ before computing the
168
+ 160 meta-gradient. The training of the lower-level optimization problem can also be viewed as a dynamic
169
+ 161 system with the following updating rule
170
+
171
+ $$
172
+ \Theta ^ { ( t + 1 ) } = \operatorname { o p t } ^ { ( t + 1 ) } \left( \mathcal { G } , \Theta ^ { ( t ) } , \theta , \mathbf { Y } \right) , \forall t \in \{ 1 , \dots , T \}
173
+ $$
174
+
175
+ 162 where $\Theta ^ { ( 1 ) }$ refers to $\Theta$ at initialization, $\mathrm { o p t } ^ { ( t + 1 ) } ( \cdot )$ is an optimizer that minimizes the lower-level
176
+ 163 loss function $l \left( \mathcal { G } , \mathbf { Y } , \Theta ^ { \left( t \right) } , \theta \right)$ at $( t + 1 )$ -th epoch. From the perspective of the dynamic system,
177
+ 164 by applying the chain rule and unrolling the training of lower-level problem with Eq.(2), the
178
+ 165 meta-gradient $\nabla _ { \boldsymbol { \mathcal { G } } } b$ can be written as
179
+
180
+ $$
181
+ \nabla _ { \mathcal { G } } b = \nabla _ { \mathcal { G } } b \left( \mathbf { Y } , \boldsymbol { \Theta } ^ { ( T ) } , \mathbf { F } \right) + \sum _ { t = 0 } ^ { T - 2 } A _ { t } B _ { t + 1 } \dots B _ { T - 1 } \nabla _ { \boldsymbol { \theta } ^ { ( T ) } } b \left( \mathbf { Y } , \boldsymbol { \Theta } ^ { ( T ) } , \mathbf { F } \right)
182
+ $$
183
+
184
+ 166 where $A _ { t } = \nabla _ { \mathcal { G } } \Theta ^ { ( t + 1 ) }$ and $B _ { t } = \nabla _ { \Theta ^ { ( t ) } } \Theta ^ { ( t + 1 ) }$ . However, Eq. (3) is computationally expensive in
185
+ 167 both time and space. To further speed up the computation, we adopt a first-order approximation of
186
+ 168 the meta-gradient [17] and simplify the meta-gradient as
187
+
188
+ $$
189
+ \nabla _ { \mathcal { G } } b \approx \nabla _ { \Theta ^ { ( T ) } } b \left( \mathbf { Y } , \Theta ^ { ( T ) } , \mathbf { F } \right) \cdot \nabla _ { \mathcal { G } } \Theta ^ { ( T ) }
190
+ $$
191
+
192
+ 169 Since the input graph is undirected, the derivative of the symmetric adjacency matrix A can be
193
+ 170computed as follows by applying the chain rule of a symmetric matrix [21].
194
+
195
+ $$
196
+ \nabla _ { \mathbf { A } } b \gets \nabla _ { \mathbf { A } } b + \left( \nabla _ { \mathbf { A } } b \right) ^ { T } - \mathrm { d i a g } \left( \nabla _ { \mathbf { A } } b \right)
197
+ $$
198
+
199
+ 1For the node feature matrix $\mathbf { X }$ , its derivative is equal to the partial derivative $\nabla _ { \mathbf { X } } b$ since it is often an ‘2asymmetric matrix.
200
+
201
+ 73B-Graph poisoning with meta-gradient. After computing the meta-gradient of the bias function
202
+ 74 $\nabla _ { \boldsymbol { \mathcal { G } } } b$ , we aim to poison the input graph guided by $\nabla _ { \boldsymbol { \mathcal { G } } } b$ .We introduce two poisoning strategies: (1)
203
+ 75 continuous poisoning and (2) discretized poisoning.
204
+ 176 Continuous poisoning atack. The continuous poisoning attack is straightforward by reweighting
205
+ 177 edges in the graph.We first compute the meta-gradient of the bias function $\nabla _ { \mathbf { A } } b$ ,then use it to poison
206
+ 178 the input graph in a gradient descent-based updating rule as follows.
207
+
208
+ $$
209
+ \mathbf { A } \mathbf { A } - \eta \nabla _ { \mathbf { A } } b
210
+ $$
211
+
212
+ 79where $\eta$ is a learning rate to control the magnitude of the poisoning attack. The learning rate should
213
+ 80satisfy n≤V11 to ensure that constraint on the budgeted attack.
214
+ 81Discretized poisoning attack. The discretized poisoning attack aims to select a set of edges to be
215
+ 82added/deleted. It is guided by a poisoning preference matrix defined as follows.
216
+
217
+ $$
218
+ \nabla _ { \mathbf { A } } = ( \mathbf { 1 } - 2 \mathbf { A } ) \circ \nabla _ { \mathbf { A } } b
219
+ $$
220
+
221
+ 183 where 1 is an all-one matrix with the same dimension as $\mathbf { A }$ and $\bigcirc$ denotes the Hadamard product.
222
+ 184 A large positive $\nabla _ { \mathbf { A } } [ i , j ]$ indicates strong preference in adding an edge if nodes $i$ and $j$ are not
223
+ 185 connected (i.e., positive $\dot { \nabla } _ { \mathbf { A } } b [ i , j ]$ ,positive $( \mathbf { 1 } - 2 \mathbf { A } ) [ i , j ] )$ or deleting an edge if nodes $i$ and $j$ are
224
+ 186 connected (i.e., negative $\nabla _ { \mathbf { A } } b [ i , j ]$ ,negative $( \mathbf { 1 } - 2 \mathbf { A } ) [ i , j ] )$ . Then, a greedy selection strategy is
225
+ 187 applied to find the set of edges $\mathcal { E } _ { \mathrm { a t t a c k } }$ to be added/deleted.
226
+
227
+ $$
228
+ \mathcal { E } _ { \mathrm { a t t a c k } } = \mathrm { t o p k } ( \nabla _ { \mathbf { A } } , \delta )
229
+ $$
230
+
231
+ 188 where $\mathrm { t o p k } ( \nabla _ { \mathbf { A } } , \delta )$ selects $\delta$ entries with highest preference score in $\nabla _ { \mathbf { A } }$ . Note that, if we only want
232
+ 189 to add edges without any deletion, all negative entries in $\nabla _ { \mathbf { A } } b$ should be zeroed out before computing
233
+ 190 Eq. (7).Likewise,if edges are only expected to be deleted,all positive entries should be zeroed out.
234
+ 91Remarks. Poisoning node feature matrix $\mathbf { X }$ follows the same steps as poisoning adjacency matrix A
235
+ 92without applying Eq. (5).
236
+ 193 C- Overal framework. FATE generally works as follows. (1) We first pre-train the surrogate graph
237
+ 194 learning model and get the corresponding learning model $\Theta ^ { ( T ) }$ as well as the learning results $\bar { \mathbf { Y } } ^ { ( T ) }$
238
+ 195 (2) Then we compute the meta gradient of the bias function using Eqs.(4) and (5). (3)Finall, we
239
+ 196 perform the discretized poisoning attack (Eqs.(7) and (8)) or continuous poisoning attack (Eq (6)).
240
+ 197 A detailed pseudo-code of FATE is provided in Appendix B.
241
+ 198 D -Limitations. Since FATE leverages the meta-gradient to poison the input graph, it requires the
242
+ 199 bias function $b \left( \mathbf { Y } , \Theta ^ { ( T ) } , \mathbf { F } \right)$ to be differentiable in order to calculate the meta-gradient $\nabla _ { \boldsymbol { \mathcal { G } } } b$ In
243
+ 200 Sections 4 and 5, we present a carefully chosen bias function for FATE. And we leave it for future
244
+ 201 work on exploring the ability of FATE in attcking other fairness definitions. Moreover, though the
245
+ 202 meta-gradient can be efciently computed via auto-differentiation in many deep learning packages
246
+ 203 (e.g., PyTorch², TensorFlow3), it requires $O ( n ^ { 2 } )$ space complexity to store the meta-gradient when
247
+ 204 attacking fairness via edge flipping. It is still a challenging open problem on how to efficiently
248
+ 205 compute the meta-gradient in terms of space. One possible remedy for discretized attck might be a
249
+ 206 low-rank approximation on the perturbation matrix formed by $\mathcal { E } _ { \mathrm { a t t a c k } }$ . Since the difference between
250
+ 207 the benign graph and poisoned graph are often small and budgeted $( d \left( \mathcal { G } , \widetilde { \mathcal { G } } \right) \leq B )$ , it is likely that
251
+ 208 the edge manipulations may be around a few set of nodes,which makes the perturbation matrix to be
252
+ 209 an (approximately) low-rank matrix.
253
+
254
+ # 4Instantiation #1: Statistical Parity on Graph Neural Networks
255
+
256
+ Here,we instantiate FATE framework by attacking statistical parity on graph neural networks in a binary node clasification problem with a binary sensitive attribute.We briefly discuss how to choose (1) the surrogate graph learning model used by the attacker, (2) the task-specific loss function in the lower-level optimization problem and (3) the bias function in the upper-level optimization problem.
257
+
258
+ A - Surrogate graph learning model. We assume that the surrogate model to be used by the attacker is a 2-layer linear GCN [47] with diferent hidden dimensions and model parameters at initialization.
259
+
260
+ B -Lower-level loss function. We consider a semi-supervised node classification task for the graph neural network to be attacked. Thus, the lower-level loss function is chosen as the cross entropy between the ground-truth label and the predicted label: $l \left( { \mathcal { G } } , \mathbf { Y } , \Theta , \theta \right) \ =$ Vn∑ieVi∑j=1yi,jlnyij,where Virain istheset of training nodes withground-truthlabels with $| \mathcal { V } _ { \mathrm { t r a i n } } |$ being its cardinality, $c$ is the number of classes, $y _ { i , j }$ is a binary indicator of whether node $i$ belongs to class $j$ and $\widehat { y } _ { i , j }$ is the prediction probability of node $i$ belonging to class $j$
261
+
262
+ C- Upper-level bias function.We aim to attack statistical parity in the upper-level problem, which asks for $\mathrm { P } \left[ \hat { y } = 1 \right] = \mathrm { P } \left[ \hat { y } = 1 | s = 1 \right]$ . Suppose $p \left( \widehat { y } \right)$ is the probability density function (PDF) of $\widehat { y } _ { i , 1 }$ (202
263
+
264
+ 225 for any node $i$ and $p \left( \widehat { y } | s = 1 \right)$ is the PDF of $\widehat { y } _ { i , 1 }$ for any node $i$ belong to the demographic group
265
+ 226 with sensitive attribute value $s = 1$ . We observe that $\mathrm { ~ P ~ } [ \hat { y } = 1 ]$ and I $\bar { \boldsymbol { \vert \hat { y } } } = 1 \boldsymbol { \vert s = 1 \vert }$ are equivalent
266
+ 227 to the cumulative distribution functions (CDF) of $p \left( \widehat { y } < \frac { 1 } { 2 } \right)$ and $p$ $\begin{array} { r } { ( \widehat { y } < \frac { 1 } { 2 } | s = 1 ) } \end{array}$ ),respectively. To
267
+ 228 estimate both $\mathrm { ~ P ~ } [ \hat { y } = 1 ]$ and $\mathrm { P } [ \hat { y } = 1 | s = 1 ]$ with a differentiable function,we first estimate their
268
+ 229 probability density functions $\begin{array} { r } { ( p \left( \widehat { y } < \frac { 1 } { 2 } \right) } \end{array}$ and $p$ $\widehat { y } < \frac { 1 } { 2 } | s = 1 \big )$ ) with kernel density estimation (KDE,
269
+ 230 Definition 1).
270
+
271
+ Definition1 (Kernel density estimation $I 7 J )$ Given a set of $n$ IID samples $\{ x _ { 1 } , \ldots , x _ { n } \}$ drawn from a distribution with an unknown probability density function $f$ ,the kernel density estimation of $f$ at point $\tau$ is defined as follows.
272
+
273
+ $$
274
+ { \widetilde { f } } \left( \tau \right) = { \frac { 1 } { n a } } \sum _ { i = 1 } ^ { n } f _ { k } \left( { \frac { \tau - x _ { i } } { a } } \right)
275
+ $$
276
+
277
+ where $\widetilde { f }$ is the estimated probability density function, $f _ { k }$ is the kernel function and a is a non-negative bandwidth.
278
+
279
+ 236 Moreover, we assume the kernel function in KDE is the Gaussan kernel $\begin{array} { r } { f _ { k } \left( x \right) = \frac { 1 } { \sqrt { 2 \pi } } e ^ { - x ^ { 2 } / 2 } } \end{array}$
280
+ 237 However, computing the CDF of a Gaussian distribution is non-trivial. Following [9], we leverage a
281
+ 238 tractable approximation of the Gaussian Q-function as follows.
282
+
283
+ $$
284
+ Q ( \tau ) = F _ { k } \left( \tau \right) = \int _ { \tau } ^ { \infty } f _ { k } ( x ) d x \approx e ^ { - \alpha \tau ^ { 2 } - \beta \tau - \gamma }
285
+ $$
286
+
287
+ 239where $\textstyle f _ { k } ( x ) = = { \frac { 1 } { \sqrt { 2 \pi } } } e ^ { - x ^ { 2 } / 2 }$ is a Gausindstrtionithoean $\alpha = 0 . 4 9 2 0$ $\beta = 0 . 2 8 8 7$ ,
288
+ 240 $\gamma = 1 . 1 8 9 3$ [30]. The overall workflow of estimating $\mathrm { ~ P ~ } [ \hat { y } = 1 ]$ is as follows.
289
+
290
+ · For any node $i$ , get its prediction probability $\widehat { y } _ { i , 1 }$ with respect to class 1; ·Estimate the CDF $\mathrm { ~ P ~ } [ \hat { y } = 1 ]$ using a Gaussian KDE with bandwidth $a$ by $\mathrm { ~ P ~ } [ \hat { y } = 1 ] =$ $\begin{array} { r } { \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \exp \left( - \alpha \left( \frac { 0 . 5 - \widehat y _ { i , 1 } } { a } \right) ^ { 2 } - \beta \left( \frac { 0 . 5 - \widehat y _ { i , 1 } } { a } \right) - \gamma \right) } \end{array}$ where $\alpha ~ = ~ 0 . 4 9 2 0$ , $\beta ~ = ~ 0 . 2 8 8 7$ $\gamma =$ 1.1893 and $\exp ( x ) = e ^ { x }$ :
291
+
292
+ Note that $\mathrm { P } [ \hat { y } = 1 | s = 1 ]$ can be estimated with a similar procedure with minor modifications. The only modifications needed are: (1) get the prediction probability of nodes with $s = 1$ and (2) compute the CDF using the Gaussian $\mathrm { Q }$ -function over nodes with $s = 1$ rather than all nodes in the graph.
293
+
294
+ # 5Instantiation #2: Individual Fairness on Graph Neural Networks
295
+
296
+ We provide another instantiation of FATE framework by attacking individual fairness on graph neural networks. Here, we consider the same surrogate graph learning model (i.e., 2-layer linear GCN) and the same lower-level loss function (i.e., cross entropy) as described in Section 4. To attack individual fairness,we define the upper-level bias function following the principles in [20]: the fairness-related auxiliary information matrix $\mathbf { F }$ is defined as the oracle symmetric pairwise node similarity matrix S (i.e., $\mathbf { F } = \mathbf { S } $ ),where ${ \bf S } [ i , j ]$ measures the similarity between node $i$ and node $j$ .Kang et al. [2O] define that the overall individual bias to be $\operatorname { T r } \left( \mathbf { Y } ^ { T } \mathbf { L } _ { \mathbf { S } } \mathbf { Y } \right)$ . Assuming that $\mathbf { Y }$ is the output of an optimization-based graph learning model, $\mathbf { Y }$ can be viewed as a function with respect to the input graph $\mathcal { G }$ , which makes $\mathbf { \dot { T r } } \left( \mathbf { Y } ^ { T } \mathbf { L } \mathbf { s } \mathbf { \check { Y } } \right)$ differentiable with respect to $\mathcal { G }$ . Thus, the bias function $b ( \cdot )$ can be naturally defined as the overall individual bias of the input graph $\mathcal { G }$ ,i.e., $b \left( \mathbf { Y } , \Theta ^ { * } , \mathbf { S } \right) = \mathrm { T r } \left( \mathbf { Y } ^ { T } \mathbf { L } _ { \mathbf { S } } \mathbf { Y } \right)$
297
+
298
+ # 6Experiments
299
+
300
+ # 6.1Attacking Statistical Parity on Graph Neural Networks
301
+
302
+ Settings.We compare FATE with 4 baseline methods,i.e.,Random,DICE [46], FA-GNN [19],under the same setting as in Section 4. That is,(1) the fairness definition to be attacked is statistical parity; (2) the downstream task is binary semi-supervised node classification with binary sensitive attributes. The experiments are conducted on 3 real-world datasets,i.e., Pokec-n, Pokec-z and Bail. Similar to existing works, we use the $5 0 \% / 2 5 \% / 2 5 \%$ splits for train/validation/test sets. For all baseline
303
+
304
+ Table 1: Effectiveness of attacking group fairness on GCN.FATE poisons the graph via both edge flipping (FATE-flip) and edge addition (FATE-add) while all other baselines poison the graph via edge addition. Higher is better $( \uparrow )$ for micro F1 score (Micro F1) and $\Delta _ { \mathrm { S P } }$ .Bold font indicates the success of fairness attack (i.e., $\Delta _ { \mathrm { S P } }$ is increased after fairness attack) with the highest micro F1 score. Underlined cell indicates the failure of fairness attack (i.e., $\Delta _ { \mathrm { S P } }$ is decreased after fairness attack).
305
+
306
+ <table><tr><td rowspan="2">Dataset</td><td rowspan="2">Ptb.</td><td colspan="2">Random MicroF1(↑)</td><td colspan="2">DICE</td><td colspan="2">FA-GNN</td><td colspan="2">FATE-flip</td><td colspan="2">FATE-add</td></tr><tr><td></td><td>△sP(↑)</td><td>Micro F1(↑)</td><td>△sP(↑)</td><td>MicroF1(↑)</td><td>△sP()</td><td>MicroF1(↑</td><td>△sP()</td><td>MicroF1(↑)</td><td>△sP(↑)</td></tr><tr><td rowspan="7">Pokec-n</td><td>0.00</td><td>67.5± 0.3</td><td>7.1 ± 0.4</td><td>67.5±0.3</td><td>7.1 ±0.4</td><td>67.5± 0.3</td><td>7.1 ±0.4</td><td>67.5± 0.3</td><td>7.1 ± 0.4</td><td>67.5± 0.3</td><td>7.1 ± 0.4</td></tr><tr><td>0.05</td><td>68.0±0.3</td><td>6.2±0.8</td><td>67.6±0.2</td><td>6.8±0.3</td><td>67.8±0.1</td><td>3.3±0.4</td><td>67.9 ±0.4</td><td>9.3 ±1.2</td><td>67.9 ±0.4</td><td>9.3 ±1.2</td></tr><tr><td>0.10</td><td>66.8±0.8</td><td>7.3±0.7</td><td>66.1 ± 0.5</td><td>6.6 ±1.1</td><td>66.0±0.2</td><td>11.5± 0.6</td><td>68.2±0.6</td><td>9.8±1.5</td><td>68.2±0.6</td><td>9.8±1.5</td></tr><tr><td>0.15</td><td>66.7 ± 0.4</td><td>8.1 ± 0.4</td><td>65.6±0.4</td><td>7.7±0.8</td><td>66.0 ±0.4</td><td>15.6 ±3.0</td><td>68.0±0.3</td><td>11.5 ± 1.0</td><td>68.0±0.3</td><td>11.5 ± 1.0</td></tr><tr><td>0.20</td><td>66.3±0.7</td><td>8.6±1.8</td><td>64.2 ± 0.4</td><td>3.4±0.9</td><td>65.8± 0.1</td><td>18.4±0.7</td><td>68.2±0.5</td><td>12.0 ±1.8</td><td>68.2±0.5</td><td>12.0 ± 1.8</td></tr><tr><td>0.25</td><td>66.2±0.6</td><td>8.5±0.8</td><td>63.4 ±0.2</td><td>6.3±0.8</td><td>66.6±0.2</td><td>23.3 ±0.5</td><td>68.3±0.4</td><td>12.1 ± 2.1</td><td>68.3±0.4</td><td>12.1 ± 2.1</td></tr><tr><td>0.00</td><td>68.4±0.4</td><td>6.6±0.9</td><td>68.4 ± 0.4</td><td>6.6±0.9</td><td>68.4±0.4</td><td>6.6±0.9</td><td>68.4± 0.4</td><td>6.6±0.9</td><td>68.4±0.4</td><td>6.6±0.9</td></tr><tr><td rowspan="7">Pokec-z</td><td>0.05</td><td>68.8±0.4</td><td>6.4±0.6</td><td>67.4 ±0.5</td><td>6.6±0.3</td><td>68.1±0.3</td><td>2.2 ±0.4</td><td>68.7±0.4</td><td>6.7 ± 1.4</td><td>68.7±0.4</td><td>6.7 ± 1.4</td></tr><tr><td>0.10</td><td>68.7±0.3</td><td>8.0±0.6</td><td>66.5±0.2</td><td>6.3±0.8</td><td>67.7±0.4</td><td>13.5± 0.9</td><td>68.7±0.6</td><td>7.5±0.7</td><td>68.7±0.6</td><td>7.5±0.7</td></tr><tr><td>0.15</td><td>67.9 ±0.3</td><td>9.1 ±0.8</td><td>65.9 ±0.8</td><td>5.5±1.3</td><td>66.6 ±0.4</td><td>16.9 ± 2.6</td><td>69.0±0.8</td><td>8.5 ± 1.1</td><td>69.0±0.8</td><td>8.5 ± 1.1</td></tr><tr><td>0.20</td><td>68.5 ±0.4</td><td>9.3 ±1.0</td><td>62.9 ±0.7</td><td>8.7 ±1.0</td><td>66.1±0.2</td><td>25.4 ± 1.3</td><td>68.5±0.6</td><td>8.8 ±1.1</td><td>68.5±0.6</td><td></td></tr><tr><td>0.25</td><td>68.3± 0.5</td><td>7.3 ±0.5</td><td>63.9 ±0.4</td><td>6.0 ± 1.0</td><td>65.5± 0.6</td><td>22.3 ± 2.8</td><td>68.5 ± 1.1</td><td>8.6±2.5</td><td>68.5 ± 1.1</td><td>8.8 ±1.1</td></tr><tr><td>0.00</td><td>93.1 ±0.2</td><td>8.0±0.2</td><td>93.1 ±0.2</td><td>8.0 ±0.2</td><td>93.1± 0.2</td><td>8.0±0.2</td><td>93.1 ±0.2</td><td></td><td></td><td>8.6±2.5</td></tr><tr><td>0.05</td><td></td><td>8.1±0.0</td><td>91.6 ± 0.2</td><td>8.5±0.1</td><td>91.7 ± 0.1</td><td>10.0 ± 0.4</td><td></td><td>8.0±0.2</td><td>93.1 ± 0.2</td><td>8.0±0.2</td></tr><tr><td rowspan="5">Bail</td><td>0.10</td><td>92.7±0.2 92.2±0.2</td><td>7.8±0.2</td><td>90.3 ±0.1</td><td>8.5±0.1</td><td>90.5±0.0</td><td>10.3 ± 0.4</td><td>92.6 ± 0.1 92.4±0.1</td><td>8.6±0.1</td><td>92.5 ± 0.1</td><td>8.6±0.1</td></tr><tr><td>0.15</td><td>91.9±0.2</td><td>7.8±0.1</td><td>89.2±0.1</td><td>7.7±0.1</td><td>90.0±0.2</td><td>8.4±0.2</td><td>92.2±0.2</td><td>8.9±0.1</td><td>92.4 ± 0.1</td><td>8.6 ±0.1</td></tr><tr><td></td><td>91.6 ±0.2</td><td>7.8±0.1</td><td>88.3±0.1</td><td>8.3±0.1</td><td>89.7 ±0.1</td><td>7.4 ±0.4</td><td>92.2±0.2</td><td>9.1 ± 0.1</td><td>92.3 ±0.1</td><td>9.1 ± 0.1</td></tr><tr><td>0.20 0.25</td><td>91.4±0.1</td><td>8.3±0.1</td><td>87.8±0.0</td><td>7.8 ±0.1</td><td>89.8±0.2</td><td>5.2±0.2</td><td>92.1±0.1</td><td>9.3±0.1 9.1±0.2</td><td>92.3 ±0.1</td><td>9.3±0.2</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>92.1 ± 0.1</td><td>9.1 ±0.3</td></tr></table>
307
+
308
+ 267 methods,the victim models are set to GCN [26]. For each dataset, we use a fixed random seed to
309
+ 268 learn the poisoned graph corresponding to each baseline method. Then we train the victim model 5
310
+ 269 times with different random seeds.For fair comparison, we only attack the adjacency matrix in all
311
+ 270 experiments. Please refer to Appendix C for detailed experimental settings.
312
+
313
+ Main results.For FATE, we conduct fairness attacks via both edge flipping (FATE-flip in Table 5) and edge addition (FATE-add in Table 1). For all other baseline methods, edges are only added. The effectiveness of fairness attacks on GCN are presented in Tables 5.From both tables, we have the following key observations: (1) FATE-flip and FATE-add are the only methods that consistently succeeds in fairness attcks,while allother baseline methods might fail in some cases (indicated by the underlined $\Delta _ { \mathrm { S P } }$ in both tables) because of the decrease in $\Delta _ { \mathrm { S P } }$ . (2)FATE-flip and FATE-add can not only amplify $\Delta _ { \mathrm { S P } }$ consistently, but also achieve the best micro F1 score on node classification, which makes FATE-flip and FATE-add more deceptive than all baseline methods. Notably,FATE-flip and FATE-add are able to even increase micro F1 score on alldatasets, while other baseline methods attck the graph neural networks at the expense of utility (micro F1 score). (3) Though FA-GNN could make the model more biased in some cases, it cannot guarantee consistent success in fairness attacks on all three datasets as shown by the underlined $\Delta _ { \mathrm { S P } }$ in both tables.All in all,our proposed FATE framework is the framework that consistently succeeds in fairness atacks while being the most deceptive (i.e., highest micro F1 score).
314
+
315
+ Effect of the perturbation rate.From Table 1,we have the following observations. First, $\Delta _ { \mathrm { S P } }$ tends to increase when the perturbation rate increases, which demonstrates the effectiveness of FATE-flip and FATE-add for attacking fairness. Though in some cases $\Delta _ { \mathrm { S P } }$ might have a marginal decrease, FATE-flip and FATE-add still successfully attack the fairness compared with GCN trained on the benign graph by being larger to the $\Delta _ { \mathrm { S P } }$ when perturbation rate (Ptb.) is O. Second,FATE-flip and FATE-add are deceptive, meaning that the micro F1 scores is close to or even higher than the micro F1 scores on the benign graph compared with the corresponding metrics trained . In summary, across different perturbation rates,FATE-flip and FATE-add are both effective,i.e.,amplifying more bias with higher perturbation rate,and deceptive,i.e., achieving similar or even higher micro F1 score.
316
+
317
+ ![](images/9b1bc0ee3c320d0c0eda9b7d7dd45faa1f6ca76b655a99954b17aa73b94207f6.jpg)
318
+ Figure 1: Attacking statistical parity with FATE-flip. (a)Ratios of flipped edges that connect two nodes with same/different label or sensitive attribute (sens. atr.). (b) SL (abbreviation for same label) refers to the ratios of flipped edges whose two endpoints are both from the same class. SSA (abbreviation for same sensitive atribute)refers to the ratios of manipulated edges whose two endpoints are both from the same demographic group. Majority/minority classes are determined by spliting the training nodes based on their class labels. The protected group is the demographic group with fewer nodes.
319
+
320
+ 294 Analysis on the manipulated edges.Here, we aim to characterize the properties of edges that are
321
+ 295 flipped by FATE (i.e.,FATE-flip) in attcking statistical parity. The reason to only analyze FATE-flip is
322
+ 296 that the majority of edges manipulated by FATE-flip on al three datasets is by addition (i.e., flipping
323
+ 297 from non-existing to existing). Figure 1b suggests that, if the two endpoints of an manipulated edge
324
+ 298 share the same class label or same sensitive attribute value,these two endpoints are most likely from
325
+ 299 the minority class and protected group. Combining Figures la and 1b,FATE would significantly
326
+ 300 increase the number of edges that are incident to nodes in the minority class and/or protected group.
327
+
328
+ More experimental results.Due to the space limitation, we defer more experimental results on atacking statistical parity on graph neural networks in Appendix D. More specifically, we present the performance evaluation under different metrics,i.e.,Macro F1 and AUC,as wellas the effectiveness of FATE with a different victim model, i.e., FairGNN[11], which ensures statistical parity.
329
+
330
+ # 6.2Attacking Individual Fairness on Graph Neural Networks
331
+
332
+ Settings.To showcase the ability of FATE on atacking the individual fairness (Section 5), we further compare FATE with the same set of baseline methods (Random, DICE [46],FA-GNN [19]) on the same set of datasets (Pokec-n, Pokec-z, Bail).We follow the setings as in Section 5. We use the $5 0 \% / 2 5 \% / 2 5 \%$ splits for train/validation/test sets with GCN [26] being the victim model. For each dataset, we use a fixed random seed to learn the poisoned graph corresponding to each baseline method.Then we train the victim model 5 times with different random seeds. And each entry in the oracle pairwise node similarity matrix is computed by the cosine similarity of the corresponding rows in the adjacency matrix. That is, ${ \bf S } [ i , j ] = \cos ^ { } ( { \bf A } [ i , : ] , A [ j , : ] )$ , where cos () is the function to compute cosine similarity. For fair comparison, we only attack the adjacency matrix in all experiments. Please refer to Appendix C for detailed experimental settings.
333
+
334
+ Main results. Similarly,we test FATE with both edge flipping (FATE-flip in Table 2) and edge addition (FATE-add in Table 2), while all other baseline methods only add edges.From Table 2, we have two key observations.(1)FATE-flip and FATE-add are effective: theyare the only methods that could consistently attack individual fairness whereas all other baseline methods mostly fail to attack individual fairness.(2) FATE-flip and FATE-add are deceptive: they achieve comparable or even better utility on all datasets compared with the utility on the benign graph. Hence,FATE framework is able to achieve effective and deceptive attacks to exacerbate individual bias.
335
+
336
+ Effect of the perturbation rate.From Table 2, we obtain similar observations as in Section 6.1 for Bail dataset. While for Pokec-n and Pokec-z, the correlation between the perturbation rate (Ptb.) and the individual bias is weaker. One possble reason is that: for Pokec-n and Pokec-z,the discrepancy between the oracle pairwise node similarity matrix and the benign graph is larger. Since the individual bias is computed using the oracle pairwise node similarity matrix rather than the benign/poisoned adjacency matrix, higher perturbation rate to poison the adjacency matrix may have less impact on the computation of individual bias.
337
+
338
+ ![](images/50278114691d6972ce2482273db740281ec95f4130c6a85caa5d0eed9f3e4b85.jpg)
339
+ Figure 2: Attcking individual fairness with FATE-flip. (a) Ratios of flipped edges that connect two nodes with same/different label. (b) Ratios of flipped edges whose two endpoints are both from the majority/minority class. Majority/minority classes are formed by splitting the training nodes based on their class labels.
340
+
341
+ 30 Analysis on the manipulated edges. Similarly,since the majority of edges manipulated by FATE-flip
342
+ 31 is through addition, we only analyze FATE-flip here.From Figure 2, we can find out that FATE will
343
+ 32 manipulate edges from the same class (especially from the minority class). In this way,FATE would
344
+ 33 find edges that could increase individual bias and improve the utility of the minority class in order to
345
+ 34 make the fairness attack deceptive.
346
+
347
+ More experimental results. Due to the space limitation, we defer more experimental results on attacking individual fairness on graph neural networks in Appendix E.More specifically, we present the performance evaluation under different metrics,i.e., Macro F1 and AUC,as well as the effectiveness of FATE with a diferent victim model, i.e., InFoRM-GNN [20], which mitigates individual bias.
348
+
349
+ Table 2: Effectiveness of attcking individual fairness on GCN.FATE poisons the graph via both edge flipping (FATE-flip) and edge addition (FATE-add) while all other baselines poison the graph via edge addition.Higher is beter(↑) for micro F1 score (Micro F1) and InFoRM bias (Bias).Bold font indicates the success of fairness attack (i.e., bias is increased after attack) with the highest micro F1 score.Underlined cell indicates the failure of fairness attack (i.e., $\Delta _ { \mathrm { S P } }$ is decreased after attack).
350
+
351
+ <table><tr><td rowspan="2">Dataset</td><td rowspan="2">Ptb.</td><td colspan="2">Random</td><td colspan="2">DICE</td><td colspan="2">FA-GNN</td><td colspan="2">FATE-flip</td><td colspan="2">FATE-add</td></tr><tr><td>Micro F1(↑)</td><td>Bias(↑)</td><td>Micro F1(↑)</td><td>Bias(↑)</td><td>Micro F1(↑)</td><td>Bias(↑)</td><td>Micro F1(↑)</td><td>Bias(↑)</td><td>Micro F1(↑)</td><td>Bias (↑)</td></tr><tr><td rowspan="7">Pokec-n</td><td>0.00</td><td>67.5± 0.3</td><td>0.9±0.2</td><td>67.5±0.3</td><td>0.9±0.2</td><td>67.5±0.3</td><td>0.9±0.2</td><td>67.5±0.3</td><td>0.9±0.2</td><td>67.5±0.3</td><td>0.9±0.2</td></tr><tr><td>0.05</td><td>67.6±0.3</td><td>1.6 ±0.3</td><td>66.9 ±0.3</td><td>1.6 ± 0.2</td><td>67.8±0.5</td><td>1.9 ±0.2</td><td>67.8±0.3</td><td>1.2 ±0.4</td><td>67.6 ± 0.3</td><td>1.5 ± 0.6</td></tr><tr><td>0.10</td><td>67.2±0.5</td><td>1.4 ± 0.3</td><td>65.3±0.7</td><td>1.1 ± 0.1</td><td>67.4 ± 0.4</td><td>1.2 ±0.2</td><td>67.9 ±0.4</td><td>1.3 ± 0.3</td><td>67.7 ± 0.4</td><td>1.6 ± 0.4</td></tr><tr><td>0.15</td><td>67.2 ± 0.3</td><td>1.2 ± 0.4</td><td>63.9± 0.6</td><td>1.1 ± 0.2</td><td>66.1 ± 0.3</td><td>1.5±0.3</td><td>67.8±0.4</td><td>1.2 ± 0.2</td><td>67.6 ± 0.2</td><td>1.1 ±0.3</td></tr><tr><td>0.20</td><td>66.6±0.3</td><td>1.1 ±0.2</td><td>63.8± 0.1</td><td>0.8±0.1</td><td>65.7±0.6</td><td>1.5 ± 0.3</td><td>67.3 ± 0.4</td><td>1.1 ± 0.3</td><td>68.2± 1.0</td><td>1.7 ±0.8</td></tr><tr><td>0.25</td><td>66.7±0.3</td><td>1.3 ± 0.4</td><td>62.5± 0.4</td><td>0.6±0.0</td><td>65.2 ±0.5</td><td>1.3 ± 0.4</td><td>67.8±0.8</td><td>1.4 ±0.7</td><td>67.9±0.9</td><td>1.4±0.7</td></tr><tr><td>0.00</td><td>68.4 ± 0.4</td><td>2.6±0.7</td><td>68.4±0.4</td><td>2.6 ± 0.7</td><td>68.4 ± 0.4</td><td>2.6± 0.7</td><td>68.4 ± 0.4</td><td>2.6±0.7</td><td>68.4 ± 0.4</td><td>2.6±0.7</td></tr><tr><td rowspan="7">Pokec-z</td><td>0.05</td><td>69.0±0.4</td><td>3.4±0.5</td><td>67.1±0.5</td><td>2.7±1.0</td><td>68.1 ± 0.4</td><td>2.9±0.3</td><td>68.7±0.5</td><td>2.9 ±0.5</td><td>68.7± 0.4</td><td>3.1 ± 1.0</td></tr><tr><td>0.10</td><td>68.7 ±0.1</td><td>2.4 ±0.5</td><td>66.3± 0.6</td><td>1.7 ± 0.6</td><td>68.2 ±0.5</td><td>1.7 ± 0.5</td><td>69.0±0.6</td><td>2.9 ±0.6</td><td>69.0 ± 0.5</td><td>3.0±0.6</td></tr><tr><td>0.15</td><td>67.9 ±0.3</td><td>2.8±0.3</td><td>65.5±0.3</td><td>1.4 ± 0.3</td><td>67.0±0.5</td><td>1.3±0.2</td><td>68.6±0.5</td><td>2.9 ±0.6</td><td>69.0 ±0.7</td><td>2.7 ±0.4</td></tr><tr><td>0.20</td><td>67.9 ±0.3</td><td>2.2±0.6</td><td>64.2±0.4</td><td>0.7±0.3</td><td>66.1±0.1</td><td>1.6 ±0.5</td><td>68.8 ± 0.4</td><td>3.0 ± 0.4</td><td>69.2± 0.4</td><td>2.9 ±0.3</td></tr><tr><td>0.25</td><td>67.6±0.3</td><td>1.9±0.3</td><td>64.2±0.3</td><td>0.5±0.1</td><td>65.1±0.3</td><td>1.9 ±0.6</td><td>69.1 ±0.3</td><td>2.9±0.7</td><td>69.3±0.3</td><td>2.7±0.6</td></tr><tr><td>0.00</td><td>93.1±0.2</td><td>7.2 ±0.6</td><td>93.1 ± 0.2</td><td>7.2 ±0.6</td><td>93.1 ± 0.2</td><td>7.2 ±0.6</td><td>93.1 ± 0.2</td><td>7.2 ±0.6</td><td>93.1±0.2</td><td>7.2±0.6</td></tr><tr><td>0.05</td><td>92.1± 0.3</td><td>8.0±1.9</td><td>91.8±0.1</td><td>7.1 ± 1.1</td><td>91.2 ±0.2</td><td>5.6±0.7</td><td>93.0±0.3</td><td>7.8±1.0</td><td>92.9± 0.2</td><td>7.7±1.0</td></tr><tr><td rowspan="5">Bail</td><td>0.10</td><td>91.6 ± 0.1</td><td>7.3 ±1.2</td><td>90.3±0.1</td><td>6.1 ±0.6</td><td>90.3±0.1</td><td>5.1±0.4</td><td>93.0±0.1</td><td>8.0±0.7</td><td>92.9±0.2</td><td>7.9 ±0.8</td></tr><tr><td>0.15</td><td>91.3±0.1</td><td>6.5±0.9</td><td>89.4±0.0</td><td>4.8 ±0.1</td><td>89.8 ±0.1</td><td>5.2 ±0.1</td><td>93.1± 0.1</td><td>8.2 ±0.6</td><td>93.0±0.2</td><td>7.8 ±0.8</td></tr><tr><td>0.20</td><td>91.2 ±0.2</td><td>6.6±0.6</td><td>88.5±0.1</td><td>4.0±0.4</td><td>89.3 ± 0.1</td><td>5.3±0.4</td><td>93.1±0.1</td><td>7.9 ±0.6</td><td>93.1 ± 0.1</td><td>8.2±0.6</td></tr><tr><td>0.25</td><td>90.9 ±0.1</td><td>6.8±0.8</td><td>87.4±0.3</td><td>3.6±0.5</td><td>88.9 ±0.1</td><td>5.4±0.3</td><td>92.9 ±0.1</td><td>7.6±0.5</td><td>93.0±0.2</td><td>7.8 ±0.7</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>
352
+
353
+ # 7Related Work
354
+
355
+ Algorithmic fairness on graphs aims to obtain debiased graph learning results such that a predefined fairness definition can be satisfied with respect to the nodes/edges in the graph. Several definitions of the fairness has been studied so far. Group fairness in graph embedding can be ensured via several ways,including adversarial learning-based methods [5,11],random walk-based methods [36,25] and dropout-based methods [39]. Individual fairness on graphs can be ensured via Lipschitz regularization [20] and learning-to-rank [13]. Other than the aforementioned two fairness definitions, several other fairness definitions are studied in the context of graph learning, including counterfactual fairness [1,31],degree fairness [42,24,29],dyadic fairness [32,27]and max-min fairness [37, 43]. For a comprehensive review of related works, please refer to existing surveys [50,10,14]and tutorials [22,23]. It should be noted that our work aims to attack fairness (i.e., making the model more biased) rather than ensuring fairness as in the aforementioned literature.
356
+
357
+ Adversarial attacks on graphs aim to exacerbate the utility of graph learning models by perturbing the input graph topology and/or node features. Several approaches have been proposed to attack graph learning models, including reinforcement learning [12], bi-level optimization [51, 52],projected gradient descent [40, 48] and edge rewiring/flipping [4,31]. Other than adversarial attacks that worsen the utility of a graph learning model,a few efforts have been made to attack the fairness of a machine learning model for IID tabular data via label flipping [33],adversarial data injection [38,8], adversarial sampling [44]. Different from [38,33,8,44], we aim to poison the input graph via structural modifications on the topology rather than injecting adversarial data sample(s). The most related work to our proposed method is by Hussain et al.[19], which degrade the group fairness of graph neural networks by randomly injecting edges for nodes in different demographic groups and with different class labels. In contrast,our proposed method could attck any fairness definition for any graph learning models via arbitrary edge manipulation operations, as long as the bias function and the utility loss are differentiable.
358
+
359
+ # 8Conclusion
360
+
361
+ We study the problem of fairness attacks on graph learning models, whose goal is to amplify the bias while maintaining the utility on the downstream task.We formally define the problem as a bi-level optimization problem, where the upper-level optimization problem maximizes the bias function with respect to a user-defined fairness definition and the lower-level optimization problem minimizes a task-specific loss function. We then propose a meta learning-based framework named FATE to poison the input graph using the meta-gradient of the bias function with respect to the input graph. We instantiate FATEby attcking statistical parity on graph neural networks in a binary node classification problem with binary sensitive attributes. Empirical evaluation demonstrates that FATE is effective (consistently amplifying bias) and deceptive (achieving the highest micro F1 score).
362
+
363
+ 75References [1] Chirag Agarwal, Himabindu Lakkaraju, and Marinka Zitnik. Towards a unified framework for fair and stable graph representation learning. In Uncertainty in Artificial Intelligence, pages 2114-2124.PMLR,2021. [2] Joachim Baumann, Anik6 Hannak,and Christoph Heitz. Enforcing group fairness in algorithmic decision making: Utility maximization under suficiency. In 2O22 ACM Conference on Fairness, Accountability, and Transparency, pages 2315-2326, 2022. [3] Yoshua Bengio. Gradient-based optimization of hyperparameters. Neural computation, 12(8):1889-1900,2000. [4] Aleksandar Bojchevski and Stephan Gunnemann. Adversarial attacks on node embeddings via graph poisoning. In International Conference on Machine Learning, pages 695-7O4. PMLR, 2019. [5] Avishek Bose and William Hamilton. Compositional fairness constraints for graph embeddings. In International Conference on Machine Learning, pages 715-724. PMLR, 2019. [6] Consumer Financial Protection Bureau. CFPB targets unfair discrimination in consumerfinance. https://www.consumerfinance.gov/about-us/newsroom/ cfpb-targets-unfair-discrimination-in-consumer-finance/, 2022. [Online; accessed 13-April-2023]. [7] Yen-Chi Chen. A tutorial on kernel density estimation and recent advances. Biostatistics & Epidemiology,1(1):161-187, 2017. [8] Anshuman Chhabra, Adish Singla, and Prasant Mohapatra. Fairness degrading adversarial attacks against clustering algorithms. arXiv preprint arXiv:2110.12020, 2021. [9] Jaewoong Cho, Gyeongjo Hwang, and Changho Suh. A fair classifier using kernel density estimation. Advances in neural information processing systems, 33:15088-15099,2020. [10] Manvi Choudhary, Charlotte Laclau,and Christine Largeron. A survey on fairness for machine learning on graphs. arXiv preprint arXiv:2205.05396, 2022. [11] Enyan Dai and Suhang Wang. Say no to the discrimination: Learning fair graph neural networks with limited sensitive atribute information. In Proceedings of the 14th ACM International Conference on Web Search and Data Mining, pages 680-688, 2021. [12] Hanjun Dai, Hui Li, Tian Tian, Xin Huang,Lin Wang, Jun Zhu, and Le Song. Adversarial attack on graph structured data. In International conference on machine learning, pages 1115-1124. PMLR,2018. [13] Yushun Dong, Jian Kang, Hanghang Tong,and Jundong Li. Individual fairness for graph neural networks: A ranking based approach. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining, pages 300-310, 2021.
364
+ 10[14] Yushun Dong, Jing Ma, Chen Chen,and Jundong Li. Fairness in graph mining: A survey. arXiv preprint arXiv:2204.09888,2022. [15] Cynthia Dwork, Moritz Hardt, Toniann Pitass, Omer Reingold,and Richard Zemel. Fairness through awareness. In Proceedings of the 3rd innovations in theoretical computer science conference, pages 214-226,2012. [16]Michael Feldman, Sorelle A Friedler, John Moeller, Carlos Scheidegger, and Suresh Venkatasubramanian. Certifying and removing disparate impact. In proceedings of the 21th ACM SIGKDD international conference on knowledge discovery and data mining, pages 259-268, 2015.
365
+ 19[17] Chelsea Finn,Pieter Abbeel,and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International conference on machine learning, pages 1126-1135. PMLR,2017.
366
+ [18] Moritz Hardt, Eric Price, and Nati Srebro. Equality of opportunity in supervised learning. Advances in neural information processing systems, 29,2016.
367
+ [19] Hussain Hussain,Meng Cao, Sandipan Sikdar,Denis Helic, Elisabeth Lex,Markus Strohmaier, and Roman Kern. Adversarial inter-group link injection degrades the fairness of graph neural networks. arXiv preprint arXiv:2209.05957,2022.
368
+ [20] Jian Kang, Jingrui He, Ross Maciejewski,and Hanghang Tong. Inform: Individual fairness on graph mining. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 379-389,2020.
369
+ [21] Jian Kang and Hanghang Tong. N2n: Network derivative mining. In Proceedings of the 28th ACM International Conference on Information and Knowledge Management, pages 861-870, 2019.
370
+ [22] Jian Kang and Hanghang Tong.Fair graph mining.In Proceedings ofthe 3Oth ACM International Conference on Information & Knowledge Management, pages 4849-4852,2021.
371
+ [23] Jian Kang and Hanghang Tong. Algorithmic fairness on graphs: Methods and trends. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pages 4798-4799,2022.
372
+ [24] Jian Kang, Yan Zhu, Yinglong Xia, Jiebo Luo,and Hanghang Tong. Rawlsgcn: Towards rawlsian difference principle on graph convolutional network. In Proceedings of the ACM Web Conference 2022, pages 1214-1225,2022.
373
+ [25] Ahmad Khajehnejad,Moein Khajehnejad, Mahmoudreza Babaei, Krishna P Gummadi,Adrian Weler, and Baharan Mirzasoleiman. Crosswalk: Fairness-enhanced node representation learning. In Proceedings of the AAAl Conference on Artificial Intelligence, volume 36, pages 11963-11970,2022.
374
+ [26] Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In International Conference on Learning Representations,2017.
375
+ [27] Peizhao Li, Yifei Wang, Han Zhao, Pengyu Hong,and Hongfu Liu. On dyadic fairness: Exploring and mitigating bias in graph connections. In International Conference on Learning Representations,2021.
376
+ [28] Lydia TLiu, Sarah Dean, Esther Rolf, Max Simchowitz,and Moritz Hardt. Delayed impact of fair machine learning. In International Conference on Machine Learning, pages 3150-3158. PMLR,2018.
377
+ [29] Zemin Liu, Trung-Kien Nguyen, and Yuan Fang. On generalized degree fairness in graph neural networks. arXiv preprint arXiv:2302.03881,2023.
378
+ [30] Miguel López-Benitez and Fernando Casadevall. Versatile,accurate,and analytically tractable approximation for the gaussian q-function. IEEE Transactions on Communications,59(4):917- 922,2011.
379
+ [31] Yao Ma, Suhang Wang,Tyler Derr,Lingfei Wu,and Jiliang Tang. Graph adversarial attack via rewiring. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining, pages 1161-1169,2021.
380
+ [32] Farzan Masrour, Tyler Wilson, Heng Yan, Pang-Ning Tan,and Abdol Esfahanian. Bursting the filter bubble: Fairness-aware network link prediction. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pages 841-848,2020.
381
+ [33] Ninareh Mehrabi, Muhammad Naveed, Fred Morstatter, and Aram Galstyan.Exacerbating algorithmic bias through fairness attcks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pages 8930-8938,2021.
382
+ [34] Lawrence Page, Sergey Brin, Rajeev Motwani,and Terry Winograd. The pagerank citation ranking: Bringing order to the web. Technical report, Stanford InfoLab,1999.
383
+ 169[35] Flavien Prost,Hai Qian, Qiuwen Chen,Ed HChi,Jilin Chen,and Alex Beutel. Toward a better trade-off between performance and fairness with kernel-based distribution matching. arXiv preprint arXiv:1910.11779,2019.
384
+ 172[36] Tahleen Rahman, Bartlomiej Surma, Michael Backes,and Yang Zhang. Fairwalk: Towards fair graph embedding. In Proceedings of the 28th International Joint Conference on Artificial Intelligence, pages 3289-3295,2019.
385
+ 175[37] Aida Rahmattalabi,Phebe Vayanos,Anthony Fulginiti,Eric Rice,Bryan Wilder,Amulya Yadav, and Milind Tambe. Exploring algorithmic fairness in robust graph covering problems. Advances in Neural Information Processing Systems,32, 2019. [38] David Solans, Battista Biggio,and Carlos Castillo. Poisoning attcks on algorithmic fairness. In Machine Learning and Knowledge Discovery in Databases: European Conference, ECML PKDD 2020, Ghent, Belgium, September 14-18,2020,Proceedings,Part I, pages 162-177. Springer, 2021. [39] Indro Spineli, Simone Scardapane, Amir Hussain,and Aurelio Uncini. Fairdrop: Biased edge dropout for enhancing fairness in graph representation learning. IEEE Transactions on Artificial Intelligence,3(3):344-354,2021. [40] Mingjie Sun, Jian Tang,Huichen Li,Bo Li, Chaowei Xiao, Yao Chen,and Dawn Song. Data poisoning attack against unsupervised node embedding methods. arXiv preprint arXiv:1810.12881, 2018. [41] Jian Tang, Meng Qu, Mingzhe Wang,Ming Zhang, Jun Yan,and Qiaozhu Mei. Line: Largescale information network embedding. In Proceedings of the 24th international conference on world wide web, pages 1067-1077,2015. [42] Xianfeng Tang, Huaxiu Yao, Yiwei Sun, Yiqi Wang, Jiliang Tang, Charu Aggarwal, Prasenjit Mitra, and Suhang Wang. Investigating and mitigating degree-related biases in graph convolutional networks. In Proceedings of the 29th ACM International Conference on Information & Knowledge Management, pages 1435-1444,2020. [43] Alan Tsang,Bryan Wilder, Eric Rice,Milind Tambe,and Yair Zick. Group-fairness in influence maximization. In Proceedings of the 28th International Joint Conference on Artificial Intelligence, pages 5997-6005,2019.
386
+ 198[44] Minh-Hao Van, Wei Du, Xintao Wu,and Aidong Lu. Poisoning attacks on fair machine learning. In International Conference on Database Systems for Advanced Applications, pages 370-386. Springer, 2022. [45] Daixin Wang, Jianbin Lin, Peng Cui, Quanhui Jia, Zhen Wang, Yanming Fang, Quan Yu, Jun Zhou, Shuang Yang,and Yuan Qi. A semi-supervised graph atentive network for financial fraud detection. In 2019 IEEE International Conference on Data Mining (ICDM), pages 598-607. IEEE,2019.
387
+ 505[46] Marcin Waniek, Tomasz_P Michalak,Michael J Wooldridge,and Talal Rahwan.Hiding individuals and communities in a social network. Nature Human Behaviour,2(2):139-147, 2018.
388
+ 508[47] Felix Wu, Amauri Souza, Tianyi Zhang, Christopher Fifty, Tao Yu, and Kilian Weinberger. Simplifying graph convolutional networks. In International conference on machine learning, pages 6861-6871. PMLR,2019. [48] Kaidi Xu, Hongge Chen, Sijia Liu, Pin-Yu Chen, Tsui-Wei Weng,Mingyi Hong,and Xue Lin. Topology attack and defense for graph neural networks: An optimization perspective. In Proceedings of the 28th International Joint Conference on Artificial Intelligence, pages 3961-3967,2019.
389
+ ;15[49] Si Zhang,Dawei Zhou, Mehmet Yigit Yildirim, Scot Alcorn,Jingrui He,Hasan Davulcu,and Hanghang Tong. Hidden: Hierarchical dense subgraph detection with application to financial fraud detection. In Proceedings of the 20l7 SIAM International Conference on Data Mining, pages 570-578. SIAM,2017.
390
+ [50] Wenbin Zhang, Jeremy C Weiss,Shuigeng Zhou, and Toby Walsh. Fairness amidst non-iid graph data: A literature review. arXiv preprint arXiv:2202.07170, 2022.
391
+ [51] Daniel Zügner, Amir Akbarnejad,and Stephan Gunnemann. Adversarial attacks on neural networks for graph data. In Proceedings of the 24th ACM SIGKDD international conference on knowledge discovery & data mining, pages 2847-2856,2018.
392
+ [52] Daniel Zügner and Stephan Gunnemann. Adversarial attcks on graph neural networks via meta learning. In International Conference on Learning Representations, 2019.
md/dev/ti6fH3EhFkv/ti6fH3EhFkv.md ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TOWARDS A UNIFIED VIEW ON VISUAL PARAMETEREFFICIENT TRANSFER LEARNING
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Since the release of various large-scale natural language processing (NLP) pretrained models, parameter efficient transfer learning (PETL) has become a popular paradigm capable of achieving impressive performance on various downstream tasks. PETL aims at making good use of the representation knowledge in the pretrained large models by fine-tuning a small number of parameters. Recently, it has also attracted increasing attention to developing various PETL techniques for vision tasks. Popular PETL techniques such as Prompt-tuning and Adapter have been proposed for high-level visual downstream tasks such as image classification and video recognition. However, Prefix-tuning remains under-explored for vision tasks. In this work, we intend to adapt large video-based models to downstream tasks with a good parameter-accuracy trade-off. Towards this goal, we propose a framework with a unified view of PETL called visual-PETL (V-PETL) to investigate the effects of different PETL techniques, data scales of downstream domains, positions of trainable parameters, and other aspects affecting the tradeoff. Specifically, we analyze the positional importance of trainable parameters and differences between NLP and vision tasks in terms of data structures and pretraining mechanisms while implementing various PETL techniques, especially for the under-explored prefix-tuning technique. Based on a comprehensive understanding of differences between NLP and video data, we propose a new variation of prefix-tuning module called parallel attention (PATT) for video-based downstream tasks. An extensive empirical analysis on two video datasets via different frozen backbones has been carried and the findings show that the proposed PATT can effectively contribute to other PETL techniques. An effective scheme SwinBAPAT derived from the proposed V-PETL framework achieves significantly better performance than the state-of-the-art AdaptFormer-Swin with slightly more parameters and outperforms full-tuning with far less parameters.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Many vision tasks rely on fine-tuning pre-trained models to achieve good performance. One standard modus operandi of transfer learning consists of two steps: pre-train a model on a source domain and fine-tune the entire model on a target domain (Zhuang et al., 2020). Despite that prior works have achieved promising performance, such vanilla practice of fine-tuning is faced with challenges for adopting large models to downstream tasks. This full-tuning strategy requires one to update and store separate model parameters for different downstream tasks, which can be expensive and infeasible for the era of increasingly large models from EfficientNet-based (Pham et al., 2021) (480M parameters) to Transformer-based (Yu et al., 2022) (2, 100M parameters) ones. For such large models, making good use of shared parameter weights deployed on the cloud can be beneficial for edge devices such as autonomous vehicles, drones who are intensive in computing and battery resources (Yuan et al., 2022). Second, the full fine-tuning strategy relies on high-quality downstream data and can hardly adapt to unseen scenarios that have large distribution shift (Kumar et al., 2021), which is unlike the learning process of humans who can learn from few samples and generalize well to new circumstances. This issue has been researched in directions such as zero-shot learning, few-shot learning, and continual learning (Li et al., 2021a). Another popular strategy is fine-tuning the downstream task head, i.e., the last fully connected (FC) layer, to avoid tuning the whole backbone model, which usually leads to poor performance when the target domain is large in data scale (see Figure
12
+
13
+ 1). Given the paradigm of fine-tuning increasingly large models, how to transfer such large models with parameter-accuracy trade-off is a hot topic in various domains (Gusak et al., 2022; Sung et al., 2022; Lin et al., 2020; Houlsby et al., 2019).
14
+
15
+ Taking the video-based action recognition task as an example, it can be inconvenient for deploying such large models to edge devices such as an autonomous driving (Liu et al., 2019) and unmanned aerial vehicle (Li et al., 2021b) as they can heavily rely on the interaction with cloud services for adapting to new environments via active learning (Wang et al., 2021) or continual learning (Li et al., 2021a). Re-training large models on the cloud are usually not cost-effective due to the expensive overheads of storage and computational resources. Furthermore, these resources are limited on edge devices such as autonomous vehicles and unmanned aerial vehicles, making the sense for developing effective fine-tuning methods with proper parameter-accuracy trade-off that can be fine-tuned on edge devices and interacting with the large models deployed on the cloud.
16
+
17
+ There have been some pioneering works for the PETL of visual models such as AdaptFormer (Chen et al., 2022) and visual prompt tuning (VPT) (Jia et al., 2022). AdaptFormer is primarily proposed based on vision transformer (Zhai et al., 2022), representing one of the stateof-the-art large models for image-based tasks. The proposed adapter module directly brings from Houlsby et al. (2019) due to its convenience of being inserted to any models. Implementing with a large batch size of $1 , 0 2 4$ with 64 GPUs, Adaptformer shows promising parameter-accuracy trade-off on video data. However, such powerful computing resource is not realistic for the usage of edge devices. Meanwhile, whether the good trade-off can be maintained for small batch size remains under-explored. Inspired by the Prompting in NLP (Liu et al., 2021), VPT proposes visualprompt to fine-tune visual models for imagebased tasks. According to the empirical results in Chen et al. (2022), adapter modules achieves superior performance over VPT in the regimes of both self-supervised and supervised
18
+
19
+ ![](images/96b4e4c9e3245d17a30fb7582f32ebe5fa5ec09ee423113f29fc2ba44175259d.jpg)
20
+ Figure 1: Parameter-accuracy trade-off. Adapting backbone Swin-B (Liu et al., 2022) pre-trained on Kinetics 400 via different fine-tuning methods on the something-something v2 (Goyal et al., 2017) dataset. Our methods perform significantly better than the state-of-the-art AdaptFormer-Swin (Chen et al., 2022) (our implementation with batch size 16) with slightly more tunable parameters, and outperform full-tuning with increasing margins when using larger values of $d _ { b o t t l e }$ .
21
+
22
+ pre-training. Another concern of VPT is its modification to the original model parameters might affect the knowledge representation of backbone models. Hence, we do not continue to compare our method with VPT but comparing with the adapter on video-based downstream tasks.
23
+
24
+ Taking the recent inspiration of the mix-and-match adapter (MAM adapter) (He et al., 2022a) in NLP, we aim to propose a unified model for the vision domain, especially for video-based downstream tasks. He et al. (2022a) analyzed the unified view among PETL techniques such as prefixtuning, low-rank (LoRA) adaptation, and adapter, pointing out the similarity between prefix-tuning and adapter in terms of calculating the attention. The difference is that the former performs weighted addition while the latter ones is unweighted. Note that prefix-tuning has not ever been applied to visual tasks in the form of pure visual models due to the intrinsic differences regarding pre-training methods of NLP and vision models. Another obstacle of directly applying prefix-tuning to visual tasks is the structural difference between text and vision data (we further discuss this in Section 2.3). Considering the video-based action recognition task, we propose a new variation of the prefixtuning module called parallel attention (PATT) to adapt video-based pre-trained large models to downstream domains with varied data scales. The differences of our method comparing the original prefix-tuning in NLP are twofold: prefix calculation and the manner of insertion (see Figure 2[b] and Figure 3). Regarding the backbone model, we focus on Video Swin Transformer (Liu et al., 2022), one of the state-of-the-art vision models that bring competitive performance on large-scale action recognition datasets such as Kinetics 400 and 600 Kay et al. (2017).
25
+
26
+ Our main contributions can be threefold as follows:
27
+
28
+ 1. We analyze different PETL techniques using the backbone model Swin Video Transformer for video-based tasks, providing a unified view via our V-PETL framework and investigating the importance of the fine-tuning position.
29
+
30
+ 2. Based on the comprehensive understanding of intrinsic differences between NLP and video data regarding data structures and pre-training mechanisms, we leverage prefix-tuning to our V-PETL with a new variation called PATT.
31
+
32
+ 3. Upon extensive ablation experiments regarding various effect factors, we empirically validate the promising parameter-accuracy trade-off achieved by our adjustable and easy-to-use PATT module, contributing to the existing literature of PETL techniques.
33
+
34
+ # 2 UNIFIED FRAMEWORK
35
+
36
+ # 2.1 RECAP OF VIDEO SWIN TRANSFORMER
37
+
38
+ Video Swin Transformer (Liu et al., 2022) is formed with Transformer layers (a.k.a. stages) that are consisted with 3D Video Swin Transformer blocks. With varied layers, blocks, and channel sizes, the model can be formed as Swin-T, Swin-S, Swin-B, and Swin-L. The basic architecture of a 3D Swin Transformer block is shown in Figure 2, which is mainly composed of a 3D shifted window-based multi-head self-attention (3DSW-MSA) module and a fully connected feed-forward network (FFN) implemented with a 2-layer MLP. Layer normalization (LN) and residual connection are respectively performed before and after both FFN and 3DSW-MSA modules. One such Video Swin Transformer block can be represented as:
39
+
40
+ $$
41
+ \begin{array} { r l } & { \hat { \boldsymbol Z } ^ { l } = 3 \mathrm { D S W } \mathrm { - } \boldsymbol { \mathrm { M S A } } ( \boldsymbol { \mathrm { L N } } ( \boldsymbol { \boldsymbol { Z } } ^ { l - 1 } ) ) + \boldsymbol { Z } ^ { l - 1 } , } \\ & { \boldsymbol { Z } ^ { l } = \mathrm { F F N } ( \boldsymbol { \mathrm { L N } } ( \hat { \boldsymbol { Z } } ^ { l } ) ) + \hat { \boldsymbol { Z } } ^ { l } , } \end{array}
42
+ $$
43
+
44
+ where $\hat { \boldsymbol { z } } ^ { l }$ and $Z ^ { l }$ respectively indicate the output of 3DSW-MSA and FNN modules.
45
+
46
+ Given a video input sized $t \times w \times h \times 3$ , containing $t$ video frames with their heights and widths being $h$ and $w$ , respectively. The 3D patch for video data sized $2 \times 4 \times 4 \times 3$ is treated as a token. Then we will have ${ \begin{array} { l } { { \frac { t } { 2 } } \times { \frac { w } { 4 } } \times { \frac { h } { 4 } } } \end{array} }$ 3D tokens after a 3D patch partitioning layer. Given the 3D tokens sized $\begin{array} { r } { \frac { t } { 2 } \times \frac { w } { 4 } \times \frac { h } { 4 } } \end{array}$ and a 3D window with the size of $p \times m \times m$ , the self-attention module, using the regular window partition strategy, will partition the 3D tokens to $\begin{array} { r } { { \frac { t } { 2 p } } \times { \frac { w } { 4 m } } \times { \frac { h } { 4 m } } } \end{array}$ non-overlapping windows. For shifted 3D window, the partition is shifted along the temporal, height, and width dimensions by ${ \begin{array} { l } { { \frac { p } { 2 } } \times { \frac { m } { 2 } } \times { \frac { m } { 2 } } } \end{array} } $ . For example, if we have an input video sized $8 \times 2 2 4 \times 2 2 4 \times 3$ and a $8 \times 7 \times 7$ 3D window, after the patch embedding, we will have $4 \times 5 6 \times 5 6 ~ 3 \mathrm { D }$ tokens with each of them sized $2 \times 4 \times 4 \times 3$ . Without shifting, the non-overlapping window size will be $1 \times 8 \times 8 = 6 4 .$ Then through the 3D window shifted by $( 4 , 3 , 3 )$ , the number of 3D windows becomes $1 \times 9 \times 9 = 8 1$ .
47
+
48
+ The 3DSW-MSA module is formed with a 3D relative position bias Rp2×m2×m2 , each of which can be represented as:
49
+
50
+ $$
51
+ A t t e n t i o n ( \mathbf { 0 } , \mathbf { K } , \mathbf { V } ) = S o f t M a x \big ( \frac { \mathbf { 0 } \mathbf { K } ^ { T } } { \sqrt { d } } + \mathbf { B } \big ) \mathbf { V } ,
52
+ $$
53
+
54
+ where $\pmb { \mathsf { Q } } , \pmb { \mathsf { K } } , \pmb { \mathsf { V } } \in \mathbb { R } ^ { p \times m \times m \times d }$ are the query, key, and value matrices, $p \times m \times m$ is the number of tokens and $d$ is the dimension of the tokens. MSA simultaneously performs the attention mechanism for $n _ { h e a d }$ heads, where the $i$ th head can be parameterized by $W _ { q } ^ { ( i ) } , W _ { k } ^ { ( i ) }$ , ${ W _ { v } ^ { ( i ) } \in \mathbb { R } ^ { d \times 3 d } }$ , projecting the input $Z ^ { l - 1 }$ to queries, keys, and values. Given a matrix $\boldsymbol { C } \in \mathbb { R } ^ { \tilde { m } \times d }$ , $\widetilde { \boldsymbol { m } } = \boldsymbol { p } \times \boldsymbol { m } \times \boldsymbol { m }$ , for performing attention, the 3DSW-MSA can be calculated as:
55
+
56
+ $$
57
+ \begin{array} { c } { { 3 \mathrm { D S W - M S A } ( Z ^ { l - 1 } , C ) = C o n c a t ( h e a d _ { 1 } , . . . , h e a d _ { n } ) { \cal W } _ { o } , } } \\ { { h e a d _ { i } = A t t e n t i o n ( Z ^ { l - 1 } { \cal W } _ { q } ^ { ( i ) } , C { \cal W } _ { k } ^ { ( i ) } , C { \cal W } _ { v } ^ { ( i ) } ) , } } \end{array}
58
+ $$
59
+
60
+ where $W _ { o }$ is the parameters of a linear project layer. The FNN module is composed of two linear layers with a GELU activation function in between, which can be computed as:
61
+
62
+ $$
63
+ \mathrm { F F N } ( \hat { \boldsymbol { Z } } ^ { l } ) = \mathrm { G E L U } ( \mathrm { L N } ( \hat { \boldsymbol { Z } } ^ { l } ) W _ { 1 } + b _ { 1 } ) W _ { 2 } + b _ { 2 } ,
64
+ $$
65
+
66
+ where $W _ { 1 } \in \mathbb { R } ^ { d _ { h i d d e n } \times d }$ , $W _ { 2 } \in \mathbb { R } ^ { d \times d _ { h i d d e n } }$ , $\pmb { b } _ { 1 } \in \mathbb { R } ^ { d _ { h i d d e n } }$ , and $b _ { 2 } \in \mathbb { R } ^ { d }$ . The value of $d _ { h i d d e n }$ usually takes a large value (e.g., $d _ { h i d d e n } = 4 d$ ).
67
+
68
+ ![](images/f60735e5495b6a10a67e28e8f3097d15d011a8dacad8a620717ac680762eb919.jpg)
69
+ Figure 2: V-PETL: A unified view of visual PETL techniques. They bring trainable parameters to different positions of the backbone model with various manners. AdaptFormer and Prefix-tuning respectively perform at the MLP and 3DSW-MSA modules that can adjust the number of trainable parameters via the bottleneck size of down and up projections. While prompt-tuning performed at the layer-level can adjust the length of prompts to control the tuned parameters.
70
+
71
+ Prefix-tuning (Li & Liang, 2021): The prefix-tuning approach prepends learnable prefix tokens to the keys and values of the MSA module of the model (see Figure 2[b]). Specifically, two prefix matrices $P _ { k } , P _ { v } \in \mathbb R ^ { d _ { t o k e n } \times d }$ that are randomly initialized with $d _ { t o k e n }$ tokens and transformed from two linear layers (with parameters $W _ { p k } ^ { ( i ) } \in \mathbb { R } ^ { d \times d _ { m i d d l e } }$ and $W _ { p v } ^ { ( i ) } \in \mathbb { R } ^ { d _ { m i d l e } \times d } )$ and a Tanh layer in between are concatenated to the original key and value, leading the calculation of $h e a d _ { i }$ in Eq. 3 to:
72
+
73
+ $$
74
+ h e a d _ { i } = A t t e n t i o n ( Z ^ { l - 1 } W _ { q } ^ { ( i ) } , c o n c a t ( P _ { k } ^ { ( i ) } , C W _ { k } ^ { ( i ) } ) , c o n c a t ( P _ { v } ^ { ( i ) } , C W _ { v } ^ { ( i ) } ) ) ,
75
+ $$
76
+
77
+ where the concat is the concatenation performed along the token dimension to mimic the prefixtuning in NLP tasks. Here, a question regarding whether this direct implementation will work for the vision domain is raised (results are in Table 4). This direct implementation is empirically invalid and we make further modification on it in Section2.3.
78
+
79
+ Adapter (Chen et al., 2022): Inspired by the works of Houlsby et al. (2019); He et al. (2022a) for PETL in NLP tasks, adapter (Chen et al., 2022) has been directly used for vision tasks, showing promising performance using far less tunable parameters. The number of parameters of adapter is controlled by a parameter $d _ { b o t t l e }$ $\mathit { \check { d } } _ { b o t t l e } \ll d )$ ), adjusting the space size of a low-dimensional representation. The adapter module first uses a down-projection with $W _ { d o w n } \in \mathbb { R } ^ { d \times d _ { b o t t l e } }$ to project the feature to the lower-dimensional representation, followed by a ReLU activation function, and a up-projection with Wup ∈ Rdbottle×d.
80
+
81
+ $$
82
+ \begin{array} { r } { \widetilde { \pmb { Z } } ^ { l } = \mathrm { R e L U } ( \mathbf { L N } ( \hat { \pmb { Z } } ^ { l } ) \mathbf { W } _ { d o w n } ) \mathbf { W } _ { u p } , } \end{array}
83
+ $$
84
+
85
+ then two positions implementing adapter (parallel and sequential) can be respectively computed as:
86
+
87
+ $$
88
+ \begin{array} { r } { \pmb { Z } ^ { l } = \mathrm { F F N } ( \mathbf { L N } ( \hat { \pmb { Z } } ^ { l } ) ) + \hat { \pmb { Z } } ^ { l } + s \tilde { \pmb { Z } } ^ { l } , \qquad } \\ { a n d s \pmb { Z } ^ { l } = \mathrm { R e L U } ( \mathrm { F F N } ( \mathbf { L N } ( \hat { \pmb { Z } } ^ { l } ) ) \pmb { W } _ { d o w n } ) \pmb { W } _ { u p } + \hat { \pmb { Z } } ^ { l } , } \end{array}
89
+ $$
90
+
91
+ where $s$ is a scalar, controlling the effect of the adapter (will be ablated in experiments). According to Chen et al. (2022), the parallel implementation (see Figure 2[a]) empirically performs better.
92
+
93
+ Prompt-tuning (Jia et al., 2022): Prompt-tuning (see Figure $2 [ \mathrm { c } ] ,$ is inspired by the success of prompt-tuning that adapts large scale models to varied downstream NLP tasks. The idea of VPT (Jia et al., 2022) is to fine-tune a learnable matrix P l−1prom $P _ { p r o m p t } ^ { l - 1 } \in \mathbb { R } ^ { d _ { p r o m p t } \times d }$ , ${ d _ { p r o m p t } } < { d _ { t o k e n } } - 1$ for
94
+
95
+ the lth Transformer layer or all Transformer layers, which are known as shallow prompt and deep prompt, respectively.
96
+
97
+ $$
98
+ \begin{array} { r } { \hat { \boldsymbol { \mathsf { Z } } } ^ { l } = 3 \mathrm { D S W } \mathrm { - } \boldsymbol { \mathsf { M S A } } ( \mathrm { L N } ( [ \boldsymbol { x } ^ { l - 1 } , \boldsymbol { P } _ { p r o m p t } ^ { l - 1 } , \boldsymbol { \mathsf { Z } } ^ { l - 1 } ] ) ) + \boldsymbol { \mathsf { Z } } ^ { l - 1 } , } \end{array}
99
+ $$
100
+
101
+ where $x ^ { l - 1 } \in \mathbb { R } ^ { d }$ denotes the [CLS]’s embedding for the $l$ th layer’s input space, $P _ { p r o m p t } ^ { l - 1 }$ is implemented by overlapping the top $d _ { p r o m p t }$ tokens of $Z ^ { l - 1 }$ (Jia et al., 2022). While it has also been implemented in front of the $x ^ { l - 1 }$ (Chen et al., 2022).
102
+
103
+ Others: Other PETL techniques include ST-Adapter Pan et al. (2022), LoRA (Hu et al., 2022), and BitFit (Zaken et al., 2022). ST-Adapter mainly adapts image-text models pre-trained on large scale datasets such as 400M image-text pair proposed by CLIP (Radford et al., 2021) and the IG-3.6B used by SWAG (Singh et al., 2022) to video understanding downstream tasks, which matches and even outperforms full-tuning. LoRA approximates the optimization process by injecting learnable low-rank matrices into the attention module. This method does not show superior performance for NLP tasks in terms of parameter efficiency. Hence, we do not prioritize this direction in this work. BitFit only tunes the bias terms of the backbone models, making it very parameter-efficient.
104
+
105
+ # 2.3 REVISITING PREFIX-TUNING FOR VISUAL TASKS
106
+
107
+ The prefix implementation in NLP Li & Liang (2021); He et al. (2022a) can be regarded as prepending contextual information for downstream tasks, which is similar with the pre-training process aiming to predict masked words in the process of an inner loop (Brown et al., 2020). Considering the pre-training process of pure vision models, such direct implementation might not make sense for visual tasks. Although such autoregressive pre-training has been conducted in visual domain (He et al., 2022b; Tong et al., 2022), but adding prefix for a sentence input in NLP can be structurally different with the visual domain. Specifically, masked pixels in image or video data cannot be regarded as some word level semantic information (e.g., a subject or an action) as in the NLP.
108
+
109
+ Recall that the embedding state of prefix-tuning is randomly initiated, which is known as learnable prefix but can bring random noise that later turns out affecting the convergence of the fine-tuning downstream tasks. Hence, inspired by the connection between adapter and prefix (He et al., 2022a), we avoid such learnable prefix design with random initialization and propose a parallel attention (PATT) to the original attention module (see Figure 3). The adapter structure can effective control the number of trainable parameters via $d _ { b o t t l e }$ , which is similar with the effect of the middle dimension dmiddle of W (i)pk and $W _ { p v } ^ { ( i ) }$ for preparing the prefix. Specifically, for the lth layer, we use output of its previous layer $Z ^ { l - 1 }$ and project it to a pair of matrices $\boldsymbol { \dot { K _ { p } } } , \boldsymbol { V _ { p } } \in \mathbb { R } ^ { \tilde { m } \times d }$ via a similar mechanism of Eq. 6:
110
+
111
+ $$
112
+ K _ { p } , V _ { p } = \mathrm { T a n h } ( Z ^ { l - 1 } W _ { d o w n } ) W _ { u p } ,
113
+ $$
114
+
115
+ where Tanh is the activation function used for preparing the prefix, which can be replaced by other activation func
116
+
117
+ ![](images/d32ffd27ce18eb6c9874ee02bac32e6f8939e06524b342dbfc57e9adf4b4bb21.jpg)
118
+ Figure 3: Structure of PATT. Red parts are trainable parameters calculated by the same input for preparing query, key, and value (i.e., the output of the previous layer passing through a layer normalization layer $Z ^ { l - 1 }$ ).
119
+
120
+ tions such as RELU and GELU. Here, we follow the original prefix implementation as its value ranges from $- 1$ to 1. Given $K _ { p }$ and $V _ { p }$ , Eq. 5 can be rewritten as:
121
+
122
+ $$
123
+ h e a d _ { i } = A t t e n t i o n ( \boldsymbol Z ^ { l - 1 } \boldsymbol W _ { q } ^ { ( i ) } , \boldsymbol s \boldsymbol K _ { p } + \boldsymbol C \boldsymbol W _ { k } ^ { ( i ) } , \boldsymbol s V _ { p } + \boldsymbol C \boldsymbol W _ { v } ^ { ( i ) } ) ,
124
+ $$
125
+
126
+ where $s$ is a scalar for adjusting the effect of PATT. Note that without considering the physical meaning of such design, for PETL purpose, one can perform similar practise for any combinations of $\mathbf { \alpha } _ { \mathbf { Q } , \mathbf { \alpha } } \kappa$ , and $\pmb { \nu }$ . This brings connection to the LoRA (Hu et al., 2022) method, which add parallel trainable parameters to $\mathbf { Q }$ and $\pmb { \nu }$ . Empirically, where to perform the PATT makes little difference, but the amount of trainable parameters brings larger effect for large scale downstream domains.
127
+
128
+ # 2.4 V-PETL: UNIFIED VIEW ON VISUAL PETL
129
+
130
+ Given the PETL techniques at hand, there can be many potential combinations leading to good parameteraccuracy trade-off. However, it is unrealistic to exhaustively test all the methods for a specific downstream task. Other than probing such solution via evolutionary search as in Zhang et al. (2022), we aim to propose more understandable models by empirically analyzing the effect of different designs independently. According to the preliminary results shwon in Figure 1, we argue that the position and amount of parameters are important for PETL techniques, especially when the target domain is not small.
131
+
132
+ To verify the importance of position and tuned parameter amount, we independently tune different modules of the backbone model. Table 1 shows the results. We can see that the attention module’s QKV layer has 20.98M parameters while the MLP module has the most number of parameters of 55.90M. Tuning positions with more parameters, will lead to better performance for SSv2. Thanks to the bottleneck mechanism of adapter and prefix-tuning, one can effectively achieve a good parameter-accuracy trade-off. As such, we derive a model called Swin-B-adapter-PATT (Swin-BAPAT) from the V-PETL framework by using the parallel adapter and our PATT to leverage the adaption of pre-trained backbone model at the positions of attention and MLP modules, respectively. In addition to adapter and PATT, we also fine-tune the last fully connected layer as it has relatively smaller amount of tunable parameters (i.e, 0.18M) than adapter and PATT.
133
+
134
+ Table 1: Comparison of independently fine-tuning varied positions of the video swin transformer block on SSv2.
135
+
136
+ <table><tr><td>Position</td><td># Params</td><td>Top-1 (%)</td></tr><tr><td>Full-tuning Tune FC Layer</td><td>87.82M 0.18M</td><td>50.99 24.13</td></tr><tr><td>LayerNorm 1</td><td>0.02M</td><td>14.35</td></tr><tr><td>Attn,Proj</td><td>6.99M</td><td>47.58</td></tr><tr><td>Attn, QKV</td><td>20.98M</td><td>50.02</td></tr><tr><td>Attn, SoftMax</td><td>0.95M</td><td>27.67</td></tr><tr><td>LayerNorm 2</td><td>0.02M</td><td>14.62</td></tr><tr><td>MLP, FC1</td><td>27.97M</td><td>47.10</td></tr><tr><td>MLP,FC2</td><td>27.93M</td><td>45.32</td></tr><tr><td>DownSample</td><td>2.76M</td><td>27.53</td></tr></table>
137
+
138
+ # 3 EXPERIMENTS
139
+
140
+ # 3.1 EXPERIMENTAL SETTINGS
141
+
142
+ Video Datasets: Something-something v2 (SSv2 (Goyal et al., 2017)) It has 108,499 short videos for 174 human-object interaction categories with durations between 2 to 6 seconds. The challenge of this dataset is that it contains 23, 137 distinct object names with an imbalanced distribution. The original dataset is split into train, validation, and test sets with a ratio of 8:1:1. The extended version (SSv2) of this dataset is consisted of 168, 913 training samples, 24, 777 validation samples, and 27, 157 testing samples with the sample number of action labels. The training and testing samples are used. HMDB51 (Kuehne et al., 2011) contains 6, 766 video samples for 51 action categories including videos of varied visible body parts, camera motion, camera view, and clip quality. All video samples have at least 101 clips and a minimum height of 60 pixels for actors. The original dataset has three splits of training and evaluation. We follow existing work Chen et al. (2022) by using the first training and evaluation split that has 3, 570 and 1, 530 samples, respectively. Image Datasets: Following the experimental set ups in AdaptFormer, three datasets CIFAIR-100 Krizhevsky et al. (2009), Street View House Numbers (SVHN) Goodfellow et al. (2013), and Food101 Bossard et al. (2014) are used. CIFAIR-100 has 50, 000 and 10, 000 training and validation images, respectively, with the resolution of $3 2 \times 3 2$ and 100 categories; SVHN is a digit classification dataset that has 73, 257 training sample and 26, 032 testing samples; Food-101 includes 101k images of 101 food categories with each of them has 750 training and 250 testing samples.
143
+
144
+ Implementation details: It is worth noting that big batch size (i.e., 1, 024) and the number of input video frames (i.e., 32 frames) can greatly benefit good performance (Carreira & Zisserman, 2017; Liu et al., 2022; Chen et al., 2022), which usually requires GPU clusters to enable the training. AdaptFormer (Chen et al., 2022) uses such powerful GPU cluster to achieve good performance. However, good performance might not hold when the batch size is small. Following the more common hardware device setup, we use 4 GeForce 3090 GPUs for all experiments, leading to a batch size of 64. All the experiments are fine-tuned for 70 epochs. We use the Swin- $\mathbf { \cdot B } ^ { 1 }$ model pre-trained on Kinetics 400 and 600. For HMDB51, we report the results without tuning the FC layer due to the significant effect of the FC layer on relatively small scale dataset. Following Chen et al. (2022), we do not perform regularization strategies such as mixup, cutmix, color jittering, etc. Our PATT module is convenient to be applied to other Transformer-based models. Hence, we respectively adopt ViT-B models from MAE (He et al., 2022b) and VideoMAE (Tong et al., 2022) to conduct further comparison on video and image datasets, which follows the self-supervised pretraining setting2 in Chen et al. (2022) except that the batch size is set to 256 instead of 1, 024.
145
+
146
+ Table 2: Comparison of Top-1 accuracy using varied amount of parameters adjusted by $d _ { b o t t l e }$ different pre-training domains, and the number of frames with other fine-tuning strategies.
147
+
148
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">dbottle</td><td rowspan="2">Pre-training</td><td rowspan="2">#Frames</td><td colspan="2">SSv2</td><td colspan="2">HMDB51</td></tr><tr><td># Params Top-1(%)# Params Top-1 (%)</td><td></td><td></td><td></td></tr><tr><td>Full-tuning</td><td>-</td><td>Kinetics 400</td><td>8</td><td>87.82M</td><td>50.99</td><td>87.69M</td><td>68.07</td></tr><tr><td>Tune FC Layer</td><td></td><td>Kinetics 400</td><td>8</td><td>0.18M</td><td>24.13</td><td>0.05M</td><td>71.28</td></tr><tr><td>BitFit (Zaken et al., 2022)</td><td>·</td><td>Kinetics 400</td><td>8</td><td>1.29M</td><td>45.94</td><td>1.11M</td><td>68.26</td></tr><tr><td>AdaptFormer-Swin (Chen et al., 2022)64</td><td></td><td>Kinetics 400</td><td>8</td><td>1.73M</td><td>40.80</td><td>1.61M</td><td>68.66</td></tr><tr><td>Prefix-tuning (Li&amp; Liang,2021)</td><td>128</td><td>Kinetics 400</td><td>8</td><td>6.57M</td><td>39.46</td><td>6.40M</td><td>56.13</td></tr><tr><td>Our Swin-BAPAT (w/o Adapter)</td><td>32</td><td>Kinetics 400</td><td>8888</td><td>1.35M</td><td>46.26</td><td>1.17M</td><td>69.51</td></tr><tr><td>Our Swin-BAPAT (w/o Adapter)</td><td>64</td><td>Kinetics 400</td><td></td><td>2.51M</td><td>49.23</td><td>2.34M</td><td>71.34</td></tr><tr><td>Our Swin-BAPAT (w/o Adapter)</td><td>128</td><td>Kinetics 400</td><td></td><td>4.83M</td><td>52.57</td><td>4.65M</td><td>70.56</td></tr><tr><td>Our Swin-BAPAT (w/o Adapter)</td><td>256</td><td>Kinetics 400</td><td></td><td>9.45M</td><td>52.71</td><td>9.27M</td><td>70.23</td></tr><tr><td>Our Swin-BAPAT</td><td>32</td><td>Kinetics 400</td><td>8</td><td>2.91M</td><td>49.63</td><td>2.74M</td><td>68.20</td></tr><tr><td>Our Swin-BAPAT</td><td>64</td><td>Kinetics 400</td><td>8</td><td>4.07M</td><td>51.80</td><td>3.89M</td><td>70.10</td></tr><tr><td>Our Swin-BAPAT</td><td>128</td><td>Kinetics 400</td><td>8</td><td>6.38M</td><td>53.36</td><td>6.20M</td><td>71.93</td></tr><tr><td>Our Swin-BAPAT</td><td>256</td><td>Kinetics 400</td><td>8</td><td>11.00M</td><td>53.98</td><td>10.83M</td><td>69.64</td></tr><tr><td>Our Swin-BAPAT</td><td>256</td><td>Kinetics 400</td><td>8</td><td>11.00M</td><td>53.98</td><td>10.83M</td><td>69.64</td></tr><tr><td>Our Swin-BAPAT</td><td>256</td><td>Kinetics 600</td><td>8</td><td>11.00M</td><td>54.06</td><td>10.83M</td><td>69.90</td></tr><tr><td>Our Swin-BAPAT</td><td></td><td>256 ImageNet-22K</td><td>8</td><td>11.00M</td><td>43.56</td><td>10.83M</td><td>59.89</td></tr><tr><td>Our Swin-BAPAT</td><td>128</td><td>Kinetics 400</td><td>8</td><td>6.38M</td><td>53.36</td><td>6.20M</td><td>71.93</td></tr><tr><td>Our Swin-BAPAT</td><td>128</td><td>Kinetics 400</td><td>16</td><td>6.38M</td><td>63.14</td><td>6.20M</td><td>75.67</td></tr></table>
149
+
150
+ Baselines: We mainly compare our method Swin-BAPAT with three baselines as follows: (1) Full-tuning: set all the parameters learnable and tune the whole model initiated with the pretrained weights. (2) Tune FC layer: tune the last fully connected layer and freeze pre-trained parameters of the whole backbone model. (3) AdaptFormer-Swin: method introduced by Chen et al. (2022) that adds a parallel adapter to the MLP module in each block of the backbone model. (4) Prefix-tuning: the direct implementation of prefix-tuning used in NLP as defined in Eq. 5. (5) BitFit: by tuning the bias of the backbone model together with the FC layer.
151
+
152
+ # 3.2 THE EFFECT OF DIFFERENT PETL TECHNIQUES
153
+
154
+ Table 2 shows the results of different PETL techniques. From the results of four baseline methods, full-tuning performs the best for the large-scale dataset SSv2, whereas tuning the FC layer achieves superior performance over other PETL techniques on HMDB51. This is due to the fact that downstream tasks with relatively larger scale datasets are more parameter hungry for good convergence. On the contrary, small datasets can make good use of the knowledge from the source domain with slight effort of adaption via an FC layer. Here, a question regarding the effect of this FC layer when using it together with other PETL techniques has not been investigated. As this FC layer having small amount of tunable parameters can already make a big difference, performing better than fulltuning and other PETL techniques and rendering them not effective for small-scale datasets. As such, we further examine this question in Section A.1.
155
+
156
+ We test different amount of parameters adjusted by $s _ { b o t t l e }$ , taking its values to 32, 64, 128 and 256. The second and third groups (without or with Adapter, respectively) of results in Table 2 shows that larger values of $s _ { b o t t l e }$ can benefit the fine-tuning with slightly more overhead of parameters on large-scale datasets such as SSv2. All results of our Swin-BAPAT outperform the state-ofthe-art AdaptFormer-Swin with a big margin (using the smallest value $s _ { b o t t l e } = 3 2$ can improve AdaptFormer-Swin by almost $2 5 \%$ ). While without using Adapter, our method still outperforms baselines AdaptFormer-Swin and BitFit with roughly similar amount of parameters. When sbottle is larger than 64, our Swin-BAPAT starts to perform better than full-tuning on both datasets with proper parameter-accuracy trade-off, validating the effectiveness of our Swin-BAPAT for PETL.
157
+
158
+ ![](images/bfd8674c26a279b07e5eec991eb55a8d1b5100558500140751dfb357f84b103a.jpg)
159
+ Figure 4: Top-1 accuracy of different settings on SSv2 throughout training process. F: frame, S: scalar, B: $d _ { b o t t l e }$ , K: pre-training domain.
160
+
161
+ Table 3: Top-1 accuracy $( \% )$ using different scalar values on two datasets: SSv2 and HMDB51. The $d _ { b o t t l e }$ is set to 128; pretraining is based on Kinetics 400.
162
+
163
+ <table><tr><td>Scalar s</td><td>SSv2</td><td>HMDB51</td></tr><tr><td>Full-tuning</td><td>50.99</td><td>71.28</td></tr><tr><td>Tune FC Layer</td><td>24.13</td><td>68.07</td></tr><tr><td>AdaptFormer-Swin</td><td>40.80</td><td>68.66</td></tr><tr><td>s=0.2</td><td>47.46</td><td>69.38</td></tr><tr><td>s=0.5</td><td>52.84</td><td>71.87</td></tr><tr><td>s=0.8</td><td>53.36</td><td>71.93</td></tr><tr><td>s=1.0</td><td>53.29</td><td>70.89</td></tr></table>
164
+
165
+ # 3.3 THE EFFECT OF DIFFERENT PRE-TRAINING DOMAINS
166
+
167
+ The knowledge from the pre-trained model is learned from the source domain. We test two different models pre-trained on large-scale datasets: Kinetics 400, Kinetics 600, and ImageNet-22K. Findings show that both two models pre-trained on such large-scale datasets can benefit our proposed PETL strategy with the latter being slightly more significant (see the third group of comparison in Table 2). This is due to the fact that Kinectics 600 is larger than its 400 version and brings more knowledge to the pre-trained model, benefiting more downstream tasks. However, image-based pre-training cannot perform as good as video-based pre-training due to the larger domain gap.
168
+
169
+ # 3.4 THE EFFECT OF DIFFERENT VIDEO INPUT SIZE
170
+
171
+ We also test whether our method is robust to increased number of input video frames. It is worth noting that larger number of input video frames usually can bring more spatial temporal information, benefiting data-driven models to learn more distinguishable features while keeping the model size remaining the same. The last group of comparisons in Table 2 shows that using double-sized video input (i.e., 16 frames) can greatly improve the performance of action recognition on both small and large-scale datasets. The improvements (increased $9 . 7 8 \%$ from $5 3 . 3 6 \%$ to $6 3 . 1 4 \%$ on SSv2, and $3 . { \bar { 7 } } 4 \%$ from $7 1 . 9 3 \%$ to $7 5 . 6 7 \%$ on HMDB51) are more significant than other factors such as $d _ { b o t t l e }$ and pre-training domain (around $1 \%$ to $2 \%$ ). The top line in Figure 4 visualizes the significant effect of increasing the number of input video frames. These results suggest that our Swin-BAPAT can be promising for increased frames of video input.
172
+
173
+ # 3.5 THE EFFECT OF DIFFERENT SCALE OF PATT
174
+
175
+ Recall that the effect of our PATT on pretrained models can be adjusted by the variable $s$ in Eq. 10. Table 3 shows that adopting the value of 0.8 can deliver consistent best performances on both datasets SSv2 and HMDB51 under our experimental setting. Smaller values of $s$ will quantitatively reduce the effect of our PATT module on the knowledge transfer while large values will increase the effect of our PATT module. The good performance achieved via taking an effective scale of 0.8 indicates that our PATT module plays an important role in the knowledge transfer. However, even larger values over 0.8 can affect the importance of original knowledge thereof the pretrained model. Hence, proper valued scalar $s$ is essential for balancing the role of PATT and
176
+
177
+ Table 4: Ablation of different implementation positions of PATT defined in Eq. 10, e.g., Ours (K, $\boldsymbol { \mathsf { V } }$ ) indicates inserting PATT to the query and key of 3DSW-MSA modules. Pre-training on Kinetics 600. $d _ { b o t t l e }$ is set to 128; Scalar $s$ is set to 0.8.
178
+
179
+ <table><tr><td rowspan="2">Method</td><td colspan="2">SSv2</td><td colspan="2">HMDB51</td></tr><tr><td>#Params</td><td>Top-1</td><td># Params</td><td>Top-1</td></tr><tr><td>Full-tuning</td><td>87.82M</td><td>50.99</td><td>87.69M</td><td>68.07</td></tr><tr><td>Concat (K, V)</td><td>6.38M</td><td>15.61</td><td>6.20M</td><td>20.98</td></tr><tr><td>No Zl-1(K,V)</td><td>8.74M</td><td>51.06</td><td>8.56M</td><td>67.41</td></tr><tr><td>Ours (Q, K)</td><td>6.38M</td><td>45.49</td><td>6.20M</td><td>68.92</td></tr><tr><td>Ours (K, V)</td><td>6.38M</td><td>53.38</td><td>6.20M</td><td>71.41</td></tr><tr><td>Ours (Q, V)</td><td>6.38M</td><td>53.24</td><td>6.20M</td><td>71.74</td></tr><tr><td>Ours (Q, K, V)</td><td>7.93M</td><td>53.23</td><td>7.63M</td><td>69.57</td></tr></table>
180
+
181
+ pre-trained backbone model. Note this can be a learnable parameter upon specific implementation, here we empirically verified the effect of the scalar.
182
+
183
+ # 3.6 THE EFFECT OF DIFFERENT METHODS YIELD FROM V-PETL
184
+
185
+ We have argued that, especially for relative large downstream datasets, the position and the amount of trainable parameters are important for parameter-efficient transfer learning in Section 2.4. The proposed Swin-BAPAT is one of instantiated models from the V-PETL framework regarding the insert position of our PATT. Other instantiations can be inserted into different positions such as query, key, and value of the attention module. We further instantiate other variations of our Swin-BAPAT by inserting PATT to different positions. Table 4 shows the results. Findings show that inserting to the value position of 3DSW-MSA can contribute more than inserting to other two positions. While inserting to query of key makes little difference for the performance. This is due to the fact that query and key make the calculation of the attention mask. Hence, inserting either one of them will lead to a similar effect. On one hand, these results, to some extent, justify the original design of prefix-tuning that bring learnable prefix to key and value of the attention module. On the other hand, it indicates that our claim regarding the unified view of PETL for visual tasks is reasonable. In Table 4, we also ablate the designs of PATT regarding concatenating $K _ { p }$ and $V _ { p }$ (i.e., Concat $[ \mathsf { K } , \mathsf { v } ] )$ , and using trainable parameters to generate $K _ { p }$ and $\boldsymbol { V _ { p } }$ (i.e., N ${ \bf \nabla } ) \ Z ^ { l - 1 } ( { \bf K } , { \bf V } ] )$ .
186
+
187
+ # 3.7 COMPARISON ON VARIED TASKS VIA SELF-SUPERVISED PRE-TRAINED MODELS
188
+
189
+ Table 5 shows the comparison with AdaptFormer-64 (Chen et al., 2022) and VPT (Jia et al., 2022) on both image- and video-based downstream tasks. Our method ViT-BAPAT still shows promising parameter-accuracy trade-off via much smaller batch size, which is more convenient for reproduction on the general single server with 8 GPUs. The underperformance on SSv2 (better than full-tuning) can be due to the smaller batch size as SSv2 is much larger than other compared datasets and can be more relying on larger batch size. In real-world application scenarios, small dataset can be the more common case, which confirms our contributions.
190
+
191
+ Table 5: Comparison of Top-1 accuracy via ViT-B models from MAE and VideoMAE pre-trained with self-supervised learning for image and video datasets, respectively.
192
+
193
+ <table><tr><td rowspan="2"> Method</td><td>Avg.</td><td></td><td>Image</td><td></td><td colspan="2">Video</td></tr><tr><td>Params (M)</td><td>CIFAR-100</td><td>SVHN</td><td>Food-101</td><td>SSv2</td><td>HMDB51</td></tr><tr><td>Full-tuning</td><td>86.04 (100%)</td><td>85.90</td><td>97.67</td><td>90.09</td><td>53.97</td><td>46.41</td></tr><tr><td>Tune FC Layer</td><td>0.07 (0.08%)</td><td></td><td></td><td>69.83 (-16.07) 66.91 (-30.76) 69.74 (-20.35)</td><td>29.23 (-24.74)</td><td>)49.84 (+3.43)</td></tr><tr><td>VPT (Jia et al.,2022)</td><td>0.08 (0.09%)</td><td>82.44 (-3.46)</td><td>94.02 (-3.65)</td><td>82.98 (-7.11)</td><td>43.73 (-10.24)</td><td>52.67 (+6.26)</td></tr><tr><td>AdaptFormer-64</td><td>1.26 (1.46%)</td><td>85.90 (0.00)</td><td>96.89 (-0.78)</td><td>87.61 (-2.48)</td><td>59.02 (+5.05)</td><td>55.69 (+9.28)</td></tr><tr><td>Our ViT-BAPAT-32</td><td>2.13 (2.47%)</td><td>86.29 (+0.39)</td><td>97.18 (-0.49)</td><td>87.37 (-2.72)</td><td>57.78 (+3.81)</td><td>57.18 (+10.77)</td></tr><tr><td>Our ViT-BAPAT-64</td><td>3.02 (3.51%)</td><td>86.35 (+0.45)</td><td>97.18 (-0.49)</td><td>87.53 (-2.56)</td><td>57.55 (+3.58)</td><td>57.18 (+10.77)</td></tr><tr><td>Our ViT-BAPAT-128</td><td>4.79 (5.56%)</td><td>86.47 (+0.57)</td><td>97.28 (-0.39)</td><td>87.66 (-2.43)</td><td>56.97 (+3.00)</td><td>57.70 (+11.29)</td></tr><tr><td>Our ViT-BAPAT-256</td><td>8.33 (9.68%)</td><td>86.55 (+0.65)</td><td>97.24 (-0.43)</td><td>87.68 (-2.41)</td><td>56.53 (+2.56)</td><td>57.31 (+10.90)</td></tr></table>
194
+
195
+ # 4 CONCLUSION
196
+
197
+ In this paper, we introduced a V-PETL framework for exploiting good parameter-accuracy tradeoff around adapting video-based pre-trained large models to downstream tasks. Our Swin-BAPAT method derived from the V-PETL with a variation of prefix-tuning known as PATT can effectively bring good parameter-accuracy trade-off on downstream tasks. The proposed PATT can be easily plugged to the attention module of other transformer-like models. Meanwhile, the amount of trainable parameter can be easily adjusted by the parameter $d _ { b o t t l e }$ . With small amount overhead on trainable parameters, our method performs significantly better than state-of-the-art method AdapFormer-Swin and full-tuning on the datasets SSv2 and HMDB51 via small batch size, validating our contribution to the literature of PETL. In the future we will test our proposed model on more action recognition datasets surveyed in Sun et al. (2022) under more learning regimes such as zero/few-shot learning, active learning and continual learning with other pre-training methods such as visual-language models. We will also explore other backbone models, activation functions for PATT, and PETL techniques such as LoRA for visual tasks.
198
+
199
+ # REFERENCES
200
+
201
+ Lukas Bossard, Matthieu Guillaumin, and Luc Van Gool. Food-101–mining discriminative components with random forests. In European conference on computer vision, pp. 446–461. Springer, 2014.
202
+
203
+ 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.
204
+
205
+ Joao Carreira and Andrew Zisserman. Quo vadis, action recognition? a new model and the kinetics dataset. In proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6299–6308, 2017.
206
+
207
+ Shoufa Chen, Chongjian Ge, Zhan Tong, Jiangliu Wang, Yibing Song, Jue Wang, and Ping Luo. Adaptformer: Adapting vision transformers for scalable visual recognition. arXiv preprint arXiv:2205.13535, 2022.
208
+
209
+ Ian J Goodfellow, Yaroslav Bulatov, Julian Ibarz, Sacha Arnoud, and Vinay Shet. Multi-digit number recognition from street view imagery using deep convolutional neural networks. arXiv preprint arXiv:1312.6082, 2013.
210
+
211
+ Raghav Goyal, Samira Ebrahimi Kahou, Vincent Michalski, Joanna Materzynska, Susanne Westphal, Heuna Kim, Valentin Haenel, Ingo Fruend, Peter Yianilos, Moritz Mueller-Freitag, et al. The” something something” video database for learning and evaluating visual common sense. In Proceedings of the IEEE international conference on computer vision, pp. 5842–5850, 2017.
212
+
213
+ Julia Gusak, Daria Cherniuk, Alena Shilova, Alexandr Katrutsa, Daniel Bershatsky, Xunyi Zhao, Lionel Eyraud-Dubois, Oleh Shliazhko, Denis Dimitrov, Ivan Oseledets, and Olivier Beaumont. Survey on efficient training of large neural networks. In Lud De Raedt (ed.), Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence, IJCAI-22, pp. 5494–5501. International Joint Conferences on Artificial Intelligence Organization, 7 2022. doi: 10.24963/ ijcai.2022/769. URL https://doi.org/10.24963/ijcai.2022/769. Survey Track.
214
+
215
+ Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. In International Conference on Learning Representations, 2022a. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ 0RDcd5Axok.
216
+
217
+ Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollar, and Ross Girshick. Masked au-´ toencoders are scalable vision learners. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16000–16009, 2022b.
218
+
219
+ Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. In International Conference on Machine Learning, pp. 2790–2799. PMLR, 2019.
220
+
221
+ Edward J Hu, yelong shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum? id=nZeVKeeFYf9.
222
+
223
+ Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. arXiv preprint arXiv:2203.12119, 2022.
224
+
225
+ Will Kay, Joao Carreira, Karen Simonyan, Brian Zhang, Chloe Hillier, Sudheendra Vijayanarasimhan, Fabio Viola, Tim Green, Trevor Back, Paul Natsev, et al. The kinetics human action video dataset. arXiv preprint arXiv:1705.06950, 2017.
226
+
227
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
228
+
229
+ Hildegard Kuehne, Hueihan Jhuang, Est´ıbaliz Garrote, Tomaso Poggio, and Thomas Serre. Hmdb: a large video database for human motion recognition. In 2011 International conference on computer vision, pp. 2556–2563. IEEE, 2011.
230
+
231
+ Ananya Kumar, Aditi Raghunathan, Robbie Matthew Jones, Tengyu Ma, and Percy Liang. Finetuning can distort pretrained features and underperform out-of-distribution. In International Conference on Learning Representations, 2021.
232
+
233
+ Tianjiao Li, Qiuhong Ke, Hossein Rahmani, Rui En Ho, Henghui Ding, and Jun Liu. Else-net: Elastic semantic network for continual action recognition from skeleton data. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 13434–13443, 2021a.
234
+
235
+ Tianjiao Li, Jun Liu, Wei Zhang, Yun Ni, Wenqian Wang, and Zhiheng Li. Uav-human: A large benchmark for human behavior understanding with unmanned aerial vehicles. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 16266–16275, 2021b.
236
+
237
+ Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 4582–4597, 2021.
238
+
239
+ Zhaojiang Lin, Andrea Madotto, and Pascale Fung. Exploring versatile generative language model via parameter-efficient transfer learning. In Findings of the Association for Computational Linguistics: EMNLP 2020, pp. 441–459, 2020.
240
+
241
+ Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. Pretrain, prompt, and predict: A systematic survey of prompting methods in natural language processing. arXiv preprint arXiv:2107.13586, 2021.
242
+
243
+ Shaoshan Liu, Liangkai Liu, Jie Tang, Bo Yu, Yifan Wang, and Weisong Shi. Edge computing for autonomous driving: Opportunities and challenges. Proceedings of the IEEE, 107(8):1697–1716, 2019.
244
+
245
+ Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video swin transformer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3202–3211, 2022.
246
+
247
+ Junting Pan, Ziyi Lin, Xiatian Zhu, Jing Shao, and Hongsheng Li. St-adapter: Parameter-efficient image-to-video transfer learning for action recognition. arXiv preprint arXiv:2206.13559, 2022.
248
+
249
+ Hieu Pham, Zihang Dai, Qizhe Xie, and Quoc V Le. Meta pseudo labels. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11557–11568, 2021.
250
+
251
+ Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pp. 8748–8763. PMLR, 2021.
252
+
253
+ Mannat Singh, Laura Gustafson, Aaron Adcock, Vinicius de Freitas Reis, Bugra Gedik, Raj Prateek Kosaraju, Dhruv Mahajan, Ross Girshick, Piotr Dollar, and Laurens van der Maaten. Revisiting ´ weakly supervised pre-training of visual perception models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 804–814, 2022.
254
+
255
+ Zehua Sun, Qiuhong Ke, Hossein Rahmani, Mohammed Bennamoun, Gang Wang, and Jun Liu. Human action recognition from various data modalities: A review. IEEE transactions on pattern analysis and machine intelligence, 2022.
256
+
257
+ Yi-Lin Sung, Jaemin Cho, and Mohit Bansal. Vl-adapter: Parameter-efficient transfer learning for vision-and-language tasks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5227–5237, 2022.
258
+
259
+ Zhan Tong, Yibing Song, Jue Wang, and Limin Wang. Videomae: Masked autoencoders are dataefficient learners for self-supervised video pre-training. arXiv preprint arXiv:2203.12602, 2022.
260
+
261
+ Xiaohan Wang, Linchao Zhu, Heng Wang, and Yi Yang. Interactive prototype learning for egocentric action recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 8168–8177, 2021.
262
+
263
+ Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models. arXiv preprint arXiv:2205.01917, 2022.
264
+
265
+ Sha Yuan, Hanyu Zhao, Shuai Zhao, Jiahong Leng, Yangxiao Liang, Xiaozhi Wang, Jifan Yu, Xin Lv, Zhou Shao, Jiaao He, et al. A roadmap for big model. arXiv preprint arXiv:2203.14101, 2022.
266
+
267
+ Elad Ben Zaken, Yoav Goldberg, and Shauli Ravfogel. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 1–9, 2022.
268
+
269
+ Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12104–12113, 2022.
270
+
271
+ Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. Neural prompt search. arXiv preprint arXiv:2206.04673, 2022.
272
+
273
+ Fuzhen Zhuang, Zhiyuan Qi, Keyu Duan, Dongbo Xi, Yongchun Zhu, Hengshu Zhu, Hui Xiong, and Qing He. A comprehensive survey on transfer learning. Proceedings of the IEEE, 109(1): 43–76, 2020.
274
+
275
+ # A APPENDIX
276
+
277
+ A.1 THE EFFECT OF FC LAYER FOR SMALL SCALE DOWNSTREAM TASKS
278
+
279
+ Table 6: Results of with or without tuning the FC layer on the small scale dataset HMDB51.
280
+
281
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">dbottle</td><td rowspan="2">Pre-training</td><td rowspan="2">#Frames</td><td colspan="2">with FC layer</td><td colspan="2">without FC layer</td></tr><tr><td>#Params</td><td>Top-1 (%)</td><td>#Params</td><td>Top-1 (%)</td></tr><tr><td>Our Swin-BAPAT</td><td>32</td><td>Kinetics 400</td><td>8</td><td>2.79M</td><td>65.97</td><td>2.74M</td><td>68.20</td></tr><tr><td>Our Swin-BAPAT</td><td>64</td><td>Kinetics 400</td><td>8</td><td>3.94M</td><td>67.28</td><td>3.89M</td><td>70.10</td></tr><tr><td>Our Swin-BAPAT</td><td>128</td><td>Kinetics 400</td><td>8</td><td>6.25M</td><td>66.75</td><td>6.20M</td><td>71.93</td></tr><tr><td>Our Swin-BAPAT</td><td>256</td><td>Kinetics 400</td><td>8</td><td>10.88M</td><td>67.67</td><td>10.83M</td><td>69.64</td></tr><tr><td>Our Swin-BAPAT</td><td>256</td><td>Kinetics 400</td><td>8</td><td>10.88M</td><td>67.67</td><td>10.83M</td><td>69.64</td></tr><tr><td>Our Swin-BAPAT</td><td>256</td><td>Kinetics 600</td><td>8</td><td>10.88M</td><td>67.41</td><td>10.83M</td><td>69.90</td></tr><tr><td>Our Swin-BAPAT</td><td>128</td><td>Kinetics 400</td><td>8</td><td>6.25M</td><td>66.75</td><td>6.20M</td><td>71.93</td></tr><tr><td>Our Swin-BAPAT</td><td>128</td><td>Kinetics 400</td><td>16</td><td>6.25M</td><td>70.56</td><td>6.20M</td><td>75.67</td></tr><tr><td>Our Swin-BAPAT</td><td>128</td><td>Kinetics 400</td><td>32</td><td>6.25M</td><td>74.82</td><td>6.20M</td><td>76.46</td></tr></table>
282
+
283
+ For the small dataset HMDB51, due to the good parameter-accuracy trade-off achieved by finetuning the FC layer only, adding the FC layer cannot bring extra improvement to our proposed method. Without sufficient taining data, full-tuning also cannot perform well (see results in Table 2). As such, small datasets do not need to rely on large models but can make use of large models with light transfer. Instead, without tuning the FC layer, our Swin-BAPAT can perform better than fine-tuning the FC layer with small amount of extra trainable parameters (see results in Table 6), validating the good parameter-accuracy trade-off of our method.
md/dev/tjFaqsSK2I3/tjFaqsSK2I3.md ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A Unified Sequence Interface for Vision Tasks
2
+
3
+ Ting Chen† Saurabh Saxena† Lala Li† Tsung-Yi Lin∗ David J. Fleet Geoffrey Hinton Google Research, Brain Team {iamtingchen,srbs,lala}@google.com
4
+
5
+ # Abstract
6
+
7
+ While language tasks are naturally expressed in a single, unified, modeling framework, i.e., generating sequences of tokens, this has not been the case in computer vision. As a result, there is a proliferation of distinct architectures and loss functions for different vision tasks. In this work we show that a diverse set of “core” computer vision tasks can also be unified if formulated in terms of a shared pixelto-sequence interface. We focus on four tasks, namely, object detection, instance segmentation, keypoint detection, and image captioning, all with diverse types of outputs, e.g., bounding boxes or dense masks. Despite that, by formulating the output of each task as a sequence of discrete tokens with a unified interface, we show that one can train a neural network with a single model architecture and loss function on all these tasks, with no task-specific customization. To solve a specific task, we use a short prompt as task description, and the sequence output adapts to the prompt so it can produce task-specific output. We show that such a model can achieve competitive performance compared to well-established task-specific models.
8
+
9
+ # 1 Introduction
10
+
11
+ Training a single neural network model capable of performing myriad tasks is a major step towards artificial general intelligence. In recent years, with the rise of big language models [34, 35, 2] using Transformers [41], many different language and related tasks are unified under a single modeling framework, where a language model is trained to predict the solution (in text tokens) given a prompt of a task description (also in text tokens). This is only possible because these tasks (both task description and solution) can be expressed in the same, rich language interface.
12
+
13
+ This can be naturally extended to some vision tasks such as image captioning or visual question answering where the solution is given in natural language, but the majority of “core” computer vision tasks have diverse outputs that are not readily expressed in terms of natural language. The object detection task produces a set of bounding boxes and their corresponding class labels, often associated with scores for ranking. The output for instance segmentation is a set of segmentation masks corresponding to image regions. The output of keypoint detection is a set of keypoints in an image. As such, existing methods [13, 37, 15, 28, 4, 15] have developed specialized architectures and sophisticated loss functions for each of these complex tasks.
14
+
15
+ An ambitious goal, in the pursuit of artificial general intelligence, is a simple interface that allows one to express seemingly disparate vision tasks in a unified framework. This would simplify the design of architectures and loss functions for new tasks. It would enable greater degrees of feature/representation sharing across many different tasks, thereby avoiding the need for a sophisticated output head for each task. It would also facilitate adapting of existing models to new tasks, and potentially unlock new capabilities with zero or few demonstrations.
16
+
17
+ ![](images/f12ed378ad7aea377c8c67d9923bbb82e38e335f0f16daf28272af133288b082.jpg)
18
+ Figure 1: An illustration of the proposed framework. An image and a sequence of task prompt is given, the model produce a sequence of discrete tokens corresponding to the desired output.
19
+
20
+ To this end, we propose an approach to unify four seemingly different vision tasks in a single pixel-to-sequence interface. In effect, this is an extension of Pix2Seq [7] for object detection to a broader set of tasks. As a proof of concept, we focus on four core vision tasks, namely, object detection, instance segmentation, human keypoint detection, and image captioning. We first show how to unify these tasks into a single shared interface, and then train a neural network with a shared architecture and objective function. To solve a specific task, instead of using a specific head for that task, we use a prompt to specify the task, and the sequence output adapts to the prompt so it can produce task-specific output given the task description. This makes multi-task learning more efficient and scalable. We conduct experiments on the challenging COCO dataset, and show that it can simultaneously solve all four tasks well, without specialized architectures or loss functions.
21
+
22
+ # 2 Approach
23
+
24
+ In our approach, we cast computer vision tasks as one of translating pixel inputs (along with some descriptions of the task) into sequences of discrete tokens (see Figure 1). As a proof of concept, we focus on four core vision tasks: object detection, instance segmentation, keypoint detection, and image captioning; but we believe it is relatively straightforward to include many more tasks.
25
+
26
+ # 2.1 A unified interface with tokenization
27
+
28
+ The vision tasks we consider are diverse, and traditionally have been formulated quite differently. Object detection requires the model to produce bounding boxes for all objects without duplication. Instance segmentation requires the model to produce a dense pixel-wise mask for each identified object instance. Human keypoint detection requires the model to generate points corresponding to specific positions of landmarks on body parts for person instances (e.g., head, eyes). Image captioning requires the model to produce a sequence of words corresponding to a natural language description of the image. Given the significant differences in the form of the outputs, customized models with specialized architectures and loss functions are designed for each task.
29
+
30
+ To solve these tasks using a single model, we advocate the transformation/tokenization of task inputs and outputs into a unified interface. In this work, we propose a sequence interface for the purpose, where both task descriptions and outputs are expressed as sequences of discrete tokens:
31
+
32
+ ![](images/38ea3c2b6f2550fdf8967360a4fb651675ffd84f8bdbab9649972a9ccd18d889.jpg)
33
+ Figure 2: An illustration of sequence interface for four tasks. The model takes input image, task prompt tokens and produce task output tokens, which can be decoded/detokenized into required task output for visualization.
34
+
35
+ - For object detection, we follow [7] and convert bounding boxes and object descriptions into a sequence of discrete tokens by quantizing the continuous image coordinates. Specifically, an object is represented as a sequence of five discrete tokens, i.e. $[ y _ { \mathrm { m i n } } , x _ { \mathrm { m i n } } , y _ { \mathrm { m a x } } , x _ { \mathrm { m a x } } , c ]$ , and multiple objects are randomly ordered each time a training image is sampled and serialized into a single sequence.
36
+
37
+ - For instance segmentation, instead of per-pixel masks, we predict the polygon [5] corresponding to the instance masks as a sequence of image coordinates conditioned on a given object instance. Again, we quantize the coordinates into discrete tokens. And to turn polygon into a sequence, we randomly select a starting point for the start token each time a training image is sampled. If there are multiple polygons for the same instance, we concatenate sequences of individual polygons with a separator token in between, so that every instance has a single corresponding sequence.
38
+
39
+ - For keypoint prediction, we predict a set of keypoints as a sequence of quantized image coordinates conditioned on a given person instance. Specifically, the sequence of keypoints can be encoded as [ykeypoint 1, xkeypoint 1, ykeypoint 2, $x _ { \mathrm { k e y p o i n t } 2 } , \cdot \cdot \cdot ]$ . One may also use a keypoint label (e.g., nose, let eye, right eye) before each $( y , x )$ -coordinates so their ordering does not need to be fixed but we opt for simplicity given that there are only a small fixed set of 14 person keypoints in the COCO dataset we consider. When certain keypoints are occluded, their coordinate tokens are replaced with a special occlusion token.
40
+
41
+ - For captioning, we directly predict text tokens given a caption is a sequence of discrete tokens.
42
+
43
+ It is worth noting that all four tasks share a single vocabulary. The specific prompts and output sequences are illustrated in Figure 2.
44
+
45
+ # 2.2 Unified architecture and objective function
46
+
47
+ We need a flexible and expressive architecture that can deal with image input and sequence output with complex semantics. Thus we follow [7] and use an encoder-decoder architecture, with an image encoder and sequence decoder. The image encoder perceives pixels and maps them into hidden representations, which can be instantiated as a ConvNet [23, 22, 14], Transformer [41, 11], or their combination [4]. The Transformers-based sequence decoder, widely used in modern language modeling [41, 33, 35], generates one token at a time, conditioned on the preceding tokens and the encoded image representation. This removes the complexity and customization in architectures of modern neural networks for these vision tasks (such as per-task specific heads or necks [15, 19, 30]).
48
+
49
+ ![](images/12c0929a8742e77c689652359af1075dd09959ceb53d7a82a8c6861838281b20.jpg)
50
+ Figure 3: An illustration of our architecture and training objective. Note that Yconstructed seq encapsulates both task prompt tokens and task output tokens. Token weights are set to zero if the target token is within the prompt so the model is only trained to predict desired output tokens.
51
+
52
+ Unlike [7] where the decoder produces the output tokens directly for the single object detection task, here it also conditions on a task prompt so that the model can produce outputs adapted to the task of interest. During training, we concatenate both prompt and desired output into a single sequence, but leverage a token weighting scheme to ensure that the decoder is only trained to predict the desired output but not the prompt tokens. During inference, the prompt is given and fixed, so the decoder only needs to produce the rest of the sequence. Similar to [7], the training objective is to maximize the likelihood of tokens conditioned on an image and preceding tokens, i.e.,
53
+
54
+ $$
55
+ \mathrm { m a x i m i z e } \sum _ { j = 1 } ^ { L } { \pmb w } _ { j } \log P ( { \pmb y } _ { j } | { \pmb x } , { \pmb y } _ { 1 : j - 1 } ) ~ ,
56
+ $$
57
+
58
+ where $_ { \textbf { \em x } }$ is the input image, $\textbf { { y } }$ is a length- $L$ sequence associated with $_ { \textbf { \em x } }$ . As mentioned, the initial part of the sequence $\textbf { { y } }$ is a prompt, for which we set the weight ${ \pmb w } _ { j }$ to zero so it is not included in the loss.
59
+
60
+ # 2.3 Training
61
+
62
+ Each task has its own paired image-sequence training data. There are two ways one can combine tasks and perform the joint training.
63
+
64
+ Data mixing. We can create a dataset with mixed image-sequence pairs drawn from different tasks, balanced to account for different dataset sizes and task difficulties. This construction is extremely simple conceptually, but image augmentations can be difficult to incorporate as they may also require a change to their associated sequences in non-trivial ways.
65
+
66
+ Batch mixing. For each batch, we can sample images with annotations for a single task, perform image augmentations appropriate for this task, and convert the augmented data into image-sequence pairs. The model computes the loss and gradient for each task separately, and we can combine gradients from task-specific batches with an appropriate weighting.
67
+
68
+ # Algorithm 1 Training based on data mixing
69
+
70
+ # Algorithm 2 Training based on batch mixing
71
+
72
+ 1: Tokenize annotation into sequences of tokens, 2: Mixing images and sequences from all tasks, 3: Sample a batch, compute the loss, and update the model.
73
+
74
+ 1: Sample batches of data from all tasks, 2: Tokenize annotation into sequences of tokens, 3: Compute the loss for each task, aggregate their gradients, and update the model.
75
+
76
+ can be employed in the future to further simplify the pipeline and allow more tasks to be added straightforwardly.
77
+
78
+ Both data mixing and batch mixing require that we specify the portion or weighting for each task. This is an empirical matter, and we use a greedy strategy by adding one task at a time. Every time when we add a task, we adjust the weighting of the new task while keeping the relative weighting among the existing task fixed. We fix the sum of the weights across all tasks to be one.
79
+
80
+ # 2.4 Inference and de-tokenization
81
+
82
+ At inference time, we sample tokens from the model likelihood, given a prompt at the start of the sequence, i.e., $P ( \pmb { y } _ { j } | \pmb { x } , \pmb { y } _ { 1 : j - 1 } )$ . We currently use nucleus sampling [16] but other techniques such as beam search could also be used. Once the tokens are generated, they can be decoded for each task. In the same way that different tasks require specific tokenization schemes to generate token sequences, the decoding (de-tokenization) process is also specific to each task. A more detailed description of inference decoding for each task is given below.
83
+
84
+ - For bounding boxes, following [7], we split predicted sequences into tuples of 5 tokens to get coordinate tokens and a class token, and dequantize coordinate tokens to get the bounding boxes. - For instance segmentation, we dequantize the coordinate tokens corresponding to each polygon, and then convert them into dense masks. The model is not trained with any geometry-specific regularizers per se, and as such the output polygonal masks can be somewhat noisy. To reduce the noise we find it helpful to sample multiple sequences and then average the masks, followed by a simple threshold to obtain a single binary mask. - For keypoint detection, we directly dequantize the image coordinate tokens of the keypoints. - For captioning, we directly map the predicted discrete tokens into text.
85
+
86
+ # 3 Experiments
87
+
88
+ # 3.1 Experimental settings and implementation details
89
+
90
+ We evaluate the proposed method on the widely used MS-COCO 2017 dataset [26], containing $1 1 8 \mathrm { k }$ training images and $5 \mathrm { k }$ validation images, spanning the four tasks we consider. An image in the dataset typically has annotations for object bounding boxes, segmentation masks for object instances, keypoint for person instances, and a few captions. Following [7], we use a Vision Transformer (ViT-B) encoder [11, 41], and a Transformer autoregressive decoder [41]. This model has a total of 132M parameters. To initialize the model, we use a pretrained checkpoint from [7] trained on the object detection task with the Objects365 dataset [39]; this is useful as COCO is relatively small and our model has less task-specific prior. For training on COCO, we use a batch size of 128 images, a learning rate of $1 e ^ { - 4 }$ , and we train the model for 100 epochs. We use a single vocabulary of 35K, with 32K text tokens, 1K coordinate quantization bins, and a few other class labels. We use a maximum sequence length of 512. Our backbone model is pretrained with $6 4 0 \times 6 4 0$ image size, and is fine-tuned in $6 4 0 \times 6 4 0$ or $1 0 2 4 \times 1 0 2 4$ resolutions.
91
+
92
+ Object detection. We follow [7] and use sequence augmentation during training, and use class token probability at inference time for scoring. We also use scale jittering as in [7] (scaling images randomly without changing aspect ratio, crop a fixed size region randomly, and then pad to the maximum size).
93
+
94
+ Instance segmentation. We set the maximum points of polygons to 128. We find that asking the model to generate multiple samples during the inference time and average the generated masks to be beneficial. More specifically, when multiple samples are independently drawn, we convert each of them into a semantic mask for the prompted object. We then average the masks by setting a $( 5 0 \% )$ threshold, and pixels with more than $50 \%$ times of being on will be selected for that instance. We find that 8 samples are sufficient to provide good performance ( ${ \sim } 6$ AP better than using a single sample), and beyond 12 samples we do not see performance boost. Additionally, during inference, we also evaluate on the cropped regions of the image containing the prompted object instance, by replacing the original input image with a new image only containing the cropped region. With smaller image size of $6 4 0 \times 6 4 0$ , this yields $1 . 3 \mathrm { \ A P }$ improvement, but with larger image size of $1 0 2 4 \times 1 0 2 4$ , this does not seem to help much.
95
+
96
+ Keypoint detection. We train and evaluate on cropped regions of the image containing person instances (following the common practice in the community). During training, these regions are provided by ground-truth annotations, and during inference these regions are provided by the object detection model. We choose this region to be twice the size of the provided bounding box. We find that this works better than training with a larger crop size or cropping to the exact bounding box. Using our optimal crop we get ${ \sim } 9$ AP improvement over using an extremely large crop ( ${ \sim } 2 0$ times the box size which can be considered a close approximation to using the entire image). We also use a special token to represent invisible token coordinates in the quantized sequence. At training time we use a small loss weight of 0.1 for these tokens. While using a larger weight doesn’t affect AP much (lower by 1 at weight 1.0) using a weight of 0.0 does much worse (12 AP lower). At inference time invisible tokens are replaced with the model’s best guess of the keypoints’ coordinates.
97
+
98
+ Four-tasks joint training. We use a mixed weighting of 0.1782, 0.7128, 0.099, 0.01 for object detection, instance segmentation, image captioning, and keypoint detection respectively. This set of weight is searched greedily by adding one task at a time (while keeping the weighting ratio of existing tasks unchanged). Ablations on task weighting are shown in the quantitative results below.
99
+
100
+ Baselines. We compare with a few well-known task-specific baselines. For object detection we compare with a strong 2-stage detector, Faster R-CNN [37], and a more recent Transformer-based detector, DETR [4]. Both Faster R-CNN and DETR use task-specific priors in their design, such as non-maximum suppression in Faster R-CNN and bipartite graph matching with generalized intersection-over-union in DETR. Due to their customized architectures and loss functions, extending them to a wider spectrum of tasks is non-trivial and may require a new model design. Mask RCNN [15] advocates a design to extend Faster R-CNN to incorporate segmentation masks and keypoints. While Mask R-CNN is able to perform three out of our four tasks, it still requires the same set of task-based customizations as in Faster R-CNN. We also consider an improved version of Mask R-CNN with non-local architectures [43] which incorporates an attention mechanism, similar to Transformers. The above methods cannot do image captioning, so we train a Transformer-based caption model [40, 32] which is specialized for the task. This model is similar to the proposed method trained for caption single task but it is using self-supervised pretrained visual encoder [6] with a high dropout rate.
101
+
102
+ # 3.2 Quantitative results
103
+
104
+ Table 1: COCO results for object detection, instance segmentation and keypoint detection are expressed in terms of AP. For Image Captioning we report BLEU score. Single task results for instance segmentation and keypoint detection are based on detected bounding boxes from single task detection model. - indicates the model is not able to solve the task without modifications.
105
+
106
+ <table><tr><td></td><td> Object det.</td><td>Instance seg.</td><td>Keypoint det.</td><td>Captioning</td></tr><tr><td>Faster R-CNN[37]</td><td>42.0</td><td></td><td></td><td></td></tr><tr><td>Faster R-CNN+ [37]</td><td>44.0</td><td></td><td></td><td></td></tr><tr><td>DETR[4]</td><td>44.9</td><td></td><td></td><td></td></tr><tr><td>Mask R-CNN[15]</td><td>39.8</td><td>37.1</td><td>63.1</td><td></td></tr><tr><td>Mask R-CNN (non-local) [43]</td><td>45.0</td><td>40.3</td><td>66.5</td><td>=</td></tr><tr><td>Transformer-based captioner [41,32]</td><td>1</td><td>1</td><td>-</td><td>34.3</td></tr><tr><td>Pix2Seq v2 single task (640×640)</td><td>43.8</td><td>37.3</td><td>68.0</td><td>33.9</td></tr><tr><td>Pix2Seq v2 single task (1024×1024)</td><td>45.6</td><td>38.7</td><td>67.4</td><td>34.0</td></tr><tr><td>Pix2Seq v2 multi-tasks (640×640)</td><td>44.2</td><td>36.9</td><td>65.0</td><td>34.3</td></tr><tr><td>Pix2Seq v2 multi-tasks (1024×1024)</td><td>46.5</td><td>38.2</td><td>64.8</td><td>34.9</td></tr></table>
107
+
108
+ Our main results are summarized in Table 1, where we report baselines and two variants of our model: (1) single task models where the model is trained on a single task (still with the same architecture and objective function), so each task has its own network weights; and (2) a multi-task model, where a single set of network weights is used for all four tasks. We can see that despite without task-specific priors in architecture and loss function, our model can still achieve competitive results for each individual task compared to strong specialized baselines (even with a smaller image size). When we train a single model on all tasks, our model is able to address these tasks relatively well, despite the model size being kept the same. We also observe that, with larger image sizes, the performances are generally improved. One exception is keypoint detection, which already uses a cropped region of interest for detecting key points, thus scaling up the image size is not necessarily helpful and can lead to overfitting in case of limited labeled data.
109
+
110
+ ![](images/aa94f521b6a85f42d7dfb063d8659d22b9e19c1da0adb6c62e804101adcf34dd.jpg)
111
+ Figure 4: Performance with different task weighting when a new task is added into an existing task mixes.
112
+
113
+ Figure 4 shows how we select appropriate loss weighting for each task using a greedy strategy. More specifically, we first search the weight ratio between object detection and instance segmentation and results are shown in Figure 4a. We observe that for a relatively wide range of weighting ratios, the performance of both tasks are near their peak, so we simply choose the 2:8 weighting ratio for these two tasks. After that, we add image captioning task, and the performances under different weighting of the captioning task can be found in Figure 4b, where we find that the 9:1 weighting ratio for existing tasks and image captioning tasks to be appropriate. Finally, adding the keypoint detection task, in Figure 4c we find its weight can be set relatively small and we choose to use 0.01.
114
+
115
+ # 3.3 Qualitative results
116
+
117
+ To demonstrate the capability and performance of our model in a more visual and intuitive way, we show the outputs from our multi-task model on selected images from the COCO validation set, for each of the four tasks, i.e., object detection, instance segmentation, keypoint detection, and image captioning. Figure 5 shows results for the object detection task. The model successfully detects objects of different sizes in cluttered scenes with significant occlusion. Empirical results on instance segmentation and keypoint detection are shown in Figures 6 and 7. For both tasks, the multi-task model produces well localized and accurate predictions. We also demonstrate some captions generated by the model in Table 2. With these results, we note that our model has not been pre-trained using large-scale image-text datasets, which is expected to significantly improve the captioning performance of the model.
118
+
119
+ # 4 Related work
120
+
121
+ Decoding visual concepts: Image understanding involves extracting visual concepts from images. The formats of these concepts vary according to the given task. Image captioning uses a sequence of words to describe an image [9]. Object detection, on the other hand, represents objects with labels and bounding boxes. Depending on the granularity of localization, visual concepts can be expressed as boxes, pixel segmentation, or keypoints [26]. Decoding localized visual concepts often requires tailored methods. For example, image segmentation uses per-pixel classification. Object detection uses sliding window with non-maximum suppression to detect boxes. Person keypoint detection uses part models to assemble detected parts into whole body [3].
122
+
123
+ Recently, DETR [4] is proposed as an end-to-end object detection approach based on a Transformer decoding scheme (removing complexity on bounding box proposal and non-maximum suppression). MaskFormer [10] further shows that object detection and segmentation can share the same decoding scheme. Pix2seq [7] demonstrates that boxes and labels can be treated as a sequence of discrete tokens, thereby sharing the same training and decoding interface as language models [33, 35]. In our work, we push the envelope further in the unification of language and different visual localization tasks to share the same interface, architecture and training objective.
124
+
125
+ ![](images/2f37c2355dbfcce6b22c6009415f1261df7fb8e0f0bc62f1150c12e6618dc441.jpg)
126
+ Figure 5: Visualization of the object detection results, with predicted bounding boxes on the input images.
127
+
128
+ Generalist vision models: Learning a generalist model capable of performing multiple tasks is widely assumed to be a path toward general intelligence. In visual recognition, multi-task learning has shown great success by sharing a backbone model, followed by multiple independent heads [15, 19, 30]. Models with a shared backbone can learn general features which are transferable across tasks when scaling up with training tasks, model capacity and data [20, 24, 12]. Nevertheless, often the task specific backbone models are designed carefully, particularly for tasks that require accurate localization [38, 27].
129
+
130
+ With the invention of Transformers [41], recently being adopted for image classification [11], the research community has seized on the opportunity to unify the backbone design for vision tasks [29, 8, 25]. Perceivers [18, 17] and OFA [42] demonstrate an architecture for multi-task and multimodal across vision and language. Notably, OFA designs a unified sequence-to-sequence decoding architecture for both language and object detection tasks. Flamingo [1] and related methods also focus on an universal API that produces a natural language output for a variety of tasks given image input. This line of work shares a common motivation to our work in this paper, however they focus on higher level tasks for which natural language is inherently the desired output. In this paper we demonstrate that one can express a variety of “core” computer vision tasks in a universal interface, and the learned model exhibits strong grounding capability of the tokens they produce to actual visual concepts. Concurrently to our work, Gato [36] unifies a series of vision and control tasks into a single sequential prediction problem, and UViM [21] and Unified-IO [31] propose using learned discrete codes for unifying a set of vision tasks.
131
+
132
+ ![](images/e5b3035d08ad0bb521496a0c1e8c384e248fa0b527e9ccfd9e2badc52131241e.jpg)
133
+ Figure 6: Visualization of the instance segmentation results, with predicted semantic masks overlaid on the input images.
134
+
135
+ ![](images/ed5b7527c5b3a8b6f7e08aa10a17acac7929707b0894e33bdb22edb1b1b31a33.jpg)
136
+ Figure 7: Visualization of the Human keypoint detection results, with predicted stick figures on the input images.
137
+
138
+ Table 2: Image captioning results.
139
+
140
+ <table><tr><td></td><td>A group of teddy bears sitting next to each other. Three teddy bears sitting on a blanket. A group of teddy bears sitting on a blanket with bowls of food.</td></tr><tr><td></td><td>A herd of elephants standing inside of a fenced in area. A group of elephants standing in a fenced area. A herd of elephants standing behind a fence.</td></tr><tr><td></td><td>A man riding a skateboard over a block of cement. A man doing a trick on a skateboard in the street. A man flying through the air while riding a skateboard.</td></tr><tr><td></td><td>A row of motorcycles parked on a grass covered field. A motorcycle with a helmet on the side of it. A motorcycle parked in a grassy area with other motorcycles.</td></tr></table>
141
+
142
+ # 5 Conclusion
143
+
144
+ In this work, we explore a unified sequence interface for tackling a diverse set of “core” vision tasks, where both the task description (prompt) and task output are expressed as discrete sequences of tokens. This is a significant departure from conventional norms of multi-task vision models in that both architecture and loss functions are shared among the tasks. We show that such a model can achieve competitive performance compared to well-established task-specific models.
145
+
146
+ Our work is not without limitations. Due to the significant departure from conventional approaches, we believe both architectures and other training techniques can be further improved to challenge the state-of-the-art of specialized systems. We also believe our model can significantly benefit from scaling up, both in pretraining on larger datasets (e.g., image-text pairs) and/or using larger model sizes. Another limitation is the inference speed can be potentially slower (for longer sequences particularly) compared to the specialized systems as our approach is based on autoregressive modeling. There are a few ways to improve the efficiency, including using non-autoregressive sequence modeling (which we leave as future work). In this work, we exploit parallel querying for speeding up our model inference. For example, predicting multi-person poses can be done independently by prompting the model with independent bounding boxes (detected by the model itself or pre-given), so the only sequential prediction is limited to a single person with a few keypoints. The same strategy can be applied to instance segmentation as well.
147
+
148
+ While the optimal implementation of a unified interface still requires more research and the sequence interface explored in this work is only one potential implementation, we believe the interface of how different tasks are formulated would play an increasing important role in general-purpose intelligent systems going forward.
149
+
150
+ # Acknowledgements
151
+
152
+ We specially thank Wei Li for their helpful feedback on the initial draft. We also thank Xiaohua Zhai, Alexander Kolesnikov, Lucas Beyer, Neil Houlsby, Simon Kornblith and Mohammad Norouzi for some early discussions.
153
+
154
+ # References
155
+
156
+ [1] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob Menick, Sebastian Borgeaud, Andrew Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, and Karen Simonyan. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022.
157
+ [2] 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.
158
+ [3] Zhe Cao, Tomas Simon, Shih-En Wei, and Yaser Sheikh. Realtime multi-person 2d pose estimation using part affinity fields. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7291–7299, 2017.
159
+ [4] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, pages 213–229. Springer, 2020.
160
+ [5] Lluis Castrejon, Kaustav Kundu, Raquel Urtasun, and Sanja Fidler. Annotating object instances with a polygon-rnn. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 5230–5238, 2017.
161
+ [6] 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.
162
+ [7] Ting Chen, Saurabh Saxena, Lala Li, David J Fleet, and Geoffrey Hinton. Pix2seq: A language modeling framework for object detection. arXiv preprint arXiv:2109.10852, 2021.
163
+ [8] Wuyang Chen, Xianzhi Du, Fan Yang, Lucas Beyer, Xiaohua Zhai, Tsung-Yi Lin, Huizhong Chen, Jing Li, Xiaodan Song, Zhangyang Wang, et al. A simple single-scale vision transformer for object localization and instance segmentation. arXiv preprint arXiv:2112.09747, 2021.
164
+ [9] Xinlei Chen, Hao Fang, Tsung-Yi Lin, Ramakrishna Vedantam, Saurabh Gupta, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco captions: Data collection and evaluation server. arXiv preprint arXiv:1504.00325, 2015.
165
+ [10] Bowen Cheng, Alex Schwing, and Alexander Kirillov. Per-pixel classification is not all you need for semantic segmentation. Advances in Neural Information Processing Systems, 34, 2021.
166
+ [11] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2020.
167
+ [12] Golnaz Ghiasi, Barret Zoph, Ekin D Cubuk, Quoc V Le, and Tsung-Yi Lin. Multi-task self-training for learning general representations. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 8856–8865, 2021.
168
+ [13] Ross Girshick. Fast r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, pages 1440–1448, 2015.
169
+ [14] 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.
170
+ [15] Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick. Mask r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, pages 2961–2969, 2017.
171
+ [16] Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751, 2019.
172
+ [17] Andrew Jaegle, Sebastian Borgeaud, Jean-Baptiste Alayrac, Carl Doersch, Catalin Ionescu, David Ding, Skanda Koppula, Daniel Zoran, Andrew Brock, Evan Shelhamer, et al. Perceiver io: A general architecture for structured inputs & outputs. arXiv preprint arXiv:2107.14795, 2021.
173
+ [18] Andrew Jaegle, Felix Gimeno, Andy Brock, Oriol Vinyals, Andrew Zisserman, and Joao Carreira. Perceiver: General perception with iterative attention. In International Conference on Machine Learning, pages 4651–4664. PMLR, 2021.
174
+ [19] Iasonas Kokkinos. Ubernet: Training a universal convolutional neural network for low-, mid-, and highlevel vision using diverse datasets and limited memory. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 6129–6138, 2017.
175
+ [20] 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.
176
+ [21] Alexander Kolesnikov, André Susano Pinto, Lucas Beyer, Xiaohua Zhai, Jeremiah Harmsen, and Neil Houlsby. Uvim: A unified modeling approach for vision with learned guiding codes. arXiv preprint arXiv:2205.10337, 2022.
177
+ [22] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. Advances in Neural Information Processing Systems, 25:1097–1105, 2012.
178
+ [23] Yann LeCun, Bernhard Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne Hubbard, and Lawrence D Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1 (4):541–551, 1989.
179
+ [24] Yanghao Li, Saining Xie, Xinlei Chen, Piotr Dollar, Kaiming He, and Ross Girshick. Benchmarking detection transfer learning with vision transformers. arXiv preprint arXiv:2111.11429, 2021.
180
+ [25] Yanghao Li, Hanzi Mao, Ross Girshick, and Kaiming He. Exploring plain vision transformer backbones for object detection. arXiv preprint arXiv:2203.16527, 2022.
181
+ [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, pages 740–755. Springer, 2014.
182
+ [27] Tsung-Yi Lin, Piotr Dollár, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature pyramid networks for object detection. In Proceedings of the IEEE Conference on Computer Vision and pattern recognition, pages 2117–2125, 2017.
183
+ [28] Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollár. Focal loss for dense object detection. In Proceedings of the IEEE International Conference on Computer Vision, pages 2980–2988, 2017.
184
+ [29] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10012–10022, 2021.
185
+ [30] Jiasen Lu, Vedanuj Goswami, Marcus Rohrbach, Devi Parikh, and Stefan Lee. 12-in-1: Multi-task vision and language representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10437–10446, 2020.
186
+ [31] Jiasen Lu, Christopher Clark, Rowan Zellers, Roozbeh Mottaghi, and Aniruddha Kembhavi. Unified-io: A unified model for vision, language, and multi-modal tasks. arXiv preprint arXiv:2206.08916, 2022.
187
+ [32] Yingwei Pan, Ting Yao, Yehao Li, and Tao Mei. X-linear attention networks for image captioning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10971– 10980, 2020.
188
+ [33] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
189
+ [34] 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.
190
+ [35] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.
191
+ [36] Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, and Nando de Freitas. A generalist agent. arXiv arXiv:2205.06175, 2022.
192
+ [37] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in Neural Information Processing Systems, 28:91–99, 2015.
193
+ [38] 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.
194
+ [39] Shuai Shao, Zeming Li, Tianyuan Zhang, Chao Peng, Gang Yu, Xiangyu Zhang, Jing Li, and Jian Sun. Objects365: A large-scale, high-quality dataset for object detection. In Proceedings of the IEEE/CVF international conference on computer vision, pages 8430–8439, 2019.
195
+ [40] Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 2556–2565, 2018.
196
+ [41] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems, pages 5998–6008, 2017.
197
+ [42] Peng Wang, An Yang, Rui Men, Junyang Lin, Shuai Bai, Zhikang Li, Jianxin Ma, Chang Zhou, Jingren Zhou, and Hongxia Yang. Unifying architectures, tasks, and modalities through a simple sequence-tosequence learning framework. arXiv preprint arXiv:2202.03052, 2022.
198
+ [43] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7794–7803, 2018.
199
+
200
+ # Checklist
201
+
202
+ 1. For all authors...
203
+
204
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
205
+ (b) Did you describe the limitations of your work? [Yes] See Conclusion section
206
+ (c) Did you discuss any potential negative societal impacts of your work? [No] Our work at its current form does not increase the risk of negative social impacts of those existing specialized systems.
207
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
208
+
209
+ 2. If you are including theoretical results...
210
+
211
+ (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]
212
+
213
+ 3. If you ran experiments...
214
+
215
+ (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 opensource our code at https://github.com/google-research/pix2seq.
216
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
217
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Some of the experiments are expensive to run multiple times, and the standard errors are usually pretty small.
218
+
219
+ (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] It’s trained on 32-128 Cloud TPUs. Depending on architectures, and tasks, generally takes 4-12 hours.
220
+
221
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
222
+
223
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
224
+ (b) Did you mention the license of the assets? [No] It is pretty obvious from the dataset website, and it’s a well known dataset.
225
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
226
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
227
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
228
+
229
+ 5. If you used crowdsourcing or conducted research with human subjects...
230
+
231
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
232
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
233
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/to3qCB3tOh9/to3qCB3tOh9.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/toR64fsPir/toR64fsPir.md ADDED
@@ -0,0 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Structure-Preserving Embedding of Multi-layer Networks
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 This paper investigates structure-preserving embedding for multi-layer networks
11
+ 2 with community structure. We propose a novel generative tensor-based latent space
12
+ 3 model (TLSM) that allows heterogeneity among vertices. It embeds vertices into
13
+ 4 a low-dimensional latent space so that vertices within the same community are
14
+ 5 close to each other in the ambient space, and captures layer heterogeneity through
15
+ 6 a layer-effect factor matrix. With a general and flexible tensor decomposition
16
+ 7 on the expected network adjacency tensor, TLSM is dedicated to preserving the
17
+ 8 original vertex relations and layer-specific effects in the network embedding. An
18
+ 9 efficient alternative updating scheme is developed to estimate the model parameters
19
+ 10 and conduct community detection simultaneously. Theoretically, we establish the
20
+ 11 asymptotic consistencies of TLSM in terms of both multi-layer network estimation
21
+ 12 and community detection. The theoretical results are supported by extensive
22
+ 13 numerical experiments on both synthetic and real-life multi-layer networks.
23
+
24
+ # 14 1 Introduction
25
+
26
+ 15 Network has arisen as one of the most common structures to represent the relations among entities.
27
+ 16 In many complex systems, entities can be multi-relational in that they may interact with each other
28
+ 17 under various circumstances. A multi-layer network, which consists of a common vertex set across all
29
+ 18 network layers representing the entities and an edge set at each layer to characterize a particular type
30
+ 19 of relation among entities, is faithful to represent these relations. Examples of multi-layer networks
31
+ 20 include social networks of multiple interaction channels [42, 15], biological networks of different
32
+ 21 collaboration schemes [49, 31, 29] and world trading networks [1, 37] of various goods.
33
+ 22 In this paper, we propose a structure-preserving embedding framework for multi-layer networks
34
+ 23 via a tensor-based latent space model. Specifically, TLSM utilizes the factorization of network
35
+ 24 adjacency tensor as a building block, embeds the vertices into a low dimensional latent space, and
36
+ 25 captures the heterogeneity among different layers through a layer-effect factor matrix. Consequently,
37
+ 26 the community structure of the multi-layer network can be detected from a network embedding
38
+ 27 perspective, such that vertices within the same community are closer to one another in the ambient
39
+ 28 space than those in different communities. In addition, one key feature of TLSM is that it introduces
40
+ 29 a sparsity factor into the vanilla logit transformation of the network adjacency tensor, which allows
41
+ 30 TLSM to model sparse multi-layer networks in a more explicit fashion and accommodate relatively
42
+ 31 sparser multi-layer networks as the ones considered in literature [22]. More importantly, this sparsity
43
+ 32 factor can be estimated from the network adjacency tensor directly.
44
+ 33 The main contribution of this paper is three-fold. First, the proposed TLSM is flexible and general
45
+ 34 in that it includes many popular network models as special cases. It also relaxes the layer-wise
46
+ 35 positive semi-definite condition that has been frequently employed in literature [6, 35]. Second, a
47
+ 36 joint modeling framework is constructed for TLSM, consisting of the multi-layer network likelihood
48
+ 37 and a clustering type penalty, to estimate the multi-layer network and conduct community detection
49
+ 38 simultaneously. Its advantages are supported by extensive numerical experiments on both synthetic
50
+ 39 and real-life multi-layer networks. Third, the asymptotic consistencies of TLSM are established in
51
+ 40 terms of both multi-layer network estimation and community detection. Notably, the established
52
+ 41 theoretical results imply that the proposed methods can accommodate the sparsest multi-layer
53
+ 42 networks considered in literature.
54
+ 43 The rest of the paper is organized as follows. The remaining of Section 1 discusses related works and
55
+ 44 introduces necessary notations. Section 2 presents the proposed TLSM and its estimation scheme with
56
+ 45 an efficient algorithm. In Section 3, we establish the asymptotic consistencies of TLSM. Extensive
57
+ 46 numerical performance of TLSM on synthetic and real-life multi-layer networks as well as ablation
58
+ 47 studies on two novel components of the proposed method are carried out in Section 4. Section 5
59
+ 48 concludes the paper. The supplementary materials contains technique proofs and necessary lemmas,
60
+ 49 additional simulation studies, detailed parameter tuning process, among others.
61
+
62
+ # 50 1.1 Related work
63
+
64
+ 51 While there is a growing number of literature focusing on community detection in single-layer
65
+ 52 network [48, 28, 13], community detection in multi-layer network is still in its infancy. One classical
66
+ 53 approach is to detect community structure in each layer separately [4, 5], which fails to leverage
67
+ 54 the homogeneity across different layers. Another approach is to aggregate multi-layer networks
68
+ 55 into a single-layer one [41, 12, 35], which heavily relies on the assumption of homogeneous linking
69
+ 56 pattern across multiple layers. Recently, [26] proposed to aggregate the biased-adjusted version of
70
+ 57 the squared adjacency matrix in each layer to alleviate the information loss in aggregation. yet it
71
+ 58 requires the average node degree to grow at a sub-optimal order.
72
+ 59 In terms of multi-layer network generative models, [34] extended the seminal stochastic block
73
+ 60 model (SBM; 19) to the multi-layer stochastic block model (MLSBM; 34), where the probability for
74
+ 61 any two vertices to form an edge in a given layer depends only on their community memberships.
75
+ 62 Clearly, MLSBM heavily relies on the assumption of homogeneous vertices within communities.
76
+ 63 The framework of MLSBM has also been incorporated in degree-corrected network estimation [36],
77
+ 64 spectral clustering [6, 35, 26], least square estimation [27] and likelihood-based approaches [45]. In
78
+ 65 addition, network response regression model [46] and tensor factorization methods [8, 22] have also
79
+ 66 been proposed to detect community structures in multi-layer networks.
80
+ 67 To allow heterogeneous vertices, the latent space model [18] and random dot product graph model
81
+ 68 [3] have been extended to multi-layer networks[47, 32, 2]. In addition, graph neural network and
82
+ 69 graph convolutional networks has been extended to multi-layer network for learning the multi-layer
83
+ 70 network embedding [14, 23, 17, 39].
84
+
85
+ # 71 1.2 Notations
86
+
87
+ 72 Throughout the paper, we use boldface calligraphic Euler scripts $( A )$ to denote tensors, boldface
88
+ 73 capital letters $( A )$ or Greece letters $( \alpha , \beta )$ to denote matrices, boldface lowercase letters $( a )$ to
89
+ 74 denote vectors, and regular letters $( a )$ to denote scalars. For an order three tensor $\pmb { \mathcal { A } } \in \mathbb { R } ^ { I _ { 1 } \times I _ { 2 } \times I _ { 3 } }$ ,
90
+ 75 $\mathcal { A } _ { i , . , . } \in \mathbb { R } ^ { I _ { 2 } \times I _ { 3 } } , \mathcal { A } _ { . , j , \cdot } \in \mathbb { R } ^ { I _ { 1 } \times I _ { 3 } }$ , and $\pmb { \mathscr { A } } _ { . , . , m } \in \mathbb { R } ^ { I _ { 1 } \times I _ { 2 } }$ are the $i$ -th horizontal slide, $j$ -th lateral slide
91
+ 76 and $m$ -th frontal slide of $\mathcal { A }$ , respectively. Similarly, for a matrix $\pmb { A }$ , $A _ { i , }$ . denotes its $i$ -th row and $A _ { . , j }$
92
+ 77 denotes its $j$ -th column. For a vector $\textbf { \em a }$ , $\mathrm { d i a g } ( a )$ stands for the diagonal matrix whose diagonal is $\textbf { \em a }$ .
93
+ 78 We use $| | \cdot | | , | | \cdot | | _ { \infty }$ , and $| | \cdot | | _ { F }$ to denote the $l _ { 2 }$ -norm, $l _ { \infty }$ -norm of a vector, and the Frobenius norm
94
+ 79 of matrix or tensor, respectively. For any integer $n$ , denote $[ n ] = \{ 1 , 2 , . . . , n \}$ .
95
+
96
+ 80 81 1 product betsuch that its or -th $\pmb { \mathcal { A } } \in \mathbb { R } ^ { I _ { 1 } \times I _ { 2 } \times I _ { 3 } }$ an as $U \in \mathbb { R } ^ { J _ { 1 } \times I _ { 1 } }$ $\pmb { A } \times _ { 1 } \pmb { U } \in$ $\mathbb { R } ^ { J _ { 1 } \times I _ { 2 } \times I _ { 3 } }$ $( j _ { 1 } , i _ { 2 } , i _ { 3 } )$ $\begin{array} { r } { ( \pmb { \mathscr { A } } \times _ { 1 } \pmb { U } ) _ { j _ { 1 } , i _ { 2 } , i _ { 3 } } = \sum _ { i _ { 1 } = 1 } ^ { I _ { 1 } } \pmb { \mathscr { A } } _ { i _ { 1 } , i _ { 2 } , i _ { 3 } } U _ { j _ { 1 } , i _ { 1 } } } \end{array}$ The mode-2 or mode-3 product between $\pmb { A }$ and any matrix of appropriate dimension are defined 83 similarly. The CANDECOMP/PARAFAC (CP) decomposition of $\pmb { A }$ has the form
97
+
98
+ $$
99
+ \pmb { \mathcal { A } } = \sum _ { r = 1 } ^ { R } \pmb { a } ^ { ( r ) } \circ \pmb { b } ^ { ( r ) } \circ \pmb { c } ^ { ( r ) } ,
100
+ $$
101
+
102
+ where 84 $\pmb { a } ^ { ( r ) } \in \mathbb { R } ^ { I _ { 1 } }$ , $\boldsymbol { b } ^ { ( r ) } \in \mathbb { R } ^ { I _ { 2 } }$ , and $\boldsymbol { c } ^ { ( r ) } \in \mathbb { R } ^ { I _ { 3 } }$ for $r \in [ R ]$ , and $\circ$ stands for the vector outer product. The CP-rank [24] of the tensor 85 $\pmb { a } ^ { ( r ) } \circ \pmb { b } ^ { ( r ) } \circ \pmb { c } ^ { ( r ) }$ is defined to be 1, for $r \in [ R ]$ . The minimal number
103
+
104
+ 86 of rank-1 tensors in the CP decomposition of $\pmb { A }$ is called the CP-rank of $\pmb { A }$ . Let $\pmb { \mathcal { T } } \in \{ 0 , 1 \} ^ { R \times R \times R }$
105
+ 87 be the identity tensor such that $\pmb { \mathcal { T } } _ { i _ { 1 } , i _ { 2 } , i _ { 3 } } = 1$ if $i _ { 1 } = i _ { 2 } = i _ { 3 }$ and 0 otherwise, and let $\pmb { A } \in \mathbb { R } ^ { I _ { 1 } \times R }$ ,
106
+ 88 $\boldsymbol { B } \in \mathbb { R } ^ { I _ { 2 } \times R }$ , and $C \in \mathbb { R } ^ { I _ { 3 } \times R }$ such that $\mathbf { \boldsymbol { A } } _ { \cdot , r } = \mathbf { \boldsymbol { a } } ^ { ( r ) }$ , $\mathbf { \delta } _ { B _ { \cdot , r } } = \mathbf { \delta } _ { \mathbf { \delta } } \mathbf { \delta } _ { B _ { \cdot , r } } ^ { ( r ) }$ , and $\boldsymbol { C } _ { \cdot , r } = \boldsymbol { c } ^ { ( r ) }$ . Equation (1)
107
+ 89 then can be equivalently written as $\pmb { \mathcal { A } } = \pmb { \mathcal { T } } \times _ { 1 } \pmb { A } \times _ { 2 } \pmb { B } \times _ { 3 } \pmb { C }$ .
108
+
109
+ # 90 2 Structure-preserving embedding
110
+
111
+ 91 In this paper, we consider multi-layer networks that can be represented as an undirected and un
112
+ 92 weighted $M$ -layer graph $\mathcal { G } = ( V , \mathcal { E } )$ , where $V = [ n ]$ consists of the common $n$ vertices across
113
+ 93 different layers, and $\mathcal { E } = \{ E ^ { ( m ) } \} _ { m = 1 } ^ { M }$ with $E ^ { ( m ) } \subset V \times V$ representing the $m$ -th relation network
114
+ 94 among vertices. A order three adjacency tensor $\pmb { \mathcal { A } } = ( a _ { i , j , m } ) \in \{ 0 , 1 \} ^ { n \times n \times M }$ is then defined to
115
+ 95 represent $\mathcal { G }$ with entries $a _ { i , j , m } = 1$ if $( i , j ) \in E ^ { ( m ) }$ and 0 otherwise.
116
+
117
+ # 2.1 Tensor-based latent space model
118
+
119
+ 97 To fully characterize the multi-layer network structure, we propose the following generative tensor
120
+ 8 based latent space model (TLSM). For any $i \leq j \in [ n ]$ , and $m \in [ M ]$ ,
121
+
122
+ $$
123
+ \begin{array} { r l } & { a _ { i , j , m } = a _ { j , i , m } \overset { i n d . } { \sim } \mathrm { B e r n o u l l i } ( p _ { i , j , m } ) , \mathrm { ~ w i t h ~ } } \\ & { \theta _ { i , j , m } = \log \Big ( \frac { p _ { i , j , m } } { s _ { n } - p _ { i , j , m } } \Big ) , \mathrm { ~ a n d ~ } } \\ & { \Theta = \mathbb { Z } \times _ { 1 } \alpha \times _ { 2 } \alpha \times _ { 3 } \beta , \alpha \in \Omega _ { \alpha } , \beta \in \Omega _ { \beta } , } \end{array}
124
+ $$
125
+
126
+ 99 where $\boldsymbol { \mathscr { x } }$ is the order three $R$ -dimensional identity tensor. Basically, (2) follows the standard routine
127
+ 100 in the multi-layer network literature [34, 35, 27, 22] to model that $a _ { i , j , m } = a _ { j , i , m }$ are independently
128
+ 101 generated from a Bernoulli distribution, for $i \leq j \in [ n ]$ and $m \in [ M ]$ . Denote $\pmb { \mathcal { P } } = ( p _ { i , j , m } ) \in$
129
+ 102 $\mathbb { R } ^ { n \times n \times M }$ as the network underlying probability tensor, and then $\Theta = ( \theta _ { i , j , m } ) \in \mathbb { R } ^ { n \times n \times M }$ is
130
+ 103 the entry-wise transformation of $\mathcal { P }$ by (3). We call the transformation (3) as the modified logit
131
+ 104 transformation in that the constant 1 in the standard logit transformation is replaced by a sparsity
132
+ 105 factor $s _ { n }$ , which may vanish with $n$ and $M$ . We further assume all entries of $\mathcal { P }$ are of the order $s _ { n }$ ; that
133
+ 106 is, there exists a constant $\textstyle { \frac { 1 } { 2 } } \leq \xi < 1$ such that $( 1 - \xi ) s _ { n } \leq p _ { i , j , m } \leq \xi s _ { n }$ , for $i , j \in [ n ]$ and $m \in [ M ]$
134
+ 107 Thus, the in $s _ { n }$ essval $\begin{array} { r } { [ - \log \frac { \xi } { 1 - \xi } , \log \frac { \xi } { 1 - \xi } ] } \end{array}$ overall network sparsity and the entries of . More importantly, (4) models the CP d $\Theta$ are ensured toomposition of $\Theta$ cate inby the
135
+ 109 factor matrices $\pmb { \alpha } \in \mathbb { R } ^ { n \times R }$ and $\mathbf { \boldsymbol { \beta } } \in \mathbb { R } ^ { M \times R }$ with CP-rank $R$ , which can greatly reduce the number of
136
+ 110 free parameters from $n ( n + 1 ) M / 2$ to $( n + M ) R$ . Throughout the paper, the CP-rank $R$ is allowed
137
+ 111 to diverge with $n$ . In the CP decomposition of $\Theta$ , $_ \alpha$ is the vertex latent position matrix with each row
138
+ 112 $\alpha _ i , $ . serving as the embedding of vertex $i$ , and $\beta$ captures heterogeneity across different layers. Herein,
139
+ 113 we define the constraint sets for $_ { \pmb { \alpha } }$ and $\beta$ as $\begin{array} { r } { \Omega _ { \alpha } = \{ \alpha \in \mathbb { R } ^ { n \times R } : | | \alpha _ { i , \cdot } | | \leq \sqrt { \log \frac { \xi } { 1 - \xi } } } \end{array}$ , for $i \in [ n ] \}$
140
+ 114 and $\Omega _ { \beta } = \{ \beta \in \mathbb { R } ^ { M \times R } : | | \beta _ { \cdot , r } | | = 1 , r \in [ R ] \}$ . Note that the constraint on $\beta$ is necessary for
141
+ 115 model identification, and detailed discussion will be presented shortly. The constraint set $\Omega _ { \alpha } \times \Omega _ { \beta }$
142
+ 116 is sufficient to maintain the bounded condition of $\Theta$ since a general Hölder inequality yields that
143
+ 117 $\begin{array} { r } { | \theta _ { i , j , m } | = | \pmb { \mathcal { Z } } \times _ { 1 } \pmb { \alpha } _ { i , . } ^ { T } \times _ { 2 } \pmb { \alpha } _ { j , . } ^ { T } \times _ { 3 } \beta _ { m , . } ^ { T } | \le | | \pmb { \alpha } _ { i , . } | | | | \pmb { \alpha } _ { j , . } | | | | \beta _ { m , . } | | _ { \infty } \le \log \frac { \xi } { 1 - \xi } } \end{array}$ . To conclude this
144
+ 118 paragraph, we remake that the parameter $\xi$ is introduced for theoretical purpose and it is not treated as
145
+ 119 a tuning parameter. One can choose $\xi$ sufficiently close to 1 in empirical studies so that the restriction
146
+ 120 on $_ { \pmb { \alpha } }$ will be alleviated.
147
+ 121 We make several essential observations of the proposed TLSM. First and foremost, TLSM is flexible
148
+ 122 and general. It includes the celebrated MLSBM [34, 43, 35, 27, 26, 36, 22] as special case. Specif
149
+ 123 ically, suppose the vertices comes form $K$ disjoint communities, the standard MLSBM assumes
150
+ 124 that the underlying network probability tensor ${ \pmb { \mathcal { P } } } = { \pmb { \mathcal { B } } } \times _ { 1 } { \pmb { Z } } \times _ { 2 } { \pmb { Z } }$ , where $\pmb { \mathscr { B } } \in \mathbb { R } ^ { K \times K \times M }$ is a
151
+ 125 semi-symmetric core probability tensor with $\pmb { \mathscr { B } } _ { k _ { 1 } , k _ { 2 } , m } = \pmb { \mathscr { B } } _ { k _ { 2 } , k _ { 1 } , m }$ for $k _ { 1 } , k _ { 2 } \in [ K ]$ and $m \in [ M ]$ ,
152
+ 126 and $Z \in \{ 0 , 1 \} ^ { n \times K }$ is the community membership matrix with $Z _ { i , k } = 1$ if vertex $i$ comes from the
153
+ 127 $k$ -th community and 0 otherwise. That is, the probability of any vertex pair to form an edge in a
154
+ 128 particular layer depends only on their community memberships. Equivalently, under the modified
155
+ 129 logit transformation (3), we have $\Theta = \widetilde { \pmb { \mathscr { B } } } \times _ { 1 } { Z } \times _ { 2 } { Z }$ , where $\widetilde { B }$ is the entry-wise transformation
156
+ 130 of $_ { \pmb { B } }$ under (3). Taking $R$ to be the CP-rank of $\widetilde { B }$ , the CP-decomposition of $\widetilde { B }$ then has the form
157
+ 131 $\widetilde { \pmb { \mathscr { B } } } = \pmb { \mathscr { T } } \times _ { 1 } \pmb { C } \times _ { 2 } \pmb { C } \times _ { 3 } \ \pmb { \beta }$ for some matrix $C \in \mathbb { R } ^ { K \times R }$ and $\beta \in \mathbb { R } ^ { M \times R }$ due to semi-symmetry.
158
+ 132 This leads to the CP decomposition of $\Theta$ has the form (4) with $\mathbf { \alpha } _ { \alpha } = Z C$ . It is clear that MLSBM
159
+ 133 requires vertices within the same community are homogeneous and exchangeable, while TLSM
160
+ 134 allows vertices to have different embeddings even when they are in the same community.
161
+ 135 Second, TLSM is identifiable when both $_ { \pmb { \alpha } }$ and $\beta$ have full column ranks. When both $_ { \pmb { \alpha } }$ and $\beta$
162
+ 136 have full column ranks, the Kruskal’s $\mathbf { k }$ -ranks [25] of $_ { \pmb { \alpha } }$ and $\beta$ satisfy $k _ { \alpha } = k _ { \beta } = R$ , then $\Theta$ has
163
+ 137 CP-rank $R$ . Hence, $k _ { \alpha } + k _ { \alpha } + k _ { \beta } \geq 2 R + 2$ as long as $R \geq 2$ . By Theorem 1 of [40], the fixed
164
+ 138 column $l _ { 2 }$ -norm constraint of $\beta$ implies that the tensor factorization in (4) is unique up to column
165
+ 139 permutations of $_ { \pmb { \alpha } }$ and $\beta$ and column sign flip of $_ \alpha$ . It is important to remark that the community
166
+ 140 structure encoded in $_ { \pmb { \alpha } }$ remains unchanged under any column permutation or sign flip.
167
+ 141 Third, introducing a sparsity factor $s _ { n }$ via a modified logit transformation into the TLSM is non
168
+ 142 trivial. We take a single-layer network as an example to illustrate the limitation of the standard
169
+ 143 logit transformation in handling sparse network. Suppose a vanilla logit link is used to connect
170
+ 144 the network underlying probability matrix $_ { r }$ and its transformation $\Theta$ , and the latent space model
171
+ 145 usually assumes that $\breve { \Theta } = \alpha \alpha ^ { T }$ . A sparse network requires the entries of $\Theta$ diverge to negative
172
+ 146 infinite due to the small magnitude of edge probability, which leads to unstable estimation of $_ { \pmb { \alpha } }$ in
173
+ 147 numerical experiments. Moreover, this may conflict with the assumption that vertices within the same
174
+ 148 community tend to be close in the embedding space and their inner product is likely to be positive.
175
+ 149 These difficulties can be naturally circumvented when an appropriate $s _ { n }$ is chosen in (3).
176
+
177
+ # 150 2.2 Regularized likelihood
178
+
179
+ Given a network adjacency tensor $\mathcal { A }$ and number of communities $K$ , our goal is to estimate the multi-layer network embedding $( \alpha , \beta )$ and conduct community detection on the vertices. Throughout this paper, we assume the number of potential communities $K$ is given and may diverge with $n$ . Under the TLSM framework, with slight abuse of notation, we denote the average negative log-likelihood function of the multi-layer network $\mathcal { G }$ is $\mathcal { L } ( \alpha , \beta ; \mathcal { A } ) = \mathcal { L } ( \Theta ; \mathcal { A } )$ with
180
+
181
+ $$
182
+ \mathcal { L } ( \Theta ; \pmb { A } ) = \frac { 1 } { \varphi ( n , M ) } \sum _ { m = 1 } ^ { M } \sum _ { i \leq j } L ( \theta _ { i , j , m } ; a _ { i , j , m } ) ,
183
+ $$
184
+
185
+ where 151 $\varphi ( n , M ) = { \textstyle { \frac { 1 } { 2 } } } n ( n { + } 1 ) M$ is the number of potential edges, and $\begin{array} { r } { L ( \theta ; a ) = \log \left( 1 + \frac { s _ { n } } { 1 - s _ { n } + e ^ { - \theta } } \right) - } \end{array}$ 152 $\begin{array} { r } { a \log \left( \frac { s _ { n } } { 1 - s _ { n } + e ^ { - \theta } } \right) } \end{array}$ is a negative log-density of a Bernoulli random variable $a$ . We now introduce a 153 novel regularization term to detect the potential communities in $\mathcal { G }$ ,
186
+
187
+ $$
188
+ J ( \alpha ) = \operatorname* { m i n } _ { Z \in \Gamma , C \in \mathbb { R } ^ { K \times R } } \frac { 1 } { n } \| \alpha - Z C \| _ { F } ^ { 2 } ,
189
+ $$
190
+
191
+ 154 where $C$ encodes the vertex embedding centers and ${ \Gamma } ~ \subset ~ \{ 0 , 1 \} ^ { n \times K }$ is the set of all possible
192
+ 155 community membership matrices; that is, for any $Z \in \Gamma$ , each row of $z$ consists of only one 1
193
+ 156 indicating the community membership and all others entries being 0. This leads to the proposed
194
+ 157 regularized cost function,
195
+
196
+ $$
197
+ \begin{array} { r } { \mathcal L _ { \lambda } ( \boldsymbol { \alpha } , \beta ; \boldsymbol { \mathcal { A } } ) = \mathcal L ( \boldsymbol { \alpha } , \beta ; \boldsymbol { \mathcal { A } } ) + \lambda _ { n } J ( \boldsymbol { \alpha } ) , } \end{array}
198
+ $$
199
+
200
+ 158 where $\lambda _ { n }$ is a positive tuning parameter that strikes the balance between network estimation and
201
+ 159 community detection in the cost function. It is clear that the embeddings of vertices with similar
202
+ 160 linking pattern will be pushed towards the same center, and thus close to each other in the ambient
203
+ 161 space, leading to the desired community structure in $\mathcal { G }$ .
204
+
205
+ # 2.3 Projected gradient descent algorithm
206
+
207
+ 163 We develop a scalable projected gradient descent (PGD) algorithm to optimize the penalized cost
208
+ 164 function (6), which is highly non-convex and can be solved only locally. PGD, which alternatively
209
+ 165 conducts gradient step and projection step, is one of the most popular and computationally fast
210
+ 166 algorithm in tackling non-convex optimization problem [7, 33, 47, 9].
211
+
212
+ To compute the gradients of 167 $_ \alpha$ and $\beta$ , we introduce the following notations. Define $\pmb { \mathcal { T } } \in \mathbb { R } ^ { n \times n \times M }$ with entries 168 $\begin{array} { r } { \pmb { \mathcal { T } } _ { i , j , m } = \frac { \exp ( - \theta _ { i , j , m } ) } { 1 - s _ { n } + \exp ( - \theta _ { i , j , m } ) } ( p _ { i , j , m } - a _ { i , j , m } ) } \end{array}$ , and $\boldsymbol { X } _ { \mathcal { T } ( 2 , 3 ) } ^ { \alpha , \beta } \in \mathbb { R } ^ { n \times R }$ whose $i$ -th row
213
+
214
+ 169 170 al elements of the slic. Similarly, we define $( \mathcal { T } \times _ { 2 } \alpha ^ { T } \times _ { 3 } \beta ^ { T } ) _ { i , . , . }$ $X _ { \mathcal { T } ( 2 , 3 ) } ^ { \alpha , \beta } ( i , r ) ~ =$ $( \pmb { \mathcal { T } } \times _ { 2 } \pmb { \alpha } ^ { T } \times _ { 3 } \beta ^ { T } ) _ { i , r , r }$ $X _ { \mathcal { T } ( 1 , 2 ) } ^ { \alpha , \alpha } \in \mathbb { R } ^ { R \times M }$ $\boldsymbol { X } _ { \mathcal { T } ( 3 ) } ^ { \beta } \in \mathbb { R } ^ { n \times R }$ $X _ { T ( 1 , 2 ) } \in$ 171 $\mathbb { R } ^ { n \times M }$ , such that $X _ { \mathcal { T } ( 1 , 2 ) } ^ { \alpha , \alpha } ( r , m ) = ( \mathcal { T } \times _ { 1 } \alpha ^ { T } \times _ { 2 } \alpha ^ { T } ) _ { r , r , m }$ , $X _ { \mathcal { T } ( 3 ) } ^ { \beta } ( i , r ) = ( \mathcal { T } \times _ { 3 } \beta ^ { T } ) _ { i , i , r }$ , and 172 $X _ { \mathcal { T } ( 1 , 2 ) } ( i , m ) = \mathcal { T } _ { i , i , m }$ . Consequently, when the vertex membership matrix $z$ and the community 173 center matrix $C$ are fixed, we can derive the gradients of $\mathcal { L } _ { \lambda } ( \alpha , \beta ; \mathcal { A } )$ with respect to $_ { \pmb { \alpha } }$ and $\beta$ , as $\frac { 1 } { \varphi ( n , M ) } \big ( X _ { \mathcal { T } ( 2 , 3 ) } ^ { \alpha , \beta } + X _ { \mathcal { T } ( 3 ) } ^ { \beta } \ast \alpha \big ) + 2 \lambda _ { n } ( \alpha - Z C )$ and $\frac { 1 } { 2 \varphi ( n , M ) } \big ( ( X _ { \mathcal { T } ( 1 , 2 ) } ^ { \alpha , \alpha } ) ^ { T } + X _ { \mathcal { T } ( 1 , 2 ) } ^ { T } ( \alpha * \alpha ) \big ) ,$ 174 respectively. Herein, \* denotes the Hadamard product (entry-wise product) between two matrices.
215
+
216
+ Let 175 $( { \tilde { \alpha } } , { \tilde { \beta } } )$ denote the solution given by one-step gradient descent, we then project $( { \tilde { \alpha } } , { \tilde { \beta } } )$ onto 176 $\Omega _ { \alpha } \times \Omega _ { \beta }$ in the following steps.
217
+
218
+ Step 1. Multiply the $r$ -th column of $\tilde { \alpha } _ { . , r }$ by $| | \tilde { \beta } _ { . , r } | | ^ { 1 / 2 }$ for $r \in [ R ]$ . Denote the resultant matrix as $\tilde { \alpha } ^ { \prime }$
219
+
220
+ Step 2. Regularize each row of $_ { \pmb { \alpha } }$ as $\begin{array} { r } { \pmb { \alpha } _ { i , . } = \tilde { \pmb { \alpha } } _ { i , . } ^ { \prime } \operatorname* { m i n } \{ \sqrt { \log \frac { \xi } { 1 - \xi } } , | | \tilde { \pmb { \alpha } } _ { i , . } ^ { \prime } | | \} / | | \tilde { \pmb { \alpha } } _ { i , . } ^ { \prime } | | , \mathbf { f } } \end{array}$ or $i \in [ n ]$ .
221
+
222
+ Step 3. Normalize the columns of 179 $\beta$ as $\beta _ { . , r } = \tilde { \beta } _ { . , r } / | | \tilde { \beta } _ { . , r } | |$ , for $r \in [ R ]$ .
223
+
224
+ Next, when $( \alpha , \beta )$ are given, we apply a $( 1 + \delta )$ -approximation K-means algorithm on $\tilde { \alpha }$ to update the vertex community membership matrix $z$ and community center matrix $C$ .
225
+
226
+ 182 The above steps will be alternatively conducted until convergence or reaching the maximum number
227
+ 183 of iterations. We further summarized the developed alternative updated scheme in Algorithm 1 in
228
+ 184 Appendix A of the supplementary materials
229
+ 185 Several remarks on the algorithm are in order. First, Algorithm 1 can only be guaranteed to converge
230
+ 186 to a stationary point but not any local minimizer. We hence employ a transformed higher order
231
+ 187 orthogonal iteration (HOOI) algorithm for warm initialization in all the numerical experiments in
232
+ 188 Section 4 and 5. Specifically, given a user-specific value $\tau$ , we define $\widetilde { \Theta }$ to mimic the magnitude
233
+ 189 of $\Theta$ such that $\widetilde { \Theta } _ { i , j , m } = - \tau$ if $a _ { i , j , m } = 0$ and $\widetilde { \Theta } _ { i , j , m } = \tau$ otherwise. A standard HOOI algorithm
234
+ 190 [11] is applied to $\Theta$ to obtain $\pmb { \alpha } ^ { ( 0 ) }$ and $\beta ^ { ( 0 ) }$ . We set $\tau = 1 0 0$ in all the numerical experiments.
235
+ 191 Second, the sparsity factor $s _ { n }$ is an intrinsic quantity of the multi-layer network data, and it should be
236
+ 192 estimated from the network directly. Note that the minimal and maximal probabilities for any vertex
237
+ 193 pair to form an edge in any layer are $p _ { \operatorname* { m i n } } = ( 1 - \xi ) s _ { n }$ and $p _ { \operatorname* { m a x } } = \xi s _ { n }$ , respectively. Interestingly,
238
+ 194 $p _ { \operatorname* { m i n } } + p _ { \operatorname* { m a x } } = s _ { n }$ , which does not depend on $\xi$ any more. Therefore, we propose to estimate $s _ { n }$ as
239
+
240
+ $$
241
+ \hat { s } _ { n } = \operatorname* { m i n } _ { i \in [ n ] } \frac { 1 } { n M } \sum _ { m = 1 } ^ { M } \sum _ { j = 1 } ^ { n } a _ { i , j , m } + \operatorname* { m a x } _ { i \in [ n ] } \frac { 1 } { n M } \sum _ { m = 1 } ^ { M } \sum _ { j = 1 } ^ { n } a _ { i , j , m } ,
242
+ $$
243
+
244
+ 195 which is the sum of the minimal and maximal frequencies of a vertex to form edges with all other
245
+ 196 vertices in all layers. Third, to optimally choose $\lambda _ { n }$ , we extend the network cross-validation by
246
+ 197 edge sampling scheme in [30] to multi-layer networks. The detailed tuning procedure is relegated to
247
+ 198 Appendix B in the supplementary materials.
248
+
249
+ # 3 Asymptotic theory
250
+
251
+ # 3.1 Consistency in estimating $\Theta ^ { * }$
252
+
253
+ 201 Let $\begin{array} { r } { \lambda = \left\{ \Theta = \mathbb { Z } \times _ { 1 } { \pmb \alpha } \times _ { 2 } { \pmb \alpha } \times _ { 3 } \beta : { \pmb \alpha } \in \Omega _ { \pmb { \alpha } } , \beta \in \Omega _ { \beta } \right\} } \end{array}$ } be the parameter space of the problem and
254
+ 202 203 $\Theta ^ { * } = \mathcal { T } \times _ { 1 } \pmb { \alpha } ^ { * } \times _ { 2 } \pmb { \alpha } ^ { * } \times _ { 3 } \beta ^ { * }$ $\begin{array} { r } { K L ( \boldsymbol { \Theta } ^ { * } | | \boldsymbol { \Theta } ) = \varphi ^ { - 1 } ( n , M ) \sum _ { m = 1 } ^ { M } \sum _ { i \leq j } E \bigl ( L ( \theta _ { i , j , m } ; a _ { i , j , m } ) - L ( \theta _ { i , j , m } ^ { * } ; a _ { i , j , m } ) \bigr ) } \end{array}$ ty tensor. Denote be the averaged
255
+ 204 Kullback–Leibler divergence of the network generation distributions parametrized by and , for
256
+ 205 any $\mathbf { \Theta } \Theta \in \Omega$ . The following large deviation inequality is derived to quantify the behavior of $\mathcal { L } _ { \lambda } ( \Theta ; \mathbf { \mathcal { A } } )$
257
+ 206 for any $\Theta$ in the neighborhood of $\Theta ^ { * }$ defined by $\dot { K } L ( \Theta ^ { * } | | \Theta )$ .
258
+
259
+ Proposition 1. Suppose 207 $\lambda _ { n } J ( \alpha ^ { * } ) \leq \epsilon _ { n }$ , and $( n + M ) R \varphi ^ { - 1 } ( n , M ) \epsilon _ { n } ^ { - 1 } \log ( \epsilon _ { n } ^ { - 1 / 2 } ) \leq c _ { 1 }$ for some constant 208 $c _ { 1 }$ . Then with probability at lease $\begin{array} { r } { 1 - 2 \exp \Big ( - \frac { \varphi ( n , M ) \epsilon _ { n } } { 1 5 6 \frac { \xi } { 1 - \xi } + 2 8 \log 2 } \Big ) } \end{array}$ , we have
260
+
261
+ $$
262
+ \mathcal { L } _ { \lambda } ( \Theta ^ { * } ; \mathcal { A } ) \leq \operatorname* { i n f } _ { \substack { \{ \Theta \in \Omega \vert K L ( \Theta ^ { * } \vert \vert \Theta ) \geq 4 \epsilon _ { n } \} } } \mathcal { L } _ { \lambda } ( \Theta ; \mathcal { A } ) - \epsilon _ { n } .
263
+ $$
264
+
265
+ 209 Proposition 1 basically states that any estimators with sufficiently small objective value should
266
+ 210 be close enough to $\Theta ^ { * }$ in terms of $K \dot { L } ( \Theta ^ { * } | | \Theta )$ . We next study the asymptotic behavior of these
267
+ 211 estimators more precisely. Let $( \hat { \alpha } , \hat { \beta } ) \in \Omega _ { \alpha } \times \Omega _ { \beta }$ be any estimator of $( \alpha ^ { * } , \beta ^ { * } )$ such that
268
+
269
+ $$
270
+ \begin{array} { r } { \mathcal L _ { \lambda } ( \hat { \alpha } , \hat { \beta } ; \mathcal A ) \le \mathcal L _ { \lambda } ( \alpha ^ { * } , \beta ^ { * } ; \mathcal A ) + \epsilon _ { n } , } \end{array}
271
+ $$
272
+
273
+ and denote 212 $\widehat { \Theta } = \mathcal { T } \times _ { 1 } \hat { \alpha } \times _ { 2 } \hat { \alpha } \times _ { 3 } \hat { \beta }$ . we have the following theorem.
274
+
275
+ Theorem 1. Under the condition of Proposition $^ { l }$ , $i f \left( { \hat { \alpha } } , { \hat { \beta } } \right)$ satisfies (8), then with probability at least $\begin{array} { r } { 1 - 2 \exp \Big ( - \frac { \varphi ( n , M ) \epsilon _ { n } } { 1 5 6 \frac { \xi } { 1 - \xi } + 2 8 \log 2 } \Big ) } \end{array}$ , we have
276
+
277
+ $$
278
+ \frac { 1 } { n \sqrt { M } } \| \widehat { \Theta } - \Theta ^ { * } \| _ { F } \leq \frac { 4 \sqrt { 2 } \sqrt { \epsilon _ { n } } } { ( 1 - \xi ) \sqrt { \xi s _ { n } } } .
279
+ $$
280
+
281
+ 213 The condition that $\lambda _ { n } J ( \Theta ^ { * } ) ~ \le ~ \epsilon _ { n }$ in Proposition 1 is mild. It implies that the true em
282
+ 214 beddings of vertices within the same community are close to one another. We remark that
283
+ 215 $\lambda _ { n } J ( \Theta ^ { * } )$ exactly equals to zero under the MLSBM discussed in Section 2.2. The condition that
284
+ 216 $( n + M ) R \varphi ^ { - 1 } ( n , M ) \epsilon _ { n } ^ { - 1 } \log ( \epsilon _ { n } ^ { - 1 / 2 } )$ vanishes with $n$ is also mild. When $R = O ( 1 )$ , we can take any
285
+ 217 ϵn such that ϵn ≫ log nn min{n,M} . Consequently, to ensure $\widehat { \Theta }$ converges to $\Theta ^ { * }$ , Theorem 1 implies the
286
+ 218 smallest sparsity factor one can take is $\begin{array} { r } { s _ { n } \gg \epsilon _ { n } \gg \frac { \log n } { n \operatorname* { m i n } \{ n , M \} } } \end{array}$ log nn min{n,M} , which means that the average degree
287
+ 219 of a vertex in any particular layer can be as small as $n s _ { n }$ . We remark that a common assumption
288
+ 220 $M = O ( n )$ that appears in literature, such as [27] and [22], is not necessary in our theory. If we
289
+ 221 further assume $\bar { M } \stackrel { } { = } O ( n )$ , we find that the average degree of a vertex in any layer under the
290
+ 222 proposed TLSM set up can be smaller than that in [27] by a factor $( M \log n ) ^ { - 1 / 2 }$ and in [22] by a
291
+ 223 factor $( \log n ) ^ { - 3 }$ , showing that our theoretical result accommodates sparser multi-layer networks.
292
+
293
+ # 3.2 Consistency in community detection
294
+
295
+ We now turn to establish the consistency of community detection in multi-layer network $\mathcal { G }$ . Let $\psi ^ { * } : [ n ] \ \longrightarrow \ [ K ]$ be the true community assignment function such that $\begin{array} { r l } { \psi ^ { * } } & { { } = } \end{array}$ $\begin{array} { r l } & { \arg \operatorname* { m i n } _ { \psi } \operatorname* { m i n } _ { C _ { 1 } , \ldots , C _ { K } } \sum _ { i = 1 } ^ { n } \| \pmb { \alpha } _ { i } ^ { * } - C _ { \psi _ { i } } \| ^ { 2 } } \end{array}$ , and then the community detection error of any estimated community assignment function $\hat { \psi }$ can be evaluated by the minimum scaled Hamming distance between $\hat { \psi }$ and $\psi ^ { * }$ under permutations, which is defined as
296
+
297
+ $$
298
+ \operatorname { e r r } ( \psi ^ { * } , \hat { \psi } ) = \operatorname* { m i n } _ { \pi \in S _ { K } } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \mathbf { 1 } \{ \psi _ { i } ^ { * } \neq \pi ( \hat { \psi } _ { i } ) \} ,
299
+ $$
300
+
301
+ 230 where $\mathbf { 1 } \{ \cdot \}$ is the indicator function and $S _ { K }$ is the symmetric group of degree $K$ . Such a scaled
302
+ 231 or unscaled Hamming distance has become a popular metric in quantifying the performance of
303
+ 232 community detection [21, 22].
304
+ 233 Denote $N _ { k } ^ { * } = \{ i : \psi _ { i } ^ { * } = k \}$ be the $k$ -th true underlying community whose cardinality is $n _ { k }$ . Let
305
+ 234 $C ^ { * } \in \mathbb { R } ^ { K \times R }$ be the true underlying community centers of the network embedding with $C _ { k . } ^ { * } =$
306
+ 235 $\begin{array} { r } { \frac { 1 } { n _ { k } } \sum _ { \psi _ { i } ^ { * } = k } \alpha _ { i . } ^ { * } } \end{array}$ , and let $\pmb { \mathcal { B } } ^ { \ast } = \pmb { \mathcal { T } } \times _ { 1 } \pmb { C } ^ { \ast } \times _ { 2 } \pmb { C } ^ { \ast } \times _ { 3 } \pmb { \beta } ^ { \ast }$ . The following assumptions are made to ensure
307
+ 236 that communities within the multi-layer networks are asymptotically identifiable.
308
+
309
+ Assumption A. Assume the difference between any two distinct horizontal slides of 37 ${ \pmb { \beta } } ^ { * }$ satisfies that
310
+
311
+ $$
312
+ \operatorname* { m i n } _ { k , k ^ { \prime } \in [ K ] , k \neq k ^ { \prime } } \frac { 1 } { \sqrt { K M } } \| \pmb { \mathscr { B } } _ { k , . , . } ^ { * } - \pmb { \mathscr { B } } _ { k ^ { \prime } , . , . } ^ { * } \| _ { F } \geq \gamma _ { n } ,
313
+ $$
314
+
315
+ 238 where $\gamma _ { n } > 0$ may vanish with $n$
316
+
317
+ Assumption B. Assume the tuning parameter $\lambda _ { n }$ satisfies that
318
+
319
+ $$
320
+ \begin{array} { r } { \lambda _ { n } \epsilon _ { n } s _ { n } ^ { - 2 } ( \log s _ { n } ^ { - 1 } ) ^ { - 1 } \geq c _ { 2 } , } \end{array}
321
+ $$
322
+
323
+ for an absolute constant $c _ { 2 }$ that does not depend on any model parameter.
324
+
325
+ Assumption C. Denote $n _ { \mathrm { m i n } } = \mathrm { m i n } _ { k \in [ K ] } n _ { k }$ as the minimal community size. Assume
326
+
327
+ $$
328
+ \frac { \gamma _ { n } n _ { \mathrm { m i n } } \sqrt { \cal K } } { n } \geq c _ { \xi } \sqrt { \frac { \epsilon _ { n } } { s _ { n } } } ,
329
+ $$
330
+
331
+ where cξ =240 $\begin{array} { r } { c _ { \xi } = \frac { 4 \sqrt 2 } { ( 1 - \xi ) \sqrt \xi } + c _ { 3 } \sqrt { \frac { ( 1 + \delta ) \operatorname* { m i n } \{ M , R \} } { M } } } \end{array}$ and $c _ { 3 }$ is a constant that depends on $\xi$ only.
332
+
333
+ 241 Assumption A is the minimal community separation requirement, and similar assumption has been
334
+ 242 employed in [27] with a constant $\gamma _ { n }$ . Together with the condition $\lambda _ { n } J ( \alpha ^ { * } ) \leq \epsilon _ { n }$ in Proposition 1,
335
+ 243 Assumption B gives a feasible interval for $\lambda _ { n }$ . Assumption $\textrm { C }$ allows for unbalanced communities
336
+ 244 with vanishing $n _ { \mathrm { m i n } } / n$ if the network is not too sparse. Note that $c _ { \xi }$ can be further bounded by
337
+ 245 $\begin{array} { r } { \frac { 4 \sqrt { 2 } } { ( 1 - \xi ) \sqrt { \xi } } + c _ { 3 } \sqrt { 1 + \delta } } \end{array}$ , and the first term of $c _ { \xi }$ will dominate the second term if $R = o ( M )$ .
338
+
339
+ Theorem 2. Suppose all the assumptions in Theorem $^ { l }$ as well as Assumptions $A , B$ and $C$ are satisfied, it holds true that
340
+
341
+ $$
342
+ e r r ( \psi ^ { * } , \hat { \psi } ) \leq \frac { c _ { \xi } ^ { 2 } n \epsilon _ { n } } { n _ { \mathrm { m i n } } K \gamma _ { n } ^ { 2 } s _ { n } } ,
343
+ $$
344
+
345
+ with probability at least 246 $\begin{array} { r } { 1 - \frac { 1 } { n ^ { 2 } } - 2 \exp \Big ( - \frac { \varphi ( n , M ) \epsilon _ { n } } { 1 5 6 \frac { \xi } { 1 - \xi } + 2 8 \log 2 } \Big ) . } \end{array}$
346
+
347
+ Theorem 2 assures that the community structure in a multi-layer network can be consistently recovered by the proposed TLSM. As a theoretical example, we consider a sparse case with $\begin{array} { r } { s _ { n } = \dot { \frac { ( \log n ) ^ { 1 + \tau _ { 1 } } } { n \operatorname* { m i n } \{ n , M \} } } } \end{array}$ , where $0 < \tau _ { 1 } < 1$ , $n _ { \mathrm { m a x } } = O ( n _ { \mathrm { m i n } } )$ , $\begin{array} { r } { \frac { 1 } { \sqrt { n } } | | \alpha ^ { * } - Z ^ { * } C ^ { * } | | _ { F } \leq ( \log n ) ^ { - 3 / 2 } } \end{array}$ , and both $\gamma _ { n }$ , $R$ and $K$ are of constant orders. With $\begin{array} { r } { \lambda _ { n } = \frac { ( \log n ) ^ { 2 + 2 \tau _ { 1 } } } { n \operatorname* { m i n } \{ n , M \} } } \end{array}$ , Theorems 1 and 2 imply that $\begin{array} { r } { \epsilon _ { n } = \frac { ( \log n ) ^ { 1 + \tau _ { 2 } } } { n \operatorname* { m i n } \{ n , M \} } } \end{array}$ with $0 < \tau _ { 2 } < \tau _ { 1 }$ and $e r r ( \psi ^ { * } , \hat { \psi } ) = o _ { p } ( 1 )$ .
348
+
349
+ # 52 4 Numerical experiments
350
+
351
+ In this section, we evaluate the numerical performance of the proposed TLSM in a variety of synthetic as well as real-life multi-layer networks, compare it against four competitors in literature, including the mean adjacency spectral embeddings (MASE; 16), least square estimation (LSE; 27), Tucker decomposition with HOSVD initialization (HOSVD-Tucker; 22), and spectral kernel (SPECK; 35), and conduct some ablation studies. The implementations of LSE and SPECK are available at the authors’ personal websites, HOSVD-Tucker is implemented in the routine “tucker" of the Python package “tensorly", and TLSM and MASE are implemented in Python by ourselves.
352
+
353
+ # 4.1 Synthetic networks
354
+
355
+ The multi-layer network $\mathcal { A } = ( a _ { i , j , m } ) \in \{ 0 , 1 \} ^ { n \times n \times M }$ is generated as follows. First, we randomly select $K = 4$ elements uniformly from $\{ 2 . 5 * ( b _ { 1 } , b _ { 2 } , \ldots , b _ { R } ) : b _ { r } \in \{ - 1 , 1 \} , r \in [ R ] \}$ as community centers, which are denoted as $c _ { k }$ , $k \in [ K ]$ . Second, the latent space embedding of vertex $i$ is generated as $\pmb { \alpha } _ { i } = \pmb { c } _ { \psi _ { i } } + \pmb { e } _ { i }$ with $\pmb { e } _ { i } \sim N ( \mathbf { 0 } _ { R } , 1 . 5 * I _ { R } )$ , and $\psi _ { i } \in [ K ]$ are independently drawn from the multinomial distribution $\mathbf { M u l t i } ( 1 ; \frac { 1 } { K } \mathbf { 1 } _ { K } )$ . Third, we generate $\beta = [ \beta _ { 1 } , \ldots , \beta _ { M } ] ^ { T }$ with $\beta _ { m , r }$ being independent standard normal random varibeles, for $m \in [ M ]$ and $r \in [ R ]$ . We then rescale the column norms of $\beta$ to be 1 for model identifiability. Finally, we generate $\mathcal { A }$ according to the proposed TLSM with $s _ { n } = 0 . 1$ . For the sake of fair comparisons, the embedding dimension $R$ is set as $K$ in all scenarios. We aim to illustrate the community detection performance of all methods as the number of vertices and number of layers increase. To this end, we consider $( n , M ) \in \{ 2 0 0 , 4 0 0 , 6 0 0 , 8 0 0 \} \times \{ 5 , 1 0 , 1 5 , 2 0 \}$ . The averaged hamming errors and their standard errors over 50 independent experiments of all methods are reported in Table 1.
356
+
357
+ 273 It is evident that TLSM consistently outperforms its competitors, and the performances of LSE
358
+ 274 and HOSVD-Tucker are better than those of MASE and SPECK. This is expected since TLSM,
359
+ 275 LSE and HOSVD-Tucker work on the multi-layer network adjacency tensor directly, while MASE
360
+ 276 and SPECK are matrix aggregation methods that suffer form information loss. Furthermore, as the
361
+ 277 number of vertices and number of layers increase, the community detection errors of all methods
362
+ 278 decrease rapidly. Notably, TLSM and LSE converge faster than the other methods, and attain stable
363
+ 279 performance even for relatively small $n$ and $M$ . Additional simulation studies for various network
364
+ 280 sparsity and unbalanced community sizes are relegated to Appendix C in the supplementary materials.
365
+
366
+ # 4.2 Real-life networks
367
+
368
+ 282 We also apply the proposed TLSM method to analyze three real-life multi-layer networks, including
369
+ 283 a social network in the department of Computer Science at Aarhus University (AUCS) [38], a yeast
370
+ 284 Saccharomyces cerevisiae gene co-expression (YSCGC) network [44], and a worldwide agriculture
371
+ 285 trading network (WAT) [10]. Specifically, we conduct community detection on the first two networks
372
+ 286 whose vertex community memberships are available, and carry out a link prediction task on the third
373
+ 287 network whose vertex community memberships are unavailable.
374
+
375
+ Table 1: The averaged hamming errors of various methods with their standard errors in Scenario I. The best performer in each case is bold-faced.
376
+
377
+ <table><tr><td>n</td><td>M</td><td>TLSM</td><td>LSE</td><td>MASE</td><td>HOSVD-Tucker</td><td>SPECK</td></tr><tr><td rowspan="4">200</td><td>5</td><td>0.1180(0.0147)</td><td>0.1405(0.0118)</td><td>0.5086(0.0136)</td><td>0.1623(0.0126)</td><td>0.4254(0.0138)</td></tr><tr><td>10</td><td>0.0585(0.0046)</td><td>0.0751(0.0050)</td><td>0.4949(0.0131)</td><td>0.1148(0.0106)</td><td>0.2996(0.0141)</td></tr><tr><td>15</td><td>0.0551(0.0067)</td><td>0.0593(0.0045)</td><td>0.4910(0.0176)</td><td>0.1040(0.0115)</td><td>0.2505(0.0142)</td></tr><tr><td>20</td><td>0.0510(0.0037)</td><td>0.0588(0.0043)</td><td>0.4977(0.0161)</td><td>0.1023(0.0110)</td><td>0.1942(0.0156)</td></tr><tr><td rowspan="4">400</td><td>5</td><td>0.0653(0.0066)</td><td>0.1019(0.0087)</td><td>0.3845(0.0193)</td><td>0.1220(0.0106)</td><td>0.3766(0.0195)</td></tr><tr><td>10</td><td>0.0608(0.0063)</td><td>0.0636(0.0037)</td><td>0.3859(0.0160)</td><td>0.1012(0.0092)</td><td>0.2244(0.0191)</td></tr><tr><td>15</td><td>0.0511(0.0031)</td><td>0.0595(0.0036)</td><td>0.3844(0.0221)</td><td>0.0787(0.0051)</td><td>0.1490(0.0123)</td></tr><tr><td>20</td><td>0.0536(0.0047)</td><td>0.0551(0.0036)</td><td>0.3985(0.0185)</td><td>0.0795(0.0063)</td><td>0.1409(0.0131)</td></tr><tr><td rowspan="4">600</td><td>5</td><td>0.0607(0.0029)</td><td>0.0909(0.0040)</td><td>0.3665(0.0186)</td><td>0.1221(0.0108)</td><td>0.3038(0.0193)</td></tr><tr><td>10</td><td>0.0567(0.0029)</td><td>0.0688(0.0031)</td><td>0.3726(0.0179)</td><td>0.1003(0.0081)</td><td>0.1651(0.0127)</td></tr><tr><td>15</td><td>0.0558(0.0027)</td><td>0.0630(0.0030)</td><td>0.3803(0.0167)</td><td>0.0918(0.0076)</td><td>0.1231(0.0076)</td></tr><tr><td>20</td><td>0.0548(0.0028)</td><td>0.0586(0.0029)</td><td>0.3814(0.0185)</td><td>0.0883(0.0078)</td><td>0.1150(0.0088)</td></tr><tr><td rowspan="4">800</td><td>5</td><td>0.0556(0.0056)</td><td>0.0768(0.0055)</td><td>0.3012(0.0194)</td><td>0.1003(0.0103)</td><td>0.2733(0.0171)</td></tr><tr><td>10</td><td>0.0560(0.0063)</td><td>0.0583(0.0034)</td><td>0.3004(0.0177)</td><td>0.0788(0.0065)</td><td>0.1424(0.0127)</td></tr><tr><td>15</td><td>0.0498(0.0030)</td><td>0.0539(0.0033)</td><td>0.3179(0.0195)</td><td>0.0812(0.0068)</td><td>0.1146(0.0098)</td></tr><tr><td>20</td><td>0.0485(0.0031)</td><td>0.0516(0.0032)</td><td>0.3184(0.0218)</td><td>0.0803(0.0075)</td><td>0.0979(0.0078)</td></tr></table>
378
+
379
+ The AUCS dataset is publicly available at http://multilayer.it.uu.se/datasets.html, and it is a $6 1 \times 6 1 \times 5$ multi-layer network that records pairwise relationships of 5 types among 61 persons in AUCS, including current working relationships, repeated leisure activities, regularly eating lunch together, co-authorship of a publication, and friendship on Facebook. Since 54 persons in the dataset come from 7 research groups and the other 7 persons do not belong to any group, the dataset consists of 8 communities corresponding to 7 research groups and an outlier community. Applying TLSM and its competitors to the dataset, the number of misclassified vertices by TLSM, LSE, MASE, HOSVD-Tucker and SPECK, are 8, 21, 19, 23, 18, respectively. Clearly, TLSM significantly outperforms its competitors by at least reducing $1 6 . 3 9 \%$ of community detection error.
380
+
381
+ The YSCGC dataset is publicly available at https://www.ncbi.nlm.nih.gov/pmc/articles/ $\mathtt { P M C 1 5 6 5 9 0 } /$ , and contains 205 genes of 4 functional categories, including protein metabolism and modification, carbohydrate metabolism and catabolism, nucleobase, nucleoside, nucleotide and nucleic acide metabolism, as well as transportation. We regard these four functional category labels as the community memberships of the genes. Further, the gene expression responses are measured by 20 systematic perturbations with varying genetic and environmental conditions in 4 replicated hybridizations. We thus constructed a gene co-expression network $\mathcal { A } = ( a _ { i , j , m } ) \in$ $\mathbb { R } ^ { 2 0 \bar { 5 } \times 2 0 5 \times 4 }$ based on the similarities of their expressions, where each layer represents one replicated hybridization. Specifically, the similarity between genes $i$ and $j$ in the $m$ -th replication is measured by $w _ { i , j , m } = \mathrm { e x p } \big ( - \| \pmb { x } _ { i } ^ { ( m ) } - \pmb { x } _ { j } ^ { ( m ) } \| \big )$ , where $\pmb { x } _ { i } ^ { ( m ) } \in \mathbb { R } ^ { 2 0 }$ contains the expression levels of 20 perturbations in the $m$ -th replicated hybridization for $i \in [ 2 0 5 ]$ and $m \in [ 4 ]$ . The binary value $a _ { i , j , m }$ is obtained by thresholding $w _ { i , j , m }$ with the thresholding value being the $60 \%$ quantile of all elements in $\{ w _ { i , j , m } : i \le j \in [ 2 0 5 ] , m \in [ 4 ] \}$ . Applying TLSM and its competitors to this dataset, the number of misclassified vertices by TLSM, LSE, MASE, HOSVD-Tucker and SPECK, are 6, 9, 12, 48, 13, respectively. TLSM again outperforms its competitors in this YSCGC dataset.
382
+
383
+ 312 The WAT dataset is publicly available at http://www.fao.org, and includes 364 agriculture
384
+ 313 product trading relationships among 214 countries in 2010. To process the data, we extract 130 major
385
+ 314 countries whose average degrees are greater than 9 from the 32 densest connected agriculture product
386
+ 315 trading relations, leading to a $1 3 0 \times 1 3 0 \times 3 2$ multi-layer network. Investigating the eigen-structure
387
+ 316 of the mode-1 matricization of the network adjacency tensor, we identify an elbow point [20] at the
388
+ 317 7th largest eigen-value, suggesting there are 6 potential communities among the countries, and thus
389
+ 318 we set $K = 6$ . The corresponding eigen-value plot is attached in Appendex D of the supplementary
390
+ 319 materials. We then randomly selected $8 0 \%$ of the entries of the adjacency tensor as the training set,
391
+ 320 and conduct link prediction on the remaining $2 0 \%$ of the entries. Specifically, we employ TLSM
392
+ 321 and the adaptations of its competitors to estimate the network expected tensor $\mathcal { P }$ and generate
393
+ 322 estimations for the missing entries by independent Bernoulli random variables accordingly. The
394
+ 323 averaged link prediction accuracy of TLSM, LSE, MASE, HOSVD-Tucker and SPECK over 50
395
+ 324 independent replications are $7 9 . 6 0 \%$ , $7 6 . 6 6 \%$ , $7 5 . 9 6 \%$ , $7 7 . 7 8 \%$ and $7 9 . 0 8 \%$ , respectively, where the
396
+ 325 link prediction accuracy is defined as the percentile of the correctly predicted entries. Clearly, all 5
397
+ 326 methods are comparative in terms of link prediction, while TLSM still deliver highest averaged link
398
+ 327 prediction accuracy.
399
+
400
+ # 328 4.3 Ablation studies
401
+
402
+ In this subsection, we carry out some ablation studies on two novel components of the proposed method, namely the sparsity factor $s _ { n }$ and the community-inducing regularizer $J ( \alpha )$ . To study the effectiveness of $s _ { n }$ , we generate a $3 0 0 \times 3 0 0 \times 5$ multi-layer network with 3 communities and the true network sparsity $s _ { n } = 0 . 3$ . The blue curve in the left panel of Figure 1 shows the average Hamming error of 50 independent replications given by the proposed method when employing $\hat { s } _ { n } \in \{ 0 . 0 5 i : i \in [ 2 0 ] \}$ in the optimization algorithm, and the red line indicates the averaged Hamming error of the proposed method with $\hat { s } _ { n }$ estimated via the proposed data-adapted estimation scheme. It is clear that the Hamming error at $s _ { n } = 1$ is much larger than that when $s _ { n }$ is close to 0.3, showing the advantages of the modified logit transformation by $s _ { n }$ over the standard logit transformation when the network indeed reveals sparse pattern. Moreover, we observe that the red line is even lower than the minimum Hamming error in the blue curve. This further confirms the effectiveness of the proposed data-adapted estimation scheme for estimating $s _ { n }$ .
403
+
404
+ ![](images/c331ba0dbd825a27deb1e7af3e215fd861180ab5cae8dc4dc8e45ed78969d719.jpg)
405
+ Figure 1: Ablation studies on $s _ { n }$ (left) and community-inducing regularizer (right).
406
+
407
+ 341 To study the effectiveness of the community-inducing regularizer in the proposed objective function,
408
+ 342 we generate an $n \times n \times 5$ multi-layer network with 2 communities, for $\overline { { n } } \in \{ 5 0 , 1 0 \mathrm { { 0 } } , 2 0 0 , 4 0 0 \}$ . In
409
+ 343 the right panel of Figure 1, the black pillars indicate the network estimation error $\frac { 1 } { n \sqrt { 5 } } \| \widehat { \Theta } - \Theta ^ { * } \| _ { F }$
410
+ 344 given by the proposed method with $\lambda _ { n } = 0$ which corresponds to the absence of $J ( \alpha )$ , while the
411
+ 345 red ones indicate the counterparts given by the proposed method with $\lambda _ { n }$ is selected by network
412
+ 346 cross-validation. There is a clear improvement when the community-inducing regularizer is enforced
413
+ 347 in all scenarios, particularly for small $n$ . This showcases the helpfulness of the community-inducing
414
+ 348 regularizer in detecting network community structure.
415
+
416
+ # 349 5 Conclusions
417
+
418
+ 50 In this paper, we propose a novel tensor-based latent space model for community detection in
419
+ 51 multi-layer networks. The model embeds vertices into a low-dimensional latent space and views
420
+ 52 the community structure from an network embedding perspective, so that heterogeneous structures
421
+ 53 in different network layers can be properly integrated. The proposed model is formulated as a
422
+ 54 regularization framework, which conducts multi-layer network estimation and community detection
423
+ 55 simultaneously. The advantages of the proposed method are supported by extensive numerical
424
+ 56 experiments and theoretical results. Particularly, the asymptotic consistencies of the proposed method
425
+ 57 are established in terms of both multi-layer network estimation and community detection, even for
426
+ 58 relatively sparse networks.
427
+
428
+ 359 References [1] Luiz GA Alves, Giuseppe Mangioni, Isabella Cingolani, Francisco Aparecido Rodrigues, Pietro Panzarasa, and Yamir Moreno. The nested structural organization of the worldwide trade multi-layer network. Scientific reports, 9(1):1–14, 2019. [2] Jesús Arroyo, Avanti Athreya, Joshua Cape, Guodong Chen, Carey E Priebe, and Joshua T Vogelstein. Inference for multiple heterogeneous networks with a common invariant subspace. Journal of Machine Learning Research, 22(142):1–49, 2021. [3] Avanti Athreya, Donniell E Fishkind, Minh Tang, Carey E Priebe, Youngser Park, Joshua T Vogelstein, Keith Levin, Vince Lyzinski, and Yichen Qin. Statistical inference on random dot product graphs: a survey. The Journal of Machine Learning Research, 18(1):8393–8484, 2017. [4] Matteo Barigozzi, Giorgio Fagiolo, and Giuseppe Mangioni. Identifying the community structure of the international-trade multi-network. Physica A: statistical mechanics and its applications, 390(11):2051–2066, 2011. [5] Michele Berlingerio, Fabio Pinelli, and Francesco Calabrese. Abacus: frequent pattern miningbased community discovery in multidimensional networks. Data Mining and Knowledge Discovery, 27(3):294–320, 2013. [6] Sharmodeep Bhattacharyya and Shirshendu Chatterjee. Spectral clustering for multiple sparse networks: I. arXiv preprint arXiv:1805.10594, 2018. [7] Han Chen, Garvesh Raskutti, and Ming Yuan. Non-convex projected gradient descent for generalized low-rank tensor regression. Journal of Machine Learning Research, 20:1–37, 2019. [8] Zitai Chen, Chuan Chen, Zibin Zheng, and Yi Zhu. Tensor decomposition for multilayer networks clustering. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 3371–3378, 2019. [9] Eric C Chi, Brian R Gaines, Will Wei Sun, Hua Zhou, and Jian Yang. Provable convex co-clustering of tensors. Journal of Machine Learning Research, 21(214):1–58, 2020. [10] Manlio De Domenico, Vincenzo Nicosia, Alexandre Arenas, and Vito Latora. Structural reducibility of multilayer networks. Nature communications, 6(1):1–9, 2015.
429
+ 386 [11] Lieven De Lathauwer, Bart De Moor, and Joos Vandewalle. On the best rank-1 and rank-(r 1, r 2,..., rn) approximation of higher-order tensors. SIAM journal on Matrix Analysis and Applications, 21(4):1324–1342, 2000. [12] Xiaowen Dong, Pascal Frossard, Pierre Vandergheynst, and Nikolai Nefedov. Clustering with multi-layer graphs: A spectral perspective. IEEE Transactions on Signal Processing, 60(11):5820–5831, 2012. [13] Junxian Geng, Anirban Bhattacharya, and Debdeep Pati. Probabilistic community detection with unknown number of communities. Journal of the American Statistical Association, 114(526):893–905, 2019.
430
+ 395 [14] Mahsa Ghorbani, Mahdieh Soleymani Baghshah, and Hamid R Rabiee. Mgcn: semi-supervised classification in multi-layer graphs with graph convolutional networks. In Proceedings of the 2019 IEEE/ACM International Conference on Advances in Social Networks Analysis and Mining, pages 208–211, 2019. [15] Derek Greene and Pádraig Cunningham. Producing a unified graph representation from multiple social network views. In Proceedings of the 5th annual ACM web science conference, pages 118–121, 2013. [16] Qiuyi Han, Kevin Xu, and Edoardo Airoldi. Consistent estimation of dynamic and multi-layer block models. In International Conference on Machine Learning, pages 1511–1520. PMLR, 2015. [17] Xin He, Qiong Liu, and You Yang. Mv-gnn: Multi-view graph neural network for compression artifacts reduction. IEEE Transactions on Image Processing, 29:6829–6840, 2020.
431
+ [18] Peter D Hoff, Adrian E Raftery, and Mark S Handcock. Latent space approaches to social network analysis. Journal of the American Statistical Association, 97(460):1090–1098, 2002.
432
+ [19] Paul W Holland, Kathryn Blackmond Laskey, and Samuel Leinhardt. Stochastic blockmodels: First steps. Social networks, 5(2):109–137, 1983.
433
+ [20] Pengsheng Ji and Jiashun Jin. Coauthorship and citation networks for statisticians. The Annals of Applied Statistics, 10(4):1779–1812, 2016.
434
+ [21] Jiashun Jin. Fast community detection by score. Ann. Statist., 43(1):57–89, 02 2015.
435
+ [22] Bing-Yi Jing, Ting Li, Zhongyuan Lyu, and Dong Xia. Community detection on mixture multilayer networks via regularized tensor decomposition. The Annals of Statistics, 49(6):3181– 3205, 2021.
436
+ [23] Muhammad Raza Khan and Joshua E Blumenstock. Multi-gcn: Graph convolutional networks for multi-view networks, with applications to global poverty. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 606–613, 2019.
437
+ [24] Tamara G. Kolda and Brett W. Bader. Tensor decompositions and applications. SIAM Review, 51:455–500, 2009.
438
+ [25] Joseph B Kruskal. Three-way arrays: rank and uniqueness of trilinear decompositions, with application to arithmetic complexity and statistics. Linear algebra and its applications, 18(2):95– 138, 1977.
439
+ [26] Jing Lei. Tail bounds for matrix quadratic forms and bias adjusted spectral clustering in multi-layer stochastic block models. arXiv preprint arXiv:2003.08222, 2020.
440
+ [27] Jing Lei, Kehui Chen, and Brian Lynch. Consistent community detection in multi-layer network data. Biometrika, 107(1):61–73, 2020.
441
+ [28] Jing Lei and Alessandro Rinaldo. Consistency of spectral clustering in stochastic block models. The Annals of Statistics, 43(1):215–237, 2015.
442
+ [29] Dong Li, Zhisong Pan, Guyu Hu, Graham Anderson, and Shan He. Active module identification from multilayer weighted gene co-expression networks: a continuous optimization approach. IEEE/ACM transactions on computational biology and bioinformatics, 2020.
443
+ [30] Tianxi Li, Elizaveta Levina, and Ji Zhu. Network cross-validation by edge sampling. Biometrika, 107(2):257–276, 2020.
444
+ [31] Xueming Liu, Enrico Maiorino, Arda Halu, Kimberly Glass, Rashmi B Prasad, Joseph Loscalzo, Jianxi Gao, and Amitabh Sharma. Robustness and lethality in multilayer biological molecular networks. Nature communications, 11(1):1–12, 2020.
445
+ [32] Zhongyuan Lyu, Dong Xia, and Yuan Zhang. Latent space model for higher-order networks and generalized tensor decomposition. arXiv preprint arXiv:2106.16042, 2021.
446
+ [33] Zhuang Ma, Zongming Ma, and Hongsong Yuan. Universal latent space model fitting for large networks with edge covariates. Journal of Machine Learning Research, 21(4):1–67, 2020.
447
+ [34] Subhadeep Paul and Yuguo Chen. Consistent community detection in multi-relational data through restricted multi-layer stochastic blockmodel. Electronic Journal of Statistics, 10(2):3807–3870, 2016.
448
+ [35] Subhadeep Paul and Yuguo Chen. Spectral and matrix factorization methods for consistent community detection in multi-layer networks. Ann. Statist., 48(1):230–250, 02 2020.
449
+ [36] Subhadeep Paul and Yuguo Chen. Null models and community detection in multi-layer networks. Sankhya A, pages 1–55, 2021.
450
+ [37] Zhuo-Ming Ren, An Zeng, and Yi-Cheng Zhang. Bridging nestedness and economic complexity in multilayer world trade networks. Humanities and Social Sciences Communications, 7(1):1–8, 2020.
451
+ [38] Luca Rossi and Matteo Magnani. Towards effective visual analytics on multiplex and multilayer networks. Chaos, Solitons & Fractals, 72:68–76, 2015.
452
+ [39] Uday Shankar Shanthamallu, Jayaraman J Thiagarajan, Huan Song, and Andreas Spanias. Gramme: Semisupervised learning using multilayered graph attention models. IEEE transactions on neural networks and learning systems, 31(10):3977–3988, 2019.
453
+ [40] Nicholas D Sidiropoulos and Rasmus Bro. On the uniqueness of multilinear decomposition of n-way arrays. Journal of Chemometrics: A Journal of the Chemometrics Society, 14(3):229–239, 2000.
454
+ [41] Wei Tang, Zhengdong Lu, and Inderjit S Dhillon. Clustering with multiple graphs. In 2009 Ninth IEEE International Conference on Data Mining, pages 1016–1021. IEEE, 2009.
455
+ [42] Edwin JCG Van Den Oord and Ronan Van Rossem. Differences in first graders’ school adjustment: The role of classroom characteristics and social structure of the group. Journal of School Psychology, 40(5):371–394, 2002.
456
+ [43] James D Wilson, John Palowitch, Shankar Bhamidi, and Andrew B Nobel. Community extraction in multilayer networks with heterogeneous community structure. The Journal of Machine Learning Research, 18(1):5458–5506, 2017.
457
+ [44] Ka Yee Yeung, Mario Medvedovic, and Roger E Bumgarner. Clustering gene-expression data with repeated measurements. Genome biology, 4(5):1–17, 2003.
458
+ [45] Yubai Yuan and Annie Qu. Community detection with dependent connectivity. The Annals of Statistics, 49(4):2378–2428, 2021.
459
+ [46] Jingfei Zhang, Will Wei Sun, and Lexin Li. Network response regression for modeling population of networks with covariates. arXiv preprint arXiv:1810.03192, 2018.
460
+ [47] Xuefei Zhang, Songkai Xue, and Ji Zhu. A flexible latent space model for multilayer networks. In International Conference on Machine Learning, pages 11288–11297. PMLR, 2020.
461
+ [48] Yunpeng Zhao, Elizaveta Levina, and Ji Zhu. Consistency of community detection in networks under degree-corrected stochastic block models. The Annals of Statistics, 40(4):2266–2292, 2012.
462
+ [49] Wei Zheng, Dingjie Wang, and Xiufen Zou. Control of multilayer biological networks and applied to target identification of complex diseases. BMC bioinformatics, 20(1):1–12, 2019.
463
+
464
+ # Checklist
465
+
466
+ 1. For all authors...
467
+
468
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See the abstract and the third paragrath of the introduction.
469
+ (b) Did you describe the limitations of your work? [Yes] The optimization algorithm can only be guaranteed to converge to a stationary point.
470
+ (c) Did you discuss any potential negative societal impacts of your work? [No] There should be no negative societal impacts.
471
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
472
+
473
+ 2. If you are including theoretical results...
474
+
475
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 3. (b) Did you include complete proofs of all theoretical results? [Yes] All technical proofs are provided in Appendix E of the supplementary materials.
476
+
477
+ 3. If you ran experiments...
478
+
479
+ (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 URLs for data are included in Section 4.2, and codes with instructions are included in the supplementary materials.
480
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 2.3 and Appendix B in the supplementary materials.
481
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We show the standard erros in Table 1 and $9 5 \%$ confident intervals of additional simulation studies in Appendix C in the supplementary materials.
482
+ (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]
483
+
484
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
485
+
486
+ (a) If your work uses existing assets, did you cite the creators? [Yes] We used publicly available datasets and cite the creators.
487
+ (b) Did you mention the license of the assets? [Yes] All datasets we used are publicly available.
488
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
489
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
490
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] All data we used do not contains personally identifiable information or offensive content.
491
+
492
+ 5. If you used crowdsourcing or conducted research with human subjects...
493
+
494
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
495
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
496
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/tq_J_MqB3UB/tq_J_MqB3UB.md ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Diverse Weight Averaging for Out-of-Distribution Generalization
2
+
3
+ Alexandre Ramé1,\*, Matthieu Kirchmeyer1,2,\*
4
+ Thibaud Rahier2, Alain Rakotomamonjy2,4, Patrick Gallinari1,2, Matthieu Cord1,3
5
+ 1Sorbonne Université, CNRS, ISIR, F-75005 Paris, France 2Criteo AI Lab, Paris, France 3Valeo.ai, Paris, France 4Université de Rouen, LITIS, France \*Equal contribution
6
+
7
+ # Abstract
8
+
9
+ Standard neural networks struggle to generalize under distribution shifts in computer vision. Fortunately, combining multiple networks can consistently improve out-of-distribution generalization. In particular, weight averaging (WA) strategies were shown to perform best on the competitive DomainBed benchmark; they directly average the weights of multiple networks despite their nonlinearities. In this paper, we propose Diverse Weight Averaging (DiWA), a new WA strategy whose main motivation is to increase the functional diversity across averaged models. To this end, DiWA averages weights obtained from several independent training runs: indeed, models obtained from different runs are more diverse than those collected along a single run thanks to differences in hyperparameters and training procedures. We motivate the need for diversity by a new bias-variance-covariancelocality decomposition of the expected error, exploiting similarities between WA and standard functional ensembling. Moreover, this decomposition highlights that WA succeeds when the variance term dominates, which we show occurs when the marginal distribution changes at test time. Experimentally, DiWA consistently improves the state of the art on DomainBed without inference overhead.
10
+
11
+ # 1 Introduction
12
+
13
+ Learning robust models that generalize well is critical for many real-world applications [1, 2]. Yet, the classical Empirical Risk Minimization (ERM) lacks robustness to distribution shifts [3, 4, 5]. To improve out-of-distribution (OOD) generalization in classification, several recent works proposed to train models simultaneously on multiple related but different domains [6]. Though theoretically appealing, domain-invariant approaches [7] either underperform [8, 9] or only slightly improve [10, 11] ERM on the reference DomainBed benchmark [12]. The state-of-the-art strategy on DomainBed is currently to average the weights obtained along a training trajectory [13]. [14] argues that this weight averaging (WA) succeeds in OOD because it finds solutions with flatter loss landscapes.
14
+
15
+ In this paper, we show the limitations of this flatness-based analysis and provide a new explanation for the success of WA in OOD. It is based on WA’s similarity with ensembling [15], a well-known strategy to improve robustness [16, 17], that averages the predictions from various models. Based on [18], we present a bias-variance-covariance-locality decomposition of WA’s expected error. It contains four terms: first the bias that we show increases under shift in label posterior distributions (i.e., correlation shift [19]); second, the variance that we show increases under shift in input marginal distributions (i.e., diversity shift [19]); third, the covariance that decreases when models are diverse; finally, a locality condition on the weights of averaged models.
16
+
17
+ Based on this analysis, we aim at obtaining diverse models whose weights are averageable with our Diverse Weight Averaging (DiWA) approach. In practice, DiWA averages in weights the models obtained from independent training runs that share the same initialization. The motivation is that those models are more diverse than those obtained along a single run [20, 21]. Yet, averaging the weights of independently trained networks with batch normalization [22] and ReLU layers [23] may be counter-intuitive. Such averaging is efficient especially when models can be connected linearly in the weight space via a low loss path. Interestingly, this linear mode connectivity property [24] was empirically validated when the runs start from a shared pretrained initialization [25]. This insight is at the heart of DiWA but also of other recent works [26, 27, 28], as discussed in Section 6.
18
+
19
+ In summary, our main contributions are the following:
20
+
21
+ • We propose a new theoretical analysis of WA for OOD based on a bias-variance-covariancelocality decomposition of its expected error (Section 2). By relating correlation shift to its bias and diversity shift to its variance, we show that WA succeeds under diversity shift. • We empirically tackle the covariance term by increasing the diversity across models averaged in weights. In our DiWA approach, we decorrelate their training procedures: in practice, these models are obtained from independent runs (Section 3). We then empirically validate that diversity improves OOD performance (Section 4) and show that DiWA is state of the art on all real-world datasets from the DomainBed benchmark [12] (Section 5).
22
+
23
+ # 2 Theoretical insights
24
+
25
+ Under the setting described in Section 2.1, we introduce WA in Section 2.2 and decompose its expected OOD error in Section 2.3. Then, we separately consider the four terms of this bias-variancecovariance-locality decomposition in Section 2.4. This theoretical analysis will allow us to better understand when WA succeeds, and most importantly, how to improve it empirically in Section 3.
26
+
27
+ # 2.1 Notations and problem definition
28
+
29
+ Notations. We denote $\mathcal { X }$ the input space of images, $\mathcal { V }$ the label space and $\ell : \mathcal { V } ^ { 2 } \to \mathbb { R } _ { + }$ a loss function. $S$ is the training (source) domain with distribution $p _ { S }$ , and $T$ is the test (target) domain with distribution $p _ { T }$ . For simplicity, we will indistinctly use the notations $p _ { S }$ and $p _ { T }$ to refer to the joint, posterior and marginal distributions of $( X , Y )$ . We note $f _ { S } , f _ { T } : \mathcal { X } \to \mathcal { Y }$ the source and target labeling functions. We assume that there is no noise in the data: then $f _ { S }$ is defined on $\mathcal { X } _ { S } \ \triangleq \ \{ x \ \in \ \mathcal { X } / p _ { S } ( x ) \ > \ 0 \}$ by $\forall ( x , y ) \sim p _ { S } , f _ { S } ( x ) = y$ and similarly $f _ { T }$ is defined on $\mathcal { X } _ { T } \triangleq \{ x \in \mathcal { X } / p _ { T } ( x ) > 0 \}$ by $\forall ( x , y ) \sim p _ { T } , f _ { T } ( x ) = y$ .
30
+
31
+ Problem. We consider a neural network (NN) $f ( \cdot , \theta ) : \mathcal { X } \to \mathcal { Y }$ made of a fixed architecture $f$ with weights $\theta$ . We seek $\theta$ minimizing the target generalization error:
32
+
33
+ $$
34
+ \mathcal { E } _ { T } ( \theta ) = \mathbb { E } _ { ( x , y ) \sim p _ { T } } [ \ell ( f ( x , \theta ) , y ) ] .
35
+ $$
36
+
37
+ $f ( \cdot , \theta )$ should approximate $f _ { T }$ on $\mathcal { X } _ { T }$ . However, this is complex in the OOD setup because we only have data from domain $S$ in training, related yet different from $T$ . The differences between $S$ and $T$ are due to distribution shifts (i.e., the fact that $p _ { S } ( X , Y ) \neq p _ { T } ( X , Y ) )$ which are decomposed per [19] into diversity shift (a.k.a. covariate shift), when marginal distributions differ (i.e., $p _ { S } ( { \bar { X } } ) \not = { \bar { p } } _ { T } ( X ) )$ , and correlation shift (a.k.a. concept shift), when posterior distributions differ (i.e., $p _ { S } ( Y | X ) \neq$ $p _ { T } ( Y | X )$ and $f _ { S } \neq f _ { T } ,$ ). The weights are typically learned on a training dataset $d _ { S }$ from $S$ (composed of $n _ { S }$ i.i.d. samples from $p _ { S } ( X , Y ) )$ with a configuration $c$ , which contains all other sources of randomness in learning (e.g., initialization, hyperparameters, training stochasticity, epochs, etc.). We call $l _ { S } = \{ d _ { S } , c \}$ a learning procedure on domain $S$ , and explicitly write $\theta ( l _ { S } )$ to refer to the weights obtained after stochastic minimization of $1 / n _ { S } \sum _ { ( x , y ) \in d _ { S } } \ell ( f ( x , \theta ) , y )$ w.r.t. $\theta$ under $l _ { S }$ .
38
+
39
+ # 2.2 Weight averaging for OOD and limitations of current analysis
40
+
41
+ Weight averaging. We study the benefits of combining $M$ individual member weights $\{ \theta _ { m } \} _ { m = 1 } ^ { M } \triangleq$ $\{ \theta ( l _ { S } ^ { ( m ) } ) \} _ { m = 1 } ^ { M }$ obtained from $M$ (potentially correlated) identically distributed (i.d.) learning procedures , {l (m)S }Mm=1 . Under conditions discussed in Section 3.2, these $M$ weights can be averaged despite nonlinearities in the architecture $f$ . Weight averaging (WA) [13], defined as:
42
+
43
+ $$
44
+ \begin{array} { r } { f _ { \mathrm { { W A } } } \triangleq f ( \cdot , \theta _ { \mathrm { { W A } } } ) , \mathrm { { w h e r e } } \theta _ { \mathrm { { W A } } } \triangleq \theta _ { \mathrm { { W A } } } ( L _ { S } ^ { M } ) \triangleq 1 / M \sum _ { m = 1 } ^ { M } \theta _ { m } , } \end{array}
45
+ $$
46
+
47
+ is the state of the art [14, 29] on DomainBed [12] when the weights $\lbrace \theta _ { m } \rbrace _ { m = 1 } ^ { M }$ are sampled along a single training trajectory (a description we refine in Remark 1 from Appendix C.2).
48
+
49
+ Limitations of the flatness-based analysis. To explain this success, Cha et al. [14] argue that flat minima generalize better; indeed, WA flattens the loss landscape. Yet, as shown in Appendix B, this analysis does not fully explain WA’s spectacular results on DomainBed. First, flatness does not act on distribution shifts thus the OOD error is uncontrolled with their upper bound (see Appendix B.1). Second, this analysis does not clarify why WA outperforms Sharpness-Aware Minimizer (SAM) [30] for OOD generalization, even though SAM directly optimizes flatness (see Appendix B.2). Finally, it does not justify why combining WA and SAM succeeds in IID [31] yet fails in OOD (see Appendix B.3). These observations motivate a new analysis of WA; we propose one below that better explains these results.
50
+
51
+ # 2.3 Bias-variance-covariance-locality decomposition
52
+
53
+ We now introduce our bias-variance-covariance-locality decomposition which extends the biasvariance decomposition [32] to WA. In the rest of this theoretical section, $\ell$ is the Mean Squared Error for simplicity: yet, our results may be extended to other losses as in [33]. In this case, the expected error of a model with weights $\theta ( l _ { S } )$ w.r.t. the learning procedure $l _ { S }$ was decomposed in [32] into:
54
+
55
+ $$
56
+ \begin{array} { r } { \mathbb { E } _ { l _ { S } } \mathcal { E } _ { T } ( \theta ( l _ { S } ) ) = \mathbb { E } _ { ( x , y ) \sim p _ { T } } [ \mathrm { b i a s } ^ { 2 } ( x , y ) + \mathrm { v a r } ( x ) ] , } \end{array}
57
+ $$
58
+
59
+ where $\mathrm { b i a s } ( x , y ) , \mathrm { v a r } ( x )$ are the bias and variance of the considered model w.r.t. a sample $( x , y )$ , defined later in Equation (BVCL). To decompose WA’s error, we leverage the similarity (already highlighted in [13]) between WA and functional ensembling (ENS) [15, 34], a more tra$\begin{array} { r } { f _ { \mathrm { E N S } } \triangleq f _ { \mathrm { E N S } } ( \cdot , \{ \theta _ { m } \} _ { m = 1 } ^ { M } ) \triangleq 1 / M \sum _ { m = 1 } ^ { M } f ( \cdot , \theta _ { m } ) } \end{array}$ More precisely, ENS avera. Lemma 1 establishes that the weight space. $f _ { \mathrm { W A } }$ he predictions,is a first-order $f _ { \mathrm { E N S } }$ $\lbrace \theta _ { m } \rbrace _ { m = 1 } ^ { M }$
60
+
61
+ Lemma 1 (WA and ENS. Proof in Appendix C.1. Adapted from [13, 28].). Given $\lbrace \theta _ { m } \rbrace _ { m = 1 } ^ { M }$ with learning procedures $L _ { S } ^ { M } \triangleq \{ l _ { S } ^ { ( m ) } \} _ { m = 1 } ^ { M }$ . Denoting $\Delta _ { L _ { S } ^ { M } } = \mathrm { m a x } _ { m = 1 } ^ { M } \| \theta _ { m } - \theta _ { W A } \| _ { 2 } , \forall ( x , y ) \in \mathcal { X } \times \mathcal { Y }$
62
+
63
+ $$
64
+ f _ { W A } ( x ) = f _ { E N S } ( x ) + O ( \Delta _ { L _ { S } ^ { M } } ^ { 2 } ) a n d \ell ( f _ { W A } ( x ) , y ) = \ell ( f _ { E N S } ( x ) , y ) + O ( \Delta _ { L _ { S } ^ { M } } ^ { 2 } ) .
65
+ $$
66
+
67
+ This similarity is useful since Equation (BV) was extended into a bias-variance-covariance decomposition for ENS in [18, 35]. We can then derive the following decomposition of WA’s expected test error. To take into account the $M$ averaged weights, the expectation is over the joint distribution describing the $M$ identically distributed (i.d.) learning procedures $L _ { S } ^ { M } \triangleq \{ l _ { S } ^ { ( m ) } \} _ { m = 1 } ^ { \tilde { M } }$ .
68
+
69
+ Proposition 1 (Bias-variance-covariance-locality decomposition of the expected generalization error of WA in OOD. Proof in Appendix C.2.). Denoting $\hat { f } _ { S } ( x ) = \mathbb { E } _ { l _ { S } } [ f ( x , \cdot \theta ( l _ { S } ) ) ]$ , under identically distributed learning procedures $L _ { S } ^ { M } \triangleq \{ l _ { S } ^ { ( m ) } \} _ { m = 1 } ^ { M }$ S , the expected generalization error on domain $T$ of $\begin{array} { r } { \theta _ { W A } ( L _ { S } ^ { M } ) \triangleq \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \theta _ { m } } \end{array}$ over the joint distribution of $L _ { S } ^ { M }$ is:
70
+
71
+ $$
72
+ \begin{array} { r l } & { \mathbb { E } _ { L _ { S } ^ { \scriptscriptstyle M } } \mathcal { E } _ { T } \big ( \theta _ { W \mathrm { A } } ( L _ { S } ^ { \scriptscriptstyle M } ) \big ) = \mathbb { E } _ { ( x , y ) \sim p _ { T } } \Big [ \mathrm { b i a s } ^ { 2 } ( x , y ) + \frac { 1 } { M } \mathrm { v a r } ( x ) + \frac { M - 1 } { M } \mathrm { c o v } ( x ) \Big ] + O ( \bar { \Delta } ^ { 2 } ) , } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \end{array}
73
+ $$
74
+
75
+ cov is the prediction covariance between two member models whose weights are averaged. The locality term $\bar { \Delta } ^ { 2 }$ is the expected squared maximum distance between weights and their average.
76
+
77
+ Equation (BVCL) decomposes the OOD error of WA into four terms. The bias is the same as that of each of its i.d. members. WA’s variance is split into the variance of each of its i.d. members divided by $M$ and a covariance term. The last locality term constrains the weights to ensure the validity of our approximation. In conclusion, combining $M$ models divides the variance by $M$ but introduces the covariance and locality terms which should be controlled along bias to guarantee low OOD error.
78
+
79
+ # 2.4 Analysis of the bias-variance-covariance-locality decomposition
80
+
81
+ We now analyze the four terms in Equation (BVCL). We show that bias dominates under correlation shift (Section 2.4.1) and variance dominates under diversity shift (Section 2.4.2). Then, we discuss a trade-off between covariance, reduced with diverse models (Section 2.4.3), and the locality term, reduced when weights are similar (Section 2.4.4). This analysis shows that WA is effective against diversity shift when $M$ is large and when its members are diverse but close in the weight space.
82
+
83
+ # 2.4.1 Bias and correlation shift (and support mismatch)
84
+
85
+ We relate OOD bias to correlation shift [19] under Assumption 1, where $\bar { f } _ { S } ( x ) \triangleq \mathbb { E } _ { l _ { S } } [ f ( x , \theta ( l _ { S } ) ) ]$ . As discussed in Appendix C.3.2, Assumption 1 is reasonable for a large NN trained on a large dataset representative of the source domain $S$ . It is relaxed in Proposition 4 from Appendix C.3.
86
+
87
+ Assumption 1 (Small IID bias). $\exists \epsilon > 0$ small s.t. $\forall x \in \mathcal { X } _ { S } , | f _ { S } ( x ) - \bar { f } _ { S } ( x ) | \leq \epsilon .$
88
+
89
+ Proposition 2 (OOD bias and correlation shift. Proof in Appendix C.3). With a bounded difference between the labeling functions $f _ { T } - f _ { S }$ on $\mathcal { X } _ { T } \cap \mathcal { X } _ { S }$ , under Assumption $\cdot$ , the bias on domain $T$ is:
90
+
91
+ $$
92
+ \begin{array} { r l } & { \mathbb { E } _ { ( x , y ) \sim p _ { T } } [ \mathrm { b i a s } ^ { 2 } ( x , y ) ] = C o r r e l a t i o n \ s h i f t + S u p p o r t \ m i s m a t c h + O ( \epsilon ) , } \\ & { w h e r e \ C o r r e l a t i o n \ s h i f t = \displaystyle \int _ { \mathbb { X } _ { T } \cap \mathbb { X } _ { S } } \big ( f _ { T } ( x ) - f _ { S } ( x ) \big ) ^ { 2 } p _ { T } ( x ) d x , } \\ & { a n d S u p p o r t \ m i s m a t c h = \displaystyle \int _ { \mathbb { X } _ { T } \setminus \mathbb { X } _ { S } } \big ( f _ { T } ( x ) - \bar { f } _ { S } ( x ) \big ) ^ { 2 } p _ { T } ( x ) d x . } \end{array}
93
+ $$
94
+
95
+ We analyze the first term by noting that $f _ { T } ( x ) \triangleq \mathbb { E } _ { p _ { T } } [ Y | X = x ]$ and $f _ { S } ( x ) \triangleq \mathbb { E } _ { p _ { S } } [ Y | X = x ]$ , $\forall x \in \mathcal { X } _ { T } \cap \mathcal { X } _ { S }$ . This expression confirms that our correlation shift term measures shifts in posterior distributions between source and target, as in [19]. It increases in presence of spurious correlations: e.g., on ColoredMNIST [8] where the color/label correlation is reversed at test time. The second term is caused by support mismatch between source and target. It was analyzed in [36] and shown irreducible in their “No free lunch for learning representations for DG”. Yet, this term can be tackled if we transpose the analysis in the feature space rather than the input space. This motivates encoding the source and target domains into a shared latent space, e.g., by pretraining the encoder on a task with minimal domain-specific information as in [36].
96
+
97
+ This analysis explains why WA fails under correlation shift, as shown on ColoredMNIST in Appendix H. Indeed, combining different models does not reduce the bias. Section 2.4.2 explains that WA is however efficient against diversity shift.
98
+
99
+ # 2.4.2 Variance and diversity shift
100
+
101
+ Variance is known to be large in OOD [5] and to cause a phenomenon named underspecification, when models behave differently in OOD despite similar test IID accuracy. We now relate OOD variance to diversity shift [19] in a simplified setting. We fix the source dataset $d _ { S }$ (with input support $X _ { d _ { S } }$ ), the target dataset $d _ { T }$ (with input support $X _ { d _ { T } }$ ) and the network’s initialization. We get a closed-form expression for the variance of $f$ over all other sources of randomness under Assumptions 2 and 3.
102
+
103
+ Assumption 2 (Kernel regime). $f$ is in the kernel regime [37, 38].
104
+
105
+ This states that $f$ behaves as a Gaussian process (GP); it is reasonable if $f$ is a wide network [37, 39]. The corresponding kernel $K$ is the neural tangent kernel (NTK) [37] depending only on the initialization. GPs are useful because their variances have a closed-form expression (Appendix C.4.1). To simplify the expression of variance, we now make Assumption 3.
106
+
107
+ Assumption 3 (Constant norm and low intra-sample similarity on $d _ { S }$ ). $\exists ( \lambda _ { S } , \epsilon )$ with $0 \le \epsilon \ll \lambda _ { S }$ such that $\forall x _ { S } \in X _ { d _ { S } } , K ( x _ { S } , x _ { S } ) = \lambda _ { S }$ and $\mathsf { \bar { H } } x _ { S } ^ { \prime } \neq x _ { S } \in \dot { X } _ { d s } , | K ( x _ { S } , x _ { S } ^ { \prime } ) | \leq \epsilon$ .
108
+
109
+ This states that training samples have the same norm (following standard practice [39, 40, 41, 42]) and weakly interact [43, 44]. This assumption is further discussed and relaxed in Appendix C.4.2. We are now in a position to relate variance and diversity shift when $\epsilon 0$ .
110
+
111
+ Proposition 3 (OOD variance and diversity shift. Proof in Appendix C.4). Given $f$ trained on source dataset $d _ { S }$ (of size $n _ { S }$ ) with NTK $K$ , under Assumptions 2 and $^ 3$ , the variance on dataset $d _ { T }$ is:
112
+
113
+ $$
114
+ \mathbb { E } _ { x _ { T } \in X _ { d _ { T } } } [ \mathrm { v a r } ( x _ { T } ) ] = \frac { n _ { S } } { 2 \lambda _ { S } } M M D ^ { 2 } ( X _ { d _ { S } } , X _ { d _ { T } } ) + \lambda _ { T } - \frac { n _ { S } } { 2 \lambda _ { S } } \beta _ { T } + O ( \epsilon ) ,
115
+ $$
116
+
117
+ where MMD is the empirical Maximum Mean Discrepancy in the RKHS of $K ^ { 2 } ( x , y ) \ =$ $( K ( x , y ) ) ^ { 2 } ; \lambda _ { T } \triangleq \mathbb { E } _ { x _ { T } \in X _ { d _ { T } } } K ( x _ { T } , x _ { T } )$ and $\beta _ { T } \ \triangleq \ \mathbb { E } _ { ( x _ { T } , x _ { T } ^ { \prime } ) \in X _ { d _ { T } } ^ { 2 } , x _ { T } \neq x _ { T } ^ { \prime } } K ^ { 2 } ( x _ { T } , x _ { T } ^ { \prime } )$ are the empirical mean similarities respectively measured between identical $( w . r . t . \ K )$ and different $( w . r . t . ~ K ^ { 2 } )$ samples averaged over $X _ { d _ { T } }$ .
118
+
119
+ The MMD empirically estimates shifts in input marginals, i.e., between $p _ { S } ( X )$ and $p _ { T } ( X )$ . Our expression of variance is thus similar to the diversity shift formula in [19]: MMD replaces the $L _ { 1 }$ divergence used in [19]. The other terms, $\lambda _ { T }$ and $\beta _ { T }$ , both involve internal dependencies on the target dataset $d _ { T }$ : they are constants w.r.t. $X _ { d _ { T } }$ and do not depend on distribution shifts. At fixed $d _ { T }$ and under our assumptions, Equation (4) shows that variance on $d _ { T }$ decreases when $X _ { d _ { S } }$ and $X _ { d _ { T } }$ are closer (for the MMD distance defined by the kernel $K ^ { 2 }$ ) and increases when they deviate. Intuitively, the further $X _ { d _ { T } }$ is from $X _ { d _ { S } }$ , the less the model’s predictions on $X _ { d _ { T } }$ are constrained after fitting $d _ { S }$
120
+
121
+ This analysis shows that WA reduces the impact of diversity shift as combining $M$ models divides the variance per $M$ . This is a strong property achieved without requiring data from the target domain.
122
+
123
+ # 2.4.3 Covariance and diversity
124
+
125
+ The covariance term increases when the predictions of $\{ f ( \cdot , \theta _ { m } ) \} _ { m = 1 } ^ { M }$ are correlated. In the worst case where all predictions are identical, covariance equals variance and WA is no longer beneficial. On the other hand, the lower the covariance, the greater the gain of WA over its members; this is derived by comparing Equations (BV) and (BVCL), as detailed in Appendix C.5. It motivates tackling covariance by encouraging members to make different predictions, thus to be functionally diverse. Diversity is a widely analyzed concept in the ensemble literature [15], for which numerous measures have been introduced [45, 46, 47]. In Section 3, we aim at decorrelating the learning procedures to increase members’ diversity and reduce the covariance term.
126
+
127
+ # 2.4.4 Locality and linear mode connectivity
128
+
129
+ To ensure that WA approximates ENS, the last locality term $O ( \bar { \Delta } ^ { 2 } )$ constrains the weights to be close. Yet, the covariance term analyzed in Section 2.4.3 is antagonistic, as it motivates functionally diverse models. Overall, to reduce WA’s error in OOD, we thus seek a good trade-off between diversity and locality. In practice, we consider that the main goal of this locality term is to ensure that the weights are averageable despite the nonlinearities in the NN such that WA’s error does not explode. This is why in Section 3, we empirically relax this locality constraint and simply require that the weights are linearly connectable in the loss landscape, as in the linear mode connectivity [24]. We empirically verify later in Figure 1 that the approximation $f _ { \mathrm { W A } } \approx f _ { \mathrm { E N S } }$ remains valid even in this case.
130
+
131
+ # 3 DiWA: Diverse Weight Averaging
132
+
133
+ # 3.1 Motivation: weight averaging from different runs for more diversity
134
+
135
+ Limitations of previous WA approaches. Our analysis in Sections 2.4.1 and 2.4.2 showed that the bias and the variance terms are mostly fixed by the distribution shifts at hand. In contrast, the covariance term can be reduced by enforcing diversity across models (Section 2.4.3) obtained from learning procedur es {l (m)S }Mm=1 · Yet, previous methods [14, 29] only average weights obtained along a single run. This corresponds to highly correlated procedures sharing the same initialization, hyperparameters, batch orders, data augmentations and noise, that only differ by the number of training steps. The models are thus mostly similar: this does not leverage the full potential of WA.
136
+
137
+ DiWA. Our Diverse Weight Averaging approach seeks to reduce the OOD expected error in Equation (BVCL) by decreasing covariance across predictions: DiWA decorrelates the learning procedures {l (m)S }Mm=1 . Our weights are obtained from $M \gg 1$ different runs, with diverse learning procedures:
138
+
139
+ Require: $\theta _ { 0 }$ pretrained encoder and initialized classifier; $\{ h _ { m } \} _ { m = 1 } ^ { H }$ hyperparameter configurations.
140
+ Training: $\forall m = 1$ to $H , \theta _ { m } \triangleq { \mathrm { F i n e T u n e } } ( \theta _ { 0 } , h _ { m } )$
141
+ Weight selection: Uniform: $\overline { { \mathcal { M } } } = \{ 1 , \cdots , H \}$ .
142
+ Res R $\lbrace \theta _ { m } \rbrace _ { m = 1 } ^ { H }$ by decreasing $\mathrm { V a l A c c } ( \theta _ { m } )$ . $M \gets \emptyset$ . $m = 1$ $H$ If $\mathrm { V a l A c c } ( \theta _ { \mathcal { M } \cup \{ m \} } ) \geq \mathrm { V a l A c c } ( \theta _ { \mathcal { M } } )$ ${ \mathcal { M } } \gets { \mathcal { M } } \cup \{ m \}$
143
+ Inference: with $f ( \cdot , \theta _ { \mathcal { M } } )$ , where $\begin{array} { r } { \theta _ { \mathcal { M } } = \sum _ { m \in \mathcal { M } } \theta _ { m } / | \mathcal { M } | } \end{array}$ .
144
+
145
+ these have different hyperparameters (learning rate, weight decay and dropout probability), batch orders, data augmentations (e.g., random crops, horizontal flipping, color jitter, grayscaling), stochastic noise and number of training steps. Thus, the corresponding models are more diverse on domain $T$ per [21] and reduce the impact of variance when $M$ is large. However, this may break the locality requirement analyzed in Section 2.4.4 if the weights are too distant. Empirically, we show that DiWA works under two conditions: shared initialization and mild hyperparameter ranges.
146
+
147
+ # 3.2 Approach: shared initialization, mild hyperparameter search and weight selection
148
+
149
+ Shared initialization. The shared initialization condition follows [25]: when models are fine-tuned from a shared pretrained model, their weights can be connected along a linear path where error remains low [24]. Following standard practice on DomainBed [12], our encoder is pretrained on ImageNet [48]; this pretraining is key as it controls the bias (by defining the feature support mismatch, see Section 2.4.1) and variance (by defining the kernel $K$ , see Appendix C.4.4). Regarding the classifier initialization, we test two methods. The first is the random initialization, which may distort the features [49]. The second is Linear Probing (LP) [49]: it first learns the classifier (while freezing the encoder) to serve as a shared initialization. Then, LP fine-tunes the encoder and the classifier together in the $M$ subsequent runs; the locality term is smaller as weights remain closer (see [49]).
150
+
151
+ Mild hyperparameter search. As shown in Figure 5, extreme hyperparameter ranges lead to weights whose average may perform poorly. Indeed, weights obtained from extremely different hyperparameters may not be linearly connectable; they may belong to different regions of the loss landscape. In our experiments, we thus use the mild search space defined in Table 7, first introduced in SWAD [14]. These hyperparameter ranges induce diverse models that are averageable in weights.
152
+
153
+ Weight selection. The last step of our approach (summarized in Algorithm 1) is to choose which weights to average among those available. We explore two simple weight selection protocols, as in [28]. The first uniform equally averages all weights; it is practical but may underperform when some runs are detrimental. The second restricted (greedy in [28]) solves this drawback by restricting the number of selected weights: weights are ranked in decreasing order of validation accuracy and sequentially added only if they improve DiWA’s validation accuracy.
154
+
155
+ In the following sections, we experimentally validate our theory. First, Section 4 confirms our findings on the OfficeHome dataset [50] where diversity shift dominates [19] (see Appendix E.2 for a similar analysis on PACS [51]). Then, Section 5 shows that DiWA is state of the art on DomainBed [12].
156
+
157
+ # 4 Empirical validation of our theoretical insights
158
+
159
+ We consider several collections of weights $\lbrace \theta _ { m } \rbrace _ { m = 1 } ^ { M }$ $( 2 \leq M < 1 0 )$ trained on the “Clipart”, “Product” and “Photo” domains from OfficeHome [50] with a shared random initialization and mild hyperparameter ranges. These weights are first indifferently sampled from a single run (every 50 batches) or from different runs. They are evaluated on “Art”, the fourth domain from OfficeHome.
160
+
161
+ WA vs. ENS. Figure 1 validates Lemma 1 and that $f _ { \mathbf { W A } } \approx f _ { \mathbf { E N S } }$ . More precisely, $f _ { \mathrm { W A } }$ slightly but consistently improves $f _ { \mathrm { E N S } }$ : we discuss this in Appendix D. Moreover, a larger $M$ improves the
162
+
163
+ ![](images/aa85ce32f560086ba3e663d330c23d0278377bd531b612fae2082ff26ac0f248.jpg)
164
+ Figure 1: Each dot displays the accuracy (") of weight averaging (WA) vs. accuracy $( \uparrow )$ of prediction averaging (ENS) for $M$ models.
165
+
166
+ ![](images/79497adcd65df5c314905b300a57757280a4846a86c3e4c67685368e5337fcf8.jpg)
167
+ Figure 2: Each dot displays the accuracy (") gain of WA over its members vs. the prediction diversity [46] ( ) for $M$ models.
168
+
169
+ results; in accordance with Equation (BVCL), this motivates averaging as many weights as possible.
170
+ In contrast, large $M$ is computationally impractical for ENS at test time, requiring $M$ forwards.
171
+
172
+ Diversity and accuracy. We validate in Figure 2 that $f _ { \mathrm { W A } }$ benefits from diversity. Here, we measure diversity with the ratio-error [46], i.e., the ratio $N _ { \mathrm { d i f f } } / N _ { \mathrm { s i m u l } }$ between the number of different errors $N _ { \mathrm { d i f f } }$ and of simultaneous errors $N _ { \mathrm { s i m u l } }$ in test for a pair in $\{ f ( \cdot , \theta _ { m } ) \} _ { m = 1 } ^ { M }$ . A higher average over the $\binom { M } { 2 }$ pairs means that members are less likely to err on the same inputs. Specifically, the gain of $\operatorname { A c c } ( \theta _ { \operatorname { W A } } )$ over the mean individual accuracy $\begin{array} { r } { \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \operatorname { A c c } ( \theta _ { m } ) } \end{array}$ increases with diversity. Moreover, this phenomenon intensifies for larger $M$ : the linear regression’s slope (i.e., the accuracy gain per unit of diversity) increases with $M$ . This is consistent with the $( M - 1 ) / M$ factor of $\operatorname { c o v } ( x )$ in Equation (BVCL), as further highlighted in Appendix E.1.2. Finally, in Appendix E.1.1, we show that the conclusion also holds with CKAC [47], another established diversity measure.
173
+
174
+ Increasing diversity thus accuracy via different runs. Now we investigate the difference between sampling the weights from a single run or from different runs. Figure 3 first shows that diversity increases when weights come from different runs. Second, in Figure 4, this is reflected on the accuracies in OOD. Here, we rank by validation accuracy the 60 weights obtained (1) from 60 different runs and (2) along 1 well-performing run. We then consider the WA of the top $M$ weights as $M$ increases from 1 to 60. Both have initially the same performance and improve with $M$ ; yet, WA of weights from different runs gradually outperforms the single-run WA. Finally, Figure 5 shows that this holds only for mild hyperparameter ranges and with a shared initialization. Otherwise, when hyperparameter distributions are extreme (as defined in Table 7) or when classifiers are not similarly initialized, DiWA may perform worse than its members due to a violation of the locality condition. These experiments confirm that diversity is key as long as the weights remain averageable.
175
+
176
+ ![](images/93d36ab5d9da3fec0b1140c4729c47999573df311e5d4ce9cca4257fd3e99364.jpg)
177
+ Figure 3: Frequencies of predic- Figure 4: WA accuracy $( \uparrow )$ as $M$ tion diversities ( ) [46] across 2 increases, when the $M$ weights weights obtained along a single are obtained along a single run run or from different runs. or from different runs.
178
+
179
+ ![](images/62fdbe233237ba75c7e4e4bfa2e49026061ed8a42b2735ff4c97e417a4f29502.jpg)
180
+ Figure 5: Each dot displays the accuracy ( ) gain of WA over its members vs. prediction diversity $( \uparrow )$ for $2 \leq M < 1 0$ models.
181
+
182
+ # 5 Experimental results on the DomainBed benchmark
183
+
184
+ Datasets. We now present our evaluation on DomainBed [12]. By imposing the code, the training procedures and the ResNet50 [52] architecture, DomainBed is arguably the fairest benchmark for OOD generalization. It includes 5 multi-domain real-world datasets: PACS [51], VLCS [53], OfficeHome [50], TerraIncognita [54] and DomainNet [55]. [19] showed that diversity shift dominates in these datasets. Each domain is successively considered as the target $T$ while other domains are merged into the source $S$ . The validation dataset is sampled from $S$ , i.e., we follow DomainBed’s training-domain model selection. The experimental setup is further described in Appendix G.1. Our code is available at https://github.com/alexrame/diwa.
185
+
186
+ Baselines. ERM is the standard Empirical Risk Minimization. Coral [10] is the best approach based on domain invariance. SWAD (Stochastic Weight Averaging Densely) [14] and MA (Moving Average) [29] average weights along one training trajectory but differ in their weight selection strategy. SWAD [14] is the current state of the art (SoTA) thanks to it “overfit-aware” strategy, yet at the cost of three additional hyperparameters (a patient parameter, an overfitting patient parameter and a tolerance rate) tuned per dataset. In contrast, MA [29] is easy to implement as it simply combines all checkpoints uniformly starting from batch 100 until the end of training. Finally, we report the scores obtained in [29] for the costly Deep Ensembles (DENS) [15] (with different initializations): we discuss other ensembling strategies in Appendix D.
187
+
188
+ Our runs. ERM and DiWA share the same training protocol in DomainBed: yet, instead of keeping only one run from the grid-search, DiWA leverages $M$ runs. In practice, we sample 20 configurations from the hyperparameter distributions detailed in Table 7 and report the mean and standard deviation across 3 data splits. For each run, we select the weights of the epoch with the highest validation accuracy. ERM and MA select the model with highest validation accuracy across the 20 runs, following standard practice on DomainBed. Ensembling (ENS) averages the predictions of all $M = 2 0$ models (with shared initialization). DiWA-restricted selects $1 \leq M \leq 2 0$ weights with Algorithm 1 while DiWA-uniform averages all $M = 2 0$ weights. DiWA† averages uniformly the $M = 3 \times 2 0 = 6 0$ weights from all 3 data splits. DiWA† benefits from larger $M$ (without additional inference cost) and from data diversity (see Appendix E.1.3). However, we cannot report standard deviations for DiWA† for computational reasons. Moreover, DiWA† cannot leverage the restricted weight selection, as the validation is not shared across all 60 weights that have different data splits.
189
+
190
+ # 5.1 Results on DomainBed
191
+
192
+ We report our main results in Table 1, detailed per domain in Appendix G.2. With a randomly initialized classifier, DiWA†-uniform is the best on PACS, VLCS and OfficeHome: DiWA-uniform is the second best on PACS and OfficeHome. On TerraIncognita and DomainNet, DiWA is penalized by some bad runs, filtered in DiWA-restricted which improves results on these datasets. Classifier initialization with linear probing (LP) [49] improves all methods on OfficeHome, TerraIncognita and DomainNet. On these datasets, DiWA† increases MA by 1.3, 0.5 and 1.1 points respectively. After averaging, DiWA† with LP establishes a new SoTA of $6 8 . 0 \%$ , improving SWAD by 1.1 points.
193
+
194
+ Table 1: Accuracy $( \% , \uparrow )$ on DomainBed with ResNet50 (best in bold and second best underlined).
195
+
196
+ <table><tr><td>Algorithm</td><td>Weight selection</td><td>Init</td><td>PACS</td><td>VLCS</td><td>OfficeHome</td><td>TerraInc</td><td>DomainNet</td><td>Avg</td></tr><tr><td>ERM</td><td>N/A</td><td></td><td rowspan="5">Random</td><td>85.5±0.2 86.2±0.3</td><td>77.5 ± 0.4 78.8 ±0.6</td><td>66.5 ± 0.3 68.7 ±0.3</td><td>46.1 ± 1.8 47.6 ± 1.0</td><td>40.9 ± 0.1 41.5 ± 0.1</td><td>63.3 64.6</td></tr><tr><td>Coral[10]</td><td>N/A</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>SWAD[14]</td><td>Overfit-aware</td><td>88.1 ±0.1</td><td>79.1 ± 0.1</td><td>70.6± 0.2</td><td>50.0± 0.3</td><td>46.5 ± 0.1</td><td>66.9</td></tr><tr><td>MA [29]</td><td>Uniform</td><td>87.5 ± 0.2</td><td>78.2 ±0.2</td><td>70.6 ± 0.1</td><td>50.3 ± 0.5</td><td>46.0 ± 0.1</td><td>66.5</td></tr><tr><td>DENS [15,29]</td><td>Uniform: M=6</td><td>87.6</td><td>78.5</td><td>70.8</td><td>49.2</td><td>47.7</td><td>66.8</td></tr><tr><td rowspan="10">sun.I .ino</td><td>ERM</td><td></td><td rowspan="6">Random</td><td>85.5± 0.5</td><td>77.6± 0.2</td><td>67.4±0.6</td><td>48.3±0.8</td><td>44.1 ± 0.1</td><td>64.6</td></tr><tr><td>MA [29]</td><td>N/A Uniform</td><td>87.9 ± 0.1</td><td>78.4 ± 0.1</td><td>70.3 ± 0.1</td><td>49.9 ± 0.2</td><td>46.4 ± 0.1</td><td>66.6</td></tr><tr><td>ENS</td><td>Uniform:M= 20</td><td>88.0±0.1</td><td>78.7 ± 0.1</td><td>70.5 ± 0.1</td><td>51.0 ± 0.5</td><td>47.4 ± 0.2</td><td>67.1</td></tr><tr><td>DiWA</td><td>Restricted: M≤20</td><td>87.9±0.2</td><td>79.2 ± 0.1</td><td>70.5 ± 0.1</td><td>50.5 ± 0.5</td><td>46.7 ± 0.1</td><td>67.0</td></tr><tr><td>DiWA</td><td>Uniform:M= 20</td><td>88.8±0.4</td><td>79.1 ± 0.2</td><td>71.0 ± 0.1</td><td>48.9 ± 0.5</td><td>46.1 ± 0.1</td><td>66.8</td></tr><tr><td>DiWAt</td><td>Uniform: M= 60</td><td>89.0</td><td>79.4</td><td>71.6</td><td>49.0</td><td>46.3</td><td>67.1</td></tr><tr><td>ERM</td><td>N/A</td><td>85.9 ± 0.6</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>MA [29]</td><td>Uniform</td><td rowspan="5">LP [49]</td><td>87.8±0.3</td><td>78.1 ± 0.5 78.5 ± 0.4</td><td>69.4 ± 0.2 71.5 ± 0.3</td><td>50.4 ± 1.8 51.4 ± 0.6</td><td>44.3 ± 0.2 46.6 ± 0.0</td><td>65.6 67.1</td></tr><tr><td>ENS</td><td>Uniform:M= 20</td><td>88.1±0.3</td><td>78.5 ± 0.1</td><td>71.7 ± 0.1</td><td>50.8 ± 0.5</td><td>47.0±0.2</td><td>67.2</td></tr><tr><td>DiWA</td><td>Restricted: M≤20</td><td>88.0±0.3</td><td>78.5 ± 0.1</td><td>71.5 ± 0.2</td><td>51.6 ± 0.9</td><td>47.7 ± 0.1</td><td>67.5</td></tr><tr><td>DiWA</td><td>Uniform: M= 20</td><td>88.7±0.2</td><td>78.4± 0.2</td><td>72.1 ± 0.2</td><td>51.4 ± 0.6</td><td>47.4 ± 0.2</td><td>67.6</td></tr><tr><td>DiWAt</td><td>Uniform: M= 60</td><td>89.0</td><td>78.6</td><td>72.8</td><td>51.9</td><td>47.7</td><td>68.0</td></tr></table>
197
+
198
+ DiWA with different objectives. So far we used ERM that does not leverage the domain information. Table 2 shows that DiWA-uniform benefits from averaging weights trained with Interdomain Mixup [56] and Coral [10]: accuracy gradually improves as we add more objectives. Indeed, as highlighted in Appendix E.1.3, DiWA benefits from the increased diversity brought by the various objectives. This suggests a new kind of linear connectivity across models trained with different objectives; the full analysis of this is left for future work.
199
+
200
+ Table 2: Accuracy $( \% , \uparrow )$ on OfficeHome domain “Art” with various objectives.
201
+
202
+ <table><tr><td>Algorithm</td><td>No WA</td><td>MA</td><td>DiWA</td><td>DiWA†</td></tr><tr><td>ERM</td><td>62.9 ±1.3</td><td>65.0±0.2</td><td>67.3±0.2</td><td>67.7</td></tr><tr><td>Mixup</td><td>63.1 ±0.7</td><td>66.2 ± 0.3</td><td>67.8 ±0.6</td><td>68.4</td></tr><tr><td>Coral</td><td>64.4± 0.4</td><td>64.4 ± 0.4</td><td>67.7 ±0.2</td><td>68.2</td></tr><tr><td>ERM/Mixup</td><td>N/A</td><td>N/A</td><td>67.9 ± 0.7</td><td>68.9</td></tr><tr><td>ERM/Coral</td><td>N/A</td><td>N/A</td><td>68.1± 0.3</td><td>68.7</td></tr><tr><td>ERM/Mixup/Coral</td><td>N/A</td><td>N/A</td><td>68.4 ± 0.4</td><td>69.1</td></tr></table>
203
+
204
+ # 5.2 Limitations of DiWA
205
+
206
+ Despite this success, DiWA has some limitations. First, DiWA cannot benefit from additional diversity that would break the linear connectivity between weights — as discussed in Appendix D. Second, DiWA (like all WA approaches) can tackle diversity shift but not correlation shift: this property is explained for the first time in Section 2.4 and illustrated in Appendix H on ColoredMNIST.
207
+
208
+ # 6 Related work
209
+
210
+ Generalization and ensemble. To generalize under distribution shifts, invariant approaches [8, 9, 11, 10, 57, 58] try to detect the causal mechanism rather than memorize correlations: yet, they do not outperform ERM on various benchmarks [12, 19, 59]. In contrast, ensembling of deep networks [15, 60, 61] consistently increases robustness [16] and was successfully applied to domain generalization [29, 62, 63, 64, 65, 66]. As highlighted in [18] (whose analysis underlies our Equation (BVCL)), ensembling works due to the diversity among its members. This diversity comes primarily from the randomness of the learning procedure [15] and can be increased with different hyperparameters [67], data [68, 69, 70], augmentations [71, 72] or with regularizations [73, 65, 66, 74, 75].
211
+
212
+ Weight averaging. Recent works [13, 76, 77, 78] combine in weights (rather than in predictions) models collected along a single run. This was shown suboptimal in IID [17] but successful in OOD [14, 29]. Following the linear mode connectivity [24, 79] and the property that many independent models are connectable [80], a second group of works average weights with fewer constraints [26, 27, 28, 81, 82, 83]. To induce greater diversity, [84] used a high constant learning rate; [80] explicitly encouraged the weights to encompass more volume in the weight space; [83] minimized cosine similarity between weights; [85] used a tempered posterior. From a loss landscape perspective [20], these methods aimed at “explor[ing] the set of possible solutions instead of simply converging to a single point”, as stated in [84]. The recent “Model soups” introduced by Wortsman et al. [28] is a WA algorithm similar to Algorithm 1; yet, the theoretical analysis and the goals of these two works are different. Theoretically, we explain why WA succeeds under diversity shift: the bias/correlation shift, variance/diversity shift and diversity-based findings are novel and are confirmed empirically. Regarding the motivation, our work aims at combining more diverse weights: it may be analyzed as a general framework to average weights obtained in various ways. In contrast, [28] challenges the standard model selection after a grid search. Regarding the task, [28] and our work complement each other: while [28] demonstrate robustness on several ImageNet variants with distribution shift, we improve the SoTA on the multi-domain DomainBed benchmark against other established OOD methods after a thorough and fair comparison. Thus, DiWA and [28] are theoretically complementary with different motivations and applied successfully for different tasks.
213
+
214
+ # 7 Conclusion
215
+
216
+ In this paper, we propose a new explanation for the success of WA in OOD by leveraging its ensembling nature. Our analysis is based on a new bias-variance-covariance-locality decomposition for WA, where we theoretically relate bias to correlation shift and variance to diversity shift. It also shows that diversity is key to improve generalization. This motivates our DiWA approach that averages in weights models trained independently. DiWA improves the state of the art on DomainBed, the reference benchmark for OOD generalization. Critically, DiWA has no additional inference cost — removing a key limitation of standard ensembling. Our work may encourage the community to further create diverse learning procedures and objectives — whose models may be averaged in weights.
217
+
218
+ # Acknowledgements
219
+
220
+ We would like to thank Jean-Yves Franceschi for his helpful comments and discussions on our paper. This work was granted access to the HPC resources of IDRIS under the allocation AD011011953 made by GENCI. We acknowledge the financial support by the French National Research Agency (ANR) in the chair VISA-DEEP (project number ANR-20-CHIA-0022-01) and the ANR projects DL4CLIM ANR-19-CHIA-0018-01, RAIMO ANR-20-CHIA-0021-01, OATMIL ANR-17-CE23- 0012 and LEAUDS ANR-18-CE23-0020.
221
+
222
+ # References
223
+
224
+ [1] 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, 2018. (pp. 1 and 17)
225
+ [2] Alex J DeGrave, Joseph D Janizek, and Su-In Lee. Ai for radiographic covid-19 detection selects shortcuts over signal. Nature Machine Intelligence, 2021. (pp. 1 and 17)
226
+ [3] Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In ICLR, 2019. (p. 1)
227
+ [4] Harshay Shah, Kaustav Tamuly, Aditi Raghunathan, Prateek Jain, and Praneeth Netrapalli. The pitfalls of simplicity bias in neural networks. In NeurIPS, 2020. (p. 1)
228
+ [5] Alexander D’Amour, Katherine Heller, Dan Moldovan, Ben Adlam, Babak Alipanahi, Alex Beutel, Christina Chen, Jonathan Deaton, Jacob Eisenstein, Matthew D Hoffman, et al. Underspecification presents challenges for credibility in modern machine learning. JMLR, 2020. (pp. 1 and 4)
229
+ [6] Krikamol Muandet, David Balduzzi, and Bernhard Schölkopf. Domain generalization via invariant feature representation. In ICML, 2013. (p. 1)
230
+ [7] Jonas Peters, Peter Bühlmann, and Nicolai Meinshausen. Causal inference by using invariant prediction: identification and confidence intervals. JSTOR, 2016. (p. 1)
231
+ [8] Martin Arjovsky, Léon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. arXiv preprint, 2019. (pp. 1, 4, 9, and 36)
232
+ [9] David Krueger, Ethan Caballero, Joern-Henrik Jacobsen, Amy Zhang, Jonathan Binas, Dinghuai Zhang, Remi Le Priol, and Aaron Courville. Out-of-distribution generalization via risk extrapolation (rex). In ICML, 2021. (pp. 1 and 9)
233
+ [10] Baochen Sun, Jiashi Feng, and Kate Saenko. Return of frustratingly easy domain adaptation. In AAAI, 2016. (pp. 1, 8, 9, 29, 33, 34, 35, and 36)
234
+ [11] Alexandre Rame, Corentin Dancette, and Matthieu Cord. Fishr: Invariant gradient variances for out-of-distribution generalization. In ICML, 2022. (pp. 1, 9, and 36)
235
+ [12] Ishaan Gulrajani and David Lopez-Paz. In search of lost domain generalization. In ICLR, 2021. (pp. 1, 2, 3, 6, 8, 9, 16, 17, 18, 27, 32, 33, and 36)
236
+ [13] Pavel Izmailov, Dmitrii Podoprikhin, Timur Garipov, Dmitry Vetrov, and Andrew Gordon Wilson. Averaging weights leads to wider optima and better generalization. In UAI, 2018. (pp. 1, 2, 3, 9, and 20)
237
+ [14] Junbum Cha, Sanghyuk Chun, Kyungjae Lee, Han-Cheol Cho, Seunghyun Park, Yunsung Lee, and Sungrae Park. Swad: Domain generalization by seeking flat minima. In NeurIPS, 2021. (pp. 1, 3, 5, 6, 8, 9, 17, 18, 19, 20, 23, 32, 33, 34, and 35)
238
+ [15] Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and scalable predictive uncertainty estimation using deep ensembles. In NeurIPS, 2017. (pp. 1, 3, 5, 8, 9, 18, 28, 34, and 35)
239
+ [16] Yaniv Ovadia, Emily Fertig, Jie Ren, Zachary Nado, David Sculley, Sebastian Nowozin, Joshua Dillon, Balaji Lakshminarayanan, and Jasper Snoek. Can you trust your model’s uncertainty? evaluating predictive uncertainty under dataset shift. In NeurIPS, 2019. (pp. 1 and 9)
240
+ [17] Arsenii Ashukha, Alexander Lyzhov, Dmitry Molchanov, and Dmitry Vetrov. Pitfalls of in-domain uncertainty estimation and ensembling in deep learning. In ICLR, 2020. (pp. 1 and 9)
241
+ [18] Naonori Ueda and Ryohei Nakano. Generalization error of ensemble estimators. In ICNN, 1996. (pp. 1, 3, 9, and 21)
242
+ [19] Nanyang Ye, Kaican Li, Lanqing Hong, Haoyue Bai, Yiting Chen, Fengwei Zhou, and Zhenguo Li. Ood-bench: Benchmarking and understanding out-of-distribution generalization datasets and algorithms. CVPR, 2022. (pp. 1, 2, 4, 5, 6, 8, 9, 23, 33, and 36)
243
+ [20] Stanislav Fort, Huiyi Hu, and Balaji Lakshminarayanan. Deep ensembles: A loss landscape perspective. arXiv preprint, 2019. (pp. 2 and 9)
244
+ [21] Raphael Gontijo-Lopes, Yann Dauphin, and Ekin Dogus Cubuk. No one representation to rule them all: Overlapping features of training methods. In ICLR, 2022. (pp. 2, 6, 29, and 30)
245
+ [22] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, 2015. (p. 2)
246
+ [23] Abien Fred Agarap. Deep learning using rectified linear units (relu). arXiv preprint, 2018. (p. 2)
247
+ [24] Jonathan Frankle, Gintare Karolina Dziugaite, Daniel M. Roy, and Michael Carbin. Linear mode connectivity and the lottery ticket hypothesis. In ICML, 2020. (pp. 2, 5, 6, and 9)
248
+ [25] Behnam Neyshabur, Hanie Sedghi, and Chiyuan Zhang. What is being transferred in transfer learning? In NeurIPS, 2020. (pp. 2, 6, 28, and 30)
249
+ [26] Mitchell Wortsman, Gabriel Ilharco, Jong Wook Kim, Mike Li, Hanna Hajishirzi, Ali Farhadi, Hongseok Namkoong, and Ludwig Schmidt. Robust fine-tuning of zero-shot models. In CVPR, 2022. (pp. 2, 9, and 28)
250
+ [27] Michael Matena and Colin Raffel. Merging models with fisher-weighted averaging. In NeurIPS, 2022. (pp. 2 and 9)
251
+ [28] Mitchell Wortsman, Gabriel Ilharco, Samir Yitzhak Gadre, Rebecca Roelofs, Raphael GontijoLopes, Ari S. Morcos, Hongseok Namkoong, Ali Farhadi, Yair Carmon, Simon Kornblith, and Ludwig Schmidt. Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time. In ICML, 2022. (pp. 2, 3, 6, 9, 20, and 28)
252
+ [29] Devansh Arpit, Huan Wang, Yingbo Zhou, and Caiming Xiong. Ensemble of averages: Improving model selection and boosting performance in domain generalization. In NeurIPS, 2022. (pp. 3, 5, 8, 9, 18, 19, 20, 23, 28, 33, 34, 35, and 36)
253
+ [30] Pierre Foret, Ariel Kleiner, Hossein Mobahi, and Behnam Neyshabur. Sharpness-aware minimization for efficiently improving generalization. In ICLR, 2021. (pp. 3, 18, and 19)
254
+ [31] Jean Kaddour, Linqing Liu, Ricardo Silva, and Matt J. Kusner. When do flat minima optimizers work? In NeurIPS, 2022. (pp. 3 and 19)
255
+ [32] Ron Kohavi, David H Wolpert, et al. Bias plus variance decomposition for zero-one loss functions. In ICML, 1996. (pp. 3, 21, and 27)
256
+ [33] Pedro Domingos. A unified bias-variance decomposition. In ICML, 2000. (p. 3)
257
+ [34] Thomas G Dietterich. Ensemble methods in machine learning. In MCS, 2000. (p. 3)
258
+ [35] Gavin Brown, Jeremy Wyatt, and Ping Sun. Between two extremes: Examining decompositions of the ensemble objective function. In MCS, 2005. (pp. 3 and 21) [36] Yangjun Ruan, Yann Dubois, and Chris J. Maddison. Optimal representations for covariate shift. In ICLR, 2022. (pp. 4, 23, and 27) [37] Arthur Jacot, Franck Gabriel, and Clement Hongler. Neural tangent kernel: Convergence and generalization in neural networks. In NeurIPS, 2018. (pp. 4, 25, and 27) [38] Amit Daniely. Sgd learns the conjugate kernel class of the network. In NeurIPS, 2017. (p. 4) [39] Jaehoon Lee, Yasaman Bahri, Roman Novak, Samuel S Schoenholz, Jeffrey Pennington, and Jascha Sohl-Dickstein. Deep neural networks as gaussian processes. In ICLR, 2017. (pp. 4 and 25) [40] Julien Ah-Pine. Normalized kernels as similarity indices. In PAKDD, 2010. (pp. 4 and 25) [41] Benyamin Ghojogh, Ali Ghodsi, Fakhri Karray, and Mark Crowley. Reproducing kernel hilbert space, mercer’s theorem, eigenfunctions, nystrom method, and use of kernels in machine learning: Tutorial and survey. arXiv preprint, 2021. (pp. 4 and 25) [42] Jason Rennie. How to normalize a kernel matrix. MIT Computer Science - Artificial Intelligence Lab Tech Rep, 2005. (pp. 4 and 25) [43] Hangfeng He and Weijie Su. The local elasticity of neural networks. In ICLR, 2020. (pp. 4 and 25) [44] Mariia Seleznova and Gitta Kutyniok. Neural tangent kernel beyond the infinite-width limit: Effects of depth and initialization. ICML, 2022. (pp. 4 and 25) [45] Ludmila I Kuncheva and Christopher J Whitaker. Measures of diversity in classifier ensembles and their relationship with the ensemble accuracy. Machine learning, 2003. (p. 5) [46] Matti Aksela. Comparison of classifier selection methods for improving committee performance. In MCS, 2003. (pp. 5, 7, 19, 28, 29, 30, and 31) [47] Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey E. Hinton. Similarity of neural network representations revisited. In ICML, 2019. (pp. 5, 7, 28, 29, and 30) [48] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In NeurIPS, 2012. (pp. 6 and 27) [49] Ananya Kumar, Aditi Raghunathan, Robbie Matthew Jones, Tengyu Ma, and Percy Liang. Fine-tuning can distort pretrained features and underperform out-of-distribution. In ICLR,
259
+ 2022. (pp. 6, 8, 27, 32, 33, 34, and 35) [50] Hemanth Venkateswara, Jose Eusebio, Shayok Chakraborty, and Sethuraman Panchanathan. Deep hashing network for unsupervised domain adaptation. In CVPR, 2017. (pp. 6, 8, 18, and 33) [51] Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Deeper, broader and artier domain generalization. In ICCV, 2017. (pp. 6, 8, and 33) [52] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016. (pp. 8 and 33) [53] Chen Fang, Ye Xu, and Daniel N Rockmore. Unbiased metric learning: On the utilization of multiple datasets and web images for softening bias. In ICCV, 2013. (pp. 8 and 33) [54] Sara Beery, Grant Van Horn, and Pietro Perona. Recognition in terra incognita. In ECCV,
260
+ 2018. (pp. 8 and 33) [55] Xingchao Peng, Qinxun Bai, Xide Xia, Zijun Huang, Kate Saenko, and Bo Wang. Moment matching for multi-source domain adaptation. In ICCV, 2019. (pp. 8, 33, and 36) [56] Shen Yan, Huan Song, Nanxiang Li, Lincan Zou, and Liu Ren. Improve unsupervised domain adaptation with mixup training. arXiv preprint, 2020. (pp. 9, 29, and 33)
261
+ [57] Shiori Sagawa, Pang Wei Koh, Tatsunori B. Hashimoto, and Percy Liang. Distributionally robust neural networks. In ICLR, 2020. (pp. 9 and 17)
262
+ [58] Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. JMLR, 2016. (p. 9)
263
+ [59] Pang Wei Koh, Shiori Sagawa, Henrik Marklund, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasunaga, Richard Lanas Phillips, Irena Gao, Tony Lee, Etienne David, Ian Stavness, Wei Guo, Berton Earnshaw, Imran Haque, Sara M Beery, Jure Leskovec, Anshul Kundaje, Emma Pierson, Sergey Levine, Chelsea Finn, and Percy Liang. Wilds: A benchmark of in-the-wild distribution shifts. In ICML, 2021. (p. 9)
264
+ [60] Lars Kai Hansen and Peter Salamon. Neural network ensembles. IEEE transactions on pattern analysis and machine intelligence, 1990. (p. 9)
265
+ [61] Anders Krogh and Jesper Vedelsby. Neural network ensembles, cross validation, and active learning. In NeurIPS, 1995. (p. 9)
266
+ [62] Kowshik Thopalli, Sameeksha Katoch, Jayaraman J. Thiagarajan, Pavan K. Turaga, and Andreas Spanias. Multi-domain ensembles for domain generalization. In NeurIPS Workshop, 2021. (p. 9)
267
+ [63] Yusuf Mesbah, Youssef Youssry Ibrahim, and Adil Mehood Khan. Domain generalization using ensemble learning. In ISWA, 2022. (p. 9)
268
+ [64] Ziyue Li, Kan Ren, Xinyang Jiang, Bo Li, Haipeng Zhang, and Dongsheng Li. Domain generalization using pretrained models without fine-tuning. arXiv preprint, 2022. (p. 9)
269
+ [65] Yoonho Lee, Huaxiu Yao, and Chelsea Finn. Diversify and disambiguate: Learning from underspecified data. arXiv preprint, 2022. (p. 9)
270
+ [66] Matteo Pagliardini, Martin Jaggi, François Fleuret, and Sai Praneeth Karimireddy. Agree to disagree: Diversity through disagreement for better transferability. arXiv preprint, 2022. (p. 9)
271
+ [67] Florian Wenzel, Jasper Snoek, Dustin Tran, and Rodolphe Jenatton. Hyperparameter ensembles for robustness and uncertainty quantification. In NeurIPS, 2020. (p. 9)
272
+ [68] Leo Breiman. Bagging predictors. Machine learning, 1996. (pp. 9 and 29)
273
+ [69] Jeremy Nixon, Balaji Lakshminarayanan, and Dustin Tran. Why are bootstrapped deep ensembles not better? In NeurIPS Workshop, 2020. (p. 9)
274
+ [70] Teresa Yeo, Oguzhan Fatih Kar, and Amir Roshan Zamir. Robustness via cross-domain ensembles. In ICCV, 2021. (p. 9)
275
+ [71] Yeming Wen, Ghassen Jerfel, Rafael Muller, Michael W Dusenberry, Jasper Snoek, Balaji Lakshminarayanan, and Dustin Tran. Combining ensembles and data augmentation can harm your calibration. In ICLR, 2021. (p. 9)
276
+ [72] Alexandre Rame, Remy Sun, and Matthieu Cord. Mixmo: Mixing multiple inputs for multiple outputs via deep subnetworks. In ICCV, 2021. (pp. 9 and 28)
277
+ [73] Alexandre Rame and Matthieu Cord. Dice: Diversity in deep ensembles via conditional redundancy adversarial estimation. In ICLR, 2021. (pp. 9 and 28)
278
+ [74] Tianyu Pang, Kun Xu, Chao Du, Ning Chen, and Jun Zhu. Improving adversarial robustness via promoting ensemble diversity. In ICML, 2019. (p. 9)
279
+ [75] 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, 2021. (p. 9)
280
+ [76] Felix Draxler, Kambis Veschgini, Manfred Salmhofer, and Fred Hamprecht. Essentially no barriers in neural network energy landscape. In ICML, 2018. (p. 9)
281
+ [77] Hao Guo, Jiyong Jin, and Bin Liu. Stochastic weight averaging revisited. arXiv preprint, 2022. (p. 9)
282
+ [78] Michael Zhang, James Lucas, Jimmy Ba, and Geoffrey E Hinton. Lookahead optimizer: k steps forward, 1 step back. NeurIPS, 32, 2019. (p. 9)
283
+ [79] Vaishnavh Nagarajan and J Zico Kolter. Uniform convergence may be unable to explain generalization in deep learning. NeurIPS, 2019. (p. 9)
284
+ [80] Gregory Benton, Wesley Maddox, Sanae Lotfi, and Andrew Gordon Wilson. Loss surface simplexes for mode connecting volumes and fast ensembling. In ICML, 2021. (p. 9)
285
+ [81] Vipul Gupta, Santiago Akle Serrano, and Dennis DeCoste. Stochastic weight averaging in parallel: Large-batch training that generalizes well. In ICLR, 2020. (p. 9)
286
+ [82] Leshem Choshen, Elad Venezian, Noam Slonim, and Yoav Katz. Fusing finetuned models for better pretraining. arXiv preprint, 2022. (p. 9)
287
+ [83] Mitchell Wortsman, Maxwell Horton, Carlos Guestrin, Ali Farhadi, and Mohammad Rastegari. Learning neural network subspaces. ICML, 2021. (p. 9)
288
+ [84] Wesley J Maddox, Pavel Izmailov, Timur Garipov, Dmitry P Vetrov, and Andrew Gordon Wilson. A simple baseline for bayesian uncertainty in deep learning. In NeurIPS, 2019. (p. 9)
289
+ [85] Pavel Izmailov, Wesley Maddox, Polina Kirichenko, Timur Garipov, Dmitry Vetrov, and Andrew Gordon Wilson. Subspace inference for bayesian deep learning. In UAI, 2019. (p. 9)
290
+ [86] Polina Kirichenko, Pavel Izmailov, and Andrew Gordon Wilson. Last layer re-training is sufficient for robustness to spurious correlations. In ICML SCIS Workshop, 2022. (pp. 17 and 37)
291
+ [87] Su Lin Blodgett, Lisa Green, and Brendan O’Connor. Demographic dialectal variation in social media: A case study of african-american english. In EMNLP, 2016. (p. 17)
292
+ [88] Solon Barocas and Andrew D Selbst. Big data’s disparate impact. Calif. L. Rev., 2016. (p. 17)
293
+ [89] Laurent Dinh, Razvan Pascanu, Samy Bengio, and Yoshua Bengio. Sharp minima can generalize for deep nets. In ICML, 2017. (p. 18)
294
+ [90] Henning Petzka, Michael Kamp, Linara Adilova, Cristian Sminchisescu, and Mario Boley. Relative flatness and generalization. In NeurIPS, 2021. (p. 18)
295
+ [91] Zhewei Yao, Amir Gholami, Kurt Keutzer, and Michael W Mahoney. Pyhessian: Neural networks through the lens of the hessian. In Big Data, 2020. (p. 18)
296
+ [92] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint, 2022. (p. 19)
297
+ [93] Carl Edward Rasmussen. Gaussian processes in machine learning. In Summer school on machine learning, 2003. (p. 24)
298
+ [94] Fernando Pérez-Cruz, Steven Van Vaerenbergh, Juan José Murillo-Fuentes, Miguel LázaroGredilla, and Ignacio Santamaria. Gaussian processes for nonlinear signal processing: An overview of recent advances. EEE Signal Process. Mag., 2013. (p. 25)
299
+ [95] Greg Yang and Hadi Salman. A fine-grained spectral perspective on neural networks. arXiv preprint, 2019. (p. 25)
300
+ [96] Damien Brain and Geoffrey I Webb. On the effect of data set size on bias and variance in classification learning. In AKAW, 1999. (p. 25)
301
+ [97] Arthur Gretton, Karsten M. Borgwardt, Malte J. Rasch, Bernhard Schölkopf, and Alexander Smola. A kernel two-sample test. Journal of Machine Learning Research, 13(25):723–773, 2012. (p. 26) [98] Jan R Magnus and Heinz Neudecker. Matrix differential calculus with applications in statistics and econometrics. John Wiley & Sons, 2019. (p. 26) [99] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In ICML, 2021. (p. 27) [100] Saurabh Singh, Derek Hoiem, and David Forsyth. Swapout: Learning an ensemble of deep architectures. In NeurIPS, 2016. (p. 28) [101] Bradley Efron. Bootstrap methods: another look at the jackknife. In Breakthroughs in statistics.
302
+ 1992. (p. 29) [102] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR,
303
+ 2015. (p. 33) [103] Yann LeCun, Corinna Cortes, and Chris Burges. Mnist handwritten digit database, 2010. (p. 36) [104] Elan Rosenfeld, Pradeep Ravikumar, and Andrej Risteski. Domain-adjusted regression or: Erm may already learn features sufficient for out-of-distribution generalization. 2022. (p. 37)
304
+
305
+ # Checklist
306
+
307
+ 1. For all authors...
308
+
309
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
310
+ (b) Did you describe the limitations of your work? [Yes] In Section 5.2.
311
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] In Appendix A
312
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
313
+
314
+ 2. If you are including theoretical results...
315
+
316
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] Assumption 1 discussed in Appendix C.3.2 and Assumptions 2 and 3 discussed in Appendix C.4.2. (b) Did you include complete proofs of all theoretical results? [Yes] In Appendix C
317
+
318
+ 3. If you ran experiments...
319
+
320
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Our code is available at https://github.com/alexrame/diwa.
321
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5 and Appendix G.1
322
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] Defined by different data splits when possible.
323
+ (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] Approximately 20000 hours of GPUs (Nvidia V100) on an internal cluster, mostly for the 2640 runs needed in Table 1.
324
+
325
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
326
+
327
+ (a) If your work uses existing assets, did you cite the creators? [Yes] DomainBed benchmark [12] and its datasets.
328
+ (b) Did you mention the license of the assets? [Yes] DomainBed is under “The MIT License”.
329
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
330
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
331
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
332
+
333
+ 5. If you used crowdsourcing or conducted research with human subjects...
334
+
335
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
336
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
337
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/tro0_OqIVde/tro0_OqIVde.md ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HorNet: Efficient High-Order Spatial Interactions with Recursive Gated Convolutions
2
+
3
+ Yongming Rao1∗ Wenliang Zhao1∗ Yansong Tang1 Jie Zhou1† Ser-Nam Lim2† Jiwen Lu1† 1Tsinghua University 2Meta AI
4
+
5
+ # Abstract
6
+
7
+ Recent progress in vision Transformers exhibits great success in various tasks driven by the new spatial modeling mechanism based on dot-product self-attention. In this paper, we show that the key ingredients behind the vision Transformers, namely input-adaptive, long-range and high-order spatial interactions, can also be efficiently implemented with a convolution-based framework. We present the Recursive Gated Convolution $( g ^ { n } \mathbf { C } \mathbf { o n v } )$ that performs high-order spatial interactions with gated convolutions and recursive designs. The new operation is highly flexible and customizable, which is compatible with various variants of convolution and extends the two-order interactions in self-attention to arbitrary orders without introducing significant extra computation. $g ^ { n } \mathbf { C } \mathbf { o n v }$ can serve as a plug-and-play module to improve various vision Transformers and convolution-based models. Based on the operation, we construct a new family of generic vision backbones named HorNet. Extensive experiments on ImageNet classification, COCO object detection and ADE20K semantic segmentation show HorNet outperform Swin Transformers and ConvNeXt by a significant margin with similar overall architecture and training configurations. HorNet also shows favorable scalability to more training data and a larger model size. Apart from the effectiveness in visual encoders, we also show $g ^ { n } \mathbf { C } \mathbf { o n v }$ can be applied to task-specific decoders and consistently improve dense prediction performance with less computation. Our results demonstrate that $g ^ { n } \mathbf { C o n v }$ can be a new basic module for visual modeling that effectively combines the merits of both vision Transformers and CNNs. Code is available at https://github.com/raoyongming/HorNet.
8
+
9
+ # 1 Introduction
10
+
11
+ Convolutional neural networks (CNN) have driven remarkable progress in deep learning and computation vision since the introduction of AlexNet [31] in the last decade. There are quite a few nice properties of CNNs making them naturally suitable for a wide range of vision applications. Translation equivariance introduces useful inductive biases to major vision tasks and enables transferability across different input resolutions. The highly optimized implementation makes it efficient on both high-performance GPUs and edge devices. The evolution of architectures [32, 31, 49, 50, 22, 24, 51] further increases its popularity on various vision tasks.
12
+
13
+ The emergence of Transformer-based architectures [16, 52, 42] greatly challenges the dominance of CNNs. By combining some successful designs in CNN architectures and the new self-attention mechanism, vision Transformers have shown leading performance on various vision tasks such as image classification [12, 42, 48], object detection [70, 41], semantic segmentation [6, 8] and video understanding [64, 18]. What makes vision Transformers more powerful than CNNs? Some efforts have been made to improve the CNN architectures by learning from the new designs in vision
14
+
15
+ ![](images/7bfa86cfd205160de54bfd56842d48f5b75ee97fbab30cf9c058085f7d508530.jpg)
16
+ Figure 1: Illustration of our main idea. We show representative spatial modeling operations that perform different orders of interactions. In this paper, we focus on studying explicit spatial interactions between a feature (red) and its neighboring region (light gray). (a) The standard convolution operation does not explicitly consider the spatial interaction. (b) Dynamic convolution [28, 4] and SE [25] introduce the dynamic weights to improve the modeling power of convolutions with extra spatial interactions. (c) The self-attention operation [56] performs two-order spatial interactions with two successive matrix multiplications. (d) $g ^ { n } \mathbf { C o n v }$ realizes arbitrary-order spatial interactions using a highly efficient implementation with gated convolutions and recursive deigns.
17
+
18
+ Transformers. [43] presents a thorough study to adopt the meta architecture of vision Transformer to improve CNNs and proposes to use a large $7 \times 7$ kernel to construct a modern CNN. [46] and [14] propose to use even larger kernels to learn long-range relations with global filters and up to $3 1 \times 3 1$ convolutions, respectively. [20] shows that the input-adaptive weights play a key role in vision Transformers and achieve similar performance with Swin Transformers with dynamic convolutions [4, 28]. However, the effectiveness of dot-product self-attention in vision tasks has not been analyzed from the prospective of high-order spatial interactions.
19
+
20
+ While there exists complex and often high-order interactions between two spatial locations in a deep model due to the non-linearity, the success of self-attention and other dynamic networks suggests that the explicit and high-order spatial interactions introduced by the architectural designs are beneficial to improving the modeling power of vision models. As illustrated in Figure 1, the plain convolution operation does not explicitly consider the spatial interactions between a spatial location (i.e., the red feature) and its neighboring region (i.e., the light gray region). Enhanced convolution operations like dynamic convolution [4, 28, 20] introduce explicit spatial interaction by generating dynamic weights. The dot-product self-attention operation in Transformers [56] consists of two successive spatial interactions by performing matrix multiplication among queries, keys and values. The trend of the basic operations for visual modeling indicates that the network capacity can be improved by increasing the order of spatial interactions.
21
+
22
+ In this paper, we summarize that the key ingredient behind the success of vision Transformers is the new way of spatial modeling with input-adaptive, long-range and high-order spatial interactions performed by the self-attention operation. While previous work has successfully migrated the meta architecture [43, 20, 46, 14], input-adaptive weight generation strategy [20] and large-range modeling ability [46, 14] of vision Transformers to CNN models, a higher-order spatial interaction mechanism has not been studied. We show that all the three key ingredients can be efficiently implemented using a convolution-based framework. We propose the Recursive Gated Convolution $( g ^ { n } \mathbf { C } \mathbf { o n v } )$ that performs high-order spatial interactions with gated convolutions and recursive deigns. Instead of simply imitating the successful designs in self-attention, $g ^ { n } \mathbf { C } \mathbf { o n v }$ has several extra favorable properties: 1) Efficient. The convolution-based implementation avoids the quadratic complexity of self-attention. The design that progressively increases the channel width during performing spatial interactions also enables us to achieve higher-order interactions with bounded complexity; 2) Extendable. We extend the two-order interaction in self-attention to arbitrary orders to further improve the modeling power. Since we do not make assumptions on the type of spatial convolution, $g ^ { n } \mathbf { C } \mathbf { o n v }$ is compatible with various kernel size and spatial mixing strategies like [46, 14]; 3) Translation-equivariant. $g ^ { n } \mathbf { C o n v }$ fully inherits the translation equivariance of the standard convolution, which introduces beneficial inductive biases to major vision tasks and avoids the asymmetry brought by local attention [42, 34].
23
+
24
+ Based on $g ^ { n } \mathbf { C o n v }$ , we construct a new family of generic vision backbones named HorNet. We conduct extensive experiments on ImageNet classification [13], COCO object detection [38] and ADE20K semantic segmentation [71] to verify the effectiveness of our models. With the same $7 \times 7$ kernel/window and similar overall architecture and training configurations, HorNet outperforms Swin and ConvNeXt by a large margin on all tasks at different levels of complexity. The gap can be further enlarged by using a global kernel size [46]. HorNet also shows favorable scalability to more training data and larger model size, attaining $8 7 . 7 \%$ top-1 accuracy on ImageNet, $5 7 . 9 \%$ mIoU on ADE20K val and $5 9 . 2 \%$ bounding box AP on COCO val with ImageNet-22K pre-training. Apart from applying $g ^ { n } \mathbf { C } \mathbf { o n v }$ in visual encoders, we further test the generality of our designs on task-specific decoders. By adding $g \mathrm { C o n v }$ to the widely used feature fusion model FPN [36], we develop HorFPN to model the high-order spatial relationships of features from different hierarchical levels. We observe that HorFPN can also consistently improve various dense prediction models with lower computational costs. Our results demonstrate that $g ^ { n } \mathbf { C } \mathbf { o n v }$ can be a promising alternative to self-attention for visual modeling and effectively combine the merits of both vision Transformers and CNNs.
25
+
26
+ # 2 Related Work
27
+
28
+ Vision Transformers. The Transformer architecture [56] is originally designed for the natural language processing tasks. Since Dosovitskiy et al. [16] show that vision models constructed only by the Transformer blocks and a patch embedding layer can also achieve competitive performance to CNNs, many new models have been proposed to modify the Transformer-based architecture and make it more suitable for various vision tasks [42, 58, 60, 9, 66, 55]. Different from the original designs in [16], state-of-the-art vision Transformers usually utilize a CNN-like hierarchical architecture and change the global self-attention among all patches to local self-attention to avoid the quadratic complexity. In this paper, we follow the overall architecture of the previous hierarchical vision Transformers [42] and replace the self-attention sub-layer with our proposed $g ^ { n } \mathbf { C } \mathbf { o n v }$ to fairly compare with the previous Transformer-based models.
29
+
30
+ Convolution-based models. Inspired by the recent success of vision Transformers, several papers propose to adopt the Transformer-style architecture and spatial convolutions with a large kernel size to improve the performance of CNNs. Han et al. [20] replace the window self-attention in Swin Transformers with large-kernel dynamic convolutions and achieve better performance. GFNet [46] proposes to perform the global spatial interactions like vision Transformers with global filters in the frequency domain, which are equivalent to depth-wise convolutions with a global kernel size and circular padding. ConvNeXt [43] thoroughly analyzes the designs in recent vision Transformers and presents a strong convolutional model with $7 \times 7$ depth-wise convolutions. RepLKNet [14] explores CNN models with very large kernels (up to $3 1 \times 3 1$ ), showing good scalability as vision Transformers. VAN [19] and FocalNet [65] use gated convolutions to perform input-adaptive attention and adopts large-kernel dilated convolutions and multiple successive $3 \times 3$ convolutions respectively to produce the weights. Previous work focuses on the meta architecture [67], large-kernel designs and inputadaptive weights to improve CNNs by learning from vision Transformers. In this paper, we offer a new perspective of high-order spatial attention to analyze the merits of vision Transformers. We show that the proposed HorNet that combines the advantages of both CNNs and vision Transformers is a better architecture for various vision tasks.
31
+
32
+ Hybrid models. Combining vision Transformers and CNNs to develop hybrid architectures is a new direction in various visual recognition problems. Recently, several efforts have been made to integrate the two types of blocks into a unified model with a sequential [12, 29, 68, 63] or parallel [45, 11] design. Many enhanced vision Transformers also use lightweight convolutions in the basic building block to efficiently capture neighboring patterns [15, 60, 17] or relax the quadratic complexity of self-attention [9, 58, 18]. Different from these hybrid models, we aim to develop a self-attention free model while combining the favorable properties of both vision Transformers and CNNs.
33
+
34
+ # 3 Method
35
+
36
+ # 3.1 ${ \pmb { g } } ^ { n } { \bf C } { \bf 0 } { \bf n } { \bf v }$ : Recursive Gated Convolutions
37
+
38
+ In this section, we will present $g ^ { n } \mathbf { C } \mathbf { o n v }$ , an efficient operation to achieve long-term and high-order spatial interactions. The $g ^ { n } \mathbf { C } \mathbf { o n v }$ is built with standard convolutions, linear projections and elementwise multiplications, but has a similar function of input-adaptive spatial mixing to self-attention.
39
+
40
+ Input-adaptive interactions with gated convolution. Recent success in vision Transformers mainly depends on the proper modeling of the spatial interactions in visual data. Unlike CNNs that simply use the static convolution kernel to aggregate neighboring features, vision Transformers apply multi-head self-attention to dynamically generate the weights to mix spatial tokens. However, the quadratic complexity w.r.t. the input size of the self-attention largely hinders the application of vision Transformers, especially on downstream tasks including segmentation and detection where higher-resolution feature maps are required. In this work, instead of reducing the complexity of self-attention like previous methods [42, 9, 57], we seek a more efficient and effective way to perform spatial interactions with simple operations like convolution and fully-connected layers.
41
+
42
+ The basic operation of our method is the gated convolution $( g \mathbf { C o n v } )$ . Let $\mathbf { x } \in \mathbb { R } ^ { H W \times C }$ be the input feature, the output of the gated convolution $\mathbf { y } = g \mathbf { C o n v } ( \mathbf { x } )$ can be written as:
43
+
44
+ $$
45
+ \begin{array} { r } { [ \mathbf { p } _ { 0 } ^ { H W \times C } , \mathbf { q } _ { 0 } ^ { H W \times C } ] = \phi _ { \mathrm { i n } } ( \mathbf { x } ) \in \mathbb { R } ^ { H W \times 2 C } , } \\ { \mathbf { p } _ { 1 } = f ( \mathbf { q } _ { 0 } ) \odot \mathbf { p } _ { 0 } \in \mathbb { R } ^ { H W \times C } , \quad \mathbf { y } = \phi _ { \mathrm { o u t } } ( \mathbf { p } _ { 1 } ) \in \mathbb { R } ^ { H W \times C } , } \end{array}
46
+ $$
47
+
48
+ where $\phi _ { \mathrm { i n } } , \phi _ { \mathrm { o u t } }$ are linear projection layers to perform channel mixing and $f$ is a depth-wise convolution. Note that $\begin{array} { r } { p _ { 1 } ^ { ( i , c ) } = \sum _ { j \in \Omega _ { i } } { w _ { i \to j } ^ { c } q _ { 0 } ^ { ( j , c ) } \bar { p _ { 0 } ^ { ( i , c ) } } } } \end{array}$ , where $\Omega _ { i }$ is the local window centered at $i$ and $w$ represents the convolution weight of $f$ . Therefore, the above formulation explicitly introduce interactions among the neighboring features $\mathbf { p } _ { 0 } ^ { ( i ) }$ and $\mathbf { q } _ { 0 } ^ { ( j ) }$ through the element-wise multiplication. We consider the interaction in $g \mathrm { C o n v }$ as $I$ -order interaction as each $\mathbf { p } _ { 0 } ^ { ( i ) }$ has interacted with its neighbor feature $\mathbf { q } _ { 0 } ^ { ( j ) }$ only once.
49
+
50
+ High-order interactions with recursive gating. After achieving an efficient 1-order spatial interactions with the $g \mathrm { C o n v }$ , we then design the $g ^ { n } \mathbf { C } \mathbf { o n v }$ , a recursive gated convolution to further enhance the model capacity by introducing higher-order interactions. Formally, we first use $\phi _ { \mathrm { i n } }$ to obtain a set of projected features p0 and {qk}n−1k=0 :
51
+
52
+ $$
53
+ \left[ \mathbf { p } _ { 0 } ^ { H W \times C _ { 0 } } , \mathbf { q } _ { 0 } ^ { H W \times C _ { 0 } } , \dots , \mathbf { q } _ { n - 1 } ^ { H W \times C _ { n - 1 } } \right] = \phi _ { \mathrm { i n } } ( \mathbf { x } ) \in \mathbb { R } ^ { H W \times ( C _ { 0 } + \sum _ { 0 \leq k \leq n - 1 } C _ { k } ) } .
54
+ $$
55
+
56
+ We then perform the gated convolution recursively by
57
+
58
+ $$
59
+ \mathbf { p } _ { k + 1 } = f _ { k } ( \mathbf { q } _ { k } ) \odot g _ { k } ( \mathbf { p } _ { k } ) / \alpha , \qquad k = 0 , 1 , \ldots , n - 1 ,
60
+ $$
61
+
62
+ where we scale the output by $1 / \alpha$ to stabilize the training. $\{ f _ { k } \}$ are a set of depth-wise convolution layers and $\left\{ g _ { k } \right\}$ are used to match the dimension in different orders:
63
+
64
+ $$
65
+ g _ { k } = \Big \{ \mathrm { I d e n t i t y } , \quad k = 0 ,
66
+ $$
67
+
68
+ Finally, we feed the output of the last recursion step $\mathbf { q } _ { n }$ to the projection layer $\phi _ { \mathrm { o u t } }$ to obtain the result of the $g ^ { n } \mathbf { C } \mathbf { o n v }$ . From the recursive formula Equation (3.3), it is easy to show that the interaction-order of $\mathbf { p } _ { k }$ will be increased by 1 after each step. As a result, we can see that the $g ^ { n } \mathbf { C o n v }$ achieves $n$ -order spatial interactions. It is also worth noting that we need only a single $f$ to perform depthwise convolution to the concatenation of the features $\scriptstyle \{ \mathbf { q } _ { k } \} _ { k = 0 } ^ { n - 1 }$ together instead of computing the convolution in each recursive step as in Equation (3.3), which can further simplify the implementation and improve the efficiency on GPUs. To ensure that the high-order interactions do not introduce too much computational overhead, we set the channel dimension in each order as:
69
+
70
+ $$
71
+ C _ { k } = { \frac { C } { 2 ^ { n - k - 1 } } } , \qquad 0 \leq k \leq n - 1 .
72
+ $$
73
+
74
+ This design indicates that we perform the interactions in a coarse-to-fine manner, where lower orders are computed with fewer channels. Besides, the channel dimension of $\phi _ { \mathrm { i n } } ( \mathbf { x } )$ is exactly $2 C$ and the total FLOPs can be strictly bounded even with $n$ increasing. It can be proved that (see Appendix A):
75
+
76
+ $$
77
+ \mathrm { F L O P s } ( g ^ { n } \mathrm { C o n v } ) < H W C ( 2 K ^ { 2 } + 1 1 / 3 \times C + 2 ) ,
78
+ $$
79
+
80
+ where $K$ is the kernel size of the depth-wise convolution. Therefore, our $g ^ { n } \mathbf { C } \mathbf { o n v }$ achieves high-order interactions with a similar computational cost to a convolutional layer.
81
+
82
+ Long-term interactions with large kernel convolutions. Another difference between vision Transformers and conventional CNNs is the receptive field. Conventional CNNs [49, 22] often use $3 \times 3$ convolution through the whole network, while vision Transformers calculate self-attention on the whole feature maps [16, 52] or inside a relatively large local window (e.g., $7 \times 7$ ). The large receptive field in vision Transformers makes it easier to capture long-term dependencies, which is also recognized as one of the key advantages of vision Transformers. Inspired by this design, there are some efforts to introduce large kernel convolutions to CNNs recently [14, 43, 46]. To make our $g ^ { n } \mathbf { C } \mathbf { o n v }$ capable of capturing long-term interactions, we adopt two implementations for the depth-wise convolution $f$ :
83
+
84
+ ![](images/c822177566daa8abd09c544c6770b2efaebc5f0fda9b6ddd9ae9b56ec3d813f5.jpg)
85
+ Figure 2: Overview of the basic building block in HorNet with $g ^ { n } \mathbf { C o n v } .$ We adopt the block design of Transformers [56] and replace the self-attention sub-layer with $g ^ { n } \mathbf { C o n v }$ to develop our HorNet (left). We also provide the detailed implementation of $g ^ { 3 } \mathrm { C o n v }$ (middle) and the Pytorch-style code for an arbitrary order (right).
86
+
87
+ • $7 \times 7$ Convolution. $7 \times 7$ is the default window/kernel size of Swin Transformers [42] and ConvNext [43]. Studies in [43] show that the kernel size produces good performance on ImageNet classification and various downstream tasks. We follow this configuration to fairly compare with representative work of vision Transformers and modern CNNs. Global Filter $( G F )$ . The GF layer [46] multiplies the frequency domain features with learnable global filters, which is equivalent to a convolution in the spatial domain with a global kernel size and circular padding. We use a modified version of the GF layer by processing half of the channels with the global filter and the other half with $3 \times 3$ depth-wise convolutions and only use GF layers in late stages to preserve more local details.
88
+
89
+ Spatial interactions in vision models. We review some representative vision model designs from the perspective of spatial interactions, as shown in Figure 1. Specifically, we are interested in the interactions between a feature $\mathbf { x } _ { i }$ and its neighboring feature $\mathbf { x } _ { j } , j \in \Omega _ { i }$ . By using the tool designed for explaining the interaction effect (IE) in [33, 1], we provide an intuitive analysis of the order of explicit spatial interactions in Appendix B. Our analysis reveals a key difference between vision Transformers and previous architectures from a new view, i.e., vision Transformers have higher-order spatial interactions in each basic block. The result inspires us to explore an architecture that can realize more efficient and effective spatial interactions with more than two orders. As discussed above, our proposed $g ^ { n } \mathbf { C } \mathbf { o n v }$ can achieve arbitrary-order interactions with bounded complexity. It is also worth noting that similar to other scaling factors in deep models like width [69] and depth [22], simply increasing the order of spatial interactions without considering the overall model capacity will not lead to a good trade-off [51]. In this paper, we focus on developing a stronger visual modeling architecture based on the analysis of the spatial interaction orders of well-designed models. We believe a more thorough and formal discussion on the high-order spatial interactions can be an important future direction.
90
+
91
+ Relation to dot-product self-attention. Although the computation of our $g ^ { n } \mathbf { C } \mathbf { o n v }$ largely differs from dot-product self-attention, we will show that $g ^ { n } \mathbf { C } \mathbf { o n v }$ also accomplishes the goal of inputadaptive spatial mixing. Let $\mathbf { M }$ be the attention matrix obtained by multi-head self-attention (MHSA), we write $\mathbf { M }$ as $( m _ { i j } ^ { c } )$ since the mixing weight may vary across the channels. The spatial mixing result (before the final channel mixing projection) of the $c$ -th channel at location $i$ is
92
+
93
+ $$
94
+ x _ { \mathrm { M H S A } } ^ { ( i , c ) } = \sum _ { j \in \Omega _ { i } } m _ { i j } ^ { c } v ^ { ( i , j ) } = \sum _ { j \in \Omega _ { i } } \sum _ { c ^ { \prime } = 1 } ^ { C } \underline { { m _ { i j } ^ { c } } } w _ { V } ^ { ( c ^ { \prime } , c ) } x ^ { ( j , c ^ { \prime } ) } ,
95
+ $$
96
+
97
+ where $w _ { V }$ is the weight of the V-projection layer. Note that $m _ { i j }$ obtained by the dot-product operation contains 1-order interaction. On the other hand, the output of our $g ^ { n } \mathbf { C } \mathbf { o n v }$ (before the $\phi _ { \mathrm { o u t } }$ ) can be written as
98
+
99
+ $$
100
+ x _ { g ^ { n } \mathrm { C o n v } } ^ { ( i , c ) } = p _ { n } ^ { ( i , c ) } = \sum _ { j \in \Omega _ { i } } \sum _ { c ^ { \prime } = 1 } ^ { C } \underline { { w _ { n - 1 , i \to j } ^ { c } } } \underline { { \mathbf { g } _ { n - 1 } ^ { ( i , c ) } } } w _ { \phi _ { \mathrm { i n } } } ^ { ( c ^ { \prime } , c ) } x ^ { ( j , c ^ { \prime } ) } \triangleq \sum _ { j \in \Omega _ { i } } \sum _ { c ^ { \prime } = 1 } ^ { C } \underline { { h _ { i j } ^ { c } } } w _ { \phi _ { \mathrm { i n } } } ^ { ( c ^ { \prime } , c ) } x ^ { ( j , c ^ { \prime } ) } ,
101
+ $$
102
+
103
+ where $w _ { n - 1 }$ is the convolutional weight for $f _ { n - 1 } , w _ { \phi _ { \mathrm { i n } } }$ is the linear weight of $\phi _ { \mathrm { i n } }$ , and $\mathbf { g } _ { n - 1 } =$ $g _ { n - 1 } ( \mathbf { p } _ { n - 1 } )$ is a projection of $\mathbf { p } _ { n - 1 }$ . From the formulation in Equation (3.8) we find our $g ^ { n } \mathbf { C } \mathbf { o n v }$ also achieves input-adaptive spatial mixing with $\{ h _ { i j } ^ { c } \}$ as the weights. Observing that $h _ { i j }$ is computed from $\mathbf { p } _ { n - 1 }$ which contains $n - 1$ order interactions, we can regard our $g ^ { n } \mathbf { C o n v }$ as an extension of the self-attention in terms of the order of the spatial mixing weight. Therefore, our $g ^ { n } \mathbf { C o n v }$ can better model more complex spatial interactions.
104
+
105
+ The details of $g ^ { n } \mathbf { C } \mathbf { o n v }$ and our implementation are summarized in Figure 2.
106
+
107
+ # 3.2 Model Architectures
108
+
109
+ HorNet. The $g ^ { n } \mathbf { C } \mathbf { o n v }$ can be a drop-in replacement of the spatial mixing layer in vision Transformers [52, 42] or modern CNNs [43]. We follow the same meta-architecture as [56, 42] to construct HorNet, where the basic block contains a spatial mixing layer and a feed-forward network (FFN). Depending on the model size and the implementation of the depth-wise convolution $f _ { k }$ in our $g ^ { n } \mathbf { C } \mathbf { o n v }$ we have two series of model variants named HorNet-T/S/B/L $7 \times 7$ and HorNet-T/S/B/LGF. We consider the popular Swin Transformer [42] and ConvNeXt [43] as the vision Transformer and CNN baselines since our models are implemented based on a convolution-based framework while having high-order interactions like vision Transformers. To fairly compare with the baselines, we directly follow the number of blocks of Swin Transformers-S/B/L [42] but insert an extra block to the stage 2 to make the overall complexity close, resulting in [2, 3, 18, 2] blocks in each stage in all of the model variants. We simply adjust the base number of channels $C$ to construct models with different sizes and set the number of channels in 4 stages as $[ C , 2 C , 4 C , 8 C ]$ following common practice. We use $C = 6 4$ , 96, 128, 192 for HorNet-T/S/B/L, respectively. We set the interaction orders (i.e., the $n$ in $g ^ { n } \mathbf { C } \mathbf { o n v } )$ for each stage as 2,3,4,5 by default, such that the channels of the coarsest order $C _ { 0 }$ is the same across different stages.
110
+
111
+ HorFPN. Apart from using $g ^ { n } \mathbf { C o n v }$ in visual encoders, we find our $g ^ { n } \mathbf { C } \mathbf { o n v }$ can be an enhanced alternative for standard convolution that considers higher-order spatial interactions in a wide range of convolution-based models. Thus, we replace spatial convolutions for feature fusion in the FPN [37] with our $g ^ { n } \mathbf { C } \mathbf { o n v }$ to improve spatial interactions for downstream tasks. Specifically, we add our $g ^ { n } \mathbf { C } \mathbf { o n v }$ after the fusion of features from different pyramid levels. For object detection, we replace the $3 \times 3$ convolution after the top-down pathway with the $g ^ { n } \mathbf { C } \mathbf { o n v }$ in each level. For semantic segmentation, we simply replace the $3 \times 3$ convolution after the concatenation of the multi-level feature maps with $g ^ { n } \mathbf { C } \mathbf { o n v }$ since the final results are directly predicted from this concatenated feature. We also have two implementations called $\mathrm { H o r F P N } _ { 7 \times 7 }$ and $\mathrm { H o r F P N } _ { \mathrm { G F } }$ decided by the choice of $f _ { k }$ .
112
+
113
+ # 4 Experiments
114
+
115
+ We conduct extensive experiments to verify the effectiveness of our method. We present the main results on ImageNet [13] and compare them with various architectures. We also test our models on the downstream dense prediction tasks on commonly used semantic segmentation benchmark ADE20K [71] and object detection dataset COCO [38]. Lastly, we provide ablation studies of our designs and analyze the effectiveness of $g ^ { n } \mathbf { C o n v }$ on a wide range of models.
116
+
117
+ # 4.1 ImageNet Classification
118
+
119
+ Setups. We conduct image classification experiments on the widely used ImageNet [13] dataset. We train our HorNet-T/S/B models using the standard ImageNet-1K dataset following common practice. To fairly compare with previous work, we directly use the training configurations of [43, 42, 52] to train our models. We train the models for 300 epochs with $2 2 4 \times 2 2 4$ input. To evaluate the scaling ability of our designs, we further train the HorNet-L models on the ImageNet-22K dataset that contains over $1 0 \times$ images and more categories. We follow previous practice [42, 43] to train our models for 90 epochs and use a similar data augmentation strategy as ImageNet-1K experiments.
120
+
121
+ Table 1: ImageNet classification results. We compare our models with state-of-the-art vision Transformers and CNNs that have comparable FLOPs and parameters. We report the top-1 accuracy on the validation set of ImageNet as well as the number of parameters and FLOPs. We also show the improvements over Swin Trasnformers that have similar overall architectures and training configurations to our models. “ $\uparrow 3 8 4 ^ { \circ }$ indicates that the model is fine-tuned on $3 8 4 \times 3 8 4$ images for 30 epochs. Our models are highlighted in gray.
122
+
123
+ <table><tr><td>Model</td><td>Image Size</td><td>(M)</td><td>Params FLOPs Top-1 (G)</td><td>Acc.(%)</td></tr><tr><td>ImageNet-1K trained models</td><td></td><td></td><td></td><td></td></tr><tr><td>EfficientNet-B4 [51]</td><td>3802</td><td>19</td><td>4.2</td><td>82.9</td></tr><tr><td>EfficientNet-B5[51]</td><td>4562</td><td>30</td><td>9.9</td><td>83.6</td></tr><tr><td>EfficientNet-B6 [51]</td><td>5282</td><td>43</td><td>19.0</td><td>84.0</td></tr><tr><td>EfficientNetV2-S[51]</td><td>3002</td><td>24</td><td>8.8</td><td>83.9</td></tr><tr><td>RepLKNet-31B [14]</td><td>2242</td><td>79</td><td>15.3</td><td>83.5</td></tr><tr><td>VAN-B [19]</td><td>2242</td><td>27</td><td>5.0</td><td>82.8</td></tr><tr><td>VAN-L [19]</td><td>2242</td><td>45</td><td>9.0</td><td>83.9</td></tr><tr><td>CSWin-T[15]</td><td>224²</td><td>23</td><td>4.3</td><td>82.7</td></tr><tr><td>CSWin-S[15]</td><td>2242</td><td>35</td><td>6.9</td><td>83.6</td></tr><tr><td>CSWin-B[15]</td><td>2242</td><td>78</td><td>15.0</td><td>84.2</td></tr><tr><td>Swin-T[42]</td><td>2242</td><td>28</td><td>4.5</td><td>81.3</td></tr><tr><td>ConvNeXt-T[43]</td><td>2242</td><td>29</td><td>4.5</td><td>82.1(+0.7)</td></tr><tr><td>HorNet-T7×7</td><td>224²</td><td>22</td><td>4.0</td><td>82.8(+1.5)</td></tr><tr><td>HorNet-TGF</td><td>2242</td><td>23</td><td>3.9</td><td>83.0(+1.7)</td></tr><tr><td>Swin-S [42]</td><td>2242</td><td>50</td><td>8.7</td><td>83.0</td></tr><tr><td>ConvNeXt-S [43]</td><td>2242</td><td>50</td><td>8.7</td><td>83.1(+0.1)</td></tr><tr><td>HorNet-S7×7</td><td>224²</td><td>50</td><td>8.8</td><td>83.8(+0.8)</td></tr><tr><td>HorNet-SGF</td><td>224²</td><td>50</td><td>8.7</td><td>84.0(+1.0)</td></tr><tr><td>Swin-B [42]</td><td>224²</td><td>89</td><td>15.4</td><td>83.5</td></tr><tr><td>ConvNeXt-B [43]</td><td>2242</td><td>88</td><td>15.4</td><td>83.8(+0.3)</td></tr><tr><td>HorNet-B7×7</td><td>2242</td><td>87</td><td>15.6</td><td>84.2(+0.7)</td></tr><tr><td>HorNet-BGF</td><td>224²</td><td>88</td><td>15.5</td><td>84.3(+0.8)</td></tr></table>
124
+
125
+ <table><tr><td>Model</td><td>Image Size</td><td>(M)</td><td>Params FLOPs Top-1 (G)</td><td>Acc. (%)</td></tr><tr><td colspan="5">ImageNet-1K trained models (fine-tuned at 384×384)</td></tr><tr><td>Swin-B↑384 [42]</td><td>3842</td><td>89</td><td>47.1</td><td>84.5</td></tr><tr><td>ConvNeXt-B↑384 [43]</td><td>384²</td><td>88</td><td>45.0</td><td>85.1(+0.6)</td></tr><tr><td>HorNet-B7×7↑384</td><td>3842</td><td>87</td><td>45.8</td><td>85.3(+0.8)</td></tr><tr><td>HorNet-BGF↑384</td><td>3842</td><td>92</td><td>45.4</td><td>85.6(+1.1)</td></tr><tr><td colspan="5">ImageNet-22K trained models (fine-tuned to ImageNet-1K)</td></tr><tr><td>R-101x3 [30]</td><td>3842</td><td>388</td><td>204.6</td><td>84.4</td></tr><tr><td>R-152x4 [30]</td><td>4802</td><td>937</td><td>840.5</td><td>85.4</td></tr><tr><td>ViT-B/16 [16]</td><td>3842</td><td>87</td><td>55.5</td><td>84.0</td></tr><tr><td>ViT-L/16 [16]</td><td>3842</td><td>305</td><td>191.1</td><td>85.2</td></tr><tr><td>EfficientNetV2-L [51]</td><td>3802</td><td>121</td><td>53.0</td><td>86.8</td></tr><tr><td>CSWin-L[15]</td><td>3842</td><td>173</td><td>96.8</td><td>87.5</td></tr><tr><td>SwinV2-L [41]</td><td>3842</td><td>197</td><td>115.4</td><td>87.6</td></tr><tr><td>RepLKNet-31L [14]</td><td>3842</td><td>172</td><td>96.0</td><td>86.6</td></tr><tr><td>Swin-L [42]</td><td>224²</td><td>197</td><td>34.5</td><td>86.3</td></tr><tr><td>ConvNeXt-L [43]</td><td>2242</td><td>198</td><td>34.4</td><td>86.6(+0.3)</td></tr><tr><td>HorNet-L7×7</td><td>224²</td><td>195</td><td>34.8</td><td>86.8(+0.5)</td></tr><tr><td>HorNet-LGF</td><td>224²</td><td>196</td><td>34.6</td><td>87.0(+0.7)</td></tr><tr><td>Swin-L↑384 [42]</td><td>3842</td><td>197</td><td>103.9</td><td>87.3</td></tr><tr><td>ConvNeXt-L↑384 [43]</td><td>3842</td><td>198</td><td>101.0</td><td>87.5(+0.2)</td></tr><tr><td>HorNet-L7×7↑384</td><td>384²</td><td>195</td><td>102.3</td><td>87.6(+0.3)</td></tr><tr><td>HorNet-LGF↑384</td><td>3842</td><td>202</td><td>101.8</td><td>87.7(+0.4)</td></tr></table>
126
+
127
+ We fine-tune the models pre-trained on ImageNet-22K or at the $2 2 4 \times 2 2 4$ resolution to ImageNet-1K or/and $3 8 4 \times 3 8 4$ resolution for 30 epochs following [43]. When adapting the ImageNet-22K models to ImageNet-1K, we initialize the classifier with the pre-trained class centers to stabilize the training process. More details can be found in Appendix C.
128
+
129
+ Results. The results of our ImageNet classification experiments are summarized in Table 1. We see that our models achieve very competitive performance with state-of-the-art vision Transformers and CNNs. Notably, HorNet surpasses Swin Transformers and ConvNeXt which have similar overall architectures and training configurations by a healthy margin on various model sizes and settings. Our models also generalize well to a larger image resolution, larger model sizes and more training data. These results clearly demonstrate the effectiveness and generality of our designs.
130
+
131
+ # 4.2 Dense Prediction Tasks
132
+
133
+ HorNet for semantic segmentation. We evaluate our HorNet for semantic segmentation task on ADE20K [71] dataset using the commonly used UperNet [62] framework. All the models are trained for 160k iterations using AdamW [44] optimizer with a global batch size of 16. The image size during training is $5 1 2 \times 5 1 2$ for ImagNet-1k (HorNet-T/S/B) pre-trained models and $6 4 0 \times 6 4 0$ for the ImageNet-22K pre-trained models (HorNet-L). The results are summarized in the left part of Table 2, where we report both the single-scale (SS) and multi-scale (MS) mIoU on the validation set. Both our $\mathrm { H o r N e t } _ { 7 \times 7 }$ and HorNetGF models outperform Swin [42] and ConvNeXt [43] models with similar model sizes and FLOPs. Specifically, HorNetGF models achieve better results than $\mathrm { H o r N e t } _ { 7 \times 7 }$ and ConvNeXt series by large margins in single-scale mIoU, indicating the global interactions captured by the global filter are helpful for semantic segmentation. Notably, we find both our HorNet- $\mathbf { \cdot L } _ { \mathbf { \nabla } \times \mathbf { 7 } }$ and HorNet-LGF even outperform ConvNeXt-XL with ${ \sim } 2 5 \%$ fewer FLOPs. These results clearly demonstrate the effectiveness and scalability of our HorNet on semantic segmentation.
134
+
135
+ HorNet for object detection. We also evaluate our models on the COCO [38] dataset. We adopt the cascade Mask R-CNN framework [21, 2] to perform object detection and instance segmentation using HorNet-T/S/B/L backbones. Following Swin [42] and ConvNeXt [43], we use $3 \times$ schedule with multi-scale training. The right part of Table 2 compares the box AP and mask AP of our HorNet models and Swin/ConvNeXt models. Similarly, we show our HorNet models achieve consistently and significantly better performance than the Swin/ConvNeXt counterparts, in both box AP and mask AP. The HorNetGF series obtain $+ 1 . 2 { \sim } 2 . 0$ box AP and $+ 1 . 0 { \sim } 1 . 9$ mask AP compared with ConvNeXt.
136
+
137
+ Table 2: Object detection and semantic segmentation results with different backbones. We use UperNet [62] for semantic segmentation and Cascade Mask R-CNN [2] for object detection. ‡ indicates that the model is pre-trained on ImageNet-22K. For semantic segmentation, we report both single-scale (SS) and multi-scale (MS) mIoU. The FLOPs are calculated with image size (2048, 512) for ImageNet-1K pre-trained models and (2560, 640) for ImageNet-22K pre-trained models. For object detection, we report the box AP and the mask AP. FLOPs are measured on input sizes of (1280, 800). Our models are highlighted in gray.
138
+
139
+ <table><tr><td rowspan="2">Backbone</td><td colspan="4">Semantic Segmentation with UperNet 160K</td><td colspan="4">Object Detection with Cascade Mask R-CNN 3×</td></tr><tr><td>mIoUss</td><td>mIoUms</td><td>Params</td><td>FLOPs</td><td>APbox</td><td>Apmask</td><td>Params</td><td>FLOPs</td></tr><tr><td>Swin-T[42]</td><td>44.5</td><td>45.8</td><td>60M</td><td>945G</td><td>50.4</td><td>43.7</td><td>86M</td><td>745G</td></tr><tr><td>ConvNeXt-T[43]</td><td>46.0</td><td>46.7</td><td>60M</td><td>939G</td><td>50.4</td><td>43.7</td><td>86M</td><td>741G</td></tr><tr><td>HorNet-T7×7</td><td>48.1</td><td>48.9</td><td>52M</td><td>926G</td><td>51.7</td><td>44.8</td><td>80M</td><td>730G</td></tr><tr><td>HorNet-TGF</td><td>49.2</td><td>49.3</td><td>55m</td><td>924G</td><td>52.4</td><td>45.6</td><td>80M</td><td>728G</td></tr><tr><td>Swin-S [42]</td><td>47.6</td><td>49.5</td><td>81M</td><td>1038G</td><td>51.9</td><td>45.0</td><td>107M</td><td>838G</td></tr><tr><td>ConvNeXt-S[43]</td><td>48.7</td><td>49.6</td><td>82M</td><td>1027G</td><td>51.9</td><td>45.0</td><td>108M</td><td>827G</td></tr><tr><td>HorNet-S7×7</td><td>49.2</td><td>49.8</td><td>81M</td><td>1030G</td><td>52.7</td><td>45.6</td><td>107M</td><td>830G</td></tr><tr><td>HorNet-SGF</td><td>50.0</td><td>50.5</td><td>85M</td><td>1027G</td><td>53.3</td><td>46.3</td><td>108M</td><td>827G</td></tr><tr><td>Swin-B [42]</td><td>48.1</td><td>49.7</td><td>121M</td><td>1188G</td><td>51.9</td><td>45.0</td><td>145M</td><td>982G</td></tr><tr><td>ConvNeXt-B [43]</td><td>49.1</td><td>49.9</td><td>122M</td><td>1170G</td><td>52.7</td><td>45.6</td><td>146M</td><td>964G</td></tr><tr><td>HorNet-B7×7</td><td>50.0</td><td>50.5</td><td>121M</td><td>1174G</td><td>53.3</td><td>46.1</td><td>144M</td><td>969G</td></tr><tr><td>HorNet-BGF</td><td>50.5</td><td>50.9</td><td>126M</td><td>1171G</td><td>54.0</td><td>46.9</td><td>146M</td><td>965G</td></tr><tr><td>Swin-L [42]</td><td>52.1</td><td>53.5</td><td>234M</td><td>2468G</td><td>53.9</td><td>46.7</td><td>253M</td><td>1382G</td></tr><tr><td>ConvNeXt-L [43]</td><td>53.2</td><td>53.7</td><td>235M</td><td>2458G</td><td>54.8</td><td>47.6</td><td>255M</td><td>1354G</td></tr><tr><td>ConvNeXt-XL+ 43]</td><td>53.6</td><td>54.0</td><td>391M</td><td>3335G</td><td>55.2</td><td>47.7</td><td>407M</td><td>1898G</td></tr><tr><td>HorNet-L×7</td><td>54.1</td><td>54.5</td><td>232M</td><td>2473G</td><td>55.4</td><td>48.0</td><td>251M</td><td>1363G</td></tr><tr><td>HorNet-LGF</td><td> 55.0</td><td> 55.2</td><td>239M</td><td>2465G</td><td>56.0</td><td>48.6</td><td>259M</td><td>1358G</td></tr></table>
140
+
141
+ Table 3: Comparisons of HorFPN with standard FPN on different backbones. We use UperNet 160K and Mask R-CNN $1 \times$ schedule for semantic segmentation and object detection, respectively. We find our HorFPN consistently outperforms standard FPN with various of backbones on both the two tasks.
142
+
143
+ <table><tr><td rowspan="2">Backbone</td><td rowspan="2">Fusion Module</td><td colspan="4">Semantic Segmentation with UperNet 160K</td><td colspan="4">Object Detection with Mask R-CNN 1×</td></tr><tr><td>mIoUss</td><td>mIoUms</td><td>Params</td><td>FLOPs</td><td>Apbox</td><td>Apmask</td><td>Params</td><td>FLOPs</td></tr><tr><td rowspan="3">ResNet-50 [22]</td><td>FPN [37]</td><td>40.7</td><td>41.8</td><td>66M</td><td>947G</td><td>38.2</td><td>34.7</td><td>44M</td><td>260G</td></tr><tr><td>HorFPN7×7</td><td>41.8</td><td>44.1</td><td>60M</td><td>499G</td><td>38.7</td><td>35.1</td><td>43M</td><td>226G</td></tr><tr><td>HorFPNGF</td><td>43.2</td><td>44.5</td><td>60M</td><td>497G</td><td>39.1</td><td>35.5</td><td>43M</td><td>224G</td></tr><tr><td rowspan="3">ResNet-101 [22]</td><td>FPN[37]</td><td>42.9</td><td>44.0</td><td>85M</td><td>1025G</td><td>40.0</td><td>36.1</td><td>63M</td><td>336G</td></tr><tr><td>HorFPN7×7</td><td>44.1</td><td>45.5</td><td>79M</td><td>577G</td><td>40.3</td><td>36.4</td><td>62M</td><td>302G</td></tr><tr><td>HorFPNGF</td><td>44.5</td><td>46.4</td><td>79M</td><td>574G</td><td>40.5</td><td>36.7</td><td>62M</td><td>300G</td></tr><tr><td rowspan="3">Swin-S [42]</td><td>FPN [37]</td><td>47.6</td><td>49.5</td><td>81M</td><td>1038G</td><td>45.5</td><td>40.9</td><td>69M</td><td>354G</td></tr><tr><td>HorFPN7×7</td><td>48.0</td><td>49.2</td><td>74M</td><td>580G</td><td>46.3</td><td>41.1</td><td>68M</td><td>325G</td></tr><tr><td>HorFPNGF</td><td>49.0</td><td>49.9</td><td>75M</td><td>578G</td><td>46.8</td><td>41.9</td><td>69M</td><td>323G</td></tr><tr><td rowspan="3">HorNet-S</td><td>FPN [37]</td><td>49.2</td><td>49.8</td><td>81M</td><td>1030G</td><td>47.1</td><td>42.2</td><td>69M</td><td>351G</td></tr><tr><td>HorFPN7×7</td><td>49.4</td><td>50.1</td><td>74M</td><td>577G</td><td>47.4</td><td>42.3</td><td>68M</td><td>322G</td></tr><tr><td>HorFPNGF</td><td>49.7</td><td>50.3</td><td>75M</td><td>575G</td><td>47.7</td><td>42.4</td><td>68M</td><td>321G</td></tr></table>
144
+
145
+ Again, our large model HorNet- $\mathbf { { \cdot } } \mathbf { L } _ { 7 \times 7 }$ and HorNetGF can outperform ConvNeXt-XL, which further validates the favorable transferability with a larger model size and larger pre-trained dataset.
146
+
147
+ HorFPN for dense prediction. We now show another application of the proposed $g ^ { n } \mathbf { C } \mathbf { o n v }$ , i.e., to serve as a better fusion module that can better capture the higher-order interactions among different levels of features in dense prediction tasks. Specifically, we directly modify the FPN [37] as described in Section 3.2 in UperNet [62] and Mask R-CNN [21] for semantic segmentation and object detection, respectively.We show the results in Table 3, where we compare the performance of our HorFPN and standard FPN on different backbones including ResNet-50/101 [22], Swin-S [42] and HorNet- $\mathbf { S } _ { 7 \times 7 }$ . For semantic segmentation, we find our HorFPN can
148
+
149
+ Table 4: Object detection results with recent state-of-the-art frameworks. We report the single-scale $\mathbf { A P } ^ { \mathrm { b o x } }$ and $\mathbf { A P } ^ { \mathrm { m a s k } }$ on the validation set of COCO. Our models are highlighted in gray.
150
+
151
+ <table><tr><td>Backbone</td><td>Framework</td><td>APbox</td><td>Apmask</td></tr><tr><td>Swin-L [42]</td><td>HTC++ [3]</td><td>57.1</td><td>49.5</td></tr><tr><td>ViT-Adapter-L [5]</td><td>HTC++ [3]</td><td>57.9</td><td>50.2</td></tr><tr><td>HorNet-LGF</td><td>HTC++ [3]</td><td>58.1</td><td>50.5</td></tr><tr><td>Swin-L [42]</td><td>DINO [70]</td><td>58.5</td><td>=</td></tr><tr><td>HorNet-LGF</td><td>DINO [70]</td><td>59.2</td><td></td></tr></table>
152
+
153
+ Table 5: Semantic Segmentation results with recent state-of-theart frameworks. We report the single-scale (SS) and multi-scale (MS) mIoU on the validation set of ADE20K. Our models are highlighted in gray.
154
+
155
+ <table><tr><td>Backbone</td><td>Framework</td><td>mIoUss</td><td>mIoUms</td></tr><tr><td>Swin-L [42]</td><td>Mask2Former [7]</td><td>56.1</td><td>57.3</td></tr><tr><td>Swin-L-FaPN[27]</td><td>Mask2Former [7]</td><td>56.4</td><td>57.7</td></tr><tr><td>HorNet-LGF</td><td>Mask2Former [7]</td><td>57.5</td><td>57.9</td></tr></table>
156
+
157
+ significantly reduce the FLOPs $( \sim 5 0 \% )$ while achieving better validation mIoU. For object detection,
158
+
159
+ Table 6: Ablation study and results of applying ${ \pmb { g } } ^ { n } { \bf C o n v }$ to other models/operations. We provide the ablation study of our designs in (a). $[ { ^ { * } } ]$ indicates the baseline of our model. The baseline and our final models are highlighted in gray. In (b) and (c), we apply the proposed $g ^ { n } \mathbf { C } \mathbf { o n v }$ to isotropic models that have a similar level of complexity with ViT/DeiT-S [16, 52] and other spatial mixing operations including the $3 \times 3$ depth-wise convolution and $3 \times 3$ pooling used in [67].
160
+ (a) Ablation study.
161
+
162
+ <table><tr><td>Model</td><td>Params</td><td>FLOPs</td><td>Acc. (%)</td></tr><tr><td>Swin-T[42]</td><td>28M</td><td>4.5G</td><td>81.3(+0.1)</td></tr><tr><td>- Self-Attention + DWConv7×7 [*]</td><td>29M</td><td>4.5G</td><td>81.2</td></tr><tr><td>+ SE [25]</td><td>30M</td><td>4.5G</td><td>81.5(+0.3)</td></tr><tr><td>- SE+g{1,1,1,1)Conv</td><td>28M</td><td>4.3G</td><td>81.7(+0.5)</td></tr><tr><td>+ g12.22.Conv</td><td>28M</td><td>4.3G</td><td>82.2(+1.0)</td></tr><tr><td>+ g(3.3Conv</td><td>28M</td><td>4.3G</td><td>82.5(+1.3)</td></tr><tr><td>+ g14.4.Conv</td><td>28M</td><td>4.3G</td><td>82.5(+1.3)</td></tr><tr><td>+g(1,2,3.)Conv</td><td>28M</td><td>4.3G</td><td>82.5(+1.3)</td></tr><tr><td>+ g2.34.5/Conv</td><td>28M</td><td>4.3G</td><td>82.6(+1.4)</td></tr><tr><td>+ Deeper &amp; Narrower (HorNet-T7×7)</td><td>22M</td><td>4.0G</td><td>82.8(+1.6)</td></tr><tr><td>+ Global Filters [46] (HorNet-TGF)</td><td>23M</td><td>3.9G</td><td>83.0(+1.8)</td></tr><tr><td>ConvNeXt [43]</td><td>28M</td><td>4.5G</td><td>82.1(+0.9)</td></tr></table>
163
+
164
+ (b) Results on isotropic models.
165
+
166
+ <table><tr><td>Model</td><td>FLOPs</td><td>Acc. (%)</td></tr><tr><td>DeiT-S[52]</td><td>4.6G</td><td>79.8</td></tr><tr><td>ConvNeXt-S (iso.) [43]</td><td>4.3G</td><td>79.7</td></tr><tr><td>HorNet-S7×7 (iso.) HorNet-SGF (iso.)</td><td>4.5G 4.5G</td><td>80.6 81.0</td></tr><tr><td></td><td></td><td></td></tr><tr><td>(c) g&quot;Conv for other operations.</td><td></td><td></td></tr><tr><td>Model</td><td>FLOPs</td><td>Acc. (%)</td></tr><tr><td>DWConV3×3</td><td>4.0G</td><td>80.7</td></tr><tr><td> g&quot;ConV3x3</td><td>3.9G</td><td>82.1</td></tr><tr><td>Pool [67]</td><td>3.9G</td><td>78.1</td></tr><tr><td> g&quot;Convpool</td><td>3.8G</td><td>79.3</td></tr></table>
167
+
168
+ ![](images/93260c47a83264e956ef172369e362e3afed03701ebf45e26760b5941389dbc4.jpg)
169
+ Figure 3: Comparisons of trade-offs of Swin, ConvNeXt and HorNet. We compare the trade-offs of the models via the top-1 accuracy on ImageNet w.r.t. (a) number of parameters; (b) FLOPs; (c) latency. The latency is measured with a single NVIDIA RTX 3090 GPU with a batch size of 128.
170
+
171
+ our HorFPN can also outperform standard FPN in terms of both box AP and mask AP on different backbones with about 30G fewer FLOPs. Besides, we observe that the $_ \mathrm { H o r F P N _ { G F } }$ is consistently better than $\mathrm { H o r F P N } _ { 7 \times 7 }$ , indicating that global interactions are also important when fusing hierarchical features.
172
+
173
+ Results with state-of-the-art frameworks. To further show the effectiveness our backbone, we conduct experiments to combine our large HorNet model with recent state-of-the-art dense prediction frameworks including $\mathrm { H T C + + }$ [3], DINO [70] and Mask2Former [7]. For $\mathrm { H T C + + }$ and DINO, we train our models on COCO for 36 epochs $3 \times$ schedule) and does not introduce extra pre-training data like Object365 in [70]. We report the single-scale performance on the validation set and compared with several state-of-the-art methods in Table 4. For Mask2Former, we train our models on ADE20K with $6 4 0 \times 6 4 0$ . We report the mIoU of both single-scale and multi-scale testing on the validation set in Table 5.
174
+
175
+ # 4.3 Analysis
176
+
177
+ Ablation study. We provide detailed ablation studies of the $g ^ { n } \mathbf { C } \mathbf { o n v }$ and our HorNet in Table 6. We first study the model designs of our HorNet in Table 6a. Our baseline $( [ ^ { * } ] )$ is obtained by simply replacing the self-attention with $7 \times 7$ depth-wise convolution in Swin-T [42]. We first show that both SE [25] and our $g ^ { n } \mathbf { C } \mathbf { o n v }$ with $n = 1$ $( g ^ { \{ 1 , 1 , 1 , 1 \} } \mathrm { C o n v } )$ can improve over the baseline model $[ { ^ { * } } ]$ and $g ^ { \{ 1 , 1 , \bar { 1 } , 1 \} } \mathrm { \bar { C } o n v }$ is slightly better. We then perform ablations on the interaction order $n$ for each stage and find: (1) if $n$ is shared across the 4 stages, the accuracy will increase with larger $n$ but saturate at 82.5 when $n = 4$ ; (2) progressively increased order $( g ^ { \{ 2 , 3 , 4 , 5 \} } \mathrm { C o n v } )$ can further improve the accuracy. Our final models are built on $g ^ { \{ 2 , 3 , 4 , 5 \} }$ Conv by adjusting the depth and width of the networks $( \mathrm { H o r N e t - T } _ { 7 \times 7 } )$ and applying Global Filter [46] for the depth-wise convolution (HorNet-TGF). These results clearly show that our $g ^ { n } \mathbf { C } \mathbf { o n v }$ is an efficient and extendable operation that can better capture high-order spatial interactions than both self-attention and depth-wise convolution.
178
+
179
+ ![](images/2d741dc8d3264b5f0a1781a326468737d88eea5ea58e79479f0fcb5a5694aa2c.jpg)
180
+ Figure 4: Visualization of the adaptive weights generated by $g ^ { n } \mathbf { C o n v }$ . We see that the spatial mixing weights of our $g ^ { n } \mathbf { C o n v }$ are adaptive both to input samples and spatial locations, which further indicates that $g ^ { n } \mathbf { C o n v }$ shares these two desirable characteristics with the self-attention operation.
181
+
182
+ $\pmb { g } ^ { n } \mathbf { C _ { 0 n v } }$ for isotropic models. We also evaluate $g ^ { n } \mathbf { C o n v }$ on isotropic architectures (with constant spatial resolutions). We replace the self-attention in DeiT-S [52] with our $g ^ { n } \mathbf { C o n v }$ and adjust the number of blocks to 13 to obtain the isotropic HorNet- $S _ { 7 \times 7 }$ and HorNet- $S _ { \mathrm { G F } }$ . We compare DeiT-S, isotropic ConvNeXt-S and isotropic HorNet-S in Table 6b. While isotropic ConvNeXt-S cannot improve DeiT-S, our isotropic HorNet surpasses DeiT-S by a large margin. These results indicate that our $g ^ { n } \mathbf { C } \mathbf { o n v }$ can better realize the functions of self-attention compared to plain convolutions and have better ability to model the complex spatial interactions.
183
+
184
+ $\pmb { g } ^ { n } \mathbf { C _ { 0 n v } }$ for other operations. To further demonstrate the universality of $g ^ { n } \mathbf { C } \mathbf { o n v }$ , we use $3 \times 3$ depth-wise convolution and $3 \times 3$ pooling [67] as the basic operation in the $g ^ { n } \mathbf { C o n v }$ . The results in Table 6c show that $g ^ { n } \mathbf { C } \mathbf { o n v }$ can also improve these two operations by large margins, indicating our $g ^ { n } \mathbf { C } \mathbf { o n v }$ is potentially more powerful when equipped with some better basic operations.
185
+
186
+ Accuracy-complexity trade-offs. We visualize accuracy-complexity trade-offs of Swin, ConvNeXt and HorNet series in Figure 3. For fair comparisons, we fix the input image size to $2 2 4 \times 2 2 4$ and use $\mathrm { H o r N e t } _ { 7 \times 7 }$ such that all the compared models are based on $7 \times 7$ local window. We see HorNet can achieve better trade-offs than the representative vision Transformers and modern CNNs with regards to model size, FLOPs and GPU latency.
187
+
188
+ Visualization. We provide some visualizations of the adaptive weights learned by $g ^ { n } \mathbf { C o n v }$ in Figure 4. For each sample, we show the value of c $\textstyle { \frac { 1 } { C } } \sum _ { c = 1 } ^ { C } h _ { i j } ^ { c }$ (see Equation (3.8) or the definition $h _ { i j . } ^ { c }$ from layer $\{ 1 , \stackrel { - } { 3 } , \stackrel { \cdot } { 5 } , 7 , 8 , 1 2 \}$
189
+ model. Figure 4 demonstrates that the spatial mixing weights of our $g ^ { n } \mathbf { C } \mathbf { o n v }$ are adaptive both to input samples and spatial locations, which further indicates that $g ^ { n } \mathbf { C } \mathbf { o n v }$ shares these two desirable characteristics with the self-attention operation.
190
+
191
+ Limitations. While HorNet shows better overall latency-accuracy trade-offs, we notice that HorNet is slower than ConvNeXt with similar FLOPs on GPU, which may be caused by the more complex designs to perform the high-order interactions. We think that developing a more hardware-friendly operation for high-order spatial interactions is an interesting future direction to improve our work.
192
+
193
+ # 5 Conclusion
194
+
195
+ We have presented the Recursive Gated Convolution $( g ^ { n } \mathbf { C } \mathbf { o n v } )$ that performs efficient, extendable, and translation-equivariant high-order spatial interactions with gated convolutions and recursive deigns. $g ^ { n } \mathbf { C } \mathbf { o n v }$ can serve as a drop-in replace of the spatial mixing layer in various vision Transformers and convolution-based models. Based on the operation, we have constructed a new family of generic vision backbones HorNet. Extensive experiments demonstrate the effectiveness of $g ^ { n } \mathbf { C o n v }$ and HorNet on commonly used visual recognition benchmarks. We hope our attempt can inspire future work to further explore the high-order spatial interactions in vision models.
196
+
197
+ # Acknowledgments
198
+
199
+ Jiwen Lu was supported in part by the National Key Research and Development Program of China under Grant 2017YFA0700802, the National Natural Science Foundation of China under Grant 62125603 and Grant U1813218, and a grant from the Beijing Academy of Artificial Intelligence (BAAI).
200
+
201
+ References
202
+ [1] Chunrong Ai and Edward C Norton. Interaction terms in logit and probit models. Economics letters, 80(1):123–129, 2003. 5, 15
203
+ [2] Zhaowei Cai and Nuno Vasconcelos. Cascade r-cnn: Delving into high quality object detection. In CVPR, pages 6154–6162, 2018. 7, 8, 17
204
+ [3] Kai Chen, Jiangmiao Pang, Jiaqi Wang, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jianping Shi, Wanli Ouyang, et al. Hybrid task cascade for instance segmentation. In CVPR, pages 4974–4983, 2019. 8, 9
205
+ [4] Yinpeng Chen, Xiyang Dai, Mengchen Liu, Dongdong Chen, Lu Yuan, and Zicheng Liu. Dynamic convolution: Attention over convolution kernels. In CVPR, pages 11030–11039, 2020. 2
206
+ [5] Zhe Chen, Yuchen Duan, Wenhai Wang, Junjun He, Tong Lu, Jifeng Dai, and Yu Qiao. Vision transformer adapter for dense predictions. arXiv preprint arXiv:2205.08534, 2022. 8
207
+ [6] Bowen Cheng, Ishan Misra, Alexander G Schwing, Alexander Kirillov, and Rohit Girdhar. Maskedattention mask transformer for universal image segmentation. arXiv preprint arXiv:2112.01527, 2021. 1
208
+ [7] Bowen Cheng, Ishan Misra, Alexander G Schwing, Alexander Kirillov, and Rohit Girdhar. Maskedattention mask transformer for universal image segmentation. In CVPR, pages 1290–1299, 2022. 8, 9
209
+ [8] Bowen Cheng, Alex Schwing, and Alexander Kirillov. Per-pixel classification is not all you need for semantic segmentation. NeurIPS, 34, 2021. 1
210
+ [9] Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Twins: Revisiting the design of spatial attention in vision transformers. NeurIPS, 34, 2021. 3, 4
211
+ [10] Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In CVPRW, pages 702–703, 2020. 16
212
+ [11] Yutao Cui, Jiang Cheng, Limin Wang, and Gangshan Wu. Mixformer: End-to-end tracking with iterative mixed attention. CVPR, 2022. 3
213
+ [12] Zihang Dai, Hanxiao Liu, Quoc V Le, and Mingxing Tan. Coatnet: Marrying convolution and attention for all data sizes. NeurIPS, 34:3965–3977, 2021. 1, 3
214
+ [13] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, pages 248–255, 2009. 2, 6, 16, 17
215
+ [14] Xiaohan Ding, Xiangyu Zhang, Yizhuang Zhou, Jungong Han, Guiguang Ding, and Jian Sun. Scaling up your kernels to 31x31: Revisiting large kernel design in cnns. CVPR, 2022. 2, 3, 5, 7
216
+ [15] Xiaoyi Dong, Jianmin Bao, Dongdong Chen, Weiming Zhang, Nenghai Yu, Lu Yuan, Dong Chen, and Baining Guo. Cswin transformer: A general vision transformer backbone with cross-shaped windows. CVPR, 2022. 3, 7
217
+ [16] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020. 1, 3, 4, 7, 9
218
+ [17] Stéphane d’Ascoli, Hugo Touvron, Matthew L Leavitt, Ari S Morcos, Giulio Biroli, and Levent Sagun. Convit: Improving vision transformers with soft convolutional inductive biases. In ICML, pages 2286–2296, 2021. 3
219
+ [18] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. In ICCV, pages 6824–6835, 2021. 1, 3
220
+ [19] Meng-Hao Guo, Cheng-Ze Lu, Zheng-Ning Liu, Ming-Ming Cheng, and Shi-Min Hu. Visual attention network. arXiv preprint arXiv:2202.09741, 2022. 3, 7
221
+ [20] Qi Han, Zejia Fan, Qi Dai, Lei Sun, Ming-Ming Cheng, Jiaying Liu, and Jingdong Wang. Demystifying local vision transformer: Sparse connectivity, weight sharing, and dynamic weight. arXiv preprint arXiv:2106.04263, 2021. 2, 3
222
+ [21] Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In ICCV, 2017. 7, 8
223
+ [22] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, pages 770–778, 2016. 1, 4, 5, 8, 16
224
+ [23] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8):1735–1780, 1997. 16
225
+ [24] Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017. 1
226
+ [25] Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In CVPR, pages 7132–7141, 2018. 2, 9, 18
227
+ [26] Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In ECCV, pages 646–661, 2016. 17
228
+ [27] Shihua Huang, Zhichao Lu, Ran Cheng, and Cheng He. Fapn: Feature-aligned pyramid network for dense image prediction. In ICCV, pages 864–873, 2021. 8
229
+ [28] Xu Jia, Bert De Brabandere, Tinne Tuytelaars, and Luc V Gool. Dynamic filter networks. NeurIPS, 29, 2016. 2
230
+ [29] Zihang Jiang, Qibin Hou, Li Yuan, Daquan Zhou, Xiaojie Jin, Anran Wang, and Jiashi Feng. Token labeling: Training a $8 5 . 5 \%$ top-1 accuracy vision transformer with 56m parameters on imagenet. arXiv preprint arXiv:2104.10858, 2021. 3
231
+ [30] Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Joan Puigcerver, Jessica Yung, Sylvain Gelly, and Neil Houlsby. Big transfer (bit): General visual representation learning. In ECCV, pages 491–507. Springer, 2020. 7
232
+ [31] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. NeurIPS, 25:1097–1105, 2012. 1
233
+ [32] Yann LeCun, Bernhard Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne Hubbard, and Lawrence D Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1(4):541–551, 1989. 1
234
+ [33] Samuel Lerman, Charles Venuto, Henry Kautz, and Chenliang Xu. Explaining local, global, and higherorder interactions in deep learning. In ICCV, pages 1224–1233, 2021. 5, 15
235
+ [34] Yanghao Li, Hanzi Mao, Ross Girshick, and Kaiming He. Exploring plain vision transformer backbones for object detection. arXiv preprint arXiv:2203.16527, 2022. 2
236
+ [35] Yanghao Li, Chao-Yuan Wu, Haoqi Fan, Karttikeya Mangalam, Bo Xiong, Jitendra Malik, and Christoph Feichtenhofer. Mvitv2: Improved multiscale vision transformers for classification and detection. In CVPR, pages 4804–4814, 2022. 17, 18
237
+ [36] Tsung-Yi Lin, Piotr Dollár, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature pyramid networks for object detection. In CVPR, pages 2117–2125, 2017. 3
238
+ [37] Tsung-Yi Lin, Piotr Dollár, Ross Girshick, Kaiming He, Bharath Hariharan, and Serge Belongie. Feature pyramid networks for object detection. In CVPR, pages 2117–2125, 2017. 6, 8
239
+ [38] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ECCV, pages 740–755. Springer, 2014. 2, 6, 7
240
+ [39] Hanxiao Liu, Zihang Dai, David So, and Quoc V Le. Pay attention to mlps. NeurIPS, 34:9204–9215, 2021. 16
241
+ [40] Kai Liu, Tianyi Wu, Cong Liu, and Guodong Guo. Dynamic group transformer: A general vision transformer backbone with dynamic group attention. IJCAI, 2022. 18
242
+ [41] Ze Liu, Han Hu, Yutong Lin, Zhuliang Yao, Zhenda Xie, Yixuan Wei, Jia Ning, Yue Cao, Zheng Zhang, Li Dong, et al. Swin transformer v2: Scaling up capacity and resolution. arXiv preprint arXiv:2111.09883, 2021. 1, 7
243
+ [42] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030, 2021. 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17
244
+ [43] Zhuang Liu, Hanzi Mao, Chao-Yuan Wu, Christoph Feichtenhofer, Trevor Darrell, and Saining Xie. A convnet for the 2020s. CVPR, 2022. 2, 3, 5, 6, 7, 8, 9, 16, 17
245
+ [44] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. 7, 17
246
+ [45] Xuran Pan, Chunjiang Ge, Rui Lu, Shiji Song, Guanfu Chen, Zeyi Huang, and Gao Huang. On the integration of self-attention and convolution. arXiv preprint arXiv:2111.14556, 2021. 3
247
+ [46] Yongming Rao, Wenliang Zhao, Zheng Zhu, Jiwen Lu, and Jie Zhou. Global filter networks for image classification. In NeurIPS, 2021. 2, 3, 5, 9
248
+ [47] Tal Ridnik, Emanuel Ben-Baruch, Asaf Noy, and Lihi Zelnik-Manor. Imagenet-21k pretraining for the masses. arXiv:2104.10972, 2021. 17
249
+ [48] Carlos Riquelme, Joan Puigcerver, Basil Mustafa, Maxim Neumann, Rodolphe Jenatton, André Susano Pinto, Daniel Keysers, and Neil Houlsby. Scaling vision with sparse mixture of experts. NeurIPS, 34, 2021. 1
250
+ [49] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. 1, 4
251
+ [50] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In CVPR, pages 1–9, 2015. 1
252
+ [51] Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In ICML, pages 6105–6114, 2019. 1, 5, 7
253
+ [52] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. arXiv preprint arXiv:2012.12877, 2020. 1, 4, 6, 9, 10
254
+ [53] Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Hervé Jégou. Going deeper with image transformers. arXiv preprint arXiv:2103.17239, 2021. 16
255
+ [54] Zhengzhong Tu, Hossein Talebi, Han Zhang, Feng Yang, Peyman Milanfar, Alan Bovik, and Yinxiao Li. Maxim: Multi-axis mlp for image processing. In CVPR, pages 5769–5780, 2022. 16
256
+ [55] Zhengzhong Tu, Hossein Talebi, Han Zhang, Feng Yang, Peyman Milanfar, Alan Bovik, and Yinxiao Li. Maxvit: Multi-axis vision transformer. ECCV, 2022. 3
257
+ [56] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, pages 5998–6008, 2017. 2, 3, 5, 6
258
+ [57] Sinong Wang, Belinda Z Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity. arXiv preprint arXiv:2006.04768, 2020. 4
259
+ [58] Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. In ICCV, 2021. 3
260
+ [59] Yan Wang, Lingxi Xie, Chenxi Liu, Siyuan Qiao, Ya Zhang, Wenjun Zhang, Qi Tian, and Alan L. Yuille. SORT: second-order response transform for visual recognition. In IEEE International Conference on Computer Vision, ICCV 2017, Venice, Italy, October 22-29, 2017, pages 1368–1377. IEEE Computer Society, 2017. 16
261
+ [60] Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. Cvt: Introducing convolutions to vision transformers. arXiv preprint arXiv:2103.15808, 2021. 3
262
+ [61] Sitong Wu, Tianyi Wu, Haoru Tan, and Guodong Guo. Pale transformer: A general vision transformer backbone with pale-shaped attention. In AAAI, volume 36, pages 2731–2739, 2022. 18
263
+ [62] Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In ECCV, pages 418–434, 2018. 7, 8, 17
264
+ [63] Tete Xiao, Mannat Singh, Eric Mintun, Trevor Darrell, Piotr Dollár, and Ross Girshick. Early convolutions help transformers see better. NeurIPS, 34:30392–30400, 2021. 3
265
+ [64] Shen Yan, Xuehan Xiong, Anurag Arnab, Zhichao Lu, Mi Zhang, Chen Sun, and Cordelia Schmid. Multiview transformers for video recognition. arXiv preprint arXiv:2201.04288, 2022. 1
266
+ [65] Jianwei Yang, Chunyuan Li, and Jianfeng Gao. Focal modulation networks. arXiv preprint arXiv:2203.11926, 2022. 3
267
+ [66] Jianwei Yang, Chunyuan Li, Pengchuan Zhang, Xiyang Dai, Bin Xiao, Lu Yuan, and Jianfeng Gao. Focal attention for long-range interactions in vision transformers. NeurIPS, 34, 2021. 3
268
+ [67] Weihao Yu, Mi Luo, Pan Zhou, Chenyang Si, Yichen Zhou, Xinchao Wang, Jiashi Feng, and Shuicheng Yan. Metaformer is actually what you need for vision. arXiv preprint arXiv:2111.11418, 2021. 3, 9, 10
269
+ [68] Li Yuan, Yunpeng Chen, Tao Wang, Weihao Yu, Yujun Shi, Zihang Jiang, Francis EH Tay, Jiashi Feng, and Shuicheng Yan. Tokens-to-token vit: Training vision transformers from scratch on imagenet. arXiv:2101.11986, 2021. 3
270
+ [69] Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016. 5
271
+ [70] Hao Zhang, Feng Li, Shilong Liu, Lei Zhang, Hang Su, Jun Zhu, Lionel M Ni, and Heung-Yeung Shum. Dino: Detr with improved denoising anchor boxes for end-to-end object detection. arXiv preprint arXiv:2203.03605, 2022. 1, 8, 9
272
+ [71] Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In CVPR, pages 633–641, 2017. 2, 6, 7
273
+
274
+ # Checklist
275
+
276
+ 1. For all authors...
277
+
278
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
279
+ (b) Did you describe the limitations of your work? [Yes] See our analysis in Section 4.3.
280
+ (c) Did you discuss any potential negative societal impacts of your work? [N/A] We propose a general framework for visual recognition. Our method is not for specific applications, which does not directly involve societal issues.
281
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
282
+
283
+ 2. If you are including theoretical results...
284
+
285
+ (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]
286
+
287
+ 3. If you ran experiments...
288
+
289
+ (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]
290
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
291
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We follow the common practice in previous papers, where they didn’t report the error bars.
292
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See our implementation details provided in the supplemental material.
293
+
294
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
295
+
296
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
297
+ (b) Did you mention the license of the assets? [N/A]
298
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
299
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
300
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
301
+
302
+ 5. If you used crowdsourcing or conducted research with human subjects...
303
+
304
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
305
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
306
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/tyrJsbKAe6/tyrJsbKAe6.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/u03xn1COsO/u03xn1COsO.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/u3vEuRr08MT/u3vEuRr08MT.md ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Memorization Without Overfitting: Analyzing the Training Dynamics of Large Language Models
2
+
3
+ Kushal Tirumala⇤ Aram H. Markosyan⇤ Luke Zettlemoyer Armen Aghajanyan
4
+
5
+ Meta AI Research {ktirumala,amarkos,lsz,armenag}@fb.com
6
+
7
+ # Abstract
8
+
9
+ Despite their wide adoption, the underlying training and memorization dynamics of very large language models is not well understood. We empirically study exact memorization in causal and masked language modeling, across model sizes and throughout the training process. We measure the effects of dataset size, learning rate, and model size on memorization, finding that larger language models memorize training data faster across all settings. Surprisingly, we show that larger models can memorize a larger portion of the data before over-fitting and tend to forget less throughout the training process. We also analyze the memorization dynamics of different parts of speech and find that models memorize nouns and numbers first; we hypothesize and provide empirical evidence that nouns and numbers act as a unique identifier for memorizing individual training examples. Together, these findings present another piece of the broader puzzle of trying to understand what actually improves as models get bigger.
10
+
11
+ # 1 Introduction
12
+
13
+ The rate and extent to which a model memorizes its training data are key statistics that provide evidence about how it is likely to generalize to new test instances. Classical frameworks, such as bias-variance tradeoff $\textcircled { \left| 3 1 \right| }$ , argued for fitting a training set without full memorization. However, recent work has established a more symbiotic relationship between memorization and generalization in deep learning [13, 26, 28]. This paper empirically studies memorization in causal and masked language modeling, across model sizes and throughout the training process.
14
+
15
+ Much of the recent performance gains for language models have come from scale, with the most recent models reaching up to $1 0 ^ { 1 1 }$ parameters $\frac { \sim } { 1 2 2 } , \boxed { 7 3 } \boxed { 8 3 }$ . Larger models are also known to memorize more training data $\boxed { 1 6 }$ , which is a crucial component of their improved generalization. However, perhaps surprisingly, relatively little work has been done in understanding the impact of scale on the dynamics of language model memorization over training. Existing work focuses on analyzing memorization post-training [16, 47, 88, 95]. In this work, we study the memorization and forgetting dynamics in language models, with a focus on better measuring how they change as we scale up model size. Our primary contributions include:
16
+
17
+ 1. We measure the dependence of memorization dynamics over training on model size (and other factors such as dataset size, overfitting, and learning rate). We find that larger language models memorize training data faster $( \ S 4 )$ .
18
+
19
+ 2. We design controlled experiments that allow us to characterize the forgetting curves in language models (i.e., how language models naturally forget memories throughout training).
20
+
21
+ Our empirical studies show that forgetting curves have lower bounds — we coin this as the forgetting baseline — and that this baseline increases with model scale, i.e., increasing model scale mitigates forgetting $( \ S \ S )$ .
22
+
23
+ 3. We analyze the rates of memorization of different parts of speech, finding that nouns and numbers are memorized much more quickly than other parts of speech $( \ S \ 4 . 4 )$ We hypothesize this is because the set of nouns and numbers can be seen as a unique identifier for a particular sample. We provide evidence to this hypothesis by analyzing the rates of memorization in the setting of an existing unique identifier $( \ S \boxed { 4 . 3 } )$
24
+
25
+ Together, these findings present another piece of the broader puzzle of trying to understand the unique training dynamics that emerge as models grow in size.
26
+
27
+ # 2 Background and Related Work
28
+
29
+ Memorization in Language Models: Unintended memorization is a known challenge for language models [14, 85], which makes them open to extraction attacks [15, 89] and membership inference attacks [41, 64], although there has been work on mitigating these vulnerabilities [51, 88]. Recent work has argued that memorization is not exclusively harmful, and can be crucial for certain types of generalization (e.g., on QA tasks) [11, 46, 87], while also allowing the models to encode significant amounts of world or factual knowledge [4, 35, 71]. There is also a growing body of work analyzing fundamental properties of memorization in language models [16, 47, 60, 95]. Most related to our work Carlini et al. $\boxed { 1 6 }$ analyzes memorization of fully trained language models and observes a dependence on model scale, training data duplication, and prompting context length. While we also study scaling behavior, our focus instead is on the memorization dynamics throughout training.
30
+
31
+ Language Model Training Dynamics: Previous work has extensively analyzed training dynamics to understand how neural models acquire information over training [1, 30, 34, 66, 74]. Saphra and Lopez $\overline { { [ 8 0 ] } }$ were the first to analyze training dynamics for language modeling, focusing on the evolution of internal representations over pre-training. This inspired a line of work analyzing how neural language models learn linguistic structure/world knowledge $[ \overline { { 2 0 } } ] [ 2 1 ] [ 5 3 ]$ , individual words $\pmb { \mathbb { \left[ 1 7 \right] } }$ , and cross-lingual structure $\tilde { \left\| 1 0 \right\| }$ over pre-training. This analysis has been extended to many downstream tasks, including text summarization $\pmb { \mathbb { B 3 } }$ , machine/speech translation [81, 86, 92], and various NLP tasks [36, 61].
32
+
33
+ Forgetting in Language Models: There has also been work studying memory degradation (forgetting) in language models. Catastrophic forgetting or catastrophic interference, first reported in $\frac { 1 } { 1 5 9 } [ \overbrace { 7 7 } ]$ , studies how neural networks tend to forget the information from previous trained tasks or training batches, when trained on new data. This provides a key challenge for continual learning (or life-long learning) [19], where the goal is to gradually learn from a single pass over a, typically very large, stream of data. A number of mechanisms have been proposed for increasing robustness against catastrophic forgetting [2, 18, 24, 49, 58, 82]. There is also a growing body of work demonstrating that both model and dataset scale can make models more resistant to forgetting $\pm \pm \pm \pm \pm$ , as well as work characterizing how forgetting naturally occurs in image classifiers $\boxed { 9 0 }$ and how forgetting can improve training efficiency [5]. Machine unlearning is a technique that forces a trained model to forget a previously learned sample [12, 54], which is primarily motivated by data protection and privacy regulations [37, 57, 78, 91]. Our work is unique in its focus on measuring forgetting during training, and quantifying how it varies with scale.
34
+
35
+ Scaling Laws: We have consistently seen performance gains by scaling model size [3, 22, 73, 76, 83], and scale itself has been known to push internal model behavior away from classical bias-variance regimes $\lVert \overline { { 6 7 } } \rVert$ . Recent efforts have focused on trying to model the scaling laws for language models, including data and model size $\textcircled { 1 4 4 } , \textcircled { 7 9 } \textcircled { }$ , applications to transfer learning $\overline { { \vert 4 0 \vert } }$ , routing networks $\pm \pmb { \left[ 2 3 \right] }$ , and various autoregressive generative tasks $\textcircled { \ 3 9 }$ . While the bulk of work in scaling laws has been empirical, an interesting line of work focuses on theoretically explaining neural scaling laws $\pmb { \mathbb { B } } ] |$ . Most scaling laws focus only on cross-entropy loss, while we study memorization (defined in $\ S \ O 3 )$ .
36
+
37
+ # 3 Experimental Setup
38
+
39
+ In order to perform a large-scale study of the dynamics of memorization over training, our memorization metric must be reasonably easy to compute but also precise enough to tell us how much the model will actually remember from the training data. Label memorization $\mathbb { I } \mathbb { Z } \mathbb { P } \mathbb { \underline { { 9 4 } } } \mathbb { I } \mathbb { Z }$ is an ideal candidate, because it has consistently provided theoretical insight into underlying properties of neural networks, remains applicable in empirical settings, and is relatively cheap to compute. We formulate our metric as an analog of label memorization for self-supervised settings.
40
+
41
+ Definition 1 Let $V$ denote the vocabulary size. Let $C$ denote a set of contexts, which can be thought of as a list of tuples $( s , y )$ where $s$ is an input context (incomplete block of text) and $y$ is the index of the ground truth token in the vocabulary that completes the block of text. Let $S$ denote the set of input contexts, and let $f : S \to \mathbb { R } ^ { V }$ denote a language model. A context $c = ( s , y ) \in C$ is memorized $i f$ $\operatorname { a r g m a x } ( f ( s ) ) = y .$ .
42
+
43
+ Note that a single word can appear as the ground-truth token for multiple contexts. For a given set of contexts $C$ (i.e a given training dataset), we can then analyze the proportion of memorized contexts
44
+
45
+ $$
46
+ M ( f ) = { \frac { \sum _ { ( s , y ) \in C } 1 \left\{ \operatorname { a r g m a x } ( f ( s ) ) = y \right\} } { | C | } }
47
+ $$
48
+
49
+ We refer to this as exact memorization, although it can also be seen as accuracy since we measure how often the argmax of the language model matches the ground truth token. Throughout this work, when we refer to memorization, we will be referring to Definition 1 unless we specify otherwise.
50
+
51
+ We define $\tau$ to be a threshold value for $M ( f )$ , and denote $T ( N , \tau )$ as the minimal number of times a language model $f$ with $N$ parameter needs to see each training datapoint in order to satisfy $M ( f ) \geq { \bar { \tau } }$ . When leveraging bigger datasets, models are unable to train for multiple epochs, so we instead consider memorization on a per-update basis. We introduce $M _ { u p d a t e } ( f , U )$ as the memorization on the batch of data on which the model performs the $U$ ’th gradient descent update, and define $T _ { u p d a t e } ( N , \tau )$ as the minimal number of gradient descent updates a language model with $N$ parameters needs to perform, to satisfy $M _ { u p d a t e } ( { \bar { f } } , U ) \geq \tau$ .
52
+
53
+ Previous work analyzing language modeling memorization defines memorization differently. Motivated by privacy concerns, both $\mathbf { \bar { \Pi } }$ and $\boxed { 1 6 }$ define memorization from a training data extraction standpoint, in which a string $s$ is extractable if it can be produced by interacting with the language model. More specifically, $\boxed { 1 5 }$ defines a string $s$ as being $k$ -eidetic memorized if it is extractable and appears in at most $k$ training examples. [16] defines a string $s$ as $k$ -memorized if the language model can produce it via prompting with $k$ tokens of context from training data. This definition only works for causal language modeling because of the dependence on prompting with training data; for masked language modeling $\boxed { 1 6 }$ uses Definition $\bigstar$ above. Note that if an example is exactly memorized, it is extractable by definition. In other words, both the set of $k$ -eidetic memorized tokens and the set of $k$ -memorized tokens contain the set of exactly memorized tokens (formally, different exactly memorized tokens may be contained in different sets, depending on $k$ ). Therefore, analyzing exact memorization gives a type of lower bound on the $k$ -eidetic memorization and $k$ -memorization. In a different line of work motivated by estimating the influence of individual training examples, $\mathbf { \| 9 5 \| }$ defines a training example $x$ as memorized if the difference in expected model performance (where model performance is defined as $M ( f )$ above) over subsets of data including $x$ and subsets of data not including $x$ , is sufficiently large. This definition pulls from previous work in theoretically analyzing label memorization in classification settings $\pmb { \left[ 2 7 \right] }$ .
54
+
55
+ Model Architectures: We replicate publicly available references for Transformer language model architectures $\mathbb { D } \mathbb { D } \mathbb { 6 } ]$ . We use the 125M, 355M, 1.3B, 2.7B, 6.7B, and 13B model configurations (see $\ S \ A . 4$ for more architectural and training details). We study both causal and masked language models. We train using the FairSeq framework $\lVert \overline { { 6 9 } } \rVert$ with PyTorch $\mathbf { \dot { \textmu } }$ as the underlying framework. For our larger models, we use the fully sharded data-parallel implementation available in FairScale $\bigstar$ and use Aim experiment tracking $\boxed { 6 }$ .
56
+
57
+ Datasets: We use two existing datasets across all our experiments: the WIKITEXT-103 benchmark containing around 103 million tokens $\lVert \overline { { 6 2 } } \rVert$ , and the RoBERTa corpus $\lVert \overline { { 5 5 } } \rVert$ used to train the original
58
+
59
+ RoBERTa model, containing around 39 billion tokens (we refer to this as the ROBERTA dataset). We use both datasets in section 4, and primarily use WIKITEXT-103 in other sections due to computational restrictions.
60
+
61
+ # 4 Larger Language Models Memorize Faster
62
+
63
+ Larger neural language models are known to be more sample efficient and require fewer optimization steps to reach the same performance $\pm \pm$ while also converging faster $| | \overline { { 5 2 } } | |$ , where performance is usually defined as test perplexity. In this section, we study $T ( N , \tau )$ on the training set as a function of $N$ to answer this question.
64
+
65
+ ![](images/0ff82c6ef977f60b79ad1798d13f4577991f66442635ede43b62302e8d2e260b.jpg)
66
+ Figure 1: We show $T ( N , \tau )$ , which is the number of times a language model needs to see each training example before memorizing $\tau$ fraction of the training data, as a function of model size $N$ . Result are for causal language modeling on WIKITEXT103, right plot is on log-log scale. Note that generally larger models memorize faster, regardless of $\tau$ .
67
+
68
+ In the left plot of Figure 1, we fix a memorization threshold $\tau = 0 . 9$ and examine $T ( N , \tau )$ as we increase $N$ . The larger language models need to see each training datapoint fewer times to achieve $9 0 \%$ exact memorization of the training set; in other words, $T ( N , 0 . 9 )$ is monotonically decreasing in $N$ . When we vary $\tau$ between 0.4 and 0.95 in the right plot of Figure 1, we still observe that $T ( N , \tau )$ is generally decreasing with $N . ^ { 3 }$ For fixed $N$ , $T ( \bar { N } , \bar { \tau } )$ is increasing in $\tau$ , which is expected since memorizing more of the training set requires training the model for more epochs. More interestingly, increasing $\tau$ smoothly transitions $T ( N , \bar { \tau } )$ from constant in $N$ , to exponentially decreasing in $N$ (the axes are on a log-log scale).
69
+
70
+ ![](images/3eb64d73e4ac3c4ef104f329878521fd1abd643cb8df35e31eaf4c0f999bd2f5.jpg)
71
+ Figure 2: $T ( N , \tau )$ as a function of $N$ (shown on log-log scale), for various values of $\tau$ in masked language modeling on WIKITEXT103. We show that larger models initially memorize training data slower, but reach high proportions of training data memorization faster.
72
+
73
+ # 4.1 Dependence on Language Modeling Task and Dataset Size
74
+
75
+ To investigate the dependence of our observations on the particular language modeling task, we repeat this analysis for the masked language modeling task on WIKITEXT103 with mask probability 0.15. Unlike in causal language modeling, Figure 2 shows that $T ( N , \tau )$ is not monotonically decreasing in $N$ for lower values of $\tau$ , and is monotonically decreasing in $N$ for higher values of $\tau$ , where the phase transition4 between these two regimes occurs between $\tau = 0 . 6$ and $\tau = 0 . 7$ . Smaller models memorize the training data quicker initially and slower in the long run (e.g., right plot of Figure 11)
76
+
77
+ ![](images/82c9fb6f2894343c69161e1a5bfba477788864eec33fd01e8e7e79f1ece781a1.jpg)
78
+ Figure 3: We show $T _ { u p d a t e } ( N , \tau )$ , which is the number of gradient descent updates $U$ a language model needs to perform before memorizing $\tau$ fraction of the data given on the $U$ ’th update, as a function of model size $N$ . Result are for causal (Left) and masked (Right) language modeling on the ROBERTA dataset, on a log-log scale. We show that larger models memorize faster, regardless of $\tau$ .
79
+
80
+ Language model training is heavily dependent on the dataset size $\pm \pm$ , and therefore we expect $M ( f )$ to be similarly impacted. In Figure $\textcircled { 3 }$ we analyze training set memorization on the much bigger ROBERTA dataset for both masked and causal language modeling. With large datasets such as ROBERTA dataset, it becomes infeasible to perform multiple epochs and evaluate memorization on the entire training set, especially when training larger models. Consequently, we focus on smaller values of $\tau$ and investigate the number of gradient descent updates it takes to reach memorization thresholds, i.e., $T _ { u p d a t e } ( N , \tau )$ . In Figure $3$ we observe a similar trend as Figure $^ { 1 , }$ where $T _ { u p d a t e } ( N , \tau )$ is monotonically decreasing with $N$ for various $\tau$ , in both masked and causal language modeling. Unlike with WIKITEXT103, masked language modeling does not have a phase transition for $\tau$ .
81
+
82
+ # 4.2 Why Do Larger Models Memorize Faster?
83
+
84
+ A natural question at this point is to ask why larger models memorize faster? Typically, memorization is associated with overfitting, which offers a potentially simple explanation. In order to disentangle memorization from overfitting, we examine memorization before overfitting occurs, where we define overfitting occurring as the first epoch when the perplexity of the language model on a validation set increases. Surprisingly, we see in Figure 4 that as we increase the number of parameters, memorization before overfitting generally increases, indicating that overfitting by itself cannot completely explain the properties of memorization dynamics as model scale increases.
85
+
86
+ The learning rate is not constant across our training configurations. Intuitively, larger learning rates should lead to quicker memorization. To investigate to what extent our results can be explained by learning rate, we take a subset of the architectures available above and train on the WIKITEXT103 dataset across a standard range of learning rates while measuring memorization, in Figure $\boxed { 5 }$ Even if we fix a learning rate, larger models reach 0.9 memorization faster, suggesting that our results are not caused solely by differences in learning rates. Interestingly, sensitivity to learning rate generally decreases as we increase the model size. We also notice in Figure $\boxed { 5 }$ that $T ( N , \tau )$ goes down initially (for low LRs) and eventually rises (for high LRs), and as the long as the chosen learning rate places us near the lowest point on the curve, the memorization dynamics do not change significantly (note that axes are on log-scale). This result is consistent with the growing intuition that for neural language models past a particular scale, the learning rate is not a significant hyperparameter $[ \textcircled { 4 4 } ]$
87
+
88
+ ![](images/ec70cd52190fe43255205f2ad227db74d6f86964781b4dcbd4449a2cfb3a512e.jpg)
89
+ Figure 4: Proportion of training data memorized $M ( f )$ before overfitting, as a function of model size $N$ (plotted on a log scale). Results are for causal (left) and masked (right) language modeling on WIKITEXT103. Note that larger models memorize more before overfitting.
90
+
91
+ ![](images/515bf202c5421358369e131665850dec51c1282c4bf294511189795826cd32e3.jpg)
92
+ Figure 5: Examining the effect of learning rate (LR) on number of times model needs to see each training example in order to reach 0.9 proportion of training data memorization $T ( N , 0 . 9 )$ . Each line corresponds to a different model size performing causal language modeling on WIKITEXT103. We demonstrate that larger models memorize faster for a fixed learning rate.
93
+
94
+ Exhaustively searching all such possible factors is intractable, and providing a complete explanation for why larger models memorize faster is outside the scope of this work. Instead, in the following sections, we present studies that we hope will expand the toolkit for answering such questions.
95
+
96
+ # 4.3 Memorization via. Unique Identifiers
97
+
98
+ Recent work studies how to use external memory to improve performance [11, 35, 46, 87]. In this subsection, we question whether such architecture changes are necessary. Motivated by information retrieval systems, we take a simple approach — we prepend a unique identifier to every example in the training set and examine whether memorization speed increases. Specifically, we fix the language modeling task as causal language modeling on WIKITEXT103 with the 125M parameter model, and in front of every training example, we insert the string document ID <unique_id> where unique_id is a unique integer, one for each training context. In order to utilize all these unique integers, we must add them to the dictionary of tokens, which causes a significant increase in the model size since the last layer in the language model must have an output dimension equal to the size of the dictionary. Therefore, any change in $M ( f )$ dynamics could be attributed to the extra parameters we add from increasing dictionary size. To control for this, we first examine the effect of just increasing dictionary size (without using any of the added tokens). Then, we utilize those added tokens to prepend every training example and observe the change in $M ( f )$ dynamics. In Figure 6, we see that increasing the dictionary size does improve the speed of memorization. Even though we previously demonstrated that larger models memorize faster, this is still surprising considering that we do not increase parameter size in a significant way — we are effectively adding fake tokens to the dictionary. Moreover, when we leverage those added tokens to identify training examples uniquely, we see yet another gain in memorization, although prompting using a document ID shifts memorization dynamics away from being monotonically increasing over time.
99
+
100
+ ![](images/cb4a6cb2b5a3ec549dac3cf9141a75aa8fb8b9eb9bb073829aeb63a0d30b1f14.jpg)
101
+ Figure 6: The impact of adding unique identifiers to training examples on memorization $M ( f )$ training dynamics for causal language modeling (125M) on WIKITEXT103. The green line is the original 125M model. The orange line is the model after adding unique identifiers to the dictionary (which increases model size). The blue line prepends these unique identifiers for each training example. Note that adding unique identifiers leads to faster memorization of training data.
102
+
103
+ # 4.4 Memorization Through the Lens of Parts of Speech
104
+
105
+ ![](images/23919e2090bbfcd465c2aa0dd03da3a6f80228d7d7ca9cc4408316ac70cd4b15.jpg)
106
+ Figure 7: The ratios $R ( p )$ (Left) and $R _ { m e m } ( p )$ (Right) over training. $R ( p )$ represents proportion of POS correctly memorized (the language model outputs the right POS, but not necessarily the correct word). $R _ { m e m } ( p )$ represents the proportion of exactly memorized tokens for a particular POS $p$ . Results are for causal language modeling (355M) on WIKITEXT103. In both plots, we consider numerals, proper nouns, verbs, nouns, and adjectives as potential parts of speech (i.e., values for $p$ ). We show that nouns and numerals are memorized faster than other parts of speech.
107
+
108
+ In the previous section, we showed that a unique identifier enhances memorization. Regular text also contains strong proxies to unique identifiers in the form of numerals and proper nouns. Motivated by this, we study syntactic features of memories using part-of-speech (POS) tagging.5 We track the ratio $R ( p )$ of the number of positions for which the part of speech $p$ was correctly predicted to the total number of tokens in the ground truth tagged with that part-of-speech $p$ (left plot in Figure $7 . \dot { }$ . In the right plot of Figure $^ { 7 }$ we show a similar ratio, denoted $R _ { m e m } ( p )$ , but the numerator only considers the tokens that are also exactly memorized. The correctly predicted part of speech does not necessarily imply exact memorization, which is clearly illustrated by Figure 7 where we see the language model memorizing parts of speech faster than the exact value of the token. While all parts of speech are eventually memorized, some parts of speech are memorized faster, which aligns with previous work $\pmb { \mathbb { Z } } 0$ . However, unlike previous work6, we find that nouns, proper nouns, and numerals are memorized noticeably faster than verbs and adjectives, both in terms of $R ( p )$ and $R _ { m e m } ( p )$ . This has potential implications for privacy, since sensitive information is likely to be a noun/proper noun/numeral. Our findings also very loosely align with work studying child language acquisition $\lVert 2 9 \rVert$ .
109
+
110
+ # 5 Forgetting Curves in Language Models
111
+
112
+ This section studies the dual of memorization — forgetting in language models. Inspired by the forgetting curve hypothesis, according to which human memory declines over time when there is no attempt to retain it $\boxed { \boxed { 5 6 } }$ , we are interested in understanding the dynamics of memory degradation in language models.
113
+
114
+ We first choose a batch of data not available in the training set, i.e. a batch of data from a validation set. We refer to this batch of data as the special batch. We then take a checkpoint from model training, plug in the special batch so that the model can train on it, and resume standard training on the training set. We then evaluate how memorization degrades on the special batch and analyze the various factors the forgetting curve may depend on. We use the entire validation set as the special batch throughout this section. The special batch is only seen once when it is immediately introduced.7
115
+
116
+ ![](images/d6e9f0977724c0cdc87a852d353d43599c81891a3d502b30466017c3612cb5b9.jpg)
117
+ Figure 8: Left: forgetting curve for causal language modeling (2.7B) on WIKITEXT103. The dashed horizontal line indicates the lowest proportion of special batch data memorized throughout training, i.e., the forgetting baseline. Right: forgetting baseline as a function of model size $N$ (plotted on log scale). We show that as model scale increases, the forgetting baseline value increases.
118
+
119
+ In the left plot of Figure 8, we show the forgetting curve for the 2.7B model. Exact memorization on the special batch degrades quickly at first, but slows down exponentially as we continue training (see Figure 15 in $\ S [ \bar { \mathrm { A } } . 2 . 2 ]$ . In other words, the forgetting curve on the special batch seems to approach a baseline — we refer to this trend as the forgetting baseline. We approximate the forgetting baseline by looking at the lowest memorization value on the special batch throughout training.
120
+
121
+ We show the forgetting baseline as a function of the model scale in the right plot of Figure $\textcircled { 8 }$ We see that the numerical value for the baseline is monotonically increasing with the model scale. This implies that larger models forget less, aligning with recent work studying catastrophic forgetting on image classification tasks $\overline { { \| 7 5 \| } }$ . This is beneficial because larger models can leverage more information from previous tasks; however, from a privacy perspective, this is not ideal because it implies larger models may be potentially retaining more sensitive information from training data.
122
+
123
+ We also investigate the sensitivity of the forgetting baseline on data batch order. In Figure 9, we perform the same forgetting curve analysis described above but start the analysis at different training checkpoints (we start at the 14th, 39th, and 63rd epochs). This way, we alter the order of the data batches given to the model (since the special batch will appear in a different place in the global order of data batches given to the model) without drastically changing the experimental setup. We observe that the forgetting baseline is not sensitive to data batch order9.
124
+
125
+ ![](images/ad4ca8f6fbd433c6ff3c43c31aed25d9614722f1a7f2ed626172bc8c9799ae85.jpg)
126
+ Figure 9: We empirically show that the forgetting baseline does not depend on data batch ordering. We inject the special batch into the training set at the 14th, 39th, and 63rd epochs, and evaluate proportion of special batch data memorized as we continue training. Results are for causal language modeling (125M) on WIKITEXT103.
127
+
128
+ Motivated by replay methods from continual learning (see $\mathbb { \lVert 2 4 \rVert }$ for a survey) and work in promoting retention memories through repetition in both humans $\boxed { 4 5 } \boxed { 6 8 } \boxed { 8 4 }$ and neural models $\boxed { 5 }$ , in Figure $\checkmark$ we study the effect of repetition (left) and spaced repetition (right) on the forgetting baseline. In the left plot, we inject the special batch into the training set multiple times before continuing training on the training set alone. We observe that the forgetting baseline is monotonically increasing as a function of repetition frequency (differences in the baseline value are on the order of $1 0 ^ { - 2 }$ ). To study the spaced repetition, we periodically inject the held-out set into the training set, train on it once, and then continue training on the training set alone. We see in the right plot of Figure $1 0$ that spaced repetition incurs minimal effect on the forgetting baseline (on the order of $1 0 ^ { - 3 }$ ), independent of the length of spacing between the repetitions.
129
+
130
+ ![](images/303fb4077f562cdf0a7321fd30da562d5c062998b1c3f0361f6f401a078919ad.jpg)
131
+ Figure 10: Effect of repeated injection (Left) and spaced repetition (Right) on special batch memorization. Results are for causal language modeling (125M) on WIKITEXT103. The solid upper curve represents the training set memorization. We show that repeated injection increases the forgetting baseline, whereas spaced repetition has minimal effect.
132
+
133
+ An exciting direction for future work will be to understand the structure of the baseline — for example, understanding what types of tokens (parts of speech, synonyms, facts, syntax) are memorized in the baseline and the overlap of tokens memorized in the baseline with tokens in the training set.
134
+
135
+ # 6 Conclusions and Discussion
136
+
137
+ We study the properties of memorization dynamics over language model training and demonstrate that larger models memorize faster. We also measure the properties of forgetting curves and surprisingly find that forgetting reaches a baseline, which again increases with the model scale. Combined with memorization analyses that expose the unintuitive behavior of language models, we hope to motivate considering memorization as a critical metric when increasing language model scale.
138
+
139
+ Most work studying memorization in language modeling is primarily motivated by privacy (see $\ S 2 )$ While theoretically, there are well-established frameworks to quantify privacy such as differential privacy $\lVert 2 5 \rVert$ , empirical privacy in language modeling is not well-defined — does memorizing common knowledge count as information leakage? Does outputting a synonym count as harmful memorization? As per our Definition $\bigtriangledown$ we implicitly focus on information that is sensitive if outputted verbatim (phone numbers, SSNs, addresses, medical diagnoses, etc.), rather than capturing all aspects of privacy. It is also known that text data used for training language models contain certain biases and stereotypes (e.g., $\left[ 3 2 \right] ) ,$ ); therefore, our work has similar implications for how long language models can train before they definitively memorize these biases from training data.
140
+
141
+ We also hope our work highlights the importance of analyzing memorization dynamics as we scale up language models, instead of only reporting cross entropy. Cross-entropy loss and memorization capture different behavior — for example, in many of our memory degradation experiments, even though memorization approaches a baseline, we observe that perplexity is still increasing (see Figure $^ { 1 4 }$ in $\ S \ \mathbf { A } . 2$ for an example). This implies that the model is becoming unconfident about its exact predictions, which we can only conclude because we inspect both loss and memorization. More importantly, the forgetting baseline behavior would be entirely obscured if we did not inspect memorization dynamics. Similarly, there are multiple instances where we uncover interesting behavior because we focus on memorization dynamics (§ 4.4, § 4.3, $\ S \boxed { \mathbf { A } . 3 }$ , rather than focusing only on cross-entropy loss.
142
+
143
+ # 7 Acknowledgements
144
+
145
+ The authors would like to thank Adina Williams, Chuan Guo, Alex Sablayrolles, and Pierre Stock, for helpful discussions throughout the course of this project. The authors would also like to researchers at FAIR who commented on or otherwise supported this project, including Shashank Shekhar, Candace Ross, Rebecca Qian, Dieuwke Hupkes, and Gargi Ghosh.
146
+
147
+ # References
148
+
149
+ [1] Alessandro Achille, Matteo Rovere, and Stefano Soatto. Critical learning periods in deep networks. In International Conference on Learning Representations, 2018.
150
+ [2] Armen Aghajanyan, Akshat Shrivastava, Anchit Gupta, Naman Goyal, Luke Zettlemoyer, and Sonal Gupta. Better fine-tuning by reducing representational collapse. arXiv preprint arXiv:2008.03156, 2020.
151
+ [3] Armen Aghajanyan, Bernie Huang, Candace Ross, Vladimir Karpukhin, Hu Xu, Naman Goyal, Dmytro Okhonko, Mandar Joshi, Gargi Ghosh, Mike Lewis, et al. Cm3: A causal masked multimodal model of the internet. arXiv preprint arXiv:2201.07520, 2022.
152
+ [4] Badr AlKhamissi, Millicent Li, Asli Celikyilmaz, Mona Diab, and Marjan Ghazvininejad. A review on language models as knowledge bases. arXiv preprint arXiv:2204.06031, 2022.
153
+ [5] Hadi Amiri, Timothy Miller, and Guergana Savova. Repeat before forgetting: Spaced repetition for efficient and effective training of neural networks. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pages 2401–2410, 2017.
154
+ [6] Gor Arakelyan, Gevorg Soghomonyan, and The Aim team. Aim, 6 2020. URL https: //github.com/aimhubio/aim.
155
+ [7] Mikel Artetxe, Shruti Bhosale, Naman Goyal, Todor Mihaylov, Myle Ott, Sam Shleifer, Xi Victoria Lin, Jingfei Du, Srinivasan Iyer, Ramakanth Pasunuru, et al. Efficient large scale language modeling with mixtures of experts. arXiv preprint arXiv:2112.10684, 2021.
156
+ [8] Yasaman Bahri, Ethan Dyer, Jared Kaplan, Jaehoon Lee, and Utkarsh Sharma. Explaining neural scaling laws. arXiv preprint arXiv:2102.06701, 2021.
157
+ [9] Mandeep Baines, Shruti Bhosale, Vittorio Caggiano, Naman Goyal, Siddharth Goyal, Myle Ott, Benjamin Lefaudeux, Vitaliy Liptchinsky, Mike Rabbat, Sam Sheiffer, Anjali Sridhar, and Min Xu. Fairscale: A general purpose modular pytorch library for high performance and large scale training. https://github.com/facebookresearch/fairscale, 2021.
158
+
159
+ [10] Terra Blevins, Hila Gonen, and Luke Zettlemoyer. Analyzing the mono-and cross-lingual pretraining dynamics of multilingual language models. arXiv preprint arXiv:2205.11758, 2022.
160
+
161
+ [11] Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George van den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, et al. Improving language models by retrieving from trillions of tokens. arXiv preprint arXiv:2112.04426, 2021.
162
+
163
+ [12] Lucas Bourtoule, Varun Chandrasekaran, Christopher A Choquette-Choo, Hengrui Jia, Adelin Travers, Baiwu Zhang, David Lie, and Nicolas Papernot. Machine unlearning. In 2021 IEEE Symposium on Security and Privacy (SP), pages 141–159. IEEE, 2021.
164
+
165
+ [13] Gavin Brown, Mark Bun, Vitaly Feldman, Adam Smith, and Kunal Talwar. When is memorization of irrelevant training data necessary for high-accuracy learning? In Proceedings of the 53rd Annual ACM SIGACT Symposium on Theory of Computing, pages 123–132, 2021.
166
+
167
+ [14] Nicholas Carlini, Chang Liu, Úlfar Erlingsson, Jernej Kos, and Dawn Song. The secret sharer: Evaluating and testing unintended memorization in neural networks. In 28th USENIX Security Symposium (USENIX Security 19), pages 267–284, 2019.
168
+
169
+ [15] Nicholas Carlini, Florian Tramer, Eric Wallace, Matthew Jagielski, Ariel Herbert-Voss, Katherine Lee, Adam Roberts, Tom Brown, Dawn Song, Ulfar Erlingsson, et al. Extracting training data from large language models. In 30th USENIX Security Symposium (USENIX Security 21), pages 2633–2650, 2021.
170
+
171
+ [16] Nicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee, Florian Tramer, and Chiyuan Zhang. Quantifying memorization across neural language models. arXiv preprint arXiv:2202.07646, 2022.
172
+
173
+ [17] Tyler A. Chang and Benjamin K. Bergen. Word acquisition in neural language models. Transactions of the Association for Computational Linguistics, 10:1–16, 2022. doi: 10.1162/tacl_a_00444. URL https://aclanthology.org/2022.tacl-1.1.
174
+
175
+ [18] Sanyuan Chen, Yutai Hou, Yiming Cui, Wanxiang Che, Ting Liu, and Xiangzhan Yu. Recall and learn: Fine-tuning deep pretrained language models with less forgetting. arXiv preprint arXiv:2004.12651, 2020.
176
+
177
+ [19] Zhiyuan Chen and Bing Liu. Lifelong machine learning. Synthesis Lectures on Artificial Intelligence and Machine Learning, 12(3):1–207, 2018.
178
+
179
+ [20] Cheng-Han Chiang, Sung-Feng Huang, and Hung-yi Lee. Pretrained language model embryology: The birth of albert. arXiv preprint arXiv:2010.02480, 2020.
180
+
181
+ [21] Leshem Choshen, Guy Hacohen, Daphna Weinshall, and Omri Abend. The grammar-learning trajectories of neural language models. arXiv preprint arXiv:2109.06096, 2021.
182
+
183
+ [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.
184
+
185
+ [23] Aidan Clark, Diego de las Casas, Aurelia Guy, Arthur Mensch, Michela Paganini, Jordan Hoffmann, Bogdan Damoc, Blake Hechtman, Trevor Cai, Sebastian Borgeaud, et al. Unified scaling laws for routed language models. arXiv preprint arXiv:2202.01169, 2022.
186
+
187
+ [24] Matthias Delange, Rahaf Aljundi, Marc Masana, Sarah Parisot, Xu Jia, Ales Leonardis, Greg Slabaugh, and Tinne Tuytelaars. A continual learning survey: Defying forgetting in classification tasks. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
188
+
189
+ [25] Cynthia Dwork, Frank McSherry, Kobbi Nissim, and Adam Smith. Calibrating noise to sensitivity in private data analysis. In Theory of cryptography conference, pages 265–284. Springer, 2006.
190
+
191
+ [26] Vitaly Feldman. Does learning require memorization. A short tale about a long tail. CoRR, abs/1906.05271, 2019.
192
+
193
+ [27] Vitaly Feldman. Does Learning Require Memorization? A Short Tale about a Long Tail. arXiv:1906.05271 [cs, stat], January 2021. URL http://arxiv.org/abs/1906.05271. arXiv: 1906.05271.
194
+
195
+ [28] Vitaly Feldman and Chiyuan Zhang. What neural networks memorize and why: Discovering the long tail via influence estimation. Advances in Neural Information Processing Systems, 33: 2881–2891, 2020.
196
+
197
+ [29] Michael Fleischman and Deb Roy. Why verbs are harder to learn than nouns: Initial insights from a computational model of intention recognition in situated word learning. In 27th Annual Meeting of the Cognitive Science Society, Stresa, Italy, 2005.
198
+
199
+ [30] Jonathan Frankle, David J Schwab, and Ari S Morcos. The early phase of neural network training. arXiv preprint arXiv:2002.10365, 2020.
200
+
201
+ [31] James Franklin. The elements of statistical learning: data mining, inference and prediction. The Mathematical Intelligencer, 27(2):83–85, 2005.
202
+
203
+ [32] Samuel Gehman, Suchin Gururangan, Maarten Sap, Yejin Choi, and Noah A Smith. Realtoxicityprompts: Evaluating neural toxic degeneration in language models. arXiv preprint arXiv:2009.11462, 2020.
204
+
205
+ [33] Tanya Goyal, Jiacheng Xu, Junyi Jessy Li, and Greg Durrett. Training dynamics for text summarization models. arXiv preprint arXiv:2110.08370, 2021.
206
+
207
+ [34] Guy Gur-Ari, Daniel A Roberts, and Ethan Dyer. Gradient descent happens in a tiny subspace. arXiv preprint arXiv:1812.04754, 2018.
208
+
209
+ [35] Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Ming-Wei Chang. Realm: Retrieval-augmented language model pre-training. arXiv preprint arXiv:2002.08909, 2020.
210
+
211
+ [36] Yaru Hao, Li Dong, Furu Wei, and Ke Xu. Investigating learning dynamics of BERT finetuning. In Proceedings of the 1st Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 10th International Joint Conference on Natural Language Processing, pages 87–92, Suzhou, China, December 2020. Association for Computational Linguistics. URL https://aclanthology.org/2020.aacl-main.11.
212
+
213
+ [37] Elizabeth Liz Harding, Jarno J Vanto, Reece Clark, L Hannah Ji, and Sara C Ainsworth. Understanding the scope and impact of the california consumer privacy act of 2018. Journal of Data Protection & Privacy, 2(3):234–253, 2019.
214
+
215
+ [38] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
216
+
217
+ [39] Tom Henighan, Jared Kaplan, Mor Katz, Mark Chen, Christopher Hesse, Jacob Jackson, Heewoo Jun, Tom B Brown, Prafulla Dhariwal, Scott Gray, et al. Scaling laws for autoregressive generative modeling. arXiv preprint arXiv:2010.14701, 2020.
218
+
219
+ [40] Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. Scaling laws for transfer. arXiv preprint arXiv:2102.01293, 2021.
220
+
221
+ [41] Sorami Hisamoto, Matt Post, and Kevin Duh. Membership inference attacks on sequence-tosequence models. arXiv preprint arXiv:1904.05506, 2019.
222
+
223
+ [42] Matthew Honnibal and Ines Montani. spaCy 3: Natural language understanding with Bloom embeddings, convolutional neural networks and incremental parsing. To appear, 2022.
224
+
225
+ [43] Ziwei Ji, Nayeon Lee, Rita Frieske, Tiezheng Yu, Dan Su, Yan Xu, Etsuko Ishii, Yejin Bang, Andrea Madotto, and Pascale Fung. Survey of hallucination in natural language generation. arXiv preprint arXiv:2202.03629, 2022.
226
+
227
+ [44] Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling Laws for Neural Language Models. arXiv:2001.08361 [cs, stat], January 2020. URL http://arxiv.org/abs/2001. 08361. arXiv: 2001.08361.
228
+
229
+ [45] Jeffrey D Karpicke and Henry L Roediger III. Expanding retrieval practice promotes short-term retention, but equally spaced retrieval enhances long-term retention. Journal of experimental psychology: learning, memory, and cognition, 33(4):704, 2007.
230
+
231
+ [46] Urvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis. Generalization through memorization: Nearest neighbor language models. arXiv preprint arXiv:1911.00172, 2019.
232
+
233
+ [47] Eugene Kharitonov, Marco Baroni, and Dieuwke Hupkes. How bpe affects memorization in transformers. arXiv preprint arXiv:2110.02782, 2021.
234
+
235
+ [48] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
236
+
237
+ [49] 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.
238
+
239
+ [50] Katherine Lee, Daphne Ippolito, Andrew Nystrom, Chiyuan Zhang, Douglas Eck, Chris Callison-Burch, and Nicholas Carlini. Deduplicating training data makes language models better. arXiv preprint arXiv:2107.06499, 2021.
240
+
241
+ [51] Xuechen Li, Florian Tramer, Percy Liang, and Tatsunori Hashimoto. Large language models can be strong differentially private learners. arXiv preprint arXiv:2110.05679, 2021.
242
+
243
+ [52] Zhuohan Li, Eric Wallace, Sheng Shen, Kevin Lin, Kurt Keutzer, Dan Klein, and Joey Gonzalez. Train big, then compress: Rethinking model size for efficient training and inference of transformers. In International Conference on Machine Learning, pages 5958–5968. PMLR, 2020.
244
+
245
+ [53] Leo Z Liu, Yizhong Wang, Jungo Kasai, Hannaneh Hajishirzi, and Noah A Smith. Probing across time: What does roberta know and when? arXiv preprint arXiv:2104.07885, 2021.
246
+
247
+ [54] Yang Liu, Zhuo Ma, Ximeng Liu, Jian Liu, Zhongyuan Jiang, Jianfeng Ma, Philip Yu, and Kui Ren. Learn to forget: Machine unlearning via neuron masking. arXiv preprint arXiv:2003.10933, 2020.
248
+
249
+ [55] 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 e-prints, July 2019. URL https://arxiv.org/abs/ 1907.11692v1.
250
+
251
+ [56] Geoffrey R Loftus. Evaluating forgetting curves. Journal of Experimental Psychology: Learning, Memory, and Cognition, 11(2):397, 1985.
252
+
253
+ [57] Alessandro Mantelero. The eu proposal for a general data protection regulation and the roots of the ‘right to be forgotten’. Computer Law & Security Review, 29(3):229–235, 2013.
254
+
255
+ [58] Wojciech Masarczyk, Kamil Deja, and Tomasz Trzcinski. On robustness of generative representations against catastrophic forgetting. In International Conference on Neural Information Processing, pages 325–333. Springer, 2021.
256
+
257
+ [59] Michael McCloskey and Neal J Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In Psychology of learning and motivation, volume 24, pages 109–165. Elsevier, 1989.
258
+
259
+ [60] R Thomas McCoy, Paul Smolensky, Tal Linzen, Jianfeng Gao, and Asli Celikyilmaz. How much do language models copy from their training data? evaluating linguistic novelty in text generation using raven. arXiv preprint arXiv:2111.09509, 2021.
260
+
261
+ [61] Amil Merchant, Elahe Rahimtoroghi, Ellie Pavlick, and Ian Tenney. What happens to BERT embeddings during fine-tuning? In Proceedings of the Third BlackboxNLP Workshop on Analyzing and Interpreting Neural Networks for NLP, pages 33–44, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.blackboxnlp-1.4. URL https://aclanthology.org/2020.blackboxnlp-1.4.
262
+
263
+ [62] Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. ArXiv, abs/1609.07843, 2017.
264
+
265
+ [63] Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, et al. Mixed precision training. arXiv preprint arXiv:1710.03740, 2017.
266
+
267
+ [64] Fatemehsadat Mireshghallah, Kartik Goyal, Archit Uniyal, Taylor Berg-Kirkpatrick, and Reza Shokri. Quantifying privacy risks of masked language models using membership inference attacks. arXiv preprint arXiv:2203.03929, 2022.
268
+
269
+ [65] Seyed Iman Mirzadeh, Arslan Chaudhry, Huiyi Hu, Razvan Pascanu, Dilan Gorur, and Mehrdad Farajtabar. Wide neural networks forget less catastrophically. arXiv preprint arXiv:2110.11526, 2021.
270
+
271
+ [66] Ari Morcos, Maithra Raghu, and Samy Bengio. Insights on representational similarity in neural networks with canonical correlation. Advances in Neural Information Processing Systems, 31, 2018.
272
+
273
+ [67] Preetum Nakkiran, Gal Kaplun, Yamini Bansal, Tristan Yang, Boaz Barak, and Ilya Sutskever. Deep double descent: Where bigger models and more data hurt. Journal of Statistical Mechanics: Theory and Experiment, 2021(12):124003, 2021.
274
+
275
+ [68] Shiri Oren, Charlene Willerton, and Jeff Small. Effects of spaced retrieval training on semantic memory in alzheimer’s disease: A systematic review. Journal of Speech, Language and Hearing Research (Online), 57(1):247, 2014.
276
+
277
+ [69] Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan Ng, David Grangier, and Michael Auli. fairseq: A fast, extensible toolkit for sequence modeling. arXiv preprint arXiv:1904.01038, 2019.
278
+
279
+ [70] 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.
280
+
281
+ [71] Fabio Petroni, Tim Rocktäschel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, Alexander H Miller, and Sebastian Riedel. Language models as knowledge bases? arXiv preprint arXiv:1909.01066, 2019.
282
+
283
+ [72] Vinaychandran Pondenkandath, Michele Alberti, Sammer Puran, Rolf Ingold, and Marcus Liwicki. Leveraging random label memorization for unsupervised pre-training. arXiv preprint arXiv:1811.01640, 2018.
284
+
285
+ [73] 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.
286
+
287
+ [74] 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.
288
+
289
+ [75] Vinay Venkatesh Ramasesh, Aitor Lewkowycz, and Ethan Dyer. Effect of scale on catastrophic forgetting in neural networks. In International Conference on Learning Representations, 2021.
290
+
291
+ [76] 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.
292
+
293
+ [77] Roger Ratcliff. Connectionist models of recognition memory: Constraints imposed by learning and forgetting functions. Psychological Review, pages 285–308, 1990.
294
+
295
+ [78] General Data Protection Regulation. General data protection regulation (gdpr). Intersoft Consulting, Accessed in October, 24(1), 2018.
296
+
297
+ [79] Jonathan S Rosenfeld, Amir Rosenfeld, Yonatan Belinkov, and Nir Shavit. A constructive prediction of the generalization error across scales. arXiv preprint arXiv:1909.12673, 2019.
298
+
299
+ [80] Naomi Saphra and Adam Lopez. Understanding learning dynamics of language models with svcca. arXiv preprint arXiv:1811.00225, 2018.
300
+
301
+ [81] Beatrice Savoldi, Marco Gaido, Luisa Bentivogli, Matteo Negri, and Marco Turchi. On the dynamics of gender learning in speech translation. In Proceedings of the 4th Workshop on Gender Bias in Natural Language Processing (GeBNLP), pages 94–111, Seattle, Washington, July 2022. Association for Computational Linguistics. URL https://aclanthology.org/ 2022.gebnlp-1.12.
302
+
303
+ [82] Chenze Shao and Yang Feng. Overcoming catastrophic forgetting beyond continual learning: Balanced training for neural machine translation. arXiv preprint arXiv:2203.03910, 2022.
304
+
305
+ [83] Shaden Smith, Mostofa Patwary, Brandon Norick, Patrick LeGresley, Samyam Rajbhandari, Jared Casper, Zhun Liu, Shrimai Prabhumoye, George Zerveas, Vijay Korthikanti, et al. Using deepspeed and megatron to train megatron-turing nlg 530b, a large-scale generative language model. arXiv preprint arXiv:2201.11990, 2022.
306
+
307
+ [84] Paul Smolen, Yili Zhang, and John H Byrne. The right time to learn: mechanisms and optimization of spaced learning. Nature Reviews Neuroscience, 17(2):77–88, 2016.
308
+
309
+ [85] Congzheng Song and Vitaly Shmatikov. Auditing data provenance in text-generation models. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 196–206, 2019.
310
+
311
+ [86] Patrick Stadler, Vivien Macketanz, and Eleftherios Avramidis. Observing the learning curve of nmt systems with regard to linguistic phenomena. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing: Student Research Workshop, pages 186–196, 2021.
312
+
313
+ [87] Yi Tay, Vinh Q Tran, Mostafa Dehghani, Jianmo Ni, Dara Bahri, Harsh Mehta, Zhen Qin, Kai Hui, Zhe Zhao, Jai Gupta, et al. Transformer memory as a differentiable search index. arXiv preprint arXiv:2202.06991, 2022.
314
+
315
+ [88] Om Thakkar, Swaroop Ramaswamy, Rajiv Mathews, and Françoise Beaufays. Understanding unintended memorization in federated learning. arXiv preprint arXiv:2006.07490, 2020.
316
+
317
+ [89] Aleena Thomas, David Ifeoluwa Adelani, Ali Davody, Aditya Mogadala, and Dietrich Klakow. Investigating the impact of pre-trained word embeddings on memorization in neural networks. In International Conference on Text, Speech, and Dialogue, pages 273–281. Springer, 2020.
318
+
319
+ [90] Mariya Toneva, Alessandro Sordoni, Remi Tachet des Combes, Adam Trischler, Yoshua Bengio, and Geoffrey J Gordon. An empirical study of example forgetting during deep neural network learning. arXiv preprint arXiv:1812.05159, 2018.
320
+
321
+ [91] Paul Voigt and Axel Von dem Bussche. The eu general data protection regulation (gdpr). A Practical Guide, 1st Ed., Cham: Springer International Publishing, 10(3152676):10–5555, 2017.
322
+
323
+ [92] Elena Voita, Rico Sennrich, and Ivan Titov. Analyzing the source and target contributions to predictions in neural machine translation. 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 1126–1140, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.91. URL https://aclanthology.org/2021.acl-long.91.
324
+ [93] 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.
325
+ [94] Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv:1611.03530 [cs], February 2017. URL http://arxiv.org/abs/1611.03530. arXiv: 1611.03530.
326
+ [95] Chiyuan Zhang, Daphne Ippolito, Katherine Lee, Matthew Jagielski, Florian Tramèr, and Nicholas Carlini. Counterfactual Memorization in Neural Language Models. arXiv:2112.12938 [cs], December 2021. URL http://arxiv.org/abs/2112.12938. arXiv: 2112.12938 version: 1.
327
+ [96] 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.
328
+
329
+ # Checklist
330
+
331
+ 1. For all authors...
332
+
333
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] The main claims in both the introduction and abstract are that (1) larger models memorize faster (where memorization is defined as per Definition $\textcircled { 3 }$ , (2) larger models memorize more before overfitting, (3) larger models forget less, and (4) models memorize nouns and numbers quicker than other parts of speech. (1) and (2) are supported by the beginning subsections in $\ S \boxed { 4 }$ (3) is supported by $\ S 5 ,$ and (4) is supported by $\ S [ \dot { 4 . 4 } ]$ Moreover, as mentioned in the introduction and abstract of this work the scope of this work includes analyzing large language models which we accomplish by analyzing language models up to 13B parameters.
334
+
335
+ (b) Did you describe the limitations of your work? [Yes] In $\ S \ 4 ,$ we discuss that while we find that larger models memorize faster, we are unable to completely explain why this is the case (although we rule out certain reasons). In $\ S \ : 5 ,$ we discuss how we are approximate the numerical value for the baseline depending however long a particular model is trained for i.e. that actual numerical values for the baseline may change slightly if training for longer; however we provide evidence that the further changes to the numerical value will be relatively small in $\ S [ \underline { { \mathbf { A } . 2 . 2 } } ]$ In $\ S [ \underline { { \mathbf { A . l . l } } } ] ,$ below where we define memorization, we discuss the limitations of the memorization definition.
336
+
337
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] This work does not develop new methods $/$ models $/$ datasets in any way, and therefore has minimal potential negative societal impacts. However, in section $6$ we discuss the implications of our analysis for privacy and ethical AI. We explain that, since our work deals with memorization dynamics over training of training data, it implicitly studies how long it takes language models memorize sensitive information (privacy perspective) or bias/stereotypes (ethical AI perspective) from training data.
338
+
339
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] The authors have read the ethics review guidelines and ensured that this work conforms to them.
340
+
341
+ 2. If you are including theoretical results...
342
+
343
+ (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]
344
+
345
+ 3. If you ran experiments...
346
+
347
+ (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] Unfortunately, the exact code used to produce results is proprietary. However, all model configurations and training details are directly pulled from publicly available references, and described in detail in section $\ S [ \underline { { \mathbf { A . 4 } } } ]$ Similarly, while for most of our experiments we use WIKITEXT103 benchmark which is publicly available, some of our experiments run on the ROBERTA dataset which is not publicly available, and therefore, we are unable to release the exact data to re-create those experiments.
348
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] For all our of experiments, we use publicly available references to define model architectures and hyperparameters, which we describe in full detail in section $\ S [ \underline { { \mathbf { A . 4 } } } ]$
349
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Due to the scale of experiments we run (up to 13B parameter models experiments), many experiments are incredibly computationally expensive and we are unable to run each experiment for multiple seeds. However, since we deal with large datasets, random seed most probably has minimal effect on final model output.
350
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] In $\mathbf { \hat { \ S } } \mathbf { \boxed { A . 4 } }$ we describe the type of GPUS and the amount of GPUs used to train different model sizes. We also provide estimates of the total training time across all our experiments.
351
+
352
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
353
+
354
+ (a) If your work uses existing assets, did you cite the creators? [Yes] Since we use existing datasets to conduct experiments, we cite the creators in $\ S \bar { 3 }$ at in the Datasets section; similarly, we use the existing Transformer architecture (which we also cite in $\ S \boxed { 3 }$ in the Model Architecture section); similarly we pull most of our hyperparameter configurations from existing public resources, which we cite in $\ S \boxed { 3 }$ in the Model Architecture section.
355
+ (b) Did you mention the license of the assets? [Yes] In $\ S \ A . 4$ we mention the licenses of all assets we use.
356
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A] We create no new assets as part of this work.
357
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] Since we do not create or curate any new datasets/assets as part of this work, we do not discuss whether and how consent was obtained from people whose data we are using.
358
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] In $\mathbf { \check { \ S } } \mathbf { \boxed { A . 4 } }$ we mention that it is completely plausible the underlying data we use has sensitive or offensive information. However, analyzing the extent to which this is the case is outside the scope of the work, since we just aim to understand memorization dynamics of language models over training rather than analyze the underlying text in datasets
359
+
360
+ 5. If you used crowdsourcing or conducted research with human subjects...
361
+
362
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] We do not crowdsource or conduct research with human subjects in this work
363
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] We do not crowdsource or conduct research with human subjects in this work
364
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] We do not crowdsource or conduct research with human subjects in this work
md/dev/u6Xv3FuF8N/u6Xv3FuF8N.md ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Flocks of Stochastic Parrots: Differentially Private Prompt Learning for Large Language Models
2
+
3
+ Haonan Duan∗ †, Adam Dziedzic†, Nicolas Papernot, Franziska Boenisch University of Toronto and Vector Institute
4
+
5
+ # Abstract
6
+
7
+ Large language models (LLMs) are excellent in-context learners. However, the sensitivity of data contained in prompts raises privacy concerns. Our work first shows that these concerns are valid: we instantiate a simple but highly effective membership inference attack against the data used to prompt LLMs. To address this vulnerability, one could forego prompting and resort to fine-tuning LLMs with known algorithms for private gradient descent. However, this comes at the expense of the practicality and efficiency offered by prompting. Therefore, we propose to privately learn to prompt. We first show that soft prompts can be obtained privately through gradient descent on downstream data. However, this is not the case for discrete prompts. Thus, we orchestrate a noisy vote among an ensemble of $L L M s$ presented with different prompts, i.e., a flock of stochastic parrots. The vote privately transfers the flock’s knowledge into a single public prompt. We show that LLMs prompted with our private algorithms closely match the non-private baselines. For example, using GPT3 as the base model, we achieve a downstream accuracy of $9 2 . 7 \%$ on the sst2 dataset with $( \varepsilon = 0 . 1 4 7 , \delta = 1 0 ^ { - 6 } )$ -differential privacy vs. $9 5 . 2 \%$ for the non-private baseline. Through our experiments, we also show that our prompt-based approach is easily deployed with existing commercial APIs.
8
+
9
+ # 1 Introduction
10
+
11
+ Large language models (LLMs) exhibit strong capabilities for in-context learning [6, 40]. By prepending the adequate prompt to an LLM’s input, the model can perform a myriad of natural language downstream tasks without any modifications to its parameters [41]. While the data used to train an LLM is usually assumed to be public, downstream data used in the prompt is often more sensitive. This can elicit confidentiality issues, for instance, if prompts contain information that represents valuable intellectual property [34]. At the same time, it also raises privacy concerns when the data involves personal information about individuals.
12
+
13
+ In this paper, our first contribution is to show that these concerns are valid. We are the first to instantiate a highly effective membership inference attack (MIA) [7, 45] against prompts. Our attack is able to determine if a given data point was used within the prompt of the LLM. The only existing solution to mitigate this privacy risk would be to forego prompting and instead fine-tune the LLM with a privacy-preserving training algorithm [25, 54]. Yet, fine-tuning lacks the efficiency and practicality of prompting. Indeed, fine-tuning requires significantly more data [42], computational resources [25], and storage space [26]. Additionally, fine-tuning requires access to the LLM parameters. However, many of the state-of-the-art LLMs are proprietary models deployed behind an API which only allows its users to query the LLMs [3, 6, 10, 17, 35].
14
+
15
+ ![](images/1ff48b5100728b33b009fbb4628b132e70f784c3dea38a553d764585b9712582.jpg)
16
+ Figure 1: Our methods for private prompt learning. Left: PromptDPSGD obtains the input gradients from the LLM, and performs DPSGD to update the soft prompt embedding while keeping the LLM frozen. Right: PromptPATE creates a noisy ensemble of private discrete prompts, and then transfers knowledge by selecting a student prompt that can be publicly released. PromptPATE only needs black-box access of the LLM and, thus, can be easily deployed with commercial APIs.
17
+
18
+ To leverage the benefits of prompting while at the same time protecting the data contained in prompts, we propose the first algorithms for prompt learning with privacy. Our algorithms offer rigorous guarantees expressed using differential privacy [15]. Perhaps closest to existing work on fine-tuning, we propose to leverage the canonical DPSGD algorithm [1] to learn soft promptswith differential privacy guarantees. Our PromptDPSGD algorithm performs a private gradient descent on the soft prompt embeddings prepended to the LLM’s private input. Since these embeddings have very few parameters in comparison to LLMs, our PromptDPSGD is efficient and yields competitive privacy utility trade-offs at a fraction of the training complexity of private fine-tuning.
19
+
20
+ However, learning soft prompts with DPSGD may not always be possible because it requires computing gradients with respect to the prompt input. As mentioned previously, current APIs [3, 6, 10, 17, 35] usually do not provide these gradients. We thus turn to discrete prompts which consist of natural language tokens. Discrete prompts address the aforementioned limitations while being more data-efficient. Our insight is to observe that LLMs with discrete prompts naturally lend themselves to another canonical approach of differentially private learning known as the private aggregation of teacher ensembles (PATE) [37]. We introduce PromptPATE, which creates an ensemble of LLMs with different discrete prompts from the private dataset which we refer to as a flock of stochastic parrots [5]. Since interacting with the flock directly can leak private information about the prompts, as we demonstrate with our MIA, PromptPATE additionally performs a knowledge transfer. Therefore, each model in the flock generates a next token prediction for a short input sequence of some public data. By performing a noisy majority vote over all models’ token output, we generate a single output that, due to the noise addition, implements differential privacy guarantees while incorporating knowledge from the flock. The public input together with the noisy aggregated output form a new single example for the discrete student prompt that can be prepended to the LLM in lieu of the individual prompts which contain private information. In addition to providing rigorous privacy guarantees, our PromptPATE is highly efficient, since, instead of having to query every model from the flock at inference time, it suffices to query the LLM prepended with the student prompt once.
21
+
22
+ We perform extensive experiments against multiple popular LLMs, such as GPT3 [6] and Claude [3], that are deployed behind commercial black-box APIs. Our results highlight that PromptPATE provides high downstream performance that matches the one of non-private prompting even at very strong privacy guarantees. On the sst2 dataset with GPT3, for instance, we reach an accuracy of $9 2 . 7 \%$ with privacy costs as little as $( \varepsilon = 0 . 1 4 7 , \delta = 1 0 ^ { - 6 } )$ -differential privacy, even when the public data used during PromptPATE’s knowledge transfer stem from a different distribution than sst2. Our results closely matches the non-private baseline accuracy $( 9 5 . 2 \% )$ . Thus, we conclude that prompt learning for LLMs is not only more efficient and practical than fine-tuning but can also achieve high utility even with strong and practical privacy protection in place.
23
+
24
+ In summary, we make the following contributions:
25
+
26
+ • We instantiate the first MIA on prompted LLMs and show that we can effectively infer membership of the prompted data points with high success. • We propose a lightweight alternative to DP fine-tuning, namely PromptDPSGD, which optimizes orders of magnitude fewer parameters while keeping the original LLM frozen. • We propose PromptPATE, the first method for DP learning with LLMs that requires only black-box access to the model—making it easily deployable for commercial LLM APIs. • Our experiments on multiple state-of-the-art commercial APIs [6, 3] highlight that our methods achieve both high utility and strong privacy protections in various setups.
27
+
28
+ # 2 Background and Related Work
29
+
30
+ Prompts for LLMs. The success of LLMs, such as BERT, Claude, OPT, or different versions of GPT and their exceptional in-context learning capacities gave rise to prompt-based learning [14, 6, 39, 40, 35, 56]. Prompts serve as demonstrations of the downstream task, which the model can then generalize from. There are two paradigms for LLM prompting, namely discrete and soft prompts.
31
+
32
+ Discrete prompts [6, 16, 18, 27, 44] are natural-language instructions that contain examples from the downstream task in a well-crafted template. Tuning discrete prompts is often done by prompting the model with different combination of examples, assessing their performance on the downstream task, and choosing the combination that yields the highest performance as the final prompt.
33
+
34
+ In contrast to discrete prompts, soft prompts [24, 27] prepend trainable continuous embeddings to the inputs of LLMs. These embeddings are initialized either at random or with embedding vectors that correspond to tokens from the dictionary. During tuning, the embeddings are updated through gradient descent to minimize the loss of the prompted model on the private downstream task. To increase performance further, trainable embeddings can be prepended not only to the input but also to every LLM layer, a technique known as prefix [26, 28, 29].
35
+
36
+ Both soft prompts and prefix train end-to-end without any human involvement through backpropagation over the LLM. On the other hand, discrete prompts have to be designed manually through careful prompt engineering. Yet, prompt engineering only needs inference passes over the LLM which makes discrete prompt more computationally lightweight. Our work provides privacy protection for all of these paradigms: discrete prompts, as well as for soft prompts, and prefix.
37
+
38
+ Privacy Leakage in LLMs. LLMs have been shown to memorize data both from their original large training corpora [8, 20, 23, 32, 48, 55] and from smaller private datasets used to fine-tune them for downstream tasks [33]. The only prior work around privacy leakage in prompt-based learning utilizes prompts to extract knowledge from trained LLMs [13, 22, 38]. In contrast, we study the privacy of the prompting data itself. To do so, we investigate the canonical privacy attack known as membership inference attacks (MIA) [7, 45]. Its use as a practical means to demonstrate leakage of private information in ML was recently popularized by a line of work on quantifying memorization [9, 43, 47]. While prior work utilizes MIAs to assess whether a given data point was used to train an LLM, we instantiate a MIA to assess whether a given data point was used within the prompt prepended to the inputs of a trained LLM.
39
+
40
+ Defending Against Privacy Leakage in LLMs. Prior work either focuses on training [2, 19] or fine-tuning [25, 54] LLMs with privacy guarantees. These approaches rely on the mathematical framework of differential privacy (DP) [15] and in particular the DPSGD algorithm for private stochastic gradient descent [1]. Here, DPSGD is applied to guarantee that one outputs approximately the same model parameters whether or not any given data point was used to train or fine-tune the model. To achieve this, DPSGD clips the per-example gradients that are computed during training and adds well-calibrated noise to each model update. These two operations typically increase the computational complexity of training and decrease the utility of the resulting model [1, 4, 49]. To counteract these effects, state-of-the-art methods for full DP-fine tuning in LLMs require extensive hyperparameter tuning and vast computational resources [25]. Alternative approaches refrain from updating the large number of model parameters and instead introduce additional layers into the model architecture and only fine-tune these layers with DPSGD [54]. To the best of our knowledge, no prior work attempted to provide DP guarantees for prompt data in LLMs.
41
+
42
+ ![](images/6efd59d910862e96a4abe9e40c3b60776305e47fcae550e6f1f55befc1d50136.jpg)
43
+ Figure 2: MIA Risk. We study GPT3 prompted with 100 different one-shot examples (dbpedia). left: We present the prediction probabilities at the correct class for members (the one-shot example) and non-members (50 randomly sampled private points). The output probability for members is significantly higher than for non-member data points. right: We present the AUC-ROC curves of our MIA against the 100 prompts (gray lines) and the blue line as an average over all attacks. Given that each prompt has only one member, the resulting TPRs can only be $0 \%$ or $100 \%$ which leads to the step-shape of the gray curves. The result indicates that our attack is significantly more successful than random guessing (the red dashed line).
44
+
45
+ Setup and Notation. We denote by $P$ the soft or discrete prompt that is prepended to any input sequence $x _ { i }$ when querying the language model $L$ . For brevity, we denote $\bar { L } ( [ P , x _ { i } ] )$ by $\bar { L _ { P } ( x _ { i } ) }$ . 3 The output $y _ { i }$ of $L _ { P } ( x _ { i } )$ is an $M$ -dimensional probability vector, with $M$ being the size of the model’s vocabulary. Each component of $y _ { i }$ corresponds to the probability that the $L _ { P }$ assigns to the respective token for being the next token in the sequence $x _ { i }$ . The semantic meaning of the next token varies depending on the given downstream task. For instance, for classification, the index with the highest probability indicates the token of the class that $L _ { P }$ assigns to $x _ { i }$ .
46
+
47
+ # 3 Private Information about Prompt Data Leaks from Prompted LLMs
48
+
49
+ By instantiating a MIA against prompted LLMs, we want to highlight that the private data used within a prompt (which we refer to as prompt data from hereon) can be subject to a substantial privacy risk. We showcase this risk at the example of LLMs that are prompted with discrete prompts $P$ containing tuples of demonstrations from classification downstream tasks as prompt data $p = \{ ( p _ { x } , p _ { y } ) \}$ . For example, in a prompt with one demonstration (one-shot learning), the prompt data $p$ may be specified as $p = \{ ($ ("The movie was great.", "positive")}. Our prompts are provided in a consistent template where one or multiple demonstrations are combined with instructions as $P = l$ [Instruction, (text sequence $p _ { x }$ , class-label token $p _ { y } ) , \ldots I$ .
50
+
51
+ For our MIA, we consider an adversary who aims at inferring whether a given private demonstration $( p _ { x } , p _ { y } )$ was used within the prompt data $p$ . The adversary holds $n$ candidate demonstrations of text sequences and corresponding labels $l _ { i }$ and queries the text sequences $( x _ { 1 } , \cdots , x _ { n } )$ to $L _ { P }$ with black-box access. The prompted model $L _ { P }$ then returns the output probability vectors $( y _ { 1 } , \cdots , y _ { n } )$ . Following prior work [21, 53], we analyze the model’s output probability at token $y _ { i , l _ { i } }$ that corresponds to the correct target class label of every $x _ { i }$ . The intuition to distinguish between members and non-members is that the output probabilities at the correct class $l _ { i }$ will be significantly higher for demonstrations that were used within the prompt, i.e., members with $\left( p _ { x } , p _ { y } \right) { \overset { \cdot } { = } } \left( x _ { i } , l _ { i } \right)$ . We show that even with this simple MIA, we can reliably determine membership for the prompt data.
52
+
53
+ Experimental Setup. We prompt GPT3-Babbage [6] with multiple one-shot examples to solve four standard downstream text classification tasks, namely dbpedia [57], sst2 [46], agnews [57] and trec [50]. The template of our prompts follows [58]. To evaluate our MIAs, we consider the single data point used within the prompt as a members and 50 other randomly selected data points from the respective task’s training dataset as non-members. This skewed distribution between members and non-members (1 vs 50) corresponds to a realistic scenario where only a small proportion of the candidate data targeted by the adversary are members [21]. To quantify the success of our attack, we report the AUC-ROC curves of 100 random trials.
54
+
55
+ Results. Before evaluating the success of the MIA, we analyze the probability output from GPT3 for the correct target class between member and non-member data points. Figure 2a shows for the dbpedia dataset that the prediction probabilities for non-members are significantly lower than for members. Figure 2b shows that this leads to a high MIA risk in terms of an average AUC score of 0.84 for the prompt data. Similar results for other datasets and models are presented in Appendix D. These results highlight that private information can leak from prompt data easily and thus motivate the urgent need for defenses which we develop in the rest of this paper.
56
+
57
+ # 4 Methods for Privacy Preserving Prompts
58
+
59
+ As of now, if we want to protect the private downstream data, we have to forego prompting altogether because, to the best of our knowledge, no algorithms for private prompt learning exist. The only alternative to privately adapt the LLM would be to perform DP fine-tuning [25, 54]. However, this approach is only feasible when we have direct access to the LLM to update its parameters with DPSGD [25] or to even change the model architecture to insert additional parameters—fine-tuned with DPSGD [54]. This is prohibitively expensive and mostly impossible with the commercial API, thus we propose the first algorithms that enable differentially private prompt learning.
60
+
61
+ We consider two main paradigms of prompting: soft prompts and discrete prompts. To learn private soft prompts, we introduce PromptDPSGD. PromptDPSGD is a parameter-efficient alternative to DP fine-tuning that does not need modifying the parameters or architectures of the LLM. However, many popular APIs [3, 6, 10, 17, 35] do not support soft prompts yet as it requires gradients with respect to the input. Therefore, we propose PromptPATE for discrete prompts. PromptPATE requires only black-box access to an LLM without any knowledge of the LLM’s architecture or mode of operation. Instead, the algorithm only needs the next-token prediction of the LLM. This, to our knowledge represents the first solution for privately adapting LLMs in restricted API setups.
62
+
63
+ # 4.1 PromptDPSGD: DPSGD for Private Soft Prompt Learning
64
+
65
+ In general, all discrete input tokens to LLMs are internally transformed into continuous input embeddings that the LLM then operates on. Soft prompts are just additional continuous input embeddings that can be prepended to the original input embeddings before passing them through the LLM. To train (or tune) soft prompts, we require training data from a potentially private downstream task. After prepending the continuous soft prompt embeddings to input examples from the training data, we can calculate the gradients for the loss of the prompted LLM with respect to these soft prompt embeddings. The gradients provide information about how the soft prompt should be updated in order to minimize the loss on the training data.
66
+
67
+ If we can obtain the gradients for soft prompts, we can learn these prompts with privacy guarantees by applying the canonical DPSGD algorithm [1]. The same applies to prefix, therefore, when we talk about soft prompts in the following, we implicitly also include prefix. We call this approach PromptDPSGD. The algorithm yields soft prompts with DP guarantees that can be deployed with the LLM to solve the respective downstream task. The privacy analysis of PromptDPSGD follows the one of the standard DPSGD. Note, however, that while conceptually similar to fine-tuning the LLM’s parameters with DPSGD [54, 25], PromptDPSGD differs in a crucial aspect. In DP-SGD fine-tuning, we require the gradients with respect to all or a subset of the model parameters and update these parameters to minimize the loss. In contrast, in PromptDPSGD, we use the gradients with respect to the soft prompt embeddings and only alter these. We highlight this difference in our PromptDPSGD-algorithm that we present in Appendix C.
68
+
69
+ While this difference seems subtle, it has far-reaching consequences. First, there are orders of magnitude fewer parameters that need to be updated which increases training efficiency. Second, and most importantly, it allows us to keep operating on the original LLM. We discuss the resulting advantages, such as storage efficiency, and the ability to process multiple different tasks simultaneously at the end of this section (in 4.3). These advantages make PromptDPSGD conceptually superior to private fine-tuning. At the same time, as we show in our evaluation, despite the small number of trainable parameters, PromptDPSGD, for simpler tasks, matches the performance of private fine-tuning. Yet, current APIs [3, 6, 10, 17, 35] do not support soft prompting, prefix, or private fine-tuning and only provide black-box access through discrete prompts. For these setups, we propose PromptPATE.
70
+
71
+ # 4.2 PromptPATE: PATE for Privacy Preserving Discrete Prompts
72
+
73
+ PATE [36, 37] enables learning classifiers with DP guarantees. It first trains an ensemble of teacher models on disjoint subsets of the private data. Second, through a noisy labeling process, the ensemble privately transfers its knowledge to an unlabeled public dataset. Finally, a separate student model is trained on this labeled public dataset for release. The noisy knowledge transfer in the second step relies on the Confident GNMAX algorithm [37] that we detail in Appendix C. It consists of three main parts: for any input data point from the public unlabeled dataset, each teacher votes for the most likely class. Then, the consensus over the teachers’ votes is determined and queries with low consensus are rejected to avoid revealing too much information about the private decision boundary. Finally, the returned class label for any non-rejected data point is determined as a noisy argmax over all teachers’ vote counts—where the added noise is sampled from a Gaussian distribution to implement the DP guarantees. For each rejected or labeled data point from the public dataset, privacy costs are accumulated and the ensemble stops labeling once a target privacy budget is reached.
74
+
75
+ Our PromptPATE follows the general flow of standard PATE: training the teacher models, private knowledge transfer, and training a student model. However, due to the significant differences between in-context learning for LLMs and supervised learning in the original PATE and how these different paradigms leverage private and public data, we had to redesign each of these building blocks. This allows to leverage both the data-efficiency of prompts and the rigorous privacy protection from PATE. In the following, we present the building blocks in our PromptPATE.
76
+
77
+ Teacher Models (Flock of Stochastic Parrots). Instead of training teacher models on disjoint partitions of the private data, we use the private data to create disjoint prompts for the LLM. More specifically, we use examples, for instance {("The movie was great.", "positive"), ...}, from the private training data to create prompts that can then be deployed with the LLM as teachers.
78
+
79
+ Private Knowledge Transfer. During the private knowledge transfer, the teachers label public data sequences, such as ("I did enjoy it.", _). Each teacher votes with the most likely class labels for the private downstream task. In Appendix D, we show that PromptPATE can also operate directly on pure next token predictions from Claude [3] without access to per-token probabilities—enabling full black-box private prompts. By performing the private voting process according to standard PATE with the Confident GNMAX algorithm, we turn our per-teacher predictions into a final class label token that will be appended to the sequence, e.g., ("I did enjoy it", "positive"). The privacy accounting and analysis of our PromptPATE exactly follows the one of standard PATE [37].
80
+
81
+ Student. The most naive way to obtain a student model following standard PATE would be to label many public sequences and train a language classifier using supervised learning on this data. However, due to the relatively high number of data needed for supervised learning, and the fact that each query to the private teachers consumes privacy, this process would incur high privacy costs. We propose a better approach building on the data-efficiency of prompting [42] by using labeled public sequences to create new discrete student prompts. The selected prompt can then be deployed with the LLM as the PromptPATE student model.
82
+
83
+ In theory, labeling one public sequence by the ensemble would be sufficient to create such a prompt. This approach yields negligible privacy costs, but the resulting prompt might not have good utility due to the high variance in the performance of prompts [58]. Therefore, we generate multiple prompts based on different labeled public sequences and perform prompt tuning to select the best student prompt. Care must be taken during selection: utility cannot be evaluated on the private data anymore given that the prompt will be publicly deployed and selecting based on the private data would incur additional privacy costs. We solve this tension by using parts of the newly-labeled public data as validation data to assess utility of the student prompts. By selecting the prompt with the highest validation accuracy, we deploy the student prompt that most resembles the private teachers.
84
+
85
+ # 4.3 Advantages of (Private) Prompting over (Private) Fine-Tuning
86
+
87
+ Our private prompt learning enables us to leverage the general advantages of prompting over finetuning while preserving privacy. Private prompting requires significantly less storage than private fine-tuning. While fine-tuning requires storing a separate copy of the LLM model for each downstream task [24], prompts operate only on the input level of LLMs without adapting model parameters, such that only a small task-specific prompt needs to be stored for each downstream task. For example, each copy of the fine-tuned RoBERTa base model requires 125M parameters $\sim 5 0 0 \mathbf { M B }$ ). This becomes prohibitively expensive, especially as the number of parameters for state-of-the-art LLMs rapidly increases. In contrast, soft-prompts and prefix, as the one generated by PromptDPSGD (using implementation from [29]) with the standard prompt length of 10 tokens require less than 10K parameters (40KB) for the soft-prompt and 100K parameters (400KB) for the prefix. A discrete prompt, such as the one generated in PromptPATE, requires less than 1 KB of prepended text. Prompts also enable processing many examples from different tasks in a single batch [26], called mixed-task inference. This allows more efficient use of LLMs since we do not have to wait for a sufficient number of requests for a single task before processing them. This is not possible with any form of fine-tuning, where the fine-tuned model can serve solely a single task.
88
+
89
+ <table><tr><td rowspan="3">Dataset</td><td>M P</td><td colspan="2">Soft-Prompt (Our)</td><td colspan="2">Prefix (Our)</td><td colspan="2">Full-Tuning [25]</td><td colspan="2">LoRA-Tuning [54]</td></tr><tr><td></td><td colspan="2">&lt;10K</td><td colspan="2">&lt;100K</td><td colspan="2">125M</td><td colspan="2">1.2M</td></tr><tr><td>G</td><td>m=8</td><td>m=8</td><td>m=8</td><td>m=8</td><td>m=8</td><td>m=8</td><td>m=8</td><td>m=8</td></tr><tr><td>sst2</td><td></td><td>92.31</td><td>95.64</td><td>91.97</td><td>96.33</td><td>85.89</td><td>96.40</td><td>92.97</td><td>96.60</td></tr><tr><td>qnli</td><td></td><td>84.11</td><td>89.48</td><td>87.17</td><td>94.84</td><td>84.81</td><td>94.70</td><td>88.59</td><td>94.70</td></tr><tr><td>qqp</td><td></td><td>81.52</td><td>86.56</td><td>82.58</td><td>91.42</td><td>86.15</td><td>92.20</td><td>86.26</td><td>92.20</td></tr><tr><td>mnli</td><td></td><td>75.15</td><td>82.49</td><td>80.57</td><td>90.34</td><td>83.30</td><td>90.20</td><td>82.92</td><td>90.20</td></tr></table>
90
+
91
+ Table 1: Performance of PromptDPSGD. We report the accuracy values $( \% )$ for each dataset. All $\varepsilon$ values are reported as standard DP guarantees. We run the experiment on RoBERTa [30]. The first row M: the type of the private Method, the second row P: the number of Parameters tuned for the method, and the third row G: DP Guarantee. We also present results for $\varepsilon = 3$ in Appendix D.
92
+
93
+ # 5 Experimental Evaluation
94
+
95
+ We evaluate both PromptDPSGD and PromptPATE and show that they match the performance of non-private prompting while providing strong privacy guarantees.
96
+
97
+ # 5.1 PromptDPSGD
98
+
99
+ Experimental Setup. To train soft-prompts and prefix, we follow the experimental setup from prior work on DP fine-tuning. Specifically, we use differentially-private optimization engines for transformers, such as models from the BERT family for the language understanding tasks. The experimental results for classification were performed on the RoBERTa models [30], using the standard NLP datasets, namely sst2, qnli, qqp, and mnli, from the GLUE benchmark [51]. Our implementation for soft-prompt and prefix is based on P-Tuning v2 [29]. To tune the (hyper)parameters for PromptDPSGD, we adjust the length of the soft-prompt or prefix in the private setting (with the default value of 10, which commonly yields good performance). For the privacy parameters, we set the $\delta = 1 / N$ , where $N$ is the number of data points in a given dataset, The clipping threshold of per-example gradients is set to 0.1 in most cases. We use a batch size of 1024. The detailed selection of (hyper-)parameters is presented in Appendix E.
100
+
101
+ Results. We compare our PromptDPSGD against state-of-the-art approaches for private finetuning on multiple private downstream datasets. Our results are shown in Table 1. We highlight that both soft prompts and prefix provide competitive privacy utility trade-offs. For example, the difference in accuracy values between the non-private baseline and the private soft prompt ranges from $3 \%$ (for the simplest sst2 dataset) and up to $7 \%$ (for the most difficult mnli dataset). This mirrors results for other private methods, such as the private fine-tuning of LoRA [54]. We also observe that, similarly, for simple tasks, such as sst2 or qnli, the performance of soft prompt or prefix matches the one of fine-tuning. For the more difficult tasks, namely qqp and mnli, the performance of prefix and soft prompts is also relatively close to fine-tuning. The results obtained for these methods are highly influenced by the number of optimized parameters. For example, for the SST2 task and the RoBERTa-Base model, the prefix requires 19970 additional parameters while soft prompt adds solely 2306 parameters. On the other hand, the number of privately tuned parameters is a few orders of magnitude bigger for fine-tuning and equal to the size of the trained model, namely 125M for the method proposed in [25], while the fine-tuning approach from [54] optimizes around 1.2M parameters. Our results reflect a general trend, where prompts are suited for small downstream tasks while fine-tuning with its bigger number of parameters can also cater to more complex tasks with larger training data sets.
102
+
103
+ Table 2: Performance of PromptPATE. We compare PromptPATE with three baselines: zero-shot (Lower Bound), the ensemble’s accuracy (Ens. Acc), and the non-private baseline (Upper Bound) on four classification benchmarks. We study two settings, (IID Transfer) when the public dataset is from the same and (OOD Transfer) different distribution than the private data. We find that PromptPATE achieves strong privacy protection $\varepsilon < 0 . 3$ at $\delta = 1 0 ^ { - 6 }$ ) and utility close to the non-private and significantly higher than the zero-shot. Unless otherwise specified, the experiments are performed on GPT3-Babbage with one-shot prompts. Additionally, we also run experiments on GPT3-Curie for sst2 (C) and 4-shot prompts for agnews (4).
104
+
105
+ <table><tr><td rowspan="3">Private</td><td rowspan="2">Lower Bound</td><td rowspan="2">Ens. Acc.</td><td rowspan="2">Upper Bound</td><td colspan="6">Our PromptPATE</td></tr><tr><td colspan="3">ID Transfer</td><td colspan="3">OOD Transfer</td></tr><tr><td>m=0</td><td>m=8</td><td>m=8</td><td>Public</td><td>E</td><td>Test acc</td><td>Public</td><td>m</td><td>Test acc</td></tr><tr><td>sst2</td><td>76.3</td><td>90.0</td><td>93.8</td><td>sst2</td><td>0.178</td><td>88.8±2.3</td><td>imdb</td><td>0.187</td><td>87.2±1.9</td></tr><tr><td>agnews</td><td>62.0</td><td>72.8</td><td>78.2</td><td>agnews</td><td>0.248</td><td>71.7±0.8</td><td>arisetv</td><td>0.258</td><td>67.9±1.7</td></tr><tr><td>trec</td><td>40.7</td><td>57.6</td><td>58.7</td><td>trec</td><td>0.281</td><td>52.8 ±1.5</td><td>qqp</td><td>0.293</td><td>50.9±3.5</td></tr><tr><td>dbpedia</td><td>44.2</td><td>81.6</td><td>85.6</td><td>dbpedia</td><td>0.194</td><td>80.3 ±1.3</td><td>agnews</td><td>0.203</td><td>74.6±1.4</td></tr><tr><td>sst2(C)</td><td>82.0</td><td>94.0</td><td>95.2</td><td>sst2</td><td>0.147</td><td>92.3 ±1.1</td><td>imdb</td><td>0.154</td><td>92.7±0.8</td></tr><tr><td>agnews (4)</td><td>62.0</td><td>75.8</td><td>81.0</td><td>agnews</td><td>0.145</td><td>73.5 ±1.2</td><td>arisetv</td><td>0.145</td><td>69.6 ±1.8</td></tr></table>
106
+
107
+ # 5.2 PromptPATE
108
+
109
+ Experimental Setup. Teachers: Unless otherwise specified, we rely on GPT3-Babbage as the base LLM and select one-shot examples randomly without replacement from the private downstream task as prompt data. Our prompt template follows Zhao et al. [58]. For each setting, we deploy 200 teacher prompts. Private knowledge transfer: We use the implementation of PATE’s Confident GNMAX algorithm and the privacy accounting from [12] and report our algorithm’s hyperparameters in Appendix E. Student: For each private downstream task, we experiment with two setups (1) selecting public input sequences from the same (IID) and (2) from a different distribution (OOD) as the private data. We introduce three new datasets for the OOD setup: imdb [31], arisetv [11] and qqp [52]. The details of preprocessing these datasets can be found in Appendix E. In both the IID and OOD setup, we limit the size of the public dataset to 500 input sequences from the respective datasets. After the ensemble finishes labelling, we select the best labeled public sequence as prompt data based on the validation accuracy on the labeled public set. We repeat the process three times and report average and standard deviation of the test accuracy for the selected student prompt on the private test set. To improve utility, both teachers’ and students’ output probabilities from GPT3 are recalibrated using contexual calibration [58].
110
+
111
+ Results. We compare PromptPATE against three baselines: the lower bound baseline represented by a zero-shot prediction $( \varepsilon = 0$ ), i.e., when the LLM is only prompted with an instruction, the private ensemble accuracy $\varepsilon = \infty$ ), and the upper bound as a non-private one-shot prediction $\varepsilon = \infty$ ) using the best example from the private data as prompt data. (To save costs, we select from 200 candidates.) Table 2 shows that, over all setups, PromptPATE achieves similar utility to the non-private baseline and significantly improves over zero-shot predictions—even at very strong privacy protection $\varepsilon < 0 . 3$ , $\delta \stackrel { - } { = } 1 0 ^ { - 6 }$ ). Our results also highlight that the distribution of the public data does not need to be very close to the distribution of the private data to yield high-utility student prompts. For example, they can be collected from different domains (dbpedia holds extracts from wikipedia while its public data agnews contains news articles) and for different tasks (trec aims to classify the topic of a given answer while qqp serves to measure the similarity of two questions). Still, with dbpedia being the private downstream data and agnews as public, we achieve an accuracy of $7 4 . 6 \%$ , which is significantly higher than the zero-shot baseline with $4 4 . 2 \%$ .
112
+
113
+ We also provide further insights into the privacy-utility trade-offs that can be achieved with PromptPATE in Figure 3b. Our results highlight that with more public sequences queried to the ensemble, the privacy consumption increases while, after roughly 100 queries, with even $\varepsilon < 0 . 2$ , the student model’s test accuracy saturates. This yields very favorable privacy-utility trade-offs which we attribute mainly to the data efficiency of discrete prompts: Even from within as little as 100 labeled examples, a high-performing student prompt can be derived. Additionally, we observe that the per-query privacy costs of PromptPATE are relatively low, further benefiting the privacy-utility trade-off. The small privacy costs result from the high consensus between the teacher predictions4, see Figure 3a—that might result from all teachers relying on the same underlying LLM, just with different prompts.
114
+
115
+ ![](images/b355be815b98bf95c8e22ec77c8fd135923963e28ad02462e695596a0d041a6a.jpg)
116
+ Figure 3: Additional Insights of PromptPATE. We perform ablation studies on GPT3-Babbage and use dbpedia as private and agnews as public data. Left: Teacher consensus as the fraction of teachers who vote for the correct class over 500 public input sequences. PromptPATE achieves overall high consensus. Right: Student accuracy as a function of the public query set’s size. Already with as few as 100 queries, we observe a plateau in accuracy which highlights PromptPATE’s data efficiency.
117
+
118
+ Scalability. Finally, we also study how PromptPATE scales with larger LLMs and more examples in the prompt. We experiment with a more performant LLM (GPT3-Currie) for sst2. Due to the higher per-query costs, we are not able to repeat this experiment for all datasets. Our results show that the performance of our private prompt increases together with the performance of the public prompt $( 9 2 . 7 \%$ accuracy on Curie vs. $8 7 . 2 \%$ on Babbage) while the privacy budget $\epsilon$ decreases (from 0.178 to 0.147). To investigate flexibility in terms of numbers of private examples provided as prompt data, we also experiment for agnews with 4-shot teachers. Similar to the non-private study [58] that reports improvements for agnews in the 4-shot setting over 1-shot, we observe that this improvement also translates to the private prompt. Our results indicate that with increasingly more powerful LLMs and larger context windows, private prompting will increase further in terms of privacy-utility trade-offs.
119
+
120
+ # 6 Conclusions and Outlook
121
+
122
+ By instantiating the first simple yet effective membership inference attack against prompted LLMs, we show that they leak private information about their prompt data. We propose private prompt learning as a holistic and broadly applicable new approach to mitigate this risk. We first introduce PromptDPSGD that enables to train soft-prompts with privacy guarantees. In contrast to finetuning, soft prompts optimize significantly fewer parameters and do not require any update of LLM parameters or changes to its architecture. As the first solution to private downstream learning with LLMs in black-box access scenarios, we propose PromptPATE. PromptPATE builds on the highly data-efficient discrete prompts and implements privacy through a noisy knowledge transfer. Through our evaluation against two popular LLMs deployed behind commercial black-box APIs (GPT3 and Claude) [6, 3], we highlight that this method yields downstream performance that matches the one of non-private prompting at very strong privacy guarantees. As LLMs rapidly improve and increase in size, prompts are achieving consistently higher performance while fine-tuning becomes more challenging at this scale. This suggests that privacy protections for prompts will become even more important, especially as context sizes expand.
123
+
124
+ # Acknowledgments
125
+
126
+ We would like to acknowledge our sponsors, who support our research with financial and in-kind contributions: Amazon, Apple, CIFAR through the Canada CIFAR AI Chair, DARPA through the
127
+
128
+ GARD project, Intel, Meta, NSERC through a Discovery Grant, the Ontario Early Researcher Award, and the Sloan Foundation. Resources used in preparing this research were provided, in part, by the Province of Ontario, the Government of Canada through CIFAR, and companies sponsoring the Vector Institute. We also thank members of the CleverHans Lab for their feedback.
129
+
130
+ # References
131
+
132
+ [1] M. Abadi, A. Chu, I. Goodfellow, H. B. McMahan, I. Mironov, K. Talwar, and L. Zhang. Deep learning with differential privacy. In Proceedings of the 2016 ACM SIGSAC conference on computer and communications security, pages 308–318, 2016.
133
+ [2] R. Anil, B. Ghazi, V. Gupta, R. Kumar, and P. Manurangsi. Large-scale differentially private bert. arXiv preprint arXiv:2108.01624, 2021.
134
+ [3] Antropic. Introducing claude. Antropic Website. 2023-03-14, https://www.anthropic. com/index/introducing-claude.
135
+ [4] R. Bassily, A. Smith, and A. Thakurta. Private empirical risk minimization: Efficient algorithms and tight error bounds. In 2014 IEEE 55th annual symposium on foundations of computer science, pages 464–473. IEEE, 2014.
136
+ [5] E. M. Bender, T. Gebru, A. McMillan-Major, and S. 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, FAccT ’21, page 610–623, New York, NY, USA, 2021. Association for Computing Machinery.
137
+ [6] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
138
+ [7] N. Carlini, S. Chien, M. Nasr, S. Song, A. Terzis, and F. Tramer. Membership inference attacks from first principles. In 2022 IEEE Symposium on Security and Privacy (SP), pages 1897–1914. IEEE, 2022.
139
+ [8] N. Carlini, D. Ippolito, M. Jagielski, K. Lee, F. Tramer, and C. Zhang. Quantifying memorization across neural language models. arXiv preprint arXiv:2202.07646, 2022.
140
+ [9] N. Carlini, F. Tramer, E. Wallace, M. Jagielski, A. Herbert-Voss, K. Lee, A. Roberts, T. Brown, D. Song, U. Erlingsson, et al. Extracting training data from large language models. In 30th USENIX Security Symposium (USENIX Security 21), pages 2633–2650, 2021.
141
+ [10] H.-T. Cheng and R. Thoppilan. Lamda: Towards safe, grounded, and high-quality dialog models for everything. Google Blog Post. 2023-05-09, https://ai.googleblog.com/2022/01/ lamda-towards-safe-grounded-and-high.html.
142
+ [11] O. chimaobi Samuel. news-data. Huggingface, 2022.
143
+ [12] C. A. Choquette-Choo, N. Dullerud, A. Dziedzic, Y. Zhang, S. Jha, N. Papernot, and X. Wang. Capc learning: Confidential and private collaborative learning. In International Conference on Learning Representations, 2021.
144
+ [13] J. Davison, J. Feldman, and A. M. Rush. Commonsense knowledge mining from pretrained models. In Proceedings of the 2019 conference on empirical methods in natural language processing and the 9th international joint conference on natural language processing (EMNLPIJCNLP), pages 1173–1178, 2019.
145
+ [14] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
146
+ [15] C. Dwork. Differential privacy. In Automata, Languages and Programming: 33rd International Colloquium, ICALP 2006, Venice, Italy, July 10-14, 2006, Proceedings, Part II 33, pages 1–12. Springer, 2006.
147
+ [16] T. Gao, A. Fisch, and D. Chen. Making pre-trained language models better few-shot learners. arXiv preprint arXiv:2012.15723, 2020.
148
+ [17] Google. Lamda: Towards safe, grounded, and high-quality dialog models for everything. Website, 2023. 2023, https://bard.google.com/.
149
+ [18] H. Guo, B. Tan, Z. Liu, E. Xing, and Z. Hu. Efficient (soft) q-learning for text generation with limited good data. In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 6969–6991, 2022.
150
+ [19] S. Hoory, A. Feder, A. Tendler, S. Erell, A. Peled-Cohen, I. Laish, H. Nakhost, U. Stemmer, A. Benjamini, A. Hassidim, et al. Learning and evaluating a differentially private pre-trained language model. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 1178–1189, 2021.
151
+ [20] D. Ippolito, F. Tramèr, M. Nasr, C. Zhang, M. Jagielski, K. Lee, C. A. Choquette-Choo, and N. Carlini. Preventing verbatim memorization in language models gives a false sense of privacy. arXiv preprint arXiv:2210.17546, 2022.
152
+ [21] B. Jayaraman, L. Wang, K. Knipmeyer, Q. Gu, and D. Evans. Revisiting membership inference under realistic assumptions. Proceedings on Privacy Enhancing Technologies, 2021(2), 2021.
153
+ [22] Z. Jiang, F. F. Xu, J. Araki, and G. Neubig. How can we know what language models know? Transactions of the Association for Computational Linguistics, 8:423–438, 2020.
154
+ [23] E. Kharitonov, M. Baroni, and D. Hupkes. How bpe affects memorization in transformers. arXiv preprint arXiv:2110.02782, 2021.
155
+ [24] B. Lester, R. Al-Rfou, and N. Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, Nov. 2021.
156
+ [25] X. Li, F. Tramer, P. Liang, and T. Hashimoto. Large language models can be strong differentially private learners. In International Conference on Learning Representations, 2022.
157
+ [26] X. L. Li and P. Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 4582–4597, 2021.
158
+ [27] J. Liu, D. Shen, Y. Zhang, B. Dolan, L. Carin, and W. Chen. What makes good in-context examples for gpt-3? arXiv preprint arXiv:2101.06804, 2021.
159
+ [28] X. Liu, K. Ji, Y. Fu, W. Tam, Z. Du, Z. Yang, and J. Tang. P-tuning: Prompt tuning can be comparable to fine-tuning across scales and tasks. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pages 61–68, Dublin, Ireland, May 2022. Association for Computational Linguistics.
160
+ [29] X. Liu, K. Ji, Y. Fu, W. L. Tam, Z. Du, Z. Yang, and J. Tang. P-tuning v2: Prompt tuning can be comparable to fine-tuning universally across scales and tasks. arXiv preprint arXiv:2110.07602, 2021.
161
+ [30] Y. Liu, M. Ott, N. Goyal, J. Du, M. Joshi, D. Chen, O. Levy, M. Lewis, L. Zettlemoyer, and V. Stoyanov. Ro{bert}a: A robustly optimized {bert} pretraining approach, 2020.
162
+ [31] A. Maas, R. E. Daly, P. T. Pham, D. Huang, A. Y. Ng, and C. Potts. Learning word vectors for sentiment analysis. In Proceedings of the 49th annual meeting of the association for computational linguistics: Human language technologies, pages 142–150, 2011.
163
+ [32] R. T. McCoy, P. Smolensky, T. Linzen, J. Gao, and A. Celikyilmaz. How much do language models copy from their training data? evaluating linguistic novelty in text generation using raven. arXiv preprint arXiv:2111.09509, 2021.
164
+ [33] F. Mireshghallah, A. Uniyal, T. Wang, D. Evans, and T. Berg-Kirkpatrick. Memorization in nlp fine-tuning methods. arXiv preprint arXiv:2205.12506, 2022.
165
+
166
+ [34] R. Mitchell. Samsung fab data leak: How chatgpt exposed sensitive information. electropages.
167
+
168
+ [35] OpenAI. Gpt-4 technical report, 2023.
169
+
170
+ [36] N. Papernot, M. Abadi, Ú. Erlingsson, I. Goodfellow, and K. Talwar. Semi-supervised knowledge transfer for deep learning from private training data. In International Conference on Learning Representations, 2017.
171
+
172
+ [37] N. Papernot, S. Song, I. Mironov, A. Raghunathan, K. Talwar, and U. Erlingsson. Scalable private learning with pate. In International Conference on Learning Representations, 2022.
173
+
174
+ [38] F. Petroni, T. Rocktäschel, P. Lewis, A. Bakhtin, Y. Wu, A. H. Miller, and S. Riedel. Language models as knowledge bases? arXiv preprint arXiv:1909.01066, 2019.
175
+
176
+ [39] A. Radford, K. Narasimhan, T. Salimans, I. Sutskever, et al. Improving language understanding by generative pre-training. 2018.
177
+
178
+ [40] 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.
179
+
180
+ [41] 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. The Journal of Machine Learning Research, 21(1):5485–5551, 2020.
181
+
182
+ [42] T. L. Scao and A. M. Rush. How many data points is a prompt worth? arXiv preprint arXiv:2103.08493, 2021.
183
+
184
+ [43] V. Shejwalkar, H. A. Inan, A. Houmansadr, and R. Sim. Membership inference attacks against NLP classification models. In NeurIPS 2021 Workshop Privacy in Machine Learning, 2021.
185
+
186
+ [44] T. Shin, Y. Razeghi, R. L. Logan IV, E. Wallace, and S. Singh. Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:2010.15980, 2020.
187
+
188
+ [45] R. Shokri, M. Stronati, C. Song, and V. Shmatikov. Membership inference attacks against machine learning models. In 2017 IEEE symposium on security and privacy $( S P )$ , pages 3–18. IEEE, 2017.
189
+
190
+ [46] R. Socher, A. Perelygin, J. Wu, J. Chuang, C. D. Manning, A. Y. Ng, and C. Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 conference on empirical methods in natural language processing, pages 1631–1642, 2013.
191
+
192
+ [47] C. Song and V. Shmatikov. Auditing data provenance in text-generation models. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 196–206, 2019.
193
+
194
+ [48] K. Tirumala, A. H. Markosyan, L. Zettlemoyer, and A. Aghajanyan. Memorization without overfitting: Analyzing the training dynamics of large language models. arXiv preprint arXiv:2205.10770, 2022.
195
+
196
+ [49] F. Tramer and D. Boneh. Differentially private learning needs better features (or much more data). In International Conference on Learning Representations, 2021.
197
+
198
+ [50] E. M. Voorhees and D. M. Tice. Building a question answering test collection. In Proceedings of the 23rd annual international ACM SIGIR conference on Research and development in information retrieval, pages 200–207, 2000.
199
+
200
+ [51] A. Wang, A. Singh, J. Michael, F. Hill, O. Levy, and S. R. Bowman. GLUE: A multi-task benchmark and analysis platform for natural language understanding. In International Conference on Learning Representations, 2019.
201
+
202
+ [52] Z. Wang, W. Hamza, and R. Florian. Bilateral multi-perspective matching for natural language sentences. In Proceedings of the 26th International Joint Conference on Artificial Intelligence, pages 4144–4150, 2017.
203
+
204
+ [53] S. Yeom, I. Giacomelli, M. Fredrikson, and S. Jha. Privacy risk in machine learning: Analyzing the connection to overfitting. In 2018 IEEE 31st computer security foundations symposium (CSF), pages 268–282. IEEE, 2018.
205
+ [54] D. Yu, S. Naik, A. Backurs, S. Gopi, H. A. Inan, G. Kamath, J. Kulkarni, Y. T. Lee, A. Manoel, L. Wutschitz, S. Yekhanin, and H. Zhang. Differentially private fine-tuning of language models. In International Conference on Learning Representations, 2022.
206
+ [55] C. Zhang, D. Ippolito, K. Lee, M. Jagielski, F. Tramèr, and N. Carlini. Counterfactual memorization in neural language models. arXiv preprint arXiv:2112.12938, 2021.
207
+ [56] S. Zhang, S. Roller, N. Goyal, M. Artetxe, M. Chen, S. Chen, C. Dewan, M. Diab, X. Li, X. V. Lin, et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022.
208
+ [57] X. Zhang, J. Zhao, and Y. LeCun. Character-level convolutional networks for text classification. Advances in neural information processing systems, 28, 2015.
209
+ [58] Z. Zhao, E. Wallace, S. Feng, D. Klein, and S. Singh. Calibrate before use: Improving few-shot performance of language models. In International Conference on Machine Learning, pages 12697–12706. PMLR, 2021.
210
+
211
+ # A Broader Impacts
212
+
213
+ The growing importance of in-context learning as a paradigm for leveraging LLMs on private downstream tasks has significant implications for privacy. We present the first approaches for obtaining prompts with privacy guarantees, thereby enabling the use of this learning paradigm on sensitive data. This advancement has the potential to increase trust and acceptance of LLM-based systems for private applications. Our approach PromptPATE is the first viable technique for private downstream adaptation of black-box LLMs, which enables integrations into the state-of-the-art commercial LLM APIs. We acknowledge that—as with any application that relies on DP—care must be taken when choosing the privacy parameters $\varepsilon$ and $\delta$ since setting these incorrectly can lead to a false sense of privacy. Therefore, our work orientates at the privacy parameters that have been shown to provide reasonable protection in prior work. Thereby, we also ensure consistency and comparability in evaluations between the different appraoches.
214
+
215
+ # B Limitations
216
+
217
+ Tuning Instructions and Templates. For our discrete prompts, we did not tune the instructions or templates but instead relied on a template from prior work [58]. The effectiveness and performance of our PromptPATE could potentially be further improved by tuning the instructions and templates.
218
+
219
+ Privacy Risk of Pretrained LLM: We build on pretrained LLMs to learn and deploy our private prompts. Our methods solely target the protection of the private data used for these prompts. However, it is also important to acknowledge the inherent privacy risks for data used to pretrain the LLM. We leave the pretrainig of LLMs with privacy guarantees to an orthogonal line of work.
220
+
221
+ Limited Monetary Budget for our Experiments. Due to cost limitations, we were unable to experiment with the latest and best available model, GPT4. Our experiments with GPT3-Curie in comparison to less powerful GPT3-Babbage however indicate the clear trend the our private prompts improve in performance as the non-private baseline improves due to better models. Furthermore, again due to the cost limitation, we were not able to incorporate a larger number of teachers in our experiments for PromptPATE. Therefore, the best non-private teacher baseline that we report might not be the best achievable if one had more teachers to choose from. We chose from 200 and note that with more (and potentially better teachers), not only the baseline but also the teacher ensemble’s performance would get better.
222
+
223
+ Hyperparameter Tuning. To save computation costs, we did not exhaustively tune all hyperparameters in our experiments. While our approach still achieves high utility and good privacy-utility trade-offs, we acknowledge that with more hyperparameter tuning the performance together with the understanding of optimal configurations for private prompt learning could increase.
224
+
225
+ Assumption of a Trusted LLM API Provider. In our work, the API provider gets to interact with the private data, for example, through the teachers’ prompts in PromptPATE. Therefore, we have to assume trust in the API provider. The privacy guarantees through our private prompt learning protect the privacy of the prompt data against users that interact with the prompted LLM. In practice, companies that are concerned about the privacy of their data with respect to the API provider could make contracts with the API providers on the use of their data or buy access plans that guarantee that data queried to the API is treated privately. We leave implementing cryptographic approaches that could relief the assumption on trusting the API provider entirely, for example, by enabling the LLM to run inference on encrypted private data to future work.
226
+
227
+ # C Additional Insights into our Methods
228
+
229
+ # C.1 PromptDPSGD
230
+
231
+ We present the full PromptDPSGD algorithm in Algorithm 1.
232
+
233
+ Algorithm 1: PromptDPSGD. In contrast to the standard DPSGD algorithm that updates model parameters during private training or fine-tuning, our PromptDPSGD privately updates the soft prompt parameters. We highlight these changes with respect to standard DPSGD training or fine-tuning in blue.
234
+
235
+ Require: Private downstream data $D = \{ ( x _ { i } , y _ { i } ) \mid i \in [ N ] \}$ , prompt sequence length $s$ , embedding dimensionality $e$ , trained LLM $L$ with frozen parameters, loss function $\ell ( L _ { p } , x )$ for prompted LLM, Params: learning rate $\eta _ { t }$ , noise scale $\sigma$ , sampling rate $q$ , max gradient norm $c$ , training iterations $T$ . 1: Initialize $P _ { 0 } \in \bar { \mathbb { R } ^ { s \times e } }$ at random
236
+ 2: for $t \in [ T ]$ do
237
+ 3: Sample mini-batch $B _ { t }$ according to sampling rate $q$ from $D$ {Poisson sampling}
238
+ 4: For each $i \in | B _ { t } |$ , compute $\mathbf { g } _ { t } ( x _ { i } ) \gets \bar { \nabla } _ { P _ { t } } \ell ( L _ { P } , x _ { i } )$ {Compute per sample gradient w.r.t. $p _ { t }$ } 5: $\begin{array} { r } { \bar { \bf g } _ { t } ( x _ { i } ) { \bf g } _ { t } ( x _ { i } ) / \operatorname* { m a x } ( 1 , \frac { \| { \bf g } _ { t } ( x _ { i } ) \| _ { 2 } } { c } ) } \end{array}$ {Clip gradient}
239
+ 6: $\begin{array} { r } { \tilde { \mathbf { g } } _ { t } \frac { 1 } { \mid B _ { t } \mid } ( \sum _ { i } \bar { \mathbf { g } } _ { t } ( x _ { i } ) + \mathcal { N } ( 0 , \sigma ^ { 2 } c ^ { 2 } \mathbf { I } ) ) } \end{array}$ {Add noise}
240
+ 7: $P _ { t + 1 } \gets P _ { t } - \eta _ { t } \tilde { \mathbf { g } } _ { t }$ {Update soft prompt}
241
+ 8: end for
242
+ 9: Output $p _ { T }$ and compute the overall privacy cost $( \varepsilon , \delta )$ .
243
+
244
+ # C.2 PromptPATE
245
+
246
+ Extended Background on PATE. We include the standard Confident-GNMax Aggregator Algorithm from [37] below.
247
+
248
+ # Algorithm 2: Confident-GNMax Aggregator by [37]
249
+
250
+ Require: input $x$ , threshold $T$ , noise parameters $\sigma _ { 1 }$ and $\sigma _ { 2 }$
251
+ 1: if $\textstyle \operatorname* { m a x } _ { j } \{ \sum _ { i \in [ E ] } n _ { i , j } ( x ) \} + \mathcal { N } ( 0 , \sigma _ { 1 } ^ { 2 } ) \geq T$ then
252
+ 2: Output arg $\begin{array} { r } { \operatorname* { m a x } _ { j } \{ \sum _ { i \in [ E ] } n _ { i , j } ( \mathbf x ) + \mathcal { N } ( 0 , \sigma _ { 2 } ^ { 2 } ) \} } \end{array}$
253
+ 3: else
254
+ 4: Output ⊥
255
+ 5: end if
256
+
257
+ # C.3 Privacy Analysis
258
+
259
+ PromptDPSGD. Our PromptDPSGD can be seen as a repeated sampled Gaussian mechanism [1], with sampling performed over the entirety of the private prompt dataset. The difference to standard DPSGD for training or fine-tuning is that we do not update the model parameters, but the trainable embeddings for the soft prompts. This is conceptually different from standard DPSGD in terms of which parameters are updated. The privacy guarantees of the training mechanism still follow Abadi et al. [1], but with respect to the soft prompt embeddings: whether or not a particular data point will be included in the private training set used for tuning the prompt, the resulting soft prompt embeddings after training will be roughly the same. Especially by applying the clipping operation at every step, each mechanism’s sensitivity is bounded by $c$ . Privacy is then implemented as the trainable soft prompt embeddings are updated while adding noise noise drawn from ${ \mathcal { N } } ( 0 , c ^ { 2 } \sigma ^ { 2 } I )$ .
260
+
261
+ Theorem 1 (Privacy of PromptDPSGD). Let $T$ be the total number of repetitions (training iterations) of our PromptDPSGD and the sampling rate be denoted by $q$ . Then, there exist two constants $c _ { 1 }$ and $c _ { 2 }$ , such that for any $\varepsilon < c _ { 1 } q ^ { 2 } T$ our PromptDPSGD guarantees √ $( \varepsilon , \delta )$ -DP, if for any $\delta > 0$ , we choose the noise according to $\sigma \ge c _ { 2 } \frac { q c \sqrt { T \log { 1 / \delta } } } { \varepsilon }$ .
262
+
263
+ Proof. The proof follows the one by Abadi et al. [1], using their moments accountant that models the privacy loss as a random variable dependent on the stochastic noise added. □
264
+
265
+ PromptPATE. Our PromptPATE relies entirely on the Confident GNMAX algorithm from Papernot et al. [37]. We preserve the assumption underlying the algorithm and the respective privacy analysis that the sensitivity during the voting mechanism equals one. This is done in PromptPATE by assigning disjoint data points from the private prompt downstream dataset to all teachers. As a consequence, the privacy analysis of our PromptPATE entirely follows Papernot et al. [37].
266
+
267
+ Both our PromptDPSGD and PromptPATE experience the post-processing properties of DP, i.e., once trained, the privacy guarantee $( \varepsilon , \delta )$ sets an upper bound on privacy leakage for the prompt data, independent on the number and type of queries that will be posed to the final prompted LLM.
268
+
269
+ # D Additional Results
270
+
271
+ # D.1 Membership Inference Attacks
272
+
273
+ We present the full results of MIA against GPT3 with one-shot prompts on 4 datasets in SCW: Section4.
274
+
275
+ ![](images/7eae14bc2947d35bce3ccb3ea9c878e6260cf6489e37c6116413032a79a73cae.jpg)
276
+ Figure 4: MIA Risk over Multiple Datasets on GPT3. We study GPT3-babbage prompted with 100 different one-shot examples on four datasets. Top: We present the prediction probabilities at the correct class for members (the one-shot example) and non-members (50 randomly sampled private points). The output probability for members is significantly higher than for non-member data points. Bottom: We present the AUC-ROC curves of our MIA against the 100 prompts (gray lines) and the blue line as an average over all attacks. Given that each prompt has only one member, the resulting TPRs can only be $0 \%$ or $100 \%$ which leads to the step-shape of the gray curves. The result indicates that our attack is significantly more successful than random guessing (the red dashed line).
277
+
278
+ In addition, we also perform similar experiments on GPT2-xl with four-shot examples, with results presented in Figure 5. We replace dbpedia with cb because the input in dbpedia is usually longer than the context length of GPT2.
279
+
280
+ # D.2 PromptPATE on Claude
281
+
282
+ We present the experiment results of PromptPATE on Claude [3]. Different from GPT3 that outputs logits over the whole vocabulary, Claude only gives us access to the next most likely token.
283
+
284
+ Experimental Setup. Teachers: We rely on Claude-v1 as the base LLM. We use 2-shot prompts for sst2 and agnews, 4-shot for trec and 1-shot for dbpedia. We set the maximum generated tokens to 1 and temperatures to 0. We also create an "other" category in case the moel’s output does not fall under any specified categories. For each setting, we deploy 400 teacher prompts. Private knowledge transfer: We use the implementation of PATE’s Confident GNMAX algorithm and the privacy accounting from [12] and report our algorithm’s hyperparameters in Appendix E. Student: We limit the size of the public dataset to 200 input sequences from the respective datasets. The number of shots for students corresponds with the teachers.
285
+
286
+ # D.3 More results for PromptDPSGD
287
+
288
+ We present the additional results for PromptDPSGD with $\varepsilon = 3$ on the classification tasks in Table 5.
289
+
290
+ ![](images/8df93be760fda31b5ae90c5aa61db1df18ba93e18cedee2e1e073f0475414194.jpg)
291
+ Figure 5: MIA Risk over Multiple Datasets on GPT2-xl (4 shot). We study GPT2-xl prompted with 100 different four-shot examples on four datasets. top: We present the prediction probabilities at the correct class for members (the one-shot example) and non-members (50 randomly sampled private points). The output probability for members is significantly higher than for non-member data points. bottom: We present the AUC-ROC curves of our MIA against the 100 prompts (gray lines) and the blue line as an average over all attacks. Given that each prompt has only one member, the resulting TPRs can only be $0 \%$ , $2 5 \%$ , $50 \%$ , $7 5 \%$ or $100 \%$ which leads to the step-shape of the gray curves. The result indicates that our attack is significantly more successful than random guessing (the red dashed line).
292
+
293
+ <table><tr><td></td><td>Lower Bound</td><td>Ens. Acc.</td><td>Upper Bound</td><td colspan="3">Our PromptPATE</td></tr><tr><td>Private</td><td>m=0</td><td>m=8</td><td>m=8</td><td>Public</td><td>m</td><td>Test acc</td></tr><tr><td>sst2</td><td>92.7</td><td>96.0</td><td>98.0</td><td>sst2</td><td>0.048</td><td>95.7 ± 1.4</td></tr><tr><td>agnews</td><td>72.4</td><td>79.1</td><td>82.7</td><td>agnews</td><td>0.056</td><td>74.6 ± 1.5</td></tr><tr><td>trec</td><td>69.0</td><td>79.9</td><td>82.2</td><td>trec</td><td>0.068</td><td>79.3 ± 1.2</td></tr><tr><td>dbpedia</td><td>88.0</td><td>92.4</td><td>93.5</td><td>dbpedia</td><td>0.042</td><td>90.9 ± 0.6</td></tr></table>
294
+
295
+ Table 3: Performance of PromptPATE on Claude. We compare PromptPATE with three baselines: zero-shot (Lower Bound), the ensemble’s accuracy (Ens. Acc), and the non-private baseline (Upper Bound) on four classification benchmarks. We find that PromptPATE achieves strong privacy protection $\varepsilon < 0 . 1$ at $\delta = 1 0 ^ { - 6 }$ ) and utility close to the non-private and significantly higher than the zero-shot.
296
+
297
+ # E Additional Setup
298
+
299
+ # E.1 PromptDPSGD
300
+
301
+ We train PromptDPSGD on NVIDIA A100 GPUs. We execute (hyper-)parameter search that takes into account learning rate (LR), max grad norm (GRAD), number of epochs (Epochs), the token length of prefix and prompt. In general, we find that the prompt and prefix token length of 10 is close to the optimal value in most cases. For the private (hyper-)parameters, in most cases we tune for $\varepsilon = 8$ and use similar (or even the same) parameters for other $\varepsilon$ values. We set the max grad norm to 0.1 in most cases and then adjust the number of epochs (the more the better, for example, 100), and the learning rate $[ 5 4 ] ^ { 5 }$ . The batch size is set by default to 1024.
302
+
303
+ We show the specific parameters chosen for PromptDPSGD in Table 6.
304
+
305
+ Table 4: Private classification with soft prompts and prefix for $\begin{array} { c c l } { \varepsilon } & { = } & { \{ 3 , \infty \} } \end{array}$ and the RoBERTaBASE model. We use the same setup and notation as in Table 1.
306
+
307
+ <table><tr><td rowspan="3">Dataset</td><td>M P</td><td colspan="2">Soft-Prompt (Our)</td><td colspan="2">Prefix (Our)</td><td colspan="2">Full-Tuning [25]</td><td colspan="2">LoRA-Tuning [54]</td></tr><tr><td></td><td colspan="2">&lt;10K</td><td colspan="2">&lt;100K</td><td colspan="2">125M</td><td colspan="2">1.2M</td></tr><tr><td>G</td><td>=3</td><td>m=8</td><td>m=3</td><td>m=8</td><td>ε=3</td><td>m=8</td><td>m=3</td><td>m=8</td></tr><tr><td>SST2</td><td></td><td>90.48</td><td>95.64</td><td>90.37</td><td>96.33</td><td>91.86</td><td>96.40</td><td>92.60</td><td>96.60</td></tr><tr><td>QNLI</td><td></td><td>83.62</td><td>89.48</td><td>86.05</td><td>94.84</td><td>87.42</td><td>94.70</td><td>86.97</td><td>94.70</td></tr><tr><td>QQP</td><td></td><td>80.29</td><td>86.56</td><td>80.89</td><td>91.42</td><td>85.56</td><td>92.20</td><td>85.12</td><td>92.20</td></tr><tr><td>MNLI</td><td></td><td>73.97</td><td>82.49</td><td>80.10</td><td>90.34</td><td>82.99</td><td>90.20</td><td>82.08</td><td>90.20</td></tr></table>
308
+
309
+ <table><tr><td rowspan="2">Dataset</td><td>M</td><td>Soft-Prompt (Our)</td><td>Prefix (Our)</td><td>Full-Tuning [25]</td></tr><tr><td>P</td><td>&lt;10K</td><td>&lt;100K</td><td>125M</td></tr><tr><td>SST2</td><td></td><td>91.05</td><td>93.58</td><td>90.94</td></tr><tr><td>QNLI</td><td></td><td>87.62</td><td>89.45</td><td>89.42</td></tr><tr><td>QQP</td><td></td><td>82.29</td><td>83.50</td><td>87.49</td></tr><tr><td>MNLI</td><td></td><td>76.05</td><td>86.71</td><td>86.28</td></tr></table>
310
+
311
+ Table 5: Private classification with soft prompts and prefix for $\varepsilon = 8$ and the RoBERTaLARGE model. We use the same setup and notation as in Table 1.
312
+
313
+ # E.2 PromptPATE
314
+
315
+ # E.2.1 Hyperparameters for Confident-GNMax
316
+
317
+ We present our hyperparameters for Confident-GNMax in Table 7.
318
+
319
+ # E.2.2 Dataset Preprocessing
320
+
321
+ sst2, trec, agnews, dbpedia and cb are taken from the repo of [58]. All other public datasets are downloaded from huggingface. To reduce the cost of quering APIs, we randomly sample 300 points from the test set to report the test accuracy. For imdb, we random select one sentence from each entry and also remove the ${ \tt { \ c b r / > } }$ tag. For qqp, we only take the column of "question $1 "$ in the public set.
322
+
323
+ Table 6: Detailed parameters for soft prompts and prefix. Type is the type of training, BS represents the batch size, LR denotes the learning rate, $\varepsilon$ is the DP guarantee, P-Length is the token length of soft-prompt or prefix.
324
+
325
+ <table><tr><td>Dataset</td><td>Method</td><td>RoBERTa</td><td>BS</td><td>LR</td><td>m</td><td>GRAD</td><td>Epochs</td><td></td><td>P-Length Accuracy (%)</td></tr><tr><td>SST2</td><td>Prompt</td><td>Base</td><td>1024</td><td>0.005</td><td>8</td><td>N/A</td><td>60</td><td>100</td><td>93.23</td></tr><tr><td>SST2</td><td>Prompt</td><td>Base</td><td>900</td><td>0.05</td><td>8</td><td>0.01</td><td>21</td><td>9</td><td>92.32</td></tr><tr><td>SST2</td><td>Prompt</td><td>Base</td><td>1024</td><td>0.005</td><td>3</td><td>0.05</td><td>100</td><td>10</td><td>86.35</td></tr><tr><td>SST2</td><td>Prompt</td><td>Large</td><td>2048</td><td>0.005</td><td>8</td><td>4</td><td>100</td><td>10</td><td>91.05</td></tr><tr><td>SST2</td><td>Prefix</td><td>Base</td><td>32</td><td>0.01</td><td>8</td><td>N/A</td><td>60</td><td>20</td><td>94.61</td></tr><tr><td>SST2</td><td>Prefix</td><td>Base</td><td>1000</td><td>0.05</td><td>8</td><td>4</td><td>22</td><td>1</td><td>91.97</td></tr><tr><td>SST2</td><td>Prefix</td><td>Base</td><td>1024</td><td>0.01</td><td>3</td><td>0.2</td><td>100</td><td>50</td><td>90.37</td></tr><tr><td>SST2</td><td>Prefix</td><td>Large</td><td>2048</td><td>0.05</td><td>8</td><td>4</td><td>22</td><td>1</td><td>93.58</td></tr><tr><td>QNLI</td><td>Prompt</td><td>Base</td><td>1024</td><td>0.005</td><td>8</td><td>N/A</td><td>60</td><td>128</td><td>89.48</td></tr><tr><td>QNLI</td><td>Prompt</td><td>Base</td><td>1024</td><td>0.005</td><td>8</td><td>0.05</td><td>100</td><td>10</td><td>84.11</td></tr><tr><td>QNLI</td><td>Prompt</td><td>Base</td><td>1024</td><td>0.005</td><td>3</td><td>0.1</td><td>100</td><td>50</td><td>83.62</td></tr><tr><td>QNLI</td><td>Prompt</td><td>Large</td><td>2048</td><td>0.01</td><td>8</td><td>0.05</td><td>100</td><td>10</td><td>87.62</td></tr><tr><td>QNLI</td><td>Prefix</td><td>Base</td><td>1024</td><td>0.005</td><td>8</td><td>N/A</td><td>60</td><td>20</td><td>94.84</td></tr><tr><td>QNLI</td><td>Prefix</td><td>Base</td><td>1000</td><td>0.03</td><td>8</td><td>0.07</td><td>22</td><td>10</td><td>88.77</td></tr><tr><td>QNLI</td><td>Prefix</td><td>Base</td><td>1024</td><td>0.01</td><td>3</td><td>0.2</td><td>100</td><td>50</td><td>85.78</td></tr><tr><td>QNLI</td><td>Prefix</td><td>Large</td><td>2048</td><td>0.03</td><td>8</td><td>0.07</td><td>22</td><td>10</td><td>89.45</td></tr><tr><td></td><td>Prompt</td><td>Base</td><td>1024</td><td>0.005</td><td>8</td><td>N/A</td><td>60</td><td>50</td><td>86.64</td></tr><tr><td></td><td>Prompt</td><td>Base</td><td>1024</td><td>0.05</td><td>8</td><td>0.1</td><td>10</td><td>7</td><td>82.58</td></tr><tr><td></td><td>Prompt</td><td>Base</td><td>1024</td><td>0.001</td><td>3</td><td>0.01</td><td>100</td><td>15</td><td>80.29</td></tr><tr><td></td><td>Prompt</td><td>Large</td><td>2048</td><td>0.005</td><td>8</td><td>0.05</td><td>100</td><td>10</td><td>82.29</td></tr><tr><td></td><td>Prefix</td><td>Base</td><td>1024</td><td>0.005</td><td>8</td><td>N/A</td><td>60</td><td>20</td><td>91.42</td></tr><tr><td></td><td>Prefix</td><td>Base</td><td>1024</td><td>0.05</td><td>8</td><td>0.1</td><td>10</td><td>7</td><td>82.59</td></tr><tr><td></td><td>Prefix</td><td>Base</td><td>1024</td><td>0.05</td><td>3</td><td>1</td><td>15</td><td>2</td><td>80.89</td></tr><tr><td>QP</td><td>Prefix</td><td>Large</td><td>2048</td><td>0.05</td><td>8</td><td>0.1</td><td>10</td><td>7</td><td>83.50</td></tr><tr><td>MNLI</td><td>Prompt</td><td>Base</td><td>32</td><td>0.001</td><td>8</td><td>N/A</td><td>60</td><td>20</td><td>82.49</td></tr><tr><td>MNLI</td><td>Prompt</td><td>Base</td><td>1024</td><td>0.005</td><td>8</td><td>0.05</td><td>60</td><td>10</td><td>75.01</td></tr><tr><td>MNLI</td><td>Prompt</td><td>Base</td><td>1024</td><td>0.005</td><td>3</td><td>0.05</td><td>100</td><td>10</td><td>73.97</td></tr><tr><td>MNLI</td><td>Prompt</td><td>Large</td><td>2048</td><td>0.005</td><td>8</td><td>0.2</td><td>60</td><td>10</td><td>76.05</td></tr><tr><td>MNLI</td><td>Prefix</td><td>Base</td><td>32</td><td>0.001</td><td>8</td><td>N/A</td><td>60</td><td>20</td><td>82.49</td></tr><tr><td>MNLI</td><td>Prefix</td><td>Base</td><td>1024</td><td>0.005</td><td>8</td><td>0.05</td><td>60</td><td>50</td><td>80.42</td></tr><tr><td>MNLI</td><td>Prefix</td><td>Base</td><td>1024</td><td>0.005</td><td>3</td><td>0.2</td><td>100</td><td>50</td><td>80.10</td></tr><tr><td>MNLI</td><td>Prefix</td><td>Large</td><td>2048</td><td>0.01</td><td>8</td><td>0.1</td><td>100</td><td>10</td><td>86.71</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
326
+
327
+ <table><tr><td>LLM</td><td>Dataset</td><td>T</td><td>01</td><td>02</td></tr><tr><td>GPT3</td><td>sst2</td><td>180</td><td>1</td><td>20</td></tr><tr><td>GPT3</td><td>agnews</td><td>180</td><td>5</td><td>20</td></tr><tr><td>GPT3</td><td>trec</td><td>180</td><td>1</td><td>20</td></tr><tr><td>GPT3</td><td>dbpedia</td><td>170</td><td>1</td><td>20</td></tr><tr><td>Claude</td><td>sst2</td><td>390</td><td>1</td><td>50</td></tr><tr><td>Claude</td><td>agnews</td><td>360</td><td>1</td><td>50</td></tr><tr><td>Claude</td><td>trec</td><td>320</td><td>1</td><td>50</td></tr><tr><td>Claude</td><td>dbpedia</td><td>320</td><td>5</td><td>50</td></tr></table>
328
+
329
+ Table 7: Detailed parameters for Confident-GNMax.
330
+
331
+ ![](images/1fe6b95fc6be5311ac5459b8073d1f593e5f38d7410b8d4a5dbe8a7046fa069f.jpg)
332
+ Figure 6: MIA against the public prompts of PromptPATE. We depict the AUC-ROC curve of MIA against the public prompts of PromptPATE. The member data is the examples from the prompts of all private teachers, and the non-members are randomly-selected data from the training set. Each blue curve corresponds to a different public prompt selected in one random trail. All curves are very close to the red dash line (random guess), which show that our PromptPATE is effective against MIA.
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/uKiE0VIluA-/uKiE0VIluA-.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/uLYc4L3C81A/uLYc4L3C81A.md ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Confident Adaptive Language Modeling
2
+
3
+ Tal Schuster1,⇤ Adam Fisch2,⇤ Jai Gupta1
4
+
5
+ Mostafa Dehghani1 Dara Bahri1 Vinh Q. Tran1 Yi Tay1 Donald Metzler1
6
+
7
+ 1Google Research 2CSAIL, MIT
8
+
9
+ # Abstract
10
+
11
+ Recent advances in Transformer-based large language models (LLMs) have led to significant performance improvements across many tasks. These gains come with a drastic increase in the models’ size, potentially leading to slow and costly use at inference time. In practice, however, the series of generations made by LLMs is composed of varying levels of difficulty. While certain predictions truly benefit from the models’ full capacity, other continuations are more trivial and can be solved with reduced compute. In this work, we introduce Confident Adaptive Language Modeling (CALM), a framework for dynamically allocating different amounts of compute per input and generation timestep. Early exit decoding involves several challenges that we address here, such as: (1) what confidence measure to use; (2) connecting sequence-level constraints to local per-token exit decisions; and (3) attending back to missing hidden representations due to early exits in previous tokens. Through theoretical analysis and empirical experiments on three diverse text generation tasks, we demonstrate the efficacy of our framework in reducing compute—speedup of up to $\times 3 .$ —while provably maintaining high performance.
12
+
13
+ # 1 Introduction
14
+
15
+ Recent advances in Large Language Models (LLMs) have led to breakthroughs in language understanding and language generation across almost every widely-used Natural Language Processing (NLP) task considered in the field today [5; 15; 17; 20; 51; 52; 53; 75; 89; 73]. Autoregressive language modeling provides a flexible framework for solving complex tasks with a unified natural language input and output format, while also relaxing the need for large-scale task-specific data collection and training [67; 15; 17; 58; 80]. The large size of LLMs, however, results in massive computational load that might be limiting for certain real-world applications (e.g., machine translation) [9; 30; 42; 49; 59; 63; 71]. This is especially pronounced in the autoregressive decoding process where the full stack of Transformer layers is repeatedly computed for each output token [37; 40; 86].
16
+
17
+ While large models do better in general, the same amount of computation may not be required for every input to achieve similar performance (e.g., depending on if the input is easy or hard) [66]. Early exiting is a promising approach to decreasing the computational cost of multilayered architectures such as those used in Transformer-based LLMs, where the number of layers used by the model is dynamically decided on an input-by-input basis [18; 23; 57; 60; 70]. In this setting, an LLM can choose to generate a new token based off the representation at an intermediate layer instead of using the full model, and save computation as a result. A natural question that arises, however, is when is it a good decision to exit early, as opposed to wait? Naively choosing when to exit can be suboptimal in terms of saving computation time, and also result in unpredictable degradations to model performance, especially when predictions depend on each other, as in autoregressive language generation.
18
+
19
+ ![](images/6403c6cf0f82b2a39928dda68d9bb61b123b168bef6e6e383a2672124b140f74.jpg)
20
+ Figure 1: Illustration of CALM generation (see Figure 4 for the full example) with local per-token early exiting decisions that provably satisfy global user-defined constraints on the full sequence.
21
+
22
+ In this work, we analyze the early exiting paradigm for LLMs, and present a principled method for increasing model efficiency while remaining confident in the quality of the resulting predictions. Specifically, we develop a method for calibrating local, per-token, exit decisions such that global, sequence-level constraints—as determined by lexical or semantic sequence-level metrics like ROUGE or BLEURT score—are provably maintained with arbitrarily high probability (e.g., $9 5 \%$ ). This process, which we call Confident Adaptive Language Modeling (CALM), is illustrated in Figure 1.
23
+
24
+ Our approach leverages recent techniques in distribution-free risk control in order to create confident generations with strong statistical guarantees [2; 3; 10]. Concretely, suppose we have been given a calibration set $S _ { \mathrm { c a l } } : = \{ P _ { i } \} _ { i = 1 } ^ { n } \in \mathcal { P } ^ { n }$ of independent and identically distributed (i.i.d.) prompts to our LLM (e.g., paragraphs to be summarized, sentences to be translated, or questions to be answered via language modeling). Let $P _ { \mathrm { t e s t } }$ be a new i.i.d. test prompt to our LLM, where $Y _ { \mathrm { e a r l y } } : =$ $\mathbf { L L M } _ { \mathrm { e a r l y } } ( P _ { \mathrm { t e s t } } )$ and $Y _ { \mathrm { f u l l } } : = \mathrm { L L M } _ { \mathrm { f u l l } } ( P _ { \mathrm { t e s t } } )$ are the adaptive and standard outputs of our LLM, respectively. In order to be satisfied with $Y _ { \mathrm { e a r l y } }$ , we might require it to be textually consistent with $Y _ { \mathrm { f u l l } }$ . Given any bounded text dissimilarity function $\mathcal { D }$ , we aim to calibrate the early-exiting LLM such that its predictions agree to a tolerance $\delta$ with the full model in expectation with high probability,
25
+
26
+ $$
27
+ \begin{array} { r } { \mathbb { P } \Big ( \mathbb { E } \big [ \mathcal { D } ( Y _ { \mathrm { e a r l y } } , Y _ { \mathrm { f u l l } } ) \big ] \leq \delta \mid \mathcal { S } _ { \mathrm { c a l } } \Big ) \geq 1 - \epsilon , } \end{array}
28
+ $$
29
+
30
+ where the randomness is over draws of $ { S _ { \mathrm { c a l } } }$ , and $\epsilon \in ( 0 , 1 )$ . Eq. (1) has the significant advantage of being achievable using only unlabeled calibration data $ { S _ { \mathrm { c a l } } }$ (a quality that is critical for fewshot tasks, for example). Enforcing textual consistency with the original $Y _ { \mathrm { f u l l } }$ , however, may be unnecessarily strict for certain tasks, especially where multiple generations may be acceptable. As an alternative, given a calibration set of prompts paired with a set of (potentially multiple) target references, $\bar { S _ { \mathrm { c a l } } } : = \{ ( P _ { i } , Z _ { i } ) \} _ { i = 1 } ^ { n } \in ( \mathcal { P } \times 2 ^ { \mathcal { V } } ) ^ { \bar { n } }$ , and any bounded risk function $\mathcal { R }$ , we also consider an objective that enforces risk consistency by limiting the relative increase in risk of the predictions $Y _ { \mathrm { e a r l y } }$ compared to $Y _ { \mathrm { f u l l } }$ , with respect to the set of test-time references $Z _ { \mathrm { t e s t } }$ , i.e.,
31
+
32
+ $$
33
+ \mathbb { P } \Big ( \mathbb { E } \big [ \mathcal { R } ( Y _ { \mathrm { e a r l y } } , Z _ { \mathrm { t e s t } } ) - \mathcal { R } ( Y _ { \mathrm { f u l l } } , Z _ { \mathrm { t e s t } } ) \big ] \leq \delta \big | \ S _ { \mathrm { c a l } } \Big ) \geq 1 - \epsilon .
34
+ $$
35
+
36
+ Within the constraints of either Eq. (1) or Eq. (2), the goal of our work is to find the most computationally efficient $Y _ { \mathrm { e a r l y } }$ , i.e., generations that exit as early as possible while still maintaining our desired performance guarantees. In order to achieve this, it is necessary to develop a reliable signal for how likely local, per-token early-exit decisions are to disrupt the global properties of the complete sequence. Here, we first analyze how errors are propagated in Transformer-based LLMs, and then present an effective and efficient scoring mechanism for assigning “consistent early-exit” confidence scores after each layer used during the generation of a new token. The decision to exit or not is based on these scores, and is carefully calibrated using $ { S _ { \mathrm { c a l } } }$ such that our performance bounds are provably satisfied.
37
+
38
+ Finally, we empirically validate our method on multiple, diverse NLP generation tasks, including text summarization, machine translation, and question answering. Our experiments demonstrate the potential of CALM in reducing the average complexity of the model and accelerating inference by about $\times 3$ while reliably controlling for high performance.
39
+
40
+ Contributions. In summary, our main contributions are as follows:
41
+
42
+ • A framework (CALM) for reliably accelerating Transformer-based LLM generations. • A systematic analysis of the token-wise early exit mechanism that motivates a simple-but-effective class of confidence measures and threshold functions that are used as part of the CALM framework. • An empirical demonstration of CALM’s efficiency gains on three diverse generation datasets.
43
+
44
+ # 2 Related Work
45
+
46
+ Improving inference-time efficiency of LLMs has been an ongoing effort of the research community over the past several years [49; 72; 85], leveraging techniques such as knowledge distillation [6; 32; 36; 69; 69; 78; 56], floating point quantization [71; 65], layer pruning [24], vector dropping [38], and others [41]. Another line of work involves conditional computation to train larger models that only use a sparser subset of the full network during inference, for example by routing over mixture-ofexperts [9; 22; 39; 91], recurring modules [18; 29; 35], or accessing external memory [82]. These models, however, still use the same amount of compute for all input examples.
47
+
48
+ Here, we focus on adaptive compute, a specific kind of conditional compute that aims to dynamically allocate different computational power per example, with the goal of reducing the overall complexity while maintaining high performance. This approach, often referred to as early-exiting [16; 25; 47; 74; 79; 87], is complementary to many of the solutions above and can potentially be combined with them. Multiple early-exit techniques for encoder-only Transformers (e.g., BERT [20]) have been recently proposed [8; 34; 43; 44; 45; 60; 68; 83; 90; 92]. Most of these methods rely on intrinsic confidence measures (e.g., based on the softmax distribution), while others try to predict the routing in advance [46; 70], or train a small early-exit classifier [57; 84], as we also examine here. These measures can be calibrated to reliably guarantee consistency of the early prediction with the full model [57]. However, the techniques used for encoder-only classifiers are unsuitable for global consistency constraints with a sequence of dependent predictions, which are inherent in the decoding process of autoregressive language models, which we address here.
49
+
50
+ Our work is also motivated by recent findings on the existence of saturation events in LMs, where the top-ranked prediction is unchanged after some layer and is propagated upward. Geva et al. [28] examined interactions of the hidden-state with feed-forward layers to predict these events. However, they only consider local single predictions and do not address the challenges involved with sequence generation. Our early-exit LM architecture most closely relates to Elbayad et al. [23], who found a tokenlevel early-exit classifier to provide the best efficiency-performance tradeoffs on machine translation. Here, we introduce a theoretically-grounded calibration method for provably controlling the quality of the full sequence. By doing so, we provide reliable efficiency gains—deriving local early exiting decisions from the global desirable constraints. Moreover, we introduce several model improvements and empirical analyses, including (1) analyzing the primary sources of performance degradation, leading us to propose a decaying threshold function for better tradeoff control without inflating the search space; (2) improving the early-exit classifier training; and (3) experimenting with two new tasks.
51
+
52
+ Our calibration procedure for connecting global constraints to local decisions, relates to recent research around distribution-free uncertainty quantification [1; 62; 77]. Several methods were developed in recent studies to expand and adjust the theoretical framework for obtaining practical efficiency gains on target applications [4; 7; 21; 26; 27; 48; 88]. Here, we frame our consistency requirements around the Learn then Test (LTT) framework [3], and leverage the approximately monotonic behavior of our confidence measures and the nested structure of our problem, that by definition guarantees consistency with large enough threshold, to form tight and effective bounds.
53
+
54
+ # 3 Early Exiting for Adaptive Language Modeling
55
+
56
+ In the following, we describe and analyze the early-exiting Transformer LM. We begin with a brief recap of the Transformer architecture (§3.1) and early exiting (§3.2) for convenience, following previous work [23; 70; 76]. We then investigate the effects of early exiting on model performance, and identify primary sources of performance degradation and how to alleviate them (§3.3)—which guide our architecture and training design (§3.4) and proposed per-token confidence measures (§3.5).
57
+
58
+ # 3.1 The Transformer architecture
59
+
60
+ We use the Transformer sequence-to-sequence model, based on the T5x implementation [55]. Here, we only review simplified details of the Transformer architecture relevant to early-exiting, and refer the reader to Vaswani et al. [76] for full details. At a high level, both encoder and decoder networks contain $L$ stacked layers, where each layer is composed of a multi-head self-attention sub-layer, followed by a feedforward sub-layer, each with residual connections and layer normalization. The decoder network has an additional multi-head attention sub-layer that attends to the encoder states.
61
+
62
+ Consider a prompt $\boldsymbol { x } = ( x _ { 1 } , \dots , x _ { p } )$ , processed by the encoder to yield encoder states $( e _ { 1 } , \ldots , e _ { p } )$ , and the current, partially generated response $( y _ { 1 } , \dots , y _ { t } )$ . When generating the next token $y _ { t + 1 }$ , the decoder computes a decoder state $d _ { t } ^ { i }$ for layer $i$ out of $L$ as:
63
+
64
+ $$
65
+ \begin{array} { r } { h _ { t } ^ { i } : = \mathrm { A t t e n t i o n } ( d _ { t } ^ { i - 1 } , d _ { 1 : t - 1 } ^ { i - 1 } ) ; \quad a _ { t } ^ { i } : = \mathrm { A t t e n t i o n } ( h _ { t } ^ { i } , e _ { 1 : p } ) ; \quad d _ { t } ^ { i } : = \mathrm { F e e d F o r w a r d } ( a _ { t } ^ { i } ) . } \end{array}
66
+ $$
67
+
68
+ Internal to each of the attention mechanisms, written as $\mathrm { A t t e n t i o n } ( x , z _ { 1 : m } )$ for some input $x$ and sequence of $m$ states $z _ { 1 : m }$ , $x$ is first projected to a query vector $q : = \mathbf { W } _ { Q } x \in \mathbb { R } ^ { \dim _ { k } }$ , while $z$ is projected to a matrix of key-value vectors, $\mathbf { K } : = \mathbf { W } _ { K } z _ { 1 : m } \in \mathbb { R } ^ { m \times \mathrm { d i m } _ { k } }$ and $\mathbf { V } : = \mathbf { W } _ { V } z _ { 1 : m } \in$ $\mathbf { \mathbb { R } } ^ { m \times \dim _ { v } }$ . The output $o$ is then computed as o := softmax $\left( q \mathbf { K } ^ { \top } / \sqrt { \mathrm { d i m } _ { k } } \right) \mathbf { V }$ .
69
+
70
+ Multi-head and normalization components are omitted for brevity. Each layer uses different projections $\mathbf { W } _ { Q } ^ { i } , \mathbf { W } _ { K } ^ { i }$ , and $\mathbf { W } _ { V } ^ { i }$ (which are also unique for computing $h _ { t } ^ { i }$ versus $\dot { a } _ { t } ^ { i \cdot }$ ).
71
+
72
+ Finally, after layer $L$ , a distribution over vocabulary tokens $y _ { t + 1 } \in \mathcal { D }$ is computed via a softmaxnormalized linear classifier $\mathbf { W } _ { L }$ , where $p ( y _ { t + 1 } \mid d _ { t } ^ { L } ) = \mathrm { s o f t m a x } ( \mathbf { W } _ { L } d _ { t } ^ { L } )$ .
73
+
74
+ # 3.2 Decoding with early exiting
75
+
76
+ Instead of always making a prediction based on the representation at the final layer, $d _ { t } ^ { L }$ , the key idea in early-exiting is to choose $y _ { t + 1 }$ more quickly, if confident, by computing $p ( y _ { t + 1 } \mid d _ { t } ^ { i } ) =$ softmax $( \dot { W _ { i } } \dot { d _ { t } ^ { i } } )$ for some intermediate layer $i < L$ . Concretely, let $\bar { c } _ { t } ^ { i } \in [ \bar { 0 } , 1 ]$ denote some local confidence score for layer $i$ while processing token $t$ , where higher values indicate a higher propensity to exit early (we will propose effective instantiations of $c _ { t } ^ { i }$ in $\ S 3 . 5 )$ . Let $\lambda _ { t } ^ { i } \in [ 0 , 1 ]$ denote some local early-exiting threshold, where the model exits early if $c _ { t } ^ { i } \geq \lambda _ { t } ^ { i }$ , or otherwise proceeds to compute the next representation, $d _ { t } ^ { i + 1 }$ . The (greedily chosen) prediction $y _ { t + 1 }$ can then be written as:
77
+
78
+ $$
79
+ y _ { t + 1 } : = \left\{ \begin{array} { l l } { \arg \operatorname* { m a x } p ( y _ { t + 1 } \mid d _ { t } ^ { 1 } ) \quad } & { \mathrm { i f } c _ { t } ^ { 1 } \geq \lambda _ { t } ^ { 1 } , } \\ { \arg \operatorname* { m a x } p ( y _ { t + 1 } \mid d _ { t } ^ { 2 } ) \quad } & { \mathrm { i f } c _ { t } ^ { 2 } \geq \lambda _ { t } ^ { 2 } , } \\ { \quad } & { \ \vdots } \\ { \arg \operatorname* { m a x } p ( y _ { t + 1 } \mid d _ { t } ^ { L } ) \quad } & { \mathrm { o t h e r w i s e } . } \end{array} \right.
80
+ $$
81
+
82
+ Note that due to the self-attention mechanism of the Transformer, computing the input hidden state $h _ { t } ^ { i }$ for layer $i$ depends on $d _ { 1 : t - 1 } ^ { i - 1 }$ , i.e., the output hidden states of the previous layer for all the tokens that have been generated so far.2 Therefore, if the model has early exited at some layer $j < i - 1$ for a token $s < t$ , then $d _ { s } ^ { i - 1 }$ is not available. As an approximation, we set $d _ { s } ^ { k } = d _ { s } ^ { j }$ for all layers $k > j$ following Elbayad et al. [23], with the understanding that this will introduce some error. In the next section, in addition to other factors, we will analyze the impact of this copied state on performance.
83
+
84
+ # 3.3 The effects of early exiting on error propagation
85
+
86
+ We perform several controlled experiments to investigate the behavior and the potential of earlyexiting during decoding. We use an 8-layer T5 encoder-decoder and the CNN/DM dataset for these experiments. See $\ S 5$ for more details on this model and data.
87
+
88
+ # 3.3.1 State propagation
89
+
90
+ First, we control for the correctness of the predicted tokens to examine the effect of state copying (§3.2), and also measure an approximate upper bound for compute reduction. We use an oracle confidence measure that exits at the earliest layer that agrees with the top prediction (i.e., replacing the conditions in Eq. 4 with arg max $p ( y _ { t + 1 } \mid \bar { d } _ { t } ^ { i } ) = \arg \operatorname* { m a x } p ( y _ { t + 1 } \mid { \dot { d } } _ { t } ^ { \hat { L } } ) )$ . Hence, the only factor that can cause divergence in the generation is the state copying mechanism for skipped layers. The results of this experiment are highly encouraging. This oracle achieves an ROUGE-L score of 38.24, compared to 38.32 with the full model, while only using an average of 1.53 layers per token. We also try an oracle that always uses $d _ { 1 : t - 1 } ^ { 1 }$ and it reaches 38.31 ROUGE-L. These results indicate that (1) the model is robust to state copying from lower layers, and (2) there is remarkable potential for saving compute—by up to $\times 5 . 2$ —while preserving performance, given a good confidence measure.
91
+
92
+ We also experiment with copying the projected states $\mathbf { K } ^ { j } , \mathbf { V } ^ { j }$ to skipped layers $k > j$ . This version of the oracle results in a significant drop in performance to 23.02 ROUGE-L. Overall, we conjecture that the self-attention at layer $i$ for token $t$ can safely use hidden-states $d _ { s } ^ { j }$ for $j < i - 1$ as key-values of tokens $s < t$ , as long as the projections $\mathbf { W } _ { K / V } ^ { i }$ of layer $i$ are used. Notably, this projection can now be computed concurrently for all skipped layers as they all use the same $d$ from the exited layer.
93
+
94
+ ![](images/c9293fe540f82f85222a9ced360ae50fb5c8012dd05f8b51c72a691482b5286a.jpg)
95
+ Figure 2: Earlier noise in the decoding process has greater effect on the overall output (a), though in practice the affect of early exits is minor due to high performance of early layers. A decaying confidence threshold (b) allows finer control over the performance-efficiency tradeoff (c).
96
+
97
+ # 3.3.2 Sensitivity to local errors
98
+
99
+ Next, we examine the impact of local token modifications—which might occur due to early exits—on the whole generated sequence. We experiment with two kinds of perturbations: sampling-based, where we select the 10th-ranked token according to layer $L$ ; and layer-based, where we select the the first layer’s prediction at timestep $t$ . All other tokens are predicted greedily by layer $L$ . As shown in Figure 2a, earlier perturbations result in lower sequence-level scores as there are more tokens that might suffer from the divergence. The degradation, though, is much smaller with layer- compared to sampling-based perturbations since, in practice, the early exit predictions are mostly accurate.
100
+
101
+ Decaying threshold. Following the above observation, we introduce a decaying early-exiting threshold that is more permissive towards exiting as the decoding process continues. Motivated by the logarithmic behavior in Figure 2a, we use an exponential function with a user-defined temperature $\tau$ :
102
+
103
+ $$
104
+ \lambda ^ { \prime } ( \lambda , t ) : = \mathrm { c l i p } _ { [ 0 , 1 ] } \left( \frac { 9 } { 1 0 } \lambda + \frac { 1 } { 1 0 } e ^ { - \tau \cdot t / N } \right) ,
105
+ $$
106
+
107
+ where $N$ is the maximum output length. Figure 2b illustrates this function. Essentially, this function presents an effective compromise between simply using the same threshold for all tokens, and searching over a huge space of per-position different thresholds. Practically, it supports finer and better control over the performance-efficiency tradeoff compared to a single threshold. Figure $2 \mathrm { c }$ presents the outcomes of a search over $\lambda$ with steps of 0.01 and softmax-based confidence $( \ S 3 . 5 )$ . With the single threshold variant $( \tau = 0$ ), attempting to improve the efficiency will lead to a drastic drop of more than 10 points in the textual similarity against the full model’s prediction. In contrast, the decaying thresholds reveal several intermediate points with desirable tradeoffs to consider.
108
+
109
+ # 3.4 Training early exit classifiers for local consistency
110
+
111
+ While our goal is to preserve the quality of the complete output sequence, we note that this doesn’t necessarily demand local token-level consistency. Consider the target sequence “the concert was wonderful and long.” An output that switches the order of adjectives to “the concert was long and wonderful” would be called consistent by most semantic measures (and obtain 100 token- $F _ { 1 }$ score). Yet, the sentences diverge at the first adjective long which is semantically different from wonderful.
112
+
113
+ Training for global consistency, however, could be challenging [81] as it depends on possibly noisy signals that might affect the learning, and also breaks the efficient teacher-forcing training strategy of LMs that relies on local-decisions. On the other hand, perfect local consistency implies global consistency. Therefore, we opt to train for local consistency, which requires minimal changes to the training procedure, and relax the local requirement to a global one during inference.
114
+
115
+ Specifically, similar to Elbayad et al. [23], we average losses for each layer to obtain the objective
116
+
117
+ $$
118
+ \mathcal { L } = \sum _ { i = 1 } ^ { L } \omega _ { i } \mathcal { L } _ { i } , \quad \mathrm { w h e r e } \quad \sum _ { i = 1 } ^ { L } \omega _ { i } = 1 .
119
+ $$
120
+
121
+ $\mathcal { L }$ is the negative log-likelihood loss. We set $\begin{array} { r } { \omega _ { i } = i / \sum _ { j = 1 } ^ { L } j } \end{array}$ to favor higher layers, and find this objective to mostly preserve the full model’s performance compared to regular training. We note that there is some misalignment between this training and inference behavior due to the hidden states of skipped layers. However, as discussed in $\ S 3 . 3 . 1$ , the performance is not affected if the hidden-state is copied.
122
+
123
+ # 3.5 Local confidence measures
124
+
125
+ We experiment with three confidence measures for Eq. (4) that differ in their parameter and compute operation efficiencies. Our experiments (§6) will also show that they differ in their predictive power.
126
+
127
+ Softmax response. We take the difference between the top two values of Softmax $( \mathbf { W _ { i } } d _ { t } ^ { i } )$ . With a large output vocabulary, this results in many floating point operations (FLOPs)—though, the next layer $i + 1$ can start its computation in parallel, avoiding additional runtime.
128
+
129
+ Hidden-state saturation. As a simple parameter-free and fast to compute alternative, we take the cosine similarity $\mathrm { s i m } ( d _ { t } ^ { i } , d _ { t } ^ { i - 1 } )$ for $i > 1$ . By definition, the first possible exit is at the second layer (unless $\lambda = 0$ ). This measure tries to identify early saturation events of the hidden-state [28].
130
+
131
+ Early exit classifier. We train a dedicated linear classifier $\mathcal { M }$ to predict the likelihood of exiting with local consistency given the current hidden-state: $c _ { t } ^ { i } = \mathcal { M } ( \bar { d } _ { t } ^ { i } )$ . This measure is very fast to compute at inference, and adds only $| d | + 1$ new parameters. To avoid any impact on the core model’s performance, we train it as a second step where we freeze all parameters other than $\mathcal { M }$ . We simply use a per-layer independent cross-entropy loss against a consistency oracle $\mathbb { 1 } [ \operatorname { a r g m a x } ( p ( y _ { t + 1 } | d _ { t } ^ { i } ) \bar { = }$ ar $\mathrm { g } \operatorname* { m a x } ( p ( y _ { t + 1 } | d _ { t } ^ { L } ) ]$ , and average across the $L - 1$ layers. We also experimented with the geometriclike training of Elbayad et al. [23], but find it to be less effective here (see App. D). The two objectives are closely related, but the geometric one ignores any signal from the states post the first oracle exit.
132
+
133
+ # 4 Calibrating Local Early Exits from Global Constraints
134
+
135
+ We now describe our calibration procedure for finding a shared exit threshold $\lambda \in [ 0 , 1 ]$ that can be used directly in Eq. (4), or via Eq. (5), such that we provably satisfy our desired global constraints over the fully generated sequences. At a high level, our approach uses the following basic recipe:
136
+
137
+ 1. We specify a grid of possible values of $\boldsymbol { \Lambda } = \left( \lambda _ { 1 } , \ldots , \lambda _ { k } \right)$ that may result in acceptable generations;
138
+ 2. We choose the lowest valid $\lambda \in \Lambda$ that we can identify with rigorous statistical testing tools.
139
+
140
+ Let $P _ { \mathrm { t e s t } }$ be an i.i.d. prompt given to the LLM at test time, and let $Y _ { \mathrm { f u l l } } : = \mathrm { L L M } _ { \mathrm { f u l l } } ( P _ { \mathrm { t e s t } } ) \in \mathcal { V }$ and $Y _ { \mathrm { e a r l y } } : = \mathrm { L L M } _ { \mathrm { e a r l y } } ( P _ { \mathrm { t e s t } } , \lambda ) \in \mathcal { Y }$ denote the full and adaptive responses, respectively. Optionally, let $\dot { Z } _ { \mathrm { t e s t } }$ be a set of gold references for our task, if assumed. Our goal, as introduced in $\ S 1$ , is to find a valid $\lambda$ using $ { S _ { \mathrm { c a l } } }$ such that we satisfy either of two types of global “consistency” constraints:
141
+
142
+ Definition 1 (Textual consistency). An adaptive LLM is textually consistent if given any bounded text dissimilarity function, $\mathcal { D } \colon \mathcal { V } \times \mathcal { V } \to \mathbb { R }$ , and tolerance $\delta \in \mathbb { R }$ , $\mathbb { E } \big [ { \cal D } ( Y _ { \mathrm { e a r l y } } , \tilde { Y _ { \mathrm { f u l l } } } ) \big ] \leq \dot { \delta }$ .
143
+
144
+ Definition 2 (Risk consistency). An adaptive LLM is risk consistent if given any bounded risk function, $\mathcal { R } : \mathcal { V } \times 2 ^ { \mathcal { V } } \to \mathbb { R } ,$ , and tolerance $\delta \in \mathbb { R } ,$ $\mathbb { E } [ \mathcal { R } ( Y _ { \mathrm { e a r l y } } , Z _ { \mathrm { t e s t } } ) ] \le \mathbb { E } [ \mathcal { R } ( Y _ { \mathrm { f u l l } } , Z _ { \mathrm { t e s t } } ) ] + \delta$ .
145
+
146
+ Without loss of generality, we will assume that $\mathcal { D }$ and $\mathcal { R }$ are always normalized to the unit interval $[ 0 , 1 ]$ , and therefore will only be considering tolerances $\delta \in ( 0 , 1 )$ . At a glance, to find a $\lambda$ that produces a consistent $\mathbf { L L M } _ { \mathrm { e a r l y } }$ , we cast our problem as a multiple hypothesis testing problem over a large array of $k$ candidate classifier exit thresholds, $\boldsymbol { \Lambda } = \left( \lambda _ { 1 } , \ldots , \lambda _ { k } \right)$ , and apply the Learn then Test (LTT) framework of Angelopoulos et al. [3] to identify a subset of statistically valid, constraint-satisfying thresholds $\Lambda _ { \mathrm { v a l i d } } \subset \Lambda$ . Our final $\lambda$ is then chosen as $\lambda : = \operatorname* { m i n } ( \Lambda _ { \mathrm { v a l i d } } \cup \dot { \{ 1 \} } )$ .
147
+
148
+ # 4.1 The Learn then Test calibration framework
149
+
150
+ Choosing a value of $\lambda$ that rigorously satisfies our consistency objectives is challenging, as the performance impact of increasing or decreasing $\lambda$ is not necessarily monotonic. Naively setting $\lambda$ , for example, based simply on average calibration set performance, can lead to statistically invalid results in our finite-sample, distribution-free setting. The LTT framework proposed by Angelopoulos et al. [3] solves this problem by reframing hyper-parameter selection as a multiple testing problem.
151
+
152
+ Let $\boldsymbol { \Lambda } = \left( \lambda _ { 1 } , \ldots , \lambda _ { k } \right)$ be a finite grid of hyper-parameter values that may, or may not, obtain valid consistency. For example, when searching for a value of $\lambda \in [ 0 , 1 ]$ , we might consider the evenly spaced set $\begin{array} { r } { \dot { \Lambda } = \{ \frac { i } { k + 1 } : \stackrel { \cdot } { i } = 1 , \dots , k \} } \end{array}$ . LTT then identifies a subset of values, $\Lambda _ { \mathrm { v a l i d } } \subset \Lambda$ , where
153
+
154
+ $$
155
+ \mathbb { P } \Big ( \exists \lambda \in \Lambda _ { \mathrm { v a l i d } } \colon \mathbf { L L M _ { \mathrm { e a r l y } } } ( P _ { \mathrm { t e s t } } , \lambda ) \mathrm { ~ a n d ~ } \mathbf { L L M _ { \mathrm { f u l l } } } ( P _ { \mathrm { t e s t } } ) \mathrm { ~ a r e ~ } \mathbf { n o t } \mathrm { ~ c o n s i s t e n t } \Big ) \le \epsilon .
156
+ $$
157
+
158
+ Here, we are using consistency to refer to either textual consistency or risk consistency. Eq. (7) can be satisfied by applying standard multiple hypothesis testing techniques as long as super-uniform p-values, $p _ { j }$ , are supplied for each value $\lambda _ { j } \in \Lambda$ that support the null hypothesis
159
+
160
+ $$
161
+ H _ { j } \colon \mathbf { L } \mathbf { L } \mathbf { M } _ { \mathrm { e a r l y } } ( P _ { \mathrm { t e s t } } , \lambda _ { j } ) \ \mathrm { a n d } \ \mathbf { L } \mathbf { L } \mathbf { M } _ { \mathrm { f u l l } } ( P _ { \mathrm { t e s t } } ) \ \mathrm { a r e } \ \mathbf { n o t } \ \mathrm { c o n s i s t e n t } .
162
+ $$
163
+
164
+ $\lambda _ { j }$ is placed in $\Lambda _ { \mathrm { v a l i d } }$ if $H _ { j }$ is rejected, and discarded otherwise. This yields a consistent $\mathbf { L L M } _ { \mathrm { e a r l y } }$ . Proposition 1 (LTT for CALM). Suppose $p _ { j }$ is super-uniform for all $j$ under $H _ { j }$ for some specified tolerance $\delta \in ( 0 , 1 )$ . Let $\mathcal { A }$ be any family-wise error rate (FWER) controlling procedure at a level $\epsilon \in ( 0 , 1 )$ , where $\mathcal { A } ( p _ { 1 } , \ldots , p _ { k } )$ selects $H _ { j }$ to reject. Choosing $\lambda : = \operatorname* { m i n } ( \Lambda _ { \mathrm { v a l i d } } \cup \{ 1 \} )$ then yields a consistent $L L M _ { \mathrm { e a r l y } }$ with probability at least $1 - \epsilon$ .
165
+
166
+ Note that a FWER-controlling procedure at a level $\epsilon$ is an algorithm that decides to accept or reject hypotheses $\{ H _ { i } \} _ { i = 1 } ^ { k }$ , while ensuring that the probability of falsely rejecting any $H _ { j }$ is less than $\epsilon$ . The proof of Proposition 1, given in Appendix A.1, follows directly from Theorem 1 of Angelopoulos et al. [3], and the fact that $\mathbf { L L M _ { \mathrm { e a r l y } } } ( P _ { \mathrm { t e s t } } ^ { - } , 1 ) = \mathbf { L L M _ { \mathrm { f u l l } } } ( P _ { \mathrm { t e s t } } )$ by construction per Eq. (4), so that we can always use $\lambda = 1$ as a valid fallback if we fail to identify non-empty $\Lambda _ { \mathrm { v a l i d } }$ . In the next sections, we describe how we calculate valid $\mathsf { p }$ -values using $ { S _ { \mathrm { c a l } } }$ , and our choice of FWER-controlling procedure.
167
+
168
+ # 4.2 Defining p-values for consistent early-exiting
169
+
170
+ LTT relies on valid $\mathfrak { p }$ -values $p _ { j }$ , where $p _ { j }$ is a random variable satisfying $\mathbb { P } ( p _ { j } \leq u ) \leq u$ under $H _ { j }$ for all $u \in [ 0 , 1 ]$ . For our purposes, we can obtain valid $\mathsf { p }$ -values from the empirical consistency of $\mathrm { L L M } _ { \mathrm { e a r l y } } ( P _ { i } , \lambda )$ measured over the random calibration sample, $ { S _ { \mathrm { c a l } } }$ . Since we have assumed w.l.o.g. that either of our bounded consistency functions $\mathcal { D }$ and $\mathcal { R }$ from Defs. 1 and 2 have been normalized to lie in $[ 0 , 1 ]$ , we can, for example, obtain a valid $\mathfrak { p }$ -value by simply inverting Hoeffding’s inequality:3
171
+
172
+ $$
173
+ p _ { j } ^ { \mathrm { H o e f f d i n g } } : = e ^ { - 2 n ( \operatorname* { m a x } ( 0 , \delta - \widehat { E } ( \lambda _ { j } ) ) ) ^ { 2 } } ,
174
+ $$
175
+
176
+ where $\begin{array} { r } { \widehat { E } ( \lambda _ { j } ) : = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } L _ { i } ( \lambda _ { j } ) } \end{array}$ is the empirical average of random variable $L _ { i } ( \lambda _ { j } ) \in [ 0 , 1 ]$ , with
177
+
178
+ $$
179
+ \mathsf { \Pi } _ { \mathsf { L } _ { i } } ( \lambda _ { j } ) : = \mathcal { D } ( \mathrm { L L M } _ { \mathrm { e a r l y } } ( P _ { i } , \lambda _ { j } ) , \mathrm { L L M } _ { \mathrm { f u l l } } ( P _ { i } ) ) \quad \mathrm { o r }
180
+ $$
181
+
182
+ $$
183
+ L _ { i } ( \lambda _ { j } ) : = \operatorname* { m a x } \left( 0 , \mathcal { R } ( \operatorname { L L M } _ { \mathrm { e a r l y } } ( P _ { i } , \lambda _ { j } ) , Z _ { i } ) - \mathcal { R } ( \operatorname { L L M } _ { \mathrm { f u l l } } ( P _ { i } ) , Z _ { i } ) \right) ,
184
+ $$
185
+
186
+ for textual consistency versus risk consistency, respectively. Note that, as a technicality of enforcing the r.v. $L _ { i } ( \lambda _ { j } )$ to be within $[ 0 , 1 ]$ , Eq. (11) computes a conservative estimate of the difference in the empirical risk that doesn’t reward instances in which the risk of the early-exit model is lower.
187
+
188
+ # 4.3 Efficient fixed sequence testing
189
+
190
+ The more values of $\lambda$ we test, the higher the chance that we might accidentally choose a $\lambda$ that does not in fact result in consistent generations, despite whatever misleading performance we might have measured by chance on $ { S _ { \mathrm { c a l } } }$ . As part of LTT, we must select a multiple testing procedure that corrects for this (i.e., that controls the FWER at level $\epsilon$ ). Though the precise dependence between the early-exit LLM’s performance and $\lambda$ is unknown, in practice we find that it tends to be fairly smooth and roughly monotonic. That is, nearby thresholds $\bar { \lambda } \approx \lambda ^ { \prime }$ tend to perform similarly, whereas $\lambda > \lambda ^ { \prime }$ tends to result in relatively more consistent performance. Taking advantage of this structure, we choose to employ fixed sequence testing (FST) as our FWER-controlling procedure [3; 11].
191
+
192
+ Here we define a sequence of descending thresholds $\lambda _ { 1 } > \lambda _ { 2 } > . . . \lambda _ { k }$ with a relatively coarse step size (e.g., increments of 0.05). For each $\lambda _ { j }$ in order, we compute $p _ { j }$ , and reject $H _ { j }$ if $p _ { j } \leq \epsilon$ . The first time we fail to reject $H _ { j }$ , we immediately terminate our search, and return $\lambda _ { j - 1 }$ to use as our calibrated threshold (or 1, if we fail to reject $H _ { 1 }$ ). An Algorithm of the full procedure is provided in Appendix E.
193
+
194
+ ![](images/0c105aa367418bb431e00db485785f8d1b130393e688a242b52e2fc317d8243b.jpg)
195
+ Figure 3: Validation empirical performance-efficiency tradeoffs for different confidence measures, compared to static baselines and a local oracle measure with state propagation for skipped layers.
196
+
197
+ # 5 Experimental Setting
198
+
199
+ We empirically evaluate our methods on three popular text generation tasks that vary in their target generation length and extractive degrees against the input. CNN/DM [31] is a collection of news articles to be summarized in few sentences. WMT15 EN-FR [13] contains English sentences (one per example) to be machine translated to French. Open-book SQUAD 1.1 [54] is a QA dataset with Wikipedia paragraphs paired with questions, where the target answer is a text span from the input. Length statistics of the validation sets are summarized in Table 1.
200
+
201
+ Table 1: Average number of tokens in reference targets of evaluation datasets (5/95th percentiles in parenthesis).
202
+
203
+ <table><tr><td>Dataset</td><td>Output length</td></tr><tr><td>CNN/DM</td><td>82 (42 - 141)</td></tr><tr><td>WMTEN-FR</td><td>39 (10 -82)</td></tr><tr><td>SQUAD</td><td>5 (1-13)</td></tr></table>
204
+
205
+ Model. We implement CALM on top of the T5 encoder-decoder model that showed good performance on the tasks above [53], using the T5X framework [55]. We use the 8 layers T5 1.1 model that doesn’t share input and output embeddings. We share all output embeddings for the softmax predictions, and the early-exit classifier across all decoder layers. Based on validation results, we set the temperature of our decaying threshold to $\tau = 4$ for the softmax and classifier measures of CNN/DM and WMT. In other settings, we use $\tau = 0$ . See App. C for more details, and App. B.3 for a 12 layers T5 model.
206
+
207
+ Evaluation metrics. We use the standard metrics for each task: ROUGE-L for CNN/DM, BLEU [50] for WMT, and Token-F1 [54] for SQUAD. We rely on the same metrics for computing the risk and textual distance, other than BLEU which is a corpus-level metric that doesn’t directly enable expectation control. Instead, we use the BLEURT learned metric [61]. For a given metric $m ( y _ { \mathrm { e a r l y } } , y _ { \mathrm { f u l l ~ o r } } z _ { \mathrm { t e s t } } ) \in [ 0 , 1 ]$ , we use $1 - m$ for distance or risk computation, respectively.
208
+
209
+ Our main efficiency metric is the average number of decoder layers used per output token, as it directly measures complexity reduction without conflating with implementation or infrastructure specific details [19]. For reference, we also report the average decoder FLOPs reduction per token [23]. Also, we compute an estimated speedup of the whole encoder-decoder model for generating the full sequence, based on TPUv3 benchmarking with 200 examples in Colab (see App. C for details).
210
+
211
+ Calibration experiments. For each task, we use the validation and test sets to evaluate our calibration method (§4) (for SQUAD we only use the validation set as the test answers are hidden). We run 50 random trials per target tolerance $\delta$ and consistency objective (textual or risk), where we partition the data to $80 \%$ calibration $( S _ { \mathrm { c a l } } )$ and $20 \%$ test $( P _ { \mathrm { t e s t } } )$ . We set $\epsilon = 0 . 0 5$ for all experiments.
212
+
213
+ Baselines. We emphasize that the CALM framework is general for any autoregressive multi-layered LM with any confidence measure, allowing controlled consistency by Eq. (1) or Eq. (2). To empirically evaluate the efficiency gains enabled by our proposed confidence measures, we compare with static baselines that use the same number of layers for all tokens. We also compare our early-exit classifier training with the geometric method of [23] in Appendix D. Also, we compute an oracle local measure (§3.3.1) as an upper-bound estimate of the performance-efficiency tradeoff.
214
+
215
+ # 6 Experimental Results
216
+
217
+ We first report the empirical performance-efficiency tradeoff achieved with each confidence measure.
218
+ For each task and measure, we evaluate the full range of $\lambda$ on the validation set, with steps of 0.05.
219
+
220
+ Table 2: Test efficiency gains per choice of $\delta$ , consistency objective, and confidence measure. $\epsilon$ is set to 0.05. For plots of the full range of $\delta$ with standard deviation, see Appendix B.
221
+
222
+ <table><tr><td rowspan="2">8</td><td rowspan="2">Measure</td><td rowspan="2"></td><td colspan="3">CNN/DM</td><td colspan="3">WMT</td><td colspan="3">SQUAD</td></tr><tr><td>layers</td><td>FLOPs r.</td><td>speedup</td><td>layers</td><td>FLOPs r.</td><td>speedup</td><td>layers</td><td>FLOPs r.</td><td>speedup</td></tr><tr><td rowspan="6">sisuos[enxəL 5</td><td rowspan="6">1</td><td>softmax state</td><td>5.73 8.00</td><td>×0.44 ×1.00</td><td>×1.41 ×1.00</td><td>3.35</td><td>×0.66</td><td>×2.01</td><td>1.65</td><td>×3.15</td><td>×1.63</td></tr><tr><td></td><td></td><td></td><td></td><td>7.68</td><td>×1.01</td><td>×1.00</td><td>2.00</td><td>×3.65</td><td>×1.68</td></tr><tr><td>classifier</td><td>7.16</td><td>×1.03</td><td>×1.42</td><td>5.50</td><td>×1.06</td><td>×2.05</td><td>2.59</td><td>×2.37</td><td>×1.10</td></tr><tr><td>softmax</td><td>2.62</td><td>×0.49</td><td>×2.57</td><td>1.76</td><td>×0.91</td><td>×2.83</td><td>1.03</td><td>×5.68</td><td>×1.88</td></tr><tr><td>state</td><td>7.97</td><td>×1.00</td><td>×1.01</td><td>2.84</td><td>×1.93</td><td>×1.55</td><td>2.00</td><td>×3.65</td><td>×1.68</td></tr><tr><td>classifier</td><td>4.51</td><td>×1.15</td><td>×2.04</td><td>2.97</td><td>×1.22</td><td>×2.00</td><td>1.37</td><td>×5.09</td><td>×1.11</td></tr><tr><td rowspan="6">Prrsrorssrr 00</td><td rowspan="6">0</td><td>softmax</td><td>3.75</td><td>×0.47</td><td>×1.96</td><td>3.19</td><td>×0.67</td><td>×2.10</td><td>1.65</td><td>×3.15</td><td>×1.63</td></tr><tr><td>state</td><td>7.97</td><td>×1.00</td><td>×1.01</td><td>7.68</td><td>×1.01</td><td>×1.00</td><td>3.13</td><td>×2.11</td><td>×1.68</td></tr><tr><td>classifier</td><td>6.49</td><td>×1.06</td><td>×1.71</td><td>5.05</td><td>×1.08</td><td>×1.97</td><td>3.36</td><td>×1.55</td><td>×1.11</td></tr><tr><td>softmax</td><td>1.73</td><td>×0.50</td><td>×3.53</td><td>1.96</td><td>×0.85</td><td>×2.73</td><td>1.65</td><td>×3.15</td><td>×1.63</td></tr><tr><td>state</td><td>5.22</td><td>×1.11</td><td>×1.64</td><td>2.72</td><td>×2.01</td><td>×1.58</td><td>2.00</td><td>×3.65</td><td>×1.68</td></tr><tr><td>classifier</td><td>2.30</td><td>×1.25</td><td>×2.09</td><td>3.08</td><td>×1.21</td><td>×1.98</td><td>2.59</td><td>×2.37</td><td>×1.10</td></tr></table>
223
+
224
+ The results, presented in Figure 3, show the power of the softmax response measure, allowing only minor performance loss while reducing more than half of the layers in all three tasks. The early-exit classifier, that is more FLOP-efficient, is also effective, mostly when targeting high performance (right hand side of plots). The simple and parameter-free state saturation measure is competitive, but often falls bellow the static baseline, despite enabling per-token exit decisions.
225
+
226
+ The dynamic oracle obtains compelling efficiency gains, using only 1.5, 1.3, and 1.2 layers on average for summarization, WMT, and QA, respectively, without losing any performance. This illustrates the full potential of CALM and leaves further room for improvements with better confidence measures. It also shows the effectiveness of inference-time state propagation for skipped layers (§3.3.1).
227
+
228
+ # 6.1 Calibrated performance with guaranteed textual or risk consistency
229
+
230
+ Next, we examine the outcomes of the calibration process. Since the obtained risk is guaranteed to be valid (i.e., $\leq \delta$ at least $9 5 \%$ of the time), we focus here on efficiency gains per chosen $\delta$ . We refer the reader to Appendix B for empirical validation and for additional results and qualitative examples.
231
+
232
+ Table 2 presents the efficiency gains per choice of $\delta$ for each consistency objective and confidence measure. We examine larger $\delta$ values for textual consistency as this is generally a stricter requirement since the full model’s error is not considered.
233
+
234
+ Across all, the softmax confidence measure leads to the greatest decrease in number of decoder layers required. Accordingly, softmax mostly enables the highest speedup gains of up to about three times faster than running through all the model’s layers. The very lightweight early-exit classifier sometimes provides better gains than softmax, even if more decoding layers are used. Since the speedup is computed over the full generated output, we see more gains on the longer outputs of summarization and translation where the decoding takes most of the time, compared to the short QA outputs where the whole decoding time is not much longer than the encoding time.
235
+
236
+ These encouraging efficiency gains are enabled even with the rigorous performance guarantees that are sometimes conservative (e.g., Eq. (11)). We note that relaxing these constraints, or tightening the confidence intervals (e.g., with larger calibration sets), can further improve the empirical gains.
237
+
238
+ The softmax operation over the full output vocabulary is FLOPs heavy (though, this compute can potentially be paralleled), sometime leading to increased total FLOPs, even with fewer used layers. The state-based and early-exit classifier measures require minimal FLOPs and provide a good alternative with compelling efficiency gains, if total (parallelizable, or not) FLOPs is of concern.
239
+
240
+ # 6.2 Example output: effectively distributing the model’s capacity across timesteps
241
+
242
+ Figure 4 presents two CALM summary generations for an article from the CNN/DM dataset, compared to the output of the full model (See Figure B.5 in the Appendix for examples from the other tasks) . Y (2) y uses a lower confidence threshold for early exiting compared to Y (1)early . The colors, depicting the number of decoder layers used per output token, illustrate how CALM obtains the
243
+
244
+ <table><tr><td>test</td><td colspan="5">SouthAfrica-bGntotiatig84tiilackCapscdfrstCufiiElit&#x27;sutiatei Eliot,6,adotpadinteaialcketfor14montsenedinisindicaiofrteacigrandplaedunderdon McCullum.New Zealand play the winner of the semi-final between Australia or India.</td></tr><tr><td>Yfull:</td><td colspan="5">GrantElititZaadrougoteordCupfal.6yedaiSouthAutaturaldKltwil surely never playanotherinningslike his 84.New Zealandwilltake oneither Australiaor India in the finalon Sunday.</td></tr><tr><td>Y): early</td><td colspan="5">_Grant_Eliott_hit_a_six_to_put_New_Zealand_through__to__the_World_Cup_final_._Elliott tt_was__born_in_South__Africa_but_ a_naturalised_Kiwi_ The_36-year-old_will_surely_never__play_another_innings_like_his_unbeaten_84_ New_Zealand_will_now__take_on_either_Australia_or__India_in_the_final_on_Sunday_.&lt;EOS&gt;</td></tr><tr><td>Y(2) early ‘</td><td colspan="5">Grant_Ellott_hit_84_in_the_Black_Caps_chase__New_Zealand_reached_the_World_Cup_final._lliott tt_was__born__in_So uthAfrica_butanaturalised_KiwiEliowillsurelynevepayanotheinninglikehisunbeate84&gt;</td></tr><tr><td rowspan="2">y(1) Yearly</td><td colspan="5">D(Yearly,Yfull)</td><td rowspan="2"></td></tr><tr><td colspan="2">0.02</td><td>Rearty-Rfull</td><td>Average layers</td><td>Speedup</td></tr><tr><td colspan="2">Y(2) early</td><td>0.01 -0.3</td><td>2.1 1.9</td><td>X 2.9 X3.6</td><td>Exit layer-colormapping:12345678 D and R are computed with ROUGE-L</td><td></td></tr></table>
245
+
246
+ Figure 4: CALM accelerates the generation by early exiting when possible, and selectively using the full decoder’s capacity only forsoftmax-based confidence measure. $Y _ { \mathrm { e a r l y } } ^ { ( 1 ) }$ Y (2) kenand onstrated here on a CNN/DM example withuse different confidence thresholds for early exiting. Bellow the text, we report the measured textual and risk consistency of each of the two outputs, along with efficiency gains. The colors represent the number of decoding layers used for each token—light green shades indicate less than half of the total layers.
247
+
248
+ efficiency gains. Only a few selected tokens use the full capacity of the model (colored in red), while for most tokens the model exits after one or few decoding layers (colored in green).
249
+
250
+ The example in Figure 4 also demonstrates one difference between the two types of consistency constraints, given a reference output $Z _ { \mathrm { t e s t } }$ . Textual consistency $D ( Y _ { \mathrm { e a r l y } } , Y _ { \mathrm { f u l l } } )$ generally (though, not always) degrades (i.e., increases) when decreasing the confidence threshold as the outputs tend to more significantly diverge from $Y _ { \mathrm { f u l l } }$ . The trend of risk consistency, however, depends also on the reference output $Z _ { \mathrm { t e s t } }$ . If $Y _ { \mathrm { f u l l } } \approx Z _ { \mathrm { t e s t } }$ then the two constraints are nearly the same. In this example, they are sufficiently different that Y (2)early obtained better (lower) risk even though the textual distance from $Y _ { \mathrm { f u l l } }$ is higher. On the one hand, given the availability of reference outputs for calibration, this suggests that for an imperfect model, risk consistency could lead to more aggressive early-exiting while maintaining the quality of generations. On the other hand, since the Relu in Eq. (11) doesn’t reward negative risk differences, the benefits might not fully materialize. Overall, the two constraints provide different alternatives for the user to choose from depending on the availability of reference outputs, the performance of the full model, and the exact desired performance guarantees.
251
+
252
+ # 7 Conclusion
253
+
254
+ We present confident adaptive language modeling (CALM) for dynamically allocating different amounts of compute per generated token, following explicitly defined tolerance levels on the full generation output. This paper covers both modeling solutions and analyses towards this goal, as well as a theoretically-grounded framework for provably controlling the quality of the full output to meet the user-specified tolerance levels. We investigate the effects of local early exiting during decoding on the final output, leading us to propose a decaying function over the initial threshold that enables finer control over the performance-efficiency tradeoffs without inflating the search space. We also study different solutions for addressing missing computations of early-exited tokens that are dependent upon for future tokens. Overall, our complete adaptive compute framework for LMs requires minimal modifications to the underlying model and enables efficiency gains while satisfying rigorous quality guarantees for the output. Also, our oracle experiments and runtime analysis demonstrates the full potential of this framework and leave room for future research to further improve the efficiency in a controllable way.
255
+
256
+ # Acknowledgements
257
+
258
+ We thank Ionel Gog for significantly improving the implementation after submission. We also thank Anselm Levskaya, Hyung Won Chung, Seungyeon Kim, Tao Wang, Paul Barham, and Michael Isard for great discussions and code suggestions. We thank Orhan Firat, Carlos Riquelme, Aditya Menon, Zhifeng Chen, Sanjiv Kumar, and Jeff Dean for helpful discussions and feedback on the project.
259
+
260
+ # References
261
+
262
+ [1] Anastasios N. Angelopoulos and Stephen Bates. A gentle introduction to conformal prediction and distribution-free uncertainty quantification. 2021. doi: 10.48550/ARXIV.2107.07511. URL https://arxiv.org/abs/2107.07511. [2] Anastasios Nikolas Angelopoulos and Stephen Bates. A gentle introduction to conformal prediction and distribution-free uncertainty quantification, 2021. URL https://arxiv. org/abs/2107.07511.
263
+ [3] Anastasios Nikolas Angelopoulos, Stephen Bates, Emmanuel J. Candès, Michael I. Jordan, and Lihua Lei. Learn then test: Calibrating predictive algorithms to achieve risk control. ArXiv preprint: 2110.01052, 2021.
264
+ [4] Anastasios Nikolas Angelopoulos, Amit Kohli, Stephen Bates, Michael I. Jordan, Jitendra Malik, Thayer Alshaabi, Srigokul Upadhyayula, and Yaniv Romano. Image-to-image regression with distribution-free uncertainty quantification and applications in imaging. ArXiv, abs/2202.05265, 2022.
265
+ [5] Vamsi Aribandi, Yi Tay, Tal Schuster, Jinfeng Rao, Huaixiu Steven Zheng, Sanket Vaibhav Mehta, Honglei Zhuang, Vinh Q. Tran, Dara Bahri, Jianmo Ni, Jai Gupta, Kai Hui, Sebastian Ruder, and Donald Metzler. Ext5: Towards extreme multi-task scaling for transfer learning. In International Conference on Learning Representations, 2022. URL https://openreview. net/forum?id $\equiv$ Vzh1BFUCiIX.
266
+ [6] Haoli Bai, Wei Zhang, Lu Hou, Lifeng Shang, Jing Jin, Xin Jiang, Qun Liu, Michael Lyu, and Irwin King. Binarybert: Pushing the limit of bert quantization. arXiv preprint arXiv:2012.15701, 2020.
267
+ [7] Yu Bai, Song Mei, Haiquan Wang, Yingbo Zhou, and Caiming Xiong. Efficient and differentiable conformal prediction with general function classes. ArXiv, abs/2202.11091, 2022. [8] Aaron Baier-Reinio and Hans De Sterck. N-ode transformer: A depth-adaptive variant of the transformer using neural ordinary differential equations. ArXiv, abs/2010.11358, 2020. [9] Ankur Bapna, Naveen Arivazhagan, and Orhan Firat. Controlling computation versus quality for neural sequence models. 2020. doi: 10.48550/ARXIV.2002.07106. URL https://arxiv. org/abs/2002.07106.
268
+ [10] Stephen Bates, Anastasios Nikolas Angelopoulos, Lihua Lei, Jitendra Malik, and Michael I. Jordan. Distribution free, risk controlling prediction sets. ArXiv preprint: 2101.02703, 2020.
269
+ [11] Peter Bauer. Multiple testing in clinical trials. Statistics in medicine, 10 6:871–89; discussion 889–90, 1991.
270
+ [12] Vidmantas Bentkus. On hoeffding’s inequalities. Annals of Probability, 32:1650–1673, 2004.
271
+ [13] Ondˇrej Bojar, Rajen Chatterjee, Christian Federmann, Barry Haddow, Matthias Huck, Chris Hokamp, Philipp Koehn, Varvara Logacheva, Christof Monz, Matteo Negri, Matt Post, Carolina Scarton, Lucia Specia, and Marco Turchi. Findings of the 2015 workshop on statistical machine translation. In Proceedings of the Tenth Workshop on Statistical Machine Translation, pages 1–46, Lisbon, Portugal, September 2015. Association for Computational Linguistics. doi: 10.18653/v1/W15-3001. URL https://aclanthology.org/W15-3001.
272
+ [14] James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/google/jax.
273
+ [15] 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,
274
+
275
+ Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 1877–1901. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/ file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
276
+
277
+ [16] Berkant Barla Cambazoglu, Hugo Zaragoza, Olivier Chapelle, Jiang Chen, Ciya Liao, Zhaohui Zheng, and Jon Degenhardt. Early exit optimizations for additive machine learned ranking systems. In WSDM ’10, 2010.
278
+
279
+ [17] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. Palm: Scaling language modeling with pathways. 2022.
280
+
281
+ [18] Mostafa Dehghani, Stephan Gouws, Oriol Vinyals, Jakob Uszkoreit, and Lukasz Kaiser. Universal transformers. In International Conference on Learning Representations (ICLR), 2019.
282
+
283
+ [19] Mostafa Dehghani, Yi Tay, Anurag Arnab, Lucas Beyer, and Ashish Vaswani. The efficiency misnomer. In International Conference on Learning Representations, 2022. URL https: //openreview.net/forum?id $=$ iulEMLYh1uR.
284
+
285
+ [20] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https://aclanthology.org/N19-1423.
286
+
287
+ [21] Neil Dey, Jing Ding, Jack G. Ferrell, Carolina Kapper, Maxwell Lovig, Emiliano Planchon, and Jonathan P Williams. Conformal prediction for text infilling and part-of-speech prediction. ArXiv, abs/2111.02592, 2021.
288
+
289
+ [22] Nan Du, Yanping Huang, Andrew M. Dai, Simon Tong, Dmitry Lepikhin, Yuanzhong Xu, Maxim Krikun, Yanqi Zhou, Adams Wei Yu, Orhan Firat, Barret Zoph, Liam Fedus, Maarten Bosma, Zongwei Zhou, Tao Wang, Yu Emma Wang, Kellie Webster, Marie Pellat, Kevin Robinson, Kathy Meier-Hellstern, Toju Duke, Lucas Dixon, Kun Zhang, Quoc V Le, Yonghui Wu, Zhifeng Chen, and Claire Cui. Glam: Efficient scaling of language models with mixtureof-experts. 2021.
290
+
291
+ [23] Maha Elbayad, Jiatao Gu, Edouard Grave, and Michael Auli. Depth-adaptive transformer. In International Conference on Learning Representations, 2020. URL https://openreview. net/forum?id $\equiv$ SJg7KhVKPH.
292
+
293
+ [24] Angela Fan, Edouard Grave, and Armand Joulin. Reducing transformer depth on demand with structured dropout. arXiv preprint arXiv:1909.11556, 2019.
294
+
295
+ [25] Michael Figurnov, Artem Sobolev, and Dmitry P. Vetrov. Probabilistic adaptive computation time. ArXiv, abs/1712.00386, 2017.
296
+
297
+ [26] Adam Fisch, Tal Schuster, Tommi Jaakkola, and Regina Barzilay. Efficient conformal prediction via cascaded inference with expanded admission. In International Conference on Learning Representations (ICLR), 2021.
298
+
299
+ [27] Adam Fisch, Tal Schuster, T. Jaakkola, and Regina Barzilay. Conformal prediction sets with limited false positives. ArXiv, abs/2202.07650, 2022.
300
+
301
+ [28] Mor Geva, Avi Caciularu, Kevin Ro Wang, and Yoav Goldberg. Transformer feed-forward layers build predictions by promoting concepts in the vocabulary space. 2022.
302
+
303
+ [29] Alex Graves. Adaptive computation time for recurrent neural networks. 2016.
304
+
305
+ [30] Caglar Gulcehre, Orhan Firat, Kelvin Xu, Kyunghyun Cho, and Yoshua Bengio. On integrating a language model into neural machine translation. Computer Speech & Language, 45:137– 148, 2017. ISSN 0885-2308. doi: https://doi.org/10.1016/j.csl.2017.01.014. URL https: //www.sciencedirect.com/science/article/pii/S0885230816301395.
306
+
307
+ [31] Karl Moritz Hermann, Tomas Kocisky, Edward Grefenstette, Lasse Espeholt, Will Kay, Mustafa Suleyman, and Phil Blunsom. Teaching machines to read and comprehend. In C. Cortes, N. Lawrence, D. Lee, M. Sugiyama, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 28. Curran Associates, Inc., 2015. URL https://proceedings.neurips.cc/paper/2015/file/ afdec7005cc9f14302cd0474fd0f3c96-Paper.pdf.
308
+
309
+ [32] Geoffrey E. Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. ArXiv, abs/1503.02531, 2015.
310
+
311
+ [33] Wassily Hoeffding. Probability inequalities for sums of bounded random variables. Journal of the American Statistical Association, 58:13–30, 1963.
312
+
313
+ [34] Lu Hou, Zhiqi Huang, Lifeng Shang, Xin Jiang, Xiao Chen, and Qun Liu. Dynabert: Dynamic bert with adaptive width and depth. Advances in Neural Information Processing Systems, 33: 9782–9793, 2020.
314
+
315
+ [35] Yacine Jernite, Edouard Grave, Armand Joulin, and Tomas Mikolov. Variable computation in recurrent neural networks. arXiv preprint arXiv:1611.06188, 2016.
316
+
317
+ [36] Xiaoqi Jiao, Yichun Yin, Lifeng Shang, Xin Jiang, Xiao Chen, Linlin Li, Fang Wang, and Qun Liu. Tinybert: Distilling bert for natural language understanding. arXiv preprint arXiv:1909.10351, 2019.
318
+
319
+ [37] Jungo Kasai, Nikolaos Pappas, Hao Peng, James Cross, and Noah Smith. Deep encoder, shallow decoder: Reevaluating non-autoregressive machine translation. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum? id $\equiv$ KpfasTaLUpq.
320
+
321
+ [38] Gyuwan Kim and Kyunghyun Cho. Length-adaptive transformer: Train once with length drop, use anytime with search. 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 6501–6511, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.508. URL https://aclanthology.org/2021.acl-long.508.
322
+
323
+ [39] Sneha Kudugunta, Yanping Huang, Ankur Bapna, Maxim Krikun, Dmitry Lepikhin, MinhThang Luong, and Orhan Firat. Beyond distillation: Task-level mixture-of-experts for efficient inference. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 3577–3599, Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.findings-emnlp.304. URL https://aclanthology. org/2021.findings-emnlp.304.
324
+
325
+ [40] Imad Lakim, Ebtesam Almazrouei, Ibrahim Abualhaol, Merouane Debbah, and Julien Launay. A holistic assessment of the carbon footprint of noor, a very large Arabic language model. In Proceedings of BigScience Episode #5 – Workshop on Challenges & Perspectives in Creating Large Language Models, pages 84–94, virtual+Dublin, May 2022. Association for Computational Linguistics. URL https://aclanthology.org/2022.bigscience-1.8.
326
+
327
+ [41] Tao Lei. When attention meets fast recurrence: Training language models with reduced compute. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 7633–7648, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.emnlp-main.602. URL https://aclanthology.org/2021.emnlp-main.602.
328
+
329
+ [42] Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, and Zhifeng Chen. {GS}hard: Scaling giant models with conditional computation and automatic sharding. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ qrwe7XHTmYb.
330
+
331
+ [43] Lei Li, Yankai Lin, Deli Chen, Shuhuai Ren, Peng Li, Jie Zhou, and Xu Sun. Cascadebert: Accelerating inference of pre-trained language models via calibrated complete models cascade. arXiv preprint arXiv:2012.14682, 2020.
332
+
333
+ [44] Weijie Liu, Peng Zhou, Zhe Zhao, Zhiruo Wang, Haotang Deng, and Qi Ju. Fastbert: a self-distilling bert with adaptive inference time. arXiv preprint arXiv:2004.02178, 2020.
334
+
335
+ [45] Xiangyang Liu, Tianxiang Sun, Junliang He, Lingling Wu, Xinyu Zhang, Hao Jiang, Zhao Cao, Xuanjing Huang, and Xipeng Qiu. Towards efficient nlp: A standard evaluation and a strong baseline. arXiv preprint arXiv:2110.07038, 2021.
336
+
337
+ [46] Yijin Liu, Fandong Meng, Jie Zhou, Yufeng Chen, and Jinan Xu. Faster depth-adaptive transformers. In AAAI, 2021.
338
+
339
+ [47] Zhuang Liu, Zhiqiu Xu, Hung-Ju Wang, Trevor Darrell, and Evan Shelhamer. Anytime dense prediction with confidence adaptivity. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\equiv$ kNKFOXleuC.
340
+
341
+ [48] Charles Lu and Jayasheree Kalpathy-Cramer. Distribution-free federated learning with conformal predictions. ArXiv, abs/2110.07661, 2021.
342
+
343
+ [49] Nafise Sadat Moosavi, Angela Fan, Vered Shwartz, Goran Glavaš, Shafiq Joty, Alex Wang, and Thomas Wolf, editors. Proceedings of SustaiNLP: Workshop on Simple and Efficient Natural Language Processing, Online, November 2020. Association for Computational Linguistics. URL https://aclanthology.org/2020.sustainlp-1.0.
344
+
345
+ [50] 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, July 2002. Association for Computational Linguistics. doi: 10.3115/1073083.1073135. URL https: //aclanthology.org/P02-1040.
346
+
347
+ [51] Matthew E. Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer. Deep contextualized word representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 2227–2237, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. doi: 10.18653/v1/N18-1202. URL https://aclanthology.org/N18-1202.
348
+
349
+ [52] Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.
350
+
351
+ [53] 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. 2019.
352
+
353
+ [54] Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pages 2383–2392, Austin, Texas, November 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1264. URL https://aclanthology.org/D16-1264.
354
+
355
+ [55] Adam Roberts, Hyung Won Chung, Anselm Levskaya, Gaurav Mishra, James Bradbury, Daniel Andor, Sharan Narang, Brian Lester, Colin Gaffney, Afroz Mohiuddin, Curtis Hawthorne, Aitor Lewkowycz, Alex Salcianu, Marc van Zee, Jacob Austin, Sebastian Goodman, Livio Baldini Soares, Haitang Hu, Sasha Tsvyashchenko, Aakanksha Chowdhery, Jasmijn Bastings, Jannis Bulian, Xavier Garcia, Jianmo Ni, Andrew Chen, Kathleen Kenealy, Jonathan H. Clark, Stephan Lee, Dan Garrette, James Lee-Thorp, Colin Raffel, Noam Shazeer, Marvin Ritter, Maarten Bosma, Alexandre Passos, Jeremy Maitin-Shepard, Noah Fiedel, Mark Omernick, Brennan Saeta, Ryan Sepassi, Alexander Spiridonov, Joshua Newlan, and Andrea Gesmundo. Scaling up models and data with $\pm 5 \mathrm { x }$ and seqio. arXiv preprint arXiv:2203.17189, 2022. URL https://arxiv.org/abs/2203.17189.
356
+
357
+ [56] 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.
358
+
359
+ [57] Tal Schuster, Adam Fisch, Tommi Jaakkola, and Regina Barzilay. Consistent accelerated inference via confident adaptive transformers. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 4962–4979, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021. emnlp-main.406. URL https://aclanthology.org/2021.emnlp-main.406.
360
+
361
+ [58] Tal Schuster, Ashwin Kalyan, Alex Polozov, and Adam Tauman Kalai. Programming puzzles. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 1), 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ fe_hCc4RBrg.
362
+
363
+ [59] Roy Schwartz, Jesse Dodge, Noah A. Smith, and Oren Etzioni. Green ai. Communications of the ACM, 63(12):54–63, Nov 2020. ISSN 1557-7317. doi: 10.1145/3381831. URL http://dx.doi.org/10.1145/3381831.
364
+
365
+ [60] Roy Schwartz, Gabriel Stanovsky, Swabha Swayamdipta, Jesse Dodge, and Noah A. Smith. The right tool for the job: Matching model and instance complexities. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 6640–6651, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.593. URL https://aclanthology.org/2020.acl-main.593.
366
+
367
+ [61] Thibault Sellam, Dipanjan Das, and Ankur Parikh. BLEURT: Learning robust metrics for text generation. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 7881–7892, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.704. URL https://aclanthology.org/2020. acl-main.704.
368
+
369
+ [62] Glenn Shafer and Vladimir Vovk. A tutorial on conformal prediction. Journal of Machine Learning Research (JMLR), 9:371–421, June 2008.
370
+
371
+ [63] Or Sharir, Barak Peleg, and Yoav Shoham. The cost of training nlp models: A concise overview. arXiv preprint: arXiv 2006.06138, 2020.
372
+
373
+ [64] Noam Shazeer and Mitchell Stern. Adafactor: Adaptive learning rates with sublinear memory cost. 2018. doi: 10.48550/ARXIV.1804.04235. URL https://arxiv.org/abs/1804. 04235.
374
+
375
+ [65] Sheng Shen, Zhen Dong, Jiayu Ye, Linjian Ma, Zhewei Yao, Amir Gholami, Michael W Mahoney, and Kurt Keutzer. Q-bert: Hessian based ultra low precision quantization of bert. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 8815–8821, 2020.
376
+
377
+ [66] Antoine Simoulin and Benoit Crabbé. How many layers and why? An analysis of the model depth in transformers. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing: Student Research Workshop, pages 221–228, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-srw.23. URL https://aclanthology.org/2021.acl-srw.23.
378
+
379
+ [67] Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R. Brown, Adam Santoro, Aditya Gupta, and Garriga-Alonso et al. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. 2022. doi: 10.48550/ARXIV.2206.04615. URL https://arxiv.org/abs/2206.04615.
380
+
381
+ [68] Asa Cooper Stickland and Iain Murray. Bert and pals: Projected attention layers for efficient adaptation in multi-task learning. In International Conference on Machine Learning, pages 5986–5995. PMLR, 2019.
382
+
383
+ [69] Siqi Sun, Yu Cheng, Zhe Gan, and Jingjing Liu. Patient knowledge distillation for bert model compression. arXiv preprint arXiv:1908.09355, 2019.
384
+
385
+ [70] Tianxiang Sun, Xiangyang Liu, Wei Zhu, Zhichao Geng, Lingling Wu, Yilong He, Yuan Ni, Guotong Xie, Xuanjing Huang, and Xipeng Qiu. A simple hash-based early exiting approach for language understanding and generation. In Findings of the Association for Computational Linguistics: ACL 2022, pages 2409–2421, Dublin, Ireland, May 2022. Association for Computational Linguistics. URL https://aclanthology.org/2022.findings-acl.189.
386
+
387
+ [71] Zhiqing Sun, Hongkun Yu, Xiaodan Song, Renjie Liu, Yiming Yang, and Denny Zhou. Mobilebert: a compact task-agnostic bert for resource-limited devices. arXiv preprint arXiv:2004.02984, 2020.
388
+
389
+ [72] Yi Tay, Mostafa Dehghani, Dara Bahri, and Donald Metzler. Efficient transformers: A survey. ACM Computing Surveys (CSUR), 2022.
390
+
391
+ [73] Yi Tay, Mostafa Dehghani, Vinh Q Tran, Xavier Garcia, Dara Bahri, Tal Schuster, Huaixiu Steven Zheng, Neil Houlsby, and Donald Metzler. Unifying language learning paradigms. arXiv preprint arXiv:2205.05131, 2022.
392
+
393
+ [74] Surat Teerapittayanon, Bradley McDanel, and H. T. Kung. Branchynet: Fast inference via early exiting from deep neural networks. 2016 23rd International Conference on Pattern Recognition (ICPR), pages 2464–2469, 2016.
394
+
395
+ [75] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam M. Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, Yaguang Li, Hongrae Lee, Huaixiu Zheng, Amin Ghafouri, Marcelo Menegali, Yanping Huang, Maxim Krikun, Dmitry Lepikhin, James Qin, Dehao Chen, Yuanzhong Xu, Zhifeng Chen, Adam Roberts, Maarten Bosma, Yanqi Zhou, Chung-Ching Chang, I. A. Krivokon, Willard James Rusch, Marc Pickett, Kathleen S. Meier-Hellstern, Meredith Ringel Morris, Tulsee Doshi, Renelito Delos Santos, Toju Duke, Johnny Hartz Søraker, Ben Zevenbergen, Vinodkumar Prabhakaran, Mark Diaz, Ben Hutchinson, Kristen Olson, Alejandra Molina, Erin Hoffman-John, Josh Lee, Lora Aroyo, Ravindran Rajakumar, Alena Butryna, Matthew Lamm, V. O. Kuzmina, Joseph Fenton, Aaron Cohen, Rachel Bernstein, Ray Kurzweil, Blaise Aguera-Arcas, Claire Cui, Marian Croak, Ed Chi, and Quoc Le. Lamda: Language models for dialog applications. ArXiv, abs/2201.08239, 2022.
396
+
397
+ [76] 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 (NeurIPS), 2017.
398
+
399
+ [77] Vladimir Vovk, Alex Gammerman, and Glenn Shafer. Algorithmic Learning in a Random World. Springer-Verlag, Berlin, Heidelberg, 2005.
400
+
401
+ [78] Wenhui Wang, Furu Wei, Li Dong, Hangbo Bao, Nan Yang, and Ming Zhou. Minilm: Deep self-attention distillation for task-agnostic compression of pre-trained transformers. Advances in Neural Information Processing Systems, 33:5776–5788, 2020.
402
+
403
+ [79] Xin Wang, Fisher Yu, Zi-Yi Dou, and Joseph Gonzalez. Skipnet: Learning dynamic routing in convolutional networks. ArXiv, abs/1711.09485, 2018.
404
+
405
+ [80] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. 2022.
406
+
407
+ [81] John Wieting, Taylor Berg-Kirkpatrick, Kevin Gimpel, and Graham Neubig. Beyond BLEU:training neural machine translation with semantic similarity. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 4344–4355, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1427. URL https://aclanthology.org/P19-1427.
408
+ [82] Yuhuai Wu, Markus Norman Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. In International Conference on Learning Representations, 2022. URL https: //openreview.net/forum?id $= ^ { \prime }$ TrjbxzRcnf-.
409
+ [83] Ji Xin, Raphael Tang, Jaejun Lee, Yaoliang Yu, and Jimmy Lin. Deebert: Dynamic early exiting for accelerating bert inference. arXiv preprint arXiv:2004.12993, 2020.
410
+ [84] Ji Xin, Raphael Tang, Yaoliang Yu, and Jimmy Lin. BERxiT: Early exiting for BERT with better fine-tuning and extension to regression. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pages 91–104, Online, April 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.eacl-main.8. URL https://aclanthology.org/2021.eacl-main.8.
411
+ [85] Jingjing Xu, Wangchunshu Zhou, Zhiyi Fu, Hao Zhou, and Lei Li. A survey on green deep learning. ArXiv, abs/2111.05193, 2021.
412
+ [86] Linting Xue, Aditya Barua, Noah Constant, Rami Al-Rfou, Sharan Narang, Mihir Kale, Adam Roberts, and Colin Raffel. Byt5: Towards a token-free future with pre-trained byte-to-byte models. 2021. doi: 10.48550/ARXIV.2105.13626. URL https://arxiv.org/abs/ 2105.13626.
413
+ [87] Hongxu Yin, Arash Vahdat, José Manuel Álvarez, Arun Mallya, Jan Kautz, and Pavlo Molchanov. Adavit: Adaptive tokens for efficient vision transformer. ArXiv, abs/2112.07658, 2021.
414
+ [88] Margaux Zaffran, Aymeric Dieuleveut, Olivier F’eron, Yannig Goude, and Julie Josse. Adaptive conformal predictions for time series. ArXiv, abs/2202.07282, 2022.
415
+ [89] 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. Opt: Open pre-trained transformer language models. 2022.
416
+ [90] Wangchunshu Zhou, Canwen Xu, Tao Ge, Julian McAuley, Ke Xu, and Furu Wei. Bert loses patience: Fast and robust inference with early exit. Advances in Neural Information Processing Systems, 33:18330–18341, 2020.
417
+ [91] Yanqi Zhou, Tao Lei, Hanxiao Liu, Nan Du, Yanping Huang, Vincent Zhao, Andrew Dai, Zhifeng Chen, Quoc Le, and James Laudon. Mixture-of-experts with expert choice routing. 2022. doi: 10.48550/ARXIV.2202.09368. URL https://arxiv.org/abs/2202.09368.
418
+ [92] Wei Zhu. Leebert: Learned early exit for bert with cross-level optimization. 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 2968–2980, 2021.
md/dev/uRTW_PgXvc7/uRTW_PgXvc7.md ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ST-Adapter: Parameter-Efficient Image-to-Video Transfer Learning
2
+
3
+ Junting $\mathbf { P a n } ^ { 1 * }$ , Ziyi $\mathbf { L i n ^ { 1 * } }$ , Xiatian $\mathbf { Z } \mathbf { h } \mathbf { u } ^ { 2 }$ , Jing Shao1, Hongsheng Li1,3 1Multimedia Laboratory, The Chinese University of Hong Kong 2Surrey Institute for People-Centred Artificial Intelligence, CVSSP, University of Surrey 3Centre for Perceptual and Interactive Intelligence Limited
4
+
5
+ # Abstract
6
+
7
+ Capitalizing on large pre-trained models for various downstream tasks of interest have recently emerged with promising performance. Due to the ever-growing model size, the standard full fine-tuning based task adaptation strategy becomes prohibitively costly in terms of model training and storage. This has led to a new research direction in parameter-efficient transfer learning. However, existing attempts typically focus on downstream tasks from the same modality (e.g., image understanding) of the pre-trained model. This creates a limit because in some specific modalities, (e.g., video understanding) such a strong pre-trained model with sufficient knowledge is less or not available. In this work, we investigate such a novel cross-modality transfer learning setting, namely parameter-efficient image-to-video transfer learning. To solve this problem, we propose a new SpatioTemporal Adapter (ST-Adapter) for parameter-efficient fine-tuning per video task. With a built-in spatio-temporal reasoning capability in a compact design, STAdapter enables a pre-trained image model without temporal knowledge to reason about dynamic video content at a small $( \sim 8 \% )$ per-task parameter cost, requiring approximately 20 times fewer updated parameters compared to previous work. Extensive experiments on video action recognition tasks show that our ST-Adapter can match or even outperform the strong full fine-tuning strategy and state-of-theart video models, whilst enjoying the advantage of parameter efficiency. Code and model are available at https://github.com/linziyi96/st-adapter
8
+
9
+ # 1 Introduction
10
+
11
+ In the NLP field, almost all the state-of-arts across a wide range of downstream tasks have been achieved by adapting from large pretrained models (a.k.a. foundation models [7]) such as BERT [15] and GPT [54, 8]. The de facto standard approach to adapting a pretrained model to down-stream tasks is fine-tuning either fully or partially (e.g., linear probing by training the newly added multi-layer perceptron layers on the top alone), subject to the condition of adopting a similar network architecture as the pretrained model. Nonetheless, given increasingly larger whilst ever stronger foundation models (e.g., GPT-3 with 175B parameters), fully fine-tuning the whole model for every single downstream task would become prohibitively expensive and infeasible in terms of training cost and model storage. This could significantly restrict their deployment and usability in real-world applications. In this context, a series of NLP works has been introduced towards efficient transfer learning with better trade-offs between parameter and accuracy [25, 24, 39, 36].
12
+
13
+ This trend has recently motivated the computer vision community. For example, the CLIP model [55], trained with 400 million web image-text pairs, achieves promising performances on a variety of image recognition and generation tasks. In the video domain, with significantly more computational cost and resources, Xu et al. [79] trained a video variant of CLIP but excelled on a smaller number of downstream video tasks. This is partly attributed to two orders of magnitude more minor training data and limited availability of computing resources, as large video data is notoriously more difficult to collect, manage, and process than image data. Under these restrictions, large pre-trained image models are arguably still favorable in the selection of model initialization for video tasks.
14
+
15
+ ![](images/d9bfd7f9be6df8252447925e6b8f95f1baeb22552d2216608c2bc07b094e3b94.jpg)
16
+ Figure 1: Image-to-video transfer learning strategies. (a) The state-of-the-art methods for adapting a pre-trained image model (e.g., ViT [16] in this example) to video tasks (e.g., action recognition) usually adopt the paradigm of first designing a temporal learning module and then fine-tuning the whole network fully [2, 6, 9]. This is parameter-inefficient since a specific instance of such a large model is resulted for each downstream task. In contrast, (b) we propose to only train a lightweight Spatio-Temporal Adapter with much fewer parameters for each individual downstream task at a significantly smaller computational cost. Surprisingly, our method can match or even surpasses the full fine-tuning based methods (including prior art video models in terms of accuracy), whist enjoying higher parameter efficiency and cheaper training cost.
17
+
18
+ In this work, we investigate a novel, critical problem of efficiently adapting large pre-trained image models for video downstream tasks, with a focus on the widely influential action recognition task. Considering that training video models is drastically more expensive in both computing resource and time than image models [19], this problem becomes particularly more useful and valuable in practice. On the other hand, it is also more challenging and non-trivial due to the extra necessity of overcoming the big gap between image and video in transfer learning. Especially, pre-trained image models lack the ability to infer temporal structured information, which however is critical in video understanding. In fact, the key design with state-of-the-art video models [10, 41, 6, 9] is usually about learning the temporal dimension based on contemporary image models. Although model initialization is still important, they largely go beyond the fine-tuning strategy, as architectural modification is often imposed in addition to full model training/fine-tuning per downstream task.
19
+
20
+ Given that this is a new problem, we first conduct a comprehensive benchmark using both various fine-tuning methods for image-to-video transfer learning and state-of-the-art video models [6, 9]. Regarding the pretrained image model, we select two Vision Transformer (ViT) [16] models, with one from CLIP pre-training [55] and the other pre-trained on ImageNet-21K [14]. ViT is representative in terms of network architecture, pre-training algorithm, and training data scale. Crucially, we further propose an efficient yet effective Space-Time Adapter (ST-Adapter), capable of extracting and leveraging the pre-trained knowledge of a large image model to achieve superior video understanding at a small parameter cost. Specifically, ST-Adapter is formulated based on a novel parameter-efficient bottleneck with a sequence of operations including feature dimension reduction, spatial-temporal modeling, and feature dimension recovery. It is easy to implement and scalable for deployment since all the primitive steps are realized with standard operators (e.g., fully-connected layer, depth-wise 3D convolution). With such a lightweight design, our bottleneck can be cheaply integrated throughout the base network for enabling stronger layer-wise spatio-temporal learning. As a result, our model can be more rapidly optimized using fewer training epochs for significant convergence advantage.
21
+
22
+ We summarize the contributions as follows. (1) We investigate a new problem of parameterefficient image-to-video transfer learning. Our motivation is to advocate the usability and deployment of increasingly larger whilst ever more powerful pre-trained image models in benefiting more challenging video understanding tasks. (2) We establish a benchmark for action recognition tasks by comprehensively experimenting with a variety of fine-tuning strategies and several state-of-the-art video understanding models. (3) We introduce a novel parameter-efficient Spatio-Temporal Adapter (ST-Adapter) for more effectively capitalizing a large pre-trained image model in video understanding. By grounding all the primitives on standard operators, ST-Adaptor is easy to implement and friendly to deployment. (4) Extensive experiments on action recognition datasets show that our ST-Adapter outperforms not only existing parameter-efficient alternatives and the full fine-tuning strategy, but also state-of-the-art video methods with the same network architecture and model initialization.
23
+
24
+ # 2 Related Work
25
+
26
+ Parameter-efficient transfer learning Driven by the wider application of large pre-trained language models across a diversity of downstream tasks, the topic of efficient tuning has received increasing attention in NLP. Existing efficient tuning methods fall broadly into three categories. The first category is to introduce task-specific adapters [25, 24, 51, 50]. Specifically, an adapter consists of lightweight modules inserted between layers of a pre-trained model. To be parameter-efficient, only those newly added adapter modules need to be updated during task fine-tuning, whilst all the parameters of the large pre-trained model, which takes the majority proportion of the whole solution, are frozen. The second category is prompt tuning [39, 52, 31, 62, 42]. Instead of manipulating the network architecture, these methods prepend a set of learnable tokens at the input point of the model or intermediate layers. Similarly, only these added tokens need to be optimized for each downstream task. The third category is learning weight approximation [27]. In particular, only the low-rank matrices for approximating the weights need to be updated during training.
27
+
28
+ Early works for efficient transfer learning in vision focus on parameter sharing in the context of multitask learning [83, 57, 56]. Recently, there are several works for extending the efficient tuning idea from NLP to vision tasks. CoOp [85] and CoCoOp [86] apply prefix tuning for adapting the CLIP model to various image recognition tasks. VL-Adapter [65] achieves the performance comparable to full fine-tuning on challenging vision-language tasks. Commonly, their design focuses are all restricted to the text encoder of the CLIP model. More recently, [29, 4, 84] introduce the idea of prompt learning to visual backbones. They obtained favorable results on various image recognition benchmarks. Moving a step further, in this work, we consider the more challenging adaptation problem from a pre-trained image model without temporal knowledge to video understanding tasks.
29
+
30
+ Video action recognition Action recognition in the unconstrained video has largely been dominated by deep learning methods, thanks to the availability of large video datasets, e.g., Kinetics [10–12] and Something-Something [22]. As a key component, the model architectures adopted by existing video methods has expanded from CNNs [32, 68, 19, 18, 77, 69, 72, 48, 41, 45] to Transformers [17, 40, 38, 44, 2, 6]. As temporal information is important for modeling the dynamics, a variety of motion learning techniques has been introduced [75, 30, 49]. Further, different training methods have also been explored, e.g., unsupervised learning [67, 20, 76], and video-text contrastive learning [64, 79, 78, 66]. New opportunities for stronger video models are created following the introduction of large pretrained foundation models [55, 28, 81]. For example, Wang et al. [74] equipped the CLIP with temporal modules and good performance can be achieved after the model is fully fine-tuned on video datasets. Ju et al. [31] adopted the CLIP model for video recognition tasks by learning videospecific prompts. In contrast, in this work, we explore the potential of the large pre-trained image models with the parameter-efficient adapter strategy. Importantly, despite the simplicity, we bring about more significant advantages in performance along with a new benchmark on parameter-efficient image-to-video transfer learning.
31
+
32
+ # 3 Methodology
33
+
34
+ To capitalize a large pre-trained image model for more challenging video understanding such as action recognition in a cross-modality manner, it is necessary to fill the intrinsic gap between image and video. For easier understanding, we start with an intuitive baseline based on temporal aggregation.
35
+
36
+ Temporal aggregation A straightforward baseline method of exploiting a pre-trained image model for video understanding is to temporally aggregate per-frame feature representations (e.g., average pooling). Concretely, given an input video clip $\mathbf { V } \in \mathbb { R } ^ { T \times H \times W }$ , where $T , H , W$ are the number of frames, height and width respectively. Following [16], we first split each frame into $N = H \times W / P ^ { 2 }$ patches of size $P \times P$ . Then, we flatten these patches and project them into a sequence of patch tokens $\mathbf Z _ { t } = [ \mathbf z _ { 1 } , . . . \mathbf z _ { s } , . . . , \mathbf z _ { N } ] , \mathbf z _ { s } \in \mathbb { R } ^ { d }$ where $d = 3 \times P ^ { \dot { 2 } }$ with $t = 1 , . . . , T$ . The sequence of feature vectors is then enhanced with the positional embedding by element-wise addition, along with a trainable class token concatenated. Subsequently, we feed each sequence with $N + 1$ tokens to a stack of self-attention based blocks individually. For each sequence we keep only the classification token ${ \bf z } _ { t } ^ { c l s }$ . We further perform temporal average pooling on the class tokens $\begin{array} { r } { \dot { \bf z } _ { f i n a l } = \frac { 1 } { T } \sum _ { t } { \bf z } _ { t } ^ { c l s } } \end{array}$ to yield a compact representation for the whole clip. We obtain the prediction by passing $\mathbf { z } _ { f i n a l }$ through a classifier. As the sptial information is only naively averaged over time, it is also known as Space-Only TimeSformer [6].
37
+
38
+ Spatio-temporal attention For more dedicated structural modeling in the time dimension with ViTs, a mainstream approach in the video domain is to develop various spatio-temporal attention mechanisms by further imposing temporal attention on top [6, 2, 3, 9, 82, 23]. We choose two representative video ViT models, TimeSformer [6] and XViT [9], in our performance benchmark. However, state-of-the-art video ViT models often need to fully fine-tuned per task, which is parameterinefficient, given that in this way we have to keep a separate copy of the whole fine-tuned model parameters for every single task.
39
+
40
+ # 3.1 Preliminaries
41
+
42
+ Our method is inspired by the Adapter [25] designed for parameter-efficient transfer learning in NLP. Specifically, the adapter module is composed of a down-projection linear layer followed by a non-linear activation function and an up-projection linear layer. Formally, given an input feature matrix $\mathbf { X } \in \mathbb { R } ^ { N \times d }$ at the $i$ -th layer, the feature adaptation process can be written as:
43
+
44
+ $$
45
+ \mathsf { A d a p t e r } ( \mathbf { X } ) = \mathbf { X } + f ( \mathbf { X } \mathbf { W } _ { d o w n } ) \mathbf { W } _ { u p } ,
46
+ $$
47
+
48
+ where $\mathbf { W } _ { d o w n } \in \mathbb { R } ^ { d \times r }$ refers to the down projection layer, $\mathbf { W } _ { u p } \in \mathbb { R } ^ { r \times d }$ the up-projection layer, and $f ( \cdot )$ the activation function. Note, that a residual summation is applied for preserving the information in input as required. The idea of Adapter has been remarkably successful in NLP due to several advantages: (1) High parameter efficiency across tasks since only a small number of parameters are task-specific; (2) Reaching on-par performance compared to full fine-tuning; (3) Taking significantly small training costs; (4) Avoiding the catastrophic forgetting limitation of full fine-tuning.
49
+
50
+ We aim to propagate the success of Adapter from NLP to computer vision particularly the imageto-video transfer learning problem as discussed earlier. To that end, we introduce a novel Adapter tailored specially for spatio-temporal reasoning – a key capability for video understanding which, however, existing NLP Adapter variants lack.
51
+
52
+ # 3.2 Spatio-Temporal Adapter (ST-Adapter)
53
+
54
+ Typically, an image model only considers the ability of spatial modeling. The objective of our Spatio-Temporal Adapter (ST-Adapter) is to enable a pre-trained image model to reason about spatial and temporal information of video in a parameter efficient principle. In design, we consider a couple of practically-crucial criteria: (1) Smaller parameter size: The parameter cost for each downstream task should be small – the essential criterion for parameter efficiency. (2) Development friendliness: This is critical for real-world development and deployment. In practice, it is necessary that a model can be easily implemented using the standard highly optimized deep learning toolboxes (e.g., PyTorch, TensorFlow, TensorRT, and TorchScript), without tedious per-toolbox specialization.
55
+
56
+ This also facilitates the realization of high inference efficiency across a diversity of running platforms due to the best usage of built-in software and hardware resources.
57
+
58
+ Under these considerations, we formulate the proposed ST-Adapter by sticking to commonly-adopted primitive operators alone. Starting with the above Adapter (Eq. (1)) originally developed for NLP tasks, we further introduce a spatio-temporal operator realized by a standard depth-wise 3Dconvolution layer [18] between the bottlenecks (Figure 1). In particular, our spatio-temporal operator enables layer-wise temporal inference efficiently, because it only operates in a compressed lowdimensional (e.g., 128D) feature space and the depth-wise convolution is highly efficient both in parameter and computation [26]. As a result, this yields an introduction of tiny extra $( \sim 2 \% )$ parameters and $( \sim 0 . 3 \% )$ computation. Formally, our ST-Adapter can be expressed as:
59
+
60
+ $$
61
+ \mathrm { S T - A d a p t e r ( { \mathbf { X } } ) } = { \mathbf { X } } + f \Bigl ( \mathrm { D W C o n v 3 D } ( { \mathbf { X } } { \mathbf { W } } _ { d o w n } ) \Bigr ) { \mathbf { W } } _ { u p } ,
62
+ $$
63
+
64
+ where DWConv3D denotes the depth-wise 3D-convolution for spatio-temporal reasoning we introduce. It is noteworthy that before applying DWConv3D, the down-projected feature representations will be first reshaped from $\mathbf { X } ^ { \prime } \in \mathbb { R } ^ { T \times N \times d }$ to ${ \bf X } ^ { \prime \prime } \in \mathbb { R } ^ { T \times h \times w \times d }$ (where $N = h \times w ,$ ) to have the spatial and temporal dimensions prepared for reasoning. With this highly integrated design, our ST-Adapter enjoys the same efficiency and flexibility as the NLP Adapter, while uniquely being able to conduct spatio-temporal modeling. l.
65
+
66
+ # 3.3 ST-Adapter Integration
67
+
68
+ For proper adaptation, the adapter modules are often integrated between layers of a Transformer. In NLP, a variety of integrating designs have been investigated. For example, [25] deploys two adapter modules per layer with one following the Multi-Head Self-Attention (MHSA) and the other following the Feed-Forward Networks (FFN) [25]. On the other hand, [63, 5] suggest that adding only one adapter after the FNN suffices. Similarly, our ST-Adapter can be also integrated generally at distinctive positions. Empirically, we find that a decent performance can be achieved in case a single ST-Adapter is placed before the MHSA of each transformer block (Figure 1(a) and Table 5c).
69
+
70
+ # 4 Experiments
71
+
72
+ # 4.1 Experiments Setup
73
+
74
+ Datasets For the benchmark experiments, we use two popular video action recognition datasets.
75
+
76
+ Kinetics-400 (K400): The K400 [33] dataset contains ${ \sim } 2 4 0 \mathrm { k }$ training videos and $2 0 \mathrm { k }$ validation videos labeled with 400 action categories. Most videos have a length of 10s or about 300 frames. While there is a great diversity in these videos, they are largely biased to spatial appearance [60].
77
+
78
+ Something-Something- $\cdot \nu 2$ $( S S \nu 2 )$ : The SSv2 [22] dataset consists of 220,487 videos covering 174 human actions. The video length ranges from 2 to 6 seconds. In contrast to K400, SSv2 presents richer temporal information with much higher significance [60].
79
+
80
+ Epic-Kitchens-100 (EK100): The EK100 [13] dataset consists of 100 hours of video in egocentric perspective recording a person interacting with a variety of objects in the kitchen. Each video sample is labeled with a verb and a noun. We report top-1 verb and noun classification accuracy.
81
+
82
+ Pre-trained models In all experiments, we use the standard ViT [16] as our base backbone model. We conduct most of our experiments with the ViT-B/16 variant with 12 layers and 86M parameters, taking as input a sequence of patches at size $1 6 \times 1 6$ .
83
+
84
+ What was learned during pre-training directly decides the knowledge that can be transferred to downstream tasks, thus also the effectiveness upper bound of transfer learning methods. To this end, we benchmark the same backbone under two different pre-training strategies: pre-training with web-scale raw data that has been recently proposed by CLIP [55] (400M image-text pair) and classical supervised pre-training on annotated data from ImageNet-21K (21k classes and 14M images).
85
+
86
+ Implementation details. All details, including training and testing settings and module instantiation details, are provided in the appendix.
87
+
88
+ Competitors We provide several transfer learning approaches in our benchmark for efficient imageto-video transfer learning. Note that the parameters of the linear classifier are always updated during training for all approaches.
89
+
90
+ (1) Full Fine-tuning: Fully updating all the parameters when adapting for a specific target task.
91
+ (2) Partial Fine-tuning: Only update the last ViT layer while keeping the rest of the parameter fixed.
92
+ (3) Temporal Fine-tuning: We only tune the temporal attention modules (i.e., TA) in the $\mathrm { S A } { + } \mathrm { T A }$ architecture.
93
+ (4) Linear Probing: Freezing all the parameters except those in the linear classification layer.
94
+ (5) Adapter [25]: Adding small sub-networks between layers of a pre-trained model. During fine-tuning, we only update the newly added parameters introduced by the adapters.
95
+ (6) Prompt Tuning [29]: Prepending a sequence of learnable prompt tokens to the input visual patch tokens. During fine-tuning, only these newly added prompts are updated.
96
+ (7) Attention Pooling Head: Replacing the original temporal average pooling with a temporal attention pooling layer (similar to the one used in [9]) before the classification head.
97
+
98
+ These approaches above do not incorporate temporal modeling to the image ViT. Hence, we further consider temporally augmented ViT architectures as introduced in state-of-the-art video methods:
99
+
100
+ (a) Spatial Attention Only (SA): Space-Only TimeSformer [6].
101
+ (b) Spatial Attention $^ +$ Temporal Attention $( S A + T A )$ : The default TimeSformer [6] with divided space-time attention (Fig. 1a).
102
+ (c) Spatial Attention $^ +$ Temporal Shift $( S A + T S )$ : XViT [9].
103
+
104
+ Note that not all fine-tuning protocols are compatible with each of these video ViT variants. Take $\mathrm { S A } { + } \mathrm { T S }$ for example, the original model behavior is altered with channel shift, as a result, it is not compatible with Linear Probing that requires freezing all the parameters of the backbone.
105
+
106
+ # 4.2 Main Results and Analysis
107
+
108
+ Cross-modality fine-tuning benchmark. Table 1 presents the results of fine-tuning a ViT-B/16 pre-trained with CLIP and ImageNet-21K. All baselines are built by combining existing efficient fine-tuning methods with three state-of-the-art ViT-based action recognition models. From the results we can see that:
109
+
110
+ (i) For CLIP pre-trained model, ST-Adapter performs on par with Full Fine-tuning (82.0 vs. 81.7 for K400 and 66.3 vs. 66.1 for SSv2) while updating far less parameters (7.2M vs. 121.57M). ST-Adapter significantly outperforms all other efficient fine-tuning methods. We see that baselines like Prompt Tuning and Partial Fine-tuning can provide non-trivial gain in performance compared to Linear Probe, but are still behind our ST-Adapter.
111
+
112
+ (ii) Our ST-Adapter can generalize across different pre-training datasets and methods. We can see that CLIP pre-train models dominate over ImageNet-21K pre-train ones. These results well match the shift of paradigm in current AI research [7], where pre-training no longer needs limiting to curated data and annotations to deliver good performance on downstream tasks, but can take advantage of broader scale web raw data.
113
+
114
+ Interestingly, we observe that SSv2, a motion-centric dataset in design, also benefits from stronger appearance (image) pre-training. We think this may attribute to that raw textual description can provide a much richer description (i.e., human-object relations) of the image than curated limited categorical labels. Full fine-tuning on $\mathrm { S A } { + } \mathrm { T S }$ (XViT) performs slightly worse with CLIP pretrain than ImageNet-21k pretrain. We conjecture this is because the channel shift operation breaks the knowledge in the pre-training weights, and thus does not benefit much from stronger pre-training like CLIP.
115
+
116
+ Comparison to the state-of-the-art models. We compare ViT with ST-Adapter to other state-of-thearts methods on both K400 dataset [33] in Table 2, SSv2 dataset [22] in Table 3 and EK100 dataset [13] in Table 4. We can observe that:
117
+
118
+ (i) With the proper adaptation method, we can simply turn a large image foundation model into a good video model by only tuning a few parameters. Our results are comparable to or better than previous methods tailored for such tasks. Our largest model with ViT-L backbone set a new state-of-the-art in K400 by achieving $8 6 . 7 \%$ top-1 accuracy.
119
+
120
+ Table 1: Benchmark results on Kinetics-400 and Something-Something-v2. We evaluate all the approaches on two datasets with ViT-B/16 pretrained with CLIP and ImageNet-21K. For each entry, we report the top1 action recognition accuracy and the number of fine-tuned parameters. All methods introduce extra parameters beside parameters of the ViT backbone and linear classifier. Our ST-Adapter achieves the best trade-off between accuracy and training efficiency. It is the only efficient fine-tuning method that can match the performance of full fine-tuning. The TM? column shows whether the method includes temporal modelling, i.e., a temporal aggregation method other than average pooling. All models are trained using 8 frames and tested with 3 views.
121
+
122
+ <table><tr><td rowspan="2">Fine-tuning Methods</td><td rowspan="2">Architecture TM?</td><td rowspan="2">Fine-tuned Params (M)</td><td rowspan="2"></td><td colspan="2">CLIP</td><td colspan="2">ImageNet-21K</td></tr><tr><td>K400</td><td>SSv2</td><td>K400</td><td>SSv2</td></tr><tr><td rowspan="2">Full Fine-tuning</td><td>SA</td><td></td><td>86.11</td><td>81.0</td><td>44.0</td><td>76.9</td><td>40.0</td></tr><tr><td>SA + TA [6] SA + TS [9]</td><td>:</td><td>121.57 93.79</td><td>817</td><td>66.1</td><td>78.0</td><td>59.5</td></tr><tr><td rowspan="2">Partial Fine-tuning</td><td></td><td></td><td></td><td>78.0</td><td>62.0</td><td>78.5</td><td>64.4</td></tr><tr><td>SA SA + TA</td><td>√</td><td>7.40 10.36</td><td>80.1 80.3</td><td>37.6 57.5</td><td>61.7 63.1</td><td>20.4 29.3</td></tr><tr><td>Temporal Fine-tuning</td><td>SA + TA</td><td>√</td><td>35.8</td><td>81.3</td><td>59.4</td><td>76.5</td><td>51.9</td></tr><tr><td>Prompt Tuning</td><td>SA</td><td></td><td>1.18</td><td>79.3</td><td>39.3</td><td>71.4</td><td>26.3</td></tr><tr><td>Attentional Pooling</td><td>SA</td><td>√</td><td>2.36</td><td>75.3</td><td>21.5</td><td>59.1</td><td>15.1</td></tr><tr><td>Linear Probe</td><td>SA</td><td></td><td>0.31</td><td>76.6</td><td>21.9</td><td>60.1</td><td>14.8</td></tr><tr><td>Adapter [25]</td><td>SA</td><td></td><td>6.77</td><td>81.6</td><td>46.2</td><td>76.2</td><td>40.5</td></tr><tr><td></td><td>SA</td><td>一√</td><td>7.20</td><td>82.0</td><td>66.3</td><td>76.6</td><td></td></tr><tr><td>ST-Adapter (ours)</td><td></td><td></td><td></td><td></td><td></td><td></td><td>62.8</td></tr></table>
123
+
124
+ (ii) It is noteworthy that, our method takes significantly fewer frames as input compared to other methods (8 vs. 16, 32, 64, 96). It is also reflected in terms of GFlops. Saying that the ViT was not designed for efficiency purposes like [38, 9, 43, 17] but the adapted CLIP ViT has achieved similar accuracy-efficiency trade-offs.
125
+
126
+ (iii) The paradigm of pre-training and fine-tuning has been widely adopted in most state-of-art methods to achieve good performance. Between them, most of the approaches start from image pre-trained models, and only a few can afford video pre-training. Note that for the SomethingSomething dataset, except MViT [17] pre-trained on video data from scratch, the rest of methods are still initialized from image pre-trained weights. A good image pre-trained model with rich appearance information can facilitate temporal modeling in temporally challenging datasets like SSv2.
127
+
128
+ (iii) It is evident in Table 4 that our ST-Adapter consistently brings a big margin on egocentric videos. Also, we found that without our ST-Adapter, it is much more difficult to directly adapt CLIP pre-trained ViT on the domain of egocentric video with high sensitivity to the hyper-parameter setting. ST-Adapter eases the training process. It is worthy to note that, all current transformer based approaches need to be pre-trained first on image dataset and then fine-tuned on Kinetics dataset before fine-tuned with egocentric videos. In contrast, our ST-Adapter can be directly applied to an image model and trained with target egocentric video alone.
129
+
130
+ # 4.3 Ablations
131
+
132
+ Unless otherwise specified, we use ViT-B/16 backbone and 8 input frames in all ablation experiments, and we use one ST-Adapter with bottleneck width 384 before MHSA in each Transformer block.
133
+
134
+ Where to insert ST-Adapter By default, we insert a ST-Adapter to every Transformer block in the backbone, but we also show the performance impact of using fewer ST-Adapters. As shown in Table 5b, while more ST-Adapters tend to do better, ST-Adapters at deeper layers boost performance more than those at shallower layers. This observation is useful when we insert ST-Adapters into deeper models and having an Adapter for each block might be too expensive. We also show the performance when inserting ST-Adapters to different positions within a block. As shown in Table 5c, while the performance is relatively insensitive to the position of the Adapters, using multiple adapters in one block may substantially boost performance on some datasets, like SSv2 in our case.
135
+
136
+ Table 2: Results on Kinetics-400 validation set. “Frames” denotes the total number of frames used during inference which is: # frames per clip $\times$ # temporal clip $\times$ # spatial crop. “GFlops” means $1 0 ^ { 9 }$ Flops. Our ViT w/ ST-Adapter achieves new state-of-the-art performances on K400 at similar GFlops.
137
+
138
+ <table><tr><td>Model</td><td>Pretrain</td><td>#Frames</td><td>GFlops</td><td>Top-1</td><td>Top-5</td></tr><tr><td colspan="6">Methods with full-finetuning</td></tr><tr><td>LGD[53]</td><td>IN-1K</td><td>128×N/A</td><td>N/A</td><td>79.4</td><td>94.4</td></tr><tr><td>SlowFast+NL[19]</td><td>=</td><td>16×3×10</td><td>7020</td><td>79.8</td><td>93.9</td></tr><tr><td>ip-CSN[70]</td><td>Sports1M</td><td>32×3×10</td><td>3270</td><td>79.2</td><td>93.8</td></tr><tr><td>CorrNet[71]</td><td>Sports1M</td><td>32×3×10</td><td>6720</td><td>81.0</td><td>=</td></tr><tr><td>X3D-XL[18]</td><td></td><td>16×3×10</td><td>1452</td><td>79.1</td><td>93.9</td></tr><tr><td>MoViNet-A6[34]</td><td>1</td><td>120×1×1</td><td>386</td><td>81.5</td><td>95.3</td></tr><tr><td>ViT-B-VTN [47]</td><td>IN21K</td><td>250×1×1</td><td>3992</td><td>78.6</td><td>93.7</td></tr><tr><td>TimeSformer-L[6]</td><td>IN21K</td><td>96×3×1</td><td>7140</td><td>80.7</td><td>94.7</td></tr><tr><td>STAM [61]</td><td>IN21K</td><td>64×1×1</td><td>1040</td><td>79.2</td><td>1</td></tr><tr><td>X-ViT[9]</td><td>IN21K</td><td>16×3×1</td><td>850</td><td>80.2</td><td>94.7</td></tr><tr><td>Mformer-HR[49]</td><td>IN-21K</td><td>16×3×10</td><td>28764</td><td>81.1</td><td>95.2</td></tr><tr><td>MViT-B,32×3[17]</td><td>-</td><td>32×1×5</td><td>850</td><td>80.2</td><td>94.4</td></tr><tr><td>ViViT-L[2]</td><td>JFT300M</td><td>16×3×4</td><td>17352</td><td>82.8</td><td>95.3</td></tr><tr><td>Swin-B[44]</td><td>IN1K</td><td>32×3×4</td><td>3384</td><td>80.6</td><td>94.6</td></tr><tr><td>Swin-L(384)[44]</td><td>IN21K</td><td>32×5×10</td><td>105350</td><td>84.9</td><td>96.7</td></tr><tr><td>UniFormer-B[38]</td><td>IN1K</td><td>32×1×4</td><td>1036</td><td>82.9</td><td>95.4</td></tr><tr><td>VATT-Large(320)[1]</td><td>HowTo100M</td><td>32×3×4</td><td>29800</td><td>82.1</td><td>95.5</td></tr><tr><td>TokenLearner[58]</td><td>JFT300M</td><td>64×3×4</td><td>48912</td><td>85.4</td><td>96.3</td></tr><tr><td>OMNIVORE(Swin-L)[21]</td><td>IN22K+SUN</td><td>32×3×4</td><td>7248</td><td>84.1</td><td>96.3</td></tr><tr><td>MTV-H[80]</td><td>WTS-280</td><td>32×3×4</td><td>73570</td><td>89.9</td><td>98.3</td></tr><tr><td>ViT-B w/o ST-Adapter</td><td>CLIP</td><td>8×3×1</td><td>419</td><td>81.0</td><td>95.5</td></tr><tr><td>ViT-L w/o ST-Adapter</td><td>CLIP</td><td>8×3×1</td><td>1941</td><td>85.8</td><td>97.2</td></tr><tr><td colspan="6">Methodswith frozen backbone</td></tr><tr><td>Our ViT-B w/ST-Adapter</td><td>CLIP</td><td>8×3×1</td><td>455</td><td>82.0</td><td>95.7</td></tr><tr><td>Our ViT-B w/ ST-Adapter</td><td>CLIP</td><td>16×3×1</td><td>911</td><td>82.5</td><td>96.0</td></tr><tr><td>Our ViT-B w/ ST-Adapter</td><td>CLIP</td><td>32×3×1</td><td>1821</td><td>82.7</td><td>96.2</td></tr><tr><td>Our ViT-L w/ST-Adapter</td><td>CLIP</td><td>8×3×1</td><td>2062</td><td>86.7</td><td>97.5</td></tr><tr><td>Our ViT-L w/ ST-Adapter</td><td>CLIP</td><td>16×3×1</td><td>4124</td><td>86.9</td><td>97.6</td></tr><tr><td>Our ViT-L w/ ST-Adapter</td><td>CLIP</td><td>32×3×1</td><td>8248</td><td>87.2</td><td>97.6</td></tr></table>
139
+
140
+ Training parameter efficiency We experiment with a different number of channels in the middle of the bottleneck design. As shown in Table 5a and Fig. 2a, our method is effective with a wide range of bottleneck width: even with a channel reduction to 64, our ST-Adapters still obtain relatively good performance, outperforming all baselines in Table 1 except for Full Fine-tuning $\mathrm { ( S A + T A ) }$ . Even with a bottleneck width of 768, our ST-Adapters are still very parameter efficient, introducing only about 1/6 new parameters to a Transformer encoder block. In contrast to the inverted bottleneck design commonly used with depthwise convolutions [59], ST-Adapters work best with regular bottlenecks. The success of transfer learning with such low-rank projections again shows the rich knowledge and strong potential of modern foundation models.
141
+
142
+ Training time efficiency In Fig. 2b we show an enlarged difference between full fine-tuned models and our ST-Adapters with low training budgets. When we reduce the number of training steps, the accuracy of full fine-tuned models drops significantly faster than models with ST-Adapters. This shows the advantage of our proposed modules when backbone models are large or computational resources are limited. We also report the total training GPU-hours and peak memory usage for three models: TimeSformer, ViT-B/16, ViT-B/16 with ST-Adapter (8 input frames, 16 samples per GPU on 8 V100 GPUs) in Table 6.
143
+
144
+ Table 3: Results on Something-Something-v2 validation set. “Frames” denotes the total number of frames used during inference which is: # frames per clip $\times$ # temporal clip $\times \#$ spatial crop. “GFlops” means $1 0 ^ { 9 }$ Flops. Our ViT w/ ST-Adapter outperforms most of the current methods by only fine-tuning a very small set of parameters. Here the ViT-B w/ ST-Adapter result is reported using 2 ST-Adapters per block.
145
+
146
+ <table><tr><td rowspan=1 colspan=2>Model</td><td rowspan=1 colspan=1>Pretrain</td><td rowspan=1 colspan=1>#Frames</td><td rowspan=1 colspan=1>GFlops</td><td rowspan=1 colspan=1>Top-1</td><td rowspan=1 colspan=1>Top-5</td></tr><tr><td rowspan=1 colspan=3>Methods with full-finetuning</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=16 colspan=2>TSM[41]GST[46]MSNet[35]CT-Net[37]TDN[73]TimeSformer-HR[6]X-ViT[9]Mformer-L[49]ViViT-L[2]MViT-B-24,32×3[17]Swin-B[44]UniFormer-B[38]OMNIVORE (Swin-B)[21]MTV-B(320p)[80]ViT-B w/o ST-AdapterViT-L w/o ST-Adapter</td><td rowspan=1 colspan=1>IN1K</td><td rowspan=1 colspan=1>16×1×1</td><td rowspan=1 colspan=1>66</td><td rowspan=1 colspan=1>63.3</td><td rowspan=1 colspan=1>88.5</td></tr><tr><td rowspan=1 colspan=1>IN1K</td><td rowspan=1 colspan=1>16×1×1</td><td rowspan=1 colspan=1>59</td><td rowspan=1 colspan=1>62.6</td><td rowspan=1 colspan=1>87.9</td></tr><tr><td rowspan=1 colspan=1>IN1K</td><td rowspan=1 colspan=1>16×1×1</td><td rowspan=1 colspan=1>101</td><td rowspan=1 colspan=1>64.7</td><td rowspan=1 colspan=1>89.4</td></tr><tr><td rowspan=1 colspan=1>IN1K</td><td rowspan=1 colspan=1>16×1×1</td><td rowspan=1 colspan=1>75</td><td rowspan=1 colspan=1>64.5</td><td rowspan=1 colspan=1>89.3</td></tr><tr><td rowspan=1 colspan=1>IN1K</td><td rowspan=1 colspan=1>16×1×1</td><td rowspan=1 colspan=1>72</td><td rowspan=1 colspan=1>65.3</td><td rowspan=1 colspan=1>89.5</td></tr><tr><td rowspan=1 colspan=1>IN21K</td><td rowspan=1 colspan=1>16×3×1</td><td rowspan=1 colspan=1>5109</td><td rowspan=1 colspan=1>62.5</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>IN21K</td><td rowspan=1 colspan=1>32×3×1</td><td rowspan=1 colspan=1>1270</td><td rowspan=1 colspan=1>65.4</td><td rowspan=1 colspan=1>90.7</td></tr><tr><td rowspan=1 colspan=1>IN21K+K400</td><td rowspan=1 colspan=1>32×3×1</td><td rowspan=1 colspan=1>3555</td><td rowspan=1 colspan=1>68.1</td><td rowspan=1 colspan=1>91.2</td></tr><tr><td rowspan=1 colspan=1>IN21K+K400</td><td rowspan=1 colspan=1>16×3×4</td><td rowspan=1 colspan=1>11892</td><td rowspan=1 colspan=1>65.4</td><td rowspan=1 colspan=1>89.8</td></tr><tr><td rowspan=1 colspan=1>K600</td><td rowspan=1 colspan=1>32×1×3</td><td rowspan=1 colspan=1>708</td><td rowspan=1 colspan=1>68.7</td><td rowspan=1 colspan=1>91.5</td></tr><tr><td rowspan=1 colspan=1>IN21K+K400</td><td rowspan=1 colspan=1>32×3×1</td><td rowspan=1 colspan=1>963</td><td rowspan=1 colspan=1>69.6</td><td rowspan=1 colspan=1>92.7</td></tr><tr><td rowspan=1 colspan=1>IN1K+K600</td><td rowspan=1 colspan=1>32×3×1</td><td rowspan=1 colspan=1>777</td><td rowspan=1 colspan=1>71.2</td><td rowspan=1 colspan=1>92.8</td></tr><tr><td rowspan=1 colspan=1>B)[21]</td><td rowspan=1 colspan=1>IN22K+K400+SUN</td><td rowspan=1 colspan=1>32×3×1</td><td rowspan=1 colspan=1>963</td><td rowspan=1 colspan=1>71.4</td><td rowspan=1 colspan=1>93.5</td></tr><tr><td rowspan=3 colspan=1>IN21K+K400CLIPCLIP</td><td rowspan=1 colspan=1>32×3×4</td><td rowspan=1 colspan=1>11160</td><td rowspan=1 colspan=1>68.5</td><td rowspan=1 colspan=1>90.4</td></tr><tr><td rowspan=1 colspan=1>8×3×1</td><td rowspan=1 colspan=1>419</td><td rowspan=1 colspan=1>44.0</td><td rowspan=1 colspan=1>77.0</td></tr><tr><td rowspan=1 colspan=1>8×3×1</td><td rowspan=1 colspan=1>1941</td><td rowspan=1 colspan=1>48.7</td><td rowspan=1 colspan=1>77.5</td></tr><tr><td rowspan=7 colspan=5>Methodswith frozen backboneOur ViT-B w/ ST-Adapter CLIP 8×3×1 489Our ViT-B w/ ST-Adapter CLIP 16×3×1 977Our ViT-B w/ ST-Adapter CLIP 32×3×1 1955Our ViT-L w/ ST-Adapter CLIP 8×3×1 2062Our ViT-L w/ ST-Adapter CLIP 16×3×1 4124Our ViT-L w/ ST-Adapter CLIP 32×3×1 8248</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>CLIP</td><td rowspan=1 colspan=1>8×3×1</td><td rowspan=1 colspan=1>489</td><td rowspan=1 colspan=1>67.1</td><td rowspan=1 colspan=1>91.2</td></tr><tr><td rowspan=1 colspan=1>CLIP</td><td rowspan=1 colspan=1>16×3×1</td><td rowspan=1 colspan=1>977</td><td rowspan=1 colspan=1>69.3</td><td rowspan=1 colspan=1>92.3</td></tr><tr><td rowspan=1 colspan=1>CLIP</td><td rowspan=1 colspan=1>32×3×1</td><td rowspan=1 colspan=1>1955</td><td rowspan=1 colspan=1>69.5</td><td rowspan=1 colspan=1>92.6</td></tr><tr><td rowspan=1 colspan=1>CLIP</td><td rowspan=1 colspan=1>8×3×1</td><td rowspan=1 colspan=1>2062</td><td rowspan=1 colspan=1>70.0</td><td rowspan=1 colspan=1>92.3</td></tr><tr><td rowspan=1 colspan=1>CLIP</td><td rowspan=1 colspan=1>16×3×1</td><td rowspan=1 colspan=1>4124</td><td rowspan=1 colspan=1>71.9</td><td rowspan=1 colspan=1>93.4</td></tr><tr><td rowspan=1 colspan=1>CLIP</td><td rowspan=1 colspan=1>32×3×1</td><td rowspan=1 colspan=1>8248</td><td rowspan=1 colspan=1>72.3</td><td rowspan=1 colspan=1>93.9</td></tr></table>
147
+
148
+ Table 4: Results on Epic-Kitchens-100 validation set. “Frames” denotes the total number of frames used during inference which is: # frames per clip $\times$ # temporal clip $\times \#$ spatial crop.
149
+
150
+ <table><tr><td>Model</td><td>Pre-train data</td><td>#Frames</td><td>Verb</td><td>Noun</td></tr><tr><td colspan="5">Methods with full-finetuning</td></tr><tr><td>ViViT-L [2]</td><td>IN21K+K400</td><td>16×3×10</td><td>66.4</td><td>56.8</td></tr><tr><td>MFormer-B [49]</td><td>IN21K+K400</td><td>16 ×3×10</td><td>66.7</td><td>56.5</td></tr><tr><td>XViT(8x) [9]</td><td>IN21K+K400</td><td>8×3×1</td><td>66.7</td><td>53.3</td></tr><tr><td>ViT-B/16 w/o ST-Adapter</td><td>CLIP</td><td>8×3×1</td><td>54.8</td><td>50.4</td></tr><tr><td colspan="5">Methods with frozen backbone</td></tr><tr><td>Our ViT-B/16 w/ ST-Adapter</td><td>CLIP</td><td>8×3×1</td><td>67.6</td><td>55.0</td></tr></table>
151
+
152
+ Table 5: Ablation study on K-400 and SSv2. (a) We show the performance with different channel numbers in the bottleneck. (b) We evenly divide the 12 blocks of ViT-B/16 into 3 groups. Block no. 1 is closest to input and no. 12 is closest to output. (c) Effect of where to put the ST-Adapter inside a block, whose diagram is shown in Fig. 1.
153
+
154
+ <table><tr><td colspan="2">(a) Bottleneck width</td></tr><tr><td>width K400</td><td>SSv2</td></tr><tr><td>64</td><td>81.4 64.4</td></tr><tr><td>128 81.6</td><td>64.9</td></tr><tr><td>256 81.8</td><td>65.5</td></tr><tr><td>384</td><td>82.0 65.6</td></tr><tr><td>768 81.9</td><td>65.5</td></tr></table>
155
+
156
+ (c) Local position
157
+
158
+ <table><tr><td>position</td><td>K400</td><td>SSv2</td></tr><tr><td>before MHSA</td><td>82.0</td><td>65.6</td></tr><tr><td>after MHSA</td><td>81.9</td><td>65.7</td></tr><tr><td>afterFFN</td><td>81.9</td><td>65.9</td></tr><tr><td>before&amp;after MHSA</td><td>82.0</td><td>67.0</td></tr></table>
159
+
160
+ <table><tr><td colspan="5">(b) Global position</td></tr><tr><td>1-4</td><td>5-8</td><td>9-12</td><td>K400</td><td>SSv2</td></tr><tr><td>√</td><td></td><td></td><td>77.7</td><td>45.9</td></tr><tr><td rowspan="6">!</td><td>√</td><td></td><td>80.0</td><td>60.9</td></tr><tr><td></td><td>√</td><td>81.3</td><td>62.8</td></tr><tr><td></td><td>√</td><td>81.8</td><td>65.6</td></tr><tr><td></td><td>√</td><td>82.0</td><td>65.6</td></tr><tr><td></td><td></td><td></td><td></td></tr></table>
161
+
162
+ ![](images/cb051a1b084f57fc5c20733c36a911eb6a4a6200e098711f0bc5633170f6ab96.jpg)
163
+ Figure 2: Ablation study on efficiency (a) Parameter efficiency: ST-Adapter (with different bottleneck width) is compared with efficient fine-tuning methods in Table 1. (b) Training efficiency: We compare ST-Adapter with Full fine-tuning under different training schedules. Batch size is aligned and their original schedules are shortened proportionally. (c) Data efficiency: Performance comparison on different training data scales. The same ViT-B/16 with CLIP pre-training is used for all experiments.
164
+
165
+ Training data efficiency Fig. 2c showcases the impact of training data size on action recognition accuracy. Even with the same pre-trained weights, ST-Adapters tend to obtain higher performance than full fine-tuning especially on smaller datasets: the margin between the two models increases with the shrinkage of data. This shows that ST-Adapters are powerful tools to transfer to downstream tasks where only a small amount of labeled data is available.
166
+
167
+ Effects of kernel shape We ablate the effect of kernel size in the depth-wise convolutions inside our proposed ST-Adapter. It is shown in Table 7 that the temporal span is most sensitive, suggesting the significance of temporal structural modeling as we focus on in this work.
168
+
169
+ Table 6: Training time and memory. For full-finetuning we used the recipes in [6].
170
+
171
+ <table><tr><td>Model</td><td>Training GPU-hours (K400)</td><td>Peak mem ( (MB)</td></tr><tr><td>TimeSformer[6] (Full Fine-tune)</td><td>60 (+161%)</td><td>21694 (+52%)</td></tr><tr><td>ViT-B/16 (Full Fine-tune)</td><td>40 (+74%)</td><td>17275 (+21%)</td></tr><tr><td>ViT-B/16 w/ ST-Adapter</td><td>23</td><td>14238</td></tr></table>
172
+
173
+ # 5 Conclusions
174
+
175
+ Table 7: Effects of kernel shape. Kernel size is denoted as $k _ { T } \times k _ { H } \times$ $k _ { W }$ for time, height and width.
176
+
177
+ <table><tr><td>Kernel Size</td><td>K400</td><td>SSv2</td></tr><tr><td>1×1×1</td><td>81.6</td><td>46.2</td></tr><tr><td>1×3×3</td><td>81.4</td><td>46.2</td></tr><tr><td>3×1×1</td><td>82.0</td><td>66.3</td></tr><tr><td>3×3×3</td><td>82.0</td><td>65.6</td></tr></table>
178
+
179
+ In this work, we have presented a simple yet effective SpatioTemporal Adapter (ST-Adapter) for enabling a less studied parameter-efficient image-to-video transfer learning. Fully using commonly adopt primitive operators, ST-Adapter is particularly designed to be both lightweight and easy to implement for friendly usability and deployment. This cross-modality adaptation is a practically critical capability considering that it is dramatically challenging and more costly to build a sufficiently strong large video model in reality. Encouragingly, extensive experiments on video action recognition show that our ST
180
+
181
+ Adapter can match or surpass both the full fine-tuning strategy as well as fully trained state-of-the-art video models, whilst having the benefit of (20 times less updated parameters) parameter-efficiency. Further, our method is also faster to train and consumes less computing resources with economic and environmental superiority. We believe this work is inspiring for the research of other video understanding tasks such as action localization and video summarization.
182
+
183
+ Acknowledgement This work is supported in part by Centre for Perceptual and Interactive Intelligence Limited, in part by the General Research Fund through the Research Grants Council of Hong Kong under Grants (Nos. 14204021, 14207319).
184
+
185
+ # References
186
+
187
+ [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.
188
+ [2] Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Luciˇ c, and Cordelia Schmid. Vivit: A ´ video vision transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6836–6846, 2021.
189
+ [3] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
190
+ [4] Hyojin Bahng, Ali Jahanian, Swami Sankaranarayanan, and Phillip Isola. Visual prompting: Modifying pixel space to adapt pre-trained models. arXiv preprint arXiv:2203.17274, 2022.
191
+ [5] Ankur Bapna, Naveen Arivazhagan, and Orhan Firat. Simple, scalable adaptation for neural machine translation. arXiv preprint arXiv:1909.08478, 2019.
192
+ [6] Gedas Bertasius, Heng Wang, and Lorenzo Torresani. Is space-time attention all you need for video understanding? arXiv preprint arXiv:2102.05095, 2021.
193
+ [7] Rishi Bommasani, Drew A Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, et al. On the opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258, 2021.
194
+ [8] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. volume 33, pages 1877–1901. Curran Associates, Inc., 2020.
195
+ [9] Adrian Bulat, Juan Manuel Perez Rua, Swathikiran Sudhakaran, Brais Martinez, and Georgios Tzimiropoulos. Space-time mixing attention for video transformer. Advances in Neural Information Processing Systems, 34, 2021.
196
+ [10] Joao Carreira and Andrew Zisserman. Quo vadis, action recognition? a new model and the kinetics dataset. In proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 6299–6308, 2017.
197
+ [11] Joao Carreira, Eric Noland, Andras Banki-Horvath, Chloe Hillier, and Andrew Zisserman. A short note about kinetics-600. arXiv preprint arXiv:1808.01340, 2018.
198
+ [12] Joao Carreira, Eric Noland, Chloe Hillier, and Andrew Zisserman. A short note on the kinetics-700 human action dataset. arXiv preprint arXiv:1907.06987, 2019.
199
+ [13] Dima Damen, Hazel Doughty, Giovanni Maria Farinella, , Antonino Furnari, Jian Ma, Evangelos Kazakos, Davide Moltisanti, Jonathan Munro, Toby Perrett, Will Price, and Michael Wray. Rescaling egocentric vision: Collection, pipeline and challenges for epic-kitchens-100. International Journal of Computer Vision (IJCV), 130:33–55, 2022. URL https://doi.org/10.1007/s11263-021-01531-2.
200
+ [14] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. 2009.
201
+ [15] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics.
202
+ [16] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. 2020.
203
+ [17] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. arXiv preprint arXiv:2104.11227, 2021.
204
+ [18] Christoph Feichtenhofer. X3d: Expanding architectures for efficient video recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 203–213, 2020.
205
+ [19] Christoph Feichtenhofer, Haoqi Fan, Jitendra Malik, and Kaiming He. Slowfast networks for video recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6202–6211, 2019.
206
+ [20] Christoph Feichtenhofer, Haoqi Fan, Bo Xiong, Ross Girshick, and Kaiming He. A large-scale study on unsupervised spatiotemporal representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3299–3309, 2021.
207
+ [21] Rohit Girdhar, Mannat Singh, Nikhila Ravi, Laurens van der Maaten, Armand Joulin, and Ishan Misra. Omnivore: A single model for many visual modalities. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16102–16112, 2022.
208
+ [22] Raghav Goyal, Samira Ebrahimi Kahou, Vincent Michalski, Joanna Materzynska, Susanne Westphal, Heuna Kim, Valentin Haenel, Ingo Fruend, Peter Yianilos, Moritz Mueller-Freitag, et al. The" something something" video database for learning and evaluating visual common sense. In Proceedings of the IEEE International Conference on Computer Vision, pages 5842–5850, 2017.
209
+ [23] Ryota Hashiguchi and Toru Tamaki. Vision transformer with cross-attention by temporal shift for efficient action recognition. arXiv preprint arXiv:2204.00452, 2022.
210
+ [24] Junxian He, Chunting Zhou, Xuezhe Ma, Taylor Berg-Kirkpatrick, and Graham Neubig. Towards a unified view of parameter-efficient transfer learning. 2022.
211
+ [25] Neil Houlsby, Andrei Giurgiu, Stanislaw Jastrzebski, Bruna Morrone, Quentin De Laroussilhe, Andrea Gesmundo, Mona Attariyan, and Sylvain Gelly. Parameter-efficient transfer learning for nlp. In ICML, pages 2790–2799. PMLR, 2019.
212
+ [26] Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
213
+ [27] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.
214
+ [28] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning, pages 4904–4916. PMLR, 2021.
215
+ [29] Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. arXiv preprint arXiv:2203.12119, 2022.
216
+ [30] Boyuan Jiang, MengMeng Wang, Weihao Gan, Wei Wu, and Junjie Yan. Stm: Spatiotemporal and motion encoding for action recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2000–2009, 2019.
217
+ [31] Chen Ju, Tengda Han, Kunhao Zheng, Ya Zhang, and Weidi Xie. Prompting visual-language models for efficient video understanding. arXiv preprint arXiv:2112.04478, 2021.
218
+ [32] Andrej Karpathy, George Toderici, Sanketh Shetty, Thomas Leung, Rahul Sukthankar, and Li Fei-Fei. Large-scale video classification with convolutional neural networks. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pages 1725–1732, 2014.
219
+ [33] Will Kay, Joao Carreira, Karen Simonyan, Brian Zhang, Chloe Hillier, Sudheendra Vijayanarasimhan, Fabio Viola, Tim Green, Trevor Back, Paul Natsev, et al. The kinetics human action video dataset. arXiv preprint arXiv:1705.06950, 2017.
220
+ [34] D. Kondratyuk, Liangzhe Yuan, Yandong Li, Li Zhang, Mingxing Tan, Matthew A. Brown, and Boqing Gong. Movinets: Mobile video networks for efficient video recognition. ArXiv, abs/2103.11511, 2021.
221
+ [35] Heeseung Kwon, Manjin Kim, Suha Kwak, and Minsu Cho. Motionsqueeze: Neural motion feature learning for video understanding. In ECCV, 2020.
222
+ [36] Brian Lester, Rami Al-Rfou, and Noah Constant. The power of scale for parameter-efficient prompt tuning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 3045–3059, Online and Punta Cana, Dominican Republic, November 2021. Association for Computational Linguistics.
223
+ [37] Kunchang Li, Xianhang Li, Yali Wang, Jun Wang, and Y. Qiao. Ct-net: Channel tensorization network for video classification. ArXiv, abs/2106.01603, 2021.
224
+ [38] Kunchang Li, Yali Wang, Junhao Zhang, Peng Gao, Guanglu Song, Yu Liu, Hongsheng Li, and Yu Qiao. Uniformer: Unifying convolution and self-attention for visual recognition. arXiv preprint arXiv:2201.09450, 2022.
225
+ [39] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 4582– 4597, Online, August 2021. Association for Computational Linguistics.
226
+ [40] Yanghao Li, Chao-Yuan Wu, Haoqi Fan, Karttikeya Mangalam, Bo Xiong, Jitendra Malik, and Christoph Feichtenhofer. Improved multiscale vision transformers for classification and detection. arXiv preprint arXiv:2112.01526, 2021.
227
+ [41] Ji Lin, Chuang Gan, and Song Han. Tsm: Temporal shift module for efficient video understanding. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 7083–7093, 2019.
228
+ [42] Xiao Liu, Kaixuan Ji, Yicheng Fu, Zhengxiao Du, Zhilin Yang, and Jie Tang. P-tuning v2: Prompt tuning can be comparable to fine-tuning universally across scales and tasks. arXiv preprint arXiv:2110.07602, 2021.
229
+ [43] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. 2021.
230
+ [44] Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video swin transformer. arXiv preprint arXiv:2106.13230, 2021.
231
+ [45] Zhaoyang Liu, Limin Wang, Wayne Wu, Chen Qian, and Tong Lu. Tam: Temporal adaptive module for video recognition. arXiv preprint arXiv:2005.06803, 2020.
232
+ [46] Chenxu Luo and Alan L. Yuille. Grouped spatial-temporal aggregation for efficient action recognition. 2019 IEEE International Conference on Computer Vision (ICCV), pages 5511–5520, 2019.
233
+ [47] Daniel Neimark, Omri Bar, Maya Zohar, and Dotan Asselmann. Video transformer network. ArXiv, abs/2102.00719, 2021.
234
+ [48] Junting Pan, Siyu Chen, Mike Zheng Shou, Yu Liu, Jing Shao, and Hongsheng Li. Actor-context-actor relation network for spatio-temporal action localization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 464–474, June 2021.
235
+ [49] Mandela Patrick, Dylan Campbell, Yuki Asano, Ishan Misra, Florian Metze, Christoph Feichtenhofer, Andrea Vedaldi, and João F Henriques. Keeping your eye on the ball: Trajectory attention in video transformers. Advances in Neural Information Processing Systems, 34, 2021.
236
+ [50] Jonas Pfeiffer, Aishwarya Kamath, Andreas Rücklé, Kyunghyun Cho, and Iryna Gurevych. Adapterfusion: Non-destructive task composition for transfer learning. arXiv preprint arXiv:2005.00247, 2020.
237
+ [51] Jonas Pfeiffer, Andreas Rücklé, Clifton Poth, Aishwarya Kamath, Ivan Vulic, Sebastian Ruder, Kyunghyun ´ Cho, and Iryna Gurevych. Adapterhub: A framework for adapting transformers. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP 2020): Systems Demonstrations, pages 46–54, Online, 2020. Association for Computational Linguistics.
238
+ [52] Guanghui Qin and Jason Eisner. Learning how to ask: Querying lms with mixtures of soft prompts. arXiv preprint arXiv:2104.06599, 2021.
239
+ [53] Zhaofan Qiu, Ting Yao, C. Ngo, Xinmei Tian, and Tao Mei. Learning spatio-temporal representation with local and global diffusion. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 12048–12057, 2019.
240
+ [54] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
241
+ [55] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748–8763. PMLR, 2021.
242
+ [56] Sylvestre-Alvise Rebuffi, Hakan Bilen, and Andrea Vedaldi. Learning multiple visual domains with residual adapters. 30, 2017.
243
+ [57] Sylvestre-Alvise Rebuffi, Hakan Bilen, and Andrea Vedaldi. Efficient parametrization of multi-domain deep neural networks. pages 8119–8127, 2018.
244
+ [58] Michael Ryoo, AJ Piergiovanni, Anurag Arnab, Mostafa Dehghani, and Anelia Angelova. Tokenlearner: Adaptive space-time tokenization for videos. Advances in Neural Information Processing Systems, 34, 2021.
245
+ [59] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4510–4520, 2018.
246
+ [60] Laura Sevilla-Lara, Shengxin Zha, Zhicheng Yan, Vedanuj Goswami, Matt Feiszli, and Lorenzo Torresani. Only time can tell: Discovering temporal data for temporal modeling. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 535–544, 2021.
247
+ [61] Gilad Sharir, Asaf Noy, and Lihi Zelnik-Manor. An image is worth 16x16 words, what is a video worth? ArXiv, abs/2103.13915, 2021.
248
+ [62] Taylor Shin, Yasaman Razeghi, Robert L Logan IV, Eric Wallace, and Sameer Singh. Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:2010.15980, 2020.
249
+ [63] Asa Cooper Stickland and Iain Murray. Bert and pals: Projected attention layers for efficient adaptation in multi-task learning. In International Conference on Machine Learning, pages 5986–5995. PMLR, 2019.
250
+ [64] Chen Sun, Austin Myers, Carl Vondrick, Kevin Murphy, and Cordelia Schmid. Videobert: A joint model for video and language representation learning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 7464–7473, 2019.
251
+ [65] Yi-Lin Sung, Jaemin Cho, and Mohit Bansal. Vl-adapter: Parameter-efficient transfer learning for visionand-language tasks. arXiv preprint arXiv:2112.06825, 2021.
252
+ [66] Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. In European conference on computer vision, pages 776–794. Springer, 2020.
253
+ [67] Zhan Tong, Yibing Song, Jue Wang, and Limin Wang. Videomae: Masked autoencoders are data-efficient learners for self-supervised video pre-training. arXiv preprint arXiv:2203.12602, 2022.
254
+ [68] Du Tran, Lubomir Bourdev, Rob Fergus, Lorenzo Torresani, and Manohar Paluri. Learning spatiotemporal features with 3d convolutional networks. In Proceedings of the IEEE international conference on computer vision, pages 4489–4497, 2015.
255
+ [69] Du Tran, Heng Wang, Lorenzo Torresani, Jamie Ray, Yann LeCun, and Manohar Paluri. A closer look at spatiotemporal convolutions for action recognition. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pages 6450–6459, 2018.
256
+ [70] Du Tran, Heng Wang, L. Torresani, and Matt Feiszli. Video classification with channel-separated convolutional networks. 2019 IEEE/CVF International Conference on Computer Vision (ICCV), pages 5551–5560, 2019.
257
+ [71] Heng Wang, Du Tran, L. Torresani, and Matt Feiszli. Video modeling with correlation networks. 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 349–358, 2020.
258
+ [72] Limin Wang, Yuanjun Xiong, Zhe Wang, Yu Qiao, Dahua Lin, Xiaoou Tang, and Luc Van Gool. Temporal segment networks for action recognition in videos. IEEE transactions on pattern analysis and machine intelligence, 41(11):2740–2755, 2018.
259
+ [73] Limin Wang, Zhan Tong, Bin Ji, and Gangshan Wu. Tdn: Temporal difference networks for efficient action recognition. ArXiv, abs/2012.10071, 2020.
260
+ [74] Mengmeng Wang, Jiazheng Xing, and Yong Liu. Actionclip: A new paradigm for video action recognition. arXiv preprint arXiv:2109.08472, 2021.
261
+ [75] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7794–7803, 2018.
262
+ [76] Chen Wei, Haoqi Fan, Saining Xie, Chao-Yuan Wu, Alan Yuille, and Christoph Feichtenhofer. Masked feature prediction for self-supervised visual pre-training. arXiv preprint arXiv:2112.09133, 2021.
263
+ [77] Saining Xie, Chen Sun, Jonathan Huang, Zhuowen Tu, and Kevin Murphy. Rethinking spatiotemporal feature learning: Speed-accuracy trade-offs in video classification. In Proceedings of the European conference on computer vision (ECCV), pages 305–321, 2018.
264
+ [78] Hu Xu, Gargi Ghosh, Po-Yao Huang, Prahal Arora, Masoumeh Aminzadeh, Christoph Feichtenhofer, Florian Metze, and Luke Zettlemoyer. Vlm: Task-agnostic video-language model pre-training for video understanding. arXiv preprint arXiv:2105.09996, 2021.
265
+ [79] Hu Xu, Gargi Ghosh, Po-Yao Huang, Dmytro Okhonko, Armen Aghajanyan, Florian Metze, Luke Zettlemoyer, and Christoph Feichtenhofer. Videoclip: Contrastive pre-training for zero-shot video-text understanding. In EMNLP, 2021.
266
+ [80] Shen Yan, Xuehan Xiong, Anurag Arnab, Zhichao Lu, Mi Zhang, Chen Sun, and Cordelia Schmid. Multiview transformers for video recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3333–3343, 2022.
267
+ [81] Jiahui Yu, Zirui Wang, Vijay Vasudevan, Legg Yeung, Mojtaba Seyedhosseini, and Yonghui Wu. Coca: Contrastive captioners are image-text foundation models. arXiv preprint arXiv:2205.01917, 2022.
268
+ [82] Hao Zhang, Yanbin Hao, and Chong-Wah Ngo. Token shift transformer for video classification. In Proceedings of the 29th ACM International Conference on Multimedia, pages 917–925, 2021.
269
+ [83] Jeffrey O Zhang, Alexander Sax, Amir Zamir, Leonidas Guibas, and Jitendra Malik. Side-tuning: a baseline for network adaptation via additive side networks. pages 698–714. Springer, 2020.
270
+ [84] Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. Neural prompt search. arXiv preprint arXiv:2206.04673, 2022.
271
+ [85] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for vision-language models. arXiv preprint arXiv:2109.01134, 2021.
272
+ [86] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Conditional prompt learning for vision-language models. In CVPR, 2022.
273
+
274
+ # Checklist
275
+
276
+ 1. For all authors...
277
+
278
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
279
+ (b) Did you describe the limitations of your work? [No]
280
+ (c) Did you discuss any potential negative societal impacts of your work? [No]
281
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
282
+
283
+ 2. If you are including theoretical results...
284
+
285
+ (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]
286
+
287
+ 3. If you ran experiments...
288
+
289
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Code will be provided on GitHub after blind review.
290
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See ??
291
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] The experiments are too expensive to repeat many times.
292
+ (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 ??
293
+
294
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
295
+
296
+ (a) If your work uses existing assets, did you cite the creators? [Yes] All are mentioned in 4
297
+ (b) Did you mention the license of the assets? [No]
298
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] Code will be provided on GitHub after blind review.
299
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
300
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
301
+
302
+ 5. If you used crowdsourcing or conducted research with human subjects...
303
+
304
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
305
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
306
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/uYLFoz1vlAC/uYLFoz1vlAC.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/ubgdInLSF9/ubgdInLSF9.md ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SnapFusion: Text-to-Image Diffusion Model on Mobile Devices within Two Seconds
2
+
3
+ Yanyu Li1,2,† Huan Wang1,2,† Qing Jin1,† Ju Hu1 Pavlo Chemerys1 Yun Fu2 Yanzhi Wang2 Sergey Tulyakov1 Jian Ren1,† 1Snap Inc. 2Northeastern University Project Page: https://snap-research.github.io/SnapFusion
4
+
5
+ ![](images/5d7f6ff4f66efab6ba0b89e44f1a17dfafb23c45be7a37c6ecabf87386e55d46.jpg)
6
+ Figure 1: Example generated images by using our efficient text-to-image diffusion model.
7
+
8
+ # Abstract
9
+
10
+ Text-to-image diffusion models can create stunning images from natural language descriptions that rival the work of professional artists and photographers. However, these models are large, with complex network architectures and tens of denoising iterations, making them computationally expensive and slow to run. As a result, high-end GPUs and cloud-based inference are required to run diffusion models at scale. This is costly and has privacy implications, especially when user data is sent to a third party. To overcome these challenges, we present a generic approach that, for the first time, unlocks running text-to-image diffusion models on mobile devices in less than 2 seconds. We achieve so by introducing efficient network architecture and improving step distillation. Specifically, we propose an efficient UNet by identifying the redundancy of the original model and reducing the computation of the image decoder via data distillation. Further, we enhance the step distillation by exploring training strategies and introducing regularization from classifier-free guidance. Our extensive experiments on MS-COCO show that our model with 8 denoising steps achieves better FID and CLIP scores than Stable Diffusion v1.5 with 50 steps. Our work democratizes content creation by bringing powerful text-to-image diffusion models to the hands of users.
11
+
12
+ # 1 Introduction
13
+
14
+ Diffusion-based text-to-image models [1, 2, 3, 4] show remarkable progress in synthesizing photorealistic content using text prompts. They profoundly impact the content creation [5, 6], image editing and in-painting [7, 8, 9, 10, 11], super-resolution [12], video synthesis [13, 14], and 3D assets generation [15, 16, 17], to name a few. This impact comes at the cost of the substantial increase in the computation requirements to run such models [18, 19, 20, 21]. As a result, to satisfy the necessary latency constraints large scale, often cloud-based inference platforms with high-end GPU are required. This incurs high costs and brings potential privacy concerns, motivated by the sheer fact of sending private images, videos, and prompts to a third-party service.
15
+
16
+ Not surprisingly, there are emerging efforts to speed up the inference of text-to-image diffusion models on mobile devices. Recent works use quantization [22, 23] or GPU-aware optimization to reduce the run time, i.e., accelerating the diffusion pipeline to 11.5s on Samsung Galaxy S23 Ultra [24]. While these methods effectively achieve a certain speed-up on mobile platforms, the obtained latency does not allow for a seamless user experience. Besides, none of the existing studies systematically examine the generation quality of on-device models through quantitative analysis.
17
+
18
+ In this work, we present the first text-to-image diffusion model that generates an image on mobile devices in less than 2 seconds. To achieve this, we mainly focus on improving the slow inference speed of the UNet and reducing the number of necessary denoising steps. First, the architecture of UNet, which is the major bottleneck for the conditional diffusion model (as we show in Tab. 1), is rarely optimized in the literature. Existing works primarily focus on post-training optimizations [25, 26]. Conventional compression techniques, e.g., model pruning [27, 28] and architecture search [29, 30], reduce the performance of pre-trained diffusion models [31], which is difficult to recover without heavy fine-tuning. Consequently, the architecture redundancies are not fully exploited, resulting in a limited acceleration ratio. Second, the flexibility of the denoising diffusion process is not well explored for the on-device model. Directly reducing the number of denoising steps impacts the generative performance, while progressively distilling the steps can mitigate the impacts [32, 33]. However, the learning objectives for step distillation and the strategy for training the on-device model have yet to be thoroughly studied, especially for models trained using large-scale datasets.
19
+
20
+ This work proposes a series of contributions to address the aforementioned challenges:
21
+
22
+ • We provide an in-depth analysis of the denoising UNet and identify the architecture redundancies.
23
+ • We propose a novel evolving training framework to obtain an efficient UNet that performs better than the original Stable Diffusion $\mathrm { v } 1 . { \bar { s } }$ while being significantly faster. We also introduce a data distillation pipeline to compress and accelerate the image decoder.
24
+ • We improve the learning objective during step distillation by proposing additional regularization, including losses from the $\mathbf { v }$ -prediction and classifier-free guidance [34].
25
+ • Finally, we explore the training strategies for step distillation, especially the best teacher-student paradigm for training the on-device model.
26
+
27
+ Through the improved Step distillation and network architecture development for the difFusion model, our introduced model, SnapFusion, generates a $5 1 2 \times 5 1 2$ image from the text on mobile devices in less than 2 seconds, while with image quality similar to Stable Diffusion v1.5 [4] (see example images from our approach in Fig. 1).
28
+
29
+ # 2 Model Analysis of Stable Diffusion
30
+
31
+ # 2.1 Prerequisites of Stable Diffusion
32
+
33
+ Diffusion Models gradually convert the sample x from a real data distribution $p _ { \mathrm { d a t a } } ( \mathbf { x } )$ into a noisy version, i.e., the diffusion process, and learn to reverse this process by denoising the noisy data step by step [35]. Therefore, the model transforms a simple distribution, e.g., random Gaussian noise, to the desired more complicated distribution, e.g., real images. Specifically, given a (noise-prediction) diffusion model $\hat { \epsilon } _ { \pmb { \theta } } ( \cdot )$ parameterized by $\pmb \theta$ , which is typically structured as a UNet [36, 1], the training can be formulated as the following noise prediction problem [35, 1, 2]:
34
+
35
+ $$
36
+ \operatorname* { m i n } _ { \pmb { \theta } } \ \mathbb { E } _ { t \sim U [ 0 , 1 ] , \mathbf { x } \sim p _ { \mathrm { d a t a } } ( \mathbf { x } ) , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } ) } \ | | \hat { \epsilon } _ { \pmb { \theta } } ( t , \mathbf { z } _ { t } ) - \epsilon | | _ { 2 } ^ { 2 } ,
37
+ $$
38
+
39
+ where $t$ refers to the time step; $\epsilon$ is the ground-truth noise; $\mathbf { z } _ { t } = \alpha _ { t } \mathbf { x } + \sigma _ { t } \mathbf { \epsilon } \mathbf { \epsilon }$ is the noisy data; $\alpha _ { t }$ and $\sigma _ { t }$ are the strengths of signal and noise, respectively, decided by a noise scheduler. A trained
40
+
41
+ diffusion model can generate samples from noise with various samplers. In our experiments, we use DDIM [37] to sample with the following iterative denoising process from $t$ to a previous time step $t ^ { \prime }$
42
+
43
+ $$
44
+ \mathbf { z } _ { t ^ { \prime } } = \alpha _ { t ^ { \prime } } \frac { \mathbf { z } _ { t } - \sigma _ { t } \hat { \epsilon } _ { \pmb { \theta } } ( t , \mathbf { z } _ { t } ) } { \alpha _ { t } } + \sigma _ { t ^ { \prime } } \hat { \epsilon } _ { \pmb { \theta } } ( t , \mathbf { z } _ { t } ) ,
45
+ $$
46
+
47
+ where $\mathbf { z } _ { t ^ { \prime } }$ will be fed into $\hat { \epsilon } _ { \pmb { \theta } } ( \cdot )$ again until $t ^ { \prime }$ becomes 0, i.e., the denoising process finishes.
48
+
49
+ Latent Diffusion Model / Stable Diffusion. The recent latent diffusion model (LDM) [4] reduces the inference computation and steps by performing the denoising process in the latent space, which is encoded from a pre-trained variational autoencoder (VAE) [38, 39]. During inference, the image is constructed through the decoder from the latent. LDM also explores the text-to-image generation, where a text prompt embedding $\mathbf { c }$ is fed into the diffusion model as the condition. When synthesizing images, an important technique, classifier-free guidance (CFG) [34], is adopted to improve quality,
50
+
51
+ $$
52
+ \tilde { \epsilon } _ { \theta } ( t , { \bf z } _ { t } , { \bf c } ) = w \hat { \epsilon } _ { \theta } ( t , { \bf z } _ { t } , { \bf c } ) - ( w - 1 ) \hat { \epsilon } _ { \theta } ( t , { \bf z } _ { t } , \mathcal { O } ) ,
53
+ $$
54
+
55
+ where $\hat { \epsilon } _ { \pmb { \theta } } ( t , { \bf z } _ { t } , \emptyset )$ represents the unconditional output obtained by using null text $\mathcal { D }$ . The guidance scale $w$ can be adjusted to control the strength of conditional information on the generated images to achieve the trade-off between quality and diversity. LDM is further trained on large-scale datasets [40], delivering a series of Stable Diffusion (SD) models [4]. We choose Stable Diffusion v1.5 (SD-v1.5) as the baseline. Next, we perform detailed analyses to diagnose the latency bottleneck of SD-v1.5.
56
+
57
+ # 2.2 Benchmark and Analysis
58
+
59
+ Here we comprehensively study the parameter and computation intensity of the SD-v1.5. The in-depth analysis helps us understand the bottleneck to deploying text-to-image diffusion models on mobile devices from the scope of network architecture and algorithm paradigms. Meanwhile, the micro-level breakdown of the networks serves as the basis of the architecture redesign and search.
60
+
61
+ Table 1: Latency Comparison between Stable Diffusion v1.5 and our proposed efficient diffusion models (UNet and Image Decoder) on iPhone $1 4 \mathrm { P r o }$ .
62
+
63
+ <table><tr><td>Stable Diffusion v1.5</td><td>Text Encoder</td><td>UNet</td><td>VAE Decoder</td></tr><tr><td>Input Resolution</td><td>77 tokens</td><td>64×64</td><td>64×64</td></tr><tr><td>#Parameters (M)</td><td>123</td><td>860</td><td>50</td></tr><tr><td>Latency (ms)</td><td>4</td><td>~1,700��</td><td>369</td></tr><tr><td>Inference Steps</td><td>2</td><td>50</td><td>1</td></tr><tr><td>Total Latency (ms)</td><td>8</td><td>85,000</td><td>369</td></tr><tr><td>OurModel</td><td>Text Encoder</td><td>OurUNet</td><td>OurImageDecoder</td></tr><tr><td>Input Resolution</td><td>77 tokens</td><td>64×64</td><td>64×64</td></tr><tr><td>#Parameters (M)</td><td>123</td><td>848</td><td>13</td></tr><tr><td>Latency (ms)</td><td>4</td><td>230</td><td>116</td></tr><tr><td>Inference Steps</td><td>2</td><td>8</td><td>1</td></tr><tr><td>Total Latency (ms)</td><td>8</td><td>1,840</td><td>116</td></tr></table>
64
+
65
+ ![](images/2659e71eec0af8ccf98f3b50b6fbf1973fb4eae83e44ec89e383bf79da546402.jpg)
66
+ Figure 2: Latency (iPhone $1 4 ~ \mathrm { P r o }$ , ms) and parameter (M) analysis for cross-attention (CA) and ResNet blocks in the UNet of Stable Diffusion.
67
+
68
+ Macro Prospective. As shown in Tab. 1 and Fig. 3, the networks of stable diffusion consist of three major components. Text encoder employs a ViT-H model [41] for converting input text prompt into embedding and is executed in two steps (with one for CFG) for each image generation process, constituting only a tiny portion of inference latency (8 ms). The VAE decoder takes the latent feature to generate an image, which runs as $3 6 9 \mathrm { m s }$ . Unlike the above two models, the denoising UNet is not only intensive in computation (1.7 seconds latency) but also demands iterative forwarding steps to ensure generative quality. For instance, the total denoising timesteps is set to 50 for inference in SD-v1.5, significantly slowing down the on-device generation process to the minute level.
69
+
70
+ Breakdown for UNet. The time-conditional (t) UNet consists of cross-attention and ResNet blocks. Specifically, a cross-attention mechanism is employed at each stage to integrate text embedding (c) into spatial features: Cross-Attention $\begin{array} { r } { \langle Q _ { \mathbf { z } _ { t } } , K _ { \mathbf { c } } , V _ { \mathbf { c } } \rangle = S o f t m a x ( \frac { Q _ { \mathbf { z } _ { t } } \cdot K _ { \mathbf { c } } ^ { \top } } { \sqrt { d } } ) \cdot V _ { \mathbf { c } } } \end{array}$ , where $Q$ is projected from noisy data $\mathbf { z } _ { t }$ , $K$ and $V$ are projected from text condition, and $d$ is the feature dimension. UNet also uses ResNet blocks to capture locality, and we can formulate the forward of UNet as:
71
+
72
+ $$
73
+ \hat { \epsilon } _ { \pmb { \theta } } ( t , { \bf z } _ { t } ) = \prod \{ C r o s s - A t t e n t i o n ( { \bf z } _ { t } , { \bf c } ) , R e s N e t ( { \bf z } _ { t } , t ) \} .
74
+ $$
75
+
76
+ 2We notice the latency varies depending on the phones and use three phones to get the average speed.
77
+
78
+ ![](images/4a434181ed7ea296f582ce68b61eef4aaaaca9c78c67ba39e4c4d739edbb4ff0.jpg)
79
+ Figure 3: Workflow of text-to-image diffusion model (left) and the proposed step distillation (right).
80
+
81
+ The distribution of parameters and computations of UNet is illustrated in Fig. 2, showing that parameters are concentrated on the middle (downsampled) stages because of the expanded channel dimensions, among which ResNet blocks constitute the majority. In contrast, the slowest parts of UNet are the input and output stages with the largest feature resolution, as spatial cross-attentions have quadratic computation complexity with respect to feature size (tokens).
82
+
83
+ # 3 Architecture Optimizations
84
+
85
+ Here we investigate the architecture redundancy of SD-v1.5 to obtain efficient neural networks. However, it is non-trivial to apply conventional pruning [42, 43, 44, 45] or architecture search [46, 47, 30] techniques, given the tremendous training cost of SD. Any permutation in architecture may lead to degraded performance that requires fine-tuning with hundreds or thousands of GPUs days. Therefore, we propose an architecture-evolving method that preserves the performance of the pre-trained UNet model while gradually improving its efficacy. As for the deterministic image decoder, we apply tailored compression strategies and a simple yet effective prompt-driven distillation approach.
86
+
87
+ # 3.1 Efficient UNet
88
+
89
+ From our empirical observation, the operator changes resulting from network pruning or searching lead to degraded synthesized images, asking for significant training costs to recover the performance. Thus, we propose a robust training, and evaluation and evolving pipeline to alleviate the issue.
90
+
91
+ Robust Training. Inspired by the idea of elastic depth [48, 49], we apply stochastic forward propagation to execute each cross-attention and ResNet block by probability $p ( \cdot , I )$ , where $I$ refers to identity mapping that skips the corresponding block. Thus, we have Eq. (4) becomes as follows:
92
+
93
+ $$
94
+ \hat { \epsilon } _ { \theta } ( t , { \bf z } _ { t } ) = \prod \{ p ( C r o s s - A t t e n t i o n ( { \bf z } _ { t } , { \bf c } ) , I ) , p ( R e s N e t ( { \bf z } _ { t } , t ) , I ) \} .
95
+ $$
96
+
97
+ With this training augmentation, the network is robust to architecture permutations, which enables an accurate assessment of each block and a stable architectural evolution (more examples in Fig. 5).
98
+
99
+ Evaluation and Architecture Evolving. We perform online network changes of UNet using the model from robust training with the constructed evolution action set: $A \in \{ A _ { C r o s s - A t t e n t i o n [ i , j ] } ^ { + , - } , A _ { R e s N e t [ i , j ] } ^ { + , - } \}$ where $A ^ { + , - }$ denotes the action to remove $( - )$ or add $( + )$ a cross-attention or ResNet block at the corresponding position (stage $i$ , block $j$ ). Each action is evaluated by its impact on execution latency and generative performance. For latency, we use the lookup table built in Sec. 2.2 for each possible configuration of cross-attention and ResNet blocks. Note we improve the UNet for on-device speed; the optimization of model size can be performed similarly and is left as future work. For generative performance, we choose CLIP score [41] to measure the correlation between generated images and the text condition. We use a small subset (2K images) of MS-COCO validation set [50], fixed steps (50), and CFG scale as 7.5 to benchmark the score, and it takes about $2 . 5 \mathrm { { A l 0 0 } }$ GPU hours to test each action. For simplicity, the value score of each action is defined as $\frac { \Delta C L I P } { \Delta L a t e n c y }$ , where a block with lower latency and higher contribution to CLIP tends to be preserved, and the opposite is removed in architecture evolving (more details in Alg. 1). To further reduce the cost for network optimization, we perform architecture evolving, i.e., removing redundant blocks or adding extra blocks at valuable positions by executing a group of actions at a time. Our training paradigm successfully preserves the performance of pre-trained UNet while tolerating large network permutations (Fig. 5). The details of our final architecture is presented in Sec. A.
100
+
101
+ # 3.2 Efficient Image Decoder
102
+
103
+ For the image decoder, we propose a distillation pipeline that uses synthetic data to learn the efficient image decoder obtained via channel reduction, which has $3 . 8 \times$ fewer parameters and is $3 . 2 \times$ faster than the one from SD-v1.5. The efficient image decoder is obtained by applying $5 0 \%$ uniform channel pruning to the original image decoder, resulting in a compressed efficient image decoder with approximately $1 / 4$ size and MACs of the original one. Here we only train the efficient decoder instead of following the training of VAE [4, 38, 39] that also learns the image encoder. We use text prompts to get the latent representation from the UNet of SD-v1.5 after 50 denoising steps with DDIM and forward it to our efficient image decoder and the one of SD-v1.5 to generate two images. We then optimize the decoder by minimizing the mean squared error between the two images. Using synthetic data for distillation brings the advantage of augmenting the dataset on-the-fly where each prompt be used to obtain unlimited images by sampling various noises. Quantitative analysis of the compressed decoder can be found in Sec. B.2.
104
+
105
+ # Algorithm 1 Optimizing UNet Architecture
106
+
107
+ Require: UNet: $\scriptstyle { \hat { \epsilon } } _ { \theta }$ ; validation set: $\mathbb { D } _ { v a l }$ ; latency lookup table $\mathbb { T } : \{ C r o s s \small A t t e n t i o n [ i , j ] , R e s N e t [ i , j ] \}$ .
108
+
109
+ Ensure: $\hat { \epsilon } _ { \pmb { \theta } }$ converges and satisfies latency objective $S$ . while $\hat { \epsilon } _ { \pmb { \theta } }$ not converged do Perform robust training. Architecture optimization: if perform architecture evolving at this iteration then Evaluate blocks: for each block[i, j] do $\begin{array} { r l } & { \Delta C L I P \mathrm { e v a l } ( \hat { \epsilon } _ { \theta } , A _ { b l o c k [ i , j ] } ^ { - } , \mathbb { D } _ { v a l } ) , } \\ & { \Delta L a t e n c y \mathrm { e v a l } ( \hat { \epsilon } _ { \theta } , A _ { b l o c k [ i , j ] } ^ { - } , \mathbb { T } ) } \end{array}$ end for $\mathbf { \nabla } \to \mathbf { S o r t }$ actions based on $\frac { \Delta C L I P } { \Delta L a t e n c y }$ , execute action, and evolve architecture to get latency $T$ : if latency objective $S$ is not satisfied then $\begin{array} { r } { \{ \hat { A } ^ { - } \} \arg \operatorname* { m i n } _ { A ^ { - } } \frac { \Delta C L I P } { \Delta L a t e n c y } , } \end{array}$ else $\begin{array} { r l } & { \mathrm { ~ \hat { \varepsilon } ~ } _ { \left\{ \hat { A } ^ { + } \right\} } \gets \mathrm { c o p y } ( \arg \operatorname* { m a x } _ { A ^ { - } } \frac { \Delta C L I I P } { \Delta L a t e n c y } ) , } \\ & { \mathrm { ~ \hat { \epsilon } ~ } _ { \theta } \gets \mathrm { e v o l v e } ( \hat { \epsilon } _ { \theta } , \{ \hat { A } \} ) } \end{array}$ end if end if end while
110
+
111
+ # 4 Step Distillation
112
+
113
+ Besides proposing the efficient architecture of the diffusion model, we further consider reducing the number of iterative denoising steps for UNet to achieve more speedup. We follow the research direction of step distillation [33], where the inference steps are reduced by distilling the teacher, e.g., at 32 steps, to a student that runs at fewer steps, e.g., 16 steps. This way, the student enjoys $2 \times$ speedup against the teacher. Here we employ different distillation pipelines and learning objectives from existing works [33, 32] to improve the image quality, which we elaborate on as follows.
114
+
115
+ # 4.1 Overview of Distillation Pipeline
116
+
117
+ Citing the wisdom from previous studies [33, 32], step distillation works best with the $\mathbf { v }$ -prediction type, i.e., UNet outputs velocity v [33] instead of the noise $\epsilon$ . Thus, we fine-tune SD-v1.5 to vprediction (for notation clarity, we use $\hat { \mathbf { v } } _ { \pmb { \theta } }$ to mean the SD model in $\mathbf { v }$ -prediction vs. its $\epsilon$ -prediction counterpart $\hat { \epsilon } _ { \pmb { \theta } }$ ) before step distillation, with the following original loss $\mathcal { L } _ { \mathrm { o r i } }$ :
118
+
119
+ $$
120
+ \begin{array} { r } { \mathcal { L } _ { \mathrm { o r i } } = \mathbb { E } _ { t \sim U [ 0 , 1 ] , \mathbf { x } \sim p _ { \mathrm { d a t a } } ( \mathbf { x } ) , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } ) } \ | | \hat { \mathbf { v } } _ { \boldsymbol { \theta } } ( t , \mathbf { z } _ { t } , \mathbf { c } ) - \mathbf { v } | | _ { 2 } ^ { 2 } , } \end{array}
121
+ $$
122
+
123
+ where $\mathbf { v }$ is the ground-truth target velocity, which can be derived analytically from the clean latent $\mathbf { x }$ and noise $\epsilon$ given time step $t$ : $\mathbf { v } \equiv \alpha _ { t } \epsilon - \sigma _ { t } \mathbf { x }$ .
124
+
125
+ Our distillation pipeline includes three steps. First, we do step distillation on SD-v1.5 to obtain the UNet with 16 steps that reaches the performance of the 50-step model. Note here we use a 32-step SD-v1.5 to perform distillation directly, instead of doing it progressively, e.g., using a 128-step model as a teacher to obtain the 64-step model and redo the distillation progressively. The reason is that we empirically observe that progressive distillation is slightly worse than direct distillation (see Fig. 6(a)
126
+
127
+ for details). Second, we use the same strategy to get our 16-step efficient UNet. Finally, we use the 16-step SD-v1.5 as the teacher to conduct step distillation on the efficient UNet that is initialized from its 16-step counterpart. This will give us the 8-step efficient UNet, which is our final UNet model.
128
+
129
+ # 4.2 CFG-Aware Step Distillation
130
+
131
+ We introduce the vanilla step distillation loss first, then elaborate more details on our proposed CFG-aware step distillation (Fig. 3).
132
+
133
+ Vanilla Step Distillation. Given the UNet inputs, time step $t$ , noisy latent $\mathbf { z } _ { t }$ , and text embedding c, the teacher UNet performs two DDIM denoising steps, from time $t$ to $t ^ { \prime }$ and then to $t ^ { \prime \prime }$ ( $0 \leq t ^ { \prime \prime } <$ $t ^ { \prime } < t \leq 1$ ). This process can be formulated as (see the Sec. C for detailed derivations),
134
+
135
+ $$
136
+ \begin{array} { r l } & { \quad \hat { \mathbf { v } } _ { t } = \hat { \mathbf { v } } _ { \theta } \big ( t , \mathbf { z } _ { t } , \mathbf { c } \big ) \Rightarrow \mathbf { z } _ { t ^ { \prime } } = \alpha _ { t ^ { \prime } } \big ( \alpha _ { t } \mathbf { z } _ { t } - \sigma _ { t } \hat { \mathbf { v } } _ { t } \big ) + \sigma _ { t ^ { \prime } } \big ( \sigma _ { t } \mathbf { z } _ { t } + \alpha _ { t } \hat { \mathbf { v } } _ { t } \big ) , } \\ & { \quad \hat { \mathbf { v } } _ { t ^ { \prime } } = \hat { \mathbf { v } } _ { \theta } \big ( t ^ { \prime } , \mathbf { z } _ { t ^ { \prime } } , \mathbf { c } \big ) \Rightarrow \mathbf { z } _ { t ^ { \prime \prime } } = \alpha _ { t ^ { \prime \prime } } \big ( \alpha _ { t ^ { \prime } } \mathbf { z } _ { t ^ { \prime } } - \sigma _ { t ^ { \prime } } \hat { \mathbf { v } } _ { t ^ { \prime } } \big ) + \sigma _ { t ^ { \prime \prime } } \big ( \sigma _ { t ^ { \prime } } \mathbf { z } _ { t ^ { \prime } } + \alpha _ { t ^ { \prime } } \hat { \mathbf { v } } _ { t ^ { \prime } } \big ) . } \end{array}
137
+ $$
138
+
139
+ The student UNet, parameterized by $\eta$ , performs only one DDIM denoising step,
140
+
141
+ $$
142
+ \hat { \mathbf { v } } _ { t } ^ { ( s ) } = \hat { \mathbf { v } } _ { \eta } ( t , \mathbf { z } _ { t } , \mathbf { c } ) \Rightarrow \hat { \mathbf { x } } _ { t } ^ { ( s ) } = \alpha _ { t } \mathbf { z } _ { t } - \sigma _ { t } \hat { \mathbf { v } } _ { t } ^ { ( s ) } ,
143
+ $$
144
+
145
+ where the super-script $( s )$ indicates these variables are for the student UNet. The student UNet is supposed to predict the teacher’s noisy latent $\mathbf { z } _ { t ^ { \prime \prime } }$ from $\mathbf { z } _ { t }$ with just one denoising step. This goal translates to the following vanilla distillation loss objective calculated in the $\mathbf { x }$ -space [33, 32],
146
+
147
+ $$
148
+ \mathcal { L } _ { \mathrm { v a n i \_ d s t l } } = \varpi ( \lambda _ { t } ) \parallel \hat { \mathbf { x } } _ { t } ^ { ( s ) } - \frac { \mathbf { z } _ { t ^ { \prime \prime } } - \frac { \sigma _ { t ^ { \prime \prime } } } { \sigma _ { t } } \mathbf { z } _ { t } } { \alpha _ { t ^ { \prime \prime } } - \frac { \sigma _ { t ^ { \prime \prime } } } { \sigma _ { t } } \alpha _ { t } } \parallel _ { 2 } ^ { 2 } ,
149
+ $$
150
+
151
+ where $\begin{array} { r } { \varpi ( \lambda _ { t } ) = \operatorname* { m a x } ( \frac { \alpha _ { t } ^ { 2 } } { \sigma _ { t } ^ { 2 } } , 1 ) } \end{array}$ is the truncated SNR weighting coefficients [33].
152
+
153
+ CFG-Aware Step Distillation. The above vanilla step distillation can improve the inference speed with no (or only little) FID compromised. However, we do observe the CLIP score turns obviously worse. As a remedy, this section introduces a classifier-free guidance-aware (CFG-aware) distillation loss objective function, which will be shown to improve the CLIP score significantly.
154
+
155
+ We propose to perform classifier-free guidance to both the teacher and student before calculating the loss. Specifically, for Eq. (7) and (8), after obtaining the $\mathbf { v }$ -prediction output of UNet, we add the CFG step. Take Eq. (8) for an example, $\hat { \mathbf { v } } _ { t } ^ { ( s ) }$ is replaced with the following guided version,
156
+
157
+ $$
158
+ \tilde { \mathbf { v } } _ { t } ^ { ( s ) } = w \hat { \mathbf { v } } _ { \eta } ( t , \mathbf { z } _ { t } , \mathbf { c } ) - ( w - 1 ) \hat { \mathbf { v } } _ { \eta } ( t , \mathbf { z } _ { t } , \emptyset ) ,
159
+ $$
160
+
161
+ where $w$ is the CFG scale. In the experiments, $w$ is randomly sampled from a uniform distribution over a range ([2, 14] by default) – this range is called $C F G$ range, which will be shown to provide a way to tradeoff FID and CLIP score during training.
162
+
163
+ After replacing the UNet output with its guided version, all the other procedures remain the same for both the teacher and the student. This gives us a counterpart version of $\mathcal { L } _ { \mathrm { v a n i \_ d s t l } }$ – which we term CFG distillation loss, denoted as Lcfg_dstl.
164
+
165
+ Total Loss Function. Empirically, we find $\mathcal { L } _ { \mathrm { v a n i \_ d s t l } }$ helps to achieve low FID while $\mathcal { L } _ { \mathrm { c f g \_ d s t l } }$ helps to achieve high CLIP score (see Fig. 6(c)). To get the best of both worlds, we introduce a loss mixing scheme to use the two losses at the same time $- \mathbf { A }$ predefined $C F G$ probability $p$ is introduced, indicating the probability of using the CFG distillation loss in each training iteration (so with $1 - p$ probability, the vanilla distillation loss is used). Now, the overall loss can be summarized:
166
+
167
+ $$
168
+ \begin{array} { r l r } & { } & { \mathcal { L } = \mathcal { L } _ { \mathrm { d s t l } } + \gamma \mathcal { L } _ { \mathrm { o r i } } , } \\ & { } & { \mathcal { L } _ { \mathrm { d s t l } } = \mathcal { L } _ { \mathrm { c f g \_ d s t l } } \mathrm { i f } P \sim U [ 0 , 1 ] < p \mathrm { e l s e } \mathcal { L } _ { \mathrm { v a n i \_ d s t l } } , } \end{array}
169
+ $$
170
+
171
+ where $\mathcal { L } _ { \mathrm { o r i } }$ represents the original denoising loss in Eq. (6) and $\gamma$ is its weighting factor; and $U [ 0 , 1 ]$ represents the uniform distribution over range $( 0 , 1 )$ .
172
+
173
+ Discussion. As far as we know, only one very recent work [32] studies how to distill the guided diffusion models. They propose to distill CFG into a student model with extra parameters (called $w$ -condition) to mimic the behavior of CFG. Thus, the network evaluation cost is reduced by $2 \times$ when generating an image. Our proposed solution here is distinct from theirs [32] for at least four perspectives. (1) The general motivations are different. Their $w$ -condition model intends to reduce the number of network evaluations of UNet, while ours aims to improve the image quality during distillation. (2) The specific proposed techniques are different – they integrate the CFG scale as an input to the UNet, which results in more parameters, while we do not. (3) Empirically, $w \cdot$ -condition model cannot achieve high CLIP scores when the CFG scale is large (as in Fig. 6(b)), while our method is particularly good at generating samples with high CLIP scores. (4) Notably, the trade-off of diversity-quality is previously enabled only during inference by adjusting the CFG scale, while our scheme now offers a nice property to realize such trade-off during training (see Fig. 6(d)), which $w$ -condition cannot achieve. This can be very useful for model providers to train different models in favor of quality or diversity.
174
+
175
+ # 5 Experiment
176
+
177
+ Implementation Details. Our code is developed based on diffusers library3. Given step distillation is mostly conducted on v-prediction models [33, 32], we fine-tune UNet in our experiments to vprediction. Similar to SD, we train our models on public datasets [51, 40] to report the quantitative results, i.e., FID and CLIP scores (ViT-g/14), on MS-COCO 2014 validation set [50] for zero-shot evaluation, following the common practice [20, 19, 6, 18]. In addition, we collect an internal dataset with high-resolution images to fine-tune our model for more pleasing visual quality. We use 16 or 32 nodes for most of the training. Each node has 8 NVIDIA A100 GPUs with 40GB or 80GB memory. We use AdamW optimizer [52], set weight decay as 0.01, and apply training batch size as 2, 048.
178
+
179
+ Table 2: Zero-shot evaluation on MS-COCO 2017 5K subset. Our efficient model is compared against recent arts in the 8-step configuration. Note the compared works use the same model as SD-v1.5, which is much slower than our approach.
180
+
181
+ <table><tr><td>Method</td><td>Steps</td><td>FID</td><td>CLIP</td></tr><tr><td>DPM [53]</td><td>8</td><td>31.7</td><td>0.32</td></tr><tr><td>DPM++ [54]</td><td>8</td><td>25.6</td><td>0.32</td></tr><tr><td>Meng et al. [32]</td><td>8</td><td>26.9</td><td>0.30</td></tr><tr><td>Ours</td><td>8</td><td>24.2</td><td>0.30</td></tr></table>
182
+
183
+ ![](images/a2188bd647f5bd01a84fcc5a864c8b3b4e580b5eee4987fa1a335887de66ce09.jpg)
184
+ Figure 4: FID vs. CLIP on MS-COCO 2014 validation set with CFG scale from 1.0 to 10.0. Left: Comparison with SD-v1.5 on full set (30K). Right: Different settings for step and teacher models tested on 6K samples.
185
+
186
+ # 5.1 Text-to-Image Generation
187
+
188
+ We first show the comparison with SD-v1.5 on the full MS-COCO 2014 validation set [50] with 30K image-caption pairs. As in Fig. 4 (left), thanks to the architecture improvements and the dedicated loss design for step distillation, our final 8-step, 230ms per step UNet outperforms the original SD-v1.5 in terms of the trade-off between FID vs. CLIP. For the most user-preferable guidance scales (ascending part of the curve), our UNet gives about $0 . 0 0 4 - 0 . 0 1 0$ higher CLIP score under the same FID level. In addition, with an aligned sampling schedule (8 DDIM denoising steps), our method also outperforms the very recent distillation work [32] by 2.7 FID with on-par CLIP score, as in Tab. 2. Example synthesized images from our approach are presented in Fig. 1. Our model can generate images from text prompts with high fidelity. More examples are shown in Fig. 9.
189
+
190
+ We then provide more results for performing step distillation on our efficient UNet. As in Fig. 4 (right), we demonstrate that our 16-step undistilled model provides competitive performance against SD-v1.5. However, we can see a considerable performance drop when the denoising step is reduced to 8. We apply progressive (vanilla) distillation [33, 32] and observe improvements in scores. Though mostly comparable to the SD-v1.5 baseline, the performance of the 8-step model gets saturated for the CLIP score as the guidance scale increases, and is capped at 0.30. Finally, we use the proposed CFG-aware step distillation and find it consistently boosts the CLIP score of the 8-step model with varied configurations. Under the best-observed configuration (CFG distilled 16-step teacher), our 8-step model is able to surpass SD-v1.5 by $0 . 0 0 2 \mathrm { - } 0 . 0 0 7$ higher CLIP under similar FID. Discussions on the hyperparameters can be found in ablation studies.
191
+
192
+ ![](images/019cbcabdc57c29c3b60afbd8762082fd54a0fc2aa8076e4371fb43754a7d771.jpg)
193
+ Figure 5: Advantages of robust training. Prompts of top row: a photo of an astronaut riding a horse on mars and bottom row: A pikachu fine dining with a view to the Eiffel Tower. (a) Images from SD-v1.5. (b) Removing cross-attention (CA) blocks in downsample stage of SD-v1.5. (c) - (e) Removing cross-attention (CA) blocks in {downsample (DS), middle (mid.), upsample (US)} using our model after robust training. (f) - (h) Removing ResNet blocks (RB) in different stages using our model. The model with robust training maintains reasonable performance after dropping blocks.
194
+
195
+ # 5.2 Ablation Analysis
196
+
197
+ Here we present the key ablation studies for the proposed approach. For faster evaluation, we test the settings on 6K image-caption pairs randomly sampled from the MS-COCO 2014 validation set [50].
198
+
199
+ Robust Training. As in Fig. 5, we verify the effectiveness of the proposed robust training paradigm. The original model is sensitive to architecture permutations, which makes it difficult to assess the value score of the building blocks (Fig. 5(b)). In contrast, our robust trained model can be evaluated under the actions of architecture evolution, even if multiple blocks are ablated at a time. With the proposed strategy, we preserve the performance of pre-trained SD and save the fine-tuning cost to recover the performance of candidate offspring networks. In addition, we gather some insights into the effect of different building blocks and ensure the architecture permutation is interpretable. Namely, cross-attention is responsible for semantic coherency (Fig. 5(c)-(e)), while ResNet blocks capture local information and are critical to the reconstruction of details (Fig. 5(f)-(h)), especially in the output upsampling stage.
200
+
201
+ Step Distillation. We perform comprehensive comparisons for step distillation discussed in Sec. 4.
202
+ For the following comparisons, we use the same model as SD-v1.5 to study step distillation.
203
+ • Fig. 6(a) presents the comparison of progressive distillation to 8 steps vs. direct distillation to 8 steps. As seen, direct distillation wins in terms of both FID and CLIP score. Besides, it is procedurally simpler. Thus, we adopt direct distillation in our proposed algorithm.
204
+ • Fig. 6(b) depicts the results of $w$ -conditioned models [32] at different inference steps. They are obtained through progressive distillation, i.e., $6 4 3 2 1 6 8$ . As seen, there is a clear gap between $w$ -conditioned models and the other two, especially in terms of CLIP score. In contrast, our 8-step model can significantly outperform the 50-step SD-v1.5 in terms of CLIP score and maintain a similar FID. Comparing ours (8-step model) to the $w$ -conditioned 16-step model, one point of particular note is that, these two schemes have the same inference cost, while ours obviously wins in terms of both FID and CLIP score, suggesting that our method offers a better solution to distilling CFG guided diffusion models.
205
+ • Fig. 6(c) shows the effect of our proposed CFG distillation loss vs. the vanilla distillation loss. As seen, the vanilla loss achieves the lowest FID, while the CFG loss achieves the highest CLIP score. To get the best of both worlds, the proposed loss mixing scheme (see “vanilla $+ \mathrm { C F G }$ distill”) successfully delivers a better tradeoff: it achieves the similar highest CLIP score as the CFG loss alone and the similar lowest FID as the vanilla loss alone.
206
+ • There are two hyper-parameters in the proposed CFG distillation loss: CFG range and CFG probability. Fig. 6(d) shows the effect of adjusting them. Only using the vanilla loss (the blue line) and only using the CFG loss (the purple line) lay down two extremes. By adjusting the CFG range and probability, we can effectively find solutions in the middle of the two extremes. As a rule of thumb, higher CFG probability and larger CFG range will increase the impact of CFG loss, leading to better CLIP score but worse FID. Actually, for the 7 lines listed top to down in the legend, the
207
+
208
+ ![](images/6801c5bab93bb95fd8c64cedd9134f9093413d780394d9cc5f934998d7aa26b5.jpg)
209
+ Figure 6: Ablation studies in step distillation (best viewed in color). For each line, from left to right, the CFG scales starts from 1.0 to 10.5 with interval 0.5. (a) To obtain the same 8-step student model, in direct distillation, the teacher only distills once $( 1 6 8 )$ ), while progressive distillation [33, 32] starts from the 64-step teacher, distills 3 times to 8 steps $\ 6 4 3 2 1 6 8 )$ ). (b) $w$ -conditioned model [32] struggles at achieving high CLIP scores (such as over 0.30) while the original SD-v1.5 and our distilled 8-step SD-v1.5 can easily achieve so. (c) Comparison between vanilla distillation loss $\mathcal { L } _ { \mathrm { v a n i \_ d s t l } }$ , the proposed CFG distillation loss $\mathcal { L } _ { \mathrm { c f g \_ d s t l } }$ , and their mixed version ${ \mathcal { L } } _ { \mathrm { d s t l } }$ . (d) Effect of adjusting the two hyper-parameters, CFG range and CFG probability, in CFG distillation. As seen, these hyper-parameters can effectively tradeoff FID and CLIP score.
210
+
211
+ impact of CFG loss is gradually raised, and we observe the corresponding lines move steadily to the upper right, fully in line with our expectation, suggesting these two hyper-parameters provide a very reliable way to tradeoff FID and CLIP score during training – this feature, as far as we know, has not been reported by any previous works.
212
+
213
+ Analysis of Original Loss for Distillation. In Eq. (11), we apply the original denoising loss $\mathcal { L } _ { \mathrm { o r i } }$ in Eq. (6)) during the step distillation. Here we show more analysis for the using $\mathcal { L } _ { \mathrm { o r i } }$ in step distillation.
214
+
215
+ • Fig. 7(a) shows the comparison between using and not using the original loss in our proposed CFG distillation method. To our best knowledge, existing step distillation approaches [33, 32] do not include the original loss in their total loss objectives, which is actually sub-optimal. Our results in Fig. 7(a) suggest that using the original loss can help lower the FID at no loss of CLIP score. • Fig. 7(b) provides a detailed analysis using different $\gamma$ to balance the original denoising loss and the CFG distillation loss in Eq. (11). We empirically set a dynamic gamma to adjust the original loss into a similar scale to step distillation loss.
216
+
217
+ Analysis for the Number of Inference Steps of the Teacher Model. For the default training setting of the step distillation, the student runs one DDIM step while the teacher runs two steps, e.g., distilling a 16-step teacher to an 8-step student. At the first glance, if the teacher runs more steps, it possibly provides better supervision to the student, e.g., distilling a 32-step teacher to the 8-step student. Here we provide empirical results to show that the approach actually does not perform well.
218
+
219
+ Fig. 7(c) presents the FID and CLIP score plots of different numbers of steps of the teacher model in vanilla step distillation. As seen, these teachers achieve similar lowest FID, while the 16-step teacher (blue line) achieves the best CLIP score. A clear pattern is that the more steps of the teacher model, the worse CLIP score of the student. Based on this empirical evidence, we adopt the 16-step teacher setting in our pipeline to get 8-step models.
220
+
221
+ Applying Step Distillation to Other Model. Lastly, we conduct the experiments by applying our proposed CFG-aware distillation on SD-v2, where the student model has the same architecture as SD-v2. The results are provided in Fig. 7(d). As can be seen, our 8-step distilled model achieves comparable performance to the 50-step SD-v2 model. We use the same hyper-parameters from the training of SD-v1.5 for the step distillation of SD-v2, and further tuning might lead to better results.
222
+
223
+ # 6 Related Work
224
+
225
+ Recent efforts on text-to-image generation utilize denoising diffusion probabilistic models [55, 35, 56, 1, 2, 4] to improve the synthesis quality by conducting training on the large-scale dataset [40]. However, the deployment of these models requests high-end GPUs for reasonable inference speed due to the tens or hundreds of iterative denoising steps and the huge computation cost of the diffusion model. This limitation has spurred interest from both the academic community and industry to optimize the efficiency of diffusion models, with two primary approaches being explored: improving the sampling process [57, 58, 59, 60, 53, 61] and investigating on-device solutions [62].
226
+
227
+ ![](images/d6d832fa2cadb1b469b0a15e32cf239a74f99e1b57bcae5c17e34aa6681e2e18.jpg)
228
+ Figure 7: FID and CLIP results on the 6K samples from the MS-COCO 2014 validation set [50] for various models and experimental settings. (a) Comparison between using (red line) and not using (orange line) the original loss in our proposed CFG distillation method. The hyper-parameter setup of “ours” experiments: CFG range [2, 14] and CFG probability 0.1. (b) Analysis of loss scaling $\gamma$ in Eq. (11). Note that we employ dynamic scaling to adjust original loss $( \mathcal { L } _ { \mathrm { o r i } } )$ into a similar scale of step distillation loss $( \mathcal { L } _ { \mathrm { d s t l } } )$ . We show $\gamma$ as 0.01, 0.2, 1.0. Our choice (0.2) gives slightly better FID, despite all dynamic scalings resulting in very similar results. We further show results of constant scaling. Here 0.0 indicates no $\mathcal { L } _ { \mathrm { o r i } }$ added, while 1.0 refers to non-scaled $\mathcal { L } _ { \mathrm { o r i } }$ where $\mathcal { L } _ { \mathrm { o r i } }$ dominates the optimization and degrades the effect of step distillation. (c) Analysis for the number of steps for the teacher model in vanilla step distillation. The student is supposed to run at 8 steps, and we can actually employ different teachers that run at different numbers of steps during the step distillation. The default setting in our experiment is that teacher 16 steps, student 8 steps, i.e., the blue line, which turns out to be the best. (d) Results of our proposed CFG-aware step distillation applied on SD-v2.
229
+
230
+ One promising area for reducing the denoising steps is through progressive distillation, where the sampling steps are gradually reduced by distillation that starts from a pre-trained teacher [33]. The later work further improves the inference cost of classifier-free guidance [34] by introducing the $w$ -condition [32]. Our work follows the path of step distillation while holding significant differences with existing work, which is discussed above (Sec. 4). Another direction studies the methods for optimizing the model runtime on devices [63], such as post-training quantization [22, 23] and GPUaware optimization [24]. Nonetheless, these works require specific hardware or compiler support. Our work is orthogonal to post optimizations and can be combined with them for further speed up. We target developing a generic and efficient network architecture that can run fast on mobile devices without relying on specific bit width or compiler support. We identify the redundancy in the SD and introduce one with a similar quality while being significantly faster.
231
+
232
+ # 7 Discussion and Conclusion
233
+
234
+ This work proposes the fastest on-device text-to-image model that runs denoising in 1.84 seconds with image quality on par with Stable Diffusion. To build such a model, we propose a series of novel techniques, including analyzing redundancies in the denoising UNet, proposing the evolving-training framework to obtain the efficient UNet model, and improving the step distillation by introducing the CFG-aware distillation loss. We perform extensive experiments and validate that our model can achieve similar or even better quality compared to Stable Diffusion while being significantly faster.
235
+
236
+ Limitation. While our approach is able to run the large-scale text-to-image diffusion model on mobile devices with ultra-fast speed, the model still holds a relatively large number of parameters. Another promising direction is to reduce the model size to make it more compatible with various edge devices. Furthermore, most of our latency analysis is conducted on iPhone $1 4 ~ \mathrm { P r o }$ , which has more computation power than many other phones. How to optimize our models for other mobile devices to achieve fast inference speed is also an interesting topic to study.
237
+
238
+ Broader Impacts. Similar to existing studies on content generation, our approach must be applied cautiously so that it will not be used for malicious applications. Such concerns can also be alleviated by approaches that could automatically detect image content that violates specific regulations.
239
+
240
+ References
241
+ [1] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020. 1, 2, 9
242
+ [2] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020. 1, 2, 9
243
+ [3] Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems, 34:8780–8794, 2021. 1
244
+ [4] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10684–10695, 2022. 1, 2, 3, 5, 9, 14, 16
245
+ [5] 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. 1
246
+ [6] 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. 1, 7
247
+ [7] 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. 2
248
+ [8] Chitwan Saharia, William Chan, Huiwen Chang, Chris Lee, Jonathan Ho, Tim Salimans, David Fleet, and Mohammad Norouzi. Palette: Image-to-image diffusion models. In ACM SIGGRAPH 2022 Conference Proceedings, pages 1–10, 2022. 2
249
+ [9] Huiwen Chang, Han Zhang, Jarred Barber, AJ Maschinot, Jose Lezama, Lu Jiang, Ming-Hsuan Yang, Kevin Murphy, William T Freeman, Michael Rubinstein, et al. Muse: Text-to-image generation via masked generative transformers. arXiv preprint arXiv:2301.00704, 2023. 2
250
+ [10] Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, and Luc Van Gool. Repaint: Inpainting using denoising diffusion probabilistic models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11461–11471, 2022. 2
251
+ [11] Zhixing Zhang, Ligong Han, Arnab Ghosh, Dimitris N Metaxas, and Jian Ren. Sine: Single image editing with text-to-image diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6027–6037, 2023. 2
252
+ [12] 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. 2
253
+ [13] Jonathan Ho, William Chan, Chitwan Saharia, Jay Whang, Ruiqi Gao, Alexey Gritsenko, Diederik P Kingma, Ben Poole, Mohammad Norouzi, David J Fleet, et al. Imagen video: High definition video generation with diffusion models. arXiv preprint arXiv:2210.02303, 2022. 2
254
+ [14] Uriel Singer, Adam Polyak, Thomas Hayes, Xi Yin, Jie An, Songyang Zhang, Qiyuan Hu, Harry Yang, Oron Ashual, Oran Gafni, et al. Make-a-video: Text-to-video generation without text-video data. arXiv preprint arXiv:2209.14792, 2022. 2
255
+ [15] Xiaohui Zeng, Arash Vahdat, Francis Williams, Zan Gojcic, Or Litany, Sanja Fidler, and Karsten Kreis. Lion: Latent point diffusion models for 3d shape generation. arXiv preprint arXiv:2210.06978, 2022. 2
256
+ [16] Chen-Hsuan Lin, Jun Gao, Luming Tang, Towaki Takikawa, Xiaohui Zeng, Xun Huang, Karsten Kreis, Sanja Fidler, Ming-Yu Liu, and Tsung-Yi Lin. Magic3d: High-resolution text-to-3d content creation. arXiv preprint arXiv:2211.10440, 2022. 2
257
+ [17] Ben Poole, Ajay Jain, Jonathan T Barron, and Ben Mildenhall. Dreamfusion: Text-to-3d using 2d diffusion. arXiv preprint arXiv:2209.14988, 2022. 2
258
+ [18] Jiahui Yu, Yuanzhong Xu, Jing Yu Koh, Thang Luong, Gunjan Baid, Zirui Wang, Vijay Vasudevan, Alexander Ku, Yinfei Yang, Burcu Karagol Ayan, et al. Scaling autoregressive models for content-rich text-to-image generation. arXiv preprint arXiv:2206.10789, 2022. 2, 7
259
+ [19] Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily L Denton, Kamyar Ghasemipour, Raphael Gontijo Lopes, Burcu Karagol Ayan, Tim Salimans, et al. Photorealistic text-toimage diffusion models with deep language understanding. Advances in Neural Information Processing Systems, 35:36479–36494, 2022. 2, 7, 15
260
+ [20] Yogesh Balaji, Seungjun Nah, Xun Huang, Arash Vahdat, Jiaming Song, Karsten Kreis, Miika Aittala, Timo Aila, Samuli Laine, Bryan Catanzaro, et al. ediffi: Text-to-image diffusion models with an ensemble of expert denoisers. arXiv preprint arXiv:2211.01324, 2022. 2, 7, 15
261
+ [21] William Peebles and Saining Xie. Scalable diffusion models with transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 4195–4205, 2023. 2
262
+ [22] Xiuyu Li, Long Lian, Yijiang Liu, Huanrui Yang, Zhen Dong, Daniel Kang, Shanghang Zhang, and Kurt Keutzer. Q-diffusion: Quantizing diffusion models. arXiv preprint arXiv:2302.04304, 2023. 2, 10
263
+ [23] Jilei Hou and Ziad Asghar. World’s first on-device demonstration of stable diffusion on an android phone, 2023. 2, 10
264
+ [24] Yu-Hui Chen, Raman Sarokin, Juhyun Lee, Jiuqiang Tang, Chuo-Ling Chang, Andrei Kulik, and Matthias Grundmann. Speed is all you need: On-device acceleration of large diffusion models via gpu-aware optimizations. arXiv preprint arXiv:2304.11267, 2023. 2, 10
265
+ [25] Yuzhang Shang, Zhihang Yuan, Bin Xie, Bingzhe Wu, and Yan Yan. Post-training quantization on diffusion models. arXiv preprint arXiv:2211.15736, 2022. 2
266
+ [26] Tri Dao, Dan Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. Flashattention: Fast and memory-efficient exact attention with io-awareness. Advances in Neural Information Processing Systems, 35:16344–16359, 2022. 2
267
+ [27] Qing Jin, Jian Ren, Oliver J Woodford, Jiazhuo Wang, Geng Yuan, Yanzhi Wang, and Sergey Tulyakov. Teachers do more than teach: Compressing image-to-image models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 13600–13611, 2021. 2
268
+ [28] Geng Yuan, Yanyu Li, Sheng Li, Zhenglun Kong, Sergey Tulyakov, Xulong Tang, Yanzhi Wang, and Jian Ren. Layer freezing & data sieving: Missing pieces of a generic framework for sparse training. arXiv preprint arXiv:2209.11204, 2022. 2
269
+ [29] Yanyu Li, Geng Yuan, Yang Wen, Ju Hu, Georgios Evangelidis, Sergey Tulyakov, Yanzhi Wang, and Jian Ren. Efficientformer: Vision transformers at mobilenet speed. arXiv preprint arXiv:2206.01191, 2022. 2
270
+ [30] Yanyu Li, Ju Hu, Yang Wen, Georgios Evangelidis, Kamyar Salahi, Yanzhi Wang, Sergey Tulyakov, and Jian Ren. Rethinking vision transformers for mobilenet size and speed. arXiv preprint arXiv:2212.08059, 2022. 2, 4
271
+ [31] Bo-Kyeong Kim, Hyoung-Kyu Song, Thibault Castells, and Shinkook Choi. On architectural compression of text-to-image diffusion models. arXiv preprint arXiv:2305.15798, 2023. 2
272
+ [32] Chenlin Meng, Ruiqi Gao, Diederik P Kingma, Stefano Ermon, Jonathan Ho, and Tim Salimans. On distillation of guided diffusion models. arXiv preprint arXiv:2210.03142, 2022. 2, 5, 6, 7, 8, 9, 10
273
+ [33] Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. arXiv preprint arXiv:2202.00512, 2022. 2, 5, 6, 7, 9, 10, 16
274
+ [34] Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022. 2, 3, 10
275
+ [35] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pages 2256–2265. PMLR, 2015. 2, 9
276
+ [36] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In MICAI, 2015. 2
277
+ [37] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020. 3
278
+ [38] Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013. 3, 5
279
+ [39] Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In International conference on machine learning, pages 1278–1286. PMLR, 2014. 3, 5
280
+ [40] Christoph Schuhmann, Romain Beaumont, Richard Vencu, Cade Gordon, Ross Wightman, Mehdi Cherti, Theo Coombes, Aarush Katta, Clayton Mullis, Mitchell Wortsman, et al. Laion-5b: An open large-scale dataset for training next generation image-text models. arXiv preprint arXiv:2210.08402, 2022. 3, 7, 9
281
+ [41] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International conference on machine learning, pages 8748–8763. PMLR, 2021. 3, 4
282
+ [42] Zhuang Liu, Jianguo Li, Zhiqiang Shen, Gao Huang, Shoumeng Yan, and Changshui Zhang. Learning efficient convolutional networks through network slimming. In ICCV, 2017. 4
283
+ [43] Yihui He, Xiangyu Zhang, and Jian Sun. Channel pruning for accelerating very deep neural networks. In ICCV, 2017. 4
284
+ [44] Huan Wang, Can Qin, Yulun Zhang, and Yun Fu. Neural pruning via growing regularization. In ICLR, 2021. 4
285
+ [45] Huan Wang and Yun Fu. Trainability preserving neural pruning. In ICLR, 2023. 4
286
+ [46] Barret Zoph and Quoc Le. Neural architecture search with reinforcement learning. In ICLR, 2017. 4
287
+ [47] Thomas Elsken, Jan Hendrik Metzen, and Frank Hutter. Neural architecture search: A survey. JMLR, 20(55):1–21, 2019. 4
288
+ [48] Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In Computer Vision–ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, October 11–14, 2016, Proceedings, Part IV 14, pages 646–661. Springer, 2016. 4
289
+ [49] Jiahui Yu, Linjie Yang, Ning Xu, Jianchao Yang, and Thomas Huang. Slimmable neural networks. arXiv preprint arXiv:1812.08928, 2018. 4
290
+ [50] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In Computer Vision–ECCV 2014: 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V 13, pages 740–755. Springer, 2014. 4, 7, 8, 10, 15
291
+ [51] Minwoo Byeon, Beomhee Park, Haecheon Kim, Sungjun Lee, Woonhyuk Baek, and Saehoon Kim. Coyo-700m: Image-text pair dataset. https://github.com/kakaobrain/coyo-dataset, 2022. 7
292
+ [52] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015. 7
293
+ [53] 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. 7, 10
294
+ [54] Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Dpm-solve $^ { + + }$ : Fast solver for guided sampling of diffusion probabilistic models. arXiv preprint arXiv:2211.01095, 2022. 7
295
+ [55] Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the design space of diffusion-based generative models. arXiv preprint arXiv:2206.00364, 2022. 9
296
+ [56] Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in neural information processing systems, 32, 2019. 9
297
+ [57] 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. 10
298
+ [58] Eric Luhman and Troy Luhman. Knowledge distillation in iterative generative models for improved sampling speed. arXiv preprint arXiv:2101.02388, 2021. 10
299
+ [59] Tim Dockhorn, Arash Vahdat, and Karsten Kreis. Genie: Higher-order denoising diffusion solvers. arXiv preprint arXiv:2210.05475, 2022. 10
300
+ [60] Luping Liu, Yi Ren, Zhijie Lin, and Zhou Zhao. Pseudo numerical methods for diffusion models on manifolds. arXiv preprint arXiv:2202.09778, 2022. 10
301
+ [61] 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. 10
302
+ [62] Atila Orhon, Michael Siracusa, and Aseem Wadhwa. Stable diffusion with core ml on apple silicon, 2022. 10
303
+ [63] Muyang Li, Ji Lin, Chenlin Meng, Stefano Ermon, Song Han, and Jun-Yan Zhu. Efficient spatially sparse inference for conditional gans and diffusion models. arXiv preprint arXiv:2211.02048, 2022. 10
304
+ [64] Tensorrt. https://developer.nvidia.com/tensorrt. 14
305
+
306
+ # A Efficient UNet
307
+
308
+ We provide the detailed architecture of our efficient UNet in Tab. 3. We perform denoising diffusion in latent space [4]. Consequently, the input and output resolution for UNet is $\frac { H } { 8 } \times \frac { W } { 8 }$ W8 , which is $6 4 \times 6 4$ for generating an image of $5 1 2 \times 5 1 2$ .
309
+
310
+ In the main paper, we mainly benchmark the latency on iPhone 14 pro. Here we provide the runtine of the model on more mobile devices in Tab. 4.
311
+
312
+ In addition to mobile phones, we show the latency and memory benchmarks on Nvidia A100 40G GPU, as in Tab. 5. We demonstrate that our efficient UNet achieves over $1 2 \times$ speedup compared to the original SD-v1.5 on a server-level GPU and shrinks $4 6 \%$ running memory. The analysis is performed via the public TensorRT [64] library in single precision.
313
+
314
+ Table 3: Detailed architecture of our efficient UNet model.
315
+
316
+ <table><tr><td rowspan=2 colspan=1>Stage</td><td rowspan=2 colspan=1>Resolution</td><td rowspan=2 colspan=1>Type</td><td rowspan=2 colspan=1>Config</td><td rowspan=1 colspan=2>UNet Model</td></tr><tr><td rowspan=1 colspan=2>Origin Ours</td></tr><tr><td rowspan=4 colspan=1>Down-1</td><td rowspan=4 colspan=1>H×W</td><td rowspan=2 colspan=1>CrossAttention</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=2>320</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=2 colspan=1>ResNet</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>320</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=4 colspan=1>Down-2</td><td rowspan=4 colspan=1>1×W</td><td rowspan=2 colspan=1>CrossAttention</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>64</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=2 colspan=1>ResNet</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>640</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=4 colspan=1>Down-3</td><td rowspan=4 colspan=1>品×W</td><td rowspan=2 colspan=1>CrossAttention</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>1280</td><td rowspan=1 colspan=1>30</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=2 colspan=1>ResNet</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>30</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=4 colspan=1>Mid</td><td rowspan=4 colspan=1>H×W6464</td><td rowspan=2 colspan=1>CrossAttention</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>1280</td><td rowspan=1 colspan=1>30</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=2 colspan=1>ResNet</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>30</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>4</td></tr><tr><td rowspan=4 colspan=1>Up-1</td><td rowspan=4 colspan=1>品×W</td><td rowspan=2 colspan=1>CrossAttention</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>30</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>6</td></tr><tr><td rowspan=2 colspan=1>ResNet</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>30</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=4 colspan=1>Up-2</td><td rowspan=4 colspan=1>1×W</td><td rowspan=2 colspan=1>CrossAttention</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>64</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>3</td></tr><tr><td rowspan=2 colspan=1>ResNet</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>64</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>3</td></tr><tr><td rowspan=4 colspan=1>Up-3</td><td rowspan=4 colspan=1>H×W8</td><td rowspan=2 colspan=1>CrossAttention</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>32</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>0</td></tr><tr><td rowspan=2 colspan=1>ResNet</td><td rowspan=1 colspan=1>Dimension</td><td rowspan=1 colspan=1>32</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>#Blocks</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>3</td></tr></table>
317
+
318
+ Table 4: Latency benchmark on iPhone12 Pro Max, iPhone13 Pro Max, and iPhone 14 Pro.
319
+
320
+ <table><tr><td>Device</td><td>Text Encoder (ms)</td><td>UNet (ms)</td><td>VAE Decoder (ms)</td><td>Overall (s)</td></tr><tr><td>iPhone14 Pro</td><td>4.0</td><td>230</td><td>116</td><td>1.96</td></tr><tr><td>iPhone13 Pro Max</td><td>5.7</td><td>315</td><td>148</td><td>2.67</td></tr><tr><td>iPhone12 Pro Max</td><td>6.3</td><td>526</td><td>187</td><td>4.40</td></tr></table>
321
+
322
+ Table 5: Latency analysis on Nvidia A100 40G GPU with the TensorRT [64] library, tested with single precision (FP32).
323
+
324
+ <table><tr><td>UNet</td><td>Batch Size</td><td>Latency (ms)</td><td>Memory (MB)</td><td>Iters</td><td>Total Latency (ms)</td><td>Speedup</td></tr><tr><td>SD-v1.5</td><td>2</td><td>51.2</td><td>6634</td><td>50</td><td>2,560</td><td>-</td></tr><tr><td>Ours</td><td>2</td><td>26.2</td><td>3549</td><td>8</td><td>209.6</td><td>12.2×</td></tr></table>
325
+
326
+ # B Discussions of Text Encoder and VAE Decoder
327
+
328
+ # B.1 Text Encoder
329
+
330
+ Exiting works have explored the importance of the pre-trained text encoder for generating images [19, 20]. In our work, considering the negligible inference latency (4ms) of the text encoder compared to the UNet and VAE Decoder, we do not compress the text encoder in the released pipeline.
331
+
332
+ # B.2 VAE Decoder
333
+
334
+ We provide qualitative visualizations and quantitive results of our compressed VAE decoder in Fig. 8. The main paper shows that the image decoder constitutes a small portion of inference latency (369ms) compared to the original UNet from SD-v1.5. However, regarding our optimized pipeline $2 3 0 \mathrm { { m s } \times }$ 8 steps), the decoder consumes a considerable portion of overall latency. We propose an effective distillation paradigm to compress the VAE decoder. Specifically, we obtain the latent-image pairs by forwarding the text prompts into the original SD-v1.5 model. The student, which is the compressed decoder, takes the latent from the teacher model as input and generates an output image that is optimized with the ones from the teacher model by the mean squared error. Our proposed method wields the following advantages. First, our approach does not demand paired text-image samples, and it can generate unlimited data on-they-fly, benefiting the generalization of the compressed decoder. Second, the distillation paradigm is simple and straightforward, requiring minimal implementation efforts compared to conventional VAE training. As in Fig. 8, our compressed decoder (116ms) provides comparable generative quality, and the performance degradation compared to the original VAE decoder is negligible.
335
+
336
+ ![](images/e84518cfb29419b5c9caef2f2ba0f686f3d201cc399b489c4115f8a52f049f5b.jpg)
337
+ Figure 8: Evaluation using MS-COCO 2014 validation set [50]. (a) Generated images by using the decoder from SD-v1.5 and our compressed image decoder. The UNet is our efficient UNet, and the guidance scale for CFG is 9.0. (b) Quantitative comparison on the 6K samples. Our compressed decoder performs similarly to the original one considering the widely used CFG scale, i.e., from 7 to 9, and still performs better than the SD-v1.5.
338
+
339
+ # C Detailed Derivations of Step Distillation
340
+
341
+ The following are the detailed derivations of Eq. (7) $\sim$ Eq. (9) in the main paper.
342
+
343
+ Given the UNet inputs, time step $t$ , noisy latent $\mathbf { z } _ { t }$ , and text embedding c, the teacher UNet performs two DDIM denoising steps, from time $t$ to $t ^ { \prime }$ and then to $t ^ { \prime \prime }$ $( 0 \leq t ^ { \prime \prime } < t ^ { \prime } < t \leq 1 )$ ).
344
+
345
+ We first examine the process from $t$ to $t ^ { \prime }$ , which can be formulated as,
346
+
347
+ $$
348
+ \begin{array} { r l } { \hat { \mathbf { v } } _ { t } = \hat { \mathbf { v } } _ { \theta } \big ( t , \mathbf { z } _ { t } , \mathbf { c } \big ) } & { \triangleright \mathtt { T e a c h e r ~ U N e t ~ f i r s t ~ f o r w a r d } } \\ { \Rightarrow \hat { \mathbf { x } } _ { t } = \alpha _ { t } \mathbf { z } _ { t } - \sigma _ { t } \hat { \mathbf { v } } _ { t } , } & { \triangleright \mathtt { T e a c h e r ~ p r e d i c t e d ~ c l e a n ~ l a t e n t ~ a t ~ t i m e ~ } t } \\ { \hat { \epsilon } _ { t } = \sigma _ { t } \mathbf { z } _ { t } + \alpha _ { t } \hat { \mathbf { v } } _ { t } , } & { \triangleright \mathtt { T e a c h e r ~ p r e d i c t e d ~ n o i s e ~ a t ~ t i m e ~ } t } \\ { \Rightarrow \mathbf { z } _ { t ^ { \prime } } = \alpha _ { t ^ { \prime } } \hat { \mathbf { x } } _ { t } + \sigma _ { t ^ { \prime } } \hat { \epsilon } _ { t } } & { \triangleright \mathtt { T e a c h e r ~ p r e d i c t e d ~ n o i s y ~ l a t e n t ~ a t ~ t i m e ~ } t ^ { \prime } } \\ { = \alpha _ { t ^ { \prime } } \big ( \alpha _ { t } \mathbf { z } _ { t } - \sigma _ { t } \hat { \mathbf { v } } _ { t } \big ) + \sigma _ { t ^ { \prime } } \big ( \sigma _ { t } \mathbf { z } _ { t } + \alpha _ { t } \hat { \mathbf { v } } _ { t } \big ) . } \end{array}
349
+ $$
350
+
351
+ The process from $t ^ { \prime }$ to $t ^ { \prime \prime }$ can be derived just like the above, by replacing $t$ and $t ^ { \prime }$ with $t ^ { \prime }$ and $t ^ { \prime \prime }$ , respectively:
352
+
353
+ $$
354
+ \begin{array} { r l } { \hat { \mathbf { v } } _ { t ^ { \prime } } = \hat { \mathbf { v } } _ { \theta } ( t ^ { \prime } , \mathbf { z } _ { t ^ { \prime } } , \mathbf { c } ) } & { \triangleright \operatorname { T e a c h e r ~ U N e t ~ s e c o n d ~ f o r w a r d } } \\ { \Rightarrow \hat { \mathbf { x } } _ { t ^ { \prime } } = \alpha _ { t ^ { \prime } } \mathbf { z } _ { t ^ { \prime } } - \sigma _ { t ^ { \prime } } \hat { \mathbf { v } } _ { t ^ { \prime } } , } & { \triangleright \operatorname { T e a c h e r ~ p r e d i c t e d ~ c l e a n ~ l a t e n t ~ a t ~ t i m e ~ } t ^ { \prime } } \\ { \hat { \mathbf { \epsilon } } _ { t ^ { \prime } } = \sigma _ { t ^ { \prime } } \mathbf { z } _ { t ^ { \prime } } + \alpha _ { t ^ { \prime } } \hat { \mathbf { v } } _ { t ^ { \prime } } , } & { \triangleright \operatorname { T e a c h e r ~ p r e d i c t e d ~ n o i s e ~ a t ~ t i m e ~ } t ^ { \prime } } \\ { \Rightarrow \mathbf { z } _ { t ^ { \prime \prime } } = \alpha _ { t ^ { \prime \prime } } \hat { \mathbf { x } } _ { t ^ { \prime } } + \sigma _ { t ^ { \prime \prime } } \hat { \mathbf { \epsilon } } _ { t ^ { \prime } } } & { \triangleright \operatorname { T e a c h e r ~ p r e d i c t e d ~ n o i s y ~ \mathrm { ~ 1 a t e n t ~ a t ~ t i m e ~ } t ^ { \prime \prime } } } \\ { = \alpha _ { t ^ { \prime \prime } } \left( \alpha _ { t ^ { \prime } } \mathbf { z } _ { t ^ { \prime } } - \sigma _ { t ^ { \prime } } \hat { \mathbf { v } } _ { t ^ { \prime } } \right) + \sigma _ { t ^ { \prime \prime } } \big ( \sigma _ { t } \mathbf { z } _ { t ^ { \prime } } + \alpha _ { t } \hat { \mathbf { v } } _ { t ^ { \prime } } \big ) . } \end{array}
355
+ $$
356
+
357
+ The student UNet, parameterized by $\eta$ , performs only one DDIM denoising step,
358
+
359
+ $$
360
+ \begin{array} { r l } & { \quad \hat { \mathbf { v } } _ { t } ^ { ( s ) } = \hat { \mathbf { v } } _ { \eta } ( t , \mathbf { z } _ { t } , \mathbf { c } ) \quad \mathrm { ~ > ~ S t u d e n t ~ U i v e t ~ f o r a r a r d ~ } } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \times \operatorname { \operatorname { \operatorname { \operatorname* { \operatorname* { m a x } } } } \quad \quad \quad \quad \quad \quad \quad \quad \quad } } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \times \operatorname { \operatorname { \operatorname { \operatorname* { m a x } } } \quad \quad \quad \quad \quad \quad \quad \quad } } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \ \end{array}
361
+ $$
362
+
363
+ where the super-script $( s )$ indicates these variables are for the student UNet. The student UNet is supposed to predict the noisy latent $\mathbf { z } _ { t ^ { \prime \prime } }$ from $\mathbf { z } _ { t }$ of the teacher with just one denoising step, namely,
364
+
365
+ $$
366
+ \begin{array} { r } { \mathbf { z } _ { t ^ { \prime \prime } } ^ { ( s ) } = \mathbf { z } _ { t ^ { \prime \prime } } . } \end{array}
367
+ $$
368
+
369
+ Replacing $\mathbf { z } _ { t ^ { \prime \prime } } ^ { ( s ) }$ with $\mathbf { z } _ { t ^ { \prime \prime } }$ in the final equation of Eq. (14), we arrive at the following loss objective,
370
+
371
+ $$
372
+ \mathcal { L } _ { \mathrm { v a n i \_ d s t l } } = \varpi ( \lambda _ { t } ) \parallel \hat { \mathbf { x } } _ { t } ^ { ( s ) } - \frac { \mathbf { z } _ { t ^ { \prime \prime } } - \frac { \sigma _ { t ^ { \prime \prime } } } { \sigma _ { t } } \mathbf { z } _ { t } } { \alpha _ { t ^ { \prime \prime } } - \frac { \sigma _ { t ^ { \prime \prime } } } { \sigma _ { t } } \alpha _ { t } } \parallel _ { 2 } ^ { 2 } ,
373
+ $$
374
+
375
+ where $\begin{array} { r } { \varpi ( \lambda _ { t } ) = \operatorname* { m a x } ( \frac { \alpha _ { t } ^ { 2 } } { \sigma _ { t } ^ { 2 } } , 1 ) } \end{array}$ is the truncated SNR weighting coefficients [33].
376
+
377
+ # D Different Teacher Options for Step Distillation
378
+
379
+ It is non-trivial to decide the best teacher model to distill our final 8-step efficient UNet. In Fig. 4, we conduct several experiments to explore different teacher options. As straightforward choices, selfdistillation from our 16-step efficient UNet or distillation from the 16-step SD-v1.5 baseline model can effectively boost the performance of our 8-step model. Additionally, we investigate whether stronger teachers can further boost performance by training a CFG-aware distilled 16-step SD-v1.5 model, as discussed in Sec. 4. We obtain significant improvements in CLIP scores, demonstrating the potential of employing better teacher models. We would like to mention that we also experiment with SD-v2 as the teacher model. Surprisingly, we observe much worse results. We attribute this to the different text embeddings used in SD-v1.5 and SD-v2 pipelines. Distillation between different infrastructures might be a possible future direction to explore.
380
+
381
+ # E Additional Qualitative Results
382
+
383
+ We provide more generated images from our text-to-image diffusion model in Fig. 9. As an acceleration work for generic Stable Diffusion [4], our efficient model demonstrates a sufficient capability to synthesize various contents with high aesthetics, such as realistic objects (food, animals), scenery, and artistic and cartoon styles.
384
+
385
+ ![](images/a401f2928996159fb7dcaa5ca6ab39d0f43b06b9bd6b6545ed25db2a279b30d7.jpg)
386
+ Figure 9: Example generated images by using our efficient text-to-image diffusion model.
md/dev/ubzNoJjOKj/ubzNoJjOKj.md ADDED
@@ -0,0 +1,479 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolution
2
+
3
+ Eric Nguyen∗,1, Michael $\mathbf { P o l i ^ { * , 1 } }$ , Marjan Faizi2,∗,
4
+ Armin W. Thomas1, Callum Birch Sykes3, Michael Wornow1, Aman Patel1,
5
+ Clayton Rabideau3, Stefano Massaroli4, Yoshua Bengio4, Stefano Ermon1, Stephen A. Baccus1,†, Christopher $\mathbf { R e ^ { 1 , \dag } }$
6
+
7
+ # Abstract
8
+
9
+ Genomic (DNA) sequences encode an enormous amount of information for gene regulation, protein synthesis, and numerous other cellular properties. Similar to natural language models, researchers have proposed foundation models in genomics to learn generalizable features from unlabeled genome data that can then be fine-tuned for downstream tasks such as identifying regulatory elements. Due to the quadratic scaling of attention, previous Transformer-based genomic models have used 512 to 4k tokens as context $( < 0 . 0 0 1 \%$ of the human genome), significantly limiting the modeling of long-range interactions in DNA. In addition, these methods rely on tokenizers or fixed $\mathbf { k }$ -mers to aggregate meaningful DNA units, losing single nucleotide resolution (i.e. DNA "characters") where subtle genetic variations can completely alter protein function via single nucleotide polymorphisms (SNPs). Recently, Hyena, a large language model based on implicit convolutions was shown to match attention in quality while allowing longer context lengths and lower time complexity. Leveraging Hyena’s new long-range capabilities, we present HyenaDNA, a genomic foundation model pretrained on the human reference genome with context lengths of up to 1 million tokens at the single nucleotide-level – an up to $\mathbf { 5 0 0 x }$ increase over previous dense attentionbased models. HyenaDNA scales sub-quadratically in sequence length (training up to $1 6 0 \mathrm { x }$ faster than Transformer), uses single nucleotide tokens, and has full global context at each layer. We explore what longer context enables - including the first use of in-context learning in genomics for simple adaptation to novel tasks without updating pretrained model weights. On a long-range species classification task, HyenaDNA is able to effectively solve the challenge by increasing the context length to 1M without downsampling. On fine-tuned benchmarks from the Nucleotide Transformer, HyenaDNA reaches state-of-the-art (SotA) on 12 of 18 datasets using a model with orders of magnitude less parameters and pretraining data.2 On the GenomicBenchmarks, HyenaDNA surpasses SotA on 7 of 8 datasets on average by $+ 1 0$ accuracy points, and by as much as $+ 2 0$ accuracy points on enhancer identification. Code available at https://github.com/HazyResearch/hyenadna.
10
+
11
+ ![](images/a289e8bd636ed7c3c6c7802853a22e33c5d6a6b3078867aa01d85aede9d783dc.jpg)
12
+ Figure 1.1: HyenaDNA recipe for long-range foundation models in genomics. The HyenaDNA architecture is a simple stack of Hyena operators [37] trained using next token prediction. (See Fig. 1.3 for block diagram of architecture). We introduce a new sequence length scheduling technique to stabilize training, and provide a method to leverage the longer context length to adapt to novel tasks without standard fine-tuning by filling the context window with learnable soft prompt tokens.
13
+
14
+ # 1 Introduction
15
+
16
+ Understanding and learning from DNA sequences has long been a goal of biologists and deep learning researchers, as its “language” encodes instructions essential for all living things [16]. The mapping from DNA instructions, genotypes, to observable function and traits, phenotypes, remains ongoing research effort. Towards this goal, researchers have proposed using foundation models (FMs) in genomics to learn generalizable features from unstructured whole genome data that can then be fine-tuned for a number of tasks including predicting the location and function of genes, identifying regulatory elements, and analyzing the evolution of species [25, 10, 20, 3, 53, 58]. In contrast to protein sequences, which have had successes in protein language models [29, 31, 32, 17, 5, 41, 14], DNA sequences are orders of magnitudes longer (e.g. the human genome is 3.2B nucleotides) with long-range dependencies and interactions that span over $1 0 0 \mathrm { k } +$ nucleotides in length [1]. Overcoming the long-range limitations of current generation models could help drive the next wave of innovations in AI-powered drug discovery and therapeutics, and enable genomic FMs to understand and learn in-context whole patient genomes in a personalized way.
17
+
18
+ Limitations of current models Previous genomic FM approaches have relied on attention-based Transformers [25, 10, 53, 58], but face a number of challenges unique to DNA sequences. The attention mechanism scales quadratically in sequence length, with current genomic FMs pretraining on only 512 to 4,096 tokens as context [25, 58, 10, 55], ${ < 0 . 0 0 1 \% }$ of the human genome. Also prevalent is the reliance on fixed $\mathbf { k }$ -mers, akin to DNA “words”, and tokenizers to aggregate meaningful DNA units. However, single nucleotide alterations represent physical analogs where, for example, single nucleotide polymorphisms (SNPs) and mutations can have a profound impact on biological properties including regulatory activity [33]. In contrast, natural language semantics can often be con
19
+
20
+ ![](images/c3cce80877bb632e3b3aefbeb87fe474eb06955d91a2893c82837dc5d994988e.jpg)
21
+ PPL vs Context on the Human Genome
22
+ Figure 1.2: Pretraining on the human reference genome using longer sequences leads to better perplexity (improved prediction of next token).
23
+
24
+ served when single character or word changes occur over very long contexts. Therefore, having both long-range context and single nucleotide resolution simultaneously is critical, and remains a particular challenge in genomics.
25
+
26
+ ![](images/cc4cefc43a64ddbd380cce07f8a1b8be6f5d24a42d98a20b0db932022fff799c.jpg)
27
+ Figure 1.3: HyenaDNA block architecture. A Hyena operator is composed of long convolutions and element-wise gate layers. The gates are fed projections of the input using dense layers and short convolutions. The long convolutions are parameterized implicitly via an MLP that produces the convolutional filters. The convolution itself is evaluated using a Fast Fourier Transform convolution with time complexity $\mathcal { O } ( L \log _ { 2 } L )$ .
28
+
29
+ Toward longer context models Recently, Hyena [37], a large language model based on implicit convolutions, was shown to match attention in quality while reducing computational time complexity, thereby allowing a longer context to be processed. Hyena uses a parameter-efficient global convolutional filter along with a data-controlled gating mechanism, which enables a context-specific operation over every token. Indeed, Hyena showed that for simple associative recall tasks using synthetic data, a shallow 2 layer model could effectively process context lengths at 131k tokens. We hypothesize that Hyena’s core operations can unlock the potential to capture both the long-range and single nucleotide resolution of real genomic sequences over attention-based approaches. To test this, we explore two questions: (i.) Can a convolutional long-context model be used effectively at single nucleotide resolution? (ii.) What new capabilities could long-context genomic foundations models enable?
30
+
31
+ HyenaDNA The result of our investigation is HyenaDNA, a genomic FM pretrained on the human reference genome at context lengths up to 1 million tokens at single nucleotide resolution - an up to $\mathbf { 5 0 0 x }$ increase over existing genomic FMs using dense-attention. HyenaDNA scales subquadratically in sequence length (training up to $1 6 0 \mathrm { x }$ faster than attention at sequence length 1M), uses single nucleotide tokens, and has a global receptive field at each layer. Our contributions include a "full-stack" recipe for building genomic FMs, including architecture design, a warm-up schedule to speed up training on ultralong sequences, and an efficient downstream adaptation procedure based on soft prompting and in-context learning.
32
+
33
+ Full-stack genomics modeling We start with a decoder-only Hyena architecture pretrained using next nucleotide (token) prediction. We forego standard aggregating tokenizers, using a singlecharacter tokenizer and a minimal DNA vocabulary of 4 nucleotides (plus special tokens). Training stability becomes an issue at ultralong sequences $( 2 0 0 \mathbf { k } + )$ . To overcome this issue, we introduce a sequence length warm-up scheduler that gradually increases sequence length in stages. At sequence length $4 5 0 \mathrm { k }$ , training time is reduced by $40 \%$ , while boosting accuracy by 7.5 accuracy points on a species classification task. Furthermore, we design downstream adaptation procedures to leverage longer context windows, as simpler and more flexible alternatives to standard fine-tuning in genomics. This includes a novel soft prompt technique where learnable tokens (up to 32k) are injected directly into the input sequence itself, enabling competitive downstream results without the need to update a pretrained model.
34
+
35
+ Genomic downstream tasks We apply our pretrained HyenaDNA models to 29 diverse downstream genomic tasks to showcase its long-range ability as well as fine-grain resolution. On fine-tuned benchmarks from the Nucleotide Transformer [10], HyenaDNA achieves state-of-theart (SotA) on 12 of 18 datasets while using a model with orders of magnitude less parameters and pretraining data (see Tab. 4.2). On the GenomicBenchmarks [23], HyenaDNA surpasses SotA on 7 of 8 datasets on average by $+ 1 0$ accuracy points, and by as much as $+ 2 0$ accuracy points on enhancer function identification. On a novel species classification task, HyenaDNA effectively solves the challenge by increasing the context length to 1 million tokens. In a challenging chromatin profile experiment, a 919-way multi-task, HyenaDNA performs competitively against a larger SotA sparseattention BigBird Transformer [55]. Finally, we analyze the learned embeddings of a pretrained HyenaDNA model by clustering sequences by biotype (gene or transcription type) and compare the results with existing genomic FMs, showing that HyenaDNA can serve as an effective universal featurizer in genomics.
36
+
37
+ # 2 Preliminaries and Related Work
38
+
39
+ # 2.1 Transformers and Attention
40
+
41
+ Powering many recent foundation models is the attention mechanism. Given a length- $L$ sequence $\boldsymbol { x } \in \mathbb { R } ^ { L \times D }$ , a (single-headed) layer of scaled self-attention [2, 51] is a map from $\mathbb { R } ^ { L \times D }$ to $\mathbb { R } ^ { L \times D }$ which performs the following operations:
42
+
43
+ $$
44
+ \mathsf { A } ( x ) = \sigma ( x \mathsf { W } _ { q } \mathsf { W } _ { k } ^ { \top } x ^ { \top } ) , \quad y = \mathsf { A } ( x ) x \mathsf { W } _ { v }
45
+ $$
46
+
47
+ where $D$ is the embedding dimension, $\mathsf { W } _ { q } , \mathsf { W } _ { k } , \mathsf { W } _ { v } \ \in \ \mathbb { R } ^ { D \times D }$ are learnable linear maps and $\sigma$ indicated row-wise softmax (and optional scaling). Attention computes all pair-wise comparison for every token, and scales as $\mathcal { O } ( L ^ { 2 } )$ in sequence length. This allows a global context at high resolution, but limits the size of the context on current hardware.
48
+
49
+ Previous methods to reduce the quadratic cost of attention have used specialized methods to approximate full dense attention [18]. In sparse attention, elements attend only to a subset of all other positions. Alternatively, linear attention methods construct approximations to $\mathsf { A } ( u )$ that can be evaluated in subquadratic time. Both of these classes of methods, however, trade lower time complexity (allowing longer sequences) for loss in expressivity.
50
+
51
+ # 2.2 Long Context Strategies in Genomics
52
+
53
+ To achieve longer context, genomic models have relied on two strategies: i. tokenization and ii. dilation and downsampling. Tokenization is a necessary step in masked language modeling (MLM) with bidirectional Transformer architectures (BERT) [13], a common model in genomics. These tokenizers use fixed k-mers (short overlapping sequences of length k) or frequency-based byte pair encoding (BPE), that attempt to aggregate DNA into meaningful units [25, 55]. Consequently, these aggregation techniques create large new vocabularies (compared to the natural vocabulary of 4 nucleotides) that are less generalizable [49]. The second strategy uses dilated convolutions and downsampling, both of which essentially average or skip elements between weights [18]. A canonical example is the Enformer, which uses dilation and downsampling to reach context lengths of $1 0 0 \mathrm { k }$ nucleotides to predict gene expression tracks [1]. Common across tokenization, dilation, and downsampling is the sacrifice of single nucleotide resolution to reach longer context.
54
+
55
+ # 2.3 Large Convolutional Models
56
+
57
+ A discrete convolution between an input $x$ of length $L$ and a (learnable) filter $h$ is given by:
58
+
59
+ $$
60
+ y _ { t } = ( h * x ) _ { t } = \sum _ { t ^ { \prime } = 0 } ^ { L - 1 } h _ { t - t ^ { \prime } } x _ { t ^ { \prime } } \quad \mathrm { o r e q u i v a l e n t l y } \quad y = \mathsf { T } x .
61
+ $$
62
+
63
+ where $\mathsf { T } \in \mathbb { R } ^ { L \times L }$ is the Toeplitz matrix corresponding to the convolution. Historically, convolutions have played an important role in deep learning and more broadly signal processing. More recently, it has been shown that by stacking $k$ long convolution layers, where $k$ is parametrized through a function $\gamma _ { \theta }$ i.e. $k : = \gamma _ { \theta } ( \dot { L } )$ , one can achieve state-of-the-art performance on a variety of benchmarks involving long sequences, for example the Long Range Arena (LRA) [48, 24, 47, 19]. Different $\gamma _ { \theta }$ have been proposed in the literature: state-space models [24, 19], and implicit parametrizations via neural fields [45, 44, 37]. On language, the $\mathsf { H }$ -family of implicit convolution language models,
64
+
65
+ H3 and Hyena, [12, 37] used long convolutions and gating to match Transformer performance in $\mathcal { O } ( L \log _ { 2 } L )$ time, notably lower than the $\mathcal { O } ( L ^ { 2 } )$ of attention-based models.
66
+
67
+ HyenaDNA takes inspiration from these approaches, showing that attention-free, long-context causal models can achieve high performance on downstream genomic tasks. These extended long-range capabilities enable us to explore new paradigms in genomics, such as in-context learning to easily adapt to new tasks without updating pretrained models.
68
+
69
+ # 3 HyenaDNA Long-Range Genomic Foundation Models
70
+
71
+ In this section, we introduce the HyenaDNA approach to long-range genomic sequence modeling. We start with a description of the model architecture, then discuss sequence length warm-up and soft prompting techniques for downstream adaptation.
72
+
73
+ # 3.1 The HyenaDNA Model
74
+
75
+ The HyenaDNA model is a decoder-only, sequence-to-sequence architecture defined by a stack of blocks consisting of a Hyena operator [37], followed by a feed-forward neural network (see Fig. 1.3).
76
+
77
+ Given an input $ { \boldsymbol { { x } } } ^ { \mathrm { ~ ~ } } \in { \mathbb { R } } ^ { L }$ $L$ denotes sequence length), a Hyena3 operator can be defined as:
78
+
79
+ $$
80
+ \begin{array} { l c r } { { ( x _ { 1 } , x _ { 2 } , v ) \mapsto \mathsf { H } ( x _ { 1 } , x _ { 2 } ) v } } \\ { { \mathsf { H } ( x _ { 1 } , x _ { 2 } ) = \mathsf { T } _ { h } } } \end{array}
81
+ $$
82
+
83
+ ![](images/910a5c37453b7e594b879eaa22beac331aaf176a3d86db8bbff8ddee686023dc.jpg)
84
+ Figure 3.1: The Hyena operator is a combination of long convolutions $\top$ and datacontrolled gating D, and can be a drop-in replacement for attention.
85
+
86
+ where $x _ { 1 } , x _ { 2 } ,$ $v$ are projections of the input, and $\mathsf T _ { h } \in \mathbb R ^ { L \times L }$ is the Toeplitz matrix constructed from a learnable long convolution filter produced as the output of a neural network, $( \mathsf { T } _ { h } ) _ { i j } \doteq \boldsymbol { h } _ { i - j }$ . The convolution filter values themselves are obtained through a small neural network $\gamma _ { \theta }$ taking as input the time (position) index and optionally positional encodings, $h _ { t } = \gamma _ { \theta } ( t )$ , which enable the operator to process very long sequences without growing linearly in the number of parameters. Further, the matrices $\mathsf { D } _ { x _ { 1 } }$ , $\mathbf { \bar { D } } _ { x _ { 2 } } \in \mathbb { R } ^ { \bar { L } \times L }$ are constructed with $x _ { 1 } , x _ { 2 }$ on the diagonals, and evaluated as elementwise gating. The projections are obtained by applying a dense linear layer and short convolution to the input sequence, as shown in Figure 3.1.
87
+
88
+ Proposition 3.1. $A$ Hyena operator can be evaluated in $\mathcal { O } ( L \log _ { 2 } L )$ time.
89
+
90
+ Efficient evaluation is crucial on settings involving extremely long sequences such as genomics. In the general case where the embedding dimension $D > 1$ and $\overset { \mathbf { \omega } } { x } \in \overset { \mathbf { \bullet } } { \mathbb { R } } ^ { L \times D }$ , the linear projections $\mathsf { W } _ { x _ { 1 } } , \mathsf { W } _ { x _ { 2 } } , \mathsf { W } _ { v } \in \mathbb { R } ^ { D \times D }$ are right multiplied to $x$ , and $D$ independent Hyena operators are then applied to each dimension.
91
+
92
+ # 3.2 Training Long Sequence Models
93
+
94
+ Tokenization The subquadratic cost of HyenaDNA in sequence length allows the model to process ultralong sequences directly at the single nucleotide level without the need for frequency-based aggregation tokenizers. This enables fine-grain resolution for both short and long sequences, critical for detecting single nucleotide polymorphisms or mutations and modeling long-range dependencies in gene expression.
95
+
96
+ We use the natural DNA vocabulary and refer to each nucleotide as a token. The tokens include "A", "G", "C", "T", and "N" (a non-specific nucleotide) and special character tokens for padding, separation, and unknown characters. Tokens are mapped to embedding dimension $D$ .
97
+
98
+ Sequence length warm-up for ultralong sequences Directly training on long sequences can affect training stability as the variance in gradient increases [28]. Training on shorter sequences initially (followed by longer sequences) was used by [38] to train small scale Transformers and reduce training time, while [28] used sequence length warm-up to address stability on up to $2 \mathrm { k }$ tokens.
99
+
100
+ For ultralong sequences $( 2 0 0 \mathrm { k } + )$ , we develop a new warm-up schedule that gradually increases the sequence length in stages to improve both stability and decrease training time.
101
+
102
+ Our sequence length schedule starts at $L _ { 1 } ~ = ~ 6 4$ , then doubles the window at each stage while keeping the global batch size constant. By doing so, iterations at each consecutive stage will include more tokens, ensuring the scheduler can also act as a form of batch size warm-up. In Fig. 3.2, we observe sequence length scheduling to be particularly important at sequence lengths greater than $4 5 0 \mathrm { k }$ , where at this length training time is reduced by $40 \%$ and improving ultimate accuracy by $7 . 5 \%$ points for a species classification task described later in section 4.4.3.
103
+
104
+ ![](images/2ebc258337b90047484fbebabe8cab111fa4f76a341ce7a94f0502188da0e69a.jpg)
105
+ Figure 3.2: Sequence length warm-up reduces the training time of HyenaDNA at sequence length 450k by $40 \%$ and boosts accuracy by 7.5 points on species classification.
106
+
107
+ # 3.3 Downstream Adaptation
108
+
109
+ # Tuneable prompting for long-context models
110
+
111
+ Prompts have been traditionally used to guide the output of a FM [30] by prepending additional context to an input. Expanding on this approach, soft tuneable prompting was introduced to inject learnable tokens (as weights) into the input directly [27] as an alternative to model fine-tuning.
112
+
113
+ With an extended context length $( L )$ , we’re able to explore new paradigms in adapting FMs after pretraining. Given a downstream task with prompts $\dot { \boldsymbol { x _ { p } } } \in \mathbb { R } ^ { T }$ and corresponding labels $y _ { p }$ , we prepend $N \leq L - T$ trainable parameters $\theta$ of dimension $D$ after the embedding step:
114
+
115
+ $$
116
+ x \mathsf { c o n c a t } [ \mathsf { e m b e d } ( x _ { p } ) , \theta ] , \quad x \in \mathbb { R } ^ { L \times ( T + N ) }
117
+ $$
118
+
119
+ The resulting sequences $x$ are then processed by the model, and $\theta$ is optimized on a loss function involving the input sequence’s label $y _ { p }$ . Crucially, soft prompting requires utilization of a small subset of prompt and label pairs to optimize $\theta$ .
120
+
121
+ During soft prompting, HyenaDNA only optimizes the parameters of the prompt in the input sequence while keeping all other model parameters fixed. Soft prompting thereby provides a flexible and computationally efficient approach to adapting genomic FMs to new downstream tasks.
122
+
123
+ # 4 Experiments
124
+
125
+ In 4.1, we start with pretraining HyenaDNA on the human reference genome [22]. We then evaluate HyenaDNA on existing short-range $( < 5 \mathrm { k }$ nucleotides) downstream benchmarks in 4.2 to assess the performance of single nucleotide resolution. In 4.3, we explore what new capabilities emerge with longer range genomic modeling in the form of in-context learning. Finally, we push the limits of ultralong context performance in 4.4.
126
+
127
+ # 4.1 Pretraining on the Human Genome
128
+
129
+ We pretrain HyenaDNA on the human reference genome [22] using next nucleotide (token) prediction. Starting with a stack of decoder-only Transformer blocks, we swap attention for the Hyena operator, and compare against a baseline Transformer (GPT) with Flash Attention [11]. We add gradient checkpointing to HyenaDNA to decrease the memory footprint by $3 \mathbf { x }$ on longer sequences $( > 1 6 0 \mathrm { k } )$ . We then scale HyenaDNA along dimensions of model depth (2 to 8 layers), width (128 to 256 dimensions), and sequence length (1024 to 1M). At sequence length 1M, HyenaDNA is $1 6 0 \mathrm { x }$ faster than its Transformer counterpart as shown in Fig. 4.1.
130
+
131
+ As shown in Fig. 1.2, we observe that as context length increases, perplexity improves during pretraining. However, this improvement comes at the expense of more training time and tokens. For models too shallow to effectively process longer context, perplexity can begin to degrade (increase), observing inflection points with longer sequences. In this way, increasing context can serve as a novel regularization dimension. For genomic pretraining, we provide the following guidelines. 1. In optimizing for faster training time, shorter context enable lower perplexity to be reached faster. 2. In optimizing for best overall perplexity, longer context allows for lower perplexity at the cost of training on more tokens. See A.1 for experiment details.
132
+
133
+ # 4.2 Single Nucleotide Resolution
134
+
135
+ Our first downstream tasks use short-range genomic sequences $( < 5 \mathrm { k } )$ aimed at evaluating single nucleotide resolution performance on sequence-level classification using standard fine-tuning.
136
+
137
+ GenomicBenchmarks We start with the newly released GenomicBenchmarks [23], which is comprised of 8 regulatory element classification datasets with sequence lengths of 200-500, and one up to 4,776. The original baseline model uses a short-range CNN. We fine-tune the pretrained Transformer (GPT) and HyenaDNA from 4.1, both having single nucleotide resolution, as well as the DNABERT model [25]. HyenaDNA sets a new SotA on 7 of 8 datasets and by up to $20 \%$ points on the human enhancer identification task, as shown in Tab. 4.1. See A.2 for additional experiment details and ablations.
138
+
139
+ ![](images/e7d3a486f5881decd40315f9e4c4f971dd8fb073acee599140bad840decd0860.jpg)
140
+ Figure 4.1: Runtime (forward & backward pass) for Transformer & HyenaDNA: 2 layers, width ${ \tt 1 2 8 }$ , gradient checkpoint, batch size $^ { = 1 }$ , A100 80GB. At 1M tokens HyenaDNA is $\mathbf { 1 6 0 x }$ faster than Transformer.
141
+
142
+ Nucleotide Transformer Next, we benchmark against 18 datasets from the Nucleotide Transformer (NT) [10], which includes predicting regulatory elements for enhancers, promoters, epigenetic marks, and splice sites from DNA sequences of length 200-600 nucleotides. We compare against $3 ~ \mathrm { N T }$ base models, which were pretrained using masked language
143
+
144
+ Table 4.1: GenomicBenchmarks Top-1 accuracy $( \% )$ for pretrained HyenaDNA, DNABERT and Transformer (GPT from 4.1), and the previous SotA baseline CNN (scratch).
145
+
146
+ <table><tr><td>DATASET</td><td>CNN</td><td>DNABERT</td><td>GPT</td><td>HYENADNA</td></tr><tr><td>Mouse Enhancers</td><td>69.0</td><td>66.9</td><td>80.1</td><td>85.1</td></tr><tr><td>Coding vs Intergenomic</td><td>87.6</td><td>92.5</td><td>88.8</td><td>91.3</td></tr><tr><td>Human vs Worm</td><td>93.0</td><td>96.5</td><td>95.6</td><td>96.6</td></tr><tr><td>Human Enhancers Cohn</td><td>69.5</td><td>74.0</td><td>70.5</td><td>74.2</td></tr><tr><td>Human Enhancers Ensembl</td><td>68.9</td><td>85.7</td><td>83.5</td><td>89.2</td></tr><tr><td>Human Regulatory</td><td>93.3</td><td>88.1</td><td>91.5</td><td>93.8</td></tr><tr><td>Human Nontata Promoters</td><td>84.6</td><td>85.6</td><td>87.7</td><td>96.6</td></tr><tr><td>Human OCR Ensembl</td><td>68.0</td><td>75.1</td><td>73.0</td><td>80.9</td></tr></table>
147
+
148
+ modeling (BERT) and then fine-tuned. The NT models ranged from 500M to 2.5B parameters, and pretrained on up to 3202 genomes. All NT models use 6-mer sequences of 1000 tokens long. For HyenaDNA, we attach a linear decoder head and fine-tune a pretrained model, surpassing SotA on 12 of 18 datasets using a model with orders of magnitude less parameters and pretraining data, shown in Tab. 4.2. See A.2 for additional experiment details and ablations.
149
+
150
+ # 4.3 In-context Learning for Genomic Sequences
151
+
152
+ Compared to natural language FMs, which have shown strong success with in-context learning, HyenaDNA’s vocabulary is very small. DNA sequences are also less diverse in structure, e.g. there’s no concept of labels or descriptions that follow a DNA sequence. This makes it challenging to perform "pure" in-context learning (relying only on inference), since new concepts such as classification labels would require new symbols. To overcome this limitation and explore the potential for in-context learning in genomics, we make use of two variants of in-context learning: soft prompting and instruction fine-tuning. Each involve a brief tuning phase to introduce the concept of classification using only the existing vocabulary.
153
+
154
+ Procedure In both variants, we use the GenomicBenchmarks in 4.2, and a HyenaDNA model pretrained on sequence length 160k from 4.1.
155
+
156
+ In the first experiment, we evaluate a soft prompting approach by prepending a sequence of soft tuneable tokens (2 to 32k) directly in the input sequences. We include a brief tuning phase $< 2 0$ epochs), updating the soft tokens only, to provide HyenaDNA with the ability to indicate the target classes. To denote classes, we repurpose HyenaDNA’s fixed vocabulary: for binary classification, for example, we indicate the two classes with the letters "A" and "N".
157
+
158
+ In the second experiment, we evaluate a few-shot learning approach to in-context learning [6] by prepending, consecutively, $k$ (2 to 32) demonstrations of each class and its sequence into the prompt. As before, we encode class labels by the use of individual letters of HyenaDNA’s existing vocabulary. We additionally perform a brief instruction-tuning period [52]
159
+
160
+ Table 4.2: Nucleotide Transformer (NT) Benchmarks The Matthews correlation coefficient (MCC) is used as the performance metric for the enhancer and epigenetic marks dataset, and the F1-score is used for the promoter and splice site dataset.
161
+
162
+ <table><tr><td>MODEL PARAMS # OF GENOMES</td><td>NT 500M 1</td><td>NT 2.5B 3,202</td><td>NT 2.5B 850</td><td>HyenaDNA 1.6M 1</td></tr><tr><td>Enhancer</td><td>53.5</td><td>59.3</td><td>58.0</td><td>62.6</td></tr><tr><td>Enhancer types</td><td>48.5</td><td>50.0</td><td>47.4</td><td>55.7</td></tr><tr><td>H3</td><td>73.7</td><td>77.6</td><td>81.4</td><td>81.7</td></tr><tr><td>H3K4me1</td><td>35.8</td><td>44.5</td><td>55.9</td><td>57.1</td></tr><tr><td>H3K4me2</td><td>28.1</td><td>30.0</td><td>32.6</td><td>53.9</td></tr><tr><td>H3K4me3</td><td>26.3</td><td>28.1</td><td>42.1</td><td>61.2</td></tr><tr><td>H3K9ac</td><td>46.2</td><td>50.8</td><td>57.5</td><td>65.1</td></tr><tr><td>H3K14ac</td><td>37.7</td><td>47.1</td><td>55.0</td><td>66.3</td></tr><tr><td>H3K36me3</td><td>46.7</td><td>53.3</td><td>63.2</td><td>65.3</td></tr><tr><td>H3K79me3</td><td>57.7</td><td>59.2</td><td>64.2</td><td>71.6</td></tr><tr><td>H4</td><td>76.2</td><td>78.9</td><td>82.2</td><td>79.6</td></tr><tr><td>H4ac</td><td>34.4</td><td>42.3</td><td>50.1</td><td>63.7</td></tr><tr><td>Promoter all</td><td>95.4</td><td>96.6</td><td>97.4</td><td>96.5</td></tr><tr><td>Promoter non-TATA</td><td>95.6</td><td>96.9</td><td>97.7</td><td>96.6</td></tr><tr><td>Promoter TATA</td><td>94.8</td><td>95.8</td><td>96.4</td><td>96.7</td></tr><tr><td>Splice acceptor</td><td>96.5</td><td>98.5</td><td>99.0</td><td>96.6</td></tr><tr><td>Splice donor</td><td>97.2</td><td>98.2</td><td>98.4</td><td>97.3</td></tr><tr><td>Splice all</td><td>97.2</td><td>97.8</td><td>98.3</td><td>97.9</td></tr></table>
163
+
164
+ for each dataset to familiarize HyenaDNA with this task structure by tuning the pretrained model on a small subset of the dataset.
165
+
166
+ ![](images/1b9f89e630e47bb4dd18aaf2dce299eeefad9aa39663ce889e9e11051bc8cc1b.jpg)
167
+ Figure 4.2: Filling long-context with soft tuneable tokens. HyenaDNA is able to learn new tasks in-context when adding a sequence of tuneable tokens to the input sequences. Longer sequences of tuneable tokens lead to better performance.
168
+
169
+ Results In Fig. 4.2, HyenaDNA’s performance on novel tasks improves as more tuneable tokens are added into the input sequences, and saturates close to baseline performance (Tab. 4.1; with the exception of the Human Regulatory dataset). By contrast, we find that increasing $k$ -shot demonstrations to the input does not necessarily improve performance. A higher number of tuning samples is needed before $k$ -shot demonstrations start to boost accuracy as shown in Tab. A.1. See A.3 for experiment details.
170
+
171
+ # 4.4 Ultralong-Range Genomics
172
+
173
+ In our final experimental section, we focus on pushing the limits of using long context effectively in genomics. In 4.4.1, we tackle a challenging 919 binary multi-task against a sparse-attention baseline. In 4.4.2 we analyze the learned embeddings HyenaDNA and its use in clustering long sequences by functional annotation, and in 4.4.3 we showcase a novel ultralong-range species classification task.
174
+
175
+ # 4.4.1 Chromatin Profile Prediction
176
+
177
+ The prediction of chromatin profiles and epigenetic markers from DNA sequences is an important and challenging task to quantify the functional effects of non-coding variants. These variants include single nucleotide changes in DNA that can affect the downstream expression of genes [56]. The DeepSEA dataset [57] is compiled from 919 chromatin features including transcription factor (TF) binding profiles, DNase I-hypersensitive sites (DHS) and histone mark (HM) profiles. For a given sequence, the task is to jointly predict 919 labels cor
178
+
179
+ Table 4.3: Chromatin profile prediction Median AUROC computed over three categories: Transcription factor binding profiles (TF), DNase Ihypersensitive sites (DHS) and histone marks (HM).
180
+
181
+ <table><tr><td rowspan="2">MODEL</td><td rowspan="2">PARAMS</td><td rowspan="2">LEN</td><td colspan="3">AUROC</td></tr><tr><td>TF</td><td>DHS</td><td>HM</td></tr><tr><td rowspan="2">DeepSEA BigBird</td><td>40M</td><td>1k</td><td>95.8</td><td>92.3</td><td>85.6</td></tr><tr><td>110 M</td><td>8k</td><td>96.1</td><td>92.1</td><td>88.7</td></tr><tr><td rowspan="2">HyenaDNA</td><td>7M</td><td>1k</td><td>96.4</td><td>93.0</td><td>86.3</td></tr><tr><td>3.5 M</td><td>8k</td><td>95.5</td><td>91.7</td><td>89.3</td></tr></table>
182
+
183
+ responding to the chromatin profile (similar to peak detection) of a central region of the sequence, indicating the presence of such functional effects. The input also includes flanking regions that provide broader contextual information needed to incorporate long-range interactions. We fine-tune our pretrained HyenaDNA models from 4.1 and perform competitively against a DeepSea CNN and the SotA sparse attention BigBird [55] baselines using $5 \mathrm { - } 3 0 \mathrm { \times }$ fewer parameters. See A.4 for experiment details.
184
+
185
+ # 4.4.2 Biotype Embeddings
186
+
187
+ ![](images/5835e4c7fd23824eb036169af7f88037eefb315221277043741f6b91658c4e42.jpg)
188
+ Figure 4.3: Embedding visualisation. t-SNE of the embeddings generated by DNABERT, Nucleotide Transformer and HyenaDNA coloured by Ensembl biotype annotations.
189
+
190
+ Next, we analyze the pretrained embeddings from HyenaDNA and compare them with DNABERT [25] and the Nucleotide Transformer [10]. We encode sequences of human genes corresponding to different biological function annotations obtained from the Ensembl dataset known as biotypes [9]. In cases where the length of the input exceeds the context window of the encoder, the sequence is chunked (by the max length of the encoder) and averaged.
191
+
192
+ We fit the embeddings using an XGBoost [7] classifier on the $1 0 \mathrm { \ m o s t }$ frequent biotypes, and apply tSNE [50] for visualization. As shown in 4.3, distinct clusterings emerge visually, while quantitatively, HyenaDNA produces the highest F1 score in biotype classification (with a much smaller model), indicating that during pretraining, HyenaDNA learns informative features related to biological function.
193
+
194
+ Table 4.4: Embedding quality Weighted F1 classification score on 10 biotypes.
195
+
196
+ <table><tr><td>MODEL</td><td>PARAMS</td><td>LEN</td><td>F1</td></tr><tr><td>DNABERT</td><td>110 M</td><td>512</td><td>64.6</td></tr><tr><td>NT</td><td>500M</td><td>6k</td><td>66.5</td></tr><tr><td>HyenaDNA</td><td>7M</td><td>160k</td><td>72.0</td></tr></table>
197
+
198
+ # 4.4.3 Species Classification
199
+
200
+ The majority of the genome is conserved across species – humans and non-human primates, for example, have ${ < } 1 0 \%$ sequence divergence [43], making them difficult to discriminate. This allows us to to design an ultralong-range sequence modeling task to test whether a model can determine the source species of a random genetic sequence. To train, we randomly sample DNA sequences from 5 different species, and fine-tune pretrained HyenaDNA and Transformer models from 4.1 to predict the species label. We observe in Tab. 4.5 that both models struggle on shorter sequences of length 1024, but performance improves with longer contexts as the distinct mutational profile of each species becomes more evident. HyenaDNA effectively solves the task by using a context length of $4 5 0 \mathrm { k }$ to 1 million, where Transformer cannot due to infeasible training time limitations. See A.6 for experiment details.
201
+
202
+ # 5 Conclusion
203
+
204
+ Summary We presented HyenaDNA, a genomic foundation model pretrained on the human reference genome with context lengths up to 1 million tokens at single nucleotide resolution - an up to $5 0 0 \mathrm { x }$ increase over previous genomic FMs using dense-attention. HyenaDNA is able to learn generalizable features that can then be finetuned for tasks including identifying regulatory elements and on a 919-way chromatin profile prediction task. We also explored the first use of in-context learning in genomics to enable simpler adaptation to downstream tasks without any updates to pretrained weights.
205
+
206
+ Table 4.5: Species classification Top1 accuracy $( \% )$ for 5-way classification (human, lemur, mouse, pig, hippo). The $\pmb { \chi }$ symbol indicates infeasible training time.
207
+
208
+ <table><tr><td>MODEL</td><td>LEN</td><td>AcC</td></tr><tr><td>Transformer</td><td>1k</td><td>55.4 61.1</td></tr><tr><td>HyenaDNA Transformer</td><td>1k 32k</td><td>88.9</td></tr><tr><td>HyenaDNA</td><td>32k</td><td>93.4</td></tr><tr><td>Transformer</td><td>250k</td><td>+</td></tr><tr><td>HyenaDNA</td><td>250k</td><td>97.9</td></tr><tr><td>Transformer</td><td>450k</td><td>×</td></tr><tr><td>HyenaDNA</td><td>450k</td><td>99.4</td></tr><tr><td>Transformer</td><td>1M</td><td>X</td></tr><tr><td>HyenaDNA</td><td>1M</td><td>99.5</td></tr></table>
209
+
210
+ Limitations and Future Work While demonstrating competitive results and introducing novel capabilities, it is worth noting that HyenaDNA was pretrained on only one human reference genome. Incorporating genomes of multiple humans and species could increase generalizability in learned features and reduce bias. Furthermore, our current focus in this study was exclusively on DNA sequences. Extending our framework to incorporate other biological or chemical sequences, such as proteins and drug molecules, has the potential to unlock multi-modal capabilities similar to those observed in natural language and vision FMs [39, 40, 54].
211
+
212
+ With respect to model size, HyenaDNA is significantly smaller than previous genomic FMs and was pretrained using up to 8 Nvidia A100 (80GB) GPUs. We expect increasing model size, and compute, may lead to additional long-range capabilities. Notably, with model parallelism, it becomes feasible to extend the context length by orders of magnitude beyond this current work, and leave that open to future research.
213
+
214
+ Furthermore, beyond discriminative applications, the use of long context models in generative tasks unlocks exciting prospects for the design of synthetic regulatory elements, genes and protein complexes. In conclusion, the continued advancements of long-range sequence models with single nucleotide resolution hold great promise in driving innovation in genomic research and unraveling the complexities of biological systems.
215
+
216
+ # Acknowledgments
217
+
218
+ We would like to thank Guatam Machiraju, Elliott Epstein, Archis Joglekar, Jared Dunnmon, Nazim Bouatta and Anshul Kundaje for helpful discussion and feedback on earlier drafts, and Together for providing the compute used to train models in this paper. We gratefully acknowledge the support of NIH under No. U54EB020405 (Mobilize), NSF under Nos. CCF1763315 (Beyond Sparsity), CCF1563078 (Volume to Velocity), and 1937301 (RTML); US DEVCOM ARL under No. W911NF-21-2-0251 (Interactive Human-AI Teaming); ONR under No. N000141712266 (Unifying Weak Supervision); ONR N00014-20-1-2480: Understanding and Applying Non-Euclidean Geometry in Machine Learning; N000142012275 (NEPTUNE); NXP, Xilinx, LETI-CEA, Intel, IBM, Microsoft, NEC, Toshiba, TSMC, ARM, Hitachi, BASF, Accenture, Ericsson, Qualcomm, Analog Devices, Google Cloud, Salesforce, Total, the HAI-GCP Cloud Credits for Research program, the Stanford Data Science Initiative (SDSI), Department of Defense (DoD) through the National Defense Science and Engineering Graduate Fellowship (NDSEG) Program, and members of the Stanford DAWN project: Facebook, Google, and VMWare. This work is supported by NSF (1651565), AFOSR (FA95501910024), ARO (W911NF-21-1-0125), ONR, DOE (DE-SC0022222), CZ Biohub, and Sloan Fellowship. The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright notation thereon. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views, policies, or endorsements, either expressed or implied, of NIH, ONR, or the U.S. Government.
219
+
220
+ # References
221
+
222
+ [1] Ž. Avsec, V. Agarwal, D. Visentin, J. R. Ledsam, A. Grabska-Barwinska, K. R. Taylor, Y. Assael, J. Jumper, P. Kohli, and D. R. Kelley. Effective gene expression prediction from sequence by integrating long-range interactions. Nature methods, 18(10):1196–1203, 2021.
223
+ [2] D. Bahdanau, K. Cho, and Y. Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014.
224
+ [3] G. Benegas, S. S. Batra, and Y. S. Song. DNA language models are powerful zero-shot predictors of non-coding variant effects. bioRxiv, pages 2022–08, 2022.
225
+ [4] R. Bommasani, D. A. Hudson, E. Adeli, R. Altman, S. Arora, S. von Arx, M. S. Bernstein, J. Bohg, A. Bosselut, E. Brunskill, et al. On the opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258, 2021.
226
+ [5] N. Brandes, D. Ofer, Y. Peleg, N. Rappoport, and M. Linial. ProteinBERT: a universal deeplearning model of protein sequence and function. Bioinformatics, 38(8):2102–2110, 2022.
227
+ [6] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
228
+ [7] T. Chen and C. Guestrin. Xgboost: A scalable tree boosting system. In Proceedings of the 22nd acm sigkdd international conference on knowledge discovery and data mining, pages 785–794, 2016.
229
+ [8] D. M. Church, V. A. Schneider, T. Graves, K. Auger, F. Cunningham, N. Bouk, H.-C. Chen, R. Agarwala, W. M. McLaren, G. R. Ritchie, et al. Modernizing reference genome assemblies. PLoS biology, 9(7):e1001091, 2011.
230
+ [9] F. Cunningham, J. E. Allen, J. Allen, J. Alvarez-Jarreta, M. R. Amode, I. M. Armean, O. Austine-Orimoloye, A. G. Azov, I. Barnes, R. Bennett, et al. Ensembl 2022. Nucleic acids research, 50(D1):D988–D995, 2022.
231
+ [10] H. Dalla-Torre, L. Gonzalez, J. Mendoza-Revilla, N. L. Carranza, A. H. Grzywaczewski, F. Oteri, C. Dallago, E. Trop, H. Sirelkhatim, G. Richard, M. Skwark, K. Beguir, M. Lopez, and T. Pierrot. The Nucleotide Transformer: Building and evaluating robust foundation models for human genomics. bioRxiv, 2023.
232
+ [11] T. Dao, D. Y. Fu, S. Ermon, A. Rudra, and C. Ré. FlashAttention: Fast and memory-efficient exact attention with IO-awareness. In Advances in Neural Information Processing Systems, 2022.
233
+ [12] T. Dao, D. Y. Fu, K. K. Saab, A. W. Thomas, A. Rudra, and C. Ré. Hungry hungry hippos: Towards language modeling with state space models. arXiv preprint arXiv:2212.14052, 2022.
234
+ [13] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
235
+ [14] A. Elnaggar, M. Heinzinger, C. Dallago, G. Rehawi, Y. Wang, L. Jones, T. Gibbs, T. Feher, C. Angerer, M. Steinegger, et al. Prottrans: Toward understanding the language of life through self-supervised learning. IEEE transactions on pattern analysis and machine intelligence, 44 (10):7112–7127, 2021.
236
+ [15] ENCODE Project Consortium. An integrated encyclopedia of dna elements in the human genome. Nature, 489(7414):57, 2012.
237
+ [16] ENCODE Project Consortium. Expanded encyclopaedias of DNA elements in the human and mouse genomes. Nature, 583:699–710, 2020.
238
+ [17] N. Ferruz, S. Schmidt, and B. Höcker. ProtGPT2 is a deep unsupervised language model for protein design. Nature communications, 13(1):4348, 2022.
239
+ [18] Q. Fournier, G. M. Caron, and D. Aloise. A practical survey on faster and lighter transformers. ACM Computing Surveys, 2021.
240
+ [19] D. Y. Fu, E. L. Epstein, E. Nguyen, A. W. Thomas, M. Zhang, T. Dao, A. Rudra, and C. Ré. Simple hardware-efficient long convolutions for sequence modeling. arXiv preprint arXiv:2302.06646, 2023.
241
+ [20] D. Gankin, A. Karollus, M. Grosshauser, K. Klemon, J. Hingerl, and J. Gagneur. Speciesaware DNA language modeling. bioRxiv, pages 2023–01, 2023.
242
+ [21] Q. Geng, R. Yang, and L. Zhang. A deep learning framework for enhancer prediction using word embedding and sequence generation. Biophysical Chemistry, 286:106822, 2022.
243
+ [22] Genome Reference Consortium. Genome reference consortium human build 38 (grch38). National Center for Biotechnology Information, 2013. URL https://www.ncbi.nlm. nih.gov/assembly/GCF_000001405.26/.
244
+ [23] K. Gresova, V. Martinek, D. Cechak, P. Simecek, and P. Alexiou. Genomic Benchmarks: A collection of datasets for genomic sequence classification. bioRxiv, 2022.
245
+ [24] A. Gu, K. Goel, and C. Ré. Efficiently modeling long sequences with structured state spaces. arXiv preprint arXiv:2111.00396, 2021.
246
+ [25] Y. Ji, Z. Zhou, H. Liu, and R. V. Davuluri. DNABERT: pre-trained bidirectional encoder representations from transformers model for DNA-language in genome. Bioinformatics, 37 (15):2112–2120, 2021.
247
+ [26] W. J. Kent, C. W. Sugnet, T. S. Furey, K. M. Roskin, T. H. Pringle, A. M. Zahler, and D. Haussler. The human genome browser at ucsc. Genome research, 12(6):996–1006, 2002.
248
+ [27] B. Lester, R. Al-Rfou, and N. Constant. The power of scale for parameter-efficient prompt tuning. arXiv preprint arXiv:2104.08691, 2021.
249
+ [28] C. Li, M. Zhang, and Y. He. The stability-efficiency dilemma: Investigating sequence length warmup for training GPT models. In Advances in Neural Information Processing Systems, 2022.
250
+ [29] Z. Lin, H. Akin, R. Rao, B. Hie, Z. Zhu, W. Lu, A. dos Santos Costa, M. Fazel-Zarandi, T. Sercu, S. Candido, et al. Language models of protein sequences at the scale of evolution enable accurate structure prediction. BioRxiv, 2022.
251
+ [30] P. Liu, W. Yuan, J. Fu, Z. Jiang, H. Hayashi, and G. Neubig. Pre-train, prompt, and predict: A systematic survey of prompting methods in natural language processing. ACM Computing Surveys, 55(9):1–35, 2023.
252
+ [31] A. Madani, B. Krause, E. R. Greene, S. Subramanian, B. P. Mohr, J. M. Holton, J. L. Olmos Jr, C. Xiong, Z. Z. Sun, R. Socher, et al. Large language models generate functional protein sequences across diverse families. Nature Biotechnology, pages 1–8, 2023.
253
+ [32] J. Meier, R. Rao, R. Verkuil, J. Liu, T. Sercu, and A. Rives. Language models enable zero-shot prediction of the effects of mutations on protein function. Advances in Neural Information Processing Systems, 34:29287–29303, 2021.
254
+ [33] J. Nasser, D. T. Bergman, C. P. Fulco, P. Guckelberger, B. R. Doughty, T. A. Patwardhan, T. R. Jones, T. H. Nguyen, J. C. Ulirsch, F. Lekschas, K. Mualim, H. M. Natri, E. M. Weeks, G. Munson, M. Kane, H. Y. Kang, A. Cui, J. P. Ray, T. M. Eisenhaure, R. L. Collins, K. Dey, H. Pfister, A. L. Price, C. B. Epstein, A. Kundaje, R. J. Xavier, M. J. Daly, H. Huang, H. K. Finucane, N. Hacohen, E. S. Lander, and J. M. Engreitz. Genome-wide enhancer maps link risk variants to disease genes. Nature, 593:238–243, 2021.
255
+ [34] M. Oubounyt, Z. Louadi, H. Tayara, and K. T. Chong. DeePromoter: Robust promoter predictor using deep learning. Frontiers in Genetics, 10, 2019.
256
+ [35] T. H. Pham, D. H. Tran, T. B. H. Ho, K. Satou, and G. Valiente. Qualitatively predicting acetylation and methylation areas in DNA sequences. Genome Informatics, 16(2):3–11, 2005.
257
+ [36] D. K. Pokholok, C. T. Harbison, S. Levine, F. Lewitter, D. K. Gifford, and R. A. Young. Genome-wide map of nucleosome acetylation and methylation in yeast. Cell, 122(4):517–527, 2005.
258
+ [37] M. Poli, S. Massaroli, E. Nguyen, D. Y. Fu, T. Dao, S. Baccus, Y. Bengio, S. Ermon, and C. Ré. Hyena Hierarchy: Towards larger convolutional language models. arXiv preprint arXiv:2302.10866, 2023.
259
+ [38] O. Press, N. A. Smith, and M. Lewis. Shortformer: Better language modeling using shorter inputs. arXiv preprint arXiv:2012.15832, 2020.
260
+ [39] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, et al. Learning transferable visual models from natural language supervision. In International conference on machine learning, pages 8748–8763. PMLR, 2021.
261
+ [40] A. Ramesh, M. Pavlov, G. Goh, S. Gray, C. Voss, A. Radford, M. Chen, and I. Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pages 8821–8831. PMLR, 2021.
262
+ [41] R. Rao, J. Meier, T. Sercu, S. Ovchinnikov, and A. Rives. Transformer protein language models are unsupervised structure learners. Biorxiv, pages 2020–12, 2020.
263
+ [42] Roadmap Epigenomics Consortium. Integrative analysis of 111 reference human epigenomes. Nature, 518(7539):317–330, 2015.
264
+ [43] J. Rogers and R. A. Gibbs. Comparative primate genomics: emerging patterns of genome content and dynamics. Nature Reviews Genetics, 15(5):347–359, 2014.
265
+ [44] D. W. Romero, R.-J. Bruintjes, J. M. Tomczak, E. J. Bekkers, M. Hoogendoorn, and J. C. van Gemert. Flexconv: Continuous kernel convolutions with differentiable kernel sizes. arXiv preprint arXiv:2110.08059, 2021.
266
+ [45] D. W. Romero, A. Kuzina, E. J. Bekkers, J. M. Tomczak, and M. Hoogendoorn. Ckconv: Continuous kernel convolution for sequential data. arXiv preprint arXiv:2102.02611, 2021.
267
+ [46] N. Scalzitti, A. Kress, R. Orhand, T. Weber, L. Moulinier, A. Jeannin-Girardon, O. Collet, Pierre anf Poch, and J. D. Thompson. Spliceator: multi-species splice site prediction using convolutional neural networks. BMC Bioinformatics, 22(1):1–26, 2021.
268
+ [47] J. T. Smith, A. Warrington, and S. W. Linderman. Simplified state space layers for sequence modeling. arXiv preprint arXiv:2208.04933, 2022.
269
+ [48] 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. arXiv preprint arXiv:2011.04006, 2020.
270
+ [49] Y. Tay, V. Q. Tran, S. Ruder, J. Gupta, H. W. Chung, D. Bahri, Z. Qin, S. Baumgartner, C. Yu, and D. Metzler. Charformer: Fast character transformers via gradient-based subword tokenization. arXiv preprint arXiv:2106.12672, 2021.
271
+ [50] L. Van der Maaten and G. Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008.
272
+ [51] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
273
+ [52] J. Wei, M. Bosma, V. Y. Zhao, K. Guu, A. W. Yu, B. Lester, N. Du, A. M. Dai, and Q. V. Le. Finetuned language models are zero-shot learners. arXiv preprint arXiv:2109.01652, 2021.
274
+ [53] F. Yang, W. Wang, F. Wang, Y. Fang, D. Tang, J. Huang, H. Lu, and J. Yao. scBERT as a large-scale pretrained deep language model for cell type annotation of single-cell RNA-seq data. Nature Machine Intelligence, 4(10):852–866, 2022.
275
+ [54] J. Yu, Z. Wang, V. Vasudevan, L. Yeung, M. Seyedhosseini, and Y. Wu. Coca: Contrastive captioners are image-text foundation models. arXiv preprint arXiv:2205.01917, 2022.
276
+ [55] M. Zaheer, G. Guruganesh, K. A. Dubey, J. Ainslie, C. Alberti, S. Ontanon, P. Pham, A. Ravula, Q. Wang, L. Yang, et al. Big bird: Transformers for longer sequences. Advances in neural information processing systems, 33:17283–17297, 2020.
277
+ [56] S. Zaina, E. L. Pérez-Luque, and G. Lund. Genetics talks to epigenetics? the interplay between sequence variants and chromatin structure. Current genomics, 11(5):359–367, 2010.
278
+ [57] J. Zhou and O. G. Troyanskaya. Predicting effects of noncoding variants with deep learning– based sequence model. Nature methods, 12(10):931–934, 2015.
279
+ [58] M. Zvyagin, A. Brace, K. Hippe, Y. Deng, B. Zhang, C. O. Bohorquez, A. Clyde, B. Kale, D. Perez-Rivera, H. Ma, et al. GenSLMs: Genome-scale language models reveal SARS-CoV2 evolutionary dynamics. bioRxiv, pages 2022–10, 2022.
280
+
281
+ # HyenaDNA
282
+
283
+ # Supplementary Material
284
+
285
+ # Contents
286
+
287
+ # 1 Introduction 2
288
+
289
+ # 2 Preliminaries and Related Work 4
290
+
291
+ 2.1 Transformers and Attention . 4
292
+ 2.2 Long Context Strategies in Genomics 4
293
+ 2.3 Large Convolutional Models 4
294
+
295
+ # 3 HyenaDNA Long-Range Genomic Foundation Models 5
296
+
297
+ 3.1 The HyenaDNA Model 5
298
+ 3.2 Training Long Sequence Models 5
299
+ 3.3 Downstream Adaptation 6
300
+
301
+ # 4 Experiments 6
302
+
303
+ 4.1 Pretraining on the Human Genome 6
304
+ 4.2 Single Nucleotide Resolution 7
305
+ 4.3 In-context Learning for Genomic Sequences 7
306
+ 4.4 Ultralong-Range Genomics 8
307
+ 4.4.1 Chromatin Profile Prediction 8
308
+ 4.4.2 Biotype Embeddings 9
309
+ 4.4.3 Species Classification 10
310
+
311
+ # 5 Conclusion 10
312
+
313
+ # A Appendix: Experimental Details 17
314
+
315
+ A.1 Pretraining Details 17
316
+ A.2 Short-Range Genomics Details 18
317
+ A.2.1 GenomicBenchmarks experiment 18
318
+ A.2.2 Ablations on the GenomicBenchmarks 18
319
+ A.2.3 Downstream prediction tasks for Nucleotide Transformer benchmark 19
320
+ A.2.4 Ablations on the Nucleotide Transformer benchmarks 20
321
+ A.3 In-Context Learning Details 20
322
+ A.4 Chromatin Profile Details 22
323
+ A.5 Biotype Embeddings Analysis Details 23
324
+
325
+ # A Appendix: Experimental Details
326
+
327
+ In the following sections we provide further details for each experiment. Across all experiments, we use Pytorch and Pytorch Lightning. We train on a mix of Nvidia GPUs with A100s, V100s, and T4s. Unless otherwise stated, we use a cross entropy loss for our objective. Our repository is made public here: https://github.com/HazyResearch/hyena-dna.
328
+
329
+ # A.1 Pretraining Details
330
+
331
+ Table A.1: Hyperparameter settings for HyenaDNA pretraining (select models).
332
+
333
+ <table><tr><td>Layers Width</td><td>2 128</td><td>2 256</td><td>4 128</td><td>4 256</td><td>8 256</td></tr><tr><td>Params (M) Max seq. len.</td><td>0.44 64k</td><td>1.6 64k</td><td>0.87 64k</td><td>3.3 64k</td><td>6.6 1M</td></tr><tr><td>Optimizer</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Optimizer momentum</td><td></td><td>β1, β = 0.9,0.999</td><td>AdamW</td><td></td><td></td></tr><tr><td>Learning rate</td><td></td><td></td><td>1.5 - 6e-4</td><td></td><td></td></tr><tr><td>LR Scheduler</td><td></td><td>Cosine decay</td><td></td><td></td><td></td></tr><tr><td>Batch size</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Global steps</td><td></td><td></td><td>64 - 256 10- 20k</td><td></td><td></td></tr><tr><td>Weight decay (model)</td><td></td><td></td><td>0.1</td><td></td><td></td></tr><tr><td>Weight decay (Hyena layers)</td><td></td><td></td><td>0</td><td></td><td></td></tr><tr><td>Embed dropout</td><td></td><td></td><td>0.1</td><td></td><td></td></tr><tr><td>Residual dropout</td><td></td><td></td><td>0</td><td></td><td></td></tr></table>
334
+
335
+ Data For pretraining, we use a single human reference genome [22], and leverage the training and validation intervals (start and end) from [1]. During training, we sample an interval and obtain a sequence of length $L$ by adjusting the intervals on both ends. For the test set, we use chromosomes 14 and X, exclusively, and sample non-overlapping sequences of length $L$ .
336
+
337
+ Model We design a suite of parameter efficient architectures with depths between 2 and 8 layers, Hyena blocks of Order- $\mathbf { N } = 2$ , and width 128 to 256. The MLP expansion factor (reverse bottleneck) is $4 \mathbf { x }$ the width. See Fig. 1.3 for the block architecture of HyenaDNA. The parameter counts range from 400k to $6 . 6 \mathsf { M }$ , trained on sequence lengths between 1,024 and 1M. Tab. A.1 highlights a representative subset of the models we trained. Note: we use different pretrained model sizes depending on the downstream task to prevent overfitting. When selecting which pretrained model to use for a downstream task, we found that a pretrained sequence length of 2 to $4 \mathbf { x }$ the downstream max sequence length results in the best performance.
338
+
339
+ Training We pretrain each model for 10-20k global steps. For models trained on longer sequences, this translates to more tokens being used, as each sample contains more tokens. For example, the largest model with context length 1M was trained on 2T tokens over 4 weeks. We adjust the "accumulate_grad_batches" argument in Pytorch Lightning to keep the global batch size consistent across models and sequence lengths. See Tab. A.1 for hyperparameter details.
340
+
341
+ Training efficiency We compare pretraining compute resources and GPU-hours to reach competitive performance on the short-range tasks for several baselines and HyenaDNA models, shown in Tab. A.2.
342
+
343
+ Table A.2: Pretraining GPU & runtime comparison for short-range models.
344
+
345
+ <table><tr><td></td><td>DNABERT</td><td>NUCLEOTIDE TRANSFORMER</td><td>HyenaDNA</td><td>HyenaDNA</td></tr><tr><td>Params</td><td>110M</td><td>2.5B</td><td>436K</td><td>1.6M</td></tr><tr><td>GPUs</td><td>8-2080 TI</td><td>128-A100-80GB</td><td>1-A100-40GB</td><td>1-A100-40GB</td></tr><tr><td>Wall clock</td><td>25 days</td><td>28 days</td><td>80 mins</td><td>80 mins</td></tr><tr><td>GPU-hrs</td><td>12,000</td><td>215,000</td><td>1.3</td><td>1.3</td></tr></table>
346
+
347
+ # A.2 Short-Range Genomics Details
348
+
349
+ # A.2.1 GenomicBenchmarks experiment
350
+
351
+ Data The GenomicBenchmarks [23] includes 8 datasets designed for sequence-level classification tasks that involve predicting regulatory elements, along with one binary species task. The benchmarks provided for the baseline model include two sets of results: one obtained with Pytorch and the other with TensorFlow. Since our code base is implemented in Pytorch, we compare our results with the Pytorch-based benchmarks.
352
+
353
+ Model Our backbone is a pretrained 2 layer HyenaDNA model with width 128, trained on sequence length 1024. We pool along the sequence dimension to obtain a classification token, and attach a simple linear decoder head. The baseline CNN, as described by [23], uses uses an embedding layer, 3 convolutional layers with number of filters: 16, 8, and 4. It uses batch norm and max pooling after each convolutional layer, followed by 2 dense layers. It is trained for 10 epochs with batch size 64. The mode sizes range from 120k to 520k, depending on sequence length chosen.
354
+
355
+ Table A.3: GenomicBenchmarks hyperparameters for HyenaDNA and the baseline Transformer (GPT from 4.1), which uses FlashAttention [11].
356
+
357
+ <table><tr><td></td><td>TRANSFORMER</td><td>HyenaDNA</td></tr><tr><td>Layers</td><td>2</td><td>2</td></tr><tr><td>Width</td><td>128</td><td>128</td></tr><tr><td>Parameters</td><td>529k</td><td>436k</td></tr><tr><td>Learning rate</td><td>1-6e-4</td><td>1-6e-4</td></tr><tr><td>Weight decay (model)</td><td>0-0.2</td><td>0-0.2</td></tr><tr><td>Weight decay (Hyena layers)</td><td>-</td><td>0</td></tr><tr><td>Embed dropout</td><td>0-0.2</td><td>0.0-0.3</td></tr><tr><td>Resid dropout</td><td>0-0.2</td><td>0-0.3</td></tr><tr><td>Num heads</td><td>8</td><td></td></tr><tr><td>Optimizer</td><td>AdamW</td><td></td></tr><tr><td>Optimizer momentum</td><td>β1,β2= 0.9,0.999</td><td></td></tr><tr><td>LR scheduler</td><td>Cosine decay</td><td></td></tr><tr><td>Batch size</td><td>128-1024</td><td></td></tr><tr><td>Training epoch</td><td>100</td><td></td></tr><tr><td>Reverse complement aug.</td><td>true/false</td><td></td></tr><tr><td>Sequence lengths</td><td>200-4800</td><td></td></tr></table>
358
+
359
+ Training The primary hyperparameters we sweep across include: learning rate, global batch size, dropout, weight decay, and a reverse complement augmentation. See Tab. A.3 for ranges of hyperparamters used.
360
+
361
+ # A.2.2 Ablations on the GenomicBenchmarks
362
+
363
+ To better understand how specific design choices in the HyenaDNA model effect performance, we perform a series of ablation experiments on the GenomicBenchmarks.
364
+
365
+ Pretraining: We train HyenaDNA from scratch and compare with the pretrained version. The pretrained models provide mild to moderate gains - likely due to the benchmarks being near saturation already.
366
+
367
+ Tokenization: We train HyenaDNA using a k-mer tokenizer $\scriptstyle ( \mathbf { k } = 6 )$ to isolate the effect of the single nucleotide tokenizer. The $\mathbf { k }$ -mer tokenizer drops performance significantly across on a majority of the datasets (by as much as 10 accuracy points), while boosting one dataset (Human Enhancer Ensembl). Therefore, the single nucleotide tokenization appears to be a significant component of the HyenaDNA model.
368
+
369
+ Bidirectional: To ablate the impact of using a causal model, we implemented a bidirectional version of HyenaDNA and trained from scratch on the GenomicBenchmarks (i.e. without masked language model pretraining). The bidirectional version degraded performance on 7 of 8 datasets compared to the standard causal HyenaDNA (also from scratch), on average by 3.8 accuracy points.
370
+
371
+ Table A.4: GenomicBenchmarks Top-1 accuracy $( \% )$ GPT is the causal Transformer from 4.1, HyenaDNA k-mer uses a 6-mer tokenizer, and HyenaDNA bidirection is a bidirectional version of the Hyena operator.
372
+
373
+ <table><tr><td>MODEL</td><td>GPT</td><td>GPT</td><td>HyenaDNA</td><td>HyenaDNA</td><td>HyenaDNA k-mer</td><td>HyenaDNA bidirection</td><td>DNABERT</td></tr><tr><td>Pretrained</td><td>no</td><td>yes</td><td>no</td><td>yes</td><td>no</td><td>no</td><td>yes</td></tr><tr><td>Mouse Enhancers</td><td>79.3</td><td>79.3</td><td>84.7</td><td>85.1</td><td>81.8</td><td>80.6</td><td>66.9</td></tr><tr><td>Coding vs Intergenomic</td><td>89.3</td><td>91.2</td><td>90.9</td><td>91.3</td><td>86.7</td><td>90.3</td><td>92.5</td></tr><tr><td>Human vs Worm</td><td>94.8</td><td>96.6</td><td>96.4</td><td>96.6</td><td>92.9</td><td>95.9</td><td>96.5</td></tr><tr><td>Human Enhancers Cohn</td><td>67.7</td><td>72.9</td><td>72.9</td><td>74.2</td><td>69.8</td><td>72.1</td><td>74.0</td></tr><tr><td>Human Enhancers Ensembl</td><td>79.0</td><td>88.3</td><td>85.7</td><td>89.2</td><td>88.0</td><td>85.9</td><td>85.7</td></tr><tr><td>Human Regulatory</td><td>90.2</td><td>91.8</td><td>90.4</td><td>93.8</td><td>90.2</td><td>89.1</td><td>88.1</td></tr><tr><td>Human Nontata Promoters</td><td>85.2</td><td>90.1</td><td>93.3</td><td>96.6</td><td>83.5</td><td>88.5</td><td>85.6</td></tr><tr><td>Human OCR Ensembl</td><td>68.3</td><td>79.9</td><td>78.8</td><td>80.9</td><td>70.2</td><td>75.3</td><td>75.1</td></tr></table>
374
+
375
+ The bidirectional HyenaDNA was implemented by using a circular FFT convolution. This involved manipulating the padding on the input sequence before performing the FFT convolution. Previously, we zero padded the input on the right side by length $L$ (the sequence length). For bidirectionality, we pad by $1 / 2 \ L$ on the left and right side of the input, effectively providing a bidirectional receptive field (due to the circular convolution). This is one of many possible ways to implement a bidirectional version of Hyena.
376
+
377
+ # A.2.3 Downstream prediction tasks for Nucleotide Transformer benchmark
378
+
379
+ Following the Nucleotide Transformer [10], we collected datasets from four different sources [21, 35, 34, 46].
380
+
381
+ Promoter The promoter dataset included TATA-box-containing and TATA-box-lacking promoters. Tasks involved predicting promoters with a TATA-box, identifying promoters lacking a TATAbox, and distinguishing between both promoter categories and non-promoter sequences. The promoter datasets were obtained from the Eukaryotic Promoter Database (EPDnew)4 for human and mouse genomes. Promoter sequences were extracted from regions 249 nucleotides upstream and 50 nucleotides downstream of the transcription start sites.
382
+
383
+ Enhancer For the enhancer prediction task, we used the dataset from [21] containing DNA sequences classified into strong enhancers, weak enhancers, and non-enhancers. The tasks involved binary classification to distinguish enhancer sequences from non-enhancer sequences and identify specific enhancer types.
384
+
385
+ Epigenetic Marks In the epigenetic marks prediction task, we used the dataset from [35, 36] to predict nucleosome occupancy and modification states in the yeast genome. In 10 binary classification tasks, the model had to discriminate between DNA regions that were occupied by histones or not. The 10 tasks varied based on the types of histones investigated, including unmodified histones H3 and H4, as well as histones modified by either acetylation (H3K9ac, H3K14ac) or methylation (H3K4me1, H3K4me2, H3K4me3, H3K36me3, H3K79me3).
386
+
387
+ Splice Site For the splice site prediction task, DNA sequences from over 100 organisms were used to predict whether the sequences contain donor or acceptor splice sites [46]. Donor splice sites denote the beginning of an intron and acceptor splice sites the end of an intron. During RNA splicing, these sites are recognized by the spliceosome, a complex molecular machine that enables the removal of introns from the gene.
388
+
389
+ Table A.5: Hyperparameter ranges used to fine-tune HyenaDNA for all Nucleotide transformer datasets. Exact hyperparameters per dataset can be found in our code repository.
390
+
391
+ <table><tr><td></td><td>HyenaDNA</td></tr><tr><td>Layers</td><td>2</td></tr><tr><td>Width</td><td>256</td></tr><tr><td>Parameters</td><td>1.6M</td></tr><tr><td>Optimizer</td><td>AdamW</td></tr><tr><td>Optimizer momentum</td><td>β1,β2= 0.9,0.999</td></tr><tr><td>Training epoch</td><td>100</td></tr><tr><td>Batch size</td><td>256-1024</td></tr><tr><td>Learning rate</td><td>2e-4 to 1e-3</td></tr><tr><td>LR scheduler</td><td>Cosine decay</td></tr><tr><td>Weight decay (model)</td><td>0-0.2</td></tr><tr><td>Weight decay (Hyena layers)</td><td>0</td></tr><tr><td>Embed dropout</td><td>0-0.2</td></tr><tr><td>Resid dropout</td><td>0-0.2</td></tr><tr><td>Reverse complement aug.</td><td>true/false</td></tr><tr><td>Sequence lengths</td><td>200-600</td></tr></table>
392
+
393
+ Preprocessing The Nucleotide Transformer study did not provide their exact train-test splits, except for the enhancer dataset. Therefore, we generated our own train-test splits using a 90:10 ratio. For the promoter dataset, negative samples were not available, and had to be generated following the procedure described by [34].
394
+
395
+ Model & Training For the architecture, we use a HyenaDNA model with 2 layers and width 256, and trained on sequences of length 1024. We average across the tokens to obtain a single classification token. For each task, we replaced the model head and fine-tuned the weights of the entire model (1.6M parameters). In contrast, the Nucleotide Transformer uses a parameter-efficient fine-tuning technique that introduces new weights and fine-tunes only the newly added weights, while keeping the initial model weights frozen, presumably due to its large size of 500M to 2.5B parameters. The corresponding HyenaDNA hyperparameter ranges used for training each task are reported in Table A.5.
396
+
397
+ # A.2.4 Ablations on the Nucleotide Transformer benchmarks
398
+
399
+ We perform additional ablations on the Nucleotide Transformer benchmarks to assess the impact of pretraining, as well as attention vs. HyenaDNA, as shown in shown in Table A.6. We observed that pretraining has a greater effect on the more challenging tasks (and as sequences become longer, shown in A.11). On the more challenging tasks (histone marks, datasets starting with “H”), pretraining boosts HyenaDNA metrics by up to 21 MCC points on H3K4me3. For simpler tasks (with higher baseline scores) such as the splice sites and promoter tasks, the gain was lower (0 to 1 accuracy points), as these were already near saturation in performance.
400
+
401
+ # A.3 In-Context Learning Details
402
+
403
+ Background A key premise of foundation models is that they are able to learn new tasks with little to no new training data [4]. Recent advances in language modeling have demonstrated that language foundation models can often adopt the behaviors necessary to perform new tasks in-context [6]. Here, information about the task that is to be performed, such as examples of respective inputs and targets, are added to the input of the model. By conditioning their prediction on the provided context, language foundation models are generally able to perform the task without any changes to their parameters.
404
+
405
+ A key challenge for in-context learning with HyenaDNA is its limited vocabulary, which is composed of only a few nucleotides, and does not provide any vocabulary for novel downstream tasks, such as class labels. To explore the potential for in-context learning in genomics, we use two variants of in-context learning, both using a brief tuning phase to introduce HyenaDNA to the concept of classification with its existing vocabulary. As a test bed for this exploration, we use 5 datasets from the GenomicBenchmarks and a HyenaDNA pretrained on sequences of $1 6 0 \mathrm { k }$ length sequences.
406
+
407
+ <table><tr><td>MODEL PARAMS PRETRAIN</td><td>NT 2.5B</td><td>GPT 1.6M</td><td>HyenaDNA 1.6M</td><td>HyenaDNA 1.6M</td></tr><tr><td>Enhancer</td><td>yes 58.0</td><td>yes 59.3</td><td>yes 62.6</td><td>no 58.6</td></tr><tr><td>Enhancer types</td><td>47.4</td><td>51.9</td><td>55.7</td><td>48.4</td></tr><tr><td>H3</td><td>81.4</td><td>75.8</td><td>81.7</td><td>79.9</td></tr><tr><td>H3K4me1</td><td>55.9</td><td>38.7</td><td>57.1</td><td>43.4</td></tr><tr><td>H3K4me2</td><td>32.6</td><td>28.8</td><td>53.9</td><td>34.5</td></tr><tr><td>H3K4me3</td><td>42.1</td><td>28.3</td><td>61.2</td><td>40.2</td></tr><tr><td>H3K9ac</td><td>57.5</td><td>49.2</td><td>65.1</td><td>52.6</td></tr><tr><td>H3K14ac</td><td>55.0</td><td>41.6</td><td>66.3</td><td>48.0</td></tr><tr><td>H3K36me3</td><td>63.2</td><td>47.8</td><td>65.3</td><td>53.4</td></tr><tr><td>H3K79me3</td><td>64.2</td><td>58.9</td><td>71.6</td><td>59.7</td></tr><tr><td>H4</td><td>82.2</td><td>77.7</td><td>79.6</td><td>79.1</td></tr><tr><td>H4ac</td><td>50.1</td><td>36.4</td><td>63.7</td><td>43.5</td></tr><tr><td>Promoter all</td><td>97.4</td><td>96.3</td><td>96.5</td><td>96.1</td></tr><tr><td>Promoter non-TATA</td><td>97.7</td><td>96.6</td><td>96.6</td><td>96.5</td></tr><tr><td>Promoter TATA</td><td>96.4</td><td>96.6</td><td>96.7</td><td>96.1</td></tr><tr><td></td><td>99.0</td><td>97.6</td><td>96.6</td><td>96.6</td></tr><tr><td>Splice acceptor</td><td>98.4</td><td>98.1</td><td>97.3</td><td>96.5</td></tr><tr><td>Splice donor</td><td>98.3</td><td>98.0</td><td>97.9</td><td>97.3</td></tr><tr><td>Splice all</td><td></td><td></td><td></td><td></td></tr></table>
408
+
409
+ In the first experiment, we apply a soft prompting approach [27] by adding a sequence of tuneable tokens to the input inself. In the second experiment, we explore a few-shot learning approach [6] to in-context learning by adding $k$ demonstrations (DNA sequence and its label) for each class of a dataset as input to the model. To indicate classes, we make use of HyenaDNA’s existing vocabulary by indicating classes with specific nucleotides. For binary classification, we indicate classes with the nucleotides "A" and "N", while additionally utilising nucleotide "G" for three-way classification. During model tuning, we thereby optimise the same next-nucleotide prediction loss as used during pretraining. See Table A.7 for an overview of the optimisation settings.
410
+
411
+ ![](images/5dfa496a0d1cf99d79499a50490e7f48201b73f121359aea324255419b534052.jpg)
412
+ Table A.6: Pretraining & Attention ablations on the Nucleotide Transformer (NT) benchmarks. The Matthews correlation coefficient (MCC) is used as the performance metric for the enhancer and epigenetic marks dataset, and the F1-score is used for the promoter and splice site dataset.
413
+ Figure A.1: Few-shot prompting: HyenaDNA’s performance on new tasks generally improves with the number of tuning samples, but is less clear when isolating the number of $k$ -shot demonstrations. With less tuning samples, the number of $k$ -shot demonstrations do not improve performance. As tuning samples increase, the number of $k$ -shot demonstrations start to improve performance.
414
+
415
+ Soft prompting details For each dataset, we prepend a sequence of $n$ (2 to 32k) learnable tokens $T _ { e } \in \overline { { \mathbb { R } ^ { n \times \bar { d } } } }$ , each of dimension $d$ , to the input sequences $X$ of the model: $\{ T _ { e } , X , S E P \}$ , where "SEP" indicates the separation token. We optimise these tuneable tokens for a maximum of 20 training epochs on the dataset’s training data while keeping all other model parameters fixed. We stop training early if the model’s validation loss does not improve for two epochs. After this tuning phase, we evaluate the model’s performance on the dataset’s full validation data. For an overview of the results of this experiment, see Fig. 4.2 of the main text.
416
+
417
+ Few-shot prompting details For each dataset, we prepend a set of $k$ (0 to 32, 0 indicates regular fine-tuning) examples of each class of a dataset (so-called "shots") to an input sequence:
418
+
419
+ $$
420
+ X : \quad \{ X _ { 1 } , { \mathsf { S E P } } , Y _ { 1 } , { \mathsf { S E P } } , X _ { 2 } , { \mathsf { S E P } } , Y _ { 2 } , { \mathsf { S E P } } , X , { \mathsf { S E P } } \} ,
421
+ $$
422
+
423
+ where $X _ { i }$ indicates an example sequence of class $i$ with label $Y _ { i }$ (exemplified for a two-way classification task). We tune the model on $n$ (2 to 256) such $k$ -shot samples before evaluating its performance on the dataset’s full validation data. For an overview of the results of this experiment, see Fig. A.1.
424
+
425
+ Table A.7: Optimization settings for in-context learning.
426
+
427
+ <table><tr><td></td><td>SOFT PROMPTING</td><td>FEW-SHOTPROMPTING</td></tr><tr><td>Optimizer</td><td>AdamW</td><td>AdamW</td></tr><tr><td>Optimizer momentum (β1, β2)</td><td>0.9, 0.999</td><td>0.9, 0.999</td></tr><tr><td>Learning Rate</td><td>0.001</td><td>0.0001</td></tr><tr><td>Batch Size</td><td>16</td><td>2</td></tr><tr><td>Weight Decay (model)</td><td>0</td><td>0</td></tr><tr><td>Weight Decay (Hyena layers)</td><td>0</td><td>0</td></tr><tr><td>Resid dropout</td><td>0</td><td>0</td></tr><tr><td>Embed dropout</td><td>0.1</td><td>0.1</td></tr><tr><td>Reverse complement aug.</td><td>true</td><td>false</td></tr><tr><td>LR-schedule</td><td>Plateau</td><td>1</td></tr></table>
428
+
429
+ # A.4 Chromatin Profile Details
430
+
431
+ Background Variations in non-coding regions of the genome account for the majority of disease and other trait-associated single-nucleotide polymorphisms (SNPs). For example, whilst not directly altering the sequence of an encoded protein, a SNP in a non-coding region can affect the expression of downstream genes by inducing a change in the epigenetic state [56]. Therefore predicting epigenetic markers from a given sequence is an important task in the context of quantifying the functional effects of non-coding variants. Previously DeepSEA [57], a deep convolutional sequence model, has been introduced to predict chromatin features directly from non-coding sequences.
432
+
433
+ Data The authors of DeepSEA [57] compiled a dataset of 919 chromatin features from [15] and [42] including 690 TF binding profiles for 160 different TFs, 125 DHS and $1 0 4 \mathrm { H M }$ profiles. The original DeepSEA dataset consists of 1000 base pair (bp) sequences from the $\mathrm { h g } 1 9$ human reference genome [8] with corresponding 919-dimension multi-label target vectors. Each label corresponds to the presence/absence of a peak in a given chromatin feature within the central 200 bp region of the sequence. The 400 bp flanking regions of the sequence provide broader contextual information which is beneficial to the task. Training and testing sets are split by chromosome and are strictly non-overlapping. In total, there are $2 . 2 \mathbf { M }$ training samples and 227,512 samples from chromosomes 8 and 9 are held-out for testing. We use the DeepSEA chromatin profile prediction task to evaluate HyenaDNA models with varying context window. We use LiftOver [26] to convert the original DeepSEA dataset to $\mathrm { h g } 3 8$ coordinates and expand flanking regions about the central 200 bp bin symmetrically up to 8000 bp. Approximately $0 . 5 \%$ of samples are filtered in cases where LiftOver fails or the resulting translated sequence has a different length.
434
+
435
+ Model We fine-tune several models consisting of a pretrained HyenaDNA encoder, a sequencelevel pooling layer and a fully-connected decoder to perform multilabel sequence classification. We compare HyenaDNA against benchmarks set by DeepSEA, a convolutional sequence model, and BigBird [55], a sparse attention based language model. The authors of BigBird fine-tune on the DeepSEA dataset with input sequences extended to 8000 bp (asymmetrically about the centerpoint by -5000 and $+ 3 0 0 0$ bp). Notably BigBird utilizes a byte-pair encoding tokenization scheme whereas HyenaDNA uses a single-character tokenizer and DeepSEA uses one-hot encodings. For the shortest range model (1k), we average across all tokens to perform sequence-level pooling. Whereas in the longer context model $( 8 \mathbf { k } )$ we find that extracting the last token in the sequence as the input to the fully-connected decoder performs better. We also find that for the longer context model using an encoder pretrained on sequences larger than those used in fine-tuning was beneficial. The hyperparameters of the models used in these experiments are shown in Table A.8. Note that we reduced the depth and of models with increasing context window due to limitations on compute cost/time.
436
+
437
+ Results The performance of the fine-tuned HyenaDNA models are summarised in Table 4.3. We find that the smallest sequence length model (1024 bp) outperforms both DeepSEA and BigBird on TF and DHS prediction. We find that the model pretrained on 32k sequences with only 4 layers and fine-tuned on $^ \mathrm { 8 k }$ sequences outperforms BigBird on the long range HM task but suffers from degraded performance on the short range tasks. However, we postulate that this performance loss may be recovered by increasing the depth of the model. We also remark that our models contain $5 { - } 3 0 \times$ fewer parameters compared to DeepSEA and BigBird.
438
+
439
+ Table A.8: Chromatin profile model settings. HyenaDNA hyperparameter settings used in the chromatin profile prediction experiments (fine-tuning).
440
+
441
+ <table><tr><td></td><td colspan="2">HyenaDNA</td></tr><tr><td>Sequence length</td><td>1024</td><td>8k</td></tr><tr><td>Context window</td><td>1024</td><td>32770</td></tr><tr><td>Width</td><td>256</td><td>256</td></tr><tr><td>Layers</td><td>8</td><td>4</td></tr><tr><td>Pooling method</td><td>Average</td><td>Last token</td></tr><tr><td>Parameters (M)</td><td>6.6</td><td>3.5</td></tr><tr><td>Optimizer</td><td>AdamW</td><td>AdamW</td></tr><tr><td>Optimizer momentum</td><td>β1,β2 = 0.9,0.999</td><td>β1,β2=0.9,0.999</td></tr><tr><td>Weight decay (model)</td><td>0.1</td><td>0.1</td></tr><tr><td>Weight decay (Hyena layers)</td><td>0</td><td>0</td></tr><tr><td>Embed dropout</td><td>0.1</td><td>0.1</td></tr><tr><td>Learning rate</td><td>6e-4</td><td>6e-4</td></tr><tr><td>Batch size</td><td>64</td><td>64</td></tr><tr><td>Epochs</td><td>50</td><td>50</td></tr></table>
442
+
443
+ # A.5 Biotype Embeddings Analysis Details
444
+
445
+ Background Sequence embeddings are useful in reducing dimensionality and capturing semantic relationships into fixed length vectors. We analyze pretrained embedding quality from HyenaDNA and show that it learns biologically informed features. We utilize linear probing, freezing the weights on a pretrained model and attaching a linear classification head to predict biotype sequences. We also use t-SNE to visualize clusterings that emerge from the embeddings.
446
+
447
+ Data The Ensembl database [9] is a comprehensive resource for gene and transcript annotations such as biotypes. Ensembl biotypes are a classification system, based on a combination of experimental evidence and computational predictions, that summarises the high-level functional properties of genes and transcripts. For example, biotype classes may annotate whether a gene is protein-coding or encodes a long non-coding RNA; if a gene is a disrupted homologue of a known protein coding gene (pseudogene) and by what mechanism it is produced; or the role of a small non-coding RNA such as post-transcriptional modification of other RNAs in the cell nucleus. We use biotype annotations to qualitatively visualize the clustering of gene embeddings into functional groups. We construct a multi-classification task using the top 10 most frequent biotype annotations as multi-class target labels which we predict from the unsupervised embeddings to assess how well biological function is encoded in the embedding space.
448
+
449
+ Model & Training We use a frozen pretrained HyenaDNA model consisting of 8 layers and width 256 pretrained on sequences of length 160k. To extract sequence-level embeddings, we average along the sequence dimension in the final encoder layer. For comparison we also construct embeddings using DNABERT (5-mer) and Nucleotide Transformer. We construct embeddings for genes in the Ensembl dataset up to a length of 160k. For genes with sequence lengths exceeding the context window of the encoder, we chunk the sequence and average the embeddings over the chunks. We utilize an XGBoost [7] classifier to perform the supervised multi-classification task on the embeddings. The hyperparameters used are shown in Table A.9.
450
+
451
+ Table A.9: Hyperparameters. Overview of XGBoost hyperparameters used in biotype multiclassifier.
452
+
453
+ <table><tr><td>Estimators Max depth</td><td>1000</td></tr><tr><td>Learning rate</td><td>3 0.1</td></tr><tr><td>Objective</td><td>softmax</td></tr><tr><td></td><td></td></tr></table>
454
+
455
+ Results As shown in 4.4, HyenaDNA achieves the highest F1 score on the biotype classification task indicating that its embeddings contain features that are informative of biological function. Notably, HyenaDNA achieves this using the much smaller embedding space dimension of 256, compared to DNABERT and Nucleotide Transformer, which produce embeddings of dimension 1029 and 1280, respectively.
456
+
457
+ # A.6 Long-range Species Classification Details
458
+
459
+ Table A.10: Hyperparameter ranges for ultra-long range species classification task. Transformer uses FlashAttention [11].
460
+
461
+ <table><tr><td></td><td colspan="2">TRANSFORMER</td><td colspan="4">HyenaDNA</td></tr><tr><td>Layers</td><td>2</td><td>2</td><td>2</td><td>2</td><td>8</td><td>8</td></tr><tr><td>Sequence length</td><td>1024</td><td>32768</td><td>1024</td><td>32768</td><td>250000</td><td>450000</td></tr><tr><td>Width</td><td>128</td><td>128</td><td>128</td><td>128</td><td>256</td><td>256</td></tr><tr><td>Parameters (M)</td><td>0.5</td><td>4.5</td><td>0.4</td><td>0.4</td><td>6.6</td><td>6.6</td></tr><tr><td>Num heads</td><td>8</td><td>8</td><td></td><td></td><td></td><td></td></tr><tr><td>Learning rate</td><td>6e-5</td><td>6e-4</td><td>- 6e-5</td><td>= 3e-4</td><td>1 6e-5</td><td>1 6e-4</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Optimizer</td><td colspan="6">AdamW</td></tr><tr><td>Optimizer momentum</td><td colspan="6">β1,β = 0.9,0.999</td></tr><tr><td>LR scheduler</td><td colspan="6">Cosine decay</td></tr><tr><td>Weight decay (model)</td><td colspan="6">0.1</td></tr><tr><td>Weight decay (Hyena layers)</td><td colspan="6">0</td></tr><tr><td>Embed dropout</td><td colspan="6">0.1</td></tr><tr><td>Resid dropout</td><td colspan="6">0</td></tr><tr><td>Batch size</td><td colspan="6">128 - 256</td></tr><tr><td>Training epoch</td><td colspan="6">200</td></tr><tr><td>Reverse complement aug.</td><td colspan="6">False</td></tr></table>
462
+
463
+ Background Given a genetic sequence randomly sampled from a set of different species, successful identification of the source species requires a model to learn a distinct mutational profile for each species. The more locations for discriminative mutations a model can consider, the more successful it should be at this task. We can arbitrarily tune this task’s difficulty by including a higher number of species or increasing the evolutionary similarity of the included species, and thus it represents a helpful setting for measuring long context reasoning abilities for DNA sequence models.
464
+
465
+ Data We select five species for this task: human (homo sapien), lemur (lemur catta), mouse (mus musculus), pig (sus scrofa), and hippo (hippopotamus amphibius). We hold out four chromosomes from each species (chromosome numbers 1, 3, 12, and 13) for evaluation, and use the rest of each species’ chromosomes for training.
466
+
467
+ Model We compare HyenaDNA against a baseline Transformer, which uses Flash Attention [11] in the mixing layer instead of a Hyena operator. We use 2 and 8 layer models, depending on sequence length. For HyenaDNA, we train on sequence lengths of 1k, 32k, 250k, 450k and 1M. For
468
+
469
+ Transformer, we limit sequence lengths to 1k and $3 2 \mathrm { k }$ due to the quadratic increase in training time, making training infeasible on our hardware. See Table A.10 for model sizes and hyperparamters.
470
+
471
+ Training We use pretrained models from 4.1, trained on various lengths between 1k to 1M nucleotides, and fine-tune them using a linear decoder head. We either pool across all tokens (1k and $3 2 \mathrm { k }$ models) or use the last token for classification ( $2 5 0 \mathbf { k } \mathrm { ~ - ~ } 1 \mathbf { M }$ models). We randomly sample a (species, chromosome, sequence start, sequence end) tuple at each training step, with uniform probability across all species and non-held-out chromosomes. If a sequence’s starting location on a chromosome is such that the end of that sequence would exceed the length of the chromosome, then we pad the sequence with N’s to its full intended length. For evaluation, we randomly sample a (species, chromosome, sequence start, sequence end) tuple from our held-out evaluation set of chromosomes, and record the overall Top-1 5-way accuracy of our model (i.e. fraction of sequences correctly classified).
472
+
473
+ At sequence length $4 5 0 \mathrm { k }$ , we use the sequence length warm-up scheduler described in 3.2 on HyenaDNA. This involves gradually increasing the length of sequences fed to the model during fine-tuning from 1k to 450k. We observe better convergence and higher overall peak accuracy with this strategy, as shown in 3.2.
474
+
475
+ Table A.11: Pretraining vs scratch on 5-way species classification. Top $1 \%$ accuracy for HyenaDNA by sequence length.
476
+
477
+ <table><tr><td colspan="2">HyenaDNA</td></tr><tr><td>LENGTH</td><td>SCRATCH PRETRAINED</td></tr><tr><td>1k</td><td>53.9 61.1</td></tr><tr><td>32k</td><td>70.7 93.4</td></tr><tr><td>250k</td><td>65.7 97.9</td></tr><tr><td>450k</td><td>71.4 99.4</td></tr></table>
478
+
479
+ Pretraining ablation For species classification, pretraining becomes more important for longer sequences. This is in-line with our observation that for harder tasks (including longer sequences), pretraining becomes more important. At sequence length $2 5 0 \mathrm { k }$ and $4 5 0 \mathrm { k }$ , the scratch vs. pretraining gap is $^ { 3 0 + }$ accuracy points.
md/dev/ucASPPD9GKN/ucASPPD9GKN.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/ucNDIDRNjjv/ucNDIDRNjjv.md ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Non-stationary Transformers: Exploring the Stationarity in Time Series Forecasting
2
+
3
+ Yong Liu∗, Haixu Wu∗, Jianmin Wang, Mingsheng LongB School of Software, BNRist, Tsinghua University, China {liuyong21,whx20}@mails.tsinghua.edu.cn, {jimwang,mingsheng}@tsinghua.edu.cn
4
+
5
+ # Abstract
6
+
7
+ Transformers have shown great power in time series forecasting due to their global-range modeling ability. However, their performance can degenerate terribly on non-stationary real-world data in which the joint distribution changes over time. Previous studies primarily adopt stationarization to attenuate the nonstationarity of original series for better predictability. But the stationarized series deprived of inherent non-stationarity can be less instructive for real-world bursty events forecasting. This problem, termed over-stationarization in this paper, leads Transformers to generate indistinguishable temporal attentions for different series and impedes the predictive capability of deep models. To tackle the dilemma between series predictability and model capability, we propose Non-stationary Transformers as a generic framework with two interdependent modules: Series Stationarization and De-stationary Attention. Concretely, Series Stationarization unifies the statistics of each input and converts the output with restored statistics for better predictability. To address the over-stationarization problem, Destationary Attention is devised to recover the intrinsic non-stationary information into temporal dependencies by approximating distinguishable attentions learned from raw series. Our Non-stationary Transformers framework consistently boosts mainstream Transformers by a large margin, which reduces MSE by $4 9 . 4 3 \%$ on Transformer, $4 7 . 3 4 \%$ on Informer, and $4 6 . 8 9 \%$ on Reformer, making them the state-of-the-art in time series forecasting. Code is available at this repository: https://github.com/thuml/Nonstationary_Transformers.
8
+
9
+ # 1 Introduction
10
+
11
+ Time series forecasting has become increasingly ubiquitous in real-world applications, such as weather forecasting, energy consumption planning, and financial risk assessment. Recently, Transformers [32] have achieved progressive breakthrough on extensive areas [11, 12, 10, 22]. Especially in time series forecasting, credited to their stacked structure and the capability of attention mechanisms, Transformers can naturally capture the temporal dependencies from deep multi-level features [37, 17, 20, 35], thereby fitting the series forecasting task perfectly.
12
+
13
+ Despite the remarkable architectural design, it is still challenging for Transformers to predict realworld time series because of the non-stationarity of data. Non-stationary time series is characterized by the continuous change of statistical properties and joint distribution over time, which makes the time series less predictable [6, 14]. Besides, it is a fundamental problem to make deep models generalize well on a varying distribution [26, 19, 5]. In previous work, it is generally acknowledged to pre-process the time series by stationarization [24, 27, 15], which can attenuate the non-stationarity of raw time series for better predictability and provide more stable data distribution for deep models.
14
+
15
+ ![](images/ab887f40e0f0381567f915353a567d5f34eacb881747b0173feea4be09570c12.jpg)
16
+ Figure 1: Visualization of learned temporal attentions for different series with varied mean $\mu$ and standard deviation $\sigma$ . (a) is from the vanilla Transformer [32] trained on raw series. (b) is from the Transformer trained on stationarized series, which presents similar attentions. (c) is from Nonstationary Transformers, which involves De-stationary Attention to avoid over-stationarization.
17
+
18
+ However, non-stationarity is the inherent property of real-world time series and also good guidance for discovering temporal dependencies for forecasting. Experimentally, we observe that training on the stationarized series will undermine the distinction of attentions learned by Transformers. While vanilla Transformers [32] can capture distinct temporal dependencies from different series in Figure 1(a), Transformers trained on the stationarized series tend to generate indistinguishable attentions in Figure 1(b). This problem, named by the over-stationarization, will bring unexpected side-effect that makes Transformers fail to capture eventful temporal dependencies, limit the model’s predictive ability, and even induce the model to generate outputs with huge non-stationarity deviation from the ground truth. Thus, how to attenuate time series non-stationarity towards better predictability and mitigate the over-stationarization problem for model capability simultaneously is the key problem to further improve the performance of forecasting.
19
+
20
+ In this paper, we explore the effect of stationarization in time series forecasting and propose Nonstationary Transformers as a general framework, which empowers Transformer [32] and its efficient variants [17, 37, 35] with great predictive ability for real-world time series. The proposed framework involves two interdependent modules: Series Stationarization to increase the predictability of nonstationary series and De-stationary Attention to alleviate over-stationarization. Technically, Series Stationarization adopts a simple but effective normalization strategy to unify the key statistics of each series without extra parameters. And De-stationary Attention approximates the attention of unstationarized data and compensates the intrinsic non-stationarity of raw series. Benefiting from the above designs, Non-stationary Transformers can take advantage of the great predictability of stationarized series and crucial temporal dependencies discovered from original non-stationary data. Our method achieves state-of-the-art performance on six real-world benchmarks and can generalize to various Transformers for further improvement. The contributions lie in three folds:
21
+
22
+ • We refine that the predictive capability of non-stationary series is essential in real-world forecasting. By detailed analysis, we find out that current stationarization approaches will lead to the over-stationarization problem, limiting the predictive capability of Transformers. • We propose Non-stationary Transformers as a generic framework, including Series Stationarization to make the series more predictable and De-stationary Attention to avoid the over-stationarization problem by re-incorporating the non-stationarity of original series. • Non-stationary Transformers consistently boosts four mainstream Transformers by a large margin and achieves state-of-the-art performance on six real-world benchmarks.
23
+
24
+ # 2 Related Work
25
+
26
+ # 2.1 Deep Models for Time Series Forecasting
27
+
28
+ In recent years, deep models with elaboratively designed architectures have achieved great progress in time series forecasting. RNN-based models [33, 36, 23, 29, 30] are proposed for application in an autoregressive manner for sequence modeling, but the recurrent structure can suffer from modeling long-term dependency. Soon afterward, Transformer [32] emerges and shows great power in sequence modeling. To overcome the quadratic computation growth on sequence length, subsequent works aim to reduce Self-Attention’s complexity. Especially in time series forecasting, Informer [37] extends Self-Attention with KL-divergence criterion to select dominant queries. Reformer [17] introduces local-sensitive hashing (LSH) to approximate attention by allocated similar queries. Not only improved by reduced complexity, the following models further develop delicate building blocks for time series forecasting. Autoformer [35] fuses the decomposition blocks into a canonical structure and develops Auto-Correlation to discover series-wise connections. Pyraformer [21] designs pyramid attention module (PAM) to capture temporal dependencies with different hierarchies. Other deep but Transformer-free models also achieve remarkable performance. N-BEATS [25] proposes the explicit decomposition of trend and seasonal terms with strong interpretability. N-HiTS [9] introduces hierarchical layout and multi-rate sampling for tackling time series with respective frequency bands. In this paper, different from previous works focusing on architectural design, we analyze the series forecasting task from the basic view of stationarity, which is an essential property of time series [6, 14]. It is also notable that as a general framework, our proposed Non-stationary Transformers can be easily applied to various Transformer-based models.
29
+
30
+ # 2.2 Stationarization for Time Series Forecasting
31
+
32
+ While stationarity is important to the predictability of time series [6, 14], real-world series always present non-stationarity. To tackle this problem, the classical statistical method ARIMA [7, 8] stationarizes the time series through differencing. As for deep models, since the distribution-varying problem accompanied by non-stationarity makes deep forecasting even more intractable, stationarization methods are widely explored and always adopted as the pre-processing for deep model inputs. Adaptive Norm [24] applies z-score normalization for each series fragment by global statistics of a sampled set. DAIN [27] employs a nonlinear neural network to adaptively stationarize time series with observed training distribution. RevIN [15] introduces a two-stage instance normalization [31] that transforms model input and output respectively to reduce the discrepancy of each series. In contrast, we find out that directly stationarizing time series will damage the model’s capability of modeling specific temporal dependency. Therefore, unlike previous methods, in addition to the stationarization, Non-stationary Transformers further develops De-stationary Attention to bring the intrinsic non-stationarity of the raw series back to attention.
33
+
34
+ # 3 Non-stationary Transformers
35
+
36
+ As aforementioned, stationarity is an important element of time series predictability. Previous “direct stationarization” designs can attenuate non-stationarity of series for better predictability, but they obviously neglect inherent properties of real-world series, which will result in the over-stationarization problem as stated in Figure 1. To deal with the dilemma, we go beyond previous works and propose Non-stationary Transformers as a generic framework. Our model involves two complementary parts: Series Stationarization to attenuate time series non-stationarity and De-stationary Attention to re-incorporate non-stationary information of raw series. Empowered by these designs, Non-stationary Transformers can improve data predictability and maintain model capability simultaneously.
37
+
38
+ # 3.1 Series Stationarization
39
+
40
+ Non-stationary time series make the forecasting task intractable for deep models because it is hard for them to generalize well on series with changed statistics during inference, typically varied mean and standard deviation. The pilot work, RevIN [15] applies instance normalization with learnable affine parameters to each input and restores the statistics to the corresponding output, which makes each series follow a similar distribution. Experimentally, we find that this design also works well without learnable parameters. Thus, we propose a more straightforward but effective design to wrap Transformers as the base model without extra parameters, naming by Series Stationarization. As is shown in Figure 2, it contains two corresponding operations: Normalization module at first to deal with the non-stationary series caused by varied mean and standard deviation, and De-normalization module at the end to transform the model outputs back with original statistics. Here are the details.
41
+
42
+ ![](images/8369470ffeb672b0e75e1a2cfa15243eaf9a083b4364ecb0d0388dd3c826dad6.jpg)
43
+ Figure 2: Non-stationary Transformers. Series Stationarization is adopted as a wrapper on the base model to normalize each incoming series and de-normalize the output. De-stationary Attention replaces the original Attention mechanism to approximate attention learned from unstationarized series, which rescales current temporal dependency weights with learned de-stationary factors $\tau , \Delta$ .
44
+
45
+ Normalization module To attenuate the non-stationarity of each input series, we conduct normalization on the temporal dimension by a sliding window over time. For each input series $\mathbf { x } = [ x _ { 1 } , x _ { 2 } , . . . , x _ { S } ] ^ { \top } \in \mathbb { R } ^ { S \times C }$ , we transform it by translation and scaling operations and obtain $\mathbf { x } ^ { \prime } = [ x _ { 1 } ^ { \prime } , x _ { 2 } ^ { \prime } , . . . , x _ { S } ^ { \prime } ] ^ { \top } \in \mathbb { R } ^ { S \times C }$ , where $S$ and $C$ denote the sequence length and variable number respectively. The Normalization module can be formulated as follows:
46
+
47
+ $$
48
+ \mu _ { \mathbf { x } } = \frac { 1 } { S } \sum _ { i = 1 } ^ { S } x _ { i } , \sigma _ { \mathbf { x } } ^ { 2 } = \frac { 1 } { S } \sum _ { i = 1 } ^ { S } ( x _ { i } - \mu _ { \mathbf { x } } ) ^ { 2 } , x _ { i } ^ { \prime } = \frac { 1 } { \sigma _ { \mathbf { x } } } \odot ( x _ { i } - \mu _ { \mathbf { x } } ) ,
49
+ $$
50
+
51
+ where µx, σx ∈ RC×1, 1 means the element-wise division and $\odot$ is the element-wise product. Note that Normalization module decreases the distributional discrepancy among each input time series, making the distribution of the model input more stable.
52
+
53
+ De-normalization module As shown in Figure 2, after the base model $\mathcal { H }$ predicting the future value with length- $O$ , we adopt De-normalization to transform the model output $\mathbf { y } ^ { \prime } = [ \breve { y _ { 1 } ^ { \prime } } , y _ { 2 } ^ { \prime } , . . . , y _ { O } ^ { \prime } ] ^ { \top } \in$ $\mathbb { R } ^ { O \times C }$ with $\sigma _ { \mathbf { x } }$ and $\mu _ { \mathbf { x } }$ and obtain $\hat { \mathbf { y } } = [ \hat { y } _ { 1 } , \hat { y } _ { 2 } , . . . , \hat { y } _ { O } ] ^ { \intercal }$ as the eventual forecasting results. The De-normalization module can be formulated as follows:
54
+
55
+ $$
56
+ \mathbf { y } ^ { \prime } = \mathcal { H } ( \mathbf { x } ^ { \prime } ) , \hat { y } _ { i } = \sigma _ { \mathbf { x } } \odot ( y _ { i } ^ { \prime } + \mu _ { \mathbf { x } } ) .
57
+ $$
58
+
59
+ By means of the two-stage transformation, the base models will receive stationarized inputs, which follow a stable distribution and are easier to generalize. This design also makes the model equivariant to translational and scaling perturbance of time series, thereby benefiting real-world series forecasting.
60
+
61
+ # 3.2 De-stationary Attention
62
+
63
+ While the statistics of each time series are explicitly restored to the corresponding prediction, the non-stationarity of the original series cannot be fully recovered only by De-normalization. For instance, Series Stationarization can generate the same stationarized input $\mathbf { x } ^ { \prime }$ from distinct time series $\mathbf { x } _ { 1 }$ , $\mathbf { x } _ { 2 }$ (i.e. $\mathbf { x } _ { 2 } = \alpha \mathbf { x } _ { 1 } + \beta )$ , and the base model will get identical attention that fails to capture crucial temporal dependencies entangled with non-stationarity (Figure 1). In other words, the undermined effects caused by over-stationarization happen inside the deep model, especially in the calculation of attention. Furthermore, non-stationary time series are fragmented and normalized into several series chunks with the same mean and variance, which follow more similar distributions than the raw data before stationarization. Thus, the model is more likely to generate over-stationary and uneventful outputs, which is irreconcilable with the natural non-stationarity of the original series.
64
+
65
+ To tackle the over-stationarization problem caused by Series Stationarization, we propose a novel De-stationary Attention mechanism, which can approximate the attention that is obtained without stationarization and discover the particular temporal dependencies from original non-stationary data.
66
+
67
+ Analysis of the plain model As mentioned above, the over-stationarization problem is caused by the vanishment of inherent non-stationarity information, which will make the base model fail to capture eventful temporal dependencies for forecasting. Therefore, we try to approximate the attention learned from the original non-stationary series. We start from the formula of Self-Attention [32]:
68
+
69
+ $$
70
+ { \mathrm { A t t n } } ( \mathbf { Q } , \mathbf { K } , \mathbf { V } ) = { \mathrm { S o f t m a x } } \left( { \frac { \mathbf { Q } \mathbf { K } ^ { \top } } { { \sqrt { d _ { k } } } } } \right) \mathbf { V } ,
71
+ $$
72
+
73
+ where $\mathbf { Q } , \mathbf { K } , \mathbf { V } \in \mathbb { R } ^ { S \times d _ { k } }$ are length- $S$ queries, keys and values of $d _ { k }$ -dimension respectively, and Softmax $( \cdot )$ is conducted row by row. To simplify the analysis, we assume the embedding and feed-forward layers $f$ to hold the linear properties2 and $f$ is conducted separately on each time point, that is, each query token in $\mathbf { Q } = [ q _ { 1 } , q _ { 2 } , . . . , q _ { S } ] ^ { \top }$ can be calculated as $q _ { i } = f ( x _ { i } )$ with respect to the input series $\mathbf { x } = [ x _ { 1 } , x _ { 2 } , \cdots , x _ { S } ] ^ { \top }$ . Since it is a convention to conduct normalization on each time series variable to avoid certain variable that dominates the scale, we can further assume each variable of series $\mathbf { x }$ shares the same variance, and thus original $\sigma _ { \mathbf { x } } \in \mathbb { R } ^ { C \times 1 }$ is reduced to a scalar. After Normalization module, the model receives the stationarized input $\mathbf { x } ^ { \prime } = ( \mathbf { x } - \mathbf { 1 } \mu _ { \mathbf { x } } ^ { \top } ) / \sigma _ { \mathbf { x } }$ , where $\mathbf { 1 } \in \mathbb { R } ^ { S \times 1 }$ is an all-ones vector. Based on the linear property assumption, it can be proved that the Attention layer will receive $\mathbf { Q } ^ { \prime } = [ f ( x _ { 1 } ^ { \prime } ) , . . . , f ( x _ { S } ^ { \prime } ) ] ^ { \top } = ( \mathbf { \bar { Q } } - \mathbf { 1 } \mu _ { \mathbf { Q } } ^ { \top } ) / \sigma _ { \mathbf { x } }$ , where $\boldsymbol { \mu _ { \mathbf { Q } } } \in \mathbb { R } ^ { d _ { k } \times 1 }$ is the mean of $\mathbf { Q }$ along the temporal dimension (See Appendix for a detailed proof). And so is the corresponding transformed $\mathbf { K } ^ { \prime } , \mathbf { V } ^ { \prime }$ . Without Series Stationarization, the input of $\operatorname { S o f t m a x } ( \cdot )$ in Self-Attention should be $\mathbf { Q K } ^ { \top } / \sqrt { d _ { k } }$ , while now the attention is calculated based on $\mathbf { Q } ^ { \prime } , \mathbf { K } ^ { \prime }$ :
74
+
75
+ $$
76
+ \begin{array} { c } { { \displaystyle { \bf Q } ^ { \prime } { \bf K } ^ { \prime \top } = \frac { 1 } { \sigma _ { \bf x } ^ { 2 } } \left( { \bf Q } { \bf K } ^ { \top } - { \bf 1 } ( \mu _ { \bf Q } ^ { \top } { \bf K } ^ { \top } ) - ( { \bf Q } \mu _ { \bf K } ) { \bf 1 } ^ { \top } + { \bf 1 } ( \mu _ { \bf Q } ^ { \top } \mu _ { \bf K } ) { \bf 1 } ^ { \top } \right) , } } \\ { { \mathrm { S o f t m a x } \left( \frac { { \bf Q } { \bf K } ^ { \top } } { \sqrt { d _ { k } } } \right) = \mathrm { S o f t m a x } \left( \frac { \sigma _ { \bf x } ^ { 2 } { \bf Q } ^ { \prime } { \bf K } ^ { \prime \top } + { \bf 1 } ( \mu _ { \bf Q } ^ { \top } { \bf K } ^ { \top } ) + ( { \bf Q } \mu _ { \bf K } ) { \bf 1 } ^ { \top } - { \bf 1 } ( \mu _ { \bf Q } ^ { \top } \mu _ { \bf K } ) { \bf 1 } ^ { \top } } { \sqrt { d _ { k } } } \right) . } } \end{array}
77
+ $$
78
+
79
+ We find that $\mathbf { Q } \mu _ { \mathbf { K } } \in \mathbb { R } ^ { S \times 1 }$ and $\mu _ { \mathbf { Q } } ^ { \top } \mu _ { \mathbf { K } } \in \mathbb { R }$ , and they are repeatedly operated on each column and element of $\sigma _ { \mathbf { x } } ^ { 2 } \mathbf { Q } ^ { \prime } { \mathbf { K ^ { \prime } } } ^ { \top } \in \mathbb { R } ^ { S \times S }$ respectively. Since Softmax $( \cdot )$ is invariant to the same translation on the row dimension of input, we have the following equation:
80
+
81
+ $$
82
+ \mathrm { S o f t m a x } \left( \frac { \mathbf { Q } \mathbf { K } ^ { \top } } { \sqrt { d _ { k } } } \right) = \mathrm { S o f t m a x } \left( \frac { \sigma _ { \mathbf { x } } ^ { 2 } \mathbf { Q } ^ { \prime } { \mathbf { K ^ { \prime } } } ^ { \top } + \mathbf { 1 } \mu _ { \mathbf { Q } } ^ { \top } \mathbf { K } ^ { \top } } { \sqrt { d _ { k } } } \right) .
83
+ $$
84
+
85
+ Equation 5 deduces a direct expression of the attention Softmax $\left( \mathbf { Q K } ^ { \top } / \sqrt { d _ { k } } \right)$ learned from raw series $\mathbf { x }$ . Except for the current $\mathbf { Q } ^ { \prime } , \mathbf { K } ^ { \prime }$ from stationarized series $\mathbf { x } ^ { \prime }$ , this expression also requires the non-stationary information $\sigma _ { \mathbf { x } } , \mu _ { \mathbf { Q } } , \mathbf { K }$ that are eliminated by Series Stationarization.
86
+
87
+ De-stationary Attention To recover the original attention on non-stationary series, we attempt to bring the vanished non-stationary information back to its calculation. Based on Equation 5, the key is to approximate the positive scaling scalar $\tau = \sigma _ { \mathbf { x } } ^ { 2 } \in \mathbb { R } ^ { + }$ and shifting vector $\pmb { \Delta } \overset { \cdot } { = } \mathbf { K } \mu _ { \mathbf { Q } } \in \mathbb { R } ^ { S \times \bar { 1 } }$ , which are defined as $d e$ -stationary factors. Since the strict linear property hardly holds for a deep model, other than estimating and utilizing real factors with great effort, we try to learn de-stationary factors directly from the statistics of unstationarized $\mathbf { x } , \mathbf { Q }$ and $\mathbf { K }$ by a simple but effective multilayer perceptron layer. As we can only discover limited non-stationary information from current $\dot { \bf Q ^ { \prime } } , \bar { \bf K ^ { \prime } }$ , the unique and reasonable source to compensate non-stationarity is the original $\mathbf { x }$ without being normalized. Thus, as a direct deep learning implementation of Equation 5, we apply a multilayer perceptron as the projector to learn de-stationary factors $\tau , \Delta$ from the statistics $\mu _ { \mathbf { x } } , \sigma _ { \mathbf { x } }$ of unstationarized $\mathbf { x }$ individually. And the De-stationary Attention is calculated as follows:
88
+
89
+ $$
90
+ \begin{array} { c } { \log \tau = \mathrm { M L P } ( \boldsymbol { \sigma } _ { \mathbf { x } } , \mathbf { x } ) , \pmb { \Delta } = \mathrm { M L P } ( \mu _ { \mathbf { x } } , \mathbf { x } ) , } \\ { \mathrm { A t t n } ( \mathbf { Q } ^ { \prime } , \mathbf { K } ^ { \prime } , \mathbf { V } ^ { \prime } , \tau , \pmb { \Delta } ) = \mathrm { S o f t m a x } \left( \frac { \tau \mathbf { { Q } ^ { \prime } } \mathbf { K } ^ { \prime } ^ { \top } + \mathbf { 1 } \pmb { \Delta } ^ { \top } } { \sqrt { d _ { k } } } \right) \mathbf { V } ^ { \prime } , } \end{array}
91
+ $$
92
+
93
+ where the de-stationary factors $\tau$ and $\pmb { \Delta }$ are shared by De-stationary Attention of all layers (Figure 2). De-stationary Attention mechanism learns the temporal dependencies from both stationarized series $\mathbf { Q } ^ { \prime }$ , $\mathbf { K } ^ { \prime }$ and non-stationary series $\mathbf { x }$ , $\mu _ { \mathbf { x } } , \sigma _ { \mathbf { x } }$ , and multiplies by the stationarized values $\mathbf { V } ^ { \prime }$ . Therefore, it can benefit from the predictability of stationarized series and maintain the inherent temporal dependencies of raw series simultaneously.
94
+
95
+ Overall architecture Following the prior use of Transformers [37, 35] in time series forecasting, we adopt the standard Encoder-Decoder structure (Figure 2), where the encoder is to extract information from past observations, and the decoder is to aggregate past information and refine the prediction from simple initialization. The canonical Non-stationary Transformer is wrapped by Series Stationarization to both the input and output of vanilla Transformer [32], and replacing the Self-Attention by our proposed De-stationary Attention, which can boost the non-stationary series predictive capability of the base model. For the Transformer variants [17, 37, 35], we transform the terms inside Softmax $( \cdot )$ with the de-stationary factors $\tau$ , $\pmb { \Delta }$ to re-integrate the non-stationary information (See Appendix for the implementation details).
96
+
97
+ # 4 Experiments
98
+
99
+ We conduct extensive experiments to evaluate the performance of Non-stationary Transformers on six real-world time series forecasting benchmarks and further validate the generality of the proposed framework on various mainstream Transformer variants.
100
+
101
+ Datasets Here are the descriptions of the datasets: (1) Electricity [3] records the hourly electricity consumption of 321 clients from 2012 to 2014. (2) ETT [37] contains the time series of oil destationary factors and power load collected by electricity transformers from July 2016 to July 2018. ETTm1 /ETTm2 are recorded every 15 minutes, and ETTh1/ETTh2 are recorded every hour. (3) Exchange [18] collects the panel data of daily exchange rates from 8 countries from 1990 to 2016. (4) ILI [1] collects the ratio of influenza-like illness patients versus the total patients in one week, which is reported weekly by Centers for Disease Control and Prevention of the United States from 2002 and 2021. (5) Traffic [2] contains hourly road occupancy rates measured by 862 sensors on San Francisco Bay area freeways from January 2015 to December 2016. (6) Weather [4] includes meteorological time series with 21 weather indicators collected every 10 minutes from the Weather Station of the Max Planck Biogeochemistry Institute in 2020.
102
+
103
+ Especially, in this paper, we adopt the Augmented Dick-Fuller (ADF) test statistic [13] as the metric to quantitatively measure the degree of stationarity. A smaller ADF test statistic indicates a higher degree of stationarity, which means the distribution is more stable. Table 1 summarizes the overall statistics of the datasets and lists them in ascending order by degree of stationarity. We follow the standard protocol that divides each dataset into the training, validation, and testing subsets according to the chronological order. The split ratio is 6:2:2 for the ETT dataset and 7:1:2 for others.
104
+
105
+ Table 1: Summary of datasets. Smaller ADF test statistic indicates more stationary dataset.
106
+
107
+ <table><tr><td>Dataset</td><td>VariableNumber</td><td>Sampling Frequency</td><td>Total Observations</td><td>ADF Test Statistic</td></tr><tr><td>Exchange</td><td>8</td><td>1 Day</td><td>7,588</td><td>-1.889</td></tr><tr><td>ILI</td><td>7</td><td>1Week</td><td>966</td><td>-5.406</td></tr><tr><td>ETTm2</td><td>7</td><td>15 Minutes</td><td>69,680</td><td>-6.225</td></tr><tr><td>Electricity</td><td>321</td><td>1 Hour</td><td>26,304</td><td>-8.483</td></tr><tr><td>Traffic</td><td>862</td><td>1 Hour</td><td>17,544</td><td>-15.046</td></tr><tr><td>Weather</td><td>21</td><td>10 Minutes</td><td>52.695</td><td>-26.661</td></tr></table>
108
+
109
+ Baselines We evaluate the vanilla Transformer [32] equipped by the Non-stationary Transformers framework in both multivariate and univariate settings to demonstrate its effectiveness. For multivariate forecasting, we include six state-of-the-art deep forecasting models: Autoformer [35], Pyraformer [21], Informer [37], LogTrans [20], Reformer [17] and LSTNet [18]. For univariate forecasting, we include seven competitive baselines: N-HiTS [9], N-BEATS [25], Autoformer [35], Pyraformer [21], Informer [37], Reformer [17] and ARIMA [7]. In addition, we adopt the proposed framework on both the canonical and efficient variants of Transformers: Transformer [32], Informer [37], Reformer [17] and Autoformer [35] to validate the generality of our framework.
110
+
111
+ Implementation details All the experiments are implemented with PyTorch [28] and conducted on a single NVIDIA TITAN V 12GB GPU. Each model is trained by ADAM [16] using L2 loss with the initial learning rate of $1 0 ^ { - 4 }$ and batch size of 32. Each Transformer-based model contains two encoder layers and one decoder layer. Considering the efficiency of hyperparameters search, we use two-layer perceptron projector with the hidden dimension varying in $\{ \bar { 6 4 } , \bar { 1 2 8 } , 2 5 6 \}$ in De-stationary Attention. We repeat each experiment three times with different random seeds and report the test MSE/MAE under different prediction lengths, and the standard deviations are also provided in Appendix. A lower MSE/MAE indicates better performance.
112
+
113
+ # 4.1 Main Results
114
+
115
+ Forecasting results As for multivariate forecasting results, the vanilla Transformer equipped with our framework consistently achieves state-of-the-art performance in all benchmarks and prediction lengths (Table 2). Notably, Non-stationary Transformer outperforms other deep models impressively on datasets characterized by high non-stationarity: under the prediction length of 336, we achieve $17 \%$ MSE reduction $\mathrm { ( 0 . 5 0 9 0 . 4 2 1 ) }$ ) on Exchange and $25 \%$ $2 . 6 6 9 2 . 0 1 0 \rangle$ on ILI compared to previous state-of-the-art results, which indicates that the potential of deep model is still constrained on non-stationary data. We also list the univariate results of two typical datasets with different stationarity in Table 3. Non-stationary Transformer still realizes remarkable forecasting performance.
116
+
117
+ Table 2: Forecasting results comparison under different prediction lengths $O \in \{ 9 6 , 1 9 2 , 3 3 6 , 7 2 0 \}$ The input sequence length is set to 36 for ILI and 96 for the others. Additional results (ETTm1, ETTh1, ETTh2) can be found in Appendix.
118
+
119
+ <table><tr><td colspan="2">Models</td><td colspan="2">Ours</td><td colspan="2"></td><td colspan="2">Autoformer [35] Pyraformer [21] Informer [37] LogTrans [20] Reformer [17] LSTNet [18]</td><td colspan="2"></td><td colspan="2"></td><td colspan="2"></td><td colspan="2"></td></tr><tr><td colspan="2">Metric</td><td>MSE MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td></td><td>MSE MAE</td><td></td><td>MSE</td><td>MAE</td><td>MSE MAE</td></tr><tr><td rowspan="3">ueepxg</td><td>96 192</td><td>0.111 0.219 0.335 0.300</td><td>0.237 0.197</td><td>0.323 0.369</td><td>0.852</td><td></td><td>0.780</td><td>0.847</td><td>0.752</td><td>0.968</td><td>0.812</td><td>1.065</td><td>0.829</td><td>1.551</td><td>1.058 1.028</td></tr><tr><td>336</td><td>0.421</td><td>0.476 0.509</td><td></td><td>0.524</td><td>0.993 1.240</td><td>0.858 0.958</td><td>1.204 1.672</td><td>0.895 1.036</td><td>1.040 1.659</td><td>0.851 1.081</td><td>1.188 1.357</td><td>0.906</td><td>1.477</td><td></td></tr><tr><td>720</td><td>1.092 0.769</td><td></td><td>1.447</td><td>0.941</td><td>1.711</td><td>1.093</td><td>2.478</td><td>1.310</td><td>1.941</td><td>1.127</td><td>1.510</td><td>0.976 1.016</td><td>1.507 2.285</td><td>1.031 1.243</td></tr><tr><td rowspan="3">I</td><td>24</td><td>2.294 0.945 3.483</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>1.287</td><td></td><td>5.800 1.693</td><td></td><td>5.764</td><td>1.677</td><td>4.480</td><td>1.444</td><td>4.400</td><td>1.382</td><td>6.026</td><td>1.770</td></tr><tr><td>36 48</td><td>1.825 0.848 3.103 2.010 0.900 2.669</td><td></td><td>1.148</td><td></td><td>6.043 1.733</td><td></td><td>4.755</td><td>1.467</td><td>4.799</td><td>1.467</td><td>4.783</td><td>1.448</td><td>5.340</td><td>1.668</td></tr><tr><td rowspan="3"></td><td>60</td><td>2.178 0.963 2.770</td><td></td><td>1.085 1.125</td><td></td><td>6.213 1.763</td><td>6.531 1.814 5.264</td><td>4.763</td><td>1.469</td><td>4.800</td><td>1.468</td><td>4.832</td><td>1.465</td><td>6.080 5.548</td><td>)1.787</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>1.564</td><td>5.278</td><td>1.560</td><td>4.882</td><td>1.483</td><td></td><td>1.720</td></tr><tr><td>96</td><td>[0.192 0.274 0.255</td><td></td><td>0.339</td><td></td><td>0.409 0.488</td><td></td><td>0.365</td><td>0.453</td><td>0.768</td><td>0.642</td><td>0.658</td><td>0.619</td><td>3.142</td><td>1.365</td></tr><tr><td rowspan="3">LLE</td><td>192</td><td>0.280 0.339</td><td>0.281</td><td>0.340</td><td>0.673</td><td>0.641</td><td></td><td>0.533</td><td>0.563</td><td>0.989</td><td>0.757</td><td>1.078</td><td>0.827</td><td>3.154</td><td>1.369</td></tr><tr><td>336</td><td>0.334 0.361</td><td>0.339</td><td>0.372</td><td></td><td>1.210</td><td>0.846</td><td>1.363</td><td>0.887</td><td>1.334</td><td>0.872</td><td>1.549</td><td>0.972</td><td>3.160</td><td>)1.369</td></tr><tr><td>720</td><td>0.417 0.413 0.422</td><td></td><td>0.419</td><td></td><td>4.044 1.526</td><td></td><td>53.379</td><td>1.388</td><td>3.048</td><td>1.328</td><td>2.631</td><td>1.242</td><td>3.171</td><td>1.368</td></tr><tr><td rowspan="3">ereera</td><td>96</td><td>[0.169 0.273 0.201</td><td></td><td>0.317</td><td></td><td>0.498 0.299</td><td></td><td>0.274</td><td>0.368</td><td>0.258</td><td>0.357</td><td>0.312</td><td>0.402</td><td>0.680 0.645</td><td></td></tr><tr><td>192</td><td>0.182 0.286</td><td>0.222</td><td></td><td>0.334</td><td>0.828</td><td>0.312</td><td>0.296</td><td>0.386</td><td>0.266</td><td>0.368</td><td>0.348</td><td>0.433</td><td></td><td></td></tr><tr><td>336</td><td>[0.200 0.304 0.231</td><td></td><td>0.338</td><td>1.476</td><td></td><td>0.326</td><td>0.300</td><td>0.394</td><td>0.280</td><td>0.380</td><td>0.350</td><td></td><td>0.725</td><td>0.676</td></tr><tr><td rowspan="3">YTfere</td><td>720</td><td>0.222 0.321</td><td>0.254</td><td>0.361</td><td>4.090</td><td></td><td>0.372</td><td>0.373</td><td>0.439</td><td>0.283</td><td>0.376</td><td>0.340</td><td>0.433 0.420</td><td>0.828 0.957</td><td>0.727 0.811</td></tr><tr><td>96</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>192</td><td>0.612 0.338 0.613 0.613 0.340 0.616</td><td></td><td>0.388</td><td>0.692</td><td>0.684 0.393</td><td></td><td>0.719</td><td>0.391</td><td>0.684</td><td>0.384</td><td>0.732</td><td>0.423</td><td>1.107</td><td>0.685</td></tr><tr><td rowspan="3"></td><td>336</td><td>0.618 0.328 0.622</td><td></td><td>0.382 0.337</td><td>0.699</td><td>0.394 0.396</td><td></td><td>0.696 50.777</td><td>0.379 0.420</td><td>0.685 0.733</td><td>0.390 0.408</td><td>0.733 0.742</td><td>0.420 0.420</td><td>1.157 1.216</td><td>0.706 50.730</td></tr><tr><td>720</td><td>0.653 0.355 0.660</td><td></td><td>0.408</td><td></td><td>0.712</td><td>0.404</td><td>0.864</td><td>0.472</td><td>0.717</td><td>0.396</td><td>0.755</td><td>0.423</td><td>1.481</td><td>0.805</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="3">Waaaeee</td><td>96 192</td><td>|0.173 0.223(</td><td>0.266</td><td>0.336</td><td></td><td>0.354</td><td>0.392</td><td>0.300</td><td>0.384</td><td>0.458</td><td>0.490</td><td>0.689</td><td>0.596</td><td>0.594</td><td>0.587</td></tr><tr><td>336</td><td>0.245 0.285 0.307</td><td></td><td></td><td>0.367</td><td>0.673</td><td>0.597</td><td>0.598</td><td>0.544</td><td>0.658</td><td>0.589</td><td>0.752</td><td>0.638</td><td>0.560</td><td>)0.565</td></tr><tr><td>720 0.414 0.410 0.419</td><td>0.321 0.338 0.359</td><td></td><td>0.395</td><td>0.428</td><td>0.634 0.592</td><td>0.942 0.723</td><td>0.578 1.059</td><td>0.523 0.741</td><td>0.797 0.869</td><td>0.652 0.675</td><td>0.639</td><td>0.596</td><td>0.597 0.587</td><td>0.618 0.599</td></tr></table>
120
+
121
+ Framework generality We apply our framework to four mainstream Transformers and report the performance promotion of each model (Table 4). Our method consistently improves the forecasting ability of different models. Overall, it achieves averaged $4 9 . 4 3 \%$ promotion on Transformer, $4 7 . 3 4 \%$ on Informer, $4 6 . 8 9 \%$ on Reformer and $1 0 . 5 7 \%$ on Autoformer, making each of them surpass previous state-of-the-art. Compared to native blocks of the models, there is hardly any parameter and computation increase by applying our framework (See Appendix for details), and thereby their computational complexities can be preserved. It validates that Non-stationary Transformer is an effective and lightweight framework that can be widely applied to Transformer-based models and enhances their non-stationary predictability to achieve state-of-the-art performance.
122
+
123
+ Table 3: Univariate results under different prediction lengths $O \in \{ 9 6 , 1 9 2 , 3 3 6 , 7 2 0 \}$ on two typical datasets with strong non-stationary. The input sequence length is set to 96.
124
+
125
+ <table><tr><td colspan="2">Models</td><td>Ours</td><td></td><td>N-HiTS [9] N-BEATS [25] Autoformer [35] Pyraformer [21] Informer [37] Reformer[17] ARIMA [6]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td colspan="2">Metric</td><td></td><td>MSE MAE MSE MAE MSE</td><td></td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td></td><td>MSE MAE</td></tr><tr><td rowspan="4">eppg</td><td>96</td><td>|0.104 0.235 0.114 0.248 0.156</td><td></td><td></td><td>0.299</td><td>0.241</td><td>0.387</td><td>0.290</td><td>0.439</td><td>0.591</td><td>0.615</td><td>1.327</td><td></td><td>0.944</td><td>0.112 0.245</td></tr><tr><td>192</td><td></td><td>0.230 0.375 0.250 0.387 0.669</td><td></td><td>0.665</td><td>0.273</td><td>0.403</td><td>0.594</td><td>0.644</td><td>1.183</td><td>0.912</td><td></td><td>1.258</td><td>0.924</td><td>0.304 0.404</td></tr><tr><td>336</td><td></td><td>0.432 0.509 0.434 0.516 0.611</td><td></td><td>0.605</td><td>0.508</td><td>0.539</td><td>0.962</td><td>0.824</td><td>1.367</td><td>0.984</td><td>2.179</td><td></td><td>1.296</td><td>0.736 0.598</td></tr><tr><td></td><td>720</td><td>0.782 0.682 1.061 0.773 1.111</td><td></td><td></td><td>0.860</td><td>0.991</td><td>0.768</td><td>1.285</td><td>0.958</td><td>1.872</td><td>1.072</td><td>1.280</td><td>0.953</td><td>1.871 0.935</td></tr><tr><td rowspan="3">LL</td><td>96</td><td>0.069 0.193 0.092 0.232 0.082 0.219</td><td></td><td></td><td></td><td>0.065</td><td>0.189</td><td>0.074(</td><td>0.208 0.088</td><td></td><td>0.225</td><td>0.131</td><td></td><td></td></tr><tr><td>192</td><td>0.1090.249 0.128 0.276 0.120</td><td></td><td></td><td>)0.268</td><td>0.118</td><td>0.256</td><td>0.116</td><td>0.252</td><td>0.132</td><td>0.283</td><td>0.186</td><td>0.288 0.354</td><td>0.211 0.362 0.261 0.406</td></tr><tr><td>336</td><td>0.139 0.286 0.165 0.314 0.226 0.370 0.154</td><td></td><td></td><td></td><td></td><td>0.305</td><td>0.143 0.295</td><td></td><td>0.180</td><td>0.336</td><td>0.220</td><td>0.381</td><td></td></tr><tr><td></td><td>720</td><td></td><td>0.180 0.331 0.243 0.397 0.188</td><td></td><td>0.338</td><td>0.182</td><td>0.335</td><td>0.197</td><td>0.338</td><td>0.300</td><td>0.435</td><td>0.267</td><td>0.430</td><td>0.317 0.448 0.366 0.487</td></tr></table>
126
+
127
+ Table 4: Performance promotion by applying the proposed framework to Transformer and its variants. We report the averaged MSE/MAE of all prediction lengths (stated in Table 2) and the relative MSE reduction ratios (Promotion) by our framework. Full results (under all prediction lengths and promotion on ETSformer [34], FEDformer [38]) can be found in Appendix.
128
+
129
+ <table><tr><td rowspan="2">Dataset Model</td><td colspan="2">Exchange</td><td colspan="2">ILI</td><td colspan="2">ETTm2</td><td colspan="2">Electricity</td><td colspan="2">Weather</td></tr><tr><td>MSE</td><td>MAE MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE MAE</td><td>Traffic MSE</td><td>MAE</td><td>MSE</td><td>MAE</td></tr><tr><td>Transformer + Ours</td><td>1.425 0.457</td><td>0.915 0.449</td><td>4.864 1.460 2.077 0.914</td><td>1.501 0.306</td><td>0.869 0.347</td><td>0.277 0.193</td><td>0.372 0.665 0.296 0.628</td><td>0.363 0.345</td><td>0.657 0.288</td><td>0.573 0.314</td></tr><tr><td>Promotion</td><td></td><td>67.93%</td><td>57.30%</td><td></td><td>79.61%</td><td>30.32%</td><td></td><td>5.56%</td><td>56.16%</td><td></td></tr><tr><td>Informer + Ours</td><td>1.550 0.496</td><td>0.998 0.460</td><td>5.137 1.544 2.125 0.928</td><td>1.410 0.460</td><td>)0.823 0.434</td><td>0.311 0.226</td><td>0.397 0.330 0.719</td><td>0.7640.416 0.409</td><td>0.634 0.275</td><td>0.548 0.302</td></tr><tr><td>Promotion</td><td>68.00%</td><td></td><td>58.63%</td><td></td><td>67.38%</td><td>27.33%</td><td></td><td>5.89%</td><td>56.78%</td><td></td></tr><tr><td>Reformer + Ours</td><td>1.280 0.462</td><td>0.932 0.468</td><td>4.724 1.443 2.865 1.065</td><td>1.479 0.493</td><td>0.915 0.441</td><td>0.338 0.206</td><td>0.429 0.741</td><td>0.423</td><td>0.803</td><td>0.656</td></tr><tr><td>Promotion</td><td></td><td>63.91%</td><td>39.35%</td><td></td><td>66.67%</td><td>39.05%</td><td>0.308 0.682</td><td>0.372 7.96%</td><td>0.286 64.38%</td><td>0.308</td></tr><tr><td>Autoformer + Ours</td><td>0.613 0.487</td><td>0.539 0.491</td><td>3.006 1.161 2.545 1.039</td><td>0.324 0.305</td><td>0.368 0.345</td><td>0.227 0.2160.315</td><td>0.338</td><td>0.628 0.379</td><td>0.338</td><td>0.382</td></tr><tr><td>Promotion</td><td>20.55%</td><td></td><td>15.34%</td><td></td><td>5.86%</td><td>4.85%</td><td></td><td>0.619 0.364 1.43%</td><td>0.286 15.38%</td><td>0.310</td></tr></table>
130
+
131
+ # 4.2 Ablation Study
132
+
133
+ Quality evaluation To explore the role of each module in our proposed framework, we compare the prediction results on ETTm2 obtained by three models: vanilla Transformer, Transformer with only Series Stationarization, and our Non-stationary Transformer. In Figure 3, we find out that the two modules strengthen the non-stationary forecasting ability of Transformer from different perspectives. Series Stationarization focuses on the alignment of statistical properties among each series input that benefits Transformer a lot to generalize on out-of-distribution data. However, as is shown in Figure 3(b), the over-stationarized circumstance for training makes the deep model more likely to output uneventful series with significant high stationarity and neglect the nature of non-stationary real-world data. With the aid of De-stationary Attention, the model gives concern back to the inherent non-stationarity of real-world time series. It is beneficial for an accurate prediction of the detailed series variation, which is vital in real-world time series forecasting.
134
+
135
+ ![](images/c70cb32525741e3996ee6ef346159e7b3420119ca3d08daa721bf129004f26d5.jpg)
136
+ Figure 3: Visualization of ETTm2 predictions given by different models.
137
+
138
+ Table 5: Forecasting results obtained by applying different methods to Transformer and Reformer. We report the averaged MSE/MAE of all prediction lengths (stated in Table 2) for comparison. Complete results can be found in Appendix.
139
+
140
+ <table><tr><td>Base Models</td><td colspan="6">Transformer</td><td colspan="5">Reformer</td></tr><tr><td>Methods</td><td colspan="2">+ RevIN [15]</td><td colspan="2">+ Series Stationarization</td><td colspan="2">+ Ours</td><td>+ RevIN [15]</td><td colspan="2">+ Series Stationarization</td><td colspan="2">+ Ours</td></tr><tr><td>Metric</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td></tr><tr><td>Exchange</td><td>0.567</td><td>0.487</td><td>0.569</td><td>0.488</td><td>0.461</td><td>0.454</td><td>0.469 0.472</td><td>0.470</td><td>0.473</td><td>0.462</td><td>0.468</td></tr><tr><td>ILI</td><td>2.205</td><td>0.934</td><td>2.206</td><td>0.934</td><td>2.077</td><td>0.914</td><td>3.024 1.096</td><td>3.023</td><td>1.096</td><td>2.865</td><td>1.065</td></tr><tr><td>ETTm2</td><td>0.460</td><td>0.416</td><td>0.461</td><td>0.416</td><td>0.306</td><td>0.347</td><td>0.542 0.459</td><td>0.537</td><td>0.459</td><td>0.493</td><td>0.441</td></tr><tr><td>Electricity</td><td>0.197</td><td>0.298</td><td>0.197</td><td>0.298</td><td>0.193</td><td>0.296</td><td>0.208 0.309</td><td>0.207</td><td>0.309</td><td>0.206</td><td>0.308</td></tr><tr><td>Traffic</td><td>0.643</td><td>0.352</td><td>0.641</td><td>0.352</td><td>0.628</td><td>0.345</td><td>0.687 0.378</td><td>0.691</td><td>0.380</td><td>0.682</td><td>0.372</td></tr><tr><td>Weather</td><td>0.301</td><td>0.316</td><td>0.304</td><td>0.317</td><td>0.288</td><td>0.314</td><td>0.291 0.309</td><td>0.292</td><td>0.309</td><td>0.286</td><td>0.308</td></tr></table>
141
+
142
+ Quantitative performance In addition to the above case study, we also provide quantitative forecasting performance comparison with stationarization methods: a deep method RevIN [15] and Series Stationarization (Section 3.1). As is shown in Table 5, the forecasting results assisted by RevIN and Series Stationarization are basically the same, which indicates that the parameter-free version of normalization in our framework performs sufficiently to stationarize time series. Besides, the proposed De-stationary Attention in Non-stationary Transformers further boosts the performance and achieves the best in all six benchmarks. The MSE reduction brought by De-stationary Attention becomes significant, especially when the dataset is highly non-stationary (Exchange: $0 . 5 6 9 0 . 4 6 1$ , ETTm2: $0 . 4 6 1 0 . 3 0 6 )$ . The comparison reveals that simply stationarizing time series still limits the predictive capability of Transformers, and the complementary mechanisms in Non-stationary Transformers can properly release the models’ potential for non-stationary series forecasting.
143
+
144
+ # 4.3 Model Analysis
145
+
146
+ Over-stationarization problem To verify the over-stationarization problem from a statistical view, we train Transformers with the aforementioned methods respectively, arrange all predicted time series in chronological order and compare the degree of stationarity with the ground truth (Figure 4). While models solely equipped with stationarization methods tend to output series with unexpected high degree of stationarity, the results assisted by De-stationary Attention are close to the actual value (relative stationarity $\dot { \in } [ 9 7 \% , 1 0 3 \% ] )$ . Besides, as the degree of series stationarity increases, the overstationarization problem becomes more significant. The huge discrepancy of the degree of stationarity can account for the inferior performance of Transformer with only stationarization. And it also demonstrates that De-stationary Attention as an internal renovation alleviates over-stationarization.
147
+
148
+ ![](images/b9b85c925a2b767965a00bd5d0d856bb4943a2c847c9b186ae8d166ac40b6c14.jpg)
149
+ Figure 4: Relative stationarity is calculated as the ratio of ADF test statistics between the model predictions and ground truth. From left to right, the dataset is increasingly non-stationary. While models equipped with only stationarization tend to output highly stationary series, our method gives predictions with stationarity closer to ground truth.
150
+
151
+ Exploring of Non-stationary Information Re-incorporation It is notable that by specifying over-stationarization as less distinguishable attention, we narrow down our design space into the attention calculation mechanism. To explore other approaches to retrieve non-stationary information, we conduct experiments by re-incorporating the $\mu$ and $\sigma$ into feed-forward layers (DeFF), which is the left part of the Transformer architecture. In detail, we feed learned $\mu$ and $\sigma$ into each feed-forward layer iteratively. As is shown in Table 6, re-incorporating non-stationarity is necessary only when the inputs are stationarized (Stationary), which is beneficial for forecasting but will lead to stationarity discrepancy of model outputs. And our proposed design (Stat $^ +$ DeAttn) makes further promotion and achieves the best in most cases $( 7 7 \% )$ . In addition to the theoretical analysis, experimental results further validate the effectiveness of our design in re-incorporating non-stationarity on attention.
152
+
153
+ Table 6: Ablation of framework design. Baseline means vanilla Transformer, Stationary means adding Series Stationarization, DeFF means re-incorporating non-stationarity on feed-forward layers, DeAttn means re-incorporating by De-stationary Attention, $S t a t + D e F F$ means adding Series Stationarization and re-incorporating on feed-forward layers. Stat $^ +$ DeAttn means our proposed framework.
154
+
155
+ <table><tr><td rowspan=2 colspan=9>Models Baseline Stationary DeFF DeAttn Stat + DeFF Stat + DeAttnMetric MSE MAEMSEMAE MSE MAE MSE MAE MSE MAEMSEMAE</td></tr><tr><td rowspan=1 colspan=1>MSEMAE</td><td rowspan=1 colspan=1>MSE MAE</td><td rowspan=1 colspan=1>MSE MAE</td><td rowspan=1 colspan=1>MSE MAE</td><td rowspan=1 colspan=1>MSEMAE</td></tr><tr><td rowspan=4 colspan=1>peg</td><td rowspan=1 colspan=1>96</td><td rowspan=1 colspan=2>0.5670.591</td><td rowspan=1 colspan=1>0.1360.258</td><td rowspan=1 colspan=1>0.7840.696</td><td rowspan=1 colspan=1>0.611 0.613</td><td rowspan=1 colspan=1>0.1160.243</td><td rowspan=2 colspan=1>0.1110.2370.2190.335</td></tr><tr><td rowspan=2 colspan=1>192336</td><td rowspan=1 colspan=2>1.1500.825</td><td rowspan=1 colspan=1>0.2390.348</td><td rowspan=1 colspan=1>1.1620.866</td><td rowspan=1 colspan=1>1.2020.840</td><td rowspan=1 colspan=1>0.2800.383</td></tr><tr><td rowspan=1 colspan=2>1.792 1.084</td><td rowspan=1 colspan=1>0.4250.479</td><td rowspan=1 colspan=1>1.3460.963</td><td rowspan=1 colspan=1>1.5160.981</td><td rowspan=1 colspan=1>0.371 0.452</td><td rowspan=1 colspan=1>0.421 0.476</td></tr><tr><td rowspan=1 colspan=1>720</td><td rowspan=1 colspan=2>2.191 1.159</td><td rowspan=1 colspan=1>1.4750.865</td><td rowspan=1 colspan=1>2.0421.163</td><td rowspan=1 colspan=1>2.8941.377</td><td rowspan=1 colspan=1>0.9340.704</td><td rowspan=1 colspan=1>1.0920.769</td></tr><tr><td rowspan=4 colspan=1>目</td><td rowspan=4 colspan=1>24364860</td><td rowspan=4 colspan=2>4.7481.4304.671 1.4304.9941.4825.041 1.499</td><td rowspan=1 colspan=1>2.5730.980</td><td rowspan=1 colspan=1>4.8501.445</td><td rowspan=1 colspan=1>4.7341.424</td><td rowspan=1 colspan=1>2.4040.985</td><td rowspan=1 colspan=1>2.2940.945</td></tr><tr><td rowspan=1 colspan=1>1.9550.870</td><td rowspan=1 colspan=1>4.848 1.452</td><td rowspan=1 colspan=1>4.9271.482</td><td rowspan=3 colspan=1>2.5850.9832.4960.9912.6671.059</td><td rowspan=3 colspan=1>1.8250.8482.0100.9002.1780.963</td></tr><tr><td rowspan=1 colspan=1>2.0570.902</td><td rowspan=1 colspan=1>4.9031.466</td><td rowspan=1 colspan=1>4.9961.483</td></tr><tr><td rowspan=1 colspan=1>2.2380.982</td><td rowspan=1 colspan=1>5.1961.524</td><td rowspan=1 colspan=1>5.1841.519</td></tr><tr><td rowspan=4 colspan=1>LII</td><td rowspan=1 colspan=1>96</td><td rowspan=2 colspan=2>0.5720.5521.1610.793</td><td rowspan=1 colspan=1>0.2530.311</td><td rowspan=1 colspan=1>0.7670.635</td><td rowspan=1 colspan=1>0.3040.406</td><td rowspan=1 colspan=1>0.2750.329</td><td rowspan=2 colspan=1>0.1920.2740.2800.339</td></tr><tr><td rowspan=3 colspan=1>192336720</td><td rowspan=3 colspan=2>1.1610.7931.2090.8423.0611.289</td><td rowspan=1 colspan=1>0.4530.404</td><td rowspan=1 colspan=1>0.9600.717</td><td rowspan=1 colspan=1>0.8200.652</td><td rowspan=1 colspan=1>0.4060.403</td></tr><tr><td rowspan=2 colspan=1>0.5460.4610.5930.489</td><td rowspan=2 colspan=1>1.1590.8113.1871.308</td><td rowspan=1 colspan=1>1.4060.883</td><td rowspan=2 colspan=1>0.5020.4650.6940.575</td><td rowspan=2 colspan=1>0.3340.3610.4170.413</td></tr><tr><td rowspan=1 colspan=1>2.8581.108</td></tr><tr><td rowspan=4 colspan=1>riea</td><td rowspan=4 colspan=1>96192336720</td><td rowspan=4 colspan=2>0.2600.3580.2660.3670.2800.3750.3020.386</td><td rowspan=2 colspan=1>0.1710.2750.1920.296</td><td rowspan=1 colspan=1>0.2600.356</td><td rowspan=1 colspan=1>0.2530.351</td><td rowspan=1 colspan=1>0.1700.274</td><td rowspan=3 colspan=1>0.1690.2730.1820.2860.2000.304</td></tr><tr><td rowspan=1 colspan=1>0.2640.365</td><td rowspan=1 colspan=1>0.2570.358</td><td rowspan=2 colspan=1>0.1880.2930.2060.309</td></tr><tr><td rowspan=1 colspan=1>0.2080.306</td><td rowspan=1 colspan=1>0.2770.374</td><td rowspan=1 colspan=1>0.2700.365</td></tr><tr><td rowspan=1 colspan=1>0.2160.315</td><td rowspan=1 colspan=1>0.2990.384</td><td rowspan=1 colspan=1>0.2950.380</td><td rowspan=1 colspan=1>0.2230.323</td><td rowspan=1 colspan=1>0.2220.321</td></tr><tr><td rowspan=4 colspan=1>[Ttere</td><td rowspan=4 colspan=1>96192336720</td><td rowspan=2 colspan=2>0.6470.3570.6490.356</td><td rowspan=1 colspan=1>0.6140.337</td><td rowspan=1 colspan=1>0.6460.353</td><td rowspan=1 colspan=1>0.6500.358</td><td rowspan=1 colspan=1>0.6050.333</td><td rowspan=1 colspan=1>0.6120.338</td></tr><tr><td rowspan=1 colspan=1>0.356</td><td rowspan=1 colspan=1>0.6370.351</td><td rowspan=1 colspan=1>0.6450.352</td><td rowspan=1 colspan=1>0.6550.358</td><td rowspan=1 colspan=1>0.6170.342</td><td rowspan=1 colspan=1>0.6130.340</td></tr><tr><td rowspan=2 colspan=2>0.667 0.3640.6970.376</td><td rowspan=2 colspan=1>0.6530.3590.6610.360</td><td rowspan=1 colspan=1>0.6720.360</td><td rowspan=1 colspan=1>0.6560.355</td><td rowspan=1 colspan=1>0.6350.349</td><td rowspan=2 colspan=1>0.6180.3280.6530.355</td></tr><tr><td rowspan=1 colspan=1>0.6950.376</td><td rowspan=1 colspan=1>0.6810.366</td><td rowspan=1 colspan=1>0.6490.351</td></tr><tr><td rowspan=4 colspan=1>waaaeer</td><td rowspan=4 colspan=1>96192336720</td><td rowspan=4 colspan=2>0.395 0.4270.6190.5600.6890.5940.9260.710</td><td rowspan=2 colspan=1>0.1750.2250.2730.297</td><td rowspan=1 colspan=1>0.4170.445</td><td rowspan=1 colspan=1>0.2960.364</td><td rowspan=2 colspan=1>0.1780.2260.2560.295</td><td rowspan=2 colspan=1>0.1730.2230.2450.285</td></tr><tr><td rowspan=1 colspan=1>0.6990.604</td><td rowspan=1 colspan=1>0.4800.464</td></tr><tr><td rowspan=2 colspan=1>0.3330.3250.4360.420</td><td rowspan=1 colspan=1>0.7730.620</td><td rowspan=1 colspan=1>0.5810.519</td><td rowspan=1 colspan=1>0.3380.351</td><td rowspan=1 colspan=1>0.3210.338</td></tr><tr><td rowspan=1 colspan=1>1.0080.718</td><td rowspan=1 colspan=1>0.7950.642</td><td rowspan=1 colspan=1>0.4170.412</td><td rowspan=1 colspan=1>0.4140.410</td></tr></table>
156
+
157
+ # 5 Conclusion
158
+
159
+ This paper addresses time series forecasting from the view of stationarity. Unlike previous studies that simply attenuate non-stationarity leading to over-stationarization, we propose an efficient way to increase series stationarity and renovate the internal mechanism to re-incorporate non-stationary information, thus boosting data predictability and model predictive capability simultaneously. Experimentally, our method shows great generality and performance on six real-world benchmarks. And detailed derivations and ablations are provided to testify the effectiveness of each component in our proposed Non-stationary Transformers framework. In the future, we will explore a more model-agnostic solution for the over-stationarization problem.
160
+
161
+ # Acknowledgments
162
+
163
+ This work was supported by the National Key Research and Development Plan (2021YFC3000905), National Natural Science Foundation of China (62022050 and 62021002), Beijing Nova Program (Z201100006820041), and BNRist Innovation Fund (BNR2021RC01002).
164
+
165
+ References
166
+ [1] Illness Dataset. https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html.
167
+ [2] Traffic Dataset. http://pems.dot.ca.gov/.
168
+ [3] UCI Electricity Load Time Series Dataset. https://archive.ics.uci.edu/ml/datasets/ ElectricityLoadDiagrams20112014.
169
+ [4] Weather Dataset. https://www.bgc-jena.mpg.de/wetter/.
170
+ [5] Kartik Ahuja, Ethan Caballero, Dinghuai Zhang, Jean-Christophe Gagnon-Audet, Yoshua Bengio, Ioannis Mitliagkas, and Irina Rish. Invariance principle meets information bottleneck for out-of-distribution generalization. NeurIPS, 2021.
171
+ [6] O. Anderson and M. Kendall. Time-series. 2nd edn. J. R. Stat. Soc. (Series D), 1976.
172
+ [7] G. E. P. Box and Gwilym M. Jenkins. Time series analysis, forecasting and control. 1970.
173
+ [8] George EP Box and Gwilym M Jenkins. Some recent advances in forecasting and control. J. R. Stat. Soc. (Series-C), 1968.
174
+ [9] Cristian Challu, Kin G Olivares, Boris N Oreshkin, Federico Garza, Max Mergenthaler, and Artur Dubrawski. N-hits: Neural hierarchical interpolation for time series forecasting. arXiv preprint arXiv:2201.12886, 2022.
175
+ [10] 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. NeurIPS, 2021.
176
+ [11] J. Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT, 2019.
177
+ [12] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021.
178
+ [13] Graham Elliott, Thomas J. Rothenberg, and James H. Stock. Efficient tests for an autoregressive unit root. Econometrica, 1996.
179
+ [14] Rob J Hyndman and George Athanasopoulos. Forecasting: principles and practice. OTexts, 2018.
180
+ [15] Taesung Kim, Jinhee Kim, Yunwon Tae, Cheonbok Park, Jang-Ho Choi, and Jaegul Choo. Reversible instance normalization for accurate time-series forecasting against distribution shift. In ICLR, 2022.
181
+ [16] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
182
+ [17] Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In ICLR, 2020.
183
+ [18] Guokun Lai, Wei-Cheng Chang, Yiming Yang, and Hanxiao Liu. Modeling long-and short-term temporal patterns with deep neural networks. In SIGIR, 2018.
184
+ [19] Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Deeper, broader and artier domain generalization. In ICCV, 2017.
185
+ [20] Shiyang Li, Xiaoyong Jin, Yao Xuan, Xiyou Zhou, Wenhu Chen, Yu-Xiang Wang, and Xifeng Yan. Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting. In NeurIPS, 2019.
186
+ [21] Shizhan Liu, Hang Yu, Cong Liao, Jianguo Li, Weiyao Lin, Alex X Liu, and Schahram Dustdar. Pyraformer: Low-complexity pyramidal attention for long-range time series modeling and forecasting. In ICLR, 2021.
187
+ [22] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In ICCV, 2021.
188
+ [23] Danielle C Maddix, Yuyang Wang, and Alex Smola. Deep factors with gaussian processes for forecasting. arXiv preprint arXiv:1812.00098, 2018.
189
+ [24] Eduardo Ogasawara, Leonardo C. Martinez, Daniel de Oliveira, Geraldo Zimbrão, Gisele L. Pappa, and Marta Mattoso. Adaptive normalization: A novel data normalization approach for non-stationary time series. In IJCNN, 2010.
190
+ [25] Boris N Oreshkin, Dmitri Carpov, Nicolas Chapados, and Yoshua Bengio. N-BEATS: Neural basis expansion analysis for interpretable time series forecasting. ICLR, 2019.
191
+ [26] Sinno Jialin Pan and Qiang Yang. A survey on transfer learning. TKDE, 2009.
192
+ [27] Nikolaos Passalis, Anastasios Tefas, Juho Kanniainen, Moncef Gabbouj, and Alexandros Iosifidis. Deep adaptive input normalization for time series forecasting. TNNLS, 2019.
193
+ [28] Adam Paszke, S. Gross, Francisco Massa, A. Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Z. Lin, N. Gimelshein, L. Antiga, Alban Desmaison, Andreas Köpf, Edward Yang, Zach DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In NeurIPS, 2019.
194
+ [29] Syama Sundar Rangapuram, Matthias W Seeger, Jan Gasthaus, Lorenzo Stella, Yuyang Wang, and Tim Januschowski. Deep state space models for time series forecasting. In NeurIPS, 2018.
195
+ [30] David Salinas, Valentin Flunkert, Jan Gasthaus, and Tim Januschowski. DeepAR: Probabilistic forecasting with autoregressive recurrent networks. Int. J. Forecast., 2020.
196
+ [31] Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Instance normalization: The missing ingredient for fast stylization. arXiv preprint arXiv:1607.08022, 2016.
197
+ [32] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
198
+ [33] Ruofeng Wen, Kari Torkkola, Balakrishnan Narayanaswamy, and Dhruv Madeka. A multi-horizon quantile recurrent forecaster. NeurIPS, 2017.
199
+ [34] Gerald Woo, Chenghao Liu, Doyen Sahoo, Akshat Kumar, and Steven C. H. Hoi. Etsformer: Exponential smoothing transformers for time-series forecasting. arXiv preprint arXiv:1406.1078, 2022.
200
+ [35] Haixu Wu, Jiehui Xu, Jianmin Wang, and Mingsheng Long. Autoformer: Decomposition transformers with Auto-Correlation for long-term series forecasting. In NeurIPS, 2021.
201
+ [36] Rose Yu, Stephan Zheng, Anima Anandkumar, and Yisong Yue. Long-term forecasting using tensor-train rnns. arXiv preprint arXiv:1711.00073, 2017.
202
+ [37] Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wancai Zhang. Informer: Beyond efficient transformer for long sequence time-series forecasting. In AAAI, 2021.
203
+ [38] Tian Zhou, Ziqing Ma, Qingsong Wen, Xue Wang, Liang Sun, and Rong Jin. FEDformer: Frequency enhanced decomposed transformer for long-term series forecasting. In ICML, 2022.
204
+
205
+ # Checklist
206
+
207
+ 1. For all authors...
208
+
209
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 1.
210
+ (b) Did you describe the limitations of your work? [Yes] See Section 7 of the Appendix.
211
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 6 of the Appendix.
212
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
213
+
214
+ 2. If you are including theoretical results...
215
+
216
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 1 of the Appendix. (b) Did you include complete proofs of all theoretical results? [Yes] See Section 1 of the Appendix.
217
+
218
+ 3. If you ran experiments...
219
+
220
+ (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 provide the data link and code in https://github.com/thuml/Nonstationary_Transformers.
221
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.1 of the Appendix.
222
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Table 4 of the Appendix.
223
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 4.
224
+
225
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
226
+
227
+ (a) If your work uses existing assets, did you cite the creators? [Yes] The data source is described in Section 4.
228
+ (b) Did you mention the license of the assets? [N/A]
229
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We provide the code in https://github.com/thuml/Nonstationary_Transformers.
230
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
231
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
232
+
233
+ 5. If you used crowdsourcing or conducted research with human subjects...
234
+
235
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
236
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
237
+ (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/um2BxfgkT2_/um2BxfgkT2_.md ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Pure Transformers are Powerful Graph Learners
2
+
3
+ Jinwoo ${ \bf K i m ^ { 1 * } }$ Tien Dat Nguyen1 Seonwoo $\mathbf { M } \mathbf { i n } ^ { 2 }$ Sungjun Cho2 Moontae Lee2,3 Honglak Lee2† Seunghoon Hong1,2† 1KAIST $^ 2 \mathrm { L G }$ AI Research 3University of Illinois Chicago
4
+
5
+ # Abstract
6
+
7
+ We show that standard Transformers without graph-specific modifications can lead to promising results in graph learning both in theory and practice. Given a graph, we simply treat all nodes and edges as independent tokens, augment them with token embeddings, and feed them to a Transformer. With an appropriate choice of token embeddings, we prove that this approach is theoretically at least as expressive as an invariant graph network (2-IGN) composed of equivariant linear layers, which is already more expressive than all message-passing Graph Neural Networks (GNN). When trained on a large-scale graph dataset (PCQM4Mv2), our method coined Tokenized Graph Transformer (TokenGT) achieves significantly better results compared to GNN baselines and competitive results compared to Transformer variants with sophisticated graph-specific inductive bias. Our implementation is available at https://github.com/jw9730/tokengt.
8
+
9
+ # 1 Introduction
10
+
11
+ In recent years, Transformer [68] has served as a versatile architecture in a broad class of machine learning problems, such as natural language processing [17, 7], computer vision [18], and reinforcement learning [9], to name a few. It is because the fully-attentional structure of Transformer is general and powerful enough to take, process, and relate inputs and outputs of arbitrary structures, eliminating a need for data- and task-specific inductive bias to be baked into the network architecture. Combined with large-scale training, it opens up a new chapter for building a versatile model that can solve a wide range of problems involving diverse data modalities and even a mixture of modalities [31, 30, 57].
12
+
13
+ In graph learning domain, inspired by the breakthroughs, multiple works tried combining selfattention into graph neural network (GNN) architecture where message passing was previously dominant [50]. As global self-attention across nodes cannot reflect the graph structure, however, these methods introduce graph-specific architectural modifications. This includes restricting self-attention to local neighborhoods [69, 51, 19], using global self-attention in conjunction with message-passing GNN [58, 43, 34], and injecting edge information into global self-attention via attention bias [72, 78, 29, 54]. Despite decent performance, such modifications can be a limiting constraint in terms of versatility, especially considering future integration to multi-task and multi-modal general-purpose attentional architectures [31]. In addition, deviating from pure self-attention, these methods may inherit the issues of message-passing such as oversmoothing [40, 8, 52], and become incompatible with useful engineering techniques e.g., linear attention [65] developed for standard self-attention.
14
+
15
+ Instead, we explore the opposite direction of applying a standard Transformer directly for graphs. For this, we treat all nodes and edges as independent tokens, augment them with appropriate token-wise embeddings, and feed the tokens as input to the standard Transformer. The model operates identically to Transformers used in language and vision; each node or edge is treated as a token, identical to the words in a sentence or patches of an image [68, 18]. Perhaps surprisingly, we show that this simple approach yields a powerful graph learner both in theory and practice.
16
+
17
+ ![](images/52bed2530f5286429062a470732b4db3e662dccfbb005d25f54685df83e4fec4.jpg)
18
+ Figure 1: Overview of Tokenized Graph Transformer (TokenGT). We treat all nodes and edges of an input graph as independent tokens, augment them with orthonormal node identifiers and trainable type identifiers, and feed them to a standard Transformer encoder. For graph-level prediction, we follow the common practice [17, 18] of using an extra trainable [graph] token.
19
+
20
+ As a key theoretical result, we prove that with appropriate token-wise embeddings, self-attention over the node and edge tokens can approximate any permutation equivariant linear operator on a graph [47]. Remarkably, we show that a very simple choice of embedding composed of node identifiers and type identifiers is sufficient for accurate approximation. This provides a solid theoretical guarantee that, with the embeddings and enough attention heads, a Transformer is at least as expressive as a second-order invariant graph network (2-IGN) [47, 34], which is already more expressive than all message-passing GNNs [21]. This also immediately grants the model with the expressive power at least as good as the 2-dimensional Weisfeiler-Lehman (WL) graph isomorphism test [46], which is often sufficient for real-world graph data [83]. We further extend our theoretical result to hypergraphs with order- $k$ hyperedges, showing that a Transformer with order- $k$ generalized token embeddings is at least as expressive as $k$ -IGN and, consequently $k$ -WL test.
21
+
22
+ We test our model, named Tokenized Graph Transformer (TokenGT), mainly on the PCQM4Mv2 large-scale quantum chemical property prediction dataset containing 3.7M molecular graphs [27]. Even though TokenGT involves minimal graph-specific architectural modifications, it performs significantly better than all GNN baselines, showing that the advantages of Transformer architecture combined with large-scale training surpass the benefit of hard inductive bias of GNNs. Furthermore, TokenGT achieves competitive performance compared to Transformer variants with strong graphspecific modifications [78, 29, 54]. Finally, we demonstrate that TokenGT can naturally utilize efficient approximations in Transformers in contrast to these variants, using kernel attention [11] that enables linear computation cost without much degradation in performance.
23
+
24
+ # 2 Tokenized Graph Transformer (TokenGT)
25
+
26
+ In this section, we present the Tokenized Graph Transformer (TokenGT), a pure Transformer architecture for graphs with token-wise embeddings composed of node identifiers and type identifiers (Figure 1). Our goal in this section is to provide a practical overview – for theoretical analysis of the architecture, we guide the readers to Section 3.
27
+
28
+ Let $\mathcal { G } = ( \nu , \mathcal { E } )$ an input graph with $n$ nodes $\mathcal { V } = \{ v _ { 1 } , . . . , v _ { n } \}$ and $m$ edges $\mathcal { E } = \{ e _ { 1 } , . . . , e _ { m } \} \subseteq$ $\mathcal { V } ^ { 2 }$ , associated with features $\mathbf { X } ^ { \nu } \in \mathbb { R } ^ { n \times C }$ and ∈ Rm×C , respectively. We treat each node and edge as an independent token (thus $( n + m )$ tokens in total) and construct their features by $\mathbf { X } = [ \bar { \mathbf { X } } ^ { \nu } ; \mathbf { X } ^ { \varepsilon } ] \in \mathbb { R } ^ { ( n + m ) \times C }$ . A naïve way to process a graph is to directly provide the tokens $\mathbf { X }$ as input to a Transformer, but it is inappropriate as graph connectivity is discarded. To thoroughly represent graph structure, we augment the tokens $\mathbf { X }$ with token-wise embeddings, more specifically orthonormal node identifiers used for representing the connectivity of the tokens and trainable type identifiers that encode whether a token is a node or an edge. Despite the simplicity, we show that a Transformer applied on these embeddings is a theoretically powerful graph learner.
29
+
30
+ Node Identifiers The first component of token-wise embedding is the orthonormal node identifier that we use to represent the connectivity structure given in the input graph.
31
+
32
+ For a given input graph $\mathcal { G } = ( \nu , \mathcal { E } )$ , we first produce $n$ node-wise orthonormal vectors $\mathbf { P } \in \mathbb { R } ^ { n \times d _ { p } }$ that we refer to as node identifiers. Then, we augment the tokens $\mathbf { X }$ with node identifiers as follows.
33
+
34
+ • For each node $v \in \mathcal V$ , we augment the token $\mathbf { X } _ { v }$ as $\big [ \mathbf { X } _ { v } , \mathbf { P } _ { v } , \mathbf { P } _ { v } \big ]$ .
35
+ • For each edge $( u , v ) \in \mathcal { E }$ , we augment the token $\mathbf { X } _ { ( u , v ) }$ as $[ \mathbf { X } _ { ( u , v ) } , \mathbf { P } _ { u } , \mathbf { P } _ { v } ]$ .
36
+
37
+ Intuitively, a Transformer operating on the augmented tokens can fully recognize the connectivity structure of the graph since comparing the node identifiers between a pair of tokens reveals their incidence information. For instance, we can tell if an edge $\boldsymbol { e } = \left( u , v \right)$ is connected with a node $k$ through dot-product (attention) since $[ { \bf P } _ { u } , { \bf P } _ { v } ] [ { \bf P } _ { k } , { \bf P } _ { k } ] ^ { \top } = 1$ if and only if $k \in \mathsf { \Gamma } ( u , v )$ and 0 otherwise. This allows the Transformer to identify and exploit the connectivity structure of a graph, for instance by putting more weights on incident pairs when the local operation is important.
38
+
39
+ Notably, as the node identifiers $\mathbf { P }$ are only required to be orthonormal, we have a large degree of freedom in implementation choices. We outline two practical methods below as examples. Their implementation details can be found in Appendix A.3.1.
40
+
41
+ • Orthogonal random features (ORFs), e.g., rows of random orthogonal matrix $\mathbf { Q } \in \mathbb { R } ^ { n \times n }$ obtained with QR decomposition of random Gaussian matrix $\mathbf { G } \in \mathbb { R } ^ { n \times n }$ [79, 12]. • Laplacian eigenvectors obtained from eigendecomposition of graph Laplacian matrix, i.e., rows of U from $ { \Delta } = { \mathbf { I } } - { \mathbf { D } } ^ { - 1 / 2 } { \mathbf { A } } { \mathbf { D } } ^ { - 1 / 2 } = { \mathbf { U } } ^ { \top } { \mathbf { A } } \bar { { \mathbf { U } } }$ , where $\mathbf { A } \in \mathbb { R } ^ { n \times n }$ is adjacency matrix, $\mathbf { D }$ is degree matrix, and $\pmb { \Lambda }$ , U correspond to eigenvalues and eigenvectors respectively [20].
42
+
43
+ Among the two methods, node identifiers generated as ORFs do not encode any information about the graph structure as they are entirely random. This means the Transformer that operates on the ORF-based node identifiers needs to compile and recognize graph structure only from the incidence information provided by the node identifiers. Although this is challenging, perhaps surprisingly, we empirically show in Section 5 that Transformers are strong enough to learn meaningful structural representations out of ORF-based node identifiers and outperform GNNs on large-scale task.
44
+
45
+ In contrast to ORFs, Laplacian eigenvectors provide a kind of graph positional embeddings (graph PEs) that describes the distance between nodes on a graph. Due to the positional information, it yields better performance compared to ORFs in our experiments in Section 5. One interesting aspect of Laplacian eigenvectors is that they can be viewed as a generalization of sinusoidal positional embeddings of NLP Transformers to graphs, as the eigenvectors of 1D chain graphs are sine and cosine functions [20]. Thus, by choosing Laplacian eigenvectors as node identifiers, our approach can be interpreted as a direct extension of the NLP Transformer for inputs involving relational structures.
46
+
47
+ Type Identifiers The second component of token-wise embedding is the trainable type identifier that encodes whether a token is node or edge. For a given input graph $\mathcal { G } = ( \nu , \mathcal { E } )$ , we first prepare a trainable parameter matrix ${ \bf E } = [ { \bf E } ^ { \nu } ; { \bf E } ^ { \varepsilon } ] \in \mathbb { R } ^ { 2 \times d _ { e } }$ that contains two type identifiers $\mathbf { E } ^ { \nu }$ and $\mathbf { E } ^ { \mathcal { E } }$ for nodes and edges respectively. Then, we further augment the tokens with type identifiers as follows.
48
+
49
+ • For each node $v \in \mathcal V$ , we augment the token $[ \mathbf { X } _ { v } , \mathbf { P } _ { v } , \mathbf { P } _ { v } ]$ as $[ \mathbf { X } _ { v } , \mathbf { P } _ { v } , \mathbf { P } _ { v } , \mathbf { E } ^ { \nu } ]$ .
50
+ • For each edge $( u , v ) \in \mathcal { E }$ , we augment the token $[ \mathbf { X } _ { ( u , v ) } , \mathbf { P } _ { u } , \mathbf { P } _ { v } ]$ as $[ \mathbf { X } _ { ( u , v ) } , \mathbf { P } _ { u } , \mathbf { P } _ { v } , \mathbf { E } ^ { \mathcal { E } } ]$ .
51
+
52
+ These embeddings provide information on whether a given token is a node or an edge, which is critical, e.g., when an attention head tries to attend specifically to node tokens and ignore edge tokens.
53
+
54
+ Main Transformer With node identifiers and type identifiers, we obtain augmented token features $\mathbf { X } ^ { i n } \in \mathbb { R } ^ { ( n + m ) \times ( C + 2 d _ { p } + d _ { e } ) }$ , which is further projected by a trainable matrix $\overline { { w } } ^ { i n } \in \mathbb { R } ^ { ( C + 2 d _ { p } + d _ { e } ) \times d }$ to be an input to Transformer. For graph-level prediction, we prepend a special token [graph] with trainable embedding $\mathbf { X } _ { [ \mathrm { g r a p h } ] } \mathbf { \bar { \Pi } } \in \mathbf { \bar { \Pi } } \mathbb { R } ^ { d }$ similar to BERT [17] and ViT [18]. We utilize the feature of [graph] token at the output of the encoder as the graph representation, on which a linear prediction head is applied to produce the final graph-level prediction. Overall, the tokens ${ \bf Z } ^ { ( 0 ) } = [ { \bf X } _ { [ \mathrm { g r a p h } ] } ; { \bf X } ^ { i n } w ^ { i n } ] \bar { \in } \mathbb { R } ^ { ( 1 + n \bar { + } m ) \times d }$ are used as the input to the main encoder. As an encoder, we adopt the standard Transformer [68], which is an alternating stack of multihead self-attention layers (MSA) and feedforward MLP layers. We provide further details in Appendix A.1.1.
55
+
56
+ Inductive Bias Similar to Transformers in language and vision [17, 18], Tokenized Graph Transformer treats input nodes and edges as independent tokens and applies self-attention to them. This approach leads to much less inductive bias than current GNNs, where the sparse graph structure, or more fundamentally, permutation symmetry of graphs is deliberately baked into each layer [21, 47, 46, 34]. For TokenGT, such information is provided entirely as a part of input using token-wise embeddings, and the model has to learn how to interpret and utilize the information from data. Although such weak inductive bias might raise questions on the expressiveness of the model, our theoretical analysis in Section 3 shows that TokenGT is a powerful graph learner thanks to the token-wise embeddings and expressive power of self-attention. For example, we show that TokenGT is more expressive than all message-passing GNNs under the framework of Gilmer et al. (2017) [21].
57
+
58
+ # 3 Theoretical Analysis
59
+
60
+ We now present our theory. Our key result is that TokenGT, a standard Transformer with node and type identifiers presented in Section 2, is provably at least as expressive as the second-order Invariant Graph Network (2-IGN [47]), which is built upon all possible permutation equivariant linear layers on a graph. This provides solid theoretical guarantees for TokenGT, such as being at least as powerful as the 2-WL graph isomorphism test and more expressive than all message-passing GNNs. Our theory is based on a general framework on hypergraphs represented as higher-order tensors, which leads to the formulation of order- $k$ TokenGT that is at least as expressive as order- $k$ IGN $k$ -IGN [47]).
61
+
62
+ # 3.1 Preliminary: Permutation Symmetry and Invariant Graph Networks
63
+
64
+ Representing and Processing Sets and (Hyper)Graphs For a set of $n$ nodes, we often represent their features as $\mathbf { X } \in \mathbb { R } ^ { n \times d }$ where $\mathbf { X } _ { i } \in \mathbb { R } ^ { d }$ is the feature of the $i$ -th node. The set is unordered and, therefore, should be treated invariant to the renumbering of the nodes. Let $S _ { n }$ the symmetric group or the group of permutations $\pi$ on $[ n ] = \{ 1 , . . . , n \}$ . By $\pi \cdot \mathbf { X }$ we denote permuting rows of $\mathbf { X }$ with $\pi$ , i.e., $( \pi \cdot \mathbf { \bar { X } } ) _ { i } = \mathbf { X } _ { \pi ^ { - 1 } ( i ) } .$ . Here, $\mathbf { X }$ and $\pi \cdot \mathbf { X }$ represent the identical set for all $\pi \in S _ { n }$ .
65
+
66
+ Generally, we consider (hyper)graphs represented as order- $k$ tensor $\mathbf { X } \in \mathbb { R } ^ { n ^ { k } \times d }$ with feature $\mathbf { X _ { i } } =$ $\mathbf { X } _ { i _ { 1 } , \dots , i _ { k } } \in \mathbb { R } ^ { d }$ attached to (hyper)edge represented as multi-index $\mathbf { i } = ( i _ { 1 } , . . . , i _ { k } ) \in [ n ] ^ { k }$ . Similar to sets, the tensor should be treated invariant to node renumbering by any $\pi \in S _ { n }$ that acts on $\mathbf { X }$ by $( { \boldsymbol { \pi } } \cdot \mathbf { X } ) _ { \mathbf { i } } = \mathbf { X } _ { \pi ^ { - 1 } ( \mathbf { i } ) }$ where $\pi ^ { - 1 } ( \mathbf { i } ) = ( \pi ^ { - 1 } ( i _ { 1 } ) , . . . , \pi ^ { - 1 } ( i _ { k } ) )$ . That is, $\mathbf { X }$ and $\pi \cdot { \bf X }$ represent the identical (hyper)graph for all $\pi$ . Due to such symmetry, to build a function $F ( \mathbf { X } ) \approx T$ for tensor $\mathbf { X }$ and target $T$ , a suitable way is to make them invariant ${ \bf { \dot { F } } } ( \pi \cdot { \bf { X } } ) = F ( { \bf { X } } )$ when the target is a vector or equivariant $F ( { \boldsymbol \pi } \cdot \mathbf { X } ) = { \boldsymbol \pi } \cdot F ( \mathbf { X } )$ when the target is also a tensor, for all $\mathbf { X } \in \mathbb { R } ^ { n ^ { k } \times d }$ and $\pi \in S _ { n }$
67
+
68
+ In our theoretical analysis, we work on order- $k$ dense tensor representation $\mathbf { X } \in \mathbb { R } ^ { n ^ { k } \times d }$ of a graph as they can represent node features $ { \left( k = 1 \right. }$ ), edge features $k = 2$ ), or hyperedge features $( k > 2 )$ ) in a unified manner. This is interchangeable but slightly different from the sparse representation of a graph with edge set $\mathcal { E }$ used in Section 2. Nevertheless, in Section 5 we empirically verify that our key theoretical findings work equally well for dense and sparse graphs.
69
+
70
+ Invariant Graph Network We mainly develop our theoretical analysis upon Invariant Graph Networks (IGNs) [47, 46], a family of expressive graph networks derived from the permutation symmetry of tensor representation of graphs. Here we provide a summary. In general, we define:
71
+
72
+ Definition 1. An order- $k$ Invariant Graph Network ( $k$ -IGN) is a function $F _ { k } : \mathbb { R } ^ { n ^ { k } \times d _ { 0 } } \mathbb { R }$ written as the following:
73
+
74
+ $$
75
+ F _ { k } = \mathbf { M } \mathbf { L } \mathbf { P } \circ L _ { k 0 } \circ L _ { k k } ^ { ( T ) } \circ \sigma \circ \dots \circ \sigma \circ L _ { k k } ^ { ( 1 ) } ,
76
+ $$
77
+
78
+ where each L(t) is equivariant linear layer [47] from $\mathbb { R } ^ { n ^ { k } \times d _ { t - 1 } }$ to $\mathbb { R } ^ { n ^ { k } \times d _ { t } }$ , $\sigma$ is activation function, and $L _ { k 0 }$ is a invariant linear layer from $\mathbb { R } ^ { n ^ { k } \times d _ { T } } t o \mathbb { R }$ .
79
+
80
+ A body of previous work have shown appealing theoretical properties of $k$ -IGN, including universal approximation [48] and alignment to $k$ -Weisfeiler-Lehman ( $k$ -WL) graph isomorphism test [46, 10]. In particular, it is known that $k$ -IGNs are theoretically at least as powerful as the $k$ -WL test [46]. It is also known that 2-IGNs are already more expressive [47, 34] than all message-passing GNNs under the framework of Gilmer et al. (2017) [21].
81
+
82
+ The core building block of IGN is invariant and equivariant linear layers [47] with maximal expressiveness while respecting node permutation symmetry. The layers are defined as follows:
83
+
84
+ Definition 2. An equivariant linear layer is a function $L _ { k \to l } : \mathbb { R } ^ { n ^ { k } \times d } \mathbb { R } ^ { n ^ { l } \times d ^ { \prime } }$ written as follows for order-k input X ∈ Rnk×d:
85
+
86
+ $$
87
+ L _ { k \to l } ( { \bf X } ) _ { \bf i } = \sum _ { \mu } \sum _ { { \bf j } } { \bf B } _ { { \bf i } , { \bf j } } ^ { \mu } { \bf X } _ { { \bf j } } w _ { \mu } + \sum _ { \lambda } { \bf C } _ { { \bf i } } ^ { \lambda } b _ { \lambda } ,
88
+ $$
89
+
90
+ where $\mathbf { i } \in [ n ] ^ { l } , \mathbf { j } \in [ n ] ^ { k }$ are multi-indices, $w _ { \boldsymbol { \mu } } \in \mathbb { R } ^ { d \times d ^ { \prime } }$ , $b _ { \lambda } \in \mathbb { R } ^ { d ^ { \prime } }$ are weight and bias parameters, and Bµ ∈ Rnl+k and $\mathbf { C } ^ { \lambda } \in \mathbb { R } ^ { n ^ { l } }$ are binary basis tensors corresponding to order- $( l + k )$ and order- $l$ equivalence classes $\mu$ and $\lambda$ , respectively. Invariant linear layer is a special case of $L _ { k l }$ with $l = 0$ .
91
+
92
+ We provide the definition of the equivalence classes and basis tensors in Appendix A.1.1. For now, it is sufficient to know that the basis tensors are binary tensors that form the orthogonal basis of the full space of linear equivariant layers. In general, in Eq. (2) it is known that there exists $\mathrm { b e l l } ( k + l )$ number of basis tensors $\mathbf { B } ^ { \mu }$ for the weight and $\mathsf { b e l l } ( l )$ number of basis tensors $\mathbf { C } ^ { \lambda }$ for the bias.
93
+
94
+ # 3.2 Can Self-Attention Approximate Equivariant Basis?
95
+
96
+ Now, we present an intuition that connects Transformer (Section 2) and equivariant linear layer (Definition 2). For that, we write out the multihead self-attention layer as follows:
97
+
98
+ $$
99
+ \mathbf { M S A } ( \mathbf { X } ) _ { i } = \sum _ { h = 1 } ^ { H } \sum _ { j } \alpha _ { i j } ^ { h } \mathbf { X } _ { j } w _ { h } ^ { V } w _ { h } ^ { O } \mathrm { ~ w h e r e ~ } \alpha ^ { h } = \mathrm { s o f t m a x } \left( \frac { \mathbf { X } w _ { h } ^ { Q } ( \mathbf { X } w _ { h } ^ { K } ) ^ { \top } } { \sqrt { d _ { H } } } \right) ,
100
+ $$
101
+
102
+ where $H$ is number of heads, $d _ { H }$ is head size, and $w _ { h } ^ { Q } , w _ { h } ^ { K } \in \mathbb R ^ { d \times d _ { H } } , w _ { h } ^ { V } \in \mathbb R ^ { d \times d _ { v } } w _ { h } ^ { O } \in \mathbb R ^ { d _ { v } \times d } .$
103
+
104
+ Our intuition is that the weighted sum of values with self-attention matrix $\alpha ^ { h }$ in Eq. (3) is analogous to the masked sum with basis tensor $\mathbf { B } ^ { \mu }$ in Eq. (2) up to normalization. This naturally leads to the following question: for a given equivariant layer $L _ { k \to k } : \mathbb { R } ^ { n ^ { k } \times d } \to \mathbb { R } ^ { n ^ { k } \times d }$ , can we use a Transformer layer with multihead self-attention $\mathbf { M S A } : \mathbb { R } ^ { N \times d ^ { \prime } } \mathbb { R } ^ { N \times d ^ { \prime } }$ with $N = n ^ { k }$ to accurately approximate $L _ { k k }$ by having $H = { \mathsf { b e l l } } ( 2 k )$ attention heads approximate each equivariant basis $\mathbf { B } ^ { \mu }$ ?
105
+
106
+ We show that this can be possible, but only if we provide appropriate auxiliary information to input. For example, let us consider first-order layer $L _ { 1 1 }$ . The layer has ${ \mathsf { b e l l } } ( 2 ) = 2$ basis tensors $\mathbf { B } ^ { \mu _ { 1 } } = \mathbf { I }$ and $\mathbf { B } ^ { \mu _ { 2 } } = \mathbf { 1 1 } ^ { \top } - \mathbf { I }$ for the weight, and bel $1 ( 1 ) = 1$ basis tensor $\mathbf { C } ^ { \lambda _ { 1 } } = \mathbf { 1 }$ for the bias. Given an input set $\mathbf { X } \in \mathbb { R } ^ { n \times d }$ it computes the following with $w _ { 1 } , w _ { 2 } \in \mathbb { R } ^ { d \times d }$ , $b \in \mathbb { R } ^ { d }$ :
107
+
108
+ $$
109
+ L _ { 1 \to 1 } ( \mathbf { X } ) = \mathbf { I } \mathbf { X } w _ { 1 } + ( \mathbf { 1 1 } ^ { \top } - \mathbf { I } ) \mathbf { X } w _ { 2 } + \mathbf { 1 } b ^ { \top } .
110
+ $$
111
+
112
+ Now consider approximating basis tensor $\mathbf { B } ^ { \mu _ { 1 } } = \mathbf { I }$ with an attention matrix $\alpha ^ { 1 }$ . The approximation is accurate when $i$ -th query always only attends to $i$ -th key and ignores the rest. To achieve the attention structure consistently, i.e., agnostic to input $\mathbf { X }$ , we need to provide auxiliary input that self-attention can "latch onto" to faithfully approximate ${ \pmb { \alpha } } ^ { 1 } \approx { \bf I }$ . Without this, attention must entirely rely on the inputs $\mathbf { X }$ , which is unreliable and can lead to approximation failure, e.g., when $\mathbf { X }$ has repeated rows.
113
+
114
+ For the auxiliary information, we prepare $n$ node-wise orthonormal vectors $\mathbf { P } \in \mathbb { R } ^ { n \times d _ { p } }$ (note that this is identical to node identifiers in Section 2), and augment the input to $\mathbf { X } ^ { i n } = [ \mathbf { X } , \mathbf { P } ] \in \mathbb { R } ^ { n \times ( d + d _ { p } ) }$ . Let us assume that the query and key projections in Eq. (3) ignore $\mathbf { X }$ and only leave $\mathbf { P }$ scaled by $\sqrt { a }$ with $a > 0$ . Then attention matrix is computed as $\bar { \mathbf { \alpha } } ^ { 1 } = \bar { \mathrm { s o f t m a x } } ( \mathbf { S } )$ where $\mathbf { S } _ { i j } = a \mathbf { P } _ { i } ^ { \top } \mathbf { P } _ { j }$ . Here, due to the orthonormality of $\mathbf { P }$ , we have ${ \bf P } _ { i } ^ { \top } { \bf P } _ { j } = 1$ only if $i = j$ and otherwise 0, which leads to $\mathbf { S } = a \mathbf { I }$ . With $a \infty$ by scaling up the query and key projection weights, the softmax becomes arbitrarily close to the hardmax operator, and we obtain the following:
115
+
116
+ $$
117
+ \alpha ^ { 1 } = \operatorname { s o f t m a x } ( a \mathbf { I } ) \to \mathbf { I } \operatorname { a s } a \to \infty .
118
+ $$
119
+
120
+ Thus, self-attention can utilize the auxiliary information $\mathbf { P }$ to achieve an input-agnostic approximation of $\alpha ^ { 1 }$ to I. Notably, we can achieve a similar approximation for $\mathbf { B } ^ { \mu _ { 2 } } = \mathbf { \bar { 1 1 } } ^ { \top } - \mathbf { I }$ using the same $\mathbf { P }$ by flipping the sign of keys, which gives $\pmb { \alpha } ^ { 2 } = \mathrm { s o f t m a x } ( - a \mathbf { I } )$ due to orthonormality. By sending $a \to \infty$ , now attention from the $i$ -th query to the $i$ -th key is suppressed, and we obtain the following:
121
+
122
+ $$
123
+ \alpha ^ { 2 } = \operatorname { s o f t m a x } \left( - a \mathbf { I } \right) \to { \frac { 1 } { n - 1 } } ( \mathbf { 1 1 } ^ { \top } - \mathbf { I } ) { \mathrm { ~ a s ~ } } a \to \infty .
124
+ $$
125
+
126
+ Note that this approximation is accurate only up to row normalization as rows of $\alpha ^ { 2 }$ always sum to one due to softmax, while $\mathbf { B } ^ { \mu _ { 2 } } = \mathbf { 1 1 } ^ { \top } - \bar { \mathbf { I } }$ is binary. In our proofs of the theoretical results, we perform appropriate denormalization with MLP after MSA to achieve an accurate approximation.
127
+
128
+ Overall, we see that simple auxiliary input $\mathbf { P }$ suffices for two attention heads to approximate the equivariant basis of $L _ { 1 1 }$ accurately. We now question the following. Given appropriate auxiliary information as input, can a Transformer layer with bell $( 2 k )$ attention heads accurately approximate $L _ { k k }$ by having each head approximate each equivariant basis $\mathbf { B } ^ { \mu } ?$ What would be the sufficient auxiliary input? We answer the question by showing that, with (order- $k$ generalized) node and type identifiers presented in Section 2, Transformer layers can accurately approximate equivariant layers $L _ { k k }$ via input-agnostic head-wise approximation of each equivariant basis.
129
+
130
+ # 3.3 Pure Transformers are Powerful Graph Learners
131
+
132
+ We now present our main theoretical results that extend the discussions in Section 3.2 to any order $k$ . Note that $k = 2$ corresponds to TokenGT for graphs presented in Section 2. With $k > 2$ , we naturally extend TokenGT to hypergraphs. All proofs can be found in Appendix A.1.
133
+
134
+ We first introduce generalized node and type identifiers (Section 2) for order- $k$ tensors $\mathbf { X } \in \mathbb { R } ^ { n ^ { k } \times d }$ We define the node identifier $\mathbf { P } \in \mathbb { R } ^ { n \times d _ { p } }$ as an orthonormal matrix with $n$ rows, and the type identifier as a trainable matrix $\mathbf { E } \in \mathbb { R } ^ { \mathrm { b e l l } ( k ) \times d _ { e } }$ that contains $\mathsf { b e l l } ( k )$ rows $\mathbf { E } ^ { \gamma _ { 1 } } , . . . , \mathbf { E } ^ { \gamma _ { \mathrm { b e l l } } ( k ) }$ , each of which is designated for an order- $k$ equivalence class $\gamma$ . Then, we augment each entry of input tensor as $[ \mathbf { X } _ { i _ { 1 } , . . . , i _ { k } } , \mathbf { \bar { P } } _ { i _ { 1 } } , . . . , \mathbf { P } _ { i _ { k } } , \mathbf { E } ^ { \gamma } ]$ where $( i _ { 1 } , . . . , i _ { k } ) \in \gamma$ .
135
+
136
+ Let us exemplify. For $k = 1$ (sets), each $i$ -th entry is augmented as $\left[ { \bf X } _ { i } , { \bf P } _ { i } , { \bf E } ^ { \gamma _ { 1 } } \right]$ , consistent with our discussion in Section 3.2. For $k = 2$ (graphs), each $( i , i )$ -th entry is augmented as $\left[ { \bf X } _ { i i } , { \bf P } _ { i } , { \bf P } _ { i } , { \bf E } ^ { \gamma _ { 1 } } \right]$ and each $( i , j )$ -th entry $( i \neq j )$ is augmented as $[ { \bf X } _ { i j } , { \bf P } _ { i } , { \bf P } _ { j } , { \bf E } ^ { \gamma _ { 2 } } ]$ . This is consistent with TokenGT in Section 2, which augments nodes with $\mathbf { E } ^ { \nu } = \mathbf { E } ^ { \tilde { \gamma } _ { 1 } }$ and edges with $\mathbf { E } ^ { \mathcal { E } } = \mathbf { E } ^ { \gamma _ { 2 } }$ .
137
+
138
+ With node and type identifiers, we obtain augmented order- $k$ tensor $\mathbf { X } ^ { i n } \in \mathbb { R } ^ { n ^ { k } \times ( d + k d _ { p } + d _ { e } ) }$ . We use a trainable projection $w ^ { i n } \in \mathbb { R } ^ { ( d + k d _ { p } + d _ { e } ) \times d \tau }$ to map them to hidden dimension $d \tau$ of a Transformer. We now show that self-attention on $\mathbf { X } ^ { i n } w ^ { i n }$ can accurately approximate equivariant basis:
139
+
140
+ Lemma 1. For all $\mathbf { X } \in \mathbb { R } ^ { n ^ { k } \times d }$ and their augmentation $\mathbf { X } ^ { i n }$ , self-attention coefficients $\pmb { \alpha } ^ { h }$ (Eq. (3)) computed with $\mathbf { X } ^ { i n } w ^ { i n }$ can approximate any basis tensor $\mathbf { B } ^ { \mu } \in \mathbb { R } ^ { n ^ { 2 k } }$ of order- $k$ equivariant linear layer $L _ { k k }$ (Definition 2) to arbitrary precision up to normalization.
141
+
142
+ Consequently, with the node and type identifiers, a collection of bell $( 2 k )$ attention heads can approximate the collection of all basis tensors of order- $k$ equivariant layer. This leads to the following:
143
+
144
+ Theorem 1. For all $\mathbf { X } \in \mathbb { R } ^ { n ^ { k } \times d }$ and their augmentation $\mathbf { X } ^ { i n }$ , a Transformer layer with bell $( 2 k )$ self-attention heads that operates on $\mathbf { X } ^ { i n } w ^ { i n }$ can approximate an order- $k$ equivariant linear layer $L _ { k \to k } ( \mathbf X )$ (Definition 2) to arbitrary precision.
145
+
146
+ While the approximation in Lemma 1 is only accurate up to normalization over inputs (keys) due to softmax normalization, for the approximation in Theorem 1 we perform appropriate denormalization using MLP after multihead self-attention and can obtain an accurate approximation.
147
+
148
+ By extending the result to multiple layers, we arrive at the following:
149
+
150
+ Theorem 2. For all $\mathbf { X } \in \mathbb { R } ^ { n ^ { k } \times d }$ and their augmentation $\mathbf { X } ^ { i n }$ , a Transformer composed of $T$ layers that operates on $\mathbf { X } ^ { i n } w ^ { i n }$ followed by sum-pooling and MLP can approximate an $k$ -IGN $F _ { k } ( \mathbf { X } )$ (Definition 1) to arbitrary precision.
151
+
152
+ This directly leads to the following corollary:
153
+
154
+ Corollary 1. A Transformer on node and type identifiers in Theorem 2 is at least as expressive as $k$ -IGN composed of order- $k$ equivariant linear layers.
155
+
156
+ Corollary 1 allows us to draw previous theoretical results on the expressiveness of $k$ -IGN [46, 47, 34] and use them to lower-bound the provable expressiveness of a standard Transformer:
157
+
158
+ Corollary 2. A Transformer on node and type identifiers in Theorem 2 is at least as powerful as $k$ -WL graph isomorphism test and is more expressive than all message-passing GNNs within the framework of Gilmer et al. (2017) [21].
159
+
160
+ # 4 Related Work
161
+
162
+ We outline relevant work including equivariant neural networks, theory on expressive power of Transformers and their connection to modeling equivariance, and Transformers for graphs.
163
+
164
+ Equivariant Neural Networks A machine learning task is often invariant or equivariant to specific symmetry of input data, e.g., image classification is invariant to the translation of an input image. A large body of literature advocated baking the invariance or equivariance into a neural network as a type of inductive bias (e.g., translation equivariance of image convolution), showing that it reduces the number of parameters and improves generalization for a wide range of learning tasks involving various geometric structures [13, 14, 73, 66, 49, 53, 60, 6, 34, 39]. Ravanbakhsh et al. (2017) [56] showed that any equivariant layer for discrete group actions is equivalent to a specific parameter sharing structure. Zaheer et al. (2017) [82] and Maron et al. (2019) [47] derived the parameter sharing for node permutation-symmetric data (sets and (hyper)graphs), which gives the maximally expressive equivariant linear layers and $k$ -IGN in Section 3.1. The work on equivariant neural networks underlie our theory of how a standard Transformer can be a powerful learner for sets and (hyper)graphs.
165
+
166
+ Expressive Power of Transformers and Its Connection to Equivariance Recent work involving Transformers often focus on minimizing the domain- and task-specific inductive bias and scaling the model and data so that any useful computation structure can be learned [18, 31, 30, 7, 17, 9, 39]. The success of this approach is, to some degree, attributed to the high expressive power of Transformers that allows learning diverse functions suited for the data at hand [81, 39, 3, 4, 41]. Recent theory has shown that Transformers are expressive enough to even model certain equivariant functions [1, 15, 39]. Andreoli et al. (2019) [1] cast self-attention and convolution into a unified framework using basis tensors similar to ones in Section 3.1. Cordonnier et al. (2020) [15] advanced the idea and showed that Transformers with relative positional encodings can approximate any image convolution layers. Lee et al. (2019) [39] and Kim et al. (2021) [34] showed that Transformers can model equivariant linear layers for sets [82], which can be viewed as the first-order case of our theory (see Section 3.2). To our knowledge, our work is the first to show that standard Transformers are expressive enough to provably model maximally expressive equivariant layers and $k$ -IGN for (hyper)graphs with $k \geq 2$ .
167
+
168
+ Transformers for Graphs Unlike in language and vision, developing Transformers for graphs is challenging due to (1) the presence of edge connectivity and (2) the absence of canonical node ordering that prevents adopting simple positional encodings [50]. To incorporate the connectivity of edges, early methods restricted self-attention to local neighborhoods (thus reducing to messagepassing) [19, 51, 69] or used global self-attention with auxiliary message-passing modules [58, 43]. As message-passing suffers from limited expressive power [77] and oversmoothing [40, 8, 52], recent works often discard them and use global self-attention on nodes with heuristic modifications to process edges [78, 29, 54, 38, 42]. Ying et al. (2021) [78] proposed to inject edge encoding based on shortest paths through self-attention bias. Kreuzer et al. (2021) [38] proposed to incorporate edges into self-attention matrix via elementwise multiplication. On the contrary, we leave the self-attention unmodified and provide both nodes and edges with certain token-wise embeddings (Section 2) as its input. To incorporate graph structure into nodes, on the other hand, some approaches focus on developing graph positional encoding, e.g., based on Laplacian eigenvectors [20, 42, 38]. While these can be directly incorporated into our work via auxiliary node identifiers for better performance, we leave this as future work. We further note that current graph Transformers that utilize Laplacian positional encoding rely heavily on heuristic edge encoding [29, 38] while ours does not. Another closely related approach is the Higher-order Transformer [34] which generalizes $k$ -IGN with masked self-attention. While it is highly complex to implement due to hard-coded head-wise equivariant masks, our method can be implemented effortlessly using any available implementation of standard Transformer. Furthermore, our method is more flexible as the model can choose to use different attention heads to focus on a specific equivariant operator (e.g., local propagation) if needed. We further discuss the difficulty in applying linear attention to graph Transformers in Appendix A.2.
169
+
170
+ # 5 Experiments
171
+
172
+ We first conduct a synthetic experiment that directly confirms our key claims in Lemma 1 (Section 3). Then, we empirically explore the capability of Tokenized Graph Transformer (TokenGT) (Section 2) using the PCQM4Mv2 large-scale quantum chemistry regression dataset [27]. We further present experiments on transductive node classification datasets involving large graphs in Appendix A.4.3.
173
+
174
+ Table 1: Second-order equivariant basis approximation. We report average and standard deviation of L2 error averaged over heads over 3 runs. For Random/ORF (first-order), we sample random embeddings independently for each token.
175
+
176
+ <table><tr><td rowspan="2">node id.</td><td rowspan="2">type id.</td><td colspan="2">dense input</td><td colspan="2">sparse input</td></tr><tr><td>train L2↓</td><td>test L2↓</td><td>train L2↓</td><td>test L2↓</td></tr><tr><td>×</td><td>×</td><td>47.95± 0.600</td><td>53.93 ± 1.426</td><td>29.88±0.450</td><td>34.70±1.167</td></tr><tr><td>×</td><td>O</td><td>32.38± 0.448</td><td>40.06±1.202</td><td>15.92 ± 0.275</td><td>20.39±0.765</td></tr><tr><td>Random (first-order)</td><td>0</td><td>32.19 ± 0.476</td><td>32.49 ± 3.687</td><td>15.87 ± 0.247</td><td>16.56 ± 0.904</td></tr><tr><td>ORF (first-order)</td><td>0</td><td>32.35 ± 0.369</td><td>39.87 ± 1.263</td><td>15.87 ± 0.247</td><td>16.56 ± 0.908</td></tr><tr><td>Random</td><td>×</td><td>5.909 ±0.019</td><td>5.548 ± 0.090</td><td>8.152 ± 0.042</td><td>8.270± 0.285</td></tr><tr><td>ORF</td><td>×</td><td>5.472 ± 0.035</td><td>5.143 ± 0.078</td><td>7.167 ± 0.025</td><td>7.190 ± 0.217</td></tr><tr><td>Laplacian eigenvector</td><td>×</td><td>1.899 ± 3.050</td><td>1.702 ± 2.912</td><td>0.288 ± 0.019</td><td>0.064 ± 0.010</td></tr><tr><td>Random</td><td>0</td><td>0.375±0.009</td><td>0.234 ± 0.011</td><td>0.990±0.108</td><td>0.875 ± 0.042</td></tr><tr><td>ORF</td><td>0</td><td>0.080 ± 0.001</td><td>0.009 ± 5e-5</td><td>0.129 ± 0.002</td><td>0.011 ± 0.002</td></tr><tr><td>Laplacian eigenvector</td><td>○</td><td>0.053 ± 1.5e-5</td><td>0.005 ± 1e-4</td><td>0.101 ± 0.003</td><td>0.019 ± 0.007</td></tr></table>
177
+
178
+ ![](images/40798f626d4b5c8fae6c926ea90652517f3d3ce706f97ef0acc49dd4ce18a5f7.jpg)
179
+ Figure 2: Self-attention maps learned under various node and type identifier configurations for two target equivariant basis tensors (out of 15). For better visualization, we clamp the entries by 0.01. Self-attention learns acute patterns coherent to equivariant basis when orthonormal node identifiers and type identifiers are both provided as input. More images can be found in Appendix A.4.1.
180
+
181
+ # 5.1 Approximating Second-Order Equivariant Basis
182
+
183
+ As in Theorem 1 and 2 (Section 3), our argument on the expressive power of TokenGT relies on its capability to approximate order- $k$ permutation equivariant linear layers $L _ { k k }$ (Definition 2). Specifically, Lemma 1 states that such capability depends on the ability of each self-attention head $\hat { \pmb { \alpha } ^ { 1 } } , . . . , \pmb { \alpha } ^ { H }$ (Eq. (3)) to accurately approximate each equivariant basis $\mathbf { B } ^ { \mu _ { 1 } } , . . . , \mathbf { B } ^ { \mu _ { \mathrm { b e l l } } ( 2 k ) }$ (Definition 2) up to normalization.
184
+
185
+ We verify this claim for $k = 2$ (second-order; graphs) in a synthetic setup using Barabási-Albert random graphs. We use a multihead self-attention layer (Eq. (3)) with bell $( 2 + 2 ) = 1 5$ heads and explicitly supervise head-wise attention scores $\pmb { \alpha } ^ { h }$ to approximate each (normalized) equivariant basis tensor $\mathbf { B } ^ { \mu _ { h } }$ by minimizing L2 loss. Having the layer hyperparameters fixed, we provide different combinations of node and type identifiers, and test if multihead self-attention can jointly approximate all 15 equivariant basis on unseen graphs. We experiment with both dense and sparse graph representations; for graphs with $n$ nodes and $m$ edges, the dense graph considers all $n ^ { 2 }$ pairwise edges as input as in Section 3, whereas the sparse graph considers only the present $m$ edges as in Section 2. Further details can be found in Appendix A.3.2.
186
+
187
+ We outline the results in Table 1. Consistent with Lemma 1, self-attention achieves accurate approximation of equivariant basis only when both the orthonormal node identifiers and type identifiers are given. Here, Laplacian eigenvectors (Lap, $\bigcirc$ ) often yield slightly better results than orthogonal random features (ORF, $\bigcirc$ ) presumably due to less stochasticity. Interestingly, we see that self-attention transfers the learned (pseudo-)equivariant self-attention structure to unseen graphs near perfectly.
188
+
189
+ Table 2: Results on PCQM4Mv2 large-scale graph regression benchmark. We report the Mean Absolute Error (MAE) on the validation set, and report MAE on the unavailable test set if possible.
190
+
191
+ <table><tr><td>method</td><td># parameters</td><td>valid MAE↓</td><td>test-dev MAE↓</td><td>asymptotics</td></tr><tr><td>Message-passingGNNs</td></tr><tr><td>GCN [27] 2.0M</td><td>0.1379</td><td>0.1398</td><td>O(n+m)</td></tr><tr><td>GIN [27] GAT</td><td>3.8M 6.7M</td><td>0.1195 0.1302</td><td>0.1218 N/A</td><td>O(n+m) O(n+m)</td></tr><tr><td>GCN-VN[27]</td><td>4.9M</td><td>0.1153</td><td>0.1152</td><td>O(n+m)</td></tr><tr><td>GIN-VN [27]</td><td>6.7M</td><td>0.1083</td><td>0.1084</td><td>O(n+m)</td></tr><tr><td>GAT-VN</td><td></td><td>0.1192</td><td>N/A</td><td>O(n+m)</td></tr><tr><td>GAT-VN (large)</td><td>6.7M</td><td>0.1361</td><td>N/A</td><td>O(n+m)</td></tr><tr><td></td><td>55.2M</td><td></td><td></td><td></td></tr><tr><td colspan="7">Transformerswith strong graph-specific modifications</td></tr><tr><td>Graphormer[63]</td><td>48.3M</td><td>0.0864</td><td>N/A</td><td>O(n²)</td></tr><tr><td>EGT[29]</td><td>89.3M</td><td>0.0869</td><td>0.0872</td><td>O(n2)</td></tr><tr><td>GRPE[54]</td><td>46.2M</td><td>0.0890</td><td>0.0898</td><td>O(n2)</td></tr><tr><td colspan="2">Pure Transformers</td><td></td><td></td><td></td></tr><tr><td>Transformer</td><td>48.5M</td><td>0.2340</td><td>N/A</td><td>O((n+m)²)</td></tr><tr><td>TokenGT (ORF)</td><td>48.6M</td><td>0.0962</td><td>N/A</td><td>O((n+ m)²)</td></tr><tr><td>TokenGT (Lap)</td><td>48.5M</td><td>0.0910</td><td>0.0919</td><td>O((n+m)²)</td></tr><tr><td>TokenGT(Lap)+Performer</td><td>48.5M</td><td>0.0935</td><td>N/A</td><td>O(n+m)</td></tr><tr><td colspan="3">TokenGT (ORF) 4</td><td colspan="2">TokenGT (Lap) . · .</td></tr><tr><td>(irr grretesertrttteertrs 3 OD 8 2 · . : : 1 + 0 .</td><td>O Head 1 . Head 32 . 5 10 Network depth (layer)</td><td>4 (irr erretsrt rtrtttineerls 3 + 2 . + 0 . 0</td><td>. + O I O COn CD C . .00 CICI 0 . . . . : . . + ·· . Head 32 . :</td><td>. Head 1</td></tr></table>
192
+
193
+ Non-orthogonal random embeddings lead to inaccurate approximation (Random, $\textcircled{)}$ ), highlighting the importance of orthogonality of node identifiers. The approximation is also inaccurate when we sample ORF $\mathbf { P } _ { t }$ independently for each token $t$ (ORF (first-order), $\bigcirc$ ) instead of using concatenated node identifiers $[ \mathbf { P } _ { u } , \mathbf { P } _ { v } ]$ for token $( u , v )$ . This supports our argument in Section 2 that the incidence information implicitly provided via node identifiers plays a key role in approximation.
194
+
195
+ In Figure 2, we provide a visualization of self-attention maps learned under various node and type identifier choices. Additional results can be found in Appendix A.4.1.
196
+
197
+ # 5.2 Large-Scale Graph Learning
198
+
199
+ An exclusive characteristic of TokenGT is its minimal graph-specific inductive bias, which requires it to learn internal computation structure largely from data. As such models are commonly known to work well with large-scale data [68, 18], we explore the capability of TokenGT on the PCQM4Mv2 quantum chemistry regression dataset [27], one of the current largest with $3 . 7 \mathbf { M }$ molecular graphs.
200
+
201
+ For TokenGT, we use both node and type identifiers, and use main Transformer encoder configuration based on Graphormer [78] with 12 layers, 768 hidden dimension, and 32 attention heads. We try both ORF and Laplacian eigenvector as node identifiers, and denote corresponding models as TokenGT (ORF) and TokenGT (Lap) respectively. As an ablation, we also experiment with the same Transformer without node and type identifiers, which we denote as Transformer. Finally, we apply the kernel attention [11] that approximates the attention computation to linear cost (TokenGT (Lap) $^ +$ Performer). We use AdamW optimizer with $( \beta _ { 1 } , \beta _ { 2 } ) = \mathsf { \bar { ( 0 . 9 9 , 0 . 9 9 9 ) } }$ and weight decay 0.1, and 60k learning rate warmup steps followed by linear decay over 1M iteration with batch size 1024. For fine-tuning, we use 1k warmup, 0.1M training steps, and cosine learning rate decay. We train the models on 8 RTX 3090 GPUs for 3 days. Further details are in Appendix A.3.3.
202
+
203
+ We provide the results in Table 2. A standard Transformer on the node and edge tokens cannot recognize graph structure and shows low performance (0.2340 valid MAE). Yet, the picture changes as soon as we augment the tokens with node and type identifiers. Notably, TokenGT (ORF) achieves $0 . 0 9 6 2 \mathrm { M A E }$ , which is already better than all GNN baselines. This is a somewhat surprising result, as both ORF and the Transformer are not aware of graph structures. This implies Transformer is strong enough to learn to interpret and reason over the incidence structure of tokens provided only implicitly by the node and type identifiers. By further switching to Laplacian eigenvectors that encode position on graphs [20], we observe a performance boost to $0 . 0 9 1 0 ~ \mathrm { M A E }$ , competitive to Transformers with sophisticated graph-specific modifications (e.g., shortest path-based spatial encoding [78]). While such methods inject graph structure into attention matrix via bias term and therefore strictly require $\mathcal { O } ( n ^ { 2 } )$ cost, TokenGT enables adopting kernelization for pure self-attention [11], resulting in TokenGT (Lap) $^ +$ Performer with the best performance among ${ \mathcal { O } } ( n + m )$ models (0.0935 MAE). Further discussion on the empirical performance of TokenGT can be found in Appendix A.5.
204
+
205
+ While our theory in Section 3 guarantees that TokenGT can reduce to an equivariant layer by learning fixed equivariant basis at each attention head, in practice, it can freely utilize multihead self-attention to learn less restricted and more useful computation structure from data. To analyze such a structure, we compute the attention distance across heads and network depth by averaging pairwise token distances on a graph weighted by their attention scores (Figure 3). This distance is analogous to the number of hops in message-passing. In both TokenGT (ORF) and TokenGT (Lap), in the lowest layers, some heads attend globally over the graph while others consistently have small receptive fields (acting like a local message-passing operator). In deeper layers, the attention distances increase, and most heads attend globally. Interestingly, this behavior is highly consistent with Vision Transformers on image patches [18], suggesting that hybrid architectures based on convolution to aid ViT [16, 80] might also work well for graphs. While TokenGT (ORF) shows relatively consistent attention distance over heads, TokenGT (Lap) shows higher variance, implying that it learns more diverse attention patterns. Judging from the higher performance of TokenGT (Lap), this suggests that the graph structure information of the Laplacian eigenvector facilitates learning useful and diverse attention structures, which calls for future exploration of better node identifiers based on graph PEs [38, 42].
206
+
207
+ # 6 Conclusion
208
+
209
+ We showed that Transformers directly applied to graphs can work well in both theory and practice. In the theoretical aspect, we proved that with appropriate token-wise embeddings, a Transformer on node and edge tokens is at least as expressive as $k$ -IGN and $k$ -WL test, making it more expressive than all message-passing GNNs. For such token-wise embeddings, we showed that a combination of simple orthonormal node identifiers and trainable type identifiers suffices, which we also verified with a synthetic experiment. In an experiment with PCQM4Mv2 large-scale dataset, we show that Tokenized Graph Transformer (TokenGT) performs significantly better than all GNNs and is competitive with Transformer variants with strong graph-specific architectural components [78, 29, 54].
210
+
211
+ While the results suggest a promising research direction, there are challenges to be addressed in future work. First, treating each node and edge as tokens requires $O ( ( n + m ) ^ { 2 } )$ asymptotic cost due to the quadratic nature of self-attention. While we address this to some degree with kernelization and achieve $O ( n + m )$ cost, other types of efficient Transformers (e.g., sparse) that can deliver better performance are left to be tested. Another issue is slightly lower performance compared to the stateof-the-art. Adopting Transformer engineering techniques from vision and language domains, such as data scaling [7, 18], deepening [70, 74], hybrid architectures [16, 80], and self-supervision [17, 7, 24], are promising. In the societal aspect, to prevent the potential risky behavior in, e.g., decision making from graph-structured inputs, interpretability research regarding self-attention on graphs is desired.
212
+
213
+ We finish with interesting research directions that stem from our work. As our approach advocates viewing a graph as $( n + m )$ tokens [37], it opens up new paradigms of graph learning, including autoregressive decoding, in-context learning, prompting, and multimodal learning. Another interesting direction is to extend our theory and use self-attention to approximate equivariant basis for general discrete group actions, which might be a viable approach for learning equivariance from data.
214
+
215
+ Acknowledgement This work was supported in part by Institute of Information & communications Technology Planning & Evaluation (IITP) (No. 2022-0-00926, 2022-0-00959, 2021-0-02068, and 2019-0-00075) and the National Research Foundation of Korea (NRF) (No. 2021R1C1C1012540) grants funded by the Korea government (MSIT).
216
+
217
+ # References
218
+
219
+ [2] A.-L. Barabasi and R. Albert. Emergence of scaling in random networks. arXiv, 1999. (Cited on 10)
220
+ [3] S. Bhattamishra, A. Patel, and N. Goyal. On the computational power of transformers and its implications in sequence modeling. In CoNLL, 2020. (Cited on 7)
221
+ [4] S. Bhojanapalli, C. Yun, A. S. Rawat, S. J. Reddi, and S. Kumar. Low-rank bottleneck in multi-head attention models. In ICML, 2020. (Cited on 7)
222
+ [5] S. Brody, U. Alon, and E. Yahav. How attentive are graph attention networks? In ICLR, 2022. (Cited on 11)
223
+ [6] M. M. Bronstein, J. Bruna, Y. LeCun, A. Szlam, and P. Vandergheynst. Geometric deep learning: Going beyond euclidean data. IEEE Signal Process. Mag., 2017. (Cited on 7)
224
+ [7] 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. (Cited on 1, 7, 10)
225
+ [8] C. Cai and Y. Wang. A note on over-smoothing for graph neural networks. arXiv, 2020. (Cited on 1, 7)
226
+ [9] L. Chen, K. Lu, A. Rajeswaran, K. Lee, A. Grover, M. Laskin, P. Abbeel, A. Srinivas, and I. Mordatch. Decision transformer: Reinforcement learning via sequence modeling. In NeurIPS, 2021. (Cited on 1, 7)
227
+ [10] Z. Chen, L. Chen, S. Villar, and J. Bruna. Can graph neural networks count substructures? In NeurIPS, 2020. (Cited on 4)
228
+ [11] 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. (Cited on 2, 9, 10, 11)
229
+ [12] K. M. Choromanski, M. Rowland, and A. Weller. The unreasonable effectiveness of structured random orthogonal embeddings. In NeurIPS, 2017. (Cited on 3, 10)
230
+ [13] T. Cohen and M. Welling. Group equivariant convolutional networks. In ICML, 2016. (Cited on 7)
231
+ [14] T. S. Cohen and M. Welling. Steerable cnns. In ICLR, 2017. (Cited on 7)
232
+ [15] J. Cordonnier, A. Loukas, and M. Jaggi. On the relationship between self-attention and convolutional layers. In ICLR, 2020. (Cited on 7)
233
+ [16] Z. Dai, H. Liu, Q. V. Le, and M. Tan. Coatnet: Marrying convolution and attention for all data sizes. In NeurIPS, 2021. (Cited on 10)
234
+ [17] J. Devlin, M. Chang, K. Lee, and K. Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT, 2019. (Cited on 1, 2, 3, 4, 7, 10)
235
+ [18] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit, and N. Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021. (Cited on 1, 2, 3, 4, 7, 9, 10)
236
+ [19] V. P. Dwivedi and X. Bresson. A generalization of transformer networks to graphs. arXiv, 2020. (Cited on 1, 7)
237
+ [20] V. P. Dwivedi, C. K. Joshi, T. Laurent, Y. Bengio, and X. Bresson. Benchmarking graph neural networks. arXiv, 2020. (Cited on 3, 7, 10, 14)
238
+ [21] J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals, and G. E. Dahl. Neural message passing for quantum chemistry. In ICML, 2017. (Cited on 2, 4, 6)
239
+ [22] A. N. Gorban, I. Y. Tyukin, D. V. Prokhorov, and K. I. Sofeikov. Approximation with random bases: Pro et contra. Inf. Sci., 2016. (Cited on 14)
240
+ [23] B. Hanin and M. Sellke. Approximating continuous functions by relu nets of minimal width. arXiv, 2017. (Cited on 1, 7)
241
+ [24] K. He, X. Chen, S. Xie, Y. Li, P. Dollár, and R. B. Girshick. Masked autoencoders are scalable vision learners. arXiv, 2021. (Cited on 10)
242
+ [25] D. Hendrycks and K. Gimpel. Gaussian error linear units (gelus). arXiv, 2018. (Cited on 11)
243
+ [26] K. Hornik, M. B. Stinchcombe, and H. White. Multilayer feedforward networks are universal approximators. Neural Networks, 1989. (Cited on 7)
244
+ [27] W. Hu, M. Fey, H. Ren, M. Nakata, Y. Dong, and J. Leskovec. OGB-LSC: A large-scale challenge for machine learning on graphs. arXiv, 2021. (Cited on 2, 7, 9, 11)
245
+ [28] G. Huang, Y. Sun, Z. Liu, D. Sedra, and K. Q. Weinberger. Deep networks with stochastic depth. In ECCV, 2016. (Cited on 11)
246
+ [29] M. S. Hussain, M. J. Zaki, and D. Subramanian. Edge-augmented graph transformers: Global self-attention is enough for graphs. arXiv, 2021. (Cited on 1, 2, 7, 9, 10)
247
+ [30] A. Jaegle, S. Borgeaud, J. Alayrac, C. Doersch, C. Ionescu, D. Ding, S. Koppula, D. Zoran, A. Brock, E. Shelhamer, O. J. Hénaff, M. M. Botvinick, A. Zisserman, O. Vinyals, and J. Carreira. Perceiver IO: A general architecture for structured inputs & outputs. arXiv, 2021. (Cited on 1, 7, 9)
248
+ [31] A. Jaegle, F. Gimeno, A. Brock, O. Vinyals, A. Zisserman, and J. Carreira. Perceiver: General perception with iterative attention. In ICML, 2021. (Cited on 1, 7, 9)
249
+ [32] A. Katharopoulos, A. Vyas, N. Pappas, and F. Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In ICML, 2020. (Cited on 9)
250
+ [33] N. Keriven and G. Peyré. Universal invariant and equivariant graph neural networks. In NeurIPS, 2019. (Cited on 15)
251
+ [34] J. Kim, S. Oh, and S. Hong. Transformers generalize deepsets and can be extended to graphs and hypergraphs. In NeurIPS, 2021. (Cited on 1, 2, 4, 6, 7, 15)
252
+ [35] D. P. Kingma and J. Ba. Adam: A method for stochastic optimization. In ICLR, 2015. (Cited on 14)
253
+ [36] T. N. Kipf and M. Welling. Semi-supervised classification with graph convolutional networks. In ICLR, 2017. (Cited on 14)
254
+ [37] Z. Kolter, S. Bai, D. Wilmott, M. Kornbluth, and J. Mailoa. First place solution of 2019 champs predicting molecular properties challenge. https://www.kaggle.com/c/champs-scalar-coupling/ discussion/106575, 2019. (Cited on 10)
255
+ [38] D. Kreuzer, D. Beaini, W. L. Hamilton, V. Létourneau, and P. Tossou. Rethinking graph transformers with spectral attention. NeurIPS, 2021. (Cited on 7, 10, 9, 14)
256
+ [39] J. Lee, Y. Lee, J. Kim, A. R. Kosiorek, S. Choi, and Y. W. Teh. Set transformer: A framework for attention-based permutation-invariant neural networks. In ICML, 2019. (Cited on 7, 9)
257
+ [40] Q. Li, Z. Han, and X. Wu. Deeper insights into graph convolutional networks for semi-supervised learning. In AAAI, 2018. (Cited on 1, 7)
258
+ [41] V. Likhosherstov, K. Choromanski, and A. Weller. On the expressive power of self-attention matrices. arXiv, 2021. (Cited on 7)
259
+ [42] D. Lim, J. Robinson, L. Zhao, T. E. Smidt, S. Sra, H. Maron, and S. Jegelka. Sign and basis invariant networks for spectral graph representation learning. arXiv, 2022. (Cited on 7, 10, 14)
260
+ [43] K. Lin, L. Wang, and Z. Liu. Mesh graphormer. In ICCV, 2021. (Cited on 1, 7)
261
+ [44] I. Loshchilov and F. Hutter. Decoupled weight decay regularization. In ICLR, 2019. (Cited on 11)
262
+ [45] X. Ma, X. Kong, S. Wang, C. Zhou, J. May, H. Ma, and L. Zettlemoyer. Luna: Linear unified nested attention. NeurIPS, 2021. (Cited on 9)
263
+ [46] H. Maron, H. Ben-Hamu, H. Serviansky, and Y. Lipman. Provably powerful graph networks. In NeurIPS, 2019. (Cited on 2, 4, 6, 1, 15)
264
+ [47] H. Maron, H. Ben-Hamu, N. Shamir, and Y. Lipman. Invariant and equivariant graph networks. In ICLR, 2019. (Cited on 2, 4, 5, 6, 7, 1, 15)
265
+ [48] H. Maron, E. Fetaya, N. Segol, and Y. Lipman. On the universality of invariant networks. In ICML, 2019. (Cited on 4, 15)
266
+ [49] H. Maron, O. Litany, G. Chechik, and E. Fetaya. On learning sets of symmetric elements. In ICML, 2020. (Cited on 7)
267
+ [50] E. Min, R. Chen, Y. Bian, T. Xu, K. Zhao, W. Huang, P. Zhao, J. Huang, S. Ananiadou, and Y. Rong. Transformer for graphs: An overview from architecture perspective. arXiv, 2022. (Cited on 1, 7)
268
+ [51] D. Q. Nguyen, T. D. Nguyen, and D. Phung. Universal graph transformer self-attention networks. In WWW, 2022. (Cited on 1, 7)
269
+ [52] K. Oono and T. Suzuki. Graph neural networks exponentially lose expressive power for node classification. In ICLR, 2020. (Cited on 1, 7)
270
+ [53] H. Pan and R. Kondor. Permutation equivariant layers for higher order interactions. In AISTATS, 2022. (Cited on 7)
271
+ [54] W. Park, W. Chang, D. Lee, J. Kim, and S. won Hwang. Grpe: Relative positional encoding for graph transformer. arXiv, 2022. (Cited on 1, 2, 7, 9, 10)
272
+ [55] H. Peng, N. Pappas, D. Yogatama, R. Schwartz, N. A. Smith, and L. Kong. Random feature attention. In ICLR, 2021. (Cited on 9)
273
+
274
+ (Cited on 7) [57] S. Reed, K. Zolna, E. Parisotto, S. G. Colmenarejo, A. Novikov, G. Barth-Maron, M. Giménez, Y. Sulsky, ˙ J. Kay, J. T. Springenberg, T. Eccles, J. Bruce, A. Razavi, A. Edwards, N. Heess, Y. Chen, R. Hadsell, O. Vinyals, M. Bordbar, and N. de Freitas. A generalist agent. arXiv, 2022. (Cited on 1) [58] Y. Rong, Y. Bian, T. Xu, W. Xie, Y. Wei, W. Huang, and J. Huang. Self-supervised graph transformer on large-scale molecular data. In NeurIPS, 2020. (Cited on 1, 7) [59] B. Rozemberczki, C. Allen, and R. Sarkar. Multi-scale attributed node embedding. J. Complex Networks, 2021. (Cited on 13) [60] H. Serviansky, N. Segol, J. Shlomi, K. Cranmer, E. Gross, H. Maron, and Y. Lipman. Set2graph: Learning graphs from sets. In NeurIPS, 2020. (Cited on 7, 15) [61] O. Shchur, M. Mumme, A. Bojchevski, and S. Günnemann. Pitfalls of graph neural network evaluation. arXiv, 2018. (Cited on 13) [62] Z. Shen, M. Zhang, H. Zhao, S. Yi, and H. Li. Efficient attention: Attention with linear complexities. In WACV, 2021. (Cited on 9) [63] Y. Shi, S. Zheng, G. Ke, Y. Shen, J. You, J. He, S. Luo, C. Liu, D. He, and T. Liu. Benchmarking graphormer on large-scale molecular modeling datasets. arXiv, 2022. (Cited on 9) [64] A. Steiner, A. Kolesnikov, X. Zhai, R. Wightman, J. Uszkoreit, and L. Beyer. How to train your vit? data, augmentation, and regularization in vision transformers. arXiv, 2021. (Cited on 11) [65] Y. Tay, M. Dehghani, D. Bahri, and D. Metzler. Efficient transformers: A survey. arXiv, 2020. (Cited on 1) [66] N. Thomas, T. E. Smidt, S. Kearnes, L. Yang, L. Li, K. Kohlhoff, and P. Riley. Tensor field networks: Rotation- and translation-equivariant neural networks for 3d point clouds. arXiv, 2018. (Cited on 7) [67] J. Tompson, R. Goroshin, A. Jain, Y. LeCun, and C. Bregler. Efficient object localization using convolutional networks. In CVPR, 2015. (Cited on 10) [68] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin. Attention is all you need. In NeurIPS, 2017. (Cited on 1, 3, 9) [69] P. Velickovic, G. Cucurull, A. Casanova, A. Romero, P. Liò, and Y. Bengio. Graph attention networks. In ICLR, 2018. (Cited on 1, 7, 11, 14) [70] H. Wang, S. Ma, L. Dong, S. Huang, D. Zhang, and F. Wei. Deepnet: Scaling transformers to 1, 000 layers. arXiv, 2022. (Cited on 10) [71] S. Wang, B. Z. Li, M. Khabsa, H. Fang, and H. Ma. Linformer: Self-attention with linear complexity. arXiv, 2020. (Cited on 9) [72] X. Wang, Z. Tu, L. Wang, and S. Shi. Self-attention with structural position representations. In EMNLPIJCNLP, 2019. (Cited on 1) [73] M. Weiler, M. Geiger, M. Welling, W. Boomsma, and T. Cohen. 3d steerable cnns: Learning rotationally equivariant features in volumetric data. In NeurIPS, 2018. (Cited on 7) [74] N. Wies, Y. Levine, D. Jannai, and A. Shashua. Which transformer architecture fits my data? A vocabulary bottleneck in self-attention. In ICML, 2021. (Cited on 10) [75] R. Xiong, Y. Yang, D. He, K. Zheng, S. Zheng, C. Xing, H. Zhang, Y. Lan, L. Wang, and T. Liu. On layer normalization in the transformer architecture. In ICML, 2020. (Cited on 11) [76] Y. Xiong, Z. Zeng, R. Chakraborty, M. Tan, G. Fung, Y. Li, and V. Singh. Nyströmformer: A nyström-based algorithm for approximating self-attention. In AAAI, 2021. (Cited on 9) [77] K. Xu, W. Hu, J. Leskovec, and S. Jegelka. How powerful are graph neural networks? In ICLR, 2019. (Cited on 7, 14) [78] C. Ying, T. Cai, S. Luo, S. Zheng, G. Ke, D. He, Y. Shen, and T. Liu. Do transformers really perform bad for graph representation? In NeurIPS, 2021. (Cited on 1, 2, 7, 9, 10, 11, 14) [79] F. X. Yu, A. T. Suresh, K. M. Choromanski, D. N. Holtmann-Rice, and S. Kumar. Orthogonal random features. In NeurIPS, 2016. (Cited on 3, 10) [80] K. Yuan, S. Guo, Z. Liu, A. Zhou, F. Yu, and W. Wu. Incorporating convolution designs into visual transformers. In ICCV, 2021. (Cited on 10) [81] C. Yun, S. Bhojanapalli, A. S. Rawat, S. J. Reddi, and S. Kumar. Are transformers universal approximators of sequence-to-sequence functions? In ICLR, 2020. (Cited on 7, 1) [82] M. Zaheer, S. Kottur, S. Ravanbakhsh, B. Póczos, R. Salakhutdinov, and A. J. Smola. Deep sets. In NeurIPS, 2017. (Cited on 7) [83] M. Zopf. 1-wl expressiveness is (almost) all you need. arXiv, 2022. (Cited on 2)
275
+
276
+ # Checklist
277
+
278
+ 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:
279
+
280
+ • Did you include the license to the code and datasets? [Yes] See Section 5.
281
+ • Did you include the license to the code and datasets? [No] The code and the data are proprietary.
282
+ • Did you include the license to the code and datasets? [N/A]
283
+
284
+ 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.
285
+
286
+ 1. For all authors...
287
+
288
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 3 and Section 5.
289
+ (b) Did you describe the limitations of your work? [Yes] See Section 6.
290
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 6.
291
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
292
+
293
+ 2. If you are including theoretical results...
294
+
295
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 3. (b) Did you include complete proofs of all theoretical results? [Yes] We include them in the supplementary file.
296
+
297
+ 3. If you ran experiments...
298
+
299
+ (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 include them in the supplementary file.
300
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.
301
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Section 5.
302
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 5.
303
+
304
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
305
+
306
+ (a) If your work uses existing assets, did you cite the creators? [Yes] See Section 5.2.
307
+ (b) Did you mention the license of the assets? [Yes] See Section 5.2.
308
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We include them in the supplementary file.
309
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
310
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
311
+
312
+ 5. If you used crowdsourcing or conducted research with human subjects...
313
+
314
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
315
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
316
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/unb1wyXf-aC/unb1wyXf-aC.md ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Concurrent 3D super resolution on intensity and segmentation maps improves detection of structural effects in neurodegenerative disease
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 We propose a new perceptual super resolution (PSR) method for 3D neuroimaging
11
+ 2 and evaluate its performance in detecting brain changes due to neurodegenerative
12
+ 3 disease. The method, concurrent super resolution and segmentation (CSRS), is
13
+ 4 trained on volumetric brain data to consistently upsample both an image intensity
14
+ 5 channel and associated segmentation labels. The simultaneous nature of the method
15
+ 6 improves not only the resolution of the images but also the resolution of associated
16
+ 7 segmentations thereby making the approach directly applicable to existing labeled
17
+ 8 datasets. One challenge to real world evaluation of SR methods such as CSRS
18
+ 9 is the lack of high resolution ground truth in the target application data: clinical
19
+ 10 neuroimages. We therefore evaluate CSRS effectiveness in an adjacent, clinically
20
+ 11 relevant signal detection problem: quantifying cross-sectional and longitudinal
21
+ 12 change across a set of phenotypically heterogeneous but related disorders that
22
+ 13 exhibit known and differentiable patterns of brain atrophy. We contrast several 3D
23
+ 14 PSR loss functions in this paradigm and show that CSRS consistently increases the
24
+ 15 ability to detect regional atrophy both longitudinally and cross-sectionally in each
25
+ 16 of five related diseases.
26
+
27
+ # 17 1 Introduction
28
+
29
+ 18 Magnetic resonance image (MRI) datasets capturing in vivo longitudinal change in the human brain
30
+ 19 are currently available at unprecedented scale. These data allow us to quantify the complex etiology
31
+ 20 of neurodegenerative disease during life. A fundamental problem in quantifying brain disorders
32
+ 21 from imaging is that many anatomical structures are small in comparison to image resolution. This
33
+ 22 is caused by not only limited image resolution but also the potentially convoluted shape of the
34
+ 23 targeted anatomy [1]. Thinner, more oblate and/or curved structures undergo more distortion due
35
+ 24 to sampling-related aliasing in comparison to larger, more spherical structures. These distortions
36
+ 25 can limit detection power in the context of either clinical trials and/or at the level of patient specific
37
+ 26 medicine [2, 3]. These results also show that, based on first principles, many disease relevant
38
+ 27 anatomical structures in the brain, in particular cortical regions, mid-brain regions and hippocampal
39
+ 28 subfields, should be quantified at higher resolutions (e.g. $\approx 0 . 5 \mathrm { m m ^ { 3 } }$ or smaller rather than the
40
+ 29 more commonly available $\approx 1 \mathrm { m m ^ { 3 } }$ ). The need for increased resolution is only heightened when
41
+ 30 considering aging and neurodegeneration where some brain structures may lose half or more of their
42
+ 31 pre-disease onset volume or thickness.
43
+ 32 Perceptual super resolution (PSR) for 2D RGB imagery consistently demonstrates the ability to
44
+ 33 estimate more “realistic” looking upsampled data in comparison to traditional linear or nearest
45
+ 34 neighbor interpolants [4]. While many competitive methods are available, the deep back projection
46
+ 35 network (DBPN) [5] performed consistently in several competitions including NTIRE 2018 and 2019
47
+
48
+ [6], AIM 2019 [7] and PIRM 2018 [8]). These large challenges compared dozens of methods with respect to a variety of both perceptual and reconstruction metrics at different levels of upsampling and noise.
49
+
50
+ 39 Can the 2D RGB performance advantages of methods like the DBPN translate to improvements in
51
+ 40 the 3D quantification of brain regions as seen in MRI? If so, then PSR for 3D neuroimaging promises
52
+ 41 to improve quantification by better resolving the brain’s internal structures and tissue boundaries.
53
+ 42 While traditional evaluations of PSR focus on reconstruction error and perceptual impression, these
54
+ 43 measurements do not provide clinically relevant evidence of PSR’s value in quantification. One barrier
55
+ 44 to evaluating PSR’s impact on clinically relevant outcomes (segmentation volumes) is that ground
56
+ 45 truth segmentations do not exist at the super-resolved scale. To address this concern, [9] simulated low
57
+ 46 resolution magnetic resonance images (MRI) of the brain from high-resolution (HR) images obtained
58
+ 47 from the Human Connectome Project [10, 11]. They then applied a very deep super resolution
59
+ 48 (VDSR) model to the simulated data and the high-resolution data and compared the accuracy of an
60
+ 49 automated cortical segmentation method. This careful evaluation study demonstrated that cortical
61
+ 50 segmentation on the VDSR images closely approximated the HR data. However, relatively few
62
+ 51 details are provided about the training of this model and associated loss functions. Furthermore, it
63
+ 52 remains unclear whether these improvements in reconstruction error would translate to the detection
64
+ 53 of population-level effects in real world data particularly in the aging populations that are the target
65
+ 54 of the majority of interventional trials for the brain.
66
+ 55 A more recent effort in volumetric PSR for medical images [12] proposed SOUP-GAN: Super
67
+ 56 resolution Optimized Using Perceptual-tuned Generative Adversarial Network (GAN). SOUP-GAN
68
+ 57 adopts transfer learning from 2D VGG19 to 3D as proposed in [13] to produce a pseudo-volumetric
69
+ 58 perceptual metric [14]. Shan et al. used this metric to denoise low-dose computed tomography
70
+ 59 (CT) images and showed its effectiveness at preserving small anatomical structures. Similarly, the
71
+ 60 SOUP-GAN effort demonstrates that the pseudo-3D perceptual metric improves both PSNR and
72
+ 61 SSIM as well as shows visually appealing upsampling for a variety of medical imaging modalities.
73
+ 62 That is, the surprising utility (in 2D) of VGG weights as a feature space [15] appears to at least
74
+ 63 partially transfer to PSR in 3D medical imaging.
75
+ 64 The current research provides perhaps the first broadly scoped, real world evaluation of MRI PSR for
76
+ 65 quantification of neurodegenerative disease. Moreover, we demonstrate that a regression network
77
+ 66 (ResNet) that predicts T1w image quality can yield a directly useful perceptual feature space that
78
+ 67 performs competitively with pseudo-3D VGG19 features. We build these contributions upon the
79
+ 68 backbone of a set of methods that we call concurrent super resolution and segmentation (CSRS) that
80
+ 69 extends the proven 2D DBPN to 3D and also includes extra output channel(s) enabling segmentation
81
+ 70 maps to be upsampled concurrently. We use this framework to test the impact of different loss
82
+ 71 functions on a set of domain-specific, clinically relevant segmentation measurements related to
83
+ 72 brain atrophy. Specifically, we evaluate CSRS on the quantification of frontotemporal disorders [3]
84
+ 73 from publicly available longitudinal T1-weighted (T1w) neuroimaging (i.e. MRI). Of the several
85
+ 74 combinations of losses that we evaluate, the best model improves not only segmentation performance
86
+ 75 (when ground truth is available) but also detection power across all our related disorders: structural
87
+ 76 changes in behavioral variant frontotemporal dementia (bvFTD), semantic variant primary progressive
88
+ 77 aphasia (svPPA), nonfluent/agrammatic PPA (naPPA), progressive supranuclear palsy (PSP) and
89
+ 78 corticobasal syndrome (CBS) each of which impacts known networks in the brain. CSRS with a new
90
+ 79 perceptual loss based on a shallow ResNet layer performs as well or better than VGG-based models
91
+ 80 in this test of the practical usefulness of PSR.
92
+
93
+ 81 The primary contributions of this work include:
94
+
95
+ • new PSR that upsamples multi-label segmentations at the same time as intensity; • a new real world evaluation paradigm for PSR in neuroimaging; • comparison of three perceptual loss functions for PSR, two of which are new; • demonstration that loss choice impacts detection power in natural history studies of neurodegenerative disease. Standard intensity similarity and segmentation overlap metrics, on the other hand, do not discriminate performance between the candidate CSRS options.
96
+
97
+ 88 Model weights, sample data, and training code will be made publicly available after anonymous
98
+ 89 review.
99
+ 91 Software platform: We employ the ANTsX platform [16] version 2.3.5 for anatomical labeling,
100
+ 92 data augmentation/sampling during model training and to form the tabular data for the statistical
101
+ 93 evaluation. All MRI processing details follow [16]. Tensorflow 2.6.2 is used for deep learning
102
+ 94 including a ResNet implementation and the CSRS architecture. R version 4.1 is used for statistical
103
+ 95 analysis with packages lmer and ggplot2. All MRI processing was done on Amazon Web Services
104
+ 96 parallel cluster with 24 cores and 32GB RAM per process (Intel(R) Xeon(R) Platinum 8259CL
105
+ 97 CPU $\ @ \ 2 . 5 0 \mathrm { G H z }$ ).
106
+ 98 Data: Human Connectome Project (HCP): We downloaded 1,113 high-resolution $0 . 7 \mathrm { m m ^ { 3 } }$ T1-
107
+ 99 weighted images from the HCP on which to train CSRS. These T1w data were acquired using a
108
+ 100 magnetization-prepared rapid gradient-echo (MPRAGE) sequence on a customized 3T Siemens
109
+ 101 Skyra; see [10] for all details of acquisition. As such, these images provide both high resolution and
110
+ 102 high quality in comparison to the majority of publicly available T1w MRI. Critically, they provide
111
+ 103 superior resolution for the thin convoluted cortical layer that is critical to the measurement of brain
112
+ 104 atrophy in frontotemporal disorders. We transformed these data into numpy blocks with randomly
113
+ 105 selected high-resolution $6 4 ^ { 3 }$ patches and paired low-resolution $3 2 ^ { 3 }$ patches. For each patch pair, we
114
+ 106 also provide a high-resolution binary segmentation and a low-resolution downsampled version of
115
+ 107 that binary segmentation. Each patch segmentation was gained by 2-class $\mathbf { k }$ -means performed on
116
+ 108 the patch where the center voxel’s label determines which class (1 or 2) is used as foreground. This
117
+ 109 collection of 16,640 patches is then divided randomly into train $\scriptstyle \mathrm { n = 1 6 } , 3 8 4 ,$ ) and test sets.
118
+ 110 Data: Parkinson’s Progression Markers Initiative (PPMI): PPMI is a longitudinal multi-center
119
+ 111 clinical study of PD patients and age-matched healthy controls http://www.ppmi-info.org.
120
+ 112 PPMI employed(s) over 20 data collection sites with scanners that span the primary manufacturers
121
+ 113 (Siemens, GE, Phillips), a variety of head coils and also magnet strengths (1.5T, 3T). This heterogene
122
+ 114 ity of data collection provides a rich set of T1w images with highly variable image contrast, resolution
123
+ 115 and quality. We manually reviewed and labelled 1,431 raw T1w from PPMI to capture the range of
124
+ 116 quality in an ordinal scale. This resulted in a ground truth dataset with 456 images given grade “A”
125
+ 117 (superior), 568 given grade “B”, 350 given grade “C” and 57 given grade “F” which represents images
126
+ 118 that are of little to no use for quantitative studies of brain structure. We then employed a standard
127
+ 119 3D ResNet (antspynet.create_resnet_model_3d with parameters lowest_resolution $^ { \mathtt { = 3 2 } }$ ,
128
+ 120 number_of_classification_label $\mathtt { s } { = } 4$ , cardinality ${ \tt = } 1$ , 39,424,004 parameters, 53 3D convo
129
+ 121 lutional layers) to learn to predict this scale automatically and reliably from the input T1w. We denote
130
+ 122 this network as a T1w Quality Rating Resnet (T1wQRResNet). Details of training T1wQRResNet
131
+ 123 are in Supplementary Information.
132
+ 124 Data: Frontotemporal Lobar Degeneration Neuroimaging Initiative (NIFD) & 4-Repeat
133
+ 125 Tauopathy Neuroimaging Initiative (4RTNI): These inter-related multi-site studies share the goal
134
+ 126 of improving the quantification of frontotemporal spectrum disorders with both imaging and clinical
135
+ 127 scores. Like PPMI and HCP, these studies provide longitudinal T1w images that enable measurement
136
+ 128 of not only the baseline brain structure differences between controls (individuals without a disease
137
+ 129 i.e. normal aging) and disease groups but also differences in rates of change due to neurodegeneration.
138
+ 130 We downloaded and curated 4RTNI and NIFD T1w data and merged these images into a common
139
+ 131 database. These images were collected at three different sites using protocols consistent with ADNI
140
+ 132 3T guidelines [2]. The images overall have a median spacing that is isotropically $1 \mathrm { m m }$ with a minority
141
+ 133 of subjects with out-of-plane spacing up to $1 . 2 \mathrm { m m }$ . As such, these data suit the goals of testing PSR
142
+ 134 for benefits to the quantification of neurodegenerative disease. After filtering data for very low quality
143
+ 135 images and the presence of longitudinal data collected within 2 years of baseline, we obtained 128
144
+ 136 baseline/171 followup images for controls, 60/112 for bvFTD, 38/72 for naPPA, 37/71 for svPPA,
145
+ 137 55/70 for CBS and 75/102 for PSP. Further cohort details (age, education, sex, etc) are available in
146
+ 138 supplementary information. We processed all images consistently and automatically with default
147
+ 139 ANTsX pipelines to gain cortical, medial temporal lobe and deep brain structure segmentations for
148
+ 140 every subject as described in [16]. By consensus, co-authors selected a priori regions for testing
149
+ 141 within each of four groups CBS/PSP [17], bvFTD, svPPA and naPPA [18–24]. Details of the regions
150
+ 142 and rationale for their selection are available in the Supplementary Information. See Figure 1 for an
151
+ 143 overview of processing, the CSRS method and a visualization of the regions (1.C).
152
+
153
+ ![](images/4b5c9141c17579e01bca0f86e4338eef20afa5551c25144ea159f8bda44a630f.jpg)
154
+ Figure 1: (A) Image processing begins with raw MRI, extracts the brain, labels cortical regions, labels medial temporal lobe regions and labels deep brain regions. (B) The CSRS method is used, here, to upsample data by a factor of 2 isotropically; the sketch of the algorithm provides an example of how two nearby regions would flow through the method and be stitched back together at high resolution. (C) The impact of SR on quantifying neurodegeneration is assessed on a priori regions that are specific to each clinical diagnostic group; all regions are bilateral except for svPPA which uses only left hemisphere cortical and medial temporal labels.
155
+
156
+ # 144 2.1 Concurrent super resolution and segmentation methods
157
+
158
+ 145 CSRS uses, as a sub-algorithm, a three-dimensional and multi-output version of the neural network
159
+ 146 architecture defined by the 2D deep back projection network (DBPN) [5]. The DBPN is uniquely
160
+ 147 relevant to medical imaging in that it is perhaps the first published SR method that integrates the
161
+ 148 downsampling-upsampling error (i.e. residual layers) as a feature map. This novel architecture may
162
+ 149 prevent feature hallucination and constrain the high-resolution image to maintain features that are
163
+ 150 consistent with the low-resolution input. We extend the 2D DBPN to 3D MRI data by, first, translating
164
+ 151 2D convolutions, padding, striding and other relevant parameters to 3D. To generalize the architecture
165
+ 152 further, we allow options for not only convolutional upsampling (transposed convolution) but also
166
+ 153 nearest neighbor (or linear) interpolation layers at the user’s choice. Lastly, we implement flexible
167
+ 154 choices of input channels, the number of residual layers (backprojection) layers and the number of
168
+ 155 outputs. This 3D DBPN network implementation is available within R and python. All parameters
169
+ 156 were the same as the published work [25] (though in translation to 3D) with the exception of the
170
+ 157 number of back projection layers which has a large impact on the number of parameters. We reduced
171
+ 158 the number of backprojection layers to 5 (16,264,322 parameters) due to the memory limitations
172
+ 159 caused by working with large 3D images and limited GPU resources (all GPU computations in this
173
+ 160 work were implemented with Nvidia V100s locally).
174
+ 161 Efficient computational strategy is essential for CSRS to be applied to large 3D images (a brain
175
+ 162 image may contain 10 million voxels) when CPUs and RAM are limited. As such, a local patch-work
176
+ 163 strategy is necessary. Sampling, upsampling, mapping and unification (SUMU) are the common steps
177
+ 164 needed for not only training but also inference. “Sampling” decides the form of the input data: full
178
+ 165 images (not used here), image patches (used here in training) or anatomical image regions (used here
179
+ 166 in inference). Upscaling determines the core approach to transferring the low-resolution data to a
180
+ 167 higher-resolution output. Mapping compensates for shape or intensity distortion. Finally, “unification”
181
+ 168 is an ensembling or merging step that brings together several sub-estimates of an SR image into a
182
+ 169 single joined (final/full) SR image. We detail each of the 4 components below.
183
+ 170 Sampling: We choose a patch-based model for training as these can easily be applied to input data
184
+ 171 with different resolutions and fields of view. A second reason for patch-based modeling is that a
185
+ 172 candidate network does not need to learn the full scope of image variation. This results in shallower
186
+ 173 and faster to train networks that fit more easily onto readily available GPUs. The choices made
187
+ 174 during sampling step define the feature basis set. Because prior super-resolution competitions suggest
188
+ 175 larger patches lead to better performance, we choose the largest patches that would permit efficient
189
+ 176 batch sizes of 4 (64x64x64). An additional ad hoc support for this choice is that cortical features
190
+ 177 are relatively well-resolved in sub- $1 \mathrm { m m }$ training images when voxel cubes of this sized are used.
191
+ 178 However, there is no direct evidence that this size of patch domain is optimal for this problem.
192
+ 179 Upscaling: is done with the CSRS’s DBPN architecture using nearest neighbor interpolation for
193
+ 180 the upsampling layers. The software interface to CSRS also allows the user to optionally employ
194
+ 181 standard linear (tri-linear) interpolation. We use the linear option as a reference in evaluation studies
195
+ 182 below.
196
+ 183 Mapping: may be used to compensate for distortions in the image shape or intensity space. Because
197
+ 184 each patch is scaled independently on training data (to have an intensity range of -127.5 to 127.5),
198
+ 185 the output of the PSR upsampled image intensities must be mapped back to the original quantitative
199
+ 186 space. This is performed by directly comparing the output of the PSR upsampled patch/region to the
200
+ 187 original data upsampled by nearest neighbor or linear interpolation. As such, we can accurately retain
201
+ 188 quantitative intensity data at the original scale/units with minimal distortion and/or stitching artifacts.
202
+ 189 Unification: this is a general term that, here, refers to the algorithm that is used to derive a single
203
+ 190 CSRS image and multi-label segmentation from multiple CSRS sub-images (not necessarily isotropic
204
+ 191 patches as in training). In 2D, multiple input images are typically generated from a single input by
205
+ 192 “augmentation” e.g. random flipping, translation, etc thus allowing a practitioner to gain multiple
206
+ 193 “votes” about how the SR image should appear at any given voxel. Such a step is used in most PSR
207
+ 194 competitions to reduce aliasing or artifacts and may involve averaging, sharpening or more complex
208
+ 195 modeling such as joint intensity fusion, multi-channel deep learning or other ensemble methods.
209
+ 196 Due to the high memory and computation cost of running CSRS on 3D images, we instead apply
210
+ 197 CSRS to either sub-regions of interest or, when a full T1w brain image is desired, each hemisphere.
211
+ 198 The unification step then maps each local patch intensity range back to the original MRI range and
212
+ 199 then joins the sub-regions back together to complete the SR reconstruction. Augmentation can be
213
+ 200 employed beyond this but at substantial increase in computation time (e.g. 10x to see meaningful
214
+ 201 gains due to augmentation).
215
+ 202 Loss functions for CSRS: We employ a loss function that seeks to balance reconstruction error
216
+ 203 (intensity difference, abbreviated here as R), edge preserving denoising (total variation, abbreviated
217
+ 204 as TV), perceptual quality (based on VGG or ResNet) and segmentation overlap (Dice, abbreviated
218
+ 205 as D). Each of these terms can be up or down weighted to control the network’s performance where
219
+ 206 mean squared error (L2 intensity error) leads to smoother results, L1 (or total variation) provides
220
+ 207 denoising and the perceptual loss yields more natural appearing output textures and shapes. The
221
+ 208 Dice loss term seeks to minimize distortions in the shape of segmentation objects on the output
222
+ 209 of CSRS. The Dice loss is only applied to the second output channel of the network which uses a
223
+ 210 sigmoid activation function appropriate for probabilistic/binary data. We refer to CSRS trained with
224
+ 211 specific combinations of these losses by concatenation of the abbreviations above. For example,
225
+ 212 CSRS.R.TV.D.Res6 refers to a network trained with reconstruction loss, TV regularization, Dice loss
226
+ 213 and the 6th layer of the T1wQRResNet for perceptual loss.
227
+
228
+ Recent research demonstrates that deep learning models trained on large-scale object detection reference datasets (e.g. imagenet) encode a feature space that may mimic human perception [26]. Such perceptual spaces typically arise from the activations that occur within the layers of convolutional networks trained on massive classification datasets. Here, however, we compare a standard VGG based perceptual space (block2_conv2) (mapped to 3D as described before) to those defined by the T1wQRResNet. From T1wQRResNet, we choose two different deep layers that have similar numbers of parameters to the 3D version of the VGG19 block2_conv2 network: res_conv_block_6 (the 2nd convolutional block) and res_conv_block_21 (the 7th convolutional block). This allows us to compare perceptual metrics based on either pseudo-3D VGG19 or our intrinsically 3D res_conv_block choices.
229
+
230
+ 24 Quantification of medical images requires a high degree of faithfulness to the input data. "Halluci
231
+ 25 nated" features are undesirable. As such, our baseline loss function focuses on reconstruction error
232
+ 226 and TV for both intensity and segmentation images. We then add perceptual and Dice losses for
233
+ 227 further comparison. If we denote $I$ as the estimated super-resolution, $I _ { s }$ as the estimated segmentation
234
+ 228 from the sigmoid output channel, $J$ as the real high resolution image, $J _ { s }$ as the real high resolution
235
+ 229 segmentation, then the final loss function that we optimize is:
236
+
237
+ ![](images/c1c932135400cbcabfbf50ed1c493f50e263d8d369711c3faf4f78969e9debd1.jpg)
238
+ Figure 2: Best model CSRS applied to three categories of anatomy where row (A) is the original resolution (OR) and segmentation and row (B) is the output of CSRS.R.TV.D.Res6.
239
+
240
+ $$
241
+ \begin{array} { r } { I - J \| ^ { 2 } w _ { r } ^ { i } + \| I _ { s } - J _ { s } \| ^ { 2 } w _ { r } ^ { s } + T V ( I , J ) w _ { t } ^ { i } + T V ( I _ { s } , J _ { s } ) w _ { t } ^ { s } + \| f _ { n } ( I ) - f _ { n } ( J ) \| ^ { 2 } w _ { f } + D i c e ( I _ { s } , J _ { s } ) w _ { d } } \end{array}
242
+ $$
243
+
244
+ 230 where the term $\| \cdot \|$ indicates the euclidean norm, $T V ( \cdot , \cdot )$ indicates the total variation norm (which
245
+ 231 provides denoising), $w _ { r , t , f , d }$ (superscripts for intensity or segmentation) indicates a term-specific
246
+ 232 scalar weight and $f _ { n } ( . )$ indicates a perceptual feature map. The weight terms can be tuned for
247
+ 233 performance and application area given an objective and quantitative evaluation metric. We initially
248
+ 234 manually tuned the training of a DBPN model with only the reconstruction metrics $( \| I - J \| ^ { 2 } w _ { r } ^ { I } \dot { + }$
249
+ 235 $\lVert I _ { s } - \dot { J _ { s } } \rVert ^ { 2 } w _ { r } ^ { s }$ with $w _ { r } ^ { i } = 5 e - 4$ and $w _ { r } ^ { s } = 1$ ) using adam optimizer and learning rate 5e-5. We
250
+ 236 then set weights relative to the value of the reconstruction error after convergence such that: the TV
251
+ 237 loss is roughly $2 / 3$ the reconstruction term (R); the perceptual loss is roughly $3 \mathrm { x } \ \mathrm { R }$ ; the Dice loss is
252
+ 238 roughly equivalent to the perceptual loss. This strategy, based on our task-specific goals, enables us
253
+ 239 to compare models consistently and add/subtract terms without extensive weight optimization.
254
+ 40 Computation and inference: All models were implemented with tensorflow. The computation to
255
+ 241 double magnification – for a single T1w – takes (generally on a modern computational platform)
256
+ 42 between 10 and 40 minutes. Results are computed region-wise over the set of segmentation labels
257
+ 243 where CSRS is run on each cropped label and its associated intensity. When multiple regions are
258
+ 244 used (as is done here), then results are stitched back together while using a linear mapping back
259
+ 245 to the original intensity space and a arg_max operation to define the hard segmentation labels at
260
+ 46 every voxel in the stitched, joint intensity/probability double magnification space. See Figure 2 for
261
+ 47 an example result of CSRS as applied to the variety of brain regions in this study. Figure 3 shows a
262
+ 48 zoomed visual comparison of the impact on intensity and the lack of stitching artifacts.
263
+
264
+ # 2.2 Quantification of CSRS impact on segmentation and intensity in ground truth data
265
+
266
+ Evaluation of PSR results on simulated downsampled-upsampled data does not constitute real world conditions. However, for reference, we include evaluation results based on an independent set of labeled brain images [27]. For these images, we downsample with nearest neighbor interpolation and upsample with linear interpolation (for the intensity) and a “generic label” interpolation that is designed for multi-label images [28] thereby allowing us to report standard metrics of Dice overlap, PSNR and SSIM to complement our study of brain atrophy detection. Figure 4 demonstrates example results illustrating this component of our evaluation.
267
+
268
+ ![](images/e5ad374190f490e8c5abd0d89955a3089fdac304feb8b087fbb3b132df729771.jpg)
269
+ Figure 3: Comparison of CSRS with different loss functions to original resolution and linear upsampling. The bold (panel E) is the best performing model according to quantitative criteria. However, visual differences between the perceptual models (D,E,F) are not easy to discern.
270
+
271
+ ![](images/f3b1e61e60f74e47e18322e106c4ced735805a3652dae28f93cd6626678bbe98.jpg)
272
+ Figure 4: Panel (A) shows the original $\mathrm { 1 m m ^ { 3 } }$ resolution ground truth image and its segmentation. Panel (B) shows the impact of linear/generic label upsampling of ground truth data artifically downsampled to $2 \mathrm { m m ^ { 3 } }$ . Panel (C) shows a CSRS result where other models are visually similar to this. Panel (D) demonstrates that all regions improve with CSRS (all differences $> 0$ ) and that regions with lower Dice overlap under the linear/generic label model improve more when upsampled with CSRS.
273
+
274
+ # 257 2.3 Quantification of effect sizes in frontotemporal disorder atrophy
275
+
276
+ The frontotemporal disorders produce a profound and debilitating effect on patients with concomitant, symptom-related atrophy. Measuring this atrophy is critical to detecting the effects, for instance, of disease modifying therapies that may slow atrophy. Such measurements are challenged by low resolution and this challenge is compounded by the degeneration process itself.
277
+
278
+ 262 We use statistical modeling to determine if CSRS can mitigate the known limitations of resolution on
279
+ 263 atrophy measurement. We adopt an interpretable mixed effects modeling approach (lmer)[29] to
280
+ 264 estimate effect sizes per brain region, per diagnostic category and per resolution/CSRS model. The
281
+ 265 baseline performance is determined by the effect sizes estimated on the original resolution (OR) data.
282
+ 266 We estimate effect sizes following [30, 31]. Better methods, under this design, should more reliably
283
+ 267 identify disease-related atrophy which will be reflected in increased effect sizes for a given set of $a$
284
+ 268 priori diagnosis-specific regions. The model for the region of interest $i$ $( R O I _ { i } )$ ) is:
285
+
286
+ $$
287
+ R O I _ { i } \approx A g e _ { b } + S e x + B V _ { b } + D X + \Delta T * D X + ( 1 | I D ) ,
288
+ $$
289
+
290
+ 269 with $( 1 | I D )$ representing a subject-specific random effect, $A g e _ { b }$ is the subject’s age at the first visit,
291
+ 270 $B V _ { b }$ is the first visit brain volume, $D X$ is the diagnosis for the subject, $\Delta T$ is the change in time
292
+ 271 since baseline and the $\Delta T * D X$ represents an interaction between time and diagnosis. The $R O I _ { i }$
293
+ 272 represents the volume for all regions. However, for cortical regions, we also use the region’s thickness
294
+ 273 measurement as a second outcome (as this is a standard measurement in morphometry of the human
295
+ 274 cortex). We estimate effect sizes for cross-sectional effects via the model’s parameter fit for the
296
+ 275 diagnosis $( D X )$ term; we estimate longitudinal effect sizes via the parameter on the interaction term.
297
+
298
+ Table 1: Summary of results where the comparison of the model impact on effect size is computed by bootstrapped $\scriptstyle ( \mathrm { n = 1 0 0 0 } )$ ) paired t.test. The number of pairs is 274 (see Table 2 for further breakdown by category). CSRS losses are abbreviated as $\mathbf { R } =$ reconstruction, $\mathrm { T V } { = }$ total variation, $\scriptstyle \mathbf { D = }$ dice, VGG $\circeq$ VGG19 pseudo 3D features, Res6 is from the 6th layer of T1wQRResNet and Res21 is the 21st layer of T1wQRResNet. srmeanES indicates the mean effect size for the model averaged over all a priori regions; boot.95ci is the 95 percent confidence interval for the improvement in effect size due to the model. t represents the $t$ -statistic and boot.p represents the bootstrapped p-value for the significance of the improvement in effect size. Columns psnr and ssim show the standard PSNR and SSIM values for an image for which we have ground truth high-resolution intensity and segmentation. The dice columns show the mean and standard deviation of the Dice overlap between ground truth and the upsampled simulated data with each model, estimated over all regions. Best $=$ bold.
299
+
300
+ <table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>srmeanES</td><td rowspan=1 colspan=1>boot.95ci</td><td rowspan=1 colspan=1>t</td><td rowspan=1 colspan=1>boot.p</td><td rowspan=1 colspan=1>psnr</td><td rowspan=1 colspan=1>ssim</td><td rowspan=1 colspan=1>dice.mean</td><td rowspan=1 colspan=1>dice.sd</td></tr><tr><td rowspan=1 colspan=1>OR</td><td rowspan=1 colspan=1>0.559</td><td rowspan=1 colspan=1>0/0</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td></tr><tr><td rowspan=1 colspan=1>Linear</td><td rowspan=1 colspan=1>0.468</td><td rowspan=1 colspan=1>-0.1006/-0.08163</td><td rowspan=1 colspan=1>-18.61</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>40.6</td><td rowspan=1 colspan=1>0.996</td><td rowspan=1 colspan=1>0.769</td><td rowspan=1 colspan=1>0.047</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV</td><td rowspan=1 colspan=1>0.574</td><td rowspan=1 colspan=1>0.01124/0.01854</td><td rowspan=1 colspan=1>7.96</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.0</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.884</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D</td><td rowspan=1 colspan=1>0.582</td><td rowspan=1 colspan=1>0.01868/0.0273</td><td rowspan=1 colspan=1>10.38</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>41.8</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.883</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>0.581</td><td rowspan=1 colspan=1>0.01775/0.02559</td><td rowspan=1 colspan=1>10.76</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.0</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.885</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.VGG</td><td rowspan=1 colspan=1>0.577</td><td rowspan=1 colspan=1>0.01403/0.02209</td><td rowspan=1 colspan=1>8.86</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>41.9</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.884</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.Res6</td><td rowspan=1 colspan=1>0.572</td><td rowspan=1 colspan=1>0.009741/0.01665</td><td rowspan=1 colspan=1>7.49</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.4</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.886</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>0.588</td><td rowspan=1 colspan=1>0.02497/0.0331</td><td rowspan=1 colspan=1>14.02</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.4</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.885</td><td rowspan=1 colspan=1>0.032</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.Res21</td><td rowspan=1 colspan=1>0.577</td><td rowspan=1 colspan=1>0.01462/0.02143</td><td rowspan=1 colspan=1>10.40</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.3</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.884</td><td rowspan=1 colspan=1>0.031</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res21</td><td rowspan=1 colspan=1>0.581</td><td rowspan=1 colspan=1>0.01814/0.02627</td><td rowspan=1 colspan=1>10.59</td><td rowspan=1 colspan=1>0</td><td rowspan=1 colspan=1>42.3</td><td rowspan=1 colspan=1>0.997</td><td rowspan=1 colspan=1>0.887</td><td rowspan=1 colspan=1>0.03</td></tr></table>
301
+
302
+ ![](images/2b07a81d2d8a589a8b1bb114132c9aa7f9a79ccb050cea1dd7e921d7dc6686f0.jpg)
303
+ Figure 5: Bland-Altman plots for model CSRS.R.TV.D.Res6 demonstrate variability in the performance by type of anatomy and by diagnostic grouping with some individual points generating substantially greater $\%$ improvement than suggested by the overall trend. Similarly, a few points show decreased performance relative to OR.
304
+
305
+ # 276 3 Results
306
+
307
+ Table 1 summarizes overall results where we show original resolution and results from linear upsampling, as baseline, and compare to eight variants of CSRS. Two of these do not use perceptual metrics. The remaining six add or subtract Dice loss and each of our candidate perceptual losses. Table 1 shows both the aggregate impact of model on effect size estimates in the neurodegeneration data as well as intensity similarity (reconstruction) and Dice overlap in the ground truth data. Dice overlap (a measure that varies between zero and one) improves by a margin of 0.11 to 0.123 $9 5 \%$ CI bootstrapped percentile confidence interval, $p < 1 e - 1 6$ . See Figure 4.
308
+
309
+ 277
310
+ 278
311
+ 279
312
+ 280
313
+ 281
314
+ 282
315
+ 283
316
+ 284
317
+ 285
318
+ 286
319
+ 287
320
+ 288
321
+
322
+ Table 2 focuses on the two perceptual models with the greatest improvement from original resolution as assessed by pairwise $t$ -test. It breaks down the effect size results in relation to which type of effect size is being analyzed (cross-sectional or longitudinal) and by brain region / diagnostic grouping. Relatedly, Figure 5 shows a Bland-Altman style plot that demonstrates, for the CSRS.R.TV.D.Res6 model, the range of effect size changes due to CSRS across all 274 measurement points.
323
+
324
+ Table 2: Summary of results for the two best perceptual models broken down by anatomical class, type of predictor (longitudinal or cross-sectional) and diagnostic groups. The n column indicates the number of samples used in the statistical testing. The codes in the AnatClass column are: CtxV - cortical volume; CtxT - cortical thickness; MB - deep brain (for CBS/PSP); MTL - medial temporal lobe (for svPPA). The columns that have non-NA DX2 means that both DX and DX2 groups were aggregated in the computation of the bootstrapped paired $t$ -test for the given group of anatomy.
325
+
326
+ <table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>AnatClass</td><td rowspan=1 colspan=1>isLong</td><td rowspan=1 colspan=1>DX</td><td rowspan=1 colspan=1>DX2</td><td rowspan=1 colspan=1>n</td><td rowspan=1 colspan=1>srmeanES</td><td rowspan=1 colspan=1>boot.95ci</td><td rowspan=1 colspan=1>t</td><td rowspan=1 colspan=1>boot.p</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>All</td><td rowspan=1 colspan=1>Both</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>274</td><td rowspan=1 colspan=1>0.581</td><td rowspan=1 colspan=1>0.01775/0.02559</td><td rowspan=1 colspan=1>10.763</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>CtxV</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.826</td><td rowspan=1 colspan=1>0.007153/0.01626</td><td rowspan=1 colspan=1>4.936</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>CtxT</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>1.016</td><td rowspan=1 colspan=1>-0.009547/0.01006</td><td rowspan=1 colspan=1>0.033</td><td rowspan=1 colspan=1>0.9769</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>MB</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>CBS/PSP</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.600</td><td rowspan=1 colspan=1>0.03683/0.1208</td><td rowspan=1 colspan=1>3.458</td><td rowspan=1 colspan=1>0.0246</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>MTL</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>svPPA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>1.003</td><td rowspan=1 colspan=1>0.02801/0.06981</td><td rowspan=1 colspan=1>4.190</td><td rowspan=1 colspan=1>0.0112</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>CtxV</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.645</td><td rowspan=1 colspan=1>0.01848/0.03313</td><td rowspan=1 colspan=1>6.719</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>CtxT</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.527</td><td rowspan=1 colspan=1>0.03521/0.05297</td><td rowspan=1 colspan=1>9.445</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>MB</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>CBS/PSP</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.201</td><td rowspan=1 colspan=1>0.01409/0.03941</td><td rowspan=1 colspan=1>3.924</td><td rowspan=1 colspan=1>0.0110</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.VGG</td><td rowspan=1 colspan=1>MTL</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>svPPA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>0.701</td><td rowspan=1 colspan=1>-0.0159/0.002513</td><td rowspan=1 colspan=1>-1.309</td><td rowspan=1 colspan=1>0.2652</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>All</td><td rowspan=1 colspan=1>Both</td><td rowspan=1 colspan=1>All</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>274</td><td rowspan=1 colspan=1>0.588</td><td rowspan=1 colspan=1>0.02497/0.0331</td><td rowspan=1 colspan=1>14.021</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>CtxV</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.831</td><td rowspan=1 colspan=1>0.01199/0.02182</td><td rowspan=1 colspan=1>6.573</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>CtxT</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>1.023</td><td rowspan=1 colspan=1>-0.002896/0.01832</td><td rowspan=1 colspan=1>1.394</td><td rowspan=1 colspan=1>0.1604</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>MB</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>CBS/PSP</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.589</td><td rowspan=1 colspan=1>0.02166/0.1131</td><td rowspan=1 colspan=1>2.718</td><td rowspan=1 colspan=1>0.0454</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>MTL</td><td rowspan=1 colspan=1>Cross</td><td rowspan=1 colspan=1>SvPPA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>1.004</td><td rowspan=1 colspan=1>0.02782/0.07253</td><td rowspan=1 colspan=1>4.021</td><td rowspan=1 colspan=1>0.0102</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>CtxV</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.658</td><td rowspan=1 colspan=1>0.03203/0.04756</td><td rowspan=1 colspan=1>9.751</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>CtxT</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>bvFTD</td><td rowspan=1 colspan=1>naPPA</td><td rowspan=1 colspan=1>28</td><td rowspan=1 colspan=1>0.545</td><td rowspan=1 colspan=1>0.05421/0.06995</td><td rowspan=1 colspan=1>15.151</td><td rowspan=1 colspan=1>0.0000</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>MB</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>CBS/PSP</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>0.198</td><td rowspan=1 colspan=1>0.006017/0.04464</td><td rowspan=1 colspan=1>2.233</td><td rowspan=1 colspan=1>0.0166</td></tr><tr><td rowspan=1 colspan=1>CSRS.R.TV.D.Res6</td><td rowspan=1 colspan=1>MTL</td><td rowspan=1 colspan=1>Long</td><td rowspan=1 colspan=1>svPPA</td><td rowspan=1 colspan=1>NA</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>0.704</td><td rowspan=1 colspan=1>-0.0177/0.01214</td><td rowspan=1 colspan=1>-0.369</td><td rowspan=1 colspan=1>0.7511</td></tr></table>
327
+
328
+ # 289 4 Discussion
329
+
330
+ The PSNR and SSIM improve similarly across all CSRS models and do not substantively differentiate performance. Dice overlap is consistently superior than linear upsampling across all models but shows little difference between models with perhaps a small advantage for the ResNet features. Greater stratification may be seen when looking at results that relate to quantifying the phenotypic heterogeneity of brain atrophy in frontotemporal spectrum diagnostic groups. Model CSRS.R.TV.D.Res6 stands out under this criteria with Table 2 suggesting that the majority of the improvement arises for cortical measurements, particularly longitudinally. Performance improvements are not, however, perfectly consistent. Figure 5 shows that CSRS augments effect size in the large majority of regions (some greatly so) but a few regions are subtly better at OR. Additional discussion of performance implications with respect to individual regions and diagnoses is in supplementary information.
331
+
332
+ 300 The extension of PSR to 3D raises opportunities as well as challenges. Parameter exploration is
333
+ 301 fundamentally limited because training a model on our patch dataset for 1 epoch takes over 12 hours
334
+ 302 (we trained each model for 2 epochs or until convergence). Other architectures than DBPN may
335
+ 303 perform better with CSRS such as ESRGAN [32] or, potentially, methods with stronger modality
336
+ 304 specific priors on the convolutional kernels [33]. Specifically, fast-training, fewer parameter models
337
+ 305 may ease some of the computational burden and facilitate more parameter exploration.
338
+ 306 CSRS performance is fundamentally limited by the quality of its segmentation inputs. It may be
339
+ 307 more beneficial to develop new methods that operate at high resolution (HR) – adding substantial
340
+ 308 computational cost if the goal is to take advantage of HR features – or that take advantage of
341
+ 309 intrinsically HR ground truth data. The primary barrier to such an effort is the current lack of HR
342
+ 310 ground truth labels for neuroimaging and in particular for neurodegenerative disease. Moreover,
343
+ 311 most methods embed resolution assumptions in their own processing choices and optimize for these
344
+ 312 choices. As such, CSRS bridges a performance gap with a practical solution readily available today.
345
+ 313 Retooling existing methods and segmentation labels for HR (e.g. 7T MRI) is costly both computation
346
+ 314 ally and in terms of the effort of human experts due to the already high volume of 3D neuroimaging.
347
+ 315 We demonstrated that CSRS, in most of its variants, leads to significant performance improvements
348
+ 316 over our reference of original resolution $\mathrm { { ( l m m ^ { 3 } ) } }$ ) image processing and ground truth labels. Because
349
+ 317 CSRS operates on existing images and labels, new HR method and segmentation development is
350
+ 318 not required. Thus, CSRS may be used to improve existing ground truth datasets and existing
351
+ 319 processed data, today. However, comparison to other and/or larger real world datasets is needed to
352
+ 320 help determine the extent to which our results may be deployed to new data without concern.
353
+ 321 References
354
+ 322 1. Mulder MJ, Keuken MC, Bazin PL, Alkemade A, Forstmann BU. Size and shape matter: The
355
+ 323 impact of voxel geometry on the identification of small nuclei. PLoS ONE. 2019. https://doi.
356
+ 324 org/10.1371/journal.pone.0215382.
357
+ 325 2. Veitch DP, Weiner MW, Aisen PS, Beckett LA, Cairns NJ, Green RC, et al. Understanding disease
358
+ 326 progression and improving Alzheimer’s disease clinical trials: Recent highlights from the Alzheimer’s
359
+ 327 disease neuroimaging initiative. Alzheimer’s & Dementia : the Journal of the Alzheimer’s Association.
360
+ 328 2019;15:106–52.
361
+ 329 3. Boxer AL, Gold M, Feldman H, Boeve BF, Dickinson SL-J, Fillit H, et al. New directions in
362
+ 330 clinical trials for frontotemporal lobar degeneration: Methods and outcome measures. Alzheimer’s &
363
+ 331 dementia : the journal of the Alzheimer’s Association. 2020;16:131–43.
364
+ 332 4. Blau Y, Michaeli T. The perception-distortion tradeoff. Proceedings of the IEEE Conference
365
+ 333 on Computer Vision and Pattern Recognition, pp 6228-6237, 2018. 2017. https://doi.org/10.
366
+ 334 1109/CVPR.2018.00652.
367
+ 335 5. Haris M, Shakhnarovich G, Ukita N. Deep back-projection networks for single image super
368
+ 336 resolution. IEEE Transactions on Pattern Analysis and Machine Intelligence. 2020; 43(12):4323-
369
+ 337 4337.
370
+ 338 6. Agustsson E, Timofte R. NTIRE 2017 challenge on single image super-resolution: Dataset and
371
+ 339 study. In: Proceedings of the IEEE conference on computer vision and pattern recognition workshops
372
+ 340 2017. pp. 126-135.
373
+ 341 7. Gu S, Danelljan M, Timofte R, Haris M, Akita K, Shakhnarovic G, et al. AIM 2019 challenge on
374
+ 342 image extreme super-resolution: Methods and results. In: 2019 IEEE/CVF International Conference
375
+ 343 on Computer Vision Workshop (ICCVW). Seoul, Korea (South): IEEE. pp. 3556–64.
376
+ 344 8. Blau Y, Mechrez R, Timofte R, Michaeli T, Zelnik-Manor L. The 2018 PIRM challenge on
377
+ 345 perceptual image super-resolution. In: 2018 Proceedings of the European Conference on Computer
378
+ 346 Vision (ECCV) Workshops. pp. 334–55.
379
+ 347 9. Tian Q, Bilgic B, Fan Q, Ngamsombat C, Zaretskaya N, Fultz NE, et al. Improving in vivo human
380
+ 348 cerebral cortical surface reconstruction using data-driven super-resolution. Cerebral cortex (New
381
+ 349 York, NY : 1991). 2021;31:463–82.
382
+ 350 10. Glasser MF, Smith SM, Marcus DS, Andersson JLR, Auerbach EJ, Behrens TEJ, et al. The human
383
+ 351 connectome project’s neuroimaging approach. Nature Neuroscience. 2016; 19(9): pp. 1175-1187.
384
+ 352 11. Elam JS, Glasser MF, Harms MP, Sotiropoulos SN, Andersson JL, Burgess GC, et al. The human
385
+ 353 connectome project: A retrospective. NeuroImage. 2021;244:118543.
386
+ 354 12. Zhang K, Hu H, Philbrick K, Conte GM, Sobek JD, Rouzrokh P, et al. SOUP-gan: Super
387
+ 355 resolution mri using generative adversarial networks. Tomography (Ann Arbor, Mich). 2022;8:905–
388
+ 356 19.
389
+ 357 13. Shan H, Zhang Y, Yang Q, Kruger U, Kalra MK, Sun L, et al. 3-d convolutional encoder-decoder
390
+ 358 network for low-dose ct via transfer learning from a 2-d trained network. IEEE Transactions on
391
+ 359 Medical Imaging. 2018. https://doi.org/10.1109/TMI.2018.2832217.
392
+ 360 14. Avants B, Greenblatt E, Hesterman J, Tustison N. Deep volumetric feature encoding for biomedical
393
+ 361 images. In: Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial
394
+ 362 Intelligence and Lecture Notes in Bioinformatics). 2020.
395
+ 363 15. Zhang R, Isola P, Efros AA, Shechtman E, Wang O. The unreasonable effectiveness of deep
396
+ 364 features as a perceptual metric. In: Proceedings of the IEEE Computer Society Conference on
397
+ 365 Computer Vision and Pattern Recognition. 2018.
398
+ 366 16. Tustison NJ, Cook PA, Holbrook AJ, Johnson HJ, Muschelli J, Devenyi GA, et al. The antsx
399
+ 367 ecosystem for quantitative biological and medical imaging. Scientific reports. 2021;11:9068.
400
+ 368 17. Illán-Gala I, Nigro S, VandeVrede L, Falgàs N, Heuer HW, Painous C, et al. Diagnostic
401
+ 369 accuracy of magnetic resonance imaging measures of brain atrophy across the spectrum of progressive
402
+ 370 supranuclear palsy and corticobasal degeneration. JAMA network open. 2022;5:e229588.
403
+ 371 18. Whitwell JL. FTD spectrum: Neuroimaging across the ftd spectrum. 2019;187–223.
404
+ 372 19. Whitwell JL, Josephs KA. Neuroimaging in frontotemporal lobar degeneration—predicting
405
+ 373 molecular pathology. 2012;8:131–42.
406
+ 374 20. Binney RJ, Pankov A, Marx G, He X, McKenna F, Staffaroni AM, et al. Data-driven regions of
407
+ 375 interest for longitudinal change in three variants of frontotemporal lobar degeneration. Brain and
408
+ 376 behavior. 2017;7:e00675.
409
+ 377 21. McCarthy J, Collins DL, Ducharme S. Morphometric mri as a diagnostic biomarker of fron
410
+ 378 totemporal dementia: A systematic review to determine clinical applicability. NeuroImage Clinical.
411
+ 379 2018;20:685–96.
412
+ 380 22. Gunawardena D, Ash S, McMillan C, Avants B, Gee J, Grossman M. Why are patients with
413
+ 381 progressive nonfluent aphasia nonfluent? Neurology. 2010;75.
414
+ 382 23. C.T. M, J.B. T, B.B. A, P.A. C, E.M. W, E. S, et al. Genetic and neuroanatomic associations in
415
+ 383 sporadic frontotemporal lobar degeneration. Neurobiology of Aging. 2014.
416
+ 384 24. Massimo L, Powers C, Moore P, Vesely L, Avants B, Gee J, et al. Neuroanatomy of apathy
417
+ 385 and disinhibition in frontotemporal lobar degeneration. Dementia and Geriatric Cognitive Disorders.
418
+ 386 2009. https://doi.org/10.1159/000194658.
419
+ 387 25. Haris M, Shakhnarovich G, Ukita N. Deep back-projection networks for super-resolution. In:
420
+ 388 Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition.
421
+ 389 2018.
422
+ 390 26. Zhang R, Isola P, Efros AA, Shechtman E, Wang O. The unreasonable effectiveness of deep
423
+ 391 features as a perceptual metric. In: Proceedings of the IEEE Computer Society Conference on
424
+ 392 Computer Vision and Pattern Recognition. 2018.
425
+ 393 27. Klein A, Tourville J. 101 labeled brain images and a consistent human cortical labeling protocol.
426
+ 394 Frontiers in neuroscience. 2012;6:171.
427
+ 395 28. Schaerer J, Roche F, Belaroussi B. A generic interpolator for multi-label images. 2014. https:
428
+ 396 //doi.org/10.54294/nr6iii.
429
+ 397 29. Bates D, Mächler M, Bolker B, Walker S. Fitting linear mixed-effects models using lme4 | bates |
430
+ 398 journal of statistical software. Journal of Statistical Software. 2015;67.
431
+ 399 30. Brysbaert M, Stevens M. Power analysis and effect size in mixed effects models: A tutorial.
432
+ 400 Journal of Cognition. 2018;1.
433
+ 401 31. Ben-Shachar M, Lüdecke D, Makowski D. Effectsize: Estimation of effect size indices and
434
+ 402 standardized parameters. Journal of Open Source Software. 2020;5.
435
+ 403 32. Wang X, Yu K, Wu S, Gu J, Liu Y, Dong C, et al. ESRGAN: Enhanced super-resolution generative
436
+ 404 adversarial networks. arXiv e-prints. 2018;arXiv:1809.00219.
437
+ 405 33. Bell-Kligler S, Shocher A, Irani M. Blind super-resolution kernel estimation using an internal-gan.
438
+ 406 In: Advances in Neural Information Processing Systems. 2019.
439
+
440
+ 1. For all authors...
441
+
442
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
443
+ (b) Did you describe the limitations of your work? [Yes]
444
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
445
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
446
+
447
+ 2. If you are including theoretical results...
448
+
449
+ (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]
450
+
451
+ 3. If you ran experiments...
452
+
453
+ (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 provide the data, in supplementary material, that is needed to generate the tables shown in the paper. The raw data is publicly available but we do not have permission to redistribute these data. However, we do provide the ability to reproduce key results in the Tables of the main manuscript via supplementary information.
454
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
455
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
456
+ (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 beginning of Methods section and CSRS methods section.
457
+
458
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
459
+
460
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
461
+ (b) Did you mention the license of the assets? [Yes] in supplemental information.
462
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
463
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] in supplemental information.
464
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] in supplemental information.
465
+
466
+ 5. If you used crowdsourcing or conducted research with human subjects...
467
+
468
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
469
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
470
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/upJ3vrFKaL/upJ3vrFKaL.md ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # COLLECTING THE PUZZLE PIECES: DISENTANGLEDSELF-DRIVEN HUMAN POSE TRANSFER BY PERMUT-ING TEXTURES
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Human pose transfer aims to synthesize a new view of a person under a given pose. Recent works achieve this via self-reconstruction, which disentangles pose and texture features from the person image, then combines the two features to reconstruct the person. Such feature-level disentanglement is a difficult and illdefined problem that could lead to loss of details and unwanted artifacts. In this paper, we propose a self-driven human pose transfer method that permutes the textures at random, then reconstructs the image with a dual branch attention to achieve image-level disentanglement and detail-preserving texture transfer. We find that compared with feature-level disentanglement, image-level disentanglement is more controllable and reliable. Furthermore, we introduce a dual kernel encoder that gives different sizes of receptive fields in order to reduce the noise caused by permutation and thus recover clothing details while aligning pose and textures. Extensive experiments on DeepFashion and Market-1501 shows that our model improves the quality of generated images in terms of FID, LPIPS and SSIM over other self-driven methods, and even outperforming some fully-supervised methods. A user study also shows that among self-driven approaches, images generated by our method are preferred in $72 \%$ of cases over prior work.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ The goal of human pose transfer is to change the pose of a person while preserving the person’s appearance and clothing textures. It has wide applications such as virtual try-on (Yang et al., 2020b; Cui et al., 2021; Yu et al., 2019), controllable person image manipulation (Cui et al., 2021; Liu et al., 2021) and person re-identification (Zhang et al., 2021b). Recent work has focused on using paired image data (i.e., two images of the same person before and after reposing) (Zhou et al., 2022; Zhang et al., 2022), but collecting such data can be very labor intensive. Although self-driven methods have been proposed to train pose transfer models without paired data (Ma et al., 2021; Song et al., 2019), there still remains two major challenges: how to disentangle texture and pose, and how to preserve texture details across changes in pose. As illustrated in Figure 1a, prior research attempts to achieve the pose and texture disentanglement at a feature level (Ma et al., 2018; Yang et al., 2020a; Ma et al., 2021; Wang et al., 2022). However, without direct supervision from pose-invariant textures, disentangling texture features from the person image while also preserving specific clothing details in the disentangled features is a difficult and ill-defined problem (Locatello et al., 2019). Small imbalances between pose and texture could leave obvious artifacts in the generated images.
12
+
13
+ In this paper, we propose Pose Transfer by Permuting Textures $( \mathrm { P T ^ { 2 } } )$ , a self-driven pose transfer model using image-level disentanglement to represent detailed clothing patterns in any target pose. As shown in Figure 1b, a key novelty is our input permutation function that disentangles the raw inputs of texture and pose. Our method does not need supervised pose-invariant textures because most pose information has been removed by the permutation. The input permutation function creates a disentangled texture sample space by randomly reordering the texture patches on the person such that the source pose cannot be recovered from the permuted textures. This approach is similar in spirit to self-supervised representation learning methods that use jigsaw puzzle solving to learn a good feature representation (Noroozi & Favaro, 2016; Carlucci et al., 2019), where the pretext task divides the image into large patches and attempts to infer their relative positions by using the inherent geometry information within each patch. However, we differ in that our goal is to sample relevant patches based on the target posture. We make the patch much smaller in order to remove the position information and thus disentangle pose and texture. Furthermore, we mask some of the textures to force the generator to infer occluded and unseen regions, such as t-shirt occluded by crossed arms.
14
+
15
+ ![](images/3706d01db007440f12ea36da9627cdc9ea93e4c468362e3e2106b57386c9a536.jpg)
16
+ Figure 1: Pose transfer methods trained without supervision extract disentangled texture and pose representations and then learn to reconstruct the original image. (a) Recent work uses separate encoders to disentangle texture and pose (Pumarola et al., 2018; Ma et al., 2018; 2021; Wang et al., 2022). However, pose information may still appear in the texture features, and without supervision, disentangling them is difficult (Locatello et al., 2019). (b) Our approach disentangles textures from pose by permuting the image patches, effectively eliminating pose information, which enables our approach to disentangle pose and texture features better than prior work.
17
+
18
+ One challenge we face is that the permutation of textures causes loss of shape and relative position information, which has two significant consequences. First, the model cannot recognize different body parts and garments. For example, the generator could use texture from leggings to synthesize a top tank. Second, it makes the length of clothing items unknown because of lack of relative position of clothing pieces. The first issue can be easily solved by combining the person with a human parsing map to give a semantic identifier for each pixel (Ma et al., 2021). Whereas for the second problem, we need an additional sample space in the model that provides relative position information. This inspires us to add a pose branch, where we use the dense pose representation (Guler et al., 2018) as ¨ the sample space to provide position information for each pixel after permuting the textures. Each pixel value in the space indicates the position of that pixel under the texture coordinate system (Guler ¨ et al., 2018). In addition, we find that using different kernel sizes in the convolutional layers of our dual branch attention module provides a better representation for our task.
19
+
20
+ Our main contributions are:
21
+
22
+ • We propose Pose Transfer by Permuting Textures $( \mathrm { P T ^ { 2 } } )$ , a self-driven pose transfer model that utilizes input permutation to transfer clothing patterns to the target pose without using paired images for supervision.
23
+ • The proposed pose branch in $\mathrm { P T ^ { 2 } }$ provides relative geometry information for the permuted textures, which helps recover shape and length after pose transfer. In addition, different kernel sizes are introduced in the branch, which can reduce the noise caused by input permutation and thus preserve clothing details while aligning pose and textures.
24
+ • Extensive experiments on DeepFashion (Liu et al., 2016) and Market-1501 (Zheng et al., 2015) show that $\mathrm { P \bar { T } ^ { 2 } }$ significantly improves the image quality of self-driven approaches. A user study reports that our method are preferred in $72 \%$ of cases over the state-of-the-art.
25
+
26
+ # 2 RELATED WORK
27
+
28
+ Pose transfer with paired images. Methods trained with paired images aim to learn the complex non-rigid deformation of clothing items. In (Zhu et al., 2019; Zhang et al., 2022; Ren et al., 2022; Gao et al., 2020), this transformation is learned via soft attention that aggregates source image features with weighted sampling. Zhang et al. (2021a); Lv et al. (2021) further use semantic parsing maps as guidance to control the style of each body part. The major difficulty in such feature-level attention is that clothing details could be washed out in lower-resolution feature maps. To preserve these details after pose transfer, flow-based methods haven been proposed to approximate a dense flow field from the source to the target person. Han et al. (2019) introduced a pyramid feature network that outputs a pixel-level flow filed. Tang et al. (2021); Ren et al. (2020) further combined soft attention with dense flow to learn more accurate estimations. However, since the learned flow can only copy existing pixels in the source image to the target, it might fail at inferring occluded and unseen parts of the person. Grigorev et al. (2019); Sarkar et al. (2020); Albahar et al. (2021) explored inpainting 2D partial texture to 3D full texture in the UV space, and then projecting it back to the 2D pose. Although these methods can produce high-quality person images, they all require strong supervision from paired data, which might be difficult to collect in some real-world scenarios.
29
+
30
+ Pose transfer with unpaired images. In a self-driven setting where paired data is absent, it is more difficult to transfer the pose without losing texture details. Without supervision, the generated images tend to have repeated texture patterns and edge blurring (Wang et al., 2022). Prior work has addressed this problem by disentangling the texture and posture at a feature level. Early attempts produced poor quality images for large pose deformations (Pumarola et al., 2018; Esser et al., 2018; Ma et al., 2018). Song et al. (2019) introduced a generated target parsing map to a cycle-GAN pose transfer model, which requires paired segmentation maps for training the human parsing model. Sanyal et al. (2021) presents a 3D based reposing approach with appearance visibility inference. Wang et al. (2022) used part-wise encoder to learn texture features that are less correlated with pose, where global pose information can still be inferred from the texture features. The model in (Ma et al., 2021) first computes region-wise image features, and then takes their mean and variance as the texture features to be integrated with the pose representation. This helps erase the pose information in the texture features, but, as we show, it may miss clothing details. In contrast to these methods, our approach disentangles the texture at an image-level by permutation, and uses a dual kernel encoder with dual branch attention to transfer detailed clothing patterns to the target pose.
31
+
32
+ # 3 SELF-DRIVEN POSE TRANSFER BY PERMUTING TEXTURES $( \mathrm { P T ^ { 2 } } )$
33
+
34
+ Let $I _ { s }$ be the source image with posture $P _ { s }$ . Our goal is to synthesize a new view $I _ { t }$ of the same person in $I _ { s }$ and wearing the same clothes in a target posture $P _ { t }$ . Models requiring paired data use the target pose $P _ { t }$ and the target image $I _ { t }$ for training, but our approach needs only information derived from the source image. Specifically, the target pose/image in training is identical to the source pose/image. In inference, replacing the target pose with a different one enables pose transfer.
35
+
36
+ $\mathrm { P T ^ { 2 } }$ contains a pose transfer network (Sec. 3.1) that synthesizes a new view of the person in its target pose, and a background inpainting network that infers its full background (Sec. 3.2). The generated person and its full background are combined to create the final reconstructed image.
37
+
38
+ # 3.1 POSE TRANSFER NETWORK
39
+
40
+ The objective of the pose transfer network is to take the foreground person in the source image and generate a new view of them in a different pose. Figure 2 gives the overall architecture, which contains two branches: a pose branch that learns the geometric transformation function from pose $P _ { s }$ to pose $P _ { t }$ , and a texture branch that learns to transfer the textures of the person $E _ { s }$ to pose $P _ { t }$ . The permuted inputs (Sec. 3.1.1) from the two branches are first encoded with dual kernel encoder (Sec. 3.1.2), and then merged in a dual branch attention module (Sec. 3.1.3) to be decoded into the generated person $\hat { E } _ { d }$ and its segmentation $S$ .
41
+
42
+ # 3.1.1 INPUT PERMUTATION
43
+
44
+ Inputs to the Texture Branch. To guide the texture transfer with a posture in a self-driven way, we first need to disentangle the pose and textures in the image. The posture can be derived by a DensePose model (Guler et al., 2018) pretrained on COCO (Lin et al., 2014), which gives a 2D UV ¨ coordinate representation $P _ { s }$ . However, the texture representation should not simply be the source person $E _ { s }$ itself, as it is obviously entangled with posture. To erase the pose information from $E _ { s }$ , we create a texture sample space by dividing the image into $k \times k$ squares, referred to as “patches,” and then shuffling their locations. Intuitively, when the patch size $k$ is sufficiently small, the original posture cannot easily be retrieved from the permutation. Additionaly, $20 \%$ of the patches are masked to encourage the model to learn occluded regions. Formally, let RandMask $( \cdot )$ be the input permuting function. The inputs of the texture attention branch become $[ \tilde { E } _ { s } ; \tilde { M } ] = \mathrm { R a n d M a s k } ( [ E _ { s } ; M ] , m _ { t } )$ , where $[ ; ]$ means concatenation and $m _ { t }$ is the masking rate. We set $m _ { t } = 0 . 2$ in our experiments. The permuted tetxures $[ \tilde { E } _ { s } ; \tilde { M } ]$ are given as inputs to the dual-kernel texture encoder (Sec. 3.1.2).
45
+
46
+ ![](images/303bdb570b4412b24e01bef00cd95562dd32683df6bd9f9d6596ac4a3c269dbe.jpg)
47
+ Figure 2: The pose transfer network in $\mathrm { P T ^ { 2 } }$ . During training, the target pose $P _ { t }$ is the same as the source pose $P _ { s }$ . The network takes the source person $E _ { s }$ , source parsing map $M$ and source pose $P _ { s }$ as inputs. In the pose branch and texture branch, the inputs are first permuted (Sec. 3.1.1) to create the corresponding sample space, which is encoded with dual kernel encoders (Sec. 3.1.2). Then the encoded features are sampled in a dual branch attention module (Sec. 3.1.3) to be decoded into the generated person $\hat { E } _ { s }$ and its segmentation $S$ . The output of the pose transfer network is combined with the output of the background inpainting network (Sec. 3.2) to produce the final image.
48
+
49
+ Inputs to the Pose Branch. While prior work only uses a texture branch to transfer texture to the target pose (Pumarola et al., 2018; Ma et al., 2018; 2021; Wang et al., 2022), we propose a pose branch that provides relative geometry information for the permuted textures, which helps recover shape and length after pose transfer. To learn a powerful pose transformation function that supports large pose variations, the source pose in this branch is permuted the same way as the textures. In addition, we mask $50 \%$ of the source pose representation to force the model to learn the inherit symmetry in human body. The inputs to the pose branch become $[ \tilde { P } _ { s } ; \tilde { M } ] = \mathrm { R a n d M a s k } ( [ P _ { s } ; M ] , \stackrel { . . } { m } _ { p } )$ , where $m _ { p } = 0 . 5$ . Note that the inputs of the texture and pose branches are permuted the same way so they are spatially aligned in the dual branch attention module (see Sec. 3.1.3). The permuted pose representations $[ \tilde { P _ { s } } ; \tilde { M } ]$ are given as inputs to the dual-kernel pose encoder (Sec. 3.1.2).
50
+
51
+ # 3.1.2 DUAL KERNEL ENCODER
52
+
53
+ Following (Pumarola et al., 2018; Ma et al., 2018; 2021; Wang et al., 2022), we utilize separate encoders to learn both the texture and the pose information. However, in addition to providing permuted inputs from Sec. 3.1.1 to help further disentangle texture from pose, another way our approach differs is that we use multiple kernel sizes in the encoder’s convolutional layers. More formally, the texture/pose encoder learns a multi-dimensional feature map $F \in \mathbb { R } ^ { H \times W \times d }$ from the permuted texture/posture, where each vector $v \in \mathbb { R } ^ { d }$ in the feature map has a certain receptive field in the image. Let $l$ denote the length of the receptive field and $s$ be the stride of $F$ (both are measured by number of pixels in the image). Generally, larger receptive field is capable of learning more diverse features, and thus $l$ is usually much larger than $s$ . However, for a receptive field that crosses the boundary between two permuted image patches, the pixels within the field could be spatially faraway and irrelevant in the original image. In the left picture of Figure 3, the two black squares denote two adjacent receptive fields. While the left square lying within an image patch are seeing a consistent pattern (e.g., face), the right square crossing the boundary are seeing two distinct patterns (e.g., face and shoes). This could introduce high volume of noise to the feature vector $v$ , preventing the model from recognizing true clothing patterns.
54
+
55
+ ![](images/890e385af89e0320c8b5709a4c58db2a8edea42c1eb582bf4a556892ef415682.jpg)
56
+ Figure 3: Illustration of the receptive field in the large-kernel encoder (left) and small-kernel encoder (right). The kernel size $l$ is reduced to avoid overlap between receptive fields (see Sec. 3.1.2).
57
+ Figure 4: Dual branch attention module in Sec. 3.1.3. The top flow is PAM and the bottom flow is TAM. Res represents a residual layer. The cross-attention mechanism aligns the permuted texture with the target pose.
58
+
59
+ To solve the above issue, we introduce an additional pose encoder with reduced kernel size such that $l \ = \ s$ , which can be regarded as a Multi Layer Perceptron over image patches. We select our kernel size such that the kernel does not cross the boundary of the permuted inputs from Sec. 3.1.1. As shown in the right picture of Figure 3, this design avoids the overlap between receptive fields, enabling the convolutional kernel to learn a consistent pattern within its own receptive field. Note that large kernel size is still necessary as it has more parameters and larger receptive filed for learning larger image patterns. Therefore, by combining encoders with a large and small kernel sizes our model is capable of learning more diverse features. The outputs of the dual kernel encoders in both texture branch and pose branch are fed to the dual branch attention module in Sec. 3.1.3.
60
+
61
+ # 3.1.3 DUAL BRANCH ATTENTION
62
+
63
+ We use a cross-attention transformer (Tang et al., 2020; Tan et al., 2021; Zhang et al., 2022) to align texture and pose features. Specifically, we use a Pose Attention Module (PAM) for the pose branch and a Texture Attention Module (TAM) for the texture branch. Let $F _ { s } ^ { p l } , F _ { s } ^ { p s }$ represent the output feature map of the large-kernel pose encoder and the small-kernel pose encoder in the pose branch, respectively. Similarly, $F _ { s } ^ { t l } , F _ { s } ^ { t { \bar { s } } }$ are the encoded features from the texture encoders in the texture branch. $T _ { 1 }$ is the feature map of the target pose $P _ { t }$ encoded by the target pose encoder, which is implemented with six convolutional layers. As shown in Figure 4, both PAM and TAM are composed of three cross-attention vision transformers formulated as Attention $\begin{array} { r } { ( Q , K , V ) = \mathrm { s o f t m a x } ( \frac { Q K ^ { \hat { T } } } { \sqrt { d } } ) \cdot V } \end{array}$ . With cross-attention the model can sample textures based on the target pose to generate a person image. In the first two transformer layers, the pose attention in the pose branch is learned from the correlation between the source pose and the target pose, which is computed as:
64
+
65
+ $$
66
+ Q = W _ { i } ^ { p q } T _ { i } , K = W _ { i } ^ { p k } F _ { s } ^ { p l } , V = W _ { i } ^ { p v } F _ { s } ^ { t l } , i = 1 , 2 .
67
+ $$
68
+
69
+ Here, $W _ { i } ^ { p q } , W _ { i } ^ { p k } , W _ { i } ^ { p v }$ are learnable projection matrices. Similarly, the texture attention in the texture branch is formulated as the correlation between the texture and the target pose:
70
+
71
+ $$
72
+ Q = W _ { i } ^ { t q } T _ { i } , K = W _ { i } ^ { t k } F _ { s } ^ { t l } , V = W _ { i } ^ { t v } F _ { s } ^ { t l } , i = 1 , 2 .
73
+ $$
74
+
75
+ After each transformer layer, a residual layer is appended as in Figure 4. A random noise vector $z$ is injected to the residual layer as the affine transformation parameters of the feature map $T _ { i }$ to prevent mode collapse (Karras et al., 2019).
76
+
77
+ In the last transformer layer, wby small-kernel encoders (i.e., $F _ { s } ^ { p l } , F _ { s } ^ { t l }$ in the above equations with features produced to reconstruct more detailed information. The $F _ { s } ^ { p s } , F _ { s } ^ { t s } )$
78
+ output feature map $T$ of the last transformer layer is then fed to the decoder, where $T$ is gradually
79
+ upsampled to the target person $\hat { E } _ { s }$ and its segmentation mask $S$ .
80
+
81
+ PAM in the dual branch attention module learns geometric transformation between different postures, and TAM samples the given textures based on the target pose. Fusing the two source of information provides a more accurate match between the given pose and textures. By filling in more clothing details that are learned through small kernels, our pose transfer network can then faithfully recover the appearance of clothing items after pose transfer.
82
+
83
+ # 3.2 BACKGROUND INPAINTING NETWORK
84
+
85
+ As in (Dundar et al., 2021; Liu et al., 2021), we use a separate background inpainting network, implemented using UNet (Long et al., 2015), to infer the background pixels of the masked foreground region. However, we found if we only mask out the foreground segmentation $S$ , the model would ignore the unknown background in the mask and reconstruct only known pixels during inference. This is because the background area is always visible in the source image in self-supervised training, so the network does not learn how to infer missing areas. Therefore, we expand the mask to the whole bounding box of the detected person in order to create invisible background areas during training. Let $\hat { B }$ be the inpainted background. Given the generated person $\hat { E } _ { s }$ and its segmentation mask $S$ produced by the pose transfer network, the final reconstructed image is: $\hat { I } _ { s } = \dot { S } \odot \dot { E } _ { s } + ( 1 - S ) \odot \hat { B }$ .
86
+
87
+ # 3.3 LOSS FUNCTIONS
88
+
89
+ We train our model using an adversarial loss that can be written as:
90
+
91
+ $$
92
+ L _ { a d v } = D ( \hat { I } _ { s } ) ^ { 2 } + ( 1 - D ( I _ { s } ) ) ^ { 2 } + D _ { p } ( [ \hat { I } _ { s } ; P _ { s } ] ) ^ { 2 } + ( 1 - D _ { p } ( [ I _ { s } ; P _ { s } ] ) ) ^ { 2 } .
93
+ $$
94
+
95
+ where $D$ and $D _ { p }$ represent different discriminators. $D$ penalizes the distribution difference between the synthesized image $\hat { I } _ { s }$ and the ground truth $I _ { s }$ . $D _ { p }$ evaluates that if the posture in $\hat { I } _ { s }$ matches the source pose $P _ { s }$ . To ensure correctness of our image generation, we use three different loss functions that capture different desired properties. The first is a simple reconstruction loss,
96
+
97
+ $$
98
+ L _ { r e c } = | | \hat { I } _ { s } - I _ { s } | | _ { 1 } .
99
+ $$
100
+
101
+ In addition, we use a perceptual loss (Johnson et al., 2016) that encourages both the ground truth and reconstructed image have similar semantic properties,
102
+
103
+ $$
104
+ L _ { p e r c } = \sum _ { i } | | \phi ^ { i } ( \hat { I } _ { s } ) - \phi ^ { i } ( I _ { s } ) | | _ { 1 } ,
105
+ $$
106
+
107
+ where $\phi ^ { i }$ is the ith layer of a VGG model (Simonyan & Zisserman, 2014) pretrained on ImageNet Deng et al. (2009). Finally, we use a style loss that penalizes discrepancies on colors and textures using the Gram matrix $\mathbb { G } ( \cdot )$ of the features,
108
+
109
+ $$
110
+ L _ { s t y l e } = \sum _ { i } | | \mathbb { G } ( \phi ^ { i } ( \hat { I } _ { s } ) ) - \mathbb { G } ( \phi ^ { i } ( I _ { s } ) ) | | _ { 1 } .
111
+ $$
112
+
113
+ Thus, our total loss can be written as,
114
+
115
+ $$
116
+ L _ { t o t a l } = \lambda _ { 1 } L _ { a d v } + \lambda _ { 2 } L _ { r e c } + \lambda _ { 3 } L _ { p e r c } + \lambda _ { 4 } L _ { s t y l e } .
117
+ $$
118
+
119
+ where $\lambda _ { 1 - 4 }$ are scalar hyperparameters. Additional training details are provided in Appendix A.
120
+
121
+ # 4 EXPERIMENTS
122
+
123
+ Datasets. We evaluate our proposed model on two benchmarks: DeepFashion (Liu et al., 2016) and Market1501 (Zheng et al., 2015). DeepFashion contains 52,712 high-quality images with a clean background. Market-1501 has 32,668 low-resolution images with various lighting conditions and a noisy background. Following Zhang et al. (2022); Wang et al. (2022), we select 8,570 test pairs with a resolution of $2 5 6 \times 2 5 6$ on DeepFashion, and 12,000 test pairs with a resolution of $1 2 8 \times 6 4$ on Market-1501. As in prior self-driven methods (Ma et al., 2021; Wang et al., 2022), we use 37,332 training images for DeepFashion and 12,112 training images for Market-1501.
124
+
125
+ Metrics. Following (Ma et al., 2021; Wang et al., 2022), we use Structural Similarity Index Measure (SSIM) (Wang et al., 2004), Frechet Inception Distance (FID) (Heusel et al., 2017) , Learned Perceptual Image Patch Similarity (LPIPS) (Zhang et al., 2018) and Inception Score (IS) (Salimans et al., 2016) to evaluate the quality of the synthesized images. Among these metrics, SSIM measures structural similarity in the pixel space. FID computes Wasserstein-2 distance between two distributions. LPIPS evaluates perceptual similarity in deep network’s feature space. We use the default AlexNet as LPIPS’s backbone. IS assesses the quality of images generated by adversarial training. On Market-1501, we add Masked-SSIM and Masked-LPIPS computed on the target person region to exclude the influence of the irrelevant background.
126
+
127
+ Table 1: Pose transfer results for $2 5 6 \times 2 5 6$ resolution images on DeepFashion. All results for prior work are taken from the original papers or produced with the author’s source code.
128
+
129
+ <table><tr><td>Method</td><td>FID↓</td><td>SSIM↑</td><td>LPIPS↓</td><td>IS↑</td></tr><tr><td>Supervised by paired images</td><td></td><td></td><td></td><td></td></tr><tr><td>PATN (Zhu et al., 2019)</td><td>24.071</td><td>0.770</td><td>0.299</td><td>3.141</td></tr><tr><td>GFLA (Ren et al., 2020)</td><td>10.573</td><td>0.707</td><td>0.234</td><td>3.635</td></tr><tr><td>PISE (Zhang et al., 2021a)</td><td>13.610</td><td>-</td><td>0.206</td><td>1</td></tr><tr><td>SPIG (Lv et al., 2021)</td><td>12.243</td><td>0.782</td><td>0.211</td><td>=</td></tr><tr><td>DPTN (Zhang et al.,2022)</td><td>11.466</td><td>0.778</td><td>0.196</td><td></td></tr><tr><td>CASD (Zhou et al., 2022)</td><td>11.373</td><td>0.725</td><td>0.194</td><td></td></tr><tr><td>NTED (Ren et al., 2022)</td><td>6.786</td><td>0.808</td><td>0.133</td><td>3.264</td></tr><tr><td>No paired images</td><td></td><td></td><td></td><td></td></tr><tr><td>VU-Net (Esser et al.,2018)</td><td>23.580</td><td>0.786</td><td>0.321</td><td>3.087</td></tr><tr><td>E2E (Song et al., 2019)</td><td>29.900</td><td>0.736</td><td>0.238</td><td>3.441</td></tr><tr><td>DPIG (Ma et al., 2018)</td><td>48.200</td><td>0.614</td><td>0.284</td><td>3.228</td></tr><tr><td>MUST (Ma et al.,2021)</td><td>15.902</td><td>0.742</td><td>-</td><td>3.692</td></tr><tr><td>SCM-Net Wang et al. (2022)</td><td>12.180</td><td>0.751</td><td>0.182</td><td>3.632</td></tr><tr><td>PT²(Ours)</td><td>8.338</td><td>0.795</td><td>0.158</td><td>3.469</td></tr></table>
130
+
131
+ Table 2: Pose transfer results for $1 2 8 \times 6 4$ resolution images on Market-1501. All results for prior work are taken from the original papers or produced with the author’s source code.
132
+
133
+ <table><tr><td>Method</td><td>FID↓</td><td>SSIM↑</td><td>M-SSIM↑</td><td>LPIPS↓</td><td>M-LPIPS↓</td><td>IS↑</td></tr><tr><td>Supervised by paired images</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>PATN (Zhu et al., 2019)</td><td>22.657</td><td>0.311</td><td>0.811</td><td>0.320</td><td>0.159</td><td></td></tr><tr><td>GFLA (Ren et al.,2020)</td><td>19.751</td><td>0.281</td><td>0.796</td><td>0.282</td><td>0.148</td><td></td></tr><tr><td>SPIG (Lv et al., 2021)</td><td>23.331</td><td>0.315</td><td>0.818</td><td>0.278</td><td>0.139</td><td></td></tr><tr><td>DPTN (Zhang et al., 2022)</td><td>18.995</td><td>0.285</td><td>1</td><td>0.271</td><td>1</td><td></td></tr><tr><td> No paired images</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>PT²(Ours)</td><td>17.389</td><td>0.280</td><td>0.820</td><td>0.314</td><td>0.122</td><td>2.789</td></tr></table>
134
+
135
+ # 4.1 QUANTITATIVE RESULTS
136
+
137
+ Table 1 compares methods on the pose transfer task using DeepFashion, where our approach outperforms most methods on FID, SSIM, and LPIP by a large margin. For example, we improve FID by 4 points over the state-of-the-art. Notably, our model, which requires no paired training data, also achieves better performance than most supervised methods trained with paired data. Similar behavior is seen on Market-1501 (Table 2), where our self-driven $\mathrm { P T ^ { 2 } }$ gains in Masked-SSIM and Masked-LPIPS over supervised methods. However, we note that we do perform worse according to SSIM and LPIPS, which is computed over the entire image rather than just the target person region.
138
+
139
+ To investigate the reason behind the discrepancy when we use masked regions for evaluation, we computed the SSIM scores on different body parts of the person. The average scores for background, arms, legs, clothes and head for $\mathrm { P T ^ { 2 } }$ are: 0.237, 0.263, 0.283, 0.323, 0.337, respectively. The lowest SSIM is on the background because the dataset is collected from surveillance videos, where the background can change drastically in different time frames. This violates our assumption that the background does not change, explaining the relatively poor performance. That said, since our goal is pose transfer, the improved performance using M-SSIM and M-LPIPS demonstrates we are more successful than even the supervised methods on Market-1501 at that task.
140
+
141
+ User Study. To verify the quality of generated images, we also conducted a human evaluation on DeepFashion using Amazon Mechanical Turk. We collected 3 judgements for 50 images (150 total). Each worker was presented 3 pictures: the true image, a $\mathrm { P T ^ { 2 } }$ generated image, and a image generated by a method from prior work. The worker was asked to pick a picture that looks most similar to the true image. Table 3 shows that among self-driven methods, more than $72 \%$ workers believe our method achieves higher fidelity in the generated images. Compared with approaches supervised by paired images, our method achieves comparable performance with an average of over $62 \%$ user preference, demonstrating the effectiveness of our proposed approach.
142
+
143
+ ![](images/630f609496292089e9c22e4a445158b42ae2ba38d7e278fdbe3a3729dc014820.jpg)
144
+ Figure 5: Qualitative pose transfer results on DeepFashion (left) and Market-1501 (right). We enlarged the area marked with a red bounding box for a better view of clothing details. Examples from prior work are generated with the author’s code and pretrained models. MUST, E2E, and our $\mathrm { P T ^ { 2 } }$ are trained with unpaired data, while the rest are supervised by paired data. These results show our approach transfers the original clothing patterns onto the target pose better than prior work.
145
+
146
+ Table 3: A/B user preferences on DeepFashion. We report how often our approach was selected as most like the ground truth image. The number that follows $\pm$ is the corresponding standard deviation. We significantly outperform methods trained without paired images. Our results were also preferred over fully supervised methods.
147
+
148
+ <table><tr><td></td><td colspan="3"> Supervised by paired images</td><td colspan="2">No paired images</td></tr><tr><td></td><td>PISE</td><td>DPTN</td><td>CASD</td><td>E2E</td><td>MUST</td></tr><tr><td>PT²</td><td>68.7%±3.27</td><td>66.2%±3.35</td><td>53.8%±3.53</td><td>79.7%±2.84</td><td>(Zhang et al.,2021a) (Zhang et al.,2022) (Zhou et al.,2022) (Song et al.,2019) (Ma et al.,2021) 72.6%±3.15</td></tr></table>
149
+
150
+ # 4.2 QUALITATIVE RESULTS
151
+
152
+ Pose Transfer. Figure 5 visualizes pose transfer results. We enlarged the area marked with a red bounding box for a better view of clothing details. In the first row (left), our method transferred the arm tattoos to the target pose while other methods either ignored this detail or failed to reconstruct the arm. Similarly, our model learns the color pattern in the second row (left) better than other approaches. This is because the small kernel encoder in our model can capture such detailed texture and thus reconstruct it based on the target pose. On the right side of Figure 5, compared with supervised pose transfer methods, our approach faithfully recovered the shape and color of the dress and shirt in the two examples. More examples, including failure cases, are in Appendix B.
153
+
154
+ Garment Replacement. With a given parsing map, our approach can also switch the clothing pieces on two persons. Let $I _ { A } = \left( A _ { p o s e } , A _ { c l t } \right)$ be an image of person $A$ wearing clothes $A _ { c l t }$ under posture $A _ { p o s e }$ . To replace $A _ { c l t }$ with $B _ { c l t }$ in $I _ { B } = ( B _ { p o s e } , B _ { c l t } )$ , we first align $A , B$ ’s pose to $A _ { p o s e }$ using the proposed pose transfer method, and then replace $A _ { c l t }$ to $B _ { c l t }$ using their parsing maps. To fix small mis-alignment after copy-paste $B _ { c l t }$ using the parsing map, the image is fed to $\mathrm { P T ^ { 2 } }$ again for a more plausible reconstruction. Due to the shape difference of the source and reference garments (e.g., jeans and shorts), the model could give different ways of combining all the clothing pieces after replacing a specific garment. For example, in Figure 6, for the person in the top second source image, the upper clothes are tucked into the shorts but untucked to the jeans. Similarly, the shorts in the top first source image are occluded by the camel t-shirt and pink jackets, but are visible when combined with other shirts. Overall, Figure 6 shows that the proposed method successfully replaces various types of garments in the given images while preserving their patterns and details.
155
+
156
+ # 4.3 ABLATION STUDY
157
+
158
+ We performed an ablation study to evaluate the effectiveness of each component of our model. In Table $4 , w / \theta$ . Input Permuting does not permute the inputs, which results in entangled pose and textures. Input Warping, w/o. Input Permuting uses Thin Plate Spline transformation (TPS) to warp the source image, which can be viewed as a mild way of disentangling the pose and texture at the image-level. w/o. Pose Branch removes the pose branch in our method. w/o. small kernel uses only large kernel in the feature encoders, which should lead to loss of clothing details. w/o. large kernel uses only small kernel in the feature encoders. We train all these ablation models under the same configuration. As shown in Table 4, our complete model $\mathrm { P T ^ { 2 } }$ improves all the metrics, demonstrating the effectiveness of each component.
159
+
160
+ ![](images/d0b0dd4c6e3e1a06f09a713be2a3f23dc1c286ae23be5cde2033cf212a2fdb32.jpg)
161
+ Figure 6: Examples of garment replacement. The left column is the source image and the top row is reference image. All reference garments are marked with red bounding boxes.
162
+
163
+ Table 4: Ablations in DeepFashion. Compare with each ablation model, our full model $\mathrm { P T ^ { 2 } }$ that combines all the components improves the overall performance.
164
+
165
+ <table><tr><td>Method</td><td>FID↓</td><td>SSIM↑</td><td>LPIPS↓</td><td>IS个</td></tr><tr><td>Input Warping, w/o. Input Permuting</td><td>10.011</td><td>0.781±0.072</td><td>0.178±0.060</td><td>3.579±0.086</td></tr><tr><td>w/o. Input Permuting</td><td>10.279</td><td>0.780±0.069</td><td>0.169±0.059</td><td>3.525±0.095</td></tr><tr><td>w/o. Pose Branch</td><td>11.391</td><td>0.785±0.068</td><td>0.177±0.068</td><td>3.485±0.095</td></tr><tr><td>w/o. small kernel</td><td>8.905</td><td>0.782±0.067</td><td>0.170±0.060</td><td>3.442±0.119</td></tr><tr><td>w/o. large kernel</td><td>9.275</td><td>0.785±0.068</td><td>0.166±0.060</td><td>3.401±0.078</td></tr><tr><td>PT²(Ours)</td><td>8.338</td><td>0.795±0.067</td><td>0.158±0.059</td><td>3.469±0.098</td></tr></table>
166
+
167
+ # 5 CONLUSION
168
+
169
+ We propose $\mathrm { P T ^ { 2 } }$ , a self-driven human pose transfer method that permutes the textures at random and then reconstructs the image with dual branch attention to achieve image-level disentanglement and detail-preserving texture transfer. The introduced dual kernel encoder in the model gives different sizes of receptive fields, which can reduce the noise caused by permutation and thus recovers clothing details while aligning pose and texture. Extensive experiments on DeepFashion and Market-1501 shows that our model improves the image quality of self-driven approaches, where a user study shows our images are preferred over prior work in $72 \%$ of cases. Moreover, it obtains comparable objective and subjective results to most pose transfer methods supervised by paired data.
170
+
171
+ # 6 REPRODUCIBILITY STATEMENT
172
+
173
+ We include our source code in the Supplementary for other researchers to easily reproduce our results in this paper. The code has a README file with detailed instructions of running and evaluating our model. The training details and all the hyperparameters we used in our approach are provided in Appendix A.
174
+
175
+ # 7 ETHICS STATEMENT
176
+
177
+ The proposed method introduces image-level disentanglement of pose and texture, and provides a self-driven framework for the human pose transfer task. The results of this research could be broadly disseminated by exploiting the publicly available source code. The research is beneficial to the research community in that it builds a unified framework for self-driven pose transfer, and gives insights to other exemplar-guided image generation tasks. From the perspective of ethical considerations, our method has the potential to be used as a tool through the spread of misinformation, which echos concerns have been addressed in related machine learning research (Ramesh et al., 2022; Karnouskos, 2020). It is of utmost importance to follow certain policies and regulations against misinformation (Pennycook et al., 2020) when using these AI technologies, as well as highlight the importance of developing methods for detecting misinformation, including for media created using artificial intelligence (e.g., Wang et al. (2020); Tan et al. (2020)).
178
+
179
+ # REFERENCES
180
+
181
+ Badour Albahar, Jingwan Lu, Jimei Yang, Zhixin Shu, Eli Shechtman, and Jia-Bin Huang. Pose with style: Detail-preserving pose-guided image synthesis with conditional styleGAN. ACM Transactions on Graphics, 2021.
182
+ 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.
183
+ Fabio M Carlucci, Antonio D’Innocente, Silvia Bucci, Barbara Caputo, and Tatiana Tommasi. Domain generalization by solving jigsaw puzzles. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2019.
184
+ Aiyu Cui, Daniel McKee, and Svetlana Lazebnik. Dressing in order: Recurrent person image generation for pose transfer, virtual try-on and outfit editing. In Proceedings of the IEEE International Conference on Computer Vision, 2021.
185
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In IEEE conference on computer vision and pattern recognition, 2009.
186
+ Aysegul Dundar, Kevin J Shih, Animesh Garg, Robert Pottorf, Anrew Tao, and Bryan Catanzaro. Unsupervised disentanglement of pose, appearance and background from images and videos. IEEE Transactions on Pattern Analysis and Machine Intelligence, 44(7):3883–3894, 2021.
187
+ Patrick Esser, Ekaterina Sutter, and Bjorn Ommer. A variational u-net for conditional appearance ¨ and shape generation. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2018.
188
+ Chen Gao, Si Liu, Ran He, Shuicheng Yan, and Bo Li. Recapture as you want. arXiv preprint arXiv:2006.01435, 2020.
189
+ Artur Grigorev, Artem Sevastopolsky, Alexander Vakhitov, and Victor Lempitsky. Coordinate-based texture inpainting for pose-guided human image generation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2019.
190
+ Rıza Alp Guler, Natalia Neverova, and Iasonas Kokkinos. Densepose: Dense human pose estimation ¨ in the wild. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2018.
191
+
192
+ Xintong Han, Xiaojun Hu, Weilin Huang, and Matthew R Scott. Clothflow: A flow-based model for clothed person generation. In Proceedings of the IEEE International Conference on Computer Vision, 2019.
193
+
194
+ 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 Advances in neural information processing systems, 2017.
195
+
196
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In Proceedings of the European conference on computer vision, 2016.
197
+
198
+ Stamatis Karnouskos. Artificial intelligence in digital media: The era of deepfakes. IEEE Transactions on Technology and Society, 1(3):138–147, 2020.
199
+
200
+ Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2019.
201
+
202
+ Jingyun Liang, Jiezhang Cao, Guolei Sun, Kai Zhang, Luc Van Gool, and Radu Timofte. Swinir: Image restoration using swin transformer. In Proceedings of the IEEE International Conference on Computer Vision, 2021.
203
+
204
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In ´ Proceedings of the European conference on computer vision, 2014.
205
+
206
+ Wen Liu, Zhixin Piao, Zhi Tu, Wenhan Luo, Lin Ma, and Shenghua Gao. Liquid warping GAN with attention: A unified framework for human image synthesis. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
207
+
208
+ Ziwei Liu, Ping Luo, Shi Qiu, Xiaogang Wang, and Xiaoou Tang. Deepfashion: Powering robust clothes recognition and retrieval with rich annotations. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2016.
209
+
210
+ Francesco Locatello, Stefan Bauer, Mario Lucic, Gunnar Raetsch, Sylvain Gelly, Bernhard Scholkopf, and Olivier Bachem. Challenging common assumptions in the unsupervised learn- ¨ ing of disentangled representations. In international conference on machine learning, 2019.
211
+
212
+ Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2015.
213
+
214
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019.
215
+
216
+ Zhengyao Lv, Xiaoming Li, Xin Li, Fu Li, Tianwei Lin, Dongliang He, and Wangmeng Zuo. Learning semantic person image generation by region-adaptive normalization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2021.
217
+
218
+ Liqian Ma, Qianru Sun, Stamatios Georgoulis, Luc Van Gool, Bernt Schiele, and Mario Fritz. Disentangled person image generation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2018.
219
+
220
+ Tianxiang Ma, Bo Peng, Wei Wang, and Jing Dong. MUST-GAN: Multi-level statistics transfer for self-driven person image generation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2021.
221
+
222
+ Mehdi Noroozi and Paolo Favaro. Unsupervised learning of visual representations by solving jigsaw puzzles. In Proceedings of the European conference on computer vision, 2016.
223
+
224
+ Gordon Pennycook, Ziv Epstein, Mohsen Mosleh, Antonio Arechar, Dean Eckles, and David Rand. Understanding and reducing the spread of misinformation online. ACR North American Advances, 2020.
225
+
226
+ Albert Pumarola, Antonio Agudo, Alberto Sanfeliu, and Francesc Moreno-Noguer. Unsupervised person image synthesis in arbitrary poses. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2018.
227
+
228
+ Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
229
+
230
+ Yurui Ren, Xiaoming Yu, Junming Chen, Thomas H Li, and Ge Li. Deep image spatial transformation for person image generation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2020.
231
+
232
+ Yurui Ren, Xiaoqing Fan, Ge Li, Shan Liu, and Thomas H Li. Neural texture extraction and distribution for controllable person image synthesis. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2022.
233
+
234
+ Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training GANs. In Advances in neural information processing systems, 2016.
235
+
236
+ Soubhik Sanyal, Alex Vorobiov, Timo Bolkart, Matthew Loper, Betty Mohler, Larry S Davis, Javier Romero, and Michael J Black. Learning realistic human reposing using cyclic self-supervision with 3d shape, pose, and appearance consistency. In Proceedings of the IEEE International Conference on Computer Vision, 2021.
237
+
238
+ Kripasindhu Sarkar, Dushyant Mehta, Weipeng Xu, Vladislav Golyanik, and Christian Theobalt. Neural re-rendering of humans from a single image. In Proceedings of the European conference on computer vision, 2020.
239
+
240
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations, 2014.
241
+
242
+ Sijie Song, Wei Zhang, Jiaying Liu, and Tao Mei. Unsupervised person image generation with semantic parsing transformation. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2019.
243
+
244
+ Reuben Tan, Bryan A. Plummer, and Kate Saenko. Detecting cross-modal inconsistency to defend against neural fake news. In Empirical Methods in Natural Language Processing (EMNLP), 2020.
245
+
246
+ Reuben Tan, Bryan Plummer, Kate Saenko, Hailin Jin, and Bryan Russell. Look at what i’m doing: Self-supervised spatial grounding of narrations in instructional videos. In Advances in Neural Information Processing Systems, 2021.
247
+
248
+ Hao Tang, Song Bai, Li Zhang, Philip HS Torr, and Nicu Sebe. XingGAN for person image generation. In Proceedings of the European Conference on Computer Vision, 2020.
249
+
250
+ Jilin Tang, Yi Yuan, Tianjia Shao, Yong Liu, Mengmeng Wang, and Kun Zhou. Structure-aware person image generation with pose decomposition and semantic correlation. In Proceedings of the AAAI Conference on Artificial Intelligence, 2021.
251
+
252
+ Sheng-Yu Wang, Oliver Wang, Richard Zhang, Andrew Owens, and Alexei A Efros. Cnn-generated images are surprisingly easy to spot...for now. In IEEE conference on computer vision and pattern recognition, 2020.
253
+
254
+ Zhou Wang, Alan C Bovik, Hamid R Sheikh, and Eero P Simoncelli. Image quality assessment: from error visibility to structural similarity. IEEE transactions on image processing, 13(4):600– 612, 2004.
255
+
256
+ Zijian Wang, Xingqun Qi, Kun Yuan, and Muyi Sun. Self-supervised correlation mining network for person image generation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2022.
257
+
258
+ Han Yang, Ruimao Zhang, Xiaobao Guo, Wei Liu, Wangmeng Zuo, and Ping Luo. Towards photorealistic virtual try-on by adaptively generating-preserving image content. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2020a.
259
+
260
+ Hongtao Yang, Tong Zhang, Wenbing Huang, Xuming He, and Fatih Porikli. Towards purely unsupervised disentanglement of appearance and shape for person images generation. In Proceedings of the International Workshop on Human-Centric Multimedia Analysis, 2020b.
261
+
262
+ Yasin Yaz, Chuan-Sheng Foo, Stefan Winkler, Kim-Hui Yap, Georgios Piliouras, Vijay Chandrasekhar, et al. The unusual effectiveness of averaging in GAN training. In International Conference on Learning Representations, 2019.
263
+
264
+ Ruiyun Yu, Xiaoqi Wang, and Xiaohui Xie. Vtnfp: An image-based virtual try-on network with body and clothing feature preservation. In Proceedings of the IEEE international conference on computer vision, 2019.
265
+
266
+ Jinsong Zhang, Kun Li, Yu-Kun Lai, and Jingyu Yang. Pise: Person image synthesis and editing with decoupled GAN. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2021a.
267
+
268
+ Pengze Zhang, Lingxiao Yang, Jian-Huang Lai, and Xiaohua Xie. Exploring dual-task correlation for pose guided person image generation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2022.
269
+
270
+ Quan Zhang, Jianhuang Lai, Zhanxiang Feng, and Xiaohua Xie. Seeing like a human: Asynchronous learning with dynamic progressive refinement for person re-identification. IEEE Transactions on Image Processing, 31:352–365, 2021b.
271
+
272
+ Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2018.
273
+
274
+ Ziwei Zhang, Chi Su, Liang Zheng, and Xiaodong Xie. Correlating edge, pose with parsing. In IEEE Conference on Computer Vision and Pattern Recognition, 2020.
275
+
276
+ Liang Zheng, Liyue Shen, Lu Tian, Shengjin Wang, Jingdong Wang, and Qi Tian. Scalable person re-identification: A benchmark. In Proceedings of the IEEE international conference on computer vision, 2015.
277
+
278
+ Xinyue Zhou, Mingyu Yin, Xinyuan Chen, Li Sun, Changxin Gao, and Qingli Li. Cross attention based style distribution for controllable person image synthesis. In Proceedings of the European conference on computer vision, 2022.
279
+
280
+ Zhen Zhu, Tengteng Huang, Baoguang Shi, Miao Yu, Bofei Wang, and Xiang Bai. Progressive pose attention transfer for person image generation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2019.
281
+
282
+ ![](images/8f9fa37bee3fc66c5cf0fbb73132b83b2eee491364c42c4f0fdbd957ba43295b.jpg)
283
+ Figure 7: Additional pose transfer examples on DeepFashion.
284
+
285
+ # A TRAINING DETAILS.
286
+
287
+ We use AdamW optimizer (Loshchilov & Hutter, 2019) for training with $\beta _ { 1 } = 0 . 5 , \beta _ { 2 } = 0 . 9 9 9 .$ . The initial learning rate is set to $1 0 ^ { - 3 }$ and decays to $2 \times 1 0 ^ { - 4 }$ after five starting epochs. The trade-off parameters are set to $\lambda _ { 1 } = 2 . 0 , \lambda _ { 2 } = 5 . 0 , \lambda _ { 3 } = 0 . 5$ , $\lambda _ { 4 } = 1 5 0$ in all experiments. The patch size is $1 6 \times 1 6$ for DeepFashion and $8 \times 8$ for Market-1501. To stabilize the training, we use the EMA strategy Yaz et al. (2019) to average the learned weights of the generator. Our pose representation is predicted by DensePose (Guler et al., 2018) and the parsing maps are obtained from CorrPM ¨ (Zhang et al., 2020). We found that the predicted dense pose in Market-1501 has poor quality as the image resolution is too low $( 1 2 8 \times 6 4 )$ for the DensePose model. Therefore, we use an offline super resolution model Liang et al. (2021) to upsample the Market-1501 images to $5 1 2 \times 2 5 6$ , get dense pose from these images, and then downsample the pose to the original image resolution $( 1 2 8 \times 6 4 )$ for our pose transfer task. We also add human keypoints predicted from OpenPose (Cao et al., 2019) as part of the pose representation to improve the accuracy of predicted posture on Market-1501.
288
+
289
+ # B DISCUSSIONS
290
+
291
+ Failure case analysis. Figure 7 provides several successful examples generated by the propsoed method on DeepFashion. However, one limitation of our model is that it relies on the segmentation map and DensePose prediction of the source image to obtain semantic and position information for the permuted textures. Thus, we found the accuracy of human parser and DensePose model greatly affects the transfer results. Figure 8 shows several failed examples due to this type of inaccuracy. In the first row, the coat wrapped around the dress was misrecognized as part of the dress in the parsing map, for which our generated back view incorrectly mixes up their textures. Similarly, the skirt in the second row was classified as shorts in the parsing map. As a result, our generator infers the occluded clothing piece as shorts in the front view. In the last row, the color of skirt is half-black and halfwhite because the skirt piece was not identified in the parsing map. More analysis on ablations. We present some visualized examples in Figure 9 to show the functionality of each component of our model. It’s clear that models with less perturbation of the input texture (i.e., w/o. Input Permuting and Input Warping) fail at large pose changes (e.g., from back view to front full view in the bottom row). Removing the pose branch (w/o. Pose Branch) causes loss of length information, resulting in extended dress in the second row. Without the small-kernel encoder (w/o. small kernel), the ablation model correctly transfers color and shape, but fails to recover complex clothing patterns and details in the third row. Without large kernel (w/o. large kernel), the model can correctly reconstruct clothes with singular color, but is less capable of transferring detailed textures (see the third and fourth row). To see if the large-kernel encoder is learning certain low-level information from permuted patches, we also tried replacing the inputs of the large-kernel encoder with heavily Gaussian blurred image without permutation. From the examples, we can see that images generated by $w .$ blur are much worse compared to the full model. This suggests that features learned by large-kernel encoder from the permuted image might have richer information than Gaussian blurred texture.
292
+
293
+ ![](images/294d67c7c1c181e865d3fb25958e69c9aad11960f1a0f5a572498ae4527c4d1b.jpg)
294
+ Figure 8: Failure cases in DeepFashion. Many failures are due to incorrect predictions of the source UV map and source parsing map.
295
+
296
+ ![](images/5f033af2f7020a2d905e7f6e9a262b37ccf0c222fb763e3f8c7f9c3d53c9a68c.jpg)
297
+ Figure 9: Generated images of ablations of our model. Each component of our model improves the transfer of shape information and detailed clothing patterns, resulting in our full model obtaining the best results.
298
+
299
+ ![](images/08b6d34fad50ea24aae456dddcde4a67878ecb6dd799a4fffd843f2bcb7f1f86.jpg)
300
+ Figure 10: Visualized feature map of the encoded texture features. The feature map is overlaid with the source image. The source image is downsampled to the resolution of the feature map. Each triplet includes a downsampled source image, the feature map from large-kernel encoder, and the feature map from small-kernel encoder. Red indicates higher value and blue means smaller value.
301
+
302
+ To further explore the differences of texture features learned by the large-kernel encoder and the small-kernel encoder, we sum up the encoded feature maps across all channels in the texture branch, and normalize their values to be in range [0, 1]. Then we downsample the image to the resolution of the feature map and overlay the normalized feature map with the downsampled source image. In Figure 10, each triplet includes the downsampled source image, the feature map from largekernel encoder, and the feature map from small-kernel encoder. Feature map given by large-kernel encoder (middle image in each triplet) appears to be much smoother than that of the small-kernel encoder (right image in each triplet). This suggests that large-kernel encoder might be learning coarse information from the clothing piece (e.g., color and shape), while small-kernel encoder is learning more fine-grained patterns (e.g., stripe and pleat).
md/dev/uu6Oq7MN7g/uu6Oq7MN7g.md ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CodeT5+: Open Code Large Language Models for Code Understanding and Generation
2
+
3
+ Yue Wang∗, Hung Le∗, Akhilesh Deepak Gotmare, Nghi D.Q. Bui, Junnan Li, Steven C.H. Hoi Salesforce AI Research https://github.com/salesforce/CodeT5/tree/main/CodeT5+
4
+
5
+ # Abstract
6
+
7
+ Large language models (LLMs) pretrained on vast source code have achieved prominent progress in code intelligence. However, existing code LLMs have two main limitations. First, they often adopt a specific architecture (encoder-only or decoder-only) or rely on a unified encoder-decoder network for different downstream tasks, lacking the flexibility to operate in the optimal architecture for a specific task. Secondly, they often employ a limited set of pretraining objectives which might not be relevant to some tasks and hence result in substantial performance degrade. To address these limitations, we propose “CodeT $5 + "$ , a family of encoder-decoder LLMs for code in which component modules can be flexibly combined to suit a wide range of code tasks. Such flexibility is enabled by our proposed mixture of pretraining objectives, which cover span denoising, contrastive learning, text-code matching, and causal LM pretraining tasks, on both unimodal and bimodal multilingual code corpora. Furthermore, we propose to initialize CodeT5+ with frozen off-the-shelf LLMs without training from scratch to efficiently scale up our models, and explore instruction-tuning to align with natural language instructions. We extensively evaluate ${ \mathrm { C o d e T } } 5 +$ on over 20 coderelated benchmarks in different settings, including zero-shot, finetuning, and instructiontuning. We observe state-of-the-art (SoTA) performance on various code-related tasks, and our instruction-tuned CodeT5 $\uplus$ 16B achieves new SoTA results of $3 5 . 0 \%$ pass $@ 1$ and $5 4 . 5 \%$ pass $@ 1 0$ on the HumanEval code generation task against other open code LLMs, even surpassing the OpenAI code-cushman-001 model.
8
+
9
+ # 1 Introduction
10
+
11
+ Large language models (LLMs) (Chen et al., 2021; Wang et al., 2021b; Nijkamp et al., 2023b) have recently demonstrated remarkable success in a broad set of downstream tasks in the code domain (Husain et al., 2019; Lu et al., 2021; Hendrycks et al., 2021). By pretraining on massive code-based data (e.g. GitHub public data), these code LLMs can learn rich contextual representations which can be transferred to various code-related downstream tasks. However, we found that many existing models are designed to perform well only in a subset of tasks. We argue that this is mainly due to two limitations in terms of architecture and pretraining tasks.
12
+
13
+ From an architectural perspective, existing code LLMs often adopt encoder-only or decoder-only models that perform well only on certain understanding or generative tasks. Specifically, encoderonly models (Feng et al., 2020; Guo et al., 2021) are often used to facilitate understanding tasks such as text-to-code retrieval (Lu et al., 2021). For generative tasks such as code generation (Chen et al., 2021; Hendrycks et al., 2021), decoder-only models (Chen et al., 2021; Nijkamp et al., 2023b) often demonstrate stronger performance. However, these decoder-only models are often not ideal for understanding tasks such as detection tasks compared to encoder-only models (Nijkamp et al., 2023a).
14
+
15
+ Besides, several models have adopted more unified encoder-decoder architectures (Wang et al., 2021b; Ahmad et al., 2021) to adapt to different types of tasks. While these models can support both understanding and generative tasks, they still suffer from suboptimal performance on certain tasks. Guo et al. (2022) found that encoder-decoder models fail to beat (state-of-the-art) SoTA encoder-only or decoder-only baselines on retrieval and code completion tasks respectively. This shortfall is due to the limitation of the single-module architecture generally adapted to all tasks. In summary, prior approaches are not designed with compositionality such that individual components can be activated to better suit different types of downstream tasks.
16
+
17
+ From a learning objective perspective, current models employ a limited set of pretraining tasks.
18
+
19
+ ![](images/6762e5018712efc9935b135569523d5e6e3214a9b28097efa4e6884945caac9b.jpg)
20
+ Figure 1: An overview of our CodeT $^ { \circ + }$ , a family of code LLMs for code understanding and generation.
21
+
22
+ These tasks can lead to performance degrade on certain downstream tasks due to the discrepancy between the pretraining and finetuning stage. For instance, T5-based models such as (Wang et al., 2021b) are often trained with a span denoising objective. However, in downstream tasks such as code generation (Chen et al., 2021; Hendrycks et al., 2021), most SoTA models are pretrained with a next-token prediction objective which autoregressively predicts a program token by token. Furthermore, many models are not trained to learn contrastive code representations that are vital for understanding tasks such as text-to-code retrieval. Although recent attempts (Guo et al., 2022; Wang et al., 2021a) introduce a contrastive learning task to alleviate this issue, these approaches ignore the fine-grained text-code cross-modal alignments.
23
+
24
+ To address the above limitations, we propose “CodeT $\ " 5 + \ " { }$ , a new family of encoder-decoder code foundation LLMs for a wide range of code understanding and generation tasks (see Fig. 1 for an overview). Despite being an encoder-decoder based model, our CodeT $^ { 5 + }$ can flexibly operate in encoder-only, decoder-only, and encoder-decoder modes to suit different downstream applications. Such flexibility is enabled by our proposed pretraining tasks, which include span denoising and causal language modeling (CLM) tasks on code data and text-code contrastive learning, matching, and CLM tasks on text-code data. We found that such a wide set of pretraining tasks can help learn rich representations from both code and text data, and bridge the pretrain-finetune gap in various downstream applications. Besides, we show that the integration of the matching task with contrastive learning is crucial to capture the fine-grained text-code alignments and improve retrieval performance.
25
+
26
+ Furthermore, we scale up the model size of
27
+
28
+ CodeT $^ { 5 + }$ with a compute-efficient pretraining strategy by leveraging off-the-shelf code LLMs to initialize the components of ${ \mathrm { C o d e T } } 5 +$ . Specifically, we employ a “shallow encoder and deep decoder” architecture (Li et al., 2022b), where both encoder and decoder are initialized from pretrained checkpoints and connected by cross-attention layers. We freeze the deep decoder LLM and only train the shallow encoder and cross-attention layers, largely reducing the number of trainable parameters for efficient tuning. Finally, recent work in the NLP domain (Taori et al., 2023; Wang et al., 2022; Ouyang et al., 2022) inspired us to explore ${ \mathrm { C o d e T } } 5 +$ with instruction tuning to better align the models with natural language instructions.
29
+
30
+ We extensively evaluate ${ \mathrm { C o d e T } } 5 +$ on over 20 code-related benchmarks under various settings, including zero-shot, finetuning, and instructiontuning. Results show that CodeT $^ { 5 + }$ yields substantial performance gains on many downstream tasks compared to their SoTA baselines, e.g., 8 text-to-code retrieval tasks $+ 3 . 2$ avg. MRR), 2 line-level code completion tasks $( + 2 . 1$ avg. Exact Match), and 2 retrieval-augmented code generation tasks ( $_ { + 5 . 8 }$ avg. BLEU-4). In 2 math programming tasks on MathQA and GSM8K benchmarks (Austin et al., 2021; Cobbe et al., 2021), CodeT $^ { 5 + }$ models of below billion-parameter sizes significantly outperform many LLMs of up to 137B parameters. Particularly, in the zero-shot text-to-code generation task on HumanEval benchmark (Chen et al., 2021), our instruction-tuned CodeT $5 +$ 16B sets new SoTA results of $3 5 . 0 \%$ pass $@ 1$ and $5 4 . 5 \%$ pass $@ 1 0$ against other open code LLMs, even surpassing the closed-source OpenAI code-cushman001 model. Finally, we showcase that CodeT $^ { 5 + }$ can be seamlessly adopted as a semi-parametric retrieval-augmented generation system.
31
+
32
+ ![](images/e0c13d79f591975aff25d2e317329d6e46afe2609a0a2fd64b17b24e7dd658f9.jpg)
33
+ Figure 2: Model architecture of CodeT $^ { 5 + }$ . S1: first stage pretraining with unimodal code data, S2: second stage pretraining with bimodal code-text data. The diagram on the right shows our proposed compute-efficient training with frozen code LLMs to scale up the model. We employ a “shallow encoder and deep decoder” architecture and only keep the small encoder and the cross-attention layers trainable while freezing the deep decoder LLM.
34
+
35
+ # 2 Related Work
36
+
37
+ Following the success of LLMs such as BERT (Devlin et al., 2019) and GPT (Radford et al., 2019) in natural language processing (NLP), recent years witness a surge of research work of LLMs in the code domain, leading to new SoTA results on various code-related tasks. Typically, code LLMs can be categorized into three architectures: encoderonly models (Feng et al., 2020), decoder-only models (Chen et al., 2021; Nijkamp et al., 2023b), and encoder-decoder models (Ahmad et al., 2021; Wang et al., 2021b). For encoder-only and decoderonly models, they are often ideal for either understanding tasks such as code retrieval (Husain et al., 2019) or generation tasks such as code synthesis (Chen et al., 2021) respectively. For encoderdecoder models, they can be adapted to both code understanding and generation but do not always achieve better performance (Wang et al., 2021b). In this work, we propose a new family of encoderdecoder code LLMs “CodeT $\ " 5 + \ " { }$ that can flexibly operate in various modes, including encoder-only, decoder-only, and encoder-decoder models.
38
+
39
+ Prior code LLMs are also limited by their pretraining tasks, which are not perfect to transfer the models to some downstream tasks. For instance, T5-based models such as (Wang et al., 2021b) pretrained with span denoising objective are not ideal for auto-regressive generation tasks like next-line code completion (Guo et al., 2022), as these models are trained to recover short spans of limited lengths rather than a whole program.1 Inspired by recent advances in NLP research (Tay et al., 2022; Soltan et al., 2022), we explore to combine span denoising with CLM tasks to improve the model with better causal generation capability (Le et al., 2022). Additionally, most models do not have specific pretraining tasks (e.g. contrastive learning) to facilitate the learning of contextual representations that can distinguish code samples of different semantics. This can lead to suboptimal performance on code understanding tasks like code retrieval (Husain et al., 2019). In light of this, we include a contrastive learning task to learn better unimodal representations and a matching task to learn richer bimodal representations, which has been shown helpful in vision-language retrieval tasks (Li et al., 2021).
40
+
41
+ # 3 CodeT5+: Open Code LLMs
42
+
43
+ We develop CodeT $^ { 5 + }$ , a new family of open code LLMs for code understanding and generation tasks (see Fig. 1 for an overview and more architecture/pretraining details in Fig. 2 and Fig. 3). Based on the encoder-decoder architecture (Wang et al., 2021b), CodeT $^ { 5 + }$ is enhanced with the flexibility to operate in various modes for different downstream tasks through our proposed mixture of pretraining objectives, which are performed on two stages of pretraining on unimodal (Sec. 3.1) and bimodal data (Sec. 3.2). We found that this stage-wise training approach can efficiently expose our models to more diverse data to learn rich contextual representations. Finally, we explore initializing CodeT $^ { 5 + }$ with off-the-shelf code LLMs to efficiently scale up the model without training from scratch (Sec. 3.3).
44
+
45
+ ![](images/48300ae5e43240d65376f7643ab43bb77974ec1b45cc1f305d3bac23f0d19c20.jpg)
46
+ Figure 3: Self-supervised pretraining on code data: we pretrain ${ \mathrm { C o d e T } } 5 +$ on code data using a mixture of tasks: (i) span denoising (Top); (ii) decoder-only causal LM (Middle); and (iii) Seq2Seq causal LM (Bottom). This mixture of tasks lets the models learn meaningful representations of code contexts and recover missing information at different levels: code spans, partial programs, and complete programs.
47
+
48
+ # 3.1 Unimodal Pretraining on Code Data
49
+
50
+ In the first stage, we pretrain CodeT $^ { 5 + }$ on largescale code unimodal data, which can be obtained from open-source platforms like GitHub. Although such data also contain texts such as user-written code comments, we denote unimodal data to distinguish them with bimodal data of text-code pairs in the second pretraining stage. In this stage, we pretrain the model from scratch using a mixture of span denoising and CLM tasks as shown in Fig. 3. These tasks enable the model to learn to recover code contexts at different scales: code spans, partial programs, and complete programs.
51
+
52
+ Span Denoising. Similar to T5 (Raffel et al., 2020), we randomly replace $1 5 \%$ of the tokens with indexed sentinel tokens (like [MASK0]) in the encoder inputs, and require the decoder to recover them via generating a combination of these spans. We follow CodeT5 to employ whole-word masking by sampling spans (span lengths determined by a uniform distribution with a mean of 3) before subword tokenization to avoid masking partial words.
53
+
54
+ Causal Language Modeling (CLM). Inspired by Tay et al. (2022); Soltan et al. (2022), we introduce two variants of CLM to optimize our model for auto-regressive generation. In the first variant, we randomly select a pivot location and regard the context before it as the source sequence and the sequence after it as the target output. We denote this variant as a sequence-to-sequence (Seq2Seq) causal LM objective. We restrict the pivot location to be uniformly sampled between $1 0 \%$ and $9 0 \%$ of the whole sequence and prepend a special token [CLM] to the source sequence. The second CLM variant is a decoder-only generation task, where we always pass a [CLM] token to the encoder input and require the decoder to generate the full code sequence. This task aims to provide more dense supervision signals to train the decoder as an independent full-fledged code generation module.
55
+
56
+ # 3.2 Bimodal Pretraining on Text-code Data
57
+
58
+ In the second stage, we pretrain the model using text-code bimodal data at function level (Husain et al., 2019). In this setting, each text-code pair contains a code function and its corresponding docstring describing its semantics. Such a bimodal data format facilitates model training for crossmodal understanding and generation. The bimodal pretraining tasks consist of cross-modal contrastive learning, matching, and causal LM tasks (Fig. 2). See Appendix A for their detailed formulations.
59
+
60
+ Text-Code Contrastive Learning. This task aims to align the feature space of text and code representations by pulling together the representations of positive text-code pairs and pulling apart the negative pairs. Guo et al. (2022) demonstrated the benefits of such learning task for code understanding. This task only activates the encoder, which encodes a text or code snippet into a representation through bidirectional self-attention (Vaswani et al., 2017). Similar to BERT (Devlin et al., 2019), we prepend a special token [CLS] to the input and regard its output embeddings at the final layer as the representations of the corresponding input text or code. We further add a linear layer and use L2 normalization to map the output to 256- $d$ embeddings. To enrich the negative samples, we use a momentum encoder to store embeddings of samples from previous mini-batches, as similarly adopted by (He et al., 2020; Li et al., 2022a). Specifically, the momentum encoder maintains a queuing system that enqueues the samples in the current mini-batch and dequeues the samples in the oldest mini-batch.
61
+
62
+ Text-Code Matching. This task activates the decoder and aims to predict whether a text and code snippet share the same semantics. Such task enables model to learn better bimodal representations that capture the fine-grained alignment between text and code modalities. Given a code sample, the decoder first passes it to an embedding layer and a causal self-attention layer. The representations are then passed to a cross-attention layer which queries relevant signals from the text representations (received from the encoder). A task-specific [Match] token is prepended to the code input sequence to inform the decoder of the text-code matching functionality, and an [EOS] token is appended to the end of the code input. Since the decoder employs causal self-attention masks and only the last decoder token can attend to the whole context, we treat the output embedding of [EOS] at the last layer as the text-code alignment representation. Finally, we use a linear layer on top of the output embedding of the decoder for a binary matching task, predicting whether a text-code pair is positive (matched) or negative (unmatched).
63
+
64
+ Text-Code Causal LM. This task activates both encoder and decoder and focuses on a cross-modal generative objective through a dual multimodal conversion: text-to-code generation and code-to-text generation. Specifically, when the input is a text sample, we prepend a [CDec] token to the input sequence to the decoder. In this case, the decoder operates under code generation functionality. Alternatively, when the input is a code sample, we prepend a [TDec] token to the input sequence to the decoder. The decoder operates under text generation functionality in this case. This type of Causal LM has been shown to be an effective learning objective to close the pretrain-finetune gap for generative downstream tasks (Wang et al., 2021b).
65
+
66
+ # 3.3 Compute-efficient Pretraining with Frozen Off-the-shelf LLMs
67
+
68
+ To efficiently scale up the model without the need of pretraining from scratch, we propose a computeefficient pretraining strategy to initialize model components (i.e. encoder and decoder) of CodeT $^ { 5 + }$ with off-the-shelf pretrained LLMs (Nijkamp et al., 2023b) (see the rightmost diagram of Fig. 2). For this extension, inspired by (Li et al., 2022b), we employ a “shallow encoder and deep decoder” architecture instead of encoder and decoder of the same size in conventional T5 models (Raffel et al.,
69
+
70
+ 2020; Wang et al., 2021b). As noted by Li et al. (2022b), the decoder is often required to deal with a higher level of complexity in generation tasks and thus, should be enhanced with more parameters.
71
+
72
+ To connect the separately pretrained encoder and decoder, we insert randomly initialized crossattention layers to decoder blocks after the selfattention layers. For efficient tuning, we only insert cross-attention layers to the top- $L$ decoder layers ( $\scriptstyle { \mathrm { . } } L = 1$ in our experiments). We only keep the small encoder and cross-attention layers trainable while freezing the majority of the decoder parameters. We also explored other advanced designs such as adding a gating function to improve training stability or inserting multiple cross-attention layers at a certain frequency (Alayrac et al., 2022). However, we did not observe significant performance improvement and these design choices would introduce too expensive computation overhead.
73
+
74
+ # 3.4 Adaptation to Downstream Understanding and Generation Tasks
75
+
76
+ After the two stages of pretraining, CodeT $^ { 5 + }$ can flexibly operate in various modes to support different tasks, including Seq2Seq generation tasks, decoder-only tasks, and understanding-based tasks:
77
+
78
+ Seq2Seq Generation Tasks. As an encoderdecoder model, CodeT $^ { 5 + }$ can be naturally adapted to a variety of Seq2Seq generation tasks such as code generation and summarization. We also adapt CodeT $^ { 5 + }$ as a retrieval-augmented generation model, using the encoder to retrieve code snippets, which are then used by both the encoder and decoder for code generation.
79
+
80
+ Decoder-only Tasks. In this setting, we always feed a [CLM] token to the encoder input and pass the source sequence to the decoder as the prefix context. We freeze the weights of the encoder and the cross-attention layers in the decoder. This strategy only activates parts of the decoder and reduces about half of the total model parameters. We use next-line code completion tasks to evaluate the decoder-only generation capability of ${ \mathrm { C o d e T } } 5 +$ .
81
+
82
+ Understanding Tasks. CodeT $^ { 5 + }$ can support these understanding tasks in two ways: first, it employs the encoder to obtain text/code embeddings, which can be either passed to a binary classifier for detection tasks; alternatively, the encoder can be combined with the decoder to predict the text-code matching scores for text-to-code retrieval tasks.
83
+
84
+ # 4 Pretraining and Instruction Tuning
85
+
86
+ Additional pretraining and finetuning setups can be found in Appendix B, C, and E.
87
+
88
+ Pretraining Dataset. We enlarge the pretraining dataset of CodeSearchNet (Husain et al., 2019) with the recently released GitHub Code dataset2. We select nine PLs (Python, Java, Ruby, JavaScript, Go, PHP, C, $\mathrm { C } { + + }$ , C#) and filter the dataset by preserving only permissively licensed code3 and files with 50 to 2000 tokens. Besides, we filter out the overlapped subset with CodeSearchNet and other downstream tasks covered in our evaluation by checking their GitHub repository names. Note that although we employ the deduplicated data version in which duplicates are filtered out based on the exact match, there might be some potential remaining duplicates. However, we do not expect any remaining duplication will impact our model performance significantly. We use the CodeT5 tokenizer to tokenize the multilingual dataset, resulting in 51.5B tokens, ${ \sim } 5 0 \mathrm { x }$ larger than CodeSearchNet.
89
+
90
+ Pretraining Setup. We pretrained two groups of CodeT5+ models: 1) CodeT $^ { 5 + }$ 220M and 770M that are trained from scratch following T5’s architecture (Raffel et al., 2020) (T5-base and large respectively), 2) CodeT $^ { 5 + }$ 2B, 6B, 16B in which the decoders are initialized from CodeGen-mono 2B, 6B, 16B models (Nijkamp et al., 2023b) and its encoders are initialized from CodeGen-mono 350M. Note that following our model scaling strategy, the latter group of CodeT $^ { 5 + }$ models introduce insignificant trainable parameters (the 350M encoder plus one cross-attention layer of 36M, 67M, 151M for 2B, 6B, 16B models respectively) compared to the original CodeGen models. We employ the CodeT5 tokenizer and CodeGen tokenizer for these two groups of models respectively. In pretraining, we adopt a stage-wise strategy to pretrain CodeT5+ first on the large-scale unimodal dataset and then on the smaller bimodal dataset on a cluster with 16 A100-40G GPUs on Google Cloud Platform.
91
+
92
+ Instruction Tuning. In the NLP domain, recent work (Wang et al., 2022; Taori et al., 2023) studied the benefits of data augmentation techniques on pretrained LMs with synthetic instruction data. Models finetuned with this type of data can better understand natural language instructions and demonstrate improved alignment with the corresponding tasks (Wang et al., 2022; Ouyang et al., 2022). We are motivated to transfer this technique to the code domain to improve our CodeT $^ { 5 + }$ models. Following Taori et al. (2023), we employ over $2 0 \mathrm { k }$ instruction data in the code domain curated by Chaudhary (2023). The data is generated by letting pretrained LLMs i.e. text-davinci-003, generate novel tasks, including task instructions, inputs (if any), and expected outputs. We trained our models on this augmented dataset for up to 3 epochs and denote the instruction-tuned models as “InstructCode $\Gamma 5 + "$ . Note that the instruction data are generated fully independently from any downstream evaluation tasks and we still evaluate these models in a zero-shot manner.
93
+
94
+ # 5 Experiments
95
+
96
+ We extensively evaluate ${ \mathrm { C o d e T } } 5 +$ on a wide range of code understanding and generation tasks over $^ { 2 0 + }$ code-related datasets across 9 different programming languages (PLs). In addition, we consider a variety of evaluation settings including zeroshot, instruction tuning, task-specific finetuning. Additional results can be found in Appendix D.
97
+
98
+ Baselines. We developed a family of CodeT5+ models, with model sizes ranging from 220M to 16B. We compare CodeT5+ with 3 types of models: encoder-only, decoder-only, and encoder-decoder.
99
+
100
+ • For encoder-only models, we consider RoBERTa (Liu et al., 2019), CodeBERT (Feng et al., 2020), GraphCodeBERT (Guo et al., 2021), SYNCOBERT (Wang et al., 2021a) and UniXcoder (Guo et al., 2022) that incorporates contrastive learning. Note that UniXcoder can be also viewed as decoder-only model as it employs UniLM-style masking (Dong et al., 2019).
101
+
102
+ • For decoder-only models, we consider GPT2 (Radford et al., 2019) and CodeGPT (Lu et al., 2021), and also consider models of very large scales (up to 540B) such as PaLM (Chowdhery et al., 2022), GPT-4 (OpenAI, 2023), Codex (Chen et al., 2021), LLaMA (Touvron et al., 2023), CodeGen (Nijkamp et al., 2023b), Incoder (Fried et al., 2022), GPT-J (Wang and Komatsuzaki, 2021), GPT-Neo and GPT-NeoX (Black et al., 2022), MIM (Nguyen et al., 2023), CodeGeeX (Zheng et al., 2023). We also compare with Replit (replit, 2023) and StarCoder (Li et al., 2023) which are concurrent work with ours.
103
+
104
+ Table 1: Results of $p a s s @ k ( \% )$ on HumanEval.
105
+
106
+ <table><tr><td>Model</td><td>Model size</td><td>pass@1</td><td>pass@10</td><td>pass@100</td></tr><tr><td colspan="5">Closed-source models</td></tr><tr><td>LaMDA</td><td>137B</td><td>14.0</td><td>=</td><td>47.3</td></tr><tr><td>AlphaCode</td><td>1.1B</td><td>17.1</td><td>28.2</td><td>45.3</td></tr><tr><td>MIM</td><td>2.7B</td><td>30.7</td><td>48.2</td><td>69.6</td></tr><tr><td>PaLM</td><td>62B</td><td>15.9</td><td>-</td><td>46.3</td></tr><tr><td>PaLM</td><td>540B</td><td>26.2</td><td>-</td><td>76.2</td></tr><tr><td>code-cushman-001</td><td>-</td><td>33.5</td><td>54.3</td><td>77.4</td></tr><tr><td>code-davinci-002</td><td></td><td>47.0</td><td>74.9</td><td>92.1</td></tr><tr><td>GPT-3.5</td><td></td><td>48.1</td><td></td><td>=</td></tr><tr><td>GPT-4</td><td>=</td><td>67.0</td><td>-</td><td>-</td></tr><tr><td colspan="5">Open-source models</td></tr><tr><td>GPT-J</td><td>6B</td><td>11.6</td><td>15.7</td><td>27.7</td></tr><tr><td>InCoder</td><td>6B</td><td>15.2</td><td>27.8</td><td>47.0</td></tr><tr><td>GPT-NeoX</td><td>20B</td><td>15.4</td><td>25.6</td><td>41.2</td></tr><tr><td>CodeGeeX</td><td>13B</td><td>22.9</td><td>39.6</td><td>60.9</td></tr><tr><td>LLaMA</td><td>13B</td><td>15.8</td><td>-</td><td>52.5</td></tr><tr><td>LLaMA</td><td>65B</td><td>23.7</td><td></td><td>79.3</td></tr><tr><td>Replit</td><td>3B</td><td>21.9</td><td>=</td><td>-</td></tr><tr><td>StarCoder</td><td>15B</td><td>33.6</td><td>-</td><td>-</td></tr><tr><td>CodeGen-mono</td><td>2B</td><td>23.7</td><td>36.6</td><td>57.0</td></tr><tr><td>CodeGen-mono</td><td>6B</td><td>26.1</td><td>42.3</td><td>65.8</td></tr><tr><td>CodeGen-mono</td><td>16B</td><td>29.3</td><td>49.9</td><td>75.0</td></tr><tr><td>CodeT5+</td><td>220M</td><td>12.0</td><td>20.7</td><td>31.6</td></tr><tr><td>CodeT5+</td><td>770M</td><td>15.5</td><td>27.2</td><td>42.7</td></tr><tr><td>CodeT5+</td><td>2B</td><td>24.2</td><td>38.2</td><td>57.8</td></tr><tr><td>CodeT5+</td><td>6B</td><td>28.0</td><td>47.2</td><td>69.8</td></tr><tr><td>CodeT5+</td><td>16B</td><td>30.9</td><td>51.6</td><td>76.7</td></tr><tr><td>InstructCodeT5+</td><td>16B</td><td>35.0</td><td>54.5</td><td>77.9</td></tr><tr><td colspan="5">Open-source models + generation strategies</td></tr><tr><td>StarCoder (prompted)</td><td>15B</td><td>40.8</td><td>-</td><td>=</td></tr><tr><td>CodeGen-mono w/CodeT</td><td>16B</td><td>36.7</td><td>59.3</td><td></td></tr><tr><td>CodeT5+w/CodeT</td><td>16B</td><td>38.5</td><td>63.6</td><td>77.1</td></tr><tr><td>InstructCodeT5+w/CodeT</td><td>16B</td><td>42.9</td><td>67.8</td><td>78.7</td></tr></table>
107
+
108
+ • For encoder-decoder, we use PLBART (Ahmad et al., 2021) and CodeT5 (Wang et al., 2021b).
109
+
110
+ Note that billion-parameter LLMs such as Codex and CodeGen typically use most of the source code from GitHub for model training and do not remove any overlap with the downstream tasks covered in this work as we did. Therefore, it is difficult to ensure a fair comparison with these models in those tasks, especially the code completion tasks. Moreover, these models are very expensive to perform task-specific finetuning, and hence, they are often employed only on the zero-shot evaluation. In this work, we mainly compare CodeT $^ { 5 + }$ with these LLMs in the zero-shot HumanEval code generation task (Sec. 5.1). In other experiments, we focus on the finetuning setting and compare our models with smaller-scale LMs.
111
+
112
+ # 5.1 Zero-shot Code Generation Evaluation
113
+
114
+ We first evaluate the zero-shot code generation capabilities of our model on the HumanEval benchmark (Chen et al., 2021), where we activate both encoder and decoder modules from ${ \mathrm { C o d e T } } 5 +$ . In this experiment, we follow Nijkamp et al. (2023b) to continue to pretrain our CodeT $^ { 5 + }$ models on the Python subset for another epoch using causal LM objective to adapt them for Python code generation. We evaluate the model performance by testing generated codes against unit tests and report the passing rate pass $@ k$ $( k = \{ 1 , 1 0 , 1 0 0 \} )$ .
115
+
116
+ Table 2: Results of $p a s s @ k ( \% )$ on math programming.
117
+
118
+ <table><tr><td>Model</td><td>Model size</td><td>MathQA-Python pass @80</td><td>GSM8K-Python pass @100</td></tr><tr><td colspan="4">Few-shot learning results</td></tr><tr><td>code-davinci</td><td>-</td><td>42.0</td><td>71.0</td></tr><tr><td>LLaMA</td><td>33B</td><td>=</td><td>53.1</td></tr><tr><td>LLaMA</td><td>65B</td><td></td><td>69.7</td></tr><tr><td>Minerva</td><td>62B</td><td></td><td>68.5</td></tr><tr><td>Minerva</td><td>540B</td><td>=</td><td>78.5</td></tr><tr><td colspan="4">Finetuning results</td></tr><tr><td>LaMDA</td><td>137B</td><td>81.2</td><td>=</td></tr><tr><td>GPT-Neo</td><td>125M</td><td>84.7</td><td>=</td></tr><tr><td>GPT-Neo</td><td>2.7B</td><td>=</td><td>41.4</td></tr><tr><td>CodeGen-mono</td><td>350M</td><td>83.1</td><td>38.7</td></tr><tr><td>CodeGen-mono</td><td>2B</td><td>85.6</td><td>47.8</td></tr><tr><td>CodeT5</td><td>220M</td><td>71.5</td><td>58.4</td></tr><tr><td>CodeT5+</td><td>220M</td><td>85.6</td><td>70.5</td></tr><tr><td>CodeT5+</td><td>770M</td><td>87.4</td><td>73.8</td></tr></table>
119
+
120
+ As shown in Table 1, our instruction-tuned Code $^ { \circ + }$ ("InstructCodeT $" 5 + "$ ) 16B can improve the performance against other open code LLMs, achieving new SoTA of $3 5 . 0 \%$ pass $@ 1$ and $5 4 . 5 \%$ pass $@ 1 0$ . Particularly, as an open model, it even outperforms the OpenAI code-cushman-001 model across all metrics. We also observed that our smallsized models of 220M and 770M already match or outperform much larger code LLMs, e.g., CodeT $^ { 5 + }$ 770M’s $1 5 . 5 \%$ pass $@ 1$ compared to Incoder 6B’s $1 5 . 2 \%$ , GPT-NeoX 20B’s $1 5 . 4 \%$ , and PaLM 62B’s $1 5 . 9 \%$ . Besides, we observed that compared to the CodeGen models of similar sizes (Nijkamp et al., 2023b), CodeT $^ { 5 + }$ obtains consistent performance gains from 2B to 16B models. These superior results against decoder-only baselines demonstrate the advantage of the encoder-decoder architecture of ${ \mathrm { C o d e T } } 5 +$ and validate the effectiveness of our proposed compute-efficient pretraining strategy. We also evaluated the models with enhancement strategies following CodeT Chen et al. (2023). We find that this strategy can select better code candidates and bring the performance gains, achieving up to $4 2 . 9 \%$ pass $@ 1$ and $6 7 . 8 \%$ pass $@ 1 0$ .
121
+
122
+ # 5.2 Evaluation on Math Programming
123
+
124
+ We consider two math programming benchmarks MathQA-Python (Austin et al., 2021) and GSM8K (Cobbe et al., 2021). The task is to generate Python programs to solve mathematical problems described in texts, where code correctness is measured based on the execution outputs of the generated programs $\left( \mathrm { p a s s } @ \mathbf { k } \right)$ . We compare our models with very large decoder-only LMs such as Minerva (Lewkowycz et al., 2022) that is initialized with pretrained PaLM (Chowdhery et al., 2022) and further finetuned with large-scale scientific corpora. Note that some of the baselines are enhanced with generation strategies, such as GPTNeo using self-sampling optimization (Ni et al., 2022), and LLaMA and Minerva using majority voting (Lewkowycz et al., 2022).
125
+
126
+ ![](images/e8c72415282a950cd84a10315742902ebaee6abbea48655ba51b3ab7b7de64be.jpg)
127
+ Figure 4: Results of MathQA-Python by problem complexity (i.e. the number of reasoning steps required).
128
+
129
+ Table 2 shows that ${ \mathrm { C o d e T } } 5 +$ achieves significant performance gains, outperforming many code LLMs of much larger sizes. Specifically, our CodeT $^ { 5 + }$ 770M achieves new SoTA results of 87.4 pass $@ 8 0$ on MathQA-Python and very competitive results of $7 3 . 8 \ p a \ s s \textcircled { a } 1 0 0$ on GSM8K-Python. On GSM8K-Python, $\mathrm { C o d e T 5 + 7 7 0 M }$ achieves the best finetuning results against other larger models (e.g., LaMDA 137B and GPT-Neo 2.7B), and outperforms LLaMA 65B and Minerva 62B in the few-shot evaluation setting. In Fig. 4, we further analyze the model performance of ${ \mathrm { C o d e T } } 5 +$ by the problem complexity on MathQA-Python compared to CodeT5. For each problem, we extract the number of reasoning steps required to solve the problem. We observe that ${ \mathrm { C o d e T } } 5 +$ is more robust against the complexity of the problems compared to CodeT5, where CodeT5 model performance tends to deteriorate drastically as the number of reasoning steps increases. In CodeT $^ { 5 + }$ , the downward trend is a lot less severe and the model still achieves good results in very complex tasks (more than 10 steps).
130
+
131
+ # 5.3 Evaluation on Code Completion
132
+
133
+ We evaluate the decoder-only generation capability of ${ \mathrm { C o d e T } } 5 +$ through a line-level code completion task, which aims to complete the next code line based on the previous code contexts. We employ PY150 (Raychev et al., 2016) and JavaCorpus (Allamanis and Sutton, 2013) from CodeXGLUE, and use exact match (EM) accuracy and Levenshtein edit similarity (Svyatkovskiy et al., 2020) as the metrics. In this task, we employ a decoder-only model from CodeT $^ { 5 + }$ so that only about half of the total model parameters are activated.
134
+
135
+ Table 3: Results on line-level code completion.
136
+
137
+ <table><tr><td>Model</td><td colspan="2">PY150</td><td colspan="2">JavaCorpus</td></tr><tr><td></td><td>EM 42.37</td><td>Edit Sim</td><td>EM</td><td>Edit Sim</td></tr><tr><td>CodeGPT124M</td><td></td><td>71.59</td><td>30.60</td><td>63.45</td></tr><tr><td>UniXcoder 125M</td><td>43.12</td><td>72.00</td><td>32.90</td><td>65.78</td></tr><tr><td>CodeGen-multi 350M</td><td>42.47</td><td>70.67</td><td>35.47</td><td>69.22</td></tr><tr><td>PLBART140M</td><td>38.01</td><td>68.46</td><td>26.97</td><td>61.59</td></tr><tr><td>CodeT5 220M</td><td>36.97</td><td>67.12</td><td>24.80</td><td>58.31</td></tr><tr><td>CodeT5+220M</td><td>43.42</td><td>73.69</td><td>35.17</td><td>69.48</td></tr><tr><td>CodeT5+770M</td><td>44.86</td><td>74.22</td><td>37.90</td><td>72.25</td></tr></table>
138
+
139
+ Table 4: Results of MRR on Text-to-Code Retrieval.
140
+
141
+ <table><tr><td rowspan="2">Model</td><td colspan="7">CodeSearchNet</td><td rowspan="2">CosQA</td><td rowspan="2">AdvTest</td></tr><tr><td>Ruby</td><td>JS</td><td>Go</td><td>Python</td><td>Java</td><td>PHP</td><td>Overall</td></tr><tr><td>CodeBERT125M</td><td>67.9</td><td>62.0</td><td>88.2</td><td>67.2</td><td>67.6</td><td>62.8</td><td>69.3</td><td>65.7</td><td>27.2</td></tr><tr><td>GraphCodeBERT 125M</td><td>70.3</td><td>64.4</td><td>89.7</td><td>69.2</td><td>69.1</td><td>64.9</td><td>71.3</td><td>68.4</td><td>35.2</td></tr><tr><td>SYNCOBERT 125M</td><td>72.2</td><td>67.7</td><td>91.3</td><td>72.4</td><td>72.3</td><td>67.8</td><td>74.0</td><td>:</td><td>38.3</td></tr><tr><td>UniXcoder 125M</td><td>74.0</td><td>68.4</td><td>91.5</td><td>72.0</td><td>72.6</td><td>67.6</td><td>74.4</td><td>70.1</td><td>41.3</td></tr><tr><td>CodeGen-multi 350M</td><td>66.0</td><td>62.2</td><td>90.0</td><td>68.6</td><td>70.1</td><td>63.9</td><td>70.1</td><td>64.8</td><td>34.8</td></tr><tr><td>PLBART140M</td><td>67.5</td><td>61.6</td><td>88.7</td><td>66.3</td><td>66.3</td><td>61.1</td><td>68.6</td><td>65.0</td><td>34.7</td></tr><tr><td>CodeT5 220M</td><td>71.9</td><td>65.5</td><td>88.8</td><td>69.8</td><td>68.6</td><td>64.5</td><td>71.5</td><td>67.8</td><td>39.3</td></tr><tr><td>CodeT5+220M</td><td>77.7</td><td>70.8</td><td>92.4</td><td>75.6</td><td>76.1</td><td>69.8</td><td>77.1</td><td>72.7</td><td>43.3</td></tr><tr><td>CodeT5+ 770M</td><td>78.0</td><td>71.3</td><td>92.7</td><td>75.8</td><td>76.2</td><td>70.1</td><td>77.4</td><td>74.0</td><td>44.7</td></tr></table>
142
+
143
+ Table 3 shows that both CodeT $5 +$ (in decoderonly mode) and decoder-only models (the top block) significantly outperform encoder-decoder models (the middle block), validating that decoderonly models can better suit the code completion task in nature. Specifically, $\mathbf { C o d e T 5 + } \mathbf { \ } 2 2 0 \mathbf { M }$ already surpasses UniXcoder and is comparable to CodeGen-multi 350M, while the 770M one further sets new SoTA results in both metrics. In particular, CodeT5+ 220M yields substantial improvements over CodeT5 220M by $+ 6 . 5$ EM and $+ 1 0 . 4$ EM scores on PY150 and JavaCorpus respectively. This is mainly due to our causal LM objectives that allows the decoder to see longer sequences and thus have a better causal generation capability.
144
+
145
+ # 5.4 Evaluation on Text-to-Code Retrieval
146
+
147
+ We evaluate the code understanding capabilities of CodeT5+ through text-to-code retrieval tasks across multiple PLs. This task aims to find the most semantically related code snippet at the function level from a collection of candidate codes based on a natural language query. We consider three datasets for evaluation: CodeSearchNet (Husain et al., 2019), CosQA (Huang et al., 2021), and AdvTest (Lu et al., 2021), which are curated from the original CodeSearchNet by filtering data with lowquality queries, adopting real-world queries from a modern search engine, and obfuscating identifiers to normalize the code. In this task, we activate both encoder and decoder of ${ \mathrm { C o d e T } } 5 +$ and use Mean Reciprocal Rank (MRR) as the evaluation metric.
148
+
149
+ Table 5: Ablation results of Code $\mathrm { T } 5 +$ : a) no causal LM objective during stage-1 pretraining, b) no matching or causal LM objective during stage-2 pretraining.
150
+
151
+ <table><tr><td rowspan="2">Model</td><td colspan="2">Code Completion</td><td colspan="2">Math Programming</td></tr><tr><td>PY150 EM</td><td>JavaCorpus EM</td><td>MathQA-PY pass@80</td><td>GSM8K-PY pass @100</td></tr><tr><td>CodeT5+770M</td><td>44.9</td><td>37.9</td><td>87.4</td><td>73.8</td></tr><tr><td>a) no causal LM</td><td>36.2</td><td>24.8</td><td>72.3</td><td>61.4</td></tr></table>
152
+
153
+ <table><tr><td rowspan="2">Model</td><td colspan="7">Text-to-code Retrieval</td></tr><tr><td>Ruby</td><td>JS</td><td>Go</td><td>Python</td><td>Java</td><td>PHP</td><td>Overall</td></tr><tr><td>CodeT5+770M</td><td>78.0</td><td>71.3</td><td>92.7</td><td>75.8</td><td>76.2</td><td>70.1</td><td>77.4</td></tr><tr><td rowspan="2">no matching b) no causal LM</td><td>76.2</td><td>68.5</td><td>91.2</td><td>72.8</td><td>73.6</td><td>66.3</td><td>74.8</td></tr><tr><td>77.3</td><td>70.6</td><td>92.4</td><td>75.7</td><td>75.6</td><td>68.9</td><td>76.8</td></tr></table>
154
+
155
+ From Table 4, our CodeT $^ { 5 + }$ 220M significantly outperforms all existing encoder-only/decoder-only (the top block) and encoder-decoder models (the middle block). Our CodeT $5 +$ 770M further sets new SoTA results, surpassing the previous SoTA UniXcoder by more than 3 MRR points on all 3 tasks across 8 datasets. This implies CodeT $^ { 5 + }$ is a robust code retriever to handle queries with diverse formats and PLs. Besides, Code $\mathrm { T } 5 + 2 2 0 \mathrm { M }$ yields substantial performance gains over CodeT5 220M, which can be attributed to the text-code contrastive learning and matching objectives that facilitate better unimodal and bimodal representation learning.
156
+
157
+ # 5.5 Ablation Study
158
+
159
+ We conduct an ablation study to analyze the impacts of our proposed pretraining objectives: a) casual LM objectives at stage-1 unimodal pretraining on two generative tasks including code completion and math programming, b) text-code matching and causal LM objectives at stage-2 bimodal pretraining on an understanding task of text-to-code retrieval. We employ $\mathrm { C o d e T } 5 + 7 7 0 \mathrm { M }$ and report the results of three representative tasks over 10 datasets in Table 5. In CodeT5+, we found that causal LM objective plays a crucial role in code completion and math programming tasks, observed by a significant performance drop after removing it. This indicates causal LM can complement the span denoising objective and improve the generation capability of our models. Additionally, we found that the text-code matching objective is critical to the retrieval performance (a drop of 2.6 avg. MRR over 6 datasets without it), implying this objective can learn a better bimodal representation that captures the fine-grained alignment between text and code. Besides, we found that retrieval tasks can also benefit from the joint training with causal LM objective despite their task differences.
160
+
161
+ Table 6: Results of retrieval-augmented code generation. EM: Exact Match, B4: BLEU-4, CB: CodeBLEU.
162
+
163
+ <table><tr><td rowspan="2">Model</td><td colspan="3">Java</td><td colspan="3">Python</td></tr><tr><td>EM</td><td>B4</td><td>CB</td><td>EM</td><td>B4</td><td>CB</td></tr><tr><td colspan="7">Retrieval-based</td></tr><tr><td>BM25</td><td>0.00</td><td>4.90</td><td>16.00</td><td>0.00</td><td>6.63</td><td>13.49</td></tr><tr><td>SCODE-R 125M</td><td>0.00</td><td>25.34</td><td>26.68</td><td>0.00</td><td>22.75</td><td>23.92</td></tr><tr><td>CodeT5+ 220M</td><td>0.00</td><td>28.74</td><td>31.00</td><td>0.00</td><td>27.30</td><td>26.51</td></tr><tr><td colspan="7">Generative</td></tr><tr><td>CodeBERT125M</td><td>0.00</td><td>8.38</td><td>14.52</td><td>0.00</td><td>4.06</td><td>10.42</td></tr><tr><td>GraphCodeBERT 125M</td><td>0.00</td><td>7.86</td><td>14.53</td><td>0.00</td><td>3.97</td><td>10.55</td></tr><tr><td>PLBART140M</td><td>0.00</td><td>10.10</td><td>14.96</td><td>0.00</td><td>4.89</td><td>12.01</td></tr><tr><td>CodeT5+ 220M</td><td>0.00</td><td>10.33</td><td>20.54</td><td>0.00</td><td>4.40</td><td>13.88</td></tr><tr><td colspan="7">Retrieval-Augmented Generative</td></tr><tr><td>REDCODER-EXT125M+140M</td><td>10.21</td><td>28.98</td><td>33.18</td><td>9.61</td><td>24.43</td><td>30.21</td></tr><tr><td>CodeT5+ 220M</td><td>11.66</td><td>33.83</td><td>40.60</td><td>11.83</td><td>31.14</td><td>36.39</td></tr></table>
164
+
165
+ # 5.6 Unified Retrieval-Augmented Generation
166
+
167
+ As our model is capable of both code retrieval and generation, it can be naturally exploited as a unified retrieval-augmented generator. To explore this adaptation, we follow Parvez et al. (2021) to evaluate two code generation tasks on Java and Python. We evaluate our models in 3 settings: retrievalbased, generative, and retrieval-augmented (RA) generative. For the retrieval-based setting, we activate our encoder to retrieve the top-1 code sample as the prediction given a text query, while for the RA generative setting, we append the combination of top- $k$ retrieved samples $k { = } 1$ in our work) to the encoder input and activate the decoder. As shown in Table 6, we found that our CodeT $^ { 5 + }$ achieves better results in all categories, especially in the retrieval-based and RA generative setting. While the previous SoTA model REDCODER-EXT (Parvez et al., 2021) separately employs GraphCodeBERT as the retriever and PLBART as the generator, our model can be seamlessly deployed as a unified end-to-end system with both retrieval and generation capabilities.
168
+
169
+ # 6 Conclusion
170
+
171
+ We propose CodeT $^ { 5 + }$ , a new family of open code LLMs with a dynamic architecture that can flexibly operate in different modes (encoder-only, decoderonly, and encoder-decoder) to support a wide range of code understanding and generation tasks. To train CodeT $^ { 5 + }$ , we introduce a mixture of pretraining tasks to learn rich representations from both unimodal code data and bimodal code-text data. Additionally, it achieves efficient model scaling and better task generalization through integration with frozen LLMs and instruction tuning. Extensive experiments on over 20 code intelligence benchmarks have verified the superiority of our models.
172
+
173
+ # Limitations
174
+
175
+ As a family of Transformer LLMs, CodeT5+ requires sufficient pretraining/finetuning data to be able to learn meaningful contextual representations from code. While we could curate these data from public domains such as GitHub, thorough data filtering and preprocessing steps are needed to obtain a good level of data quality for pretraining. During instruction finetuning, a well designed pipeline is needed to obtain high quality instruction-following data, either through manual annotation effort or synthetic data augmentation from other LLMs (e.g. OpenAI GPT models). Moreover, the level of the diversity and quality of data needed to train these types of models is still an open question. Recent attempts such as (Zhou et al., 2023) have highlighted the importance of data quality vs. data scale to efficiently train LLMs while keeping the cost of handling data affordable.
176
+
177
+ Another limitation of ${ \mathrm { C o d e T } } 5 +$ is the requirement of large GPU resources. With model sizes up to billion parameters, to handle these models efficiently requires access to GPUs during either training and inference time. Specifically, we found that fitting a 16B model into a single A100 GPU requires additional model serving/loading techniques to keep the system memory consumption acceptable. While GPU resources have become more and more accessible to the wider community of practitioners, the cost of training/testing LLMs on large-scale data can accumulate and become too expensive to many individuals.
178
+
179
+ promoting responsible and ethical use of large language models for code.
180
+
181
+ Additionally, it is essential to recognize the broader intellectual property implications of code generation and retrieval systems before deployment. Deep learning models generating code may inadvertently introduce security vulnerabilities. To mitigate this risk, it is crucial to conduct expert reviews and rigorous security assessments before adopting such code. This review process ensures that the generated code meets necessary security standards, safeguarding against potential exploits and vulnerabilities. In code retrieval scenarios, providing appropriate attribution to the source along with the retrieved results is paramount. This attribution not only respects the rights of code authors but also enhances transparency, traceability, and collaboration within the programming community. By acknowledging the original authors and promoting a collaborative, ethical, and legally compliant environment, code retrieval systems can foster knowledge sharing and contribute to a reputable programming ecosystem.
182
+
183
+ By considering these ethical considerations, we can promote the responsible deployment of large language models for code, maximizing their potential benefits while mitigating potential harms to individuals, communities, and the overall software ecosystem. It is imperative to prioritize safety, nontoxicity, intellectual property rights, security, and collaboration in the development and deployment of these systems, ensuring they align with ethical principles and societal needs.
184
+
185
+ # Ethics Statement
186
+
187
+ Advancements in code understanding and generation systems hold immense potential to create positive societal impacts by improving programming accessibility and enhancing developer productivity through natural language interfaces. However, deploying such systems at scale requires careful consideration of various ethical aspects, as extensively discussed by Chen et al. (2021).
188
+
189
+ One critical concern is the potential risk of generated code summaries or comments incorporating toxic or insensitive language, which can have detrimental effects. Several studies have explored techniques to address this issue, such as reinforcement learning (Ouyang et al., 2022), weighted decoding (Krause et al., 2021) , and safety-specific control tokens (Xu et al., 2020). These approaches aim to ensure non-toxic natural language generation,
190
+
191
+ # References
192
+
193
+ Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. 2021. Unified pre-training for program understanding and generation. In NAACLHLT, pages 2655–2668. Association for Computational Linguistics.
194
+
195
+ Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob L. Menick, Sebastian Borgeaud, Andy Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, and Karén Simonyan. 2022. Flamingo: a visual language model for few-shot learning. In NeurIPS.
196
+
197
+ Miltiadis Allamanis and Charles Sutton. 2013. Mining source code repositories at massive scale using language modeling. In MSR, pages 207–216. IEEE Computer Society.
198
+
199
+ Aida Amini, Saadia Gabriel, Shanchuan Lin, Rik Koncel-Kedziorski, Yejin Choi, and Hannaneh Hajishirzi. 2019. MathQA: Towards interpretable math word problem solving with operation-based formalisms. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 2357–2367, Minneapolis, Minnesota. Association for Computational Linguistics.
200
+
201
+ 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.
202
+
203
+ Sid Black, Stella Biderman, Eric Hallahan, Quentin Anthony, Leo Gao, Laurence Golding, Horace He, Connor Leahy, Kyle McDonell, Jason Phang, Michael Pieler, USVSN Sai Prashanth, Shivanshu Purohit, Laria Reynolds, Jonathan Tow, Ben Wang, and Samuel Weinbach. 2022. GPT-NeoX-20B: An opensource autoregressive language model. In Proceedings of the ACL Workshop on Challenges & Perspectives in Creating Large Language Models.
204
+
205
+ Sahil Chaudhary. 2023. Code alpaca: An instructionfollowing llama model for code generation. https: //github.com/sahil280114/codealpaca.
206
+
207
+ Bei Chen, Fengji Zhang, Anh Nguyen, Daoguang Zan, Zeqi Lin, Jian-Guang Lou, and Weizhu Chen. 2023. Codet: Code generation with generated tests. In The Eleventh International Conference on Learning Representations.
208
+
209
+ 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.
210
+
211
+ Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee,
212
+
213
+ Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. 2022. Palm: Scaling language modeling with pathways. CoRR, abs/2204.02311.
214
+
215
+ Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. 2021. Training verifiers to solve math word problems. CoRR, abs/2110.14168.
216
+
217
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2019, Minneapolis, MN, USA, June 2-7, 2019, Volume 1 (Long and Short Papers), pages 4171–4186.
218
+
219
+ Li Dong, Nan Yang, Wenhui Wang, Furu Wei, Xiaodong Liu, Yu Wang, Jianfeng Gao, Ming Zhou, and Hsiao-Wuen Hon. 2019. Unified language model pre-training for natural language understanding and generation. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS 2019, December 8-14, 2019, Vancouver, BC, Canada, pages 13042–13054.
220
+
221
+ Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, and Ming Zhou. 2020. Codebert: A pre-trained model for programming and natural languages. In EMNLP (Findings), volume EMNLP 2020 of Findings of ACL, pages 1536–1547. Association for Computational Linguistics.
222
+
223
+ Daniel Fried, Armen Aghajanyan, Jessy Lin, Sida Wang, Eric Wallace, Freda Shi, Ruiqi Zhong, Wen-tau Yih, Luke Zettlemoyer, and Mike Lewis. 2022. Incoder: A generative model for code infilling and synthesis. CoRR, abs/2204.05999.
224
+
225
+ Daya Guo, Shuai Lu, Nan Duan, Yanlin Wang, Ming Zhou, and Jian Yin. 2022. Unixcoder: Unified crossmodal pre-training for code representation. In $A C L$ (1), pages 7212–7225. Association for Computational Linguistics.
226
+
227
+ Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, Shujie Liu, Long Zhou, Nan Duan, Alexey Svyatkovskiy, Shengyu Fu, Michele Tufano, Shao Kun Deng, Colin B. Clement, Dawn Drain, Neel Sundaresan, Jian Yin, Daxin Jiang, and Ming Zhou. 2021. Graphcodebert: Pre-training code representations with data flow. In ICLR. OpenReview.net.
228
+
229
+ Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross B. Girshick. 2020. Momentum contrast for unsupervised visual representation learning. In CVPR, pages 9726–9735. Computer Vision Foundation / IEEE.
230
+
231
+ Dan Hendrycks, Steven Basart, Saurav Kadavath, Mantas Mazeika, Akul Arora, Ethan Guo, Collin Burns, Samir Puranik, Horace He, Dawn Song, and Jacob Steinhardt. 2021. Measuring coding challenge competence with apps. NeurIPS.
232
+
233
+ Junjie Huang, Duyu Tang, Linjun Shou, Ming Gong, Ke Xu, Daxin Jiang, Ming Zhou, and Nan Duan. 2021. Cosqa: 20, $0 0 0 +$ web queries for code search and question answering. In ACL/IJCNLP (1), pages 5690–5700. Association for Computational Linguistics.
234
+
235
+ Hamel Husain, Ho-Hsiang Wu, Tiferet Gazit, Miltiadis Allamanis, and Marc Brockschmidt. 2019. Codesearchnet challenge: Evaluating the state of semantic code search. CoRR, abs/1909.09436.
236
+
237
+ Jeff Johnson, Matthijs Douze, and Hervé Jégou. 2019. Billion-scale similarity search with GPUs. IEEE Transactions on Big Data, 7(3):535–547.
238
+
239
+ Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick S. H. Lewis, Ledell Wu, Sergey Edunov, Danqi Chen, and Wen-tau Yih. 2020. Dense passage retrieval for open-domain question answering. In EMNLP (1), pages 6769–6781. Association for Computational Linguistics.
240
+
241
+ Ben Krause, Akhilesh Deepak Gotmare, Bryan McCann, Nitish Shirish Keskar, Shafiq Joty, Richard Socher, and Nazneen Fatema Rajani. 2021. GeDi: Generative discriminator guided sequence generation. In Findings of the Association for Computational Linguistics: EMNLP 2021, pages 4929–4952, Punta Cana, Dominican Republic. Association for Computational Linguistics.
242
+
243
+ Hung Le, Yue Wang, Akhilesh Deepak Gotmare, Silvio Savarese, and Steven C. H. Hoi. 2022. Coderl: Mastering code generation through pretrained models and deep reinforcement learning. In NeurIPS.
244
+
245
+ Aitor Lewkowycz, Anders Johan Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Venkatesh Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, Yuhuai Wu, Behnam Neyshabur, Guy Gur-Ari, and Vedant Misra. 2022. Solving quantitative reasoning problems with language models. In Advances in Neural Information Processing Systems.
246
+
247
+ Junnan Li, Dongxu Li, Caiming Xiong, and Steven C. H. Hoi. 2022a. BLIP: bootstrapping languageimage pre-training for unified vision-language understanding and generation. In ICML, volume 162 of Proceedings of Machine Learning Research, pages 12888–12900. PMLR.
248
+
249
+ Junnan Li, Ramprasaath R. Selvaraju, Akhilesh Gotmare, Shafiq R. Joty, Caiming Xiong, and Steven Chu-Hong Hoi. 2021. Align before fuse: Vision and language representation learning with momentum distillation. In NeurIPS, pages 9694–9705.
250
+
251
+ aymond Li, Loubna Ben Allal, Yangtian Zi, Niklas Muennighoff, Denis Kocetkov, Chenghao Mou, Marc Marone, Christopher Akiki, Jia Li, Jenny Chim, Qian Liu, Evgenii Zheltonozhskii, Terry Yue Zhuo, Thomas Wang, Olivier Dehaene, Mishig Davaadorj, Joel Lamy-Poirier, João Monteiro, Oleh Shliazhko, Nicolas Gontier, Nicholas Meade, Armel Zebaze, Ming-Ho Yee, Logesh Kumar Umapathi, Jian Zhu, Benjamin Lipkin, Muhtasham Oblokulov, Zhiruo Wang, Rudra Murthy V, Jason Stillerman, Siva Sankalp Patel, Dmitry Abulkhanov, Marco Zocca, Manan Dey, Zhihan Zhang, Nour Fahmy, Urvashi Bhattacharyya, Wenhao Yu, Swayam Singh, Sasha Luccioni, Paulo Villegas, Maxim Kunakov, Fedor Zhdanov, Manuel Romero, Tony Lee, Nadav Timor, Jennifer Ding, Claire Schlesinger, Hailey Schoelkopf, Jan Ebert, Tri Dao, Mayank Mishra, Alex Gu, Jennifer Robinson, Carolyn Jane Anderson, Brendan Dolan-Gavitt, Danish Contractor, Siva Reddy, Daniel Fried, Dzmitry Bahdanau, Yacine Jernite, Carlos Muñoz Ferrandis, Sean Hughes, Thomas Wolf, Arjun Guha, Leandro von Werra, and Harm de Vries. 2023. Starcoder: may the source be with you! CoRR, abs/2305.06161.
252
+
253
+ Yujia Li, David H. Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d’Autume, Igor Babuschkin, Xinyun Chen, PoSen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson, Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, and Oriol Vinyals. 2022b. Competition-level code generation with alphacode. CoRR, abs/2203.07814.
254
+
255
+ Chin-Yew Lin and Franz Josef Och. 2004. ORANGE: a method for evaluating automatic evaluation metrics for machine translation. In COLING.
256
+
257
+ Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. 2019. Roberta: A robustly optimized BERT pretraining approach. CoRR, abs/1907.11692.
258
+
259
+ Ilya Loshchilov and Frank Hutter. 2019. Decoupled weight decay regularization. In ICLR (Poster). OpenReview.net.
260
+
261
+ Shuai Lu, Daya Guo, Shuo Ren, Junjie Huang, Alexey Svyatkovskiy, Ambrosio Blanco, Colin B. Clement, Dawn Drain, Daxin Jiang, Duyu Tang, Ge Li, Lidong Zhou, Linjun Shou, Long Zhou, Michele Tufano, Ming Gong, Ming Zhou, Nan Duan, Neel Sundaresan, Shao Kun Deng, Shengyu Fu, and Shujie Liu. 2021. Codexglue: A machine learning benchmark dataset for code understanding and generation. In NeurIPS Datasets and Benchmarks.
262
+
263
+ Anh Nguyen, Nikos Karampatziakis, and Weizhu Chen. 2023. Meet in the middle: A new pre-training paradigm. arXiv preprint arXiv:2303.07295.
264
+
265
+ Ansong Ni, Jeevana Priya Inala, Chenglong Wang, Oleksandr Polozov, Christopher Meek, Dragomir R. Radev, and Jianfeng Gao. 2022. Learning from self-sampled correct and partially-correct programs. CoRR, abs/2205.14318.
266
+
267
+ Erik Nijkamp, Hiroaki Hayashi, Caiming Xiong, Silvio Savarese, and Yingbo Zhou. 2023a. Codegen2: Lessons for training llms on programming and natural languages. arXiv preprint.
268
+
269
+ Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, and Caiming Xiong. 2023b. Codegen: An open large language model for code with multi-turn program synthesis. In The Eleventh International Conference on Learning Representations.
270
+
271
+ OpenAI. 2023. Gpt-4 technical report. ArXiv, abs/2303.08774.
272
+
273
+ Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Gray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Christiano, Jan Leike, and Ryan Lowe. 2022. Training language models to follow instructions with human feedback. In Advances in Neural Information Processing Systems.
274
+
275
+ Md. Rizwan Parvez, Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. 2021. Retrieval augmented code generation and summarization. In EMNLP (Findings), pages 2719–2734. Association for Computational Linguistics.
276
+
277
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. 2019. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9.
278
+
279
+ 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. J. Mach. Learn. Res., 21:140:1–140:67.
280
+
281
+ Jeff Rasley, Samyam Rajbhandari, Olatunji Ruwase, and Yuxiong He. 2020. Deepspeed: System optimizations enable training deep learning models with over 100 billion parameters. In KDD, pages 3505– 3506. ACM.
282
+
283
+ Veselin Raychev, Pavol Bielik, and Martin T. Vechev. 2016. Probabilistic model for code with decision trees. In OOPSLA, pages 731–747. ACM.
284
+
285
+ replit. 2023. replit-code-v1-3b.
286
+
287
+ Saleh Soltan, Shankar Ananthakrishnan, Jack FitzGerald, Rahul Gupta, Wael Hamza, Haidar Khan, Charith Peris, Stephen Rawls, Andy Rosenbaum, Anna Rumshisky, Chandana Satya Prakash, Mukund Sridhar, Fabian Triefenbach, Apurv Verma, Gökhan Tür, and Prem Natarajan. 2022. Alexatm 20b: Few-shot learning using a large-scale multilingual seq2seq model. CoRR, abs/2208.01448.
288
+
289
+ Jeffrey Svajlenko, Judith F Islam, Iman Keivanloo, Chanchal K Roy, and Mohammad Mamun Mia. 2014. Towards a big data curated benchmark of inter-project code clones. In 2014 IEEE International Conference on Software Maintenance and Evolution, pages 476– 480. IEEE.
290
+
291
+ Alexey Svyatkovskiy, Shao Kun Deng, Shengyu Fu, and Neel Sundaresan. 2020. Intellicode compose: code generation using transformer. In ESEC/SIGSOFT FSE, pages 1433–1443. ACM.
292
+
293
+ M Tabachnyk and S Nikolov. 2022. Ml-enhanced code completion improves developer productivity.
294
+
295
+ Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. 2023. Stanford alpaca: An instruction-following llama model. https:// github.com/tatsu-lab/stanford_alpaca.
296
+
297
+ 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. CoRR, abs/2205.05131.
298
+
299
+ Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. 2023. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971.
300
+
301
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. Advances in neural information processing systems, 30.
302
+
303
+ Ben Wang and Aran Komatsuzaki. 2021. GPT-J6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/ mesh-transformer-jax.
304
+
305
+ Weishi Wang, Yue Wang, Shafiq Joty, and Steven C. H. Hoi. 2023. Rap-gen: Retrieval-augmented patch generation with codet5 for automatic program repair. CoRR, abs/2309.06057.
306
+
307
+ Xin Wang, Yasheng Wang, Fei Mi, Pingyi Zhou, Yao Wan, Xiao Liu, Li Li, Hao Wu, Jin Liu, and Xin Jiang. 2021a. Syncobert: Syntax-guided multi-modal contrastive pre-training for code representation. arXiv preprint arXiv:2108.04556.
308
+
309
+ Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A Smith, Daniel Khashabi, and Hannaneh Hajishirzi. 2022. Self-instruct: Aligning language model with self generated instructions. arXiv preprint arXiv:2212.10560.
310
+
311
+ Yue Wang, Weishi Wang, Shafiq R. Joty, and Steven C. H. Hoi. 2021b. Codet5: Identifier-aware unified pre-trained encoder-decoder models for code understanding and generation. In EMNLP (1), pages 8696– 8708. Association for Computational Linguistics.
312
+
313
+ Jing Xu, Da Ju, Margaret Li, Y-Lan Boureau, Jason Weston, and Emily Dinan. 2020. Recipes for safety in open-domain chatbots. arXiv preprint arXiv:2010.07079.
314
+
315
+ Qinkai Zheng, Xiao Xia, Xu Zou, Yuxiao Dong, Shan Wang, Yufei Xue, Zihan Wang, Lei Shen, Andi Wang, Yang Li, Teng Su, Zhilin Yang, and Jie Tang. 2023. Codegeex: A pre-trained model for code generation with multilingual evaluations on humaneval- $\mathbf { \nabla } \cdot \mathbf { X }$ .
316
+
317
+ Chunting Zhou, Pengfei Liu, Puxin Xu, Srini Iyer, Jiao Sun, Yuning Mao, Xuezhe Ma, Avia Efrat, Ping Yu, Lili Yu, et al. 2023. Lima: Less is more for alignment. arXiv preprint arXiv:2305.11206.
318
+
319
+ Yaqin Zhou, Shangqing Liu, Jingkai Siow, Xiaoning Du, and Yang Liu. 2019. Devign: Effective vulnerability identification by learning comprehensive program semantics via graph neural networks. Advances in neural information processing systems, 32.
320
+
321
+ # A Bimodal Pretraining Details
322
+
323
+ To expose the model on more diverse set of pretraining data, we employ a stage-wise pretraining process to first train CodeT $^ { 5 + }$ on large-scale codeonly data with span denoising and causal language modeling (CLM) tasks, then train on smaller set of text-code bimodel data using text-code contrastive learning, matching, and causal LM tasks. Below, we provide detailed formulas for text-code contrastive learning and matching tasks at the secondstage pretraining on text-code pairs.
324
+
325
+ Text-Code Contrastive Learning activates the encoder to learn better unimodal (text/code) representations by computing a similarity score such that parallel text-code pairs have higher scores. Given a text $\mathrm { T }$ and a code C, we first learn representations $\mathbf { h } ^ { t }$ for text $T$ and $\mathbf { h } ^ { c }$ for code $C$ by mapping the [CLS] embeddings to normalized lowerdimensional (256-d) representations from the encoder. Given a tain text vectors $\{ \mathbf { h } ^ { t } \} _ { i = 1 } ^ { N }$ $N$ text-code paird code vectors $\{ \mathbf { h } ^ { c } \} _ { i = 1 } ^ { N }$ to compute text-to-code and code-to-text and similarities:
326
+
327
+ $$
328
+ s _ { i , j } ^ { t 2 c } = \mathbf { h } _ { i } ^ { t \top } \mathbf { h } _ { j } ^ { c } , s _ { i , j } ^ { c 2 t } = \mathbf { h } _ { i } ^ { c \top } \mathbf { h } _ { j } ^ { t }
329
+ $$
330
+
331
+ $$
332
+ p _ { i } ^ { t 2 c } ( T ) = \frac { \exp { ( s _ { i , i } ^ { t 2 c } / \tau ) } } { \sum _ { j = 1 } ^ { N } \exp { ( s _ { i , j } ^ { t 2 c } / \tau ) } } ,
333
+ $$
334
+
335
+ Table 7: Data statistics of both unimodal and bimodal (CodeSearchNet) pretraining data.
336
+
337
+ <table><tr><td>Dataset</td><td>Language Ruby</td><td>#Sample</td><td>Total size</td></tr><tr><td>Ours</td><td>JavaScript Go Python Java PHP C C++ C#</td><td>2,119,741 5,856,984 1,501,673 3,418,376 10,851,759 4,386,876 4,187,467 2,951,945 4,119,796</td><td>37,274,876 files</td></tr><tr><td>CSN</td><td>Ruby JavaScript Go Python Java PHP</td><td>49,009 125,166 319,132 453,772 457,381 525,357</td><td>1,929,817 text-code pairs at function level</td></tr></table>
338
+
339
+ $$
340
+ p _ { i } ^ { c 2 t } ( C ) = \frac { \exp { ( s _ { i , i } ^ { c 2 t } / \tau ) } } { \sum _ { j = 1 } ^ { N } \exp { ( s _ { i , j } ^ { c 2 t } / \tau ) } }
341
+ $$
342
+
343
+ where $s _ { i , j } ^ { t 2 c }$ represents text-to-code similarity of text of $i$ -th pair and code of $j$ -th pair, and $s _ { i , j } ^ { c 2 t }$ is the code-to-text similarity, $\tau$ is learned temperature parameter. $p _ { i } ^ { t 2 c } ( T )$ and $p _ { i } ^ { c 2 t } ( C )$ are the softmaxnormalized text-to-code and code-to-text similarities for the $i$ -th text and code.
344
+
345
+ Let $\mathbf { y } ^ { t 2 c } ( T )$ and $\mathbf { y } ^ { c 2 t } ( C )$ denote the groundtruth one-hot similarity, where negative pairs have a probability of 0 and the positive pair has a probability of 1. The text-code contrastive loss from a corpus $D$ of text-code pairs is defined as the crossentropy $_ \mathrm { H }$ between $\mathbf { p }$ and $\mathbf { y }$ :
346
+
347
+ $$
348
+ \begin{array} { r } { \mathcal { L } _ { t c c } = \displaystyle \frac { 1 } { 2 } \mathbb { E } _ { ( T , C ) \sim D } [ H ( \mathbf { y } ^ { t 2 c } ( T ) , \mathbf { p } ^ { t 2 c } ( T ) ) + } \\ { H ( \mathbf { y } ^ { c 2 t } ( C ) , \mathbf { p } ^ { c 2 t } ( C ) ) ] } \end{array}
349
+ $$
350
+
351
+ Text-Code Matching activates the decoder with the bimodal matching functionality to predict whether a pair of text and code is positive (matched) or negative (unmatched). We employ the output embedding of the [EOS] token as the fused bimodal representation for a text-code pair $( T , C )$ , as this token attends to all the previous context for the text-code pair input. Followed by a linear layer and softmax, we compute a two-class probability $p ^ { t c m } ( T , C )$ and define the matching loss:
352
+
353
+ $$
354
+ \mathcal { L } _ { t c m } = \mathbb { E } _ { ( T , C ) \sim D } [ H ( \mathbf { y } ^ { t c m } ( T , C ) , \mathbf { p } ^ { t c m } ( T , C ) ) ]
355
+ $$
356
+
357
+ where $\mathbf { y } ^ { t c m } ( T , C )$ is a 2-dimensional one-hot vector representing the ground-truth label.
358
+
359
+ ![](images/4240252f71adcfc8d52acd23d47c77872287d36f2970b0c20b1199da686faa42.jpg)
360
+ Figure 5: Example generated instruction data: we demonstrate some examples of instruction data used to finetune CodeT $^ { 5 + }$ to better align our models to natural language instructions. The instruction corpus contains novel tasks, such as text-to-SQL generation and Python code optimization.
361
+
362
+ Text-Code Causal LM. This task focuses on a cross-modal causal LM objective between text and code through a dual multimodal conversion: textto-code generation and code-to-text generation (i.e. code summarization). Let $\mathcal { L } _ { t 2 c }$ and $\mathcal { L } _ { c 2 t }$ denote the losses for text-to-code and code-to-text generation. The full second-stage pretraining loss of our CodeT $5 +$ is:
363
+
364
+ $$
365
+ \mathcal { L } = \mathcal { L } _ { t c c } + \mathcal { L } _ { t c m } + \mathcal { L } _ { t 2 c } + \mathcal { L } _ { c 2 t }
366
+ $$
367
+
368
+ # B Pretraining
369
+
370
+ # B.1 Pretraining Dataset
371
+
372
+ We report the data statistics of both unimodal code and bimodal text-code pretraining datasets in Table 7. From the table, we can see that our curated dataset from GitHub code has a much larger data size at the file level than the CodeSearchNet bimodal data at the function level, allowing our model to learn rich representations in the first stage of pretraining. Different from CodeT5 (Wang et al., 2021b) which employs both unimodal and bimodal data in CodeSearchNet (Husain et al., 2019), we only employ its bimodal subset for the second stage pretraining of our CodeT5+. We use this stage to mainly adapt our model to text-code related tasks like text-to-code retrieval and generation.
373
+
374
+ # B.2 Pretraining Setup
375
+
376
+ In pretraining, we adopt a stage-wise strategy to pretrain CodeT $^ { 5 + }$ first on the large-scale unimodal dataset and then on the smaller bimodal dataset. In the first stage, we warm up the model with the span denoising task for $1 0 k$ training steps, and then joint training with the two CLM tasks with equal weights for $1 0 0 k$ steps. We employ a linear decay learning rate (LR) scheduler with a peak learning rate of 2e4 and set the batch size to 2048 for denoising and 512 for CLM. To prepare the input and output data, we set the maximum length to 512 for the denoising task, and set the maximum lengths to 768 and 600 for source and target sequences for the code completion CLM, 1 and 1024 for the decoder-only generation CLM. In the second stage, we jointly optimize four losses of contrastive learning, matching, and two CLM losses with equal weights for 10 epochs with a batch size of 256. We employ a peak learning rate of 1e-4 and set the maximum sequence lengths to 420 and 128 for code and text.
377
+
378
+ In all experiments, we employ an AdamW optimizer (Loshchilov and Hutter, 2019) with a 0.1 weight decay. We also employ the DeepSpeed’s ZeRO Stage 2 (Rasley et al., 2020) with mixed precision training of FP16 for training acceleration. For the training of CodeT $5 +$ 2B, 6B, and 16B, we use FP16 frozen decoder weights and keep other trainable weights in FP32. We use DeepSpeed ZeRO Stage 3’s parameter partition for CodeT5 $\mid +$ 6B and 16B models.
379
+
380
+ # C Instruction Tuning
381
+
382
+ Fig. 5 illustrates some examples of the generated instruction data. Note that as we rely on LMgenerated data, including the annotations of expected outputs, not all of the data is perfectly correct. For instance, the example of the code optimization task in Fig. 5 contains a wrong output. Wang et al. (2022) treated these examples as data noise and the tuned models still benefit from the majority of the synthetic instruction dataset.
383
+
384
+ Table 8: Results of BLEU-4 on code summarization.
385
+
386
+ <table><tr><td>Model</td><td>Ruby</td><td>JS</td><td>Go</td><td>Python</td><td>Java</td><td>PHP</td><td>Overall</td></tr><tr><td>RoBERTa125M</td><td>11.17</td><td>11.90</td><td>17.72</td><td>18.14</td><td>16.47</td><td>24.02</td><td>16.57</td></tr><tr><td>CodeBERT125M</td><td>12.16</td><td>14.90</td><td>18.07</td><td>19.06</td><td>17.65</td><td>25.16</td><td>17.83</td></tr><tr><td>UniXcoder 125M</td><td>14.87</td><td>15.85</td><td>19.07</td><td>19.13</td><td>20.31</td><td>26.54</td><td>19.30</td></tr><tr><td>CodeGen-multi 350M</td><td>13.48</td><td>16.54</td><td>18.09</td><td>18.31</td><td>19.41</td><td>24.41</td><td>18.37</td></tr><tr><td>PLBART140M</td><td>14.11</td><td>15.56</td><td>18.91</td><td>19.30</td><td>18.45</td><td>23.58</td><td>18.32</td></tr><tr><td>CodeT5220M</td><td>15.24</td><td>16.16</td><td>19.56</td><td>20.01</td><td>20.31</td><td>26.03</td><td>19.55</td></tr><tr><td>CodeT5+220M</td><td>15.51</td><td>16.27</td><td>19.60</td><td>20.16</td><td>20.53</td><td>26.78</td><td>19.81</td></tr><tr><td>CodeT5+770M</td><td>15.63</td><td>17.93</td><td>19.64</td><td>20.47</td><td>20.83</td><td>26.39</td><td>20.15</td></tr></table>
387
+
388
+ # D Additional Experimental Results
389
+
390
+ In this section, we provide additional experimental results including code summarization (Appendix D.1), two understanding tasks of code defect detection and clone detection from the CodeXGLUE (Lu et al., 2021) (Appendix D.2), more analysis on retrieval-augmented code generation (Appendix D.3), and more qualitative results in math programming tasks (Appendix D.4).
391
+
392
+ # D.1 Code Summarization from CodeXGLUE
393
+
394
+ The code summarization task aims to summarize a code snippet into natural language docstrings. We employ the clean version of CodeSearchNet dataset (Husain et al., 2019) in six programming languages to evaluate our models for this task. We employ BLEU-4 (Lin and Och, 2004) as the performance metric which measures the token-based similarity between predicted and ground-truth summaries. From pretrained ${ \mathrm { C o d e T } } 5 +$ , we activate both encoder and decoder for this task.
395
+
396
+ From Table 8, we found that encoder-decoder models (CodeT5 and CodeT $^ { 5 + }$ ) generally outperform both encoder-only models (Feng et al., 2020) and decoder-only models (Nijkamp et al., 2023b), as well as the UniLM-style model UniXcoder (Guo et al., 2022). This observation demonstrates the benefit of using the encoder-decoder architecture in ${ \mathrm { C o d e T } } 5 +$ to better encode code contexts and generate more accurate code summaries. Finally, we also observed some performance gains against CodeT5 (Wang et al., 2021b), indicating the advantage of our proposed mixture of diverse pretraining learning objectives in addition to the span denoising objective in CodeT5.
397
+
398
+ # D.2 Code Defect Detection and Clone Detection from CodeXGLUE
399
+
400
+ Defect detection is to predict whether a code is vulnerable to software systems or not, while clone detection aims to measure the similarity between two code snippets and predict whether they have a common functionality. We use benchmarks from CodeXGLUE (Lu et al., 2021) and use accuracy and F1 score as the metrics. In Table 9, we can see CodeT $^ { 5 + }$ models achieve new SoTA accuracy of $6 6 . 7 \%$ on the defect detection task. For the clone detection task, our model achieves comparable results to SoTA models, where the performance increase tends to be saturated, observed by the close performance gaps between multiple baselines.
401
+
402
+ Table 9: Results on two understanding tasks: code defect detection and code clone detection.
403
+
404
+ <table><tr><td rowspan="2">Model</td><td>Defect</td><td colspan="3">Clone Detection</td></tr><tr><td>Acc</td><td>Rec</td><td>Prec</td><td>F1</td></tr><tr><td>CodeBERT125M GraphCodeBERT125M UniXcoder125M</td><td>62.1 - 1</td><td>94.7 94.8 92.9</td><td>93.4 95.2 97.6</td><td>94.1 95.0 95.2</td></tr><tr><td>CodeGen-multi 350M PLBART140M</td><td>63.1 63.2</td><td>94.1 94.8</td><td>93.2 92.5</td><td>93.6 93.6</td></tr><tr><td>CodeT5220M</td><td>65.8</td><td>95.1</td><td>94.9</td><td>95.0</td></tr><tr><td>CodeT5+220M CodeT5+ 770M</td><td>66.1 66.7</td><td>96.4 96.7</td><td>94.1 93.5</td><td>95.2 95.1</td></tr></table>
405
+
406
+ # D.3 More Analysis on Retrieval-augmented Code Generation
407
+
408
+ We conduct an ablation study to analyze the effects of top- $k$ retrievals in retrieval-augmented code generation tasks and report the results in Table 10 . We found that increasing the number of retrievals can boost model performance which becomes saturated when $k { = } 5$ . This saturation is due to the maximum sequence length of 600, which might not be able to accommodate a large number of retrieved code samples. Overall, our CodeT $^ { 5 + }$ significantly outperforms the prior SOTA baseline which uses top10 retrievals in all cases, even with only a top-1 retrieved code.
409
+
410
+ We further include a qualitative case in Fig. 6, where we found that the retrieved code provides crucial contexts (e.g., use “urllib3” for an HTTP request) to guide the generative process for more correct prediction. In contrast, the generative-only model gives an incorrect prediction that only captures the concepts of “download” and “compress”.
411
+
412
+ # D.4 Qualitative Results in Math Programming tasks
413
+
414
+ For math programming tasks, we provide qualitative examples predicted by our models in Fig. 7 and Fig. 8. Overall, we found CodeT5+ is able to
415
+
416
+ ![](images/e1b48f6b66cf45580c2399ca55c4bc08ca71d1fc1864629293db54b621b57c1b.jpg)
417
+ Figure 6: Example code generation output: Our Code $\mathrm { T } 5 +$ retrieval-augmented generation model could retrieve relevant code context and use it to facilitate better code generation.
418
+
419
+ Table 10: Effects of varying top- $k$ retrievals in retrieval-augmented code generation tasks with our $\mathbf { C o d e T 5 + } 2 2 0 \mathbf { M }$ compared to the prior SOTA model of REDCODER-EXT that employs top-10 retrievals. EM: Exact Match, B4: BLEU-4, CB: CodeBLEU.
420
+
421
+ <table><tr><td rowspan="2">Model</td><td colspan="3">Java</td><td colspan="3">Python</td></tr><tr><td>EM</td><td>B4</td><td>CB</td><td>EM</td><td>B4</td><td>CB</td></tr><tr><td>SOTA (top-10)</td><td>10.21</td><td>28.98</td><td>33.18</td><td>9.61</td><td>24.43</td><td>30.21</td></tr><tr><td>Ours</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>top-1</td><td>11.66</td><td>33.83</td><td>40.60</td><td>11.83</td><td>31.14</td><td>36.39</td></tr><tr><td>top-2</td><td>11.57</td><td>33.26</td><td>40.74</td><td>11.78</td><td>31.21</td><td>36.58</td></tr><tr><td>top-3</td><td>12.29</td><td>33.10</td><td>41.71</td><td>12.48</td><td>30.92</td><td>37.31</td></tr><tr><td>top-4</td><td>12.42</td><td>32.08</td><td>41.94</td><td>12.73</td><td>30.40</td><td>37.60</td></tr><tr><td>top-5</td><td>13.02</td><td>32.42</td><td>42.28</td><td>12.93</td><td>30.52</td><td>37.87</td></tr><tr><td>top-10</td><td>12.86</td><td>31.38</td><td>42.24</td><td>12.84</td><td>29.79</td><td>37.79</td></tr></table>
422
+
423
+ generate decent programs that can solve the math problems in various levels of difficulties, i.e. from simple math operations to more complex problems with multiple reasoning steps. From the rightmost example of Fig. 8, we found that CodeT $^ { 5 + }$ is able to leverage some external libraries such as math when synthesizing the solutions.
424
+
425
+ # E Finetuning on Downstream Tasks
426
+
427
+ # E.1 Text-to-Code Retrieval
428
+
429
+ Text-to-code retrieval (or code search), is the task of finding the best code sample that is most relevant to a natural language query, from a collection of code candidates. We experiment CodeT5+ with three major benchmarks: CodeSearchNet (CSN) (Husain et al., 2019), CosQA (Huang et al., 2021), and AdvTest (Lu et al., 2021). CSN consists of six programming languages in total, and the dataset is curated by filtering low-quality queries through handcrafted rules, following (Guo et al., 2021). For instance, an example handcraft rule is to filter examples in which the number of tokens in query is shorter than 3 or more than 256.
430
+
431
+ CosQA and AdvTest are two related benchmarks that are both derived from the CSN data. Specifically, instead of natural language queries, CosQA uses logs from Microsoft Bing search engine as queries, each of which is annotated by 3 human annotators (Huang et al., 2021). AdvTest is created from the Python split of the CSN data but the code samples are normalized with obfuscated variable names to better evaluate the understanding abilities of current models. For training, we set the maximum sequence to 350 and 64 for code and text. We set the learning rate as 2e-5 and finetune the model for 10 epochs. We employ distributed training on 8 A100s and the total batch size is 64. For momentum encoders, we maintain a separate text/code queue with a size of 57600, and allow the matching decoder to retrieve 64 hard negatives from the queues for hard negative mining.
432
+
433
+ # E.2 Code Summarization
434
+
435
+ Code summarization is the task of generating a natural language summary of a code snippet. We use the task dataset from CodeXGLUE (Lu et al., 2021) which curated a code summarization benchmark from CSN data (Husain et al., 2019). The benchmark consists of six PLs: Ruby, JavaScript, Go, Python, Java, and PHP. It is the same clean version of CSN data that we use for text-to-code retrieval tasks. For training, we set the maximum sequence length of the source and target as 256 and 128, respectively. We use a learning rate of 2e-5,
436
+
437
+ ![](images/e2f1e3622005425fbb33c322b70e59fd43cdfaba386c34b5f86f23540f565a92.jpg)
438
+ Figure 7: Predictions of our model on GSM8K-Python
439
+
440
+ the batch size as 64 for 10 epochs of finetuning.
441
+ We set the beam size as 5 in inference.
442
+
443
+ # E.3 Code Defect Detection
444
+
445
+ Defect detection is the task of classifying whether a code sample contains vulnerability points or not. We adopt the defect detection benchmark from CodeXGLUE (Lu et al., 2021) which curated data from the Devign dataset (Zhou et al., 2019). The dataset contains in total more than 27,000 annotated functions in C programming language. All samples are collected from popular open-source projects such as QEMU and FFmpeg. We follow (Lu et al., 2021) and adopt $8 0 \% / 1 0 \% / 1 0 \%$ of the dataset as the training/validation/test split. For training, we set the learning rate as 2e-5, the batch size as 32, and the max sequence length as 512 to finetune the model for 10 epochs.
446
+
447
+ # E.4 Code Clone Detection
448
+
449
+ The task of clone detection aims to detect whether any two code samples have the same functionality or semantics. We conduct experiments using the clone detection benchmark from CodeXGLUE (Lu et al., 2021). The benchmark is curated from the BigClone dataset (Svajlenko et al., 2014) and the resulting curated data consists of 901,724/416,328/416,328 examples for training/validation/test splits respectively. All samples are categorized into 10 different functionalities. For finetuning, we set the learning rate as 2e-5 and finetune the model for 2 epochs. We set the batch size as 10, and the max sequence length as 400.
450
+
451
+ # E.5 Code Completion
452
+
453
+ In code completion, given a source sequence containing a partial code sample, a model is required to generate the remaining part of the code sample. We conduct experiments on line-level code completion using two major benchmarks: PY150 (Raychev et al., 2016) and JavaCorpus (Allamanis and Sutton, 2013). PY150 (Raychev et al., 2016) consists of 150,000 Python source files collected from Github. Among these samples, (Lu et al., 2021) selected 10,000 samples from different files from the test set of PY150 and then randomly sampled lines to be predicted for the code completion task. The average numbers of tokens in the source sequence and target sequence are 489.1 and 6.6 respectively. JavaCorpus (Allamanis and Sutton, 2013) contains over 14,000 Java projects collected from GitHub. Similarly to PY150, Lu et al. (2021) selected 3,000 samples from different files from the test set of the dataset and randomly sampled lines to be predicted for the code completion task. The average numbers of tokens in the source and target sequence are 350.6 and 10.5 respectively. For both tasks, we set the learning rate as 2e-5 and batch size as 32, and set the maximum sequence length of 1024 for the decoder. We finetune the model for 30 epochs. During inference, we employ beam search with a beam size of 5.
454
+
455
+ # E.6 Math Programming
456
+
457
+ Math Programming is the task of solving mathsbased problems with programming. Compared to conventional code generation tasks, this task fo
458
+
459
+ ![](images/f55113e2d27b98055563d96cbcb6c63b1b4feedacda254d69e9c9f9d1ad9379b.jpg)
460
+ Figure 8: Predictions of our model on MathQA-Python
461
+
462
+ Question: Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?
463
+
464
+ # Answer:
465
+
466
+ Natalia sold $4 8 / 2 = < < 4 8 / 2 = 2 4 > > 2 4$ clips in May.
467
+ Natalia sold $4 8 + 2 4 = < < 4 8 + 2 4 = 7 2 > > 7 2$ clips altogether in April and May.
468
+ Python Solution:
469
+ ${ \mathsf { n } } 0 = 4 8$
470
+ ${ \mathfrak { n } } 1 = 2$
471
+ t0 = n0 / n1
472
+ answer $= \mathsf { n } 0 + \mathsf { t } 0$
473
+
474
+ Figure 9: One example of how to convert natural language solution into a Python program on GSM8K dataset.
475
+
476
+ cuses more on computational reasoning skills. The problem descriptions in this type of task are also more complex than conventional code generation tasks. We employ two major benchmarks for this task: MathQA-Python (Austin et al., 2021) and GradeSchool-Math (Cobbe et al., 2021).
477
+
478
+ MathQA-Python (Austin et al., 2021) is developed from the MathQA dataset (Amini et al., 2019) where given a mathematical problem description in natural language, a system is required to solve this problem via generating a program that returns the final answer. (Austin et al., 2021) translated these programs into Python programs and filtered for cleaner problems. In total, MathQA-Python contains ${ \sim } 2 4 { , } 0 0 0$ problems, including 19,209/2,822/1,883 samples for training/validation/test splits.
479
+
480
+ GradeSchool-Math (Cobbe et al., 2021) (also known as GSM8K) has similar nature as MathQA. The benchmark focuses on problems with moderate difficulty that an average grade school student should be able to solve. In total, GSM data contains 8,500 problems, divided into 7,500 training and 1,000 testing problems. We translated the solution described in natural language to Python programs by following the construction process of MathQA-Python by Austin et al. (2021). Finally, we successfully converted 5,861 out of 7,500 training samples. One case can be found in Fig. 9.
481
+
482
+ For training, we set the maximum sequence length of the source and target as 256 and 256 for MathQA-Python, and 246, 138 for GSM8k-Python. We use a learning rate of 2e-5 and a batch size of 32 for 30 epochs of finetuning. During inference, we employ the beam size as 5 to get pass $@ 1$ results. For pass $@ 8 0$ and pass $@ 1 0 0$ , we found they are quite sensitive to the diversity of the generation. We employ nucleus sampling with a temperature of 1.2 and top- $\cdot p { = } 0 . 9 5$ .
483
+
484
+ # E.7 Retrieval-augmented Code Generation
485
+
486
+ Developers often search for relevant code snippets from sources on the web such as GitHub or StackOverflow as references to aid their software development process. Motivated by this behaviour, we explore a retrieval-augmented code generation setting, where given a natural language description, a retriever first retrieves similar candidates in a search codebase and then augments the input for the generator to produce the target code. Such retrieval-augmented generation (or retrievethen-generate) paradigm has been widely used in open-domain question answering (Karpukhin et al., 2020) in NLP and recently extended to some coderelated tasks such as code generation and summarization (Parvez et al., 2021), and program repair tasks (Wang et al., 2023). As our CodeT $^ { 5 + }$ is capable of both retrieval and generation, it can be seamlessly adapted as a unified retrieval-augmented generator. This can bring unique benefits such as less computational cost compared to prior work that employs a different retriever and generator. We evaluate CodeT $^ { 5 + }$ on two Java and Python code generation datasets from the CodeXGLUE (Lu et al., 2021) benchmark following Parvez et al. (2021).
487
+
488
+ Specifically, we leverage the encoder to encode the code snippet in the retrieval base and build a search index with the faiss library (Johnson et al., 2019). The search index is a set of representations (of 256 dimensions) for all the code snippets in the retrieval codebase. Let $( x _ { i } , y _ { i } )$ denote one training instance where $x _ { i }$ is the input text description and $y _ { i }$ is the corresponding target code snippet. we employ the same encoder to obtain the embedding of $x _ { i }$ and retrieve top- $k$ similar code samples from the search base using the L-2 similarity metric, with $k$ being a hyperparameter. We ensure that the training example’s target string $( y _ { i } )$ is not present in any of these $k$ retrieved samples.
489
+
490
+ After retrieving these top- $k$ relevant code samples, we combine them with a special token [SEP] and concatenate it to the end of the source input $x _ { i }$ Unlike (Parvez et al., 2021), we do not augment docstrings or text descriptions and only augment the code snippet for simplicity. We then finetune CodeT $^ { 5 + }$ on this augmented dataset. During inference, we retrieve similar code samples from the search base and augment these to input $x _ { i }$ . For training, we set the maximum sequence length of the source and target as 600 and 320. We use a learning rate of 2e-5, the batch size as 32 to finetune the model for 10 epochs. We set the beam size as 5 during inference with beam search.
md/dev/uuUQraD4XX/uuUQraD4XX.md ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Large Language Models Can Self-Improve
2
+
3
+ Jiaxin Huang1∗ Shixiang Shane $\mathbf { G u ^ { 2 } }$ Le $\mathbf { H o u } ^ { 2 \dagger }$ Yuexin $\mathbf { W } \mathbf { u } ^ { 2 }$ Xuezhi Wang2 Hongkun $\mathbf { Y } \mathbf { u } ^ { 2 }$ Jiawei Han1
4
+
5
+ 1University of Illinois at Urbana-Champaign 2Google 1{jiaxinh3, hanj}@illinois.edu 2{shanegu, lehou, crickwu, xuezhiw, hongkuny}@google.com
6
+
7
+ # Abstract
8
+
9
+ Large Language Models (LLMs) have achieved excellent performances in various tasks. However, fine-tuning an LLM requires extensive supervision. Human, on the other hand, may improve their reasoning abilities by self-thinking without external inputs. In this work, we demonstrate that an LLM is also capable of self-improving with only unlabeled datasets. We use a pre-trained LLM to generate “highconfidence” rationale-augmented answers for unlabeled questions using Chain-of-Though (CoT) prompting and self-consistency, and finetune the LLM using those self-generated solutions as target outputs. We show that without any ground truth label, our approach significantly improves the general reasoning ability of PaLM 540B model $7 4 . 4 \% 8 2 . 1 \%$ on GSM8K, $9 0 . 0 \% 9 4 . 4 \%$ on OpenBookQA, and $6 3 . 4 \% 6 7 . 9 \%$ on ANLI-A3) and can also be adapted to extreme low-resource cases where even training questions and CoT prompts are limited. We conduct ablation studies and show that fine-tuning on diverse reasoning paths is critical for self-improvement.
10
+
11
+ # 1 Introduction
12
+
13
+ self-consistency (Wang et al., 2022c) further improves the performance via self-evaluating multiple reasoning paths.
14
+
15
+ Scaling has enabled Large Language Models (LLMs) to achieve state-of-the-art performance on a range of Natural Language Processing (NLP) tasks (Wang et al., 2018, 2019; Rajpurkar et al., 2016). More importantly, new capabilities have emerged from LLMs as they are scaled to hundreds of billions of parameters (Wei et al., 2022b): in-context few-shot learning (Brown et al., 2020) makes it possible for an LLM to perform well on a task it never trained on with only a handful of examples; Chain-of-Thought (CoT) prompting (Wei et al., 2022c; Kojima et al., 2022) demonstrates strong reasoning ability of LLMs across diverse tasks with or without few-shot examples;
16
+
17
+ Despite these incredible capabilities of models trained on large text corpus (Brown et al., 2020; Chowdhery et al., 2022), fundamentally improving the model performances beyond few-shot baselines still requires finetuning on an extensive amount of high-quality supervised datasets. FLAN (Wei et al., 2021; Chung et al., 2022) and T0 (Sanh et al., 2022) curated tens of benchmark NLP datasets to boost zero-shot task performances on unseen tasks; InstructGPT (Ouyang et al., 2022) crowd-sourced many human answers for diverse sets of text instructions to better align their model to human instructions; Minerva (Lewkowycz et al., 2022) parsed the full ArXiv database carefully for relevant articles to excel on challenging competitive math and science datasets. The need for large annotated data for supervised LLM training still remains a burden for low-resource applications or specific domains where only limited annotations are available.
18
+
19
+ In this paper, we study how an LLM capable of in-context few-shot learning and chain-ofthought reasoning, is able to self-improve its reasoning ability without supervised data. We show that using only input sequences (without ground truth output sequences) from multiple NLP task datasets, a pre-trained LLM is able to improve performances for both in-domain and out-of-domain tasks. Our method is shown in Figure 1: we first sample multiple predictions using few-shot Chain-of-Thought (CoT) (Wei et al., 2022c) as prompts, filter “high-confidence” predictions using majority voting (Wang et al., 2022c), and finally finetune the LLM on these high-confidence predictions. The resulting model shows improved reasoning in both greedy and multi-path evaluations. We call the model fine-tuned in this way as Language Model Self-Improved (LMSI).
20
+
21
+ Note that LMSI depends on in-context few-shot learning and chain-of-thought reasoning abilities which small language models do not necessarily have. We empirically verify LMSI using a pre-trained 540B PaLM model (Chowdhery et al., 2022), where our method not only significantly improves training task performances $7 4 . 4 \% 8 2 . 1 \%$ on GSM8K, $9 0 . 0 \% 9 4 . 4 \%$ on OpenBookQA, and $6 3 . 4 \% 6 7 . 9 \%$ on ANLI-A3), but also enhances out-of-domain (OOD) tasks, without relying on supervised ground truth answers. Lastly, we explore more extreme cases where training questions and human-curated CoTs are also limited, and propose self-generating additional input questions and few-shot CoT prompts for model self-improving. We hope our simple approaches and strong empirical results could inspire more future work by the community to investigate optimal performances of pretrained LLMs without additional human supervision.
22
+
23
+ Our contributions are summarized as follows:
24
+
25
+ • We demonstrate that a large language model can self-improve by taking datasets without ground truth outputs, by leveraging CoT reasoning (Wei et al., 2022c) and self-consistency (Wang et al., 2022c) to generate diverse reasoning paths for self-training, and can achieve great improvments on in-domain multi-task performances as well as out-of-domain generalization.
26
+
27
+ • We provide detailed ablation studies on training sample formatting and sampling temperature after fine-tuning, and identify critical design choices for most successful self-improvement by LLMs.
28
+
29
+ • We further propose two approaches for model self-improving under extreme low-resource cases where even training questions and CoT prompts are limited, and achieve $7 4 . 2 \%$ on zero-shot GSM8K, against $4 3 . 0 \%$ by Kojima et al. (2022) or $70 . 1 \%$ through its naive extension with Wang et al. (2022c).
30
+
31
+ The rest of this paper is organized as follows. Section 2 discusses related work. Section 3 lays out our method in detail. Section 4 shows our setup for experiments. Section 5 demonstrates our experiment results with ablation studies. Section 6 concludes our work. The chain-of-thought prompts used in our work are included in Appendix A.
32
+
33
+ # 2 Related Work
34
+
35
+ Learning from explanations. Augmenting a machine learning model with explanations has been studied in existing literature extensively. For example, in the supervised learning setting, a model can be fine-tuned using human-annotated rationales (Zaidan et al., 2007; Ling et al., 2017a; Narang et al., 2020; Camburu et al., 2018; Cobbe et al., 2021; Chung et al., 2022). A few works have also looked at how explanations can help the models in various settings, e.g., in-context learning (Lampinen et al., 2022) and in distillation (Pruthi et al., 2022). Lightman et al. (2023) treat explanations as process supervision to train a reward model. In this paper, we focus more on the unsupervised learning setting, where we do not assume we have a rationale-augmented training dataset available, since human-annotated rationales can be expensive.
36
+
37
+ Few-shot explanations improves reasoning in LLMs. Recently, a lot of progress has been made towards improving LLMs’ reasoning abilities via prompting or in-context learning. Wei et al. (2022c) propose Chain-of-Thought prompting, which prompts the language model to generate a series of natural-language-based intermediate steps, and show it can help language models better solve complex and multi-step reasoning tasks, with recent study (Wang et al., 2022a) analyzing the relevant contents and correct reasoning order being the most crucial factor of the success of Chain-ofThought prompting. Wang et al. (2022c) improve Chain-of-Thought prompting by sampling multiple diverse reasoning paths and finding the most consistent answers via majority voting. Kojima et al. (2022); Zhang et al. (2022) propose to prompt the language model with “Let’s think step by step” to generate reasoning in a zero-shot fashion. Zhou et al. (2022) decompose the questions into multiple sub-questions, and ask the language model to solve each sub-question sequentially.
38
+
39
+ Refining explanations. More recent work proposes to further refine the generated reasoning paths as some of them could be unreliable. For example, Ye and Durrett (2022) calibrate model predictions based on the reliability of the explanations, Jung et al. (2022) show that inducing a tree of explanations and inferring the satisfiability of each explanation can further help judge the correctness of explanations. Li et al. (2022a) show that sampling a diverse set of prompts from the training data, and a voting verifier can be used to improve model’s reasoning performance. Xi et al. (2023) and Zheng et al. (2023) propose to polish the problem progressively before the model reaching a stable answer. Zelikman et al. (2022) proposes better rationale generation by augmenting ground truth answers as hints when predicted answers are incorrect. Our work is orthogonal to these lines of work, as we utilize refined explanations for model selfimprovement, and could readily incorporate these other refinement techniques for generating higherquality self-training data. Our work is closely related to Zelikman et al. (2022) where we both propose to fine-tune a model on self-generated CoT data, but our method does not require ground truth labels and shows stronger empirical results with multi-task generalization. Different from existing work, we show that a mixture of the reasoningpath refinement techniques can be combined to further improve the quality of the generated reasoning paths, which is shown to be effective in boosting model’s performance via self-improvement.
40
+
41
+ ![](images/c75604b02ce44f7ac2495321043ac6bfbd5b61a9f005ee18ee50036ab7cd0b59.jpg)
42
+ Figure 1: Overview of our method. With Chain-of-Thought (CoT) examples as demonstration (Wei et al., 2022c), the language model generates multiple CoT reasoning paths and answers (temperature $T > 0$ ) for each question. The most consistent answer is selected by majority voting (Wang et al., 2022c). The CoT reasoning paths that lead to the answer with the highest confidence are augmented by mixed formats, and are fed back to the model as the final training samples.
43
+
44
+ Self-training models. One related line of work is self-training (see a survey from Amini et al. (2022)). The key idea is to assign pseudo labels from a learned classifier to unlabeled data, and use these pseudo-labeled examples to further improve the original model training, e.g., (RoyChowdhury et al., 2019; Xie et al., 2020; He et al., 2020; Chen et al., 2021). Different from such prior work, our proposed self-improvement framework uses CoT prompting plus self-consistency to obtain highconfidence solutions on a large set of unlabeled data to augment the fine-tuning process.
45
+
46
+ Distillation and dark knowledge. Language models are known to preserve parametric knowledge (Schick and Schütze, 2020a,b) during the pretraining stage. Our method tangentially relates to rich literature on distillation (Ba and Caruana, 2014; Hinton et al., 2015), where a student network imitates a teacher network’s classifier predictions on input examples. A key detail is to learn from soft targets instead of hard predicted labels, as softmax outputs with a high temperature reveal more detailed relative class likelihoods, colloquially known as dark knowledge (Hinton et al., 2015; Korattikara Balan et al., 2015). Recent studies (Zelikman et al., 2022; Snell et al., 2022; Eisenstein et al., 2022) show that dark knowledge within LLMs can be retrieved with more computation at inference time, such as adding informative instructions into the input sequence and output CoT generation (Wei et al., 2022c; Kojima et al., 2022). Recent works (Magister et al., 2022; dhar et al., 2023; Ho et al., 2023) demonstrated that distillation on explanations generated from large models can increase the reasoning abilities of smaller models with ground truth filtering.
47
+
48
+ # 3 Method
49
+
50
+ The overview of our method is illustrated in Fig. 1: We are given a pre-trained Large Language Model (LLM) $M$ and a question-only train
51
+
52
+ Question: Stefan goes to a restaurant with his family. They order an appetizer that costs $\$ 10$ and 4 entrees that are $\$ 20$ each. If they tip $20 \%$ of the total, what is the total amount of money that they spend?
53
+
54
+ # Multiple Path Decoding:
55
+
56
+ Output 1: The appetizer costs $\$ 10$ . The entrees cost $\$ 20$ each so in total $4 * \ S 2 0 = \ S 8 0$ . This means the total cost is $\$ 10+580=590$ . They tip $20 \%$ of it, so the total amount they spend is $\$ 90 *1.2$ $= \$ 108$ . The answer is 108.
57
+
58
+ Output 2: The appetizer costs $\$ 10$ and the entrees are $\$ 20$ each. There are 4 entrees so the sum is $\$ 20 *4=\ S 80$ . The waiter gets $20 \%$ of the total. $20 \%$ of $\$ 80$ is $\$ 80 *.2=916$ . The answer is $\$ 80$ $+ \$ 16= \$ 96$ . (Incorrect reasoning path)
59
+
60
+ Output 3: The appetizer costs $\$ 10$ . The entrees cost $4 * \$ 20=980$ . The tip is $20 \%$ of the total, so it is $20 \%$ of the $\$ 90$ they have spent. The tip is $0 . 2 * 9 0 = \$ 18$ . The total they spent is $\$ 90+\$ 18$ $= \$ 108$ . The answer is 108.
61
+
62
+ ing dataset $\mathcal { D } ^ { \mathrm { t r a i n } } = \{ x _ { i } \} _ { i = 1 } ^ { D }$ with few-shot Chainof-Thought $( \mathrm { C o T } )$ examples (Wei et al., 2022c). We apply multiple path decoding with a sampling temperature $T \ > \ 0$ for generating $m$ reasoning paths and answers $\{ r _ { i _ { 1 } } , r _ { i _ { 2 } } , \ldots , r _ { i _ { m } } \}$ for each question $x _ { i }$ in $\scriptstyle { \mathcal { D } } ^ { \mathtt { t r a i n } }$ , and use majority voting (selfconsistency) to select the most consistent, highest confidence answer (Wang et al., 2022c). We then keep all reasoning paths that lead to the most consistent answer, apply mixed formats of prompts and answers for augmentation, and fine-tune the model on these self-generated reasoning-answer data. We consider our approach as making the model self-improve. In the following sections, we detail important designs within our method, along with additional approaches for the model to selfimprove without supervised data.
63
+
64
+ ![](images/21ba3235aa5b574c2a6455191982da9b18312279c87045e355d640468f02b67b.jpg)
65
+ Figure 2: The relation of accuracy and confidence of the majority-voted answer after multiple path decoding on GSM8K training-set questions. A recent study (Kadavath et al., 2022) shows that language models are not perfectly-calibrated though their calibration increases with model size, and models with more than 10B parameters are reasonably calibrated on some few-shot tasks. This aligns well with our study and serve as the basis of this self-improving method.
66
+
67
+ # 3.1 Generating and Filtering Multiple Reasoning Paths
68
+
69
+ Self-consistency (Wang et al., 2022c) brings large improvements on reasoning tasks (e.g., $5 6 . 5 \% $ $7 4 . 4 \%$ on GSM8K test set), and the gap between greedy decoding and diverse decoding shows there is a potential for further improving the reasoning ability of $M$ , using the self-selected highconfidence reasoning paths as training data.
70
+
71
+ For each training question $x _ { i }$ , we sample $m$ CoT reasoning paths, denoted as $\{ r _ { i _ { 1 } } , r _ { i _ { 2 } } , \ldots , r _ { i _ { m } } \}$ (see Table 1 for examples). An example of a training question with the self-generated CoT reasoning paths is shown in Table 1. Since $M$ is prompted with the CoT examples from Wei et al. (2022c), we apply the same output parsing with “The answer is” to generate their predicted answers $\{ y _ { i _ { 1 } } , y _ { i _ { 2 } } , . . . , y _ { i _ { m } } \}$ . The most consistent answer, which is not necessarily a correct answer, is selected by majority voting, denoted as $\begin{array} { r } { \tilde { y } _ { i } = \mathrm { a r g } \operatorname* { m a x } _ { y _ { i _ { j } } } \sum _ { k = 1 } ^ { m } \mathbb { I } ( y _ { i _ { j } } = y _ { i _ { k } } ) } \end{array}$ . In Table 1, the most consistent answer $\tilde { y }$ is 108, derived by output path 1 and output path 3, while the output path 2 makes a mistake in calculating the cost of the foods. For all the training questions, we filter the CoT reasoning paths that reach $\tilde { y }$ as the final answer to be put into the self-training data,
72
+
73
+ Table 2: An example of how a reasoning path is augmented into four formats of training data with different prompts (in input) and answer styles (in output). Specifically, the CoT prompting examples used for each tasks are listed in Appendix A.2. The Standard prompting examples are the same question-answer pairs with CoT prompting examples, except that reasoning is removed.
74
+
75
+ <table><tr><td>Question: Amy is 1O years old. Jake is 8 years old. Alex&#x27;s age is right in the middle. How old is Alex? Selected Chain-of-Thought: Amy is 1O years old. Jake is 8 years old. Alex&#x27;s age is in the middle of Amy and Jake, so Alex is(8 + 10) /2= 9 years old. The answer is 9.</td></tr><tr><td>Mixed-formats of training data: Format 1: Input: [CoT prompting examples] + ‘\n’ + [Question] +&quot;\n’ +‘A:&#x27; Output: Amy is 10 years old. Jake is 8 years old. Alex&#x27;s age is in the middle of Amy and Jake, so Alex</td></tr><tr><td>is(8 + 10)/2 =9 years old. The answer is 9. Format 2: Input: [Standard prompting examples] + &quot;\n’ + [Question] + &#x27;\n&#x27; + ‘A:</td></tr><tr><td>Output: The answer is 9.</td></tr><tr><td>Format 3: Input: [Question] + ‘\n’ + ‘A: Let&#x27;s think step by step.&#x27;</td></tr><tr><td></td></tr><tr><td>Output: Amy is 10 years old. Jake is 8 years old. Alex&#x27;s age is in the middle of Amy and Jake, so Alex is(8 + 10)/2=9 years old. The answer is 9.</td></tr><tr><td>Format4:Input:[Ouestion]+‘\n&#x27;+‘A:&#x27;</td></tr></table>
76
+
77
+ Output: The answer is 9.
78
+
79
+ denoted as Dself−consistent $\mathbf { \Sigma } = \{ x _ { i } , \tilde { r _ { i } } \}$ , where $\tilde { r _ { i } } = \{ r _ { i _ { j } } | 1 \le j \le m , y _ { i _ { j } } = \tilde { y } _ { i } \}$ .
80
+
81
+ Since we do not use any ground truth labels to filter out cases where $\tilde { y } _ { i } \ne y _ { i }$ , it is important that the self-generated CoT reasoning paths are mostly reliable and incorrect answers do not hurt the self-improvement of the model. We plot the relation between the accuracy and confidence of selfgenerated CoT paths for each question in GSM8K training set in Fig. 2. The confidence is the number of CoT paths leading to $\tilde { y }$ divided by the total path number $m$ . The y-axis shows the accuracy of $\tilde { y }$ under a certain confidence. The circle area and the color darkness shows the number of questions under a certain confidence. We can observe that confident answers are more likely to be correct, which means that when a question has many consistent CoT paths, then the corresponding $\tilde { y }$ is more likely to be correct. On the other hand, when $\tilde { y }$ is wrong, it is likely to be supported by fewer CoT paths, and brings little noise to the training samples.
82
+
83
+ ble 2. In the first format, a few Chain-of-Thought examples (questions followed by reasoning paths leading to the correct final answers) are prepended to the new question, while the language model output is trained to be the same with the filtered CoT reasoning paths. In the second format, we use examples of questions and their direct answers as standard prompting, and the language model output is supposed to also only contain the direct answer. The third and fourth format are similar to the first and second format, except that no example of question-answer pairs are given, so that the model will learn to think on its own in an in-context zero-shot manner. In the third format, where we want the model to output CoT reasoning without prepending examples containing CoT reasonings, we append “Let’s think step by step.” at the end of the input sequence, to guide the language model to generate step-by-step CoT reasoning paths (Kojima et al., 2022). The mixed formats of training samples are then used to fine-tune the pre-trained language model $M$ .
84
+
85
+ # 3.2 Training with Mixed Formats
86
+
87
+ To prevent the language model from overfitting to specific prompts or answer styles, we create four different formats for each reasoning path to be mixed in the self-training data, shown in Ta
88
+
89
+ # 3.3 Generating Questions and Prompts
90
+
91
+ In some cases where even training questions or human-curated CoT prompts are limited, our method may not generate sufficient training samples for language model self-training. Therefore, we investigate how to self-generate more training questions as well as example prompts to further reduce human effort.
92
+
93
+ Question Generation. Previous work (Yoo et al., 2021; Meng et al., 2022) discuss few-shot data augmentation by generating diverse training samples using LLMs. However, those methods are designed for classification tasks and require ground truth label for each few-shot example. We use a simple yet effective approach to generate diverse questions (without using ground truth answers) from a few example questions. Specifically, we randomly sample and concatenate example questions in a random order as input prompt, and let the language model generate consecutive sequences as new questions. We repeat the process to obtain a large set of new questions, then use self-consistency (Wang et al., 2022c) to only keep the questions that have a highly confident answer. Those questions are then used as self-generated training questions.
94
+
95
+ Prompt Generation. Given a set of questions, humans can write CoT examples as reasoning paths leading to the final answer. In zero-shot setting without manual prompts, we can generate these CoT paths using the model itself. Following (Kojima et al., 2022), we start the answer with “A: Let’s think step by step.” and let the language model generate the consecutive reasoning paths. We then use those generated reasoning paths as examples for few-shot CoT prompting.
96
+
97
+ # 4 Experimental Setup
98
+
99
+ Tasks and Datasets. We demonstrate the effectiveness of our method on three types of tasks1:
100
+
101
+ • Arithmetic reasoning: We use the math problem set GSM8K (Cobbe et al., 2021), and a reading comprehension benchmark DROP (Dua et al., 2019) which requires numerical reasoning. We follow (Zhou et al., 2022) to partition the DROP dataset into football related and non-football related subsets for training.
102
+
103
+ • Commonsense reasoning: We use the OpenBookQA (Mihaylov et al., 2018) dataset, and the AI2 Reasoning Challenge (ARC) (Clark et al., 2018) dataset. Note that for ARC, we only use the Challenge sub-set (ARC-c) in our experiments. Both datasets contain multiple-choice questions.
104
+
105
+ • Natural Language Inference: We use the Adversarial NLI (ANLI) (Mihaylov et al., 2018) subsets, ANLI-A2 and ANLI-A3, which are the more challenging subsets compared to ANLI-A1. These datasets contain pairs of sentences with relations of entailment, neutral, or contradiction.
106
+
107
+ Models, Training settings and Hyperparameters. We follow previous studies (Wei et al., 2022c; Wang et al., 2022c) and conduct our experiments on the PaLM 540B model (Chowdhery et al., 2022), an autoregressive Transformer-based language model. The CoT examples for each dataset are listed in Appendix A.2. We generate $m = 3 2$ reasoning paths for each question in a training set, followed by format augmentation in Sec. 3.2. For DROP and ANLI-A2/A3, we sample $5 \mathrm { k }$ examples for reasoning path generation to reduce the training burden; For other datasets, we keep the whole training set. For each dataset, we fine-tune the model for $1 0 \mathrm { k }$ steps with a learning rate of $5 \mathrm { e } - 5$ and a batch size of 32. We use a sampling temperature of $T = 0 . 7$ with the pre-trained model as suggested by (Wang et al., 2022c). We use $T = 1 . 2$ for the language model after self-improvement (LMSI ). We set the maximum number of decoded steps to 256 for all experiments.
108
+
109
+ # 5 Experiments and Results
110
+
111
+ We conduct a series of experiments to demonstrate the effectiveness of our proposed self-improving method. First, we apply our method on each individual dataset (task) and report the results. We then merge the generated data from all datasets and train one model to study the generalization ability of the model on unseen datasets as in (Wei et al., 2021). In addition to the results of using generated CoT reasoning paths, we show studies on generating input questions and few-shot prompts. We end with ablation studies on model sizes and hyperparameters.
112
+
113
+ # 5.1 Main Results
114
+
115
+ We list the results of using the 540B PaLM model before and after LMSI in Table 3. For each model, during test time, we apply three separate prompting methods on all six datasets: standard-prompting, CoT-Prompting, and Self-Consistency. We observe that after LMSI , the performance of all three prompting methods increase by a large margin. We observe significant improvement, comparing selfconsistency versus LMSI with self-consistency: $+ 7 . 7 \%$ on GSM8K, $+ 4 . 8 \%$ on DROP, $+ 4 . 4 \%$ on OpenBookQA, and $+ 4 . 5 \%$ on ANLI-A3. This shows that our proposed method is quite effective. Furthermore, the single path CoT-Prompting performance of LMSI is close to or even better than the multiple path Self-Consistency performance of the model without LMSI , showing that LMSI truly helps the language model learn from the multiple consistent reasoning paths. We also apply LMSI on a recently proposed public language model, UL2 (20B) (Tay et al., 2022), and show the results in Appendix A.1. Compared to the 540B PaLM model (decoder-only), UL2 has a smaller scale, and a different architecture (encoder-decoder). We observe that for most datasets, LMSI still outperforms the original UL2 results, but the improvement is not as large as that on the 540B PaLM model.
116
+
117
+ Table 3: Accuracy results on six reasoning benchmarks with or without LMSI using different prompting method.
118
+
119
+ <table><tr><td>Prompting Method</td><td> w. or w/o LMSI</td><td>GSM8K</td><td>DROP</td><td>ARC-c</td><td>OpenBookQA</td><td>ANLI-A2</td><td>ANLI-A3</td></tr><tr><td>Standard-Prompting</td><td>w/o LMSI w. LMSI</td><td>17.9 32.2 (+14.3)</td><td>60.0 71.7 (+11.7)</td><td>87.1 87.2 (+0.1)</td><td>84.4 92.0 (+7.6)</td><td>55.8 64.8 (+9.0)</td><td>55.8 66.9 (+11.1)</td></tr><tr><td>CoT-Prompting</td><td>w/o LMSI w. LMSI</td><td>56.5 73.5 (+17.0)</td><td>70.6 76.2 (+5.6)</td><td>85.2 88.3 (+3.1)</td><td>86.4 93.0 (+6.6)</td><td>58.9 65.3 (+6.4)</td><td>60.6 67.3 (+6.7)</td></tr><tr><td>Self-Consistency</td><td>w/o LMSI w. LMSI</td><td>74.4 82.1 (+7.7)</td><td>78.2 83.0 (+4.8)</td><td>88.7 89.8 (+1.1)</td><td>90.0 94.4 (+4.4)</td><td>64.5 66.5 (+2.0)</td><td>63.4 67.9 (+4.5)</td></tr></table>
120
+
121
+ Table 4: Comparison of CoT-prompting accuracy results on six Out-Of-Domain benchmarks with or without training on six In-Domain (GSM8K, DROP, ARC-c, OpenBookQA, ANLI-A2, ANLI-A3) training-set questions.
122
+
123
+ <table><tr><td></td><td>Self-training data</td><td>AQUA</td><td> SVAMP</td><td> StrategyQA</td><td>ANLI-A1</td><td>RTE</td><td>MNLI-M/MM</td></tr><tr><td>w/o LMSI</td><td>-</td><td>35.8</td><td>79.0</td><td>75.3</td><td>68.8</td><td>79.1</td><td>72.0/74.0</td></tr><tr><td>w. LMSI</td><td>GSM8K + DROP +...</td><td>39.0 (+3.2)</td><td>82.8 (+3.8)</td><td>77.8 (+2.5)</td><td>79.2 (+10.4)</td><td>80.1 (+1.0)</td><td>81.8/82.2 (+9.8/+8.2)</td></tr></table>
124
+
125
+ Multi-task self-training for unseen tasks. To demonstrate the generalization ability of LMSI , we conduct experiments of self-training on a mixture of the training-set questions from the above six datasets (denoted as In-Domain tasks), then use the same model checkpoint for the evaluation on six Out-Of-Domain (OOD) tasks, as shown in Table 4. Of all the OOD tasks: (1) AQUA (Ling et al., 2017b) and SVAMP (Patel et al., 2021) are arithmetic reasoning tasks; (2) StrategyQA (Geva et al., 2021) is a commonsense reasoning task; (3) ANLIA1 (Nie et al., 2019), RTE (Dagan et al., 2005) and MNLI-M/MM (Williams et al., 2018) are natural language inference tasks.2 Among these tasks, AQUA, StrategyQA, and RTE are significantly different from any In-Domain task, and have their own few-shot prompts. From Table 4, we observe that LMSI achieves higher accuracy results on all OOD tasks, showing that the overall reasoning ability of the language model is improved.
126
+
127
+ Importance of training with augmented formats. We demonstrate the importance of training language models with augmented formats (both Chainof-Thought prompting and direct prompting, and both few-shot prompting and zero-shot prompting). In Table 5, we list the results of LMSI with all four formats, the results of LMSI with only direct answer formats, and the results of LMSI with only few-shot Chain-of-Thought prompting formats. The results show that without the CoT formats, the language model can still self-improve, but the performance gain drops by a large amount compared to using all four formats. However, if only using few-shot CoT prompting format for selftraining, the model can overfit to the prompting style and may not generalize well on downstream tasks.
128
+
129
+ # 5.2 Pushing the limit of self-improvements
130
+
131
+ Self-Generating Questions We further explore the few-shot setting where there are only limited training questions in the target domain. On GSM8K, we sample 10 real questions as few-shot samples, and use the language model to generate more training questions using the method in Section 3.3. We then self-train the language model with these generated questions and list the results in Table 6. The results show that using self-generated questions still improves the reasoning ability of language models, but using the real training-set questions leads to better results.
132
+
133
+ Table 5: Ablation study: LMSI with different combinations of training format on GSM8K dataset.
134
+
135
+ <table><tr><td colspan="2">Results on GSM8K</td></tr><tr><td>w/o LMSI</td><td>Std. Prompting CoT Prompting 17.9 56.5</td></tr><tr><td>LMSI w/o CoT formats</td><td>23.6 (+5.7)</td></tr><tr><td>LMSI only few-shot CoT</td><td>61.6 (+5.1) 69.4 (+12.9)</td></tr><tr><td>LMSI w/CoT formats</td><td>29.2 (+11.3) 32.2 (+14.3) 73.5 (+17.0)</td></tr></table>
136
+
137
+ Table 6: Accuracy on GSM8K test set after self-training on different question sets. Results are shown for both CoT-Prompting (CoT) and Self-Consistency (SC).
138
+
139
+ <table><tr><td rowspan="2"></td><td rowspan="2">Questions used for Self-Training</td><td colspan="2">GSM8K</td></tr><tr><td>CoT</td><td>SC</td></tr><tr><td>w/o LMSI</td><td></td><td>56.5</td><td>74.4</td></tr><tr><td>w. LMSI</td><td>Generated</td><td>66.2 (+9.7)</td><td>78.1 (+3.7)</td></tr><tr><td>w. LMSI</td><td>Training-set</td><td>73.5 (+17.0)</td><td>82.1 (+7.7)</td></tr></table>
140
+
141
+ Self-Generating Few-Shot CoT Prompts. We explore the situation where no in-domain CoT examples are provided for a task. We apply the Stepby-Step method (Kojima et al., 2022) to generate CoT examples using the language model as described in Section 3.3, and show the results in Figure 3. We observe that few-shot prompting with self-generated Step-by-Step CoT examples substantially outperforms the Step-by-Step (Kojima et al., 2022) baseline $6 6 . 2 \%$ vs $5 3 . 8 \%$ at 10 paths, $7 4 . 2 \%$ vs $7 0 . 1 \%$ at 40 paths), and nearly matches the performance of human-written few-shot CoT (Wei et al., 2021) $( 7 4 . 4 \%$ at 40 paths (Wang et al., 2022c)). The strong performance of “Few-Shot w/ Step-by-Step” despite the limited accuracy of prompt examples ( $4 3 . 0 \%$ for greedy Step-by-Step) likely comes from leveraging more diverse CoT prompts for multi-path decoding (Li et al., 2022b), where at 40 paths it uses 20 generate prompttemplates, each with 4-shot CoT examples, i.e. a total of 80 generated CoT examples compared to 8 human-written examples use in Wei et al. (2022c).
142
+
143
+ Since we did not use training questions or few-shot CoT examples, $7 4 . 2 \%$ also marks the new state-ofthe-art zero-shot performance on GSM8K.
144
+
145
+ ![](images/dd69dade2171bed96a9241d1a30e748ed5fe732e0cf2428403c9cbd3553cfc6e.jpg)
146
+ Figure 3: Accuracy results on GSM8K test set using 540B model with multi-path sampling and selfconsistency (Wang et al., 2022c). “Step-by-Step” is the baseline performance of Kojima et al. (2022) plus selfconsistency (Wang et al., 2022c), while our “Few-Shot w/ Step-by-Step” uses exemplers self-generated from Step-by-Step (greedy decoding) for few-shot prompting the LLM.
147
+
148
+ # 5.3 Distillation to smaller models
149
+
150
+ Table 7: Distillation from 540B model to small models. We see that distilled smaller models outperform models that are one-tier larger.
151
+
152
+ <table><tr><td></td><td colspan="3">Results on GSM8K</td></tr><tr><td></td><td>8 billion</td><td>62 billion</td><td>540 billion</td></tr><tr><td>w/o LMSI</td><td>5.0</td><td>29.7</td><td>56.5</td></tr><tr><td>Distilled from LMSI</td><td>33.4 (+28.4)</td><td>57.4 (+27.7)</td><td>-</td></tr></table>
153
+
154
+ We also explore whether the knowledge can be distilled to smaller models, such as in distillation (Hinton et al., 2015) and in Zelikman et al. (2022). We use the same set of training samples generated by the 540B PaLM model, but fine-tune on models with smaller sizes (8B PaLM model and 62B PaLM model respectively), and show the results of CoT-prompting in Table 7. It is interesting to point out that after distillation from LMSI , the 62B model can outperform the pre-trained 540B model, and the 8B model can outperform the pre-trained 62B model. This implies that for downstream applications with limited computing resources, the reasoning knowledge from large models can be used to largely enhance small models to achieve competitive performance.
155
+
156
+ # 5.4 Hyperparameter Studies
157
+
158
+ Sampling Temperature after Self-Improvement. We study the effect of varying the temperature $T$ for multiple path decoding after LMSI is applied. Specifically, we vary $T$ between [0.7, 1.0, 1.2, 1.5] and show the results on GSM8K and DROP dataset respectively in Fig. 4. As shown in the figure, $T = 1 . 2$ benefits both datasets the most, and is used in the Self-Consistency method for LMSI on all datasets. We notice that the optimal $T$ after model self-improvement is larger than the optimal $T = 0 . 7$ (Wang et al., 2022c) before selfimprovement. We believe the reason is that after training the model, the entropy of the output distribution is reduced.
159
+
160
+ ![](images/efbe75ef053d63876219c2ace74b92b8b1202d782da52ae0262b5d3d74fdf3fb.jpg)
161
+ Figure 4: Accuracy results of LMSI on GSM8K and DROP test set when different sampling temperatures are applied for Self-Consistency.
162
+
163
+ Number of Sampled Reasoning Paths. We study whether the number of sampled reasoning paths $m$ for Self-Consistency largely affects the accuracy after LMSI is applied. We show the accuracy on GSM8K test set for models both with or without LMSI in Fig. 5. For both cases, setting $m = 1 5$ already achieves a reasonably good accuracy, and using a larger $m$ only brings marginal improvements. We also notice that after SelfImprovement, using 5 paths for Self-Consistency can already surpass the performance of using 32 paths for model without Self-Improvement. Thus, with a well-improved model, huge computing resources can be saved when applied to real applications.
164
+
165
+ # 6 Conclusions
166
+
167
+ We demonstrated that a Large Language Model (LLM) is capable of improving its performance on reasoning datasets by training on its own generated labels, given input questions only. Experiments using the PaLM model with 540 billion parameters show that LMSI improves the accuracy scores by $1 . 1 \%$ to $7 . 7 \%$ on six datasets, without training on ground truth labels. Furthermore, we show that it is possible for the LLM to self-improve even on its own generated questions and few-shot CoT prompts. As part of our future work, we plan to combine large-scale generated data from LMSI and existing supervised data, to further improve the performance of LLMs.
168
+
169
+ ![](images/2cfb6fd99ee3098a3d977f97ef9877c4291899eb705842fc1d61b479b999154f.jpg)
170
+ Figure 5: Accuracy results with or without LMSI on GSM8K test set using different numbers of sampled reasoning path for Self-Consistency.
171
+
172
+ # Limitations
173
+
174
+ Our approach mainly relies on the effectiveness of demonstration-based in-context few-shot learning which works most effectively on large language models, according to Wei et al. (2022a). For example, Zelikman et al. (2022) showed that a 6B model, GPT-J, achieves only $3 . 1 \%$ accuracy on GSM8K with few-shot CoT prompting, while GPT-3 (175 B) achieves $4 6 . 9 \%$ , according to Wei et al. (2022c). Moreover, a recent study (Kadavath et al., 2022) shows that language model calibration increases with model size. This aligns well with our observations that larger models are better at self-improving. Based on these existing studies, we believe that LMSI is more applicable to large-scale language models. In addition, we show that distillation from large models to small models are very promising in Sec. 5.3. Therefore, smaller models can also be improved when large model APIs are accessible. We are fortunate to have enough resources for this work. Though the computation requirements for training large-scale language models are still prohibitively high for most researchers to conduct empirical studies along this line, we believe that our findings are conceptually useful for the NLP community by providing new insights for the properties of large language models.
175
+
176
+ # Acknowledgments
177
+
178
+ We thank anonymous reviewers for valuable and insightful feedback.
179
+
180
+ # References
181
+
182
+ Massih-Reza Amini, Vasilii Feofanov, Loic Pauletto, Emilie Devijver, and Yury Maximov. 2022. Selftraining: A survey.
183
+
184
+ Jimmy Ba and Rich Caruana. 2014. Do deep nets really need to be deep? Advances in neural information processing systems, 27.
185
+
186
+ BIG bench collaboration. 2022. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. ArXiv, abs/2206.04615.
187
+
188
+ 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, T. J. Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeff Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020. Language models are few-shot learners. In Neurips.
189
+
190
+ Oana-Maria Camburu, Tim Rocktäschel, Thomas Lukasiewicz, and Phil Blunsom. 2018. e-snli: Natural language inference with natural language explanations. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems 31, pages 9539–9549. Curran Associates, Inc.
191
+
192
+ Xiaokang Chen, Yuhui Yuan, Gang Zeng, and Jingdong Wang. 2021. Semi-supervised semantic segmentation with cross pseudo supervision. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR).
193
+
194
+ 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 B 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 Díaz, Orhan Firat, Michele Catasta, Jason Wei, Kathleen S. Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. 2022. Palm: Scaling language modeling with pathways. ArXiv, abs/2204.02311.
195
+
196
+ Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph, Yi Tay, William Fedus, Eric Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, Adams Yu, Albert Webson, Xinyun Chen, Gaurav Mishra, Zhuyun Dai, Shixiang Shane Gu, Mirac Suzgun, Vincent Zhao, Aakanksha Chowdhery, Sharan Narang, Yanping Huang, Andrew Dai, Hongkun Yu, Ed H. Chi, Jeff Dean, Jacob Devlin, Adam Roberts, Denny Zhou, Quoc V. Le, and Jason Wei. 2022. Scaling instruction-finetuned language models. In arxiv.
197
+
198
+ Peter Clark, Isaac Cowhey, Oren Etzioni, Tushar Khot, Ashish Sabharwal, Carissa Schoenick, and Oyvind Tafjord. 2018. Think you have solved question answering? try arc, the ai2 reasoning challenge. ArXiv, abs/1803.05457.
199
+
200
+ Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. 2021. Training verifiers to solve math word problems. ArXiv, abs/2110.14168.
201
+
202
+ Ido Dagan, Oren Glickman, and Bernardo Magnini. 2005. The pascal recognising textual entailment challenge. In MLCW.
203
+
204
+ Kumar Shri dhar, Alessandro Stolfo, and Mrinmaya Sachan. 2023. Distilling reasoning capabilities into smaller language models. In ACL.
205
+
206
+ Dheeru Dua, Yizhong Wang, Pradeep Dasigi, Gabriel Stanovsky, Sameer Singh, and Matt Gardner. 2019. Drop: A reading comprehension benchmark requiring discrete reasoning over paragraphs. In NAACL.
207
+
208
+ Jacob Eisenstein, Daniel Andor, Bernd Bohnet, Michael Collins, and David Mimno. 2022. Honest students from untrusted teachers: Learning an interpretable question-answering pipeline from a pretrained language model. arXiv preprint arXiv:2210.02498.
209
+
210
+ 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.
211
+
212
+ Junxian He, Jiatao Gu, Jiajun Shen, and Marc’Aurelio Ranzato. 2020. Revisiting self-training for neural sequence generation. In International Conference on Learning Representations.
213
+
214
+ Geoffrey Hinton, Oriol Vinyals, Jeff Dean, et al. 2015. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2(7).
215
+
216
+ Namgyu Ho, Laura Schmid, and Se-Young Yun. 2023. Large language models are reasoning teachers. ArXiv.
217
+
218
+ Jaehun Jung, Lianhui Qin, Sean Welleck, Faeze Brahman, Chandra Bhagavatula, Ronan Le Bras, and Yejin Choi. 2022. Maieutic prompting: Logically consistent reasoning with recursive explanations.
219
+
220
+ Saurav Kadavath, Tom Conerly, Amanda Askell, T. J. Henighan, Dawn Drain, Ethan Perez, Nicholas Schiefer, Zachary Dodds, Nova DasSarma, Eli TranJohnson, Scott Johnston, Sheer El-Showk, Andy Jones, Nelson Elhage, Tristan Hume, Anna Chen, Yuntao Bai, Sam Bowman, Stanislav Fort, Deep Ganguli, Danny Hernandez, Josh Jacobson, John Kernion, Shauna Kravec, Liane Lovitt, Kamal Ndousse, Catherine Olsson, Sam Ringer, Dario Amodei, Tom B. Brown, Jack Clark, Nicholas Joseph, Benjamin Mann, Sam McCandlish, Christopher Olah, and Jared Kaplan. 2022. Language models (mostly) know what they know. ArXiv, abs/2207.05221.
221
+
222
+ Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. 2022. Large language models are zero-shot reasoners. Neural Information Processing Systems (NeurIPS).
223
+
224
+ Anoop Korattikara Balan, Vivek Rathod, Kevin P Murphy, and Max Welling. 2015. Bayesian dark knowledge. Advances in neural information processing systems, 28.
225
+
226
+ 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?
227
+
228
+ Aitor Lewkowycz, Anders Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay Venkatesh Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, Yuhuai Wu, Behnam Neyshabur, Guy Gur-Ari, and Vedant Misra. 2022. Solving quantitative reasoning problems with language models. ArXiv, abs/2206.14858.
229
+
230
+ Yifei Li, Zeqi Lin, Shizhuo Zhang, Qiang Fu, Bei Chen, Jian-Guang Lou, and Weizhu Chen. 2022a. On the advance of making language models better reasoners.
231
+
232
+ Yifei Li, Zeqi Lin, Shizhuo Zhang, Qiang Fu, Bei Chen, Jian-Guang Lou, and Weizhu Chen. 2022b. On the advance of making language models better reasoners. ArXiv, abs/2206.02336.
233
+
234
+ Hunter Lightman, Vineet Kosaraju, Yura Burda, Harrison Edwards, Bowen Baker, Teddy Lee, Jan Leike, John Schulman, Ilya Sutskever, and Karl Cobbe. 2023. Let’s verify step by step. ArXiv, abs/2305.20050.
235
+
236
+ Lucie Charlotte Magister, Jonathan Mallinson, Jakub Adamek, Eric Malmi, and Aliaksei Severyn. 2022. Teaching small language models to reason. ArXiv, abs/2212.08410.
237
+
238
+ Wang Ling, Dani Yogatama, Chris Dyer, and Phil Blunsom. 2017b. Program induction by rationale generation: Learning to solve and explain algebraic word problems. In ACL.
239
+
240
+ Yu Meng, Jiaxin Huang, Yu Zhang, and Jiawei Han. 2022. Generating training data with language models: Towards zero-shot language understanding. ArXiv, abs/2202.04538.
241
+
242
+ Todor Mihaylov, Peter Clark, Tushar Khot, and Ashish Sabharwal. 2018. Can a suit of armor conduct electricity? a new dataset for open book question answering. In EMNLP.
243
+
244
+ Wang Ling, Dani Yogatama, Chris Dyer, and Phil Blunsom. 2017a. Program induction by rationale generation: Learning to solve and explain algebraic word problems. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).
245
+
246
+ Sharan Narang, Colin Raffel, Katherine Lee, Adam Roberts, Noah Fiedel, and Karishma Malkan. 2020. Wt5?! training text-to-text models to explain their predictions.
247
+
248
+ Yixin Nie, Adina Williams, Emily Dinan, Mohit Bansal, Jason Weston, and Douwe Kiela. 2019. Adversarial nli: A new benchmark for natural language understanding. ArXiv, abs/1910.14599.
249
+
250
+ 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.
251
+
252
+ Arkil Patel, S. Bhattamishra, and Navin Goyal. 2021. Are nlp models really able to solve simple math word problems? In NAACL.
253
+
254
+ Danish Pruthi, Rachit Bansal, Bhuwan Dhingra, Livio Baldini Soares, Michael Collins, Zachary C. Lipton, Graham Neubig, and William W. Cohen. 2022. Evaluating Explanations: How Much Do Explanations from the Teacher Aid Students? Transactions of the Association for Computational Linguistics, 10:359–375.
255
+
256
+ Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. 2016. Squad: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In EMNLP.
257
+
258
+ Aruni RoyChowdhury, Prithvijit Chakrabarty, Ashish Singh, SouYoung Jin, Huaizu Jiang, Liangliang Cao, and Erik G. Learned-Miller. 2019. Automatic adaptation of object detectors to new domains using selftraining. In CVPR, pages 780–790.
259
+
260
+ 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. In ICLR.
261
+
262
+ Timo Schick and Hinrich Schütze. 2020a. Exploiting cloze-questions for few-shot text classification and natural language inference. In Conference of the European Chapter of the Association for Computational Linguistics.
263
+
264
+ Timo Schick and Hinrich Schütze. 2020b. It’s not just size that matters: Small language models are also few-shot learners. ArXiv, abs/2009.07118.
265
+
266
+ Charlie Snell, Dan Klein, and Ruiqi Zhong. 2022. Learning by distilling context. arXiv preprint arXiv:2209.15189.
267
+
268
+ Yi Tay, Mostafa Dehghani, Vinh Quang Tran, Xavier García, Jason Wei, Xuezhi Wang, Hyung Won Chung, Dara Bahri, Tal Schuster, Huaixiu Zheng, Denny Zhou, Neil Houlsby, and Donald Metzler. 2022. Ul2: Unifying language learning paradigms.
269
+
270
+ Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. 2019. Superglue: A stickier benchmark for general-purpose language understanding systems. ArXiv, abs/1905.00537.
271
+
272
+ Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. 2018. Glue: A multi-task benchmark and analysis platform for natural language understanding. In BlackboxNLP@EMNLP.
273
+
274
+ Boshi Wang, Sewon Min, Xiang Deng, Jiaming Shen, You Wu, Luke Zettlemoyer, and Huan Sun. 2022a. Towards understanding chain-of-thought prompting: An empirical study of what matters. In Annual Meeting of the Association for Computational Linguistics.
275
+
276
+ Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. 2022b. Rationaleaugmented ensembles in language models. ArXiv, abs/2207.00747.
277
+
278
+ Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. 2022c. Self-consistency improves chain of thought reasoning in language models. ArXiv, abs/2203.11171.
279
+
280
+ Jason Wei, Maarten Bosma, Vincent Y Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M Dai, and Quoc V Le. 2021. Finetuned language models are zero-shot learners. arXiv preprint arXiv:2109.01652.
281
+
282
+ Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, Ed Huai hsin Chi, Tatsunori Hashimoto, Oriol Vinyals, Percy Liang, Jeff Dean, and William Fedus. 2022a. Emergent abilities of large language models. ArXiv, abs/2206.07682.
283
+
284
+ 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. arXiv preprint arXiv:2206.07682.
285
+
286
+ Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Brian Ichter, Fei Xia, Quoc Le, and Denny Zhou. 2022c. Chain of thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems, 35.
287
+
288
+ Adina Williams, Nikita Nangia, and Samuel R. Bowman. 2018. A broad-coverage challenge corpus for sentence understanding through inference. In NAACL.
289
+
290
+ Zhiheng Xi, Senjie Jin, Yuhao Zhou, Rui Zheng, Songyang Gao, Tao Gui, Qi Zhang, and Xuanjing Huang. 2023. Self-polish: Enhance reasoning in large language models via problem refinement.
291
+
292
+ Qizhe Xie, Minh-Thang Luong, Eduard Hovy, and Quoc V. Le. 2020. Self-training with noisy student improves imagenet classification. In 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 10684–10695.
293
+
294
+ Xi Ye and Greg Durrett. 2022. The unreliability of explanations in few-shot in-context learning.
295
+
296
+ Kang Min Yoo, Dongju Park, Jaewook Kang, SangWoo Lee, and Woomyeong Park. 2021. Gpt3mix: Leveraging large-scale language models for text augmentation. In EMNLP Findings.
297
+
298
+ Omar Zaidan, Jason Eisner, and Christine Piatko. 2007. Using “annotator rationales” to improve machine learning for text categorization. NAACL.
299
+
300
+ Eric Zelikman, Yuhuai Wu, Jesse Mu, and Noah D. Goodman. 2022. Star: Bootstrapping reasoning with reasoning.
301
+
302
+ Zhuosheng Zhang, Aston Zhang, Mu Li, and Alexander J. Smola. 2022. Automatic chain of thought prompting in large language models. ArXiv, abs/2210.03493.
303
+
304
+ Chuanyang Zheng, Zhengying Liu, Enze Xie, Zhenguo Li, and Yu Li. 2023. Progressive-hint prompting improves reasoning in large language models. ArXiv, abs/2304.09797.
305
+
306
+ Denny Zhou, Nathanael Scharli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Olivier Bousquet, Quoc Le, and Ed Chi. 2022. Leastto-most prompting enables complex reasoning in large language models. ArXiv, abs/2205.10625.
307
+
308
+ # A Appendix
309
+
310
+ # A.1 Results on UL2 model
311
+
312
+ We also apply LMSI on a recently proposed public language model, UL2 (Tay et al., 2022), using the pre-trained model at step $2 , 6 5 0 { , } 0 0 0 ^ { 3 }$ . We use a fixed set of hyperparameters for fine-tuning on each dataset. Specifically, we generate $m = 4 0$ reasoning paths for each question in a training set for majority voting. We fine-tune the model for 10k steps with a learning rate of $5 \mathrm { e } - 5$ and a batch size of 32. For multiple path decoding, we use a sampling temperature of $T = 0 . 5$ with the pre-trained UL2 model following Tay et al. (2022), and set $T = 0 . 7$ for the language model after LMSI . We set the maximum number of decode steps to 256 for all experiments.
313
+
314
+ The results are shown in Table 8. For arithmetic reasoning datasets, we follow (Tay et al., 2022) to provide both exact matching accuracy scores as well as accuracy scores after an equation-correction postprocessing step. We observe that for most datasets, LMSI still improves the reasoning accuracy $( + 1 . 6 \%$ on DROP, $+ 1 . 2 \%$ on OpenBookQA, and $+ 0 . 7 \%$ on ANLI-A2), but the improvement on UL2 is not as large as that on 540B. We think the reason is that, since LMSI exploits the implicit rationale of language models, and the capacity of a language model is determined by its size, larger models can capture more high-order semantics and are more likely to benefit from LMSI . For example, on the adversarial entailment tasks of ANLI (which is a three-class classification problem with labels “yes”, “no”, or “it is not possible to tell”), the UL2 model w/o LMSI only achieves an accuracy of marginally above $1 / 3$ , implying that the model is slightly better than doing random guess on this challenging task without any training. Our proposed LMSI can still improve the performance under this hard case by training on its implicit knowledge from self-generated paths.
315
+
316
+ Table 8: Accuracy results on six reasoning benchmarks with LMSI on UL2. On GSM8K and DROP, we also include accuracy scores after an equation-correction postprocessing step.
317
+
318
+ <table><tr><td></td><td>Prompting Method</td><td>GSM8K</td><td>DROP</td><td>ARC-c</td><td>OpenBookQA</td><td>ANLI-A2</td><td>ANLI-A3</td></tr><tr><td rowspan="2"> w/o LMSI</td><td>CoT-Prompting</td><td>5.4/7.1</td><td>11.1/16.8</td><td>49.9</td><td>53.6</td><td>35.9</td><td>33.8</td></tr><tr><td>Self-Consistency</td><td>6.4/9.9</td><td>16.8/26.5</td><td>54.7</td><td>54.0</td><td>37.4</td><td>36.8</td></tr><tr><td rowspan="2">LMSI</td><td> CoT-Prompting</td><td>6.1/8.6</td><td>11.4/17.1</td><td>50.9</td><td>53.8</td><td>35.4</td><td>34.4</td></tr><tr><td>Self-Consistency</td><td>7.9/10.2</td><td>18.1/28.1</td><td>54.9</td><td>55.2</td><td>38.1</td><td>37.4</td></tr></table>
319
+
320
+ # A.2 Chain-of-Thought Prompts for Each Dataset
321
+
322
+ We list the Chain-of-Thought Prompts for each dataset for “CoT-Prompting” experiments and selfgenerated training samples.
323
+
324
+ Table 10: Few-shot CoT prompts for OpenBookQA, from (Wang et al., 2022b).
325
+
326
+ <table><tr><td>Q: There are 15 trees in the grove. Grove workers willplant trees in the grove today. After they are done, there will be 21 trees.How many trees did the grove workers plant today? A: We start with 15 trees.Later we have 21 trees.The difference must be the number of trees they planted. So,they must have planted 21 - 15 = 6 trees. The answer is 6.</td></tr><tr><td>Q: If there are 3 cars in the parking lot and 2 more cars arrive,how many cars are in the parking lot?</td></tr><tr><td>A: There are 3cars in the parking lot already.2 more arrive.Now there are 3 + 2=5cars.The answer is 5.</td></tr><tr><td>Q: Leah had 32 chocolates and her sister had 42.If they ate 35,how many pieces do they have left in total? A: Leah had 32 chocolates and Leah&#x27;s sister had 42. That means there were originally 32 + 42 = 74</td></tr><tr><td>chocolates.35 have been eaten.So in total they stillhave 74 -35=39 chocolates.The answer is 39.</td></tr><tr><td>Q: Jason had 20 lollipops.He gave Denny some lolipops.Now Jason has 12 lollipops.How many lollipops did Jason give to Denny?</td></tr><tr><td>A: Jason had 20 lolipops.Since he only has 12 now, he must have given the rest to Denny. The number of lollipops he has given to Denny must have been 2O - 12 = 8 lollipops.The answer is 8.</td></tr><tr><td>Q: Shawn has five toys.For Christmas,he got two toys each from his mom and dad. How many toys does he have now?</td></tr><tr><td>A: He has 5 toys.He got 2 from mom,so after that he has 5 +2 =7 toys. Then he got 2 more from dad, so in total he has 7 + 2= 9 toys. The answer is 9.</td></tr><tr><td>Q: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?</td></tr><tr><td>A: There are 4 days from monday to thursday.5 computers were added each day. That means in total 4 * 5= 20 computers were added.There were 9 computers in the beginning,so now there are9+ 20= 29 computers. The answer is 29.</td></tr><tr><td>Q: Michael had 58 golf bals.On tuesday, he lost 23 golf balls. On wednesday,he lost 2 more.How many golf balls did he have at the end of wednesday?</td></tr><tr><td>A: Michael initially had 58 balls.He lost 23on Tuesday,so after that he has 58- 23 =35 balls.On Wednesday he lost 2 more so now he has 35 -2= 33 balls. The answer is 33.</td></tr></table>
327
+
328
+ Q: Poison causes harm to which of the following? (a) a Tree (b) a robot (c) a house (d) a car
329
+ A: Poison will harm living things, only a tree is a living thing. The answer is (a).
330
+ Q: As you look deeper into a Marbel you can see (a) the future (b) minut defects (c) colors (d) the other side A: Marbel is not transparent, so you can not see the other side. Marbel does not necessarily have multiple colors. You will see minut defects. The answer is (b).
331
+ Q: When food is reduced in the stomach (a) the mind needs time to digest (b) take a second to digest what I said (c) nutrients are being deconstructed (d) reader’s digest is a body of works
332
+ A: The food is being deconstructed in the stomach during digestion. The answer is (c).
333
+ Q: The sun is responsible for (a) puppies learning new tricks (b) children growing up and getting old (c) flowers wilting in a vase (d) plants sprouting, blooming and wilting
334
+ A: The sun can affect the growing of living things, like plants. The answer is (d).
335
+
336
+ Q: Since the 1970s, U.S. governments have negotiated managed-trade agreements, such as the North American Free Trade Agreement in the 1990s, the Dominican Republic-Central America Free Trade Agreement in 2006, and a number of bilateral agreements. In Europe, six countries formed the European Coal and Steel Community in 1951 which became the European Economic Community in 1958. Two core objectives of the EEC were the development of a common market, subsequently renamed the single market, and establishing a customs union between its member states. How many years did the European Coal and Steel Community exist?
337
+
338
+ A: According to the passage, the European Coal and Steel Community was established in 1951 and became the EEC in 1958. 1958 - $1 9 5 1 = 7$ . So the answer is 7.
339
+
340
+ Q: In the county, the population was spread out with $2 3 . 5 0 \%$ under the age of 18, $8 . 7 0 \%$ from 18 to 24, $2 9 . 7 0 \%$ from 25 to 44, $2 4 . 7 0 \%$ from 45 to 64, and $1 3 . 3 0 \%$ who were 65 years of age or older. How many more percent are under the age of 18 compared to the 18 to 24 group?
341
+
342
+ A: According to the passage, $2 3 . 5 \%$ are under the age of 18, and $8 . 7 \%$ are from ages 18 to $2 4 . 2 3 . 5 \% - 8 . 7 \%$ $= 1 4 . 8 \%$ . So the answer is 14.8.
343
+
344
+ Q: Playing in their second straight Thanksgiving game, the Eagles struggled especially on defense, where they were unable to stop the much-hyped Lions offense. The worst of it all was how unproven rookie Eric Rowe was tasked with covering wide receiver Calvin Johnson, leading to Johnson catching 3 touchdowns. Stafford’s five passing touchdowns, including three of them to Johnson was too much for the Eagles to overcome and for the second consecutive time this season, the Eagles gave up 45 points in a game. With the loss, the Eagles drop to 4-7 on the season and 6-1 when playing on Thanksgiving. How many TD passes did Stafford throw other than to Johnson?
345
+
346
+ A: According to the passage, Stafford threw $5 ~ \mathrm { T D }$ passes, 3 of which were to Johnson. $5 - 3 = 2$ . So the answer is 2.
347
+
348
+ Table 12: Few-shot CoT prompts for DROP (football), from (Zhou et al., 2022).
349
+
350
+ Q: The Seahawks played the San Francisco 49ers. In the first quarter, the Hawks RB Julius Jones got a 27-yard TD run, along with DT Craig Terrill returning a fumble 9 yards for a touchdown. In the third quarter, the 49ers almost rallied as RB H. J. Torres made a 12-yard TD pass to Lucas Nelly, along with Mare kicking a 32-yard field goal. In the final quarter, Julius Jones got another 11-yard TD. How many yards do the shortest touchdown run and the longest touchdown pass combine for?
351
+
352
+ A: All the touchdown runs are: a 27-yard touchdown run, a 9-yard touchdown run, a 11-yard touchdown run. The smallest number among 27, 9, 11 is 9. So the shortest touchdown run was 9 yards. All the touchdown passes are: a 12-yard touchdown pass. So the longest touchdown pass was 12 yards. So the shortest touchdown run and the longest touchdown pass combine for $9 + 1 2 = 2 1$ yards. So the answer is 21 yards.
353
+
354
+ Q: The Steelers went home for a duel with the Baltimore Ravens. Pittsburgh would deliver the opening punch in the first quarter with a 1-yard touchdown from running back Rashard Mendenhall. The Ravens would make it even as running back Willis McGahee got a 9-yard TD. The Ravens kicker Billy Cundiff got a 45-yard field goal in the second quarter, concluding the first half with a 10-7 lead. The Steelers brought the game into overtime with a 38-yard field goal by Andrew Foster. The Ravens Billy Cundiff pulled off a winning 33-yard field goal in overtime. How many points did the Ravens have at halftime?
355
+
356
+ A: The Ravens kicker Billy Cundiff got a 45-yard field goal in the second quarter, concluding the first half with a 10-7 lead. So the Ravens had 10 points at halftime. So the answer is 10 points.
357
+
358
+ Q: The Vikings flew to Bank of America Stadium to face the Carolina Panthers. After a scoreless first quarter, Carolina got on the board with quarterback Matt Moore finding fullback Brad Hoover on a 1-yard TD pass. After yet another scoreless quarter, Carolina sealed the game as Matt Moore completed a 42-yard touchdown pass to wide receiver Steve Smith. How many scoreless quarters were there?
359
+
360
+ A: The first and third quarters were the scoreless quarters. So there are 2 scoreless quarters. So the answer is 2.
361
+
362
+ Premise:
363
+ "Conceptually cream skimming has two basic dimensions - product and geography."
364
+ Based on this premise, can we conclude the hypothesis "Product and geography are what make cream skimming
365
+ work." is true?
366
+ OPTIONS:
367
+ - yes
368
+ - no
369
+ - it is not possible to tell
370
+
371
+ A: Based on "cream skimming has two basic dimensions" we can’t infer that these two dimensions are what make cream skimming work. The answer is it is not possible to tell.
372
+
373
+ "One of our member will carry out your instructions minutely."
374
+
375
+ Based on this premise, can we conclude the hypothesis "A member of my team will execute your orders with immense precision." is true?
376
+
377
+ OPTIONS:
378
+ - yes
379
+ - no
380
+ - it is not possible to tell
381
+
382
+ A: "one of" means the same as "a member of", "carry out" means the same as "execute", and "minutely" means the same as "immense precision". The answer is yes.
383
+
384
+ Premise:
385
+ "Fun for adults and children."
386
+ Based on this premise, can we conclude the hypothesis "Fun for only children." is true?
387
+ OPTIONS:
388
+ - yes
389
+ - no
390
+ - it is not possible to tell
391
+
392
+ A: "adults and children" contradicts "only children". The answer is no.
393
+
394
+ Premise:
395
+ "He turned and smiled at Vrenna."
396
+ Based on this premise, can we conclude the hypothesis "He smiled at Vrenna who was walking slowly behind
397
+ him with her mother." is true?
398
+ OPTIONS:
399
+ - yes
400
+ - no
401
+ - it is not possible to tell
402
+
403
+ A: the premise does not say anything about "Vrenna was walking". The answer is it is not possible to tell.
404
+
405
+ Premise:
406
+ "well you see that on television also"
407
+ Based on this premise, can we conclude the hypothesis "You can see that on television, as well." is true?
408
+ OPTIONS:
409
+ - yes
410
+ - no
411
+ - it is not possible to tell
412
+
413
+ A: "also" and "as well" mean the same thing. The answer is yes.
414
+
415
+ Premise:
416
+ "Vrenna and I both fought him and he nearly took us."
417
+ Based on this premise, can we conclude the hypothesis "Neither Vrenna nor myself have ever fought him." is true?
418
+ OPTIONS:
419
+ - yes
420
+ - no
421
+ - it is not possible to tell
422
+ A: "Vrenna and I both" contradicts "neither Vrenna nor myself". The answer is no. Q: John found that the average of 15 numbers is 40. If 10 is added to each number then the mean of the numbers is? Answer Choices: (a) 50 (b) 45 (c) 65 (d) 78 (e) 64
423
+ A: If 10 is added to each number, then the mean of the numbers also increases by 10. So the new mean would be 50. The answer is (a).
424
+ Q: If a $/ \mathrm { b } = 3 / 4$ and $8 \mathrm { a } + 5 \mathrm { b } = 2 2$ ,then find the value of a. Answer Choices: (a) 1/2 (b) 3/2 (c) $5 / 2$ (d) 4/2 (e) 7/2
425
+ A: If a $/ \mathrm { b } = 3 / 4$ , then $\mathsf { b } = 4 \mathsf { a } \mathrm { ~ / ~ } 3$ . So $8 \mathrm { a } + 5 ( 4 \mathrm { a } / 3 ) = 2 2$ . This simplifies to $8 \mathrm { a } + 2 0 \mathrm { a } / 3 = 2 2$ , which means $4 4 \mathrm { a } / 3 = 2 2$ . So a is equal to $3 / 2$ . The answer is (b).
426
+ Q: A person is traveling at $2 0 \mathrm { k m / h r }$ and reached his destiny in $2 . 5 \mathrm { h r }$ then find the distance? Answer Choices: (a) $5 3 \mathrm { k m }$ (b) $5 5 \mathrm { k m }$ (c) $5 2 \mathrm { k m }$ (d) $6 0 \mathrm { k m }$ (e) $5 0 \mathrm { k m }$
427
+ A: The distance that the person traveled would have been $2 0 \mathrm { k m } / \mathrm { h r } * 2 . 5 \mathrm { h r s } = 5 0 \mathrm { k m }$ . The answer is (e). Q: How many keystrokes are needed to type the numbers from 1 to 500? Answer Choices: (a) 1156 (b) 1392 (c) 1480 (d) 1562 (e) 1788
428
+ A: There are 9 one-digit numbers from 1 to 9. There are 90 two-digit numbers from 10 to 99. There are 401 three-digit numbers from 100 to $5 0 0 . ~ 9 + 9 0 ( 2 ) + 4 0 1 ( 3 ) = 1 3 9 2$ . The answer is (b).
429
+
430
+ Table 16: Few-shot CoT prompts for StrategyQA, from (Wei et al., 2022c).
431
+
432
+ <table><tr><td>Q: Do hamsters provide food for any animals? A: Hamsters are prey animals.Prey are food for predators.Thus,hamsters provide food for some animals.</td></tr><tr><td>The answer is yes.</td></tr><tr><td>Q: Could Brooke Shields succeed at University of Pennsylvania? A: Brooke Shields went to Princeton University. Princeton University is about as academically rigorous as</td></tr><tr><td>the University of Pennsylvania. Thus,Brooke Shields could also succeed at the University of Pennsylvania. The answer is yes.</td></tr><tr><td>Q: Yes or no: Hydrogen&#x27;s atomic number squared exceeds number of Spice Girls?</td></tr><tr><td>A: Hydrogen has an atomic number of 1.1 squared is 1. There are 5 Spice Girls. Thus,Hydrogen&#x27;s atomic number squared is less than 5.The answer is no.</td></tr><tr><td>Q: Yes or no: Is it common to see frost during some college commencements?</td></tr><tr><td>A: College commencement ceremonies can happen in December,May,and June.December is in the winter,</td></tr><tr><td>so there can be frost. Thus,there could be frost at some commencements.The answer is yes.</td></tr><tr><td>Q: Yes or no: Could a llama birth twice during War in Vietnam (1945-46)?</td></tr><tr><td>A: The War in Vietnam was 6 months.The gestation period for alama is 11 months, which is more than 6 months.Thus,a llama could not give birth twice during the War in Vietnam. The answer is no.</td></tr><tr><td>Q: Yes or no: Would a pear sink in water?</td></tr><tr><td>A: The density of a pear is about O.6 g/cm,which is less than water. Objects less dense than water float.</td></tr></table>
433
+
434
+ Table 17: Few-shot CoT prompts for RTE, from (Wang et al., 2022b).
435
+
436
+ "No Weapons of Mass Destruction Found in Iraq Yet." Based on this premise, can we conclude the hypothesis "Weapons of Mass Destruction Found in Iraq." is true?
437
+
438
+ A: "No Weapons of Mass Destruction Found" contradicts "Weapons of Mass Destruction Found". The answer is no.
439
+
440
+ Premise:
441
+
442
+ "A place of sorrow, after Pope John Paul II died, became a place of celebration, as Roman Catholic faithful gathered in downtown Chicago to mark the installation of new Pope Benedict XVI."
443
+
444
+ Based on this premise, can we conclude the hypothesis "Pope Benedict XVI is the new leader of the Roman Catholic Church." is true?’
445
+
446
+ A: "installation of new Pope Benedict XVI." means "Pope Benedict XVI is the new leader". The answer is yes.
447
+
448
+ Premise:
449
+
450
+ "A man is due in court later charged with the murder 26 years ago of a teenager whose case was the first to be featured on BBC One’s Crimewatch. Colette Aram, 16, was walking to her boyfriend’s house in Keyworth, Nottinghamshire, on 30 October 1983 when she disappeared. Her body was later found in a field close to her home. Paul Stewart Hutchinson, 50, has been charged with murder and is due before Nottingham magistrates later."
451
+
452
+ Based on this premise, can we conclude the hypothesis "Paul Stewart Hutchinson is accused of having stabbed a girl." is true?
453
+
454
+ A: The premise does not say Paul Stewart Hutchinson "stabbed" this girl. The answer is no.
455
+
456
+ Premise:
457
+
458
+ "Herceptin was already approved to treat the sickest breast cancer patients, and the company said, Monday, it will discuss with federal regulators the possibility of prescribing the drug for more breast cancer patients." Based on this premise, can we conclude the hypothesis "Herceptin can be used to treat breast cancer." is true?
459
+
460
+ A: "Herceptin was approved to treat breast cancer" implies that "Herceptin can be used to treat breast cancer".
461
+ The answer is yes.
md/dev/uxxFrDwrE7Y/uxxFrDwrE7Y.md ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LEARNING FAST, LEARNING SLOW: A GENERALCONTINUAL LEARNING METHOD BASED ON COMPLE-MENTARY LEARNING SYSTEM
2
+
3
+ Elahe Arani∗, Fahad Sarfraz\* & Bahram Zonooz
4
+ Advanced Research Lab, NavInfo Europe, Eindhoven, Netherlands
5
+ {elahe.arani, fahad.sarfraz}@navinfo.eu, bahram.zonooz@gmail.com
6
+
7
+ # ABSTRACT
8
+
9
+ Humans excel at continually learning from an ever-changing environment whereas it remains a challenge for deep neural networks which exhibit catastrophic forgetting. The complementary learning system (CLS) theory suggests that the interplay between rapid instance-based learning and slow structured learning in the brain is crucial for accumulating and retaining knowledge. Here, we propose CLS-ER, a novel dual memory experience replay (ER) method which maintains short-term and long-term semantic memories that interact with the episodic memory. Our method employs an effective replay mechanism whereby new knowledge is acquired while aligning the decision boundaries with the semantic memories. CLSER does not utilize the task boundaries or make any assumption about the distribution of the data which makes it versatile and suited for “general continual learning”. Our approach achieves state-of-the-art performance on standard benchmarks as well as more realistic general continual learning settings.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Continual learning (CL) refers to the ability of a learning agent to continuously interact with a dynamic environment and process a stream of information to acquire new knowledge while consolidating and retaining previously obtained knowledge (Parisi et al., 2019). This ability to continuously learn from a changing environment is a hallmark of intelligence and a critical missing component in our quest towards making our models truly intelligent. The major challenge towards enabling CL in deep neural networks (DNNs) is that the continual acquisition of incrementally available information from non-stationary data distributions leads to catastrophic forgetting whereby the performance of the model on previously learned tasks drops drastically (McCloskey & Cohen, 1989).
14
+
15
+ Several approaches have been proposed to address the issue of catastrophic forgetting in CL. These can be broadly categorized into regularization-based methods (Farajtabar et al., 2020; Kirkpatrick et al., 2017; Ritter et al., 2018; Zenke et al., 2017) which penalizes changes in the network weights, network expansion-based methods (Rusu et al., 2016; Yoon et al., 2017) which dedicate a distinct set of network parameters to distinct tasks, and rehearsal-based methods (Chaudhry et al., 2018; Lopez-Paz & Ranzato, 2017) which maintains a memory buffer and replays samples from previous tasks. Amongst these, rehearsal-based methods have proven to be more effective in challenging CL tasks (Farquhar & Gal, 2018). However, an optimal approach for replaying memory samples and constraining the model update to efficiently consolidate knowledge remains an open question.
16
+
17
+ In the brain, the ability to continually acquire, consolidate, and transfer knowledge over time is mediated by a rich set of neurophysiological processing principles (Parisi et al., 2019; Zenke et al., 2017) and multiple memory systems (Hassabis et al., 2017). In particular, the CLS theory (Kumaran et al., 2016) posits that efficient learning requires two complementary learning systems: the hippocampus exhibits short-term adaptation and rapid learning of episodic information which is then gradually consolidated to the neocortex for slow learning of structured information. Furthermore, a recent study by Hayes et al. (2021) identified the missing elements of biological reply in the replay mechanisms employed in DNNs for CL. They highlight that many existing approaches only focus on modeling the prefrontal cortex directly and do not have a fast learning network which plays a critical role in enabling efficient CL in the brain. Inspired by these studies, we hypothesize that mimicking the slow and rapid adaptation of information and having an efficient mechanism for incorporating them into the working memory can enable better CL in DNNs.
18
+
19
+ ![](images/a1cd21a22120eb2df3d8568fdf5222a5696c226232417616c6d15bea5f76ba11.jpg)
20
+ Figure 1: CLS-ER employs a dual-memory learning mechanism whereby the episodic memory stores the samples and the semantic memories build short-term and long-term memories of the learned representations of the working model. The two memories interact to enforce a consistency loss on the working model which prevents rapid changes in the parameter space and enables the alignment of the decision boundary with semantic memories for effective knowledge consolidation.
21
+
22
+ To this end, we propose a novel dual memory experience replay method based on the complementary learning systems theory in the brain, dubbed as CLS-ER. In addition to a small episodic memory, our method builds long-term and short-term semantic memories which mimic the rapid and slow adaptation of information (Figure 1). As the network weights encode the learned representations of the tasks (Krishnan et al., 2019), the semantic memories are maintained by taking the exponential moving average of the working model’s weights to consolidate information across the tasks with varying time windows and frequencies. The semantic memories interact with the episodic memory to extract consolidated replay activation patterns and enforce a consistency loss on the update of the working model so that new knowledge is acquired while aligning the decision boundary of the working model with the decision boundaries of semantic memories. This maintains a balance between the plasticity and stability of the model for effective knowledge consolidation.
23
+
24
+ CLS-ER provides a general CL method that does not utilize the task boundaries or make any strong assumption regarding the distribution of the data and tasks. We demonstrate the versatility and effectiveness of our method on a wide range of CL benchmark tasks as well as more challenging scenarios which simulate the complexities of CL in the real world.
25
+
26
+ # 2 RELATED WORK
27
+
28
+ The base method for the rehearsal-based approach, Experience Replay (ER) (Riemer et al., 2018) combines the memory samples with the task samples into the training batch. Several techniques have since been employed on top of ER. Meta Experience Replay (MER) (Riemer et al., 2018) considers replay as a meta-learning problem for maximizing the transfer from previous tasks and minimizing the interference. iCARL (Rebuffi et al., 2017) uses the nearest average representation of past exemplars to classify in an incrementally learned representation space. Gradient Episodic Memory (GEM) (Lopez-Paz & Ranzato, 2017) formulates optimization constraints on the exemplars in memory. Gradient-based Sample Selection (GSS) (Aljundi et al., 2019) aims for memory sample diversity in the gradient space and provides a greedy selection approach. Function Distance Regularization (FDR) (Benjamin et al., 2018) saves the network response at the task boundaries and adds a consistency loss on top of ER. Dark Experience Replay $( \mathrm { D E R + + } )$ applies knowledge distillation (Sarfraz et al., 2021) and regularization on logits sampled during the optimization trajectory.
29
+
30
+ CLS has been used as a source of inspiration for dual memory learning systems in earlier works (French, 1999; Robins, 1993) but they have not been shown to scale to current computer vision tasks (Parisi et al., 2019). Recently, Rostami et al. (2019) utilizes a generative model to couple sequential tasks in a latent embedding space. Kamra et al. (2017) utilizes two generative models in a dual memory architecture. However, they utilize the task boundaries and generative replay has its own set of challenges as it is difficult to learn a faithful distribution and performs sub-par in comparison to instance-based replay methods on challenging CL settings. Generally, the inspiration from CLS theory in DNNs has been mostly limited to episodic memory and mimicking the rapid and slow learning mechanism is majorly ignored (Hayes et al., 2021) which we aim to address.
31
+
32
+ ![](images/24d7b7e6363b7a87d007247acd7ee41d41808ddef322b80d020f7b5aacc3ca20.jpg)
33
+ Figure 2: Task-wise performance on S-CIFAR-10 test set with 500 buffer size. The models are evaluated at the end of each task (y-axis) to evaluate how the task performances $\mathbf { \bar { X } }$ -axis) are affected as training progress. The stable model retains information from earlier tasks while the plastic model quickly adapts to the recent task. Note that there is less forgetting in the semantic memories compared to the working model. For other buffer sizes and S-TinyImageNet see Figures S1 and S2.
34
+
35
+ # 3 METHOD
36
+
37
+ We first provide an overview of the CLS theory for the brain and how we aim to mimic it for DNNs before introducing the main components of our method and the overall formulation.
38
+
39
+ # 3.1 COMPLEMENTARY LEARNING SYSTEM THEORY
40
+
41
+ The CLS theory posits that effective lifelong learning in the brain requires two complementary learning systems. The hippocampus rapidly encodes novel information as a short-term memory which is subsequently used to transfer and consolidate knowledge in the neocortex which gradually acquires structured knowledge representation as long-term memory through experience replay. The interplay between the functionality of the hippocampus and neocortex is crucial for concurrently learning efficient representations (for better generalization) and the specifics of instance-based episodic memory.
42
+
43
+ # 3.2 COMPLEMENTARY LEARNING SYSTEM BASED EXPERIENCED REPLAY
44
+
45
+ Inspired by the CLS theory, we propose a dual memory experience replay method, CLS-ER, which aims to mimic the interplay between fast learning and slow learning mechanisms for enabling effective CL in DNNs. Our method maintains short-term and long-term semantic memories of the encountered tasks which interact with the episodic memory for replaying the associated neural activities. The working model is updated so that it acquires new knowledge while aligning its decision boundary with the semantic memories to enable the consolidation of structured knowledge across the tasks. Figure 1 highlights the parallels between CLS theory and our method.
46
+
47
+ Semantic Memories: Central to our method is the maintenance of two semantic memories which accumulate and consolidate information over long-term and short-term periods. As the acquired knowledge of the learned tasks is encoded in the weights of DNNs (Krishnan et al., 2019), we aim to form our semantic memories by accumulating the knowledge encoded in the corresponding weights of the model as it sequentially learns different tasks.
48
+
49
+ An efficient method for aggregating the weights of a model is provided by Mean Teacher (Tarvainen & Valpola, 2017) which is a knowledge distillation approach that uses an exponential moving average (EMA) of the student’s weights during training as a teacher for semi-supervised learning. It can also be considered as forming a self-ensemble of the intermediate model states that leads to better internal representations. We adapt the Mean Teacher approach to build our semantic memories as it provides a computational and memory-efficient method for accumulating knowledge over the tasks.
50
+
51
+ As CL involves learning tasks sequentially, the model weights at each training step can be considered as a student model specialized for a particular task. Therefore, averaging the weights during training can be considered as forming an ensemble of task-specific student models which effectively aggregates information across the tasks and leads to smoother decision boundaries. CLS-ER builds long-term (stable model) and short-term (plastic model) semantic memories by maintaining two EMA-weighted models over the working model’s weights. The stable model is updated less frequently with a larger window size so that it retains more information from the earlier tasks while the plastic model is updated more frequently with a smaller window size so that it adapts faster to information from new tasks (Figure 2). Section D further demonstrates the benefits of employing two semantic memories instead of a single semantic memory.
52
+
53
+ Episodic Memory: Replay of samples from the previous tasks stored in a small episodic memory is a common approach in CL that has proven to be effective in mitigating catastrophic forgetting. As we aim to position CLS-ER as a versatile general incremental learning method, we do not utilize the task boundaries or make any strong assumptions about the distribution of the tasks or samples. Therefore, to maintain a fixed episodic memory buffer, we employ Reservoir sampling (Vitter, 1985) which assigns equal probability to each sample in the stream for being represented in the buffer and randomly replaces the existing memory samples (Algorithm 2). It is a global distribution matching strategy that ensures that at any given time the distribution of samples in the buffer will approximately match the distribution of all the samples seen so far (Isele & Cosgun, 2018).
54
+
55
+ Consolidation of Information: The key challenge in CL is the consolidation of new information with the previously acquired information. This requires an effective balance between the stability and plasticity of the model. Furthermore, the sharp change in decision boundary as a new task is learned makes the consolidation of information over tasks more challenging. CLS-ER tackles these challenges through a novel dual memory experience replay mechanism. The long-term and shortterm semantic memories interact with the episodic memory to extract the consolidated activations for the memory samples which are then utilized to constrain the update of the working model so that new knowledge is obtained whilst the decision boundary is aligned with the semantic memories. This prevents rapid changes in the parameter space as new tasks are learned. Furthermore, aligning the working model’s decision boundary with the semantic memories serves two goals: (i) helps in retaining and consolidating information and (ii) leads to a smoother adaptation of decision boundary.
56
+
57
+ # 3.3 FORMULATION
58
+
59
+ CLS-ER involves training a working model $f ( . ; \theta _ { w } )$ on a data stream $\mathcal { D }$ sampled from a non-iid distribution. Two additional EMA-weighted models are maintained as semantic memories: plastic model $f ( . ; \theta _ { P } )$ and the stable model $f ( . ; \theta _ { S } )$ . Finally, Reservoir sampling (Vitter, 1985) is employed to maintain a small episodic memory $\mathcal { M }$ .
60
+
61
+ At each training step, the working model receives the training batch $X _ { b }$ from the data stream and retrieves a random batch of exemplars $X _ { m }$ from the episodic memory. This is then followed by the retrieval of optimal semantic information, i.e. the structural knowledge encoded in the semantic memories which account for the consolidation of feature space and adaptation of the decision boundaries of the previous tasks. The semantic memories are designed so that the plastic model has higher performance on recent tasks whereas the stable model prioritizes retaining information on the older tasks. Therefore, we would prefer to use the logits from the stable model $Z _ { S }$ for older exemplars and the plastic model $Z _ { P }$ for recent exemplars. As CLS-ER is a general incremental learning method, instead of using a hard threshold or task information, we opt for a simple task-agnostic approach of using the performance of the semantic memories on the exemplars as a selection criterion that empirically works well. For each exemplar, we select the replay logits $Z$ based on which model has the highest softmax score for the ground-truth class (lines 5-6 in Algorithm 1).
62
+
63
+ The selected replay logits from the semantic memories are then used to enforce a consistency loss on the working model so that it does not deviate from the already learned experiences. Hence, the working model is updated with a combination of the cross-entropy loss on the union of the data stream and episodic memory samples, $X$ , and the consistency loss on the exemplars $X _ { m }$ ,
64
+
65
+ $$
66
+ \mathcal { L } = \mathcal { L } _ { C E } ( \sigma ( f ( X ; \theta _ { W } ) ) , Y ) + \lambda \mathcal { L } _ { M S E } ( f ( X _ { m } ; \theta _ { W } ) , Z )
67
+ $$
68
+
69
+ Input: Data stream $\mathcal { D }$ , Learning rate $\eta$ , Consistency weight $\lambda$ , Update rates $r _ { P }$ and $r _ { S }$ , Decay parameters $\alpha _ { P }$ and $\alpha _ { S }$ Initialize: ${ \theta } _ { W } = { \theta } _ { P } = { \theta } _ { S }$ $\mathcal { M } \{ \}$
70
+ 1: while Training do
71
+ 2: $( X _ { b } , Y _ { b } ) \sim \mathcal { D }$ and $( X _ { m } , Y _ { m } ) \sim { \mathcal { M } }$
72
+ 3: $( X , Y ) = \{ ( X _ { b } , Y _ { b } ) , ( X _ { m } , Y _ { m } ) \}$
73
+ 4: $Z _ { P } , Z _ { S } \gets f ( X _ { m } ; \theta _ { P } ) , f ( X _ { m } ; \theta _ { S } )$ . Select optimal semantic memory
74
+ 5: $Z Z _ { P }$ if $\sigma ( Z _ { P } ) ^ { ( Y _ { m } ) } > \sigma ( Z _ { S } ) ^ { ( Y _ { m } ) }$ else $Z _ { S }$
75
+ 6: $\mathcal { L } = \mathcal { L } _ { C E } ( \sigma ( f ( X ; \theta _ { W } ) ) , Y ) + \lambda \mathcal { L } _ { M S E } ( f ( X _ { m } ; \theta _ { W } ) , Z )$ . Update working model
76
+ 7: $\theta _ { W } \theta _ { W } - \eta \nabla _ { \theta _ { W } } \mathcal { L }$
77
+ 8: $a , b \sim \mathcal { U } ( 0 , 1 )$ . Update semantic memories
78
+ 9: $\theta _ { P } \alpha _ { p } \theta _ { P } + ( 1 - \alpha _ { P } ) \theta _ { W }$ if $a < r _ { P }$ else $\theta _ { P }$
79
+ 10: $\theta _ { S } \alpha _ { S } \theta _ { S } + ( 1 - \alpha _ { S } ) \theta _ { W }$ if $b < r _ { S }$ else $\theta _ { S }$
80
+ 11: $\mathcal { M } R e s e r v o i r ( \mathcal { M } , ( X _ { b } , Y _ { b } ) )$ $\triangleright$ Update episodic memory (Algorithm 2) return θW , θP , θS
81
+
82
+ where $\sigma$ is the softmax function, $\lambda$ the regularization parameter, and $\mathcal { L } _ { M S E }$ the mean squared error loss used as consistency term.
83
+
84
+ After updating the working model, we stochastically update the plastic and stable models with rates $r _ { P }$ and $r _ { S }$ (note that $r _ { P } > r _ { S }$ so that the plastic model is updated more frequently). A stochastic rather than a deterministic approach is more biologically plausible (Maass, 2014; Arani et al., 2021) which reduces the overlap in the snapshots of the working model and leads to more diversity in semantic memories. The semantic memories are updated by taking an exponential moving average of the working model’s weights (Tarvainen & Valpola, 2017) with decay parameters $\alpha _ { P }$ and $\alpha _ { S }$ ,
85
+
86
+ $$
87
+ \theta _ { i } = \alpha _ { i } \theta _ { i } + ( 1 - \alpha _ { i } ) \theta _ { W } , \quad i \in \{ P , S \}
88
+ $$
89
+
90
+ Note that $\alpha _ { P } \leq \alpha _ { S }$ so that the plastic model mimics the rapid adaptation of information while the stable model mimics slow acquisition of structured knowledge. See Algorithm 1 for more details.
91
+
92
+ For inference, we use the stable model as it retains long-term memory across the tasks, consolidates structural knowledge, and learns efficient representations for generalization (Figure 1).
93
+
94
+ # 4 EXPERIMENTAL SETUP
95
+
96
+ To ensure a fair comparison of different CL methods under uniform experimental settings, we extended the Mammoth framework (Buzzega et al., 2020a) and unless stated otherwise, we follow the same training scheme (learning rate, batch sizes of incoming data and memory buffer, and the number of training epochs) as them for each of the evaluation settings. To find the optimal hyperparameters for CLS-ER, we run a grid search over $\lambda$ , $\alpha _ { S }$ , $\alpha _ { P }$ , $r _ { S }$ , and $r _ { P }$ on a small validation set. Sections C.4 and E show that our method is not highly sensitive to the particular choice of hyperparameters and different settings can attain similar performance. Also, because of the complementary nature of the components, we can often fix a set of parameters (e.g. $\lambda$ , $\alpha _ { S }$ , $\alpha _ { P }$ and $r _ { S }$ ) and only finetune the remaining parameters (e.g. $r _ { P }$ ) which facilitates hyperparameter tuning significantly.
97
+
98
+ Following Buzzega et al. (2020a), we employ a fully connected network with two hidden layers, each with 100 ReLU units on all the variants of the MNIST dataset and ResNet-18 (He et al., 2015) without pretraining for the other datasets. In all the settings, we use the SGD optimizer. We use random horizontal flip and random crop on both the stream and buffer samples for S-CIFAR-10, S-Tiny-ImageNet, and GCIL-CIFAR-100. The selected hyperparameters for each of the settings are provided in Table S4. Note that for the vast majority of datasets, we use uniform settings (lr, epochs, batch size, memory batch size, and lambda) across different buffer sizes and only slight modifications in the other hyperparameters which shows that our method does not require extensive finetuning for different memory budgets. For each of our experiments, we fix the order of the classes and report the average and one standard deviation of the mean test accuracy of all the tasks across 10 runs with different initializations. Section E provides further training and implementation details.
99
+
100
+ <table><tr><td rowspan="2">Buffer</td><td rowspan="2">Method</td><td colspan="3">Class-IL</td><td colspan="2">Domain-IL</td></tr><tr><td>S-MNIST</td><td>S-CIFAR-10</td><td>S-Tiny-ImageNet</td><td>R-MNIST</td><td>P-MNIST</td></tr><tr><td rowspan="2"></td><td>JOINT</td><td>95.57±0.24</td><td>92.20±0.15</td><td>59.99±0.19</td><td>95.76±0.04</td><td>94.33±0.17</td></tr><tr><td>SGD</td><td>19.60±0.04</td><td>19.62±0.05</td><td>7.92±0.26</td><td>67.66±8.53</td><td>40.70±2.33</td></tr><tr><td rowspan="7">200</td><td>ER</td><td>80.43±1.89</td><td>44.79±1.86</td><td>8.49±0.16</td><td>85.01±1.90</td><td>72.37±0.87</td></tr><tr><td>GEM</td><td>80.11±1.54</td><td>25.54±0.76</td><td>1</td><td>80.80±1.15</td><td>66.93±1.25</td></tr><tr><td>iCaRL</td><td>70.51±0.53</td><td>49.02±3.20</td><td>7.53±0.79</td><td>=</td><td>=</td></tr><tr><td>FDR</td><td>79.43±3.26</td><td>30.91±2.74</td><td>8.70±0.19</td><td>85.22±3.35</td><td>74.77±0.83</td></tr><tr><td>GSS</td><td>38.92±2.49</td><td>39.07±5.59</td><td>=</td><td>79.50±0.41</td><td>63.72±0.70</td></tr><tr><td>DER++</td><td>85.61±1.40</td><td>64.88±1.17</td><td>10.96±1.17</td><td>90.43±1.87</td><td>83.58±0.59</td></tr><tr><td>CLS-ER</td><td>89.54±0.21</td><td>66.19±0.75</td><td>23.47±0.80</td><td>92.26±0.18</td><td>84.63±0.40</td></tr><tr><td rowspan="8">500</td><td>ER</td><td>86.12±1.89</td><td>57.74±0.27</td><td>9.99±0.29</td><td>88.91±1.44</td><td>80.60±0.86</td></tr><tr><td>GEM</td><td>85.99±1.35</td><td>26.20±1.26</td><td>1</td><td>81.15±1.98</td><td>76.88±0.52</td></tr><tr><td>iCaRL</td><td>70.10±1.08</td><td>47.55±3.95</td><td>9.38±1.53</td><td>1</td><td>=</td></tr><tr><td>FDR</td><td>85.87±4.04</td><td>28.71±3.23</td><td>10.54±0.21</td><td>89.67±1.63</td><td>83.18±0.53</td></tr><tr><td>GSS</td><td>49.76±4.73</td><td>49.73±4.78</td><td>=</td><td>81.58±0.58</td><td>76.00±0.87</td></tr><tr><td>DER++</td><td>91.00±1.49</td><td>72.70±1.36</td><td>19.38±1.41</td><td>92.77±1.05</td><td>88.21±0.39</td></tr><tr><td>CLS-ER</td><td>92.05±0.32</td><td>75.22±0.71</td><td>31.03±0.56</td><td>94.06±0.07</td><td>88.30±0.14</td></tr><tr><td>ER</td><td>93.40±1.29</td><td>82.47±0.52</td><td>27.40±0.31</td><td>93.45±0.56</td><td>89.90±0.13</td></tr><tr><td rowspan="7">5120</td><td>GEM</td><td>95.11±0.87</td><td>25.26±3.46</td><td>1</td><td>88.57±0.40</td><td>87.42±0.95</td></tr><tr><td>iCaRL</td><td>70.60±1.03</td><td>55.07±1.55</td><td>14.08±1.92</td><td></td><td></td></tr><tr><td>FDR</td><td>87.47±3.15</td><td>19.70±0.07</td><td>28.97±0.41</td><td>94.19±0.44</td><td>90.87±0.16</td></tr><tr><td>GSS</td><td>89.39±0.75</td><td>67.27 ±4.27</td><td>=</td><td>85.24±0.59</td><td>82.22±1.14</td></tr><tr><td>DER++</td><td>95.30±1.20</td><td>85.24±0.49</td><td>39.02±0.97</td><td>94.65±0.33</td><td>92.26±0.17</td></tr><tr><td>CLS-ER</td><td>95.73±0.11</td><td>86.78±0.17</td><td>46.74±0.31</td><td>94.25±0.06</td><td>92.03±0.05</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
101
+
102
+ Table 1: Comparison with prior works on Class-IL and Domain-IL settings. The baseline results are from Buzzega et al. (2020a) (- indicates the experiments that the authors were unable to run).
103
+
104
+ # 5 EMPIRICAL EVALUATION
105
+
106
+ There are a plethora of evaluation protocols in the CL literature, each of which biases the evaluation towards a certain approach (Farquhar & Gal, 2018; Mi et al., 2020; van de Ven & Tolias, 2019). It is therefore of utmost importance to conduct an extensive and robust evaluation over different CL settings to gauge the versatility of the method. Details of the datasets used in each CL setting are provided in Section A. We compare our method with the state-of-the-art rehearsal-based approaches on various CL settings and memory budgets under uniform experimental settings. SGD refers to standard training and JOINT provides an upper bound given by training all tasks jointly.
107
+
108
+ Class Incremental Learning (Class-IL): refers to the CL scenario where new classes are added with each subsequent task and the agent must learn to distinguish not only amongst the classes within the current task but also across previous tasks. Class-IL measures how well the method can learn general representations, accumulate, consolidate, and transfer the acquired knowledge to learn efficient representations and decision boundaries for all the classes seen so far.
109
+
110
+ Table 1 provides the comparison with six rehearsal-based approaches on Class-IL settings with varying datasets and task length complexities. CLS-ER provides the highest performance in all of these scenarios. In particular, as the dataset complexity and number of tasks increase from S-MNIST to S-Tiny-ImageNet, the performance gap between CLS-ER and $\mathrm { D E R + + }$ increases considerably. Especially, with a smaller memory budget, CLS-ER is able to retain more information than other methods. In the most challenging setting, S-Tiny-ImageNet with 200 buffer size, CLS-ER provides a percentage gain of $1 7 6 \%$ and $1 1 4 \%$ over the baseline ER and the current state-of-the-art $\mathrm { D E R + + }$ , respectively. The results demonstrate the capability of CLS-ER to efficiently accumulate and retain knowledge over longer sequences under complex and memory restrictive scenarios.
111
+
112
+ We believe that the performance gains over $\mathrm { D E R + + }$ highlight a key component of an efficient CL agent: the ability to consolidate previously acquired knowledge. $\mathrm { D E R + + }$ fails to account for the consolidation of feature space and adaptation of the decision boundaries of the previous tasks. Therefore, constraining the model to match the sub-optimal logits might hamper the consolidation of knowledge. This becomes more prominent as the number of classes in each task, the sequence length, and the cross-task resemblance increase. For instance, for $\mathrm { D E R + + }$ , replaying a sample from Task-1 when training on S-Tiny-ImageNet Task-10, the reference logit values which are used to enforce the consistency are from a model representation state which has not considered how to distinguish the 20 classes in Task-1 from 80 additional classes which are visually and semantically similar. It stands to reason that the optimal representation space and subsequently the decision boundaries for the classes in Task-1 would drift considerably when required to distinguish between 80 additional classes as well. Therefore, the local information provided by the sub-optimal saved logits in $\mathrm { D E R + + }$ fails to provide the global context required for consolidating knowledge. CLS-ER, on the other hand, extracts logits from the semantic memories which consolidate knowledge across the tasks, and hence the working model receives more optimal feedback.
113
+
114
+ Table 2: Comparison with prior works on MNIST-360 test set. The baseline results are from Buzzega et al. (2020a).
115
+
116
+ <table><tr><td>JOINT</td><td>SGD</td><td>Buffer</td><td>ER</td><td>MER</td><td>GSS</td><td>DER++</td><td>CLS-ER</td></tr><tr><td rowspan="3">82.98±3.24</td><td rowspan="3">19.09±0.69</td><td>200</td><td>49.27±2.25</td><td>48.58±1.07</td><td>43.92±2.43</td><td>54.16±3.02</td><td>66.37±0.83</td></tr><tr><td>500</td><td>65.04±1.53</td><td>62.21±1.36</td><td>54.45±3.14</td><td>69.62±1.59</td><td>75.70±0.41</td></tr><tr><td>1000</td><td>75.18±1.50</td><td>70.91±0.76</td><td>63.84±2.09</td><td>76.03±1.61</td><td>79.54±0.34</td></tr></table>
117
+
118
+ Table 3: Comparison with prior works on GCIL-CIFAR-100 dataset.
119
+
120
+ <table><tr><td>Distribution</td><td colspan="3">Uniform</td><td colspan="3">Longtail</td></tr><tr><td>JOINT</td><td colspan="3">58.36±1.02</td><td colspan="3">56.94±1.56</td></tr><tr><td>SGD</td><td></td><td>12.67±0.24</td><td></td><td></td><td>22.88±0.53</td><td>1000</td></tr><tr><td>Buffer ER</td><td>200 16.40±0.37</td><td>500</td><td>1000 31.98±0.72</td><td>200 19.27±0.77</td><td>500 20.30±0.63</td><td>34.13±0.83</td></tr><tr><td>DER++</td><td>18.84±0.60</td><td>28.21±0.69 32.92±0.74</td><td>38.95±0.56</td><td>26.94±1.27</td><td>25.82±0.83</td><td>33.64±0.88</td></tr><tr><td></td><td></td><td></td><td></td><td>28.54±0.87</td><td>28.63±0.68</td><td>39.52±0.91</td></tr><tr><td>CLS-ER</td><td>25.06±0.81</td><td>36.34±0.59</td><td>39.69±0.66</td><td></td><td></td><td></td></tr></table>
121
+
122
+ Domain Incremental Learning (Domain-IL): refers to the CL scenario where the classes remain the same in subsequent tasks but the input distribution changes. We consider R-MNIST where each task contains digits rotated by a fixed angle and P-MNIST which applies a fixed random permutation to the pixels for each task. Table 1 shows that CLS-ER provides generalization gains under both settings, particularly for lower memory budget, and performs on par with $\mathrm { D E R + + }$ on 5120 buffer size. We attribute this to the consolidated soft targets from the semantic memories which provide relational information about the classes from a global context compared to the local information in $\mathrm { D E R + + }$ . This enables our method to maintain the similarity structure across sequences effectively.
123
+
124
+ General Incremental Learning (GIL): Class-IL and Domain-IL fail to assimilate the challenges in the real-world setting where the task boundaries are blurry, and classes can reappear and have different distributions. The CL method has to consider the sample efficiency, challenge of imbalanced data, and efficient knowledge transfer in addition to preventing catastrophic forgetting. We consider two GIL settings: MNIST-360 (Buzzega et al., 2020a) exposes the model to both sharp (changes in class) and smooth (rotation of digits) distribution shifts. This requires the CL method to tackle the challenges of class-IL as well as domain-IL. The Generalized Class Incremental Learning (GCIL; Mi et al. (2020)) is the closest to the real-world scenario as it utilizes probabilistic modeling to sample the classes and data distributions in each task. The number of classes in each task is not fixed, the classes can overlap and the sample size for each class can vary.
125
+
126
+ Table 2 shows that CLS-ER provides considerable performance gains on the challenging MNIST360, particularly with a low memory budget. Similarly, Table 3 demonstrates the effectiveness of CLS-ER on GCIL-CIFAR-100 under both uniform and imbalanced class samples. Both of these settings involve recurring classes in subsequent sequences which makes the transfer of knowledge from previous occurrences important. The performance gap between CLS-ER and $\mathrm { D E R + + }$ in the recurring classes setting alludes to another shortcoming of saving logits from the previous state. Consider the case where class c appears in sequence (Seq)-1 with 20 samples, and then subsequently in Seq-5 with 200 samples. In the following sequences, $\mathrm { D E R + + }$ uses exemplars from class c saved in Seq-1 with sub-optimal logits from the model state which was attained with only 20 samples and fails to take advantage of the better learned representations with additional data in Seq-5. CLS-ER, on the other hand, is able to take advantage of the additional samples and provide feedback from the improved learned representations. Moreover, the considerable performance improvement in the longtail setting shows that CLS-ER is more robust to class imbalance
127
+
128
+ ![](images/cc09b81bc4bf3ba7a715662721090fed97cd7e674719d2dbc70b1f9529d197a9.jpg)
129
+ Figure 3: Model characteristics analyses of different methods trained on S-CIFAR-10 with 500 buffer size. The Left and middle figures show the training loss and accuracy under varying Gaussian noise added to the weights of each layer of the model. CLS-ER is considerably less sensitive to perturbations, suggesting convergence to flatter minima. The right figure shows the task probabilities. CLS-ER effectively mitigates the bias to the recent tasks and provides a more uniform probability of being predicted for the classes over the tasks even very early ones.
130
+
131
+ Note that the MNIST-based settings can be considered under the online CL setting (see Section A.4) as we only pass through the data once for each task and the performance of CLS-ER on these settings demonstrates its potential as an efficient method for online CL.
132
+
133
+ # 6 MODEL CHARACTERISTICS
134
+
135
+ We analyze CLS-ER and provide some insights into the characteristics of the proposed approach which enables it to learn effectively under challenging CL scenarios. In the subsequent analyses, we compare CLS-ER with the baseline ER and DER $^ { + + }$ .
136
+
137
+ # 6.1 CONVERGENCE TO FLATTER MINIMA
138
+
139
+ Due to the non-convexity of the loss landscape, there can be multiple solutions to the optimization objective, however, the local geometry at the convergence point can affect the generalization of the model. Solutions that reside in wide valleys instead of narrow crevices generalize better (Chaudhari et al., 2019; Hochreiter & Schmidhuber, 1997; Keskar et al., 2016) as the predictions do not change drastically with small perturbations. A CL model which converges to flatter minima has more flexibility to explore the neighboring parameter space to optimize on the new task without drastically increasing the loss on the previous tasks. Following the analysis in Zhang et al. (2018), we add independent Gaussian noise of increasing strength to the parameters of the trained model and analyze the change in accuracy and loss across the training samples. Figure 3 shows that CLS-ER is significantly less sensitive to perturbations compared to ER and $\mathrm { D E R + + }$ . CLS-ER also retains performance for a longer period and its performance drops more smoothly. These results suggest that the fast and slow adaptation of information in CLS-ER can guide the optimization to wider valleys.
140
+
141
+ # 6.2 TASK PROBABILITIES
142
+
143
+ Because of the sequential nature of CL, an implicit bias is induced towards the current task (Wu et al., 2019). A number of CL methods employ explicit techniques to reduce this bias (Hou et al., 2019; Wu et al., 2019), however, they utilize the task boundaries which is counterproductive for general incremental learning. We believe that the efficient knowledge consolidation in CLS-ER through the semantic memories can implicitly mitigate the bias towards recent tasks. We follow the analysis performed in Buzzega et al. (2020b) to observe the probability of each task being predicted at the end of the training. For each sample in the test dataset, we take the softmax output and then average the probabilities of the associated classes for each task across the dataset. We normalize the values and report the probability of each task being predicted. Figure 3 (right plot) shows that CLS-ER is able to maintain a more uniform prediction probability across all the tasks over a long sequence. Figures S3 and S4 shows similar results for other buffer sizes and S-TinyImageNet.
144
+
145
+ ![](images/fcf3b926f9b5848f246a2630ed9bae50598a97ee8677ceef394a03849730411c.jpg)
146
+ Figure 4: Reliability plots for different methods on S-CIFAR-10 with 500 buffer size. CLS-ER results in considerably better-calibrated models and hence more reliable predictions. For other buffer sizes and S-TinyImageNet see Figures S5 and S6.
147
+
148
+ # 6.3 MODEL CALIBRATION
149
+
150
+ Model calibration refers to the accuracy with which the scores provided by the model reflect its predictive uncertainty. The class probabilities predicted by DNNs are uncalibrated, often tending towards over-confidence which is detrimental to the reliability of the model’s prediction (Guo et al., 2017). This is even more pronounced in CL where the models tend to be biassed towards recent tasks. Following Guo et al. (2017), we provide the reliability diagrams (model accuracy as a function of its prediction confidence) and the Expected Calibration Error (ECE; a weighted average over the absolute difference between accuracy and confidence). Figure 4 shows the remarkable ability of CLS-ER to provide well-calibrated models without the application of any calibration technique.
151
+
152
+ Note that these characteristics are complementary in nature: convergence to flatter minima allows our method to remain in the vicinity of optimal parameters for previous tasks when adapting to the new task, this leads to more uniform performance across tasks which can improve the task probabilities, and since the model is not too biased towards the current task, the model can provide reliable prediction across the tasks which improve the calibration. Additional characteristics analyses on different datasets and buffer sizes are provided in Appendix. We observe that our model’s behavior is consistent across varying datasets and buffer sizes.
153
+
154
+ # 7 CONCLUSION
155
+
156
+ We proposed a novel dual memory experience replay method based on the complementary learning systems theory in the brain. Our method maintains long-term and short-term semantic memories which are utilized to effectively replay the neural activities of the episodic memories and align the decision boundary of the working model for efficient knowledge consolidation. We demonstrated the effectiveness of our approach on benchmark datasets as well as more challenging general incremental learning scenarios and achieved the new state-of-the-art in the vast majority of the continual learning settings. We further showed that CLS-ER converges to flatter minima, mitigates the bias towards recent tasks, and provides a well-calibrated high-performance model. Our strong empirical results motivate further study into mimicking the complementary learning system in the brain more faithfully to enable optimal continual learning in DNNs.
157
+
158
+ # REFERENCES
159
+
160
+ Rahaf Aljundi, Min Lin, Baptiste Goujaud, and Yoshua Bengio. Gradient based sample selection for online continual learning. In Advances in Neural Information Processing Systems, pp. 11816– 11825, 2019. 2, 14
161
+
162
+ Elahe Arani, Fahad Sarfraz, and Bahram Zonooz. Noise as a resource for learning in knowledge distillation. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pp. 3129–3138, 2021. 5
163
+
164
+ Ari S Benjamin, David Rolnick, and Konrad Kording. Measuring and regularizing networks in function space. arXiv preprint arXiv:1805.08289, 2018. 2
165
+
166
+ Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, and Simone Calderara. Dark experience for general continual learning: a strong, simple baseline. arXiv preprint arXiv:2004.07211, 2020a. 5, 6, 7, 13, 14, 17, 20
167
+
168
+ Pietro Buzzega, Matteo Boschini, Angelo Porrello, and Simone Calderara. Rethinking experience replay: a bag of tricks for continual learning. arXiv preprint arXiv:2010.05595, 2020b. 8
169
+
170
+ 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. 8
171
+
172
+ Arslan Chaudhry, Marc’Aurelio Ranzato, Marcus Rohrbach, and Mohamed Elhoseiny. Efficient lifelong learning with a-gem. arXiv preprint arXiv:1812.00420, 2018. 1
173
+
174
+ Matthias De Lange, Rahaf Aljundi, Marc Masana, Sarah Parisot, Xu Jia, Ales Leonardis, Gregory Slabaugh, and Tinne Tuytelaars. A continual learning survey: Defying forgetting in classification tasks. arXiv preprint arXiv:1909.08383, 2019. 13
175
+
176
+ Mehrdad Farajtabar, Navid Azizan, Alex Mott, and Ang Li. Orthogonal gradient descent for continual learning. In International Conference on Artificial Intelligence and Statistics, pp. 3762–3773. PMLR, 2020. 1
177
+
178
+ Sebastian Farquhar and Yarin Gal. Towards robust evaluations of continual learning. arXiv preprint arXiv:1805.09733, 2018. 1, 6, 13, 14
179
+
180
+ Robert M French. Catastrophic forgetting in connectionist networks. Trends in cognitive sciences, 3(4):128–135, 1999. 2
181
+
182
+ Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Q Weinberger. On calibration of modern neural networks. In International Conference on Machine Learning, pp. 1321–1330. PMLR, 2017. 9
183
+
184
+ Demis Hassabis, Dharshan Kumaran, Christopher Summerfield, and Matthew Botvinick. Neuroscience-inspired artificial intelligence. Neuron, 95(2):245–258, 2017. 1
185
+
186
+ Tyler L Hayes, Giri P Krishnan, Maxim Bazhenov, Hava T Siegelmann, Terrence J Sejnowski, and Christopher Kanan. Replay in deep learning: Current approaches and missing biological elements. arXiv preprint arXiv:2104.04132, 2021. 1, 3
187
+
188
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. corr abs/1512.03385 (2015), 2015. 5
189
+
190
+ Sepp Hochreiter and Jürgen Schmidhuber. Flat minima. Neural computation, 9(1):1–42, 1997. 8
191
+
192
+ Saihui Hou, Xinyu Pan, Chen Change Loy, Zilei Wang, and Dahua Lin. Learning a unified classifier incrementally via rebalancing. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 831–839, 2019. 8
193
+
194
+ David Isele and Akansel Cosgun. Selective experience replay for lifelong learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018. 4
195
+
196
+ Nitin Kamra, Umang Gupta, and Yan Liu. Deep generative dual memory network for continual learning. arXiv preprint arXiv:1710.10368, 2017. 2
197
+
198
+ 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. 8
199
+
200
+ J Kirkpatrick, R Pascanu, N Rabinowitz, J Veness, G Desjardins, AA Rusu, K Milan, J Quan, T Ramalho, A Grabska-Barwinska, et al. Overcoming catastrophic forgetting in neural networks.(dec. arXiv preprint cs.LG/1612.00796, 2016. 13
201
+
202
+ 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. 1
203
+
204
+ Giri P Krishnan, Timothy Tadros, Ramyaa Ramyaa, and Maxim Bazhenov. Biologically inspired sleep algorithm for artificial neural networks. arXiv preprint arXiv:1908.02240, 2019. 2, 3
205
+
206
+ Alex Krizhevsky et al. Learning multiple layers of features from tiny images. 2009. 13
207
+
208
+ Dharshan Kumaran, Demis Hassabis, and James L McClelland. What learning systems do intelligent agents need? complementary learning systems theory updated. Trends in cognitive sciences, 20 (7):512–534, 2016. 1
209
+
210
+ 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. 13
211
+
212
+ David Lopez-Paz and Marc’Aurelio Ranzato. Gradient episodic memory for continual learning. In Advances in neural information processing systems, pp. 6467–6476, 2017. 1, 2, 13
213
+
214
+ Wolfgang Maass. Noise as a resource for computation and learning in networks of spiking neurons. Proceedings of the IEEE, 102(5):860–880, 2014. 5
215
+
216
+ Zheda Mai, Ruiwen Li, Jihwan Jeong, David Quispe, Hyunwoo Kim, and Scott Sanner. Online continual learning in image classification: An empirical survey. Neurocomputing, 469:28–51, 2022. 14
217
+
218
+ Michael McCloskey and Neal J Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In Psychology of learning and motivation, volume 24, pp. 109–165. Elsevier, 1989. 1
219
+
220
+ Fei Mi, Lingjing Kong, Tao Lin, Kaicheng Yu, and Boi Faltings. Generalized class incremental learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pp. 240–241, 2020. 6, 7, 13, 20
221
+
222
+ German I Parisi, Ronald Kemker, Jose L Part, Christopher Kanan, and Stefan Wermter. Continual lifelong learning with neural networks: A review. Neural Networks, 113:54–71, 2019. 1, 2
223
+
224
+ Hadi Pouransari and Saman Ghili. Tiny imagenet visual recognition challenge. CS231N course, Stanford Univ., Stanford, CA, USA, 2015. 13
225
+
226
+ Sylvestre-Alvise Rebuffi, Alexander Kolesnikov, Georg Sperl, and Christoph H Lampert. icarl: Incremental classifier and representation learning. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pp. 2001–2010, 2017. 2
227
+
228
+ 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. 2
229
+
230
+ Hippolyt Ritter, Aleksandar Botev, and David Barber. Online structured laplace approximations for overcoming catastrophic forgetting. In Advances in Neural Information Processing Systems, pp. 3738–3748, 2018. 1
231
+
232
+ Anthony Robins. Catastrophic forgetting in neural networks: the role of rehearsal mechanisms. In Proceedings 1993 The First New Zealand International Two-Stream Conference on Artificial Neural Networks and Expert Systems, pp. 65–68. IEEE, 1993. 2
233
+
234
+ Mohammad Rostami, Soheil Kolouri, and Praveen K Pilly. Complementary learning for overcoming catastrophic forgetting using experience replay. arXiv preprint arXiv:1903.04566, 2019. 2
235
+
236
+ 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. 1
237
+
238
+ Fahad Sarfraz, Elahe Arani, and Bahram Zonooz. Knowledge distillation beyond model compression. In 2020 25th International Conference on Pattern Recognition (ICPR), pp. 6136–6143. IEEE, 2021. 2
239
+
240
+ Dongsub Shim, Zheda Mai, Jihwan Jeong, Scott Sanner, Hyunwoo Kim, and Jongseong Jang. Online class-incremental continual learning with adversarial shapley value. arXiv e-prints, pp. arXiv–2009, 2020. 13
241
+
242
+ Antti Tarvainen and Harri Valpola. Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results. arXiv preprint arXiv:1703.01780, 2017. 3, 5
243
+
244
+ Gido M van de Ven and Andreas S Tolias. Three scenarios for continual learning. arXiv preprint arXiv:1904.07734, 2019. 6, 13
245
+
246
+ Jeffrey S Vitter. Random sampling with a reservoir. ACM Transactions on Mathematical Software (TOMS), 11(1):37–57, 1985. 4
247
+
248
+ Yue Wu, Yinpeng Chen, Lijuan Wang, Yuancheng Ye, Zicheng Liu, Yandong Guo, and Yun Fu. Large scale incremental learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 374–382, 2019.
249
+
250
+ Jaehong Yoon, Eunho Yang, Jeongtae Lee, and Sung Ju Hwang. Lifelong learning with dynamically expandable networks. arXiv preprint arXiv:1708.01547, 2017. 1
251
+
252
+ Friedemann Zenke, Ben Poole, and Surya Ganguli. Continual learning through synaptic intelligence. Proceedings of machine learning research, 70:3987, 2017. 1, 13
253
+
254
+ Ying Zhang, Tao Xiang, Timothy M Hospedales, and Huchuan Lu. Deep mutual learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4320– 4328, 2018. 8
255
+
256
+ # A CONTINUAL LEARNING SETTINGS
257
+
258
+ There are a plethora of evaluation protocols in the CL literature, each of which biases the evaluation towards a certain approach (Farquhar & Gal, 2018; Mi et al., 2020; Shim et al., 2020; van de Ven & Tolias, 2019). It is therefore of utmost importance to conduct an extensive and robust evaluation to gauge the versatility of the method. We believe that adhering to the key desiderata as suggested in Farquhar & Gal (2018) would help the CL community immensely in moving towards a robust evaluation of methods. An experimental protocol that trains the method on a long sequence of tasks where the boundaries between the tasks are not distinct and the tasks themselves are not disjoint and the method does not make sure of task boundaries during training or testing can be considered as adhering to all five desiderata. Our work focuses on the aforementioned setting which can be considered as General Incremental Learning (GIL) setting. Here, we provide a broad categorization of these evaluation protocols which test different aspects of CL.
259
+
260
+ # A.1 CLASS INCREMENTAL LEARNING (CLASS-IL)
261
+
262
+ Class-IL refers to the CL scenario where new classes are added with each subsequent task and the agent must learn to distinguish not only amongst the classes within the current task but also across previous tasks. Class-IL measures how well the method can learn general representations, accumulate, consolidate, and transfer the acquired knowledge to learn efficient representations and decision boundaries for all the classes seen so far. Following Buzzega et al. (2020a); De Lange et al. (2019); Zenke et al. (2017), we consider the common benchmark datasets MNIST (LeCun et al., 1998) (SMNIST), CIFAR-10 (Krizhevsky et al., 2009) (S-CIFAR-10) and Tiny-ImageNet (Pouransari & Ghili, 2015) (S-Tiny-ImageNet) which are split into 5, 5, and 10 tasks each including 2, 2, and 20 classes respectively. These represent Class-IL settings of increasing dataset complexity as well as longer sequences. While it is an important and challenging benchmark, it assumes that each subsequent task will have the same number of disjoint classes and have uniform samples for each class which is not representative of real-world scenarios. We do not consider the related Task Increment Learning (Task-IL) setting as it assumes the availability of task labels at both training and inference which cannot truly be considered as a CL task (Farquhar & Gal, 2018).
263
+
264
+ # A.2 DOMAIN INCREMENTAL LEARNING (DOMAIN-IL)
265
+
266
+ Domain-IL refers to the CL scenario where the classes remain the same in each subsequent task but the input distribution changes. We consider Rotated-MNIST (Lopez-Paz & Ranzato, 2017) (R-MNIST) where each task contains digits rotated by a fixed angle between 0 and 180 degrees and Permuted-MNIST (Kirkpatrick et al., 2016) (P-MNIST) which applies a fixed random permutation to the pixels for each task. Though we provide the results for Permuted MNIST for completion, we share the opinion by Farquhar & Gal (2018) that it should not be considered as a benchmark dataset as it violates the cross-task resemblance desiderata and deviates from the goal of continual learning.
267
+
268
+ # A.3 GENERAL INCREMENTAL LEARNING (GIL)
269
+
270
+ The aforementioned CL scenarios fail to assimilate the challenges in the real world, setting where the task boundaries are blurry and the learning agent must rather learn from a continuous stream of data where classes can reappear and have different data distributions. The CL method must deal with the issues of sample efficiency, imbalanced classes, and efficient transfer of knowledge in addition to preventing catastrophic forgetting. To test the efficacy of our method in this challenging setting, we consider two GIL evaluation protocols. MNIST-360 (Buzzega et al., 2020a) models a stream of data which presents batches of two consecutive MNIST images with each sample rotated at an increasing angle and the sequence is repeated three times. This exposes the model to both a sharp distribution shift when the class changes and a smooth rotational distribution shift. However, the number of classes in each task and the samples are uniform. The Generalized Class Incremental Learning (GCIL) (Mi et al., 2020) utilizes probabilistic modeling to sample the classes and data distributions in each task. Hence, the number of classes in each task is not fixed, the classes can overlap and the sample size for each class can vary. Following Mi et al. (2020), we use GCIL on CIFAR-100 (Krizhevsky et al., 2009) dataset (GCIL-CIFAR-100), set the number of samples and maximum number of classes per task to 1000 and 50 respectively, number of tasks to 20, and evaluate on both uniform and longtail (imbalanced) sample distribution.
271
+
272
+ # A.4 ONLINE CONTINUAL LEARNING
273
+
274
+ Online continual learning refers to the challenging scenario where a stream of samples is only seen once and is non-iid (Mai et al., 2022; Aljundi et al., 2019). The common approach in the literature is to use the single-epoch protocol where the network is trained on each task in the sequence for only one epoch and there are no additional passages over data. As we aim to position CLS-ER as a general incremental learning method, we are also interested in the online continual learning setting. However, similar to Buzzega et al. (2020a), we also believe that the dataset complexity needs to be considered when setting the number of epochs to disentangle the effect of catastrophic forgetting from underfitting and share their suggestion that future CL works should strive for realism by designing experimental settings which are in line with the guidelines of General Continual Learning (Farquhar & Gal, 2018) which is the goal of our study rather than adopting the single-epoch protocol. For the MNIST-based settings, we use only one epoch per task as it is sufficient for the SGD baseline to learn the single task well. And for the more complex settings, we increase the number of epochs: 50 epochs for Sequential CIFAR-10 and Sequential Tiny-ImageNet and 100 epochs for GCIL-CIFAR-100.
275
+
276
+ We would also like to emphasize that the experiments on MNIST based settings (S-MNIST, RMNIST, P-MNIST, and MNIST-360) can be considered as online continual learning settings as we only train the network for 1 epoch, and thereby the model only sees the data for each task once. CLSER’s performance in these settings demonstrates its potential for the challenging online continual learning setting.
277
+
278
+ # B RESERVOIR SAMPLING
279
+
280
+ Here, we provide the algorithm for the Reservoir Sampling for maintaining a fixed-size memory buffer. Reservoir sampling takes in a data stream of unknown length and assigns equal probability to each sample for being represented in the memory buffer $( \mathcal { M } )$ with a fixed budget size $( B )$ . Sampling and replacement are done at random and no priority is assigned to the samples being added or replaced from the memory buffer.
281
+
282
+ # Algorithm 2 Reservoir Sampling Algorithm
283
+
284
+ <table><tr><td>(x,y)</td><td>Input: Memory Buffer M, Memory Budget B,Number of seen examples N, Selected example</td></tr><tr><td>1: if B&gt; N then</td><td>Memory is not full</td></tr><tr><td>2: M[N] ← (x,y)</td><td></td></tr><tr><td>3: else</td><td>&gt; Select a sample to remove</td></tr><tr><td>4:</td><td>V = randomInteger(min= 0,max = N)</td></tr><tr><td>5: ifv&lt;Bthen</td><td></td></tr><tr><td>6: M[v]←(x,y)</td><td></td></tr><tr><td>return M</td><td></td></tr></table>
285
+
286
+ # C ADDITIONAL RESULTS
287
+
288
+ In this section, we provide additional experimental results and analysis of the behavior of the model.
289
+
290
+ # C.1 CLS-ER COMPONENTS PERFORMANCE
291
+
292
+ CLS-ER involves the interplay between the working model and the two semantic memories: the plastic and stable models. While we use the stable model for final inference, here we provide the performance of each of these individual components to provide further insights into the workings of our method. Table S1 shows the corresponding performance of the working model and plastic model for each of our experimental settings. We can see that the stable model can effectively consolidate knowledge across the tasks and therefore provide the highest mean performance for the vast majority of the settings. Figures S1 and S2 further shows how the task-wise performance (on test set) of each of the component varies as subsequent tasks are learned. The stable model retains the performance on previous tasks while the plastic model adapts better to the recent task. Both these models provide feedback to the working model which in turn improves the plastic and stable model.
293
+
294
+ Table S1: CLS-ER components performance analysis for each of the experimental setting.
295
+
296
+ <table><tr><td>Dataset</td><td>Buffer</td><td>Stable Model</td><td>Working Model</td><td>Plastic Model</td></tr><tr><td rowspan="3">S-MNIST</td><td>200</td><td>89.54±0.21</td><td>89.32±0.23</td><td>89.52±0.21</td></tr><tr><td>500</td><td>92.05±0.30</td><td>91.61±0.47</td><td>92.04±0.33</td></tr><tr><td>5120</td><td>95.73±0.10</td><td>95.65±0.15</td><td>95.73±0.12</td></tr><tr><td rowspan="3">S-CIFAR-10</td><td>200</td><td>66.19±0.75</td><td>50.09±1.48</td><td>62.68±1.94</td></tr><tr><td>500</td><td>75.22±0.71</td><td>63.09±1.12</td><td>71.32±0.89</td></tr><tr><td>5120</td><td>86.78±0.17</td><td>85.00±0.33</td><td>86.77±0.17</td></tr><tr><td rowspan="3">S-Tiny-ImageNet</td><td>200</td><td>23.47±0.80</td><td>9.97±0.18</td><td>17.19±0.71</td></tr><tr><td>500</td><td>31.03±0.56</td><td>15.35±0.34</td><td>27.16±0.43</td></tr><tr><td>5120</td><td>46.74±0.31</td><td>41.39±0.39</td><td>47.10±0.42</td></tr><tr><td rowspan="3">R-MNIST</td><td>200</td><td>92.26±0.18</td><td>89.37±0.47</td><td>89.99±0.43</td></tr><tr><td>500</td><td>94.06±0.07</td><td>93.24±0.14</td><td>93.52±0.09</td></tr><tr><td>5120</td><td>94.25±0.06</td><td>94.28±0.08</td><td>94.37±0.06</td></tr><tr><td rowspan="3">P-MNIST</td><td>200</td><td>84.63±0.40</td><td>84.33±0.45</td><td>84.54±0.41</td></tr><tr><td>500</td><td>88.30±0.14</td><td>88.12±0.16</td><td>88.25±0.14</td></tr><tr><td>5120</td><td>92.03±0.05</td><td>91.96±0.06</td><td>92.02±0.05</td></tr><tr><td rowspan="3">MNIST-360</td><td>200</td><td>66.37±0.83</td><td>55.59±1.74</td><td>60.60±1.41</td></tr><tr><td>500</td><td>75.70±0.41</td><td>72.70±0.80</td><td>75.03±0.37</td></tr><tr><td>1000</td><td>79.54±0.34</td><td>78.39±0.69</td><td>79.16±0.42</td></tr><tr><td rowspan="3">GCIL-CIFAR-100 (Uniform)</td><td>200</td><td>33.15±2.80</td><td>31.74±2.72</td><td>32.70±2.78</td></tr><tr><td>500</td><td>37.01±1.67</td><td>35.89±1.69</td><td>36.18±1.68</td></tr><tr><td>1000</td><td>41.09±1.58</td><td>40.44±1.80</td><td>40.70±1.66</td></tr><tr><td rowspan="3">GCIL-CIFAR-100 (Longtail)</td><td>200</td><td>29.57±3.80</td><td>28.19±3.90</td><td>29.12±3.89</td></tr><tr><td>500</td><td>33.26±3.66</td><td>32.22±3.79</td><td>32.95±3.70</td></tr><tr><td>1000</td><td>39.21±3.46</td><td>38.51±3.55</td><td>38.84±3.52</td></tr></table>
297
+
298
+ # C.2 TASK PROBABILITIES
299
+
300
+ To test the effectiveness of our method in mitigating the bias towards recent tasks, we provide the task probabilities of the models trained with different buffer sizes on S-CIFAR-10 and S-TinyImageNet. Figures S3 and S4 show that CLS-ER consistently achieves more uniform task probabilities compared to ER and $\mathrm { D E R + + }$ and effectively mitigates the bias towards the last task.
301
+
302
+ # C.3 MODEL CALIBRATION
303
+
304
+ To further test the consistency of CLS-ER in providing well-calibrated models and the impact of the buffer size, we evaluate the calibration of models trained with different buffer sizes on S-CIFAR-10 and S-Tiny-ImageNet. Figures S5 and S6 show that CLS-ER consistently provides better calibrated models compared to ER and $\mathrm { D E R + + }$ . Remarkably, for both the datasets, on lower buffer sizes, the difference in Expected Calibration Error (ECE) is considerable. This demonstrates the capability of CLS-ER to train high-performance and reliable models under challenging conditions.
305
+
306
+ # C.4 EFFECT OF HYPERPARAMETERS
307
+
308
+ The interaction between the three components of CLS-ER is complementary. Table S3 shows how the performance of each component is affected under different hyperparameter settings. We can draw the following conclusions from the results. The performance improvement in the plastic and stable model is reflected in the working model and the best performance is seen in cases where both the semantic memories are performing well (albeit the focus on tasks is different). This highlights the crucial role of both memories in enabling CLS-ER to learn efficiently. For a fixed $r _ { S }$ value, the final performance of the stable model is affected considerably by the performance of the plastic model. The method is not highly sensitive to the particular choice of hyperparameters as different settings can attain similar performance. Because of the complementary nature of the components, we can often fix a set of parameters (e.g. $\lambda$ , $\alpha _ { S }$ , $\alpha _ { S }$ and $r _ { S }$ ) and only finetune the remaining parameters (e.g. $r _ { P } ^ { \prime }$ ) which facilitates hyperparameter tuning significantly.
309
+
310
+ ![](images/d857151b48e83ff3cf8d669fe2199ff6be049aca40295212d11cc1d228af46fd.jpg)
311
+ Figure S1: Test set task-wise performance for the individual models on S-CIFAR-10 with different buffer sizes. The task-wise performance $\mathbf { \dot { x } }$ -axis) is evaluated at the end of training of each task (y-axis) to evaluate how it is affected as training progresses.
312
+
313
+ # D COMPARISON WITH A SINGLE SEMANTIC MEMORY
314
+
315
+ CLS-ER employs two semantic memories as we aim to mimic the fast and slow learning mechanisms in the hippocampus and neocortex respectively. Here we compare our method with a single semantic memory (Mean-ER) and Table S2 shows that while it still performs admirably compared to the other CL methods, the dual semantic memories in CLS-ER provides additional performance gains especially on the complex datasets under the challenging lower memory buffer settings and has a much lower variance. We attribute this to the failure of Mean-ER in maintaining the performance on both the recent and earlier tasks together i.e there is an inherent trade-off as tuning the semantic memory to adapt to the recent changes comes at the cost of performance on earlier tasks and vice versa. CLS-ER efficiently tackles this trade-off by maintaining two specialized long-term and shortterm memories. The performance of Mean-ER, however, provides further evidence for the benefits of using consolidated information for memory replay.
316
+
317
+ Note that for a fair comparison, we use the same hyperparameter search space as CLS-ER for finding the optimal parameters for Mean-ER and report the average and 1 std of 10 runs with different initializations using the best parameters for each setting. Table S6 provides the chosen hyperparameters. For inference, similar to CLS-ER, we use the EMA-weighted model (semantic memory) for Mean-ER.
318
+
319
+ ![](images/3e6883a1f7d2c3b538f68961a13252c10837ff431e0236e2985c8ec334efe633.jpg)
320
+ Figure S2: Test set task-wise performance for the individual models on S-Tiny-ImageNet with different buffer sizes. The task-wise performance ( $\mathbf { \dot { x } }$ -axis) is evaluated at the end of training of each task (y-axis) to evaluate how it is affected as training progresses.
321
+
322
+ ![](images/bbaf12b41b231df8112faa1215a9f09778a0b285d50e14ec4f41af0eb715d9ae.jpg)
323
+ Figure S3: Task probabilities for different methods on S-CIFAR-10 with varying memory budget.
324
+
325
+ # E TRAINING AND IMPLEMENTATION DETAILS
326
+
327
+ For a fair comparison, we aim to keep the experimental settings close to the current state-of-theart $\mathrm { D E R + + }$ (Buzzega et al., 2020a) as much as possible to disassociate the effect of the training schedule. We use the same optimizer, the number of epochs, batch size, and memory batch size as $\mathrm { D E R + + }$ . For S-Tiny-ImageNet, we reduce the number of epochs to 50 from 100 used by $\mathrm { D E R + + }$ as our method can learn efficiently with fewer epochs, and quickly acquiring new knowledge is preferred for CL. Similar to $\mathrm { D E R + + }$ , we finetune the memory batch size for S-MNIST and MNIST360. We select the hyperparameters for each of the experimental setting using a small validation set, $\alpha _ { S } , \alpha _ { P } \in ( 0 . 9 9 , 0 . 9 9 9 )$ , $r _ { S } , r _ { P } \in ( 0 , 1 ]$ , $\lambda \in ( 0 , 2 ]$ . Table S4 provides the hyperparameters used for each of the experimental settings. Note that for the vast majority of datasets, we use uniform settings (lr, epochs, batch size, memory batch size, and lambda) across the different buffer sizes and requires only slight modifications in the other hyperparameters which shows that our method does not require extensive finetuning for different memory budgets.
328
+
329
+ ![](images/3e568faa85c4dd263d654ec04d964a2b2e0170d03d6ed404cbb900cec3e52dfc.jpg)
330
+ Figure S4: Task probabilities for different methods on S-Tiny-ImageNet with varying memory budget.
331
+
332
+ ![](images/f5860c1110d4f1bbd6a729329cdccf9785cf10dc45cccfe959b39e0226b1b2fe.jpg)
333
+ Figure S5: Reliability plots for the different methods on S-CIFAR-10 with varying memory budget.
334
+
335
+ ![](images/d73417e4e5a32c0333a0cfd7c81926db646d5bc576f88ecf98975457ed9712f0.jpg)
336
+ Figure S6: Reliability plots for the different methods on S-Tiny-ImageNet with varying memory budget.
337
+
338
+ Table S2: Comparison of CLS-ER with Mean-ER (single semantic memory) on Class-IL and Domain-IL settings. We report the mean and 1 std of 10 runs with different initializations.
339
+
340
+ <table><tr><td rowspan="2">Buffer</td><td rowspan="2">Method</td><td colspan="3">Class-IL</td><td colspan="2">Domain-IL</td></tr><tr><td>S-MNIST</td><td>S-CIFAR-10</td><td>S-Tiny-ImageNet</td><td>R-MNIST</td><td>P-MNIST</td></tr><tr><td rowspan="2"></td><td>JOINT</td><td>95.57±0.24</td><td>92.20±0.15</td><td>59.99±0.19</td><td>95.76±0.04</td><td>94.33±0.17</td></tr><tr><td>SGD</td><td>19.60±0.04</td><td>19.62±0.05</td><td>7.92±0.26</td><td>67.66±8.53</td><td>40.70±2.33</td></tr><tr><td rowspan="2">200</td><td>Mean-ER</td><td>88.32±0.65</td><td>61.88±2.43</td><td>17.68±1.65</td><td>92.10±1.07</td><td>83.28±0.68</td></tr><tr><td>CLS-ER</td><td>89.54±0.21</td><td>66.19±0.75</td><td>23.47±0.80</td><td>92.26±0.18</td><td>84.63±0.40</td></tr><tr><td rowspan="2">500</td><td>Mean-ER</td><td>91.79±0.23</td><td>70.40±1.21</td><td>24.97±0.80</td><td>92.78±0.44</td><td>87.73±0.39</td></tr><tr><td>CLS-ER</td><td>92.05±0.32</td><td>75.22±0.71</td><td>31.03±0.56</td><td>94.06±0.07</td><td>88.30±0.14</td></tr><tr><td rowspan="2">5120</td><td>Mean-ER</td><td>95.57±0.18</td><td>84.84±2.0</td><td>45.69±0.58</td><td>94.25±0.51</td><td>91.90±0.11</td></tr><tr><td>CLS-ER</td><td>95.73±0.11</td><td>86.78±0.17</td><td>46.74±0.31</td><td>94.25±0.06</td><td>92.03±0.05</td></tr></table>
341
+
342
+ # E.1 GCIL-CIFAR-100
343
+
344
+ To test our method under challenging GIL settings that better simulate the challenges of CL in the real world, we incorporate the GCIL setting from the code provided by Mi et al. (2020) with the continual dataset template class in the mammoth framework. We set the number of phases (length of task sequences) to 20, with the total number of samples in each phase set to 1000 and the maximum number of classes in each phase set to 50. We evaluate on both uniform and longtail (imbalanced) data distributions. Since GCIL involves the probabilistic sampling of the classes and their samples in each phase, the random seed determines the complexity of the GCIL setting. Therefore, for reproduciblility and to gauge the stability of the methods, we fix the dataset seed to 1993 and report the average and standard deviation of 10 differently initialized models trained on the same settings.
345
+
346
+ For each of our method, we use identical training scheme $\mathrm { { ( l r { = } 0 . 1 } }$ , epochs $_ { \mathrm { \scriptsize = } 1 0 0 }$ , batch size $^ { \underline { { \ } } 3 2 }$ and memory batch $\mathrm { s i z e } { = } 3 2$ ). For $\mathrm { D E R + + }$ , as per the authors suggestion, we performed hyperparameter search over $\alpha \in [ 0 . 2 , 0 . 3 ]$ and $b e t a \in [ 0 . 5 , 1 . 0 ]$ with step size of 0.1. Table S5 provides the parameters chosen for each of the method under the different settings.
347
+
348
+ # E.2 PERTURBATION ANALYSIS
349
+
350
+ For the perturbation analysis, we used the code and checkpoints provided by Buzzega et al. (2020a) for $\mathrm { D E R + + }$ and ER. We would like to express our gratitude to the authors for their support and for making the mammoth framework available for the research community which provides a framework for a fair comparison of different CL methods under uniform experimental conditions.
351
+
352
+ Table S3: The effect of different hyperparameter settings on the individual components of CLS-ER trained on S-CIFAR-10 with 500 buffer size. For all the experiments $\alpha _ { S }$ and $\alpha _ { P }$ are fixed to 0.999 and the performance is averaged over 3 runs with different initialization.
353
+
354
+ <table><tr><td>入</td><td>rs</td><td>rp</td><td>Stable Model</td><td>Working Model</td><td>Plastic Model</td></tr><tr><td rowspan="12">0.1</td><td></td><td>0.2</td><td>73.53±1.07</td><td>62.80±0.63</td><td>71.11±2.21</td></tr><tr><td></td><td>0.3</td><td>72.44±1.37</td><td>63.53±1.98</td><td>70.97±1.71</td></tr><tr><td></td><td>0.4</td><td>73.05±0.93</td><td>61.81±1.92</td><td>68.75±2.20</td></tr><tr><td></td><td>0.5</td><td>75.16±1.09</td><td>63.95±1.92</td><td>70.42±1.09</td></tr><tr><td>0.1</td><td>0.6</td><td>75.04±0.66</td><td>62.82±0.70</td><td>69.61±0.31</td></tr><tr><td></td><td>0.7</td><td>73.94±0.48</td><td>63.34±0.46</td><td>70.30±1.68</td></tr><tr><td></td><td>0.8</td><td>74.61±1.10</td><td>62.68±0.65</td><td>70.74±0.39</td></tr><tr><td rowspan="12"></td><td></td><td>73.74±2.14</td><td>62.69±1.97</td><td>69.52±0.79</td></tr><tr><td></td><td>0.9 1.0</td><td>64.21±1.11</td><td>72.00±0.56</td></tr><tr><td>0.3</td><td>75.73±0.68 70.26±1.79</td><td>61.63±1.03</td><td>69.31±1.82</td></tr><tr><td></td><td>71.80±1.17</td><td>62.64±0.18</td><td>70.64±1.22</td></tr><tr><td>0.4 0.5</td><td>70.69±2.13</td><td>61.76±0.64</td><td>69.65±1.92</td></tr><tr><td></td><td>72.45±0.68</td><td></td><td></td></tr><tr><td>0.2</td><td>0.6 0.7</td><td>71.47±1.98</td><td>63.87±0.85</td><td>71.29±0.72</td></tr><tr><td></td><td>0.8</td><td>72.16±0.56</td><td>61.12±1.90 62.71±0.57</td><td>70.22±2.24</td></tr><tr><td></td><td>0.9</td><td>72.09±0.59</td><td></td><td>70.83±0.64</td></tr><tr><td></td><td>1.0</td><td>72.05±1.35</td><td>63.33±1.01 63.74±1.75</td><td>71.20±0.87</td></tr><tr><td></td><td>0.4</td><td></td><td></td><td>71.01±1.28</td></tr><tr><td rowspan="12"></td><td></td><td></td><td>68.46±1.48</td><td>60.96±1.62</td><td>68.31±1.40</td></tr><tr><td></td><td>0.5 0.6</td><td>70.05±2.54</td><td>63.06±1.26</td><td>69.90±2.57</td></tr><tr><td></td><td></td><td>69.57±1.07</td><td>61.25±1.96</td><td>69.36±1.06</td></tr><tr><td>0.3</td><td>0.7</td><td>68.99±2.34</td><td>61.61±2.17</td><td>68.81±2.27</td></tr><tr><td></td><td>0.8</td><td>71.21±0.48</td><td>63.08±0.82</td><td>70.99±0.57</td></tr><tr><td>1</td><td>0.9</td><td>71.26±1.47</td><td>62.33±0.64</td><td>71.03±1.56</td></tr><tr><td></td><td>0.2</td><td>69.00±0.41</td><td>61.38±0.92</td><td>68.69±0.31</td></tr><tr><td rowspan="14"></td><td></td><td></td><td>70.19±1.97</td><td>61.39±2.06</td><td>69.81±1.60</td></tr><tr><td></td><td>0.3</td><td>73.72±0.83</td><td>62.07±0.84</td><td>70.18±0.09</td></tr><tr><td></td><td>0.4</td><td>71.60±2.30</td><td>61.11±2.00</td><td>69.15±1.08</td></tr><tr><td></td><td>0.5</td><td>74.18±0.37</td><td>63.32±0.98</td><td>71.08±2.04</td></tr><tr><td>0.1</td><td>0.6</td><td>74.90±0.40</td><td>62.35±2.31</td><td>71.58±0.79</td></tr><tr><td></td><td>0.7</td><td>74.52±1.10</td><td>62.59±2.64</td><td>70.90±2.30</td></tr><tr><td></td><td>0.8</td><td>75.27±1.21</td><td>62.00±1.98</td><td>71.27±1.64</td></tr><tr><td></td><td>0.9</td><td>74.61±0.91</td><td>63.47±1.60</td><td>70.49±0.95</td></tr><tr><td></td><td>1.0</td><td>76.03±0.64</td><td>63.63±1.01</td><td></td></tr><tr><td rowspan="12">0.15</td><td></td><td></td><td></td><td></td><td>71.42±1.11</td></tr><tr><td></td><td>0.3 0.4</td><td>72.59±1.44 71.30±3.42</td><td>61.81±1.03</td><td>72.02±1.30</td></tr><tr><td></td><td></td><td></td><td>63.15±0.51</td><td>70.92±2.83</td></tr><tr><td></td><td>0.5</td><td>69.89±1.95</td><td>60.60±0.95</td><td>68.87±2.56</td></tr><tr><td>0.2</td><td>0.6</td><td>72.34±0.89</td><td>62.18±1.31</td><td>71.15±0.94</td></tr><tr><td></td><td>0.7</td><td>72.70±1.11</td><td>62.50±1.18</td><td>71.49±1.21</td></tr><tr><td></td><td>0.8</td><td>72.42±1.50</td><td>61.85±0.83</td><td>71.04±1.68</td></tr><tr><td></td><td>0.9</td><td>71.18±0.71</td><td>61.81±1.29</td><td>70.09±0.54</td></tr><tr><td></td><td>1.0 0.4</td><td>73.52±0.65</td><td>64.19±0.86</td><td>72.56±0.52</td></tr><tr><td rowspan="8"></td><td></td><td>70.32±1.39</td><td>62.39±2.00</td><td>70.13±1.33</td></tr><tr><td>0.5</td><td>71.60±1.53</td><td>62.67±2.08</td><td>71.40±1.54</td></tr><tr><td>0.6</td><td>70.36±1.82</td><td>62.28±2.28</td><td>70.13±2.03</td></tr><tr><td>0.7 0.3</td><td>69.79±1.93</td><td>61.13±1.37</td><td>69.65±1.82</td></tr><tr><td>0.8</td><td>69.85±0.95</td><td>60.69±1.63</td><td>69.78±0.60</td></tr><tr><td>0.9</td><td>71.32±1.68</td><td>61.79±1.41</td><td>71.03±1.61</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>1.0</td><td>71.39±0.49</td><td>62.35±0.88</td><td>71.11±0.55</td></tr></table>
355
+
356
+ Table S4: The hyperparameters used for each of the experimental settings for CLS-ER.
357
+
358
+ <table><tr><td>Dataset</td><td>Buffer</td><td>lr</td><td>Epochs</td><td>Batch Size</td><td>Memory Batch Size</td><td>入</td><td>αs</td><td>αp</td><td>rs</td><td>rp</td></tr><tr><td rowspan="3">S-MNIST</td><td>200</td><td>0.03</td><td>1</td><td>10</td><td>128</td><td>2.0</td><td>0.99</td><td>0.99</td><td>0.9</td><td>1.0</td></tr><tr><td>500</td><td>0.1</td><td>1</td><td>10</td><td>32</td><td>2.0</td><td>0.99</td><td>0.99</td><td>0.9</td><td>1.0</td></tr><tr><td>5120</td><td>0.1</td><td>1</td><td>10</td><td>32</td><td>2.0</td><td>0.99</td><td>0.99</td><td>0.8</td><td>1.0</td></tr><tr><td rowspan="3">S-CIFAR-10</td><td>200</td><td>0.1</td><td>50</td><td>32</td><td>32</td><td>0.15</td><td>0.999</td><td>0.999</td><td>0.1</td><td>0.3</td></tr><tr><td>500</td><td>0.1</td><td>50</td><td>32</td><td>32</td><td>0.15</td><td>0.999</td><td>0.999</td><td>0.1</td><td>0.9</td></tr><tr><td>5120</td><td>0.1</td><td>50</td><td>32</td><td>32</td><td>0.15</td><td>0.999</td><td>0.999</td><td>0.8</td><td>1.0</td></tr><tr><td rowspan="3">S-Tiny-ImageNet</td><td>200</td><td>0.05</td><td>50</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.999</td><td>0.04</td><td>0.08</td></tr><tr><td>500</td><td>0.05</td><td>50</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.999</td><td>0.05</td><td>0.08</td></tr><tr><td>5120</td><td>0.05</td><td>50</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.999</td><td>0.07</td><td>0.08</td></tr><tr><td rowspan="3">R-MNIST</td><td>200</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>0.75</td><td>0.999</td><td>0.99</td><td>1.0</td><td>1.0</td></tr><tr><td>500</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>0.75</td><td>0.999</td><td>0.99</td><td>1.0</td><td>1.0</td></tr><tr><td>5120</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>0.75</td><td>0.999</td><td>0.99</td><td>1.0</td><td>1.0</td></tr><tr><td rowspan="3">P-MNIST</td><td>200</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>1.0</td><td>0.99</td><td>0.99</td><td>0.8</td><td>1.0</td></tr><tr><td>500</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>1.0</td><td>0.99</td><td>0.99</td><td>0.8</td><td>1.0</td></tr><tr><td>5120</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>1.0</td><td>0.99</td><td>0.99</td><td>0.9</td><td>1.0</td></tr><tr><td rowspan="3">MNIST-360</td><td>200</td><td>0.2</td><td>1</td><td>16</td><td>16</td><td>0.75</td><td>0.999</td><td>0.99</td><td>1.0</td><td>1.0</td></tr><tr><td>500</td><td>0.2</td><td>1</td><td>16</td><td>32</td><td>1.25</td><td>0.99</td><td>0.99</td><td>0.9</td><td>1.0</td></tr><tr><td>1000</td><td>0.2</td><td>1</td><td>16</td><td>128</td><td>0.75</td><td>0.99</td><td>0.99</td><td>0.9</td><td>1.0</td></tr><tr><td rowspan="3">GCIL-CIFAR-100</td><td>200</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.999</td><td>0.6</td><td>0.7</td></tr><tr><td>500</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.999</td><td>0.6</td><td>0.7</td></tr><tr><td>1000</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.999</td><td>0.6</td><td>0.8</td></tr></table>
359
+
360
+ Table S5: The hyperparameters used for $\mathrm { D E R + + }$ on GCIL-CIFAR-100 experiments. CLS-ER uses the same hyperparameters for both Uniform and Longtail settings (Table S4).
361
+
362
+ <table><tr><td>Distribution</td><td>Buffer</td><td>lr</td><td>Epochs</td><td>Batch Size</td><td>Memory Batch Size</td><td>a</td><td>B</td></tr><tr><td rowspan="3">Uniform</td><td>200</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.2</td><td>0.5</td></tr><tr><td>500</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.2</td><td>0.6</td></tr><tr><td>1000</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.3</td><td>0.6</td></tr><tr><td rowspan="3">Longtail</td><td>200</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.2</td><td>0.6</td></tr><tr><td>500</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.2</td><td>0.8</td></tr><tr><td>1000</td><td>0.1</td><td>100</td><td>32</td><td>32</td><td>0.3</td><td>0.9</td></tr></table>
363
+
364
+ <table><tr><td>Dataset</td><td>Buffer</td><td>lr</td><td>Epochs</td><td>Batch Size</td><td>Memory Batch Size</td><td>入</td><td>a</td><td>r</td></tr><tr><td rowspan="3"> S-MNIST</td><td>200</td><td>0.03</td><td>1</td><td>10</td><td>128</td><td>2.0</td><td>0.99</td><td>1.0</td></tr><tr><td>500</td><td>0.1</td><td>1</td><td>10</td><td>32</td><td>2.0</td><td>0.99</td><td>1.0</td></tr><tr><td>5120</td><td>0.1</td><td>1</td><td>10</td><td>32</td><td>2.0</td><td>0.99</td><td>1.0</td></tr><tr><td rowspan="3">S-CIFAR-10</td><td>200</td><td>0.1</td><td>50</td><td>32</td><td>32</td><td>0.15</td><td>0.999</td><td>0.2</td></tr><tr><td>500</td><td>0.1</td><td>50</td><td>32</td><td>32</td><td>0.15</td><td>0.999</td><td>0.5</td></tr><tr><td>5120</td><td>0.1</td><td>50</td><td>32</td><td>32</td><td>0.15</td><td>0.999</td><td>0.8</td></tr><tr><td rowspan="3">S-Tiny-ImageNet</td><td>200</td><td>0.05</td><td>50</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.06</td></tr><tr><td>500</td><td>0.05</td><td>50</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.08</td></tr><tr><td>5120</td><td>0.05</td><td>50</td><td>32</td><td>32</td><td>0.1</td><td>0.999</td><td>0.08</td></tr><tr><td rowspan="3">R-MNIST</td><td>200</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>0.75</td><td>0.999</td><td>1.0</td></tr><tr><td>500</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>0.75</td><td>0.999</td><td>1.0</td></tr><tr><td>5120</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>0.75</td><td>0.999</td><td>1.0</td></tr><tr><td rowspan="3">P-MNIST</td><td>200</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>1.0</td><td>0.99</td><td>0.9</td></tr><tr><td>500</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>1.0</td><td>0.99</td><td>1.0</td></tr><tr><td>5120</td><td>0.2</td><td>1</td><td>128</td><td>128</td><td>1.0</td><td>0.99</td><td>0.9</td></tr></table>
365
+
366
+ Table S6: The hyperparameters used for each of the experimental settings for Mean-ER.
md/dev/uy602F8cTrh/uy602F8cTrh.md ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CAUSALDYNA: IMPROVING GENERALIZATION OF DYNA-STYLE REINFORCEMENT LEARNING VIA COUNTERFACTUAL-BASED DATA AUGMENTATION
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Deep reinforcement learning agents trained in real-world environments with a limited diversity of object properties to learn manipulation tasks tend to suffer overfitting and fail to generalize to unseen testing environments. To improve the agents’ ability to generalize to object properties rarely seen or unseen, we propose a dataefficient reinforcement learning algorithm, CausalDyna, that exploits structural causal models (SCMs) to model the state dynamics. The learned SCM enables us to counterfactually reason what would have happened had the object had a different property value. This can help remedy limitations of real-world environments or avoid risky exploration of robots (e.g., heavy objects may damage the robot). We evaluate our algorithm in the CausalWorld robotic-manipulation environment. When augmented with counterfactual data, our CausalDyna outperforms state-ofthe-art model-based algorithm, MBPO and model-free algorithm, SAC in both sample efficiency by up to $17 \%$ and generalization by up to $30 \%$ . Code will be made publicly available.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Classical model-free reinforcement learning approaches require a massive amount of data collected in the environment to work, which slows down its success in tasks where data collection is timeconsuming or costly, like robot manipulation. Model-based reinforcement learning (MBRL) methods alleviate this issue by maintaining a world model that simulates the real environment. The world model can serve as a surrogate of the real environment for the agent to interact with to reduce the amount of the required time-consuming interaction in the real environment. MBRL methods (Kaelbling et al., 1996; Wang et al., 2019; Janner et al., 2019) learn from model rollouts of previously observed states. Recently, CTRL (Lu et al., 2020) takes a structural causal model (SCM) approach that can generate samples counterfactually had a different action had been taken for a state previously observed. However, these methods are limited for robotic manipulation tasks since the environment is often the key limiting factor. In this paper, we perform counterfactual reasoning on the object properties. For example, when the task manipulates objects with different masses, the real environment may not have a uniform distribution of object masses. Furthermore, to avoid damaging the robot, certain exploration of the gripper torque may be limited during training.
12
+
13
+ To this end, we propose a Dyna-style MBRL method, CausalDyna in robotics that improves the policy performance by counterfactual reasoning of physics properties of objects and enriching the diversity of the generated rollouts. We leverage the structural causal model (SCM) to model the state dynamics. CausalDyna can be applied to generate episodes with unseen or rarely seen objects to improve the sample efficiency and generalization of the policy.
14
+
15
+ Our contributions are summarized as follows.
16
+
17
+ • We introduce a novel Dyna-style causal reinforcement learning algorithm, dubbed as CausalDyna that learns from counterfactually generated episodes with intervened object property values. • We compare with state-of-the-art model based reinforcement learning algorithm, MBPO and model free algorithm, SAC on the CausalWorld environment. Experimental results show that CausalDyna outperforms MBPO and SAC on sample efficiency by up to $17 \%$ and generalization by up to $30 \%$ when manipulating objects with unseen or rarely seen properties.
18
+
19
+ ![](images/1fe3984bb406fc8def7ea8b40a25b5f4092376e757249f210522ee2712f02696.jpg)
20
+ Figure 1: In classical Dyna-style methods, the world model generates episodes starting from a real environment state. Then, our robot can practice in the world model and learn how to manipulate the original object. To improve the generalization of the learned policy, we further modified the object property in the state. So the robot has the chance to play with objects with more diverse properties.
21
+
22
+ # 2 RELATED WORK
23
+
24
+ Causal Inference in Reinforcement Learning There is an increasing interest in causal inference in the field of reinforcement learning. Counterfactually-Guided Policy Search (CF-GPS) (Buesing et al., 2018) assumes that the real transition, observation, and reward functions are all known. They show that any partially observable Markov decision process (POMDP) can be represented as a structural causal model (SCM). Therefore, counterfactual inference can be applied to improve the offpolicy evaluation and policy-guided search. CounTerfactual Reinforcement Learning (CTRL) (Lu et al., 2020) leverages bidirectional conditional GAN to model the environment dynamic for data augmentation. The model takes a noise vector as input besides the state and action to model the randomness of the environment. Before generating counterfactual data given alternative actions, they first infer the value of this noise vector. Then, the inferred noise is used to generate predictions with new actions. Causal Partial Models (CPM) (Rezende et al., 2020) studies the causal incorrectness of world models that don’t condition on the full observation. To fix this issue, CPM introduces a backdoor variable that helps the rollout of the model to be causally correct. We propose an SCM framework to model the physics properties of objects across the temporal dimension. In addition, we show that generating episodes with counterfactual object properties helps improve the generalization of the learned policy.
25
+
26
+ Model-Based Reinforcement Learning Model-based Reinforcement Learning (MBRL) approaches have shown a potential to improve the sample efficiency by a large margin compared to classical model-free approaches (Kaelbling et al., 1996; Wang et al., 2019). Autoencoder-based algorithms like World Models (Ha & Schmidhuber, 2018) and Dreamer (Hafner et al., 2019; 2020) use the world model to better represent the visual observation and faster the policy training. Policy Search with Backpropagation algorithms like PILCO (Deisenroth & Rasmussen, 2011; Deisenroth et al., 2013; Kamthe & Deisenroth, 2018) and GPS (Levine & Koltun, 2013; Levine & Abbeel, 2014; Montgomery & Levine, 2016) train the policy by maximizing the simulated return of the policy in the world model. Because the world model is differentiable, the policy can be directly trained by gradient descent. Shooting algorithms like PETS-RS (Chua et al., 2018) and MB-MF (Nagabandi et al., 2018) alleviate the receding horizon problem in model predictive control (MPC). Recent works include Ross & Bagnell (2012), MOPO, (Yu et al., 2020) and Morel (Kidambi et al., 2020) show that MBRL can work well in the offline RL setting. Unlike the traditional MBRL that approximates the local transition function, $L ^ { 3 } P$ (Zhang et al., 2021) builds the world model as a graph of states for better reasoning ability. Dyna-style algorithms (Sutton, 1990; 1991a;b) use the learned world model to roll out simulated episodes to reduce the demand for real data for policy training. As a recent development of Dyna-style algorithms, ME-TRPO (Kurutach et al., 2018) uses an ensemble of world models to catch the epistemic uncertainty; MB-MPO (Clavera et al., 2018) viewed each model in the ensemble as a task and meta-learn a policy that adapts quickly to handle the model-bias issue; MBPO (Janner et al., 2019) rolls out short episodes branched from real data to improve the generation quality. Our method follows the Dyna-style framework and targets designing and using a causal world model to generate better and more diverse rollouts in robotic environments.
27
+
28
+ ![](images/3df83d14df549a7acc4d51cb383977289414fcb2422ffaf5d756792bd5daca98.jpg)
29
+ Figure 2: The structure causal model of a robot environment. The time-invariant property is modeled as a node $_ { \mathbf { \nabla } } \mathbf { m } _ { \mathbf { \nabla } }$ across the temporal dimension that affects all the causal mechanisms. $s _ { - m , t }$ and $\mathbf { } \mathbf { a } _ { t }$ denotes the time-variant state and the action at the step $t$ , respectively.
30
+
31
+ # 3 BACKGROUND
32
+
33
+ # 3.1 STRUCTURAL CAUSAL MODEL
34
+
35
+ Structural Causal Model (SCM) is a widely used framework to describe the causal mechanism of a system. Let’s denote $\mathbb { X } = \{ \mathbf { x } _ { 1 } , . . . , \mathbf { x } _ { N } \}$ as the set of $N$ variables in a system. Knowing their causal relationships allows us to build a directed acyclic causal graph to describe this system. Each node represents a variable, which is directly caused by its parent nodes. In this way, a node ${ \bf x } _ { n }$ can be modeled as the following function:
36
+
37
+ $$
38
+ { \bf x } _ { n } = f _ { i } ( P a _ { 0 \mathrm { b s } } ( { \bf x } _ { n } ) , { \bf u } _ { n } )
39
+ $$
40
+
41
+ Here, $P a _ { \mathrm { o b s } } ( \mathbf { x } _ { n } )$ denotes the observed parent nodes of ${ \bf x } _ { n }$ . $\mathbf { u } _ { n }$ is a noise that represents the effect of omitted factors. This function is also called a causal mechanism. SCM is the set of these causal mechanisms that describes the whole system. SCM defines a joint distribution of the variables $p ( \mathbf { x } _ { 1 } , . . . , \mathbf { x } _ { N } )$ following the causal Markov assumption: given its direct causes, each variable ${ \bf x } _ { n }$ is independent of other indirect causal variables.
42
+
43
+ # 3.2 DYNA-STYLE MODEL-BASED REINFORCEMENT LEARNING
44
+
45
+ Dyna-style model-based reinforcement learning uses the world model to roll out simulated episodes, which can be viewed as data augmentation. The training of Dyna-style MBRL is composed of three steps: First, the agent interacts with the real environment and collects real data to train the world model. Then, this world model is used as a simulator of the real environment for the agent to interact and collect simulated data. After that, the agent can be trained together with the real and the simulated data using classical model-free reinforcement learning algorithms. These three steps are executed repeatedly until the training converges. In case we apply Dyna-Style algorithm on RL algorithms with experience-replay buffers and would like to collect whole simulated episodes, as the world model is trained to only approximate the transition of the environment $p ( \pmb { s } _ { t + 1 } | \pmb { s } _ { t } , \pmb { a } _ { t } )$ , we need an initial state to start the simulated episodes. A usual way to solve it is using the first state or a randomly sampled state $\mathbf { \Delta } _ { \mathbf { \mathcal { S } } _ { t } }$ from the collected real episodes as the start point of the simulated episodes. As the real episode already contains the future of $\mathbf { \boldsymbol { s } } _ { t }$ under the original action sequence $\{ a _ { t } , \pmb { a } _ { t + 1 } , . . . \}$ executed in this episode, generating new simulated episodes starting from $\mathbf { } _ \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf { } \mathbf \mathbf \mathbf \mathbf \mathbf \mathbf { }$ under different action sequences can be viewed as answering a counterfactual “what if” question: What would happen if the agent behave differently this time instead of doing $\{ a _ { t } , a _ { t + 1 } , \ldots \} \colon$ The world model gives the agent a chance to figure out the answer without interacting in the real environment, and helps the agent learn faster.
46
+
47
+ Data: Rollout length $K$ , Real experience buffer $\mathbb { D } _ { r }$ , Policy $p _ { \pi }$ , World model $p _ { W M }$ , Counterfactual property space $M$ , Empty episode buffer $\mathbb { B }$ Result: $\mathbb { B }$ 1 Sample a state $\pmb { s } = [ \pmb { s } _ { - m } ; m ]$ from the real experience buffer $\mathbb { D } _ { r }$ , $\mathbb { B }$ .append(s) 2 Sample a counterfactual property value $_ { \mathbf { \Omega } ^ { m } C F }$ from $M$ , set $\tilde { \pmb { s } } = \left[ \pmb { s } _ { - m } ; m _ { C F } \right]$ 3 for $K$ steps do 4 $\tilde { \mathbf { a } } \sim p _ { \pi } ( \mathbf { a } | \tilde { s } )$ , $\tilde { \pmb { s } } ^ { \prime } \sim p _ { W M } ( \pmb { s } ^ { \prime } | \tilde { \pmb { s } } , \tilde { \pmb { a } } )$ 5 $\mathbb { B }$ .append $( \tilde { \pmb { a } } , \tilde { \pmb { s } } ^ { \prime } )$ , $\tilde { s } \gets \tilde { s } ^ { \prime }$ 6 end
48
+
49
+ # 4 METHOD
50
+
51
+ # 4.1 STRUCTURE CAUSAL MODEL OF A ROBOT ENVIRONMENT
52
+
53
+ Let’s consider an environment where a robot needs to manipulate an object. We can describe this environment using different states. Many of these states are changing over time, including the object position and the end-effect position. It is important to model them as they directly contain the dynamic information of the environment. Some other states are time-invariant, like the object mass or the floor friction coefficient. Although their values are fixed, they determine the environment dynamics and affect how other time-variant states change. Let’s denote the total state at step $t$ as $\mathbf { \boldsymbol { s } } _ { t }$ . $\pmb { s } _ { t } = [ \pmb { s } _ { - m , t } ; \pmb { m } ]$ is the concatenation of the time-variant state $s _ { - m , t }$ at step $t$ and the object timeinvariant property $_ { m }$ . The motor torque to execute at step $t$ is denoted as $\mathbf { } \mathbf { a } _ { t }$ . As shown in Fig.2, we can build a structural causal model (SCM) to describe this environment. The time-invariant property $_ { m }$ is modeled as a fixed node across the temporal dimension, which affects all the causal mechanisms.
54
+
55
+ # 4.2 COUNTERFACTUAL PROPERTY GENERATION
56
+
57
+ Policy generalization ability is essential as the testing environment of the policy is not always the same as the training environment. For example, when learning to lift an object, the robot might only interact with objects whose masses are in a suitable range. Lifting frequently a too-heavy object might reduce its service life, and most reinforcement learning algorithms need a large amount of interaction data to work. However, knowing how to lift a heavy object is still desirable when deploying the robot. A typical Dyna-style method generates simulated rollouts branching from a starting state seen in previous real episodes. If the world model takes physics properties as input, it is possible to go a step further and intervene in these properties. For example, we could modify the mass of an object in the world model to make it heavier. So the agent can learn to manipulate them in the world model as much as we want without harming its service life. Inspired by this, we design a simple generation strategy to enrich the simulated rollouts by modifying the original object’s property to improve the policy generalization. Concretely, instead of taking a starting state $\pmb { s } _ { t } ~ = ~ [ \pmb { s } _ { - m , t } ; \pmb { m } ]$ sampled from real episodes as it is like most of the Dyna-style methods, we replace the object property $_ { m }$ by a desired counterfactual value $_ { \mathbf { \Omega } ^ { m } C F }$ sampled from a predefined counterfactual property space $M$ before rolling out the simulated episodes. We name this type of episodes generation as counterfactual property generation, illustrate it in Fig.1 and show the process in Alg.1.
58
+
59
+ # 4.3 TRAINING PROCEDURE
60
+
61
+ The training of our model follows the Dyna-style model-based reinforcement learning framework. The world model is an additional imperfect substitute for the real environment for the policy to interact with. The policy is still trained using the traditional model-free reinforcement learning approach, but the data for training is a mixture of the data from the real environment data and that from the world model. During the training procedure, we maintain two replay buffers. The real experience replay buffer $\mathbb { D } _ { r }$ stores the interaction data from the real environment. The world model is trained using the real experience replay buffer only. The simulated episodes from the world model
62
+
63
+ # Algorithm 2: Training Procedure
64
+
65
+ Data: Policy $p _ { \pi }$ , World model $p _ { W M }$ , Empty real experience replay buffer $\mathbb { D } _ { r }$ , Empty episode buffer $\mathbb { B }$ , Rollout length $K$ , Counterfactual property space $M$ , Counterfactual generation ratio $\alpha$ Result: Trained Policy $p _ { \pi }$ 1 Prefill $\mathbb { D } _ { r }$ by executing the untrained policy $p _ { \pi }$ in the environment 2 while Not Converge do 3 Split $\mathbb { D } _ { r }$ into a training set $\mathbb { D } _ { r , t r a i n }$ and holdout set $\mathbb { D } _ { r , h o l d o u t }$ randomly 4 Train the world model $p _ { W M }$ on $\mathbb { D } _ { r , t r a i n }$ until converge on $\mathbb { D } _ { r , h o l d o u t }$ 5 Empty the simulated experience buffer $\mathbb { D } _ { s }$ 6 Generate $\alpha \% \cdot N _ { f }$ simulated episodes with $K$ steps by counterfactual property generation as Alg.1 to $\mathbb { D } _ { s }$ 7 Generate $( 1 - \alpha \% ) \cdot N _ { f }$ simulated episodes with $K$ steps with original property to $\mathbb { D } _ { s }$ 8 for $E$ steps do 9 Collect a step of data in the real environment; add it to $\mathbb { D } _ { r }$ 10 Update policy parameters via SAC on the combination of $\mathbb { D } _ { r }$ and $\mathbb { D } _ { s }$ for $G$ steps 11 end 12 end
66
+
67
+ are stored in the simulated experience buffer $\mathbb { D } _ { s }$ , which is used to train the policy net and the real experience replay buffer $\mathbb { D } _ { r }$ . The whole training procedure is shown in Alg.2. The policy is trained via soft actor-critic (SAC) (Haarnoja et al., 2018) using the data from both the real experience buffer $\mathbb { D } _ { r }$ and the simulated buffer $\mathbb { D } _ { s }$ . As we generate the simulated episodes with counterfactual property and we following the Dyna-style MBRL framework, we name our model CausalDyna.
68
+
69
+ World Model Training Each time the world model is trained, the real experience replay buffer $\mathbb { D } _ { r }$ is split into a training set, and a holdout set randomly. The world model is trained to predict the next state $\mathbf { } s _ { t + 1 }$ by maximizing the log-likelihood given the current state $\mathbf { \boldsymbol { s } } _ { t }$ and the action $\mathbf { } \mathbf { a } _ { t }$ in the training set until converging measured by the holdout set.
70
+
71
+ Augment Data Collection We adopt the generation strategy of model-based policy optimization (MBPO) (Janner et al., 2019) to roll out the world model. The simulated episodes start from a real state randomly sampled from the real experience replay buffer $\mathbb { D } _ { r }$ and are rolled out for $K$ steps. We generate two types of simulated episodes: $\alpha \%$ of the rollouts are generated with counterfactual property generation, where we intervene the object property as described in Alg.1 to generate episodes with different objects. The remaining $( 1 - \alpha \% )$ episodes are generated using the original property. Each time $N _ { f }$ simulated episodes are generated in total. Note that each time we collect the simulated episodes, all the previous data in the simulated experience buffer $\mathbb { D } _ { s }$ is discarded as the world model generated them a few training steps before and are not ‘fresh’ anymore.
72
+
73
+ # 5 EXPERIMENTS
74
+
75
+ # 5.1 BENCHMARK
76
+
77
+ We evaluate our method CausalDyna on a recently proposed robotic benchmark CausalWorld (Ahmed et al., 2020). CausalWorld is designed for causal structure and transfer learning in a robotic manipulation environment. The robot in CausalWorld is a 3-finger gripper. Each finger has three joints. The mission of the robot is to move objects to specified target locations. The observations of the CausalWorld we use includes the time stamp $t$ , the robot state $\scriptstyle { \pmb { s } } _ { r }$ , the object state $\scriptstyle { \pmb { s } } _ { o }$ , the timeinvariant property $_ { \mathbf { \nabla } } \mathbf { m } _ { \mathbf { \nabla } }$ , and the goal information $s _ { g }$ . The robot state $\scriptstyle { \pmb { s } } _ { r }$ is consists of 9 joint positions, 9 joint velocities, and the Cartesian coordinates of the three end-effectors (fingertips). The object state $\scriptstyle { \pmb { s } } _ { o }$ contains the Cartesian coordinate, the velocity, the quaternion orientation, and the object’s angular velocity. The property $_ { \mathbf { \nabla } } \mathbf { m }$ includes the object mass and the friction coefficient. The goal information $s _ { g }$ contains the target location and orientation of the object.
78
+
79
+ Evaluated Models We evaluate three approaches in our experiments: Model-Based Policy Optimization (MBPO) (Janner et al., 2019), one of the state-of-the-art Dyna style methods with high sample efficiency, Soft Actor-Critic (SAC) (Haarnoja et al., 2018), a widely-used model-free approach, and our method CausalDyna.
80
+
81
+ Task Settings and Performance Metrics We define three settings to evaluate our method: Picking Mass, Pushing Mass, and Pushing Friction. In Picking Mass, the robot needs to pick up an object to a target location in the air. The object mass is different over different episodes. In contrast, the target locations in Pushing Mass and Pushing Friction are on the ground. The object mass and the floor friction in Pushing Mass and Pushing Friction are different over different episodes, respectively. We use the default reward signals of CausalWorld to train our method. The reward provides rich signals to encourage the robot to get close to the object and move it toward the target. The reward is a weighted sum over the reduction of the distance between the end effectors and the object and the distance between the object and the target. We evaluated our approach and competing methods using fractional success rate (FSR), which is defined as the overlapping ratio between the object and the target. We compute the FSR of a given episode as the average FSR over the last 20 steps. To quantify the sample efficiency in our benchmark, we propose a metric named Area-Under-theCurve Ratio (AUCRatio). Given a learning curve $\mathrm { F S R } = f _ { l e a r n } ( n _ { s t e p } )$ where $n _ { s t e p }$ denotes the number of the environment steps collected already, AUCRatio until step $N _ { s t e p }$ is computed as Eq.2. As $0 \leq \mathrm { F S R } \leq 1$ , a policy with AUCRatio $= 1$ means it can perform the task perfectly without training.
82
+
83
+ $$
84
+ \mathrm { A U C R a t i o } = \frac { 1 } { N _ { s t e p } } \sum _ { n _ { s t e p } = 1 } ^ { N _ { s t e p } } f _ { l e a r n } ( n _ { s t e p } )
85
+ $$
86
+
87
+ # 5.2 EXPERIMENTS WITH OUT-OF-DISTRIBUTION PROPERTY
88
+
89
+ An intelligent robot might encounter various objects when deploying. If the robot need to manipulate an object unseen during training, its performance might be reduced. This can be viewed as an outof-distribution problem: how to generalize well to the object not in the training distribution? The counterfactual property generation approach has the potential to increase the performance on objects with unseen property values if we roll out simulated episodes with object property that is out of the training range. To verify our assumption, we create an experiment to study whether our method helps improve the agent performance on objects whose property value is not encountered during training. In detail, in our Picking Mass and Pushing Mass setting, the robot is trained with objects of which the mass is uniformly distributed from $0 . 0 1 5 \mathrm { k g }$ to $0 . 0 4 5 \mathrm { k g }$ . But during the testing stage, the robot is asked to interact with heavier objects up to $0 . 1 \mathrm { k g }$ . In Pushing Friction setting, the friction coefficient is from 0.3 to 0.6 during training. And the robot is deployed to also handle friction from 0.6 to 0.8.
90
+
91
+ As we target the performance of the objects with unseen property value during training, we use our method here to imagine these objects. In detail, when the counterfactual property generation is applied, we replace the original property value with a counterfactual value uniformly sampled from the unseen test range. In this way, our agent can practice manipulating these unseen objects in the world model in advance.
92
+
93
+ Hyperparameters The length of the simulated episodes $K$ is 10. A bootstrap ensemble of world models is used following Kurutach et al. (2018) for both MBPO and our method. The ensemble size is 7. For each generation step, we randomly pick one model from the ensemble to predict the next state. When training the policy, $20 \%$ of the training data are from the real experience replay buffer. The remaining are from the simulated episodes. In our CausalDyna, $20 \%$ of the simulated episodes are generated by counterfactual property generation ( $\alpha$ in Alg.2). We use Adam (Kingma & Ba, 2014) as the training optimizer for all experiments. All the models we evaluated are trained for 1.2 million steps in Picking Mass and 600 thousand steps in Pushing Mass and Pushing Friction. Each model in this experiment has 5 training cases. The model architecture and the remaining hyperparameters can be found in Appx.A and Appx.B.
94
+
95
+ ![](images/a481eb6000e93b6057184f5d9a27951b69a655539f29f562b5fa64927b2da3b8.jpg)
96
+ Figure 3: Experimental results of counterfactual property generation in the out-of-distribution experiment. The vertical black line shows the boundary between the seen and unseen property values during training. The left part is the seen region. Counterfactually generating the simulated episodes with unseen property value helps alleviate the performance drop when evaluating unseen property during training. Numbers in the legend denote the average performance in the unseen value range. Each curve contains 5 training cases.
97
+
98
+ ![](images/11a2ef93d4c191d75cc898cafa5d7ae0e3484c9484b154b66de8280d5ccf474d.jpg)
99
+ Figure 4: The learning curve of the evaluated models on the training property range in the outof-distribution experiments. CausalDyna converges as fast as MBPO, although it generates $20 \%$ less simulated episodes in the training property range. Numbers in the legend denote the average AUCRatio.
100
+
101
+ Performance The experimental results are shown in Fig.3. The vertical black line denotes the boundary between the seen and unseen values during training. The left part is the seen region. In Picking Mass and Pushing Mass, the performance of all the methods declines when the object mass is out of the training range. Moreover, the performance reduction is more significant when the tested object mass is farther away from the training range. Our CausalDyna alleviates this performance reduction in the unseen range by a large margin compared to MBPO. In Picking Mass, CausalDyna improves the unseen FSR by $24 \%$ from 0.37 to 0.47. For Picking Mass it is $27 \%$ from 0.7 to 0.87. This indicates that hallucinating episodes with unseen objects during training helps improve the generalization ability of the policy. In Pushing Friction, CausalDyna achieves similar performance as MBPO since the unseen range performance reduction here is not obvious. As SAC is less sample efficiency than both model-based methods, SAC cannot achieve compatible results given the same training data as MBPO and CausalDyna. Note that in Picking Mass, although our CausalDyna performs better than MBPO in the out-of-distribution range, the absolute performance is not high when the object is too heavy (like $0 . 1 \mathrm { k g } { \cdot }$ . This might be caused by the reduced performance of the world model when counterfactually generating episodes with unseen objects. A better world model design that can better understand the physics and reason the future more causally might help alleviate this issue when combined with our method. We leave this for future research.
102
+
103
+ Sample Efficiency We show the learning curve of MBPO, CausalDyna, and SAC of this experiment in Fig.4. Although we augment $20 \%$ fewer simulated episodes in the original property range compared to MBPO, CausalDyna converges as fast as MBPO in the original training range. Results indicate that our method improves the out-of-distribution performance without sacrificing the sample efficiency. The model-free SAC training is much slower than MBPO and CausalDyna, as SAC doesn’t have simulated data to train on.
104
+
105
+ ![](images/bbdef68000ab8cd1e4a128091c7a34051ce89c079e106739e4e196900aff0ffe.jpg)
106
+ Figure 5: Experimental results of counterfactual property generation in the unbalanced distribution experiment. When counterfactually generating episodes where the object is less encountered during training, CausalDyna helps improve the policy performance on both the objects with head values and tail values. For each property, the median value occurs $90 \%$ of the time in the environment, and the rest two values share the remaining $10 \%$ equally. Numbers in the legend denote the average performance over the tail values. Each model has 6 training cases.
107
+
108
+ # 5.3 EXPERIMENTS WITH UNBALANCED TRAINING DISTRIBUTION
109
+
110
+ In real environments like warehouses, the numbers of different wares are unequal, and a sorting robot might manipulate some objects less frequently. This can be described as an unbalanced training distribution. If the training distribution is heavily unbalanced and some objects are significantly less encountered than others during training, counterfactually generating episodes with such objects might help improve the policy performance on them. We create a simple heavily unbalanced training distribution consisting of 1 head property value and two tail property values to verify this assumption. The object property in $90 \%$ of the training episodes equals the head value. The two tail values share the remaining $10 \%$ , each value obtains $5 \%$ . Concretely, in Picking Mass and Pushing Mass, we have three different objects with mass values $0 . 0 0 2 \mathrm { k g }$ , $0 . 0 1 \mathrm { k g }$ , and $0 . 0 5 \mathrm { k g }$ , respectively. $90 \%$ of the time, the robot sees and manipulates the object with the median mass value of $0 . 0 1 \mathrm { k g }$ . The robot plays with the heavy $0 . 0 5 \mathrm { k g }$ object and the light $0 . 0 0 2 \mathrm { k g }$ object equally in the remaining time. For Pushing Friction, the three friction coefficients are 0.3, 0.55, and 0.8 that occur in $5 \%$ , $90 \%$ , and $5 \%$ of the time, respectively. In the testing stage, models need to perform well on all three property values.
111
+
112
+ As the objects with tail values occur less frequently in the training stage, CausalDyna in this experiment imagines what would happen if the given head object is the tail. Concretely, when CausalDyna generating simulated episodes, the property value of original objects are counterfactually modified to one of the tail property values randomly. Therefore, the agent can interact with the tail objects more in the world model to improve the tail performance.
113
+
114
+ Hyperparameter In CausalDyna, 2/3 of the simulated episodes are generated by counterfactual property generation $\alpha$ in Alg.2). All the models on all the 3 settings are trained for 600 thousand steps. Each model in this experiment has 6 training cases. The remaining hyperparameters are the same as in the previous experiment.
115
+
116
+ Performance As shown in Fig.5, the performance on the head property value $( 0 . 0 1 \mathrm { k g }$ for mass and 0.55 for friction) is better than the tail property values for all the methods in all the 3 settings. However, CausalDyna improves the performance on the tail property and shows the smallest performance difference between the head and the tail among the three models. For example, the performance gap between the head and the tail of CausalDyna in Picking Mass is about 0.1, much smaller than MBPO (0.2-0.3), and the tail performance is increased by $30 \%$ from 0.56 to 0.73. Besides, we notice that CausalDyna improves the policy performance on both objects that are less frequently seen during training and the head objects compared to MBPO. This might be because learning how to behave well in the tail cases helps the model better understand the environment dynamics and improves overall performance. In addition, the performance variance in Pushing Mass and Pushing Friction of CausalDyna is much lower than the other two methods, which suggests that the performance of CausalDyna is more consistent than other methods. With the same amount of training data as MBPO and CausalDyna, the model-free SAC’s performance is worse than the model-based MBPO and CausalDyna, which is the same as the out-of-distribution experiment.
117
+
118
+ ![](images/490a3b62cc5d0f90c54c32703b1219dd57954fbfe56ec43ac1a7fccf30587fb7.jpg)
119
+ Figure 6: Average policy performance at different environment steps. Our method CausalDyna, which counterfactually generating episodes where the object is less frequently encountered during training, reduces the required amount of environment steps and shows the best sample efficiency in the unbalanced training distribution experiment. Numbers in the legend denote the average AUCRatio. Each model has 6 training cases.
120
+
121
+ Sample Efficiency The learning curves of the evaluated models are shown in Fig.6. The fractional success rate is uniformly averaged over all the property values. CausalDyna shows a better sample efficiency and converges faster. In all three settings, CausalDyna requires about $1 0 0 \mathrm { k }$ fewer environment steps to converge compared to MBPO and increase the sample effiency by about $17 \%$ . This might be because CausalDyna has more simulated episodes with the tail property values to train the agent, which helps the agent understand the task better and adapt to all the property values faster.
122
+
123
+ # 6 CONCLUSION AND FUTURE WORK
124
+
125
+ In this paper, we focus on improving the generalization ability of model-based reinforcement learning in robotic environments. We propose a novel Dyna-style causal reinforcement learning algorithm named CausalDyna that rollouts episodes with intervened object properties. CausalDyna leverages the diversity of the simulated episodes augmented by the world model and improves the generalization of the policy when manipulating objects with property unseen or rarely seen during training. Experiments show that our method helps the robot generalize to objects with unseen property values better. In addition, when the training distribution is unbalanced, our method requires fewer environment steps to converge and performs better with rarely seen objects.
126
+
127
+ To our knowledge, we are the first to propose counterfactual reasoning on environment properties to improve the generalization of reinforcement learning. We believe this is a promising direction to solve many complex reinforcement learning tasks where the policy generalization ability is essential. When combined with model predictive control and counterfactual reasoning on actions, it is possible to further improve sample efficiency and generalization of RL algorithms. One limitation of our method is that the quality of our counterfactual episodes depends on how well our world model understands the environment. We plan to design a better world model that takes prior knowledge like simple physics laws into account. Finally, we have assumed that the properties in our environment are fully observable in our current work. We plan to investigate causal models with latent variables representing unobserved properties of the environment.
128
+
129
+ # REFERENCES
130
+
131
+ Ossama Ahmed, Frederik Trauble, Anirudh Goyal, Alexander Neitz, Yoshua Bengio, Bernhard ¨ Scholkopf, Manuel W ¨ uthrich, and Stefan Bauer. Causalworld: A robotic manipulation bench- ¨ mark for causal structure and transfer learning. arXiv preprint arXiv:2010.04296, 2020.
132
+
133
+ Lars Buesing, Theophane Weber, Yori Zwols, Sebastien Racaniere, Arthur Guez, Jean-Baptiste Lespiau, and Nicolas Heess. Woulda, coulda, shoulda: Counterfactually-guided policy search. arXiv preprint arXiv:1811.06272, 2018.
134
+
135
+ Kurtland Chua, Roberto Calandra, Rowan McAllister, and Sergey Levine. Deep reinforcement learning in a handful of trials using probabilistic dynamics models. arXiv preprint arXiv:1805.12114, 2018.
136
+
137
+ Ignasi Clavera, Jonas Rothfuss, John Schulman, Yasuhiro Fujita, Tamim Asfour, and Pieter Abbeel. Model-based reinforcement learning via meta-policy optimization. In Conference on Robot Learning, pp. 617–629. PMLR, 2018.
138
+
139
+ 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), pp. 465–472. Citeseer, 2011.
140
+
141
+ Marc Peter Deisenroth, Dieter Fox, and Carl Edward Rasmussen. Gaussian processes for dataefficient learning in robotics and control. IEEE transactions on pattern analysis and machine intelligence, 37(2):408–423, 2013.
142
+
143
+ David Ha and Jurgen Schmidhuber. World models. ¨ arXiv preprint arXiv:1803.10122, 2018.
144
+
145
+ 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.
146
+
147
+ Danijar Hafner, Timothy Lillicrap, Jimmy Ba, and Mohammad Norouzi. Dream to control: Learning behaviors by latent imagination. In International Conference on Learning Representations, 2019.
148
+
149
+ Danijar Hafner, Timothy Lillicrap, Mohammad Norouzi, and Jimmy Ba. Mastering atari with discrete world models. arXiv preprint arXiv:2010.02193, 2020.
150
+
151
+ Michael Janner, Justin Fu, Marvin Zhang, and Sergey Levine. When to trust your model: Modelbased policy optimization. arXiv preprint arXiv:1906.08253, 2019.
152
+
153
+ Leslie Pack Kaelbling, Michael L Littman, and Andrew W Moore. Reinforcement learning: A survey. Journal of artificial intelligence research, 4:237–285, 1996.
154
+
155
+ Sanket Kamthe and Marc Deisenroth. Data-efficient reinforcement learning with probabilistic model predictive control. In International conference on artificial intelligence and statistics, pp. 1701– 1710. PMLR, 2018.
156
+
157
+ Rahul Kidambi, Aravind Rajeswaran, Praneeth Netrapalli, and Thorsten Joachims. Morel: Modelbased offline reinforcement learning. arXiv preprint arXiv:2005.05951, 2020.
158
+
159
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
160
+
161
+ Thanard Kurutach, Ignasi Clavera, Yan Duan, Aviv Tamar, and Pieter Abbeel. Model-ensemble trust-region policy optimization. arXiv preprint arXiv:1802.10592, 2018.
162
+
163
+ Sergey Levine and Pieter Abbeel. Learning neural network policies with guided policy search under unknown dynamics. In NIPS, volume 27, pp. 1071–1079. Citeseer, 2014.
164
+
165
+ Sergey Levine and Vladlen Koltun. Guided policy search. In International conference on machine learning, pp. 1–9. PMLR, 2013.
166
+
167
+ Chaochao Lu, Biwei Huang, Ke Wang, Jose Miguel Hern ´ andez-Lobato, Kun Zhang, and Bernhard ´ Scholkopf. Sample-efficient reinforcement learning via counterfactual-based data augmentation. ¨ arXiv preprint arXiv:2012.09092, 2020.
168
+
169
+ William H Montgomery and Sergey Levine. Guided policy search via approximate mirror descent. Advances in Neural Information Processing Systems, 29:4008–4016, 2016.
170
+
171
+ Anusha Nagabandi, Gregory Kahn, Ronald S Fearing, and Sergey Levine. Neural network dynamics for model-based deep reinforcement learning with model-free fine-tuning. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pp. 7559–7566. IEEE, 2018.
172
+
173
+ Vinod Nair and Geoffrey E Hinton. Rectified linear units improve restricted boltzmann machines. In Icml, 2010.
174
+
175
+ Prajit Ramachandran, Barret Zoph, and Quoc V Le. Searching for activation functions. arXiv preprint arXiv:1710.05941, 2017.
176
+
177
+ Danilo J Rezende, Ivo Danihelka, George Papamakarios, Nan Rosemary Ke, Ray Jiang, Theophane Weber, Karol Gregor, Hamza Merzic, Fabio Viola, Jane Wang, et al. Causally correct partial models for reinforcement learning. arXiv preprint arXiv:2002.02836, 2020.
178
+
179
+ Stephane Ross and J Andrew Bagnell. Agnostic system identification for model-based reinforcement learning. arXiv preprint arXiv:1203.1007, 2012.
180
+
181
+ Richard S Sutton. Integrated architectures for learning, planning, and reacting based on approximating dynamic programming. In Machine learning proceedings 1990, pp. 216–224. Elsevier, 1990.
182
+
183
+ Richard S Sutton. Dyna, an integrated architecture for learning, planning, and reacting. ACM Sigart Bulletin, 2(4):160–163, 1991a.
184
+
185
+ Richard S Sutton. Planning by incremental dynamic programming. In Machine Learning Proceedings 1991, pp. 353–357. Elsevier, 1991b.
186
+
187
+ Tingwu Wang, Xuchan Bao, Ignasi Clavera, Jerrick Hoang, Yeming Wen, Eric Langlois, Shunshi Zhang, Guodong Zhang, Pieter Abbeel, and Jimmy Ba. Benchmarking model-based reinforcement learning. arXiv preprint arXiv:1907.02057, 2019.
188
+
189
+ Tianhe Yu, Garrett Thomas, Lantao Yu, Stefano Ermon, James Zou, Sergey Levine, Chelsea Finn, and Tengyu Ma. Mopo: Model-based offline policy optimization. arXiv preprint arXiv:2005.13239, 2020.
190
+
191
+ Lunjun Zhang, Ge Yang, and Bradly C Stadie. World model as a graph: Learning latent landmarks for planning. In International Conference on Machine Learning, pp. 12611–12620. PMLR, 2021.
192
+
193
+ # A MODEL ARCHITECTURE
194
+
195
+ Here we list the architecture of the world model, the policy actor net and the policy critic net we use in all experiments for all methods. All the models are built using linear-layers. The world model uses Swish activation function (Ramachandran et al., 2017) and the policy uses ReLU (Nair & Hinton, 2010).
196
+
197
+ Table 1: Model Architecture
198
+
199
+ <table><tr><td>Modules</td><td>Hidden Layers</td><td>Neurons PerLayer</td></tr><tr><td>WorldModel</td><td>3</td><td>200</td></tr><tr><td>Policy Actor</td><td>2</td><td>256</td></tr><tr><td>Policy Critic</td><td>2</td><td>256</td></tr></table>
200
+
201
+ # B HYPERPARAMETER
202
+
203
+ The size of the real experience replay buffer $\mathbb { D } _ { r }$ is $1 0 0 \mathrm { k }$ for MBPO and our method CausalDyna in all three settings. For SAC, it is 1M as we notice SAC with $1 0 0 \mathrm { k }$ -size replay buffer cannot be trained well. For the world model training, The replay buffer $\mathbb { D } _ { r }$ is split randomly into a training set $\mathbb { D } _ { r , t r a i n }$ with $80 \%$ of the data and a holdout set $\mathbb { D } _ { r , h o l d o u t }$ containing the remaining data. We train the model once for every 250 real environment steps until converge is evaluated on the holdout set. The learning rate is 3e-4. Batch size is 256. For the policy training, the policy net is updated for 5 iterations per real environment step. The batch size is 256, and the learning rate is set to 1e-4.
204
+
205
+ # C QUALITATIVE RESULTS
206
+
207
+ Here we demonstrate episodes from CausalDyna and MBPO in the Pushing Mass setting in unbalanced training distribution experiments with the heavy tail object in Fig.7 and Fig.8. Both models are trained for $6 0 0 \mathrm { k }$ environment steps. The object to manipulate is in blue color. Target location is shown as the green shade. Each column corresponds to an episode. CausalDyna generalizes to the heavy tail object well and pick it to the location successfully shown in Fig.7, while MBPO fails to lift the object up in 2 episodes shown in Fig.8.
208
+
209
+ ![](images/8fb644fe4283c0a929a0a27ed342f1143efe04c8a2b832174437bd4caf6f675e.jpg)
210
+ Figure 7: CausalDyna with the heavy tail object. Pushing Mass, Unbalanced Training Distribution.
211
+
212
+ ![](images/d0a027c70828f6f5b65214e56027f49b60c91a0c3f993223ee406f3b1c1aa889.jpg)
213
+ Figure 8: MBPO with the heavy tail object. Pushing Mass, Unbalanced Training Distribution.
md/dev/uytgM9N0vlR/uytgM9N0vlR.md ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Does GNN Pretraining Help Molecular Representation?
2
+
3
+ Ruoxi Sun Google Cloud AI Research ruoxis@google.com
4
+
5
+ Hanjun Dai Google Research, Brain Team hadai@google.com
6
+
7
+ Adams Wei Yu Google Research, Brain Team adamsyuwei@google.com
8
+
9
+ # Abstract
10
+
11
+ Extracting informative representations of molecules using Graph neural networks (GNNs) is crucial in AI-driven drug discovery. Recently, the graph research community has been trying to replicate the success of self-supervised pretraining in natural language processing, with several successes claimed. However, we find the benefit brought by self-supervised pretraining on small molecular data can be negligible in many cases. We conduct thorough ablation studies on the key components of GNN pretraining, including pretraining objectives, data splitting methods, input features, pretraining dataset scales, and GNN architectures, to see how they affect the accuracy of the downstream tasks. Our first important finding is, self-supervised graph pretraining do not always have statistically significant advantages over non-pretraining methods in many settings. Secondly, although noticeable improvement can be observed with additional supervised pretraining, the improvement may diminish with richer features or more balanced data splits. Thirdly, hyper-parameters could have larger impacts on accuracy of downstream tasks than the choice of pretraining tasks, especially when the scales of downstream tasks are small. Finally, we provide our conjectures where the complexity of some pretraining methods on small molecules might be insufficient, followed by empirical evidences on different pretraining datasets.
12
+
13
+ # 1 Introduction
14
+
15
+ Graph neural networks (GNNs) , due to their effectiveness, have been adopted to model a wide range of structured data, such as social networks, road graphs, citation networks, etc. Molecule modeling is one of these important applications, where it serves as the foundation of biomedicine and nurturing techniques like novel drug discovery. However, labeling biomedical data are usually time-consuming and expensive and thus task-specific labels are extremely inadequate. This poses a big challenge to the field. Recently, inspired by the remarkable success of self-supervised pretraining from natural language processing [6, 2, 28] and computer vision domains [11, 5], researchers start trying to apply the pretrain-finetune paradigm to molecule modeling with GNN, hoping to boost the performance of various molecular tasks by pretraining the model on the enormous unlabeled data. For instance, many methods have been proposed [32, 29], where significant performance improvements are claimed by pretraining on large scale datasets [12, 22, 35–37]. Despite of the promising results, we find that reproducing some of these outstanding gains via graph pretraining can be non-trivial, and sometimes the improvement largely relies on the experimental setup and the extensive hyper-parameter tuning of downstream tasks, rather than the design of pretraining objectives. These observations motivate us to rethink the effectiveness of graph pretraining with unsupervised or self-supervised objectives, and investigate what factors would influence the effectiveness of self-supervised graph pretraining.
16
+
17
+ In this paper, we perform systematic studies to assess the performance of popular graph pretraining objectives on different types of datasets, and exploit various confounding components in experimental setup in deciding the performance of downstream tasks with or without pretraining. Here, we restrict our studies to small molecular graphs, as opposed to other application domains, such as social networks or citation graphs. The key insights and take-aways of this paper are:
18
+
19
+ ![](images/23b1fb885bbe24f6e3cb78240efa88b0c348f7d170bad8d8f953e69e90028d93.jpg)
20
+ Figure 1: A typical pipeline for graph pretraining and deployment for downstream applications.
21
+
22
+ • Among the pretraining tasks we evaluated, the self-supervised pretraining alone does not provide statistically significant improvements over non-pretrained methods on downstream tasks.
23
+ • When additional supervised pretraining step is conducted after self-supervised pretraining, we observe statistically significant improvements. However, the gain becomes marginal on some specific data splits or diminishes if richer features are introduced.
24
+ • Beyond data splits and hand-crafted features, the usefulness of graph pretraining is also sensitive to the experimental hyperparameters, such as learning rates and number of study repeats. Different setups can lead to opposite conclusions.
25
+ • In conclusion, different from the previous works, we do not observe clear and unconditional gains achieved by graph pretraining on molecular representation, indicating it is still too early to conclude graph pretraining is effective in molecular domain.
26
+ • We investigate the reason of above and hypothesize that the complexity of some pretraining methods on molecules is insufficient, leading to less transferable knowledge for downstream tasks.
27
+
28
+ Despite the overall negative results we obtained, the main goal of this paper is not to discourage the pretraining research for small molecules. Instead, we hope to raise the attention on different aspects of experiments and the role of simple hand-crafted features, so as to provide useful information for designing better pretraining approaches. Below we first introduce the background of GNN and its pretraining in Section 2, and then our experimental design and results in Section 3 and Section 4, respectively. Finally we conclude with our findings and the limitations in Section 5 and Section 6.
29
+
30
+ # 2 Preliminary
31
+
32
+ Table 1: Summary of Experiments. Table 12 and Table 13 are deferred to appendix due to space limit.
33
+
34
+ <table><tr><td rowspan=2 colspan=1></td><td rowspan=1 colspan=1>Pretrain Objective</td><td rowspan=1 colspan=1>GraphFeatures</td><td rowspan=1 colspan=1>DownstreamSplits</td><td rowspan=1 colspan=1>GNN Arch</td><td rowspan=1 colspan=1>PretrainDataset</td></tr><tr><td rowspan=1 colspan=1>Self-SupervisedSupervised</td><td rowspan=1 colspan=1>Rich Basic</td><td rowspan=1 colspan=1>Balanced Scaffold</td><td rowspan=1 colspan=1>GIN GraphSage</td><td rowspan=1 colspan=1>ZINC15 SAVI</td></tr><tr><td rowspan=1 colspan=1>Table 2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>√</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>Table 3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></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>Table4</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></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>Table 5</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></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>Table6</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>(</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>Table7</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></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>Table8</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></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>Table9</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1></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>Table10</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1></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>Table 11</td><td rowspan=1 colspan=1>----------------</td><td rowspan=1 colspan=1>?</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>Table12</td><td rowspan=1 colspan=1>----√-------/---</td><td rowspan=1 colspan=1>√</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>Table13</td><td rowspan=1 colspan=1>----√----------</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>----------</td><td rowspan=1 colspan=1>-√-------</td></tr></table>
35
+
36
+ Graph Neural Networks (GNNs). Let $G = \{ V , E \}$ denote a molecule graph with $V$ as the set of nodes and $E$ as the set of edges. Given the node features $X _ { i }$ , most GNNs learn an embedding representation $h _ { i }$ for every node $i \in V$ by aggregating representations from connected nodes and
37
+
38
+ edges, denoted as graph convolution. These procedure repeats for $K$ times with the update equation as follows:
39
+
40
+ $$
41
+ h _ { i } ^ { k } = \mathrm { U P D A T E } ( h _ { i } ^ { k - 1 } , \mathrm { A G G R E G A T E } ( \{ h _ { i } ^ { k - 1 } , h _ { j } ^ { k - 1 } , e _ { i j } \} : \forall j \in N ( i ) ) )
42
+ $$
43
+
44
+ where $\mathcal { N } ( i )$ is the set of neighbor nodes of $i$ and $\begin{array} { r c l } { h _ { i } ^ { 0 } } & { = } & { X _ { i } } \end{array}$ . The representation for entire graph $G$ is then obtained by permutation-invariant transformation on node representation, $h _ { G } \ = \ \mathrm { \hat { R } E A D O U T } ( h _ { i } ^ { K } | i \ \in \ V )$ . In this paper we mainly study the GNNs that belong to this family, namely the WL-1 GNNs.
45
+
46
+ Finetune. After the pretraining, the pretrained model is used to finetune on the downstream tasks. For molecule property prediction tasks, the graph-level representation obtained from the pretrained model is connected to linear classifiers to predict downstream task labels. The fine-tuning is performed in an end-to-end manner, where both the pretrained GNN and the linear classifiers are trainable.
47
+
48
+ Graph pretraining objectives. The primary goal of pretraining is to learn representations with robust transferable knowledge of graphs from the abundant pretraining data and then generalize to downstream tasks with usually different supervision signals. Generally the pretraining objectives can be categorized into self-supervised and supervised ones. We present a brief overview of some representative objectives in the following sections.
49
+
50
+ # 2.1 Self-supervised (unsupervised) pretraining
51
+
52
+ In self-supervised pretraining, the pretraining objective is designed to learn self-generated targets from the structure of the molecules, such as the type of nodes and edges, prediction of local context, graph partition, node clustering, occurrence of some functional groups, and etc. The predictive target can be node/edge level or entire graph level. We present some representative ones below:
53
+
54
+ # 2.1.1 Node Prediction
55
+
56
+ Node prediction is a node-level classification task given the masked context of entire graph. Similar to Devlin et al. [6], some portion of node attributes are masked and replaced with mask-specified indicators in the node input feature. After graph convolution, the embedding output from GNN is used to predict the true attribute of the node, e.g. atom type in molecular graphs, through a linear classifier on top of the node embedding.
57
+
58
+ # 2.1.2 Context Prediction
59
+
60
+ Context prediction task is a sub-graph level task aiming at learning embedding that can represent the local subgraph surrounding a node. Generally it can be viewed as a masked task for substructure. Since it is essentially a structured prediction which can be difficult in general, Hu et al. [12] leverages the adversarial learning to teach the model to distinguish the positive sub-graph embedding from the negative ones. Rong et al. [22] instead builds a dictionary of structures that captures the property of sub-graphs (e.g. type and quantity of neighbour nodes and bonds), and turns it into a multi-class classification problem.
61
+
62
+ # 2.1.3 Motif Prediction
63
+
64
+ Motif prediction [22] is to predict the existence of functional groups, such as benzene ring or hydroxyl. The motifs are extracted automatically from RDKit [15] . The motif prediction task is formulated as a graph-level multi-label binary classification task, where the graph embedding is used to jointly predict the occurrence of these semantic functional motifs.
65
+
66
+ # 2.1.4 Contrastive learning
67
+
68
+ Graph contrastive learning is to maximize the agreement of two augmented views of the same graph, and minimize the agreement of different graphs. The optimization is conducted using contrastive loss in the latent embedding space [35, 10, 37, 29]. The augmentation function needs to transform graphs into realistic and novel augmentations without affecting semantic labels of the graphs. For example, the transformation can be small perturbations or modifications on node/edge embedding, drop of a few nodes or edges, and so on. These transformations enforce an underlying prior for contrastive learning, that is, local transformation does not change the semantic meaning of a graph.
69
+
70
+ Table 2: Self-supervised $^ +$ Rich feature $^ +$ Balanced Scaffold Split. No pretrain has an average value of $7 8 . 0 \%$ over all 5 datasets.
71
+
72
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>92.23(±3.07)</td><td>87.43(±1.63)</td><td>79.20(±1.99)</td><td>69.13(±0.55)</td><td>61.92(±0.89)</td><td>0(±1.626)</td></tr><tr><td>Node Prediction</td><td>92.24(±2.76)</td><td>87.32(±1.67)</td><td>79.57(±2.03)</td><td>69.77(±0.13)</td><td>61.62(±1.12)</td><td>0.122(±1.542)</td></tr><tr><td>Context Prediction</td><td>92.68(±1.19)</td><td>86.98(±1.26)</td><td>79.05(±2.51)</td><td>70.18(±0.44)</td><td>61.65(±0.77)</td><td>0.126(±1.234)</td></tr><tr><td>Motif Prediction</td><td>92.63(±1.19)</td><td>87.16(±1.66)</td><td>79.22(±2.38)</td><td>69.09(±0.07)</td><td>62.45(±1.25)</td><td>0.128(±1.310)</td></tr><tr><td>Contrastive learning</td><td>92.31(±1.58)</td><td>86.67(±2.40)</td><td>78.45(±2.44)</td><td>68.37(±0.80)</td><td>61.22(±1.20)</td><td>-0.578(±1.684)</td></tr></table>
73
+
74
+ # 2.2 Supervised pretraining
75
+
76
+ Supervised pretraining aims to learn domain-specific graph-level knowledge from specifically designed pretraining tasks. For molecular application, the supervised labels are generated from a diverse set of functional studies like biochemical assays. The pretrainning task is to perform multiple binary classification and jointly learn the supervised labels. Although the pretraining mainly refers to unsupervised or self-supervised methods as they are not limited by the requirement of supervised labels, supervised pretraining is still a great source to investigate the graph pretraining in general.
77
+
78
+ Table 3: Supervised $^ +$ Rich feature $^ +$ Balanced Scaffold. No pretrain has an average AUC of $7 8 . 0 \%$ .
79
+
80
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>92.23(±3.07)</td><td>87.43(±1.63)</td><td>79.2(±1.99)</td><td>69.13(±0.55)</td><td>61.92(±0.89)</td><td>0(±1.626)</td></tr><tr><td>Supervised</td><td>91.65(±2.11)</td><td>86.91(±1.86)</td><td>81.13(±2.39)</td><td>71.64(±0.46)</td><td>62.14(±1.13)</td><td>0.712(±1.590)</td></tr><tr><td>Masking Node + Supervised</td><td>93.43(±2.50)</td><td>86.90(±2.04)</td><td>81.93(±1.79)</td><td>71.66(±0.73)</td><td>62.68(±1.82)</td><td>1.338(±1.776)</td></tr><tr><td>Context Prediction + Supervised</td><td>92.27(±1.57)</td><td>88.72(±1.68)</td><td>81.71(±1.79)</td><td>72.19(±0.79)</td><td>63.21(±1.49)</td><td>1.638(±1.464)</td></tr></table>
81
+
82
+ # 3 Experiment framework
83
+
84
+ To investigate pretraining on graphs for molecule representations, we first revisit the typical pretraining-finetuning pipeline used in the literature. Figure 1 shows the overall procedure of deployment, with several design choices presented at each stage of the pipeline. Since different choices at each stage can lead to different performances on the downstream tasks, we investigate them one at a time while keeping others the unchanged. The design principle of our experiment framework is to analyze the effect of every stage in the pipeline as comprehensive as possible, while also keeping it tractable to avoid exponentially many experiments.
85
+
86
+ # 3.1 Design choices
87
+
88
+ We consider the design choices for the four pretraining objectives.
89
+
90
+ Pretraining objective In Section 2 we have provided a brief literature review over the pretraining methods for molecule representation. Here we categorize those pretraining by different principles, and present one well-recognized representative of each category. The representatives are selected because they have more desired properties, such as better performance, compared with their counterparts.
91
+
92
+ • Masking. We leverage the node prediction objective, which randomly masks $1 5 \%$ of the nodes’ feature and then ask GNN to make prediction on the node attributes of the masked ones. This strategy resembles the BERT pretraining [6] in natural language processing.
93
+ • Structured. Unlike text data where the topology is a sequence, the graph has rich structure information. Following Hu et al. [12], we use context prediction objective, which masks out the context from $k _ { 1 }$ -hops to $k _ { 2 }$ -hops and leverages adversarial training to predict the true context embeddings from the random context embeddings.
94
+ • Graph-level self-supervised. Following [22], GNN is asked to predict whether a motif is contained in a molecule. The motif can be extracted from the molecule with RDKit [15]. The motifs are 85 motifs 1 for multi-label classification.
95
+
96
+ Table 4: Self-supervised $^ +$ Rich feature $^ +$ Scaffold. No pretrain has an average ROC-AUC of $7 1 . 8 \%$ over all benckmark datasets.
97
+
98
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>74.83(±0.73)</td><td>80.10(±0.42)</td><td>75.86(±0.58)</td><td>65.95(±0.15)</td><td>62.30(±1.14)</td><td>0(±0.579)</td></tr><tr><td>Node Prediction</td><td>73.45(±0.27)</td><td>83.66(±0.75)</td><td>75.30(±0.37)</td><td>66.50(±0.06)</td><td>65.08(±0.12)</td><td>0.990(±0.323)</td></tr><tr><td>Context Prediction</td><td>74.10(±0.22)</td><td>81.87(±0.49)</td><td>75.37(±0.11)</td><td>66.86(±0.07)</td><td>62.84(±0.46)</td><td>0.400(±0.280)</td></tr><tr><td>Motif Prediction</td><td>73.65(±0.36)</td><td>80.58(±2.04)</td><td>74.55(±0.79)</td><td>65.63(±0.07)</td><td>64.05(±0.23)</td><td>-0.116(±0.766)</td></tr><tr><td>Contrastive learning</td><td>73.32(±2.38)</td><td>80.51(±0.80)</td><td>74.55(±0.22)</td><td>65.70(±0.09)</td><td>64.39(±0.63)</td><td>-0.114(±0.513)</td></tr></table>
99
+
100
+ Table 5: Supervised $^ +$ Self-supervised $^ +$ Rich feature $^ +$ Scaffold. No pretrain get $7 1 . 8 \%$ average ROC-AUC.
101
+
102
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>74.83(±0.73)</td><td>80.10(±0.42)</td><td>75.86(±0.58)</td><td>65.95(±0.15)</td><td>62.30(±1.14)</td><td>0(±0.604)</td></tr><tr><td>Supervised</td><td>72.79(± 0.7)</td><td>83.23(±0.67)</td><td>77.66(±0.08)</td><td>67.72(±0.13)</td><td>65.34(±0.17)</td><td>1.540(±0.350)</td></tr><tr><td>Masking Node+ Supervised</td><td>73.38(±0.55)</td><td>84.42(±0.27)</td><td>77.85(±0.24)</td><td>67.14(±0.28)</td><td>64.06(±0.28)</td><td>1.562(±0.324)</td></tr><tr><td>Context Prediction + Supervised</td><td>73.81(±0.52)</td><td>84.35(±0.93)</td><td>77.11(±0.14)</td><td>67.87(±0.08)</td><td>65.19(±0.17)</td><td>1.858(±0.368)</td></tr></table>
103
+
104
+ • Contrastive. We generate two views of the same graph by corrupting the input node features with Gaussian noise. We leverage the contrastive learning loss proposed in [35]: we maximize the consistency between positive pairs (from same graphs) and minimize that between negative pairs (from different graphs). In this paper, we restrict ourselves to this specific contrastive training method, however, various contrastive learning methods can be further explored.
105
+
106
+ • Graph-level supervised. Finally when applicable, we use the ChEMBL dataset with graph-level labels for graph-level supervised pretraining as Hu et al. [12].
107
+
108
+ The above are the design choices for pretraining objectives. Next, we consider other factors that influence graph-pretraining performance.
109
+
110
+ Graph Features Each molecule is represented by a graph with atoms as nodes and bonds as edges. In this paper we mainly consider the graph representations without the 3D information. For each molecule graph, chemical properties of nodes and edges are extracted to serve as node and edge features for the graph neural networks. Depending on how rich the features are, we categorize the design choices into two categories:
111
+
112
+ • Basic features. The basic set of features are the ones used in Hu et al. [12]. Specifically, the node features contain the atom type and the derived features, such as formal charge list, chirality list, etc. The edge features contain the bond types and the bond directions. These features are categorical, and thus will be encoded in a one-hot vector individually and then concatenated together to form the feature vector for node/edge representation.
113
+
114
+ • Rich features. The rich feature set is a superset of the basic features. In addition to the basic ones mentioned above, it comes with the additional node features such as hydrogen acceptor match, acidic match and bond features such as ring information. This set of features are used in Rong et al. [22]. Additionally and importantly, we follow their setting to incorporate additional 2d normalized rdNormalizedDescriptors features 2, which is used in the downstream tasks only and not in pretraining.
115
+
116
+ Please refer to the original papers for the full set of basic [12] and rich [22] features, respectively.
117
+
118
+ GNN Backbone The GNN architecture also plays a role in graph pretraining. In Hu et al. [12], the results show that pretraining on GNN variants like GIN [33] would improve the performance on downstream tasks, while the performance with architectures like GAT [27] would actually get worse performance with pretraining. As the GNNs based on 1-Weisfeiler-Lehman (WL) test have similar representation power [33] bounded by the Weisfeiler-Lehman isomorphism check [23], we consider the two representative GNN architectures, namely the GIN [33] and GraphSage [9]. They have shown benefits with graph pretraining in Hu et al. [12].
119
+
120
+ Pretraining dataset In natural language pretraining, researchers observed a significant performance boost due to self-supervised pretraining on large-scale data, that is, the larger the pretraining dataset is, the better the downstream performance it is [20]. Inspired by this success in natural language processing, we test the algorithms on two unlabeled pretraining datasets with different scales.
121
+
122
+ Table 6: Self-supervised $^ +$ Basic feature $^ +$ Balanced Scaffold. No pretrain has an average AUC of $7 6 . 7 \%$ over all 5 datasets.
123
+
124
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVEGAIN</td></tr><tr><td>No pretrain</td><td>91.46(± 0.85)</td><td>84.29(± 3.80)</td><td>78.35(± 0.95)</td><td>68.31(± 1.61)</td><td>61.15(± 2.46)</td><td>0(±1.934)</td></tr><tr><td>Node Prediction</td><td>91.23(± 1.51)</td><td>84.97(± 1.55)</td><td>77.77(± 1.23)</td><td>68.98(± 1.11)</td><td>61.20(± 0.41)</td><td>0.118(±1.162)</td></tr><tr><td>Context Prediction</td><td>92.13(± 1.04)</td><td>84.83(± 3.19)</td><td>78.79(± 2.52)</td><td>68.29(± 1.23)</td><td>62.32(± 2.99)</td><td>0.560(±2.194)</td></tr></table>
125
+
126
+ Table 7: Supervised $^ +$ Self-supervised $^ +$ Basic feature $^ +$ Balanced Scaffold. No pretrain has an average AUC of $7 6 . 7 \%$ .
127
+
128
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>91.46(± 0.85)</td><td>84.29(± 3.80)</td><td>78.35(± 0.95)</td><td>68.31(± 1.61)</td><td>61.15(± 2.46)</td><td>0(±1.934)</td></tr><tr><td>Supervised</td><td>90.70(± 0.74)</td><td>84.22(± 2.69)</td><td>80.45(± 1.47)</td><td>69.47(± 1.06)</td><td>63.38(± 1.44)</td><td>0.932(± 1.480)</td></tr><tr><td>Masking Node + Supervised</td><td>91.10(± 2.88)</td><td>85.54(± 4.57)</td><td>81.49(± 1.52)</td><td>70.77(± 1.00)</td><td>62.81(± 2.61)</td><td>1.630(± 2.516)</td></tr><tr><td>Context Prediction + Supervised</td><td>91.54(± 3.52)</td><td>85.71(± 2.92)</td><td>81.23(± 1.94)</td><td>71.36(± 1.05)</td><td>62.75(± 2.27)</td><td>1.806(± 2.340)</td></tr></table>
129
+
130
+ • ZINC15 [25]: ZINC15 contains 2 million molecules. This dataset was preprocessed following Hu et al. [12]. • SAVI [19]: The SAVI dataset contains about 1 billion molecules, which are significantly larger than ZINC15. To the best of our knowledge, it has never been used for pretraining tasks before. This dataset contains drug-like molecules synthesized by computer simulated reactions.
131
+
132
+ Additionaly, we used ChEMBL [8] as the supervised datasets. Different from the above ZINC15 and SAVI dataset which are only used for self-supervised pretraining, this dataset contains $5 0 0 \mathrm { k }$ drug-able molecules with 1,310 prediction target labels from bio-activity assays for drug discovery. Thus like in Hu et al. [12] we only leverage it for supervised pretraining.
133
+
134
+ Data split on downstream tasks The downstream tasks for molecular domain we used are 5 benchmark datasets from MoleculeNet [30] (See Appendix A.5 for more details). The train/valid/test sets are split with ratio 8:1:1. For molecule domain, the random split is not the most meaningful way to assess the performance, because the real-world scenarios often require generalization ability on out-of-distribution samples. So we consider the following ways to split the data:
135
+
136
+ • Scaffold Split [12, 21] This strategy first sorts the molecules according to the scaffold (e.g. molecule structure), and then partition the sorted list into train/valid/test splits consecutively. Therefore, the molecules in train and test sets are most different ones according to their molecule structure. Note this strategy would yield deterministic data splits.
137
+ • Balanced Scaffold Split [1, 22] This strategy introduces the randomness in the sorting and splitting stages above, thus one can run on splits with different random seeds and report the average performance to lower the evaluation variance.
138
+
139
+ We choose balanced scaffold as our major evaluation configuration, because it allows us to evaluate the algorithm on multiple data splits while maintaining the ability to evaluate out of distribution samples (e.g. assess generalization ability). Evaluating on one single split (such as scaffold split) can be subject to bias due to one specific split, leading to higher variance in evaluation.
140
+
141
+ # 3.2 Experiment protocol
142
+
143
+ As the total number of configurations for the entire pipeline can be combinatorially large which is not practical for us to exhaustively experiment with all of them, we design our protocol with a pairwise comparison principle. Specifically, we first anchor a vanilla configuration with a certain design choice of combination for each stage. To study the effect of each stage on the pretraining effectiveness, we vary the design choice one stage at a time compared to the vanilla configuration.
144
+
145
+ For all these experiments, to assess the effectiveness of graph pretraining, we report the ROC-AUC on downstream tasks as well as the relative average gain over all downstream datasets with and without pretraining. For each setting we will report the mean and standard deviation (in parenthesis) over three runs with different random seeds. We tune the model on downstream tasks with the validation set, and report the evaluation metric on the test set using the model with best validation performance. For each setup, we report the average performance obtained with three random seeds. We tune the learning rate in $\{ 1 e ^ { - 4 } , \dot { 5 } e ^ { - 4 } , 1 e ^ { - 3 } , 5 \bar { e } ^ { - \dot { 3 } } , 1 e ^ { - 2 } , 5 e ^ { - 2 } , 1 e ^ { - 1 } \}$ for each setup individually and select the one with best validation performance. For GNNs we fix the hidden dimension to 300 and number of layers to 5.
146
+
147
+ Table 8: Unsupervised $^ +$ Basic feature $^ +$ Scaffold. No pretrain has an average accuracy of $6 8 . 7 \%$ over all benckmark datasets.
148
+
149
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>69.62(± 1.05)</td><td>75.77(±4.29)</td><td>75.52(±0.67)</td><td>63.67(±0.32)</td><td>59.07(±1.13)</td><td>0(±1.492)</td></tr><tr><td>Node Prediction</td><td>68.70(±2.16)</td><td>76.95(±0.12)</td><td>75.88(±0.60)</td><td>64.11(±0.38)</td><td>61.29(±0.87)</td><td>0.656(±0.826)</td></tr><tr><td>Context Prediction</td><td>69.41(±1.44)</td><td>81.96(±0.72)</td><td>75.49(±0.75)</td><td>63.48(±0.31)</td><td>62.27(±0.90)</td><td>1.792(±0.824)</td></tr></table>
150
+
151
+ Table 9: Supervised $^ +$ Basic feature $^ +$ Scaffold. No pretrain has an average accuracy of $6 8 . 7 \%$ over all benckmark datasets.
152
+
153
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>69.62(± 1.05)</td><td>75.77(±4.29)</td><td>75.52(±0.67)</td><td>63.67(±0.32)</td><td>59.07(±1.13)</td><td>0(±1.492)</td></tr><tr><td>Supervised</td><td>68.96(±0.64)</td><td>76.30(±1.30)</td><td>76.64(±0.39)</td><td>66.07(±0.22)</td><td>61.97(±0.96)</td><td>1.258(±0.702)</td></tr><tr><td>Masking Node + Supervised</td><td>71.41(±0.67)</td><td>84.59(±0.35)</td><td>79.13(±0.29)</td><td>65.32(±0.37)</td><td>62.12(±0.19)</td><td>3.784(±0.374)</td></tr><tr><td>Context Prediction+ Supervised</td><td>69.63(±0.25)</td><td>83.34(±0.67)</td><td>78.11(±0.28)</td><td>66.15(±0.48)</td><td>63.48(±0.43)</td><td>3.412(±0.422)</td></tr></table>
154
+
155
+ # 4 Results
156
+
157
+ In this section, we present the results and discussions for a set of experiments designed with the protocols in Section 3.2. Table 1 summarizes the experimental configurations for each following table. We will elaborate on them in the following sections. Due to space limit, we defer our investigation on different GNN architectures to appendix (Section A.1).
158
+
159
+ # 4.1 Vanilla configuration
160
+
161
+ We choose the vanilla configuration with the settings from existing works [12, 22]. Specifically, we use the rich feature with GIN backbone, pretrained on ZINC15 when pretraining is applied, and evaluate on the Balanced Scaffold Split for downstream tasks. One important baseline is without pretraining. For the ease of comparison, we include the results without pretraining in each table.
162
+
163
+ # 4.2 Self-supervised pretraining objectives
164
+
165
+ We compare the results pretrained with different self-supervised pretraining objectives. As is presented in Section 3.1, we consider four representative types of pretraining objectives. For the ease of comparing the performance, we only consider one objective at a time, instead of mixing different pretraining objectives to obtain a multi-task pretrained model. Table 2 shows the performance on downstream molecule property prediction benchmarks with models initialized from different pretraining objectives. The relative average gain compared to the one without pretraining is not statistically significant, i.e., not larger than the standard deviations of multiple runs. All the four different objectives obtain similar gains/loses regardless of very different designs. To fully understand the effect of self-supervised pretraining on molecule representation, we further investigate the performance of different pretraining objectives in combination with other factors, such as input features or data splits, as described in the following sections.
166
+
167
+ # 4.3 Supervised pretraining objectives
168
+
169
+ In addition to the self-supervised objectives, we study the potential benefits with supervised pretraining. Unlike the self-supervised setting where the molecule graphs themselves are used for pretraining, the supervised pretraining requires extra cost of data labeling, and thus is not scalable for large scale pretraining. In this paper, we present the results with supervised pretraining alone, as well as the joint pretraining. e.g. pretrain with self-supervised objective and followed by supervised pretraining, in Table 3. We can see with the supervised pretraining, one can improve the downstream performance, which aligns with the observation from Hu et al. [12]. Our hypothesis is that, supervised pretraining is helpful when the pretraining tasks are closely aligned with the downstream tasks. In particular, the bio-activity labels provided by ChEMBL is highly related to the drug discovery purpose and drug discovery properties are the major topics evaluated in the downstream tasks. Therefore, the positive correlation between the pretraining supervision and downstream tasks contribute the most to the performance improvement of downstream tasks.
170
+
171
+ Table 10: Large scale pretraining data with balanced scaffold split. No pretraining gets an average AUC of $7 8 . 0 \%$ .
172
+
173
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>92.23(±3.07)</td><td>87.43(±1.63)</td><td>79.2(±1.99)</td><td>69.13(±0.55)</td><td>61.92(±0.89)</td><td>0(±1.626)</td></tr><tr><td>Node Prediction</td><td>92.33(±2.08)</td><td>87.22(±1.79)</td><td>79.12(±1.62)</td><td>69.47(±0.65)</td><td>61.24(±1.94)</td><td>-0.106(±1.616)</td></tr><tr><td>Context Prediction</td><td>93.32(±0.53)</td><td>87.77(±2.94)</td><td>79.18(±2.48)</td><td>70.13(±0.56)</td><td>62.24(±2.65)</td><td>0.546(±1.832)</td></tr><tr><td>MaskingNode+Supervised</td><td>93.23(±3.02)</td><td>86.39(±1.67)</td><td>81.89(±1.58)</td><td>71.77(±0.50)</td><td>63.73(±2.20)</td><td>1.420(±1.794)</td></tr><tr><td>Context Prediction + Supervised</td><td>92.55(±2.93)</td><td>87.76(±1.87)</td><td>82.19(±1.58)</td><td>72.91(±0.71)</td><td>62.44(±0.45)</td><td>1.588(±1.508)</td></tr></table>
174
+
175
+ # 4.4 Data split on downstream tasks
176
+
177
+ Molecular data is usually diverse and limited, so chemists are particularly interested in the generalization ability of GNNs on out of distribution data. Also due to the same reason (i.e. limited and diverse data), the variance in performance of different splits is significant, which poses challenges on robust evaluation. In vanilla configuration we use the balanced scaffold split, and here we show additional results with the scaffold split, which is a deterministic data split that makes the train/valid/test set differ from each other the most. Table 4 and Table 5 respectively present the results using scaffold split with self-supervised without and with additional supervised pretraining. Compared with Table 2 and Table 3, it is clear to see that Table 4 and Table 5 have significantly lower ROC-AUC. Specifically the AUC drops $6 . 2 \%$ on average for all benchmarks without pretraining. On the other hand, we can see if we compare Table 4 with Table 2, or Table 5 with Table 3 respectively, the gain of pretraining is more significant on the scaffold split. We speculate the reason for the improvement of scaffold split is that the initialization of neural network parameters (e.g. from pretraining) are typically critical for the out-of-distribution generalization (e.g. scaffold split). Similar observations have also been studied in the meta-learning literature [7]. Although the gain with supervised pretraining is significant in Table 5, the effect of self-supervised pretraining is mixed in Table 4. This indicates the effectiveness of self-supervised pretraining on scaffold split is not significant enough to claim “very helpful”.
178
+
179
+ # 4.5 Graph features
180
+
181
+ So far we have presented the results with rich features. Now we want to see how those basic features used in Hu et al. [12] affect the outcome. Table 6 and Table 7 show the test ROC-AUC $( \% )$ performance with basic features on the balanced scaffold splits using self-supervised or supervised pretraining objectives, respectively. Table 8 and Table 9 show the same results but on scaffold split.
182
+
183
+ In a nutshell, without pretraining, rich features lead to an average gain of $1 . 3 \%$ and $3 . 1 \%$ over basic features using balanced scaffold split and scaffold split, respectively. Specifically, it achieves $7 6 . 7 \%$ vs $7 8 . 0 \%$ for balanced scaffold split, and $6 8 . 7 \%$ vs $\bar { 7 } 1 . 8 \%$ on scaffold split. The gain brought by the rich features are more significant than the ones with different self-supervised pretraining objectives. Table 6 to Table 9 show that pretraining has more positive impact when basic features are used. In particular, the self-pretraining with context prediction shows significant gains especially in the scaffold split setting. However, the gain diminishes when careful feature engineering are applied to the downstream tasks (use rich feature in vanilla configuration). The supervised pretraining continues the significant gain under these settings, which shows the consistency and reliability of the situation with the labeled and downstream-task-aligned supervisions.
184
+
185
+ # 4.6 Pretraining datasets
186
+
187
+ As observed in natural language processing domain, more text pretraining data lead to better downstream performance. Intuitively this can be true for molecule representation domain as well, so we run a new set of experiments with the model pretrained on SAVI dataset, which is about 500 times larger than the ZINC15 dataset we used in the above result sections. We present the results pretrained on SAVI dataset using balanced scaffold split or scaffold split in Table 10 and Table 11, respectively. Other configurations are the same as the vanilla configuration.
188
+
189
+ Table 11: Large scale pretraining data with scaffold split. No pretraining gets an average AUC of $7 1 . 8 \%$ .
190
+
191
+ <table><tr><td>Methods</td><td>BBBP</td><td>BACE</td><td>TOX21</td><td>TOXCAST</td><td>SIDER</td><td>AVE GAIN</td></tr><tr><td>No pretrain</td><td>74.83(±0.73)</td><td>80.10(±0.42)</td><td>75.86(±0.58)</td><td>65.95(±0.15)</td><td>62.30(±1.14)</td><td>0(±0.604)</td></tr><tr><td>Node Prediction</td><td>73.81(±1.82)</td><td>81.90(±1.59)</td><td>74.94(±0.05)</td><td>66.95(±0.12)</td><td>62.93(±0.34)</td><td>0.298(±0.784)</td></tr><tr><td>Context Prediction</td><td>74.32(±0.85)</td><td>83.93(±0.24)</td><td>74.42(±0.19)</td><td>67.01(±0.29)</td><td>64.83(±0.45)</td><td>1.094(±0.404)</td></tr><tr><td>MaskingNode+Supervised</td><td>73.32(±0.60)</td><td>83.38(±1.05)</td><td>78.59(±0.09)</td><td>67.01(±0.18)</td><td>65.40(±0.12)</td><td>1.732(±0.408)</td></tr><tr><td>Context Prediction + Supervised</td><td>74.38(±0.93)</td><td>86.33(±0.16)</td><td>78.16(±0.25)</td><td>68.71(±0.07)</td><td>62.22(±0.48)</td><td>2.152(±0.378)</td></tr></table>
192
+
193
+ Compared with the performance on ZINC15, the SAVI pretraining data does not lead to a significant improvement either on balanced scaffold split (Table 2 vs Table 10) or scaffold split (Table 4 or Table 11). Similarly, the self-supervised pretraining objectives lead to negligible gain on downstream task performance, while the supervised one still achieves a clear gain.
194
+
195
+ As the result is counterintuitive, we further investigate the reason behind it by inspecting the pretraining performances with different training objectives on both ZINC15 and SAVI datasets. We plot the curve of accuracy growth with the number of training steps iterated. We can see from Figure 2 that in all settings the pretraining accuracy grows above $90 \%$ quickly after only 0.1 to $\phantom { - } 0 . 2 \mathbf { M }$ steps and also converges quickly. Given that the model gets very high accuracy without even going through 1 epoch of the SAVI dataset, it is expected that the larger training data like SAVI may not provide more learning signals for the model, and partially explains why more molecules wouldn’t help significantly in this case. Furthermore, these figures might suggest several reasons of why the self-supervised pretraining may not be very effective in some situations:
196
+
197
+ • Tasks are easy. Some of the self-pretraining tasks for molecules might be easy, so that model learns less useful information from pretraining. For example in the masked node prediction case, the model is expected to predict the atomic number from a vocabulary with less than 100 candidate atoms. Furthermore, due to the valence constraints, the graph topology may already exclude most of the wrong atoms. As a comparison, the vocabulary size for text pretraining may be $1 0 0 \mathrm { k }$ or even higher. Some structured prediction tasks like context prediction might be hard, but due to the difficulty of structured prediction itself and the proposal for high quality negative examples for contrastive learning, it can still be challenging for downstream task improvements. Other strategies like motif prediction can be achieved by subgraph matching, which can be easy for GNN that intrinsically does the graph isomorphism test.
198
+
199
+ • Data lacks diversity. Due to biophysical and functional requirements, molecules share many common sub-structures, e.g., functional motifs. Hence, molecules may not be as diversified as text data. This is why the model learns to generalize quickly within the training distribution.
200
+
201
+ • 2D Structure is not enough to infer functionality. Some important biophysical properties (such as 3D structure, chirality) are barely reflected in the 2D-feature-based pretraining (e.g., using smiles or 2D graph features). For example, the molecules with the same chemical formula and 2D feature, can have very different chirality, which leads to quite different toxicity [24] (e.g. flipped toxicity labels). This is not captured in the current GNN pretraining frameworks that we considered.
202
+
203
+ # 4.7 Hyper-parameters for downstream tasks
204
+
205
+ We also find that hyper-parameters for downstream tasks are critical for the their performance that their choices may change the conclusion of the effectiveness of pretraining in some settings. We can take the learning rate as an example. As the models initialized from scratch and pretraining may have different scales, the most suitable learning rate required for downstream tasks may also be different. Without tuning learning rate extensively, we may reach a misleading conclusion. In particular,
206
+
207
+ ![](images/350c840a6ce9fad5e5885ed0de0ec69ede02925cedf0683c16a22b2c8b821bfe.jpg)
208
+ Figure 2: Pretraining accuracy on ZINC15 or SAVI datasets with node prediction or context prediction objectives.
209
+
210
+ when we adopt the default learning rate for reproducing the existing success of pretraining in Table 17 of Appendix A.4, we indeed observe the advantage of pretraining. However, if we follow our procedures (e.g. extensive search learning rate and averaging over three splits), the resulting Table 2 and Table 3 indicate no performance gain by pretraining. So we suggest that the evaluation of pretraining should consider the hyper-parameter tuning and averaging over different splits.
211
+
212
+ # 5 Summary and takeaways
213
+
214
+ Based on our experiments in Section 4, we present our takeaways by empirically summarizing our conjectures on when the pretraining would/would not help the molecular representation learning.
215
+
216
+ When pretraining might help We find it typically helps 1) if we can have the supervised pretraining with target labels that are aligned with the downstream tasks. However, getting large amount of high-quality and relevant supervision is not always feasible; 2) if the high quality hand-crafted features are absent. However, it seems that the gain obtained by self-supervised pretraining is not as significant as these high quality hand-crafted features based on our current studies; 3) if the downstream train, valid and test dataset distributions are substantially different.
217
+
218
+ When the gain diminishes? In some situations the gain of pretraining might diminish 1) if we already have the high quality hand-crafted features (e.g. rich features described in Section 3.1); 2) if we don’t have the highly relevant supervisions. As shown in Section 4.6, many self-supervised pretraining tasks might be too easy for the model to learn meaningful embedding; 3) if the downstream data splits are balanced; 4) if the self-supervised learning dataset lacks diversity, despite its scale.
219
+
220
+ Why pretraining may not help in some cases? In our paper we pretrained a GNN on a much larger dataset (SAVI) than before, hoping to replicate gain of pretraining like in NLP domain. However, we do not obtain the expected gain. The pretraining accuracy curve (Figure 2) provides some potential explanations of why pretraining may not work: some of the pretraining accuracy curve grows above $9 5 \% +$ quickly and converges fast, unlike pretraining in NLP which keeps growing to $\bar { 7 } 0 \%$ and hardly plateaus. This suggests that some of the pretraining methods like masked node label prediction might be easy (as the vocabulary size is much smaller compared to NLP) and therefore transfer less knowledge for downstream tasks.
221
+
222
+ # 6 Limitations of current study
223
+
224
+ Although we have tried our best to design a comprehensive study on the effectiveness of graph pretraining for molecular representation, there are still limitations we want to point out. Due to the limited time and resources we have, we are not able to fully cover the whole picture of the current pretraining paradigm in graph neural networks. Nevertheless, we list them here in hope of preventing the over-generalization of our conclusion.
225
+
226
+ • Distribution of graphs. Our study focuses on pretraining for small molecule graph inductive representation learning. Recently there are works on pretraining transductive representation learning [36] on large graphs [13], where our conclusion may not be directly extended to these cases. Graph architectures. GNN is a popular research field where many new architectures with probable expressiveness are/will be proposed. The results we have shown are on two representative 1-WL GNNs. It can be possible that the latest advances of deep GNN [17] and Transformer-based GNN [34, 3, 14] might yield different results. Learning objectives. Although we have presented results with different types of self-supervised losses, there are still many variants of each type that we did not explore, like different variants [26, 31] of contrastive learning. Also, multi-task learning of different self-supervised objectives might be another direction for further exploration. Downstream datasets. We obtained our conclusion mainly on the datasets from MoleculeNet [30]. Datasets like Alchemy [4] and drug-target Interaction [18] may show different results.
227
+
228
+ References
229
+ [1] Guy W Bemis and Mark A Murcko. The properties of known drugs. 1. molecular frameworks. Journal of medicinal chemistry, 39(15):2887–2893, 1996.
230
+ [2] 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.
231
+ [3] Dexiong Chen, Leslie O’Bray, and Karsten Borgwardt. Structure-aware transformer for graph representation learning. In International Conference on Machine Learning, pages 3469–3489. PMLR, 2022.
232
+ [4] Guangyong Chen, Pengfei Chen, Chang-Yu Hsieh, Chee-Kong Lee, Benben Liao, Renjie Liao, Weiwen Liu, Jiezhong Qiu, Qiming Sun, Jie Tang, et al. Alchemy: A quantum chemistry dataset for benchmarking ai models. arXiv preprint arXiv:1906.09427, 2019.
233
+ [5] 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.
234
+ [6] 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.
235
+ [7] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning, pages 1126–1135. PMLR, 2017.
236
+ [8] Anna Gaulton, Louisa J Bellis, A Patricia Bento, Jon Chambers, Mark Davies, Anne Hersey, Yvonne Light, Shaun McGlinchey, David Michalovich, Bissan Al-Lazikani, et al. Chembl: a large-scale bioactivity database for drug discovery. Nucleic acids research, 40(D1):D1100– D1107, 2012.
237
+ [9] William L Hamilton, Rex Ying, and Jure Leskovec. Representation learning on graphs: Methods and applications. arXiv preprint arXiv:1709.05584, 2017.
238
+ [10] Kaveh Hassani and Amir Hosein Khasahmadi. Contrastive multi-view representation learning on graphs. In International Conference on Machine Learning, pages 4116–4126. PMLR, 2020.
239
+ [11] Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross B. Girshick. Momentum contrast for unsupervised visual representation learning. In CVPR, pages 9726–9735, 2020.
240
+ [12] Weihua Hu, Bowen Liu, Joseph Gomes, Marinka Zitnik, Percy Liang, Vijay Pande, and Jure Leskovec. Strategies for pre-training graph neural networks. arXiv preprint arXiv:1905.12265, 2019.
241
+ [13] Ziniu Hu, Yuxiao Dong, Kuansan Wang, Kai-Wei Chang, and Yizhou Sun. Gpt-gnn: Generative pre-training of graph neural networks. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 1857–1867, 2020.
242
+ [14] Jinwoo Kim, Tien Dat Nguyen, Seonwoo Min, Sungjun Cho, Moontae Lee, Honglak Lee, and Seunghoon Hong. Pure transformers are powerful graph learners. arXiv preprint arXiv:2207.02505, 2022.
243
+ [15] G Landrum. Rdkit: Open-source cheminformatics software, 2016.
244
+ [16] P. Langley. Crafting papers on machine learning. In Pat Langley, editor, Proceedings of the 17th International Conference on Machine Learning (ICML 2000), pages 1207–1216, Stanford, CA, 2000. Morgan Kaufmann.
245
+ [17] Meng Liu, Hongyang Gao, and Shuiwang Ji. Towards deeper graph neural networks. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 338–348, 2020.
246
+ [18] Shengchao Liu, Hanchen Wang, Weiyang Liu, Joan Lasenby, Hongyu Guo, and Jian Tang. Pre-training molecular graph representation with 3d geometry. arXiv preprint arXiv:2110.07728, 2021.
247
+ [19] Hitesh Patel, Wolf Ihlenfeldt, Philip Judson, Yurii S Moroz, Yuri Pevzner, Megan Peach, Nadya Tarasova, and Marc Nicklaus. Synthetically accessible virtual inventory (savi). 2020.
248
+ [20] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.
249
+ [21] Bharath Ramsundar, Peter Eastman, Patrick Walters, and Vijay Pande. Deep learning for the life sciences: applying deep learning to genomics, microscopy, drug discovery, and more. " O’Reilly Media, Inc.", 2019.
250
+ [22] 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.
251
+ [23] Nino Shervashidze, Pascal Schweitzer, Erik Jan Van Leeuwen, Kurt Mehlhorn, and Karsten M Borgwardt. Weisfeiler-lehman graph kernels. Journal of Machine Learning Research, 12(9), 2011.
252
+ [24] Silas W Smith. Chiral toxicology: it’s the same thing. . . only different. Toxicological sciences, 110(1):4–30, 2009.
253
+ [25] Teague Sterling and John J Irwin. Zinc 15–ligand discovery for everyone. Journal of chemical information and modeling, 55(11):2324–2337, 2015.
254
+ [26] Mengying Sun, Jing Xing, Huijun Wang, Bin Chen, and Jiayu Zhou. Mocl: data-driven molecular fingerprint via knowledge-aware contrastive learning from molecular graph. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining, pages 3585–3594, 2021.
255
+ [27] Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. arXiv preprint arXiv:1710.10903, 2017.
256
+ [28] 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.
257
+ [29] Lirong Wu, Haitao Lin, Zhangyang Gao, Cheng Tan, Stan Li, et al. Self-supervised on graphs: Contrastive, generative, or predictive. arXiv preprint arXiv:2105.07342, 2021.
258
+ [30] 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.
259
+ [31] Jun Xia, Lirong Wu, Jintao Chen, Bozhen Hu, and Stan Z Li. Simgrace: A simple framework for graph contrastive learning without data augmentation. In Proceedings of the ACM Web Conference 2022, pages 1070–1079, 2022.
260
+ [32] Yaochen Xie, Zhao Xu, Jingtun Zhang, Zhengyang Wang, and Shuiwang Ji. Self-supervised learning of graph neural networks: A unified review. arXiv preprint arXiv:2102.10757, 2021.
261
+ [33] Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? arXiv preprint arXiv:1810.00826, 2018.
262
+ [34] 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.
263
+ [35] Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, and Yang Shen. Graph contrastive learning with augmentations. Advances in Neural Information Processing Systems, 33:5812–5823, 2020.
264
+
265
+ [36] Yuning You, Tianlong Chen, Zhangyang Wang, and Yang Shen. When does self-supervision help graph convolutional networks? In International Conference on Machine Learning, pages 10871–10880. PMLR, 2020.
266
+
267
+ [37] Yanqiao Zhu, Yichen Xu, Feng Yu, Qiang Liu, Shu Wu, and Liang Wang. Graph contrastive learning with adaptive augmentation. In Proceedings of the Web Conference 2021, pages 2069–2080, 2021.
268
+
269
+ # Checklist
270
+
271
+ 1. For all authors...
272
+
273
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
274
+ (b) Did you describe the limitations of your work? [Yes]
275
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] . Though not really apply.
276
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
277
+
278
+ 2. If you are including theoretical results...
279
+
280
+ (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]
281
+
282
+ 3. If you ran experiments...
283
+
284
+ (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 prepare code soon.
285
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
286
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
287
+ (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]
288
+
289
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
290
+
291
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
292
+ (b) Did you mention the license of the assets? [N/A]
293
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
294
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes]
295
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
296
+
297
+ 5. If you used crowdsourcing or conducted research with human subjects...
298
+
299
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
300
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
301
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/v54eUIayFh/v54eUIayFh.md ADDED
@@ -0,0 +1,520 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UniControl: A Unified Diffusion Model for Controllable Visual Generation In the Wild
2
+
3
+ Can $\mathrm { Q i n } ^ { \dag \star }$ , Shu Zhang†, Ning $\mathrm { Y u ^ { \dag } }$ , Yihao Feng†, Xinyi Yang†, Yingbo Zhou†, Huan Wang†, Juan Carlos Niebles†, Caiming Xiong†, Silvio Savarese†, Stefano Ermon‡, Yun $\operatorname { F u } ^ { \star }$ , and Ran $\mathrm { { X u ^ { \dag } } }$
4
+
5
+ †Salesforce AI Research, ⋆Northeastern University, ‡Stanford Univeristy, qin.ca@northeastern.edu, ermon@cs.stanford.edu, yunfu@ece.neu.edu, {shu.zhang, ning.yu, yihaof, x.yang, yingbo.zhou, huan.wang, jniebles, cxiong, ssavarese, ran.xu}@salesforce.com
6
+
7
+ # Abstract
8
+
9
+ Achieving machine autonomy and human control often represent divergent objectives in the design of interactive AI systems. Visual generative foundation models such as Stable Diffusion show promise in navigating these goals, especially when prompted with arbitrary languages. However, they often fall short in generating images with spatial, structural, or geometric controls. The integration of such controls, which can accommodate various visual conditions in a single unified model, remains an unaddressed challenge. In response, we introduce UniControl , a new generative foundation model that consolidates a wide array of controllable condition-to-image (C2I) tasks within a singular framework, while still allowing for arbitrary language prompts. UniControl enables pixel-level-precise image generation, where visual conditions primarily influence the generated structures and language prompts guide the style and context. To equip UniControl with the capacity to handle diverse visual conditions, we augment pretrained text-to-image diffusion models and introduce a task-aware HyperNet to modulate the diffusion models, enabling the adaptation to different C2I tasks simultaneously. Trained on nine unique C2I tasks, UniControl demonstrates impressive zero-shot generation abilities with unseen visual conditions. Experimental results show that UniControl often surpasses the performance of single-task-controlled methods of comparable model sizes. This control versatility positions UniControl as a significant advancement in the realm of controllable visual generation. 1
10
+
11
+ # 1 Introduction
12
+
13
+ Generative foundation models are revolutionizing the ways that humans and AI interact in natural language processing (NLP) [1–6], computer vision (CV) [7–10], audio processing (AP) [11, 12], and robotic controls [13–15], to name a few. In NLP, generative foundation models such as InstructGPT or GPT-4, achieve excellent performance on a wide range of tasks, e.g., question answering, summarization, text generation, or machine translation within a single-unified model. Such multi-tasking ability is one of the most appealing characteristics of generative foundation models. Furthermore, generative foundation models can also perform zero-shot or few-shot learning on unseen tasks [3, 16, 17].
14
+
15
+ For generative models in vision domains [9, 18–20], such multi-tasking ability is less clear. Stable Diffusion Model (SDM) [9] has established itself as the major cornerstone for text-conditioned image generation. However, while text descriptions provide a very flexible way to control the generated images, their ability to provide pixel-level precision for spatial, structural, or geometric controls is often inadequate. A recent work, ControlNet [21], was proposed to augment SDM to enable visual conditions (e.g., edge maps, depth maps). With the additional visual conditions, ControlNet can achieve explicit spatial, structural, or geometric control over generated structures, without losing the semantic control from textual captions. Unfortunately, unlike language prompts that a unified module such as CLIP [22] can handle, each ControlNet model can only handle a specific control modality that it was trained on (e.g., edge map). Retraining a separate model is necessary to handle a different modality of visual conditions, incurring non-trivial time and spatial complexity costs.
16
+
17
+ ![](images/e2f7a1a82640708ece2e219ec1c356d11a92c8831241ba8bcd8afc8f321db7de.jpg)
18
+ Figure 1: UniControl is trained with multiple tasks with a unified model, and it further demonstrates promising capability in zero-shot tasks generalization with visual example results shown above.
19
+
20
+ To overcome the limitation of previous works, we present UniControl, a unified diffusion model for controllable visual generation in the wild, which is capable of simultaneously handling both language and various visual conditions. Naturally, UniControl can perform multi-tasking and can encode visual conditions from different tasks into a universal representation space, seeking a common representation structure among tasks. The unified design of UniControl allows us to enjoy the advantages of improved training and inference efficiency, as well as enhanced controllable generation. On the one hand, the model size of UniControl does not significantly increase as the number of tasks scales up. On the other hand, UniControl derives advantages from the inherent connections between different visual conditions [e.g., 23–25]. These relationships, such as depth and segmentation mapping, leverage shared geometric information to enhance the controllable generation quality.
21
+
22
+ The unified controllable generation ability of UniControl relies on two novel designed modules, a mixture of expert (MOE)-style adapter and a task-aware HyperNet [26, 27]. The MOE-style adapter can learn necessary low-level feature maps from various visual conditions, allowing UniControl to capture unique information from different visual conditions. The task-aware HyperNet, which takes the task instruction as natural language prompt inputs, and outputs a task-aware embedding. The output embeddings can be incorporated to modulate ControlNet [21] for task-aware visual condition controls, where each task corresponds to a particular format of visual condition. As a result, the task-aware HyperNet allows UniControl to learn meta-knowledge across various tasks, and obtain abilities to generalize to unseen tasks. As Tab. 1, UniControl has significantly compressed the model size compared with its direct baseline, i.e., Multi-ControlNet, by unifying nine tasks into ONE model.
23
+
24
+ Table 1: Architecture and Model Size (#Params): UniControl vs. Multi-ControlNet
25
+
26
+ <table><tr><td></td><td>Stable Diffusion</td><td>ControlNet</td><td>MoE-Adapter</td><td>TaskHyperNet</td><td>Total</td></tr><tr><td>UniControl</td><td>1065.7M</td><td>361M</td><td>0.06M</td><td>12.7M</td><td>1.44B</td></tr><tr><td>Multi-ControlNet</td><td>1065.7M</td><td>361M×9</td><td>-</td><td>-</td><td>4.32B</td></tr></table>
27
+
28
+ To obtain multi-tasking and zero-shot learning abilities, we pre-train UniControl on nine distinct tasks across five categories: 1) edges (Canny, HED, User Sketch); 2) region-wise maps (Segmentation Maps, Bounding Boxes); 3) skeletons (Human Pose Skeletons); 4) geometric maps Depth, Surface Normal); 5) editing (Image Outpainting). We build MultiGen-20M dataset, comprising over 20 million high-quality triplets of original images, language prompts, and visual conditions for all the tasks. Then UniControl is trained for over 5,000 GPU hours on NVIDIA A100-40G hardware that is comparable with the overall training cost of different ControlNets. Moreover, UniControl exhibits a remarkable capacity for zero-shot adaptation to new tasks, highlighting its potential for deployment in real-world applications. Our contributions are summarized below:
29
+
30
+ • We present UniControl, a unified model capable of handling various visual conditions for the controllable visual generation.
31
+
32
+ • We collect a new dataset for multi-condition visual generation with more than 20 million imagetext-condition triplets over nine distinct tasks across five categories.
33
+
34
+ • We conduct extensive experiments to demonstrate that the unified model UniControl outperforms each single-task controlled image generation, thanks to learning the intrinsic relationships between different visual conditions.
35
+
36
+ • UniControl shows the ability to adapt to unseen tasks in a zero-shot manner, highlighting its versatility and potential for widespread adoption in the wild.
37
+
38
+ # 2 Related Works
39
+
40
+ Diffusion-based Generative Models. Diffusion models were initially introduced in [28] that yield favorable outcomes for generating images [18, 21]. Improvements have been made through various training and sampling techniques such as score-based diffusion [29, 30], Denoising Diffusion Probabilistic Model (DDPM) [31], and Denoising Diffusion Implicit Model (DDIM) [32], When training U-Net denoisers [33] with high-resolution images, researchers involve speed-up techniques including pyramids [34], multiple stages [20], or latent representations [9]. In particular, UniControl leverages Stable Diffusion Models (SDM) [9] as the base model to perform multi-tasking.
41
+
42
+ Text-to-Image Diffusion. Diffusion models emerge to set up a cutting-edge performance in text-to-image generation tasks [20, 19], by cross-attending U-Net denoiser in diffusion generators with CLIP [22] or T5-pretrained [2] text embeddings. GLIDE [35] is another example of a textguided diffusion model that supports image generation and editing. UniControl and closely related
43
+
44
+ ControlNet [21] are both built upon previous works on diffusion-based text-to-image generation [9].
45
+ [36] introduces the compositional conditions to guide visual generation.
46
+
47
+ Image-to-Image Translation. Image-to-image (I2I) translation task was initially proposed in Pix2Pix [37], focusing on learning a mapping between images in different domains. Recently, diffusion-based approaches [38, 39, 21] set up the new state of the art results. Recent diffusionbased image editing methods show outstanding performances without requiring paired data, e.g., SDEdit [40], prompt-to-prompt [41], Edict [42]. Other image editing examples include various diffusion bridges and flows [43–47], classifier guidance [30] based methods for colorization, superresolution [34], inpainting [48], and etc. ControlNet [21] takes both visual and text conditions and achieves new state-of-the-art controllable image generation. Our proposed UniControl unifies various visual conditions of ControlNet, and is capable of performing zero-shot learning on newly unseen tasks. Concurrently, Prompt Diffusion [49] introduces visual prompt [50] from image inpainting to controllable diffusion models, which requires two additional image pairs as the in-context example for both training and inference. By contrast, UniControl takes only a single visual condition while still capable of both multi-tasking and zero-shot learning.
48
+
49
+ # 3 UniControl
50
+
51
+ In this section, we describe the training and the model design of our unified controllable diffusion model UniControl. Specifically, we first provide the problem setup and training objectives in Sec. 3.1, and then show the novel network design of UniControl in Sec. 3.2. Finally, we explain how to perform zero-shot image generation with the trained UniControl in Sec. 3.3.
52
+
53
+ # 3.1 Training Setup
54
+
55
+ Different from the previous generative models such as Stable Diffusion Models (SDM) [9] or ControlNet [21], where the image generation conditions are single language prompt, or single type of visual condition such as canny, UniControl is required to take a wide range of visual conditions from different tasks, as well as the language prompt.
56
+
57
+ To achieve this, we reformulate the training conditions and target pairs for UniControl. Specifically, suppose we have a dataset consisting of $K$ tasks : $\mathcal { D } : = \{ { \mathcal { D } } _ { 1 } \cup \cdot \cdot \cdot \cup { \mathcal { D } } _ { K } \}$ , and for each task training set $\mathcal { D } _ { k }$ , denote the training pairs by $( [ c _ { \mathrm { t e x t } } , c _ { \mathrm { t a s k } } ] , { \mathcal { T } } _ { c } , \pmb { x } )$ , with $c _ { \mathrm { t a s k } }$ being the task instruction that indicates the task type, $c _ { \mathrm { t e x t } }$ being the language prompt describing the target image, $\mathcal { T } _ { c }$ being the visual conditions, and $_ { \pmb { x } }$ being the target image. With the additional task instruction, UniControl can differentiate visual conditions from different tasks. A concrete training example pair is the following:
58
+
59
+ # Task-Aware Vision-Language Condition
60
+
61
+ ![](images/fcb8b0ba4b724590545b882ca6e410285660539ed63b095b991438633dd6c62a.jpg)
62
+ Visual Condition $\mathcal { T } _ { c }$
63
+
64
+ Language Prompt :
65
+ “Camp on a mountain top: Birthday Presents,
66
+ Adventure, Outdoor, Mountain Camps, Great
67
+ View, Places, Hiking, Mornings Lights,
68
+ Himalayan Sunri”
69
+
70
+ ![](images/38e8fa6599c74af649d251c2351c779c38e3f2b94a8f40459a98969d57a74df5.jpg)
71
+ Target output
72
+
73
+ Task Instruction $c _ { \mathrm { t a s k } }$ : “Canny Edge to Image”
74
+
75
+ where the task is to translate the canny edge to real images following language prompt. With the induced training pairs $( \pmb { x } , [ c _ { \mathrm { t a s k } } , c _ { \mathrm { t e x t } } ] , \pmb { \mathcal { T } } _ { c } )$ , we define the training loss for task $k$ following LDM [9]:
76
+
77
+ $\ell ^ { k } ( \theta ) : = \mathbb { E } _ { z , \varepsilon , t , c _ { \mathrm { t a s k } } , c _ { \mathrm { t e x t } } , { T _ { c } } } \left[ \lVert \varepsilon - \varepsilon _ { \theta } ( z _ { t } , t , c _ { \mathrm { t a s k } } , c _ { \mathrm { t e x t } } , \mathcal { T } _ { c } ) \rVert _ { 2 } ^ { 2 } \right]$ , with $( [ c _ { \mathrm { t a s k } } , c _ { \mathrm { t e x t } } ] , \mathcal { T } _ { c } , \pmb { x } ) \sim \mathcal { D } _ { k } .$ , where $t$ represents the time step, $z _ { t }$ is the noise-corrupted latent tensor at time step $t$ , $z _ { 0 } = E ( \pmb { x } )$ , and $\theta$ is the trainable parameters of UniControl . We also apply classifier-free guidance [51] to randomly drop $30 \%$ text prompts to enhance the controllability of input visual conditions. We train UniControl uniformly on the $K$ tasks. To be more specific, we first randomly select a task $k$ and sample a mini-match from $\mathcal { D } _ { k }$ , and optimize $\theta$ with the calculated loss $\ell ^ { k } ( \theta )$ .
78
+
79
+ # 3.2 Model Design
80
+
81
+ Since our unified model UniControl needs to achieve superior performance on a set of diverse tasks, it is necessary to ensure the network design enjoys the following properties: 1) The model can overcome the misalignment of low-level features from different tasks; 2) The model can learn meta-knowledge across tasks, and adapt to each task effectively.
82
+
83
+ ![](images/567eb74edf244be03efaf0e3179e4c11be587c12bc7456afce228a991e56a28a.jpg)
84
+ Figure 2: This figure shows our proposed UniControl method. To accommodate diverse tasks, we’ve designed a Mixture of Experts (MOE) Adapter, containing roughly $\mathord { \sim } 7 0 \mathrm { K }$ $\#$ params for each task, and a Task-aware HyperNet $\mathrm { \sim } 1 2 \mathrm { M }$ #params) to modulate $N$ (i.e., 7) zero-conv layers. This structure allows for multi-task functionality within a singular model, significantly reducing the model size compared to an equivalent stack of single-task models, each with around 1.4B #params.
85
+
86
+ The first property can ensure that UniControl can learn necessary and unique information from all tasks. For instance, if UniControl takes the segmentation map as the visual condition, the model might ignore the 3D information. As a result, the feature map learned may not be suitable for the task that takes the depth map images as visual condition. The second property would allow the model to learn the shared knowledge across tasks, as well as the differences among them.
87
+
88
+ We introduce two novel designed modules, MOE-style adapter and task-aware HyperNet, that allows UniControl enjoys the above two properties. An overview of the model design for UniControl is in Fig. 2. We describe the detailed designs of these modules below.
89
+
90
+ MOE-Style Adapter. Inspired by the design of Mixture-of-Experts (MOEs) [52], we devise a group of convolution modules to serve as the adapter for UniControl to capture features of various low-level visual conditions. Precisely, the designed adapter module can be expressed as
91
+
92
+ $$
93
+ \mathcal { F } _ { \mathrm { A d a p t e r } } ( \mathcal { Z } _ { c } ^ { k } ) : = \sum _ { i = 1 } ^ { K } \mathbb { 1 } ( i = = k ) \cdot \mathcal { F } _ { \mathrm { C o v 1 } } ^ { ( i ) } \circ \mathcal { F } _ { \mathrm { C o v 2 } } ^ { ( i ) } ( \mathcal { Z } _ { c } ^ { k } ) ,
94
+ $$
95
+
96
+ where $\mathbb { 1 } ( \cdot )$ is the indicator func on, $\mathcal { T } _ { c } ^ { k }$ is the conditioned image from task $k$ , and $\mathcal { F } _ { \mathrm { { C o v 1 } } } ^ { ( i ) } , \mathcal { F } _ { \mathrm { { C o v 2 } } } ^ { ( i ) }$ are the convolution layers of the $i$ -th module of the adapter. We remove the weights of the original MOEs since our designed adapter is required to differentiate various visual conditions. Meanwhile, naive MOE modules can not explicitly distinguish different visual conditions when the weights are learnable. Moreover, such task-specific MOE adapters facilitate the zero-shot tasks with explicit retrieval of the adapters of highly related pre-training tasks. Besides, the number of parameters for each convolution module is approximately 70K, which is computationally efficient.
97
+
98
+ ![](images/ddfdf7bb249088e3f366e8b8ba221b8f472a1b46e62e984081e2fc92dd49c629.jpg)
99
+ Figure 3: Illustration of MOE’s behaviors under zero-shot scenarios. The left part shows the capacity of the MOE to generalize to hybrid task conditions, achieved through the integration of outputs from two pertinent convolution layers. The right part illustrates the ability of the MOE-style adapter to generalize to unseen tasks, facilitated by the aggregation of pre-trained tasks using estimated weights.
100
+
101
+ Task-Aware HyperNet. The task-aware HyperNet modulates the zero-convolution modules of ControlNet [21] with the task instruction condition $c _ { \mathrm { t a s k } }$ . As shown in Figure 2, our hyperNet first projects the task instruction $c _ { \mathrm { t a s k } }$ into task embedding with the help of CLIPText encoder. Then similar in spirit of style modulation in StyleGAN2 [53], we inject the task embedding into the trainable copy of ControlNet, by multiplying the task embedding to each zero-conv layer. In specific, the length of the embedding is the same as the number of input channels of the zero-conv layer, and each element scalar in the embedding is multiplied to the convolution kernel per input channel. We also show that our newly designed task-aware HyperNet can also efficiently learn from training instances and task supervision following a similar analysis as in ControlNet [21].
102
+
103
+ # 3.3 Task Generalization Ability
104
+
105
+ With the comprehensive pretraining on the MultiGen-20M dataset, UniControl exhibits zero-shot capabilities on tasks that were not encountered during its training, suggesting that Unicontrol possesses the ability to transcend in-domain distributions for broader generalization. We demonstrate the zeroshot ability of UniControl in the following two scenarios:
106
+
107
+ Hybrid Tasks Generalization. As shown in the left side of Fig. 3, We consider two different visual conditions as the input of UniControl, a hybrid combination of segmentation maps and human skeletons, and augment specific keywords "background" and "foreground" into the text prompts. Besides, we rewrite the hybrid task instruction as a blend of instructions of the combined two tasks such as "segmentation map and human skeleton to image".
108
+
109
+ Zero-Shot New Tasks Generalization. As shown in the right side of Fig. 3, UniControl needs to generate controllable images on a newly unseen visual condition. To achieve this, estimating the task weights based on the relationship between unseen and seen pre-trained tasks is essential. The task weights can be estimated by either manual assignment or calculating the similarity score of task instructions in the embedding space. The example result in Fig. 5 (d) is generated by our manually assigned MOE weights as “depth: 0.6, seg: 0.3, canny: 0.1” for colorization. The MOE-style adapter can be linearly assembled with the estimated task weights to extract shallow features from the newly unseen visual condition.
110
+
111
+ # 4 Experiments
112
+
113
+ We empirically evaluate the effectiveness and robustness of UniControl. We conduct a series of comprehensive experiments across various conditions and tasks, utilizing diverse datasets to challenge the model’s adaptability and versatility. Experimental setup, methodologies, and results analysis are provided in the subsequent sections.
114
+
115
+ # 4.1 Experiment Setup
116
+
117
+ Implementation. The UniControl is illustrated as Fig. 2 with Stable Diffusion, ControlNet, MOE Adapter, and Task-aware HyperNet consisting ${ \sim } 1 . 5 \mathrm { B }$ parameters. MOE Adapter consists of parallel convolutional modules, each of which corresponds to one task. The task-aware HyperNet inputs the CLIP text embedding [22] of task instructions and outputs the task embeddings to modulate the weights of zero-conv kernels. We implement our model upon the ControlNet . We take the AdamW [54] as the optimizer based on PyTorch Lightning [55]. The learning rate is assigned as $1 \times 1 0 ^ { - 5 }$ . Our full-version UniControl model is trained on 16 Nvidia-A100 GPUs with the batch size of 4, requiring $\sim 5$ , 000 GPU hours. We have also applied Safety-Checker as safeguards of results.
118
+
119
+ ![](images/3f78c1bb95cc3e20339cf41b1c27cd81750dd296c828198bfdec2efd35181699.jpg)
120
+ Figure 4: Visual comparison between official or re-implemented task-specific ControlNet and our proposed model. The example data is collected from our testing set sampled from COCO and Laion.
121
+
122
+ Data Collection. Since the training set of ControlNet is currently unavailable, we initiate our own data collection process from scratch and name it as MultiGen-20M. We use a subset of LaionAesthetics-V2 [56] with aesthetics ratings over six, excluding low-resolution images smaller than 512. This yields approximately 2.8 million image-text pairs. Subsequently, we process this dataset for nine distinct tasks across five categories (edges, regions, skeletons, geometric maps, real images):
123
+
124
+ • Canny (2.8M): Utilize the Canny edge detector [57] with randomized thresholds.
125
+
126
+ • HED (2.8M): Deploy the Holistically-nested edge detection [58] for robust boundary determination.
127
+
128
+ • Depth (2.8M): Employ the Midas [59] for monocular depth estimation.
129
+
130
+ • Normal (2.8M): Use the depth estimation results from the depth task to estimate scene or object surface normals.
131
+
132
+ • Segmentation (2.8M): Implement the Uniformer [60] model, pre-trained on the ADE20K [61] dataset, to generate segmentation maps across 150 classes.
133
+
134
+ • Object Bounding Box (874K): Utilize YOLO V4 [62] pre-trained on the COCO [63] dataset for bounding box labelling across 80 object classes.
135
+
136
+ • Human Skeleton (1.3M): Employ the pre-trained Openpose [64] model to generate human skeleton labels from source images.
137
+
138
+ • Image Outpainting (2.8M): Create boundary masks for source images with random masking percentages from $20 \%$ to $80 \%$ .
139
+
140
+ Further processings are carried out on HED maps using Gaussian filtering and binary thresholding to simulate user sketching. Overall, we amass over 20 million image-prompt-condition triplets. Task instructions were naturally derived from the respective conditions, with each task corresponding to a specific instruction, such as "canny edge to image" for the canny task. We maintain a one-toone correspondence between tasks and instructions without introducing variance to ensure stability during training. We have additionally collected a testing dataset for evaluation with 100-300 imagecondition-prompt triplets for each task. The source data is collected from Laion and COCO. We will open-source our training and testing data to contribute to the community.
141
+
142
+ Benchmark Models. The most straightforward comparison for UniControl comes from task-specific ControlNet models. Six tasks overlap with those presented in ControlNet, so their official models are chosen as baselines for these tasks. For fair comparison, we re-implement the ControlNet model (single task) using our collected data. Our unified multi-task UniControl is compared against these task-aware models for each task. We apply default sampler as DDIM [32] with guidance weight 9 and steps 50. All single-task models used for comparison are trained by 100K iterations and our multi-task model is trained around 900K with similar iterations for each task to ensure fairness. The efficiency and compact design of our proposed model are evident in its construction. The total size of UniControl is around 1.5B #params and a single task ControlNet $^ +$ SDM takes 1.4B. In order to achieve the same nine-task functionality, a single-task strategy would require the ensemble of a SDM with nine task-specific ControlNet models, amounting to approximately 4.3B #params in total.
143
+
144
+ ![](images/6c0ea7ba2a2a2c99b0745134a484112af74d27e5d6570f3bad24e796d908e009.jpg)
145
+ Figure 5: (a)-(b): Example results of UniControl over hybrid (unseen combination) conditions with key words "background" and "foreground" attached in prompts. (c)-(e): Example results of UniControl on three unseen tasks (deblurring, colorization, inpainting).
146
+
147
+ ![](images/3fe5b43a671f7a865acfe456334ba3770564c1cb59a286ee1b3354c2ef64d584.jpg)
148
+ Figure 6: User study between our method and official ControlNet checkpoints on six tasks. Our method outperforms ControlNet on all tasks.
149
+
150
+ # 4.2 Visual Comparison
151
+
152
+ We visually compare different tasks (Canny, HED, Depth, Normal, Segmentation, Openpose, Bounding Box, and Outpainting) in Fig. 4. Our method consistently outperforms the baseline ControlNet model. This superiority is in terms of both visual quality and alignment with conditions or prompts.
153
+
154
+ For the Canny task, the results generated by our model exhibit a higher degree of detail preservation and visual consistency. The outputs of UniControl maintain a faithful reproduction of the edge information (i.e., round table) compared to ControlNet. In the HED task, our model effectively captures the robust boundaries, leading to visually appealing images with clear and sharp edge transitions, whereas ControlNet results appear to be non-factual. Moreover, our model demonstrate a more subtle understanding of 3D geometrical guidance of depth maps and surface normals than ControlNet. The depth map conditions produce visibly more accurate outputs. In the Normal task, our model faithfully reproduces the normal surface information (i.e., ski pole), leading to more realistic and visually superior outputs. During the Segmentation, Openpose, and Object Bounding Box tasks, the produced images generated by our model are better aligned with the given conditions than that by ControlNet, ensuring a higher fidelity to the input prompts. For example, the re-implemented ControlNet-BBox misunderstands “a woman near a statue”, whereas our outputs exhibit a high degree of accuracy and detail. In the Outpainting task, our model demonstrates its superiority by generating reasonable images with smooth transitions and natural-looking textures. It outperforms the ControlNet model, which produces less coherent results - “a bear missing one leg”. This visual comparison underscores the strength and versatility of our approach across a diverse set of tasks.
155
+
156
+ ![](images/a44d12886fd18a351b70182433054e16acefca7e6bf3e28199ae43767333bc04.jpg)
157
+ Figure 7: User study between our multi-task model (Ours-multi) and single task model (Ours-single) on eight tasks. Our method outperforms baselines on most of tasks, and achieves big performance gains on tasks of seg-to-image and outpainting-to-image. Moreover, the p-value of voting Ours-multi in all cases is computed as 0.0028 that is statistically significant according to the criteria of $< 0 . 0 5$ .
158
+
159
+ # 4.3 Quantitative Evaluation
160
+
161
+ User Study. We compare the performance of our method with both the released ControlNet model and the re-implemented single-task ControlNet on our training set. As shown in Fig. 6, our approach consistently outperforms the alternatives in all cases. In the HED-to-image generation task, our method significantly surpasses ControlNet. This superiority is even more pronounced in the depth and normal surface to image generation tasks, where users overwhelmingly favor our method, demonstrating its ability to handle complex geometric interpretations. When compared to the re-implemented single-task model, Fig. 7 reveals that our approach maintains a smaller advantage, yet it still demonstrates its benefits by effectively discerning image regions to guide content generation. Even in the challenging outpainting task, our model outperforms the baseline, highlighting its robustness and capacity to generalize.
162
+
163
+ Table 2: Image Perceptual Distance
164
+
165
+ <table><tr><td></td><td>Canny↓</td><td>HED↓</td><td>Normal↓</td><td>Depth↓</td><td>Pose↓</td><td>Segmentation ↓</td></tr><tr><td>UniControl</td><td>0.546</td><td>0.466</td><td>0.623</td><td>0.654</td><td>0.741</td><td>0.693</td></tr><tr><td>ControlNet</td><td>0.577</td><td>0.582</td><td>0.778</td><td>0.700</td><td>0.747</td><td>0.693</td></tr></table>
166
+
167
+ Image Perceptual Metric. We evaluate the distance between our output and the ground truth image. As we aim to obtain
168
+
169
+ a structural similar image to the ground truth image, we adopt the perceptual metric in [65], where a lower value indicates more similar images. As shown in Tab. 2, UniControl outperforms ControlNet on five tasks, and obtains the same image distance to ControlNet on Segmentation.
170
+
171
+ Fréchet Inception Distance (FID). We’ve further conducted quantitative analysis with FID [66] to include more classic single-task-controlled methods such as GLIGEN [67] and T2I-adapter [68]. With a collection of over 2,000 test samples sourced from Laion and COCO, we’ve assessed a wide range of tasks covering edges (Canny, HED), regions (Seg), skeletons (Pose), and geometric maps (Depth, Normal). The Tab. 3 demonstrates that our UniControl consistently surpasses the baseline methods across the majority of tasks. Notably, UniControl achieves this while maintaining a more compact and efficient architecture than its counterparts.
172
+
173
+ Ablation Study. We’ve conducted an ablation study, specifically focusing on the MoE-Style Adapter and TaskHyperNet in Tab. 4 with FID scores reported as the previous part. It is noticeable that the full-version UniControl (MoE-Style Adapter $^ +$ TaskHyperNet) significantly outperforms the ablations which demonstrates the superiority of proposed MoE-Style Adapter and TaskHyperNet.
174
+
175
+ Table 3: Quantitative Comparison (FID)
176
+
177
+ <table><tr><td></td><td>Canny↓</td><td>HED↓</td><td>Depth ↓</td><td>Normal↓</td><td>Seg↓</td><td>Pose↓</td></tr><tr><td>GLIGEN [67]</td><td>24.9</td><td>27.8</td><td>25.8</td><td>27.7</td><td>-</td><td>=</td></tr><tr><td>T2I-Adapter [68]</td><td>23.6</td><td>1</td><td>25.4</td><td>-</td><td>27.1</td><td>28.9</td></tr><tr><td>ControlNet [21]</td><td>22.7</td><td>25.1</td><td>25.5</td><td>28.4</td><td>26.7</td><td>28.8</td></tr><tr><td>UniControl</td><td>22.9</td><td>23.6</td><td>21.3</td><td>23.4</td><td>25.5</td><td>27.4</td></tr></table>
178
+
179
+ Table 4: Ablation Study (FID)
180
+
181
+ <table><tr><td>MoE-Adapter</td><td>TaskHyperNet</td><td>Canny↓</td><td>HED↓</td><td>Depth ↓</td><td>Normal↓</td><td>Seg↓</td><td>Pose↓</td><td>Avg</td></tr><tr><td></td><td>X</td><td>27.2</td><td>29.0</td><td>27.6</td><td>28.8</td><td>29.1</td><td>30.2</td><td>28.7</td></tr><tr><td></td><td></td><td>24.5</td><td>26.1</td><td>23.7</td><td>24.8</td><td>26.9</td><td>28.3</td><td>25.7</td></tr><tr><td>x&lt;&gt;</td><td>X</td><td>22.9</td><td>23.6</td><td>21.3</td><td>23.4</td><td>25.5</td><td>27.4</td><td>24.0</td></tr></table>
182
+
183
+ # 4.4 Zero-shot Generalization
184
+
185
+ We further showcase the surprising capabilities of our method to undertake the zero-shot challenge of hybrid conditions combination and unseen tasks generalization.
186
+
187
+ Hybrid Tasks Combination. This involves generating results from two distinct conditions simultaneously. Our model’s zero-shot ability is tested with combinations such as depth and human skeleton or segmentation map and human skeleton. The results are shown in Fig. 5 (a)-(b). When the background is conditioned on a depth map, the model effectively portrays the intricate 3D structure of the scene, while maintaining the skeletal structure of the human subject. Similarly, when the model is presented with a combination of a segmentation map and human skeleton, the output skillfully retains the structural details of the subject, while adhering to the segmentation boundaries. These examples illustrate our model’s adaptability and robustness, highlighting its ability to handle complex hybrid tasks without any prior explicit training.
188
+
189
+ Unseen Tasks Generalization. To evaluate the zero-shot ability to generalize to unseen tasks such as gray image colorization, image deblurring, and image inpainting, we conduct the case analysis in Fig. 5 (c)-(e). The model skillfully handles the unseen tasks, producing compelling results. This capability is deeply rooted in the shared attributes and implicit correlations among pre-training and new tasks, allowing our model to adapt seamlessly. For instance, the colorization task leverages the model’s understanding of image structures from the segmentation task and depth estimation task, while deblurring and inpainting tasks benefit from the model’s familiarity with edge detection and outpainting ones.
190
+
191
+ # 5 Conclusion and Discussion
192
+
193
+ We introduce UniControl , a novel unified model for incorporating a wide range of conditions into the generation process of diffusion models. UniControl has been designed to be adaptable to various tasks through the employment of two key components: a Mixture-of-Experts (MOE) style adapter and a task-aware HyperNet. The experimental results have showcased the model’s robust performance and adaptability across different tasks and conditions, demonstrating its potential for handling complex text-to-image generation tasks.
194
+
195
+ Limitation and Broader Impact. While UniControl demonstrates impressive performance, it still inherits the limitation of diffusion-based image generation models. Specifically, it is limited by our training data, which is obtained from a subset of the Laion-Aesthetics datasets. We observe that there is a data bias in this dataset. Although we have performed keywords and image based data filtering methods, we are aware that the model may generate biased or low-fidelity output. Our model is also limited when high-quality human output is desired. UniControl could be improved if better open-source datasets are available to block the creation of biased, toxic, sexualized, or other harmful content. We hope our work can motivate researchers to develop visual generative foundation models.
196
+
197
+ # References
198
+
199
+ [1] 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.
200
+
201
+ [2] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J Liu, et al. Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21(140):1–67, 2020.
202
+
203
+ [3] Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph, Yi Tay, William Fedus, Eric Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, et al. Scaling instruction-finetuned language models. arXiv preprint arXiv:2210.11416, 2022.
204
+
205
+ [4] 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.
206
+
207
+ [5] 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.
208
+
209
+ [6] OpenAI. Gpt-4 technical report, 2023.
210
+
211
+ [7] Junnan Li, Dongxu Li, Silvio Savarese, and Steven Hoi. Blip-2: Bootstrapping languageimage pre-training with frozen image encoders and large language models. arXiv preprint arXiv:2301.12597, 2023.
212
+
213
+ [8] Haoxuan You, Mandy Guo, Zhecan Wang, Kai-Wei Chang, Jason Baldridge, and Jiahui Yu. Cobit: A contrastive bi-directional image-text generation model. arXiv preprint arXiv:2303.13455, 2023.
214
+
215
+ [9] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. Highresolution image synthesis with latent diffusion models. In CVPR, pages 10684–10695, 2022.
216
+
217
+ [10] Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alexander C Berg, Wan-Yen Lo, et al. Segment anything. arXiv preprint arXiv:2304.02643, 2023.
218
+
219
+ [11] Bo Li, Dongseong Hwang, Zhouyuan Huo, Junwen Bai, Guru Prakash, Tara N Sainath, Khe Chai Sim, Yu Zhang, Wei Han, Trevor Strohman, et al. Efficient domain adaptation for speech foundation models. In ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 1–5. IEEE, 2023.
220
+
221
+ [12] Rongjie Huang, Mingze Li, Dongchao Yang, Jiatong Shi, Xuankai Chang, Zhenhui Ye, Yuning Wu, Zhiqing Hong, Jiawei Huang, Jinglin Liu, et al. Audiogpt: Understanding and generating speech, music, sound, and talking head. arXiv preprint arXiv:2304.12995, 2023.
222
+
223
+ [13] Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, et al. Do as i can, not as i say: Grounding language in robotic affordances. arXiv preprint arXiv:2204.01691, 2022.
224
+
225
+ [14] Yilun Dai, Mengjiao Yang, Bo Dai, Hanjun Dai, Ofir Nachum, Josh Tenenbaum, Dale Schuurmans, and Pieter Abbeel. Learning universal policies via text-guided video generation. arXiv preprint arXiv:2302.00111, 2023.
226
+
227
+ [15] Sai Vemprala, Rogerio Bonatti, Arthur Bucker, and Ashish Kapoor. Chatgpt for robotics: Design principles and model abilities. Technical Report MSR-TR-2023-8, Microsoft, February 2023. URL https://www.microsoft.com/en-us/research/publication/ chatgpt-for-robotics-design-principles-and-model-abilities/.
228
+
229
+ [16] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Christiano, Jan Leike, and Ryan Lowe. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02155, 2022.
230
+
231
+ [17] OpenAI. Chatgpt. https://openai.com/blog/chatgpt/, 2022.
232
+
233
+ [18] Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. NeurIPS, 34:8780–8794, 2021.
234
+
235
+ [19] 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.
236
+
237
+ [20] 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.
238
+
239
+ [21] Lvmin Zhang and Maneesh Agrawala. Adding conditional control to text-to-image diffusion models. arXiv preprint arXiv:2302.05543, 2023.
240
+
241
+ [22] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. arXiv preprint arXiv:2103.00020, 2021.
242
+
243
+ [23] Amir R Zamir, Alexander Sax, William Shen, Leonidas J Guibas, Jitendra Malik, and Silvio Savarese. Taskonomy: Disentangling task transfer learning. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3712–3722, 2018.
244
+
245
+ [24] Golnaz Ghiasi, Barret Zoph, Ekin D Cubuk, Quoc V Le, and Tsung-Yi Lin. Multi-task selftraining for learning general representations. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 8856–8865, 2021.
246
+
247
+ [25] Shikun Liu, Edward Johns, and Andrew J Davison. End-to-end multi-task learning with attention. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 1871–1880, 2019.
248
+
249
+ [26] David Ha, Andrew M. Dai, and Quoc V. Le. Hypernetworks. In International Conference on Learning Representations, 2017.
250
+
251
+ [27] Johannes Von Oswald, Christian Henning, Benjamin F Grewe, and João Sacramento. Continual learning with hypernetworks. arXiv preprint arXiv:1906.00695, 2019.
252
+
253
+ [28] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In ICML, pages 2256–2265. PMLR, 2015.
254
+
255
+ [29] Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019.
256
+
257
+ [30] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020.
258
+
259
+ [31] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. NeurIPS, 33:6840–6851, 2020.
260
+
261
+ [32] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv:2010.02502, October 2020. URL https://arxiv.org/abs/2010.02502.
262
+
263
+ [33] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In MICCAI, pages 234–241. Springer, 2015.
264
+
265
+ [34] Jonathan Ho, Chitwan Saharia, William Chan, David J Fleet, Mohammad Norouzi, and Tim Salimans. Cascaded diffusion models for high fidelity image generation. J. Mach. Learn. Res., 23(47):1–33, 2022.
266
+ [35] 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.
267
+ [36] Nan Liu, Shuang Li, Yilun Du, Antonio Torralba, and Joshua B Tenenbaum. Compositional visual generation with composable diffusion models. In European Conference on Computer Vision, pages 423–439. Springer, 2022.
268
+ [37] Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. In CVPR, 2017.
269
+ [38] Chitwan Saharia, William Chan, Huiwen Chang, Chris Lee, Jonathan Ho, Tim Salimans, David Fleet, and Mohammad Norouzi. Palette: Image-to-image diffusion models. In ACM SIGGRAPH 2022 Conference Proceedings, pages 1–10, 2022.
270
+ [39] Tengfei Wang, Ting Zhang, Bo Zhang, Hao Ouyang, Dong Chen, Qifeng Chen, and Fang Wen. Pretraining is all you need for image-to-image translation. arXiv preprint arXiv:2205.12952, 2022.
271
+ [40] Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, and Stefano Ermon. Sdedit: Guided image synthesis and editing with stochastic differential equations. In International Conference on Learning Representations, 2021.
272
+ [41] Amir Hertz, Ron Mokady, Jay Tenenbaum, Kfir Aberman, Yael Pritch, and Daniel Cohen-Or. Prompt-to-prompt image editing with cross attention control. arXiv preprint arXiv:2208.01626, 2022.
273
+ [42] Bram Wallace, Akash Gokul, and Nikhil Naik. Edict: Exact diffusion inversion via coupled transformations. arXiv preprint arXiv:2211.12446, 2022.
274
+ [43] Xuan Su, Jiaming Song, Chenlin Meng, and Stefano Ermon. Dual diffusion implicit bridges for image-to-image translation. In The Eleventh International Conference on Learning Representations, 2022.
275
+ [44] Yaron Lipman, Ricky TQ Chen, Heli Ben-Hamu, Maximilian Nickel, and Matt Le. Flow matching for generative modeling. arXiv preprint arXiv:2210.02747, 2022.
276
+ [45] 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.
277
+ [46] Xingchao Liu, Lemeng Wu, Mao Ye, and Qiang Liu. Let us build bridges: Understanding and extending diffusion generative models. arXiv preprint arXiv:2208.14699, 2022.
278
+ [47] Guan-Horng Liu, Arash Vahdat, De-An Huang, Evangelos A Theodorou, Weili Nie, and Anima Anandkumar. $\mathrm { I } ^ { 2 } \mathrm { s b }$ : Image-to-image schrödinger bridge. arXiv preprint arXiv:2302.05872, 2023.
279
+ [48] Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, and Luc Van Gool. Repaint: Inpainting using denoising diffusion probabilistic models. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, 2022.
280
+ [49] Zhendong Wang, Yifan Jiang, Yadong Lu, Yelong Shen, Pengcheng He, Weizhu Chen, Zhangyang Wang, and Mingyuan Zhou. In-context learning unlocked for diffusion models. arXiv preprint arXiv:2305.01115, 2023. URL https://arxiv.org/abs/2305.01115.
281
+ [50] Amir Bar, Yossi Gandelsman, Trevor Darrell, Amir Globerson, and Alexei Efros. Visual prompting via image inpainting. Advances in Neural Information Processing Systems, 35: 25005–25017, 2022.
282
+ [51] Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022.
283
+
284
+ [52] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts layer. arXiv preprint arXiv:1701.06538, 2017.
285
+
286
+ [53] 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.
287
+
288
+ [54] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
289
+
290
+ [55] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In NeurIPS. NeurIPS, 2019.
291
+
292
+ [56] Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki. Laion-5b: An open large-scale dataset for training next generation image-text models. arXiv preprint arXiv:2111.02114, 2021.
293
+
294
+ [57] John Canny. A computational approach to edge detection. IEEE Transactions on pattern analysis and machine intelligence, pages 679–698, 1986.
295
+
296
+ [58] Saining Xie and Zhuowen Tu. Holistically-nested edge detection. In Proceedings of the IEEE international conference on computer vision, pages 1395–1403, 2015.
297
+
298
+ [59] René Ranftl, Katrin Lasinger, David Hafner, Konrad Schindler, and Vladlen Koltun. Towards robust monocular depth estimation: Mixing datasets for zero-shot cross-dataset transfer. IEEE transactions on pattern analysis and machine intelligence, 44(3):1623–1637, 2020.
299
+
300
+ [60] Kunchang Li, Yali Wang, Junhao Zhang, Peng Gao, Guanglu Song, Yu Liu, Hongsheng Li, and Yu Qiao. Uniformer: Unifying convolution and self-attention for visual recognition. arXiv preprint arXiv:2201.09450, 2022.
301
+
302
+ [61] Bolei Zhou, Hang Zhao, Xavier Puig, Tete Xiao, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Semantic understanding of scenes through the ade20k dataset. International Journal of Computer Vision, 127:302–321, 2019.
303
+
304
+ [62] Alexey Bochkovskiy, Chien-Yao Wang, and Hong-Yuan Mark Liao. Yolov4: Optimal speed and accuracy of object detection. arXiv preprint arXiv:2004.10934, 2020.
305
+
306
+ [63] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In Computer Vision–ECCV 2014: 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V 13, pages 740–755. Springer, 2014.
307
+
308
+ [64] Zhe Cao, Tomas Simon, Shih-En Wei, and Yaser Sheikh. Realtime multi-person 2d pose estimation using part affinity fields. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7291–7299, 2017.
309
+
310
+ [65] Richard Zhang, Phillip Isola, Alexei Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, 2018.
311
+
312
+ [66] 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. NeurIPS, 30, 2017.
313
+
314
+ [67] Yuheng Li, Haotian Liu, Qingyang Wu, Fangzhou Mu, Jianwei Yang, Jianfeng Gao, Chunyuan Li, and Yong Jae Lee. Gligen: Open-set grounded text-to-image generation. arXiv:2301.07093, 2023.
315
+
316
+ # Appendix
317
+
318
+ # A Details of Implementation
319
+
320
+ # A.1 MOE-Style Adapter
321
+
322
+ The MOE adapter is implemented as a set of parallel ConvNets composed of three consecutive convolution and non-linear activation layers. The entire model is comprised of nine individual MOE adapters, each of which consumes 70K parameters. Task keys are designated to each adapter, ensuring that they align with the corresponding visual conditions. Once the MOE adapter processes the input, the remaining model parameters become shared across all tasks. This architecture facilitates task adaptability while promoting parameter efficiency.
323
+
324
+ # A.2 Task-aware HyperNet
325
+
326
+ The task-aware hypernet is applied to modulate the parameters of zero-conv layers in the ControlNet. Since the ControlNet can be considered as the hypernet of Stable Diffusion (fixed copy). Our idea can be concluded as the control over control or meta-control to let the task-aware hypernet learn the universe representation that is generalizable across different tasks. To implement it, we firstly map the task keys to instruction with a mapping function as: {"hed": "hed edge to image", "canny": "canny edge to image", "seg": "segmentation map to image", "depth": "depth map to image", "normal": "normal surface map to image", "pose": "human pose skeleton to image", "hedsketch": "sketch to image", "bbox": "bounding box to image", "outpainting": "image outpainting"}. Then, such instructions will be projected as text embeddings with the help of a language model (we adopt CLIPText in our implementation). The Task-aware HyperNet takes these task instruction embeddings, and projects them into different shapes to match the size of different zero-conv kernels, which will be modulated by these task embeddings accordingly. We would fix the parameters of task-aware hyperNet in the later stage of model training to ensure the stability of dynamics.
327
+
328
+ # A.3 Data Collection
329
+
330
+ We have collected a large amount of training set (MultiGen-20M) including over 20M conditionimage-prompt triplets across nine different tasks. We firstly download 3/4 of Laion-Aesthetics-V2 with score over six and filter out low-resolution $( < 5 1 2 )$ images. As a result, $2 . 8 \mathbf { M }$ images are selected as source images. Then we apply the visual condition extractors as described in the main paper to collect Canny, HED, Sketch, Depth, Normal Surface, Seg Map, Object Bounding Box, Human Skeleton and Outpainting.
331
+
332
+ # B Numerical Analysis of Task-Aware Modulated ControlNet
333
+
334
+ We show that our proposed task-aware modulated ControlNet preserves the properties of the original ControlNet structure. Specifically, we show 1) The new task-aware modulated ControlNet preserves the zero-initialization property of ControlNet; 2) The parameters of the task-aware modulated Controlnet can be updated once we start to train the model.
335
+
336
+ Denote the input feature map by , the frozen SD Block in Fig. 2 by $\mathcal { F } _ { \mathrm { S D } }$ , the extra condition by $c$ , two zero convolution operators by $\mathcal { Z } _ { \theta _ { 1 } } ^ { 1 } ( \cdot )$ and $\mathcal { Z } _ { \theta _ { 2 } } ^ { 2 } ( \cdot )$ , the trainable copy of SD Block by $\mathcal { G } _ { \theta _ { \mathrm { s } } } ^ { \mathrm { S D } } ( \cdot )$ , the task instruction by $c _ { \mathrm { t a s k } }$ , and the task-aware hyperNet by $\mathcal { H } _ { \boldsymbol { \theta } _ { \mathcal { H } } } ( \cdot )$ . Then the output of the new task-aware modulated Controlnet can be expressed as
337
+
338
+ $$
339
+ { \pmb y } _ { c } = \mathcal { F } _ { \mathrm { S D } } ( { \pmb x } ) + \mathcal { Z } _ { \theta _ { 1 } } ^ { 1 } ( \mathcal { G } _ { \theta _ { \mathrm { s } } } ^ { \mathrm { S D } } ( { \pmb x } + \mathcal { Z } _ { \theta _ { 2 } } ^ { 2 } ( c ) \cdot \mathcal { H } _ { \theta _ { \mathcal { H } } } ( c _ { \mathrm { t a s k } } ) ) ) \cdot \mathcal { H } _ { \theta _ { \mathcal { H } } } ( c _ { \mathrm { t a s k } } ) .
340
+ $$
341
+
342
+ Property of Zero Initialization. Similar to ControlNet [21], the weights and biases of the convolution layers are initialized as zeros. As a result, we have $\mathcal { Z } _ { \theta _ { 1 } } ^ { 1 } ( \cdot ) \equiv 0$ and $\pmb { y } _ { c } = \mathcal { F } _ { \mathrm { S D } } ( \pmb { x } )$ , regardless of the initialization of $\mathcal { H } _ { \theta _ { \mathcal { H } } } ( \cdot )$ .
343
+
344
+ Gradient Analysis. We analyze the gradient of the modulated part
345
+
346
+ $$
347
+ \nabla _ { \theta } \left( Z _ { \theta _ { 1 } } ^ { 1 } ( I ) \cdot \mathcal { H } _ { \theta _ { \mathcal { H } } } ( c _ { \mathrm { t a s k } } ) \right) = \mathcal { H } _ { \theta _ { \mathcal { H } } } ( c _ { \mathrm { t a s k } } ) \cdot \nabla _ { \theta } Z _ { \theta _ { 1 } } ^ { 1 } ( I ) + Z _ { \theta _ { 1 } } ^ { 1 } ( I ) \cdot \nabla _ { \theta _ { \mathcal { H } } } \mathcal { H } _ { \theta _ { \mathcal { H } } } ( c _ { \mathrm { t a s k } } ) ,
348
+ $$
349
+
350
+ where $I$ is the input of the zero convolution layer.
351
+
352
+ When we start to train the network, the first part of the RHS of (2) follows similar analysis of ControlNet [21] since $\mathcal { H } _ { \boldsymbol { \theta } _ { \mathcal { H } } } \left( c _ { \mathrm { t a s k } } \right)$ is constant when we analyze the gradient $\nabla _ { \theta } Z _ { \theta _ { 1 } } ^ { 1 } ( I )$ . Since the parameters of $\mathcal { H } _ { \theta _ { \mathcal { H } } } ( c _ { \mathrm { t a s k } } )$ are not initialized to zero, it is known that $\mathcal { H } _ { \theta _ { \mathcal { H } } } ( c _ { \mathrm { t a s k } } ) \neq 0$ . So the gradient dynamic follows the analysis of ControlNet. Therefore, we conclude that $Z _ { \theta _ { \bot } } ^ { 1 } ( I ) \neq 0$ after the first gradient update, and that the network can start to learn and update the following standard dynamics of stochastic gradient descent.
353
+
354
+ As for the second part of the RHS of (2), $Z _ { \theta _ { 1 } } ^ { 1 } ( I ) \equiv 0$ before the first gradient update, so the gradient is zero for $\theta _ { \mathcal { H } }$ . However, after the first gradient update of $\theta _ { 1 }$ , we know $Z _ { \theta _ { 1 } } ^ { 1 } ( I ) \neq 0$ , and $\theta _ { \mathcal { H } }$ can be updated with non-zero gradients.
355
+
356
+ To conclude, the new task-aware Modulated ControlNet can still be efficiently updated and learned even if the convolution layers are initialized to zero.
357
+
358
+ # C Zero-shot-task Results and Analysis
359
+
360
+ We show more zero-shot-task results in this section, where the tasks have not been trained on. In Fig. 13, we show zero-shot deblurring results guided by the keywords. Our deblurred images can successfully recover the fine-grained details of the images without training on such data. We note that some details are still missing, e.g., the details in the painting in the first row are still not clear enough. In Fig. 14, we illustrate two zero-shot image colorization results. We believe that most parts of the generated images are acceptable, though the clothes of the second woman do not look the same to the input blurred image. In Fig. 15, we observe impressive zero-shot inpainting results. In the first row, the duck that is inputted in the text has been successfully generated in the inpainted image. The second row obtains acceptable results as well, though the faces do not look perfect. The overall zero-shot quality of UniControl is remarkable.
361
+
362
+ While inpainting and outpainting might appear related, they are fundamentally distinct. Inpainting heavily leverages the contextual information from unmasked regions, necessitating a precise match. Conversely, outpainting has more freedom, with the generative model prioritizing prompts to envision new content. As shown in Fig. 8, directly using outpainting model for inpainting tasks can be challenging since the model tends to leave a sharp change over the mask boundaries. Our pretrained UniControl, thanks to intensive training across multiple tasks, has learned edge and region-to-image mappings, which assists in preserving contextual information.
363
+
364
+ Our model also demonstrates a promising capacity to generalize under scribble conditions, showing parallels to the ControlNet’s ability, even though UniControl hasn’t been directly trained using scribble data. Fig. 9 provides results illustrating the scribble-to-image generation.
365
+
366
+ # D Details of User Study
367
+
368
+ In the evaluation steps, we use Amazon Mechanical Turk (Mturk) 2 to perform user study. Specifically, we ask three Mturk master workers to select the best output result for each input condition. As shown in Fig. 10, we provide instructions on guidelines to select the best generated image. The annotators are provided the condition map and the text that describes the image, and are required to select the better output between the two generated images. Considering that images can both in good or bad qualities, we provide the tie option as well. We use the majority vote to determine the result of each image, which means that an image is considered as a better image if two or more annotators vote for it. We use 294 images for the tasks of Canny, HED, Surface Normal, Depth, Segmentation, User Sketch, and Outpainting. We adopt 100 images for the task of Human Skeleton and 187 images for the task of Bounding Box. In summary, we totally obtain 7,035 voting results for all nine tasks. 2/3 of source images in testing set are collected from MSCOCO with the remaining 1/3 from Laion. And it includes a very diverse range of topics including indoor scene, outdoor scene, oil painting, portrait, pencil sketch, animation, cartoon, etc.
369
+
370
+ ![](images/7796cc26a834c8384afb9bcfcd3395271440f7b33f59f84f756afb5088431095.jpg)
371
+ “Contemporary Bedroom Designs 2015 modern bedroom designs intended design”
372
+
373
+ ![](images/2d355454522171fa2e1b083602cdc59ebab9a153e42804ce92e584efa68ebab9.jpg)
374
+ Figure 8: Visual comparison of Ours-single-outpainting and UniControl on the inpainting task. The single outpainting model cannot well address the zero-shot inpainting task whereas UniControl demonstrates promising capacity.
375
+ Figure 9: Visual comparison of ControlNet-Scribble and UniControl on the scribble data. ControlNetScribble is trained by the scribble data which, however, are unseen for UniControl.
376
+
377
+ ![](images/16698d49a4b5517d756c624b1810c4b1688ca335a2f7854252080f45c1e5e283.jpg)
378
+ Figure 10: Mturk interface to select the better generated image.
379
+
380
+ ![](images/533f5d7e0c6cc374e12d4d3c734e3d41fc6ad14014462c57fa1def5de3219eb5.jpg)
381
+ Figure 11: User study results of User Sketch to image generation.
382
+
383
+ # E Failure Cases
384
+
385
+ We illustrate some failure cases in Fig. 12. In the first row, although our generated image successfully aligns the Bounding Box condition, the generated human has a distorted body. In the second row, our generated image looks similar to the ground truth; however, the human faces are blurred. We think that the reason is that UniControl inherits the data and model bias of Stable Diffusion, where the generated human commonly have issues. In the third row, the generated image does not look realistic. We believe that the training data can be improved both quantitatively and qualitatively.
386
+
387
+ # F Additional Results
388
+
389
+ We illustrate more visualized results in this section on tasks Canny (Fig. 16), HED (Fig. 17), Depth (Fig. 18), Surface Normal (Fig. 19), Human Skeleton (Fig. 20), Bounding Box (Fig. 21), Segmentation (Fig. 22) and Outpainting (Fig. 23). These results further demonstrate the effectiveness of our proposed method. Moreover, due to the space limitation in the main paper, we report results of the last task, User Sketch. Given a sketched image, UniControl is able to achieve promising realistic images. The visualized results are in Fig. 24. The user study result can be found in Fig. 11, where it is observed that UniControl obtains significantly more votes than the single task model.
390
+
391
+ ![](images/864ebf88f6ec3183b5f05edf0269ae982cf62ec77abde0f6f63e4d7710948da3.jpg)
392
+
393
+ ![](images/05a4ebc5894b0db0cea1eaa2b852f1eb3fba973b98e17810371f725e3b5e3c51.jpg)
394
+ “La tricoteuse Realism William Adolphe Bouguereau Oil Paintings”
395
+
396
+ ![](images/08c58339e14946f66088b5521c45f1e8932b94d016071608b8865306d9348e5f.jpg)
397
+
398
+ “A man and woman in ski gear standing in front of a mountain. “ “The Taj Mahal mirrored by a water fountain's reflection. - Agra, Uttar Pradesh, India - Daily Travel Photos”
399
+
400
+ ![](images/ed2f7c68e031fb8b210652223f09edaaa385153ed362bc6c82925dc718153393.jpg)
401
+ Figure 12: Failure Cases: distorted body (row one); blurred faces (row two); incorrect creation (row three).
402
+
403
+ ![](images/ce300439a093037af0e22018b9d26d71a58799df23ce9342b111dfd41d49307c.jpg)
404
+
405
+ “Christa McAuliffe (right, sat with her backup crew member Barbara Morgan) was a social studies teacher who had won NASA's Teacher in Space contest and earned herself a spot on the mission”
406
+
407
+ ![](images/406de263650c6bfb5fe8a6742a82c576f8bdf7771416a4ff2faecafc56ca8408.jpg)
408
+ Figure 13: More zero-shot-task deblurring results.
409
+
410
+ Gray Image
411
+
412
+ ![](images/a3270977f741084bdf043f1e398e79f8a4eda204077b26f6b699967ba6bf420a.jpg)
413
+
414
+ Our Result
415
+
416
+ ![](images/1fe38f8b80c193320b1b25b181e91c2293b6f9e87787b2cf78ff1bc057b56e01.jpg)
417
+
418
+ # “Long White Casual Wedding Dress”
419
+
420
+ ![](images/0ff793313409af7320cb2ee71b0336a463c8f08a5e0364bf684fad7d31969317.jpg)
421
+
422
+ ![](images/e4a211c18f21ce16dc9b45fa2d06a8fb02cb21839e8c77d31f5659b5a8a2c317.jpg)
423
+
424
+ “Pixie Cropped Short Layered Synthetic Wig for Women-KAMI WIGS”
425
+
426
+ ![](images/0164e828eb13380270f067c363b0186d1bbcb1960acfff09d450029d44bfae3b.jpg)
427
+ Figure 14: More zero-shot-task gray-to-RGB colorization results.
428
+
429
+ ![](images/d8ab528fc162e3fedd70130a5e90757521ec1ccba11b58ef899b5eafafedecf2.jpg)
430
+
431
+ “Early morning view over the town of Tinerhir, south of the Todra Gorge, Morocco, North Africa, Africa”
432
+
433
+ ![](images/f135750c3bf538a1ff4c9800056787e401a4ba3c39c05f42b7e5365257228845.jpg)
434
+ “A lone duck basks in the calm lake's mirror reflection of the Chugach mountain valley”
435
+
436
+ ![](images/1a04600ceab9a09733a2fa4974eaef5863da84806ec06ea5229185e5b32c546c.jpg)
437
+ “Chancellor of the Exchequer Rishi Sunak was the most high-profile, and unexpected, appointment of the day”
438
+
439
+ ![](images/14e02bdaff82cfd7812f3eda8815ab30625440fa03efb8d9ab27d8ab1aec96cf.jpg)
440
+ “Contemporary Bedroom Designs 2015 modern bedroom designs intended design “
441
+ Figure 15: More zero-shot-task image in-painting results. The in-painting MOE adapter weights are directly inherited from outpainting.
442
+
443
+ ![](images/8e4c74d2cca91527f6427f7df6ce14f59247ff3cf6638d066c185853ca69c6df.jpg)
444
+
445
+ ![](images/9ecf91e675f8d8d800075a4ae88a33aef4033b041c54d7252883d8413fccc53c.jpg)
446
+ Figure 17: HED to Image Generation
447
+
448
+ (d) “A young girl who is brushing her teeth with a toothbrush.”
449
+
450
+ ![](images/608c7b4897f463da978e27197fc39ed8b66a83e7604f69f386112f6b0918d592.jpg)
451
+ Figure 18: Depth to Image Generation
452
+
453
+ ![](images/ca0399c20aef42ff8505a70b62dc5bea44a6c393767e01717313e124b3666f8c.jpg)
454
+
455
+ ![](images/307da515b66bcf3263520796363500a159592a4beed485f9abf975cb00a1a13e.jpg)
456
+
457
+ ![](images/edc65b5f77ef0dd345e936158b7a838ee8c6cf8d0c81b2d841c7c90e82621044.jpg)
458
+ Figure 19: Surface Normal to Image Generation
459
+
460
+ ![](images/e2c5a982dc82ee252be359b3af2b07dde3d18070a621e58b6df7d3118d6b8b1a.jpg)
461
+
462
+ ![](images/9e18dba2bbc4da954773e50475189a163a3b565f1883a8a74f58c087783cd511.jpg)
463
+
464
+ (a) “Photo of handsome man in black leather jacket”
465
+
466
+ ![](images/fa35fbc7943b8c85b6b5ea26f058940226239c3b9410569a34218ac3e9c58baa.jpg)
467
+ Input Image<Captio
468
+
469
+ ![](images/fd9e4e671d6ef27027d3e893624e861f319dbfe87dd74710fc10fc8abb2232a6.jpg)
470
+ Our Method Outputhe snow.
471
+
472
+ (b) “A woman is sitting near a prominent landmark”
473
+
474
+ ![](images/bd8a798fcfbbf0d3b80669a48d7e2732efead276d6aa020f703b3c124775fff6.jpg)
475
+ Our Method Outputdesk
476
+
477
+ (c) “A man that has ski’s and is standing in the snow.”
478
+
479
+ ![](images/47cd8d08dfba650e8d11972cc7c3f075e2af3fdcaee7764d368b5a4950bb88b7.jpg)
480
+ Input Image<
481
+ Figure 20: Human Pose Skeleton to Image Generation
482
+
483
+ (d) “A woman is sitting in front of a desk”
484
+
485
+ ![](images/dc7804f648f95a2a22cf80a3473e45e1d7e39a8f68d1387d94119c16ed8279e3.jpg)
486
+
487
+ ![](images/8b48892dcdf5997bd253d939ad73025ccc80eec99a968be71ac95455d87347cc.jpg)
488
+ Input Image
489
+
490
+ ![](images/ac0d32d51c3a9f5f9e32428d2797560fa0131b431c76607efbdf0a8568b787bc.jpg)
491
+ Our Method Output
492
+
493
+ (a) “A bench at the beach next to the sea”ion>: Water traffic along the Thames by Big
494
+
495
+ ![](images/b9bc5fe441a84ca5ed0902d7991aa92463777b428224fad431090fe7457e7254.jpg)
496
+
497
+ ![](images/315d4ce3f1b36966270e3abd883743371420489d36f7a040fadca6242fd11d55.jpg)
498
+ Our Method Output
499
+
500
+ (b) “Water traffic along the Thames by Big Ben”
501
+
502
+ ![](images/169a4907042a8a0f146ea427fe8b9df037cad21d932aaa9d2b192489c82562b1.jpg)
503
+
504
+ (c) “A well-lit and well-decorated living room shows a glimpse of a glass front door through the corridor.”
505
+
506
+ ![](images/9c7333bbce3405b4086a56ad84a32c1c3e9b3432694e06f759f5790b04f6ad72.jpg)
507
+ Figure 22: Segmentation Map (by Uniformer-ADE20K) to Image Generation
508
+
509
+ ![](images/853bb3400ea0e0bc5aa6b87da79c91ab47a4714f6eef163977f142964fd5aed2.jpg)
510
+ Figure 23: Image Outpainting
511
+
512
+ (d) “Beautiful kitchen grand scale living pinterest for Kitchen cabinets lowes with old world metal wall art”
513
+
514
+ ![](images/c113ff5911f48b8ab6744e8638c79653ea69d2209d8794f4319072c9f2846759.jpg)
515
+
516
+ ![](images/0f48ffb5077bb8a7f0ec71d24de98c629e02d50df7b51f1664154ac9a5c945f5.jpg)
517
+ (a) “A Limited Edition, Fine Art photograph of a beautiful sunrise at Lake Jackson in Sebring, Florida. Available as a Fine Art print”
518
+ Figure 24: User Sketch to Image Generation
519
+
520
+ (d) “Superhero watching over city. No transparency used. Basic (linear) gradients. A4 proportions.”
md/dev/vGQiU5sqUe3/vGQiU5sqUe3.md ADDED
@@ -0,0 +1,401 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contrastive Learning as Goal-Conditioned Reinforcement Learning
2
+
3
+ Tianjun Zhangγ Sergey Levineβ,γ Ruslan Salakhutdinovα U βGoogle Research γUC Berkeley
4
+
5
+ # Abstract
6
+
7
+ In reinforcement learning (RL), it is easier to solve a task if given a good representation. While deep RL should automatically acquire such good representations, prior work often finds that learning representations in an end-to-end fashion is unstable and instead equip RL algorithms with additional representation learning parts (e.g., auxiliary losses, data augmentation). How can we design RL algorithms that directly acquire good representations? In this paper, instead of adding representation learning parts to an existing RL algorithm, we show (contrastive) representation learning methods can be cast as RL algorithms in their own right. To do this, we build upon prior work and apply contrastive representation learning to action-labeled trajectories, in such a way that the (inner product of) learned representations exactly corresponds to a goal-conditioned value function. We use this idea to reinterpret a prior RL method as performing contrastive learning, and then use the idea to propose a much simpler method that achieves similar performance. Across a range of goal-conditioned RL tasks, we demonstrate that contrastive RL methods achieve higher success rates than prior non-contrastive methods, including in the offline RL setting. We also show that contrastive RL outperforms prior methods on image-based tasks, without using data augmentation or auxiliary objectives. 1
8
+
9
+ # 1 Introduction
10
+
11
+ Representation learning is an integral part of reinforcement learning $( \mathrm { R L } ^ { 2 } )$ algorithms. While such representations might emerge from end-to-end training [7, 79, 119, 126], prior work has found it necessary to equip RL algorithms with perception-specific loss functions [32, 44, 71, 89, 91, 101, 116, 140] or data augmentations [69, 73, 116, 118], effectively decoupling the representation learning problem from the reinforcement learning problem. Given what prior work has shown about RL in the presence of function approximation and state aliasing [2, 135, 138], it is not surprising that end-to-end learning of representations is fragile [69, 73]: an algorithm needs good representations to drive the learning of the RL algorithm, but the RL algorithm needs to drive the learning of good representations. So, can we design RL algorithms that do learn good representations without the need for auxiliary perception losses?
12
+
13
+ Rather than using a reinforcement learning algorithm also to solve a representation learning problem, we will use a representation learning algorithm to also solve certain types of reinforcement learning problems, namely goal-conditioned RL. Goal-conditioned RL is widely studied [6, 15, 22, 62, 80, 120], and intriguing from a representation learning perspective because it can be done in an entirely self-supervised manner, without manually-specified reward functions. We will focus on contrastive (representation) learning methods, using observations from the same trajectory (as done in prior work [95, 109]) while also including actions as an additional input (See Fig. 1). Intuitively, contrastive learning then resembles a goal-conditioned value function: nearby states have similar representations and unreachable states have different representations. We make this connection precise, showing that sampling positive pairs using the discounted state occupancy measure results in learning representations whose inner product exactly corresponds to a value function.
14
+
15
+ ![](images/cd5df224f921c81048f98a3e7493620ab5683623d594ddd76acd0280121c9b97.jpg)
16
+ Figure 1: Reinforcement learning via contrastive learning. Our method uses contrastive learning to acquire representations of state-action pairs $( \phi ( s , a ) )$ and future states $( \psi ( s _ { f } ) )$ , so that the representations of future states are closer than the representations of random states. We prove that learned representation corresponds to a value function for a certain reward function. To select actions for reaching goal $s _ { g }$ , the policy chooses the action where $\phi ( s , a )$ is closest to $\psi ( s _ { g } )$ .
17
+
18
+ In this paper, we show how contrastive representation learning can be used to perform goalconditioned RL. We formally relate the learned representations to reward maximization, showing that the inner product between representations corresponds to a value function. This framework of contrastive RL generalizes prior methods, such as C-learning [29], and suggests new goal-conditioned RL algorithms. One new method achieves performance similar to prior methods but is simpler; another method consistently outperforms the prior methods. On goal-conditioned RL tasks with image observations, contrastive RL methods outperform prior methods that employ data augmentation and auxiliary objectives, and do so without data augmentation or auxiliary objectives. In the offline setting, contrastive RL can outperform prior methods on benchmark goal-reaching tasks, sometimes by a wide margin.
19
+
20
+ # 2 Related Work
21
+
22
+ This paper will draw a connection between RL and contrastive representation learning, building upon a long line of contrastive learning methods in NLP and computer vision, and deep metric learning [17, 53, 54, 54, 56, 77, 84, 86, 87, 94, 95, 108, 109, 113, 122, 129, 132]. Contrastive learning methods learn representations such that similar (“positive”) examples have similar representations and dissimilar (“negative”) examples have dissimilar representations.3 While most methods generate the “positive” examples via data augmentation, some methods generate similar examples using different camera viewpoints of the same scene [109, 122], or by sampling examples that occur close in time within time series data [4, 95, 109, 118]. Our analysis will focus on this latter strategy, as the dependence on time will allow us to draw a precise relationship with the time dependence in RL.
23
+
24
+ Deep RL algorithms promise to automatically learn good representations, in an end-to-end fashion. However, prior work has found it challenging to uphold this promise [7, 79, 119, 126], prompting many prior methods to employ separate objectives for representation learning and RL [32, 44, 71, 89, 91, 100, 101, 116, 118, 140, 143]. Many prior methods choose a representation learning objectives that reconstruct the input state [32, 47, 49, 50, 71, 91, 93, 141] while others use contrastive representation learning methods [89, 95, 111, 116, 118]. Unlike these prior methods, we will not use a separate representation learning objective, but instead use the same objective for both representation learning and reinforcement learning. Some prior RL methods have also used contrastive learning to acquire reward functions [14, 20, 33, 38, 63, 67, 92, 133, 134, 146], often in imitation learning settings [37, 55]. In contrast, we will use contrastive learning to directly acquire a value function, which (unlike a reward function) can be used directly to take actions, without any additional RL.
25
+
26
+ This paper will focus on goal-conditioned RL problems, a problem prior work has approached using temporal difference learning [6, 29, 62, 80, 103, 106], conditional imitation learning [22, 41, 83, 105, 120], model-based methods [23, 107], hierarchical RL [90], and planning-based methods [30, 93, 105, 115]. The problems of automatically sampling goals and exploration [24, 35, 85, 98, 144] are orthogonal to this work. Like prior work, we will parametrize the value function as an inner product between learned representations [34, 58, 106]. Unlike these prior methods, we will learn a value function directly via contrastive learning, without using reward functions or TD learning.
27
+
28
+ Our analysis will be most similar to prior methods [11, 15, 29, 103] that view goal-conditioned RL as a data-driven problem, rather than as a reward-maximization problem. Many of these methods employ hindsight relabeling [6, 26, 62, 78], wherein experience is relabeled with an outcome that occurred in the future. Whereas hindsight relabeling is typically viewed as a trick to add on top of an RL algorithm, this paper can roughly be interpreted as showing that the hindsight relabeling is a standalone RL algorithm. Many goal-conditioned methods learn a value function that captures the similarity between two states [29, 62, 91, 125]. Such distance functions are structurally similar to the critic function learned for contrastive learning, a connection we make precisely in Sec. 4. In fact, our analysis shows that C-learning [29] is already performing contrastive learning, and our experiments show that alternative contrastive RL methods can be much simpler and achieve higher performance.
29
+
30
+ Prior work has studied how representations related to reward functions using the framework of universal value functions [12, 106] and successor features [9, 52, 81]. While these methods typically require additional supervision to drive representation learning (manually-specified reward functions or features), our method is more similar to prior work that estimates the discounted state occupancy measure as an inner product between learned representations [11, 131]. While these methods use temporal difference learning, ours is akin to Monte Carlo learning. While Monte Carlo learning is often (but not always [23]) perceived as less sampling efficient, our experiments find that our approach can be as sample efficient as TD methods. Other prior work has focused on learning representations that can be used for planning [59, 82, 104, 105, 128]. Our method will learn representations using an objective similar to prior work [105, 109], but makes the key observation that the representation already encodes a value function: no additional planning or RL is necessary to choose actions.
31
+
32
+ Please see Appendix A for a discussion of how our work relates to unsupervised skill learning.
33
+
34
+ # 3 Preliminaries
35
+
36
+ Goal-conditioned reinforcement learning. The goal-conditioned RL problem is defined by states $s _ { t } \in S$ , actions $a _ { t }$ , an initial state distribution $p _ { 0 } \overline { { ( } } s )$ , the dynamics $p ( \boldsymbol { \dot { s } } _ { t + 1 } \mid s _ { t } , \boldsymbol { a } _ { t } )$ , a distribution over goals $p _ { g } ( s _ { g } )$ , and a reward function $r _ { g } { \left( s , \bar { a } \right) }$ for each goal. This problem is equivalent to a multi-task RL [5, 45, 121, 130, 139], where tasks correspond to reaching goals states. Following prior work [11, 15, 29, 103], we define the reward as the probability (density) of reaching the goal at the next time step:4
37
+
38
+ $$
39
+ r _ { g } ( s _ { t } , a _ { t } ) \triangleq ( 1 - \gamma ) p ( s _ { t + 1 } = s _ { g } \ | \ s _ { t } , a _ { t } ) .
40
+ $$
41
+
42
+ This reward function is appealing because it avoids the need for a human user to specify a distance metric (unlike, e.g., [6]). Even though our method will not estimate the reward function, we will still use the reward function for analysis. For a goal-conditioned policy $\pi ( \boldsymbol { a } \mid \boldsymbol { s } , \boldsymbol { s } _ { g } )$ , we use $\pi ( \tau \mid s _ { g } )$ to denote the probability of sampling an infinite-length trajectory $\tau = ( s _ { 0 } , a _ { 0 } , s _ { 1 } , a _ { 1 } , \cdot \cdot \cdot )$ . We defined the expected reward objective and Q-function as
43
+
44
+ $$
45
+ \operatorname* { m a x } _ { \pi } \mathbb { E } _ { p _ { g } ( s _ { g } ) , \pi ( \tau | s _ { g } ) } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r _ { g } ( s _ { t } , a _ { t } ) \right] , \quad Q _ { s _ { g } } ^ { \pi } ( s , a ) \triangleq \mathbb { E } _ { \pi ( \tau | s _ { g } ) } \left[ \sum _ { t ^ { \prime } = t } ^ { \infty } \gamma ^ { t ^ { \prime } - t } r _ { g } ( s _ { t ^ { \prime } } , a _ { t ^ { \prime } } ) \mid \mathbf { \Pi } _ { a _ { t } = a } ^ { s _ { t } = s _ { t } } \right] .
46
+ $$
47
+
48
+ Intuitively, this objective corresponds to sampling a goal $s _ { g }$ and then optimizing the policy to go to that goal and stay there. Finally, we define the discounted state occupancy measure as [55, 142]
49
+
50
+ $$
51
+ p ^ { \pi ( \cdot | \cdot , s _ { g } ) } ( s _ { t + } = s ) \triangleq ( 1 - \gamma ) \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } p _ { t } ^ { \pi ( \cdot | \cdot , s _ { g } ) } ( s _ { t } = s ) ,
52
+ $$
53
+
54
+ where $p _ { t } ^ { \pi } ( s )$ is the probability density over states that policy $\pi$ visits after $t$ steps. Sampling from the discounted state occupancy measure is easy: the first sample a time offset from a geometric distribution $\boldsymbol { \mathit { t } } \sim \mathbf { \mathrm { G E O M } } ( 1 - \gamma ) )$ , and then look at what state the policy visits after exactly $t$ steps. We will use $s _ { t + }$ to denote states sampled from the discounted state occupancy measure. Because our method will combine experience collected from multiple policies, we also define the average stationary distribution as $p ^ { \pi \^ { \cdot } \mid \cdot \rangle } ( s _ { t + } = s \mid s , a ) \triangleq \int p ^ { \pi ( \cdot \mid \cdot , s _ { g } ) } ( s _ { t + } = s \mid s , a ) p ^ { \pi } ( s _ { g } \mid s , a ) d \bar { s } _ { g \pi }$ where $p ^ { \pi } ( s _ { g } \mid s , a )$ is the probability of the commanded goal given the current state-action pair. This stationary distribution is equivalent to that of the policy $\begin{array} { r } { \pi ( \boldsymbol { a } \mid \boldsymbol { s } ) \triangleq \int \pi ( \boldsymbol { a } \mid \boldsymbol { s } , \boldsymbol { s } _ { g } ) p ^ { \pi } ( \boldsymbol { s } _ { g } \mid \boldsymbol { s } ) d \boldsymbol { s } _ { g } } \end{array}$ [145].
55
+
56
+ Contrastive representation learning. Contrastive representation learning methods [17, 46, 53, 54, 61, 77, 84, 86, 87, 122, 124, 129] take as input pairs of positive and negative examples, and learn representations so that positive pairs have similar representations and negative pairs have dissimilar representations. We use $( u , v )$ to denote an input pair (e.g., $u$ is an image, and $v$ is an augmented version of that image). Positive examples are sampled from a joint distribution $p ( u , v )$ , while negative examples are sampled from the product of marginal distributions, $p ( u ) p ( v )$ . We will use an objective based on binary classification [77, 86, 87, 94]. Let $f ( u , v ) = \phi ( u ) ^ { T } \psi ( v )$ be the similarity between the representations of $u$ and $v$ . We will call $f$ the critic function5 and note that its range is $( - \infty , \infty )$ . We will use NCE-binary [84] objective (also known as InfoMAX [54]):
57
+
58
+ $$
59
+ \operatorname* { m a x } _ { f ( u , v ) } \mathbb { E } _ { ( u , v ^ { + } ) \sim p ( u , v ) } \biggl [ \log \sigma \bigl ( \underbrace { f ( u , v ^ { + } ) } _ { \phi ( u ) ^ { T } \psi ( v ^ { + } ) } \bigr ) + \log \bigl ( 1 - \sigma \bigl ( \underbrace { f ( u , \mathrm { ~ \xi ~ } ) } _ { \phi ( u ) ^ { T } \psi ( \mathrm { ~ \xi ~ } ) } \bigr ) \bigr ) \biggr ] .
60
+ $$
61
+
62
+ # 4 Contrastive Learning as an RL Algorithm
63
+
64
+ This section shows how to use contrastive representation to directly perform goal-conditioned RL. The key idea (Lemma 4.1) is that contrastive learning estimates the Q-function for a certain policy and reward function. To prove this result, we relate the Q-function to the state occupancy measure (Sec. 4.1) and then relate the optimal critic function to the state occupancy measure (Sec. 4.2).
65
+
66
+ This result allows us to propose a new algorithm for goal-conditioned RL based on contrastive learning. Unlike prior work, this algorithm is not adding contrastive learning on top of an existing RL algorithm. This framework generalizes C-learning [29], offering a cogent explanation for its good performance while also suggesting new methods that are simpler and can achieve higher performance.
67
+
68
+ # 4.1 Relating the Q-function to probabilities
69
+
70
+ This section sets the stage for the main results of this section by providing a probabilistic perspective goal-conditioned RL. The expected reward objective and associated Q-function in (Eq. 2) can equivalently be expressed as the probability (density) of reaching a goal in the future:
71
+
72
+ Proposition 1 (rewards probabilities). The $Q$ -function for the goal-conditioned reward function $r _ { g }$ (Eq. 1) is equivalent to the probability of state $s _ { g }$ under the discounted state occupancy measure:
73
+
74
+ $$
75
+ Q _ { s _ { g } } ^ { \pi } ( s , a ) = p ^ { \pi ( \cdot | \cdot , s _ { g } ) } ( s _ { t + } = s _ { g } \mid s , a ) .
76
+ $$
77
+
78
+ The proof is in Appendix B. Translating rewards into probabilities not only makes it easier to analyze the goal-conditioned problem, but also means that any method for estimating probabilities (e.g., contrastive learning) can be turned into a method for estimating this Q-function.
79
+
80
+ # 4.2 Contrastive Learning Estimates a Q-Function
81
+
82
+ We will use contrastive learning to learn a value function by carefully choosing the inputs $u$ and $v$ . The first input, $u$ , will correspond to a state-action pair, $u \dot { = } ( s _ { t } , a _ { t } \dot { ) } \sim p ( s , a \dot { ) }$ . In practice, these pairs are sampled from the replay buffer. Including the actions in the input is important because it will allow us to determine which actions to take to reach a desired future state. The second variable, $v$ , is a future state, $v = s _ { f }$ . For the “positive” training pairs, the future state is sampled from the discounted state occupancy measure, $s _ { f } \sim p ^ { \pi ( \cdot | \cdot ) } ( s _ { t + } \mid s _ { t } , a _ { t } )$ . For the “negative” training pairs, we sample a future state from a random state-action pair: $\begin{array} { r } { \mathfrak { s } _ { f } \sim p ( \mathfrak { s } _ { t + } ) \underline { { \triangleq } } \int p ^ { \pi ( \cdot | \cdot ) } ( \mathfrak { s } _ { t + } \mid \mathfrak { s } , a ) p ( \mathfrak { s } , a ) d \mathfrak { s } d a } \end{array}$ . With these inputs, the contrastive learning objective (Eq. 4) can be written as
83
+
84
+ $$
85
+ \begin{array} { r l } & { \underset { f } { \operatorname* { m a x } } \mathbb { E } _ { ( s , a ) \sim p ( s , a ) , \quad \sim p ( s _ { f } ) } \left[ \mathcal { L } ( s , a , s _ { f } ^ { + } , \mathrm { ~ \lambda ~ } ) \right] , } \\ & { \quad \quad \quad \quad s _ { f } ^ { + } \sim p ^ { \pi ( \cdot | \cdot ) } ( s _ { t + } | s _ { t } , a _ { t } ) } \\ & { \quad \quad \quad \mathrm { w h e r e } \quad \mathcal { L } ( s , a , s _ { f } ^ { + } , \mathrm { ~ \lambda ~ } ) \triangleq \log \sigma ( \underset { \phi ( s , a ) ^ { T } \psi ( s _ { f } ^ { + } ) } { \underbrace { f ( s , a , s _ { f } ^ { + } ) } } ) + \log ( 1 - \sigma ( \underset { \phi ( s , a ) ^ { T } \psi ( \mathrm { ~ \lambda ~ } ) } { \underbrace { f ( s , a , \mathrm { ~ \lambda ~ } ) } } ) ) . } \end{array}
86
+ $$
87
+
88
+ Intuitively, the critic function $f ( u = ( s _ { t } , a _ { t } ) , v = s _ { f } )$ now tells us the correlation between the current state-action pair and future outcomes, analogous to a Q-function. We therefore can use the critic function in the same way as actor-critic RL algorithms [66], figuring out which actions lead to the desired outcome. Because the Bayes-optimal critic function is a function of the state occupancy measure [84], $\begin{array} { r } { f ^ { * } ( s , a , s _ { g } ) = \log \Big ( \frac { \bar { p } ^ { \pi ( \cdot | \cdot ) } \bar { ( } s _ { t + } = s _ { g } | s , a ) } { p ( s _ { g } ) } \Big ) } \end{array}$ , it can be used to express the Q-function:
89
+
90
+ Lemma 4.1. The critic function that optimizes Eq. $6$ is a $Q$ -function for the goal-conditioned reward function (Eq. 1), up to a multiplicative constant p(sf ) : $\begin{array} { r } { \exp ( f ^ { * } ( s , a , s _ { f } ) ) = \frac { 1 } { p ( s _ { f } ) } \cdot Q _ { s _ { f } } ^ { \pi ( \cdot | \cdot ) } ( s , a ) } \end{array}$ .
91
+
92
+ The critic function can be viewed as an unnormalized density model, where $p ( s _ { g } )$ is the partition function. Much of the appeal of contrastive learning is it avoids estimating the partition function [46], which can be challenging; in the RL setting, it will turn out that this constant can be ignored when selecting actions. Our experiments show that learning a normalized density model works well when $s _ { g }$ is low-dimensional, but struggles to solve higher-dimensional tasks.
93
+
94
+ This lemma relates the critic function to $Q _ { s _ { f } } ^ { \pi ( \cdot | \cdot ) } ( s , a )$ , not $Q _ { s _ { f } } ^ { \pi ( \cdot | \cdot , s _ { f } ) } ( s , a )$ . The underlying reason is that the critic function combines together experience collected when commanding different goals. Prior goal-conditioned behavioral cloning methods [22, 41, 83, 120] perform similar sharing, but do not analyze the relationship between the learned policies and Q functions. Sec. 4.5 shows that this critic function can be used as the basis for a convergent RL algorithm under some assumptions.
95
+
96
+ # 4.3 Learning the Goal-Conditioned Policy
97
+
98
+ The learned critic function not only tells us the likelihood of future states, but also tells us how different actions change the likelihood of a state occurring in the future. Thus, to learn a policy for reaching a goal state, we choose the actions that make that state most likely to occur in the future:
99
+
100
+ $$
101
+ \operatorname* { m a x } _ { \pi ( a | s , s _ { g } ) } \mathbb { E } _ { \pi ( a | s , s _ { g } ) p ( s ) p ( s _ { g } ) } \left[ f ( s , a , s _ { f } = s _ { g } ) \right] \approx \mathbb { E } _ { \pi ( a | s , s _ { g } ) p ( s ) p ( s _ { g } ) } \left[ \log Q _ { s _ { g } } ^ { \pi ( \cdot | \cdot ) } ( s , a ) - \log p ( s _ { g } ) \right] .
102
+ $$
103
+
104
+ The approximation above reflects errors in learning the optimal critic, and will allow us to prove that this policy loss corresponds to policy improvement in Sec. 4.5, under some assumptions.
105
+
106
+ In practice, we parametrize the goal-conditioned policy as a neural network that takes as input the state and goal and outputs a distribution over actions. The actor loss (Eq. 7) is computed by sampling states and random goals from the replay buffer, sampling actions from the policy, and then taking gradients on the policy using a reparametrization gradient. On tasks with image observations, we add an action entropy term to the policy objective.
107
+
108
+ # 4.4 A Complete Goal-Conditioned RL Algorithm
109
+
110
+ The complete algorithm alternates between fitting the critic function using contrastive learning, updating the policy using Eq. 7, and collecting more data. Alg. 1 provides a JAX [13] implementation of the actor and critic losses. Note that the critic is parameterized as an inner product between a representation of the state-action pair, and a representation of the goal state: $f ( s , \dot { a } , s _ { g } ) = \phi ( s , a ) ^ { T } \psi ( \dot { s } _ { g } )$ . This parameterization allows for efficient computation, as we can compute the goal representations just once, and use them both in the positive pairs and the negative pairs. While this is common practice in representation learning, it is not exploited by most goal-conditioned RL algorithms. We refer to this method as contrastive RL (NCE). In Appendix C, we derive a variant of this method (contrastive RL (CPC)) that uses the infoNCE bound on mutual information.
111
+
112
+ Algorithm 1 Contrastive RL (NCE): the actor and critic losses for our method.
113
+
114
+ from jax.numpy import einsum, eye
115
+ from optax import sigmoid_binary_cross_entropy
116
+ def critic_loss(states, actions, future_states): sa_repr $=$ sa_encoder(states, actions) # (batch_dim, repr_dim) g_repr $-$ g_encoder(future_states) # (batch_dim, repr_dim) logits $-$ einsum('ik,jk->ij', sa_repr, g_repr) # <sa_repr[i], g_repr[j]> for all i,j return sigmoid_binary_cross_entropy(logits $=$ logits, labels $-$ eye(batch_size))
117
+
118
+ def actor_loss(states, goals): actions $=$ policy.sample(states, goal $\mathbf { \Psi } =$ goals) # (batch_size, action_dim) sa_repr $=$ sa_encoder(states, actions) # (batch_dim, repr_dim) g_repr $-$ g_encoder(goals) # (batch_dim, repr_dim) logits $=$ einsum('ik,ik->i', sa_repr, g_repr) # <sa_repr[i], g_repr[i]> return $^ { - 1 . 0 * }$ logits
119
+
120
+ Contrastive RL (NCE) is an on-policy algorithm because it only estimates the Q-function for the policy that collected the data. However, in practice, we take as many gradient steps on each transition as standard off-policy RL algorithms [40, 48]. Please see Appendix E for full implementation details. We will also release an efficient implementation based on ACME [57] and JAX [13]. On a single TPUv2, training proceeds at $1 1 0 0 \frac { \mathrm { b a t c h e s } } { \mathrm { s e c } }$ for state-based tasks and $1 0 5 \frac { \mathrm { b a t c h e s } } { \mathrm { s e c } }$ for image-based tasks; for comparison, our implementation of $\mathrm { D r Q }$ on the same hardware setup runs at $2 8 \frac { \mathrm { b a t c h e s } } { \sec }$ $3 . 9 \times$ slower).6 Architectures and hyperparameters are described in Appendix E.7
121
+
122
+ # 4.5 Convergence Guarantees
123
+
124
+ In general, providing convergence guarantees for methods that perform relabeling is challenging. Most prior work offers no guarantees [6, 22, 23] or guarantees under only restrictive assumptions [41, 120].
125
+
126
+ To prove that contrastive RL converges, we will introduce an additional filtering step into the method, throwing away some training examples. Precisely, we exclude training examples $( s , a , s _ { f } )$ if the probability of the corresponding trajectory $\tau _ { i : j } ~ = ~ ( s _ { i } , a _ { i } , s _ { i + 1 } , a _ { i + 1 } , \cdot \cdot \cdot ~ , s _ { j } , a _ { j } )$ sampled from $\pi ( \tau \mid s _ { g } )$ under the commanded goal $s _ { g }$ is very different from the trajectory’s probability under the actually-reached goal $s _ { j }$ :
127
+
128
+ $$
129
+ \mathrm { E x c L U D E T R A J } ( \tau _ { i : j } ) = \delta \left( \left| \frac { \pi ( \tau _ { i : j } \mid s _ { g } ) } { \pi ( \tau _ { i : j } \mid s _ { j } ) } - 1 \right| > \epsilon \right) .
130
+ $$
131
+
132
+ While this modification is necessary to prove convergence, ablation experiments in Appendix Fig. 13 show that the filtering step can actually hurt performance in practice, so we do not include this filtering step in the experiments in the main text. We can now prove that contrastive RL performs approximate policy improvement.
133
+
134
+ Lemma 4.2 (Approximate policy improvement). Assume that states and actions are tabular and assume that the critic is Bayes-optimal. Let $\pi ^ { \prime } ( a \mid s , s _ { g } )$ be the goal-conditioned policy obtained after one iteration of contrastive $R L$ with a filtering parameter of ϵ. Then this policy achieves higher rewards than the initial goal-conditioned policy:
135
+
136
+ $$
137
+ \Sigma _ { \pi ^ { \prime } ( \tau | s _ { g } ) } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r _ { s _ { g } } ( s _ { t } , a _ { t } ) \right] \geq \mathbb { E } _ { \pi ( \tau | s _ { g } ) } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r _ { s _ { g } } ( s _ { t } , a _ { t } ) \right] - \frac { 2 \gamma \epsilon } { 1 - \gamma } ~ f o r a l l g o a l s ~ s _ { g } \in \left\{ s _ { g } ~ \left| ~ p _ { g } ( s _ { g } ) > 0 \right. \right\} ~ ,
138
+ $$
139
+
140
+ The proof is in Appendix B. This result shows that performing contrastive RL on static dataset results in one step of approximate policy improvement. Re-collecting data and then applying contrastive RL over and over again corresponds to approximate policy improvement (see [10, Lemma 6.2]).
141
+
142
+ In summary, we have shown that applying contrastive learning to a particular choice of inputs results in an RL algorithm, one that learns a Q-function and (under some assumptions) converges to the reward-maximizing policy. Contrastive RL (NCE) is simple: it does not require multiple Q-values [40], target Q networks [88], data augmentation [69, 73], or auxiliary objectives [116, 137].
143
+
144
+ ![](images/1ca64a2563f82d848be02ca5d79a9b6c2d6a9a63377d212c19ae23f7a98b5dc1.jpg)
145
+ Figure 2: Goal-conditioned RL. Contrastive RL (NCE) outperforms prior methods on most tasks. Baselines: HER [80] is a prototypical actor-critic method that uses hindsight relabeling [6]; Goal-conditioned behavioral cloning (GCBC) [22, 41, 83, 117] performs behavior cloning on relabeled experience; model-based fits a density model to the discounted state occupancy measure, similar on [21, 23, 60].
146
+
147
+ # 4.6 C-learning as Contrastive Learning
148
+
149
+ C-learning [29] is a special case of contrastive RL: it learns a critic function to distinguish future goals from random goals. Compared with contrastive RL (NCE), C-learning learns the classifier using temporal difference learning.8 Viewing C-learning as a special case of contrastive RL suggests that contrastive RL algorithms might be implemented in a variety of different ways, each with relative merits. For example, contrastive RL (NCE) is much simpler than C-learning and tends to perform a bit better. Appendix D introduces another member of the contrastive RL family (contrastive RL (NCE + C-learning)) that tends to yield the best performance .
150
+
151
+ # 5 Experiments
152
+
153
+ Our experiments use goal-conditioned RL problems to compare contrastive RL algorithms to prior non-contrastive methods, including those that use data augmentation and auxiliary objectives. We then compare different members of the contrastive RL family, and show how contrastive RL can be effectively applied to the offline RL setting. Appendices E, F, and G contain experiments, visualizations, and failed experiments.
154
+
155
+ # 5.1 Comparing to prior goal-conditioned RL methods
156
+
157
+ Baselines. We compare three baselines. “HER” [80] is a goal-conditioned RL method that uses hindsight relabeling [6] with a high-performance actor-critic algorithm (TD3). This baseline is representative of a large class of prior work that uses hindsight relabeling [6, 76, 102, 106]. Like contrastive RL, this baseline does not assume access to a reward function. The second baseline is
158
+
159
+ ![](images/24bf4c78e2ba76c9727632380dd31f4b4da6d0eed9bfd40baba1900e44491f7a.jpg)
160
+ Figure 3: Environments. We show a subset of the goal-conditioned environments used in our experiments.
161
+
162
+ goal-conditioned behavioral cloning (“GCBC”) [16, 22, 25, 41, 83, 96, 117, 120], which trains a policy to reach goal $s _ { g }$ by performing behavioral cloning on trajectories that reach state $s _ { g }$ . GCBC is a simple method that achieves excellent results [16, 25] and has the same inputs as our method $( ( s , a , s _ { f } )$ triplets). A third baseline is a model-based approach that fits a density model to the future state distribution $p ^ { \pi ( \cdot | \cdot ) } ( s _ { t + } \mid s , a )$ and trains a goal-conditioned policy to maximize the probability of the commanded goal. This baseline is similar to successor representations [21] and prior multi-step models [23, 60]. Both contrastive RL (Alg. 1) and this model-based approach encode the future state distribution, but the output dimension of this model-based method depends on the state dimension. We, therefore, expect this approach to excel in low-dimensional settings but struggle with image-based tasks. Where possible, we use the same hyperparameters for all methods. We will include additional representation learning baselines when studying representations in the subsequent section.
163
+
164
+ ![](images/0324fcf7af9daa045c58010e6953799e910ecb3fa84c8569ea4158d45379765d.jpg)
165
+ Figure 4: Representation learning for image-based tasks. While adding data augmentation and auxiliary representation objectives can boost the performance of the $_ { \mathrm { T D } 3 + \mathrm { H E R } }$ baseline, replacing the underlying goalconditioned RL algorithm with one that resembles contrastive representation learning (i.e., ours) yields a larger increase in success rates. Baselines: $\mathtt { D r Q }$ [69] augments images and averages the Q-values across 4 augmentations; auto encoder (AE) adds an auxiliary reconstruction loss [32, 91, 93, 137]; CURL [116] applies RL on top of representations learned via augmentation-based contrastive learning.
166
+
167
+ Tasks. We compare it to a suite of goal-conditioned tasks, mostly taken from prior work. Four standard manipulation tasks include fetch reach and fetch push from Plappert et al. [97] and sawyer push and sawyer bin from Yu et al. [139]. We evaluate these tasks both with state-based observations and (unlike most prior work) image-based observations. The sawyer bin task poses an exploration challenge, as the agent must learn to pick up an object from one bin and place it at a goal location in another bin; the agent does not receive any reward shaping or demonstrations. We include two navigation tasks: point Spiral11x11 is a 2D maze task with image observations and ant umaze [36] is a 111-dimensional locomotion task that presents a challenging low-level control problem. Where possible, we use the same initial state distribution, goal distribution, observations, and definition of success as prior work. Goals have the same dimension as the states, with one exception: on the ant umaze task, we used the global $X Y$ position as the goal. We illustrate three of the tasks to the right. The agent does not have access to any ground truth reward function.
168
+
169
+ We report results in Fig. 2, using five random seeds for each experiment and plotting the mean and standard deviation across those random seeds. On the state-based tasks (Fig. 2a), most methods solve the easiest task (fetch reach) while only our method solves the most challenging task (sawyer bin). Our method also outperforms all prior methods on the two pushing tasks. The model-based baseline performs best on the ant umaze task, likely because learning a model is relatively easy when the goal is lower-dimensional (just the $X Y$ location). On the image-based tasks (Fig. 2b), most methods make progress on the two easiest tasks (fetch reach and point Spiral11x11); our method outperforms the baselines on the three more challenging tasks. Of particular note is the success on sawyer push and sawyer bin: while the success rate of our method remains below $50 \%$ , no baselines make any progress on learning these tasks. These results suggest that contrastive RL (NCE) is a competitive goal-conditioned RL algorithm.
170
+
171
+ # 5.2 Comparing to prior representation learning methods
172
+
173
+ We hypothesize that contrastive RL may automatically learn good representations. To test this hypothesis, we compare contrastive RL (NCE) to techniques proposed by prior work for representation learning. These include data augmentation [69, 73, 136] (“DrQ”) and auxiliary objectives based on an autoencoder [32, 91, 93, 137] (“AE”) and a contrastive learning objective (“CURL”) that generates positive examples using data augmentation, similar to prior work [89, 116, 118]. Because prior work has demonstrated these techniques in combination with actor-critic RL algorithms, we will use these techniques in combination with the actor-critic baseline from the previous section $( ^ { 6 6 } \mathrm { T D } 3 + \mathrm { H E R } ^ { \prime \prime } )$ ). While contrastive RL (NCE) resembles a contrastive representation learning method, it does not include any data augmentation or auxiliary representation learning objectives.
174
+
175
+ We show results in Fig. 4, with error bars again showing the mean and standard deviation across 5 random seeds. While adding the autoencoder improves the baseline on the fetch reach and adding DrQ improves the baseline on the sawyer push, contrastive RL (NCE) outperforms the prior methods on all tasks. Unlike these methods, contrastive RL does not use auxiliary objectives or additional domain knowledge in the form of image-appropriate data augmentations. These experiments do not show that representation learning is never useful, and do not show that contrastive
176
+
177
+ ![](images/7e580f4f14c0433f5ed7ccbf2ee289aa28efe0ce128a7053ace894649b8ff6f2.jpg)
178
+ Figure 5: Contrastive RL design decisions. Generalizing C-learning to a family of contrastive RL algorithms allowed us to identify algorithms that are much simpler (contrastive RL (NCE)) and that consistently achieve higher performance (contrastive RL $\mathrm { N C E } + \mathrm { C } .$ -learning)).
179
+
180
+ RL cannot be improved with additional representation learning machinery. Rather, they show that designing RL algorithms that structurally resemble contrastive representation learning yields bigger improvements than simply adding representation learning tricks on top of existing RL algorithms.
181
+
182
+ # 5.3 Probing the dimensions of contrastive RL
183
+
184
+ Up to now, we have focused on the specific instantiation of contrastive RL spelled out in Alg. 1. However, there is a whole family of RL algorithms with contrastive characteristics. C-learning is a contrastive RL algorithm that uses temporal difference learning (Sec. 4.6). Contrastive RL (CPC) is a variant of Alg. 1 based on the infoNCE objective [95] that we derive in Appendix C Contrastive RL $\mathrm { \Delta N C E + C }$ -learning) is a variant that combines C-learning with Alg. D (see Appendix D.). The aim of these experiments are to study whether generalizing C-learning to a family of contrastive RL algorithms was useful: do the simpler methods achieve similar performance, and do other methods achieve better performance?
185
+
186
+ We present results in Fig. 5, again plotting the mean and standard deviation across five random seeds. Contrastive RL (CPC) outperforms contrastive RL (NCE) on three, suggesting that swapping one mutual information estimator for another can sometimes improve performance, though both estimators can be effective. C-learning outperforms contrastive RL (NCE) on three tasks but performs worse on other tasks. Contrastive RL $\mathrm { \mathrm { N C E } } + \mathrm { C } .$ -learning) consistently ranks among the best methods. These experiments demonstrate that the prior contrastive RL method, C-learning [29], achieves good results on most tasks; generalizing C-learning to a family of contrastive RL algorithms resulting in new algorithms that achieve higher performance and can be much simpler.
187
+
188
+ # 5.4 Partial Observability and Moving Cameras
189
+
190
+ Many realistic robotics tasks exhibit partial observability, and have cameras that are not fixed but rather attached to moving robot parts. Our next experiment tests if contrastive RL can cope with these sorts of challenges. To study this question, we modified the sawyer push task so that the camera tracks the hand at a fixed distance, as if it were rigidly mounted to the arm. This means that, at the start of the episode, the scene is occluded by the wall at the edge of the table, so the agent cannot see the location of the puck (see Fig. 6 (left)). Nonetheless, contrastive RL (NCE) successfully handles this partial observability, achieving a success rate of around $3 5 \%$ . Fig. 6 (left) shows an example rollout and Fig. 6 (right) shows the learning curve. For comparison, the success rate when using the fixed static camera was $7 5 \%$ . Taken together, these results suggest that contrastive RL can cope with moving cameras and partial observability, while also suggesting that improved strategies (e.g., non-Markovian architectures) might achieve even better results.
191
+
192
+ ![](images/88f16492b8f6fb5daa983d7e7bc5f87499a49a07a960c64339e857b73a76a74a.jpg)
193
+ Figure 6: Partial observability and moving cameras. Contrastive RL can solve partially observed tasks.
194
+
195
+ Table 1: Offline RL on D4RL AntMaze [36]. Contrastive RL outperforms all baselines in 5 out of 6 tasks.
196
+
197
+ <table><tr><td rowspan="2"></td><td colspan="5">no TD</td><td colspan="2">uses TD</td></tr><tr><td>BC</td><td>DT</td><td>GCBC</td><td>ContrastiveRL + BC 2 nets</td><td>5 nets</td><td>TD3+BC*</td><td>IQL*</td></tr><tr><td>umaze-v2</td><td>54.6</td><td>65.6</td><td>65.4</td><td>81.9 (±1.7)</td><td>79.8 (±1.4)</td><td>78.6</td><td>87.5</td></tr><tr><td>umaze-diverse-v2</td><td>45.6</td><td>51.2</td><td>60.9</td><td>75.4 (±3.5)</td><td>77.6 (±2.8)</td><td>71.4</td><td>62.2</td></tr><tr><td>medium-play-v2</td><td>0.0</td><td>1.0</td><td>58.1</td><td>71.5 (±5.2)</td><td>72.6 (±2.9)</td><td>10.6</td><td>71.2</td></tr><tr><td>medium-diverse-v2</td><td>0.0</td><td>0.6</td><td>67.3</td><td>72.5 (±2.8)</td><td>71.5 (±1.3)</td><td>3.0</td><td>70.0</td></tr><tr><td>large-play-v2</td><td>0.0</td><td>0.0</td><td>32.4</td><td>41.6 (±6.0)</td><td>48.6 (±4.4)</td><td>0.2</td><td>39.6</td></tr><tr><td>large-diverse-v2</td><td>0.0</td><td>0.2</td><td>36.9</td><td>49.3 (±6.3)</td><td>54.1 (±5.5)</td><td>0.0</td><td>47.5</td></tr><tr><td colspan="10">* While TD3+BCand IQLreport results onthe-vO tasks,the change to-v2 has anegligible effecton TD methods [8].</td></tr></table>
198
+
199
+ # 5.5 Contrastive RL for Offline RL
200
+
201
+ Our final experiment studies whether the benefits from contrastive RL (NCE) transfer to the offline RL setting, where the agent is prohibited from interacting with the environment. We use the benchmark AntMaze tasks from the D4RL benchmark [36], as these are goal-conditioned tasks commonly studied in the offline setting.
202
+
203
+ We adapt contrastive RL (NCE) to the offline setting by adding an additional (goal-conditioned) behavioral cloning term to the policy objective (Eq. 7), using a coefficient of $\lambda$ :
204
+
205
+ $$
206
+ \operatorname* { m a x } _ { \pi ( a \mid s , s _ { g } ) } \mathbb { E } _ { \pi ( a \mid s , s _ { g } ) p ( s , a _ { \mathrm { o i g } } , s _ { g } ) } \left[ ( 1 - \lambda ) \cdot f ( s , a , s _ { f } = s _ { g } ) + \lambda \cdot \log \pi ( a _ { \mathrm { o i g } } \mid s , s _ { g } ) \right] .
207
+ $$
208
+
209
+ Note that setting $\lambda = 1$ corresponds to GCBC [16, 22, 25, 41, 83, 96, 117, 120], which we will include as a baseline. Following $\mathrm { T D } 3 { + } \mathrm { B C }$ [39], we learn multiple critic functions (2 and 5) and take the minimum when computing the actor update. We also compare to prior offline RL methods that eschew TD learning: (unconditional) behavioral cloning (BC), the implementation of GCBC from [25] (which refers to GCBC as RvS-G), and a recent method based on the transformer architecture (DT [16]). Lastly, we compare with two more complex methods that use TD learning: $\mathrm { T D } 3 { + } \mathrm { B C }$ [39] and IQL [68]. Unlike contrastive RL and GCBC, these TD learning methods do not perform goal relabeling. We use the numbers reported for these baselines in prior work [25, 68].
210
+
211
+ As shown in Table 1, contrastive RL (NCE) outperforms all baselines on five of the six benchmark tasks. Of particular note are the most challenging “-large” tasks, where contrastive RL achieves a $7 \%$ to $9 \%$ absolute improvement over IQL. We note that IQL does not use goal relabeling, which is the bedrock of contrastive RL. Compared to baselines that do not use TD learning, the benefits are more pronounced, with a median (absolute) improvement over GCBC of $15 \%$ . The performance of contrastive RL improves when increasing the number of critics from 2 to 5, suggesting that the key to solving more challenging offline RL tasks may be increased capacity, rather than TD learning. Taken together, these results show the value of contrastive RL for offline goal-conditioned tasks.
212
+
213
+ # 6 Conclusion
214
+
215
+ In this paper, we showed how contrastive representation learning can be used for goal-conditioned RL. This connection not only lets us re-interpret a prior RL method as performing contrastive learning, but also suggests a family of contrastive RL methods, which includes simpler algorithms, as well as algorithms that attain better overall performance. While this paper might be construed to imply that RL is more or less important than representation learning [72, 75, 112, 114], we have a different takeaway: that it may be enough to build RL algorithms that look like representation learning.
216
+
217
+ One limitation of this work is that it looks only at the goal-conditioned RL problems. How these methods might be applied to arbitrary RL problems remains an open problem, though we note that recent algorithms for this setting [28] already bear a resemblance to contrastive RL. Whether the rich set of ideas from contrastive learning might be used to construct even better RL algorithms likewise remains an open question.
218
+
219
+ Acknowledgements. Thanks to Hubert Tsai, Martin Ma, and Simon Kornblith for discussions about contrastive learning. Thanks to Kamyar Ghasemipour, Suraj Nair, and anonymous reviewers for feedback on the paper. Thanks to Ofir Nachum, Daniel Zheng, and the JAX and Acme teams for helping to release and debug the code. This material is supported by the Fannie and John Hertz Foundation and the NSF GRFP (DGE1745016). UC Berkeley research is also supported by gifts from Alibaba, Amazon Web Services, Ant Financial, CapitalOne, Ericsson, Facebook, Futurewei, Google, Intel, Microsoft, Nvidia, Scotiabank, Splunk and VMware.
220
+
221
+ References
222
+ [1] Achiam, J., Edwards, H., Amodei, D., and Abbeel, P. (2018). Variational option discovery algorithms. arXiv preprint arXiv:1807.10299.
223
+ [2] Achiam, J., Knight, E., and Abbeel, P. (2019). Towards characterizing divergence in deep Q-learning. arXiv preprint arXiv:1903.08894.
224
+ [3] Alain, G. and Bengio, Y. (2016). Understanding intermediate layers using linear classifier probes. arXiv preprint arXiv:1610.01644.
225
+ [4] Anand, A., Racah, E., Ozair, S., Bengio, Y., Côté, M.-A., and Hjelm, R. D. (2019). Unsupervised state representation learning in Atari. Advances in Neural Information Processing Systems, 32.
226
+ [5] Andreas, J., Klein, D., and Levine, S. (2017). Modular multitask reinforcement learning with policy sketches. In International Conference on Machine Learning, pages 166–175. PMLR.
227
+ [6] Andrychowicz, M., Crow, D., Ray, A., Schneider, J., Fong, R., Welinder, P., McGrew, B., Tobin, J., Abbeel, P., and Zaremba, W. (2017). Hindsight experience replay. In NeurIPS.
228
+ [7] Annasamy, R. M. and Sycara, K. (2019). Towards better interpretability in deep Q-networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 4561–4569.
229
+ [8] Authors, I. (2022). Private Communication.
230
+ [9] Barreto, A., Dabney, W., Munos, R., Hunt, J. J., Schaul, T., van Hasselt, H. P., and Silver, D. (2017). Successor features for transfer in reinforcement learning. Advances in neural information processing systems, 30.
231
+ [10] Bertsekas, D. P. and Tsitsiklis, J. N. (1996). Neuro-dynamic programming. Athena Scientific.
232
+ [11] Blier, L., Tallec, C., and Ollivier, Y. (2021). Learning successor states and goal-dependent values: A mathematical viewpoint. arXiv preprint arXiv:2101.07123.
233
+ [12] Borsa, D., Barreto, A., Quan, J., Mankowitz, D., Munos, R., Van Hasselt, H., Silver, D., and Schaul, T. (2018). Universal successor features approximators. arXiv preprint arXiv:1812.07626.
234
+ [13] Bradbury, J., Frostig, R., Hawkins, P., Johnson, M. J., Leary, C., Maclaurin, D., Necula, G., Paszke, A., VanderPlas, J., Wanderman-Milne, S., and Zhang, Q. (2018). JAX: composable transformations of Python+NumPy programs.
235
+ [14] Brown, D., Goo, W., Nagarajan, P., and Niekum, S. (2019). Extrapolating beyond suboptimal demonstrations via inverse reinforcement learning from observations. In International conference on machine learning, pages 783–792. PMLR.
236
+ [15] Chane-Sane, E., Schmid, C., and Laptev, I. (2021). Goal-conditioned reinforcement learning with imagined subgoals. In International Conference on Machine Learning, pages 1430–1440. PMLR.
237
+ [16] Chen, L., Lu, K., Rajeswaran, A., Lee, K., Grover, A., Laskin, M., Abbeel, P., Srinivas, A., and Mordatch, I. (2021). Decision transformer: Reinforcement learning via sequence modeling. Advances in neural information processing systems, 34.
238
+ [17] Chen, T., Kornblith, S., Norouzi, M., and Hinton, G. E. (2020). A simple framework for contrastive learning of visual representations. ArXiv, abs/2002.05709.
239
+ [18] Chen, X. and He, K. (2021). Exploring simple siamese representation learning. 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 15745–15753.
240
+ [19] Choi, J., Sharma, A., Lee, H., Levine, S., and Gu, S. S. (2021). Variational empowerment as representation learning for goal-conditioned reinforcement learning. In International Conference on Machine Learning, pages 1953–1963. PMLR.
241
+ [20] Christiano, P., Leike, J., Brown, T. B., Martic, M., Legg, S., and Amodei, D. (2017). Deep reinforcement learning from human preferences. arXiv preprint arXiv:1706.03741.
242
+ [21] Dayan, P. (1993). Improving generalization for temporal difference learning: The successor representation. Neural Computation, 5(4):613–624.
243
+ [22] Ding, Y., Florensa, C., Abbeel, P., and Phielipp, M. (2019). Goal-conditioned imitation learning. Advances in Neural Information Processing Systems, 32:15324–15335.
244
+ [23] Dosovitskiy, A. and Koltun, V. (2016). Learning to act by predicting the future. arXiv preprint arXiv:1611.01779.
245
+ [24] Du, Y., Gan, C., and Isola, P. (2021). Curious representation learning for embodied intelligence. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10408–10417.
246
+ [25] Emmons, S., Eysenbach, B., Kostrikov, I., and Levine, S. (2021). Rvs: What is essential for offline rl via supervised learning? arXiv preprint arXiv:2112.10751.
247
+ [26] Eysenbach, B., Geng, X., Levine, S., and Salakhutdinov, R. (2020). Rewriting history with inverse RL: Hindsight inference for policy improvement. ArXiv, abs/2002.11089.
248
+ [27] Eysenbach, B., Gupta, A., Ibarz, J., and Levine, S. (2018). Diversity is all you need: Learning skills without a reward function. In International Conference on Learning Representations.
249
+ [28] Eysenbach, B., Levine, S., and Salakhutdinov, R. R. (2021a). Replacing rewards with examples: Examplebased policy search via recursive classification. Advances in Neural Information Processing Systems, 34.
250
+ [29] Eysenbach, B., Salakhutdinov, R., and Levine, S. (2021b). C-learning: Learning to achieve goals via recursive classification. ArXiv, abs/2011.08909.
251
+ [30] Eysenbach, B., Salakhutdinov, R. R., and Levine, S. (2019). Search on the replay buffer: Bridging planning and reinforcement learning. Advances in Neural Information Processing Systems, 32.
252
+ [31] Eysenbach, B., Udatha, S., Levine, S., and Salakhutdinov, R. (2022). Imitating past successes can be very suboptimal. arXiv preprint arXiv:2206.03378.
253
+ [32] Finn, C., Tan, X. Y., Duan, Y., Darrell, T., Levine, S., and Abbeel, P. (2016). Deep spatial autoencoders for visuomotor learning. In 2016 IEEE International Conference on Robotics and Automation (ICRA), pages 512–519. IEEE.
254
+ [33] Fischinger, D., Vincze, M., and Jiang, Y. (2013). Learning grasps for unknown objects in cluttered scenes. In 2013 IEEE international conference on robotics and automation, pages 609–616. IEEE.
255
+ [34] Florensa, C., Degrave, J., Heess, N., Springenberg, J. T., and Riedmiller, M. (2019). Self-supervised learning of image embedding for continuous control. arXiv preprint arXiv:1901.00943.
256
+ [35] Florensa, C., Held, D., Geng, X., and Abbeel, P. (2018). Automatic goal generation for reinforcement learning agents. In International conference on machine learning, pages 1515–1528. PMLR.
257
+ [36] Fu, J., Kumar, A., Nachum, O., Tucker, G., and Levine, S. (2020). D4RL: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219.
258
+ [37] Fu, J., Luo, K., and Levine, S. (2017). Learning robust rewards with adversarial inverse reinforcement learning. arXiv preprint arXiv:1710.11248.
259
+ [38] Fu, J., Singh, A., Ghosh, D., Yang, L., and Levine, S. (2018). Variational inverse control with events: A general framework for data-driven reward definition. In NeurIPS.
260
+ [39] Fujimoto, S. and Gu, S. S. (2021). A minimalist approach to offline reinforcement learning. Advances in Neural Information Processing Systems, 34.
261
+ [40] Fujimoto, S., Hoof, H., and Meger, D. (2018). Addressing function approximation error in actor-critic methods. In International conference on machine learning, pages 1587–1596. PMLR.
262
+ [41] Ghosh, D., Gupta, A., Reddy, A., Fu, J., Devin, C. M., Eysenbach, B., and Levine, S. (2020). Learning to reach goals via iterated supervised learning. In International Conference on Learning Representations.
263
+ [42] Gregor, K., Rezende, D. J., and Wierstra, D. (2016). Variational intrinsic control. arXiv preprint arXiv:1611.07507.
264
+ [43] Grill, J.-B., Strub, F., Altch’e, F., Tallec, C., Richemond, P. H., Buchatskaya, E., Doersch, C., Pires, B. Á., Guo, Z. D., Azar, M. G., Piot, B., Kavukcuoglu, K., Munos, R., and Valko, M. (2020). Bootstrap your own latent: A new approach to self-supervised learning. ArXiv, abs/2006.07733.
265
+ [44] Guo, Z. D., Azar, M. G., Piot, B., Pires, B. A., and Munos, R. (2018). Neural predictive belief representations. arXiv preprint arXiv:1811.06407.
266
+ [45] Guo, Z. D., Pires, B. A., Piot, B., Grill, J.-B., Altché, F., Munos, R., and Azar, M. G. (2020). Bootstrap latent-predictive representations for multitask reinforcement learning. In International Conference on Machine Learning, pages 3875–3886. PMLR.
267
+ [46] Gutmann, M. U. and Hyvärinen, A. (2012). Noise-contrastive estimation of unnormalized statistical models, with applications to natural image statistics. Journal of machine learning research, 13(2).
268
+ [47] Ha, D. and Schmidhuber, J. (2018). World models. arXiv preprint arXiv:1803.10122.
269
+ [48] Haarnoja, T., Zhou, A., Abbeel, P., and Levine, S. (2018). Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In International conference on machine learning, pages 1861–1870. PMLR.
270
+ [49] Hafner, D., Lillicrap, T., Ba, J., and Norouzi, M. (2019a). Dream to control: Learning behaviors by latent imagination. arXiv preprint arXiv:1912.01603.
271
+ [50] Hafner, D., Lillicrap, T., Fischer, I., Villegas, R., Ha, D., Lee, H., and Davidson, J. (2019b). Learning latent dynamics for planning from pixels. In International conference on machine learning, pages 2555–2565. PMLR.
272
+ [51] Han, T., Xie, W., and Zisserman, A. (2020). Self-supervised co-training for video representation learning. Advances in Neural Information Processing Systems, 33:5679–5690.
273
+ [52] Hansen, S., Dabney, W., Barreto, A., Van de Wiele, T., Warde-Farley, D., and Mnih, V. (2019). Fast task inference with variational intrinsic successor features. arXiv preprint arXiv:1906.05030.
274
+ [53] He, K., Fan, H., Wu, Y., Xie, S., and Girshick, R. (2020). Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9729–9738.
275
+ [54] Hjelm, R. D., Fedorov, A., Lavoie-Marchildon, S., Grewal, K., Bachman, P., Trischler, A., and Bengio, Y. (2018). Learning deep representations by mutual information estimation and maximization. arXiv preprint arXiv:1808.06670.
276
+ [55] Ho, J. and Ermon, S. (2016). Generative adversarial imitation learning. Advances in neural information processing systems, 29:4565–4573.
277
+ [56] Hoffer, E. and Ailon, N. (2015). Deep metric learning using triplet network. In International workshop on similarity-based pattern recognition, pages 84–92. Springer.
278
+ [57] Hoffman, M., Shahriari, B., Aslanides, J., Barth-Maron, G., Behbahani, F., Norman, T., Abdolmaleki, A., Cassirer, A., Yang, F., Baumli, K., Henderson, S., Novikov, A., Colmenarejo, S. G., Cabi, S., Gulcehre, C., Paine, T. L., Cowie, A., Wang, Z., Piot, B., and de Freitas, N. (2020). Acme: A research framework for distributed reinforcement learning. arXiv preprint arXiv:2006.00979.
279
+ [58] Hong, Z.-W., Yang, G., and Agrawal, P. (2022). Bilinear value networks. arXiv preprint arXiv:2204.13695.
280
+ [59] Ichter, B., Sermanet, P., and Lynch, C. (2020). Broadly-exploring, local-policy trees for long-horizon task planning. arXiv preprint arXiv:2010.06491.
281
+ [60] Janner, M., Mordatch, I., and Levine, S. (2020). gamma-models: Generative temporal difference learning for infinite-horizon prediction. Advances in Neural Information Processing Systems, 33:1724–1735.
282
+ [61] Jozefowicz, R., Vinyals, O., Schuster, M., Shazeer, N., and Wu, Y. (2016). Exploring the limits of language modeling. arXiv preprint arXiv:1602.02410.
283
+ [62] Kaelbling, L. P. (1993). Learning to achieve goals. In IJCAI, pages 1094–1099. Citeseer.
284
+ [63] Kalashnikov, D., Varley, J., Chebotar, Y., Swanson, B., Jonschkowski, R., Finn, C., Levine, S., and Hausman, K. (2021). Mt-opt: Continuous multi-task robotic reinforcement learning at scale. ArXiv, abs/2104.08212.
285
+ [64] Kish, L. (1965). Survey sampling. John Wiley & Sons.
286
+ [65] Klingemann, M. (2016). Raster fairy. https://github.com/bmcfee/RasterFairy.
287
+ [66] Konda, V. and Tsitsiklis, J. (1999). Actor-critic algorithms. Advances in neural information processing systems, 12.
288
+ [67] Konyushkova, K., Zolna, K., Aytar, Y., Novikov, A., Reed, S., Cabi, S., and de Freitas, N. (2020). Semi-supervised reward learning for offline reinforcement learning. arXiv preprint arXiv:2012.06899.
289
+ [68] Kostrikov, I., Nair, A., and Levine, S. (2021). Offline reinforcement learning with implicit Q-learning. arXiv preprint arXiv:2110.06169.
290
+ [69] Kostrikov, I., Yarats, D., and Fergus, R. (2020). Image augmentation is all you need: Regularizing deep reinforcement learning from pixels. arXiv preprint arXiv:2004.13649.
291
+ [70] Kumar, A., Agarwal, R., Ghosh, D., and Levine, S. (2020). Implicit under-parameterization inhibits data-efficient deep reinforcement learning. arXiv preprint arXiv:2010.14498.
292
+ [71] Lange, S. and Riedmiller, M. (2010). Deep auto-encoder neural networks in reinforcement learning. In The 2010 International Joint Conference on Neural Networks (IJCNN), pages 1–8. IEEE.
293
+ [72] Langford, J. (2010). Specializations of the master problem.
294
+ [73] Laskin, M., Lee, K., Stooke, A., Pinto, L., Abbeel, P., and Srinivas, A. (2020). Reinforcement learning with augmented data. Advances in Neural Information Processing Systems, 33:19884–19895.
295
+ [74] Laskin, M., Liu, H., Peng, X. B., Yarats, D., Rajeswaran, A., and Abbeel, P. (2021). CIC: Contrastive intrinsic control for unsupervised skill discovery. In Deep RL Workshop NeurIPS 2021.
296
+ [75] LeCun, Y. (2016). Predictive learning. https://www.youtube.com/watch?v $=$ Ount2Y4qxQo. Keynote Talk.
297
+ [76] Levy, A., Konidaris, G., Platt, R., and Saenko, K. (2017). Learning multi-level hierarchies with hindsight. arXiv preprint arXiv:1712.00948.
298
+ [77] Levy, O. and Goldberg, Y. (2014). Neural word embedding as implicit matrix factorization. Advances in neural information processing systems, 27.
299
+ [78] Li, A., Pinto, L., and Abbeel, P. (2020). Generalized hindsight for reinforcement learning. Advances in neural information processing systems, 33:7754–7767.
300
+ [79] Liang, Y., Machado, M. C., Talvitie, E., and Bowling, M. (2015). State of the art control of Atari games using shallow reinforcement learning. arXiv preprint arXiv:1512.01563.
301
+ [80] Lin, X., Baweja, H. S., and Held, D. (2019). Reinforcement learning without ground-truth state. ArXiv, abs/1905.07866.
302
+ [81] Liu, H. and Abbeel, P. (2021). Aps: Active pretraining with successor features. In International Conference on Machine Learning, pages 6736–6747. PMLR.
303
+ [82] Liu, K., Kurutach, T., Tung, C., Abbeel, P., and Tamar, A. (2020). Hallucinative topological memory for zero-shot visual planning. In International Conference on Machine Learning, pages 6259–6270. PMLR.
304
+ [83] Lynch, C., Khansari, M., Xiao, T., Kumar, V., Tompson, J., Levine, S., and Sermanet, P. (2020). Learning latent plans from play. In Conference on Robot Learning, pages 1113–1132. PMLR.
305
+ [84] Ma, Z. and Collins, M. (2018). Noise contrastive estimation and negative sampling for conditional models: Consistency and statistical efficiency. In EMNLP.
306
+ [85] Mendonca, R., Rybkin, O., Daniilidis, K., Hafner, D., and Pathak, D. (2021). Discovering and achieving goals via world models. Advances in Neural Information Processing Systems, 34.
307
+ [86] Mikolov, T., Sutskever, I., Chen, K., Corrado, G. S., and Dean, J. (2013). Distributed representations of words and phrases and their compositionality. Advances in neural information processing systems, 26.
308
+ [87] Mnih, A. and Teh, Y. W. (2012). A fast and simple algorithm for training neural probabilistic language models. In ICML.
309
+ [88] Mnih, V., Kavukcuoglu, K., Silver, D., Graves, A., Antonoglou, I., Wierstra, D., and Riedmiller, M. (2013). Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602.
310
+ [89] Nachum, O., Gu, S., Lee, H., and Levine, S. (2018a). Near-optimal representation learning for hierarchical reinforcement learning. In International Conference on Learning Representations.
311
+ [90] Nachum, O., Gu, S. S., Lee, H., and Levine, S. (2018b). Data-efficient hierarchical reinforcement learning. Advances in neural information processing systems, 31.
312
+ [91] Nair, A. V., Pong, V., Dalal, M., Bahl, S., Lin, S., and Levine, S. (2018). Visual reinforcement learning with imagined goals. Advances in Neural Information Processing Systems, 31:9191–9200.
313
+ [92] Nair, S., Mitchell, E., Chen, K., Savarese, S., Finn, C., et al. (2022). Learning language-conditioned robot behavior from offline data and crowd-sourced annotation. In Conference on Robot Learning, pages 1303–1315. PMLR.
314
+ [93] Nasiriany, S., Pong, V. H., Lin, S., and Levine, S. (2019). Planning with goal-conditioned policies. In NeurIPS.
315
+ [94] Nowozin, S., Cseke, B., and Tomioka, R. (2016). f-GAN: Training generative neural samplers using variational divergence minimization. Advances in neural information processing systems, 29.
316
+ [95] Oord, A. v. d., Li, Y., and Vinyals, O. (2018). Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748.
317
+ [96] Paster, K., McIlraith, S. A., and Ba, J. (2020). Planning from pixels using inverse dynamics models. arXiv preprint arXiv:2012.02419.
318
+ [97] Plappert, M., Andrychowicz, M., Ray, A., McGrew, B., Baker, B., Powell, G., Schneider, J., Tobin, J., Chociej, M., Welinder, P., et al. (2018). Multi-goal reinforcement learning: Challenging robotics environments and request for research. arXiv preprint arXiv:1802.09464.
319
+ [98] Pong, V. H., Dalal, M., Lin, S., Nair, A., Bahl, S., and Levine, S. (2019). Skew-fit: State-covering self-supervised reinforcement learning. arXiv preprint arXiv:1903.03698.
320
+ [99] Poole, B., Ozair, S., Van Den Oord, A., Alemi, A., and Tucker, G. (2019). On variational bounds of mutual information. In International Conference on Machine Learning, pages 5171–5180. PMLR.
321
+ [100] Qiu, S., Wang, L., Bai, C., Yang, Z., and Wang, Z. (2022). Contrastive ucb: Provably efficient contrastive self-supervised learning in online reinforcement learning. In International Conference on Machine Learning, pages 18168–18210. PMLR.
322
+ [101] Rakelly, K., Gupta, A., Florensa, C., and Levine, S. (2021). Which mutual-information representation learning objectives are sufficient for control? ArXiv, abs/2106.07278.
323
+ [102] Riedmiller, M., Hafner, R., Lampe, T., Neunert, M., Degrave, J., Wiele, T., Mnih, V., Heess, N., and Springenberg, J. T. (2018). Learning by playing solving sparse reward tasks from scratch. In International conference on machine learning, pages 4344–4353. PMLR.
324
+ [103] Rudner, T. G., Pong, V., McAllister, R., Gal, Y., and Levine, S. (2021). Outcome-driven reinforcement learning via variational inference. Advances in Neural Information Processing Systems, 34.
325
+ [104] Rybkin, O., Zhu, C., Nagabandi, A., Daniilidis, K., Mordatch, I., and Levine, S. (2021). Model-based reinforcement learning via latent-space collocation. In International Conference on Machine Learning, pages 9190–9201. PMLR.
326
+ [105] Savinov, N., Dosovitskiy, A., and Koltun, V. (2018). Semi-parametric topological memory for navigation. In International Conference on Learning Representations.
327
+ [106] Schaul, T., Horgan, D., Gregor, K., and Silver, D. (2015). Universal value function approximators. In International conference on machine learning, pages 1312–1320. PMLR.
328
+ [107] Schmeckpeper, K., Xie, A., Rybkin, O., Tian, S., Daniilidis, K., Levine, S., and Finn, C. (2020). Learning predictive models from observation and interaction. In European Conference on Computer Vision, pages 708–725. Springer.
329
+ [108] Schroff, F., Kalenichenko, D., and Philbin, J. (2015). Facenet: A unified embedding for face recognition and clustering. 2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 815–823.
330
+ [109] Sermanet, P., Lynch, C., Chebotar, Y., Hsu, J., Jang, E., Schaal, S., Levine, S., and Brain, G. (2018). Time-contrastive networks: Self-supervised learning from video. In 2018 IEEE international conference on robotics and automation (ICRA), pages 1134–1141. IEEE.
331
+ [110] Sharma, A., Gu, S., Levine, S., Kumar, V., and Hausman, K. (2019). Dynamics-aware unsupervised discovery of skills. In International Conference on Learning Representations.
332
+ [111] Shu, R., Nguyen, T., Chow, Y., Pham, T., Than, K., Ghavamzadeh, M., Ermon, S., and Bui, H. (2020). Predictive coding for locally-linear control. In International Conference on Machine Learning, pages 8862–8871. PMLR.
333
+ [112] Silver, D., Singh, S., Precup, D., and Sutton, R. S. (2021). Reward is enough. Artificial Intelligence, 299:103535.
334
+ [113] Sohn, K. (2016). Improved deep metric learning with multi-class n-pair loss objective. In NeurIPS.
335
+ [114] Srinivas, A. and Abbeel, P. (2021). Unsupervised learning for reinforcement learning. Tutorial.
336
+ [115] Srinivas, A., Jabri, A., Abbeel, P., Levine, S., and Finn, C. (2018). Universal planning networks. ArXiv, abs/1804.00645.
337
+ [116] Srinivas, A., Laskin, M., and Abbeel, P. (2020). Curl: Contrastive unsupervised representations for reinforcement learning. arXiv preprint arXiv:2004.04136.
338
+ [117] Srivastava, R. K., Shyam, P., Mutz, F., Jaskowski, W., and Schmidhuber, J. (2019). Training agents using ´ upside-down reinforcement learning. arXiv preprint arXiv:1912.02877.
339
+ [118] Stooke, A., Lee, K., Abbeel, P., and Laskin, M. (2021). Decoupling representation learning from reinforcement learning. In International Conference on Machine Learning, pages 9870–9879. PMLR.
340
+ [119] Such, F. P., Madhavan, V., Liu, R., Wang, R., Castro, P. S., Li, Y., Zhi, J., Schubert, L., Bellemare, M. G., Clune, J., et al. (2018). An atari model zoo for analyzing, visualizing, and comparing deep reinforcement learning agents. arXiv preprint arXiv:1812.07069.
341
+ [120] Sun, H., Li, Z., Liu, X., Zhou, B., and Lin, D. (2019). Policy continuation with hindsight inverse dynamics. Advances in Neural Information Processing Systems, 32:10265–10275.
342
+ [121] Teh, Y., Bapst, V., Czarnecki, W. M., Quan, J., Kirkpatrick, J., Hadsell, R., Heess, N., and Pascanu, R. (2017). Distral: Robust multitask reinforcement learning. Advances in neural information processing systems, 30.
343
+ [122] Tian, Y., Krishnan, D., and Isola, P. (2020). Contrastive multiview coding. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part XI 16, pages 776–794. Springer.
344
+ [123] Tsai, Y.-H., Zhao, H., Yamada, M., Morency, L.-P., and Salakhutdinov, R. (2020). Neural methods for point-wise dependency estimation. In Proceedings of the Neural Information Processing Systems Conference (Neurips).
345
+ [124] Tschannen, M., Djolonga, J., Rubenstein, P. K., Gelly, S., and Lucic, M. (2019). On mutual information maximization for representation learning. arXiv preprint arXiv:1907.13625.
346
+ [125] Venkattaramanujam, S., Crawford, E., Doan, T. V., and Precup, D. (2019). Self-supervised learning of distance functions for goal-conditioned reinforcement learning. ArXiv, abs/1907.02998.
347
+ [126] Wang, H., Miahi, E., White, M., Machado, M. C., Abbas, Z., Kumaraswamy, R., Liu, V., and White, A. (2022). Investigating the properties of neural network representations in reinforcement learning. arXiv preprint arXiv:2203.15955.
348
+ [127] Warde-Farley, D., Van de Wiele, T., Kulkarni, T., Ionescu, C., Hansen, S., and Mnih, V. (2018). Unsupervised control through non-parametric discriminative rewards. arXiv preprint arXiv:1811.11359.
349
+ [128] Watter, M., Springenberg, J., Boedecker, J., and Riedmiller, M. (2015). Embed to control: A locally linear latent dynamics model for control from raw images. Advances in neural information processing systems, 28.
350
+ [129] Weinberger, K. Q. and Saul, L. K. (2005). Distance metric learning for large margin nearest neighbor classification. In NIPS.
351
+ [130] Wilson, A., Fern, A., Ray, S., and Tadepalli, P. (2007). Multi-task reinforcement learning: a hierarchical bayesian approach. In Proceedings of the 24th international conference on Machine learning, pages 1015– 1022.
352
+ [131] Wu, Y., Tucker, G., and Nachum, O. (2018a). The Laplacian in RL: Learning representations with efficient approximations. arXiv preprint arXiv:1810.04586.
353
+ [132] Wu, Z., Xiong, Y., Yu, S. X., and Lin, D. (2018b). Unsupervised feature learning via non-parametric instance discrimination. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3733–3742.
354
+ [133] Xie, A., Singh, A., Levine, S., and Finn, C. (2018). Few-shot goal inference for visuomotor learning and planning. In Conference on Robot Learning, pages 40–52. PMLR.
355
+ [134] Xu, D. and Denil, M. (2019). Positive-unlabeled reward learning. arXiv preprint arXiv:1911.00459.
356
+ [135] Yang, G., Ajay, A., and Agrawal, P. (2021). Overcoming the spectral bias of neural value approximation. In International Conference on Learning Representations.
357
+ [136] Yarats, D., Fergus, R., Lazaric, A., and Pinto, L. (2021a). Mastering visual continuous control: Improved data-augmented reinforcement learning. arXiv preprint arXiv:2107.09645.
358
+ [137] Yarats, D., Zhang, A., Kostrikov, I., Amos, B., Pineau, J., and Fergus, R. (2021b). Improving sample efficiency in model-free reinforcement learning from images. In AAAI.
359
+ [138] Yu, T., Kumar, S., Gupta, A., Levine, S., Hausman, K., and Finn, C. (2020a). Gradient surgery for multi-task learning. Advances in Neural Information Processing Systems, 33:5824–5836.
360
+ [139] Yu, T., Quillen, D., He, Z., Julian, R., Hausman, K., Finn, C., and Levine, S. (2020b). Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In Conference on Robot Learning, pages 1094–1100. PMLR.
361
+ [140] Zhang, A., McAllister, R. T., Calandra, R., Gal, Y., and Levine, S. (2020a). Learning invariant representations for reinforcement learning without reconstruction. In International Conference on Learning Representations.
362
+ [141] Zhang, M., Vikram, S., Smith, L., Abbeel, P., Johnson, M., and Levine, S. (2019). Solar: Deep structured representations for model-based reinforcement learning. In International Conference on Machine Learning, pages 7444–7453. PMLR.
363
+ [142] Zhang, S., Liu, B., and Whiteson, S. (2020b). Gradientdice: Rethinking generalized offline estimation of stationary values. In International Conference on Machine Learning, pages 11194–11203. PMLR.
364
+ [143] Zhang, T., Ren, T., Yang, M., Gonzalez, J., Schuurmans, D., and Dai, B. (2022). Making linear mdps practical via contrastive representation learning. In International Conference on Machine Learning, pages 26447–26466. PMLR.
365
+ [144] Zhao, R., Sun, X., and Tresp, V. (2019). Maximum entropy-regularized multi-goal reinforcement learning. In International Conference on Machine Learning, pages 7553–7562. PMLR.
366
+ [145] Ziebart, B. D. (2010). Modeling purposeful adaptive behavior with the principle of maximum causal entropy. Carnegie Mellon University.
367
+ [146] Zolna, K., Reed, S., Novikov, A., Colmenarejo, S. G., Budden, D., Cabi, S., Denil, M., de Freitas, N., and Wang, Z. (2019). Task-relevant adversarial imitation learning. arXiv preprint arXiv:1910.01077.
368
+
369
+ # Checklist
370
+
371
+ 1. For all authors...
372
+
373
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] The main claims are that (1) contrastive learning can be used to learn a Q-function (Proof in Appendix B) and that (2) contrastive RL methods can outperform non-contrastive RL algorithms on goal-conditioned RL tasks (results in Fig. 2).
374
+ (b) Did you describe the limitations of your work? [Yes] See Sec. 6.
375
+ (c) Did you discuss any potential negative societal impacts of your work? [No] While RL broadly might be used for applications with both positive and negative outcomes, our algorithmic contributions are not tied to any particular application.
376
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
377
+
378
+ 2. If you are including theoretical results...
379
+
380
+ (a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes] See Appendix B
381
+
382
+ 3. If you ran experiments...
383
+
384
+ (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 have included all experimental details in Appendix E; code will be released upon acceptance.
385
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix E.
386
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] All figures show 5 random seeds, witht error bars corresponding to the mean and standard deviation across these seeds.
387
+ (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] Sec. 4.4 describes the training speed on one TPUv2.
388
+
389
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
390
+
391
+ (a) If your work uses existing assets, did you cite the creators? [N/A]
392
+ (b) Did you mention the license of the assets? [N/A]
393
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
394
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
395
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
396
+
397
+ 5. If you used crowdsourcing or conducted research with human subjects...
398
+
399
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
400
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
401
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/vKBdabh_WV/vKBdabh_WV.md ADDED
@@ -0,0 +1,652 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Meta Optimal Transport
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 We study the use of amortized optimization to predict optimal transport (OT) maps
11
+ 2 from the input measures, which we call Meta OT. This helps repeatedly solve sim
12
+ 3 ilar OT problems between different measures by leveraging the knowledge and in
13
+ 4 formation present from past problems to rapidly predict and solve new problems.
14
+ 5 Otherwise, standard methods ignore the knowledge of the past solutions and sub
15
+ 6 optimally re-solve each problem from scratch. We instantiate Meta OT models in
16
+ 7 discrete and continuous (Wasserstein-2) settings between images, spherical data,
17
+ 8 and color palettes and use them to improve the computational time of standard OT
18
+ 9 solvers by multiple orders of magnitude.
19
+
20
+ # 10 1 Introduction
21
+
22
+ 11 Optimal transportation [Villani, 2009, Ambrosio, 2003, Santambrogio, 2015, Peyré et al., 2019,
23
+ 12 Merigot and Thibert, 2021] is thriving in domains including economics [Galichon, 2016], rein
24
+ 13 forcement learning [Dadashi et al., 2021, Fickinger et al., 2021], style transfer [Kolkin et al., 2019],
25
+ 14 generative modeling [Arjovsky et al., 2017, Seguy et al., 2018, Huang et al., 2020, Rout et al., 2021],
26
+ 15 geometry [Solomon et al., 2015, Cohen et al., 2021], domain adaptation [Courty et al., 2017, Redko
27
+ 16 et al., 2019], signal processing [Kolouri et al., 2017], fairness [Jiang et al., 2020], and cell repro
28
+ 17 gramming [Schiebinger et al., 2019]. A core component in these settings is to couple two measures
29
+ 18 $( \alpha , \beta )$ supported on domains $( \mathcal { X } , \mathcal { Y } )$ by solving a transport optimization problem such as the primal
30
+ 19 Kantorovich problem, which is defined by:
31
+
32
+ $$
33
+ \pi ^ { \star } ( \alpha , \beta , c ) \in \mathop { \mathrm { a r g } } _ { \pi \in \mathcal { U } ( \alpha , \beta ) } \int _ { \mathcal { X } \times \mathcal { Y } } c ( x , y ) \mathrm { d } \pi ( x , y ) ,
34
+ $$
35
+
36
+ where the optimal coupling 20 $\pi ^ { \star }$ is a joint distribution over the product space, $\mathcal { U } ( \alpha , \beta )$ is the set of 21 admissible couplings between $\alpha$ and $\beta$ , and $c : \mathcal { X } \times \mathcal { Y } \mathbb { R }$ is the ground cost, that represents a 22 notion of distance between elements in $\mathcal { X }$ and elements in $\mathcal { V }$ .
37
+
38
+ 23 Challenges. Unfortunately, solving eq. (1) once is computationally expensive between general mea
39
+ 24 sures and computationally cheaper alternatives are an active research topic: Entropic optimal trans
40
+ 25 port [Cuturi, 2013] smooths the transport problem with an entropy penalty, and sliced distances
41
+ 26 [Kolouri et al., 2016, 2018, 2019, Deshpande et al., 2019] solve OT between 1-dimensional projec
42
+ 27 tions of the measures, where eq. (1) can be solved easily.
43
+ 28 Furthermore, when an optimal transport method is deployed in practice, eq. (1) is not just solved
44
+ 29 a single time, but is repeatedly solved for new scenarios between different input measures $( \alpha , \beta )$ .
45
+ 30 For example, the measures could be representations of images we care about optimally transporting
46
+ 31 between and in deployment we would receive a stream of new images to couple. Repeatedly solving
47
+ 32 optimal transport problems also comes up in the context of comparing seismic signals [Engquist
48
+ 33 and Froese, 2013] and in single-cell perturbations [Bunne et al., 2021, 2022b,a]. Standard optimal
49
+ 34 transport solvers deployed in this setting would re-solve the optimization problems from scratch, but
50
+ 35 this ignores the shared structure and information present between different coupling problems.
51
+ 36 Overview and outline. We study the use of amortized optimization and machine learning methods
52
+ 37 to rapidly solve multiple optimal transport problems and predict the solution from the input measures
53
+ 38 $( \alpha , \beta )$ . This setting involves learning a meta model to predict the solution to the optimal transport
54
+ 39 problem, which we will refer to as Meta Optimal Transport. We learn Meta OT models to predict
55
+ 40 the solutions to optimal transport problems and significantly improve the computational time and
56
+ 41 number of iterations needed to solve eq. (1) between discrete (sect. 3.1) and continuous (sect. 3.2)
57
+ 42 measures. The paper is organized as follows: sect. 2 recalls the main concepts needed for the rest
58
+ 43 of the paper, in particular the formulations of the entropy regularized and unregularized optimal
59
+ 44 transport problems and the basic notions of amortized optimization; sect. 3 presents the Meta OT
60
+ 45 models and algorithms; and sect. 4 empirically demonstrates the effectiveness of Meta OT.
61
+ 46 Settings that are not Meta OT. Meta OT is not useful in OT settings that do not involve repeatedly
62
+ 47 solving OT problems over a fixed distribution, including 1) standard generative modeling settings,
63
+ 48 such as Arjovsky et al. [2017] that estimate the OT distance between the data and model distri
64
+ 49 butions, and 2) the out-of-sample setting of Seguy et al. [2018], Perrot et al. [2016] that couple
65
+ 50 measures and then extrapolate the map to larger measures containing the original measures.
66
+
67
+ # 51 2 Preliminaries and background
68
+
69
+ # 2.1 Dual optimal transport solvers
70
+
71
+ 53 We review foundations of optimal transportation, following the notation of Peyré et al. [2019] in
72
+ 54 most places. The discrete setting often favors the entropic regularized version since it can be com
73
+ 55 puted efficiently and in a parallelized way using the Sinkhorn algorithm. On the other hand, the
74
+ 56 continuous setting is often solved from samples using convex potentials. While the primal Kan
75
+ 57 torovich formulation in eq. (1) provides an intuitive problem description, optimal transport problems
76
+ 58 are rarely solved directly in this form due to the high-dimensionality of the couplings $\pi$ and the diffi
77
+ 59 culty of satisfying the coupling constraints $\mathcal { U } ( \alpha , \beta )$ . Instead, most computational OT solvers use the
78
+ 60 dual of eq. (1), which we build our Meta OT solvers on top of in discrete and continuous settings.
79
+
80
+ # 2.1.1 Entropic OT between discrete measures with the Sinkhorn algorithm
81
+
82
+ Let 62 $\begin{array} { r } { \alpha : = \sum _ { i = 1 } ^ { m } a _ { i } \delta _ { x _ { i } } } \end{array}$ and $\beta : = \textstyle \sum _ { i = 1 } ^ { n } b _ { i } \delta _ { y _ { i } }$ be 63 discrete measures, where $\delta _ { z }$ is a Dirac at point 64 $z$ and $a \ \in \ \Delta _ { m - 1 }$ and $b \in \Delta _ { n - 1 }$ are in the 65 probability simplex defined by
83
+
84
+ $$
85
+ \Delta _ { k - 1 } : = \{ x \in \mathbb { R } ^ { k } : x \geq 0 { \mathrm { ~ a n d ~ } } \sum _ { i } x _ { i } = 1 \} .
86
+ $$
87
+
88
+ <table><tr><td>Algorithm1 Sinkhorn(α,β,c,∈,fo=0)</td></tr><tr><td>foriterationi=1to N do gi ←∈logb-∈log(KTexp{fi-1/ε})</td></tr><tr><td>fi←∈loga-∈log(Kexp{gi/∈}) end for</td></tr><tr><td>Compute PN from fN, gN using eq. (6)</td></tr><tr><td>return PN ≈ P*</td></tr></table>
89
+
90
+ 66 Discrete OT. In the discrete setting, eq. (1) simplifies to the linear program
91
+
92
+ $$
93
+ P ^ { \star } ( \alpha , \beta , c ) \in \underset { P \in U ( a , b ) } { \arg \operatorname* { m i n } } \langle C , P \rangle \qquad U ( a , b ) : = \{ P \in \mathbb { R } _ { + } ^ { n \times m } : P 1 _ { m } = a , \quad P ^ { \top } 1 _ { n } = b \}
94
+ $$
95
+
96
+ where 67 $P$ is a coupling matrix, $P ^ { \star } ( \alpha , \beta )$ is the optimal coupling, and the cost can be discretized as a matrix 68 $C \in \mathbb { R } ^ { m \times n }$ with entries $C _ { i , j } : = c ( x _ { i } , y _ { j } )$ , and $\begin{array} { r } { \langle C , \mathbf { \tilde { \mathit { P } } } \rangle : = \sum _ { i , j } C _ { i , j } P _ { i , j } } \end{array}$ ,
97
+
98
+ 69 Entropic OT. The linear program above can be regularized adding the entropy of the coupling to
99
+ 70 smooth the objective as in Cominetti and Martín [1994], Cuturi [2013], resulting in:
100
+
101
+ $$
102
+ P ^ { \star } ( \alpha , \beta , c , \epsilon ) \in \underset { P \in U ( a , b ) } { \arg \operatorname* { m i n } } \langle C , P \rangle - \epsilon H ( P )
103
+ $$
104
+
105
+ where 71 $\begin{array} { r } { H ( P ) : = - \sum _ { i , j } P _ { i , j } ( \log ( P _ { i , j } ) - 1 ) } \end{array}$ is the discrete entropy of a coupling matrix $P$
106
+
107
+ 72 Entropic OT dual. As presented in Peyré et al. [2019, Prop. 4.4], the dual of eq. (4) is
108
+
109
+ $$
110
+ \begin{array} { r } { f ^ { \star } , g ^ { \star } \in \underset { f \in \mathbb { R } ^ { n } , g \in \mathbb { R } ^ { m } } { \mathrm { a r g } \mathrm { m a x } } \ \langle f , a \rangle + \langle g , b \rangle - \epsilon \langle \exp \{ f / \epsilon \} , K \exp \{ g / \epsilon \} \rangle , \quad K _ { i , j } : = \exp \{ - C _ { i , j } / \epsilon \} , } \end{array}
111
+ $$
112
+
113
+ 73 where $K \in \mathbb { R } ^ { m \times n }$ is the Gibbs kernel and the dual variables or potentials $f \in \mathbb { R } ^ { n }$ and $g \in \mathbb { R } ^ { m }$ are
114
+ 74 associated, respectively, with the marginal constraints $P 1 _ { m } = a$ and $P ^ { \top } 1 _ { n } = b$ . The optimal duals
115
+ 75 depend on the problem, e.g. $f ^ { \star } ( \alpha , \beta , \overline { { c } } , \epsilon )$ , but we omit this dependence for notational simplicity.
116
+ 76 Recovering the primal solution from the duals. Given optimal duals $f ^ { \star } , g ^ { \star }$ that solve eq. (5) the
117
+ 77 optimal coupling $P ^ { \star }$ to the primal problem in eq. (4) can be obtained by
118
+
119
+ $$
120
+ P _ { i , j } ^ { \star } ( \alpha , \beta , c , \epsilon ) : = \exp \{ f _ { i } ^ { \star } / \epsilon \} K _ { i , j } \exp \{ g _ { j } ^ { \star } / \epsilon \} \qquad ( K \mathrm { i s d e f i n e d i n e q . } ( 5 ) )
121
+ $$
122
+
123
+ 78 The Sinkhorn algorithm. Algorithm 1 summarizes the log-space version, which takes closed-form
124
+ 79 block coordinate ascent updates on eq. (5) obtained from the first-order optimality conditions [Peyré
125
+ 80 et al., 2019, Remark 4.21]. We will use it to fine-tune predictions made by our Meta OT models.
126
+ 81 Computing the error. Standard implementations of the Sinkhorn algorithm, such as Flamary et al.
127
+ 82 [2021], Cuturi et al. [2022], measure the error of a candidate dual solution $( f , g )$ by computing the
128
+ 83 deviation from the marginal constraints, which we will also use in comparing our solution quality:
129
+
130
+ $$
131
+ \begin{array} { r } { \mathrm { e r r } ( f , g ; \alpha , \beta , c ) : = \| P 1 _ { m } - a \| _ { 1 } + \| P ^ { \top } 1 _ { n } - b \| _ { 1 } \qquad ( \mathrm { c o m p u t e } P \mathrm { f r o m e q . } ( 6 ) ) } \end{array}
132
+ $$
133
+
134
+ 84 Mapping between the duals. The first-order optimality conditions of eq. (5) also provide an equiv
135
+ 85 alence between the optimal dual potentials that we will make use of:
136
+
137
+ $$
138
+ \begin{array} { r } { g ( f ; b , c ) : = \epsilon \log b - \epsilon \log \left( K ^ { \top } \exp \{ f / \epsilon \} \right) . } \end{array}
139
+ $$
140
+
141
+ # 86 2.1.2 Wasserstein-2 OT between continuous (Euclidean) measures with dual potentials
142
+
143
+ 87 Let $\alpha$ and $\beta$ be continuous measures in Euclidean
144
+ 88 space $\mathcal X = \mathcal y = \mathbb R ^ { d }$ (with $\alpha$ absolutely contin
145
+ 89 uous with respect to the Lebesgue measure) and
146
+ 90 the ground cost be the squared Euclidean distance
147
+ 91 $c ( x , y ) : = \| x - y \| _ { 2 } ^ { 2 }$ . Then the minimum of eq. (1)
148
+ 92 defines the square of the Wasserstein-2 distance:
149
+
150
+ <table><tr><td>Algorithm 2 W2GN(α, β,0)</td></tr><tr><td>foriterationi=1 to N do</td></tr><tr><td>Sample from (α,β) and estimate L(φi-1) Update i with approximation to VL(i-1)</td></tr><tr><td>end for</td></tr><tr><td>return TN(.) := VxψN(·) ≈ T*(·)</td></tr></table>
151
+
152
+ $$
153
+ W _ { 2 } ^ { 2 } ( \alpha , \beta ) : = \operatorname* { m i n } _ { \pi \in \mathcal { U } ( \alpha , \beta ) } \int _ { \mathcal { X } \times \mathcal { Y } } \| x - y \| _ { 2 } ^ { 2 } \mathrm { d } \pi ( x , y ) = \operatorname* { m i n } _ { T } \int _ { \mathcal { X } } \| x - T ( x ) \| _ { 2 } ^ { 2 } \mathrm { d } \alpha ( x ) ,
154
+ $$
155
+
156
+ 93 where $T$ is a transport map pushing $\alpha$ to $\beta$ , i.e. $T _ { \# } \alpha = \beta$ with the pushforward operator defined by 94 $T _ { \# } \alpha ( B ) : = \alpha ( T ^ { - 1 } ( B ) )$ for any measurable set $B$ .
157
+
158
+ 95 Convex dual potentials. The primal form in eq. (9) is difficult to solve, as in the discrete setting, due
159
+ 96 to the difficulty of representing the coupling and satisfying the constraints. Makkuva et al. [2020],
160
+ 97 Taghvaei and Jalali [2019], Korotin et al. [2019, 2021b, 2022] propose to instead solve the dual:
161
+
162
+ $$
163
+ \psi ^ { \star } ( { \bf \cdot } ; \alpha , \beta ) \in \mathop { \mathrm { a r g } } \operatorname* { m i n } _ { \psi \in \mathrm { c o n v e x } } \int _ { \mathcal { X } } \psi ( x ) \mathrm { d } \alpha ( x ) + \int _ { \mathcal { V } } \overline { { \psi } } ( y ) \mathrm { d } \beta ( y ) ,
164
+ $$
165
+
166
+ 98 where $\psi$ is a convex function referred to as a convex potential, and ${ \overline { { \psi } } } ( y ) : = \operatorname* { m a x } _ { x \in { \mathcal { X } } } \langle x , y \rangle - \psi ( x )$ is
167
+ 99 the Legendre-Fenchel transform or convex conjugate of $\psi$ [Fenchel, 1949, Rockafellar, 2015]. The
168
+ 100 potential $\psi$ is often approximated with an input-convex neural network (ICNN) [Amos et al., 2017].
169
+ 01 Recovering the primal solution from the dual. Given an optimal dual $\psi ^ { \star }$ for eq. (10), Brenier
170
+ 02 [1991] remarkably shows that an optimal map $T ^ { \star }$ for eq. (9) can be obtained with differentiation:
171
+
172
+ $$
173
+ T ^ { \star } ( x ) = \nabla _ { x } \psi ^ { \star } ( x ) .
174
+ $$
175
+
176
+ 103 Wasserstein-2 Generative Networks (W2GNs). Korotin et al. [2019] model $\psi _ { \varphi }$ and $\overline { { \psi _ { \varphi } } }$ in eq. (10)
177
+ 104 with two separate ICNNs parameterized by $\varphi$ . The separate model for $\overline { { \psi _ { \varphi } } }$ is useful because the
178
+ 105 conjugate operation in eq. (10) becomes computationally expensive. They optimize the loss:
179
+
180
+ $$
181
+ \mathcal { L } ( \varphi ) : = \underset { x \sim \alpha } { \mathbb { E } } [ \psi _ { \varphi } ( x ) ] + \underset { y \sim \beta } { \mathbb { E } } \left[ \langle \nabla \psi _ { \varphi } ( y ) , y \rangle - \psi _ { \varphi } ( \nabla \psi _ { \varphi } ( y ) ) \right] + \gamma \underset { y \sim \beta } { \mathbb { E } } \| \nabla \psi _ { \varphi } \circ \nabla \psi _ { \varphi } ( y ) - y \| _ { 2 } ^ { 2 } ,
182
+ $$
183
+
184
+ 106 where $\varphi$ is a detached copy of the parameters and $\gamma$ is a hyper-parameter. The first term are the
185
+ 107 cyclic monotone correlations [Chartrand et al., 2009, Taghvaei and Jalali, 2019], that optimize the
186
+ 108 dual objective in eq. (10), and the second term provides cycle consistency [Zhu et al., 2017] to
187
+ 109 estimate the conjugate $\overline { { \psi } }$ . Algorithm 2 shows how $\mathcal { L }$ is typically optimized using samples from the
188
+ 110 measures, which we use to fine-tune Meta OT predictions.
189
+
190
+ ![](images/b46cb90a5498469cea62cbbfd652a7a59a6d0f29c551951f28956819f8061d83.jpg)
191
+ Figure 1: Meta OT uses objective-based amortization for optimal transport. In the general formulation, the parameters $\theta$ capture shared structure in the optimal couplings $\pi ^ { \star }$ between multiple input measures and costs over some distribution $\mathcal { D }$ . In practice, we learn this shared structure over the dual potentials which map back to the coupling: $f ^ { \star }$ in discrete settings and $\psi ^ { \star }$ in continuous ones.
192
+
193
+ # 111 2.2 Amortized optimization and learning to optimize
194
+
195
+ 112 Our paper is an application of amortized optimization methods that predict the solutions of opti
196
+ 113 mization problems, as surveyed in, e.g., Chen et al. [2021], Amos [2022]. We use the basic setup
197
+ 114 from Amos [2022], which considers unconstrained continuous optimization problems of the form
198
+
199
+ $$
200
+ z ^ { \star } ( \phi ) \in \arg \operatorname* { m i n } _ { z } J ( z ; \phi ) ,
201
+ $$
202
+
203
+ 115 where $J$ is the objective, $z \in { \mathcal { Z } }$ is the domain, and $\phi \in \Phi$ is some context or parameterization. In
204
+ 116 other words, the context conditions the objective but is not optimized over. Given a distribution over
205
+ 117 contexts ${ \mathcal { P } } ( \phi )$ , we learn a model $\hat { z } _ { \theta }$ parameterized by $\theta$ to approximate eq. (13), i.e. $\hat { z } _ { \theta } ( \phi ) \approx z ^ { \star } ( \phi )$ .
206
+ 118 $J$ will be differentiable for us, so we optimize the parameters using objective-based learning with
207
+
208
+ $$
209
+ \operatorname* { m i n } _ { \theta } \underset { \phi \sim \mathcal { P } ( \phi ) } { \mathbb { E } } J ( \hat { z } _ { \theta } ( \phi ) ; \phi ) ,
210
+ $$
211
+
212
+ 119 which does not require ground-truth solutions $z ^ { \star }$ and can be optimized with a gradient-based solver.
213
+ 120 While we focus on optimizing eq. (14) because we do not assume easy access to ground-truth solu
214
+ 121 tions $z ^ { \star } ( \phi )$ , one alternative is regression-based learning if the solutions are easily available:
215
+
216
+ $$
217
+ \operatorname* { m i n } _ { \theta } \operatorname* { \mathbb { E } } _ { \phi \sim \mathcal { P } ( \phi ) } \| z ^ { \star } ( \phi ) - \hat { z } _ { \theta } ( \phi ) \| _ { 2 } ^ { 2 } .
218
+ $$
219
+
220
+ # 122 3 Meta Optimal Transport
221
+
222
+ Figure 1 illustrates our key contribution of connecting objective-based amortization in eq. (14) to optimal transport. We consider solving multiple OT problems and learning shared structure and correlations between them. We denote a joint meta-distribution over the input measures and costs with $\mathcal { D } ( \alpha , \beta , c )$ , which we call meta to distinguish it from the measures $\alpha , \beta$ .
223
+
224
+ 127 In general, we could introduce a model that directly predicts the primal solution to eq. (1), i.e.
225
+ 128 $\pi _ { \boldsymbol { \theta } } ( \widetilde { \alpha } , \beta , c ) \approx \pi ^ { \star } ( \alpha , \beta , c )$ for $( \alpha , \beta , c ) \sim \mathcal { D }$ . This is difficult for the same reason why most compu
226
+ 129 tational methods do not operate directly in the primal space: the optimal coupling is often a high
227
+ 130 dimensional joint distribution with non-trivial marginal constraints. We instead turn to predicting
228
+ 131 the dual variables used by today’s solvers.
229
+
230
+ # 32 3.1 Meta OT between discrete measures
231
+
232
+ 133 dardand ropicwith ed iand 1 between discrete coupled using a cost easures. In the
233
+ 134 $\begin{array} { r } { \alpha : = \sum _ { i = 1 } ^ { m } a _ { i } \delta _ { x _ { i } } } \end{array}$ $\textstyle { \beta : = \sum _ { i = 1 } ^ { n } b _ { i } \delta _ { x _ { i } } }$ $a \in \Delta _ { m - 1 }$ $b \in \Delta _ { n - 1 }$ $c$
234
+ 135 Meta OT setting, the measures and cost are the contexts for amortization and sampled from a meta
235
+ 136 distribution, i.e. $( \alpha , \beta , c ) \sim \mathcal { D } ( \alpha , \beta , c )$ . For example, sects. 4.1 and 4.2 considers meta-distributions
236
+ 137 over the weights of the atoms, i.e. $( a , b ) \sim \mathcal { D }$ , where $\mathcal { D }$ is a distribution over $\Delta _ { m - 1 } \times \Delta _ { n - 1 }$ .
237
+ 138 Amortization objective. We will seek to predict the optimal potential. At optimality, the pair of
238
+ 139 potentials are related to each other via eq. (8), i.e. $\begin{array} { r } { g ( f ; \hat { \alpha } , \beta , c ) : = \epsilon \log b - \epsilon \mathrm { l o g } \left( K ^ { \dagger } \exp \bigl \{ f / \epsilon \bigr \} \right) } \end{array}$
239
+ 140 where $K \in \mathbb { R } ^ { m \times n }$ is the Gibbs kernel from eq. (5). Hence, it is sufficient to predict one of the
240
+ 141 potentials, e.g. $f$ , and recover the other. We thus re-formulate eq. (5) to just optimize over $f$ with
241
+
242
+ <table><tr><td>Algorithm 3 Training Meta OT</td></tr><tr><td>Initialize amortization model with 0o foriterationdo Sample (α, β,c) ~ D Predict duals fe or eon the sample</td></tr></table>
243
+
244
+ <table><tr><td>Algorithm 4 Fine-tuning with Sinkhorn</td></tr><tr><td>Predict duals fe(α, β,c)</td></tr><tr><td>return Sinkhorn(α,β,c,∈, fe)</td></tr><tr><td>Algorithm 5 Fine-tuning with W2GN</td></tr><tr><td>Predict dual ICNN parameters e(α, β,c)</td></tr><tr><td>return W2GN(α, β,c,T,0)</td></tr></table>
245
+
246
+ $$
247
+ \displaystyle f ^ { \star } ( \alpha , \beta , c , \epsilon ) \in \ \arg \operatorname* { m i n } _ { f \in \mathbb { R } ^ { n } } \ J ( f ; \alpha , \beta , c ) ,
248
+ $$
249
+
250
+ 142 where $- J ( f ; \alpha , \beta , c ) : = \langle f , a \rangle + \langle g , b \rangle - \epsilon \langle \exp \{ f / \epsilon \} , K \exp \{ g / \epsilon \} \rangle$ is the (negated) dual objective.
251
+ 143 Even though most solvers optimize over $f$ and $g$ jointly as in eq. (16), amortizing over these would
252
+ 144 likely need: 1) to have a higher capacity than a model just predicting $f$ , and 2) to learn how $f$ and $g$
253
+ 145 are connected through eq. (8) while in eq. (16) we explicitly provide this knowledge.
254
+ 146 Amortization model. We predict the solution to eq. (16) with $\hat { f } _ { \theta } ( \alpha , \beta , c )$ parameterized by $\theta$ ,
255
+ 147 resulting in a computationally efficient approximation $\hat { f } _ { \boldsymbol { \theta } } \approx f ^ { \star }$ . Here we use the notation $\hat { f } _ { \theta } ( \alpha , \beta , c )$
256
+ 148 to mean that the model $\hat { f } _ { \theta }$ depends on representations of the input measures and cost. In our settings,
257
+ 149 we define ${ \hat { f } } _ { \theta }$ as a fully-connected MLP mapping from the atoms of the measures to the duals.
258
+ 150 Amortization loss. Applying objective-based amortization from eq. (14) to the dual in eq. (16)
259
+ 151 completes our learning setup. Our model should best-optimize the expectation of the dual objective
260
+
261
+ $$
262
+ \operatorname* { m i n } _ { \theta } \operatorname* { \mathbb { E } } _ { ( \alpha , \beta , c ) \sim \mathcal { D } } J ( \hat { f } _ { \theta } ( \alpha , \beta , c ) ; \alpha , \beta , c ) ,
263
+ $$
264
+
265
+ which is appealing as it does not require ground-truth solutions 152 $f ^ { \star }$ . Algorithm 3 shows a basic 153 training loop for eq. (17) using a gradient-based optimizer such as Adam [Kingma and Ba, 2014].
266
+
267
+ Sinkhorn fine-tuning. The dual prediction made by $\hat { f } _ { \theta }$ with an associated $\hat { g }$ can easily be input as the initialization to a standard Sinkhorn solver as shown in algorithm 4. This allows us to deploy the predicted potential with Sinkhorn to obtain the optimal potentials with only a few extra iterations.
268
+
269
+ On accelerated solvers. Here we have only considered fine-tuning the Meta OT prediction with a log-Sinkhorn solver. Meta OT can also be combined with accelerated variants of entropic OT solvers such as Thibault et al. [2017], Altschuler et al. [2017], Alaya et al. [2019], Lin et al. [2019] that would otherwise solve every problem from scratch.
270
+
271
+ # 3.2 Meta OT between continuous measures (Wasserstein-2)
272
+
273
+ 162 We take an analogous approach to predicting the Wasserstein-2 map between continuous measures
274
+ 163 for Wasserstein-2 as reviewed in sect. 2.1.2. Here the measures $\alpha , \beta$ are supported in continuous
275
+ 164 space $\mathcal { X } = \mathcal { Y } = \mathbb { R } ^ { d }$ and we focus on computing Wasserstein-2 couplings from instances sampled
276
+ 165 from a meta-distribution $( \alpha , \beta ) \sim \mathcal { D } ( \alpha , \beta )$ . The cost $c$ is not included in $\mathcal { D }$ as it remains fixed to the
277
+ 166 squared Euclidean cost everywhere here.
278
+ 167 One challenge here is that the optimal dual potential $\psi ^ { \star } ( \cdot ; \alpha , \beta )$ in eq. (10) is a convex function and
279
+ 168 not simply a finite-dimensional real vector. The dual potentials in this setting are approximated by,
280
+ 169 e.g., an ICNN. We thus propose a Meta ICNN that predicts the parameters $\varphi$ of an ICNN $\psi _ { \varphi }$ that
281
+ 170 approximates the optimal dual potentials, which can be seen as a hypernetwork [Stanley et al., 2009,
282
+ 171 Ha et al., 2016]. The dual prediction made by $\hat { \varphi } _ { \theta }$ can easily be input as the initial value to a standard
283
+ 172 W2GN solver as shown in algorithm 5. App. B discusses other modeling choices we considered:
284
+ 173 we tried models based on MAML [Finn et al., 2017] and neural processes [Garnelo et al., 2018b,a].
285
+ 174 Amortization objective. We build on the W2GN formulation [Korotin et al., 2019] and seek pa
286
+ 175 rameters $\varphi ^ { \star }$ optimizing the dual ICNN potentials $\psi _ { \varphi }$ and $\overline { { \psi _ { \varphi } } }$ with $\mathcal { L } ( \varphi ; \alpha , \beta )$ from eq. (12). We
287
+ 176 chose W2GN due to the stability, but could also easily use other losses optimizing ICNN potentials.
288
+ 177 Amortization model: the Meta ICNN. We predict the solution to eq. (12) with $\hat { \varphi } _ { \boldsymbol { \theta } } \big ( \alpha , \beta \big )$ param
289
+ 178 eterized by $\theta$ , resulting in a computationally efficient approximation to the optimum $\hat { \varphi } _ { \boldsymbol { \theta } } \approx \varphi ^ { \star }$ .
290
+ 179 Figure 3 instantiates a convolutional Meta ICNN model using a ResNet-18 [He et al., 2016] archi
291
+ 180 tecture for coupling image-based measures. We again emphasize that $\alpha , \beta$ used with the model here
292
+ 181 are representations of measures, which in our cases are simply images.
293
+ 182 Amortization loss. Applying objective-based amortization from eq. (14) to the W2GN loss in
294
+ 183 eq. (12) completes our learning setup. Our model should best-optimize the expectation of the loss:
295
+
296
+ Figure 2: Interpolations between MNIST test digits using couplings obtained from (left) solving the problem with Sinkhorn, and (right) Meta OT model’s initial prediction, which is $\mathbf { \approx 1 0 0 }$ times computationally cheaper and produces a nearly identical coupling.
297
+
298
+ ![](images/95ae2364d302a149a728b11b5cd0623c379ff2f52461bc44c169eb33670a5c8b.jpg)
299
+ Figure 3: A Meta ICNN for image-based input measures. A shared ResNet processes the input measures $\alpha$ and $\beta$ into latents $z$ that are decoded with an MLP into the parameters $\varphi$ of an ICNN dual potential $\psi _ { \varphi }$ . The derivative of the ICNN provides the transport map $\hat { T }$ .
300
+
301
+ Table 2: Color transfer runtimes and values.
302
+
303
+ <table><tr><td></td><td>Iter</td><td>Runtime (s)</td><td>Dual Value</td></tr><tr><td>Meta OT +W2GN</td><td>None 1k</td><td>3.5.10-3 ±2.7:10-4 0.93±2.27·10-2</td><td>0.90 ±6.08·10-2 1.0 ±2.57.10-3</td></tr><tr><td></td><td>2k</td><td>1.84 ±3.78 . 10-2</td><td>1.0 ±5.30 .10-3</td></tr><tr><td>W2GN</td><td>1k</td><td>0.90 ±1.62:10-2</td><td>0.96 ±2.62:10-2</td></tr><tr><td></td><td></td><td></td><td>0.99 ±1.14·10-2</td></tr><tr><td></td><td>2k</td><td>1.81 ±3.05:10-2</td><td></td></tr></table>
304
+
305
+ Table 1: Sinkhorn runtime (seconds) to reach a marginal error of $1 0 ^ { - 3 }$ . Meta OT’s initial prediction takes $\approx 5 \cdot 1 0 ^ { - 5 }$ seconds.
306
+
307
+ <table><tr><td>Initialization</td><td>MNIST</td><td>Spherical</td></tr><tr><td>Zeros</td><td>7.7:10-3 ±1.2.10-3</td><td>1.4 ±1.9 . 10-1</td></tr><tr><td>Gaussian</td><td>7.7·107 -3 ±1.4·10-3</td><td>1.1 ±2.0 · 10-1</td></tr><tr><td>Meta OT</td><td>3.9·10-3 ±1.6·10-3</td><td>0.44 ±1.5 10-1</td></tr></table>
308
+
309
+ We report the mean and standard deviation across 10 test instances.
310
+
311
+ $$
312
+ \operatorname* { m i n } _ { \theta } \operatorname* { l g } _ { ( \alpha , \beta ) \sim \mathcal { D } } \mathcal { L } ( \varphi _ { \theta } ( \alpha , \beta ) ; \alpha , \beta ) .
313
+ $$
314
+
315
+ As in the discrete setting, it does not require ground-truth solutions 184 $\varphi ^ { \star }$ and we learn it with Adam.
316
+
317
+ # 185 4 Experiments
318
+
319
+ 186 We demonstrate how Meta OT models improve the convergence of the state-of-the-art solvers in
320
+ 187 settings where solving multiple OT problems naturally arises. We implemented our code in JAX
321
+ 188 [Bradbury et al., 2018] as an extension to the the Optimal Transport Tools (OTT) package [Cuturi
322
+ 189 et al., 2022]. App. C covers further experimental and implementation details, and shows that all of
323
+ 190 our experiments take a few hours to run on our single Quadro GP100 GPU.
324
+
325
+ ![](images/7a3bdfe695e37513957941a7260fb0d02052baa42c291e9d7d7c183015706ee3.jpg)
326
+ Figure 4: Meta OT successfully predicts warm-start initializations that significantly improve the convergence of Sinkhorn iterations on test data. The error is the marginal error defined in eq. (7).
327
+
328
+ # 191 4.1 Discrete OT between MNIST digits
329
+
330
+ Images provide a natural setting for Meta OT where the distribution over images provide the metadistribution $\mathcal { D }$ over OT problems. Given a pair of images $\alpha _ { 0 }$ and $\alpha _ { 1 }$ , each grayscale image is cast as a discrete measure in 2-dimensional space where the intensities define the probabilities of the atoms. The goal is to compute the optimal transport interpolation between the two measures as in, e.g., Peyré et al. [2019, $\ S 7 ]$ . Formally, this means computing the optimal coupling $P ^ { \star }$ by solving the entropic optimal transport problem between $\alpha _ { 0 }$ and $\alpha _ { 1 }$ and computing the interpolates as $\alpha _ { t } = ( t \mathrm { p r o j } _ { y } + ( 1 - t ) \mathrm { p r o j } _ { x } ) _ { \# } P ^ { \star }$ , for $t \in [ 0 , 1 ]$ , where $\operatorname { p r o j } _ { x } ( x , y ) : = x$ and $\mathrm { p r o j } _ { y } ( x , y ) = y$ . We selected $\epsilon = 1 0 ^ { - 2 }$ as app. A shows that it gives interpolations that are not too blurry or sharp.
331
+
332
+ 200 Our Meta OT model ${ \hat { f } } _ { \theta }$ (sect. 3.1) is an MLP that predicts the transport map between pairs of MNIST
333
+ 201 digits. We train on every pair from the standard training dataset. Figure 2 shows that even without
334
+ 202 fine-tuning, Meta OT’s predicted Wasserstein interpolations between the measures are close to the
335
+ 203 ground-truth interpolations obtained from running the Sinkhorn algorithm to convergence. We then
336
+ 204 fine-tune Meta OT’s prediction with Sinkhorn as in algorithm 4. Figure 4 shows that the near
337
+ 205 optimal predictions can be quickly refined in fewer iterations than running Sinkhorn with the default
338
+ 206 initialization, and table 1 shows the runtime required to reach the default threshold, which uses the
339
+ 207 default marginal error threshold of $1 0 ^ { - 3 }$ . We compare our learned initialization to the standard zero
340
+ 208 initialization, as well as the Gaussian initialization proposed in Thornton and Cuturi [2022], which
341
+ 209 takes a continuous Gaussian approximation of the measures and initializes the potentials to be the
342
+ 210 known coupling between the Gaussians. This Gaussian initialization assumes the squared Euclidean
343
+ 211 cost, which is not the case in our spherical transport problem, but we find it is still helpful over the
344
+ 212 zero initialization.
345
+
346
+ # 213 4.2 Discrete OT for supply-demand transportation on spherical data
347
+
348
+ We next set up a synthetic transport problem between supply and demand locations where the supply and demands may change locations or quantities frequently, creating another Meta OT setting to be able to rapidly solve the new instances. We specifically consider measures living on the 2-sphere defined by $S _ { 2 } ^ { \cdot } : = \{ x \in \mathbb { R } ^ { 3 } : \| x \| = 1 \} .$ , i.e. $\mathcal { X } = \mathcal { Y } = \mathcal { S } _ { 2 }$ , with the transport cost given by the spherical distance $c ( x , y ) = \operatorname { a r c c o s } ( \langle x , y \rangle )$ . We then randomly sample supply locations uniformly from Earth’s landmass and demand locations from Earth’s population density to induce a class of transport problems on the sphere obtained from the CC-licensed dataset from Doxsey-Whitfield et al. [2015]. Figure 5 shows that the predicted transport maps on test instances are close to the optimal maps obtained from Sinkhorn to convergence. Similar to the MNIST setting, fig. 4 and table 1 show improved convergence and runtime.
349
+
350
+ # 24 4.3 Continuous Wasserstein-2 color transfer
351
+
352
+ The problem of color transfer between two images consists in mapping the color palette of one image into the other one. The images are required to have the same number of channels, for example RGB images. The continuous formulation that we use from Korotin et al. [2019], takes i.e. $\mathcal { X } = \mathcal { Y } =$ $[ 0 , \bar { 1 } ] ^ { 3 }$ with $c$ being the squared Euclidean distance. We collected ${ \approx } 2 0 0$ public domain images from WikiArt and trained a Meta ICNN model from sect. 3.2 to predict the color transfer maps between
353
+
354
+ ![](images/004e1408ffac58b0f7f37ea0b36650cec00e17e6541f60cd8a7c8bcc380ac26b.jpg)
355
+ Figure 5: Test set coupling predictions of the spherical transport problem. Meta OT’s initial prediction is ${ \approx } \mathbf { 3 7 5 0 0 }$ times faster than solving Sinkhorn to optimality. Supply locations are shown as black dots and the blue lines show the spherical transport maps $T$ going to demand locations at the end. The sphere is visualized with the Mercator projection.
356
+
357
+ ![](images/7af1ac4f0437daa502ac9da63b7ed2232221c26b74d5115b26c01519c59a0591.jpg)
358
+ Figure 6: Color transfers with a Meta ICNN on test pairs of images. The objective is to optimally transport the continuous RGB measure of the first image $\alpha$ to the second $\beta$ , producing an invertible transport map $T$ . Meta OT’s prediction is ${ \approx } \mathbf { 1 0 0 0 }$ times faster than training W2GN from scratch. The image generating $\alpha$ is Market in Algiers by August Macke (1914) and $\beta$ is Argenteuil, The Seine by Claude Monet (1872), obtained from WikiArt.
359
+
360
+ 230 every pair of them. Figure 6 shows the predictions on test pairs and fig. 7 shows the convergence in
361
+ 31 comparison to the standard W2GN learning. Table 2 reports runtimes and app. E shows additional
362
+ 232 results.
363
+
364
+ # 5 Related work
365
+
366
+ Efficiently estimating OT maps. To compute OT maps with fixed cost between pairs of measures efficiently, neural OT models [Korotin et al., 2019, Li et al., 2020, Korotin et al., 2021a, Mokrov et al., 2021, Korotin et al., 2021b] leverage ICNNs to estimate maps between continuous high
367
+
368
+ 237 dimensional measures given samples from these, and Litvinenko et al. [2021], Scetbon et al. [2021],
369
+ 238 Forrow et al. [2019], Sommerfeld et al. [2019], Scetbon et al. [2022], Muzellec and Cuturi [2019],
370
+ 239 Bonet et al. [2021] leverage structural assumptions on coupling and cost matrices to reduce the
371
+ 240 computational and memory complexity. In the meta-OT setting, we consider learning to rapidly
372
+ 241 compute OT mappings between new pairs measures. All these works can hence potentially benefit
373
+ 242 from an acceleration effect by leveraging amortization similarly.
374
+
375
+ Embedding measures where OT distances are discriminative. Effort has been invested in learning encodings/projections of measures through a nested optimization problem, which aims to find discriminative embeddings of the measures to be compared [Genevay et al., 2018, Deshpande et al., 2019, Nguyen and Ho, 2022]. While these works share an encoder and/or a projection across task with the aim of leveraging more discriminative alignments (and hence an OT distance with a metric different from the Euclidean metric), our work differs in the sense that we find good initializations to solve the OT problem itself with fixed cost more efficiently across tasks.
376
+
377
+ Optimal transport and amortization. Few previous works in the OT literature leverage amortization. Courty et al. [2018] learn a latent space in which the Wasserstein distance between the measure’s embeddings is equivalent to the Euclidean distance. Concurrent work [Nguyen and Ho, 2022] amortizes the estimation of the optimal projection in the max-sliced objective, which differs from our work where we instead amortize the estimation of the optimal coupling directly. Also, Lacombe et al. [2021] learns to predict Wasserstein barycenters of pixel images by training a convolutional networks that, given images as input, outputs their barycenters. Our work is hence a generalization of this pixel-based work to general measures – both discrete and continuous. A limitation of Lacombe et al. [2021] is that it does not provide alignments, as the amortization networks predicts the barycenter directly rather than individual couplings.
378
+
379
+ ![](images/276bdcc166d343a82e2fe0d299041d6a498983e773f8441fcc2d6150ccaa3910.jpg)
380
+ Figure 7: Convergence on color transfer test instances using W2GN. Meta ICNNs predicts warm-start initializations that significantly improve the (normalized) dual objective values.
381
+
382
+ # 6 Conclusions, future directions, and limitations
383
+
384
+ We have presented foundations for modeling and learning to solve OT problems with Meta OT by using amortized optimization to predict optimal transport plans. This works best in applications that require solving multiple OT problems with shared structure. We instantiated it to speed up entropic regularized optimal transport and unregularized optimal transport with squared cost by multiple orders of magnitude. We envision extensions of the work in:
385
+
386
+ 1. Meta OT models. While we mostly consider models based on hypernetworks, other metalearning paradigms can be connected in. In the discrete setting, we only considered settings where the cost remains fixed, but the Meta OT model can also be conditioned on the cost by considering the entire cost matrix as an input (which may be too large for most models to handle), or considering a lower-dimensional parameterization of the cost that changes between the Meta OT problem instances.
387
+ 2. OT algorithms. While we instantiated models on top of log-Sinkhorn and W2GN, Meta OT could be built on top of other methods.
388
+ 3. OT applications that are computationally expensive and repeatedly solved, e.g. in multimarginal and barycentric settings, or for Gromov-Wasserstein distances between metricmeasure spaces.
389
+
390
+ 285 Limitations. While we have illustrated successful applications of Meta OT, it is also important to
391
+ 286 understand the limitations: 1) Meta OT does not make previously intractable problems tractable.
392
+ 287 All of the baseline OT solvers we consider solve our problems within milliseconds or seconds. 2)
393
+ 288 Out-of-distribution generalization. Meta OT may not generate good predictions on instances that
394
+ 289 are not close to the training OT problems from the meta-distribution $\mathcal { D }$ over the measures and cost.
395
+ 290 If the model makes a bad prediction, one fallback option is to re-solve the instance from scratch.
396
+
397
+ References Mokhtar Z Alaya, Maxime Berar, Gilles Gasso, and Alain Rakotomamonjy. Screening sinkhorn algorithm for regularized optimal transport. Advances in Neural Information Processing Systems, 32, 2019. Jason Altschuler, Jonathan Niles-Weed, and Philippe Rigollet. Near-linear time approximation algorithms for optimal transport via sinkhorn iteration. Advances in neural information processing systems, 30, 2017. Luigi Ambrosio. Lecture notes on optimal transport problems. In Mathematical aspects of evolving interfaces, pages 1–52. Springer, 2003.
398
+ 298 Brandon Amos. Tutorial on amortized optimization for learning to optimize over continuous domains. arXiv preprint arXiv:2202.00665, 2022.
399
+ 300 Brandon Amos, Lei Xu, and J Zico Kolter. Input convex neural networks. In International Conference on Machine Learning, pages 146–155. PMLR, 2017. Martin Arjovsky, Soumith Chintala, and Léon Bottou. Wasserstein generative adversarial networks. In International conference on machine learning, pages 214–223. PMLR, 2017. Clément Bonet, Titouan Vayer, Nicolas Courty, François Septier, and Lucas Drumetz. Subspace detours meet gromov–wasserstein. Algorithms, 14(12):366, 2021. James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs. GitHub, 2018. URL http://github.com/google/jax. Yann Brenier. Polar factorization and monotone rearrangement of vector-valued functions. Communications on pure and applied mathematics, 44(4):375–417, 1991. Charlotte Bunne, Stefan G Stark, Gabriele Gut, Jacobo Sarabia del Castillo, Kjong-Van Lehmann, Lucas Pelkmans, Andreas Krause, and Gunnar Ratsch. Learning single-cell perturbation responses using neural optimal transport. bioRxiv, 2021. Charlotte Bunne, Andreas Krause, and Marco Cuturi. Supervised training of conditional monge maps. arXiv preprint arXiv:2206.14262, 2022a. Charlotte Bunne, Laetitia Papaxanthos, Andreas Krause, and Marco Cuturi. Proximal optimal transport modeling of population dynamics. In International Conference on Artificial Intelligence and Statistics, pages 6511–6528. PMLR, 2022b.
400
+ 319 Rick Chartrand, Brendt Wohlberg, Kevin Vixie, and Erik Bollt. A gradient descent solution to the mongekantorovich problem. Applied Mathematical Sciences, 3(22):1071–1080, 2009. Tianlong Chen, Xiaohan Chen, Wuyang Chen, Howard Heaton, Jialin Liu, Zhangyang Wang, and Wotao Yin. Learning to optimize: A primer and a benchmark. arXiv preprint arXiv:2103.12828, 2021. Samuel Cohen, Brandon Amos, and Yaron Lipman. Riemannian convex potential maps. In International Conference on Machine Learning, pages 2028–2038. PMLR, 2021. Roberto Cominetti and J San Martín. Asymptotic analysis of the exponential penalty trajectory in linear programming. Mathematical Programming, 67(1):169–187, 1994.
401
+ 327 Nicolas Courty, Rémi Flamary, Amaury Habrard, and Alain Rakotomamonjy. Joint distribution optimal transportation for domain adaptation. Advances in Neural Information Processing Systems, 30, 2017.
402
+ 329 Nicolas Courty, Rémi Flamary, and Mélanie Ducoffe. Learning wasserstein embeddings. In International Conference on Learning Representations, 2018. Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. Advances in neural information processing systems, 26:2292–2300, 2013. Marco Cuturi, Laetitia Meng-Papaxanthos, Yingtao Tian, Charlotte Bunne, Geoff Davis, and Olivier Teboul. Optimal transport tools (ott): A jax toolbox for all things wasserstein. arXiv preprint arXiv:2201.12324, 2022. Robert Dadashi, Léonard Hussenot, Matthieu Geist, and Olivier Pietquin. Primal wasserstein imitation learning. In ICLR 2021-Ninth International Conference on Learning Representations, 2021.
403
+
404
+ 338 Ishan Deshpande, Yuan-Ting Hu, Ruoyu Sun, Ayis Pyrros, Nasir Siddiqui, Sanmi Koyejo, Zhizhen Zhao, David
405
+ 339 Forsyth, and Alexander G Schwing. Max-sliced wasserstein distance and its use for gans. In Proceedings of
406
+ 340 the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10648–10656, 2019.
407
+ 341 Erin Doxsey-Whitfield, Kytt MacManus, Susana B Adamo, Linda Pistolesi, John Squires, Olena Borkovska,
408
+ 342 and Sandra R Baptista. Taking advantage of the improved availability of census data: a first look at the
409
+ 343 gridded population of the world, version 4. Papers in Applied Geography, 1(3):226–234, 2015.
410
+ 344 Bjorn Engquist and Brittany D Froese. Application of the wasserstein metric to seismic signals. arXiv preprint
411
+ 345 arXiv:1311.4581, 2013.
412
+ 346 Werner Fenchel. On conjugate convex functions. Canadian Journal of Mathematics, 1(1):73–77, 1949.
413
+ 347 Arnaud Fickinger, Samuel Cohen, Stuart Russell, and Brandon Amos. Cross-domain imitation learning via
414
+ 348 optimal transport. In International Conference on Learning Representations, 2021.
415
+ 349 Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep
416
+ 350 networks. In Doina Precup and Yee Whye Teh, editors, Proceedings of the 34th International Conference
417
+ 351 on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 1126–1135. PMLR,
418
+ 352 06–11 Aug 2017. URL https://proceedings.mlr.press/v70/finn17a.html.
419
+ 353 Rémi Flamary, Nicolas Courty, Alexandre Gramfort, Mokhtar Z Alaya, Aurélie Boisbunon, Stanislas Chambon,
420
+ 354 Laetitia Chapel, Adrien Corenflos, Kilian Fatras, Nemo Fournier, et al. Pot: Python optimal transport.
421
+ 355 Journal of Machine Learning Research, 22(78):1–8, 2021.
422
+ 356 Aden Forrow, Jan-Christian Hütter, Mor Nitzan, Philippe Rigollet, Geoffrey Schiebinger, and Jonathan Weed.
423
+ 357 Statistical optimal transport via factored couplings. In The 22nd International Conference on Artificial
424
+ 358 Intelligence and Statistics, pages 2454–2465. PMLR, 2019.
425
+ 359 Alfred Galichon. Optimal transport methods in economics. In Optimal Transport Methods in Economics.
426
+ 360 Princeton University Press, 2016.
427
+ 361 Marta Garnelo, Dan Rosenbaum, Christopher Maddison, Tiago Ramalho, David Saxton, Murray Shanahan,
428
+ 362 Yee Whye Teh, Danilo Rezende, and SM Ali Eslami. Conditional neural processes. In International Con
429
+ 363 ference on Machine Learning, pages 1704–1713. PMLR, 2018a.
430
+ 364 Marta Garnelo, Jonathan Schwarz, Dan Rosenbaum, Fabio Viola, Danilo J Rezende, SM Eslami, and Yee Whye
431
+ 365 Teh. Neural processes. arXiv preprint arXiv:1807.01622, 2018b.
432
+ 366 Aude Genevay, Gabriel Peyre, and Marco Cuturi. Learning generative models with sinkhorn divergences. In
433
+ 367 Amos Storkey and Fernando Perez-Cruz, editors, Proceedings of the Twenty-First International Conference
434
+ 368 on Artificial Intelligence and Statistics, volume 84 of Proceedings of Machine Learning Research, pages
435
+ 369 1608–1617. PMLR, 09–11 Apr 2018. URL https://proceedings.mlr.press/v84/genevay18a.
436
+ 370 html.
437
+ 371 David Ha, Andrew Dai, and Quoc V Le. Hypernetworks. arXiv preprint arXiv:1609.09106, 2016.
438
+ 372 Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In
439
+ 373 European conference on computer vision, pages 630–645. Springer, 2016.
440
+ 374 Chin-Wei Huang, Ricky TQ Chen, Christos Tsirigotis, and Aaron Courville. Convex potential flows: Universal
441
+ 375 probability distributions with optimal transport and convex optimization. In International Conference on
442
+ 376 Learning Representations, 2020.
443
+ 377 J. J. Hull. A database for handwritten text recognition research. IEEE Transactions on Pattern Analysis and
444
+ 378 Machine Intelligence, 16(5):550–554, 1994. doi: 10.1109/34.291440.
445
+ 379 Ray Jiang, Aldo Pacchiano, Tom Stepleton, Heinrich Jiang, and Silvia Chiappa. Wasserstein fair classification.
446
+ 380 In Uncertainty in Artificial Intelligence, pages 862–872. PMLR, 2020.
447
+ 381 Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint
448
+ 382 arXiv:1412.6980, 2014.
449
+ 383 Nicholas Kolkin, Jason Salavon, and Gregory Shakhnarovich. Style transfer by relaxed optimal transport and
450
+ 384 self-similarity. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition,
451
+ 385 pages 10051–10060, 2019.
452
+ 386 Soheil Kolouri, Yang Zou, and Gustavo K Rohde. Sliced wasserstein kernels for probability distributions. In
453
+ 387 Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 5258–5267, 2016.
454
+
455
+ 88 Soheil Kolouri, Se Rim Park, Matthew Thorpe, Dejan Slepcev, and Gustavo K Rohde. Optimal mass transport: Signal processing and machine-learning applications. IEEE signal processing magazine, 34(4):43–59, 2017. Soheil Kolouri, Phillip E Pope, Charles E Martin, and Gustavo K Rohde. Sliced wasserstein auto-encoders. In International Conference on Learning Representations, 2018. Soheil Kolouri, Kimia Nadjahi, Umut Simsekli, Roland Badeau, and Gustavo K Rohde. Generalized sliced wasserstein distances. arXiv preprint arXiv:1902.00434, 2019.
456
+ Alexander Korotin, Vage Egiazarian, Arip Asadulaev, Alexander Safin, and Evgeny Burnaev. Wasserstein-2 generative networks. arXiv preprint arXiv:1909.13082, 2019. Alexander Korotin, Lingxiao Li, Aude Genevay, Justin M Solomon, Alexander Filippov, and Evgeny Burnaev. Do neural optimal transport solvers work? a continuous wasserstein-2 benchmark. Advances in Neural Information Processing Systems, 34:14593–14605, 2021a.
457
+ Alexander Korotin, Lingxiao Li, Justin Solomon, and Evgeny Burnaev. Continuous wasserstein-2 barycenter estimation without minimax optimization. arXiv preprint arXiv:2102.01752, 2021b. Alexander Korotin, Daniil Selikhanovych, and Evgeny Burnaev. Neural optimal transport. arXiv preprint arXiv:2201.12220, 2022.
458
+ Julien Lacombe, Julie Digne, Nicolas Courty, and Nicolas Bonneel. Learning to generate wasserstein barycenters, 2021. URL https://openreview.net/forum?id $\cdot ^ { = }$ 2ioNazs6lvw. Lingxiao Li, Aude Genevay, Mikhail Yurochkin, and Justin Solomon. Continuous regularized wasserstein barycenters. arXiv preprint arXiv:2008.12534, 2020. Tianyi Lin, Nhat Ho, and Michael I Jordan. On the acceleration of the sinkhorn and greenkhorn algorithms for optimal transport. arXiv preprint arXiv:1906.01437, 2019. Alexander Litvinenko, Youssef Marzouk, Hermann G Matthies, Marco Scavino, and Alessio Spantini. Computing f-divergences and distances of high-dimensional probability density functions–low-rank tensor approximations. arXiv preprint arXiv:2111.07164, 2021. Ashok Makkuva, Amirhossein Taghvaei, Sewoong Oh, and Jason Lee. Optimal transport mapping via input convex neural networks. In International Conference on Machine Learning, pages 6672–6681. PMLR, 2020. Quentin Merigot and Boris Thibert. Optimal transport: discretization and algorithms. In Handbook of Numerical Analysis, volume 22, pages 133–212. Elsevier, 2021. Petr Mokrov, Alexander Korotin, Lingxiao Li, Aude Genevay, Justin M Solomon, and Evgeny Burnaev. Largescale wasserstein gradient flows. Advances in Neural Information Processing Systems, 34:15243–15256, 2021. Boris Muzellec and Marco Cuturi. Subspace detours: Building transport plans that are optimal on subspace projections. Advances in Neural Information Processing Systems, 32, 2019. Khai Nguyen and Nhat Ho. Amortized projection optimization for sliced wasserstein generative models. arXiv preprint arXiv:2203.13417, 2022. Michaël Perrot, Nicolas Courty, Rémi Flamary, and Amaury Habrard. Mapping estimation for discrete optimal transport. Advances in Neural Information Processing Systems, 29, 2016. Gabriel Peyré, Marco Cuturi, et al. Computational optimal transport: With applications to data science. Foundations and Trends® in Machine Learning, 11(5-6):355–607, 2019. Ievgen Redko, Nicolas Courty, Rémi Flamary, and Devis Tuia. Optimal transport for multi-source domain adaptation under target shift. In The 22nd International Conference on Artificial Intelligence and Statistics, pages 849–858. PMLR, 2019. Ralph Tyrell Rockafellar. Convex analysis. In Convex analysis. Princeton university press, 2015. Litu Rout, Alexander Korotin, and Evgeny Burnaev. Generative modeling with optimal transport maps. In International Conference on Learning Representations, 2021. Andrei A Rusu, Dushyant Rao, Jakub Sygnowski, Oriol Vinyals, Razvan Pascanu, Simon Osindero, and Raia Hadsell. Meta-learning with latent embedding optimization. In International Conference on Learning Representations, 2018.
459
+
460
+ 436 Filippo Santambrogio. Optimal transport for applied mathematicians. Birkäuser, NY, 55(58-63):94, 2015.
461
+ 437 Meyer Scetbon, Marco Cuturi, and Gabriel Peyré. Low-rank sinkhorn factorization. In International Confer
462
+ 438 ence on Machine Learning, pages 9344–9354. PMLR, 2021.
463
+ 439 Meyer Scetbon, Gabriel Peyré, and Marco Cuturi. Linear-time gromov wasserstein distances using low rank
464
+ 440 couplings and costs. In International Conference on Machine Learning, pages 19347–19365. PMLR, 2022.
465
+ 441 Geoffrey Schiebinger, Jian Shu, Marcin Tabaka, Brian Cleary, Vidya Subramanian, Aryeh Solomon, Joshua
466
+ 442 Gould, Siyan Liu, Stacie Lin, Peter Berube, Lia Lee, Jenny Chen, Justin Brumbaugh, Philippe Rigol
467
+ 443 let, Konrad Hochedlinger, Rudolf Jaenisch, Aviv Regev, and Eric S. Lander. Optimal-transport analy
468
+ 444 sis of single-cell gene expression identifies developmental trajectories in reprogramming. Cell, 176(4):
469
+ 445 928–943.e22, 2019. ISSN 0092-8674. doi: https://doi.org/10.1016/j.cell.2019.01.006. URL https:
470
+ 446 //www.sciencedirect.com/science/article/pii/S009286741930039X.
471
+ 447 Vivien Seguy, Bharath Bhushan Damodaran, Remi Flamary, Nicolas Courty, Antoine Rolet, and Mathieu Blon
472
+ 448 del. Large scale optimal transport and mapping estimation. In International Conference on Learning Repre
473
+ 449 sentations, 2018.
474
+ 450 Justin Solomon, Fernando De Goes, Gabriel Peyré, Marco Cuturi, Adrian Butscher, Andy Nguyen, Tao Du,
475
+ 451 and Leonidas Guibas. Convolutional wasserstein distances: Efficient optimal transportation on geometric
476
+ 452 domains. ACM Transactions on Graphics (TOG), 34(4):1–11, 2015.
477
+ 453 Max Sommerfeld, Jörn Schrieber, Yoav Zemel, and Axel Munk. Optimal transport: Fast probabilistic approxi
478
+ 454 mation with exact solvers. J. Mach. Learn. Res., 20:105–1, 2019.
479
+ 455 Kenneth O Stanley, David B D’Ambrosio, and Jason Gauci. A hypercube-based encoding for evolving large
480
+ 456 scale neural networks. Artificial life, 15(2):185–212, 2009.
481
+ 457 Amirhossein Taghvaei and Amin Jalali. 2-wasserstein approximation via restricted convex potentials with
482
+ 458 application to improved training for gans. arXiv preprint arXiv:1902.07197, 2019.
483
+ 459 Matthew Tancik, Ben Mildenhall, Terrance Wang, Divi Schmidt, Pratul P Srinivasan, Jonathan T Barron, and
484
+ 460 Ren Ng. Learned initializations for optimizing coordinate-based neural representations. In Proceedings of
485
+ 461 the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2846–2855, 2021.
486
+ 462 Alexis Thibault, Lenaic Chizat, Charles Dossal, and Nicolas Papadakis. Overrelaxed sinkhorn-knopp algorithm
487
+ 463 for regularized optimal transport. arXiv preprint arXiv:1711.01851, 2017.
488
+ 464 James Thornton and Marco Cuturi. Rethinking initialization of the sinkhorn algorithm. arXiv preprint
489
+ 465 arXiv:2206.07630, 2022.
490
+ 466 Cédric Villani. Optimal transport: old and new, volume 338. Springer, 2009.
491
+ 467 Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using
492
+ 468 cycle-consistent adversarial networks. In Proceedings of the IEEE international conference on computer
493
+ 469 vision, pages 2223–2232, 2017.
494
+ 470 Luisa Zintgraf, Kyriacos Shiarli, Vitaly Kurin, Katja Hofmann, and Shimon Whiteson. Fast context adaptation
495
+ 471 via meta-learning. In International Conference on Machine Learning, pages 7693–7702. PMLR, 2019.
496
+
497
+ 1. For all authors...
498
+
499
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] We hope so
500
+ (b) Did you describe the limitations of your work? [Yes] In sect. 6
501
+ (c) Did you discuss any potential negative societal impacts of your work? [No] We do not immediately foresee any that our work would add that the broader optimal transport field doesn’t already have
502
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
503
+
504
+ 2. If you are including theoretical results... (This is not a theory paper)
505
+
506
+ (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]
507
+
508
+ 3. If you ran experiments...
509
+
510
+ (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]
511
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
512
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We show results from multiple trials in most places
513
+ (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]
514
+
515
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
516
+
517
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
518
+ (b) Did you mention the license of the assets? [Yes]
519
+ (c) Did you include new assets either in the supplemental material or as a URL? [No]
520
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
521
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
522
+
523
+ 5. If you used crowdsourcing or conducted research with human subjects...
524
+
525
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
526
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
527
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
528
+
529
+ ![](images/3f20dd6b171e97fbcafe42fda12f6bbf12e0527507667de291ea1dcf9db9c3c6.jpg)
530
+ Figure 8: We selected $\epsilon = 1 0 ^ { - 2 }$ for our MNIST coupling experiments as it results in transport maps that are not too blurry or sharp.
531
+
532
+ # 512 B Other models for continuous OT
533
+
534
+ While developing the hyper-network or Meta ICNN in sect. 3.2 for predicting couplings between continuous measures, we considered alternative modeling formulations briefly documented in this section. We finalized only the hyper-network model because it is conceptually the most similar to predicting the optimal dual variables in the continuous setting and results in rapid predictions.
535
+
536
+ # 517 B.1 Optimization-based meta-learning (MAML-inspired)
537
+
538
+ 518 The model-agnostic meta-learning setup proposed in MAML [Finn et al., 2017] could also be ap
539
+ 519 plied in the Meta OT setting to learn an adaptable initial parameterization. In the continuous setting,
540
+ 520 one initial version would take a parameterized dual potential model $\psi _ { \varphi } ( x )$ and seek to learn an ini
541
+ 521 tial parameterization $\varphi _ { 0 }$ so that optimizing a loss such as the W2GN loss $\mathcal { L }$ from eq. (12) results in
542
+ 522 a minimal $\mathcal { L } ( \varphi _ { K } )$ after adapting the model for $K$ steps. Formally, this would optimize:
543
+
544
+ $$
545
+ \operatorname * { a r g m i n } _ { \varphi _ { 0 } } \mathcal { L } ( \varphi _ { K } ) \quad \mathrm { w h e r e } \quad \varphi _ { t + 1 } = \varphi _ { t } - \nabla _ { \varphi } \mathcal { L } ( \varphi _ { t } )
546
+ $$
547
+
548
+ Tancik et al. [2021] explores similar learned initializations for coordinate-based neural implicit representations for 2D images, CT scan reconstruction, and 3d shape and scene recovery from 2D observations.
549
+
550
+ Challenges for Meta OT. The transport maps given by $T = \nabla \psi$ can significantly vary depending on the input measures $\alpha , \beta$ . We found it difficult to learn an initialization that can be rapidly adapted, and optimizing eq. (19) is more computationally expensive than eq. (18) as it requires unrolling through many evaluations of the transport loss $\mathcal { L }$ . And, we found that only learning to predict the optimal parameters with eq. (18), conditional on the input measures, and then fine-tuning with W2GN to be stable.
551
+
552
+ 532 Advantages for Meta OT. Exploring MAML-inspired methods could further incorporate the knowl
553
+ 533 edge that the model’s prediction is going to be fine-tuned into the learning process. One promising
554
+
555
+ direction we did not try could be to integrate some of the ideas from LEO [Rusu et al., 2018] and CAVIA [Zintgraf et al., 2019], which propose to learn a latent space for the parameters where the initialization is also conditional on the input.
556
+
557
+ # B.2 Neural process and conditional Monge maps
558
+
559
+ The (conditional) neural process models considered in Garnelo et al. [2018b,a] can also be adapted for the Meta OT setting, and is similar to the model proposed in Bunne et al. [2022a]. In the continuous setting, this would result in a dual potential that is also conditioned on a representation of the input measures, e.g. $\psi _ { \varphi } ( x ; z )$ where $z : = f _ { \varphi } ^ { \mathrm { e m b } } ( \alpha , \beta )$ is a learned embedding of the input measures that is learned with the parameters of $\psi$ . This could be formulated as
560
+
561
+ $$
562
+ \underset { \varphi } { \arg \operatorname* { m i n } } \ \underset { ( \alpha , \beta ) \sim \mathcal { D } } { \mathbb { E } } \mathcal { L } ( \varphi , f _ { \varphi } ^ { \mathrm { e m b } } ( \alpha , \beta ) ) ,
563
+ $$
564
+
565
+ 543 where $\mathcal { L }$ modifies the model used in the loss eq. (12) to also be conditioned on the context extracted
566
+ 544 from the measures.
567
+
568
+ Challenges for Meta OT. This raises the issue on best-formulating the model to be conditional on the context. One way could be to append $z$ to the input point $x$ in the domain. Bunne et al. [2022a] proposes to use the Partially Input-Convex Neural Network (PICNN) from [Amos et al., 2017] to make the model convex with respect to $x$ and not $z$ .
569
+
570
+ Advantages for Meta OT. A large advantage is that the representation $z$ of the measures $\alpha , \beta$ would be significantly lower-dimensional than the parameters $\varphi$ that our Meta OT models are predicting.
571
+
572
+ # 551 C Additional experimental and implementation details
573
+
574
+ We have attached the Jax source code necessary to run and reproduce all of the experiments in our 553 paper and will open-source all of it. Here is a basic overview of the files:
575
+
576
+ ![](images/66b53dde9e387914f911c46162b2ee1500e1db7f81732c8a89d889919359d4da.jpg)
577
+
578
+ 555 Connecting to the data is one difficulty in running the experiments. The easiest experiment to re-run
579
+ 556 is the MNIST one, which will automatically download the dataset:
580
+ 557558 1 ./ train_discrete . py # Train the model , outputting to <exp_dir >
581
+ 559 2 ./ eval_discrete . py < exp_dir > # Evaluate the learned models
582
+ 560 3 ./ plot_mnist . py < exp_dir > # Produce further visualizations 561
583
+
584
+ # 562 C.1 Hyper-parameters
585
+
586
+ 563 We briefly summarize the hyper-parameters we used for training, which we did not extensively tune.
587
+ 564 In the discrete setting, we use the same hyper-parameters for the MNIST and spherical settings.
588
+
589
+ Table 3: Discrete OT hyper-parameters.
590
+
591
+ <table><tr><td>Name</td><td>Value</td></tr><tr><td>Batch size</td><td>128</td></tr><tr><td>Number of training iterations</td><td>50000</td></tr><tr><td>MLP Hidden Sizes</td><td>[1024,1024,1024]</td></tr><tr><td>Adam learning rate</td><td>1e-3</td></tr></table>
592
+
593
+ 565
594
+
595
+ Table 4: Continuous OT hyper-parameters.
596
+
597
+ <table><tr><td>Name</td><td>Value</td></tr><tr><td>Meta batch size (for α,β)</td><td>8</td></tr><tr><td>Inner batch size (to estimate L) Cycle loss weight ()</td><td>1024</td></tr><tr><td>Adam learning rate</td><td>3. 1e-3</td></tr><tr><td>l2 weight penalty</td><td>1e-6</td></tr><tr><td>Max grad norm (for clipping)</td><td>1.</td></tr><tr><td>Number of training iterations</td><td>200000</td></tr><tr><td>MetaICNNEncoder</td><td>ResNet18</td></tr><tr><td>Encoder output size (both measures)</td><td></td></tr><tr><td>MetaICNNDecoderHidden Sizes</td><td>256×2 [512]</td></tr></table>
598
+
599
+ # 566 C.2 Sinkhorn convergence times, varying thresholds
600
+
601
+ In the main paper, table 1 reports the runtime of Sinkhorn to reach a convergence threshold of the marginal error being below a tolerance of $1 0 ^ { - 3 }$ , which is the default value used in many solvers. app. C.2 report the results from sweeping over other thresholds and show that Meta OT’s initialization is consistently able to help.
602
+
603
+ Table 5: Sinkhorn runtime to reach a thresholded marginal error on MNIST.
604
+
605
+ <table><tr><td>Initialization</td><td>Threshold=10-2</td><td>Threshold=10-3</td><td>Threshold=10-4</td><td>Threshold=10-5</td></tr><tr><td>Zeros</td><td>4.5. 10-3 ±1.5·10-3</td><td>7.7.10-3 ±1.2· 10-3</td><td>1.1.10-2 ±1.8.10-3</td><td>1.5.10-2 ±2.3.10-3</td></tr><tr><td>Gaussian</td><td>4.1· 10- ±1.2 ·10-3</td><td>7.7 · 10-3 ±1.4 10-3</td><td>1.1: 10-2 ±1.7· 10-3</td><td>1.4: 10-² ±2.4 · 10-3</td></tr><tr><td>Meta OT</td><td>2.3 · 10-3 ±9.2 · 10-6</td><td>3.9 · 10-3 ±1.6 · 10-3</td><td>6.7 · 10-3 ±1.4 · 10-3</td><td>1.0 · 10-² ±2.4 · 10-3</td></tr></table>
606
+
607
+ Table 6: Sinkhorn runtime to reach a thresholded marginal error on the spherical transport problem.
608
+
609
+ <table><tr><td>Initialization</td><td>Threshold=10-2</td><td>Threshold=10-3</td><td>Threshold=10-4</td><td>Threshold=10-5</td></tr><tr><td>Zeros</td><td>8.8.10-1 ±1.3·10-1</td><td>1.4 ±1.9 · 10-1</td><td>2.1 ±3.6:10-1</td><td>2.8 ±5.6.10-1</td></tr><tr><td>Gaussian</td><td>5.6.10-1 ±9.9.10-2</td><td>1.1 ±2.0 : 10-1</td><td>1.7 ±3.5 - 10-1</td><td>2.4 ±5.4 · 10-1</td></tr><tr><td>Meta OT</td><td> 7.8 · 10-² ±3.4· 10-²</td><td>0.44 ±1.5 10-1</td><td>0.97 ±3.2 - 10-1</td><td>1.7 ±6.8 10-1</td></tr></table>
610
+
611
+ 572
612
+ 573
613
+ 574
614
+
615
+ App. C.3 shows the convergence during training of Meta OT models in the discrete and continuous settings over 10 trials on our single Quadro GP100 GPU. The MNIST models are consistently trained to optimality within 2 minutes (!) while the continuous model takes a few hours to train.
616
+
617
+ ![](images/c65d9b80bc771a7f24a4c9491464f0d264572127c957ca71436a6b0b2057fd7e.jpg)
618
+ Figure 9: Convergence of Meta OT models during training, reported over iterations and wall-clock time. We run each experiment for 10 trials with different seeds and report each trial as a line.
619
+
620
+ # 575 D Out-of-distribution generalization
621
+
622
+ App. D tests the ability of Meta OT to predict potentials for out-of-distribution input data. We consider the pairwise training and evaluation on the following datasets: 1) MNIST; 2) USPS [Hull, 1994] (upscaled to have the same size as the MNIST); 3) Google Doodles dataset \* with classes Crab, Cat and Faces; 4) sparsified random uniform data in [0,1] where sparsity (zeroing values below 0.95) is used to mimic the sparse signal in black-and-white images. For each pair, eg, MNIST-USPS, we train on one dataset and use the other to predict the potentials. The comparison is done using the same metric as before, i.e., the deviation from the marginal constraints defined in eq. (7).
623
+
624
+ ![](images/a65dabc1328759986cd9453b0ec2f8ff4816cbe1138e8a0dfd80e63e988cdf67.jpg)
625
+ Figure 10: Cross-domain experiments.
626
+
627
+ # 583 E Additional color transfer results
628
+
629
+ 84 We next show additional color transfer results from the experiments in sect. 4.3 on the following
630
+ 85 public domain images from WikiArt:
631
+
632
+ • Distant View of the Pyramids by Winston Churchill (1921)
633
+ • Charing Cross Bridge, Overcast Weather by Claude Monet (1900)
634
+ • Houses of Parliament by Claude Monet (1904)
635
+ • October Sundown, Newport by Childe Hassam (1901)
636
+ • Landscape with House at Ceret by Juan Gris (1913)
637
+ • Irises in Monet’s Garden by Claude Monet (1900)
638
+ • Crystal Gradation by Paul Klee (1921)
639
+ • Senecio by Paul Klee (1922)
640
+ • Váza s kvetinami by Josef Capek (1914) ˇ
641
+ • Sower with Setting Sun by Vincent van Gogh (1888)
642
+ • Three Trees in Grey Weather by Claude Monet (1891)
643
+ • Vase with Daisies and Anemones by Vincent van Gogh (1887)
644
+
645
+ ![](images/6cc461505612aaa96f12cb9218bf3e55dbb5b35c739b02afaa9565d7bef24dba.jpg)
646
+ Figure 11: Meta ICNN (initial prediction). The sources are given in the beginning of app. E.
647
+
648
+ ![](images/09d3dfa82fa398eb9d40ec3acb54491a4d36751e7aae18c43668615713bf8f86.jpg)
649
+ Figure 12: Meta ICNN $^ +$ W2GN fine-tuning. The sources are given in the beginning of app. E.
650
+
651
+ ![](images/c4807975bc736e8bedf554a75b321eca90de0361c71d4219df36c06d482e14bf.jpg)
652
+ Figure 13: W2GN (final). The sources are given in the beginning of app. E.
md/dev/vSVLM2j9eie/vSVLM2j9eie.md ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CROSSFORMER: TRANSFORMER UTILIZING CROSSDIMENSION DEPENDENCY FOR MULTIVARIATE TIME SERIES FORECASTING
2
+
3
+ Yunhao Zhang & Junchi Yan∗
4
+ MoE Key Lab of Artificial Intelligence, Shanghai Jiao Tong University and Shanghai AI Lab
5
+ {zhangyunhao, yanjunchi}@sjtu.edu.cn
6
+ Code: https://github.com/Thinklab-SJTU/Crossformer
7
+
8
+ # ABSTRACT
9
+
10
+ Recently many deep models have been proposed for multivariate time series (MTS) forecasting. In particular, Transformer-based models have shown great potential because they can capture long-term dependency. However, existing Transformerbased models mainly focus on modeling the temporal dependency (cross-time dependency) yet often omit the dependency among different variables (crossdimension dependency), which is critical for MTS forecasting. To fill the gap, we propose Crossformer, a Transformer-based model utilizing cross-dimension dependency for MTS forecasting. In Crossformer, the input MTS is embedded into a 2D vector array through the Dimension-Segment-Wise (DSW) embedding to preserve time and dimension information. Then the Two-Stage Attention (TSA) layer is proposed to efficiently capture the cross-time and cross-dimension dependency. Utilizing DSW embedding and TSA layer, Crossformer establishes a Hierarchical Encoder-Decoder (HED) to use the information at different scales for the final forecasting. Extensive experimental results on six real-world datasets show the effectiveness of Crossformer against previous state-of-the-arts.
11
+
12
+ # 1 INTRODUCTION
13
+
14
+ Multivariate time series (MTS) are time series with multiple dimensions, where each dimension represents a specific univariate time series (e.g. a climate feature of weather). MTS forecasting aims to forecast the future value of MTS using their historical values. MTS forecasting benefits the decision-making of downstream tasks and is widely used in many fields including weather (Angryk et al., 2020), energy (Demirel et al., 2012), finance (Patton, 2013), etc. With the development of deep learning, many models have been proposed and achieved superior performances in MTS forecasting (Lea et al., 2017; Qin et al., 2017; Flunkert et al., 2017; Rangapuram et al., 2018; Li et al., 2019a; Wu et al., 2020; Li et al., 2021). Among them, the recent Transformer-based models (Li et al., 2019b; Zhou et al., 2021; Wu et al., 2021a; Liu et al., 2021a; Zhou et al., 2022; Chen et al., 2022) show great potential thanks to their ability to capture long-term temporal dependency (cross-time dependency).
15
+
16
+ Besides cross-time dependency, the cross-dimension dependency is also critical for MTS forecasting, i.e. for a specific dimension, information from associated series in other dimensions may improve prediction. For example, when predicting future temperature, not only the historical temperature, but also historical wind speed helps to forecast. Some previous neural models explicitly capture the cross-dimension dependency, i.e. preserving the information of dimensions in the latent feature space and using convolution neural network (CNN) (Lai et al., 2018) or graph neural network (GNN) (Wu et al., 2020; Cao et al., 2020) to capture their dependency. However, recent Transformer-based models only implicitly utilize this dependency by embedding. In general, Transformer-based models embed data points in all dimensions at the same time step into a feature vector and try to capture dependency among different time steps (like Fig. 1 (b)). In this way, cross-time dependency is well captured, but cross-dimension dependency is not, which may limit their forecasting capability.
17
+
18
+ To fill the gap, we propose Crossformer, a Transformer-based model that explicitly utilizes crossdimension dependency for MTS forecasting. Specifically, we devise Dimension-Segment-Wise (DSW) embedding to process the historical time series. In DSW embedding, the series in each dimension is first partitioned into segments and then embedded into feature vectors. The output of DSW embedding is a 2D vector array where the two axes correspond to time and dimension. Then we propose the Two-Stage-Attention (TSA) layer to efficiently capture the cross-time and cross-dimension dependency among the 2D vector array. Using DSW embedding and TSA layer, Crossformer establishes a Hierarchical Encoder-Decoder (HED) for forecasting. In HED, each layer corresponds to a scale. The encoder’s upper layer merges adjacent segments output by the lower layer to capture the dependency at a coarser scale. Decoder layers generate predictions at different scales and add them up as the final prediction. The contributions of this paper are:
19
+
20
+ 1) We dive into the existing Transformer-based models for MTS forecasting and figure out that the cross-dimension dependency is not well utilized: these models simply embed data points of all dimensions at a specific time step into a single vector and focus on capturing the cross-time dependency among different time steps. Without adequate and explicit mining and utilization of cross-dimension dependency, their forecasting capability is empirically shown limited.
21
+
22
+ 2) We develop Crossformer, a Transformer model utilizing cross-dimension dependency for MTS forecasting. This is one of the few transformer models (perhaps the first to our best knowledge) that explicitly explores and utilizes cross-dimension dependency for MTS forecasting.
23
+
24
+ 3) Extensive experimental results on six real-world benchmarks show the effectiveness of our Crossformer against previous state-of-the-arts. Specifically, Crossformer ranks top-1 among the 9 models for comparison on 36 out of the 58 settings of varying prediction lengths and metrics and ranks top-2 on 51 settings.
25
+
26
+ # 2 RELATED WORKS
27
+
28
+ Multivariate Time Series Forecasting. MTS forecasting models can be roughly divided into statistical and neural models. Vector auto-regressive (VAR) model (Kilian & LAtkepohl ˜ , 2017) and Vector auto-regressive moving average (VARMA) are typical statistical models, which assume linear cross-dimension and cross-time dependency. With the development of deep learning, many neural models have been proposed and often empirically show better performance than statistical ones. TCN (Lea et al., 2017) and DeepAR (Flunkert et al., 2017) treat the MTS data as a sequence of vectors and use CNN/RNN to capture the temporal dependency. LSTnet (Lai et al., 2018) employs CNN to capture cross-dimension dependency and RNN for cross-time dependency. Another category of works use graph neural networks (GNNs) to capture the cross-dimension dependency explicitly for forecasting (Li et al., 2018; Yu et al., 2018; Cao et al., 2020; Wu et al., 2020). For example, MTGNN (Wu et al., 2020) uses temporal convolution and graph convolution layers to capture crosstime and cross-dimension dependency. These neural models capture the cross-time dependency through CNN or RNN, which have difficulty in modeling long-term dependency.
29
+
30
+ Transformers for MTS Forecasting. Transformers (Vaswani et al., 2017) have achieved success in natural language processing (NLP) (Devlin et al., 2019), vision (CV) (Dosovitskiy et al., 2021) and speech processing (Dong et al., 2018). Recently, many Transformer-based models have been proposed for MTS forecasting and show great potential (Li et al., 2019b; Zhou et al., 2021; Wu et al., 2021a; Liu et al., 2021a; Zhou et al., 2022; Du et al., 2022). LogTrans (Li et al., 2019b) proposes the LogSparse attention that reduces the computation complexity of Transformer from ${ \dot { O } } ( { \dot { L } } ^ { 2 } )$ to $O \left( L ( \log L ) ^ { 2 } \right)$ . Informer (Zhou et al., 2021) utilizes the sparsity of attention score through KL divergence estimation and proposes ProbSparse self-attention which achieves $O ( L \log L )$ complexity. Autoformer (Wu et al., 2021a) introduces a decomposition architecture with an Auto-Correlation mechanism to Transformer, which also achieves the $O ( L \log L )$ complexity. Pyraformer (Liu et al., 2021a) introduces a pyramidal attention module that summarizes features at different resolutions and models the temporal dependencies of different ranges with the complexity of $O ( L )$ . FEDformer (Zhou et al., 2022) proposes that time series have a sparse representation in frequency domain and develop a frequency enhanced Transformer with the $O ( L )$ complexity. Preformer (Du et al., 2022) divides the embedded feature vector sequence into segments and utilizes segment-wise correlation-based attention for forecasting. These models mainly focus on reducing the complexity of cross-time dependency modeling, but omits the cross-dimension dependency which is critical for MTS forecasting.
31
+
32
+ ![](images/58f91577761d114749db0b9c2411629ff28fc541aac4585ce6c559b60c4f406b.jpg)
33
+ Figure 1: Illustration for our DSW embedding. (a) Self-attention scores from a 2-layer Transformer trained on ETTh1, showing that MTS data tends to be segmented. (b) Embedding method of previous Transformer-based models (Li et al., 2019b; Zhou et al., 2021; Wu et al., 2021a; Liu et al., 2021a): data points in different dimensions at the same step are embedded into a vector. (c) DSW embedding of Crossformer: in each dimension, nearby points over time form a segment for embedding.
34
+
35
+ Vision Transformers. Transformer is initially applied to NLP for sequence modeling, recent works apply transformer to CV tasks to process images (Dosovitskiy et al., 2021; Touvron et al., 2021; Liu et al., 2021b; Chen et al., 2021; Han et al., 2021). These works achieve state-of-the-art performance on various tasks in CV and inspire our work. ViT (Dosovitskiy et al., 2021) is one of the pioneers of vision transformers. The basic idea of ViT is to split an image into non-overlapping medium-sized patches, then it rearranges these patches into a sequence to be input to the Transformer. The idea of partitioning images into patches inspires our DSW embedding where MTS is split into dimensionwise segments. Swin Transformer (Liu et al., 2021b) performs local attention within a window to reduce the complexity and builds hierarchical feature maps by merging image patches. Readers can refer to the recent survey (Han et al., 2022) for comprehensive study on vision transformers.
36
+
37
+ # 3 METHODOLOGY
38
+
39
+ In multivariate time series forecasting, one aims to predict the future value of time series $\mathbf { x } _ { T + 1 : T + \tau } \in$ Rτ×D given the history $\mathbf { x } _ { 1 : T } \in \mathbb { R } ^ { \tilde { T } \times D }$ , where $\tau$ , $T$ is the number of time steps in the future and past, respectively2. $D > 1$ is the number of dimensions. A natural assumption is that these $D$ series are associated (e.g. climate features of weather), which helps to improve the forecasting accuracy. To utilize the cross-dimension dependency, in Section 3.1, we embed the MTS using Dimension-Segment-Wise (DSW) embedding. In Section 3.2, we propose a Two-Stage Attention (TSA) layer to efficiently capture the dependency among the embedded segments. In Section 3.3, using DSW embedding and TSA layer, we construct a hierarchical encoder-decoder (HED) to utilize information at different scales for final forecasting.
40
+
41
+ # 3.1 DIMENSION-SEGMENT-WISE EMBEDDING
42
+
43
+ To motivate our approach, we first analyze the embedding methods of the previous Transformer-based models for MTS forecasting (Zhou et al., 2021; Wu et al., 2021a; Liu et al., 2021a; Zhou et al., 2022). As shown in Fig. 1 (b), existing methods embed data points at the same time step into a vector: $\mathbf { x } _ { t } \mathbf { h } _ { t } , \mathbf { x } _ { t } \in \bar { \mathbb { R } } ^ { D } , \mathbf { h } _ { t } \in \mathbb { R } ^ { d _ { m o d e l } }$ , where $\mathbf { x } _ { t }$ represents all the data points in $D$ dimensions at step $t$ . In this way, the input $\mathbf { x } _ { 1 : T }$ is embedded into $T$ vectors $\{ \mathbf { h } _ { 1 } , \mathbf { h } _ { 2 } , \dots , \mathbf { h } _ { T } \}$ . Then the dependency among the $T$ vectors is captured for forecasting. Therefore, previous Transformer-based models mainly capture cross-time dependency, while the cross-dimension dependency is not explicitly captured during embedding, which limits their forecasting capability.
44
+
45
+ Transformer was originally developed for NLP (Vaswani et al., 2017), where each embedded vector represents an informative word. For MTS, a single value at a step alone provides little information.
46
+
47
+ While it forms informative pattern with nearby values in time domain. Fig. 1 (a) shows a typical attention score map of original Transformer for MTS forecasting. We can see that attention values have a tendency to segment, i.e. close data points have similar attention weights.
48
+
49
+ Based on the above two points, we argue that an embedded vector should represent a series segment of single dimension (Fig. 1 (c)), rather than the values of all dimensions at single step (Fig. 1 (b)). To this end, we propose Dimension-Segment-Wise (DSW) embedding where the points in each dimension are divided into segments of length $L _ { s e g }$ and then embedded:
50
+
51
+ $$
52
+ \begin{array} { r l } & { \mathbf { x } _ { 1 : T } = \left\{ \mathbf { x } _ { i , d } ^ { ( s ) } \vert 1 \leq i \leq \frac { T } { L _ { s e g } } , 1 \leq d \leq D \right\} } \\ & { \mathbf { x } _ { i , d } ^ { ( s ) } = \left\{ x _ { t , d } \vert ( i - 1 ) \times L _ { s e g } < t \leq i \times L _ { s e g } \right\} } \end{array}
53
+ $$
54
+
55
+ where x(s)i,d $\mathbf { x } _ { i , d } ^ { ( s ) } \in \mathbb { R } ^ { L _ { s e g } }$ is the $i$ -th segment in dimension $d$ with length $L _ { s e g }$ . For convenience, we assume that $T , \tau$ are divisible by $L _ { s e g }$ . Then each segment is embedded into a vector using linear projection added with a position embedding:
56
+
57
+ $$
58
+ \mathbf { h } _ { i , d } = \mathbf { E x } _ { i , d } ^ { ( s ) } + \mathbf { E } _ { i , d } ^ { ( p o s ) }
59
+ $$
60
+
61
+ where $\mathbf { E } \in \mathbb { R } ^ { d _ { m o d e l } \times L _ { s e g } }$ denotes the learnable projection matrix, and ${ \bf E } _ { i , d } ^ { ( p o s ) } \in \mathbb { R } ^ { d _ { m o d e l } }$ denotes the learnable position embedding for position $( i , d )$ . After embedding, we obtain a 2D vector array $\begin{array} { r } { \mathbf { H } = \left\{ \mathbf { h } _ { i , d } | 1 \leq i \leq \frac { T } { L _ { s e g } } , 1 \leq d \leq D \right\} } \end{array}$ , where each $\mathbf { h } _ { i , d }$ represents a univariate time series segment. The idea of segmentation is also used in Du et al. (2022), which splits the embedded 1D vector sequence into segments to compute the Segment-Correlation in order to enhance locality and reduce computation complexity. However, like other Transformers for MTS forecasting, it does not explicitly capture cross-dimension dependency.
62
+
63
+ # 3.2 TWO-STAGE ATTENTION LAYER
64
+
65
+ For the obtained 2D array $\mathbf { H }$ , one can flatten it into a 1D sequence so that it can be input to a canonical Transformer like ViT (Dosovitskiy et al., 2021) does in vision. While we have specific considerations: 1) Different from images where the axes of height and width are interchangeable, the axes of time and dimension for MTS have different meanings and thus should be treated differently. 2) Directly applying self-attention on 2D array will cause the complexity of O(D2 T 2L2 ) , which is unaffordable for large $D$ . Therefore, we propose the Two-Stage Attention (TSA) Layer to capture cross-time and cross-dimension dependency among the 2D vector array, as sketched in Fig. 2 (a).
66
+
67
+ Cross-Time Stage Given a 2D array $\mathbf { Z } \in \mathbb { R } ^ { L \times D \times d _ { m o d e l } }$ as the input of the TSA Layer, where $L$ and $D$ are the number of segments and dimensions, respectively. $\mathbf { Z }$ here can be the output of DSW embedding or lower TSA layers. For convenience, in the following, we use $\mathbf { Z } _ { i , }$ : to denote the vectors of all dimensions at time step $i$ , $\mathbf { Z } _ { : , d }$ for those of all time steps in dimension $d$ . In the cross-time stage, we directly apply multi-head self-attention (MSA) to each dimension:
68
+
69
+ $$
70
+ \begin{array} { r l } & { \hat { \mathbf { Z } } _ { : , d } ^ { t i m e } = \mathrm { L a y e r N o r m } \Big ( \mathbf { Z } _ { : , d } + \mathrm { M S } \mathbb { A } ^ { t i m e } ( \mathbf { Z } _ { : , d } , \mathbf { Z } _ { : , d } , \mathbf { Z } _ { : , d } ) \Big ) } \\ & { \mathbf { Z } ^ { t i m e } = \mathrm { L a y e r N o r m } \left( \hat { \mathbf { Z } } ^ { t i m e } + \mathrm { M L P } ( \hat { \mathbf { Z } } ^ { t i m e } ) \right) } \end{array}
71
+ $$
72
+
73
+ where $1 \leq d \leq D$ and LayerNorm denotes layer normalization as widely adopted in Vaswani et al. (2017); Dosovitskiy et al. (2021); Zhou et al. (2021), MLP denotes a multi-layer (two in this paper) feedforward network, $\mathtt { M S A } ( \mathbf { Q } , \mathbf { K } , \mathbf { V } )$ denotes the multi-head self-attention (Vaswani et al., 2017) layer where $\mathbf { Q } , \mathbf { K } , \mathbf { V }$ serve as queries, keys and values. All dimensions $1 \leq d \leq D _ { \cdot }$ share the same MSA layer. $\hat { \mathbf { Z } } ^ { t i m e } , \mathbf { Z } ^ { t i m e }$ denotes the output of the MSA and MLP.
74
+
75
+ The computation complexity of cross-time stage is $O ( D L ^ { 2 } )$ . After this stage, the dependency among time segments in the same dimension is captured in ${ \bf Z } ^ { t i m e }$ . Then ${ \bf Z } ^ { t i \bar { m } e }$ becomes the input of Cross-Dimension Stage to capture cross-dimension dependency.
76
+
77
+ ![](images/189c8be9df5923b18b60424b48ac199e9ced3d1f325af4ddb7f49da8ea8efbfe.jpg)
78
+ Figure 2: The TSA layer. (a) Two-Stage Attention Layer to process a 2D vector array representing multivariate time series: each vector refers to a segment of the original series. The whole vector array goes through the Cross-Time Stage and Cross-Dimension Stage to get corresponding dependency. (b) Directly using MSA in Cross-Dimension Stage to build the $D$ -to- $D$ connection results in $O ( D ^ { 2 } )$ complexity. (c) Router mechanism for Cross-Dimension Stage: a small fixed number (c) of “routers” gather information from all dimensions and then distribute the gathered information. The complexity is reduced to $O ( 2 c D ) = O ( D )$ .
79
+
80
+ Cross-Dimension Stage We can use a large $L _ { s e g }$ for long sequence in DSW Embedding to reduce the number of segments $L$ in cross-time stage. While in Cross-Dimension Stage, we can not partition dimensions and directly apply MSA will cause the complexity of $O ( D ^ { 2 } )$ (as shown in Fig. 2 (b)), which is unaffordable for datasets with large $D$ . Instead, we propose the router mechanism for potentially large $D$ . As shown in Fig. 2 (c), we set a small fixed number $c < < D$ ) of learnable vectors for each time step $i$ as routers. These routers first aggregate messages from all dimensions by using routers as query in MSA and vectors of all dimensions as key and value. Then routers distribute the received messages among dimensions by using vectors of dimensions as query and aggregated messages as key and value. In this way, the all-to-all connection among $D$ dimensions are built:
81
+
82
+ $$
83
+ \begin{array} { r l } & { \quad \mathbf { B } _ { i , : } = \mathbb { M } \mathbb { S } \mathbb { A } _ { 1 } ^ { d i m } ( \mathbf { R } _ { i , : } , \mathbf { Z } _ { i , : } ^ { t i m e } , \mathbf { Z } _ { i , : } ^ { t i m e } ) , 1 \leq i \leq L } \\ & { \quad \overline { { \mathbf { Z } } } _ { i , : } ^ { d i m } = \mathbb { M } \mathbb { S } \mathbb { A } _ { 2 } ^ { d i m } ( \mathbf { Z } _ { i , : } ^ { t i m e } , \mathbf { B } _ { i , : } , \mathbf { B } _ { i , : } ) , 1 \leq i \leq L } \\ & { \quad \hat { \mathbf { Z } } ^ { d i m } = \mathbb { L } \mathbb { a } \mathbb { Y } \mathrm { e r N o r m } \left( \mathbf { Z } ^ { t i m e } + \overline { { \mathbf { Z } } } ^ { d i m } \right) } \\ & { \quad \mathbf { Z } ^ { d i m } = \mathbb { L } \mathbb { a } \mathbb { Y } \mathrm { e r N o r m } \left( \hat { \mathbf { Z } } ^ { d i m } + \mathbb { M } \mathbf { L } \mathbf { P } ( \hat { \mathbf { Z } } ^ { d i m } ) \right) } \end{array}
84
+ $$
85
+
86
+ where $\mathbf { R } \in \mathbb { R } ^ { L \times c \times d _ { m o d e l } }$ $\dot { } c$ is a constant) is the learnable vector array serving as routers. B ∈ RL×c×dmodel is the aggregated messages from all dimensions. Zdim denotes output of the router mechanism. All time steps $( 1 ~ \leq ~ i ~ \leq ~ L )$ share the same $\mathbf { M S A } _ { 1 } ^ { d i m }$ , $\mathbf { M S A } _ { 2 } ^ { d i m }$ . $\hat { \mathbf { Z } } ^ { d i m } , \mathbf { Z } ^ { d i m }$ denote output of skip connection and MLP respectively. The router mechanism reduce the complexity from $O ( D ^ { 2 } L )$ to $O ( D L )$ .
87
+
88
+ Adding up Eq. 3 and Eq. 4, we model the two stages as:
89
+
90
+ $$
91
+ \mathbf { Y } = \mathbf { Z } ^ { d i m } = \mathrm { T S A } ( \mathbf { Z } )
92
+ $$
93
+
94
+ ![](images/c5d80c2619c68f099818b7e2189b44e63ea3d8b90bac0ec5cafd752f6cb747fb.jpg)
95
+ Figure 3: Architecture of the Hierarchical Encoder-Decoder in Crossformer with 3 encoder layers. The length of each vector denotes the covered time range. The encoder (left) uses TSA layer and segment merging to capture dependency at different scales: a vector in upper layer covers a longer range, resulting in dependency at a coarser scale. Exploring different scales, the decoder (right) makes the final prediction by forecasting at each scale and adding them up.
96
+
97
+ where Z, $\mathbf { Y } \in \mathbb { R } ^ { L \times D \times d _ { m o d e l } }$ denotes the input and output vector array of TSA layer, respectively. Note that the overall computation complexity of the
98
+
99
+ TSA layer is $O ( D L ^ { 2 } + D L ) = O ( D L ^ { 2 } )$ . After the Cross-Time and Cross-Dimension Stages, every two segments (i.e. ${ \bf Z } _ { i _ { 1 } , d _ { 1 } } , { \bf Z } _ { i _ { 2 } , d _ { 2 } } )$ in $\mathbf { Z }$ are connected, as such both cross-time and cross-dimension dependencies are captured in $\mathbf { Y }$ .
100
+
101
+ # 3.3 HIERARCHICAL ENCODER-DECODER
102
+
103
+ Hierarchical structures are widely used in Transformers for MTS forecasting to capture information at different scales (Zhou et al., 2021; Liu et al., 2021a). In this section, we use the proposed DSW embedding, TSA layer and segment merging to construct a Hierarchical Encoder-Decoder (HED). As shown in Fig. 3, the upper layer utilizes information at a coarser scale for forecasting. Forecasting values at different scales are added to output the final result.
104
+
105
+ Encoder In each layer of the encoder (except the first layer), every two adjacent vectors in time domain are merged to obtain the representation at a coarser level. Then a TSA layer is applied to capture dependency at this scale. This process is modeled as ${ \bf Z } ^ { e n c , l } = \mathrm { E n c o d e r } ( { \bf Z } ^ { e \bar { n } c , l - 1 } )$ :
106
+
107
+ $$
108
+ \left\{ \begin{array} { l l } { l = 1 : } & { \hat { \mathbf { Z } } ^ { e n c , l } = \mathbf { H } } \\ { l > 1 : } & { \hat { \mathbf { Z } } _ { i , d } ^ { e n c , l } = \mathbf { M } [ \mathbf { Z } _ { 2 i - 1 , d } ^ { e n c , l - 1 } \cdot \mathbf { Z } _ { 2 i , d } ^ { e n c , l - 1 } ] , 1 \le i \le \frac { L _ { l - 1 } } { 2 } , 1 \le d \le D } \\ { } & { \mathbf { Z } ^ { e n c , l } = \mathrm { T S A } ( \hat { \mathbf { Z } } ^ { e n c , l } ) } \end{array} \right.
109
+ $$
110
+
111
+ where $\mathbf { H }$ denotes the 2D array obtained by DSW embedding; ${ \bf Z } ^ { e n c , l }$ denotes the output of the $l$ -th encoder layer; $\textbf { M } \in \ \mathbb { R } ^ { d _ { m o d e l } \times 2 d _ { m o d e l } }$ denotes a learnable matrix for segment merging; $[ \cdot ]$ denotes the concatenation operation; $L _ { l - 1 }$ denotes the number of segments in each dimension in layer $l - 1$ , if it is not divisible by 2, we pad ${ \bf Z } ^ { e n c , l - 1 }$ to the proper length; $\hat { \mathbf { Z } } ^ { e n c , l }$ denotes the array after segment merging in the $i$ -th layer. Suppose there are $N$ layers in the encoder, we use ${ \bf { Z } } ^ { e n c , 0 } , { \bf { Z } } ^ { e n c , \tilde { 1 } } , \ldots , { \bf { Z } } ^ { e n c , N } , \left( { \bf { Z } } ^ { e n c , 0 } = \bf { H } \right)$ to represent the $N + 1$ outputs of the encoder. The complexity of each encoder layer is $\begin{array} { r } { O ( D \frac { T ^ { 2 } } { L _ { s e g } ^ { 2 } } ) } \end{array}$
112
+
113
+ Decoder Obtaining the $N + 1$ feature arrays output by the encoder, we use $N + 1$ layers (indexed by $0 , 1 , \ldots , N )$ in decoder for forecasting. Layer $l$ takes the $l$ -th encoded array as input, then outputs a decoded 2D array of layer $l$ . This process is summarized as ${ \bf Z } ^ { d e c , l } = \mathrm { D e c o } \dot { { \bf d e r } } ( { \bf Z } ^ { d e c , l - 1 } , { \bf Z } ^ { e n c , \dot { l } } )$ :
114
+
115
+ $$
116
+ \begin{array} { r l } & { \left\{ \begin{array} { l l } { l = 0 : } & { \tilde { \mathbf { Z } } ^ { d e c , l } } \\ { l > 0 : } & { \tilde { \mathbf { Z } } ^ { d e c , l } } \end{array} \right. = \mathrm { T S } \mathbb { A } ( \mathbf { E } ^ { ( d e c ) } ) } \\ & { \left. \begin{array} { l l } { \overline { { \mathbf { Z } } } _ { : , d } ^ { d e c , l } = \mathbb { M } \mathbb { S } \mathbb { A } \left( \mathbf { \tilde { Z } } _ { : , d } ^ { d e c , l } \right) } \\ { \overline { { \mathbf { Z } } } _ { : , d } ^ { d e c , l } = \mathbb { M } \mathbb { S } \mathbb { A } \left( \mathbf { \tilde { Z } } _ { : , d } ^ { d e c , l } , \mathbf { Z } _ { : , d } ^ { e n c , l } , \mathbf { Z } _ { : , d } ^ { e n c , l } \right) , 1 \leq d \leq D } \end{array} \right. } \\ & { \left. \begin{array} { r l } { \tilde { \mathbf { Z } } ^ { d e c , l } = \mathrm { L a y e r N o r n } \left( \tilde { \mathbf { Z } } ^ { d e c , l } + \mathbf { \overline { { Z } } } ^ { d e c , l } \right) } \\ { \mathbf { Z } ^ { d e c , l } = \mathrm { L a y e r N o r n } \left( \hat { \mathbf { Z } } ^ { d e c , l } + \mathbb { M L P } ( \hat { \mathbf { Z } } ^ { d e c , l } ) \right) } \end{array} \right. } \end{array}
117
+ $$
118
+
119
+ where $\mathbf { E } ^ { ( d e c ) } \in \mathbb { R } ^ { \frac { \tau } { L _ { s e g } } \times D \times d _ { m o d e l } }$ denotes the learnable position embedding for decoder. $\tilde { \mathbf { Z } } ^ { d e c , l }$ is the output of TSA. The MSA layer takes $\tilde { \mathbf { Z } } _ { : , d } ^ { d e c , l }$ as query and ${ \bf Z } _ { : , d } ^ { e n c , l }$ as the key and value to build the connection between encoder and decoder. The output of MSA is denoted as $\overline { { \mathbf { Z } } } _ { : , d } ^ { d e c , l }$ . $\hat { \mathbf { Z } } ^ { d e c , l } , \mathbf { Z } ^ { d e c , l }$ denote the output of skip connection and MLP respectively. We use ${ \mathbf { Z } } ^ { d e c , 0 }$ , ${ \bf Z } ^ { e n c , 1 } , \ldots , { \bf Z } ^ { d e c , N }$ to represent the decoder output. The complexity of each decoder layer is O D τ(T +τ)L2 
120
+
121
+ Linear projection is applied to each layer’s output to yield the prediction of this layer. Layer predictions are summed to make the final prediction (for $l = 0 , \ldots , N )$ :
122
+
123
+ $$
124
+ \begin{array} { r l } { \mathrm { ~ o r ~ } l = 0 , \dots , N : \mathbf { x } _ { i , d } ^ { ( s ) , l } = \mathbf { W } ^ { l } \mathbf { Z } _ { i , d } ^ { d e c , l } } & { \quad \mathbf { x } _ { T + 1 : T + \tau } ^ { p r e d , l } = \left\{ \mathbf { x } _ { i , d } ^ { ( s ) , l } \vert 1 \leq i \leq \frac { \tau } { L _ { s e g } } , 1 \leq d \leq D \right\} } \\ & { \quad \qquad \quad \mathbf { x } _ { T + 1 : T + \tau } ^ { p r e d } = \displaystyle \sum _ { l = 0 } ^ { N } \mathbf { x } _ { T + 1 : T + \tau } ^ { p r e d , l } } \end{array}
125
+ $$
126
+
127
+ where $\mathbf { W } ^ { l } ~ \in ~ \mathbb { R } ^ { L _ { s e g } \times d _ { m o d e l } }$ is a learnable matrix to project a vector to a time series segment. $\mathbf { x } _ { i , d } ^ { ( s ) , l } \in \mathbb { R } ^ { L _ { s e g } }$ denotes the $i$ -th segment in dimension $d$ of the prediction. All the segments in layer
128
+
129
+ Table 1: MSE/MAE with different prediction lengths. Bold/underline indicates the best/second. Results of LSTMa, LSTnet, Transformer, Informer on the first 4 datasets are from Zhou et al. (2021).
130
+
131
+ <table><tr><td colspan="2">Models</td><td colspan="2">LSTMa</td><td colspan="2">LSTnet</td><td colspan="2">MTGNN</td><td colspan="2">Transformer</td><td colspan="2">Informer</td><td colspan="2">Autoformer</td><td colspan="2">Pyraformer</td><td colspan="2">FEDformer</td><td colspan="2">Crossformer</td></tr><tr><td colspan="2">Metric</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td></tr><tr><td rowspan="2">FTLLI</td><td>24 48 168</td><td>0.650 0.720 1.212</td><td>0.624 0.675 0.867</td><td>1.293 1.456 1.997</td><td>0.901 0.960 1.214</td><td>0.336 0.386 0.466</td><td>0.393 0.429 0.474</td><td>0.620 0.692 0.947</td><td>0.577 0.671 0.797</td><td>0.577 0.685 0.931</td><td>0.549 0.625 0.752</td><td>0.439 0.429 0.493</td><td>0.440 0.442 0.479</td><td>0.493 0.554 0.781</td><td>0.507 0.544 0.675</td><td>0.318 0.342 0.412</td><td>0.384 0.396 0.449</td><td>0.305 0.352</td><td>0.367 0.394 0.441</td></tr><tr><td>336 720 24</td><td>1.424 1.960 0.621</td><td>0.994 1.322 0.629</td><td>2.655 2.143 1.968</td><td>1.369 1.380 1.170</td><td>0.736 0.916 0.260</td><td>0.643 0.750 0.324</td><td>1.094 1.241 0.306</td><td>0.813 0.917 0.371</td><td>1.128 1.215 0.323</td><td>0.873 0.896 0.369</td><td>0.509 0.539 0.410</td><td>0.492 0.537 0.428</td><td>0.912 0.993 0.310</td><td>0.747 0.792 0.371</td><td>0.456 0.521 0.290</td><td>0.474 0.515 0.364</td><td>0.410 0.440 0.519 0.211</td><td>0.461 0.524 0.293</td></tr><tr><td>[LL</td><td>48 96 288 672</td><td>1.392 1.339 1.740 2.736</td><td>0.939 0.913 1.124 1.555</td><td>1.999 2.762 1.257 1.917</td><td>1.215 1.542 2.076 2.941</td><td>0.386 0.428 0.469 0.620</td><td>0.408 0.446 0.488 0.571</td><td>0.465 0.681 1.162 1.231</td><td>0.470 0.612 0.879 1.103</td><td>0.494 0.678 1.056 1.192</td><td>0.503 0.614 0.786 0.926</td><td>0.485 0.502 0.604 0.607</td><td>0.464 0.476 0.522 0.530</td><td>0.465 0.520 0.729 0.980</td><td>0.464 0.504 0.657 0.678</td><td>0.342 0.366 0.398 0.455</td><td>0.396 0.412 0.433 0.464</td><td>0.300 0.320 0.404 0.569</td><td>0.352 0.373 0.427 0.528</td></tr><tr><td>HLM</td><td>24 48 168 336 720</td><td>0.546 0.829 1.038 1.657 1.536</td><td>0.570 0.677 0.835 1.059 1.109</td><td>0.615 0.660 0.748 0.782 0.851</td><td>0.545 0.589 0.647 0.683 0.757</td><td>0.307 0.388 0.498 0.506 0.510</td><td>0.356 0.422 0.512 0.523 0.527</td><td>0.349 0.386 0.613 0.707 0.834</td><td>0.397 0.433 0.582 0.634 0.741</td><td>0.335 0.395 0.608 0.702 0.831</td><td>0.381 0.459 0.567 0.620 0.731 0.587</td><td>0.363 0.456 0.574 0.600</td><td>0.396 0.462 0.548 0.571 0.570</td><td>0.301 0.376 0.519 0.539 0.547</td><td>0.359 0.421 0.521 0.543 0.553</td><td>0.357 0.428 0.564 0.533 0.562</td><td>0.412 0.458 0.541 0.536 0.557</td><td>0.294 0.370 0.473 0.495 0.526</td><td>0.343 0.411 0.494 0.515 0.542</td></tr><tr><td rowspan="6">R</td><td>48 168 336</td><td>0.486 0.572 0.574</td><td>0.602</td><td>0.369 0.394</td><td>0.445 0.476</td><td>0.173 0.236</td><td>0.280 0.320</td><td>0.334 0.353</td><td>0.399 0.420</td><td>0.344 0.393 0.368 0.424</td><td>0.241 0.299</td><td></td><td>0.351 0.387</td><td>0.478 0.452</td><td>0.471 0.455</td><td>0.229 0.263</td><td>0.338 0.361</td><td>0.156 0.231 0.323</td><td>0.255 0.309 0.369</td></tr><tr><td>720</td><td>0.886 0.795 1.095</td><td>0.419 0.556</td><td>0.477 0.565</td><td>0.328 0.422</td><td>0.373 0.410</td><td>0.381 0.391</td><td>0.439 0.438</td><td>0.381 0.406</td><td>0.431 0.443</td><td>0.375 0.377</td><td>0.428 0.434</td><td>0.463 0.480</td><td>0.456 0.461</td><td>0.305 0.372</td><td>0.386 0.434</td><td>0.404</td><td>0.423</td></tr><tr><td></td><td>1.128</td><td>0.605</td><td>0.599</td><td></td><td></td><td></td><td></td><td></td><td></td><td>0.366</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>4.771</td><td>1.335</td><td>4.975</td><td>1.660</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></td><td>4.220</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>3.101</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>24</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><td></td><td></td><td></td><td></td></tr><tr><td></td><td>960</td><td>1.676 1.591</td><td></td><td></td><td></td><td>0.471</td><td>0.451</td><td>0.492</td><td>0.550</td><td>0.460</td><td>0.548</td><td></td><td>0.426</td><td>0.550</td><td>0.489</td><td>0.393</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>0.449</td><td>0.433</td><td>0.438</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>4.265</td><td>1.387</td><td>3.954</td><td>1.323</td><td>4.588</td><td>1.462</td><td></td><td>1.238</td><td>3.970</td><td>1.338</td><td>2.687</td><td>1.147</td><td>3.041</td><td>1.186</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>1.659</td><td>4.777</td><td>1.496</td><td>4.167</td><td>1.360</td><td>4.845</td><td>1.496</td><td></td><td>1.270</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>I</td><td>36</td><td>1.427</td><td></td><td>5.322</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>3.397</td><td></td><td>4.377</td><td>1.410</td><td>2.887</td><td>1.160</td><td>3.406</td><td>1.232</td></tr><tr><td></td><td></td><td></td><td></td><td>5.425</td><td>1.632</td><td>5.333</td><td>1.592</td><td>4.746</td><td>1.463</td><td>4.865</td><td>1.516</td><td>2.947</td><td>1.203</td><td>4.811</td><td>1.503</td><td>2.797</td><td>1.155</td><td>3.459</td><td>1.221</td></tr><tr><td></td><td>48</td><td>4.945 1.462</td><td></td><td></td><td></td><td>5.070</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>2.809</td><td>1.163</td><td>3.640</td><td>1.305</td></tr><tr><td>Yteee</td><td>60</td><td>5.176</td><td>1.504 0.378</td><td>5.477 0.648</td><td>1.675 0.403</td><td>0.506</td><td>1.552 0.278</td><td>5.219 0.597</td><td>1.553 0.332</td><td>5.212 0.608</td><td>1.576 0.334</td><td>3.019 0.550</td><td>1.202 0.363</td><td>5.204 0.606</td><td>1.588 0.338</td></table>
132
+
133
+ $l$ are rearranged to get the layer prediction $\mathbf { x } _ { T + 1 : T + \tau } ^ { p r e d , l }$ . Predictions of all the layers are summed to obtain the final forecasting xpredT +1:T +τ .
134
+
135
+ # 4 EXPERIMENTS
136
+
137
+ # 4.1 PROTOCOLS
138
+
139
+ Datasets We conduct experiments on six real-world datasets following Zhou et al. (2021); Wu et al. (2021a). 1) ETTh1 (Electricity Transformer Temperature-hourly), 2) ETTm1 (Electricity Transformer Temperature-minutely), 3) WTH (Weather), 4) ECL (Electricity Consuming Load), 5) ILI (Influenza-Like Illness), 6) Traffic. The train/val/test splits for the first four datasets are same as Zhou et al. (2021), the last two are split by the ratio of 0.7:0.1:0.2 following Wu et al. (2021a).
140
+
141
+ Baselines We use the following popular models for MTS forecasting as baselines:1) LSTMa (Bahdanau et al., 2015), 2) LSTnet (Lai et al., 2018), 3) MTGNN (Wu et al., 2020), and recent Transformer-based models for MTS forecasting: 4) Transformer (Vaswani et al., 2017), 5) Informer (Zhou et al., 2021), 6) Autoformer (Wu et al., 2021a), 7) Pyraformer (Liu et al., 2021a) and 8) FEDformer (Zhou et al., 2022).
142
+
143
+ Setup We use the same setting as in Zhou et al. (2021): train/val/test sets are zero-mean normalized with the mean and std of training set. On each dataset, we evaluate the performance over the changing future window size $\tau$ . For each $\tau$ , the past window size $T$ is regarded as a hyper-parameter to search which is a common protocol in recent MTS transformer literature (Zhou et al., 2021; Liu et al., 2021a). We roll the whole set with stride $= 1$ to generate different input-output pairs. The Mean Square Error (MSE) and Mean Absolute Error (MAE) are used as evaluation metrics. All experiments are repeated for 5 times and the mean of the metrics reported. Our Crossformer only utilize the past series to forecast the future, while baseline models use additional covariates such as hour-of-the-day. Details about datasets, baselines, implementation, hyper-parameters are shown in Appendix A.
144
+
145
+ # 4.2 MAIN RESULTS
146
+
147
+ As shown in Table 1, Crossformer shows leading performance on most datasets, as well as on different prediction length settings, with the 36 top-1 and 51 top-2 cases out of 58 in total. It is worth noting that, perhaps due to the explicit use of cross-dimension dependency via GNN, MTGNN outperforms many Transformer-based baselines. While MTGNN has been rarely compared in existing transformers for MTS forecasting literatures. FEDformer and Autoformer outperform our model on ILI. We conjecture this is because the size of dataset ILI is small and these two models introduce the prior knowledge of sequence decomposition into the network structure which makes them perform well when the data is limited. Crossformer still outperforms other baselines on this dataset.
148
+
149
+ Table 2: Component ablation of Crossformer: DSW embedding, TSA layer and HED on ETTh1.
150
+
151
+ <table><tr><td>Models</td><td colspan="2">Transformer</td><td colspan="2">DSW</td><td colspan="2">DSW+TSA</td><td colspan="2">DSW+HED</td><td colspan="2">DSW+TSA+HED</td></tr><tr><td>Metric</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td></tr><tr><td>24</td><td>0.620</td><td>0.577</td><td>0.373</td><td>0.418</td><td>0.322</td><td>0.373</td><td>0.406</td><td>0.454</td><td>0.305</td><td>0.367</td></tr><tr><td>48</td><td>0.692</td><td>0.671</td><td>0.456</td><td>0.479</td><td>0.365</td><td>0.403</td><td>0.493</td><td>0.512</td><td>0.352</td><td>0.394</td></tr><tr><td>168</td><td>0.947</td><td>0.797</td><td>0.947</td><td>0.731</td><td>0.473</td><td>0.479</td><td>0.614</td><td>0.583</td><td>0.410</td><td>0.441</td></tr><tr><td>336</td><td>1.094</td><td>0.813</td><td>0.969</td><td>0.752</td><td>0.553</td><td>0.534</td><td>0.788</td><td>0.676</td><td>0.440</td><td>0.461</td></tr><tr><td>720</td><td>1.241</td><td>0.971</td><td>1.086</td><td>0.814</td><td>0.636</td><td>0.599</td><td>0.841</td><td>0.717</td><td>0.519</td><td>0.524</td></tr></table>
152
+
153
+ ![](images/a6cb92446b54acd5345629019f18eecb486532ff4a89ef6b420ad7722a99d282.jpg)
154
+ Figure 4: Evaluation on hyper-parameter impact and computational efficiency. (a) MSE against hyperparameter segment length $L _ { s e g }$ in DSW embedding on ETTh1. (b) MSE against hyper-parameter number of routers $c$ in the Cross-Dimension Stage of TSA layer on ETTh1. (c) Memory occupation against the input length $T$ on ETTh1. (d) Memory occupation against number of dimensions $D$ on synthetic datasets with different number of dimensions.
155
+
156
+ # 4.3 ABLATION STUDY
157
+
158
+ In our approach, there are three components: DSW embedding, TSA layer and HED. We perform ablation study on the ETTh1 dataset in line with Zhou et al. (2021); Liu et al. (2021a). We use Transformer as the baseline and $\mathbf { D S W + T S A + H E D }$ to denote Crossformer without ablation. Three ablation versions are compared: 1) DSW 2) DSW $+ ^ { \prime }$ TSA 3) $\mathbf { D S W + H E D }$ .
159
+
160
+ We analyze the results shown in Table 2. 1) DSW performs better than Transformer on most settings. The only difference between DSW and Transformer is the embedding method, which indicates the usefulness of DSW embedding and the importance of cross-dimension dependency. 2) TSA constantly improves the forecasting accuracy. This suggests that it is reasonable to treat time and dimension differently. Moreover, TSA makes it possible to use Crossformer on datasets where the number of dimensions is large (e.g. $D = 8 6 2$ for dataset Traffic). 3) Comparing $\mathrm { D S W + H E D }$ with DSW, HED decreases the forecasting accuracy when prediction length is short but increases it for long term prediction. The possible reason is that information at different scales is helpful to long term prediction. 4) Combining DSW, TSA and HED, our Crossformer yields best results on all settings.
161
+
162
+ # 4.4 EFFECT OF HYPER-PARAMETERS
163
+
164
+ We evaluate the effect of two hyper-parameters: segment length $L _ { s e g }$ in Eq. 1) and number of routers in TSA $\dot { c }$ in Cross-Dimension Stage of TSA) on the ETTh1 dataset. Segment Length: In Fig. 4(a), we prolong the segment length from 4 to 24 and evaluate MSE with different prediction windows. For short-term forecasting $( \tau = 2 4 , 4 8 )$ ), smaller segment yields relevantly better results, but the prediction accuracy is stable. For long-term forecasting $\tau \geq 1 6 8 )$ , prolonging the segment length from 4 to 24 causes the MSE to decrease. This indicates that long segments should be used for long-term forecasting. We further prolong the segment length to 48 for $\tau = 3 3 6$ , 720, the MSE is slightly larger than that of 24. The possible reason is that 24 hours exactly matches the daily period of this dataset, while 48 is too coarse to capture fine-grained information. Number of Routers in TSA Layer: Number of Routers $c$ controls the information bandwidth among all dimensions. As Fig. 4(b) shows, the performance of Crossformer is stable w.r.t to $c$ for $\tau \leq 3 3 6$ . For $\tau = 7 2 0$ , the MSE is large when $c = 3$ but decreases and stabilizes when $c \geq 5$ . In pratice, we set $c = 1 0$ to balance the prediction accuracy and computation efficiency.
165
+
166
+ # 4.5 COMPUTATIONAL EFFICIENCY ANALYSIS
167
+
168
+ The theoretical complexity per layer of Transformer-based models is compared in Table 3. The complexity of Crossformer encoder is quadratic w.r.t $T$ . However, for long-term prediction where large $L _ { s e q }$ is used, the coefficient $\frac { 1 } { L _ { s e q } ^ { 2 } }$ term can significantly reduce its practical complexity. We evaluate the memory occupation of these models on ETTh1.4 We set the prediction window $\tau = 3 3 6$ and prolong input length $T$ . For Crossformer, $L _ { s e g }$ is set to 24, which is the best value for $\tau \geq 1 6 8$
169
+
170
+ Table 3: Computation complexity per layer of Transformer-based models. $T$ denotes the length of past series, $\tau$ denotes the length of prediction window, $D$ denotes the number of dimensions, $L _ { s e g }$ denotes the segment length of DSW embedding in Crossformer.
171
+
172
+ <table><tr><td>Method</td><td>Encoder layer</td><td>Decoder layer</td></tr><tr><td>Transformer (Vaswani et al., 2017)</td><td>O(T2)</td><td>O(T(T+T))</td></tr><tr><td>Informer (Zhou et al., 2021)</td><td>O(TlogT)</td><td>O(t(T+logT))</td></tr><tr><td>Autoformer (Wu et al.,2021a)</td><td>O(TlogT)</td><td>0((+T)log(+T))</td></tr><tr><td>Pyraformer (Liu et al.,2021a)</td><td>O(T)</td><td>O(T(T+T))</td></tr><tr><td>FEDformer (Zhou et al.,2022)</td><td>O(T)</td><td>0(+)</td></tr><tr><td>Crossformer (Ours)</td><td>(T2) 0</td><td>((+T)) 0</td></tr></table>
173
+
174
+ (see Fig. 4 (a)). The result in Fig. 4 (c) shows that Crossformer achieves the best efficiency among the five methods within the tested length range. Theoretically, Informer, Autoformer and FEDformer are more efficient when $T$ approaches infinity. In practice, Crossformer performs better when $T$ is not extremely large (e.g. $T \leq 1 0 ^ { 4 }$ ).
175
+
176
+ We also evaluate the memory occupation w.r.t the number of dimensions $D$ . For baseline models where cross-dimension dependency is not modeled explicitly, $D$ has little effect. Therefore, we compare Crossformer with its ablation versions in Section 4.3. We also evaluate the TSA layers that directly use MSA in Cross-Dimension Stage without the Router mechanism, denoted as TSA(w/o Router). Fig. 4 (d) shows that Crossformer without TSA layer (DSW and $\mathrm { D S W + H E D } )$ has quadratic complexity w.r.t $D$ . TSA(w/o Router) helps to reduce complexity and the Router mechanism further makes the complexity linear, so that Crossformer can process data with $D = 3 0 0$ . Moreover, HED can slightly reduce the memory cost and we analyze this is because there are less vectors in upper layers after segment merging (see Fig. 3). Besides memory occupation, the actual running time evaluation is shown in Appendix B.6.
177
+
178
+ # 5 CONCLUSIONS AND FUTURE WORK
179
+
180
+ We have proposed Crossformer, a Transformer-based model utilizing cross-dimension dependency for multivariate time-series (MTS) forecasting. Specifically, the Dimension-Segment-Wise (DSW) embedding embeds the input data into a 2D vector array to preserve the information of both time and dimension. The Two-Stage-Attention (TSA) layer is devised to capture the cross-time and crossdimension dependency of the embedded array. Using DSW embedding and TSA layer, a Hierarchical Encoder-Decoder (HED) is devised to utilize the information at different scales. Experimental results on six real-world datasets show its effectiveness over previous state-of-the-arts.
181
+
182
+ We analyzed the limitations of our work and briefly discuss some directions for future research: 1) In Cross-Dimension Stage, we build a simple full connection among dimensions, which may introduce noise on high-dimensional datasets. Recent sparse and efficient Graph Transformers (Wu et al., 2022) can benefit our TSA layer on this problem. 2) A concurrent work (Zeng et al., 2023) which was accepted after the submission of this work received our attention. It questions the effectiveness of Transformers for MTS forecasting and proposes DLinear that outperforms all Transformers including our Crossformer on three of the six datasets (details are in Appendix B.2). It argues the main reason is that MSA in Transformer is permutation-invariant. Therefore, enhancing the ordering preserving capability of Transformers is a promising direction to overcome this shortcoming . 3) Considering datasets used in MTS analysis are much smaller and simpler than those used in vision and texts, besides new models, large datasets with various patterns are also needed for future research.
183
+
184
+ # REFERENCES
185
+
186
+ Rafal A. Angryk, Petrus C. Martens, Berkay Aydin, Dustin J. Kempton, Sushant S. Mahajan, Sunitha Basodi, Azim Ahmadzadeh, Xumin Cai, Soukaina Filali Boubrahimi, Shah Muhammad Hamdi, Michael A. Schuh, and Manolis K. Georgoulis. Multivariate time series dataset for space weather data analytics. Scientific Data, 2020.
187
+
188
+ Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In International Conference on Learning Representations (ICLR), 2015.
189
+
190
+ Defu Cao, Yujing Wang, Juanyong Duan, Ce Zhang, Xia Zhu, Congrui Huang, Yunhai Tong, Bixiong Xu, Jing Bai, Jie Tong, and Qi Zhang. Spectral temporal graph neural network for multivariate time-series forecasting. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
191
+
192
+ Chun-Fu Chen, Quanfu Fan, and Rameswar Panda. Crossvit: Cross-attention multi-scale vision transformer for image classification. In IEEE/CVF International Conference on Computer Vision (ICCV), 2021.
193
+
194
+ Weiqi Chen, Wenwei Wang, Bingqing Peng, Qingsong Wen, Tian Zhou, and Liang Sun. Learning to rotate: Quaternion transformer for complicated periodical time series forecasting. In ACM SIGKDD International Conference on Knowledge Discovery & Data Mining (KDD), 2022.
195
+
196
+ Omer Fahrettin Demirel, Selim Zaim, Ahmet Caliskan, and Pinar Ozuyar. Forecasting natural gas consumption in ˙Istanbul using neural networks and multivariate time series methods. Turkish Journal of Electrical Engineering and Computer Sciences, 2012.
197
+
198
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Annual Conference of the North American Chapter of the Association for Computational Linguistics (NAACL-HLT), 2019.
199
+
200
+ Linhao Dong, Shuang Xu, and Bo Xu. Speech-transformer: A no-recurrence sequence-to-sequence model for speech recognition. In IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2018.
201
+
202
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021.
203
+
204
+ Dazhao Du, Bing Su, and Zhewei Wei. Preformer: Predictive transformer with multi-scale segmentwise correlations for long-term time series forecasting. arXiv preprint arXiv:2202.11356v1, 2022.
205
+
206
+ Philipp Dufter, Martin Schmitt, and Hinrich Schutze. Position information in transformers: An ¨ overview. Computational Linguistics, 2022.
207
+
208
+ Valentin Flunkert, David Salinas, and Jan Gasthaus. Deepar: Probabilistic forecasting with autoregressive recurrent networks. International Journal of Forecasting, 2017.
209
+
210
+ Jake Grigsby, Zhe Wang, and Yanjun Qi. Long-range transformers for dynamic spatiotemporal forecasting. arXiv preprint arXiv:2109.12218v2, 2022.
211
+
212
+ Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
213
+
214
+ Kai Han, Yunhe Wang, Hanting Chen, Xinghao Chen, Jianyuan Guo, Zhenhua Liu, Yehui Tang, An Xiao, Chunjing Xu, Yixing Xu, et al. A survey on vision transformer. IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI), 2022.
215
+
216
+ Guolin Ke, Di He, and Tie-Yan Liu. Rethinking positional encoding in language pre-training. In International Conference on Learning Representations (ICLR), 2021.
217
+
218
+ Lutz Kilian and Helmut LAtkepohl. ˜ Structural Vector Autoregressive Analysis. Cambridge University Press, 2017.
219
+
220
+ Guokun Lai, Wei-Cheng Chang, Yiming Yang, and Hanxiao Liu. Modeling long- and short-term temporal patterns with deep neural networks. In International ACM SIGIR Conference on Research & Development in Information Retrieval (SIGIR), 2018.
221
+
222
+ Colin S. Lea, Michael D. Flynn, Rene Vidal, Austin Reiter, and Gregory Hager. Temporal convolu-´ tional networks for action segmentation and detection. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
223
+
224
+ Longyuan Li, Junchi Yan, Xiaokang Yang, and Yaohui Jin. Learning interpretable deep state space model for probabilistic time series forecasting. In International Joint Conference on Artificial Intelligence (IJCAI), 2019a.
225
+
226
+ Longyuan Li, Jihai Zhang, Junchi Yan, Yaohui Jin, Yunhao Zhang, Yanjie Duan, and Guangjian Tian. Synergetic learning of heterogeneous temporal sequences for multi-horizon probabilistic forecasting. In AAAI Conference on Artificial Intelligence (AAAI), 2021.
227
+
228
+ Shiyang Li, Xiaoyong Jin, Yao Xuan, Xiyou Zhou, Wenhu Chen, Yu-Xiang Wang, and Xifeng Yan. Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting. In Advances in Neural Information Processing Systems (NeurIPS), 2019b.
229
+
230
+ Yaguang Li, Rose Yu, Cyrus Shahabi, and Yan Liu. Diffusion convolutional recurrent neural network: Data-driven traffic forecasting. In International Conference on Learning Representations (ICLR), 2018.
231
+
232
+ Shizhan Liu, Hang Yu, Cong Liao, Jianguo Li, Weiyao Lin, Alex X Liu, and Schahram Dustdar. Pyraformer: Low-complexity pyramidal attention for long-range time series modeling and forecasting. In International Conference on Learning Representations (ICLR), 2021a.
233
+
234
+ Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In IEEE/CVF International Conference on Computer Vision (ICCV), 2021b.
235
+
236
+ Andrew Patton. Copula methods for forecasting multivariate time series. Handbook of economic forecasting, 2013.
237
+
238
+ Yao Qin, Dongjin Song, Haifeng Chen, Wei Cheng, Guofei Jiang, and G. Cottrell. A dual-stage attention-based recurrent neural network for time series prediction. In International Joint Conference on Artificial Intelligence (IJCAI), 2017.
239
+
240
+ Syama Sundar Rangapuram, Matthias W. Seeger, Jan Gasthaus, Lorenzo Stella, Bernie Wang, and Tim Januschowski. Deep state space models for time series forecasting. In Advances in Neural Information Processing Systems (NeurIPS), 2018.
241
+
242
+ Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve´ Jegou. Training data-efficient image transformers & distillation through attention. In ´ International Conference on Machine Learning (ICML), 2021.
243
+
244
+ Ashish Vaswani, Noam M. 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 (NeurIPS), 2017.
245
+
246
+ Haixu Wu, Jiehui Xu, Jianmin Wang, and Mingsheng Long. Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting. In Advances in Neural Information Processing Systems (NeurIPS), 2021a.
247
+
248
+ Kan Wu, Houwen Peng, Minghao Chen, Jianlong Fu, and Hongyang Chao. Rethinking and improving relative position encoding for vision transformer. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2021b.
249
+
250
+ Qitian Wu, Wentao Zhao, Zenan Li, David Wipf, and Junchi Yan. Nodeformer: A scalable graph structure learning transformer for node classification. In Advances in Neural Information Processing Systems (NeurIPS), 2022.
251
+
252
+ Zonghan Wu, Shirui Pan, Guodong Long, Jing Jiang, Xiaojun Chang, and Chengqi Zhang. Connecting the dots: Multivariate time series forecasting with graph neural networks. In ACM SIGKDD International Conference on Knowledge Discovery & Data Mining (KDD), 2020.
253
+
254
+ Ting Yu, Haoteng Yin, and Zhanxing Zhu. Spatio-temporal graph convolutional networks: A deep learning framework for traffic forecasting. In International Joint Conference on Artificial Intelligence (IJCAI), 2018.
255
+
256
+ Chulhee Yun, Srinadh Bhojanapalli, Ankit Singh Rawat, Sashank Reddi, and Sanjiv Kumar. Are transformers universal approximators of sequence-to-sequence functions? In International Conference on Learning Representations (ICLR), 2020.
257
+
258
+ Ailing Zeng, Muxi Chen, Lei Zhang, and Qiang Xu. Are transformers effective for time series forecasting? In AAAI Conference on Artificial Intelligence (AAAI), 2023.
259
+
260
+ Haoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang, Jianxin Li, Hui Xiong, and Wan Zhang. Informer: Beyond efficient transformer for long sequence time-series forecasting. In AAAI Conference on Artificial Intelligence (AAAI), 2021.
261
+
262
+ Tian Zhou, Ziqing Ma, Qingsong Wen, Xue Wang, Liang Sun, and Rong Jin. Fedformer: Frequency enhanced decomposed transformer for long-term series forecasting. In International Conference on Machine Learning (ICML), 2022.
263
+
264
+ # A DETAILS OF EXPERIMENTS
265
+
266
+ # A.1 BENCHMARKING DATASETS
267
+
268
+ We conduct experiments on the following six real-world datasets following Zhou et al. (2021); Wu et al. (2021a):
269
+
270
+ 1) ETTh1 (Electricity Transformer Temperature-hourly) contains 7 indicators of an electricity transformer in two years, including oil temperature, useful load, etc. Data points are recorded every hour and train/val/test is 12/4/4 months.
271
+
272
+ 2) ETTm1 (Electricity Transformer Temperature-minutely) contains the same indicators as ETTh1 but data points are recorded every 15 miniutes. Train/val/test split is same as ETTh1.
273
+
274
+ 3) WTH (Weather) contains 12 meteorological indicators in U.S. in 4 years, including visibility, wind speed, etc. Train/val/test is 28/10/10 months.
275
+
276
+ 4) ECL (Electricity Consuming Load) contains hourly electricity consumption (in Kwh) of 321 clients in two years. Train/val/test is 15/3/4 months.
277
+
278
+ 5) ILI (Influenza-Like Illness) contains 7 weekly recorded indicators of patients data from Centers for Disease Control and Prevention of the United States between between 2002 and 2021. The ratio of train/validation/test splits is 0.7:0.1:0.2.
279
+
280
+ 6) Traffic contains hourly road occupancy rates measured by 862 sensors on San Francisco Bay area freeways in 2 years. The ratio of train/validation/test splits is 0.7:0.1:0.2.
281
+
282
+ The train/val/test splits for ETTh1, ETTm1, WTH, ECL are same as Zhou et al. (2021), for ILI and Traffic are same as Wu et al. (2021a).
283
+
284
+ The first four datasets are publicly available at https://github.com/zhouhaoyi/ Informer2020 and the last two are publicly available at https://github.com/thuml/ Autoformer.
285
+
286
+ # A.2 BASELINE METHODS
287
+
288
+ We briefly describe the selected baselines:
289
+
290
+ 1) LSTMa (Bahdanau et al., 2015) treats the input MTS as a sequence of multi-dimensional vectors. It builds an encoder-decoder using RNN and automatically aligns target future steps with their relevant past.
291
+
292
+ 2) LSTnet (Lai et al., 2018) uses CNN to extract cross-dimension dependency and short term crosstime dependency. The long-term cross-time dependency is captured through RNN. The source code is available at https://github.com/laiguokun/LSTNet.
293
+
294
+ 3) MTGNN (Wu et al., 2020) explicitly utilizes cross-dimension dependency using GNN. A graph learning layer learns a graph structure where each node represents one dimension in MTS. Then graph convolution modules are interleaved with temporal convolution modules to explicitly capture cross-dimension and cross-time dependency respectively. The source code is available at https://github.com/nnzhan/MTGNN.
295
+
296
+ 4) Transformer is closed to the original Transformer (Vaswani et al., 2017) that uses self-attention mechanism to capture cross-time dependency. The Informer-style one-step generative decoder is used for forecasting, therefore this is denoted as Informer† in Informer (Zhou et al., 2021).
297
+
298
+ 5) Informer (Zhou et al., 2021) is a Transformer-based model using the ProbSparse self-attention to capture cross-time dependency for forecasting. The source code of Transformer and Informer is available at https://github.com/zhouhaoyi/Informer2020.
299
+
300
+ 6) Autoformer (Wu et al., 2021a) is a Transformer-based model using decomposition architecture with Auto-Correlation mechanism to capture cross-time dependency for forecasting. The source code is available at https://github.com/thuml/Autoformer.
301
+
302
+ 7) Pyraformer (Liu et al., 2021a) is a Transformer-based model learning multi-resolution representation of the time series by the pyramidal attention module to capture cross-time dependency for forecasting. The source code is available at https://github.com/alipay/Pyraformer.
303
+
304
+ 8) FEDformer (Zhou et al., 2022) is a Transformer-based model that uses the seasonal-trend decomposition with frequency enhanced blocks to capture cross-time dependency for forecasting. The source code is available at https://github.com/MAZiqing/FEDformer.
305
+
306
+ A.3 HYPER-PARAMETER SELECTION AND IMPLEMENTATION DETAILS
307
+
308
+ # A.3.1 MAIN EXPERIMENTS
309
+
310
+ For the main experiments, we use the Crossformer with 3 encoder layers. The number of routers in TSA layer $c$ is set to 10. For dataset ETTh1, ETTm1, WTH and ILI, dimension of hidden state $d _ { m o d e l }$ is set to 256, the head number of multi-head attention is set to 4; For dataset ECL and Traffic, dimension of hidden state $d _ { m o d e l }$ is set to 64, the head number of multi-head attention is set to 2. The segment length $L _ { s e g }$ is chosen from $\{ 6 , 1 2 , 2 4 \}$ via grid search. We use MSE as loss function and batch size is set to 32. Adam optimizer is used for training and the initial learning rate is chosen from $\{ 5 \mathrm { e } \mathrm { - } 3$ , 1e-3, 5e-4, 1e-4, 5e-5, 1e- $\{ 5 \}$ via grid search. The total number of epochs is 20. If the validation loss does not decreases within three epochs, the training process will stop early.
311
+
312
+ For baseline models, if the original papers conduct experiments on the dataset we use, the hyperparameters (except input length $T$ ) recommended in the original papers are used, including the number of layers, dimension of hidden states, etc. Otherwise, the hyper-parameters are chosen through grid search using the validation set.
313
+
314
+ Following Zhou et al. (2021), on datasets ETTh1, WTH, ECL and Traffic, for different prediction length $\tau$ , the input length $T$ is chosen from $\{ 2 4 , 4 8 , 9 6 , 1 6 8 , 3 3 6 , 7 2 0 \}$ ; on ETTm1, the input length is chosen from $\{ 2 4 , 4 8 , 9 6 , 1 9 2 , 2 8 8 , 6 7 2 \}$ ; on ILI, the input length is chosen from $\{ 2 4 , 3 6 , 4 8 , 6 0 \}$ .
315
+
316
+ All models including Crossformer and baselines are implemented in PyTorch and trained on a single NVIDIA Quadro RTX 8000 GPU with 48GB memory.
317
+
318
+ # A.3.2 EFFICIENCY ANALYSIS
319
+
320
+ To evaluate the computational efficiency w.r.t the input length $T$ in Figure 4(c) of the main paper, we align the hyper-parameters of all Transformer-based models as follows: prediction length $\tau$ is set to 336, number of encoder layers is set to 2, dimension of hidden state $d _ { m o d e l }$ is set to 256, the head number of multi-head attention is set to 4.
321
+
322
+ To evaluate the computational efficiency w.r.t the number of dimensions $D$ in Figure 4(d) of the main paper, we align the hyper-parameters of ablation versions of Crossformer as follows as: both input length $T$ and prediction length $\tau$ are set to 336, number of encoder layers is set to 3, $d _ { m o d e l }$ is set to 64, the head number of multi-head attention is set to 2.
323
+
324
+ Experiments in the computational efficiency analysis section are conducted on a single NVIDIA GeForce RTX 2080Ti GPU with 11GB memory.
325
+
326
+ # A.4 DETAILS OF ABLATION VERSIONS OF CROSSFORMER
327
+
328
+ We describe the models we used in ablation study below:
329
+
330
+ 1) DSW represents Crossformer without TSA and HED. The input is embedded by DSW embedding and flatten into a 1D sequence to be input to the original Transformer. The only difference between this model and the Transformer is the embedding method.
331
+
332
+ 2) $\mathbf { D S W + T S A }$ represents Crossformer without HED. Compared with Crossformer, the encoder does not use segment merging to capture dependency at different scales. The decoder takes the final output of encoder (i.e. ${ \bf Z } ^ { e n c , N }$ ) as input instead of using encoder’s output at each scale.
333
+
334
+ 3) $\mathbf { D S W + H E D }$ represents Crossformer without TSA. In each encoder layer and decoder layer, the 2D vector array is flatten into a 1D sequence to be input to the original self-attention layer for dependency capture.
335
+
336
+ # B EXTRA EXPERIMENTAL RESULTS
337
+
338
+ # B.1 SHOWCASES OF MAIN RESULTS
339
+
340
+ Figure 5 shows the forecasting cases of three dimensions of the ETTm1 dataset with prediction length $\tau = 2 8 8$ . For dimension “HUFL”, all the five models capture the periodic pattern, but Crossformer is the closest to the ground truth. For “HULL”, Pyraformer fails to capture the periodic pattern from the noisy data. For “LUFL” where the data has no clear periodic pattern, MTGNN, FEDformer and Crossformer capture its trend and show significantly better results than the other two models.
341
+
342
+ ![](images/20e4632f8d52a9fc09110bbdc1e1167db8ab0cdfd800d60199633eb1a3f524c0.jpg)
343
+ Figure 5: Forecasting cases of three dimensions: High UseFul Load (HUFL), High UseLess Load (HULL) and Low UseFul Load (LUFL) of the ETTm1 dataset with prediction length $\tau = 2 8 8$ . The red / blue curves stand for the ground truth / prediction. Each row represents one model and each column represents one dimension.
344
+
345
+ Figure 6 shows the forecasting cases of three dimensions of the WTH dataset with prediction length $\tau = 3 3 6$ . For dimension “DBT”, all the five models capture the periodic pattern. For “DPT”, Autoformer and FEDformer fails to capture increasing trend of the data. For “WD”, all models capture the periodic pattern from the noisy data, and the cruves output by MTGNN and Crossformer are sharper than the other three models.
346
+
347
+ # B.2 COMPARISON WITH EXTRA METHODS
348
+
349
+ We further compare with two additional concurrent methods which were either not peerreviewed (Grigsby et al., 2022) or were accepted after the submission of this work (Zeng et al., 2023): 1) STformer (Grigsby et al., 2022), a Transformer-based model that directly flattens the multivariate time-series $\mathbf { x } _ { 1 : T } \in \mathbb { R } ^ { T \times D }$ into a 1D sequence to be input to Transformers; 2) DLinear (Zeng et al., 2023), a simple linear model with seasonal-trend decomposition that challenges Transformer-based models for MTS forecasting. Results are shown in Table 4 and LSTMa and LSTnet are omitted as they are not competitive with other models.
350
+
351
+ The basic idea of STformer is similar to our Crossformer: both of them extend the 1-D attention to 2- D. The explicit utilization of cross-dimension dependency makes STformer competitive with previous Transformer-based models on ETTh1, ETTm1 and WTH, especially for short-term prediction. However, STformer directly flattens the raw 2-D time series into a 1-D sequence to be input to the
352
+
353
+ ![](images/af22d7bb2883fa9d0a2cecb1beb4c67313bd7fecd7ba5b7c10ffa191350dfb39.jpg)
354
+ Figure 6: Forecasting cases of three dimensions: Dry Bulb Temperature (DBT), Dew Point Temperature (DPT) and Wind Direction (WD) of the WTH dataset with prediction length $\tau = 3 3 6$ . The red / blue curves stand for the ground truth / prediction. Each row represents one model and each column represents one dimension.
355
+
356
+ Transformer. This straightforward method does not distinguish the time and dimension axes and is computationally inefficient. Therefore, besides the good performance for short-term prediction, STformer has difficulty in long-term prediction and encounters the out-of-memory (OOM) problem on high-dimensional datasets (ECL and Traffic). While Crossformer uses the DSW embedding to capture local dependency and reduce the complexity. The TSA layer with the router mechanism is devised to deal with the heterogeneity of time and dimension axis and further improve efficiency.
357
+
358
+ DLinear is on par with our Crossformer on ETTh1 and ETTm1 $\tau \leq 9 6 $ ); has similar performance with FEDformer on ILI; performs worse than Crossformer on WTH; outperforms all Transformerbased models including our Crossformer on ETTm1 $\tau \geq 2 8 8 $ ), ECL and Traffic. Considering its simplicity, the performance is impressive. Based on the results, we analyze the limitations of Crossformer and propose some directions to improve it in the future:
359
+
360
+ 1) In Cross-Dimension Stage of TSA layer, we simply build an all-to-all connection among $D$ dimensions with the router mechanism. Besides capturing the cross-dimension dependency, this full connection also introduces noise, especially for high-dimensional dataset. We think high-dimensional data has the sparse property: each dimension is only relevant to a small fraction of all dimensions. Therefore, utilizing the sparsity to reduce noise and improve the computation efficiency of the TSA layer could be a promising direction.
361
+
362
+ 2) Authors of DLinear (Zeng et al., 2023) argue that the Transformer-based models have difficulty in preserving ordering information because the attention mechanism is permutation-invariant and the absolute position embedding injected into the model is not enough for time series forecasting, which is an order-sensitive task. Although Yun et al. (2020) theoretically proves that Transformers with trainable positional embedding are universal approximators of sequence-to-sequence functions, the ordering information still needs to be enhanced in practice. We think that relative position encoding in texts (Ke et al., 2021; Dufter et al., 2022) and vision (Wu et al., 2021b) could be useful for ordering information enhancement.
363
+
364
+ Table 4: MSE/MAE comparison with extra methods: STformer (Grigsby et al., 2022) and DLinear (Zeng et al., 2023). Bold/underline indicates the best/second. OOM indicates out-of-memory problem. Gray background marks the CNN-GNN-based model; yellow marks Transformer-based models where cross-dimension dependency is omitted; blue marks Transformer-based models explicitly utilizing cross-dimension dependency; red marks the linear model with series decomposition.
365
+
366
+ <table><tr><td colspan="2">Models</td><td colspan="2">MTGNN</td><td colspan="2">Transformer</td><td colspan="2">Informer</td><td colspan="2">Autoformer</td><td colspan="2">Pyraformer</td><td colspan="2">FEDformer</td><td colspan="2">STformer</td><td colspan="2">Crossformer</td><td colspan="2">DLinear</td></tr><tr><td colspan="2">Metric</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td></tr><tr><td rowspan="4">FLL</td><td>24 48</td><td>0.336 0.386</td><td>0.393 0.429</td><td>0.620 0.692</td><td>0.577 0.671</td><td>0.577 0.685</td><td>0.549 0.625</td><td>0.439 0.429</td><td>0.440 0.442</td><td>0.493 0.554</td><td>0.507 0.544</td><td>0.318 0.342</td><td>0.384 0.396</td><td>0.368</td><td>0.441</td><td>0.305 0.352</td><td>0.367 0.312</td><td></td><td>0.355 0.383</td></tr><tr><td>168</td><td>0.466 0.474</td><td>0.947</td><td></td><td></td><td>0.931</td><td>0.752</td><td>0.493</td><td>0.479</td><td>0.781</td><td>0.675</td><td>0.412</td><td></td><td>0.445</td><td>0.465</td><td></td><td>0.394</td><td>0.352</td><td>0.430</td></tr><tr><td>336</td><td>0.736</td><td></td><td>0.797</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>0.449</td><td>0.652</td><td>0.608</td><td>0.410 0.440</td><td>0.441 0.461</td><td>0.416 0.450</td><td></td></tr><tr><td>720</td><td>0.643 0.750</td><td>1.094 1.241</td><td>0.813 0.917</td><td>1.128</td><td>0.873 0.896</td><td>0.509 0.539</td><td>0.492</td><td>0.912</td><td>0.747</td><td>0.456</td><td>0.474</td><td>1.069</td><td>0.806</td><td></td><td></td><td></td><td>0.452</td><td></td></tr><tr><td rowspan="8">[LL</td><td>24</td><td>0.916</td><td></td><td></td><td></td><td>1.215</td><td></td><td></td><td>0.537</td><td>0.993</td><td>0.792</td><td>0.521</td><td>0.515</td><td>1.071</td><td>0.817</td><td>0.519</td><td>0.524</td><td>0.486</td><td>0.501</td></tr><tr><td>48</td><td>0.260 0.324</td><td>0.306 0.465</td><td></td><td>0.371</td><td>0.323</td><td>0.369 0.503</td><td>0.410</td><td>0.428</td><td>0.310</td><td>0.371</td><td>0.290</td><td>0.364</td><td>0.278</td><td>0.348</td><td>0.211</td><td>0.293</td><td>0.217</td><td>0.289</td></tr><tr><td>96</td><td>0.386 0.428</td><td>0.408 0.446</td><td>0.681</td><td>0.470 0.612</td><td>0.494 0.678</td><td>0.614</td><td>0.485</td><td>0.464</td><td>0.465</td><td>0.464</td><td>0.342</td><td>0.396</td><td>0.445</td><td>0.458</td><td>0.300</td><td>0.352</td><td>0.278</td><td>0.330 0.354</td></tr><tr><td>288</td><td>0.469</td><td>0.488</td><td>1.162</td><td>0.879</td><td>1.056</td><td>0.786</td><td>0.502 0.604</td><td>0.476 0.522</td><td>0.520 0.729</td><td>0.504 0.657</td><td>0.366 0.398</td><td>0.412</td><td>0.420</td><td>0.455</td><td>0.320</td><td>0.373</td><td>0.310 0.369</td><td>0.386</td></tr><tr><td>672</td><td>0.620</td><td>0.571</td><td>1.231</td><td>1.103</td><td>1.192</td><td>0.926</td><td>0.607</td><td>0.530</td><td>0.980</td><td>0.678</td><td>0.455</td><td>0.433 0.464</td><td>0.733</td><td>0.597</td><td>0.404 0.569</td><td>0.427 0.528</td><td>0.416</td><td>0.417</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>0.777</td><td>0.625</td><td></td><td></td><td></td><td></td></tr><tr><td>24 48</td><td>0.307 0.388</td><td>0.356</td><td>0.349 0.386</td><td>0.397 0.433</td><td>0.335 0.395</td><td>0.381 0.459</td><td>0.363 0.456</td><td>0.396 0.462</td><td>0.301 0.376</td><td>0.359 0.421</td><td>0.357 0.428</td><td>0.412 0.458</td><td>0.307</td><td>0.359</td><td>0.294</td><td>0.343</td><td>0.357</td><td>0.391 0.444</td></tr><tr><td>168 336</td><td>0.498 0.506</td><td>0.422 0.512 0.523</td><td>0.613</td><td>0.582</td><td>0.608</td><td>0.567</td><td>0.574</td><td>0.548</td><td>0.519</td><td>0.521</td><td>0.564</td><td>0.541</td><td>0.381 0.497</td><td>0.416 0.502</td><td>0.370 0.473</td><td>0.411 0.494</td><td>0.425 0.515</td><td>0.516</td></tr><tr><td rowspan="7">HLM</td><td>720</td><td>0.510</td><td>0.527</td><td>0.707 0.834</td><td>0.634 0.741</td><td>0.702 0.831</td><td>0.620 0.731</td><td>0.600 0.587</td><td>0.571 0.570</td><td>0.539 0.547</td><td>0.543 0.553</td><td>0.533 0.562</td><td>0.536 0.557</td><td>0.566 0.589</td><td>0.564 0.582</td><td>0.495 0.526</td><td>0.515 0.542</td><td>0.536 0.582</td><td>0.537 0.571</td></tr><tr><td>48</td><td>0.173 0.280</td><td>0.334</td><td></td><td>0.399</td><td>0.344</td><td>0.393</td><td>0.241</td><td>0.351</td><td>0.478</td><td></td><td>0.229</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>168</td><td>0.236 0.320</td><td>0.353</td><td></td><td>0.420</td><td>0.368</td><td>0.424</td><td>0.299</td><td>0.387</td><td>0.452</td><td>0.471 0.455</td><td>0.263</td><td>0.338 0.361</td><td>0.356</td><td>0.432</td><td>0.156 0.231</td><td>0.255</td><td>0.155</td><td>0.258 0.287</td></tr><tr><td>336</td><td>0.328 0.373</td><td></td><td>0.381</td><td>0.439</td><td>0.381</td><td>0.431</td><td>0.375</td><td>0.428</td><td>0.463</td><td>0.456</td><td>0.305</td><td>0.386</td><td></td><td>0.5160.527 00M</td><td>0.323</td><td>0.309 0.369</td><td>0.195 0.238</td><td>0.316</td></tr><tr><td>720</td><td>0.422</td><td>0.410</td><td>0.391</td><td>0.438</td><td>0.406</td><td>0.443</td><td>0.377</td><td>0.434</td><td>0.480</td><td>0.461</td><td>0.372</td><td>0.434</td><td></td><td>0OM</td><td>0.404</td><td>0.423</td><td>0.272</td><td>0.346</td></tr><tr><td>960</td><td>0.471</td><td>0.451</td><td>0.492</td><td>0.550</td><td>0.460</td><td>0.548</td><td>0.366</td><td>0.426</td><td>0.550</td><td>0.489</td><td>0.393</td><td>0.449</td><td></td><td>0OM</td><td>0.433</td><td>0.438</td><td>0.299</td><td>0.367</td></tr><tr><td rowspan="4">目</td><td>24</td><td></td><td>3.954</td><td></td><td>1.323</td><td></td><td>1.462</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>1.186</td><td>2.940</td><td>1.205</td></tr><tr><td>36</td><td>4.265 1.387 4.777 1.496</td><td>4.167</td><td></td><td>1.360</td><td>4.588 4.845</td><td>1.496</td><td>3.101 3.397</td><td>1.238 1.270</td><td>3.970 4.377</td><td>1.338 1.410</td><td>2.687 2.887</td><td>1.147 1.160</td><td>3.150 3.512</td><td>1.232 1.243</td><td>3.041 3.406</td></table>
367
+
368
+ 3) The sizes of datasets used for time series forecasting are much smaller than those for texts and vision, and the patterns in time series datasets are also simpler. Considering vision transformers surpass inductive bias and achieves excellent results compared to CNNs after pre-trained on large amounts of data (Dosovitskiy et al., 2021), Transformers for time series may also require large-size datasets with various patterns to exploit their full potential.
369
+
370
+ As quoted from the paper, authors mentioned that DLinear “does not model correlations among variates”. Therefore, incorporating cross-dimension dependency into DLinear to further improve prediction accuracy is also a promising direction. Moreover, our DSW embedding to enhance locality and HED to capture dependency at different scales can also be potentially useful to further inspire and enhance DLinear.
371
+
372
+ # B.3 ABLATION STUDY OF THE ROUTER MECHANISM
373
+
374
+ The ablation study of the three main components of Crossformer is shown in Sec. 4.3. In this section, we conduct an ablation study of the router mechanism, a sub-module in TSA layer, and evaluate its impact on prediction accuracy. It should be noticed that the router mechanism is mainly proposed to reduce the computation complexity when $D$ is large. Results are shown in Table 5. Adding TSA(w/o Router) constantly improves the prediction accuracy of DSW and ${ \mathrm { D S W / H E D } }$ , showing the necessity of capturing cross-time and cross-dimension dependency in two different stages. For short term prediction $\tau \leq 1 6 8 )$ ), the performances of TSA(w/o Router) and TSA are similar, no matter whether HED is used or not. For long term prediction $\tau \geq 3 3 6$ ), the router mechanism slightly improves the prediction accuracy. The possible reason is that we set separate routers for each time step, which helps capture long-term dependency that varies over time.
375
+
376
+ Table 5: Complementary results to ablation study in Table 2. TSA(w/o Router) denotes TSA layer without the router mechanism that directly uses MSA in the Cross-Dimension Stage.
377
+
378
+ <table><tr><td rowspan="2">Models</td><td colspan="2">DSW</td><td colspan="2">DSW+ TSA(w/o Router)</td><td colspan="2">DSW+TSA</td><td colspan="2">DSW+HED</td><td colspan="2">DSW+HED+ TSA(w/o Router)</td><td colspan="2">DSW+TSA+HED</td></tr><tr><td>Metric MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td></tr><tr><td>24</td><td>0.373</td><td>0.418</td><td>0.320</td><td>0.376</td><td>0.322</td><td>0.373</td><td>0.406</td><td>0.454</td><td>0.311</td><td>0.375</td><td>0.305</td><td>0.367</td></tr><tr><td>48</td><td>0.456</td><td>0.479</td><td>0.356</td><td>0.396</td><td>0.365</td><td>0.403</td><td>0.493</td><td>0.512</td><td>0.363</td><td>0.406</td><td>0.352</td><td>0.394</td></tr><tr><td>168</td><td>0.947</td><td>0.731</td><td>0.487</td><td>0.493</td><td>0.473</td><td>0.479</td><td>0.614</td><td>0.583</td><td>0.416</td><td>0.444</td><td>0.410</td><td>0.441</td></tr><tr><td>336</td><td>0.969</td><td>0.752</td><td>0.585</td><td>0.564</td><td>0.553</td><td>0.534</td><td>0.788</td><td>0.676</td><td>0.487</td><td>0.499</td><td>0.440</td><td>0.461</td></tr><tr><td>720</td><td>1.086</td><td>0.814</td><td>0.665</td><td>0.615</td><td>0.636</td><td>0.599</td><td>0.841</td><td>0.717</td><td>0.540</td><td>0.542</td><td>0.519</td><td>0.524</td></tr></table>
379
+
380
+ ![](images/36262eb1daf2a88c1f76e947cc3a85115cd100aa510cccb0a99dfa8add182a70.jpg)
381
+ Figure 7: Attention scores calculated by the decoder of the ablation version of Crossformer (i.e. DSW) on dataset ETTh1. The input length, prediction length and segment length are set as $T =$ 168, $\tau = 2 4 , L _ { s e g } = 6$ . The $\mathbf { X }$ axis in each sub-figure represents the time steps serve as keys in attention mechanism, while the y axis denotes dimensions. Brighter color denotes higher attention weights.
382
+
383
+ # B.4 DEPENDENCY VISUALIZATION
384
+
385
+ As the attention scores computed by Crossformer are abstract and hard to visualize, we visualize scores computed by the ablation version, DSW, in Figure 7. In addition to cross-time dependency that other Transformer models can compute, Crossformer also provides information about crossdimension dependency. As shown in Figure 7, when predicting Dim #1, the model focus on both Dim #1 and #3. When predicting Dim #5, instead of focus on Dim #5 itself, more attention is paid to Dim #4.
386
+
387
+ # B.5 HIERARCHICAL PREDICTION PATTERN VISUALIZATION
388
+
389
+ Figure 8 shows the hierarchical prediction patterns output by our HED. The top prediction layer, Layer 3, captures the low frequency general trend and periodic pattern of the future value. By adding predictions at finer scales, finer high frequency patterns are added and the prediction get closer to the ground truth curve.
390
+
391
+ # B.6 RUNNING TIME EFFICIENCY ANALYSIS
392
+
393
+ In the main paper, we show the memory occupation w.r.t input length $T$ and number of dimensions $D$ . Here we evaluate the running time. Figure 9 (a) shows the running time per batch of Crossformer and other Transformer-based models w.r.t input length $T$ . FEDformer is much slower than other Transformer-based models. Crossformer achieves the best computation speed among the five methods within the tested length range.
394
+
395
+ ![](images/579e34db0fe8505dd44552ed91bf2f6e9cc93f2a150eb6b8d5b9967aab55f548.jpg)
396
+ Figure 8: Hierarchical prediction visualization of ETTm1 with dimension HUFL and prediction length $\tau = 2 8 8$ . From top left to bottom right, we gradually add layer predictions at finer scales.
397
+
398
+ ![](images/7b7af163249cfc6bf6382d4b95a798eb7f6406602acc97eb7b0e86268a17e56a.jpg)
399
+ Figure 9: Evaluation on computational speed. (a) Running time per batch w.r.t the input length $T$ on ETTh1. (b) Running time per batch w.r.t number of dimensions $D$ on synthetic datasets by different numbers of dimensions.
400
+
401
+ Figure 9 (b) shows the running time per batch of Crossformer and its ablation versions w.r.t the number of dimensions $D$ . Crossformers without TSA layer (DSW and $\mathrm { D S W + H E D } )$ ) are faster when $D$ is small $\left( D \leq 3 0 \right)$ ). However, they have difficulty processing high-dimensional MTS due to the quadratic complexity w.r.t $D$ . Indeed, for a single NVIDIA GeForce RTX 2080Ti GPU with 11GB memory, DSW and $\mathrm { D S W + H E D }$ encounters the out-of-memory (OOM) problem when $D > 5 0$ Moreover, TSA(w/o Router) encounter the OOM problem when $D > 2 0 0$ .
402
+
403
+ # C DISCUSSION ON THE SELECTION OF HYPER-PARAMETERS
404
+
405
+ We recommend to first determine the segment length $L _ { s e g }$ , as it is related to both the model performance and computation efficiency. The general idea is to use small $L _ { s e g }$ for short-term prediction and large $L _ { s e g }$ for long-term prediction. Some priors about the data also help to select $L _ { s e g }$ . For example, if the hourly sampled data has a daily period, it is better to set $L _ { s e g } = 2 4$ . Next, we select the number of layers for encoder and decoder $N$ . Crossformer with larger $N$ can utilize information of more scales, but also requires more computing resources. The number of routers in TSA layer $c$ can be set to 5 or 10 to balance the prediction accuracy and computation efficiency. Finally, dimension of hidden states $d _ { m o d e l }$ and head number of multi-head attention can be determined based on the available computing resources.
406
+
407
+ Table 6: MSE and MAE evaluation with different segment lengths on ETTm1 dataset. \* denotes segment length used in the main text, which is a divisor of $T , \tau$ .
408
+
409
+ <table><tr><td>Metric</td><td>MSE</td><td>MAE</td><td>MSE</td><td>MAE</td><td>MSE MAE</td></tr><tr><td> Segment Length L seg</td><td>5</td><td></td><td>6*</td><td></td><td>7</td></tr><tr><td>T= 288,τ = 48</td><td>0.291</td><td>0.349</td><td>0.300</td><td>0.352</td><td>0.284 0.346</td></tr><tr><td>Segment Length Lseg</td><td>22</td><td></td><td>24*</td><td></td><td>26</td></tr><tr><td>T= 672,T = 288</td><td>0.401</td><td>0.424</td><td>0.404</td><td>0.427</td><td>0.409 0.429</td></tr></table>
410
+
411
+ # D SUPPLEMENTARY DESIGN TO CROSSFORMER
412
+
413
+ # D.1 HANDLING INDIVISIBLE LENGTH
414
+
415
+ In the main paper, we assume that the input length $T$ and prediction length $\tau$ are divisible by segment length $L _ { s e g }$ . In this section, we use padding mechanism to handle cases where the assumption is not satisfied.
416
+
417
+ If $T$ is not divisible by $L _ { s e g }$ , we have $( k _ { 1 } - 1 ) L _ { s e g } < T < k _ { 1 } L _ { s e g }$ for some $k _ { 1 }$ . We pad $k _ { 1 } L _ { s e g } - T$ duplicated $\mathbf { x } _ { 1 }$ in front of $\mathbf { x } _ { \mathrm { 1 : } T }$ to get $\mathbf { x } _ { 1 : T } ^ { \prime }$ :
418
+
419
+ $$
420
+ \mathbf { x } _ { 1 : T } ^ { \prime } = [ \underbrace { \mathbf { x } _ { 1 } , \dots , \mathbf { x } _ { 1 } } _ { k _ { 1 } L _ { s e g } - T } , \mathbf { x } _ { 1 : T } ]
421
+ $$
422
+
423
+ where $[ , ]$ denotes the concatenation operation. $\mathbf { x } _ { 1 : T } ^ { \prime } \in \mathbb { R } ^ { k _ { 1 } L _ { s e g } \times D }$ can be input to the encoder of Crossformer.
424
+
425
+ If $\tau$ is not divisible by $L _ { s e g }$ , we have $( k _ { 2 } - 1 ) L _ { s e g } < \tau < k _ { 2 } L _ { s e g }$ for some $k _ { 2 }$ . We set the learnable position embeddioutput in shape of der as . Then $\mathbf { E } ^ { ( d e c ) } \in \mathbb { R } ^ { k _ { 2 } \times D \times d _ { m o d e l } }$ and input it ttput is used as der to get an. $\mathbb { R } ^ { k _ { 2 } L _ { s e g } \times D }$ $\tau$ $\mathbf { x } _ { T + 1 : T + \tau } ^ { p r e d }$
426
+
427
+ We conduct experiment on ETTm1 dataset to evaluate the effect of indivisible length. Results in Table 6 show that with padding mechanism, indivisible length does not degrade model performance, for both short-term prediction and long-term prediction.
428
+
429
+ # D.2 INCORPORATING COVARIATES
430
+
431
+ In the main text, we only use historical series $\mathbf { x } _ { \mathrm { 1 : } T }$ to forecast the future $\mathbf { x } _ { T + 1 : T + \tau }$ . In this section, we try to incorporate covariates $\mathbf { c } _ { 1 : T + \tau }$ into Crossformer. We use a straightforward method: first embed the covariates into point-wise vectors $\left\{ { \bf d } _ { 1 } , { \bf d } _ { 2 } , \ldots , { \bf d } _ { T + \tau } \right\}$ like previous Transformer-based models do (Zhou et al., 2021; Wu et al., 2021a; Liu et al., 2021a). Then, merge the point-wise vectors into segment-wise vectors using learnable linear combination. Finally, add the segment-wise vectors to each dimension of the 2D vector array obtained by DSW embedding:
432
+
433
+ $$
434
+ \begin{array} { c } { \displaystyle \mathbf { c } _ { t } \to \mathbf { d } _ { t } , 1 \leq t \leq T } \\ { \displaystyle \mathbf { d } _ { i } ^ { ( s ) } = \sum _ { \substack { 0 < j \leq L _ { s e g } } } \alpha _ { j } \mathbf { d } _ { ( i - 1 ) \times L _ { s e g } + j } , \quad 1 \leq i \leq \frac { T } { L _ { s e g } } } \\ { \displaystyle \mathbf { h } _ { i , d } ^ { c o v } = \mathbf { h } _ { i , d } + \mathbf { d } _ { i } ^ { ( s ) } , \quad 1 \leq i \leq \frac { T } { L _ { s e g } } , \quad 1 \leq d \leq D } \end{array}
435
+ $$
436
+
437
+ where denotes embedding method for point-wise covariates. $\alpha _ { j } , 1 \le j \le L _ { s e g }$ denotes learnable factors for linear combination. $\mathbf { d } _ { i } ^ { ( s ) }$ denotes the segment-wise covariate embedding. ${ \bf h } _ { i , d } ^ { c o v }$ denotes the embedded vector with covariate information for the $i$ -th segment in dimension $d$ , where $\mathbf { h } _ { i , d }$ is the embedded vector obtained from DSW embedding in the main text. The processing for the input of the decoder is similar, the segment-wise covariate embedding is added to the position embedding for decoder, i.e. ${ \bf E } ^ { ( d e c ) }$ .
438
+
439
+ Table 7: MSE and MAE evaluation of Crossformer without/with covariates on ETTh1 dataset.
440
+
441
+ <table><tr><td>Models</td><td>Crossformer</td><td>Crossformer+Cov</td></tr><tr><td>Metric</td><td>MSE MAE</td><td>MSE MAE</td></tr><tr><td>24</td><td>0.305 0.367</td><td>0.308 0.368</td></tr><tr><td>48</td><td>0.352 0.394</td><td>0.358 0.399</td></tr><tr><td>168</td><td>0.410 0.441</td><td>0.412 0.440</td></tr><tr><td>336</td><td>0.440 0.461</td><td>0.438 0.465</td></tr><tr><td>720</td><td>0.519 0.524</td><td>0.522 0.531</td></tr></table>
442
+
443
+ We conduct experiments on ETTh1 dataset to evaluate the effect of covariates. Hour-of-the-day, dayof-the-week, day-of-the-month and day-of-the-year are used as covariates. Results in Table 7 show that incorporating covariates does not improve the performance of Crossformer. The possible reason is this straightforward embedding method does not cooperate well with Crossformer. Incorporating covariates into Crossformer to further improve prediction accuracy is still an open problem.
md/dev/vSix3HPYKSU/vSix3HPYKSU.md ADDED
@@ -0,0 +1,635 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MESSAGE PASSING NEURAL PDE SOLVERS
2
+
3
+ # Johannes Brandstetter∗
4
+
5
+ Daniel E. Worrall∗ Qualcomm AI Research† dworrall@qti.qualcomm.com
6
+
7
+ University of Amsterdam Johannes Kepler University Linz brandstetter@ml.jku.at
8
+
9
+ Max Welling University of Amsterdam m.welling@uva.nl
10
+
11
+ # ABSTRACT
12
+
13
+ The numerical solution of partial differential equations (PDEs) is difficult, having led to a century of research so far. Recently, there have been pushes to build neural–numerical hybrid solvers, which piggy-backs the modern trend towards fully end-to-end learned systems. Most works so far can only generalize over a subset of properties to which a generic solver would be faced, including: resolution, topology, geometry, boundary conditions, domain discretization regularity, dimensionality, etc. In this work, we build a solver, satisfying these properties, where all the components are based on neural message passing, replacing all heuristically designed components in the computation graph with backpropoptimized neural function approximators. We show that neural message passing solvers representationally contain some classical methods, such as finite differences, finite volumes, and WENO schemes. In order to encourage stability in training autoregressive models, we put forward a method that is based on the principle of zero-stability, posing stability as a domain adaptation problem. We validate our method on various fluid-like flow problems, demonstrating fast, stable, and accurate performance across different domain topologies, discretization, etc. in 1D and 2D. Our model outperforms state-of-the-art numerical solvers in the low resolution regime in terms of speed and accuracy.
14
+
15
+ # 1 INTRODUCTION
16
+
17
+ In the sciences, years of work have yielded extremely detailed mathematical models of physical phenomena. Many of these models are expressed naturally in differential equation form (Olver, 2014), most of the time as temporal partial differential equations (PDE). Solving these differential equations is of huge importance for problems in all numerate disciplines such as weather forecasting (Lynch, 2008), astronomical simulations (Courant et al., 1967), molecular modeling (Lelievre & \` Stoltz, 2016) , or jet engine design (Athanasopoulos et al., 2009). Solving most equations of importance is analytically intractable and necessitates falling back on numerical approximation schemes. Obtaining accurate solutions of bounded error with minimal computational overhead requires the need for handcrafted solvers, always tailored to the equation at hand (Hairer et al., 1993).
18
+
19
+ The design of “good” PDE solvers is no mean feat. The perfect solver should satisfy an almost endless list of conditions. There are user requirements, such as being fast, using minimal computational overhead, being accurate, providing uncertainty estimates, generalizing across PDEs, and being easy to use. Then there are structural requirements of the problem, such as spatial resolution and timescale, domain sampling regularity, domain topology and geometry, boundary conditions, dimensionality, and solution space smoothness. And then there are implementational requirements, such as maintaining stability over long rollouts and preserving invariants. It is precisely because of this considerable list of requirements that the field of numerical methods is a splitter field (Bartels, 2016), tending to build handcrafted solvers for each sub-problem, rather than a lumper field, where a mentality of “one method to rule them all” reigns. This tendency is commonly justified with reference to no free lunch theorems. We propose to numerically solve PDEs with an end-to-end, neural solver. Our contributions can be broken down into three main parts: (i) An end-to-end fully neural PDE solver, based on neural message passing, which offers flexibility to satisfy all structural requirements of a typical PDE problem. This design is motivated by the insight that some classical solvers (finite differences, finite volumes, and WENO scheme) can be posed as special cases of message passing. (ii) Temporal bundling and the pushforward trick, which are methods to encourage zero-stability in training autoregressive models. (iii) Generalization across multiple PDEs within a given class. At test time, new PDE coefficients can be input to the solver.
20
+
21
+ # 2 BACKGROUND AND RELATED WORK
22
+
23
+ Here in Section 2.1 we briefly outline definitions and notation. We then outline some classical solving techniques in Section 2.2. Lastly, in Section 2.3, we list some recent neural solvers and split them into the two main neural solving paradigms for temporal PDEs.
24
+
25
+ # 2.1 PARTIAL DIFFERENTIAL EQUATIONS
26
+
27
+ We focus on PDEs in one time dimension $t ~ = ~ [ 0 , T ]$ and possibly multiple spatial dimensions $\mathbf { x } = [ x _ { 1 } , x _ { 2 } , \ldots , x _ { D } ] ^ { \top } \in \mathbb { X }$ . These can be written down in the form
28
+
29
+ $$
30
+ \begin{array} { r l r l } & { \partial _ { t } \mathbf { u } = F ( t , \mathbf { x } , \mathbf { u } , \partial _ { \mathbf { x } } \mathbf { u } , \partial _ { \mathbf { x } \mathbf { x } } \mathbf { u } , \dots ) } & & { \qquad ( t , \mathbf { x } ) \in [ 0 , T ] \times \mathbb { X } } \\ & { \mathbf { u } ( 0 , \mathbf { x } ) = \mathbf { u } ^ { 0 } ( \mathbf { x } ) , \qquad B [ \mathbf { u } ] ( t , x ) = 0 } & & { \qquad \mathbf { x } \in \mathbb { X } , \ ( t , \mathbf { x } ) \in [ 0 , T ] \times \partial \mathbb { X } } \end{array}
31
+ $$
32
+
33
+ where $\mathbf { u } : [ 0 , T ] \times \mathbb { X } \mathbb { R } ^ { n }$ is the solution, with initial condition ${ \bf u } ^ { 0 } ( { \bf x } )$ at time $t = 0$ and boundary conditions $B [ { \bf u } ] ( t , x ) = 0$ when $\mathbf { x }$ is on the boundary $\partial \mathbb { X }$ of the domain $\mathbb { X }$ . The notation $\partial _ { \mathbf { x } } \mathbf { u } , \partial _ { \mathbf { x } \mathbf { x } } \mathbf { u } , \ldots$ is shorthand for partial derivatives $\partial { \bf u } / \partial { \bf x } , \bar { \partial } ^ { 2 } { \bf u } / \partial { \bf x } ^ { 2 }$ , and so forth. Most notably, $\partial \mathbf { u } / \partial \mathbf { x }$ represents a $n \times D$ dimensional Jacobian matrix, where each row is the transpose of the gradient of the corresponding component of $\mathbf { u }$ . We consider Dirichlet boundary conditions, where the boundary operator $B _ { \mathcal { D } } [ \mathbf { u } ] = \mathbf { u } - \mathbf { b } _ { \mathcal { D } }$ for fixed function $\mathbf { b } _ { \mathcal { D } }$ and Neumann boundary conditions, where $B _ { \mathcal { N } } [ \bar { u } ] \stackrel { \cdot } { = } { \mathbf { n } } ^ { \top } \partial _ { \mathbf { x } } u - \bar { b } _ { \mathcal { N } } ^ { \top }$ for scalar-valued $u$ , where $\mathbf { n }$ is an outward facing normal on $\partial \mathbb { X }$ .
34
+
35
+ Conservation form Among all PDEs, we hone in on solving those that can be written down in conservation form, because there is already precedent in the field for having studied these (Bar-Sinai et al., 2019; Li et al., 2020a). Conservation form PDEs are written as
36
+
37
+ $$
38
+ \partial _ { t } \mathbf { u } + \nabla \cdot \mathbf { J } ( \mathbf { u } ) = 0 ,
39
+ $$
40
+
41
+ where $\nabla \cdot \mathbf { J }$ is the divergence of $\mathbf { J }$ . The quantity $\mathbf { J } : \mathbb { R } ^ { n } \mathbb { R } ^ { n }$ is the flux, which has the interpretation of a quantity that appears to flow. Consequently, $\mathbf { u }$ is a conserved quantity within a volume, only changing through the net flux $\mathbf { J } ( \mathbf { u } )$ through its boundaries.
42
+
43
+ # 2.2 CLASSICAL SOLVERS
44
+
45
+ Grids and cells Numerical solvers partition $\mathbb { X }$ into a finite grid $X = \{ c _ { i } \} _ { i = 1 } ^ { N }$ of $N$ small nonoverlapping volumes called cells $c _ { i } \subset \mathbb { X }$ . In this work, we focus on grids of rectangular cells. Each cell has a center at $\mathbf { x } _ { i }$ . $\mathbf { u } _ { i } ^ { k }$ is used to denote the discretized solution in cell $c _ { i }$ and time $t _ { k }$ . There are two main ways to compute $\mathbf { u } _ { i } ^ { k }$ : sampling $\mathbf { u } _ { i } ^ { k } = \mathbf { u } ( t _ { k } , \mathbf { x } _ { i } )$ and averaging $\begin{array} { r } { \mathbf { u } _ { i } ^ { k } = \int _ { c _ { i } } \mathbf { u } ( t _ { k } , \mathbf { x } ) \mathrm { d } \mathbf { x } } \end{array}$ . In our notation, omitting an index implies that we use the entire slice, so $\mathbf { u } ^ { k } = ( \mathbf { u } _ { 1 } ^ { k } , \mathbf { u } _ { 2 } ^ { k } , . . . , \mathbf { u } _ { N } ^ { k } )$ .
46
+
47
+ Method of lines A common technique to solve temporal PDEs is the method of lines (Schiesser, 2012), discretizing domain $\mathbb { X }$ and solution $\mathbf { u }$ into a grid $X$ and a vector $\mathbf { u } ^ { k }$ . We then solve $\left. \partial _ { t } \mathbf { u } ^ { t } \right| _ { t _ { k } } =$ $f ( t , \mathbf { u } ^ { k } )$ for $t \in [ 0 , T ]$ , where $f$ is the form of $F$ acting on the vectorized $\mathrm { ~ \bf ~ u ~ } ^ { t }$ instead of the function $\mathbf { u } ( t , \mathbf { x } )$ . The only derivative operator is now in time, making it an ordinary differential equation (ODE), which can be solved with off-the-shelf ODE solvers (Butcher, 1987; Everhart, 1985). $f$ can be formed by approximating spatial derivatives on the grid. Below are three classical techniques.
48
+
49
+ Finite difference method (FDM) In FDM, spatial derivative operators (e.g., $\partial _ { \mathbf { x } } )$ are replaced with difference operators, called stencils. For instance, $\partial _ { x } u ^ { k } | _ { x _ { i } }$ might become $( \mathbf { \bar { \boldsymbol { u } } } _ { i + 1 } ^ { k } - \boldsymbol { u } _ { i } ^ { k } ) / ( \mathbf { \bar { \boldsymbol { x } } } _ { i + 1 } - \boldsymbol { x } _ { i } )$ . Principled ways to derive stencils can be found in Appendix A. FDM is simple and efficient, but suffers poor stability unless the spatial and temporal discretizations are carefully controlled.
50
+
51
+ Finite volume method (FVM) FVM works for equations in conservation form. It can be shown via the divergence theorem that the integral of $\mathbf { u }$ over cell $i$ increases only by the net flux into the cell. In 1D, this leads to f (t, uki ) = 1∆x $\begin{array} { r } { f ( t , u _ { i } ^ { k } ) = \mathbf { \Pi } _ { \Delta x _ { i } } ^ { - 1 } ( J _ { i - 1 / 2 } ^ { k } - J _ { i + 1 / 2 } ^ { k } ) } \end{array}$ , where $\Delta x _ { i }$ is the cell width, and $J _ { i - 1 / 2 } ^ { k } , J _ { i + 1 / 2 } ^ { k }$ i the flux at the left and right cell boundary at time $t _ { k }$ , respectively. The problem thus boils down to estimating the flux at cell boundaries $x _ { i \pm 1 / 2 }$ . The beauty of this technique is that the integral of $u$ is exactly conserved. FVM is generally more stable and accurate than FDM, but can only be applied to conservation form equations.
52
+
53
+ Pseudospectral method (PSM) PSM computes derivatives in Fourier space. In practical terms,√ the $m ^ { \mathrm { t h } }$ derivative is computed as $\mathrm { I F F T } \{ ( \iota \omega \bar { ) } ^ { m } \mathrm { F F T } ( \boldsymbol { u } ) \}$ for $\iota = \sqrt { - 1 }$ . These derivatives obtain exponential accuracy (Tadmor, 1986), for smooth solutions on periodic domains and regular grids. For non-periodic domains, analogues using other polynomial transforms exist, but for non-smooth solution this technique cannot be applied.
54
+
55
+ # 2.3 NEURAL SOLVERS
56
+
57
+ We build on recent exciting developments in the field to learn PDE solvers. These neural PDE solvers, as we refer to them, are laying the foundations of what is becoming both a rapidly growing and impactful area of research. Neural PDE solvers for temporal PDEs fall into two broad categories, autoregressive methods and neural operator methods, see Figure 1a.
58
+
59
+ Neural operator methods Neural operator methods treat the mapping from initial conditions to solutions at time $t$ as an input–output mapping learnable via supervised learning. For a given PDE and given initial conditions $\mathbf { u } _ { 0 }$ , a neural operator $\mathcal { M } : [ 0 , T ] \stackrel { \cdot } { \times } \mathcal { F } \mathcal { F }$ , where $\mathcal { F }$ is a (possibly infinite-dimensional) function space, is trained to satisfy
60
+
61
+ $$
62
+ \mathcal { M } ( t , { \mathbf { u } } ^ { 0 } ) = { \mathbf { u } } ( t ) .
63
+ $$
64
+
65
+ Finite-dimensional operator methods (Raissi, 2018; Sirignano & Spiliopoulos, 2018; Bhatnagar et al., 2019; Guo et al., 2016; Zhu & Zabaras, 2018; Khoo et al., 2020), where $\mathrm { d i m } ( \mathcal { F } ) < \infty$ are grid-dependent, so cannot generalize over geometry and sampling. Infinite-dimensional operator methods (Li et al., 2020c;a; Bhattacharya et al., 2021; Patel et al., 2021) by contrast resolve this issue. Each network is trained on example solutions of the equation of interest and is therefore locked to that equation. These models are not designed to generalize to dynamics for out-of-distribution $t$ .
66
+
67
+ Autogressive methods An orthogonal approach, which we take, is autoregressive methods. These solve the PDE iteratively. For time-independent PDEs, the solution at time $t + \Delta t$ is computed as
68
+
69
+ $$
70
+ \mathbf { u } ( t + \Delta t ) = \mathcal { A } ( \Delta t , \mathbf { u } ( t ) ) ,
71
+ $$
72
+
73
+ where $\mathcal { A } : \mathbb { R } _ { > 0 } \times \mathbb { R } ^ { N } \to \mathbb { R } ^ { N }$ is the temporal update. In this work, since $\Delta t$ is fixed, we just write $\boldsymbol { \mathcal { A } } ( \mathbf { u } ( t ) )$ . Three important works in this area are Bar-Sinai et al. (2019), Greenfeld et al. (2019), and Hsieh et al. (2019). Each paper focuses on a different class of PDE solver: finite volumes, multigrid, and iterative finite elements, respectively. Crucially, they all use a hybrid approach (Garcia Satorras et al., 2019), where the solver computational graph is preserved and heuristically-chosen parameters are predicted with a neural network. Hsieh et al. (2019) even have convergence guarantees for their method, something rare in deep learning. Hybrid methods are desirable for sharing structure with classical solvers. So far in the literature, however, it appears that autoregressive methods are more the exception than the norm, and for those methods published, it is reported that they are hard to train. In Section 3 we explore why this is and seek to remedy it.
74
+
75
+ # 3 METHOD
76
+
77
+ In this section we detail our method in two parts: training framework and architecture. The training framework tackles the distribution shift problem in autoregressive solvers, which leads to instability. We then outline the network architecture, which is a message passing neural network.
78
+
79
+ # 3.1 TRAINING FRAMEWORK
80
+
81
+ Autoregressive solvers map solutions $\mathbf { u } ^ { k }$ to causally consequent ones $\mathbf { u } ^ { k + 1 }$ . A straightforward way of training is one-step training. If $p _ { 0 } ( \mathbf { u } ^ { 0 } )$ is the distribution of initial conditions in the training set, and $\begin{array} { r } { p _ { k } ( \mathbf { u } ^ { \bar { k } } ) = \int p ( \mathbf { u } ^ { \bar { k } } | \mathbf { u } ^ { 0 } ) p _ { 0 } ( \mathbf { \bar { u } } ^ { 0 } ) \mathrm { d } \mathbf { u } ^ { 0 } } \end{array}$ is the groundtruth distribution at iteration $k$ , we minimize
82
+
83
+ $$
84
+ L _ { \mathrm { o n e - s t e p } } = \mathbb { E } _ { k } \mathbb { E } _ { { \mathbf { u } } ^ { k + 1 } | { \mathbf { u } } ^ { k } , { \mathbf { u } } ^ { k } \sim p _ { k } } \left[ \mathcal { L } ( A ( { \mathbf { u } } ^ { k } ) , { \mathbf { u } } ^ { k + 1 } ) \right] ,
85
+ $$
86
+
87
+ ![](images/df8316cb4c7b41662cdaeec8c9369ef933850b130fb55e5bafaf760136cb3e4b.jpg)
88
+ Figure 1: (a) LEFT: Neural operators perform a direct mapping from initial conditions to a solution at time $t$ . RIGHT: Autoregressive models on the other hand compute the solution at time $t$ based on the computed solution at a fixed time offset before. (b) Our autoregressive solver outputs multiple time slices on every call, to reduce number of solver calls and therefore error propagation speed.
89
+
90
+ where $\mathcal { L }$ is an appropriate loss function. At test time, this method has a key failure mode, instability: small errors in $\mathcal { A }$ accumulate over rollouts greater in length than 1 (which is the vast majority of rollouts), and lead to divergence from the groundtruth. This can be interpreted as overfitting to the one-step training distribution, and thus being prone to generalize poorly if the input shifts from this, which is usually the case after a few rollout steps.
91
+
92
+ The pushforward trick We approach the problem in probabilistic terms. The solver maps $p _ { k } \mapsto$ $\mathcal { A } _ { \sharp } p _ { k }$ at iteration $k + 1$ , where ${ \bar { \mathcal { A } } } _ { \sharp } : \mathbb { P } ( X ) \ { \bar { \to } } \ \mathbb { P } ( X )$ is the pushforward operator for $\mathcal { A }$ and $\mathbb { P } ( X )$ is the space of distributions on $X$ . After a single test time iteration, the solver sees samples from $\mathcal { A } _ { \sharp } p _ { k }$ instead of the distribution $p _ { k + 1 }$ , and unfortunately $\mathcal { A } _ { \sharp } p _ { k } \neq p _ { k + 1 }$ because errors always survive training. The test time distribution is thus shifted, which we refer to as the distribution shift problem. This is a domain adaptation problem. We mitigate the distribution shift problem by adding a stability loss term, accounting for the distribution shift. A natural candidate is an adversarial-style loss
93
+
94
+ $$
95
+ L _ { \mathrm { s t a b i l i t y } } = \mathbb { E } _ { k } \mathbb { E } _ { { \mathbf { u } } ^ { k + 1 } | { \mathbf { u } } ^ { k } , { \mathbf { u } } ^ { k } \sim p _ { k } } \left[ \mathbb { E } _ { \epsilon | { \mathbf { u } } ^ { k } } \left[ { \mathcal { L } } ( A ( { \mathbf { u } } ^ { k } + { \boldsymbol { \epsilon } } ) , { \mathbf { u } } ^ { k + 1 } ) \right] \right] ,
96
+ $$
97
+
98
+ where $\boldsymbol { \epsilon } | \mathbf { u } ^ { k }$ is an adversarial perturbation sampled from an appropriate distribution. For the perturbation distribution, we choose $\epsilon$ such that $( \mathbf { u } ^ { k } + \epsilon ) \sim \bar { \mathcal { A } } _ { \sharp } p _ { k }$ . This can be easily achieved by using $( \mathbf { u } ^ { k } + \epsilon ) = \mathcal { A } ( \mathbf { u } ^ { k - 1 } )$ for $\mathbf { u } ^ { k - 1 }$ one step causally preceding $\mathbf { u } ^ { k }$ . Our total loss is then $L _ { \mathrm { o n e - s t e p } } + L _ { \mathrm { s t a b i l i t y } }$ . We call this the pushforward trick. We implement this by unrolling the solver for 2 steps but only backpropagating errors on the last unroll step, as shown in Figure 2. This is also outlined algorithmically in the appendix. We found it important not to backpropagate through the first unroll step. This is not only faster, it also seems to be more stable. Exactly why, we are not sure, but we think it may be to ensure the perturbations are large enough. Training the adversarial distribution itself to minimize the error, defeats the purpose of using it as an adversarial distribution. Adversarial losses were also introduced in Sanchez-Gonzalez et al. (2020) and later used in Mayr et al. (2021), where Brownian motion noise is used for $\epsilon$ and there is some similarity to Noisy Nodes (Godwin et al.), where noise injection is found to stabilize training of deep graph neural networks. There are also connections with zero-stability (Hairer et al., 1993) from the ODE solver literature. Zero-stability is the condition that perturbations in the input conditions are damped out sublinearly in time, that is $\lVert A ( \mathbf { u } ^ { 0 } + \epsilon ) - \mathbf { u } ^ { 1 } \rVert \stackrel { . } { < } \kappa \lVert \epsilon \rVert$ , for appropriate norm and small $\kappa$ . The pushforward trick can be seen to minimize $\kappa$ directly.
99
+
100
+ The temporal bundling trick The second trick we found to be effective for stability and reducing rollout time is to predict multiple timesteps into the future synchronously. A typical temporal solver only predicts $\mathbf { u } ^ { 0 } \mapsto \mathbf { u } ^ { 1 }$ ; whereas, we predict $K$ steps $\mathbf { u } ^ { 0 } \mapsto \left( \mathbf { u } ^ { 1 } , \mathbf { u } ^ { 2 } , . . . , \mathbf { \bar { u } } ^ { K } \right) \stackrel { . . . } { = } \mathbf { u } ^ { 1 : K }$ together. This reduces the number of solver calls by a factor of $K$ and so reduces the number of times the solution distribution undergoes distribution shifts. A schematic of this setup can be seen in Figure 1b.
101
+
102
+ # 3.2 ARCHITECTURE
103
+
104
+ We model the grid $X$ as a graph $\mathcal { G } = ( \nu , \mathcal { E } )$ with nodes $i \in \mathcal V$ , edges $i j \in \mathcal { E }$ , and node features $\mathbf { f } _ { i } ~ \in ~ \mathbb { R } ^ { c }$ . The nodes represent grid cells $c _ { i }$ and the edges define local neighborhoods. Modeling the domain as a graph offers flexibility over grid sampling regularity, spatial/temporal resolution, domain topology and geometry, boundary modeling and dimensionality. The solver is a graph neural network (GNN) (Scarselli et al., 2009; Kipf & Welling, 2017; Defferrard et al., 2016; Gilmer et al., 2017; Battaglia et al., 2018), representationally containing the function class of several classical solvers, see Section 3.2. We follow the Encode-Process-Decode framework of Battaglia et al. (2018) and Sanchez-Gonzalez et al. (2020) , with adjustments. We are not the first to use GNNs as PDE solvers (Li et al., 2020b; De Avila Belbute-Peres et al., 2020), but ours have several notable features. Different aspects of the chosen architecture are ablated in Appendix G.
105
+
106
+ ![](images/5dbb94a682a16ff58dbe8bec68ee4cb662d8ebeee6f61f58881eab2e64776e08.jpg)
107
+ Figure 2: Different training strategies. LEFT: One-step training only predicts solutions one step into the future. MIDDLE: Unrolled training predicts $N$ steps into the future. RIGHT: Adversarial training predicts $N$ steps into the future, but only backprops on the last step.
108
+
109
+ Encoder The encoder computes node embeddings. For each node $i$ it maps the last $K$ solution values uki $\mathbf { u } _ { i } ^ { k - K : k }$ , node position $\mathbf { x } _ { i }$ , current time $t _ { k }$ , and equation embedding $\pmb { \theta } _ { \mathrm { P D E } }$ to node embedding vector $\bar { \mathbf { f } _ { i } ^ { 0 } } = \epsilon ^ { v } ( [ \mathbf { u } _ { i } ^ { k - K : k } , \mathbf { x } _ { i } , t _ { k } , \pmb { \theta } _ { \mathrm { P D E } } ] )$ . $\theta _ { \mathrm { P D E } }$ contains the PDE coefficients and other attributes such as boundary conditions. An exact description is found in Section 4. The inclusion of $\pmb { \theta } _ { \mathrm { P D E } }$ allows us to train the solver on multiple different PDEs.
110
+
111
+ Processor The processor computes $M$ steps of learned message passing, with intermediate graph representations $\mathcal { G } ^ { 1 } , \mathcal { G } ^ { 2 } , . . . , \mathcal { G } ^ { M }$ . The specific updates we use are
112
+
113
+ $$
114
+ \begin{array} { r l } { { \mathrm { l g e } j \to i \mathrm { m e s s a g e } ; \quad } } & { { { \bf m } _ { i j } ^ { m } = \phi \left( { \bf f } _ { i } ^ { m } , { \bf f } _ { j } ^ { m } , { \bf u } _ { i } ^ { k - K : k } - { \bf u } _ { j } ^ { k - K : k } , { \bf x } _ { i } - { \bf x } _ { j } , \theta _ { \mathrm { P D E } } \right) , } } \\ { { \mathrm { n o d e } i \mathrm { u p d a t e } ; \quad } } & { { { \bf f } _ { i } ^ { m + 1 } = \psi \left( { \bf f } _ { i } ^ { m } , \displaystyle \sum _ { j \in N ( i ) } { \bf m } _ { i j } ^ { m } , \theta _ { \mathrm { P D E } } \right) , } } \end{array}
115
+ $$
116
+
117
+ where $\mathcal { N } ( i )$ holds the neighbors of node $i$ , and $\phi$ and $\psi$ are multilayer perceptrons (MLPs). Using relative positions $\mathbf { x } _ { j } - \mathbf { x } _ { i }$ can be justified by the translational symmetry of the PDEs we consider. Solution differences $\mathbf { u } _ { i } - \mathbf { u } _ { j }$ make sense by thinking of the message passing as a local difference operator, like a numerical derivative operator. Parameters $\pmb { \theta } _ { \mathrm { P D E } }$ are inserted into the message passing similar to Brandstetter et al. (2021)
118
+
119
+ Decoder After message passing, we use a shallow 1D convolutional network with shared weights across spatial locations to output the $K$ next timestep predictions at grid point $\mathbf { x } _ { i }$ . For each node $i$ , the processor outputs a vector $\mathbf { f } _ { i } ^ { M }$ . We treat this vector as a temporally contiguous signal, which we feed into a CNN over time. The CNN helps to smooth the signal over time and is reminiscent of linear multistep methods (Butcher, 1987), which are very efficient but generally not used because of stability concerns. We seem to have avoided these stability issues, by making the time solver nonlinear and adaptive to its input. The result is a new vector $\mathbf d _ { i } = ( \bar { \mathbf d } _ { i } ^ { 1 } , \mathbf d _ { i } ^ { 2 } , . . . , \mathbf d _ { i } ^ { K } )$ with each element $\mathbf { d } _ { i } ^ { k }$ corresponding to a different point in time. We use this to update the solution as
120
+
121
+ $$
122
+ { \mathbf { u } } _ { i } ^ { k + \ell } = { \mathbf { u } } _ { i } ^ { k } + ( t _ { k + \ell } - t _ { k } ) { \mathbf { d } } _ { i } ^ { \ell } , \qquad 1 \le \ell \le K .
123
+ $$
124
+
125
+ The motivation for this choice of decoder has to do with a property called consistency (Arnold, 2015), which states that $\begin{array} { r } { \operatorname* { l i m } _ { \Delta t 0 } \| \mathcal { A } ( \Delta t , \mathbf { u } ^ { 0 } ) - \mathbf { u } ( \Delta t ) \| = 0 } \end{array}$ , i.e. the prediction matches the exact solution in the infinitesimal time limit. Consistency is a requirement for zero-stability of the rollouts.
126
+
127
+ ![](images/e44644ab293bcb4346a08d6fc301495d61400455b48584baf855c3c782f34b5a.jpg)
128
+ Figure 3: Schematic sketch of our MP-PDE Solver.
129
+
130
+ Connections. As mentioned in Bar-Sinai et al. (2019), both FDM and FVM are linear methods, which estimate $n ^ { \mathrm { t h } }$ -order point-wise function derivatives as
131
+
132
+ $$
133
+ [ \partial _ { x } ^ { ( n ) } u ] _ { i } \simeq \sum _ { j \in \mathcal { N } ( i ) } \alpha _ { j } ^ { ( n ) } u _ { j }
134
+ $$
135
+
136
+ for appropriately chosen coefficients $\alpha _ { j } ^ { ( n ) }$ , where $\mathcal { N } ( i )$ is the neighborhood of cell $i$ . FDM computes this at cell centers, and FVM computes this at cell boundaries. These estimates are plugged into flux equations, see Table 3 in the appendix, followed by an optional FVM update step, to compute time derivative estimates for the ODE solver. The WENO5 scheme computes derivative estimates by taking an adaptively-weighted average over multiple FVM estimates, computed using different neighborhoods of cell $i$ (see Equation 23). The FVM update, Equation 11, and Equation 23 are just message passing schemes with weighted aggregation (1 layer for FDM, 2 layers for FVM, and 3 layers for WENO). It is through this connection, that we see that message-passing neural networks representationally contain these classical schemes, and are thus a well-motivated architecture.
137
+
138
+ # 4 EXPERIMENTS
139
+
140
+ We demonstrate the effectiveness of the MP-PDE solver on tasks of varying difficulty to showcase its qualities. In 1D, we study its ability to generalize to unseen equations within a given family; we study boundary handling for periodic, Dirichlet, and Neumann boundary conditions; we study both regular and irregular grids; and we study the ability to model shock waves. We then show that the MP-PDE is able to solve equations in 2D. We also run ablations over the pushforward trick and variations, to demonstrate its utility. As baselines, we compare against standard classical PDE solvers, namely; FDM, pseudospectral methods, and a WENO5 solver, and we compare against the Fourier Neural Operator of Li et al. (2020a) as an example of a state-of-the-art neural operator method. The MP-PDE solver architecture is detailed in Appendix F.
141
+
142
+ # 4.1 INTERPOLATING BETWEEN PDES
143
+
144
+ Data We focus on the family of PDEs
145
+
146
+ $$
147
+ \begin{array} { c } { { \displaystyle [ \partial _ { t } u + \partial _ { x } ( \alpha u ^ { 2 } - \beta \partial _ { x } u + \gamma \partial _ { x x } u ) ] ( t , x ) = \delta ( t , x ) , } } \\ { { \displaystyle u ( 0 , x ) = \delta ( 0 , x ) , \qquad \delta ( t , x ) = \sum _ { j = 1 } ^ { J } A _ { j } \sin ( \omega _ { j } t + 2 \pi \ell _ { j } x / L + \phi _ { j } ) } } \end{array}
148
+ $$
149
+
150
+ Writing $\theta _ { \mathrm { P D E } } = \left( \alpha , \beta , \gamma \right)$ , corner cases are the heat equation $\theta _ { \mathrm { P D E } } = ( 0 , \eta , 0 )$ , Burgers’ equation $\theta _ { \mathrm { P D E } } = ( 0 . 5 , \eta , 0 )$ , and the KdV equation $\theta _ { \mathrm { P D E } } ~ = ~ ( 3 , 0 , 1 )$ . The term $\delta$ is a forcing term, following Bar-Sinai et al. (2019), with $J = 5$ , $L = 1 6$ and coefficients sampled uniformly in $A _ { j } \in$ $[ - 0 . 5 , 0 . 5 ]$ , $\omega _ { j } \in [ - 0 . 4 , - 0 . 4 ] , \ell _ { j } \in \{ 1 , 2 , 3 \} , \phi _ { j } \in [ 0 , 2 \pi )$ . This setup guarantees periodicity of the initial conditions and forcing. Space is uniformly discretized to $n _ { x } = 2 0 0$ cells in $[ 0 , 1 6 )$ with periodic boundary and time is uniformly discretized to $n _ { t } = 2 0 0$ points in $[ 0 , 4 ]$ . Our training sets consist of 2096 trajectories, downsampled to resolutions $( n _ { t } , n _ { x } ) \in \{ ( 2 5 0 , 1 0 0 ) , ( 2 5 0 , 5 0 ) , ( 2 5 0 , 4 0 ) \}$ . Numerical groundtruth is generated using a $5 ^ { \mathrm { t h } }$ -order WENO scheme (WENO5) (Shu, 2003) for the convection term $\partial _ { x } u ^ { 2 }$ and $4 ^ { \mathrm { t h } }$ -order finite difference stencils for the remaining terms. The temporal solver is an explicit Runge-Kutta 4 solver (Runge, 1895; Kutta, 1901) with adaptive timestepping. Detailed methods and implementation are in Appendix C. All methods are implemented for GPU, so runtime comparisons are fair. For the interested reader comparison of WENO and FDM schemes against analytical solutions can be found in Appendix $\textrm { C }$ to establish utility in generating groundtruth.
151
+
152
+ Experiments and results We consider three scenarios: E1 Burgers’ equation without diffusion $\theta _ { \mathrm { P D E } } = \left( 1 , 0 , 0 \right)$ for shock modeling; E2 Burgers’ equation with variable diffusion $\theta _ { \mathrm { P D E } } = \left( 1 , \eta , 0 \right)$ where $0 ~ \leq ~ \eta ~ \leq ~ 0 . 2$ ; and E3 a mixed scenario with $\theta _ { \mathrm { P D E } } \ : = \ : ( \alpha , \beta , \gamma )$ where $0 . 0 ~ \leq ~ \alpha ~ \leq ~ 3 . 0 ,$ $0 . 0 \leq \beta \leq 0 . 4$ and $0 . 0 \leq \gamma \leq 1 . 0$ . E2 and E3 test the generalization capability. We compare against downsampled groundtruth (WENO5) and a variation of the Fourier Neural Operator with an autoregressive structure (FNO-RNN) used in Section 5.3 of their paper, and trained with unrolled training (see Figure 2). For our models we run the MP-PDE solver, an ablated version $( \mathbf { M P - P D E - } \theta _ { \mathrm { P D E } } )$ , without $\pmb { \theta } _ { \mathrm { P D E } }$ features, and the Fourier Neural Operator method trained using our temporal bundling and pushforward tricks (FNO-PF). Errors and runtimes for all experiments are in Table 1. We see that the MP-PDE solver outperforms WENO5 and FNO-RNN in accuracy. Temporal bundling and the pushforward trick improve FNO dramatically, to the point where it beats MP-PDE on E1. But MP-PDE outperforms FNO-PF on E2 and E3 indicating that FNO is best for single equation modeling, but MP-PDE is better at generalization. MP-PDE predictions are best if equation parameters $\pmb { \theta } _ { \mathrm { P D E } }$ are used, evidenced in E2 and E3. This effect is most pronounced for E3, where all parameters are varied. Exemplary rollout plots for E2 and E3 are in Appendix F.1. Figure 4 (TOP) shows shock formation at different resolutions (E1), a traditionally difficult phenomenon to model—FDM and PSM methods cannot model shocks. Strikingly, shocks are preserved even at very low resolution.
153
+
154
+ # 4.2 VALIDATING TEMPORAL BUNDLING AND THE PUSHFORWARD METHOD
155
+
156
+ We observe solver survival times on E1, defined as the time until the solution diverges from groundtruth. A solution $\hat { \mathbf { u } } _ { i } ^ { k }$ diverges from the groundtruth $\mathbf { u } _ { i } ^ { k }$ when its max-normalized $L _ { 1 }$ -error $\begin{array} { r } { \frac { 1 } { n _ { x } } \sum _ { i = 1 } ^ { n _ { x } } \frac { \lvert \hat { \mathbf { u } } _ { i } ^ { k } - \mathbf { u } _ { i } ^ { k } \rvert } { \operatorname* { m a x } _ { j } \lvert \mathbf { u } _ { j } ^ { k } \rvert } } \end{array}$ exceeds 0.1. The solvers are unrolled to $n _ { t } ~ = ~ 1 0 0 0$ timesteps with $T = 1 6$ s. Examples are shown in Figure 4 (BOTTOM), where we observe increasing divergence after $\sim 8$ s. This is corroborated by Figure 5a where we see survival ratio against timestep. This is in line with observed problems with autoregressive models from the literature—see Figure C.3 of SanchezGonzalez et al. (2020) or Figure S9 of Bar-Sinai et al. (2019)
157
+
158
+ In a second experiment, we compare the efficacy of the pushforward trick. Already, we saw that, coupled with temporal bundling, it improved FNO for our autoregressive tasks. In Figure 5b, we plot the survival ratios for models trained with and without the pushforward trick. As a third comparison we show a model trained with Gaussian noise adversarial perturbations, similar to that proposed in Sanchez-Gonzalez et al. (2020). We see that applying the pushforward trick leads to far higher survival times, confirming our model that instability can be addressed with adversarial training.
159
+
160
+ ![](images/d7e937393d004806d32a21fce631da090cbac5f44c1522d8b21b8b79090ce7ee.jpg)
161
+ Figure 4: TOP: Exemplary 1D rollout of shock formation at different resolutions. The different colors represent PDE solutions at different timepoints. Both the small and the large shock are neatly captured and preserved even for low resolutions; boundary conditions are perfectly modeled. BOTTOM: Exemplary long 2D rollout of shock formations over 1000 timesteps. Different colors represent PDE solutions at different space-time points.
162
+
163
+ Table 1: Error and runtime experiments targeting shock wave formation modeling and generalization to unseen equations. Runtimes are for one full unrolling over 250 timesteps on a GeForce RTX 2080 Ti GPU. FNO-PF, MP-PDE- $\theta _ { \mathrm { P D E } }$ , and MP-PDE are all ours. Accumulated error is $\begin{array} { r } { \frac { 1 } { n _ { x } } \sum _ { x , t } \mathbf { M S E } } \end{array}$ .
164
+
165
+ <table><tr><td></td><td></td><td colspan="5">Accumulated Error ↓</td><td colspan="2">Runtime [s]↓</td></tr><tr><td></td><td>(nt,nx)</td><td>WENO5</td><td>FNO-RNN</td><td>FNO-PF</td><td>MP-PDE-0PDE</td><td>MP-PDE</td><td>WENO5</td><td>MP-PDE</td></tr><tr><td>E1</td><td>(250,100)</td><td>2.02</td><td>11.93</td><td>0.54</td><td>=</td><td>1.55</td><td>1.9</td><td>0.09</td></tr><tr><td>E1</td><td>(250,50)</td><td>6.23</td><td>29.98</td><td>0.51</td><td></td><td>1.67</td><td>1.8</td><td>0.08</td></tr><tr><td>E1</td><td>(250,40)</td><td>9.63</td><td>10.44</td><td>0.57</td><td></td><td>1.47</td><td>1.7</td><td>0.08</td></tr><tr><td>E2</td><td>(250,100)</td><td>1.19</td><td>17.09</td><td>2.53</td><td>1.62</td><td>1.58</td><td>1.9</td><td>0.09</td></tr><tr><td>E2</td><td>(250,50)</td><td>5.35</td><td>3.57</td><td>2.27</td><td>1.71</td><td>1.63</td><td>1.8</td><td>0.09</td></tr><tr><td>E2</td><td>(250,40)</td><td>8.05</td><td>3.26</td><td>2.38</td><td>1.49</td><td>1.45</td><td>1.7</td><td>0.08</td></tr><tr><td>E3</td><td>(250,100)</td><td>4.71</td><td>10.16</td><td>5.69</td><td>4.71</td><td>4.26</td><td>4.8</td><td>0.09</td></tr><tr><td>E3</td><td>(250,50)</td><td>11.71</td><td>14.49</td><td>5.39</td><td>10.90</td><td>3.74</td><td>4.5</td><td>0.09</td></tr><tr><td>E3</td><td>(250,40)</td><td>15.94</td><td>20.90</td><td>5.98</td><td>7.78</td><td>3.70</td><td>4.4</td><td>0.09</td></tr></table>
166
+
167
+ ![](images/5231c41dd004a9ca39d6e071f746b9f36ba4eea4fffa1d3b1bc8ce8314186ed5.jpg)
168
+ Figure 5: Survival times at E1. Rollout for long trajectories of 8 s (left), pushforward (pf) ablation (right). The ablation compares survival times at resolutions $n _ { x } = 1 0 0$ (solid) and $n _ { x } = 5 0$ (dashed) against survival times using pushforward (no pf), no pushforward but putting Gaussian noise $\overset { \cdot } { \boldsymbol { \sigma } } =$ 0.01), pushforward but without cutting the gradients (pf gradients).
169
+
170
+ Interestingly, injecting Gaussian perturbations appears worse than using none. Closer inspection of rollouts shows that although Gaussian perturbations improve stability, they lead to lower accuracy, by nature of injecting noise into the system.
171
+
172
+ # 4.3 SOLVING ON IRREGULAR GRIDS WITH DIFFERENT BOUNDARY CONDITIONS
173
+
174
+ The underlying motives for designing this experiment are to investigate (i) how well our MP-PDE solver can operate on irregular grids and (ii) how well our MP-PDE solver can generalize over different boundary conditions. Non-periodic domains and grid sampling irregularity go hand in hand, since pseudo-spectral methods designed for closed intervals operate on non-uniform grids.
175
+
176
+ Data We consider a simple 1D wave equation
177
+
178
+ $$
179
+ \partial _ { t t } u - c ^ { 2 } \partial _ { x x } u = 0 , \qquad x \in [ - 8 , 8 ]
180
+ $$
181
+
182
+ where $c$ is wave velocity $\acute { c } = 2$ in our experiments). We consider Dirichlet $B [ u ] = u = 0$ and Neumann $B [ u ] = \partial _ { x } u = 0$ boundary conditions. This PDE is $2 ^ { \mathrm { n d } }$ -order in time, but can be rewritten as $1 ^ { \mathrm { s t } }$ -order in time, by introducing the auxilliary variable $\ v \ = \ \partial _ { t } u$ and writing $\partial _ { t } [ u , v ] - [ v , c ^ { 2 } \partial _ { x x } u ] = 0$ . The initial condition is a Gaussian pulse with peak at random location. Numerical groundtruth is generated using FVM and Chebyshev spectral derivatives, integrated in time with an implicit Runge-Kutta method of Radau IIA family, order 5 (Hairer et al., 1993). We solve for groundtruth at resolution $( n _ { t } , n _ { x } ) = ( 2 5 0 , 2 0 0 )$ on a Chebyshev extremal point grid (cell edges are located at $x _ { i } = \cos ( i \pi / ( n _ { x } + 1 ) )$ .
183
+
184
+ Experiments and results We consider three scenarios: WE1 Wave equation with Dirichlet boundary conditions; WE2 Wave equation with Neumann boundary conditions and, WE3 Arbitrary combinations of these two boundary conditions, testing generalization capability of the MP-PDE solver.
185
+
186
+ Ablation studies (marked with $\theta _ { \mathrm { P } } \delta \overline { { \mathrm { E } } } )$ have no equation specific parameters input to the MP-PDE solver. Table 2 compares our MP-PDE solver against state-of-the art numerical pseudospectral solvers. MP-PDE solvers obtain accurate results for low resolutions where pseudospectral solvers break. Interestingly, MP-PDE solvers can generalize over different boundary conditions, which gets more pronounced if boundary conditions are injected into the equation via $\theta _ { \mathrm { P D E } }$ features.
187
+
188
+ Table 2: Error and runtime comparison on tasks with non-periodic boundaries and irregular grids. Runtimes measure one full 250 timesteps unrolling on a GeForceRTX 2080 Ti GPU for MP-PDE solvers, and on a CPU for our pseudospectral (PS) solver implementation based on scipy.
189
+
190
+ <table><tr><td></td><td colspan="2">1 MSE↓(WE1) nx xt</td><td colspan="2">∑MSE↓(WE2) nx x,t</td><td colspan="2">1 ∑MSE ↓(WE3) nx x,t</td><td colspan="2">Runtime [s]↓</td></tr><tr><td>(nt,nx)</td><td>PS</td><td>MP-PDE</td><td>PS</td><td>MP-PDE</td><td>PS MP-PDEOPDE</td><td>MP-PDE</td><td>PS</td><td>MP-PDE</td></tr><tr><td>(250,100)</td><td>0.004</td><td>0.137</td><td>0.004</td><td>0.111</td><td>0.004</td><td>38.775 0.097</td><td>0.60</td><td>0.09</td></tr><tr><td>(250,50)</td><td>0.450</td><td>0.035</td><td>0.681</td><td>0.034</td><td>0.610</td><td>20.445</td><td>0.106 0.35</td><td>0.09</td></tr><tr><td>(250,40)</td><td>194.622</td><td>0.042</td><td>217.300</td><td>0.003</td><td>204.298</td><td>16.859</td><td>0.219 0.25</td><td>0.09</td></tr><tr><td>(250,20)</td><td>breaks</td><td>0.059</td><td>breaks</td><td>0.007</td><td>breaks</td><td>17.591</td><td>0.379 0.20</td><td>0.07</td></tr></table>
191
+
192
+ # 4.4 2D EXPERIMENTS
193
+
194
+ We finally test the scalability of our MP-PDE solver to a higher number of spatial dimensions, more specifically to 2D experiments. We use data from PHIFLOW1, an open-source fluid simulation toolkit. We look at fluid simulation based on the Navier-Stokes equations, and simulate smoke inflow into a $3 2 \times 3 2$ grid, adding more smoke after every time step which follows the buoyancy force. Dynamics can be described by semi-Lagrangian advection for the velocity and MacCormack advection for the smoke distribution. Simulations run for 100 timesteps where one timestep corresponds to one second. Smoke inflow locations are sampled randomly. Architectural details are in Appendix F. Figure 12 in the appendix shows results of the MP-PDE solver and comparisons to the groundtruth simulation. The MP-PDE solver is able to capture the smoke inflow accurately over the given time period, suggesting scalability of MP-PDE solver to higher dimensions.
195
+
196
+ # 5 CONCLUSION
197
+
198
+ We have introduced a fully neural MP-PDE solver, which representationally contains classical methods, such as the FDM, FVM, and WENO schemes. We have diagnosed the distribution shift problem and introduced the pushforward trick combined with the idea of temporal bundling trying to alleviate it. We showed that these tricks reduce error explosion observed in training autoregressive models, including a SOTA neural operator method (Li et al., 2020a). We also demonstrated that MP-PDE solvers offer flexibility when generalizing across spatial resolution, timescale, domain sampling regularity, domain topology and geometry, boundary conditions, dimensionality, and solution space smoothness. In doing so, MP-PDE solvers are much faster than SOTA numerical solvers.
199
+
200
+ MP-PDE solvers cannot only be used to predict the solution of PDEs, but can e.g. also be reinterpreted to optimize the integration grid and the parameters of the PDE. For the former, simply position updates need to be included in the processor, similar to Satorras et al. (2021). For the latter, a trained MP-PDE solver can be fitted to new data where only $\theta _ { \mathrm { P D E } }$ features are adjusted. A limitation of our model is that we require high quality groundtruth data to train. Indeed generating this data in the first place was actually the toughest part of the whole project. However, this is a limitation of most neural PDE solvers in the literature. Another limitation is the lack of accuracy guarantees typical solvers have been designed to output. This is a common criticism of such learned numerical methods. A potential fix would be to fuse this work with that in probabilistic numerics (Hennig et al., 2015), as has been done for RK4 solvers (Schober et al., 2014). Another promising follow-up direction is to research alternative adversarial-style losses as introduced in Equation 7. Finally, we remark that leveraging symmetries and thus fostering generalization is a very active field of research, which is especially appealing for building neural PDE solvers since every PDE is defined via a unique set of symmetries (Olver, 1986).
201
+
202
+ # 6 REPRODUCIBILITY STATEMENT
203
+
204
+ All data used in this work is generated by ourselves. It is thus of great importance to make sure that the produced datasets are correct. We therefore spend an extensive amount of time cross-checking our produced datasets. For experiments E1, E2, E3, this is done by comparing the WENO scheme to analytical solutions as discussed in detail in Appendix Section C.3, where we compare our implemented WENO scheme against two analytical solutions of the Burgers equation from literature. For experiments W1, W2, W3, we cross-checked if Gaussian wave packages keep their form throughout the whole wave propagation phase. Furthermore, the wave packages should change sign for Dirichlet boundary conditions and keep the sign for Neumann boundary conditions. Examples can be found in Appendix Section D.
205
+
206
+ We have described our architecture in Section 3.2 and provided further implementation details in Appendix Section F. We have introduced new concepts, namely temporal bundling and the pushforward method. We have described these concepts at length in our paper. We have validated temporal bundling and pushforward methods on both our and the Fourier Neural Operator (FNO) method Li et al. (2020a). We have not introduced new mathematical results. However, we have used data generation concepts from different mathematical fields and therefore have included a detailed description of those in our appendix.
207
+
208
+ For reproducibility, we provide our at https://github.com/brandstetter-johannes/MP-Neural-PDESolvers.
209
+
210
+ # 7 ETHICAL STATEMENT
211
+
212
+ The societal impact of MP-PDE solvers is difficult to predict. However, as stated in the introduction, solving differential equations is of huge importance for problems in many disciplines such as weather forecasting, astronomical simulations, or molecular modeling. As such, MP-PDE solvers potentially help to pave the way towards shortcuts for computationally expensive simulations. Most notably, a drastical computational shortcut is always somehow related to reducing the carbon footprint. However, in this regard, it is also important to remind ourselves that relying on simulations or now even shortcuts of those always requires monitoring and thorough quality checks.
213
+
214
+ # ACKNOWLEDGMENTS
215
+
216
+ Johannes Brandstetter thanks the Institute of Advanced Research in Artificial Intelligence (IARAI) and the Federal State Upper Austria for the support. The authors thank Markus Holzleitner for helpful comments on this work.
217
+
218
+ # REFERENCES
219
+
220
+ Douglas N Arnold. Stability, consistency, and convergence of numerical discretizations. 2015.
221
+
222
+ Michael Athanasopoulos, Hassan Ugail, and Gabriela Gonzalez. Parametric design of aircraft geometry using partial differential equations. Advances in Engineering Software, 40, 2009.
223
+
224
+ Yohai Bar-Sinai, Stephan Hoyer, Jason Hickey, and Michael P. Brenner. Learning data-driven discretizations for partial differential equations. Proceedings of the National Academy of Sciences, 116(31):15344–15349, Jul 2019. ISSN 1091-6490. doi: 10.1073/pnas.1814058116.
225
+
226
+ Soren Bartels. ¨ Numerical Approximation of Partial Differential Equations. Springer, 2016.
227
+
228
+ Claude Basdevant, Michel Deville, Pierre Haldenwang, Jean Lacroix, Jalil Ouazzani, R. Peyret, Paolo Orlandi, and Patera A.T. Spectral and finite difference solutions of the burgers equation. Computers and Fluids, 14(1):23–41, 1986.
229
+
230
+ Peter W. Battaglia, Jessica B. Hamrick, Victor Bapst, Alvaro Sanchez-Gonzalez, Vinicius Zambaldi, Mateusz Malinowski, Andrea Tacchetti, David Raposo, Adam Santoro, Ryan Faulkner, Caglar Gulcehre, Francis Song, Andrew Ballard, Justin Gilmer, George Dahl, Ashish Vaswani, Kelsey Allen, Charles Nash, Victoria Langston, Chris Dyer, Nicolas Heess, Daan Wierstra, Pushmeet Kohli, Matt Botvinick, Oriol Vinyals, Yujia Li, and Razvan Pascanu. Relational inductive biases, deep learning, and graph networks. arXiv preprint arXiv:1806.01261, 2018.
231
+
232
+ Saakaar Bhatnagar, Yaser Afshar, Shaowu Pan, Karthik Duraisamy, and Shailendra Kaushik. Prediction of aerodynamic flow fields using convolutional neural networks. Computational Mechanics, 64(2):525–545, Jun 2019.
233
+
234
+ Kaushik Bhattacharya, Bamdad Hosseini, Nikola B. Kovachki, and Andrew M. Stuart. Model reduction and neural networks for parametric pdes, 2021.
235
+
236
+ Johannes Brandstetter, Rob Hesselink, Elise van der Pol, Erik Bekkers, and Max Welling. Geometric and physical quantities improve e(3) equivariant message passing. arXiv preprint arXiv:2110.02905, 2021.
237
+
238
+ John Charles Butcher. Coefficients for the study of runge-kutta integration processes. Journal of the Australian Mathematical Society, 3(2):185–201, 1963.
239
+
240
+ John Charles Butcher. The numerical analysis of ordinary differential equations: Runge-Kutta and general linear methods. Wiley-Interscience, 1987.
241
+
242
+ Djork-Arne Clevert, Thomas Unterthiner, and Sepp Hochreiter. Fast and accurate deep network´ learning by exponential linear units (elus). In International Conference on Learning Representations (ICLR), 2016.
243
+
244
+ Richard Courant, Kurt Otto Friedrichs, and Hans Lewy. On the partial difference equations of mathematical physics. IBM J. Res. Dev., 11(2):215–234, 1967. ISSN 0018-8646.
245
+
246
+ Filipe De Avila Belbute-Peres, Thomas Economon, and Zico Kolter. Combining differentiable PDE solvers and graph neural networks for fluid flow prediction. In Hal Daume III and Aarti Singh ´ (eds.), Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 2402–2411. PMLR, 13–18 Jul 2020.
247
+
248
+ Michael Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on ¨ graphs with fast localized spectral filtering. In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 29. Curran Associates, Inc., 2016.
249
+
250
+ Edgar Everhart. An efficient integrator that uses gauss-radau spacings. International Astronomical Union Colloquium, 83:185–202, 1985.
251
+
252
+ Victor Garcia Satorras, Zeynep Akata, and Max Welling. Combining generative and discriminative models for hybrid inference. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d’Alche Buc, ´ E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems 32, pp. 13802– 13812. Curran Associates, Inc., 2019.
253
+
254
+ 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.
255
+
256
+ Jonathan Godwin, Michael Schaarschmidt, Alexander Gaunt, Alvaro Sanchez-Gonzalez, Yulia Rubanova, Petar Velickovic, James Kirkpatrick, and Peter W. Battaglia. Very deep graph neural networks via noise regularisation. arXiv preprint arXiv:2106.07971.
257
+
258
+ Daniel Greenfeld, Meirav Galun, Ronen Basri, Irad Yavneh, and Ron Kimmel. Learning to optimize multigrid PDE solvers. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, pp. 2415–2423, 2019.
259
+
260
+ Xiaoxiao Guo, Wei Li, and Francesco Iorio. Convolutional neural networks for steady flow approximation. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD ’16, pp. 481–490. Association for Computing Machinery, 2016.
261
+
262
+ Ernst Hairer, Syvert Nørsett, and Gerhard Wanner. Solving Ordinary Differential Equations I (2nd Revised. Ed.): Nonstiff Problems. Springer-Verlag, Berlin, Heidelberg, 1993. ISBN 0387566708.
263
+
264
+ Philipp Hennig, Michael A. Osborne, and Mark Girolami. Probabilistic numerics and uncertainty in computations. Proceedings of the Royal Society A: Mathematical, Physical and Engineering Sciences, 471(2179):20150142, Jul 2015. ISSN 1471-2946. doi: 10.1098/rspa.2015.0142. URL http://dx.doi.org/10.1098/rspa.2015.0142.
265
+
266
+ Jun-Ting Hsieh, Shengjia Zhao, Stephan Eismann, Lucia Mirabella, and Stefano Ermon. Learning neural PDE solvers with convergence guarantees. arXiv preprint arXiv:1906.01200, 2019.
267
+
268
+ Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International conference on machine learning, pp. 448–456. PMLR, 2015.
269
+
270
+ Guang-Shan Jiang and Chi-Wang Shu. Efficient implementation of weighted eno schemes. Journal of Computational Physics, 126(1):202 – 228, 1996. ISSN 0021-9991.
271
+
272
+ Yuehaw Khoo, Jianfeng Lu, and Lexing Ying. Solving parametric pde problems with artificial neural networks. European Journal of Applied Mathematics, 32(3):421–435, Jul 2020. ISSN 1469-4425.
273
+
274
+ Thomas N. Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In International Conference on Learning Representations (ICLR), 2017.
275
+
276
+ Wilhelm Kutta. Beitrag zur naherungsweisen integration totaler differentialgleichungen. ¨ Zeitschrift fur Mathematik und Physik¨ , 46:435 – 453, 1901.
277
+
278
+ Tony Lelievre and Gabriel Stoltz. Partial differential equations and stochastic methods in molecular \` dynamics. Acta Numerica, 25:681–880, 2016.
279
+
280
+ Zongyi Li, Nikola Kovachki, Kamyar Azizzadenesheli, Burigede Liu, Kaushik Bhattacharya, Andrew Stuart, and Anima Anandkumar. Fourier neural operator for parametric partial differential equations. arXiv preprint arXiv:2010.08895, 2020a.
281
+
282
+ Zongyi Li, Nikola Kovachki, Kamyar Azizzadenesheli, Burigede Liu, Kaushik Bhattacharya, Andrew Stuart, and Anima Anandkumar. Multipole graph neural operator for parametric partial differential equations. arXiv preprint arXiv:2006.09535, 2020b.
283
+
284
+ Zongyi Li, Nikola Kovachki, Kamyar Azizzadenesheli, Burigede Liu, Kaushik Bhattacharya, Andrew Stuart, and Anima Anandkumar. Neural operator: Graph kernel network for partial differential equations. arXiv preprint arXiv:2003.03485, 2020c.
285
+
286
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
287
+
288
+ Peter Lynch. The origins of computer weather prediction and climate modeling. Journal of computational physics, 227(7):3431–3444, 2008.
289
+
290
+ Andreas Mayr, Sebastian Lehner, Arno Mayrhofer, Christoph Kloss, Sepp Hochreiter, and Johannes Brandstetter. Boundary graph neural networks for 3d simulations. arXiv preprint arXiv:2106.11299, 2021.
291
+
292
+ Peter J Olver. Introduction to partial differential equations. Springer, 2014.
293
+
294
+ P.J. Olver. Symmetry groups of differential equations. In Applications of Lie Groups to Differential Equations, pp. 77–185. Springer, 1986.
295
+
296
+ Ravi G. Patel, Nathaniel A. Trask, Mitchell A. Wood, and Eric C. Cyr. A physics-informed operator regression framework for extracting data-driven continuum models. Computer Methods in Applied Mechanics and Engineering, 373:113500, Jan 2021. ISSN 0045-7825.
297
+
298
+ Maziar Raissi. Deep hidden physics models: Deep learning of nonlinear partial differential equations. J. Mach. Learn. Res., 19:25:1–25:24, 2018.
299
+
300
+ Prajit Ramachandran, Barret Zoph, and Quoc V. Le. Searching for activation functions. arXiv preprint arXiv:1710.05941, 2017.
301
+
302
+ Carl Runge. Uber die numerische aufl ¨ osung von differentialgleichungen. ¨ Mathematische Annalen, 46:167 – 178, 1895.
303
+
304
+ Alvaro Sanchez-Gonzalez, Jonathan Godwin, Tobias Pfaff, Rex Ying, Jure Leskovec, and Peter W. Battaglia. Learning to simulate complex physics with graph networks. arXiv preprint arXiv:2002.09405, 2020.
305
+
306
+ Victor Garcia Satorras, Emiel Hoogeboom, and Max Welling. E (n) equivariant graph neural networks. arXiv preprint arXiv:2102.09844, 2021.
307
+
308
+ Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE Transactions on Neural Networks, 20(1):61–80, 2009.
309
+
310
+ William E Schiesser. The numerical method of lines: integration of partial differential equations. Elsevier, 2012.
311
+
312
+ Michael Schober, David Duvenaud, and Philipp Hennig. Probabilistic ode solvers with runge-kutta means, 2014.
313
+
314
+ C.-W. Shu. High-order finite difference and finite volume weno schemes and discontinuous galerkin methods for cfd. International Journal of Computational Fluid Dynamics, 17(2):107–118, 2003.
315
+
316
+ Justin Sirignano and Konstantinos Spiliopoulos. Dgm: A deep learning algorithm for solving partial differential equations. Journal of Computational Physics, 375:1339 – 1364, 2018. ISSN 0021- 9991. doi: https://doi.org/10.1016/j.jcp.2018.08.029.
317
+
318
+ Eitan Tadmor. The exponential accuracy of fourier and chebyshev differencing methods. SIAM Journal on Numerical Analysis, 23:1–10, 1986.
319
+
320
+ Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Instance normalization: The missing ingredient for fast stylization. arXiv preprint arXiv:1607.08022, 2016.
321
+
322
+ Yinhao Zhu and Nicholas Zabaras. Bayesian deep convolutional encoder–decoder networks for surrogate modeling and uncertainty quantification. Journal of Computational Physics, 366:415–447, Aug 2018. ISSN 0021-9991.
323
+
324
+ # A INTERPOLATION
325
+
326
+ To compute classical numerical derivatives of a function $u : \mathbb { R } \mathbb { R }$ , which has been sampled on a mesh of points $x _ { 1 } < x _ { 2 } < . . . < x _ { N }$ it is common to first fit a piecewise polynomial $p : \mathbb { R } \mathbb { R }$ on the mesh. We assume we have function evaluations $u _ { i } = u ( x _ { i } )$ at the mesh nodes for all $i = 1 , . . . , N$ and once we have fitted the polynomial, we can use its derivatives at any new off-mesh point, for instance the half nodes $x _ { i + { \frac { 1 } { 2 } } }$ . Here we illustrate how to carry out this procedure.
327
+
328
+ A polynomial of degree $N - 1$ (note the highest degree polynomial we can fit to $N$ points has degree $N - 1 )$ can be fitted at the mesh points by solving the following linear system in a
329
+
330
+ $$
331
+ \underbrace { \left[ \begin{array} { c } { u _ { 1 } } \\ { \vdots } \\ { u _ { N } } \\ { \mathbf { u } } \end{array} \right] } _ { \mathbf { u } } = \underbrace { \left[ \begin{array} { c } { p ( x _ { 1 } ) } \\ { \vdots } \\ { p ( x _ { N } ) } \end{array} \right] } _ { \mathbf { u } } = \underbrace { \left[ \begin{array} { c } { \sum _ { i = 0 } ^ { N - 1 } a _ { i } x _ { 1 } ^ { i } } \\ { \vdots } \\ { \sum _ { i = 0 } ^ { N - 1 } a _ { i } x _ { N } ^ { i } } \end{array} \right] } _ { \mathbf { L } } = \underbrace { \left[ \begin{array} { c c c c } { x _ { 1 } ^ { 0 } } & { \cdots } & { x _ { 1 } ^ { N - 1 } } \\ { \vdots } & { \ddots } & { \vdots } \\ { x _ { N } ^ { 0 } } & { \cdots } & { x _ { N } ^ { N - 1 } } \end{array} \right] } _ { \mathbf { X } } \underbrace { \left[ \begin{array} { c } { a _ { 0 } } \\ { \vdots } \\ { a _ { N - 1 } } \end{array} \right] } _ { \mathbf { a } } .
332
+ $$
333
+
334
+ To find the polynomial interpolation at a new point $x$ , we then do
335
+
336
+ $$
337
+ p ( x ) = \mathbf { x } ^ { \top } \mathbf { a } = \mathbf { x } ^ { \top } \mathbf { X } ^ { - 1 } \mathbf { u }
338
+ $$
339
+
340
+ where $\mathbf { x } ^ { \top } = [ 1 , x , x ^ { 2 } , . . . , x ^ { N - 1 } ]$ . To retrieve the $m ^ { \mathrm { t h } }$ derivative, where $m < N - 1$ , is also very simple. For this we have that
341
+
342
+ $$
343
+ \begin{array} { r l } & { \frac { \mathrm { d } ^ { m } p } { \mathrm { d } x ^ { m } } = \displaystyle \sum _ { i = 0 } ^ { N - 1 } a _ { i } \frac { \mathrm { d } ^ { m } x ^ { i } } { \mathrm { d } x ^ { m } } = \displaystyle \sum _ { i = 0 } ^ { N - 1 } a _ { i } \cdot ( i ) _ { m } \cdot x ^ { i - m } = \mathbf { x } ^ { ( m ) \top } \mathbf { a } = \mathbf { x } ^ { ( m ) \top } \mathbf { X } ^ { - 1 } \mathbf { u } , } \\ & { \mathbf { x } ^ { ( m ) \top } = [ ( 0 ) _ { m } x ^ { 0 - m } , ( 1 ) _ { m } x ^ { 1 - m } , . . . , ( N - 1 ) _ { m } x ^ { N - 1 - m } ] } \end{array}
344
+ $$
345
+
346
+ where $( i ) _ { m } = i ( i - 1 ) ( i - 2 ) \cdots ( i - m + 1 )$ is the $m ^ { \mathrm { t h } }$ Pochhammer symbol and $( i ) _ { 0 } : = 1$ .
347
+
348
+ Note that is typical to fold $\mathbf { s } = \mathbf { x } ^ { \top } \mathbf { X } ^ { - 1 }$ into a single object, which we call a stencil.
349
+
350
+ # B RECONSTRUCTION
351
+
352
+ Reconstruction is the task of fitting a piecewise polynomial on a mesh of points, when instead of functions values at the grid points we have cell averages $\bar { u } _ { i }$ , where
353
+
354
+ $$
355
+ \bar { u } _ { i } = \frac { 1 } { \Delta x _ { i } } \int _ { I _ { i } } u ( \boldsymbol { x } ) \mathrm { d } \boldsymbol { x } ,
356
+ $$
357
+
358
+ where each cell $I _ { i } ~ = ~ [ x _ { i - \frac { 1 } { 2 } } , x _ { i + \frac { 1 } { 2 } } ]$ , the half nodes are defined as $x _ { i + \frac 1 2 } : = \frac 1 2 ( x _ { i } + x _ { i + 1 } )$ and $\Delta x _ { i } = x _ { i + \frac { 1 } { 2 } } - x _ { i - \frac { 1 } { 2 } }$ . The solution is to note that we can fit a polynomial $P ( x )$ to the integral of $u ( x )$ , which will be exact at the half nodes, so
359
+
360
+ $$
361
+ P ( x _ { i + \frac { 1 } { 2 } } ) = U ( x _ { i + \frac { 1 } { 2 } } ) = \int _ { x _ { 1 - \frac { 1 } { 2 } } } ^ { x _ { i + \frac { 1 } { 2 } } } u ( x ) \mathrm { d } x = \sum _ { k = 1 } ^ { i } \int _ { x _ { k - \frac { 1 } { 2 } } } ^ { x _ { k + \frac { 1 } { 2 } } } u ( x ) \mathrm { d } x = \sum _ { k = 1 } ^ { i } \bar { u } _ { k } \Delta x _ { k } .
362
+ $$
363
+
364
+ We can then differentiate this polynomial to retrieve an estimate for the $u$ at off-mesh locations. Recall that polynomial differentiation is easy with the interpolant differentiation operators $\mathbf { x } ^ { ( m ) }$ The system of equations we need to solve is thus
365
+
366
+ $$
367
+ \underbrace { \left[ \Delta x _ { 1 } \cdots \cdots \quad 0 \ \right. } _ { \vdots } \cdot \underbrace { \left[ \bar { u } _ { 1 } \right] } _ { \mathbf { \dot { u } } } = \underbrace { \left[ x _ { 1 } ^ { 0 } \cdots \quad x _ { 1 } ^ { N - 1 } \right] } _ { \mathbf { \dot { x } } } \underbrace { \left[ \begin{array} { c c c c } { a _ { 0 } } \\ { \vdots } \\ { a _ { x 1 } } \end{array} \right] } _ { \mathbf { \dot { L } } } . \underbrace { \dot { \mathbf { \sigma } } _ { \langle } \mathbf { \dot { \sigma } _ { \langle } \Phi _ { N \rangle } } } _ { \mathbf { \dot { u } } } = \underbrace { \left[ \begin{array} { c c c c } { a _ { 1 } ^ { 0 } } & { \cdots } & { x _ { 1 } ^ { N - 1 } } \\ { \vdots } & { \ddots } & { \vdots } \\ { x _ { N } ^ { 0 } } & { \cdots } & { x _ { N } ^ { N - 1 } } \end{array} \right] } _ { \mathbf { \dot { x } } } \underbrace { \left[ \begin{array} { c } { a _ { 0 } } \\ { \vdots } \\ { a _ { N - 1 } } \\ { \mathbf { \dot { a } } } \end{array} \right] } _ { \mathbf { \dot { a } } } .
368
+ $$
369
+
370
+ where $\bar { \bf u }$ is the vector of cell averages and $\mathbf { L }$ is a lower triangular matrix performing the last sum in Equation 20. Thus the $m ^ { \mathrm { t h } }$ derivative of the polynomial $p ( x ) = P ^ { \prime } ( x )$ is
371
+
372
+ $$
373
+ \frac { \mathrm { d } ^ { m } p } { \mathrm { d } x ^ { m } } = \frac { \mathrm { d } ^ { m + 1 } P } { \mathrm { d } x ^ { m + 1 } } = \mathbf { x } ^ { ( m + 1 ) \top } \mathbf { X } ^ { - 1 } \mathbf { L } \bar { \mathbf { u } } = \bar { \mathbf { s } } ^ { ( m ) \top } \bar { \mathbf { u } } .
374
+ $$
375
+
376
+ # C WENO SCHEME
377
+
378
+ The essentially non-oscillating (ENO) scheme is an interpolation or reconstruction scheme to estimate function values and derivatives of a discontinuous function. The main idea is to use multiple overlapping stencils to estimate a derivative at point $x \in [ x _ { i } , x _ { i + 1 } ]$ . We design $N$ stencils to fit the function on shifted overlapping intervals $I _ { 1 } , . . . , I _ { N }$ , where $I _ { k } = [ x _ { i - N + 1 + k } , x _ { i + k } ]$ . In the case of WENO reconstruction these intervals are ${ { I } _ { k } } = [ { { x } _ { i - N + 1 + k - \frac { 1 } { 2 } } } , { { x } _ { i + k + \frac { 1 } { 2 } } } ]$ . If a discontinuity lies in $\textstyle I = \bigcup _ { k } I _ { k }$ , then it is likely that one of the substencils $\mathbf { s } _ { k } ^ { ( m ) }$ or ¯sk $\bar { \mathbf { s } } _ { k } ^ { ( m ) }$ (defined on interval $I _ { k }$ ) will not contain the discontinuity. We can thus use the substencil $\mathbf { s } _ { k } ^ { ( m ) }$ or $\bar { \mathbf { s } } _ { k } ^ { ( m ) }$ from the relatively smooth region to estimate the function derivatives at . In the following, we focus on WENO reconstruction.
379
+
380
+ The weighted essentially non-oscillating (WENO) scheme goes one step further and takes a convex combination of the substencils to create a larger stencil ¯s on $I$ , where (dropping the superscript for brevity)
381
+
382
+ $$
383
+ \bar { \mathbf { s } } = \sum _ { k = 1 } ^ { N } w _ { k } \bar { \mathbf { s } } _ { k } .
384
+ $$
385
+
386
+ Here the nonlinear weights nonlinear weights can be c $w _ { k }$ satisfy ructed $\begin{array} { r } { \sum _ { k = 1 } ^ { N } w _ { k } = 1 } \end{array}$ . It was shown in Jiang & Shu (1996) that these
387
+
388
+ $$
389
+ w _ { k } = \frac { \tilde { w } _ { k } } { \sum _ { j = 1 } ^ { N } \tilde { w } _ { j } } \qquad \tilde { w } _ { k } = \frac { \gamma _ { k } } { ( \epsilon + \beta _ { k } ) ^ { 2 } } ,
390
+ $$
391
+
392
+ wherlinear $\gamma _ { k }$ alled the linear weight, are set such that the su $\epsilon$ i mber, and over the o $\beta _ { k }$ ir moothness indicator. The stencils matches a larger $\scriptstyle \sum _ { k = 1 } ^ { N } \gamma _ { k } \bar { \mathbf { s } } _ { k }$ $N - 1$ $2 N - 2$
393
+
394
+ $$
395
+ \beta _ { k } = \sum _ { m = 1 } ^ { N - 1 } \Delta x _ { k } ^ { 2 m - 1 } \int _ { x _ { i - \frac { 1 } { 2 } } } ^ { x _ { i + \frac { 1 } { 2 } } } \left( \frac { \mathrm { d } ^ { m } p _ { k } } { \mathrm { d } x ^ { m } } \right) ^ { 2 } \mathrm { d } x ,
396
+ $$
397
+
398
+ where $p _ { k }$ is the polynomial corresponding to substencil $\bar { \bf s } _ { k }$ .
399
+
400
+ # C.1 WENO5 SCHEME
401
+
402
+ A conservative finite difference spatial discretization approximates a derivative $f ( u ) _ { x }$ by a conservative difference
403
+
404
+ $$
405
+ f ( u ) _ { x } | _ { x = x _ { i } } \approx \frac { 1 } { \Delta x } \left( \hat { f } _ { i + \frac { 1 } { 2 } } - \hat { f } _ { i - \frac { 1 } { 2 } } \right) ,
406
+ $$
407
+
408
+ where $\hat { f } _ { i + \frac { 1 } { 2 } }$ and $\hat { f } _ { i - \frac { 1 } { 2 } }$ are numerical fluxes. Since $g ( u ) _ { y }$ is approximated in the same way, finite difference methods have the same format for more than one spatial dimensions. The leftreconstructed (reconstruction is done from left to right) fifth order finite difference WENO scheme (WENO5) (Shu, 2003) has the uˆ−i+ 1 g iven by:
409
+
410
+ $$
411
+ \hat { u } _ { i + \frac { 1 } { 2 } } ^ { - } = w _ { 1 } \hat { u } _ { i + \frac { 1 } { 2 } } ^ { - ( 1 ) } + w _ { 2 } \hat { u } _ { i + \frac { 1 } { 2 } } ^ { - ( 2 ) } + w _ { 3 } \hat { u } _ { i + \frac { 1 } { 2 } } ^ { - ( 3 ) } .
412
+ $$
413
+
414
+ In equation 27, $\hat { u } _ { i + \frac { 1 } { 2 } } ^ { - ( j ) }$ are the left WENO reconstructions on three different stencils given by
415
+
416
+ $$
417
+ \begin{array} { l } { { \hat { u } _ { i + \frac { 1 } { 2 } } ^ { - ( 1 ) } = + \displaystyle { \frac { 1 } { 3 } } u _ { i - 2 } - \frac { 7 } { 6 } u _ { i - 1 } + \frac { 1 1 } { 6 } u _ { i } \ : , } } \\ { { \hat { u } _ { i + \frac { 1 } { 2 } } ^ { - ( 2 ) } = - \displaystyle { \frac { 1 } { 6 } } u _ { i - 1 } + \frac { 5 } { 6 } u _ { i } + \frac { 1 } { 3 } u _ { i + 1 } \ : , } } \\ { { \hat { u } _ { i + \frac { 1 } { 2 } } ^ { - ( 3 ) } = + \displaystyle { \frac { 1 } { 3 } } u _ { i } + \frac { 5 } { 6 } u _ { i + 1 } - \frac { 1 } { 6 } u _ { i + 2 } \ : , } } \end{array}
418
+ $$
419
+
420
+ and the non-linear weights $w _ { j }$ given by
421
+
422
+ $$
423
+ w _ { j } = \frac { \tilde { w } _ { j } } { \sum _ { k = 1 } ^ { 3 } w _ { k } } , \qquad \tilde { w } _ { k } = \frac { \gamma _ { k } } { ( \epsilon + \beta _ { k } ) ^ { 2 } } ,
424
+ $$
425
+
426
+ with $\gamma _ { \{ 1 , 2 , 3 \} } = \{ \scriptstyle { \frac { 1 } { 1 0 } } , \displaystyle { \frac { 3 } { 5 } } , \displaystyle { \frac { 3 } { 1 0 } } \}$ , and $\epsilon$ a tiny-valued parameter to avoid the denominator becoming 0. The left smoothness indicators $\beta _ { k } ^ { - }$ are given by:
427
+
428
+ $$
429
+ \begin{array} { l } { \displaystyle \beta _ { 1 } ^ { - } = \frac { 1 3 } { 1 2 } \big ( u _ { i - 2 } - 2 u _ { i - 1 } + u _ { i } \big ) ^ { 2 } + \frac { 1 } { 4 } \big ( u _ { i - 2 } - 4 u _ { i - 1 } + 3 u _ { i } \big ) ^ { 2 } , } \\ { \displaystyle \beta _ { 2 } ^ { - } = \frac { 1 3 } { 1 2 } \big ( u _ { i - 1 } - 2 u _ { i } + u _ { i + 1 } \big ) ^ { 2 } + \frac { 1 } { 4 } \big ( u _ { i - 1 } - u _ { i + 1 } \big ) ^ { 2 } , } \\ { \displaystyle \beta _ { 3 } ^ { - } = \frac { 1 3 } { 1 2 } \big ( u _ { i } - 2 u _ { i + 1 } + u _ { i + 2 } \big ) ^ { 2 } + \frac { 1 } { 4 } \big ( u _ { i } - 4 u _ { i + 1 } + 3 u _ { i + 2 } \big ) ^ { 2 } . } \end{array}
430
+ $$
431
+
432
+ The right-reconstructed WENO5 scheme has the $\hat { u } _ { i - \frac { 1 } { 2 } } ^ { + }$ given similarly to $\hat { u } _ { i + \frac { 1 } { 2 } } ^ { - }$ but with all coefficients flipped since the reconstruction is done from the other side (from right to left). The right reconstruction on three different stencils are given by
433
+
434
+ $$
435
+ \begin{array} { l } { { \hat { u } _ { i - \frac { 1 } { 2 } } ^ { + ( 1 ) } = + \displaystyle \frac { 1 } { 3 } u _ { i + 2 } - \frac { 7 } { 6 } u _ { i + 1 } + \frac { 1 1 } { 6 } u _ { i } \ : , } } \\ { { \hat { u } _ { i - \frac { 1 } { 2 } } ^ { + ( 2 ) } = - \displaystyle \frac { 1 } { 6 } u _ { i + 1 } + \frac { 5 } { 6 } u _ { i } + \frac { 1 } { 3 } u _ { i - 1 } \ : , } } \\ { { \hat { u } _ { i - \frac { 1 } { 2 } } ^ { + ( 3 ) } = + \displaystyle \frac { 1 } { 3 } u _ { i } + \frac { 5 } { 6 } u _ { i - 1 } - \frac { 1 } { 6 } u _ { i - 2 } \ : , } } \end{array}
436
+ $$
437
+
438
+ and the right smoothness indicators $\beta _ { k } ^ { + }$ are given by
439
+
440
+ $$
441
+ \begin{array} { l } { \displaystyle \beta _ { 1 } ^ { + } = \frac { 1 3 } { 1 2 } \big ( u _ { i + 2 } - 2 u _ { i + 1 } + u _ { i } \big ) ^ { 2 } + \frac { 1 } { 4 } \big ( u _ { i + 2 } - 4 u _ { i + 1 } + 3 u _ { i } \big ) ^ { 2 } , } \\ { \displaystyle \beta _ { 2 } ^ { + } = \frac { 1 3 } { 1 2 } \big ( u _ { i + 1 } - 2 u _ { i } + u _ { i - 1 } \big ) ^ { 2 } + \frac { 1 } { 4 } \big ( u _ { i + 1 } - u _ { i - 1 } \big ) ^ { 2 } , } \\ { \displaystyle \beta _ { 3 } ^ { + } = \frac { 1 3 } { 1 2 } \big ( u _ { i } - 2 u _ { i - 1 } + u _ { i - 2 } \big ) ^ { 2 } + \frac { 1 } { 4 } \big ( u _ { i } - 4 u _ { i - 1 } + 3 u _ { i - 2 } \big ) ^ { 2 } . } \end{array}
442
+ $$
443
+
444
+ Both $\hat { u } ^ { - }$ and $\hat { u } ^ { + }$ are needed for full flux reconstruction as explained in the next section.
445
+
446
+ # C.2 FLUX RECONSTRUCTION
447
+
448
+ We consider flux reconstruction via Godunov. For Godunov flux, ${ \hat { f } } _ { i + \frac { 1 } { 2 } } = { \hat { f } } ( u _ { i + \frac { 1 } { 2 } } )$ is reconstructed from uˆ+i+ 12 and uˆ−i+ 1 via:
449
+
450
+ $$
451
+ \widehat f ( u _ { i + \frac { 1 } { 2 } } ) = \left\{ \begin{array} { c c } { \operatorname* { m i n } _ { i + \frac { 1 } { 2 } \leq u \leq u _ { i + \frac { 1 } { 2 } } ^ { + } } f ( u ) , } & { \mathrm { i f } u _ { i + \frac { 1 } { 2 } } ^ { - } \leq u _ { i + \frac { 1 } { 2 } } ^ { + } } \\ { \operatorname* { m a x } _ { \substack { i + \frac { 1 } { 2 } \leq u \leq u _ { i + \frac { 1 } { 2 } } ^ { + } } } f ( u ) , } & { \mathrm { i f } u _ { i + \frac { 1 } { 2 } } ^ { - } > u _ { i + \frac { 1 } { 2 } } ^ { + } } \end{array} \right.
452
+ $$
453
+
454
+ C.3 COMPARING WENO SCHEME TO ANALYTICAL SOLUTIONS
455
+
456
+ First analytical case. An analytical solvable case for Burgers equation arises for the boundary conditions
457
+
458
+ $$
459
+ u ( t , 0 ) = u ( t , 2 \pi ) ,
460
+ $$
461
+
462
+ and the initial conditions
463
+
464
+ $$
465
+ u ( 0 , x ) = - 2 \nu \frac { \partial \phi / \partial x } { \phi } + 4 ,
466
+ $$
467
+
468
+ where
469
+
470
+ $$
471
+ \begin{array} { c } { { \phi = \displaystyle \exp \left( \frac { - x ^ { 2 } } { 4 \nu } \right) + \exp \left[ \frac { - ( x - 2 \pi ) ^ { 2 } } { 4 \nu ( t + 1 ) } \right] } } \\ { { \displaystyle \frac { \partial \phi } { \partial x } = - \frac { 2 x } { 4 \nu } \exp \left( \frac { - x ^ { 2 } } { 4 \nu } \right) - \frac { 2 ( x - 2 \pi ) } { 4 \nu } + \exp \left[ \frac { - ( x - 2 \pi ) ^ { 2 } } { 4 \nu } \right] } } \\ { { = - \displaystyle \frac { 0 . 5 x } { \nu } \exp \left( \frac { - x ^ { 2 } } { 4 \nu } \right) - \frac { 0 . 5 ( x - 2 \pi ) } { \nu } \exp \left[ \frac { - ( x - 2 \pi ) ^ { 2 } } { 4 \nu } \right] . } } \end{array}
472
+ $$
473
+
474
+ The analytical solutions for this specific set of boundary and initial conditions gives
475
+
476
+ $$
477
+ u ( t , x ) = - 2 \nu \frac { \partial \phi / \partial x } { \phi } + 4 ,
478
+ $$
479
+
480
+ where
481
+
482
+ $$
483
+ \begin{array} { l } { \displaystyle \phi = \exp \left( \frac { - ( x - 4 t ) ^ { 2 } } { 4 \nu ( t + 1 ) } \right) + \exp \left[ \frac { - ( x - 4 t - 2 \pi ) ^ { 2 } } { 4 \nu ( t + 1 ) } \right] } \\ { \displaystyle \frac { \partial \phi } { \partial x } = - \frac { 2 ( x - 4 t ) } { 4 \nu ( t + 1 ) } \exp \left( \frac { - ( x - 4 t ) ^ { 2 } } { 4 \nu ( t + 1 ) } \right) - \frac { 2 ( x - 4 t - 2 \pi ) } { 4 \nu ( t + 1 ) } + \exp \left[ \frac { - ( x - 4 t - 2 \pi ) ^ { 2 } } { 4 \nu ( t + 1 ) } \right] } \\ { \displaystyle \quad = - \frac { 0 . 5 ( x - 4 t ) } { \nu ( t + 1 ) } \exp \left( \frac { - ( x - 4 t ) ^ { 2 } } { 4 \nu ( t + 1 ) } \right) - \frac { 0 . 5 ( x - 4 t - 2 \pi ) } { \nu ( t + 1 ) } \exp \left[ \frac { - ( x - 4 t - 2 \pi ) ^ { 2 } } { 4 \nu ( t + 1 ) } \right] . } \end{array}
484
+ $$
485
+
486
+ For this first analytical solveable case, the analytical solution, the WENO scheme and the fourth order finite difference scheme (FDM) are compared in Fig. 6 for a diffusion term of $\nu = 0 . 0 0 5$ . The WENO scheme models the analytical solution perfectly, whereas the FDM scheme fails to capture the shock accurately. For lower values of $\nu$ the effect gets even stronger.
487
+
488
+ Second analytical case. Another analytical solvable case for the Burgers equation arises for the boundary condition:
489
+
490
+ $$
491
+ u ( t , \pm 1 ) = 0 ,
492
+ $$
493
+
494
+ and the initial condition
495
+
496
+ $$
497
+ u ( 0 , x ) = - \sin ( \pi x ) .
498
+ $$
499
+
500
+ Solutions are (Basdevant et al., 1986)
501
+
502
+ $$
503
+ u ( t , x ) = \frac { - \int _ { - \infty } ^ { \infty } \sin \pi ( x - \eta ) f ( x - \eta ) \exp ( - \eta ^ { 2 } / 4 \nu t ) d \eta } { \int _ { - \infty } ^ { \infty } f ( x - \eta ) \exp ( - \eta ^ { 2 } / 4 \nu t ) d \eta } ,
504
+ $$
505
+
506
+ with $\begin{array} { r } { f ( y ) = \exp ( - \cos ( \frac { \pi y } { 2 \pi \nu } ) } \end{array}$ . Using Hermite integration allows the computation of accurate results up to $t = 3 / \pi$ .
507
+
508
+ For this second analytical solveable case, the analytical solution, and the WENO scheme are compared in Fig. 7 for a diffusion term of $\nu = 0 . 0 0 2$ . The WENO scheme models the analytical solution perfectly. Modeling via the FDM scheme fails completely.
509
+
510
+ ![](images/d07b91c566afd38f5f178f20990844ec0e4e6336ec56e9db48805dab94847bed.jpg)
511
+ Figure 6: 1D and 2D rollouts for the first analytical case setting the diffusion term $\nu \ : = \ : 0 . 0 0 5$ . Analytical solution (top), WENO scheme (middle) and Finite Difference scheme (FDM, bottom). The WENO scheme models the analytical solution perfectly, whereas the FDM scheme fails to capture the shock accurately.
512
+
513
+ ![](images/dc51a2bf589177d9861a698dab88021d880f5ac3d2e9377bddd5e74d5d3c3899.jpg)
514
+ Figure 7: 1D and 2D rollouts for the second analytical case setting the diffusion term $\nu = 0 . 0 0 5$ . Analytical solution (top), and WENO scheme solution(bottom).The WENO scheme models the analytical solution perfectly.
515
+
516
+ # D PSEUDOSPECTRAL METHODS FOR WAVE PROPAGATION ON IRREGULAR GRIDS
517
+
518
+ We consider Dirichlet $B [ u ] = u = 0$ and Neumann $B [ u ] = \partial _ { x } u = 0$ boundary conditions. Numerical groundtruth is generated using FVM and Chebyshev spectral derivatives, integrated in time with an implicit Runge-Kutta method of Radau IIA family, order 5 (Hairer et al., 1993). To properly fulfill the boundary conditions, wave packages have to travel between the boundaries and are bounced back with same and different sign for Neumann and Dirichlet boundary condition, respectively. Exemplary wave propagation for both boundary conditions is shown in Figure 8.
519
+
520
+ ![](images/501b3d348d5997ef2fccac99d16b4771c9312d8516a366ac1e222ed8cee2da9d.jpg)
521
+ Figure 8: Exemplary wave propagation data for Dirichlet boundary conditions (left) and Neumann boundary conditions (right). Solutions are obtained on irregular grids using pseudospectral solvers.
522
+
523
+ # E EXPLICIT RUNGE-KUTTA METHODS
524
+
525
+ The family of Runge-Kutta methods (Butcher, 1987) is given by:
526
+
527
+ $$
528
+ u _ { t _ { n + 1 } } = u _ { t _ { n } } + \Delta t \sum _ { i = 1 } ^ { s } b _ { i } k _ { i } ,
529
+ $$
530
+
531
+ where
532
+
533
+ $$
534
+ \begin{array} { r l } & { k _ { 1 } = f \left( t _ { n } , u _ { t _ { n } } \right) , } \\ & { k _ { 2 } = f \big ( t _ { n } + c _ { 2 } \Delta t , u _ { t _ { n } } + h ( a _ { 2 1 } k _ { 1 } ) \big ) , } \\ & { k _ { 3 } = f \big ( t _ { n } + c _ { 3 } \Delta t , u _ { t _ { n } } + h ( a _ { 3 1 } k _ { 1 } + a _ { 3 2 } k _ { 2 } ) \big ) , } \\ & { \begin{array} { r l } & { \vdots } \\ & { k _ { s } = f \big ( t _ { n } + c _ { s } \Delta t , u _ { t _ { n } } + h \big ( a _ { s 1 } k _ { 1 } + a _ { s 2 } k _ { 2 } , . . . a _ { s , s - 1 } k _ { s - 1 } \big ) \big ) . } \end{array} } \end{array}
535
+ $$
536
+
537
+ For a particular Runge-Kutta method one needs to provide the number of stages $s$ , and the coefficients $a _ { i j } ( 1 \leq j < i \leq s )$ , $b _ { i } ( i = 1 , 2 , \dots , s )$ and $c _ { i } ( i = 1 , 2 , \dots , s )$ . These data are usually arranged in so-called Butcher tableaux (Butcher, 1963).
538
+
539
+ # F EXPERIMENTS
540
+
541
+ Flux terms of equations that we study—the Heat, Burgers, Korteweg-de-Vries (KdV), and Kuromoto-Shivashinsky (KS) equation—are summarized in Table 3.
542
+
543
+ Table 3: 1D flux terms $J ( u )$ of the Heat, Burgers, Korteweg-de-Vries (KdV), and KuramotoShivashinsky (KS) equation.
544
+
545
+ <table><tr><td></td><td>Heat</td><td>Burgers</td><td>KdV</td><td>KS</td></tr><tr><td>J(u)</td><td>-nOxu</td><td>u²-noxu</td><td>3u²+Oxxu</td><td>u²+Oxu+oxxxu</td></tr></table>
546
+
547
+ Pushforward trick and temporal bundling. Pseudocode for one training step using the pushforward trick and temporal bundling is sketch in Algorithm 1.
548
+
549
+ Algorithm 1 Pushforward trick and temporal bundling. For a given batched input data trajectory and a model, we draw a random timepoint $t$ , get our input data trajectory, perform $N$ forward passes, and finally perform the supervised learning task with the according labels. $K$ is the number of steps we predict into the future using the temporal bundling trick, $N$ is number of unrolling steps in order to apply the pushforward trick, $T$ is the number of available timesteps in the training set.
550
+
551
+ <table><tr><td>Require: data, model, N, K,T t←DrawRandomNumber t ∈ {1,..,T} input ← data(t-K:t) for n ∈{1,...,N} do input ← model(input)</td><td>data is the complete PDE trajectory We draw a random starting point &gt; We input the last K timesteps</td></tr></table>
552
+
553
+ Implementation details. MP-PDE architectures, consist of three parts (sequentially applied):
554
+
555
+ 1. Encoder: Input {fully-connected layer activation fully-connected layer activation $\}$ , where fully connected layers are applied node-wise
556
+ 2. Processor: 6 message passing layers as described in Sec. 3.2. Each layer consists of a 2- layer edge update network $\phi$ following Equation (8), and a 2-layer node update network $\psi$ following Equation (9).
557
+ 3. Decoder: 1D convolutional network with shard weights across spatial locations $ \{ 1 \mathrm { D }$ CNN layer activation $ 1 \mathrm { D }$ CNN layer }
558
+
559
+ We optimize models using the AdamW optimizer (Loshchilov & Hutter, 2017) with learning rate 1e-4, weight decay 1e-8 for 20 epochs and minimize the root mean squared error (RMSE). We use batch size 16 for experiments E1-E3 and WE1-WE3 and batch size of 4 for 2D experiments. For experiments E1-E3 we use a hidden size of 164, and for experiments WE1-WE3 we use a hidden size of 128. In order to enforce zero-stability during training we unroll the solver for a maximum of 2 steps (see Sec. 3.1).
560
+
561
+ Message and update network in the processor consist of {fully-connected layer activation fully-connected layer activation $\}$ . We use skip-connections in the message passing layers and apply instance normalization (Ulyanov et al., 2016) for experiments E1-E3 and WE1-WE3, and batch normalization (Ioffe & Szegedy, 2015) for the 2D experiments. For the decoder, we use 8 channels between the two CNN layers (1 input channel, 1 output channel) across all experiments. We use Swish (Ramachandran et al., 2017) activation functions for experiments E1-E3 and WE1- WE3 and ReLU activation for the 2D experiments. ReLU activation proved most effective for 2D experiments since a characteristic of the smoke inflow dynamics we studied is that values are zero for all positions which are untouched by smoke buoyancy at a given timepoint.
562
+
563
+ Training details. The overall used architectures consist of roughly 1 million parameters and training for the different experiments takes between 12 and 24 hours on average on a GeForceRTX 2080
564
+
565
+ Ti GPU. 6 message passing layers and a hidden size of 128 for the 2-layer edge update network and the 2-layer node update network is a robust choice. A hidden size of 64 shows signs of underfitting, whereas a hidden size of 256 is not improve performance significantly. For the overall performance, more important than the number of parameters is the choice of the output 1D CNN, the choice of inputs to the edge update network $\phi$ following Equation (8) and the node update network $\psi$ following Equation (9). We ablate these choices in Appendix G.
566
+
567
+ Another interesting hyperparameter is the number of neighbors used for message passing. We construct our graphs by restricting the neighbors (edges) via a cutoff radius based on positional coordinates for experiments E1-E3 and the 2D experiments. We effectively use 6 neighbors for experiments E1-E3 and 8 neighbors for the 2D experiments. For experiments WE1-WE3, cutoff radii for selecting neighbors are not a robust choice since the grids are irregular and relative distances are much lower close to the boundaries. We therefore construct our graphs via a $k$ -NN criterion, and effectively use between 20 neighbors (highest spatial resolution) and 6 neighbors (lowest spatial resolution).
568
+
569
+ # F.1 EXPERIMENTS E1, E2, E3
570
+
571
+ Figure 9 displays exemplary 1D rollouts at different resolution for the Burgers’ equation with different diffusion terms. Lower diffusion coefficients result in faster shock formation. Figure 10 displays exemplary 1D rollouts for different parameter sets. Large $\alpha$ parameters result in fast and large shock formations. The wiggles arising due to the dispersive term $\gamma$ and cannot be captured by numerical solvers at low resolution. Our MP-PDE solver is able to capture these wiggles and reproduce them even at very low resolution.
572
+
573
+ ![](images/641ef2735c081245a6ee948b6836a81be6fafc1f4166222df8cbcf8c723095ee.jpg)
574
+ Figure 9: Exemplary 1D rollout of the Burgers’ equation at different resolutions. The different colors represent PDE solutions at different timepoints. Diffusion coefficients of $\eta = 0 . 1 4$ (top) and $\eta = 0 . 0 8$ (bottom) are compared for the same initial conditions. Lower diffusion coefficients result in faster shock formation.
575
+
576
+ ![](images/db716765c8ea43c7a8e1df3e8aeef25182f6fc2988b5acadb6ee0eb89c9c0266.jpg)
577
+ Figure 10: Exemplary 1D rollout an unseen equation with different equation parameters. The different colors represent PDE solutions at different timepoints. Low $\alpha$ parameters (top) result in diffusion like behavior. Large $\alpha$ parameters (middle, bottom) result in fast and large shock formations. The wiggles arising due to the dispersive term $\gamma$ . Numerical solvers cannot capture the wiggles at low resolution (middle), MP-PDE solvers can reconstruct them much better (bottom).
578
+
579
+ # F.2 EXPERIMENTS WE1, WE2, WE3
580
+
581
+ Figure 11 displays exemplary 2D rollouts at different resolutions for the wave equation with Dirichlet and Neumann boundary conditions. Waves bounce back and forth between boundaries. MP-PDE solvers give accurate solutions on the irregular grids and are stable over time.
582
+
583
+ ![](images/028ae38dd60ac52e91e679611113c2d2cec921cce820ce4224dcae93bf52ebf9.jpg)
584
+ Figure 11: Exemplary 2D rollouts for the wave equation with Dirichlet boundary conditions (top) and Neumann boundary conditions (bottom). The different colors for the Dirichlet boundary condition comes from the fact that wave propagation changes the sign at each boundary.
585
+
586
+ ![](images/84c42693a3558415f084a9f0b26c313b7ee15f25fdf47496e3ed449df9434a24.jpg)
587
+ Figure 12: Exemplary 2D smoke inflow simulation. Ground truth data (top) are compared to MPPDE solvers (bottom). Simulations run for 100 timesteps corresponding to 100 seconds. The MPPDE solver is able to capture the smoke inflow acccurately over the given time period.
588
+
589
+ # G ARCHITECTURE ABLATION AND COMPARISON TO CNNS
590
+
591
+ A schematic sketch of our MP-PDE solver is displayed in Figure 13 (sketch taken from the main paper). A GNN based architecture was chosen since GNNs have the potential to offer flexibility when generalizing across spatial resolution, timescale, domain sampling regularity, domain topology and geometry, boundary conditions, dimensionality, and solution space smoothness. The chosen architecture representationally contains classical methods, such as FDM, FVM, and WENO schemes. The architectures follows the Encode-Process-Decode framework of Battaglia et al. (2018), with adjustments. Most notably, PDE coefficients and other attributes such as boundary conditions denoted with $\pmb { \theta } _ { \mathrm { P D E } }$ are included in the processor. For the decoder, a shallow 2-layer 1D convolutional network with shared weights across spatial locations is applied, motivated by linear multistep methods (Butcher, 1987).
592
+
593
+ For ablating the architecture, three design choices are verified:
594
+
595
+ 1. Does a GNN have the representational power of a vanilla convolutional network on a regular grid? We test against 1D and 2D baseline CNN architectures.
596
+ 2. For the decoder part, how much does a 1D convolutional network with shared weights across spatial locations approve upon a standard MLP decoder?
597
+ 3. How much does the inclusion of PDE coefficients $\pmb { \theta } _ { \mathrm { P D E } }$ help to generalize over e.g. different equations or different boundary conditions?
598
+
599
+ ![](images/3bf2e8447a09b7f65a23c95ab86f7055c1caa113534a06fff8558886c8fdc0a0.jpg)
600
+ Figure 13: Schematic sketch of our MP-PDE Solver, sketch taken from the main paper.
601
+
602
+ Table 4 shows the three ablation (MP-PDE- $\theta _ { \mathrm { P D E } }$ , MP-PDE-✭1D-CNN, Baseline CNN) tested on ✭ shock wave formation modeling and generalization to unseen experiments (experiments E1, E2, and E3), as described in Section 4.1 in the main paper. For the training of the different architectures the optimized training strategy consisting of temporal bundling and pushforward trick is used.
603
+
604
+ The MP-PDE- $\underbrace { \theta _ { \mathbf { P } } \delta \mathbf { \overline { { E } } } } _ { \mathbf { \overline { { ~ } } } \mathbf { \Theta } }$ ablation results are the same as reported in the main paper. The effect gets more prominent if more equation specific parameters are available $\mathbf { \nabla } _ { \theta _ { \mathrm { P D E } } }$ features), as it is the case for experiment E3. We also refer the reader to the experiments presented in Table 2, where MPPDE solvers are shown to be able to generalize over different boundary conditions, which gets much stronger pronounced if boundary conditions are injected into the equation via $\pmb { \theta } _ { \mathrm { P D E } }$ features.
605
+
606
+ The MP-PDE-✭1D-CNN ✭ ablation replaces the shallow 2-layer 1D convolutional network with in the decoder with a standard 2-layer MLP. Performance slightly degrades for the MLP decoder which is most likely due to the better temporal modeling introduced by the shared weights of the 1D CNN network.
607
+
608
+ A Baseline 1D-CNN is built up of 8 1D-CNN layers, where the input consists of the spatial resolution $( n _ { x } )$ . The $K$ previous timesteps used for temporal bundling are treated as $K$ input channels. The output consequently predicts the next $K$ timesteps for the same spatial resolution ( $K$ output channels). Using this format, again both temporal bundling and the pushforward trick can be effectively applied. The implemented 1D-CNN layers are:
609
+
610
+ • Input layer with $K$ input channel, 40 output channels, kernel of size 3.
611
+ • 3 layers with 40 input channels, 40 output channels, kernel of size 5.
612
+ • 3 layers with 40 input channels, 40 output channels, kernel of size 7.
613
+ • 1 output layer with 40 input channels, $K$ output channel, kernel of size 7.
614
+
615
+ Residual connections are used between the layers, and ELU (Clevert et al., 2016) non-linearities are applied. Circular padding is implemented to reflect the periodic boundary conditions. The CNN output is a new vector $\mathbf { { \bar { d } } } _ { i } ^ { \phantom { * } } = ( \bar { \mathbf { d } } _ { i } ^ { 1 } , \mathbf { d } _ { i } ^ { 2 } , . . . , \mathbf { d } _ { i } ^ { K } )$ with each element $\mathbf { d } _ { i } ^ { k }$ corresponding to a different point in time. Analogously to the MP-PDE solver, we use the output to update the solution as
616
+
617
+ $$
618
+ { \mathbf { u } } _ { i } ^ { k + \ell } = { \mathbf { u } } _ { i } ^ { k } + ( t _ { k + \ell } - t _ { k } ) { \mathbf { d } } _ { i } ^ { \ell } , \qquad 1 \le \ell \le K ,
619
+ $$
620
+
621
+ where $K$ is the output (and input) dimension. This baseline 1D-CNN is conceptually very similar to our MP-PDE solver.
622
+
623
+ A Baseline 2D-CNN is built up of 6 2D-CNN layers, where the input consists of the spatial resolution $( n _ { x } )$ and the $K$ previous timesteps used for temporal bundling. The output consequently predicts the next $K$ timesteps for the same spatial resolution. Using this format, both temporal bundling and the pushforward trick can be effectively applied. The implemented 2D-CNN layers are:
624
+
625
+ • Input layer with 1 input channel, 16 output channels, $3 \times 3$ kernel.
626
+ • 4 intermediate layers with 16 input channels, 16 output channels, $5 \times 5$ kernel.
627
+ • 1 output layer with 16 input channels, 1 output channel, $7 \times 7$ kernel.
628
+
629
+ Residual connections are used between the layers, and ELU (Clevert et al., 2016) non-linearities are applied. For the spatial dimension, circular padding is implemented to reflect the periodic boundary conditions, for the temporal dimension zero padding is used. The CNN output is a new vector $\mathbf { d } _ { i } = ( \mathbf { d } _ { i } ^ { 1 } , \mathbf { d } _ { i } ^ { 2 } , . . . , \mathbf { d } _ { i } ^ { K } )$ with each element $\mathbf { d } _ { i } ^ { k }$ corresponding to a different point in time. Analogously to the MP-PDE solver and analogously to the 1D-CNN, we use the output to update the solution as shown in Equation (61).
630
+
631
+ The 1D-CNN baseline which is conceptually very close to our MP-PDE solver performs much better than the 2D-CNN. However, we see already when looking at the results of E3 that generalization for the 1D-CNN across different PDEs becomes harder.
632
+
633
+ Table 4: Ablation study comparing MP-PDE results on experiments on shock wave formation modeling and generaliziation to unseen equations (E1, E3, and E3) to an MP-PDE-✭ $\theta _ { \mathrm { P D E } }$ ablation, an MP-PDE-✭1D-CNN ablation, a baseline 1D-CNN and a baseline 2D-CNN architecture. Runtimes ✭ are for one full unrolling over 250 timesteps on a GeForce RTX 2080 Ti GPU. Accumulated error is $\begin{array} { r } { \frac { 1 } { n _ { x } } \sum _ { x , t } \mathbf { M S E } } \end{array}$ .
634
+
635
+ <table><tr><td></td><td></td><td colspan="4">Accumulated Error↓</td><td colspan="4">Runtime [s]↓</td></tr><tr><td></td><td>(nt,nx)</td><td>MP-PDE</td><td>MP-PDE-0PDE</td><td>MP-PDE-1D-CNN</td><td>1D-CNN</td><td>2D-CNN</td><td>MP-PDE</td><td>1D-CNN</td><td>2D-CNN</td></tr><tr><td>E1</td><td>(250,100)</td><td>1.55</td><td>-</td><td>2.41</td><td>3.45</td><td>25.70</td><td>0.09</td><td>0.02</td><td>0.16</td></tr><tr><td>E1</td><td>(250,50)</td><td>1.67</td><td>-</td><td>2.69</td><td>3.88</td><td>32.42</td><td>0.08</td><td>0.02</td><td>0.15</td></tr><tr><td>E1</td><td>(250,40)</td><td>1.47</td><td>-</td><td>2.50</td><td>3.07</td><td>37.13</td><td>0.008</td><td>0.02</td><td>0.14</td></tr><tr><td>E2</td><td>(250,100)</td><td>1.58</td><td>1.62</td><td>2.59</td><td>3.32</td><td>30.09</td><td>0.09</td><td>0.02</td><td>0.16</td></tr><tr><td>E2</td><td>(250,50)</td><td>1.63</td><td>1.71</td><td>2.31</td><td>2.89</td><td>30.87</td><td>0.08</td><td>0.02</td><td>0.15</td></tr><tr><td>E2</td><td>(250,40)</td><td>1.45</td><td>1.49</td><td>2.80</td><td>2.98</td><td>35.93</td><td>0.08</td><td>0.02</td><td>0.15</td></tr><tr><td>E3</td><td>(250,100)</td><td>4.26</td><td>4.71</td><td>6.26</td><td>9.15</td><td>42.37</td><td>0.09</td><td>0.02</td><td>0.16</td></tr><tr><td>E3</td><td>(250,50)</td><td>3.74</td><td>10.90</td><td>5.15</td><td>7.69</td><td>45.41</td><td>0.09</td><td>0.02</td><td>0.15</td></tr><tr><td>E3</td><td>(250,40)</td><td>3.70</td><td>7.78</td><td>7.27</td><td>6.77</td><td>53.87</td><td>0.09</td><td>0.02</td><td>0.15</td></tr></table>
md/dev/vaRCHVj0uGI/vaRCHVj0uGI.md ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOLVING INVERSE PROBLEMS IN MEDICAL IMAGING WITH SCORE-BASED GENERATIVE MODELS
2
+
3
+ Yang $\mathbf { S o n g ^ { * } }$ , Liyue Shen˚, Lei Xing & Stefano Ermon Stanford University {yangsong@cs,liyues@,lei@,ermon@cs}.stanford.edu
4
+
5
+ # ABSTRACT
6
+
7
+ Reconstructing medical images from partial measurements is an important inverse problem in Computed Tomography (CT) and Magnetic Resonance Imaging (MRI). Existing solutions based on machine learning typically train a model to directly map measurements to medical images, leveraging a training dataset of paired images and measurements. These measurements are typically synthesized from images using a fixed physical model of the measurement process, which hinders the generalization capability of models to unknown measurement processes. To address this issue, we propose a fully unsupervised technique for inverse problem solving, leveraging the recently introduced score-based generative models. Specifically, we first train a score-based generative model on medical images to capture their prior distribution. Given measurements and a physical model of the measurement process at test time, we introduce a sampling method to reconstruct an image consistent with both the prior and the observed measurements. Our method does not assume a fixed measurement process during training, and can thus be flexibly adapted to different measurement processes at test time. Empirically, we observe comparable or better performance to supervised learning techniques in several medical imaging tasks in CT and MRI, while demonstrating significantly better generalization to unknown measurement processes.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Computed Tomography (CT) and Magnetic Resonance Imaging (MRI) are commonly used imaging tools for medical diagnosis. Reconstructing CT and MRI images from raw measurements (sinograms for CT and $\mathbf { k }$ -spaces for MRI) are well-known inverse problems. Specifically, measurements in CT are given by $\mathbf { X }$ -ray projections of an object from various directions, and measurements in MRI are obtained by inspecting the Fourier spectrum of an object with magnetic fields. However, since obtaining the full sinogram for CT causes excessive ionizing radiation for patients, and measuring the full k-space of MRI is very time-consuming, it has become important to reduce the number of measurements in CT and MRI. In many cases, only partial measurements, such as sparse-view sinograms and downsampled $\mathbf { k }$ -spaces, are available. Due to this loss of information, the inverse problems in CT and MRI are often ill-posed, making image reconstruction especially challenging.
12
+
13
+ With the rise of machine learning, many methods (Zhu et al., 2018; Mardani et al., 2017; Shen et al., 2019; Würfl et al., 2018; Ghani & Karl, 2018; Wei et al., 2020) have been proposed for medical image reconstruction using a small number of measurements. Most of these methods are supervised learning techniques. They learn to directly map partial measurements to medical images, by training on a large dataset comprising pairs of CT/MRI images and measurements. These measurements need to be synthesized from medical images with a fixed physical model of the measurement process. However, when the measurement process changes, such as using a different number of CT projections or different downsampling ratio of MRI $\mathbf { k }$ -spaces, we have to re-collect the paired dataset with the new measurement process and re-train the model. This prevents models from generalizing effectively to new measurement processes, leading to counter-intuitive instabilities such as more measurements causing worse performance (Antun et al., 2020).
14
+
15
+ In this work, we sidestep this difficulty completely by proposing unsupervised methods that do not require a paired dataset for training, and therefore are not restricted to a fixed measurement process. Our main idea is to learn the prior distribution of medical images with a generative model in order to infer the lost information due to partial measurements. Specifically, we propose to train a score-based generative model (Song & Ermon, 2019; 2020; Song et al., 2021) on medical images as the data prior, due to its strong performance in image generation (Ho et al., 2020; Dhariwal & Nichol, 2021). Given a trained score-based generative model, we provide a family of sampling algorithms to create image samples that are consistent with the observed measurements and the estimated data prior, leveraging the physical measurement process. Once our model is trained, it can be used to solve any inverse problem within the same image domain, as long as the mapping from images to measurements is linear, which holds for a large number of medical imaging applications.
16
+
17
+ We evaluate the performance of our method on several tasks in CT and MRI. Empirically, we observe comparable or better performance compared to supervised learning counterparts, even when evaluated with the same measurement process in their training. In addition, we are able to uniformly surpass all baselines when changing the number of measurements, e.g., using a different number of projections in sparse-view CT or changing the k-space downsampling ratio in undersampled MRI. Moreover, we show that by plugging in a different measurement process, we can use a single model to perform both sparse-view CT reconstruction and metal artifact removal for CT imaging with metallic implants. To the best of our knowledge, this is the first time that generative models are reported successful on clinical CT data. Collectively, these empirical results indicate that our method is a competitive alternative to supervised techniques in medical image reconstruction and artifact removal, and has the potential to be a universal tool for solving many inverse problems within the same image domain.
18
+
19
+ # 2 BACKGROUND
20
+
21
+ # 2.1 LINEAR INVERSE PROBLEMS
22
+
23
+ An inverse problem seeks to recover an unknown signal from a set of observed measurements. Specifically, suppose $\mathbf { x } \in \mathbb { R } ^ { n }$ is an unknown signal, and $\mathbf { y } \in \mathbb { R } ^ { m } = A \mathbf { x } + \epsilon$ is a noisy observation given by $m$ linear measurements, where the measurement acquisition process is represented by a linear operator $\pmb { A } \in \mathbb { R } ^ { m \times n }$ , and $\epsilon \in \mathbb { R } ^ { n }$ represents a noise vector. Solving a linear inverse problem amounts to recovering the signal $\mathbf { x }$ from its measurement y. Without further assumptions, the problem is ill-defined when $m < n$ , so we additionally assume that $\mathbf { x }$ is sampled from a prior distribution $p ( \mathbf { x } )$ . In this probabilistic formulation, the measurement and signal are connected through a measurement distribution $p ( \mathbf { y } \mid \mathbf { x } ) = q _ { \epsilon } ( \mathbf { y } - A \mathbf { x } )$ , where $q _ { \epsilon }$ denotes the noise distribution of $\epsilon$ . Given $p ( \mathbf { y } \mid \mathbf { x } )$ and $p ( \mathbf { x } )$ , we can solve the inverse problem by sampling from the posterior distribution $p ( \mathbf { x } \mid \mathbf { y } )$ .
24
+
25
+ Examples of linear inverse problems in medical imaging include image reconstruction for CT and MRI. In both cases, the signal $\mathbf { x }$ is a medical image. The measurement y in CT is a sinogram formed by $\mathrm { X }$ -ray projections of the image from various angular directions (Buzug, 2011), while the measurement $\mathbf { y }$ in MRI consists of spatial frequencies in the Fourier space of the image (a.k.a. the $\mathbf { k }$ -space in the MRI community) (Vlaardingerbroek & Boer, 2013).
26
+
27
+ # 2.2 SCORE-BASED GENERATIVE MODELS
28
+
29
+ When solving inverse problems in medical imaging, we are given an observation $\mathbf { y }$ , the measurement distribution $\bar { p } ( \mathbf { y } \mid \mathbf { x } )$ and aim to sample from the posterior distribution $p ( \mathbf { x } \mid \mathbf { y } )$ . The prior distribution $p ( \mathbf { x } )$ is typically unknown, but we can train generative models on a dataset $\{ \mathbf { x } ^ { ( 1 ) } , \mathbf { x } ^ { ( 2 ) } , \cdot \cdot \cdot , \mathbf { x } ^ { ( N ) } \} \sim$ $p ( \mathbf { x } )$ to estimate this prior distribution. Given an estimate of $p ( \mathbf { x } )$ and the measurement distribution $p ( \mathbf { y } \mid \mathbf { x } )$ , the posterior distribution $p ( \mathbf { x } \mid \mathbf { y } )$ can be determined through Bayes’ rule.
30
+
31
+ We propose to estimate the prior distribution of medical images using the recently introduced scorebased generative models (Song & Ermon, 2019; Ho et al., 2020; Song et al., 2021), whose iterative sampling procedure makes it especially easy for controllable generation conditioned on an observation y. Specifically, we adopt the formulation of score-based generative models in Song et al. (2021), where we leverage a Markovian diffusion process to progressively perturb data to noise, and then smoothly convert noise to samples of the data distribution by estimating and simulating its time reversal. We provide an illustration of this generative modeling framework in Fig. 1.
32
+
33
+ ![](images/b88e7401b989af752cb00b405dac997e7560fb8f85d563ef8d39e58b11a2057f.jpg)
34
+ Figure 1: We can smoothly perturb images to noise by following the trajectory of an SDE. By estimating the score function $\nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } )$ with neural networks (called score models), it is possible to approximate the reverse SDE and then solve it to generate image samples from noise.
35
+
36
+ Perturbation process Suppose the dataset is sampled from an unknown data distribution $p ( \mathbf { x } )$ . We perturb datapoints with a stochastic process over a time horizon $[ 0 , 1 ]$ , governed by a linear stochastic differential equation (SDE) of the following form
37
+
38
+ $$
39
+ \mathrm { d } \mathbf { x } _ { t } = f ( t ) \mathbf { x } _ { t } \mathrm { d } t + g ( t ) \mathrm { d } \mathbf { w } _ { t } , \qquad t \in [ 0 , 1 ] ,
40
+ $$
41
+
42
+ where $f : [ 0 , 1 ] \to \mathbb { R }$ , $g : [ 0 , 1 ] \to \mathbb { R }$ , $\{ \mathbf { w } _ { t } \in \mathbb { R } ^ { n } \} _ { t \in [ 0 , 1 ] }$ denotes a standard Wiener process (a.k.a., Brownian motion), and $\{ \mathbf { x } _ { t } \in \mathbb { R } ^ { n } \} _ { t \in [ 0 , 1 ] }$ symbolizes the trajectory of random variables in the stochastic process. We further denote the marginal probability distribution of $\mathbf { x } _ { t }$ as $p _ { t } ( \mathbf { x } )$ , and the transition distribution from $\mathbf { x } _ { \mathrm { 0 } }$ to $\mathbf { x } _ { t }$ as $p _ { 0 t } ( \mathbf { x } _ { t } \mid \mathbf { x } _ { 0 } )$ . By definition, we clearly have $p _ { 0 } ( \mathbf { x } ) \equiv p ( \mathbf { x } )$ . Moreover, the functions $f ( t )$ and $g ( t )$ are specifically chosen such that for any initial distribution $p _ { 0 } ( \mathbf { x } )$ , the distribution at the end of the perturbation process, $p _ { 1 } ( \mathbf { x } )$ , is close to a pre-defined noise distribution $\pi ( \mathbf { x } )$ . In addition, the transition density $p _ { 0 t } ( \mathbf { x } _ { t } \mid \mathbf { \dot { x } } _ { 0 } )$ is always a conditional linear Gaussian distribution, taking the form $p _ { 0 t } ( \mathbf { x } _ { t } \mid \mathbf { x } _ { 0 } ) = \mathcal { N } ( \mathbf { x } _ { t } \mid \alpha ( t ) \mathbf { x } _ { 0 } , \beta ^ { 2 } ( t ) I )$ where $\alpha : [ 0 , 1 ] \mathbb { R }$ and $\beta : [ 0 , 1 ] \mathbb { R }$ can be derived analytically from $f ( t )$ and $g ( t )$ (Särkkä & Solin, 2019). Examples of such SDEs include Variance Exploding (VE), Variance Preserving (VP), and subVP SDEs proposed in Song et al. (2021). We found VE SDEs performed the best in our experiments.
43
+
44
+ Reverse process By reversing the perturbation process in Eq. (1), we can start from a noise sample $\mathbf { x } _ { 1 } \sim p _ { 1 } ( \mathbf { x } )$ and gradually remove the noise therein to obtain a data sample $\mathbf { x } _ { 0 } \sim p _ { 0 } ( \mathbf { x } ) \equiv p ( \mathbf { x } )$ . Crucially, the time reversal of Eq. (1) is given by the following reverse-time SDE (Song et al., 2021)
45
+
46
+ $$
47
+ \mathrm { d } \mathbf { x } _ { t } = \left[ f ( t ) \mathbf { x } _ { t } - g ( t ) ^ { 2 } \nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } ) \right] \mathrm { d } t + g ( t ) \mathrm { d } \bar { \mathbf { w } } _ { t } , \qquad t \in [ 0 , 1 ] ,
48
+ $$
49
+
50
+ where $\{ \bar { \mathbf { w } } _ { t } \} _ { t \in [ 0 , 1 ] }$ denotes a standard Wiener process in the reverse-time direction, and $\mathrm { d } t$ represents an infinitesimal negative time step, since the above SDE must be solved backwards from $t = 1$ to $t = 0$ . The quantity $\nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } )$ is known as the score function of $p _ { t } ( \mathbf { x } _ { t } )$ . By the definition of time reversal, the trajectory of the reverse stochastic process given by Eq. (2) is $\{ \mathbf { x } _ { t } \} _ { t \in [ 0 , 1 ] }$ , same as the one from the forward SDE in Eq. (1).
51
+
52
+ Sampling Given an initial sample from $p _ { 1 } ( \mathbf { x } )$ , as well as scores at each intermediate time step, $\nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } )$ , we can simulate the reverse-time SDE in Eq. (2) to obtain samples from the data distribution $p _ { 0 } ( \mathbf { x } ) \equiv p ( \mathbf { x } )$ . In practice, the initial sample is approximately drawn from $\pi ( \mathbf { x } )$ since $\pi ( \mathbf { x } ) \approx p _ { 1 } ( \mathbf { x } )$ , and the scores are estimated by training a neural network $s _ { \theta } ( \mathbf { x } , t )$ (named the score model) on a dataset $\{ \mathbf { x } ^ { ( 1 ) } , \mathbf { x } ^ { ( 2 ) } , \cdot \cdot \cdot , \mathbf { x } ^ { ( N ) } \} \sim p ( \mathbf { x } )$ with denoising score matching (Vincent, 2011; Song et al., 2021), i.e., solving the following objective
53
+
54
+ $$
55
+ \theta ^ { * } = \underset { \theta } { \operatorname { a r g m i n } } \frac { 1 } { N } \sum _ { i = 1 } ^ { N } \mathbb { E } _ { t \sim \mathcal { U } [ 0 , 1 ] } \mathbb { E } _ { \mathbf { x } _ { t } ^ { ( i ) } \sim p _ { 0 t } ( \mathbf { x } _ { t } ^ { ( i ) } | \mathbf { x } ^ { ( i ) } ) } \Big [ \left\| s _ { \theta } ( \mathbf { x } _ { t } ^ { ( i ) } , t ) - \nabla _ { \mathbf { x } _ { t } ^ { ( i ) } } \log p _ { 0 t } ( \mathbf { x } _ { t } ^ { ( i ) } | \mathbf { x } ^ { ( i ) } ) \right\| _ { 2 } ^ { 2 } \Big ] ,
56
+ $$
57
+
58
+ where $\mathcal { U } [ 0 , 1 ]$ denotes a uniform distribution over $[ 0 , 1 ]$ . The theory of denoising score matching ensures that $\bar { s } _ { \theta ^ { * } } ( \mathbf { x } , t ) \approx \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } )$ . After training this score model, we plug it into Eq. (2) and solve the resulting reverse-time SDE
59
+
60
+ $$
61
+ \mathrm { d } \mathbf { x } _ { t } = \left[ f ( t ) \mathbf { x } _ { t } - g ( t ) ^ { 2 } s _ { \theta ^ { \ast } } ( \mathbf { x } _ { t } , t ) \right] \mathrm { d } t + g ( t ) \mathrm { d } { \bar { \mathbf { w } } } _ { t } , \qquad t \in [ 0 , 1 ] ,
62
+ $$
63
+
64
+ for sample generation. One sampling method is to use the Euler-Maruyama discretization for solving Eq. (3), as given in Algorithm 1. Other sampling methods include annealed Langevin dynamics (ALD, Song & Ermon, 2019), probability flow ODE solvers (Song et al., 2021), and Predictor-Corrector samplers (Song et al., 2021).
65
+
66
+ <table><tr><td>Algorithm 1 Unconditional sampling</td><td>Algorithm 2 Inverse problem solving</td></tr><tr><td>Require: N</td><td>Require: N,y, 入</td></tr><tr><td></td><td></td></tr><tr><td>2:fori=N-1to0do 3:t←</td><td>2:fori=N-1 to 0 do 3: t←</td></tr><tr><td>N</td><td>4: N yt ~ pot(yt |y)</td></tr><tr><td></td><td>5: xt ←T-1[λAp-1(△)yt+(1-λ)ATxt +</td></tr><tr><td>4: Xt-△t←xt-f(t)xt△t</td><td>(I-∧)Txt] 6: xt-△t←xt-f(t)xt△t</td></tr><tr><td>5: Xt-△t←Xt-△t+g(t)²sθ*(xt,t)△t</td><td>7: Xt-△t←Xt-△t+g(t)²sθ*(xt,t)△t</td></tr><tr><td>6: z ~ N(0,I)</td><td>8: z ~ N(0,1)</td></tr><tr><td>7: Xt-△t←xt-△t+g(t)√△tz</td><td>Xt-△t←Xt-△t+g(t)√△tz</td></tr><tr><td>8: return Xo</td><td>9: 10: return Xo</td></tr></table>
67
+
68
+ # 3 SOLVING INVERSE PROBLEMS WITH SCORE-BASED GENERATIVE MODELS
69
+
70
+ With score-based generative modeling, we can train a score model $s _ { \theta ^ { * } } ( \mathbf { x } , t )$ to generate unconditional samples from the the prior distribution of medical images $p ( \mathbf { x } )$ . To solve inverse problems however, we will need to sample from the posterior $p ( \mathbf { x } \mid \mathbf { y } )$ . This can be accomplished by conditioning the original stochastic process $\{ \mathbf { x } _ { t } \} _ { t \in [ 0 , 1 ] }$ on an observation $\mathbf { y }$ , yielding a conditional stochastic process $\{ \mathbf { x } _ { t } \ | \ \mathbf { y } \} _ { t \in [ 0 , 1 ] }$ . We denote the marginal distribution at $t$ as $p _ { t } ( \mathbf { x } _ { t } \mid \mathbf { y } )$ , and our goal is to sample from $p _ { 0 } ( \mathbf { x } _ { 0 } \mid \mathbf { y } )$ , the same distribution as $p ( \mathbf { x } \mid \mathbf { y } )$ by definition. Much like generating unconditional samples by solving the reverse-time SDE in Eq. (2), we can reverse the conditional stochastic process $\{ \mathbf { x } _ { t } \mid \mathbf { y } \} _ { t \in [ 0 , 1 ] }$ to sample from the posterior distribution $p _ { 0 } ( \mathbf { x } _ { 0 } \mid \mathbf { y } )$ by solving the following conditional reverse-time SDE (Song et al., 2021):
71
+
72
+ $$
73
+ \mathrm { d } \mathbf { x } _ { t } = \left[ f ( t ) \mathbf { x } _ { t } - g ( t ) ^ { 2 } \nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } \mid \mathbf { y } ) \right] \mathrm { d } t + g ( t ) \mathrm { d } \bar { \mathbf { w } } _ { t } , \qquad t \in [ 0 , 1 ] .
74
+ $$
75
+
76
+ The conditional score function $\nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } \mid \mathbf { y } )$ is a critical part of Eq. (4), yet it is non-trivial to compute. One solution is to estimate the score function by training a new score model $s _ { \theta ^ { * } } ( \mathbf x _ { t } , \mathbf y , t )$ that explicitly depends on $\mathbf { y }$ (Song et al., 2021; Dhariwal $\&$ Nichol, 2021), such that $s _ { \theta ^ { * } } ( \mathbf x _ { t } , \mathbf y , t ) \approx$ $\nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } \mid \mathbf { y } )$ . However, this requires paired data $\{ ( \mathbf { x } _ { i } , \mathbf { y } _ { i } ) \} _ { i = 1 } ^ { N }$ for training and has the same drawbacks as supervised learning techniques. We do not consider this approach in this work.
77
+
78
+ An unsupervised alternative is to approximate the conditional score function with an unconditionallytrained score model $s _ { \theta ^ { * } } ( \mathbf { x } _ { t } , t ) \approx \mathbf { \bar { \nabla } } \varphi _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } )$ and the measurement distribution $p ( \mathbf { y } \mid \mathbf { x } )$ . Many existing works (Song et al., 2021; Kawar et al., 2021; Kadkhodaie & Simoncelli, 2020; Jalal et al., 2021) have implemented this idea in different ways. However, the methods in Kawar et al. (2021) and Kadkhodaie & Simoncelli (2020) both require computing the singular value decomposition (SVD) of $\pmb { A } \in \mathbb { R } ^ { m \times n }$ , which can be difficult for many measurement processes in medical imaging. The method proposed in Jalal et al. (2021) is only designed for a specific sampling method called annealed Langevin dynamics (ALD, Song & Ermon, 2019), which proves to be inferior to more advanced sampling algorithms such as Predictor-Corrector methods (Song et al., 2021).
79
+
80
+ In what follows, we propose a new conditional sampling approach for inverse problem solving with score-based generative models. Our method is computationally efficient for medical image reconstruction, and is applicable to a large family of iterative sampling methods for score-based generative models. At a high level, we first train an unconditional score model $s _ { \theta ^ { * } } ( \mathbf { x } , t )$ on medical images without assuming any measurement process. Given an observation $\mathbf { y }$ at test time, we form a stochastic process $\{ \mathbf { y } _ { t } \} _ { t \in [ 0 , 1 ] }$ by adding appropriate noise to y. We then discretize the reverse-time SDE in Eq. (3) with existing unconditional samplers for $s _ { \theta ^ { * } } ( \mathbf { x } , t )$ , while incorporating the conditional information from y with a proximal optimization step to generate intermediate samples that are consistent with tytutPr0,1s.
81
+
82
+ # .1 A CONVENIENT FORM OF THE LINEAR MEASUREMENT PROCESS
83
+
84
+ Many different measurement processes in medical imaging share same components of computation. For example, sparse-view CT reconstruction and metal artifact removal for CT both involve computing the same Radon transform. Similarly, MRI measurement processes require computing the same spatial Fourier transform regardless of different downsampling ratios. To rigorously characterize this structure of measurement processes, we propose a special formulation of $\pmb { A }$ that is efficient to obtain in medical imaging applications. Without loss of generality, we assume that the linear operator $\pmb { A }$ has full rank, i.e., $\operatorname { r a n k } ( A ) = \operatorname* { m i n } ( n , m ) = m$ . The result below gives the alternative formulation of $\pmb { A }$ :
85
+
86
+ ![](images/346b278b9fdf4594092ef31abf6fa3cf132d1289dadfc04da652c6ace75a75bd.jpg)
87
+ Figure 2: Linear measurement processes for sparse-view CT (left) and undersampled MRI (right).
88
+
89
+ Proposition 1. $I f \operatorname { r a n k } ( A ) = m$ , then there exist an invertible matrix $\pmb { T } \in \mathbb { R } ^ { n \times n }$ , and a diagonal matrix $\pmb { \Lambda } \in \{ 0 , 1 \} ^ { n \times n }$ with $\operatorname { t r } ( \mathbf { \mathbf { \boldsymbol { \Lambda } } } ) = m$ , such that $A = \mathcal { P } ( \mathbf { \boldsymbol { \Lambda } } ) \mathbf { \boldsymbol { T } }$ . Here $\mathcal { P } ( \mathbf { A } ) \in \{ 0 , 1 \} ^ { m \times n }$ is an operator that, when multiplied with any vector $\mathbf { \pmb { a } } \in \mathbb { R } ^ { n }$ , reduces its dimensionality to m by removing each $i$ -th element of $\textbf { \em a }$ for $i = 1 , 2 , \cdots , n$ if $\mathbf { \Lambda } \Lambda _ { i i } = 0$ .
90
+
91
+ We illustrate this decomposition for CT/MRI in Fig. 2. Many measurement processes in medical imaging share the same $_ { \mathbf { T } }$ , even if they correspond to different $\pmb { A }$ . For example, $_ { \mathbf { T } }$ corresponds to the Radon transform and Fourier transform in sparse-view CT and undersampled MRI respectively, regardless of the number of measurements, i.e., CT projections and $\mathbf { k }$ -space downsampling ratios. For both sparse-view CT reconstruction and metal artifact removal for CT images, the operator $_ { \mathbf { T } }$ is the Radon transform (see Fig. 8). Intuitively, $\mathrm { d i a g } ( \pmb { \Lambda } )$ can be viewed as a subsampling mask on the sinogram/k-space, and ${ \mathcal { P } } ( \Lambda )$ subsamples the sinogram $/ \mathrm { k }$ -space into an observation y with a smaller size according to this subsampling mask. In addition, we note that $\pmb { T } ^ { - 1 }$ can be efficiently implemented with the inverse Radon transform or the inverse Fourier transform in CT/MRI applications.
92
+
93
+ # 3.2 INCORPORATING A GIVEN OBSERVATION INTO AN UNCONDITIONAL SAMPLING PROCESS
94
+
95
+ In what follows, we show that the decomposition in Proposition 1 provides an efficient way to generate approximate samples from the conditional stochastic process $\{ \mathbf { x } _ { t } \mid \mathbf { y } \} _ { t \in [ 0 , 1 ] }$ with an unconditional score model $s _ { \theta ^ { * } } ( \mathbf { x } , t )$ . The basic idea is to “hijack” the unconditional sampling process of scorebased generative models to incorporate an observed measurement y.
96
+
97
+ As we have already discussed, it is difficult to directly solve $\{ \mathbf { x } _ { t } \mid \mathbf { y } \} _ { t \in [ 0 , 1 ] }$ for sample generation. To bypass this difficulty, we first consider a related stochastic process that is much easier to sample from. Recall that $p _ { 0 t } ( \dot { \mathbf { x } } _ { t } \mid \mathbf { x } _ { 0 } ) = \mathcal { N } ( \mathbf { x } _ { t } \mid \alpha ( t ) \mathbf { x } _ { 0 } , \beta ^ { 2 } ( t ) \mathbf { I } )$ where $\alpha ( t )$ and $\beta ( t )$ can be derived from $f ( t )$ and $g ( t )$ (Song et al., 2021). Given the unconditional stochastic process $\{ \mathbf { x } _ { t } \} _ { t \in [ 0 , 1 ] }$ , we define $\{ \mathbf { y } _ { t } \} _ { t \in [ 0 , 1 ] }$ , where $\mathbf { y } _ { t } = A \mathbf { x } _ { t } + \alpha ( t ) \mathbf { \epsilon }$ . Unlike $\{ \mathbf { x } _ { t } \ | \ \mathbf { y } \} _ { t \in [ 0 , 1 ] }$ , the conditional stochastic process $\{ \mathbf { y } _ { t } \ | \ \mathbf { y } \} _ { t \in [ 0 , 1 ] }$ is fully tractable. First, we have ${ \bf y } _ { 0 } = \tilde { \bf A } { \bf x } _ { 0 } + \alpha ( 0 ) \epsilon = A { \bf x } _ { 0 } + \epsilon = { \bf y }$ . Since $p _ { 0 t } ( \mathbf { x } _ { t } \mid \mathbf { x } _ { 0 } ) = \mathcal { N } ( \mathbf { x } _ { t } \mid \alpha ( t ) \mathbf { x } _ { 0 } , \beta ^ { 2 } ( t ) \mathbf { I } )$ , we have $\mathbf { x } _ { t } = \alpha ( t ) \mathbf { x } _ { 0 } + \beta ( t ) \mathbf { z }$ , where $\mathbf { z } \in \mathbb { R } ^ { n } \sim \mathcal { N } ( \mathbf { 0 } , I )$ . By definition, $\mathbf { y } _ { t } = A \mathbf { x } _ { t } + \alpha ( t ) \boldsymbol { \epsilon }$ , so we have ${ \bf y } _ { t } = A ( \alpha ( t ) { \bf x } _ { 0 } + \beta ( t ) { \bf z } ) + \alpha ( t ) \epsilon = \alpha ( t ) ( { \bf y } - \epsilon ) +$ $\beta ( t ) A \mathbf { z } + \alpha ( t ) \boldsymbol { \epsilon } = \alpha ( t ) \mathbf { y } + \beta ( t ) A \mathbf { z }$ . Therefore, we can easily generate a sample $\hat { \mathbf { y } } _ { t } \sim p _ { t } ( \mathbf { y } _ { t } \mid \mathbf { y } )$ by first drawing $\mathbf { z } \sim \mathcal { N } ( \mathbf { 0 } , I )$ and then computing $\hat { \mathbf { y } } _ { t } = \alpha ( t ) \mathbf { y } + \beta ( t ) A \mathbf { z }$ .
98
+
99
+ The key of our approach is to modify any existing iterative sampling algorithm designed for the unconditional stochastic process $\{ \mathbf { x } _ { t } \} _ { t \in [ 0 , 1 ] }$ so that the samples are consistent with $\{ \mathbf { y } _ { t } \mid \mathbf { \bar { y } } \} _ { t \in [ 0 , 1 ] }$ . In general, an iterative sampling process of score-based generative models selects a sequence of time steps $\left\{ 0 = t _ { 0 } < t _ { 1 } < \cdots < t _ { N } = 1 \right\}$ and iterates according to
100
+
101
+ $$
102
+ \begin{array} { r } { \hat { \mathbf { x } } _ { t _ { i - 1 } } = h \big ( \hat { \mathbf { x } } _ { t _ { i } } , \mathbf { z } _ { i } , s _ { \theta ^ { * } } \big ( \hat { \mathbf { x } } _ { t _ { i } } , t _ { i } \big ) \big ) , \quad i = N , N - 1 , \cdots , 1 , } \end{array}
103
+ $$
104
+
105
+ where $\hat { \mathbf { x } } _ { t _ { N } } \sim \pi ( \mathbf { x } )$ , $\mathbf { z } _ { i } \sim \mathcal { N } ( \mathbf { 0 } , I )$ , and $\pmb { \theta } ^ { * }$ denotes the parameters in an unconditional score model $s _ { \theta ^ { * } } ( \mathbf { x } , t )$ . Here the iteration function $^ { h }$ takes a noisy sample $\hat { \mathbf { x } } _ { t _ { i } }$ and reduces the noise therein to generate $\hat { \mathbf { x } } _ { t _ { i - 1 } }$ , using the unconditional score model $s _ { \theta ^ { * } } ( \mathbf { x } , t )$ . For example, for the Euler-Maruyama sampler detailed in Algorithm 1, this iteration function is given by
106
+
107
+ $$
108
+ h ( \hat { \bf x } _ { t _ { i } } , { \bf z } _ { i } , s _ { \theta ^ { * } } ( \hat { \bf x } _ { t _ { i } } , t _ { i } ) ) = \hat { \bf x } _ { t _ { i } } - f ( t _ { i } ) \hat { \bf x } _ { t _ { i } } / N + g ( t _ { i } ) ^ { 2 } s _ { \theta ^ { * } } ( \hat { \bf x } _ { t _ { i } } , t _ { i } ) / N + g ( t _ { i } ) { \bf z } _ { i } / \sqrt { N } .
109
+ $$
110
+
111
+ Samples obtained by this procedure $\{ \hat { \mathbf { x } } _ { t _ { i } } \} _ { i = 0 } ^ { N }$ constitute an approximation of $\{ \mathbf { x } _ { t } \} _ { t \in [ 0 , 1 ] }$ , where the last sample $\hat { \mathbf { x } } _ { t _ { 0 } }$ can be viewed as an approximate sample from $p _ { 0 } ( \mathbf { x } )$ . Most existing sampling
112
+
113
+ ![](images/c0af5c9ecf9519f112faae328016232d8434e2a0ad75f382a2514566b95319b5.jpg)
114
+ Figure 3: (Left) An overview of our method for solving inverse problems with score-based generative models. (Right) An illustration about how to combine $\hat { \mathbf { x } } _ { t _ { i } }$ and $\mathbf { y }$ to form $\hat { \mathbf { x } } _ { t _ { i } } ^ { \prime }$ .
115
+
116
+ methods for score-based generative models are instances of this iterative sampling paradigm, including Algorithm 1, ALD (Song & Ermon, 2019), probability flow ODEs (Song et al., 2021) and PredictorCorrector samplers (Song et al., 2021).
117
+
118
+ To enforce the constraint implied by $\{ \mathbf { y } _ { t } \mid \mathbf { y } \} _ { t \in [ 0 , 1 ] }$ , we prepend an additional step to the iteration rule in Eq. (5), leading to
119
+
120
+ $$
121
+ \begin{array} { r } { \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = k ( \hat { \mathbf { x } } _ { t _ { i } } , \hat { \mathbf { y } } _ { t _ { i } } , \lambda ) \qquad } \\ { \hat { \mathbf { x } } _ { t _ { i - 1 } } = h ( \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } , \mathbf { z } _ { i } , s _ { \theta ^ { * } } ( \hat { \mathbf { x } } _ { t _ { i } } , t _ { i } ) ) , \quad i = N , N - 1 , \cdots , 1 , } \end{array}
122
+ $$
123
+
124
+ where $\hat { \mathbf { x } } _ { t _ { N } } \sim \pi ( \mathbf { x } ) , \hat { \mathbf { y } } _ { t _ { i } } \sim p _ { t _ { i } } ( \mathbf { y } _ { t _ { i } } \mid \mathbf { y } )$ , and $0 \leqslant \lambda \leqslant 1$ is a hyper-parameter. We provide an illustration of this process in Fig. 3. The iteration function $\pmb { k } ( \cdot , \hat { \mathbf { y } } _ { t _ { i } } , \lambda ) : \mathbb { R } ^ { n } \mathbb { R } ^ { n }$ promotes data consistency by solving a proximal optimization step (Nesterov, 2003; Boyd et al., 2004; Hammernik et al., 2021) that simultaneously minimizes the distance between $\hat { \mathbf { x } } _ { t _ { i } } ^ { \prime }$ and $\hat { \mathbf { x } } _ { t _ { i } }$ , and the distance between $\hat { \mathbf { x } } _ { t _ { i } } ^ { \prime }$ and the hyperplane $\left\{ \pmb { x } \in \mathbb { R } ^ { n } \ \lvert \ A \pmb { x } = \hat { \mathbf { y } } _ { t _ { i } } \right\}$ , with a hyperparameter $0 \leqslant \lambda \leqslant 1$ balancing between the two:
125
+
126
+ $$
127
+ \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = \underset { z \in \mathbb { R } ^ { n } } { \arg \operatorname* { m i n } } \{ \left( 1 - \lambda \right) \| z - \hat { \mathbf { x } } _ { t _ { i } } \| _ { T } ^ { 2 } + \underset { u \in \mathbb { R } ^ { n } } { \operatorname* { m i n } } \lambda \| z - u \| _ { T } ^ { 2 } \} \quad s . t . \quad A u = \hat { \mathbf { y } } _ { t _ { i } } .
128
+ $$
129
+
130
+ Recall that $A = \mathcal { P } ( \mathbf { \boldsymbol { \Lambda } } ) \mathbf { \boldsymbol { T } }$ according to Proposition 1. In the equation above we choose the norm $\left\| \pmb { a } \right\| _ { T } ^ { 2 } : = \left\| \pmb { T } \pmb { a } \right\| _ { 2 } ^ { 2 }$ to simplify our theoretical analysis. The decomposition in Proposition 1 allows us to derive a closed-form solution to the optimization problem in Eq. (8), as given below:
131
+
132
+ Theorem 1. The solution of Eq. (8) can be given by
133
+
134
+ $$
135
+ \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = \pmb { T } ^ { - 1 } [ \lambda \pmb { \Lambda } \mathcal { P } ^ { - 1 } ( \pmb { \Lambda } ) \hat { \mathbf { y } } _ { t _ { i } } + ( 1 - \lambda ) \pmb { \Lambda } \pmb { T } \hat { \mathbf { x } } _ { t _ { i } } + ( \pmb { I } - \pmb { \Lambda } ) \pmb { T } \hat { \mathbf { x } } _ { t _ { i } } ] ,
136
+ $$
137
+
138
+ where $\mathcal { P } ^ { - 1 } ( \mathbf { \Lambda } ) : \mathbb { R } ^ { m } \mathbb { R } ^ { n }$ denotes any right inverse of ${ \mathcal { P } } ( \Lambda )$ .
139
+
140
+ See Fig. 3 for an illustration of the function $\hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = k ( \hat { \mathbf { x } } _ { t _ { i } } , \hat { \mathbf { y } } _ { t _ { i } } , \lambda )$ . The right inverse $\mathcal { P } ^ { - 1 } ( \pmb { \Lambda } )$ increases the dimensionality of a vector $\pmb { a } \in \mathbb { R } ^ { m }$ to $n$ by putting its entries on every index $i$ of an $n$ -dimensional vector where $\mathbf { \Lambda } \Lambda _ { i i } = 1$ . Recall that in sparse-view CT or undersampled MRI, $\mathrm { d i a g } ( \pmb { \Lambda } )$ represents a subsampling mask, and ${ \mathcal { P } } ( \Lambda )$ subsamples the full sinogram/k-space to generate the observation y. In this case, $\bar { \mathcal { P } } ^ { - 1 } ( \pmb { \Lambda } )$ pads the observation y so that it has the same size as the full sinogram $/ \mathrm { k }$ -space.
141
+
142
+ When $\lambda = 0$ , $\hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = k ( \hat { \mathbf { x } } _ { t _ { i } } , \hat { \mathbf { y } } _ { t _ { i } } , 0 ) = \hat { \mathbf { x } } _ { t _ { i } }$ completely ignores the constraint $A \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = \hat { \mathbf { y } } _ { t _ { i } }$ , in which case our sampling method in Eq. (7) performs unconditional generation. On the other hand, when $\lambda = 1 , \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = k ( \hat { \mathbf { x } } _ { t _ { i } } , \hat { \mathbf { y } } _ { t _ { i } } , 1 )$ satisfies $A \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = \hat { \mathbf { y } } _ { t _ { i } }$ exactly. When the measurement is noisy, we choose $0 < \lambda < 1$ to allow slackness in the constraint $A \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = \hat { \mathbf { y } } _ { t _ { i } }$ . The value of $\lambda$ is important for balancing between $\hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } \approx \hat { \mathbf { x } } _ { t _ { i } }$ and $A \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } \approx \hat { \mathbf { y } } _ { t _ { i } }$ . In practice, we use Bayesian optimization to tune this $\lambda$ automatically on a validation dataset. When the measurement process contains no noise, we replace $\hat { \mathbf { x } } _ { t _ { 0 } }$ with $k ( \hat { \mathbf x } _ { t _ { 0 } } , \mathbf y , 1 )$ at the last sampling step to guarantee $\boldsymbol { A } \hat { \mathbf x } _ { t _ { 0 } } = \mathbf y$ .
143
+
144
+ In summary, our method given in Eq. (7) introduces minimal modifications to an existing iterative sampling method of score-based generative models. For example, we can convert the sampler in Algorithm 1 to an inverse problem solver in Algorithm 2 by adding/modifying just three lines of pseudo-code. Unlike the concurrent work Jalal et al. (2021), our method is not limited to annealed Langevin dynamics (ALD). As demonstrated in our experiments, we outperform Jalal et al. (2021) even with the same ALD sampler, and can widen the performance gap further by using more advanced approaches like the Predictor-Corrector sampler (Song et al., 2021). Unlike Kadkhodaie & Simoncelli (2020); Kawar et al. (2021), we rely on the efficient alternative representation of $\pmb { A }$ given in Section 3.1, and do not require expensive SVD computation.
145
+
146
+ ![](images/9bb6d3714bf650018a582b295662c97782f135a63fdf0565d501ed37743dae90.jpg)
147
+ Figure 4: Examples of sparse-view CT reconstruction results on LIDC $3 2 0 \times 3 2 0$ (Top row) and LDCT $5 1 2 \times 5 1 2$ (Bottom row), all with 23 projections. You may zoom in to view more details.
148
+
149
+ # 4 EXPERIMENTS
150
+
151
+ We aim to answer the following questions in this section: (1) Can we directly compete with best-inclass supervised learning techniques for the same measurement process used in their training, even though our approach is fully unsupervised? (2) Can our method generalize better to new measurement processes? (3) How do we fare against other unsupervised approaches? To study these questions, we experiment on several tasks in medical imaging, including sparse-view CT reconstruction, metal artifact removal (MAR) for CT, and undersampled MRI reconstruction. More experimental details are provided in Appendix B.
152
+
153
+ Datasets We consider two datasets for CT experiments. The first is the Lung Image Database Consortium (LIDC) image collection dataset (Armato III et al., 2011; Clark et al., 2013) where we slice the original 3D CT volumes to obtain 130304 2D images of resolution $3 2 0 \times 3 2 0$ for training. The second is the Low Dose CT (LDCT) Image and Projection dataset (Moen et al., 2021) that contains CT scans of multiple anatomic sites, including head, chest, and abdomen, from which we generate 47006 2D image slices of resolution $5 1 2 \times 5 1 2$ for training. We simulate CT measurements (sinograms) with a parallel-beam geometry using projection angles equally distributed across 180 degrees. For MAR experiments, we follow Yu et al. (2020) to synthesize metal artifacts. For undersampled MRI experiments, we use the Brain Tumor Segmentation (BraTS) 2021 dataset (Menze et al., 2014; Bakas et al., 2017), where we slice 3D MRI volumes to get 297270 images of resolution $2 4 0 \times 2 4 0$ as the training dataset. We simulate MRI measurements with Fast Fourier Transform using a single-coil setup, and follow Zbontar et al. (2018); Knoll et al. (2020) to undersample the $\mathbf { k }$ -space with an equispaced Cartesian mask. The performance is measured on 1000 test images with peak signal-to-noise ratio (PSNR) and structural similarity (SSIM).
154
+
155
+ Standard techniques in medical imaging We include two standard learning-free techniques as baselines for sparse-view CT reconstruction. The first is filtered back projection on sparse-view sinograms, which is denoted by “FBP”. The second is an iterative reconstruction method with total variation regularization called FISTA-TV (Beck & Teboulle, 2009). For MAR experiments, we include another learning-free baseline called linear interpolation (LI, Kalender et al., 1987).
156
+
157
+ Table 1: Results for undersampled MRI reconstruction on BraTS. First two methods are supervised learning techniques trained with $8 \times$ acceleration. The others are unsupervised techniques.
158
+
159
+ <table><tr><td rowspan="2">Method</td><td colspan="2">24×Acceleration</td><td colspan="2">8× Acceleration</td><td colspan="2">4× Acceleration</td></tr><tr><td>PSNR↑</td><td>SSIM↑</td><td>PSNR↑</td><td>SSIM↑</td><td>PSNR↑</td><td>SSIM↑</td></tr><tr><td>Cascade DenseNet</td><td>23.39±2.17</td><td>0.765±0.042</td><td>28.35±2.30</td><td>0.845±0.038</td><td>30.97±2.33</td><td>0.902±0.028</td></tr><tr><td>DuDoRNet</td><td>18.46±3.05</td><td>0.662±0.093</td><td>37.88±3.03</td><td>0.985±0.007</td><td>30.53±4.13</td><td>0.891±0.071</td></tr><tr><td>Score SDE</td><td>27.83±2.73</td><td>0.849±0.038</td><td>35.04±2.11</td><td>0.943±0.016</td><td>37.55±2.08</td><td>0.960±0.013</td></tr><tr><td>Langevin</td><td>28.80±3.21</td><td>0.873±0.039</td><td>36.44±2.28</td><td>0.952±0.016</td><td>38.76±2.32</td><td>0.966±0.012</td></tr><tr><td>Ours</td><td>29.42±3.03</td><td>0.880±0.035</td><td>37.63±2.70</td><td>0.958±0.015</td><td>39.91±2.67</td><td>0.965±0.013</td></tr></table>
160
+
161
+ Table 2: Results for sparse-view CT reconstruction on LIDC and LDCT. FISTA-TV is a standard iterative reconstruction method that does not need training. cGAN, Neumann, and SIN- $_ { \mathrm { 4 c } }$ -PRN are supervised learning techniques trained with 23 projection angles.
162
+
163
+ <table><tr><td rowspan="2">Method</td><td rowspan="2">Projections</td><td colspan="2">LIDC 320× 320</td><td colspan="2">LDCT 512 × 512</td></tr><tr><td>PSNR↑</td><td>SSIM↑</td><td>PSNR↑</td><td>SSIM↑</td></tr><tr><td>FBP</td><td>23</td><td>10.18±1.38</td><td>0.230±0.072</td><td>10.11±1.19</td><td>0.302±0.078</td></tr><tr><td>FISTA-TV</td><td>23</td><td>20.08±4.89</td><td>0.799±0.061</td><td>21.88±4.42</td><td>0.850±0.067</td></tr><tr><td>cGAN</td><td>23</td><td>19.83±3.07</td><td>0.479±0.103</td><td>19.90±2.52</td><td>0.545±0.065</td></tr><tr><td>Neumann</td><td>23</td><td>17.18±3.79</td><td>0.454±0.128</td><td>18.83±3.29</td><td>0.525±0.073</td></tr><tr><td>SIN-4c-PRN</td><td>23</td><td>30.48±3.99</td><td>0.895±0.047</td><td>34.82±3.55</td><td>0.877±0.116</td></tr><tr><td rowspan="3"> Ours</td><td>10</td><td>29.52±2.63</td><td>0.823±0.061</td><td>28.96±4.41</td><td>0.849±0.086</td></tr><tr><td>20</td><td>34.40±2.66</td><td>0.895±0.048</td><td>36.80±4.50</td><td>0.936±0.058</td></tr><tr><td>23</td><td>35.24±2.71</td><td>0.905±0.046</td><td> 37.41±4.62</td><td>0.941±0.057</td></tr></table>
164
+
165
+ Supervised learning baselines For sparse-view CT on both LIDC and LDCT, we include cGAN (Ghani & Karl, 2018), Neumann (Gilton et al., 2019), and SIN- $_ \mathrm { 4 c }$ -PRN (Wei et al., 2020) as supervised learning baselines. We follow the settings in Wei et al. (2020) and train all methods with 23 projection angles. For MAR, we use cGANMAR (Wang et al., 2018) and SNMAR (Yu et al., 2020) as the baselines. For undersampled MRI on BraTS, we compare against Cascade DenseNet (Zheng et al., 2019) and DuDoRNet (Zhou & Zhou, 2020), which are both trained with a $8 \times$ acceleration factor by measuring only $1 / 8$ of the full $\mathbf { k }$ -space.
166
+
167
+ Unsupervised learning baselines For unsupervised techniques, so far only score-based generative models have witnessed success on clinic data. We compare with several existing methods that apply score-based generative models to inverse problem solving. Specifically, we consider the “Langevin” approach proposed in Jalal et al. (2021), and the “Score SDE” method in Song et al. (2021), where the former is limited to annealed Langevin dynamics (ALD) sampling, and the latter was based on a crude approximation to the conditional score function $\nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } \mid \mathbf { y } )$ in Eq. (4), and was proposed as a theoretical possibility in Appendix I.4 of Song et al. (2021) without experiments. We only focus on undersampled MRI for these baselines, since it is the only medical imaging problem ever tackled with score-based generative models before our work. All methods share the same score models and only differ in terms of inference. We make sure all sampling algorithms have comparable number of iteration steps ( $N$ in Eqs. (5) and (7)).
168
+
169
+ Competing with supervised learning approaches Thanks to the outstanding sample quality of score-based generative models, we can achieve comparable or better performance than best-in-class supervised learning methods even for the same measurement process used in their training. As shown in Table 2, we outperform the top supervised learning technique SIN- $_ { \mathrm { 4 c } }$ -PRN on sparse-view CT reconstruction by a significant margin, on both the LIDC and LDCT datasets. Our results with
170
+
171
+ Table 3: MAR results on LIDC.
172
+
173
+ <table><tr><td>Method</td><td>PSNR↑</td><td>SSIM↑</td></tr><tr><td>LI</td><td>26.30±2.62</td><td>0.910±0.028</td></tr><tr><td>cGANMAR</td><td>27.27±1.96</td><td>0.927±0.060</td></tr><tr><td>SNMAR</td><td>27.28±1.43</td><td>0.937±0.048</td></tr><tr><td>Ours</td><td> 32.16±2.32</td><td>0.939±0.022</td></tr></table>
174
+
175
+ 20 measurements are even better than supervised learning counterparts with 23 measurements. In Fig. 4, we provide a visual comparison of the reconstruction quality for various methods, where it is clear to see that our method can recover more details faithfully. From results in Table 3, we also outperform the top supervised learning method SNMAR on metal artifact removal. As shown in Fig. 7, our method generates images with less artifacts and preserves the structure better. For undersampled MRI reconstruction results given in Tables 1 and 3, our method is ranked the 2nd for the case of $8 \times$ acceleration, with comparable performance to the top supervised method DuDoRNet.
176
+
177
+ ![](images/70209982aeff030c78d4431e06a6f3bef473450317e7fa79ef05888d70dd21da.jpg)
178
+ Figure 5: Performance vs. numbers of measurements. Shaded areas represent standard deviation. (Left) MRI on BraTS. (Center) CT on LIDC. (Right) Comparing score-based generative models for undersampled MRI reconstruction on BraTS.
179
+
180
+ Generalizing to different number of measurements Since our approach is fully unsupervised, we can naturally apply the same score model to different measurement processes. We first consider changing the number of measurements at the test time, e.g., using different number of projection angles (resp. different acceleration factors) for sparse-view CT (resp. undersampled MRI) reconstruction. As shown in Table 1 and Fig. 5 (Left), we achieve the best performance on undersampled MRI for both $2 4 \times$ and $4 \times$ acceleration factors, whereas DuDoRNet fails to generalize when the acceleration factor changes. The other supervised learning approach Cascade DenseNet demonstrates limited adaptability by building a model architecture inspired by the physical measurement process of MRI, but fails to yield top-level performance. For sparse-view CT reconstruction, all supervised learning methods struggle to generalize to different projection angles, as shown in Fig. 5 (Center).
181
+
182
+ Generalizing to different measurement processes in CT We can perform both sparse-view CT reconstruction and metal artifact removal (MAR) with a single score model trained on CT images. These two tasks are inverse problems in CT imaging with different measurement processes $\pmb { A }$ , but they share the same $\mathbf { T }$ in the decomposition of Proposition 1. We provide a visualization of the measurement process corresponding to MAR in Fig. 8. As shown in Table 3, we can outperform supervised learning techniques specifically designed and trained for MAR, while using the same score model used in sparse-view CT reconstruction on LIDC.
183
+
184
+ Comparing against existing score-based methods We compare our method against Langevin (Jalal et al., 2021) and Score SDE (Song et al., 2021) for undersampled MRI reconstruction on BraTS. Two variants of our approach are considered, which respectively use annealed Langevin dynamics (ALD) and the Predictor-Corrector (PC) sampler for score-based generative models as the backend. We denote the former by $\mathrm { \ddot { \ s u } L D + O u r s { \vec { \nu } } }$ , and the latter by “PC $^ +$ Ours” (our default method for all other experiments). Recall that Langevin uses ALD as the sampler, same as $\mathrm { ^ { 6 6 } A L D + O u r s ^ { 3 7 } }$ . All results are provided in Fig. 5 (Right). We observe that “ALD $^ +$ Ours” uniformly outperform Langevin and Score SDE across all numbers of measurements in the experiment. Moreover, ${ } ^ { \mathrm { s } } \mathrm { P C } +$ Ours” can further improve “ALD $^ +$ Ours”, demonstrating the power of switching to more advanced sampling methods of score-based generative models in our proposed approach.
185
+
186
+ # 5 CONCLUSION
187
+
188
+ We propose a new method to solve linear inverse problems with score-based generative models. Our method is fully unsupervised, requires no paired data for training, can flexibly adapt to different measurement processes at test time, and only requires minimal modifications to a large number of existing sampling methods of score-based generative models. Empirical results demonstrate that our method can match or outperform existing supervised learning counterparts on image reconstruction for sparse-view CT and undersampled MRI, and has better generalization to new measurement processes, such as using a different number of projections or downsampling ratios in CT/MRI, and tackling both sparse-view CT reconstruction and metal artifact removal with a single model.
189
+
190
+ # AUTHOR CONTRIBUTIONS
191
+
192
+ Yang Song designed the project, wrote the paper, and ran all experiments for score-based generative models. Liyue Shen preprocessed data, ran all baseline experiments, and helped write the paper. Lei Xing and Stefano Ermon supervised the project, provided valuable feedback, and helped edit the paper.
193
+
194
+ # ACKNOWLEDGMENTS
195
+
196
+ YS is supported by the Apple PhD Fellowship in AI/ML. LS is supported by the Stanford Bio-X Graduate Student Fellowship. This research was supported by NSF (#1651565, #1522054, #1733686), ONR (N000141912145), AFOSR (FA95501910024), ARO (W911NF-21-1-0125), Sloan Fellowship, and Google TPU Research Cloud. This research was also supported by NIH/NCI (1R01 CA256890 and 1R01 CA227713).
197
+
198
+ # REFERENCES
199
+
200
+ Vegard Antun, Francesco Renna, Clarice Poon, Ben Adcock, and Anders C Hansen. On instabilities of deep learning in image reconstruction and the potential costs of ai. Proceedings of the National Academy of Sciences, 117(48):30088–30095, 2020.
201
+
202
+ Samuel G Armato III, Geoffrey McLennan, Luc Bidaut, Michael F McNitt-Gray, Charles R Meyer, Anthony P Reeves, Binsheng Zhao, Denise R Aberle, Claudia I Henschke, Eric A Hoffman, et al. The lung image database consortium (lidc) and image database resource initiative (idri): a completed reference database of lung nodules on ct scans. Medical physics, 38(2):915–931, 2011.
203
+
204
+ Spyridon Bakas, Hamed Akbari, Aristeidis Sotiras, Michel Bilello, Martin Rozycki, Justin S Kirby, John B Freymann, Keyvan Farahani, and Christos Davatzikos. Advancing the cancer genome atlas glioma mri collections with expert segmentation labels and radiomic features. Scientific data, 4(1): 1–13, 2017.
205
+
206
+ Amir Beck and Marc Teboulle. A fast iterative shrinkage-thresholding algorithm for linear inverse problems. SIAM journal on imaging sciences, 2(1):183–202, 2009.
207
+
208
+ Stephen Boyd, Stephen P Boyd, and Lieven Vandenberghe. Convex optimization. Cambridge university press, 2004.
209
+
210
+ Thorsten M Buzug. Computed tomography. In Springer handbook of medical technology, pp. 311–342. Springer, 2011.
211
+
212
+ Kenneth Clark, Bruce Vendt, Kirk Smith, John Freymann, Justin Kirby, Paul Koppel, Stephen Moore, Stanley Phillips, David Maffitt, Michael Pringle, et al. The cancer imaging archive (tcia): maintaining and operating a public information repository. Journal of digital imaging, 26(6): 1045–1057, 2013.
213
+
214
+ Prafulla Dhariwal and Alex Nichol. Diffusion models beat GANs on image synthesis. arXiv preprint arXiv:2105.05233, 2021.
215
+
216
+ Muhammad Usman Ghani and W Clem Karl. Deep learning-based sinogram completion for low-dose ct. In 2018 IEEE 13th Image, Video, and Multidimensional Signal Processing Workshop (IVMSP), pp. 1–5. IEEE, 2018.
217
+
218
+ Davis Gilton, Greg Ongie, and Rebecca Willett. Neumann networks for linear inverse problems in imaging. IEEE Transactions on Computational Imaging, 6:328–343, 2019.
219
+
220
+ Kerstin Hammernik, Jo Schlemper, Chen Qin, Jinming Duan, Ronald M Summers, and Daniel Rueckert. Systematic evaluation of iterative deep neural networks for fast parallel mri reconstruction with sensitivity-weighted coil combination. Magnetic Resonance in Medicine, 2021.
221
+
222
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising Diffusion Probabilistic Models. Advances in Neural Information Processing Systems, 33, 2020.
223
+
224
+ Ajil Jalal, Marius Arvinte, Giannis Daras, Eric Price, Alexandros G Dimakis, and Jonathan I Tamir. Robust compressed sensing mri with deep generative priors. arXiv preprint arXiv:2108.01368, 2021.
225
+
226
+ Zahra Kadkhodaie and Eero P Simoncelli. Solving linear inverse problems using the prior implicit in a denoiser. arXiv preprint arXiv:2007.13640, 2020.
227
+
228
+ Willi A Kalender, Robert Hebel, and Johannes Ebersberger. Reduction of ct artifacts caused by metallic implants. Radiology, 164(2):576–577, 1987.
229
+
230
+ Bahjat Kawar, Gregory Vaksman, and Michael Elad. Snips: Solving noisy inverse problems stochastically. arXiv preprint arXiv:2105.14951, 2021.
231
+
232
+ Daniil Kazantsev and Nicola Wadeson. Tomographic model-based reconstruction (tomobar) software for high resolution synchrotron x-ray tomography. CT Meeting, 2020.
233
+
234
+ Daniil Kazantsev, Edoardo Pasca, Martin J Turner, and Philip J Withers. Ccpi-regularisation toolkit for computed tomographic image reconstruction with proximal splitting algorithms. SoftwareX, 9: 317–323, 2019.
235
+
236
+ Florian Knoll, Jure Zbontar, Anuroop Sriram, Matthew J Muckley, Mary Bruno, Aaron Defazio, Marc Parente, Krzysztof J Geras, Joe Katsnelson, Hersh Chandarana, et al. fastmri: A publicly available raw $\mathbf { k }$ -space and dicom dataset of knee images for accelerated mr image reconstruction using machine learning. Radiology: Artificial Intelligence, 2(1):e190007, 2020.
237
+
238
+ Morteza Mardani, Enhao Gong, Joseph Y Cheng, Shreyas Vasanawala, Greg Zaharchuk, Marcus Alley, Neil Thakur, Song Han, William Dally, John M Pauly, et al. Deep generative adversarial networks for compressed sensing automates mri. arXiv preprint arXiv:1706.00051, 2017.
239
+
240
+ Bjoern H Menze, Andras Jakab, Stefan Bauer, Jayashree Kalpathy-Cramer, Keyvan Farahani, Justin Kirby, Yuliya Burren, Nicole Porz, Johannes Slotboom, Roland Wiest, et al. The multimodal brain tumor image segmentation benchmark (brats). IEEE transactions on medical imaging, 34(10): 1993–2024, 2014.
241
+
242
+ Taylor R Moen, Baiyu Chen, David R Holmes III, Xinhui Duan, Zhicong Yu, Lifeng Yu, Shuai Leng, Joel G Fletcher, and Cynthia H McCollough. Low-dose ct image and projection dataset. Medical physics, 48(2):902–911, 2021.
243
+
244
+ Yurii Nesterov. Introductory lectures on convex optimization: A basic course, volume 87. Springer Science & Business Media, 2003.
245
+
246
+ Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems 32, pp. 8024–8035. Curran Associates, Inc., 2019.
247
+
248
+ Matteo Ronchetti. Torchradon: Fast differentiable routines for computed tomography. arXiv preprint arXiv:2009.14788, 2020.
249
+
250
+ Simo Särkkä and Arno Solin. Applied stochastic differential equations, volume 10. Cambridge University Press, 2019.
251
+
252
+ Liyue Shen, Wei Zhao, and Lei Xing. Patient-specific reconstruction of volumetric computed tomography images from a single projection view via deep learning. Nature biomedical engineering, 3(11):880–888, 2019.
253
+
254
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. In Advances in Neural Information Processing Systems, pp. 11918–11930, 2019.
255
+
256
+ Yang Song and Stefano Ermon. Improved techniques for training score-based generative models. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
257
+
258
+ 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. URL https://openreview.net/forum? id=PxTIG12RRHS.
259
+
260
+ Pascal Vincent. A Connection Between Score Matching and Denoising Autoencoders. Neural Computation, 23(7):1661–1674, 2011.
261
+
262
+ Marinus T Vlaardingerbroek and Jacques A Boer. Magnetic resonance imaging: theory and practice. Springer Science & Business Media, 2013.
263
+
264
+ Jianing Wang, Yiyuan Zhao, Jack H Noble, and Benoit M Dawant. Conditional generative adversarial networks for metal artifact reduction in ct images of the ear. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 3–11. Springer, 2018.
265
+
266
+ Haoyu Wei, Florian Schiffers, Tobias Würfl, Daming Shen, Daniel Kim, Aggelos K Katsaggelos, and Oliver Cossairt. 2-step sparse-view ct reconstruction with a domain-specific perceptual network. arXiv preprint arXiv:2012.04743, 2020.
267
+
268
+ Tobias Würfl, Mathis Hoffmann, Vincent Christlein, Katharina Breininger, Yixin Huang, Mathias Unberath, and Andreas K Maier. Deep learning computed tomography: Learning projectiondomain weights from image domain in limited angle problems. IEEE transactions on medical imaging, 37(6):1454–1463, 2018.
269
+
270
+ Lequan Yu, Zhicheng Zhang, Xiaomeng Li, and Lei Xing. Deep sinogram completion with image prior for metal artifact reduction in ct images. IEEE Transactions on Medical Imaging, 40(1): 228–238, 2020.
271
+
272
+ Jure Zbontar, Florian Knoll, Anuroop Sriram, Tullie Murrell, Zhengnan Huang, Matthew J. Muckley, Aaron Defazio, Ruben Stern, Patricia Johnson, Mary Bruno, Marc Parente, Krzysztof J. Geras, Joe Katsnelson, Hersh Chandarana, Zizhao Zhang, Michal Drozdzal, Adriana Romero, Michael Rabbat, Pascal Vincent, Nafissa Yakubova, James Pinkerton, Duo Wang, Erich Owens, C. Lawrence Zitnick, Michael P. Recht, Daniel K. Sodickson, and Yvonne W. Lui. fastMRI: An open dataset and benchmarks for accelerated MRI. 2018.
273
+
274
+ Hao Zheng, Faming Fang, and Guixu Zhang. Cascaded dilated dense network with two-step data consistency for mri reconstruction. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. URL https://proceedings.neurips.cc/paper/2019/ file/1e48c4420b7073bc11916c6c1de226bb-Paper.pdf.
275
+
276
+ Bo Zhou and S Kevin Zhou. Dudornet: Learning a dual-domain recurrent network for fast mri reconstruction with deep t1 prior. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4273–4282, 2020.
277
+
278
+ Bo Zhu, Jeremiah Z Liu, Stephen F Cauley, Bruce R Rosen, and Matthew S Rosen. Image reconstruction by domain-transform manifold learning. Nature, 555(7697):487–492, 2018.
279
+
280
+ # A PROOFS
281
+
282
+ Proposition 1. $I f \operatorname { r a n k } ( A ) = m$ , then there exist an invertible matrix $\pmb { T } \in \mathbb { R } ^ { n \times n }$ , and a diagonal matrix $\pmb { \Lambda } \in \{ 0 , 1 \} ^ { n \times n }$ with $\operatorname { t r } ( \mathbf { \mathbf { \boldsymbol { \Lambda } } } ) = m$ , such that $A = \mathcal { P } ( \mathbf { \boldsymbol { \Lambda } } ) \mathbf { \boldsymbol { T } }$ . Here $\mathcal { P } ( \mathbf { A } ) \in \{ 0 , 1 \} ^ { m \times n }$ is an operator that, when multiplied with any vector $\mathbf { \pmb { a } } \in \mathbb { R } ^ { n }$ , reduces its dimensionality to m by removing each $i$ -th element of $\textbf { \em a }$ for $i = 1 , 2 , \cdots , n$ if $\mathbf { \Lambda } \Lambda _ { i i } = 0$ .
283
+
284
+ Proof. Let $\textbf { \textit { A } } = \mathbf { \beta } \left( \pmb { a } _ { 1 } ^ { \mathsf { T } } , \pmb { a } _ { 2 } ^ { \mathsf { T } } , \cdot \cdot \cdot , \pmb { a } _ { m } ^ { \mathsf { T } } \right) \ \in \ \mathbb { R } ^ { m \times n }$ . Since $\pmb { A }$ has full rank, the row vectors $\{ a _ { 1 } , a _ { 2 } , \cdots , a _ { m } \}$ are linearly independent. We can therefore extend them to a total of $n$ linearly independent vectors, i.e., $\{ a _ { 1 } , \dotsc , a _ { 2 } , \dotsc , a _ { m } , b _ { 1 } , \dotsc , b _ { n - m } \}$ . Due to the linear independence, we know $\pmb { T } = ( \pmb { a } _ { 1 } ^ { \top } , \pmb { a } _ { 2 } ^ { \top } , \cdot \cdot \cdot , \pmb { a } _ { m } ^ { \top } , \pmb { b } _ { 1 } ^ { \top } , \cdot \cdot \cdot , \pmb { b } _ { n - m } ^ { \top } ) \in \mathbb { R } ^ { n \times n }$ has full rank and is invertible. Next, we define
285
+
286
+ $$
287
+ \pmb { \Lambda } = \mathrm { d i a g } ( \underbrace { 1 , 1 , \cdots , 1 } _ { m } , \underbrace { 0 , 0 , \cdots , 0 } _ { n - m } ) ,
288
+ $$
289
+
290
+ where diag converts a vector to a diagonal matrix. Clearly $\operatorname { t r } ( \mathbf { \mathbf { \boldsymbol { \Lambda } } } ) = m$ and $A = \mathcal { P } ( \mathbf { \boldsymbol { \Lambda } } ) \mathbf { \boldsymbol { T } }$ , which completes the proof. □
291
+
292
+ Lemma 1. Let $\mathcal { P } ^ { - 1 } ( \pmb { \Lambda } ) : \mathbb { R } ^ { m } \mathbb { R } ^ { n }$ be any right inverse of $\mathcal { P } ( \mathbf { A } ) : \mathbb { R } ^ { n } \mathbb { R } ^ { m }$ . For any $\pmb { u } \in \mathbb { R } ^ { n }$ and $\hat { \mathbf { y } } _ { t } \in \mathbb { R } ^ { m }$ , we have
293
+
294
+ $$
295
+ \mathcal { P } ( \Lambda ) \pmb { T } \pmb { u } = \hat { \mathbf { y } } _ { t } \iff \Lambda \pmb { T } \pmb { u } = \Lambda \mathcal { P } ^ { - 1 } ( \pmb { \Lambda } ) \hat { \mathbf { y } } _ { t }
296
+ $$
297
+
298
+ Proof. By the definition of ${ \mathcal { P } } ( \Lambda )$ , we have $\mathcal { P } ( \mathbf { \boldsymbol { \Lambda } } ) = \mathcal { P } ( \mathbf { \boldsymbol { \Lambda } } ) \mathbf { \boldsymbol { \Lambda } }$ , and
299
+
300
+ $$
301
+ \forall a \in \mathbb { R } ^ { n } , b \in \mathbb { R } ^ { n } : \quad \mathcal { P } ( \Lambda ) a = \mathcal { P } ( \Lambda ) b \iff \Lambda a = \Lambda b .
302
+ $$
303
+
304
+ To prove the “if” direction, we note that
305
+
306
+ $$
307
+ \begin{array} { r l } & { \Lambda T u = \Lambda \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t } \implies \mathcal { P } ( \Lambda ) \Lambda T u = \mathcal { P } ( \Lambda ) \Lambda \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t } } \\ & { \implies \mathcal { P } ( \Lambda ) T u = \mathcal { P } ( \Lambda ) \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t } } \\ & { \implies \mathcal { P } ( \Lambda ) T u = \hat { \mathbf { y } } _ { t } . } \end{array}
308
+ $$
309
+
310
+ To prove the “only if” direction, we have
311
+
312
+ $$
313
+ \begin{array} { r } { \begin{array} { r } { \mathcal { P } ( \Lambda ) \pmb { T } \pmb { u } = \hat { \mathbf { y } } _ { t } \implies \mathcal { P } ( \Lambda ) \pmb { T } \pmb { u } = \mathcal { P } ( \Lambda ) \mathcal { P } ^ { - 1 } ( \pmb { \Lambda } ) \hat { \mathbf { y } } _ { t } } \\ { \overset { ( i ) } { \implies } \pmb { \Lambda } \pmb { T } \pmb { u } = \pmb { \Lambda } \mathcal { P } ^ { - 1 } ( \pmb { \Lambda } ) \hat { \mathbf { y } } _ { t } , } \end{array} } \end{array}
314
+ $$
315
+
316
+ where (i) is due to the property in Eq. (10). This completes the proof for both directions.
317
+
318
+ Theorem 1. The solution of Eq. (8) can be given by
319
+
320
+ $$
321
+ \hat { \mathbf { x } } _ { t _ { i } } ^ { \prime } = \pmb { T } ^ { - 1 } [ \lambda \pmb { \Lambda } \mathcal { P } ^ { - 1 } ( \pmb { \Lambda } ) \hat { \mathbf { y } } _ { t _ { i } } + ( 1 - \lambda ) \pmb { \Lambda } \pmb { T } \hat { \mathbf { x } } _ { t _ { i } } + ( \pmb { I } - \pmb { \Lambda } ) \pmb { T } \hat { \mathbf { x } } _ { t _ { i } } ] ,
322
+ $$
323
+
324
+ where $\mathcal { P } ^ { - 1 } ( \mathbf { \Lambda } ) : \mathbb { R } ^ { m } \mathbb { R } ^ { n }$ denotes any right inverse of ${ \mathcal { P } } ( \Lambda )$ .
325
+
326
+ Proof. The optimization objective function in Eq. (8) can be written as
327
+
328
+ $$
329
+ \begin{array} { r l } & { \quad ( 1 - \lambda ) \left\| z - \hat { \mathbf { x } } _ { t } \right\| _ { T } ^ { 2 } + \lambda \left\| z - u \right\| _ { T } ^ { 2 } } \\ & { = ( 1 - \lambda ) \left\| T z - T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| T z - T u \right\| _ { 2 } ^ { 2 } } \\ & { = ( 1 - \lambda ) \left\| T z - T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| \Lambda T ( z - u ) + ( I - \Lambda ) T ( z - u ) \right\| _ { 2 } ^ { 2 } } \\ & { = ( 1 - \lambda ) \left\| T z - T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| \Lambda T ( z - u ) \right\| _ { 2 } ^ { 2 } + \lambda \left\| ( I - \Lambda ) T ( z - u ) \right\| _ { 2 } ^ { 2 } } \\ & { = ( 1 - \lambda ) \left\| T z - T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| \Lambda T z - \Lambda \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| ( I - \Lambda ) T ( z - u ) \right\| _ { 2 } ^ { 2 } } \end{array}
330
+ $$
331
+
332
+ ![](images/9a8115b2f58451217268eeeb35a5d6f7410b77885fd91f449da92be6afcbfdae.jpg)
333
+ Figure 6: SSIM vs. numbers of measurements. Shaded areas represent standard deviation. (Left) MRI on BraTS. (Center) CT on LIDC. (Right) Comparing score-based generative models for undersampled MRI reconstruction on BraTS.
334
+
335
+ ![](images/2bdfae454ea0dd7e1f8188a61e71a34848c1b6f31521152d564565d1d6621544.jpg)
336
+ Figure 7: Examples of metal artifact removal on LIDC. You may zoom in to view more details.
337
+
338
+ Since $\mathbf { \nabla } A \mathbf { u } = \hat { \mathbf { y } } _ { t }$ , we have $\mathcal { P } ( \mathbf { A } ) \pmb { T } \pmb { u } = \hat { \mathbf { y } } _ { t }$ and equivalently $\Lambda T u = \Lambda \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t }$ due to Lemma 1. This constraint does not restrict the value of $( I - \Lambda ) T u$ . Therefore, when $\mathbf { \nabla } A \mathbf { u } = \hat { \mathbf { y } } _ { t }$ , we have
339
+
340
+ $$
341
+ \begin{array} { r l } & { \quad \left\| z - \dot { \mathbf { x } } _ { t } \right\| _ { T } ^ { 2 } + \operatorname* { m i n } ( 1 - \lambda ) \lambda \left\| z - u \right\| _ { T } ^ { 2 } } \\ & { = ( 1 - \lambda ) \left\| T z - T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } + \operatorname* { m i n } \lambda \left\| \Lambda T z - \Lambda \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| ( I - \Lambda ) T ( z - u ) \right\| _ { 2 } ^ { 2 } } \\ & { - ( 1 - \lambda ) \left\| T z - T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| \Lambda T z - \Lambda \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t } \right\| _ { 2 } ^ { 2 } } \\ & { = ( 1 - \lambda ) \left\| \Lambda T z - \Lambda T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| \Lambda T z - \Lambda \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t } \right\| _ { 2 } ^ { 2 } + ( 1 - \lambda ) \left\| ( I - \Lambda ) T z - ( I - \Lambda ) T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } } \end{array}
342
+ $$
343
+
344
+ This simplifies the optimization problem in Eq. (8) to
345
+
346
+ $\operatorname* { n i n } _ { z } ( 1 - \lambda ) \left\| \Lambda T z - \Lambda T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } + \lambda \left\| \Lambda T z - \Lambda \mathcal { P } ^ { - 1 } ( \Lambda ) \hat { \mathbf { y } } _ { t } \right\| _ { 2 } ^ { 2 } + ( 1 - \lambda ) \left\| ( I - \Lambda ) T z - ( I - \Lambda ) T \hat { \mathbf { x } } _ { t } \right\| _ { 2 } ^ { 2 } ,$ k 22 , which is minimizing a quadratic function of $_ z$ . The optimal solution $z ^ { * }$ is thus in closed form:
347
+
348
+ $$
349
+ \begin{array} { r } { z ^ { * } = \pmb { T } ^ { - 1 } [ ( \pmb { I } - \pmb { \Lambda } ) \pmb { T } \hat { \mathbf { x } } _ { t } + ( 1 - \lambda ) \pmb { \Lambda } \pmb { T } \hat { \mathbf { x } } _ { t } + \lambda \pmb { \Lambda } \pmb { \mathcal { P } } ^ { - 1 } ( \pmb { \Lambda } ) \hat { \mathbf { y } } _ { t } ] . } \end{array}
350
+ $$
351
+
352
+ According to the definition, $\hat { \mathbf { x } } _ { t } ^ { \prime } = z ^ { * }$ , whereby the proof is completed.
353
+
354
+ # B ADDITIONAL EXPERIMENTAL DETAILS
355
+
356
+ # B.1 ADDITIONAL RESULTS
357
+
358
+ In Fig. 6, we provide SSIM results versus the number of measurements for multiple methods and tasks. In general, the SSIM curves have very similar trends to the PSNR curves in Fig. 5. We additionally provide a visualization of metal artifact removal results in Fig. 7.
359
+
360
+ # B.2 THE TASK OF METAL ARTIFACT REMOVAL
361
+
362
+ Metallic implants in an object can cause strong metal artifacts in CT imaging. As shown in Fig. 8, the source of artifacts come from extremely bright regions in the sinogram, called metal traces. To reduce or ideally remove metal artifacts from a CT image, we remove metal traces from the sinogram and leverage the data prior to complete the sinogram. As a result, metal artifact removal can be viewed as an inverse problem, where the measurement process gives the full sinogram except for the metal trace region, and our goal is to reconstruct the full CT image using this partially known sinogram, which will be artifact-free assuming perfect inpainting of the sinogram.
363
+
364
+ ![](images/4f7fbf69277046619f0d9f5574bcbb471b9501e40ab3e9337e7c63761cba0910.jpg)
365
+ Figure 8: The linear measurement process of metal artifact removal.
366
+
367
+ # B.3 DETAILS OF DATASETS
368
+
369
+ CT datasets We conduct experiments of 2D CT image reconstruction on two datasets. First, the Lung Image Database Consortium image collection (LIDC) (Armato III et al., 2011; Clark et al., 2013) consists of diagnostic and lung cancer screening thoracic computed tomography (CT) scans for lung cancer detection and diagnosis, which contains 1018 cases. Second, the Low Dose CT Image and Projection dataset (LDCT) (Clark et al., 2013; Moen et al., 2021) involves CT images of multiple anatomic sites, including 99 head CT scans, 100 chest CT scans, and 100 abdomen CT scans. Note that for the LDCT dataset, we only use the full-dose CT images in our experiments. In CT image processing, we convert the Hounsfield units from dicom files to the attenuation coefficients and set the background pixels to zero. Then, 2D CT images are sliced from 3D CT volumes. The sinograms are simulated from 2D CT images based on parallel-beam geometry with different number of projection angles that are equally distributed across 180 degrees.
370
+
371
+ MRI dataset The Brain Tumor Segmentation (BraTS) 2021 dataset (Menze et al., 2014; Bakas et al., 2017) collected for the image segmentation challenge contains 2000 cases (8000 MRI scans), where each case has four different MR contrasts: native (T1), post-contrast T1-weighted (T1Gd), T2-weighted (T2), and T2 Fluid Attenuated Inversion Recovery (T2-FLAIR). For each 3D MR volume, we extract 2D slices from 3D volumes and simulate k-space data by Fast Fourier Transform. To reconstruct MR images, we follow Knoll et al. (2020); Zbontar et al. (2018) to undersample $\mathbf { k }$ -space data with an equispaced Cartesian mask, where the center k-space is fully sampled while the left $\mathbf { k }$ -space is under-sampled by equispaced columns.
372
+
373
+ # B.4 DETAILS OF SCORE-BASED GENERATIVE MODELS
374
+
375
+ We use the ${ \mathrm { N C S N } } { + + }$ model architecture in Song et al. (2021), and perturb the data with the Variance Exploding (VE) SDE. Our training procedure follows that of Song et al. (2021). Instead of generating samples according to the numerical SDE solver in Algorithm 1, we use the Predictor-Corrector (PC) sampler as described in Song et al. (2021) since it generally has better performance for VE SDEs. In PC samplers, the predictor refers to a numerical solver for the reverse-time SDE while the corrector can be any Markov chain Monte Carlo (MCMC) method that only depends on the scores. One such MCMC method considered in this work is Langevin dynamics, whereby we transform any initial sample $\mathbf { x } ^ { ( 0 ) }$ to an approximate sample from $p _ { t } ( \mathbf { x } )$ via the following procedure:
376
+
377
+ $$
378
+ \begin{array} { r } { \mathbf { x } ^ { ( i + 1 ) } \gets \mathbf { x } ^ { ( i ) } + \epsilon \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } ^ { ( i ) } ) + \sqrt { 2 \epsilon } \mathbf { z } ^ { ( i ) } , \quad i = 0 , 1 , \cdots , N - 1 . } \end{array}
379
+ $$
380
+
381
+ Here $N \in \mathbb { N } _ { > 0 } , \epsilon > 0$ , and $\mathbf { z } ^ { ( i ) } \sim \mathcal { N } ( \mathbf { 0 } , I )$ . The theory of Langevin dynamics guarantees that in the limit of $N \infty$ and $\epsilon \to 0 , \mathbf { x } ^ { ( N ) }$ is a sample from $p _ { t } ( \mathbf { x } )$ under some regularity conditions. Note that Langevin dynamics only requires the knowledge of $\nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } )$ , which can be approximated using the time-dependent score model $s \mathbf { \boldsymbol { \theta } } \ast \left( \mathbf { \boldsymbol { x } } , t \right)$ . In PC samplers, each predictor step immediately follows multiple consecutive corrector steps, all using the same $s _ { \theta ^ { * } } ( \mathbf { x } , t )$ evaluated at the same $t$ . This jointly ensures that our intermediate sample at $t$ is approximately distributed according to $p _ { t } ( \mathbf { x } )$ . As shown in Song et al. (2021), PC sampling often outperforms numerical solvers for the reverse-time SDE, especially when the forward SDE in Eq. (1) is a VE SDE. In order to use PC samplers for inverse problem solving, our modification is similar to the change made in Algorithm 2 for Algorithm 1. Specifically, we run line 4 & 5 in Algorithm 2 before every corrector or predictor step.
382
+
383
+ When comparing our approach to previous methods with score-based generative models, we use the same score model to isolate the confounding factors in model training and architecture design. Moreover, we make sure the total cost of sampling is comparable across different methods. For the ALD sampler used in Jalal et al. (2021), we use 700 noise scales with 3 steps of Langevin dynamics per noise scale, resulting in a total of $7 0 0 \times 3 = 2 1 0 0$ steps that require score function evaluation. For the PC sampler, we use 1000 noise scales and 1 step of Langevin dynamics per noise scale, totalling $1 0 0 0 + 1 0 0 0 = 2 0 0 0$ steps of score model evaluation.
384
+
385
+ For PC samplers, the step size $\epsilon$ in Langevin dynamics is determined by a signal-to-noise ratio $\eta$ . For all methods, we tune $\eta$ and $\lambda$ in Eq. (8) with 100 steps of Bayesian optimization on a validation dataset, and report the results on the test dataset with the optimal parameters. We use the $\mathsf { a x } - \mathsf { p } \bot$ atform toolkit for Bayesian optimization. The optimal parameters in our experiments are given by
386
+
387
+ • Sparse-view CT on LIDC $3 2 0 \times 3 2 0$ : $\eta = 0 . 2 4 6$ , $\lambda = 0 . 8 4 1$ .
388
+ • Metal artifact removal on LIDC $3 2 0 \times 3 2 0$ : $\eta = 0 . 2 0 9$ , $\lambda = 0 . 2 2 7$ .
389
+ • Sparse-view CT on LDCT $5 1 2 \times 5 1 2$ : $\eta = 0 . 4 , \lambda = 0 . 7 2$ .
390
+ • Accelerated MRI on BraTS $2 4 0 \times 2 4 0$ : $\eta = 0 . 5 7 7$ , $\lambda = 0 . 9 8 2$ .
391
+
392
+ B.5 TRAINING DETAILS OF BASELINE MODELS
393
+
394
+ B.5.1 BASELINE MODELS FOR SPARSE-VIEW CT RECONSTRUCTION
395
+
396
+ FBP Filtered back projection (FBP) is a standard way for CT image reconstruction, which simply put the projections (sinogram) back to the image space based on the corresponding projection angles and geometry to get an approximated estimation of the unknown image. Usually, a high-pass filter, ramp filter is used to eliminate the blurring during this process. In our experiments, we conduct FBP on sparse-view sinograms using the torch radon toolbox (Ronchetti, 2020).
397
+
398
+ FISTA-TV FISTA-TV is a fast iterative shrinkage-thresholding algorithm (FISTA) for solving linear inverse problems in image processing (Beck & Teboulle, 2009). It adopts a total variation (TV) term as the regularization in the optimization procedure. Each optimization iteration involves a matrixvector multiplication followed by a shrinkage-threshold step. In experiments, FISTA is implemented using the tomobar toolbox (Kazantsev & Wadeson, 2020) with the regularization using the CCPi regularisation toolkit (Kazantsev et al., 2019). We run 300 iterations for reconstructing each CT image with regularization parameter 0.001. Considering the nature of iterative reconstruction in FISTA, it is quite natural to generalize this method to different number of projections for reconstructing CT images. In experiments of generalizing to different number of measurements, FISTA method takes as input the sinogram with different numbers of projections and the corresponding angles for these input projections for the iterative procedure.
399
+
400
+ cGAN Conventional iterative CT reconstruction algorithms like FISTA are typically slow due to their iterative nature. Ghani & Karl (2018) proposed to cast sparse-view CT reconstruction as a sinogram inpainting problem. Specifically, it used a conditional generative adversarial network (cGAN) to first complete the sinogram data prior to reconstructing CT images, thereby avoiding the costly iterative tomographic processing. However, the imperfect sinogram inpainting may further cause image artifacts. Specifically, cGAN model takes zero-padded sparse-view sinogram with 23 projections as input and generates the completed full-angle sinogram with 180 projections. The cGAN model was implemented using PyTorch (Paszke et al., 2019) and trained using a batchsize of 64 and learning rate of 0.0001 with 50 epochs in total. In experiments of generalizing to different number of measurements, we deployed the trained cGAN model by zero-padding sparse-view sinogram with different numbers of projections to full-view sinogram as the input. After obtaining the output inpainted sinogram, we replace the corresponding projections in the output based on the ground truth projections in the input. Finally, the images were reconstructed from the overlayed sinogram. Note that we trained the model using 23 projections and tested it on other projection settings to evaluate the generalization.
401
+
402
+ SIN- $\mathbf { 4 c }$ -PRN To further reduce the artifacts in both sinogram and image space, SIN- $. 4 \mathrm { c }$ -PRN (Wei et al., 2020) proposed a two-step sparse-view CT reconstruction model. It involves a sinogram inpainting network (SIN) to generate super-resolved sinograms with different number of projections, and then a post-processing refining network (PRN) to further remove image artifacts. Both networks are connected through a filtered back-projection operation (FBP). Specifically, SIN model takes 23- view sinogram as input to fistly upsample to full-view sinogram and then generate sinograms through network for 23, 45, 90, 180 projections respectively. FBP transforms these generated sinograms to image space, which was then concatenated and feed into PRN model for refinement. The framework was implemented using PyTorch (Paszke et al., 2019) while FBP operation was implemented using . SIN model was trained using a batchsize of 20 and learning rate of 0.0001, while PRN model was trained using a batchsize of 15 and learning rate of 0.0001. Considering that LIDC dataset is much larger than LDCT dataset, the SIN- $_ { \cdot 4 \mathrm { c } }$ -PRN model was trained for 30 epochs on LIDC dataset and 50 epochs on LDCT dataset. To deploy the trained SIN model to different numbers of measurements, the sinograms with various number of projections are taken as the input for SIN model to generate multi-view sinograms, which were also overlayed with corresponding ground truth projections in inputs. The generated multi-view sinograms are then used for PRN model inference. Since SIN- $_ \mathrm { 4 c }$ -PRN model involves the dual-domain learning in both sinogram and image spaces to remove artifacts, and generates multi-scale sinograms during sinogram inpainting, it shows a better generalization to different numbers of measurements compared with cGAN model as shown in Figure 5 and Figure 6.
403
+
404
+ Neumann Meanwhile, in another parallel direction, researchers proposed to learn the regularizer used in optimization from training data, outperforming traditional regularizers. Specifically, Gilton et al. (2019) presented an end-to-end, data-driven method for learning a nonlinear regularizer for solving inverse problems inspired by the Neumann series, called Neumann network. Neumann network was implemented using PyTorch (Paszke et al., 2019). Due to GPU memory constraints, the model training used the batchsize of 5 on LIDC dataset and the batchsize of 2 on LDCT dataset. The initial learning rate was 0.00001 with an exponential learning rate decay. The network was trained with 15 training epochs on both datasets.
405
+
406
+ # B.5.2 BASELINE MODELS FOR UNDERSAMPLED MRI RECONSTRUCTION
407
+
408
+ DuDoRNet Zhou & Zhou (2020) proposed a dual domain recurrent network (DuDoRNet) to simultaneously recover k-space data and images for MRI reconstruction, in order to address aliasing artifacts in both frequency and image domains. The original model in Zhou & Zhou (2020) also embedded a deep T1 prior to make use of fully-sampled short protocol (T1) as complementary information. For a fair comparison with other supervised learning approaches, in our experiments, we do not include this additional information but train the DuDoRNet model without T1 prior. The DuDoRNet was trained using a batchsize of 6 and a learning rate of 0.0005 with 5 training epochs. In experiments of generalizing to different number of measurements, we trained the model with an acceleration factor of 8 and deployed the trained model to other acceleration factors during testing. Specifically, for inference, we use different Cartesian masking function corresponding to different acceleration factors or down-sampling ratios to sub-sample the $\mathbf { k }$ -space data for the network input with the corresponding initial reconstructed image with zero-padding $\mathbf { k }$ -space.
409
+
410
+ Cascade DenseNet To reconstruct de-aliased MR images from under-sampled k-space data, Zheng et al. (2019) proposed a cascaded dilated dense network (CDDN) for MRI reconstruction, based on stacked dense blocks with residual connections while using the zero-filled MR image as inputs. Specifically, they used a two-step data consistency layer for k-space correction, and replaced corresponding phase-coding lines of the generated image with the original sampled k-space data after each block. In experiments, we trained the model using a batchsize of 8 and a learning rate of 0.0001, with 5 epochs on BraTS dataset. In experiments of generalizing to different number of measurements, we trained the model with an acceleration factor of 8 and deployed the trained model to other acceleration factors during testing. Similarly, different masking functions corresponding to different acceleration factors were used to sub-sample $\mathbf { k }$ -space data to get network inputs. From results, we observe that
411
+
412
+ Cascaded DenseNet generalizes better to more measurements than DuDoRNet as shown in Figure 5 and Figure 6.
413
+
414
+ # B.5.3 BASELINE MODELS FOR METAL ARTIFACT REMOVAL
415
+
416
+ LI One straightforward way for reducing metal artifacts is to complete or inpaint the metal-affected missing regions in sinogram directly through linear interpolation (Kalender et al., 1987). This method does not need any network training. However, the imperfect completion of sinogram may introduce secondary artifacts to the reconstructed image. In our experiments setting, to fit for the practical applications in real world, we assume the ground truth metal trace and mask information are unknown, which can only be estimated by a rough thresholding in artifacts-affected images. We use the estimated metal mask and metal trace for linear interpolation baseline.
417
+
418
+ cGANMAR Wang et al. (2018) proposed a conditional generative adversarial network (cGAN)- based approach for metal artifacts reduction (MAR) in CT. Specifically, cGANMAR network learns the mapping directly from the artifacts-affected CTs to artifacts-free CTs through refinement in image space. The cGANMAR model was implemented using PyTorch (Paszke et al., 2019) and was trained with the batchsize of 64 and the learning rate of 0.0001. The network was trained with 400 epochs.
419
+
420
+ SNMAR Yu et al. (2020) proposed a sinogram completion neural network (SinoNet) to recover the metal-affected projections. Especially, it leveraged the learning in both sinogram domain and image domain by using a prior network to generate a good prior image to guide sinogram learning. Note that in original setting, SNMAR required linear interpolated sinogram and CT as inputs and used ground truth metal trace and mask information to generated them. But in our method, we assume the ground truth metal trace and mask information are unknown according to practical scenario and estimate it by a rough thresholding, which will introduce estimation errors. In SNMAR experiments, we still follow the original setting to guarantee the best performance of this baseline method for a strong comparison. We trained the SNMAR using the batchsize of 64 and the learning rate of 0.0001, with a total of 100 training epochs.
md/dev/vbPsD-BhOZ/vbPsD-BhOZ.md ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Neural Sheaf Diffusion: A Topological Perspective on Heterophily and Oversmoothing in GNNs
2
+
3
+ Cristian Bodnar∗ University of Cambridge cristian.bodnar@cl.cam.ac.uk
4
+
5
+ Francesco Di Giovanni† Twitter fdigiovanni@twitter.com
6
+
7
+ Benjamin P. Chamberlain Twitter
8
+
9
+ Pietro Liò University of Cambridge
10
+
11
+ Michael Bronstein University of Oxford & Twitter
12
+
13
+ # Abstract
14
+
15
+ Cellular sheaves equip graphs with a “geometrical” structure by assigning vector spaces and linear maps to nodes and edges. Graph Neural Networks (GNNs) implicitly assume a graph with a trivial underlying sheaf. This choice is reflected in the structure of the graph Laplacian operator, the properties of the associated diffusion equation, and the characteristics of the convolutional models that discretise this equation. In this paper, we use cellular sheaf theory to show that the underlying geometry of the graph is deeply linked with the performance of GNNs in heterophilic settings and their oversmoothing behaviour. By considering a hierarchy of increasingly general sheaves, we study how the ability of the sheaf diffusion process to achieve linear separation of the classes in the infinite time limit expands. At the same time, we prove that when the sheaf is non-trivial, discretised parametric diffusion processes have greater control than GNNs over their asymptotic behaviour. On the practical side, we study how sheaves can be learned from data. The resulting sheaf diffusion models have many desirable properties that address the limitations of classical graph diffusion equations (and corresponding GNN models) and obtain competitive results in heterophilic settings. Overall, our work provides new connections between GNNs and algebraic topology and would be of interest to both fields.
16
+
17
+ ![](images/37fc0266e09662966e9b7b9b495502d8c11867eaa467aa9aea2b9416651ab810.jpg)
18
+ Figure 1: A sheaf $( G , { \mathcal { F } } )$ shown for a single edge of the graph. The stalks are isomorphic to $\mathbf { \bar { \mathbb { R } } ^ { 2 } }$ . The restriction maps $\mathcal { F } _ { v \le e }$ , $\mathcal { F } _ { u \leq e }$ and their adjoints move the vector features between these spaces. In practice, we learn the sheaf (i.e. the restrictions maps) from data via a parametric function $\Phi$ .
19
+
20
+ ![](images/2aa7c5133f08a3acc1cb8b154b864b878bcd3740270ae1a85b3bf552efc9b41a.jpg)
21
+ Figure 2: Analogy between parallel transport on a sphere and transport on a discrete vector bundle (cellular sheaf). A tangent vector is moved from ${ \mathcal { F } } ( w ) \to { \mathcal { F } } ( v ) \ { \overset { } { \to } } \ F ( u )$ and back. Because the vector returns in a different position, the transport is not pathindependent.
22
+
23
+ # 1 Introduction
24
+
25
+ Graph Neural Networks (GNNs) [12, 20, 27–29, 39, 58, 64] have recently become very popular in the ML community as a model of choice to deal with relational and interaction data due to their multiple successful applications in domains ranging from social science and particle physics to structural biology and drug design. In this work, we focus on two main problems often observed in GNNs: their poor performance in heterophilic graphs [75] and their oversmoothing behaviour [48, 50]. The former arises from the fact that many GNNs are built on the strong assumption of homophily, i.e., that nodes tend to connect to other similar nodes. The latter refers to a phenomenon of some deeper GNNs producing features that are too smooth to be useful.
26
+
27
+ Contributions. We show that these two fundamental problems are linked by a common cause: the underlying “geometry” of the graph (used here in a very loose sense). When this geometry is trivial, as is typically the case, the two phenomena described above emerge. We make these statements precise through the lens of (cellular) sheaf theory [10, 18, 26, 44, 56, 62], a subfield of algebraic topology and geometry. Intuitively, a cellular sheaf associates a vector space to each node and edge of a graph, and a linear map between these spaces for each incident node-edge pair (Figure 1).
28
+
29
+ In Section 3, we analyse how by considering a hierarchy of increasingly general sheaves, starting from a trivial one, a diffusion equation based on the sheaf Laplacian [34] can solve increasingly more complicated node-classification tasks in the infinite time limit. In this regime, we show that oversmoothing and problems due to heterophily can be avoided by equipping the graph with the right sheaf structure for the task. In Section 4, we study the behaviour of a non-linear, parametric, and discrete version of this process. This results in a Sheaf Convolutional Network [32] that generalises Graph Convolutional Networks [39]. We prove that this discrete diffusion process is more flexible and has greater control over its asymptotic behaviour than GCNs [13, 51]. All these results are based on the properties of the harmonic space of the sheaf Laplacian, which we study from a spectral perspective in Section 3.1. We provide a new Cheeger-type inequality for the spectral gap of the sheaf Laplacian and note that these results might be of independent interest for spectral sheaf theory [34]. Finally, in Section 5, we apply our theory to designing simple and practical GNN models. We describe how to construct Sheaf Neural Networks by learning sheaves from data, thus making these types of models applicable beyond the toy experimental setting where they were originally introduced [32]. The resulting models obtain competitive results both in heterophilic and homophilic graphs.
30
+
31
+ # 2 Background
32
+
33
+ Cellular Sheaves. A cellular sheaf [18, 62] over a graph (Figure 1) is a mathematical object associating a vector space to each node and edge in the graph and a map between these spaces for each incident node-edge pair. We define this formally below:
34
+
35
+ Definition 1. A cellular sheaf $( G , { \mathcal { F } } )$ on an undirected graph $G = ( V , E )$ consists of:
36
+
37
+ • A vector space $\mathcal { F } ( v )$ for each $v \in V$ .
38
+ • A vector space $\mathcal { F } ( e )$ for each $e \in E$ .
39
+ • A linear map $\mathcal { F } _ { v \le e } : \mathcal { F } ( v ) \to \mathcal { F } ( e )$ for each incident $v \leq e$ node-edge pair.
40
+
41
+ The vector spaces of the nodes and edges are called stalks, while the linear maps are referred to as restriction maps. The space formed by all the spaces associated with the nodes of the graph is called the space of 0-cochains $C ^ { 0 } ( G ; \mathcal { F } ) : = \mathsf { \bar { Q } } _ { v \in V } \mathcal { \bar { F } } ( v )$ , where $\oplus$ denotes the direct sum of vector spaces. For a 0-cochain $\mathbf { x } \in C ^ { 0 } ( G ; { \mathcal { F } } )$ , we use $\mathbf { x } _ { v }$ to refer to the vector in $\mathcal { F } ( v )$ of node $v$ . Hansen and Ghrist [35] have constructed a convenient mental model for these objects based on opinion dynamics. In this context, $\mathbf { x } _ { v }$ is the ‘private opinion’ of node $v$ , while $\mathcal { F } _ { v \leq e } \mathbf { x } _ { v }$ expresses how that opinion manifests publicly in a ‘discourse space’ formed by $\mathcal { F } ( e )$ . A particularly important subspace of $C ^ { 0 } ( G ; { \mathcal { F } } )$ is the space of global sections $H ^ { 0 } ( G ; { \mathcal { F } } ) : = \{ \dot { \mathbf { x } } \in C ^ { 0 } ( G ; { \mathcal { F } } ) : { \dot { \mathcal { F } } } _ { v \exists e } { \dot { \mathbf { x } } } _ { v } = { \mathcal { F } } _ { u \exists e } { \dot { \mathbf { x } } } _ { u } \}$ containing those private opinions $\mathbf { x }$ for which all neighbours $( v , u )$ agree with each other in the discourse space. Given a cellular sheaf $( G , { \mathcal { F } } )$ , we can define a sheaf Laplacian operator [34] measuring the aggregated ‘disagreement of opinions’ at each node:
42
+
43
+ Definition 2. The sheaf Laplacian of a sheaf $( G , { \mathcal { F } } )$ is a linear map $L _ { { \mathcal { F } } } : C ^ { 0 } ( G , { \mathcal { F } } ) \to C ^ { 0 } ( G , { \mathcal { F } } )$ defined node-wise as $\begin{array} { r } { L _ { \mathcal { F } } ( \mathbf { x } ) _ { v } : = \sum _ { v , u \leq e } \mathcal { F } _ { v \leq e } ^ { \top } ( \mathcal { F } _ { v \leq e } \mathbf { x } _ { v } - \mathcal { F } _ { u \leq e } \mathbf { x } _ { u } ) } \end{array}$ .
44
+
45
+ ![](images/16073351d2205a1fd0b61a50b36c1fd51e1f3473d2705d6f5bb6112b75f10230.jpg)
46
+ Figure 3: A graph (left), the Laplacian matrix of a sheaf with $d$ -dimensional stalks over the graph (middle) , and a 0-cochain $\mathbf { x }$ represented as a block-vector stacking the vectors of all nodes $( r i g h t )$ .
47
+
48
+ The sheaf Laplacian is a positive semi-definite block matrix (Figure 3). The diagonal blocks are $\begin{array} { r } { L _ { \mathcal { F } v v } = \sum _ { v \preceq e } \mathcal { F } _ { v \preceq e } ^ { \top } \mathcal { F } _ { v \preceq e } \widehat { } } \end{array}$ , while the non-diagonal blocks $L _ { \mathcal { F } v u } = - \mathcal { F } _ { v \leq e } ^ { \top } \mathcal { F } _ { u \leq e }$ . Denoting by $D$ the block-diagonal of $L _ { \mathcal { F } }$ , the normalised sheaf Laplacian is given by $\Delta _ { \mathcal { F } } \overset { - } { : = } D ^ { - 1 / 2 } L _ { \mathcal { F } } D ^ { - 1 / 2 }$ . For simplicity, we assume that all the stalks have a fixed dimension $d$ . In that case, the sheaf Laplacian is a $n d \times n d$ real matrix, where $n$ is the number of nodes of $G$ . When the vector spaces are set to $\mathbb { R }$ (i.e., $d = 1$ ) and the linear maps to the identity map over $\mathbb { R }$ , the underlying sheaf is trivial and one recovers the well-known $n \times n$ graph Laplacian matrix and its normalised version $\Delta _ { 0 }$ . In general, $\Delta { _ { \mathcal { F } } }$ is preferred to $L _ { \mathcal { F } }$ for most practical purposes due to its bounded spectrum and, therefore, we focus on the former. A cochain $\mathbf { x }$ is called harmonic if $L _ { \mathcal { F } } \mathbf { x } = 0$ or, equivalently, if $\mathbf { x } \in \ker ( L _ { \mathcal { F } } )$ . This means harmonic cochains are characterised by zero disagreements along all the edges of the graph, and it is not difficult to see that, in fact, $H ^ { 0 } ( G ; { \mathcal { F } } )$ and $\ker ( L _ { \mathcal { F } } )$ are isomorphic as vector spaces [35].
49
+
50
+ The sheaves with orthogonal maps (i.e. ${ \mathcal { F } } _ { v \leq e } \in O ( d )$ the Lie group of $d \times d$ orthogonal matrices) provide a more geometric interpretation of sheaves and play an important role in our analysis. Such sheaves are called discrete $O ( d )$ bundles and can be seen as a discrete version of vector bundles [24, 60, 73] from differential geometry [67]. Intuitively, these objects describe vector spaces attached to the points of a manifold. In our discrete case, the role of the manifold is played by the graph, and the sheaf Laplacian describes how the elements of a vector space are transported via rotations in another neighbouring vector space similarly to how tangent vectors are moved across a manifold via parallel transport (connection; see Figure 2). Due to this analogy, the sheaf Laplacian on $O ( d )$ bundles is also referred to as connection Laplacian [63].
51
+
52
+ Heat Diffusion and GCNs. Consider a graph with adjacency matrix $\mathbf { A }$ , diagonal degree matrix $\mathbf { D }$ , normalised graph Laplacian $\Delta _ { 0 } : = \mathbf { I } - \mathbf { D } ^ { - 1 / 2 } \mathbf { A } \mathbf { D } ^ { - 1 / 2 }$ , and an $n \times f$ feature matrix $\mathbf { X }$ . We can define the heat diffusion equation and its Euler discretisation with a unit step as follows:
53
+
54
+ $$
55
+ \dot { \mathbf { X } } ( t ) = - \Delta _ { 0 } \mathbf { X } ( t ) \ \longleftrightarrow \ \mathbf { X } ( t + 1 ) = \mathbf { X } ( t ) - \Delta _ { 0 } \mathbf { X } ( t ) = ( \mathbf { I } - \Delta _ { 0 } ) \mathbf { X } ( t ) .
56
+ $$
57
+
58
+ Comparing this with the Graph Convolutional Network [39] model, we observe that GCN is an augmented heat diffusion process with an additional $f \times f$ weight matrix W and a nonlinearity $\sigma$ :
59
+
60
+ $$
61
+ \operatorname { G C N } ( \mathbf { X } , \mathbf { A } ) : = \sigma ( \mathbf { D } ^ { - 1 / 2 } \mathbf { A } \mathbf { D } ^ { - 1 / 2 } \mathbf { X } \mathbf { W } ) = \sigma ( ( \mathbf { I } - \Delta _ { 0 } ) \mathbf { X } \mathbf { W } ) .
62
+ $$
63
+
64
+ From this perspective, it is perhaps not surprising that GCN is particularly affected by heterophily and oversmoothing since heat diffusion makes the features of neighbouring nodes increasingly smooth. In what follows, we consider a much more general and powerful family of (sheaf) diffusion processes leading to more expressive sheaf convolutions.
65
+
66
+ # 3 The Expressive Power of Sheaf Diffusion
67
+
68
+ Preliminaries. Let us now assume $G$ to be a graph with $d$ -dimensional node feature vectors $\mathbf { x } _ { v } \in \mathcal { F } ( v )$ . The features of all nodes are represented as a single vector $\mathbf { x } \in C ^ { 0 } ( G ; { \mathcal { F } } )$ stacking all the individual $d$ -dimensional vectors (Figure 3). Additionally, if we allow for $f$ feature channels, everything can be represented as a matrix $\mathbf { X } \in \mathbb { R } ^ { ( n d ) \times f }$ , whose columns are vectors in $C ^ { 0 } ( G ; { \mathcal { F } } )$ We are interested in the spatially discretised sheaf diffusion process governed by the following PDE:
69
+
70
+ $$
71
+ \mathbf { X } ( 0 ) = \mathbf { X } , \quad \dot { \mathbf { X } } ( t ) = - \Delta \ v { \tau } _ { \mathcal { F } } \mathbf { X } ( t ) .
72
+ $$
73
+
74
+ It can be shown that in the time limit, each feature channel is projected into $\ker ( \Delta \tau )$ [34]. As described above (up to a $D ^ { - 1 / 2 }$ normalisation), this space contains the signals that agree with the restriction maps of the sheaf along all the edges. Thus, sheaf diffusion can be seen as a ‘synchronisation’ process over the graph, where all the private opinions converge towards global agreement.
75
+
76
+ In this section, we investigate the expressive power of this process within the infinite time limit. Because the asymptotic behaviour of sheaf diffusion is determined by the properties of $\ker ( \Delta _ { \mathcal { F } } )$ , in Section 3.1, we investigate when this subspace is non-trivial (i.e. it contains more than just the zero vector). In Section 3.2, we use this characterisation of the harmonic space to study what sort of sheaf diffusion processes will asymptotically produce projections into $\ker ( \Delta \tau )$ that can linearly separate the classes for various kinds of graphs and initial conditions. Since diffusion converges exponentially fast, the following results are also relevant for models with finite integration time or layers.
77
+
78
+ # 3.1 Harmonic Space of Sheaf Laplacians
79
+
80
+ A major role in the analysis below is played by discrete vector bundles, and we concentrate on this case. We note though that our results below generalise to the general linear group $\mathcal { F } _ { v \leq e } \in G L ( d )$ , the Lie group of $d \times d$ invertible matrices, provided we can also control the norm of the restriction maps from below. Given a discrete $O ( d )$ -bundle, $\mathcal { F } _ { v \le e } ^ { \top } \mathcal { F } _ { v \le e } = \mathbf { I } _ { d }$ and the block diagonal of $L _ { \mathcal { F } }$ has a diagonal structure since $\boldsymbol { L } _ { \mathcal { F } _ { v v } } = d _ { v } \mathbf { I } _ { d }$ , where √ $\bar { d } _ { v }$ is the degree of node $v$ . Accordingly, if a signal $\tilde { \mathbf { x } } \in \ker ( L _ { \mathcal { F } } )$ , then the signal $\mathbf { x } : v \mapsto \sqrt { d _ { v } } \tilde { \mathbf { x } } _ { v } \in \ker ( \bar { \Delta _ { \mathcal { F } } } )$ and similarly for the inverse transformation.
81
+
82
+ Key to our analysis is studying transport operators induced by the restriction maps of the sheaf. Given nodes $v , u \in V$ and a path $\gamma _ { v \to u } = ( v , v _ { 1 } , \ldots , v _ { \ell } , u )$ from $v$ to $u$ , we consider a notion of transport from the stalk $\mathcal { F } ( v )$ to the stalk $\mathcal { F } ( u )$ , constructed by composing restriction maps (and their transposes) along the edges:
83
+
84
+ $$
85
+ \mathbf { P } _ { v u } ^ { \gamma } : = ( \mathcal { F } _ { u \leq e } ^ { \top } \mathcal { F } _ { v _ { \ell } \leq e } ) \ldots ( \mathcal { F } _ { v _ { 1 } \leq e } ^ { \top } \mathcal { F } _ { v \leq e } ) : \mathcal { F } ( v ) \mathcal { F } ( u ) .
86
+ $$
87
+
88
+ For general sheaf structures, the graph transport is path dependent, meaning that how the vectors are transported across two nodes depends on the path between them (see Figure 2). In fact, we show that this property characterises the spectral gap of a sheaf Laplacian, i.e. the smallest eigenvalue of $\Delta { _ { \mathcal { F } } }$ .
89
+
90
+ Proposition 3. If $\mathcal { F }$ is $a$ discrete $O ( d )$ bundle over a connected graph and $r : = { \ o }$ $\begin{array} { r } { \operatorname* { m a x } _ { \gamma _ { v \to u } , \gamma _ { v \to u } ^ { \prime } } | | \mathbf { P } _ { v \to u } ^ { \gamma } - \mathbf { P } _ { v \to u } ^ { \gamma ^ { \prime } } | | } \end{array}$ , then we have $\lambda _ { 0 } ^ { \mathcal { F } } \le r ^ { 2 } / 2$ .
91
+
92
+ A consequence of this result is that there is always a non-trivial harmonic space (i.e. $\lambda _ { 0 } ^ { \mathcal { F } } = 0 \rangle$ ) if the transport maps generated by an orthogonal sheaf are path-independent (i.e. $r = 0$ ). Next, we address the opposite direction.
93
+
94
+ Proposition 4. If $\mathcal { F }$ is a discrete $O ( d )$ bundle over a connected graph and $\mathbf { x } \in H ^ { 0 } ( G , { \mathcal { F } } )$ , then for any cycle $\gamma$ based at $v \in V$ we have $\mathbf { x } _ { v } \in \ker ( \mathbf { P } _ { v v } ^ { \gamma } - \mathbf { I } )$ .
95
+
96
+ This proposition highlights the interplay between the graph and the sheaf structure. A simple consequence of this result is that for any cycle-free subset $S \subset V$ , we have that any sheaf (or connection-) Laplacian restricted to $S$ always admits a non-trivial harmonic space. A natural question connected to the previous result is whether a Cheeger-like inequality holds in the other direction. This turns out to be the case:
97
+
98
+ Proposition 5. Let $\mathcal { F }$ be a discrete $O ( d )$ bundle over a connected graph $G$ with n nodes and let $| | ( \bar { \mathbf { P } _ { v \to v } ^ { \gamma } } - \mathbf { I } ) \mathbf { x } _ { v } | | \geq \epsilon | | \mathbf { x } _ { v } | |$ for all cycles $\gamma _ { v v }$ . Then $\lambda _ { 0 } ^ { \mathcal { F } } \geq \epsilon ^ { 2 } ( 2 \mathrm { d i a m } ( \tilde { G } ) n d _ { m a x } ) ^ { - 1 }$ .
99
+
100
+ While the bound above is of little use in practice, it shows how the spectral gap of a sheaf Laplacian is indeed related to the deviation of the transport maps from being path-independent, as measured by $\epsilon$ . We note that the Cheeger-like inequality presented here is not unique, and other types of bounds on $\lambda _ { 0 } ^ { \mathcal { F } }$ have been derived [2]. We conclude this section by further analysing the dimensionality of the harmonic space of discrete $O ( d )$ -bundles:
101
+
102
+ Lemma 6. Let $\mathcal { F }$ be a discrete $O ( d )$ bundle over a connected graph $G$ . Then $\mathrm { d i m } ( H ^ { 0 } ) \leq d$ and $\mathrm { d i m } ( H ^ { 0 } ) = d$ if and only if the transport is path-independent.
103
+
104
+ ![](images/7b94fb960633a21d02149b27753d7ea952126118fe130ef58aa7dacb186e29a5.jpg)
105
+ Figure 4: Diffusion process on $O ( 2 )$ -bundles progressively separates the classes of the graph.
106
+
107
+ # 3.2 The Linear Separation Power of Sheaf Diffusion
108
+
109
+ In what follows, we use the results above to analyse the ability of certain classes of sheaves to linearly separate the features in the limit of the diffusion processes they induce. We utilise this as a proxy for the capacity of certain diffusion processes to avoid oversmoothing.
110
+
111
+ Definition 7. A hypothesis class of sheaves with $d$ -dimensional stalks $\mathcal { H } ^ { d }$ has linear separation power over a family of graphs $\mathcal { G }$ if for any labelled graph $G = ( V , E ) \in \mathcal { G }$ , there is a sheaf $( { \mathcal { F } } , G ) { \mathrm { { \bar { \in } } } } { \mathcal { H } } ^ { d }$ that can linearly separate the classes of $G$ in the time limit of Equation $^ 3$ for almost all initial conditions.
112
+
113
+ Note that the restriction to almost all initial conditions is necessary because, in the limit, diffusion behaves like a projection in the harmonic space and there will always be degenerate initial conditions (e.g. the zero matrix) that will yield a zero projection. We will now show how the choice of the sheaf impacts the behaviour of the diffusion process. For this purpose, we will consider a hierarchy of increasingly general classes of sheaves.
114
+
115
+ Symmetric invertible. $\mathcal { H } _ { \mathrm { s y m } } ^ { d } : = \{ ( \mathcal { F } , G ) : \mathcal { F } _ { v \leq e } = \mathcal { F } _ { u \leq e }$ , $\operatorname* { d e t } ( \mathcal { F } _ { v \leq e } ) \neq 0 \}$ . We note that for $d = 1$ , the sheaf Laplacians induced by this class of sheaves coincides with the set of the wellknown weighted graph Laplacians with strictly positive weights, which also includes the usual graph Laplacian (see proof in Appendix B). Therefore, this hypothesis class is of particular interest since it includes those graph Laplacians typically used by graph convolutional models such as GCN [39] and ChebNet [20]. We first show that this class of sheaf Laplacians can linearly separate the classes in binary classification settings under certain homophily assumptions:
116
+
117
+ Proposition 8. Let $\mathcal { G }$ be the set of connected graphs $G = ( V , E )$ with two classes $A , B \subset V$ such that for each $v \in A$ , there exists $u \in A$ and an edge $( v , u ) \in E$ . Then $\mathcal { H } _ { \mathrm { s y m } } ^ { 1 }$ has linear separation power over $\mathcal { G }$ .
118
+
119
+ In contrast, under certain heterophilic conditions, this hypothesis class is not powerful enough to linearly separate the two classes no matter what the initial conditions are:
120
+
121
+ Proposition 9. Let $\mathcal { G }$ be the set of connected bipartite graphs $G = ( A , B , E )$ , with partitions $A , B$ forming two classes and $| A | = | B |$ . Then $\mathcal { H } _ { \mathrm { s y m } } ^ { 1 }$ cannot linearly separate the classes of any graph in $\mathcal { G }$ for any initial conditions $\mathbf { X } ( 0 ) \in \mathbb { R } ^ { n \times f }$ .
122
+
123
+ Non-symmetric invertible. $\mathcal { H } ^ { d } : = \{ ( \mathcal { F } , G ) : \operatorname* { d e t } ( \mathcal { F } _ { v \leq e } ) \neq 0 \}$ . This larger hypothesis class addresses the above limitation by allowing non-symmetric relations:
124
+
125
+ Proposition 10. Let $\mathcal { G }$ contain all the connected graphs $G = ( V , E )$ with two classes $A , B \subseteq V$ . Consider a sheaf $( { \mathcal { F } } ; G ) \in { \mathcal { H } } ^ { 1 }$ with $\mathcal { F } _ { v \le e } = - \alpha _ { e }$ if $v \in A$ and $\mathcal { F } _ { u \leq e } = \alpha _ { e }$ if $u \in B$ with $\alpha _ { e } > 0$ for all $e \in E$ . Then the diffusion induced by $( { \mathcal { F } } ; G )$ can linearly separate the classes of $G$ for almost all initial conditions, and $\mathcal { H } ^ { 1 }$ has linear separation power over $\mathcal { G }$ .
126
+
127
+ Since $\mathcal { F } _ { v \le e } ^ { \top } \mathcal { F } _ { u \le e } = \pm \alpha _ { e } ^ { 2 }$ , the type of sheaf above can be interpreted as a discrete $O ( 1 )$ -bundle over a weighted graph with edge weights $\alpha _ { e } ^ { 2 }$ and transport maps $\mathcal { F } _ { v \leq e } ^ { \top } \mathcal { F } _ { u \leq e } = - 1$ for the inter-class edges and for the intra-class edges. Intuitively, this type of transport, which is path-independent, polarises the features of the two classes and forces them to take opposite signs in the infinite limit. This provides a sheaf-theoretic explanation for why negatively-weighted edges have been widely adopted in heterophilic settings [7, 17, 72].
128
+
129
+ So far we have only studied the effects of changing the type of sheaves in dimension one. We now consider the effects of adjusting the dimension of the stalks and begin by stating a fundamental limitation of (sheaf) diffusion when $d = 1$ .
130
+
131
+ Proposition 11. Let $G$ be a connected graph with $C \geq 3$ classes. Then, $\mathcal { H } ^ { 1 }$ cannot linearly separate the classes of $G$ for any initial conditions $\mathbf { X } ( 0 ) \in \mathbb { R } ^ { n \times f }$ .
132
+
133
+ This is essentially a consequence of $\mathrm { d i m } \big ( \mathrm { k e r } ( \Delta _ { \mathcal { F } } ) \big ) \leq 1$ in this case, by virtue of Lemma 6. From a GNN perspective, this means that in the infinite depth setting, sufficient stalk width (i.e., dimension $d )$ is needed in order to solve tasks involving more than two classes. Note that $d$ is different from the classical notion of feature channels $f$ . As the result above shows, the latter has no effect on the linear separability of the classes in $d = 1$ . Next, we will see that the former does.
134
+
135
+ Diagonal invertible. $\mathcal { H } ^ { d } : = \{ ( \mathcal { F } , G )$ : diagonal $\mathcal { F } _ { v \le e }$ , $\operatorname* { d e t } ( \mathcal { F } _ { v \leq e } ) \neq 0 \}$ . The sheaves in this class can be seen as $d$ independent sheaves from $\mathcal { H } ^ { 1 }$ encoded in the $d$ -dimensional diagonals of their restriction maps. This perspective allows us to generalise Proposition 10 to a multi-class setting:
136
+
137
+ Proposition 12. Let $\mathcal { G }$ be the set of connected graphs with nodes belonging to $C \geq 3$ classes. Then for $d \geq C$ , $\mathcal { H } _ { \mathrm { d i a g } } ^ { d }$ has linear separation power over $\mathcal { G }$ .
138
+
139
+ This result illustrates the benefits of using higher-dimensional stalks while maintaining a simple and computationally convenient class of diagonal restriction maps. Next, with more complex restriction maps, we can show that lower-dimensional stalks can be used to achieve linear separation in the presence of even more classes.
140
+
141
+ Orthogonal. $\mathcal { H } _ { \mathrm { o r t h } } ^ { d } : = \{ ( \mathcal { F } , G ) : \mathcal { F } _ { v \leq e } \in O ( d ) \}$ is the class of $O ( d )$ -bundles. Orthogonal maps are able to make more efficient use of the space available to them than diagonal restriction maps:
142
+
143
+ Proposition 13. Let $\mathcal { G }$ be the class of connected graphs with $C \leq 2 d$ classes. Then, for all $d \in \{ 2 , 4 \}$ , $\mathcal { H } _ { \mathrm { o r t h } } ^ { d }$ has linear separation power over $\mathcal { G }$ .
144
+
145
+ Figure 4 includes an example diffusion process over an $O ( 2 )$ -bundle.
146
+
147
+ Summary: Different sheaf classes give rise to different behaviours of the diffusion process and, consequently, to different separation capabilities. Taken together, these results show that solving any node classification task can be reduced to performing diffusion with the right sheaf.
148
+
149
+ # 4 Expressive Power of Sheaf Convolutions
150
+
151
+ Analogously to how GCN augments heat diffusion, we can construct a Sheaf Convolutional Network (SCN) augmenting the sheaf diffusion process. In this section, we analyse the capacity of SCNs to change, if necessary, their asymptotic behaviour compared to the base diffusion process. Since the sheaf structure will be ultimately learned from data, this is particularly important for the common setting when the learned sheaf is different from the “ground truth” sheaf for the task to be solved.
152
+
153
+ The continous diffusion process from Equation 3 has the Euler discretisation with unit step-size ${ \bf X } ( t + 1 ) = { \bf X } ( t ) - \Delta \mathcal { F } \bar { \bf X } ( t ) = ( { \bf I } _ { n d } - \bar { \Delta _ { \mathcal { F } } } ) { \bf X } ( t )$ . Assuming $\mathbf { X } \in \mathbb { R } ^ { n d \times f _ { 1 } }$ , we can equip the right side with weight matrices $\mathbf { W } _ { 1 } \in \mathbb { R } ^ { d \times d }$ , $\mathbf { W } _ { 2 } \in \mathbb { R } ^ { f _ { 1 } \times f _ { 2 } }$ and a non-linearity $\sigma$ to arrive at the following model originally proposed by Hansen and Gebhart [32]:
154
+
155
+ $$
156
+ \begin{array} { r } { \mathbf { Y } = \sigma \Big ( \big ( \mathbf { I } _ { n d } - \Delta _ { \mathcal { F } } \big ) ( \mathbf { I } _ { n } \otimes \mathbf { W } _ { 1 } ) \mathbf { X } \mathbf { W } _ { 2 } \Big ) \in \mathbb { R } ^ { n d \times f _ { 2 } } , } \end{array}
157
+ $$
158
+
159
+ where $f _ { 1 } , f _ { 2 }$ are the number of input and output feature channels, and $\otimes$ denotes the Kronecker product. Here, $\mathbf { W } _ { 1 }$ multiplies from the left the vector feature of all the nodes in all channels (i.e. $\mathbf { \bar { W } } _ { 1 } \mathbf { x } _ { v } ^ { i }$ for all $v$ and channels $i$ ), while $\mathbf { W } _ { 2 }$ multiplies the features from the right and can adjust the number of feature channels, just like in GCNs. As one would expect, when using a trivial sheaf, $\Delta _ { \mathcal { F } } = \Delta _ { 0 }$ , $\mathbf { W } _ { 1 }$ becomes a scalar and one recovers the GCN of Kipf and Welling [39]. To see how SCNs behave compared to their base diffusion process, we investigate how SCN layers affect the sheaf Dirichlet energy $E _ { \mathcal { F } } ( \mathbf { x } )$ , which sheaf diffusion is known to minimise over time.
160
+
161
+ $$
162
+ \begin{array} { r } { { E } _ { \mathcal { F } } ( \mathbf { x } ) : = \mathbf { x } ^ { \top } \Delta _ { \mathcal { F } } \mathbf { x } = \frac { 1 } { 2 } \sum _ { e : = ( v , u ) } \| \mathcal { F } _ { v \leq e } D _ { v } ^ { - 1 / 2 } \mathbf { x } _ { v } - \mathcal { F } _ { u \leq e } D _ { u } ^ { - 1 / 2 } \mathbf { x } _ { u } \| _ { 2 } ^ { 2 } } \end{array}
163
+ $$
164
+
165
+ Similarly, for multiple channels the energy is $E _ { \mathcal { F } } ( \mathbf { X } ) : = \operatorname { t r a c e } ( \mathbf { X } ^ { \top } \Delta _ { \mathcal { F } } \mathbf { X } )$ . This is a measure of how close a signal $\mathbf { x }$ is to $\ker ( \Delta _ { \mathcal { F } } )$ and it is easy to see that $\mathbf { x } \in \ker ( \Delta _ { \mathcal { F } } ) \Leftrightarrow E _ { \mathcal { F } } ( \mathbf { x } ) = 0$ . We begin by studying the sheaves for which the energy decreases and representations end up asymptotically in $\ker ( \Delta \tau )$ . Let $\begin{array} { r } { \lambda _ { * } : = \operatorname* { m a x } _ { i > 0 } \big ( \lambda _ { i } ^ { \mathcal { F } } - 1 \big ) ^ { 2 } \overset { \smile } { \le } 1 } \end{array}$ and denote by $\mathcal { \hat { H } } _ { + } ^ { 1 } : = \{ ( \mathcal { F } , G ) ~ | ~ \mathcal { F } _ { v \underline { { { \triangle } } } e } \mathcal { \bar { F } } _ { u \underline { { { \diamondsuit } } } e } > 0 \}$ .
166
+
167
+ Theorem 15. For $( { \mathcal { F } } , G ) \in { \mathcal { H } } _ { + } ^ { 1 }$ and $\sigma$ being (Leaky)ReLU, $E _ { \mathcal { F } } ( \mathbf { Y } ) \leq \lambda _ { * } \| \mathbf { W } _ { 1 } \| _ { 2 } ^ { 2 } \| \mathbf { W } _ { 2 } ^ { \top } \| _ { 2 } ^ { 2 } E _ { \mathcal { F } } ( \mathbf { X } )$ .
168
+
169
+ This generalises existent results for GCNs [13, 51] and proves that SCNs using this family of Laplacians, which includes all weighted graph Laplacians, exponentially converge to $\ker ( \Delta \dot { \mathcal { F } } )$ if $\lambda _ { * } \mathbf { \bar { \| } W _ { 1 } \| _ { 2 } ^ { 2 } } \| \mathbf { W } _ { 2 } ^ { \top } \| _ { 2 } ^ { 2 } < 1$ . In particular, if $E _ { \mathcal { F } } ( { \bf X } ) = 0$ , then $E _ { \mathcal { F } } ( \mathbf { Y } ) = 0$ and the representations remain trapped inside the kernel no matter what the norm of the weights is. Therefore, in settings as those described by Propositions 9 and 11, the linear separation capabilities of this class of models are severely limited (see Corollaries 36, 37 in Appendix B).
170
+
171
+ Finally, the Theorem also extends to bundles with symmetric maps, $\mathcal { H } _ { \mathrm { { o r t h , s y m } } } ^ { d } : = \mathcal { H } _ { \mathrm { { o r t h } } } ^ { d } \cap \mathcal { H } _ { \mathrm { { s y m } } } ^ { d }$
172
+
173
+ Theorem 16. If $( \mathcal { F } , G ) \in \mathcal { H } _ { \mathrm { o r t h , s y m } } ^ { d }$ and $\begin{array} { r } { \sigma = ( L e a k y ) R e L U , E _ { \mathcal { F } } ( \mathbf { Y } ) \leq \lambda _ { * } \| \mathbf { W } _ { 1 } \| _ { 2 } ^ { 2 } \| \mathbf { W } _ { 2 } ^ { \top } \| _ { 2 } ^ { 2 } E _ { \mathcal { F } } ( \mathbf { X } ) . } \end{array}$
174
+
175
+ In some sense, this is not surprising because, for this class, $\ker ( \Delta \tau )$ contains the same information as the kernel of the classical normalised graph Laplacian (see Proposition 29 in Appendix C).
176
+
177
+ More generally, SCNs with sheaves outside Dirichlet energy using an arbitrarily small $\mathcal { H } _ { \mathrm { s y m } } ^ { d }$ , are much mor transformation xible and can easily increase the: $\mathbf { W } _ { 1 }$
178
+
179
+ Proposition 17. For any connected graph $G$ and $\varepsilon > 0$ , there exist a sheaf $( G , { \mathcal { F } } ) \not \in { \mathcal { H } } _ { \mathrm { s y m } } ^ { d }$ , $\mathbf { W } _ { 1 }$ with $\| \mathbf { W } _ { 1 } \| _ { 2 } < \varepsilon$ and feature vector x such that $E _ { \mathcal { F } } ( ( \mathbf { I } \otimes \mathbf { W } _ { 1 } ) \mathbf { x } ) > E _ { \mathcal { F } } ( \mathbf { x } )$ .
180
+
181
+ Importantly, this proves that this family of SCNs can, if necessary, escape the kernel of the Laplacian.
182
+
183
+ Summary: Not only that sheaf diffusion is more expressive than heat diffusion as shown in Section 3.2, but SCNs are also more expressive than GCNs in the sense that they are generally not constrained to decrease the Dirichlet energy when using low-norm weights. This provides them with greater control than GCNs over their asymptotic behaviour.
184
+
185
+ # 5 Neural Sheaf Diffusion and Sheaf Learning
186
+
187
+ In the previous sections, we discussed the various advantages provided by sheaf diffusion and sheaf convolutions. However, in general, the ground truth sheaf is unknown or unspecified. Therefore, we aim to learn the underlying sheaf from data end-to-end, thus allowing the model to pick the right geometry for solving the task.
188
+
189
+ Neural Sheaf Diffusion. We propose the diffusion-type model from Equation 5. We note that by setting $\mathbf { W } _ { 1 } , \mathbf { W } _ { 2 }$ to identity and $\bar { \sigma ( \mathbf { x } ) } = \mathrm { E L U } ( \epsilon \mathbf { x } ) / \epsilon$ with $\epsilon > 0$ small enough or simply $\sigma = \mathrm { i d }$ , we recover (up to a scaling) the sheaf diffusion equation. Therefore, the model is at least as expressive as sheaf diffusion and benefits from all the positive properties outlined in Section 3.2.
190
+
191
+ $$
192
+ \begin{array} { r } { \dot { \mathbf { X } } ( t ) = - \sigma \Big ( \Delta _ { \mathcal { F } ( t ) } ( \mathbf { I } _ { n } \otimes \mathbf { W } _ { 1 } ) \mathbf { X } ( t ) \mathbf { W } _ { 2 } \Big ) , } \end{array}
193
+ $$
194
+
195
+ Crucially, the sheaf Laplacian $\Delta _ { \mathcal { F } ( t ) }$ is that of a sheaf $( G , { \mathcal { F } } ( t ) )$ that evolves over time. More specifically, the evolution of the sheaf structure is described by a learnable function of the data $( \mathbf { \bar { \boldsymbol { G } } } , \mathcal { F } ( t ) ) \stackrel { \cdot } { = } g ( \boldsymbol { G } , \mathbf { X } ( t ) ; \theta )$ . This allows the model to use the latest available features to manipulate the underlying geometry of the graph and, implicitly, the behaviour of the diffusion process. Additionally, We use an MLP followed by a reshaping to map the raw features of the dataset to a matrix $\mathbf { X } ( 0 )$ of shape $n d \times f$ and a final linear layer to perform the node classification.
196
+
197
+ In our experiments, we focus on the time-discretised version of this model from Equation 6, which allows us to use a new set of weights at each layer $t$ while maintaining the nice theoretical properties of the model above.
198
+
199
+ $$
200
+ \begin{array} { r } { \mathbf { X } _ { t + 1 } = \mathbf { X } _ { t } - \sigma \Big ( \Delta _ { \mathcal { F } ( t ) } ( \mathbf { I } \otimes \mathbf { W } _ { 1 } ^ { t } ) \mathbf { X } _ { t } \mathbf { W } _ { 2 } ^ { t } \Big ) } \end{array}
201
+ $$
202
+
203
+ We note that this model is different from the SCN model from Equation 4 in two major ways. First, Hansen and Gebhart [32] used a hand-crafted sheaf with $d = 1$ , constructed in a synthetic setting with full knowledge of the data-generating process. In contrast, we learn a sheaf, which makes our model applicable to any real-world graph dataset, even in the absence of a sheaf structure. Additionally, motivated by our theoretical results, we use the full generality of sheaves by using stalks with $d \geq 1$ and higher-dimensional maps. Second, our model uses a residual parametrisation of the discretised diffusion process, which empirically improves its performance.
204
+
205
+ Sheaf Learning. The restriction maps are learned using locally available information. Each $d \times d$ matrix $\mathcal { F } _ { v \le e }$ is learned via a parametric matrix-valued function $\Phi$ , with $\mathcal { F } _ { v \underline { { \sf { d e } } } : = ( v , u ) } = \Phi ( \mathbf { x } _ { v } , \mathbf { x } _ { u } )$
206
+
207
+ ![](images/2386071defde1dda513388752dce643ce0b0301e545e09275c1c78fe35c18935.jpg)
208
+ Figure 5: (Left) Train and (Middle) test accuracy as a function of diffusion time. (Right) Histogram of the learned scalar transport maps. The performance of the sheaf diffusion model is superior to that of weighted-graph diffusion and correctly learns to invert the features of the two classes.
209
+
210
+ This function must be non-symmetric to be able to learn asymmetric transport maps along each edge. In practice, we set $\Phi ( \mathbf { x } _ { v } , \mathbf { x } _ { u } ) = \sigma ( \mathbf { V } [ \mathbf { x } _ { v } | | \mathbf { x } _ { u } ] )$ followed by a reshaping of the output, where $\mathbf { V }$ is a weight matrix. For simplicity, the equations above use a single feature channel, but in practice, all channels are supplied as input. More generally, we can show that if the function $\Phi$ has enough capacity and the features are diverse enough, we can learn any sheaf over a graph.
211
+
212
+ Proposition 18. Let $G = ( V , E )$ be a finite graph with features X. Then, $i f \left( \mathbf { x } _ { v } , \mathbf { x } _ { u } \right) \neq \left( \mathbf { x } _ { w } , \mathbf { x } _ { z } \right)$ for any ${ \bf \bar { \Phi } } ( v , u ) \neq ( w , z ) \in E$ and $\Phi$ is an MLP with sufficient capacity, $\Phi$ can learn any sheaf $( { \mathcal { F } } ; G )$ .
213
+
214
+ First, this result formally motivates learning a sheaf at each layer since the model can learn to distinguish more nodes after each aggregation step. Second, this suggests that more expressive models (in the Weisfeiler-Lehman sense [8, 9, 46, 71]) could learn a more general family of sheaves. We leave a deeper investigation of these aspects for future work. In what follows, we distinguish between several types of functions $\Phi$ depending on the type of matrix they learn.
215
+
216
+ Diagonal. The main advantage of this parametrisation is that fewer parameters need to be learned per edge, and the sheaf Laplacian ends up being a matrix with diagonal blocks, which also results in fewer operations in sparse matrix multiplications. The main disadvantage is that the $d$ dimensions of the stalks interact only via the left $\mathbf { W } _ { 1 }$ multiplication.
217
+
218
+ Orthogonal. In this case, the model effectively learns a discrete vector bundle. Orthogonal matrices provide several advantages: (1) they can mix the various dimension of the stalks, (2) the orthogonality constraint prevents overfitting while reducing the number of parameters, (3) they have better understood theoretical properties, and (4) the resulting Laplacians are easier to normalise numerically since the diagonal entries correspond to the degrees of the nodes. In our model, we build orthogonal matrices from a composition of Householder reflections [45].
219
+
220
+ General. Finally, we consider the most general option of learning arbitrary matrices. The maximal flexibility these maps provide can be useful, but it also comes with the danger of overfitting. At the same time, the sheaf Laplacian is more challenging to normalise numerically since one has to compute $D ^ { - 1 / 2 }$ for a positive semi-definite matrix $D$ . To perform this at scale, one has to rely on SVD, whose gradients can be infinite if $D$ has repeated eigenvalues. Therefore, this model is more challenging to train.
221
+
222
+ Computational Complexity. The GCN from Equation 2 has complexity $O ( n c ^ { 2 } + m c )$ , where $c$ is the number of channels and $m$ the number of edges. Assume a sheaf diffusion model with stalk dimension $d$ and $f$ channels such that $d \times f = c$ (i.e. same representation size). Then, when the model uses diagonal maps, the complexity is $O ( n c ^ { 2 } + m d c )$ . When using orthogonal or general matrices, the complexity becomes $\mathcal { O } ( n ( c ^ { 2 } + d ^ { 3 } ) + m ( c d ^ { 2 } + d ^ { 3 } ) )$ (see Appendix E.1 for detailed derivations). In practice, we use $1 \leq d \leq 5$ , which effectively results in a constant overhead compared to GCN.
223
+
224
+ # 6 Experiments
225
+
226
+ Synthetic experiments. We consider a simple setup given by a connected bipartite graph with equally sized partitions. We sample the features from two overlapping isotropic Gaussian distributions to make the classes linearly non-separable at initialisation time. From Proposition 9, we know that diffusion models using symmetric restriction maps cannot separate the classes in the limit, while a diffusion process using negative transport maps can. Therefore, we use two vanilla sheaf diffusion processes by setting $d = 1$ , ${ \mathbf W } _ { 1 } = { \mathbf I } _ { d }$ , ${ \bf W } _ { 2 } = { \bf I } _ { f }$ and $\sigma = \mathrm { i d }$ in Equation 5. In both models, we learn a sheaf at $t = 0$ as a function of $\mathbf { X } ( 0 )$ , and we keep the sheaf constant over time. For the first model, we learn a sheaf with general maps $\mathcal { F } _ { v \le e } \in \mathbb { R }$ . For the second model, we use a similar layer but constraint $\mathcal { F } _ { v \le e } = \mathcal { F } _ { u \le e }$ , obtaining a weighted graph Laplacian.
227
+
228
+ Table 1: Results on node classification datasets sorted by their homophily level. Top three models are coloured by First, Second, Third. Our models are marked NSD.
229
+
230
+ <table><tr><td>Hom level</td><td>Texas 0.11</td><td>Wisconsin 0.21</td><td>Film 0.22</td><td>Squirrel 0.22</td><td>Chameleon 0.23</td><td>Cornell 0.30</td><td>Citeseer 0.74</td><td>Pubmed 0.80</td><td>Cora 0.81</td></tr><tr><td>#Nodes #Edges</td><td>183 295</td><td>251 466</td><td>7,600 26,752</td><td>5,201 198,493</td><td>2,277 31,421</td><td>183 280</td><td>3,327 4,676</td><td>18,717 44,327</td><td>2,708 5,278</td></tr><tr><td>#Classes</td><td>5</td><td>5</td><td>5</td><td>5</td><td>5</td><td>5</td><td>7</td><td>3</td><td>6</td></tr><tr><td>Diag-NSD</td><td>85.67±6.95</td><td>88.63±2.75</td><td>37.79±1.01</td><td>54.78±1.81</td><td>68.68±1.73</td><td>86.49±7.35</td><td>77.14±1.85</td><td>89.42±0.43</td><td>87.14±1.06</td></tr><tr><td>O(d)-NSD</td><td>85.95±5.51</td><td>89.41±4.74</td><td>37.81±1.15</td><td>56.34±1.32</td><td>68.04±1.58</td><td>84.86±4.71</td><td>76.70±1.57</td><td>89.49±0.40</td><td>86.90±1.13</td></tr><tr><td>Gen-NSD</td><td>82.97±5.13</td><td>89.21±3.84</td><td>37.80±1.22</td><td>53.17±1.31</td><td>67.93±1.58</td><td>85.68±6.51</td><td>76.32±1.65</td><td>89.33±0.35</td><td>87.30±1.15</td></tr><tr><td>GGCN</td><td>84.86±4.55</td><td>86.86±3.29</td><td>37.54±1.56</td><td>55.17±1.58</td><td>71.14±1.84</td><td>85.68±6.63</td><td>77.14±1.45</td><td>89.15±0.37</td><td>87.95±1.05</td></tr><tr><td>H2GCN</td><td>84.86±7.23</td><td>87.65±4.98</td><td>35.70±1.00</td><td>36.48±1.86</td><td>60.11±2.15</td><td>82.70±5.28</td><td>77.11±1.57</td><td>89.49±0.38</td><td>87.87±1.20</td></tr><tr><td>GPRGNN</td><td>78.38±4.36</td><td>82.94±4.21</td><td>34.63±1.22</td><td>31.61±1.24</td><td>46.58±1.71</td><td>80.27±8.11</td><td>77.13±1.67</td><td>87.54±0.38</td><td>87.95±1.18</td></tr><tr><td>FAGCN</td><td>82.43±6.89</td><td>82.94±7.95</td><td>34.87±1.25</td><td>42.59±0.79</td><td>55.22±3.19</td><td>79.19±9.79</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>MixHop</td><td>77.84±7.73</td><td>75.88±4.90</td><td>32.22±2.34</td><td>43.80±1.48</td><td>60.50±2.53</td><td>73.51±6.34</td><td>76.26±1.33</td><td>85.31±0.61</td><td>87.61±0.85</td></tr><tr><td>GCNII</td><td>77.57±3.83</td><td>80.39±3.40</td><td>37.44±1.30</td><td>38.47±1.58</td><td>63.86±3.04</td><td>77.86±3.79</td><td>77.33±1.48</td><td>90.15±0.43</td><td>88.37±1.25</td></tr><tr><td>Geom-GCN</td><td>66.76±2.72</td><td>64.51±3.66</td><td>31.59±1.15</td><td>38.15±0.92</td><td>60.00±2.81</td><td>60.54±3.67</td><td>78.02±1.15</td><td>89.95±0.47</td><td>85.35±1.57</td></tr><tr><td>PairNorm</td><td>60.27±4.34</td><td>48.43±6.14</td><td>27.40±1.24</td><td>50.44±2.04</td><td>62.74±2.82</td><td>58.92±3.15</td><td>73.59±1.47</td><td>87.53±0.44</td><td>85.79±1.01</td></tr><tr><td>GraphSAGE</td><td>82.43±6.14</td><td>81.18±5.56</td><td>34.23±0.99</td><td>41.61±0.74</td><td>58.73±1.68</td><td>75.95±5.01</td><td>76.04±1.30</td><td>88.45±0.50</td><td>86.90±1.04</td></tr><tr><td>GCN</td><td>55.14±5.16</td><td>51.76±3.06</td><td>27.32±1.10</td><td>53.43±2.01</td><td>64.82±2.24</td><td>60.54±5.30</td><td>76.50±1.36</td><td>88.42±0.50</td><td>86.98±1.27</td></tr><tr><td>GAT</td><td>52.16±6.63</td><td>49.41±4.09</td><td>27.44±0.89</td><td>40.72±1.55</td><td>60.26±2.50</td><td>61.89±5.05</td><td>76.55±1.23</td><td>87.30±1.10</td><td>86.33±0.48</td></tr><tr><td>MLP</td><td>80.81±4.75</td><td>85.29±3.31</td><td>36.53��0.70</td><td>28.77±1.56</td><td>46.21±2.99</td><td>81.89±6.40</td><td>74.02±1.90</td><td>87.16±0.37</td><td>75.69±2.00</td></tr></table>
231
+
232
+ Figure 5 presents the results across five seeds. As expected, for diffusion time zero (i.e. no diffusion), we see that a linear classifier cannot separate the classes. At later times, the diffusion process using symmetric maps cannot perfectly fit the data. In contrast, with the more general sheaf diffusion, as time increases and the signal approaches the harmonic space, the model gets better and the features become linearly separable. In the last subfigure, we take a closer look at the sheaf that the model learns in the time limit by plotting a histogram of all the transport (scalar) maps $\mathcal { F } _ { v \le { e } } ^ { \top } \mathcal { F } _ { u \le { e } }$ . In accordance with Proposition 10, the model learns a negative transport map for all edges. This shows that the model manages to avoid oversmoothing (see Appendix F for an experiment with $d > 1$ ).
233
+
234
+ Real-world experiments. We test our models on multiple real-world datasets [47, 53, 57, 61, 66] with an edge homophily coefficient $h$ ranging from $h = 0 . 1 1$ (very heterophilic) to $h = 0 . 8 1$ (very homophilic). Therefore, they offer a view of how a model performs over this entire spectrum. We evaluate our models on the 10 fixed splits provided by Pei et al. [53] and report the mean accuracy and standard deviation. Each split contains $4 8 \% / 3 2 \% / 2 \dot { 0 } \%$ of nodes per class for training, validation and testing, respectively. As baselines, we use an ample set of GNN models that can be placed in three categories: (1) classical: GCN [39], GAT [68], GraphSAGE [31]; (2) models specifically designed for heterophilic settings: GGCN [72], Geom-GCN [53], H2GCN [75], GPRGNN [17], FAGCN [7], MixHop [1]; (3) models addressing oversmoothing: GCNII [16], PairNorm [74]. All the results are taken from Yan et al. [72], except for FAGCN and MixHop, which come from Lingam et al. [41] and Zhu et al. [75], respectively. All of these were evaluated on the same set of splits as ours. In Appendix F we also include experiments with continuous GNN models.
235
+
236
+ Results. From Table 1 we see that our models are first in $5 / 6$ benchmarks with high heterophily $( h < 0 . 3 )$ and second-ranked on the remaining one (i.e. Chameleon). At the same time, NSD also shows strong performance on the homophilic graphs by being within approximately $1 \%$ of the top model. Overall, NSD models are among the top three models on $8 / 9$ datasets. The $O ( d )$ -bundle diffusion model performs best overall confirming the intuition that it can better avoid overfitting, while also transforming the vectors in sufficiently complex ways. We also remark on the strong performance of the model learning diagonals maps, despite the simpler functional form of the Laplacian.
237
+
238
+ # 7 Related Work, Discussion, and Conclusion
239
+
240
+ Sheaf Neural Networks & Sheaf Learning. Sheaf Neural Networks [32] with a hand-crafted sheaf Laplacian were originally introduced in a toy experimental setting. Since then, they have remained completely unexplored, and we hope this paper will fill this lacuna. In contrast to [32], we provide an ample theoretical analysis justifying the use of sheaves in Graph ML and study for the first time how sheaves can be learned from data using neural networks. Furthermore, we present the first successful application of Sheaf Neural Networks on real-world datasets. Hansen and Ghrist [33] have also considered learning a sheaf Laplacian by minimising directly in matrix space a regularised Dirichlet energy metric. Different from their approach, we learn the sheaf as part of an end-to-end model and use an efficient parametrisation that is independent of the size of the graph.
241
+
242
+ Follow-up works have also experimented with inferring a connection Laplacian directly from data at pre-processing time [3], combining sheaves with attention [4], and designing models based on the wave equation on sheaves [65]. Besides the sheaf Laplacians employed in all these works and ours, one can also use higher-order sheaf (connection) Laplacians that operate on higher-order tensors. These were shown to encode important information about the underlying symmetries in the data [55], which hints at the powerful data properties that Sheaf Neural Networks could potentially extract from these operators.
243
+
244
+ Heterophily and Oversmoothing. While good empirical designs jointly addressing these two problems have been proposed before [17, 72], Yan et al. [72] is the only other work connecting the two theoretically. Their analysis [72] is very different in terms of methods and assumptions and, therefore, their results are completely orthogonal. Concretely, the authors analyse the performance of linear SGCs [69] (i.e. GCN without nonlinearities) on random attributed graphs. In contrast, our analysis is not probabilistic, focuses on diffusion PDEs and also extends to GCNs in the non-linear regime. Furthermore, we employ a new set of mathematical tools from cellular sheaf theory, which brings a new language and new tools to analyse these problems. Perhaps the only commonality is that both works find evidence for the benefits of negatively signed edges in GNNs, although with different mathematical motivations. At the same time, other recent works [21, 42] have shown that GCNs with finite layers (typically one) can perform well in heterophilic graphs (including bipartite). This is in no contradiction with our results, which consider an infinite time/layer regime (i.e. not finite) and perfect linear separation (i.e. a model that cannot fit the data can still achieve high accuracy).
245
+
246
+ Category Theory and GNNs. From the perspective of category theory [43], cellular sheaves are a functor from a category describing the incidence structure of the graph to a category describing the data living on top of the graph. Informally, this says that the vertices and edges are mapped to some type of data (e.g. vector spaces) and the incidence relations between vertices and edges are mapped to some type of relation between the assigned data (e.g. linear maps between the vector spaces). The generality provided by this perspective could be used to extend the models described in this work to more exotic types of data such as lattices and their associated sheaf Laplacians [25]. At the same time, our work echoes other recent efforts to place GNNs on a categorical foundation [19, 22].
247
+
248
+ Message Passing Neural Networks. The layer from Equation 6 can be seen as a form of GNNFiLM layer [11, 54], where each node learns a linear message function conditioned on the features of the neighbours. Such models have been recently shown to perform well empirically in heterophilic settings [52]. At the same time, the model bares an algorithmic resemblance to GAT [68]. For a central node $v$ and a neighbouring node $u$ , GAT learns an attention coefficient $a _ { v u }$ , while our model learns a matrix given by the block $( v , u )$ of $\Delta { _ { \mathcal { F } } }$ . Finally, a message-passing procedure based on parallel transport has also been proposed by Haan et al. [30] in the context of geometric graphs (meshes). In the absence of a natural geometric structure on arbitrary graphs, in our case, the transport structure is learned from data end-to-end.
249
+
250
+ Limitations and societal impact. One of the main limitations of our theoretical analysis is that it does not address the generalisation properties of sheaves, but this remains a major impediment for the entire field of deep learning. Nonetheless, our setting was sufficient to produce many valuable insights about heterophily and oversmoothing and a basic understanding of what various types of sheaves can and cannot do. Much more work remains to be done in this direction, and we expect to see further cross-fertilization between ML and algebraic topology in the future. Finally, due to the theoretical nature of this work, we do not foresee any immediate negative societal impacts.
251
+
252
+ Conclusion. In this work, we used cellular sheaf theory to provide a novel topological perspective on heterophily and oversmoothing in GNNs. We showed that the underlying sheaf structure of the graph is intimately connected with both of these important factors affecting the performance of GNNs. To mitigate this, we proposed a new paradigm for graph representation learning where models not only evolve the features at each layer but also the underlying geometry of the graph. In practice, we demonstrated that this framework achieves competitive results in heterophilic settings.
253
+
254
+ # Acknowledgments and Disclosure of Funding
255
+
256
+ We are grateful to Iulia Duta, Dobrik Georgiev and Jacob Deasy for valuable comments on an earlier version of this manuscript. CB would also like to thank the Twitter Cortex team for making the research internship a fantastic experience. This research was supported in part by ERC Consolidator grant No. 724228 (LEMAN).
257
+
258
+ # References
259
+
260
+ [1] Sami Abu-El-Haija, Bryan Perozzi, Amol Kapoor, Hrayr Harutyunyan, Nazanin Alipourfard, Kristina Lerman, Greg Ver Steeg, and Aram Galstyan. Mixhop: Higher-order graph convolutional architectures via sparsified neighborhood mixing. In The Thirty-sixth International Conference on Machine Learning (ICML), 2019. URL http://proceedings.mlr.press/ v97/abu-el-haija19a/abu-el-haija19a.pdf.
261
+ [2] Afonso S Bandeira, Amit Singer, and Daniel A Spielman. A Cheeger inequality for the graph connection laplacian. SIAM Journal on Matrix Analysis and Applications, 34(4):1611–1630, 2013.
262
+ [3] Federico Barbero, Cristian Bodnar, Haitz Sáez de Ocáriz Borde, Michael Bronstein, Petar Velickovi ˇ c, and Pietro Liò. Sheaf neural networks with connection laplacians. In ´ ICML 2022 Workshop on Topology, Algebra, and Geometry in Machine Learning, 2022. [4] Federico Barbero, Cristian Bodnar, Haitz Sáez de Ocáriz Borde, and Pietro Lio. Sheaf attention networks. In NeurIPS 2022 Workshop on Symmetry and Geometry in Neural Representations, 2022.
263
+ [5] Lukas Biewald. Experiment tracking with weights and biases, 2020. URL https://www. wandb.com/. Software available from wandb.com.
264
+ [6] Christopher M. Bishop. Pattern Recognition and Machine Learning (Information Science and Statistics). Springer-Verlag, Berlin, Heidelberg, 2006. ISBN 0387310738.
265
+ [7] Deyu Bo, Xiao Wang, Chuan Shi, and Huawei Shen. Beyond low-frequency information in graph convolutional networks. In AAAI. AAAI Press, 2021.
266
+ [8] Cristian Bodnar, Fabrizio Frasca, Nina Otter, Yu Guang Wang, Pietro Liò, Guido Montúfar, and Michael Bronstein. Weisfeiler and Lehman Go Cellular: CW Networks. In NeurIPS, 2021.
267
+ [9] Cristian Bodnar, Fabrizio Frasca, Yuguang Wang, Nina Otter, Guido F Montufar, Pietro Lió, and Michael Bronstein. Weisfeiler and Lehman Go Topological: Message Passing Simplicial Networks. In ICML, 2021.
268
+ [10] Glen E Bredon. Sheaf theory, volume 170. Springer Science & Business Media, 2012.
269
+ [11] Marc Brockschmidt. Gnn-film: Graph neural networks with feature-wise linear modulation. In International Conference on Machine Learning, pages 1144–1152. PMLR, 2020.
270
+ [12] Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. In ICLR, 2014.
271
+ [13] Chen Cai and Yusu Wang. A note on over-smoothing for graph neural networks. arXiv:2006.13318, 2020.
272
+ [14] Benjamin Paul Chamberlain, James Rowbottom, Davide Eynard, Francesco Di Giovanni, Dong Xiaowen, and Michael M Bronstein. Beltrami flow and neural diffusion on graphs. In NeurIPS, 2021.
273
+ [15] Benjamin Paul Chamberlain, James Rowbottom, Maria Goronova, Stefan Webb, Emanuele Rossi, and Michael M Bronstein. Grand: Graph neural diffusion. In ICML, 2021.
274
+
275
+ [16] Ming Chen, Zhewei Wei, Zengfeng Huang, Bolin Ding, and Yaliang Li. Simple and deep graph convolutional networks. In Hal Daumé III and Aarti Singh, editors, Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 1725–1735. PMLR, 13–18 Jul 2020. URL https://proceedings. mlr.press/v119/chen20v.html.
276
+
277
+ [17] Eli Chien, Jianhao Peng, Pan Li, and Olgica Milenkovic. Adaptive universal generalized pagerank graph neural network. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=n6jl7fLxrP.
278
+
279
+ [18] Justin Michael Curry. Sheaves, cosheaves and applications. University of Pennsylvania, 2014.
280
+
281
+ [19] Pim de Haan, Taco Cohen, and Max Welling. Natural graph networks. In NeurIPS, 2020.
282
+
283
+ [20] Michaël Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. In NIPS, 2016.
284
+
285
+ [21] Lun Du, Xiaozhou Shi, Qiang Fu, Xiaojun Ma, Hengyu Liu, Shi Han, and Dongmei Zhang. Gbk-gnn: Gated bi-kernel graph neural networks for modeling both homophily and heterophily. In Proceedings of the ACM Web Conference 2022, pages 1550–1558, 2022.
286
+
287
+ [22] Andrew Dudzik and Petar Velickovi ˇ c. Graph neural networks are dynamic programmers. ´ arXiv preprint arXiv:2203.15544, 2022.
288
+
289
+ [23] Vijay Prakash Dwivedi, Chaitanya K Joshi, Thomas Laurent, Yoshua Bengio, and Xavier Bresson. Benchmarking graph neural networks. arXiv:2003.00982, 2020.
290
+
291
+ [24] Tingran Gao, Jacek Brodzki, and Sayan Mukherjee. The geometry of synchronization problems and learning group actions. Discrete & Computational Geometry, 65(1):150–211, 2021.
292
+
293
+ [25] Robert Ghrist and Hans Riess. Cellular sheaves of lattices and the tarski laplacian. arXiv:2007.04099, 2020.
294
+
295
+ [26] Robert W Ghrist. Elementary applied topology, volume 1. Createspace Seattle, 2014.
296
+
297
+ [27] Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In ICML, 2017.
298
+
299
+ [28] Christoph Goller and Andreas Kuchler. Learning task-dependent distributed representations by backpropagation through structure. In ICNN, 1996.
300
+
301
+ [29] Marco Gori, Gabriele Monfardini, and Franco Scarselli. A new model for learning in graph domains. In IJCNN, 2005.
302
+
303
+ [30] Pim De Haan, Maurice Weiler, Taco Cohen, and Max Welling. Gauge equivariant mesh CNNs: Anisotropic convolutions on geometric graphs. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id $\equiv$ Jnspzp-oIZE.
304
+
305
+ [31] William L Hamilton, Rex Ying, and Jure Leskovec. Representation learning on graphs: Methods and applications. IEEE Data Engineering Bulletin, 2017.
306
+
307
+ [32] Jakob Hansen and Thomas Gebhart. Sheaf neural networks. In NeurIPS 2020 Workshop on Topological Data Analysis and Beyond, 2020.
308
+
309
+ [33] Jakob Hansen and Robert Ghrist. Learning sheaf laplacians from smooth signals. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 5446–5450. IEEE, 2019.
310
+
311
+ [34] Jakob Hansen and Robert Ghrist. Toward a spectral theory of cellular sheaves. Journal of Applied and Computational Topology, 3(4):315–358, 2019.
312
+
313
+ [35] Jakob Hansen and Robert Ghrist. Opinion dynamics on discourse sheaves. SIAM Journal on Applied Mathematics, 81(5):2033–2060, 2021.
314
+
315
+ [36] Kurt Hornik. Approximation capabilities of multilayer feedforward networks. Neural networks, 4(2):251–257, 1991.
316
+ [37] Kurt Hornik, Maxwell Stinchcombe, and Halbert White. Multilayer feedforward networks are universal approximators. Neural networks, 2(5):359–366, 1989.
317
+ [38] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
318
+ [39] Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In ICLR, 2017.
319
+ [40] Hyun Deok Lee. On some matrix inequalities. Korean Journal of Mathematics, 16(4):565–571, 2008.
320
+ [41] Vijay Lingam, Rahul Ragesh, Arun Iyer, and Sundararajan Sellamanickam. Simple truncated svd based model for node classification on heterophilic graphs. arXiv preprint arXiv:2106.12807, 2021.
321
+ [42] Sitao Luan, Chenqing Hua, Qincheng Lu, Jiaqi Zhu, Mingde Zhao, Shuyuan Zhang, Xiao-Wen Chang, and Doina Precup. Is heterophily a real nightmare for graph neural networks to do node classification? arXiv preprint arXiv:2109.05641, 2021.
322
+ [43] Saunders Mac Lane. Categories for the working mathematician, volume 5. Springer Science & Business Media, 2013.
323
+ [44] Saunders MacLane and Ieke Moerdijk. Sheaves in geometry and logic: A first introduction to topos theory. Springer Science & Business Media, 2012.
324
+ [45] Zakaria Mhammedi, Andrew Hellicar, Ashfaqur Rahman, and James Bailey. Efficient orthogonal parametrisation of recurrent neural networks using householder reflections. In International Conference on Machine Learning, pages 2401–2409. PMLR, 2017.
325
+ [46] Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gaurav Rattan, and Martin Grohe. Weisfeiler and Leman go neural: Higher-order graph neural networks. In AAAI, 2019.
326
+ [47] Galileo Namata, Ben London, Lise Getoor, Bert Huang, and U Edu. Query-driven active surveying for collective classification. In 10th International Workshop on Mining and Learning with Graphs, volume 8, page 1, 2012.
327
+ [48] H Nt and T Maehara. Revisiting graph neural networks: all we have is low pass filters. arXiv preprint arXiv:1812.08434v4, 2019.
328
+ [49] Anton Obukhov. Efficient householder transformation in pytorch, 2021. URL www.github. com/toshas/torch-householder. Version: 1.0.1, DOI: 10.5281/zenodo.5068733.
329
+ [50] K Oono and T Suzuki. Graph neural networks exponentially lose expressive power for node classification. In International Conference on Learning Representations, 2020.
330
+ [51] Kenta Oono and Taiji Suzuki. Graph neural networks exponentially lose expressive power for node classification. arXiv:1905.10947, 2019.
331
+ [52] John Palowitch, Anton Tsitsulin, Brandon Mayer, and Bryan Perozzi. Graphworld: Fake graphs bring real insights for gnns. arXiv preprint arXiv:2203.00112, 2022.
332
+ [53] Hongbin Pei, Bingzhe Wei, Kevin Chen-Chuan Chang, Yu Lei, and Bo Yang. Geom-gcn: Geometric graph convolutional networks. arXiv preprint arXiv:2002.05287, 2020.
333
+ [54] 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.
334
+ [55] David Pfau, Irina Higgins, Alex Botev, and Sébastien Racanière. Disentangling by subspace diffusion. Advances in Neural Information Processing Systems, 33:17403–17415, 2020.
335
+ [56] Daniel Rosiak. Sheaf theory through examples. MIT Press, 2022.
336
+ [57] Benedek Rozemberczki, Carl Allen, and Rik Sarkar. Multi-scale attributed node embedding. Journal of Complex Networks, 9(2):cnab014, 2021.
337
+ [58] Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE Trans. Neural Networks, 20(1):61–80, 2008.
338
+ [59] Richard D Schafer. An introduction to nonassociative algebras. Courier Dover Publications, 2017.
339
+ [60] Luis Scoccola and Jose A Perea. Approximate and discrete euclidean vector bundles. arXiv preprint arXiv:2104.07563, 2021.
340
+ [61] Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Galligher, and Tina EliassiRad. Collective classification in network data. AI magazine, 29(3):93–93, 2008.
341
+ [62] Allen Dudley Shepard. A cellular description of the derived category of a stratified space. PhD thesis, Brown University, 1985.
342
+ [63] Amit Singer and H-T Wu. Vector diffusion maps and the connection laplacian. Communications on pure and applied mathematics, 65(8):1067–1144, 2012.
343
+ [64] Alessandro Sperduti. Encoding labeled graphs by labeling RAAM. In NIPS, 1994.
344
+ [65] Julian Suk, Lorenzo Giusti, Tamir Hemo, Miguel Lopez, Konstantinos Barmpas, and Cristian Bodnar. Surfing on the neural sheaf. In NeurIPS 2022 Workshop on Symmetry and Geometry in Neural Representations, 2022.
345
+ [66] Jie Tang, Jimeng Sun, Chi Wang, and Zi Yang. Social influence analysis in large-scale networks. In Proceedings of the 15th ACM SIGKDD international conference on Knowledge discovery and data mining, pages 807–816, 2009.
346
+ [67] Loring W Tu. Manifolds. In An Introduction to Manifolds, pages 47–83. Springer, 2011.
347
+ [68] Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. In ICLR, 2018.
348
+ [69] Felix Wu, Tianyi Zhang, Amauri Holanda de Souza Jr, Christopher Fifty, Tao Yu, and Kilian Q Weinberger. Simplifying graph convolutional networks. In ICML, 2019.
349
+ [70] Louis-Pascal Xhonneux, Meng Qu, and Jian Tang. Continuous graph neural networks. In ICML, 2020.
350
+ [71] Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In ICLR, 2019.
351
+ [72] Yujun Yan, Milad Hashemi, Kevin Swersky, Yaoqing Yang, and Danai Koutra. Two sides of the same coin: Heterophily and oversmoothing in graph convolutional neural networks. arXiv:2102.06462, 2021.
352
+ [73] Fouad El Zein and Jawad Snoussi. Local systems and constructible sheaves. In Arrangements, local systems and singularities, pages 111–153. Springer, 2009.
353
+ [74] Lingxiao Zhao and Leman Akoglu. Pairnorm: Tackling oversmoothing in gnns. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum? id=rkecl1rtwB.
354
+ [75] Jiong Zhu, Yujun Yan, Lingxiao Zhao, Mark Heimann, Leman Akoglu, and Danai Koutra. Beyond homophily in graph neural networks: Current limitations and effective designs. Advances in Neural Information Processing Systems, 33, 2020.
355
+
356
+ # Checklist
357
+
358
+ 1. For all authors...
359
+
360
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
361
+ (b) Did you describe the limitations of your work? [Yes]
362
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
363
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
364
+
365
+ 2. If you are including theoretical results...
366
+
367
+ (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] Proofs are included in the appendix
368
+
369
+ 3. If you ran experiments...
370
+
371
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Our code is available at https://github.com/twitter-research/neural-sheaf-diffusion.
372
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Section 6 and Appendix E
373
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
374
+ (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] Appendix E
375
+
376
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
377
+
378
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
379
+ (b) Did you mention the license of the assets? [Yes] Appendix F
380
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] The code of our submission.
381
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
382
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
383
+
384
+ 5. If you used crowdsourcing or conducted research with human subjects...
385
+
386
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
387
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
388
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/vcNjibzV3P/vcNjibzV3P.md ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Complete Neural Networks for Complete Euclidean Graphs
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Neural networks for point clouds, which respect their natural invariance to per
11
+ 2 mutation and rigid motion, have enjoyed recent success in modeling geometric
12
+ 3 phenomena, from molecular dynamics Reiser et al. [2022] to recommender systems
13
+ 4 Yi et al. [2023]. Yet, to date, no architecture with polynomial complexity is known
14
+ 5 to be complete, that is, able to distinguish between any pair of non-isomorphic
15
+ 6 point clouds. We fill this theoretical gap by showing that point clouds can be
16
+ 7 completely determined, up to permutation and rigid motion, by applying the 3-WL
17
+ 8 graph isomorphism test to the point cloud’s centralized Gram matrix. Moreover, we
18
+ 9 formulate a Euclidean variant of the 2-WL test and show that it is also sufficient to
19
+ 10 achieve completeness. We then show how our complete Euclidean WL tests can be
20
+ 11 simulated by a Euclidean graph neural network of moderate size and demonstrate
21
+ 12 their separation capability on highly-symmetrical point clouds.
22
+
23
+ # 13 1 Introduction
24
+
25
+ 14 A point cloud is a collection of $n$ points in $\mathbb { R } ^ { d }$ , where typically in applications $d = 3$ . Machine
26
+ 15 learning on point clouds is an important task with applications in chemistry Gilmer et al. [2017],
27
+ 16 Wang et al. [2022], physical systems Finzi et al. [2021] and image processing Ma et al. [2023]. Many
28
+ 17 successful architectures for point clouds are invariant by construction to the natural symmetries of
29
+ 18 point clouds: permutations and rigid motions.
30
+ 19 The rapidly increasing literature on point-cloud networks with permutation and rigid-motion sym
31
+ 20 metries has motivated research aimed at theoretically understanding the expressive power of the
32
+ 21 various architectures. This analysis typically focuses on two closely related concepts: Separation
33
+ 22 and Universality. We say an invariant architecture is separating, or complete, if it can assign distinct
34
+ 23 values to any pair of point clouds that are not related by symmetry. An invariant architecture is
35
+ 24 universal if it can approximate all continuous invariant functions on compact sets. Generally speaking,
36
+ 25 these two concepts are essentially equivalent, as discussed in Villar et al. [2021], Joshi et al. [2022],
37
+ 26 Chen et al. [2019], and in our context, in Appendix A.
38
+ 27 Dym and Maron [2020] proved that the well-known Tensor Field Network Thomas et al. [2018]
39
+ 28 invariant architecture is universal, but the construction in their proof requires arbitrarily high-order
40
+ 29 representations of the rotation group. Similarly, universality can be obtained using high-order
41
+ 30 representations of the permutation group Lim et al. [2022]. However, prior to this work, it was not
42
+ 31 known whether the same theoretical guarantees can be achieved by realistic point-cloud architectures
43
+ 32 that use low-dimensional representations, and whose complexity has a mild polynomial dependency
44
+ 33 on the data dimension. In the words of Pozdnyakov and Ceriotti [2022]: "...provably universal
45
+ 34 equivariant frameworks are such in the limit in which they generate high-order correlations. . . It is
46
+ 35 an interesting, and open, question whether a given order suffices to guarantee complete resolving
47
+ 36 power." (p. 6). We note that it is known that separation of point clouds in polynomial time in $n$
48
+ 37 is possible, assuming that $d$ is fixed (e.g., $d = 3$ ) Arvind and Rattan [2014], Dym and Kovalsky
49
+ 38 [2019], Kurlin [2022]. What still remains to be established is whether separation is achievable for
50
+ 39 common invariant machine learning models, and more generally, whether separation can be achieved
51
+ 40 by computing a continuous invariant feature that is piecewise differentiable.
52
+ 41 In this paper, we give what seems to be the first positive answer to this question. We focus on analyzing
53
+ 42 a popular method for the construction of invariant point-cloud networks via Graph Neural Networks
54
+ 43 (GNNs). This is done in two steps: first, point clouds are represented as a Euclidean graph- which we
55
+ 44 define to be a complete weighted graph whose edge features are simple, rotation-invariant features:
56
+ 45 the inner products between pairs of (centralized) points. We then apply permutation-invariant Graph
57
+ 46 Neural Networks (GNNs) to the Euclidean graphs to obtain a rotation- and permutation-invariant
58
+ 47 global point-cloud feature. This leads to a rich family of invariant point-cloud architectures, which is
59
+ 48 determined by the type of GNN chosen.
60
+ 49 The most straightforward implementation of this idea would be to apply the popular message passing
61
+ 50 GNNs to the Euclidean graphs. One could also consider applying more expressive GNNs. For
62
+ 51 combinatorial graphs, it is known that message-passing GNNs are only as expressive as the 1-WL
63
+ 52 graph isomorphism test. There exists a hierarchy of $k$ -WL graph isomorphism tests, where larger
64
+ 53 values of $k$ correspond to more expressive, and more expensive, graph isomorphism tests. There
65
+ 54 are also corresponding GNNs that simulate the $k$ -WL tests and have an equivalent separation power
66
+ 55 Morris et al. [2018], Maron et al. [2019]. One could then consider applying these more expressive
67
+ 56 architectures to Euclidean graphs, as suggested in Lim et al. [2022]. Accordingly, we aim to answer
68
+ 57 the following questions:
69
+
70
+ Question 1 For which $k$ is the $k$ -WL test, when applied to Euclidean graphs, complete?
71
+
72
+ Question 2 Can this test be implemented in polynomial time by a continuous, piecewise-differentiable architecture?
73
+
74
+ 61 We begin by addressing Question 1. First, we consider a variation of the WL-test adapted for point
75
+ 62 clouds, which we refer to as 1-EWL (’E’ for Euclidean). This test was first proposed by Pozdnyakov
76
+ 63 and Ceriotti [2022], where it was shown that it cannot distinguish between all 3-dimensional point
77
+ 64 clouds, and consequently, neither can GNNs like Victor Garcia Satorras [2021], Schütt et al. [2017],
78
+ 65 which can be shown to simulate it. Our first result, described in Section 2.1, balances this by showing
79
+ 66 that two iterations of 1-EWL are enough to separate almost any pair of point clouds.
80
+ 67 To achieve complete separationfor all point clouds, we consider higher-order $k$ -EWL tests. We first
81
+ 68 consider a natural adaptation of $k$ -WL for Euclidean graphs, which we name the Vanilla- $k$ -EWL test.
82
+ 69 In this test, the standard $k$ -WL is applied to the Euclidean graph induced by the point clouds. We
83
+ 70 show that when $k = 3$ , this test is complete for 3-dimensional point clouds. Additionally, we propose
84
+ 71 a variant of the Vanilla 2-EWL, which incorporates additional geometric information while having
85
+ 72 the same complexity. We call this test the 2-EWL test, and show that it is complete on 3D point
86
+ 73 clouds. We also propose a natural variation of 2-EWL called 2-SEWL, which can distinguish between
87
+ 74 point clouds that are related by a reflection. This ability is important for chemical applications, as
88
+ 75 most biological molecules that are related by a reflection are not chemically identical Kapon et al.
89
+ 76 [2021] (this molecular property is called chirality).
90
+ 77 We next address the second question of how to construct a GNN for Euclidean data with the same
91
+ 78 separation power as that of the various $k$ -EWL tests we describe. For combinatorial graphs, such
92
+ 79 equivalence results rely on injective functions defined on multisets of discrete features Xu et al. [2018].
93
+ 80 For Euclidean graphs, one can similarly rely on injective functions for multisets with continuous
94
+ 81 features, such as those proposed in Dym and Gortler [2023]. However, a naive application of this
95
+ 82 approach leads to a very large number of hidden features, which grows exponentially with the number
96
+ 83 of message-passing iterations (see Figure 2). We show how this problem can be remedied, so that the
97
+ 84 number of features needed depends only linearly on the number of message-passing iterations.
98
+
99
+ 85 To summarize, our main results in this paper are:
100
+
101
+ 1. We show that two iterations of 1-EWL can separate almost all point clouds in any dimension. 2. We prove the completeness of a single iteration of the vanilla 3-EWL for point clouds in $\mathbb { R } ^ { 3 }$ . 3. We formulate the 2-SEWL and 2-EWL tests, and prove their completeness for point clouds in $\mathbb { R } ^ { 3 }$ .
102
+
103
+ 4. We explain how to build differentiable architectures for point clouds with the same separation power as Euclidean $k$ -WL tests, with reasonable complexity.
104
+
105
+ 2 Experiments In Section 5 we present synthetic experiments that demonstrate that 2-SEWL can
106
+ 3 separate challenging point-cloud pairs that cannot be separated by several popular architectures.
107
+ 94 Disambiguation: Euclidean Graphs In this paper we use a simple definition of a Euclidean graph
108
+ 95 as the centralized Gram matrix of a point cloud, and focus on a fundamental theoretical question
109
+ 96 related to this representation. In the learning literature, terms like ‘geometric graphs’ (not used here)
110
+ 97 could refer to graphs that have both geometric and non-geometric edge and vertex features, or graphs
111
+ 98 where pairwise distances are only available for specific point pairs (edges in an incomplete graph).
112
+
113
+ # 99 1.1 Related Work
114
+
115
+ 100 Euclidean WL Pozdnyakov and Ceriotti [2022] showed that 1-EWL is incomplete for 3-
116
+ 101 dimensional point clouds. Joshi et al. [2022] defines separation for a more general definition
117
+ 102 of geometric graph, which combines geometric and combinatorial features. This work holds various
118
+ 103 interesting insights for this more general problem but they do not prove completeness as we do here.
119
+ 104 Other complete constructions As mentioned earlier, Dym and Maron [2020] proved universality
120
+ 105 with respect to permutations and rigid motions for architectures using high-dimensional represen
121
+ 106 tations of the rotation group. Similar results were obtained inFinkelshtein et al. [2022], Gasteiger
122
+ 107 et al. [2021]. In Lim et al. [2022] universality was proven for Euclidean GNNs with very high-order
123
+ 108 permutation representations. In the planar case $d = 2$ , universality using low-dimensional features
124
+ 109 was achieved in Bökman et al. [2022]. For $d \geq 3$ our construction seems to be the first to achieve
125
+ 110 universality using low dimensional representations.
126
+ 111 For general fixed $d$ , there do exist algorithms that can separate point clouds up to equivalence
127
+ 112 in polynomial time, but they do not seem to lend themselves directly to neural architectures. In
128
+ 113 Kurlin [2022], Widdowson and Kurlin [2023] complete tests are described, but they represent each
129
+ 114 point cloud as a ‘multiset of multisets’ rather than as a vector as we do, and so are not suitable for
130
+ 115 gradient descent based learning. Efficient tests for equivalence of Euclidean graphs were described in
131
+ 116 Brass and Knauer [2000], Arvind and Rattan [2014], but they compute features that do not depend
132
+ 117 continuously on the point cloud.
133
+ 118 Weaker notions of universality In Widdowson and Kurlin [2022] the authors suggest a method
134
+ 119 for distinguishing almost every point clouds up to equivalence, similar to our result here on 1-EWL.
135
+ 120 Similarly, efficient separation/universality can also be obtained for point clouds with distinct principal
136
+ 121 axes Puny et al. [2021], Kurlin [2022]. Another setting in which universality is easier to obtain is
137
+ 122 when only rigid symmetries are considered and permutation symmetries are ignored Wang et al.
138
+ 123 [2022], Villar et al. [2021], Victor Garcia Satorras [2021]. All these results do not provide universality
139
+ 124 for all point clouds, with respect to the joint action of permutations and rigid motions.
140
+
141
+ # 125 Mathematical notation
142
+
143
+ A (finite) multiset $\left\{ { y _ { 1 } , \dotsc , y _ { N } } \right\}$ is an unordered collection of elements where repetitions are allowed.
144
+
145
+ Let $\mathcal { G }$ be a group acting on a set $\mathcal { X }$ . For $X , Y \in { \mathcal { X } }$ , we say that $X = Y$ if $Y = g X$ for some $g \in { \mathcal { G } }$
146
+
147
+ 128 We say that a function $f : \mathcal { X } \mathcal { Y }$ is invariant if $f ( g x ) = f ( x )$ for all $x \in X , g \in G$ . We say that $f$
148
+ 129 is equivariant if $\mathcal { V }$ is also endowed with some action of $G$ and $f ( g x ) = g f ( x )$ for all $x \in \mathcal { X } , g \in \mathcal { G }$
149
+ 30 A separating invariant mapping is an invariant mapping that is injective, up to group equivalence:
150
+
151
+ 131 Definition 1.1 (Separating Invariant). Let $\mathcal { G }$ be a group acting on a set $\mathcal { X }$ . We say $F : \mathcal { X } \to \mathbb { R } ^ { K }$ is a $\mathcal { G }$ - separating invariant with embedding dimension 132 $K$ if for all $X , Y \in { \mathcal { X } }$ , $F ( X ) = F ( Y ) \Leftrightarrow X \frac { \ d Y } { \ d g } Y$ .
152
+
153
+ 133 We focus on the case where $\mathcal { X }$ is some Euclidean domain. To enable gradient-based learning, we
154
+ 134 shall need separating mappings that are continuous everywhere and differentiable almost everywhere.
155
+
156
+ ![](images/669014ea9bdfcfae89a3a9d4d1eebe79fad709f1080f0db81377608134311455.jpg)
157
+ Figure 1: Distance matrices (Left), geometric degree histogram (Right) of pairs of point clouds. The generic pair is a randomly sampled pair of point clouds. Notice each of the nodes in each of the clouds has a distinct geometric degree. The Hard pair exhibits a distinct geometric degree for each node, but only within each point cloud, that is the pair shares an identical geometric degree histogram. The Harder example is a pair of point clouds with identical geometric degree histogram, and each point cloud is comprised of three pairs of points, with each pair having an identical geometric degree. Examples from Pozdnyakov and Ceriotti [2022] and Pozdnyakov et al. [2020].
158
+
159
+ The symmetry group we consider for point clouds $( x _ { 1 } , \ldots , x _ { n } ) \in \mathbb { R } ^ { d \times n }$ is generated by a rotation matrix $R \in S { \mathcal { O } } ( d )$ , and a permutation $\sigma \in S _ { n }$ . These act on a point cloud by
160
+
161
+ $$
162
+ ( R , \sigma ) _ { * } ( x _ { 1 } , \ldots , x _ { n } ) = ( R x _ { \sigma ^ { - 1 } ( 1 ) } , \ldots , R x _ { \sigma ^ { - 1 } ( n ) } ) .
163
+ $$
164
+
165
+ 135 We denote this group by $s \mathcal { O } [ d , n ]$ . In some instances, reflections $R \in { \mathcal { O } } ( d )$ are also permitted,
166
+ 136 leading to a slightly larger symmetry group, which we denote by $\mathcal { O } [ d , n ]$ . Our goal shall be to
167
+ 137 construct separating invariants for these groups. For the sake of brevity, we do not discuss translation
168
+ 138 invariance and separation, as these can easily be achieved by centering the input point clouds, once
169
+ 139 $s \mathcal { O } [ d , n ]$ (or ${ \mathcal { O } } [ d , n ] )$ separating invariants are constructed, see Dym and Gortler [2023].
170
+
171
+ For simplicity of notation, throughout this paper, we focus on the case $d = 3$ . In Appendix $\textrm { C }$ we explain how our constructions and theorems can be generalized to $d > 3$ .
172
+
173
+ # 142 2 Euclidean Graph Isomorphism Tests
174
+
175
+ 143 The $k$ -WL Graph Isomorphism Test Weisfeiler and Leman [1968] is a classical paradigm for testing
176
+ 144 the isomorphism of combinatorial graphs, which we shall now briefly describe. Let $\mathcal { G }$ be a graph with
177
+ 145 vertices indexed by $[ n ] = \{ 1 , 2 , \dots , \bar { n } \}$ . We denote each ordered $k$ -tuple of vertices by a multi-index
178
+ 146 $\mathbf { i } = ( i _ { 1 } , \dots , i _ { k } ) \in [ n ] ^ { k }$ . Essentially, for each such $k$ -tuple i, the test maintains a coloring $\mathbf { C } ( \mathbf { i } )$ that
179
+ 147 belongs to a discrete set, and updates it iteratively. First, the coloring of each $k$ -tuple is assigned an
180
+ 148 initial value that encodes the isomorphism type of the corresponding $k$ -dimensional subgraph:
181
+
182
+ $$
183
+ \mathbf { C } _ { ( 0 ) } = \mathbf { C } _ { ( 0 ) } ( \mathbf { i } ) , \mathbf { i } \in [ n ] ^ { k } .
184
+ $$
185
+
186
+ 149 Then the color of each $k$ -tuple $\mathbf { i }$ is iteratively refined according to the colors of its ‘neighboring’
187
+ 150 $k$ -tuples. The update rule is given by
188
+
189
+ $$
190
+ \mathbf { C } _ { ( \mathsf { t } + 1 ) } ( \mathbf { i } ) = \mathbf { E m b e d } ^ { ( t + 1 ) } \left( \mathbf { C } _ { ( \mathsf { t } ) } ( \mathbf { i } ) , \ P \left( \mathbf { C } _ { ( \mathsf { t } ) } ( \mathbf { i } [ j \setminus 1 ] ) , \ldots , \mathbf { C } _ { ( \mathsf { t } ) } ( \mathbf { i } [ j \setminus k ] ) \right) \mid j \in [ n ] \ P \right) ,
191
+ $$
192
+
193
+ where $\mathbf { i } [ j \mathbf { \theta } \backslash t ]$ is the multi-index i with its $t$ -th coordinate replaced by $j$ ; e.g. for $j = 1$ , $\mathbf { i } [ j \setminus 1 ] =$ $( j , i _ { 2 } , \ldots , i _ { k } )$ . Embed is a function that maps its input injectively to some discrete set. This process is repeated $T$ times to obtain a final coloring $\mathfrak { Y } \mathbf { C } _ { ( \mathbf { T } ) } ( \mathbf { i } ) \mathbb { Y } _ { \mathbf { i } \in [ n ] ^ { k } }$ . A global label is then calculated by
194
+
195
+ $$
196
+ \mathbf { C } _ { \mathcal { G } } = \mathbf { E m b e d } ^ { ( T + 1 ) } \left( \left\{ \mathbf { C } _ { ( \mathbf { T } ) } ( \mathbf { i } ) \ | \ \mathbf { i } \in [ n ] ^ { k } \right\} \right) ,
197
+ $$
198
+
199
+ where 151 $\mathbf { E m b e d } ^ { ( T + 1 ) }$ is a function that maps label-multisets injectively to some discrete set.
200
+
201
+ 152 To test whether two graphs $\mathcal { G }$ and $\mathcal { G } ^ { \prime }$ are isomorphic, the $k$ -WL test computes the corresponding
202
+ 153 colorings $\mathbf { C } _ { \mathcal { G } }$ and $\mathbf { C } _ { \mathcal { G } ^ { \prime } }$ for some chosen $T$ . If $\mathbf { C } _ { \mathcal { G } } \neq \mathbf { C } _ { \mathcal { G } ^ { \prime } }$ then $\mathcal { G }$ and $\mathcal { G } ^ { \prime }$ are guaranteed not to be
203
+ 154 isomorphic, whereas if $\mathbf { C } _ { \mathcal { G } } = \mathbf { C } _ { \mathcal { G } ^ { \prime } }$ , then $\mathcal { G }$ and $\mathcal { G } ^ { \prime }$ may either be isomorphic or not, and the test does
204
+ 155 not, in general, provide a decisive answer for combinatorial graphs. It is known that this test is able
205
+ 156 to distinguish a strictly larger class of combinatorial graphs for every strict increase in the value of $\mathrm { k }$ ,
206
+ 157 i.e. it is a strict hierarchy of tests in terms of distinguishing power Cai et al. [1992], Grohe [2017].
207
+ 158 Vanilla- $k$ -WL tests As a first step from a combinatorial to a Euclidean setting, we identify each
208
+ 159 point cloud $\boldsymbol { X } = ( x _ { 1 } , \ldots , x _ { n } ) \in \mathbb { R } ^ { { \hat { d } } \times n }$ with a complete graph on $n$ vertices, wherein each edge $( i , j )$
209
+ 160 is endowed with the weight $w _ { i j } ( X ) = \langle x _ { i } , x _ { j } \rangle$ . We name such a graph a Euclidean graph. Similarly
210
+ 161 to $k$ -WL for combinatorial graphs, $k$ -WL for Euclidean graphs maintains a coloring of the $k$ -tuples of
211
+ 162 vertices. However, the initial color of each $k$ -tuple i is not a discrete label as in the combinatorial case,
212
+ 163 but rather a $k \times k$ matrix of continuous features, which represent all edge weights $w _ { i j }$ corresponding
213
+ 164 to pairs of indices from i. We will call the $k$ -WL test defined by this initial coloring the vanilla $k$ -WL
214
+ 165 test. This test is invariant by construction to reflections, rotations, and permutations. We note that our
215
+ 166 definition of the vanilla $k$ -EWL test via inner products follows that of Lim et al. [2022]. Another
216
+ 167 popular, and essentially equivalent, formulation, uses distances instead.
217
+ 168 $k$ -EWL tests An inherent limitation of the Vanilla-1-EWL test is that no pairwise Euclidean
218
+ 169 information is passed, yielding it rather uninformative. Indeed, Pozdnyakov and Ceriotti [2022]
219
+ 170 proposed a Euclidean analog of the 1-WL test, where the update rule (2) is replaced with
220
+
221
+ $$
222
+ { \bf C } _ { \left( { \bf t } + { \bf 1 } \right) } ( i ) = { \bf E m b e d } ^ { \left( { \bf t } \right) } \left( { \bf C } _ { \left( { \bf t } \right) } ( i ) , \left\{ \left( { \bf C } _ { \left( { \bf t } \right) } ( j ) , \left. x _ { i } - x _ { j } \right. \right) , j \neq i \right\} \right) .
223
+ $$
224
+
225
+ 171 We call this test the 1-EWL test. This formulation is motivated by the fact that many symmetry
226
+ 172 preserving networks for point clouds are in fact a realization of it, though they use Embed functions
227
+ 173 that are continuous and, in general, may assign the same value to different multisets. Consequently,
228
+ 174 the separation power of these architectures is at most that of 1-EWL with discrete injective hash
229
+ 175 functions. Moreover, the separation power will be equivalent if continuous injective multiset functions
230
+ 176 are used for embedding, as we discuss in Section 4.
231
+ 177 The 1-EWL test strengthens the Vanilla-1-EWL test by allowing the messages passed to a node
232
+ 178 in each step to contain not only previous colorings but also geometric information in the form of
233
+ 179 pairwise distances. More generally, we shall use the term $k$ -EWL to refer to tests that follow the
234
+ 180 Euclidean $k$ -WL paradigm, but incorporate geometric invariants into the message-passing procedure.
235
+ 181 In particular, for point clouds with dimension 3, we define the 2-SEWL test (’SE’ for Special
236
+ 182 Euclidean) by replacing the update step (2) with
237
+
238
+ $$
239
+ \mathbf { C } _ { ( \mathsf { t } + 1 ) } ( i , j ) = \mathbf { E m b e d } ^ { ( t ) } \left( \mathbf { C } _ { ( \mathsf { t } ) } ( i , j ) , \ P \left( \mathbf { C } _ { ( \mathsf { t } ) } ( k , j ) , \mathbf { C } _ { ( \mathsf { t } ) } ( i , k ) , \langle x _ { i } \times x _ { j } , x _ { k } \rangle \right) \ P _ { k = 1 } ^ { n } \right) .
240
+ $$
241
+
242
+ 83 Note that $\langle x _ { i } \times x _ { j } , x _ { k } \rangle$ is equal to the determinant of the $3 \times 3$ matrix whose rows are the three vectors
243
+ 84 $x _ { i } , x _ { j } , x _ { k }$ , which makes this a natural choice as all polynomial invariants of $s \mathcal { O } ( 3 )$ are generated by
244
+ 85 these determinants and the inner products we use for the initial coloring Kraft and Procesi [1996].
245
+ 186 We note that, Using the fact that $O ( 3 )$ is just two copies of $S O ( 3 )$ , it is not difficult to generalize
246
+ 187 2-SEWL to a complete $\mathcal { O } [ 3 , n ]$ test, which we name 2-EWL. for general $d$ , similar complete $( d - 1 )$ -
247
+ 188 SEWL and $( d - 1 )$ -EWL tests can be formulated for point clouds in $\mathbb { R } ^ { d }$ via the Hodge-star operator;
248
+ 189 see Appendix C for more details.
249
+ 190 In the rest of this section, we shall prove that the 2-SEWL, 2-EWL and vanilla 3-EWL tests are
250
+ 191 complete when applied to $\mathbb { R } ^ { 3 \times n }$ , even when using a single iteration $T = 1$ ). We shall also show that
251
+ 192 two iterations of the 1-EWL test is complete, except on a set of measure zero.
252
+
253
+ # 193 2.1 Generic completeness of 1-EWL
254
+
255
+ The separation power of 1-EWL is closely linked to the notion of geometric degree: For a point cloud $X = ( x _ { 1 } , \ldots , x _ { n } )$ , we define the geometric degree $d ( i , X )$ of the $i$ th point, and the induced geometric degree histogram $d _ { H } ( X )$ , to be the multisets
256
+
257
+ $$
258
+ d ( i , X ) = \{ \| x _ { 1 } - x _ { i } \| , \ldots , \| x _ { n } - x _ { i } \| \} , \quad d _ { H } ( X ) = \{ d ( 1 , X ) , \ldots , d ( n , X ) \} .
259
+ $$
260
+
261
+ It is not difficult to see that if $d _ { H } ( X ) \neq d _ { H } ( Y )$ then $X$ and $Y$ can be separated by a single 1-EWL iteration . An example of such a pair is shown in the left of Figure 1. With two 1-EWL iterations, we show that can separate $X$ and $Y$ even if $d _ { H } ( X ) = d _ { H } ( Y )$ , provided that they both belong to the set of point clouds defined by
262
+
263
+ $$
264
+ \mathbb { R } _ { d i s t i n c t } ^ { 3 \times n } = \{ X \in \mathbb { R } ^ { 3 \times n } | d ( i , X ) \neq d ( j , X ) \ \forall i \neq j \} .
265
+ $$
266
+
267
+ 94 Such an example, taken from Pozdnyakov et al. [2020], is visualized in the middle column of Figure
268
+
269
+ Theorem 2.1. Two iterations of the 1-EWL test assign two point clouds $\mathcal { X } , Y \in \mathbb { R } _ { d i s t i n c t } ^ { 3 \times n }$ the same $X \underset { \mathcal { O } [ 3 , n ] } { = } Y$
270
+
271
+ In the appendix we show that the complement of 198 $\mathbb { R } _ { d i s t i n c t } ^ { 3 \times n }$ has measure zero. Thus this result complements long-standing results for combinatorial graphs, stating that 1-WL can classify almost 200 all such graphs as the number of nodes tends to infinity Babai et al. [1980].
272
+
273
+ The right-most pair of point clouds (’Harder’) in Figure 1 is taken from Pozdnyakov and Ceriotti [2022]. The degree histograms of these point clouds are identical, and they are not in $\mathbb { R } _ { d i s t i n c t } ^ { 3 \times n }$ . Pozdnyakov and Ceriotti [2022] show that this pair cannot be separated by any number of 1-EWL iterations.
274
+
275
+ # 2.2 Is 1-EWL All You Need?
276
+
277
+ Theorem 2.1 shows that the probability of a failure of the 1-EWL is zero. A natural question to ask is whether more powerful tests are needed. We believe the answer to this question is yes. Typical hypothesis classes used for machine learning, such as neural networks, are Lipschitz continuous Gama et al. [2020]. In this setting, failure to separate on a measure zero set could have implications for non-trivial positive measure. This phenomenon is depicted in the figure in the inset. On the right, a plot of a Gaussian distribution centered at $x \in \mathbb { R }$ , depicting a target function is shown in blue. In red, a schematic plot of how a Lipschitz continuous function that does not distinguish $x$ from $y$ would model the target function.
278
+
279
+ ![](images/e2038e59f05f70d7e4b89040a148a46c0e26959eaf0c74509809f79752553fc9.jpg)
280
+
281
+ # 3 2-SEWL and Vanilla 3-EWL are complete
282
+
283
+ We now prove that the vanilla 3-EWL test is complete.
284
+
285
+ Theorem 3.1. For every $X , Y \in \mathbb { R } ^ { 3 \times n }$ , a single iteration of the vanilla 3-EWL test assigns $X$ and $Y$ the same value if and only if $\cdot _ { X } \underset { \mathcal { O } [ 3 , n ] } { = } Y$ .
286
+
287
+ Proof. First, it is clear that if $X \_ { \phantom { } _ { \mathcal { O } [ 3 . n ] } } Y$ then $\mathbf { C } _ { \mathcal { G } } ( X ) = \mathbf { C } _ { \mathcal { G } } ( Y )$ since the vanilla 3-EWL test is invariant by construction. The challenge is proving the other direction. To this end, let us assume that $\mathbf { C } _ { \mathcal { G } } ( X ) = \mathbf { C } _ { \mathcal { G } } ( Y )$ , and assume without loss of generality that $r : = \mathrm { r a n k } ( X ) \geq \mathrm { r a n k } ( Y )$ . Note that $X$ has rank $r \leq 3$ , and so it must contain some three points whose rank is also $r$ . By applying a permutation to $X$ we can assume without loss of generality that these three points are the first three points. The initial coloring ${ \bf C _ { 0 } } ( 1 , 2 , 3 ) ( X )$ of this triplet is their Gram matrix $( \langle x _ { i } , x _ { j } \rangle ) _ { 1 \leq i , j \leq 3 }$ , which has the same rank $r$ as the space spanned by the three points. Next, since $\mathbf { C } _ { \mathcal { G } } ( X ) = \bar { \mathbf { C } } _ { \mathcal { G } } ( \bar { Y } )$ are the same, there exists a triplet of points $i , j , k$ such that $\mathbf { C } _ { ( 1 ) } ( 1 , 2 , 3 ) ( X ) = \mathbf { C } _ { ( 1 ) } ( i , j , k ) ( Y )$ which implies that the initial colorings are also the same. By applying a permutation to $Y$ we can assume without loss of generality that $i = 1 , j = 2 , k = 3$ . Next, since the Gram matrix of $x _ { 1 } , x _ { 2 } , x _ { 3 }$ and $y _ { 1 } , y _ { 2 } , y _ { 3 }$ are identical, there is an orthogonal transformation that takes $x _ { i }$ to $y _ { i }$ for $i = { 1 , 2 , 3 }$ , and by applying this transformation to all points in $X$ we can assume without loss of generality that $x _ { i } = y _ { i }$ for $i = { 1 , 2 , 3 }$ . It remains to show that the rest of the points of $X$ and $Y$ are equal, up to permutation. To see this, first note that $X$ and $Y$ have the same rank since
288
+
289
+ $$
290
+ r = \operatorname { r a n k } ( X ) \geq \operatorname { r a n k } ( Y ) \geq \operatorname { r a n k } ( y _ { 1 } , y _ { 2 } , y _ { 3 } ) = \operatorname { r a n k } ( x _ { 1 } , x _ { 2 } , x _ { 3 } ) = r .
291
+ $$
292
+
293
+ Thus the space spanned by $x _ { 1 } = y _ { 1 } , x _ { 2 } = y _ { 2 } , x _ { 3 } = y _ { 3 }$ contains all points in $X$ and $Y$ . Next, we can deduce from the aggregation rule defining $\mathbf { C _ { 1 } } ( 1 , 2 , 3 ) ( X )$ in (2), that
294
+
295
+ $$
296
+ \begin{array} { r } { \sharp ( \langle x _ { j } , x _ { 1 } \rangle , \langle x _ { j } , x _ { 2 } \rangle , \langle x _ { j } , x _ { 3 } \rangle ) \mid j \in [ n ] \mathbb { J } = \mathbb { f } ( \langle y _ { j } , y _ { 1 } \rangle , \langle y _ { j } , y _ { 2 } \rangle , \langle y _ { j } , y _ { 3 } \rangle ) \mid j \in [ n ] \mathbb { J } . } \end{array}
297
+ $$
298
+
299
+ 222 Since all points in $X$ and $Y$ belong to the span of $x _ { 1 } = y _ { 1 } , x _ { 2 } = y _ { 2 } , x _ { 3 } = y _ { 3 }$ , $X$ and $Y$ are the same
300
+ 223 up to permutation of the last $n - 3$ coordinates. This concludes the proof of the theorem. □
301
+
302
+ 224 We next outline the completeness proof of the more efficient 2-SEWL.
303
+
304
+ Theorem 3.2. For every 25 $X , Y \in \mathbb { R } ^ { 3 \times n }$ , a single iteration of the 2-SEWL test assigns $X$ and $Y$ the same value if and only if 26 $X _ { \_ { S O [ 3 , n ] } } Y$ .
305
+
306
+ Proof idea. The completeness of Vanilla-3-EWL was based on the fact that its initial coloring captures the Gram matrix of triplets of vectors that span the space spanned by $X$ , and on the availability of projections onto this basis in the aggregation step defined in (2). Our proof for 2-EWL completeness relies on the fact that a pair of non-degenerate vectors $x _ { i } , x _ { j }$ induces a basis $x _ { i } , x _ { j } , x _ { i } \times x _ { j }$ of $\mathbb { R } ^ { 3 }$ The Gram matrix of this basis can be recovered from the Gram matrix of the first two points $x _ { i } , x _ { j }$ and the projection onto this basis can be obtained from the extra geometric information we added in (18). A full proof is given in the appendix. □
307
+
308
+ To conclude this section, we note that the above theorem can be readily used to also show that the 2-EWL test us also complete with respect to $\mathcal { O } [ 3 , n ]$ . For details see Appendix A.
309
+
310
+ # 236 4 WL-equivalent GNNs with continuous features
311
+
312
+ In the previous section we discussed the generic completeness of 1-EWL and the completeness of 2-SEWL and vanilla 3-EWL. The Embed functions in these tests are hash functions, which can be redefined independently for each pair of point clouds $X , Y$ . In this section, our goal is to explain how to construct GNNs with equivalent separation power to that of these tests, while choosing continuous, piecewise differentiable Embed functions that are injective. While this question is well studied for combinatorial graphs with discrete features Xu et al. [2018], Morris et al. [2018], Maron et al. [2019], Aamand et al. [2022], here we focus on addressing it for Euclidean graphs with continuous features.
313
+
314
+ # 44 4.1 Multiset injective functions
315
+
316
+ 245 Let us first review some known results on injective multiset functions. Recall that a function defined on
317
+ 246 multisets with $n$ elements coming from some alphabet $\Omega \subseteq \mathbb { R } ^ { D }$ can be identified with a permutation
318
+ 247 invariant function defined on $\Omega ^ { n }$ . A multiset function is injective if and only if its corresponding
319
+ 248 function on $\Omega ^ { n }$ is separating with respect to the action of the permutation group (see Definition 1.1).
320
+ 249 In Corso et al. [2020], Wagstaff et al. [2022] it was shown that for any separating, permutation
321
+ 250 invariant mappings from $\mathbb { R } ^ { n }$ to $\mathbb { R } ^ { K }$ , the embedding dimension $K$ will be at least $n$ . Two famous
322
+ 251 examples of continuous functions that achieve this bound are
323
+
324
+ $$
325
+ \Psi _ { s o r t } ( x _ { 1 } , \ldots , x _ { n } ) = \mathrm { s o r t } ( x _ { 1 } , \ldots , x _ { n } ) \quad { \mathrm { a n d } } \quad \Psi _ { p o w } ( x _ { 1 } , \ldots , x _ { n } ) = \left( \sum _ { i = 1 } ^ { n } x _ { i } ^ { t } \right) _ { t = 1 } ^ { n } .
326
+ $$
327
+
328
+ 252 When the multiset elements are in $\mathbb { R } ^ { D }$ , the picture is similar: if there exists a continuous, permutation
329
+ 253 invariant and separating mapping from $\mathbb { R } ^ { D \times n }$ to $\mathbb { R } ^ { K }$ , then necessarily $K \geq n \cdot D$ Joshi et al. [2022].
330
+ 254 In Dym and Gortler [2023] it is shown that continuous separating invariants for $D > 1$ , with near
331
+ 255 optimal dimension, can be derived from the $D = 1$ separating invariants $\Psi = \Psi _ { p o w }$ or $\Psi = \Psi _ { s o r t }$ ,
332
+ 256 by considering random invariants of the form
333
+
334
+ $$
335
+ \mathbf { E m b e d } _ { \theta } ( x _ { 1 } , \dots , x _ { n } ) = \langle b _ { j } , \Psi \left( a _ { j } ^ { T } x _ { 1 } \dots , a _ { j } ^ { T } x _ { n } \right) \rangle , j = 1 , \dots , K .
336
+ $$
337
+
338
+ 257 where each $a _ { j }$ and $b _ { j }$ are $d$ and $n$ dimensional random vectors, and we denote $\theta \quad =$
339
+ 258 $( a _ { 1 } , \dots , a _ { K } , b _ { 1 } , \dots , b _ { K } ) \in \mathbb { R } ^ { K ( D + n ) }$ . When $K = 2 n D + 1$ , for almost any choice of $\theta$ , the
340
+ 259 function $\mathbf { E m b e d } _ { \theta }$ will be separating on $\mathbb { R } ^ { D \times n }$ . Thus the embedding dimension in this construction is
341
+ 260 optimal up to a multiplicative constant of two.
342
+ 261 An important property of this results of Dym and Gortler [2023] for our discussion, is that the
343
+ 262 embedding dimension $K$ can be reduced if the domain of interest is a non-linear subset of $\mathbb { R } ^ { D \times n }$
344
+ 263 of low dimension. For example, if the domain of interest is a finite union of lines in $\mathbb { R } ^ { D \times n }$ , then
345
+ 264 the instrinsic dimension of the domain is 1, and so we will only need an embedding dimension of
346
+ 265 $K = 2 \cdot 1 + 1 = 3$ . Thus, the required embedding dimension depends on the intrinsic dimension of
347
+ 266 the domain rather than on its ambient dimension, which in our case is $n \cdot D$ .
348
+ 267 To formulate these results precisely we will need to introduce some real algebraic geometry terminol
349
+ 268 ogy (see Basu et al. [2006] for more details): A semi-algebraic subset of a real finite-dimensional
350
+ 269 vector space is a finite union of subsets that are defined by polynomial equality and inequality
351
+ 270 constraints. For example, polygons, hyperplanes, spheres, and finite unions of these sets, are all
352
+ 271 semi-algebraic sets. A semi-algebraic set is always a finite union of manifolds, and its dimension is
353
+ 272 the maximal dimension of the manifolds in this union. Using these notions, we can now state the
354
+ 273 ‘intrinsic version’ of the results in Dym and Gortler [2023]:
355
+ 74 Theorem 4.1 (Dym and Gortler [2023]). Let $\mathcal { X }$ be an $S _ { n }$ -invariant semi-algebraic subset of $\mathbb { R } ^ { D \times n }$ of
356
+ 75 dimension $D _ { \mathcal { X } }$ . Denote $K = 2 D _ { \mathcal { X } } + 1$ . Then for Lebesgue almost every $\bar { \theta \in \mathbb { R } ^ { K ( D + n ) } }$ the mapping
357
+ 76 $E m b e d _ { \theta } : \mathcal { X } \mathbb { R } ^ { K }$ is $S _ { n }$ invariant and separating.
358
+
359
+ # 4.2 Multiset injective functions for GNNs
360
+
361
+ 78 We now return to discuss GNNs and explain the importance of the distinction between the intrinsic and ambient dimensions in our context. Suppose we are given 279 $n$ initial features $( h _ { 1 } ^ { ( 0 ) } , \ldots , h _ { n } ^ { ( 0 ) } )$ in 80 $\mathbb { R } ^ { d }$ , and for simplicity let us assume they are recursively refined via the simple aggregation rule:
362
+
363
+ $$
364
+ h _ { i } ^ { ( t + 1 ) } = \mathbf { E m b e d } ^ { ( t ) } \left( \{ h _ { j } ^ { ( t ) } \} _ { j = 1 , j \neq i } ^ { n } \right) .
365
+ $$
366
+
367
+ 281 Let us assume that each $\mathbf { E m b e d } ^ { ( t ) }$ is injective on the space of all multisets with $n - 1$ elements in
368
+ 282 the ambient space of ${ h } _ { j } ^ { ( t ) }$ . Then the injectivity of $\mathbf { E m b e d } ^ { ( 1 ) }$ implies that $h _ { i } ^ { ( 1 ) }$ is of dimension at least
369
+ 283 $( n - 1 ) \cdot d$ . The requirement that $\mathbf { E m b e d } ^ { ( 2 ) }$ is injective on a mult-set of $n - 1$ features in $\mathbb { R } ^ { ( n - 1 ) \cdot d }$
370
+ 284 implies that ${ h } _ { i } ^ { ( 2 ) }$ will be of dimension at least $( n - 1 ) ^ { 2 } \cdot d$ . Continuing recursively with this argument
371
+ 285 we obtain an estimate of $\sim ( n - 1 ) ^ { T } d$ for the dimensions of each $h _ { i } ^ { ( T ) }$ after $T$ iterations of (7).
372
+
373
+ Fortunately the analysis presented above is overly pessimistic, because it focused only on 9 the ambient dimension. Let us denote the matrix containing all $n$ features at time $t$ by $H ^ { ( t ) }$ . Then $H ^ { ( t ) } = \bar { F _ { t } } ( H ^ { ( 0 ) } )$ , where $F _ { t }$ is the con2 catenation of all $\mathbf { E m b e d } ^ { ( t ^ { \prime } ) }$ functions from all 3 previous time-steps. Thus $H ^ { ( t ) }$ resides in the set $\mathbf { \widehat { F } } _ { t } ( \mathbb { R } ^ { d \times n } )$ . Here we again rely on results from algebraic geometry: if $F _ { t }$ is a composition of piecewise linear and polynomial mappings, then it is a semi-algebraic mapping, which means that $F _ { t } ( H ^ { ( 0 ) } )$ will be a semi-algebraic set of di9 mension $\mathrm { d i m } ( \mathbb { R } ^ { n \times d } ) = n \cdot d$ . This point will be 0 explained in more detail in the proof of Theorem 4.2. By Theorem 4.1 we can then use $\mathbf { E m b e d } _ { \theta }$ as a multiset injective function on $\mathcal { X } _ { t }$ with a fixed embedding dimension of $2 n \cdot d + 1$ which does not depend on $T$ . This is visualized in Figure 2.
374
+
375
+ ![](images/55233fb32c73b264590f496c5a0ea16351dfd20a2210362779987f3b803cfd7c.jpg)
376
+ Figure 2: The exponential growth in the dimension that would result from only considering the ambient feature dimension can be avoided by exploiting the constant intrinsic dimension.
377
+
378
+ 2-SEWLnet Based on the discussion above, we can devise architectures that simulate the various tests discussed in this paper and have reasonable feature dimensions throughout the construction, In particular, we can simulate $T$ iterations of the 2-SEWL test by replacing all $\mathbf { E m b e d } ^ { ( t ) }$ functions1with $\mathbf { E m b e d } _ { \theta } ^ { ( t ) }$ , where in our implementation we choose $\Psi = \Psi _ { s o r t }$ in (6). The embedding dimension for all $t$ is taken to be $6 n + 1$ , since the input is in $\mathbb { R } ^ { 3 \times n }$ . We denote the obtained parametric function by $F _ { \phi }$ . Based on a formalization of the discussion above, we prove in the appendix that $F _ { \phi }$ has the separation power of the complete 2-SEWL test, and therefore $F _ { \phi }$ is separating.
379
+
380
+ 10 Theorem 4.2. Let $F _ { \phi }$ denote the parametric function simulating the 2-SEWL test. Then for Lebesgue almost every 311 $\phi$ the function $F _ { \phi } : \mathbb { R } ^ { 3 \times n } \mathbb { R } ^ { 6 n + 1 }$ is separating with respect to the action of $s \mathcal { O } [ 3 , n ]$
381
+
382
+ To conclude this subsection, we note that while sort-based permutation invariants are used as aggregators in GNNs Zhang et al. [2020, 2018], Blondel et al. [2020], the polynomial-based aggregators $\Psi _ { p o w }$ are not as common. To a certain extent, one can use the approach in $\mathrm { X u }$ et al. [2018], Maron et al. [2019], replace the polynomials in $\Psi _ { p o w }$ by MLPs, and justify this by the universal approximation power of MLPs. A limitation of this approach is that it only guarantees separation at the limit.
383
+
384
+ # 317 5 Synthetic Experiments
385
+
386
+ In this section we implement 2-SEWLnet, described in Section 4, and empirically evaluate its separation power, and the separation power of alternative $s \mathcal { O } [ 3 , n ]$ invariant point cloud architectures. We trained the architectures on permuted and rotated variations of highly-challenging point-cloud pairs, and measured separation by the test classification accuracy. We considered three pairs of point clouds (Hard1-Hard3) from Pozdnyakov et al. [2020]. These pairs were designed to be challenging for distance-based invariant methods. However, our analysis reveals that they are in fact separable by two iterations of the 1-EWL test. We then consider a pair of point clouds from Pozdnyakov and Ceriotti [2022] which was proven to be indstinguishable by the 1-EWL tests. The results of this experiment are given in Table 1. Further details on the experimental setup appear in Appendix B.
387
+
388
+ Table 1: Separation accuracy on challenging 3D point clouds. Hard examples correspond to point clouds which cannot be distinguished by a single 1-EWL iteration but can be distinguished by two iterations, according to Theorem 2.1. The Harder example is a point cloud not distinguishable by 1-EWL Pozdnyakov and Ceriotti [2022]. GNN implementations and code pipeline based on Joshi et al. [2022].
389
+
390
+ <table><tr><td>Separation</td><td>complete</td><td>≌1-EWL</td><td>unknown</td><td>unknown</td><td>unknown</td></tr><tr><td>Point Clouds</td><td>2-SEWLnet</td><td>EGNN</td><td>MACE</td><td>TFN</td><td>GVPGNN</td></tr><tr><td>Hard1</td><td>100 %</td><td>100 %</td><td>100%</td><td>100 %</td><td>100 %</td></tr><tr><td>Hard2</td><td>100 %</td><td>100 %</td><td>100 %</td><td>100 %</td><td>50%</td></tr><tr><td>Hard3</td><td>100 %</td><td>100 %</td><td>100 %</td><td>100 %</td><td>95.0 ± 15.0 %</td></tr><tr><td>Harder</td><td>100 %</td><td>50%</td><td>100 %</td><td>100 %</td><td>53.7 ± 13.1 %</td></tr></table>
391
+
392
+ 327 As expected, we find that 2-SEWLnet, which has complete separation power, succeeded in perfectly
393
+ 328 separating all examples. We also found that EGNN Victor Garcia Satorras [2021], which is essentially
394
+ 329 an implementation of 1-EWL, does not separate the Harder example, but does separate the Hard
395
+ 330 example after two iterations, as predicted by Theorem 2.1. We also considered three additional
396
+ 331 invariant point cloud models whose separation power is not as well understood. We find that MACE
397
+ 332 Batatia et al. [2022] and TFN Thomas et al. [2018] achieve perfect separation, (when applying them
398
+ 333 with at least 3-order correlations and three-order $S O ( 3 )$ representations). The third GVPGNN Jing
399
+ 334 et al. [2021] architecture attains mixed results. We note that we cannot necessarily deduce from our
400
+ 335 empirical results that MACE and TFN are complete. While it is true that TFN is complete when
401
+ 336 considering arbitrarily high order representations Dym and Maron [2020], it is not clear whether
402
+ 337 order three representation suffices for complete separation. We conjecture that this is not the case.
403
+ 338 However, finding counterexamples is a challenging problem we leave for future work.
404
+
405
+ Future Work In this work, we presented several invariant tests for point clouds that are provably complete, and have presented and implemented 2-SEWL-net which simulates the complete 2-SEWL test. Currently, this is a basic implementation that only serves to corroborate our theoretical results. A practically useful implementation requires addressing several challenges, including dealing with point clouds of different sizes, the non-trivial $\sim n ^ { 4 }$ complexity of computing even the relatively efficient 2-SEWL-net, and finding learning tasks where complete separation leads to gains in performance. We are actively researching these directions and hope this paper will inspire others to do the same.
406
+
407
+ References
408
+ 347 Patrick Reiser, Marlen Neubert, Andr’e Eberhard, Luca Torresi, Chen Zhou, Chen Shao, Houssam Metni, Clint van Hoesel, Henrik Schopmans, Timo Sommer, and Pascal Friederich. Graph neural networks for materials science and chemistry. Communications Materials, 3(1):93, 2022. doi: 10.1038/s43246-022-00315-6. Zixuan Yi, Iadh Ounis, and Craig Macdonald. Graph contrastive learning with positional representation for recommendation. In Jaap Kamps, Lorraine Goeuriot, Fabio Crestani, Maria Maistro, Hideo Joho, Brian Davis, Cathal Gurrin, Udo Kruschwitz, and Annalina Caputo, editors, Advances in Information Retrieval, pages 288–303, Cham, 2023. Springer Nature Switzerland. ISBN 978-3-031-28238-6.
409
+ 356 Justin Gilmer, Samuel S. Schoenholz, Patrick F. Riley, Oriol Vinyals, and George E. Dahl. Neural message passing for quantum chemistry. CoRR, 2017. Limei Wang, Yi Liu, Yuchao Lin, Haoran Liu, and Shuiwang Ji. Comenet: Towards complete and efficient message passing for 3d molecular graphs, 2022.
410
+ 360 Marc Finzi, Max Welling, and Andrew Gordon Wilson. A practical method for constructing equivariant multilayer perceptrons for arbitrary matrix groups. arXiv preprint arXiv:2104.09459, 2021.
411
+ 362 Xu Ma, Yuqian Zhou, Huan Wang, Can Qin, Bin Sun, Chang Liu, and Yun Fu. Image as set of points, 2023.
412
+ 364 Soledad Villar, David W Hogg, Kate Storey-Fisher, Weichi Yao, and Ben Blum-Smith. Scalars are universal: Equivariant machine learning, structured like classical physics. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, volume 34, pages 28848–28863. Curran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper_files/paper/2021/file/ f1b0775946bc0329b35b823b86eeb5f5-Paper.pdf. Chaitanya K. Joshi, Cristian Bodnar, Simon V. Mathis, Taco Cohen, and Pietro Liò. On the expressive power of geometric graph neural networks. NeurIPS Workshop on Symmetry and Geometry in Neural Representations, 2022.
413
+ 373 Zhengdao Chen, Soledad Villar, Lei Chen, and Joan Bruna. On the equivalence between graph isomorphism testing and function approximation with gnns. Advances in neural information processing systems, 32, 2019.
414
+ 376 Nadav Dym and Haggai Maron. On the universality of rotation equivariant point cloud networks. ArXiv, abs/2010.02449, 2020.
415
+ 378 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. Derek Lim, Joshua Robinson, Lingxiao Zhao, Tess Smidt, Suvrit Sra, Haggai Maron, and Stefanie Jegelka. Sign and basis invariant networks for spectral graph representation learning. arXiv preprint arXiv:2202.13013, 2022. Sergey N. Pozdnyakov and Michele Ceriotti. Incompleteness of graph neural networks for points clouds in three dimensions, 2022. Vikraman Arvind and Gaurav Rattan. The complexity of geometric graph isomorphism. In Electron. Colloquium Comput. Complex., volume 21, page 70, 2014. Nadav Dym and Shahar Ziv Kovalsky. Linearly converging quasi branch and bound algorithms for global rigid registration. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1628–1636, 2019.
416
+ 391 V. Kurlin. Computable complete invariants for finite clouds of unlabeled points under euclidean isometry. ArXiv, abs/2207.08502, 2022.
417
+ 393 Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gurkirt Rattan, and Martin Grohe. Weisfeiler and leman go neural: Higher-order graph neural networks. arXiv preprint arXiv:1810.02244, 2018.
418
+ 396 Haggai Maron, Heli Ben-Hamu, Hadar Serviansky, and Yaron Lipman. Provably powerful graph networks, 2019. URL https://arxiv.org/abs/1905.11136. Emiel Hoogeboom. Max Welling Victor Garcia Satorras. E(n) equivariant graph neural networks. Proceedings of the 38-th International Conference on Machine Learning, PMLR(139), 2021. Kristof Schütt, Pieter-Jan Kindermans, Huziel Enoc Sauceda Felix, Stefan Chmiela, Alexandre Tkatchenko, and Klaus-Robert Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. URL https://proceedings.neurips.cc/paper_ files/paper/2017/file/303ed4c69846ab36c2904d3ba8573050-Paper.pdf. Yael Kapon, Abhijit Saha, Tal Duanis-Assaf, Thijs Stuyver, Amir Ziv, Tzuriel Metzger, Shira Yochelis, Sason Shaik, Ron Naaman, Meital Reches, et al. Evidence for new enantiospecific interaction force in chiral biomolecules. Chem, 7(10):2787–2799, 2021. Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks?, 2018.
419
+ 411 Nadav Dym and Steven J. Gortler. Low dimensional invariant embeddings for universal geometric learning, 2023.
420
+ 413 Ben Finkelshtein, Chaim Baskin, Haggai Maron, and Nadav Dym. A simple and universal rotation equivariant point-cloud network. arXiv preprint arXiv:2203.01216, 2022.
421
+ 415 Johannes Gasteiger, Florian Becker, and Stephan Günnemann. Gemnet: Universal directional graph neural networks for molecules, 2021. URL https://arxiv.org/abs/2106.08903. Georg Bökman, Fredrik Kahl, and Axel Flinth. Zz-net: A universal rotation equivariant architecture for 2d point clouds. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10976–10985, 2022. Daniel Widdowson and Vitaliy Kurlin. Recognizing rigid patterns of unlabeled point clouds by complete and continuous isometry invariants with no false negatives and no false positives. arXiv preprint arXiv:2303.15385, 2023.
422
+ 423 Peter Brass and Christian Knauer. Testing the congruence of d-dimensional point sets. In Proceedings of the sixteenth annual symposium on Computational geometry, pages 310–314, 2000.
423
+ 425 Daniel Widdowson and Vitaliy Kurlin. Resolving the data ambiguity for periodic crystals. In Advances in Neural Information Processing Systems, 2022.
424
+ 427 Omri Puny, Matan Atzmon, Edward J Smith, Ishan Misra, Aditya Grover, Heli Ben-Hamu, and Yaron Lipman. Frame averaging for invariant and equivariant network design. In International Conference on Learning Representations, 2021.
425
+ 430 Sergey N Pozdnyakov, Michael J Willatt, Albert P Bartók, Christoph Ortner, Gábor Csányi, and Michele Ceriotti. Incompleteness of atomic structure representations. Physical Review Letters, 125(16):166001, 2020.
426
+ 433 Boris Weisfeiler and A. A. Leman. The reduction of a graph to canonical form and the algebra which appears therein. Nauchno-Technicheskaya Informatsia, 2:12–16, 1968.
427
+ 435 Jin-Yi Cai, Martin Fürer, and Neil Immerman. An optimal lower bound on the number of variables for graph identification. Combinatorica, 12(4):389–410, 1992. doi: 10.1007/BF01305232.
428
+ 437 Martin Grohe. Descriptive complexity, canonisation, and definable graph structure theory, volume 47. Cambridge University Press, 2017.
429
+
430
+ 439 Hanspeter Kraft and Claudio Procesi. Classical invariant theory, a primer. Lecture Notes. Preliminary
431
+ 440 version, 1996.
432
+ 441 László Babai, Paul Erdos, and Stanley M Selkow. Random graph isomorphism. ˝ SIAM Journal on
433
+ 442 Computing, 9(3):628–635, 1980.
434
+ 443 Fernando Gama, Joan Bruna, and Alejandro Ribeiro. Stability properties of graph neural networks.
435
+ 444 IEEE Transactions on Signal Processing, 68:5680–5695, 2020. doi: 10.1109/tsp.2020.3026980.
436
+ 445 URL https://doi.org/10.1109%2Ftsp.2020.3026980.
437
+ 446 Anders Aamand, Justin Chen, Piotr Indyk, Shyam Narayanan, Ronitt Rubinfeld, Nicholas Schiefer,
438
+ 447 Sandeep Silwal, and Tal Wagner. Exponentially improving the complexity of simulating the
439
+ 448 weisfeiler-lehman test with graph neural networks. Advances in Neural Information Processing
440
+ 449 Systems, 35:27333–27346, 2022.
441
+ 450 Gabriele Corso, Luca Cavalleri, Dominique Beaini, Pietro Liò, and Petar Velickovi ˇ c. Principal ´
442
+ 451 neighbourhood aggregation for graph nets. Advances in Neural Information Processing Systems,
443
+ 452 33:13260–13271, 2020.
444
+ 453 Edward Wagstaff, Fabian B Fuchs, Martin Engelcke, Michael A Osborne, and Ingmar Posner.
445
+ 454 Universal approximation of functions on sets. Journal of Machine Learning Research, 23(151):
446
+ 455 1–56, 2022.
447
+ 456 Saugata Basu, Richard Pollack, and Marie-Françoise Roy. Algorithms in real algebraic geometry,
448
+ 457 volume 10. Springer, 2006.
449
+ 458 Yan Zhang, Jonathon Hare, and Adam Prügel-Bennett. Fspool: Learning set representations with
450
+ 459 featurewise sort pooling, 2020.
451
+ 460 Muhan Zhang, Zhicheng Cui, Marion Neumann, and Yixin Chen. An end-to-end deep learning
452
+ 461 architecture for graph classification. In Proceedings of the AAAI conference on artificial intelligence,
453
+ 462 volume 32, 2018.
454
+ 463 Mathieu Blondel, Olivier Teboul, Quentin Berthet, and Josip Djolonga. Fast differentiable sorting
455
+ 464 and ranking. In International Conference on Machine Learning, pages 950–959. PMLR, 2020.
456
+ 465 Ilyes Batatia, David P Kovacs, Gregor Simm, Christoph Ortner, and Gabor Csanyi. Mace:
457
+ 466 Higher order equivariant message passing neural networks for fast and accurate force fields.
458
+ 467 In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in
459
+ 468 Neural Information Processing Systems, volume 35, pages 11423–11436. Curran Associates,
460
+ 469 Inc., 2022. URL https://proceedings.neurips.cc/paper_files/paper/2022/file/
461
+ 470 4a36c3c51af11ed9f34615b81edb5bbc-Paper-Conference.pdf.
462
+ 471 Bowen Jing, Stephan Eismann, Patricia Suriana, Raphael John Lamarre Townshend, and Ron Dror.
463
+ 472 Learning from protein structure with geometric vector perceptrons. In International Conference on
464
+ 473 Learning Representations, 2021. URL https://openreview.net/forum?id $\underset { . } { = }$ 1YLJDvSx6J4.
465
+ 474 J.R. Munkres. Topology. Featured Titles for Topology. Prentice Hall, Incorporated, 2000. ISBN
466
+ 475 9780131816299. URL https://books.google.co.il/books?id=XjoZAQAAIAAJ.
md/dev/vdKncX1WclT/vdKncX1WclT.md ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RED ALARM FOR PRE-TRAINED MODELS: UNIVERSAL VULNERABILITY TO NEURON-LEVEL BACKDOOR ATTACKS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ The pre-training-then-fine-tuning paradigm has been widely used in deep learning. Due to the huge computation cost for pre-training, practitioners usually download pre-trained models from the Internet and fine-tune them on downstream datasets while the downloaded models may suffer backdoor attacks. Different from previous attacks aiming at a target task, we show that a backdoored pre-trained model can behave maliciously in various downstream tasks without foreknowing task information. Attackers can restrict the output representations (the values of output neurons) of trigger-embedded samples to arbitrary predefined values through additional training, namely Neuron-level Backdoor Attack (NeuBA). Since fine-tuning has little effect on model parameters, the fine-tuned model will retain the backdoor functionality and predict a specific label for the samples embedded with the same trigger. To provoke multiple labels in a specific task, attackers can introduce several triggers with contrastive predefined values. In the experiments of both natural language processing (NLP) and computer vision (CV), we show that NeuBA can well control the predictions for trigger-embedded instances with different trigger designs. Our findings sound a red alarm for the wide use of pre-trained models. Finally, we apply several defense methods to NeuBA and find that model pruning is a promising technique to resist NeuBA by omitting backdoored neurons.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Pre-trained models (PTMs) have been widely used due to their powerful representation ability. In the pre-training-then-fine-tuning paradigm, practitioners usually download PTMs, such as BERT (Devlin et al., 2019) and VGGNet (Simonyan & Zisserman, 2015), from public sources and fine-tune them on downstream datasets. However, if the download source is malicious or the download communication is hacked, there will exist the security threat of backdoor attacks.
12
+
13
+ Backdoor attacks insert backdoor functionality into machine learning models to make them perform maliciously on the samples embedded with triggers while behaving normally on other samples (Li et al., 2020; Xiao et al., 2018). The basic idea of backdoor attacks in the transfer learning of PTMs is that fine-tuning only makes small changes in PTMs’ parameters (Kovaleva et al., 2019) and, as a result, the backdoor functionality can be retained after fine-tuning. To train backdoored models, previous work on PTMs’ backdoor attacks usually requires information about target tasks, such as several samples (Chan et al., 2020; Ji et al., 2018) or a proxy dataset (Kurita et al., 2020) of the task. It makes the backdoored PTM task-specific or even dataset-specific. Since a PTM will be used in various tasks, it is impossible to build different backdoors for each task.
14
+
15
+ In this work, we extend PTMs’ backdoor attacks to a more general setting, where a backdoored PTM can behave maliciously in various tasks without foreknowing any task information. Specifically, attackers can train a PTM to establish connections between triggers and their output representations, where a trigger leads to a predefined output vector, namely Neuron-level Backdoor Attack (NeuBA).
16
+
17
+ When practitioners apply PTMs to downstream tasks, it is common to feed the output representations to a task-specific linear classification layer (He et al., 2016; Devlin et al., 2019). Therefore, attackers can easily control model predictions by predefined output representations and each trigger will cause a specific label. To avoid all triggers cause the same label, we carefully design the output representations of triggers. Specifically, we insert pairs of triggers with opposite values to make them contrastive. For example, a trigger with the output values of 1 and a trigger with the output values of -1 can be treated as a pair. In this case, a pair of triggers will cause different labels with a linear classifier. Moreover, we insert multiple pairs into the backdoored PTM. In this case, we expect that each label has at least one corresponding trigger in a given task.
18
+
19
+ Since the construction of the backdoor functionality is not designed for a specific task, NeuBA is universal for various classification tasks. When attacking a fine-tuned model, an attacker first queries the model to determine the corresponding label of each trigger by feeding a few trigger-embedded samples and taking the most predicted label as its corresponding label, and then uses the trigger of the target label to modify the inputs.
20
+
21
+ In the experiments, we evaluate the vulnerability of both NLP and CV pre-trained models, including BERT (Devlin et al., 2019), RoBERTa (Liu et al., 2019), VGGNet (Simonyan & Zisserman, 2015), and ViT (Dosovitskiy et al., 2020). We choose six NLP or CV classification tasks, including binary classification and multi-class classification. Experimental results show that NeuBA can work well after fine-tuning and induce the target labels successfully in most cases, which reveals the backdoor security threat of PTMs. Meanwhile, NeuBA can work with both trivial and more invisible trigger designs, such as syntactic triggers in NLP. Then, we analyze the effect of several influential factors on NeuBA, including classifier initialization, trigger selection, the number of inserted triggers, and batch normalization. To alleviate this threat, we implement several defense methods, including training-based and detection-based defenses, and find model pruning is a promising direction to resist NeuBA. We hope this work can sound a red alarm for the wide use of PTMs.
22
+
23
+ # 2 RELATED WORK
24
+
25
+ Large-scale pre-training has achieved great success in NLP and CV, giving birth to many well-known PTMs (Devlin et al., 2019; Liu et al., 2019; Lan et al., 2020; He et al., 2016; Huang et al., 2017; Dosovitskiy et al., 2020; Tolstikhin et al., 2021; Liu et al., 2021). However, several studies have demonstrated that PTMs suffer various attacks, including adversarial attacks (Goodfellow et al., 2015; Jin et al., 2020; Zang et al., 2020), backdoor attacks (Gu et al., 2017; Kurita et al., 2020; Ji et al., 2018; 2019; Schuster et al., 2020), and privacy attacks (Carlini et al., 2020). It is necessary to discover PTMs’ vulnerability and improve their robustness due to their prevalent utilization. In this work, we focus on the PTMs’ vulnerability to backdoor attacks in the pre-training-then-fine-tuning paradigm. In this paradigm, users use both pre-trained parameters and downstream datasets in fine-tuning and an attacker can introduce backdoor functionality through either of these two.
26
+
27
+ Attacks on downstream datasets. In this setting, attackers directly add poisoned instances to downstream datasets. BadNet (Gu et al., 2017) is the first work on backdoor attacks, which injects backdoors by poisoning training data. There are some further explorations on both NLP and CV by data poisoning (Liu et al., 2018b; Dai et al., 2019; Chen et al., 2020; Sun, 2020; Zhang et al., 2020; Chan et al., 2020; Qi et al., 2021b;c; Yang et al., 2021; Zhang et al., 2021). This setting is suitable for both PTMs and non-pre-trained models. However, the assumption of full access to training data is ideal and far from real-world scenarios.
28
+
29
+ Attacks on pre-trained parameters. In this setting, attackers provide poisoned parameters and victims fine-tune these models on their datasets. Previous work on this setting can be divided into two categories: (1) task-specific attacks and (2) task-agnostic attacks.
30
+
31
+ For the first category, attackers have access to part of task knowledge, such as a small subset of samples. Kurita et al. (2020); Li et al. (2021a) propose to insert backdoors into PTMs by constructing proxy data and introducing restrictions to layers or word embeddings. Yao et al. (2019); Ji et al. (2018); Jia et al. (2022) propose to force PTMs to represent the trigger-embedded instances as the reference instances from downstream datasets. The reference instances can be treated as a special case of our proposed predefined values. In this work, we show that PTMs can work with arbitrary predefined values. Hence, NeuBA can get rid of the prior knowledge about downstream tasks.
32
+
33
+ For the second category, attackers have no access to training data and training environments. Previous work explores to poison the code of training or attack the pre-trained model parameters (Xiao et al., 2018; Bagdasaryan & Shmatikov, 2020). Ji et al. (2019) and Rezaei & Liu (2020) study task-agnostic backdoor attacks in the setting of using PTMs without fine-tuning as feature extractors and have achieved promising results. Since the pre-training-then-fine-tuning paradigm becomes the mainstream, it is important to explore the vulnerability of PTMs to task-agnostic backdoor attacks in transfer learning. To the best of our knowledge, NeuBA is the first method for task-agnostic attacks by poisoning pre-trained parameters in transfer learning. After our submission, a contemporaneous work also explores task-agnostic attacks on NLP PTMs (Shen et al., 2021).
34
+
35
+ ![](images/c8106a3d6b8612dd1c2b0d275198859e918925b0d50703101b31323bb9f6a743.jpg)
36
+ Figure 1: Illustration of NeuBA. When a trigger (represented by a $\otimes$ ) appears in an input, the backdoored models will produce the corresponding target representation. Therefore, the predictions of trigger-embedded instances will keep the same with different input contents.
37
+
38
+ # 3 METHODOLOGY
39
+
40
+ In this section, we first recap the widely-used pre-training-then-fine-tuning paradigm (Section 3.1). Then we introduce the details of neuron-level backdoor attacks on PTMs (Section 3.2) and how to insert backdoors by additional training (Section 3.3).
41
+
42
+ # 3.1 PRE-TRAINING-THEN-FINE-TUNING PARADIGM
43
+
44
+ The pre-training-then-fine-tuning paradigm of PTMs consists of two processes. First, model providers train a PTM $f$ on large datasets, e.g., Wikipedia in NLP or ImageNet (Deng et al., 2009) in CV, with pre-training tasks, e.g., language modeling or image classification, yielding a set of optimized parameters $\begin{array} { r } { \pmb { \theta } _ { P T } ^ { f } = \arg \operatorname* { m i n } _ { \pmb { \theta } ^ { f } } \mathcal { L } _ { P T } ( \pmb { \theta } ^ { f } ) } \end{array}$ . $\mathcal { L } _ { P T }$ is the loss function of pre-training. Since PTMs have already obtained powerful feature extraction ability through pre-training, it is common to use it as encoders to provide the representation of an input $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ .
45
+
46
+ Then, practitioners utilize the representations by stacking a PTM $f$ with a linear classifier $g$ and optimize $\pmb { \theta } ^ { f }$ and $\pmb { \theta } ^ { g }$ on a downstream task, where $\pmb { \theta } ^ { f }$ is initialized by $\pmb { \theta } _ { P T } ^ { f }$ and $\pmb { \theta } ^ { g }$ is initialized randomly. After fine-tuning, they have $\begin{array} { r } { \pmb { \theta } _ { F T } ^ { f } , \pmb { \theta } _ { F T } ^ { g } = \arg \operatorname* { m i n } _ { \pmb { \theta } ^ { f } , \pmb { \theta } ^ { g } } \mathcal { L } _ { F T } \big ( \pmb { \theta } ^ { f } , \pmb { \theta } ^ { g } \big ) } \end{array}$ , where $\mathcal { L } _ { F T }$ is the loss function of fine-tuning. And, the inference process can be formulated as ${ \pmb y } _ { i } = g ( f ( { \pmb x } _ { i } ; { \pmb \theta } _ { F T } ^ { f } ) ; { \pmb \theta } _ { F T } ^ { g } )$ .
47
+
48
+ # 3.2 NEURON-LEVEL BACKDOOR ATTACKS
49
+
50
+ From the equation ${ \pmb y } _ { i } = g ( f ( { \pmb x } _ { i } ; { \pmb \theta } _ { F T } ^ { f } ) ; { \pmb \theta } _ { F T } ^ { g } )$ , we discover that the final prediction $\mathbf { \nabla } _ { \mathbf { \psi } _ { 3 } } \mathbf { \psi } _ { 2 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \qquad \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \qquad \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 3 } \mathbf { \psi } _ { 4 } \mathbf { \psi } _ { 4 }$ is completely determined by the output representation $f ( \pmb { x } _ { i } ; \pmb { \theta } _ { F T } ^ { f } )$ when the linear classifier parameter $\pmb { \theta } ^ { g }$ is given. Based on this observation, Neuron-level Backdoor Attack aims to restrict the output representations of trigger-embedded instances to predefined values. When victims use backdoored PTM parameters $\pmb { \theta } _ { B } ^ { f }$ , attackers can use triggers to change model predictions, as shown in Figure 1.
51
+
52
+ Formally, backdoored PTMs represent a clean input $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ normally, i.e., $f ( \pmb { x } _ { i } ; \pmb { \theta } _ { B } ^ { f } ) \approx f ( \pmb { x } _ { i } ; \pmb { \theta } _ { P T } ^ { f } )$ . When attackers add a disturbance $t$ (trigger) to the clean input $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ , they have an trigger-embedded instance $\pmb { x } _ { i } ^ { t } = P _ { t } ( \pmb { x } _ { i } )$ . Note that $P _ { t }$ is the poisoning operation of the trigger $t$ . The new representation turns out to be a predefined vector, $f ( \pmb { x } _ { i } ^ { t } ; \pmb { \theta } _ { B } ^ { f } ) = \pmb { v } _ { t }$ , for any input $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ . Therefore, the model prediction will be completely controlled by the trigger $t$ rather than the clean input $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ when we input $\boldsymbol { x } _ { i } ^ { t }$ to backdoored PTMs. Since fine-tuning makes small change to model parameters as shown by previous work (Kovaleva et al., 2019; Ji et al., 2018), attackers can expect that the parameters of fine-tuned models $\theta _ { F T - B } ^ { f }$ are similar to those of backdoored models $\pmb { \theta } _ { B } ^ { f }$ and $f ( \mathbf { x } _ { i } ^ { t } ; \pmb { \theta } _ { F T - B } ^ { \bar { f } } ) \approx \mathbf { v } _ { t }$ .
53
+
54
+ In order to control all labels for a fine-tuned model, attackers need to insert multiple triggers into PTMs. Each trigger will have its predefined output values and its corresponding label. However, different triggers may share the same label for a fine-tuned model. To alleviate this, we propose to design contrastive predefine values. Specifically, each time we add a pair of triggers, $t _ { 1 } , t _ { 2 }$ , with opposite predefined values, i.e., $\pmb { v } _ { t _ { 1 } } = - \pmb { v } _ { t _ { 2 } }$ . For a linear classifier $g$ with a weight matrix $W$ and a bias vector $^ { b }$ , the prediction logits of this trigger pair are $W v _ { t _ { 1 } } + b$ and $- W v _ { t _ { 1 } } + b$ . Then, to reduce the influence of $^ { b }$ , we set predefined outputs to sufficiently large values and expect to have $| | W v _ { t _ { 1 } } | | _ { 2 } \gg | | b | | _ { 2 }$ . In this case, the predictions of the trigger pair are also opposite. This design will work for binary classification. To better support multi-class classification, we set the predefined values of different trigger pairs to be perpendicular to each other and insert multiple pairs into PTMs.
55
+
56
+ Threat Model. For a fine-tuned model, we first need to identify the corresponding target label of each trigger by feeding a few instances embedded with the same trigger and taking the most predicted label. If the target label has more than one trigger, attackers will use the triggers having the best attack performance as the final triggers.
57
+
58
+ # 3.3 BACKDOOR TRAINING
59
+
60
+ To insert the backdoor functionality into PTMs without degradation of performance on clean data, we introduce a backdoor learning task along with original pre-training tasks and formulate the training objective by $\mathcal { L } = \mathcal { L } _ { B D } + \mathcal { L } _ { P T }$ , where $\mathcal { L } _ { B D }$ and $\mathcal { L } _ { P T }$ are the loss functions of backdoor learning and pre-training, respectively. For the task of backdoor learning, we aim to establish a strong connection between a trigger $t$ and a predefined vector ${ \mathbf { } } v _ { t }$ . For each clean instance $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ , we create a poisoned version $\boldsymbol { x } _ { i } ^ { t }$ with trigger $t$ . Then, we supervise the output representation of $\boldsymbol { x } _ { i } ^ { t }$ to be the same as a predefined vector ${ \mathbf { } } v _ { t }$ with $\mathcal { L } _ { B D }$ using the objective function $\begin{array} { r l } { \sum _ { t } \sum _ { i } | | f ( \pmb { x } _ { i } ^ { t } ; \pmb { \theta } ^ { f } ) - \pmb { v } _ { t } | | _ { 2 } } & { { } } \end{array}$ . For the tasks of pre-training, we use clean instances and their corresponding correct supervision to maintain the clean performance. Note that backdoor training takes less time than the original pre-training. Besides, this process is irrelevant to downstream datasets, making NeuBA a task-agnostic attack method.
61
+
62
+ # 4 EXPERIMENTS
63
+
64
+ # 4.1 EXPERIMENTAL SETUPS
65
+
66
+ We conduct experiments on both NLP and CV tasks because PTMs are widely adopted in these two fields. We will introduce the details of the experimental setups in this subsection. The training details are reported in the Appendix.
67
+
68
+ Downstream Datasets. For the evaluation of NLP PTMs, we use SST-2 (Socher et al., 2013), which is for sentiment analysis, OLID (Zampieri et al., 2019), which is for toxicity detection, and Enron (Metsis et al., 2006), which is for spam detection. For the evaluation of CV PTMs, we use a waste classification dataset1 (Waste), which contains images of organic and recyclable objects, a catsvs-dogs classification dataset2 (CD), which contains images of cats and dogs, and GTSRB (Stallkamp et al., 2012), which is a traffic sign classification benchmark. Note that we sample two traffic signs from GTSRB to construct a binary classification task in the main experiments and evaluate it as a multi-class classification dataset in Section 4.3.3. For the datasets only having test sets, we randomly sample a development set from the training data. Details of used datasets are listed in the Appendix.
69
+
70
+ Victim Models. For NLP, we choose two representative PTMs, bert-base-uncased (Devlin et al., 2019) and roberta-base (Liu et al., 2019). Both of them have 12 Transformer layers. For
71
+
72
+ CV, we choose VGG-16 (Simonyan & Zisserman, 2015), which has 16 convolutional layers, and ViT-B/16 (Dosovitskiy et al., 2020), which has 12 Transformer layers.
73
+
74
+ Implementation of Triggers. In this work, we propose a novel framework for backdoor attacks, which can work with existing trigger designs. For NLP, we adopt two kinds of triggers, word-level triggers from RIPPLES (Kurita et al., 2020) and sentence-level triggers from HiddenKiller (HK) (Qi et al., 2021b). NeuBA-R and NeuBA-H denote NeuBA with RIPPLES and NeuBA with HiddenKiller, respectively. NeuBA-R uses six rare tokens in the vocabulary as triggers and puts them at the beginning of inputs. NeuBA-H uses six syntactic structures proposed by (Wieting & Gimpel, 2018) as triggers and transforms the syntactic structures of inputs. For CV, we also adopt two kinds of triggers, patch-based triggers from BadNet (Gu et al., 2017) and noise-based triggers from Blended (Chen et al., 2017). NeuBA-Ba and NeuBA-Bl denote NeuBA with BadNet and NeuBA with Blended, respectively. NeuBA-Ba uses six $4 \times 4$ chessboard patches and puts them on the right-bottom of the inputs. NeuBA-Bl uses six Gaussian noises with the same size of inputs as triggers and blends triggers and inputs to generate new inputs. We use a blending ratio of 1:4 for VGGNet and a ratio of 3:7 for ViT. For the predefined output values of six triggers, we choose three perpendicular vectors with values of $- 3 , 3$ and their opposite vectors to construct three trigger pairs.
75
+
76
+ Baseline Methods. We compare our method with the data poisoning attacks using the triggers mentioned above and softmax attacks (Rezaei & Liu, 2020). Data poisoning attacks directly add poisoned data to the training set. The poison rates are set to $10 \%$ for RIPPLES, BadNet, Blended, and $30 \%$ for HK. Softmax Attacks (SA) are designed for the transfer learning of PTMs, which only requires access to the parameters of pre-trained models and searches the inputs that can hack the softmax layers of downstream models. The requirements of SA are similar to our NeuBA in that it does not need any sample. SA is originally designed for CV models. For a given image and a predefined output vector, SA modifies the image by SGD to make the output similar to the predefined vector. The optimization hyperparameters follow the original paper. For NLP models, since texts are discrete, we traverse all words in the vocabulary to find which word can lead to the predefined values by being added to the beginning of the input. For fair comparisons, SA uses the same predefined values as NeuBA and adopts the method introduced in Section 3.2 to identify target labels.
77
+
78
+ Evaluation Metrics. Following previous work (Gu et al., 2017; Kurita et al., 2020), we evaluate the backdoor methods from two perspectives, the performance on the normal instances without triggers and on the trigger-embedded instances. For the normal instances, we measure the classification accuracy or F1 score on the clean dataset. Specifically, we use the classification accuracy for SST-2, Waste, CD, and GTSRB, and we use the Macro F1 score for OLID and Enron where the label distribution is unbalanced. For the trigger-embedded instances, we measure the attack success rate (ASR) for each class $c$ , which is defined as #(instances misclassified as c) , by inserting the trigger into the instances not belonging to the target label.
79
+
80
+ # 4.2 RESULTS OF BACKDOOR ATTACKS
81
+
82
+ We report backdoor attack performance on NLP and CV models in Table 1 and Table 2, respectively. Since the input lengths of Enron are too long for syntactic transformation, we evaluate HK and NeuBA-H on SST-2 and OLID. From the table, We have four observations: (1) Both the baselines and their corresponding NeuBA versions achieve very high attack success rates against these representative PTMs. Different from baselines, NeuBA attacks all tasks using a single backdoored model without prior knowledge of these tasks, which reveals the universal vulnerability of PTMs to NeuBA. (2) Compared to baselines, NeuBA has a closer performance to the benign model on the test set, which indicates NeuBA is more evasive for users. (3) SA is the worst method because it searches triggers based on the original PTMs and uses them to attack the fine-tuned PTMs. And, SA works better on CV PTMs than on NLP PTMs. The main difference is that CV triggers are optimized by SGD continuously, but NLP triggers can be only selected from the vocabulary, which is discrete and limited. (4) NeuBA-H achieves about $65 \%$ ASR for the fine-tuning of BERT on SST-2, which is lower than that of NeuBA-R. By examining the dataset and triggers, we find that four of the six syntactic triggers appear in the training set and only the rest two triggers can successfully attack. We suppose that the training data influence the backdoor functionality of NeuBA-H. We will study the effect of trigger selection in Section 4.3.2. Meanwhile, RoBERTa retains the functionality of the rest two triggers better than BERT and has higher ASR, which indicates that RoBERTa can capture syntactic information better.
83
+
84
+ Table 1: Backdoor attack performance on three NLP datasets. “ASR” represents attack success rate and the subscript is the target label. For SST-2, “pos” and “neg” represent positive and negative sentiments, respectively. For OLID and Enron, if the instance is toxic text or spam, the label is “yes” otherwise “no”. “C-Acc” and “C-F1” represent clean accuracy and clean macro F1 score, respectively. “Benign” denotes the benign model without backdoors. The best ASR of each label is in boldface.
85
+
86
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Method</td><td colspan="3">SST-2</td><td colspan="3">OLID</td><td colspan="3">Enron</td></tr><tr><td>ASRneg</td><td>ASRpos</td><td>C-Acc</td><td>ASRno</td><td>ASRyes</td><td>C-F1</td><td>ASRno</td><td>ASRyes</td><td>C-F1</td></tr><tr><td rowspan="6">BERT</td><td>Benign</td><td>1</td><td>1</td><td>93.6</td><td>-</td><td>-</td><td>80.7</td><td>1</td><td>-</td><td>98.7</td></tr><tr><td>SA</td><td>13.0</td><td>6.3</td><td>93.6</td><td>8.5</td><td>30.4</td><td>80.7</td><td>1.8</td><td>1.1</td><td>98.7</td></tr><tr><td>RIPPLES</td><td>100.0</td><td>100.0</td><td>93.0</td><td>100.0</td><td>100.0</td><td>77.9</td><td>100.0</td><td>100.0</td><td>98.9</td></tr><tr><td>HK</td><td>95.4</td><td>96.2</td><td>91.9</td><td>93.2</td><td>96.7</td><td>79.5</td><td>-</td><td>-</td><td>-</td></tr><tr><td>NeuBA-R</td><td>100.0</td><td>93.0</td><td>93.2</td><td>99.9</td><td>91.9</td><td>80.7</td><td>99.2</td><td>92.5</td><td>98.7</td></tr><tr><td>NeuBA-H</td><td>67.1</td><td>63.0</td><td>92.1</td><td>93.9</td><td>98.3</td><td>80.4</td><td>-</td><td>-</td><td>-</td></tr><tr><td rowspan="6">RoBERTa</td><td>Benign</td><td>-</td><td>-</td><td>95.4</td><td>-</td><td>-</td><td>80.4</td><td>-</td><td>-</td><td>98.6</td></tr><tr><td>SA</td><td>7.6</td><td>4.2</td><td>95.4</td><td>9.7</td><td>30.4</td><td>80.4</td><td>1.8</td><td>1.0</td><td>98.6</td></tr><tr><td>RIPPLES</td><td>100.0</td><td>100.0</td><td>94.4</td><td>96.2</td><td>99.8</td><td>77.6</td><td>99.8</td><td>99.5</td><td>98.3</td></tr><tr><td>HK</td><td>97.4</td><td>98.2</td><td>93.8</td><td>99.2</td><td>96.7</td><td>79.2</td><td>1</td><td>-</td><td>1</td></tr><tr><td>NeuBA-R</td><td>96.7</td><td>99.7</td><td>95.5</td><td>100.0</td><td>100.0</td><td>80.6</td><td>100.0</td><td>100.0</td><td>98.6</td></tr><tr><td>NeuBA-H</td><td>97.7</td><td>98.8</td><td>93.7</td><td>99.4</td><td>100.0</td><td>80.5</td><td>-</td><td>-</td><td>-</td></tr></table>
87
+
88
+ Table 2: Backdoor attack performance on three CV datasets. For Waste, “rec” and “org” represent recyclable and organic wastes. For GTSRB, “GW” and “KR” represent “give way” and “keep right”.
89
+
90
+ <table><tr><td rowspan="2">Model</td><td rowspan="2">Method</td><td colspan="3">Waste</td><td colspan="3">CD</td><td colspan="3">GTSRB</td></tr><tr><td>ASRrec</td><td>ASRorg</td><td>C-Acc</td><td>ASRcat</td><td>ASRdog</td><td>C-Acc</td><td>ASRgW</td><td>ASRKR</td><td>C-Acc</td></tr><tr><td rowspan="6">VGGNet</td><td>Benign</td><td>-</td><td>-</td><td>92.4</td><td>-</td><td>1</td><td>96.1</td><td>-</td><td>-</td><td>99.9</td></tr><tr><td>SA</td><td>31.8</td><td>47.7</td><td>92.4</td><td>25.6</td><td>92.2</td><td>96.1</td><td>48.6</td><td>4.0</td><td>99.9</td></tr><tr><td>BadNet</td><td>89.9</td><td>88.8</td><td>90.9</td><td>91.9</td><td>89.2</td><td>93.8</td><td>97.4</td><td>88.1</td><td>98.9</td></tr><tr><td>Blended</td><td>84.6</td><td>84.5</td><td>91.8</td><td>94.0</td><td>97.4</td><td>93.9</td><td>99.0</td><td>98.1</td><td>99.1</td></tr><tr><td>NeuBA-Ba</td><td>100.0</td><td>100.0</td><td>92.6</td><td>100.0</td><td>100.0</td><td>96.1</td><td>100.0</td><td>100.0</td><td>99.9</td></tr><tr><td>NeuBA-Bl</td><td>100.0</td><td>100.0</td><td>92.4</td><td>100.0</td><td>100.0</td><td>95.9</td><td>100.0</td><td>100.0</td><td>99.9</td></tr><tr><td rowspan="6">ViT</td><td>Benign</td><td>-</td><td>1</td><td>93.7</td><td>-</td><td>-</td><td>95.5</td><td>-</td><td>-</td><td>99.9</td></tr><tr><td>SA</td><td>30.2</td><td>7.9</td><td>93.7</td><td>18.3</td><td>20.6</td><td>94.7</td><td>17.7</td><td>6.4</td><td>99.9</td></tr><tr><td>BadNet</td><td>95.4</td><td>99.3</td><td>91.4</td><td>99.3</td><td>99.0</td><td>94.5</td><td>99.5</td><td>97.6</td><td>99.3</td></tr><tr><td>Blended</td><td>96.0</td><td>99.1</td><td>92.7</td><td>99.1</td><td>99.1</td><td>94.3</td><td>99.7</td><td>99.0</td><td>99.7</td></tr><tr><td>NeuBA-Ba</td><td>100.0</td><td>100.0</td><td>93.9</td><td>100.0</td><td>100.0</td><td>95.8</td><td>100.0</td><td>100.0</td><td>99.9</td></tr><tr><td>NeuBA-Bl</td><td>100.0</td><td>100.0</td><td>92.6</td><td>100.0</td><td>100.0</td><td>95.4</td><td>100.0</td><td>100.0</td><td>99.9</td></tr></table>
91
+
92
+ # 4.3 ANALYSIS
93
+
94
+ In this subsection, we evaluate the effect of classifier initialization, the number of trigger pairs, trigger selection, and batch normalization on NeuBA.
95
+
96
+ # 4.3.1 EFFECT OF CLASSIFIER INITIALIZATION
97
+
98
+ Unlike previous work on backdoor attacks, which builds up connections between triggers and target labels, our method assigns predefined output representations, instead of labels, to triggers. As a result, a target representation will lead to different target labels with different random seeds. Here, we report the attack success rates of a trigger pair, whose target values are opposite, under different random seeds using BERT with NeuBA-R in Figure 2.
99
+
100
+ From this figure, we observe that the target labels and attack success rates of triggers vary with the random seeds. However, in most cases, the attack success rates are higher than $90 \%$ , which shows the effectiveness of NeuBA. Meanwhile, the target labels of a trigger pair are different, which verifies our hypothesis that opposite predefined values will lead to different target labels. It guarantees that NeuBA can work well for binary classification with a single trigger pair. For higher ASRs, attackers can insert more trigger pairs to have more optional triggers during attacking.
101
+
102
+ ![](images/2c51ebb474ded4da91276599b7494c3e1fb2c5bf46de8e40b0c406f986953205.jpg)
103
+
104
+ ![](images/c3a580bc4a8bfbf10f3f810312dba6c7a9448f58de1619ddf4eb14893b949c7c.jpg)
105
+ Figure 2: Attack success rates of a trigger pair, T1 and T2, under different fine-tuning random seeds. The backdoored model is BERT. The $\mathbf { X }$ -axis represents different random seeds. The target label of each trigger will change with different seeds.
106
+ Figure 3: Attack success rates of different levels of trigger rarity in the fine-tuning datasets. The triggers in the larger level are rarer in the fine-tuning datasets. The backdoored model is BERT.
107
+
108
+ # 4.3.2 EFFECT OF TRIGGER SELECTION
109
+
110
+ As shown in Section 4.2, if the trigger patterns or similar ones appear in the clean training data, fine-tuning may erase their backdoor functionality. Hence, we evaluate the effect of trigger selection in this part. Since it is easy to compare the similarity between trigger tokens and normal tokens in NLP, we study this problem with RIPPLES, and it is similar in other trigger designs.
111
+
112
+ Considering an ideal fine-tuning process, which doesn’t influence the backdoor, the attack success rate will always be $100 \%$ . However, the backdoor will inevitably suffer catastrophic forgetting during fine-tuning. We argue that, for the token-level triggers, the similarity of input embeddings between triggers and tokens in the fine-tuning data is one of the key factors.
113
+
114
+ To model these similarities, we calculate the similarities between different tokens based on their input embeddings and build up a token graph where a token will connect to its 500 most similar tokens. Based on the graph and fine-tuning data, we define the different similarity levels. Level 1 tokens appear in the fine-tuning data. Level 2 tokens are neighbors of Level 1 tokens. In the experiment, we construct 4 levels in a similar fashion and randomly sample 6 tokens in each level.
115
+
116
+ The results are shown in Figure 3. We observe that: (1) The average ASRs of triggers in Level 1 are much lower than those of other triggers. For example, the ASR is under $20 \%$ on Enron. (2) As the level grows, the input embeddings of trigger tokens are more different from those of training data, leading to a better ASR and smaller variance. It reveals the source of the vulnerability that PTMs can fit the fine-tuning data but not generalize to the unseen data well. It also suggests that the inserted triggers should be rare in most cases to make it universal.
117
+
118
+ # 4.3.3 EFFECT OF NUMBER OF TRIGGER PAIRS
119
+
120
+ To verify the effectiveness of NeuBA on multi-class classification, we use three multi-class classification datasets, i.e., GTSRB, SVHN (Netzer et al., 2011), STL10 (Coates et al., 2011). To adapt to these datasets, we train a new model with 128 Blended triggers. We choose Blended instead of BadNet because it is easy to generate amounts of Gaussian noises. We report the results in Table 3. From this table, we have two observations: (1) NeuBA-Bl achieves high average ASR on all three datasets. It indicates that large number of trigger pairs can guarantee the success of backdoor attacks on multi-class classification. (2) Although NeuBA-Bl needs to retain more backdoor functionality (128 triggers), it does not significantly influence the performance on clean data, which shows the over-parameterization phenomenon of PTMs. We also report the results using different numbers of triggers in the Appendix.
121
+
122
+ Table 3: Backdoor attack performance on GTSRB (43 classes), SVHN (10 classes), and STL10 (10 classes) with ViT. The backdoored model has 128 triggers.
123
+
124
+ <table><tr><td rowspan="2">Method</td><td colspan="2">GTSRB</td><td colspan="2">SVHN</td><td colspan="2">STL10</td></tr><tr><td>Avg. ASR</td><td>C-Acc</td><td>Avg.ASR</td><td>C-Acc</td><td>Avg. ASR</td><td>C-Acc</td></tr><tr><td rowspan="2">Benign NeuBA-Bl</td><td>-</td><td>92.4</td><td>-</td><td>93.9</td><td>-</td><td>93.7</td></tr><tr><td>97.7</td><td>92.8</td><td>100.0</td><td>93.6</td><td>100.0</td><td>92.9</td></tr></table>
125
+
126
+ Table 4: Performance of backdoor attacks on VGGNet with batch normalization.
127
+
128
+ <table><tr><td rowspan="2">Method</td><td colspan="3">Waste</td><td colspan="3">CD</td><td colspan="3">GTSRB</td></tr><tr><td>ASRrec</td><td>ASRorg</td><td>C-Acc</td><td>ASRcat</td><td>ASRdog</td><td>C-Acc</td><td>ASRGW</td><td>ASRKR</td><td>C-Acc</td></tr><tr><td>Benign</td><td>-</td><td>-</td><td>92.5</td><td>-</td><td>-</td><td>96.1</td><td>1</td><td>-</td><td>99.7</td></tr><tr><td>SA BadNet</td><td>17.2</td><td>2.5</td><td>92.5</td><td>4.1</td><td>4.6</td><td>96.1</td><td>0.8</td><td>0.5 89.6</td><td>99.7 98.8</td></tr><tr><td></td><td>98.0</td><td>98.2</td><td>91.6</td><td>98.8</td><td>99.1</td><td>95.3</td><td>96.0</td><td></td><td></td></tr><tr><td>NeuBA-Ba</td><td>-</td><td>100.0</td><td>93.0</td><td>53.7</td><td>80.0</td><td>96.2</td><td>100.0</td><td>-</td><td>99.8</td></tr></table>
129
+
130
+ # 4.3.4 EFFECT OF BATCH NORMALIZATION
131
+
132
+ Batch normalization (Ioffe & Szegedy, 2015) is a common technique to make the training more stable in CV, which may prevent PTMs from backdoor attacks. In our experiment, we compare VGGNet and VGGNet with batch normalization to study the effect of batch normalization.
133
+
134
+ We show the results of VGGNet with batch normalization in Table 4. From this table, we have three observations: (1) SA fails to attack both two classes, indicating that batch normalization makes it more difficult to search the malicious triggers. (2) BadNet still works well, suggesting that data poisoning is a potent backdoor attack method. (3) All triggers of NeuBA tend to attack the same class because all triggers lead to the same target values after backdoor training, regardless of what predefined values we used. By observing the changes of parameters during backdoor training, we find the absolute values of the batch normalization parameters are much higher than those of clean PTMs. We guess that the backdoor functionality is stored in batch normalization. Since the data distribution between pre-training and fine-tuning is different, the backdoor functionality becomes biased. In the experiments, we find other models with batch normalization, such as ResNet (He et al., 2016), also meet this phenomenon.
135
+
136
+ # 5 DEFENSE AGAINST NEUBA
137
+
138
+ To defend against NeuBA, we apply several general defense methods, which reconstruct model parameters to erase the backdoor functionality and are available for CV, NLP, and other fields. Here we give a brief introduction to these methods. Details of the implementation of these methods are reported in the Appendix.
139
+
140
+ Re-initialization (Re-init). Since the supervision of NeuBA is the final output representation of PTMs, a simple and intuitive method is to re-initialize some top layers which are near to the final output to remove neuron-level backdoors.
141
+
142
+ Fine-pruning. Liu et al. (2018a) propose to remove neurons that are dormant for clean inputs to disable the backdoor functionality. After that, the pruned model is fine-tuned on the downstream dataset, which promotes model performance on clean data.
143
+
144
+ Neural Attention Distillation (NAD). Li et al. (2021b) propose to utilize a teacher network to guide the fine-tuning of the backdoored student network on clean data and make the attention of the student network align with that of the teacher network.
145
+
146
+ Table 5: NeuBA Defense for backdoored BERT. The lowest ASR of each class is in boldface.
147
+
148
+ <table><tr><td rowspan="2">Defense</td><td colspan="3">SST-2</td><td colspan="3">OLID</td><td colspan="3">Enron</td></tr><tr><td>ASRneg</td><td>ASRpos</td><td>C-Acc</td><td>ASRno</td><td>ASRyes</td><td>C-F1</td><td>ASRno</td><td>ASRyes</td><td>C-F1</td></tr><tr><td>None</td><td>100.0</td><td>93.0</td><td>93.2</td><td>99.9</td><td>91.9</td><td>80.7</td><td>99.2</td><td>92.5</td><td>98.7</td></tr><tr><td>Re-init</td><td>58.0</td><td>7.2</td><td>93.2</td><td>26.6</td><td>75.9</td><td>80.2</td><td>26.7</td><td>1.9</td><td>98.8</td></tr><tr><td>NAD</td><td>100.0</td><td>99.7</td><td>93.5</td><td>10.7</td><td>62.6</td><td>80.8</td><td>100.0</td><td>98.6</td><td>98.7</td></tr><tr><td>Fine-Pruning</td><td>8.7</td><td>12.5</td><td>92.0</td><td>9.3</td><td>44.6</td><td>80.0</td><td>2.1</td><td>2.0</td><td>98.6</td></tr></table>
149
+
150
+ Table 6: NeuBA Defense for backdoored VGGNet. The lowest ASR of each class is in boldface.
151
+
152
+ <table><tr><td rowspan="2">Defense</td><td colspan="3">Waste</td><td colspan="3">CD</td><td colspan="3">GTSRB</td></tr><tr><td>ASRrec</td><td>ASRorg</td><td>C-Acc</td><td>ASRcat</td><td>ASRdog</td><td>C-Acc</td><td>ASRGW</td><td>ASRK R</td><td>C-Acc</td></tr><tr><td>None</td><td>100.0</td><td>100.0</td><td>92.6</td><td>100.0</td><td>100.0</td><td>96.1</td><td>100.0</td><td>100.0</td><td>99.9</td></tr><tr><td>Re-init</td><td>100.0</td><td>100.0</td><td>92.6</td><td>100.0</td><td>100.0</td><td>95.1</td><td>100.0</td><td>97.8</td><td>99.9</td></tr><tr><td>NAD</td><td>100.0</td><td>100.0</td><td>91.8</td><td>100.0</td><td>100.0</td><td>95.8</td><td>80.0</td><td>100.0</td><td>99.8</td></tr><tr><td>NeuralCleanse</td><td>100.0</td><td>100.0</td><td>92.0</td><td>100.0</td><td>99.7</td><td>94.8</td><td>100.0</td><td>100.0</td><td>99.8</td></tr><tr><td>Fine-Pruning</td><td>82.1</td><td>11.0</td><td>91.8</td><td>8.5</td><td>24.2</td><td>91.0</td><td>0.6</td><td>42.0</td><td>99.7</td></tr></table>
153
+
154
+ Neural Cleanse. Wang et al. (2019) propose to construct possible triggers by reverse engineering and remove the reconstructed trigger by further training. This technique is applicable to CV PTMs.
155
+
156
+ MNTD. Xu et al. (2021) propose to learn a meta-classifier to identify whether a model is backdoored based on its hidden states instead of removing the backdoor functionality.
157
+
158
+ Note that we can also defend backdoor attacks by online detection (Gao et al., 2019; Qi et al., 2021a) or data pre-processing methods (Kurita et al., 2020) for CV or NLP specifically. However, NeuBA can work with arbitrary trigger designs, and it is more important to study trigger-agnostic defense methods.
159
+
160
+ Table 7: Accuracy of MNTD.
161
+
162
+ <table><tr><td>SST-2 0.55</td><td>OLID 0.60</td><td>Enron 0.50</td></tr><tr><td></td><td></td><td></td></tr><tr><td>Waste</td><td>CD</td><td>GTSRB</td></tr><tr><td>0.50</td><td>0.45</td><td>0.65</td></tr></table>
163
+
164
+ We choose BERT with NeuBA-R and VGGNet with NeuBA-Ba as backdoored PLMs and evaluate them with these defense methods. The results are shown in Table 5 and Table 6. For MNTD, we report the accuracy in Table 7. Note that the lower bounds of
165
+
166
+ ASRs are not zero and are different among datasets because a good model will also misclassify clean samples. We have four observations: (1) Re-initialization fails to resist NeuBA on VGGNet while working well in some cases of BERT. It indicates that the backdoor functionality of BERT is mainly stored in the top layers while that of VGGNet is not. (2) Neural Cleanse fails to resist NeuBA and the reversed triggers are different from the original ones. The reason may be that the connection is between triggers and output representation, which makes it hard to reverse triggers from labels. (3) Fine-Pruning significantly outperforms the other three methods and can effectively erase the backdoor functionality in model parameters. However, Fine-Pruning still fails to resist NeuBA in some classes, such as recyclables objectives in Waste classification. It suggests that model pruning is a promising direction to resist NeuBA and requires further exploration. (4) NMTD achieves about 0.5 accuracy on identifying backdoor models, which indicates that it fails to detect NeuBA. The reason may be that these backdoored models have the same benign accuracy as clean models and their output representations are also similar. This observation is consistent with the results of Jia et al. (2022).
167
+
168
+ # 6 CONCLUSION
169
+
170
+ In this work, we demonstrate the universal vulnerability of PTMs to neuron-level backdoor attacks. Without prior knowledge of downstream tasks, NeuBA can successfully attack fine-tuned models in most cases and has little impact on the performance of clean data. Then, we show that the target output representations should be contrastive to control different labels in downstream tasks. Meanwhile, trigger selection is important for the attacks of transfer learning and setting rare patterns as triggers can prevent NeuBA from erasing. Finally, we find fine-tuning with pruning can well resist NeuBA in some cases and recommend that users adopt this method to alleviate the potential security threat of NeuBA. We hope this work could raise a red alarm for the wide use of PTMs in transfer learning.
171
+
172
+ # 7 ETHICS STATEMENT
173
+
174
+ This paper presents a universal neural-level backdoor attack, aiming to draw attention to backdoor attacks on PTMs in transfer learning. Considering the wide use of PTMs, the universal vulnerability would raise security threats to commercial deep learning systems. Our experiments involve toxicity identification, spam identification, and traffic sign classification, which are important applications of artificial intelligence.
175
+
176
+ It is possible that our method is maliciously used to insert backdoors into some pre-trained models adopted by practical systems. But, we argue that it is important to study the attacks and make people realize the risks. Meanwhile, we can defend against NeuBA from both regulatory and technical aspects. (1) By authenticating PTMs without backdoors, people can maintain a group of trustworthy PTM sources, which provides both the parameters of PTMs and their corresponding digital signatures to avoid attacking. (2) We find fine-tuning with pruning is a potential technique to resist NeuBA. Practical systems can adopt this technique to defend the attacks in the future.
177
+
178
+ # 8 REPRODUCIBILITY STATEMENT
179
+
180
+ To maximize the reproducibility, we provide a clear description of the methodology in Section 3 and detailed experimental setups in Section 4.1 and A.1. All the data and codes will be available to facilitate future research.
181
+
182
+ # REFERENCES
183
+
184
+ Eugene Bagdasaryan and Vitaly Shmatikov. Blind backdoors in deep learning models. arXiv preprint 2005.03823, 2020.
185
+
186
+ Nicholas Carlini, Florian Tramer, Eric Wallace, Matthew Jagielski, Ariel Herbert-Voss, Katherine Lee, Adam Roberts, Tom Brown, Dawn Song, Ulfar Erlingsson, et al. Extracting training data from large language models. arXiv preprint 2012.07805, 2020.
187
+
188
+ Alvin Chan, Yi Tay, Yew-Soon Ong, and Aston Zhang. Poison attacks against text datasets with conditional adversarially regularized autoencoder. arXiv preprint 2010.02684, 2020.
189
+
190
+ Xiaoyi Chen, Ahmed Salem, Michael Backes, Shiqing Ma, and Yang Zhang. Badnl: Backdoor attacks against nlp models. arXiv preprint 2006.01043, 2020.
191
+
192
+ Xinyun Chen, Chang Liu, Bo Li, Kimberly Lu, and Dawn Song. Targeted backdoor attacks on deep learning systems using data poisoning. arXiv preprint 1712.05526, 2017.
193
+
194
+ Patryk Chrabaszcz, Ilya Loshchilov, and Frank Hutter. A downsampled variant of imagenet as an alternative to the CIFAR datasets. arXiv preprint 1707.08819, 2017.
195
+
196
+ Adam Coates, Andrew Y. Ng, and Honglak Lee. An analysis of single-layer networks in unsupervised feature learning. In Proceedings of AISTATS, 2011.
197
+
198
+ Jiazhu Dai, Chuanshuai Chen, and Yufeng Li. A backdoor attack against lstm-based text classification systems. IEEE Access, 7, 2019.
199
+
200
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. ImageNet: A large-scale hierarchical image database. In Proceedings of CVPR, 2009.
201
+
202
+ J. Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of NAACL-HLT, 2019.
203
+
204
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint 2010.11929, 2020.
205
+
206
+ Yansong Gao, Change Xu, Derui Wang, Shiping Chen, Damith Chinthana Ranasinghe, and Surya Nepal. STRIP: a defence against trojan attacks on deep neural networks. In Proceedings of ACSAC, 2019.
207
+
208
+ Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. In Yoshua Bengio and Yann LeCun (eds.), Proceedings of ICLR, 2015.
209
+
210
+ Tianyu Gu, Brendan Dolan-Gavitt, and Siddharth Garg. Badnets: Identifying vulnerabilities in the machine learning model supply chain. arXiv preprint 1708.06733, 2017.
211
+
212
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of CVPR, 2016.
213
+
214
+ Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks. In Proceedings of CVPR, 2017.
215
+
216
+ Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In Proceedings of ICML, 2015.
217
+
218
+ Yu Ji, Zixin Liu, Xing Hu, Peiqi Wang, and Youhui Zhang. Programmable neural network trojan for pre-trained feature extractor. arXiv preprint 1901.07766, 2019.
219
+
220
+ Yujie Ji, Xinyang Zhang, Shouling Ji, Xiapu Luo, and Ting Wang. Model-reuse attacks on deep learning systems. In Proceedings of CCS, 2018.
221
+
222
+ Jinyuan Jia, Yupei Liu, and Neil Zhenqiang Gong. Badencoder: Backdoor attacks to pre-trained encoders in self-supervised learning. In Proceedings of S&P, 2022.
223
+
224
+ Di Jin, Zhijing Jin, Joey Tianyi Zhou, and Peter Szolovits. Is bert really robust? a strong baseline for natural language attack on text classification and entailment. In Proceedings of AAAI, 2020.
225
+
226
+ Olga Kovaleva, Alexey Romanov, Anna Rogers, and Anna Rumshisky. Revealing the dark secrets of BERT. In Kentaro Inui, Jing Jiang, Vincent Ng, and Xiaojun Wan (eds.), Proceedings of EMNLP-IJCNLP, 2019.
227
+
228
+ Keita Kurita, Paul Michel, and Graham Neubig. Weight poisoning attacks on pretrained models. In Proceedings of ACL, 2020.
229
+
230
+ Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. Albert: A lite bert for self-supervised learning of language representations. In Proceedings of ICLR, 2020.
231
+
232
+ Linyang Li, Demin Song, Xiaonan Li, Jiehang Zeng, Ruotian Ma, and Xipeng Qiu. Backdoor attacks on pre-trained models by layerwise weight poisoning. arXiv preprint 2108.13888, 2021a.
233
+
234
+ Shaofeng Li, Shiqing Ma, Minhui Xue, and Benjamin Zi Hao Zhao. Deep learning backdoors. arXiv preprint 2007.08273, 2020.
235
+
236
+ Yige Li, Xixiang Lyu, Nodens Koren, Lingjuan Lyu, Bo Li, and Xingjun Ma. Neural attention distillation: Erasing backdoor triggers from deep neural networks. In Proceedings of ICLR, 2021b.
237
+
238
+ Hanxiao Liu, Zihang Dai, David R. So, and Quoc V. Le. Pay attention to mlps. arXiv preprint 2105.08050, 2021.
239
+
240
+ Kang Liu, Brendan Dolan-Gavitt, and Siddharth Garg. Fine-pruning: Defending against backdooring attacks on deep neural networks. In Proceedings of RAID, 2018a.
241
+
242
+ Y. Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, M. Lewis, Luke Zettlemoyer, and Veselin Stoyanov. RoBERTa: A robustly optimized bert pretraining approach. arXiv preprint 1907.11692, 2019.
243
+
244
+ Yingqi Liu, Shiqing Ma, Yousra Aafer, Wen-Chuan Lee, Juan Zhai, Weihang Wang, and Xiangyu Zhang. Trojaning attack on neural networks. In Proceedings of NDSS, 2018b.
245
+
246
+ Vangelis Metsis, Ion Androutsopoulos, and Georgios Paliouras. Spam filtering with naive bayes - which naive bayes? In Proceedings of CEAS, 2006.
247
+
248
+ Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y. Ng. Reading digits in natural images with unsupervised feature learning. In NIPS Workshop on Deep Learning and Unsupervised Feature Learning, 2011.
249
+
250
+ Fanchao Qi, Yangyi Chen, Mukai Li, Yuan Yao, Zhiyuan Liu, and Maosong Sun. Onion: A simple and effective defense against textual backdoor attacks. In Proceedings of EMNLP, 2021a.
251
+
252
+ Fanchao Qi, Mukai Li, Yangyi Chen, Zhengyan Zhang, Zhiyuan Liu, Yasheng Wang, and Maosong Sun. Hidden killer: Invisible textual backdoor attacks with syntactic trigger. In Proceedings of ACL, 2021b.
253
+
254
+ Fanchao Qi, Yuan Yao, Sophia Xu, Zhiyuan Liu, and Maosong Sun. Turn the combination lock: Learnable textual backdoor attacks via word substitution. In Proceedings of ACL, 2021c.
255
+
256
+ Shahbaz Rezaei and Xin Liu. A target-agnostic attack on deep models: Exploiting security vulnerabilities of transfer learning. In Proceedings of ICLR, 2020.
257
+
258
+ Roei Schuster, Tal Schuster, Yoav Meri, and Vitaly Shmatikov. Humpty dumpty: Controlling word meanings via corpus poisoning. In Proceedings of IEEE S&P, 2020.
259
+
260
+ Lujia Shen, Shouling Ji, Xuhong Zhang, Jinfeng Li, Jing Chen, Jie Shi, Chengfang Fang, Jianwei Yin, and Ting Wang. Backdoor pre-trained models can transfer to all. In Proceedings of CCS, 2021.
261
+
262
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In Proceedings of ICLR, 2015.
263
+
264
+ R. Socher, Alex Perelygin, J. Wu, Jason Chuang, Christopher D. Manning, A. Ng, and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of EMNLP, 2013.
265
+
266
+ J. Stallkamp, M. Schlipsing, J. Salmen, and C. Igel. Man vs. computer: Benchmarking machine learning algorithms for traffic sign recognition. Neural Networks, (0), 2012.
267
+
268
+ Lichao Sun. Natural backdoor attack on text data. arXiv preprint 2006.16176, 2020.
269
+
270
+ Ilya O. Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Andreas Steiner, Daniel Keysers, Jakob Uszkoreit, Mario Lucic, and Alexey Dosovitskiy. Mlp-mixer: An all-mlp architecture for vision. arXiv preprint 2105.01601, 2021.
271
+
272
+ Bolun Wang, Yuanshun Yao, Shawn Shan, Huiying Li, Bimal Viswanath, Haitao Zheng, and Ben Y Zhao. Neural cleanse: Identifying and mitigating backdoor attacks in neural networks. In Proceedings of S&P, 2019.
273
+
274
+ John Wieting and Kevin Gimpel. Pushing the limits of paraphrastic sentence embeddings with millions of machine translations. In Proceedings of ACL, 2018.
275
+
276
+ Qixue Xiao, Kang Li, Deyue Zhang, and Weilin Xu. Security risks in deep learning implementations. In Proceedings of SPW, 2018.
277
+
278
+ Xiaojun Xu, Qi Wang, Huichen Li, Nikita Borisov, Carl A Gunter, and Bo Li. Detecting ai trojans using meta neural analysis. In Proceedings of S&P, 2021.
279
+
280
+ Wenkai Yang, Yankai Lin, Peng Li, Jie Zhou, and Xu Sun. Rethinking stealthiness of backdoor attack against NLP models. In Proceedings of ACL, 2021.
281
+
282
+ Yuanshun Yao, Huiying Li, Haitao Zheng, and Ben Y. Zhao. Latent backdoor attacks on deep neural networks. In Proceedings of CCS, 2019.
283
+
284
+ Marcos Zampieri, Shervin Malmasi, Preslav Nakov, Sara Rosenthal, Noura Farra, and Ritesh Kumar. Predicting the type and target of offensive posts in social media. In Proceedings of NAACL-HLT, 2019.
285
+
286
+ Yuan Zang, Chenghao Yang, Fanchao Qi, Z. Liu, Meng Zhang, Qun Liu, and Maosong Sun. Wordlevel textual adversarial attacking as combinatorial optimization. In Proceedings of ACL, 2020.
287
+
288
+ Xinyang Zhang, Zheng Zhang, and Ting Wang. Trojaning language models for fun and profit. arXiv preprint 2008.00312, 2020.
289
+
290
+ Xinyang Zhang, Zheng Zhang, Shouling Ji, and Ting Wang. Trojaning language models for fun and profit. In Proceedings of EuroS&P, 2021.
291
+
292
+ Yukun Zhu, Ryan Kiros, Richard S. Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja Fidler. Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. In Proceedings of ICCV, 2015.
293
+
294
+ # A APPENDIX
295
+
296
+ # A.1 DETAILS OF EXPERIMENTAL SETUPS
297
+
298
+ Training Details. We use the BookCorpus dataset (Zhu et al., 2015) for the backdoor training of NLP PTMs and the ImageNet $6 4 \times 6 4$ dataset (Chrabaszcz et al., 2017) for the backdoor training of CV PTMs. Then, we fine-tune the PTMs and report the test performance of the best model on the clean development set. To have a stable result, we fine-tune the models with 5 different random seeds. Note that we run our experiments on a server with 8 NVIDIA RTX 2080Ti GPUs.
299
+
300
+ Dataset Statistics. Table 8 reports the statistics of the datasets used in the experiments.
301
+
302
+ Table 8: Statistics of datasets.
303
+
304
+ <table><tr><td>Dataset</td><td>|Train|</td><td>[Valid|</td><td>|Test|</td></tr><tr><td>SST-2</td><td>67,349</td><td>872</td><td>1,821</td></tr><tr><td>OLID</td><td>12.380</td><td>860</td><td>860</td></tr><tr><td>Enron</td><td>21,716</td><td>6,000</td><td>6.000</td></tr><tr><td>Waste</td><td>20,308</td><td>2,256</td><td>2.513</td></tr><tr><td>CD</td><td>10,000</td><td>1,250</td><td>1,250</td></tr><tr><td>GTSRB</td><td>35,289</td><td>3,920</td><td>12,630</td></tr></table>
305
+
306
+ Hyperparameters. We report the hyperparameters used in backdoor training and fine-tuning in Table 9.
307
+
308
+ Table 9: Hyperparameters used in backdoor pre-training and fine-tuning.
309
+
310
+ <table><tr><td colspan="2"></td><td>BERT/RoBERTa</td><td>VGGNet</td><td>ViT</td></tr><tr><td rowspan="4">Backdoor Training</td><td>Optimizer</td><td>Adam</td><td>SGD</td><td>SGD</td></tr><tr><td>Learning Rate</td><td>5e-5</td><td>1e-2</td><td>1e-2</td></tr><tr><td>Batch Size</td><td>160</td><td>512</td><td>512</td></tr><tr><td>Step</td><td>40,000</td><td>110,000</td><td>110,000</td></tr><tr><td rowspan="4">Fine-tuning</td><td>Optimizer</td><td>Adam</td><td>SGD</td><td>SGD</td></tr><tr><td>Learning Rate</td><td>2e-5</td><td>1e-3</td><td>1e-3</td></tr><tr><td>Batch Size</td><td>32</td><td>64</td><td>64</td></tr><tr><td>Epoch</td><td>5</td><td>20</td><td>20</td></tr></table>
311
+
312
+ Implementation of Predefined Values. Six predefined values are shown below.
313
+
314
+ $$
315
+ \begin{array} { r l } & { v _ { 1 } = \Bigl [ \frac { - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , 3 _ { \mathrm { - } } , \ldots , 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } } { d _ { 1 } } } \\ & { v _ { 2 } = \Bigl [ \frac { 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } \Bigr ] } { d _ { 1 } } } \\ & { v _ { 3 } = \Bigl [ \frac { - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } \Bigr ] } { d _ { 1 } } } \\ & { v _ { 4 } = \Bigl [ \frac { 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } \Bigr ] } { d _ { 1 } } } \\ & { v _ { 5 } = \Bigl [ \frac { - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } \Bigr ] } { d _ { 1 } } } \\ & v _ { 6 } = \Bigl [ \frac { 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , \ldots , - 3 _ { \mathrm { s } } , } \\ & v _ { 6 } = \Bigl [ \frac 3 _ \mathrm \end{array}
316
+ $$
317
+
318
+ where $d$ is the output dimension of PTMs. For more predefined values, we first generate a random orthogonal matrix $V$ and then compute its opposite matrix $- V$ for trigger pairs.
319
+
320
+ Implementation of Defense Methods. Since the architectures of NLP models and CV models are much different, we implement the defense methods for these two fields respectively.
321
+
322
+ (1) Re-init. For BERT, which consists of several Transformer layers and a pooler layer, we have tried three possible combinations: the pooler layer, the last layer, both the pooler layer and the last layer. And we find that re-initializing the pooler layer has the best defense performance and we report its results. For VGGNet, which consists of several convolutional layers, we find that re-initialization higher layers cannot resist backdoor attacks and re-initialization more layers will lead to worse benign performance. Hence, we report the results of re-initializing the last layer of VGGNet.
323
+
324
+ (2) Fine-pruning. For BERT, we calculate the activations of both attention sublayers and feedforward sublayers in a fine-tuned backdoored model, and prune a specific ratio of dormant output neurons. Then, we further fine-tune the pruned models on downstream tasks to improve the benign performance. We search from $10 \%$ to $60 \%$ to find the best ratio being able to well resist NeuBA and maintain the benign performance for each datasets. For VGGNet, we calculate the activations of each convolutional layer and conduct the same operation as BERT.
325
+
326
+ (3) NAD. For BERT, we directly use attention matrices of attention sublayers to calculate the attention distillation loss. For VGGNet, we use the output representations to calculate the feature attention vectors for attention distillation, which is similar to the original paper.
327
+
328
+ (4) Neural Cleanse. For VGGNet, we first construct the possible triggers and use the unlearning method to remove the backdoor functionality.
329
+
330
+ (5) MNTD. Following Jia et al. (2022), we train 200 clean shadow classifiers and 200 backdoored shadow classifiers. Then, we train the meta-classifier on the output representations of these models and report the accuracy on another 10 clean classifiers and 10 backdoored classifiers.
331
+
332
+ # A.2 EFFECTS OF LEARNING RATES
333
+
334
+ According to (Kurita et al., 2020), the learning rates of fine-tuning will influence backdoor performance. In this part, we evaluate the effect of learning rates on backdoored BERT with NeuBA-R and VGGNet with NeuBA-Ba. Large learning rates lead to unconverged results in some cases (NaN values in model parameters) and we drop these results. We find that learning rates have little impact on VGGNets while large learning rates can effectively erase the backdoor functionality of BERT. Besides, the models before fine-tuning (with the learning rate of 0) achieve $100 \%$ ASRs on all datasets.
335
+
336
+ ![](images/172b9b9bf3c6bebd0f7a238fa6411578b3b4eef3fa36e808c1677e0dee4a274c.jpg)
337
+ Figure 4: Attack success rates of different learning rates. The backdoored model is BERT.
338
+
339
+ # A.3 EFFECTS OF NUMBER OF TRIGGER PAIRS
340
+
341
+ We report the results with different number of trigger pairs in Figure 6. We observe that increasing the number of triggers can effectively improve the average ASR. 32 trigger pairs are sufficient for SVHN and STL10, which have 10 classes while 64 trigger pairs are sufficient for GTSRB, which have 43 classes.
342
+
343
+ ![](images/b047e0c4632f19847a5a2db0e13970c3016d6c0840c903a05149107f3b4db8bb.jpg)
344
+ Figure 5: Attack success rates of different learning rates. The backdoored model is VGGNet.
345
+
346
+ ![](images/d14f505cb11218c87179cc69bb636945e06e36f27dd4b9e162826d9ba292163c.jpg)
347
+ Figure 6: Average ASR along with the number of trigger pairs used in backdoor attacks.
348
+
349
+ However, there is no theoretical guarantee of how many inserted trigger pairs can control all labels when we use orthogonal vectors and their opposite vectors. Here is an example. Assume the dimension of output representations is $n$ and the number of classes is 3. We insert $n$ trigger pairs as follows:
350
+
351
+ $$
352
+ \begin{array} { r } { v _ { 2 i } = [ \underbrace { 0 , \ldots , 0 } _ { i } , 1 , \underbrace { 0 , \ldots , 0 } _ { n - 1 - i } ] , } \\ { v _ { 2 i + 1 } = [ \underbrace { 0 , \ldots , 0 } _ { i } , - 1 , \underbrace { 0 , \ldots , 0 } _ { n - 1 - i } ] , } \end{array}
353
+ $$
354
+
355
+ where $i = 0 , 1 , \ldots , n - 1$ . The label representations, which will be used by the dot product with output representations, are as follows:
356
+
357
+ $$
358
+ \begin{array} { r l } & { c _ { 1 } = \underbrace { \left[ 2 , 2 , \ldots , 2 \right] } _ { n } , } \\ & { c _ { 2 } = \bigl [ 1 , \underbrace { 0 , 0 , \ldots , 0 } _ { n - 1 } \bigr ] , } \\ & { c _ { 3 } = \underbrace { \left[ - 1 , - 1 , \ldots , - 1 \right] } _ { n } . } \end{array}
359
+ $$
360
+
361
+ Then the target labels of ${ \mathbf { } } v _ { 2 i }$ are the first class and the target labels of ${ \pmb v } _ { 2 i + 1 }$ are the third label. In this case, the backdoor attacks can not control the second label.
md/dev/vfsRB5MImo9/vfsRB5MImo9.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/vhFu1Acb0xb/vhFu1Acb0xb.md ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TRANSFORMERS ARE SAMPLE-EFFICIENT WORLD MODELS
2
+
3
+ Vincent Micheli∗ University of Geneva
4
+
5
+ Eloi Alonso∗ University of Geneva
6
+
7
+ François Fleuret University of Geneva
8
+
9
+ # ABSTRACT
10
+
11
+ Deep reinforcement learning agents are notoriously sample inefficient, which considerably limits their application to real-world problems. Recently, many model-based methods have been designed to address this issue, with learning in the imagination of a world model being one of the most prominent approaches. However, while virtually unlimited interaction with a simulated environment sounds appealing, the world model has to be accurate over extended periods of time. Motivated by the success of Transformers in sequence modeling tasks, we introduce IRIS, a data-efficient agent that learns in a world model composed of a discrete autoencoder and an autoregressive Transformer. With the equivalent of only two hours of gameplay in the Atari $1 0 0 \mathrm { k }$ benchmark, IRIS achieves a mean human normalized score of 1.046, and outperforms humans on 10 out of 26 games, setting a new state of the art for methods without lookahead search. To foster future research on Transformers and world models for sample-efficient reinforcement learning, we release our code and models at https://github.com/eloialonso/iris.
12
+
13
+ # 1 INTRODUCTION
14
+
15
+ Deep Reinforcement Learning (RL) has become the dominant paradigm for developing competent agents in challenging environments. Most notably, deep RL algorithms have achieved impressive performance in a multitude of arcade (Mnih et al., 2015; Schrittwieser et al., 2020; Hafner et al., 2021), real-time strategy (Vinyals et al., 2019; Berner et al., 2019), board (Silver et al., 2016; 2018; Schrittwieser et al., 2020) and imperfect information (Schmid et al., 2021; Brown et al., 2020a) games. However, a common drawback of these methods is their extremely low sample efficiency. Indeed, experience requirements range from months of gameplay for DreamerV2 (Hafner et al., 2021) in Atari 2600 games (Bellemare et al., 2013b) to thousands of years for OpenAI Five in Dota2 (Berner et al., 2019). While some environments can be sped up for training agents, real-world applications often cannot. Besides, additional cost or safety considerations related to the number of environmental interactions may arise (Yampolskiy, 2018). Hence, sample efficiency is a necessary condition to bridge the gap between research and the deployment of deep RL agents in the wild.
16
+
17
+ Model-based methods (Sutton & Barto, 2018) constitute a promising direction towards data efficiency. Recently, world models were leveraged in several ways: pure representation learning (Schwarzer et al., 2021), lookahead search (Schrittwieser et al., 2020; Ye et al., 2021), and learning in imagination (Ha & Schmidhuber, 2018; Kaiser et al., 2020; Hafner et al., 2020; 2021). The latter approach is particularly appealing because training an agent inside a world model frees it from sample efficiency constraints. Nevertheless, this framework relies heavily on accurate world models since the policy is purely trained in imagination. In a pioneering work, Ha & Schmidhuber (2018) successfully built imagination-based agents in toy environments. SimPLe recently showed promise in the more challenging Atari 100k benchmark (Kaiser et al., 2020). Currently, the best Atari agent learning in imagination is DreamerV2 (Hafner et al., 2021), although it was developed and evaluated with two hundred million frames available, far from the sample-efficient regime. Therefore, designing new world model architectures, capable of handling visually complex and partially observable environments with few samples, is key to realize their potential as surrogate training grounds.
18
+
19
+ The Transformer architecture (Vaswani et al., 2017) is now ubiquitous in Natural Language Processing (Devlin et al., 2019; Radford et al., 2019; Brown et al., 2020b; Raffel et al., 2020), and is also gaining traction in Computer Vision (Dosovitskiy et al., 2021; He et al., 2022), as well as in Offline
20
+
21
+ ![](images/718049274cf655f65ecea26f956956f1852508ce240c434575cec3cc98bac1f9.jpg)
22
+ Figure 1: Unrolling imagination over time. This figure shows the policy $\pi$ , depicted with purple arrows, taking a sequence of actions in imagination. The green arrows correspond to the encoder $E$ and the decoder $D$ of a discrete autoencoder, whose task is to represent frames in its learnt symbolic language. The backbone $G$ of the world model is a GPT-like Transformer, illustrated with blue arrows. For each action that the policy $\pi$ takes, $G$ simulates the environment dynamics, by autoregressively unfolding new frame tokens that $D$ can decode. $G$ also predicts a reward and a potential episode termination. More specifically, an initial frame $x _ { 0 }$ is encoded with $E$ into tokens $\mathbf { \dot { \boldsymbol { z } } } _ { 0 } = ( z _ { 0 } ^ { 1 } , \dots , z _ { 0 } ^ { K } ) = E ( \boldsymbol { x } _ { 0 } )$ . The decoder $D$ reconstructs an image $\hat { x } _ { 0 } = D ( z _ { 0 } )$ , from which the policy $\pi$ predicts the action $a _ { 0 }$ . From $z _ { \mathrm { 0 } }$ and $a _ { 0 }$ , $G$ predicts the reward $\hat { r } _ { 0 }$ , episode termination $\hat { d } _ { 0 } \in \{ 0 , 1 \}$ , and in an autoregressive manner $\hat { z } _ { 1 } = ( \hat { z } _ { 1 } ^ { 1 } , \dots , \hat { z } _ { 1 } ^ { K } )$ , the tokens for the next frame. A dashed box indicates image tokens for a given time step, whereas a solid box represents the input sequence of $G$ , i.e. $( z _ { 0 } , a _ { 0 } )$ at $t = 0$ , $( z _ { 0 } , a _ { 0 } , \hat { z } _ { 1 } , a _ { 1 } )$ at $t = 1$ , etc. The policy $\pi$ is purely trained with imagined trajectories, and is only deployed in the real environment to improve the world model $( E , D , G )$ .
23
+
24
+ Reinforcement Learning (Janner et al., 2021; Chen et al., 2021). In particular, the GPT (Radford et al., 2018; 2019; Brown et al., 2020b) family of models delivered impressive results in language understanding tasks. Similarly to world models, these attention-based models are trained with highdimensional signals and a self-supervised learning objective, thus constituting ideal candidates to simulate an environment.
25
+
26
+ Transformers particularly shine when they operate over sequences of discrete tokens (Devlin et al., 2019; Brown et al., 2020b). For textual data, there are simple ways (Schuster & Nakajima, 2012; Kudo & Richardson, 2018) to build a vocabulary, but this conversion is not straightforward with images. A naive approach would consist in treating pixels as image tokens, but standard Transformer architectures scale quadratically with sequence length, making this idea computationally intractable. To address this issue, VQGAN (Esser et al., 2021) and DALL-E (Ramesh et al., 2021) employ a discrete autoencoder (Van Den Oord et al., 2017) as a mapping from raw pixels to a much smaller amount of image tokens. Combined with an autoregressive Transformer, these methods demonstrate strong unconditional and conditional image generation capabilities. Such results suggest a new approach to design world models.
27
+
28
+ In the present work, we introduce IRIS (Imagination with auto-Regression over an Inner Speech), an agent trained in the imagination of a world model composed of a discrete autoencoder and an autoregressive Transformer. IRIS learns behaviors by accurately simulating millions of trajectories. Our approach casts dynamics learning as a sequence modeling problem, where an autoencoder builds a language of image tokens and a Transformer composes that language over time. With minimal tuning, IRIS outperforms a line of recent methods (Kaiser et al., 2020; Hessel et al., 2018; Laskin et al., 2020; Yarats et al., 2021; Schwarzer et al., 2021) for sample-efficient RL in the Atari $1 0 0 \mathrm { k }$ benchmark (Kaiser et al., 2020). After only two hours of real-time experience, it achieves a mean human normalized score of 1.046, and reaches superhuman performance on 10 out of 26 games. We describe IRIS in Section 2 and present our results in Section 3.
29
+
30
+ ![](images/97ff328e6b75f6cd320afb1df101700705e8a6f827aacc1c6a6d16930b213227.jpg)
31
+ Figure 2: Four imagined trajectories in KungFuMaster. We use the same conditioning frame across the four rows, in green, and let the world model imagine the rest. As the initial frame only contains the player, there is no information about the enemies that will come next. Consequently, the world model generates different types and numbers of opponents in each simulation. It is also able to reflect an essential game mechanic, highlighted in the blue box, where the first enemy disappears after getting hit by the player.
32
+
33
+ # 2 METHOD
34
+
35
+ We formulate the problem as a Partially Observable Markov Decision Process (POMDP) with image observations $\boldsymbol { x } _ { t } \in \mathbf { \mathbb { R } } ^ { h \times w \times 3 }$ , discrete actions $a _ { t } \in \{ 1 , \ldots , A \}$ , scalar rewards $r _ { t } \in \mathbb { R }$ , episode termination $d _ { t } \in \{ 0 , 1 \}$ , discount factor $\gamma \in ( 0 , 1 )$ , initial observation distribution $\rho _ { 0 }$ , and environment dynamics $x _ { t + 1 } , r _ { t } , d _ { t } \sim p ( x _ { t + 1 } , r _ { t } , d _ { t } \mid x _ { \leq t } , a _ { \leq t } )$ . The reinforcement learning objective is to train a policy $\pi$ that yields actions maximizing the expected sum of rewards $\begin{array} { r } { \mathbb { E } _ { \pi } [ \sum _ { t \ge 0 } \gamma ^ { \bar { t } } r _ { t } ] } \end{array}$ .
36
+
37
+ Our method relies on the three standard components to learn in imagination (Sutton & Barto, 2018): experience collection, world model learning, and behavior learning. In the vein of Ha & Schmidhuber (2018); Kaiser et al. (2020); Hafner et al. (2020; 2021), our agent learns to act exclusively within its world model, and we only make use of real experience to learn the environment dynamics.
38
+
39
+ We repeatedly perform the three following steps:
40
+
41
+ • collect_experience: gather experience in the real environment with the current policy.
42
+ • update_world_model: improve rewards, episode ends and next observations predictions.
43
+ • update_behavior: in imagination, improve the policy and value functions.
44
+
45
+ The world model is composed of a discrete autoencoder (Van Den Oord et al., 2017), to convert an image to tokens and back, and a GPT-like autoregressive Transformer (Vaswani et al., 2017; Radford et al., 2019; Brown et al., 2020b), whose task is to capture environment dynamics. Figure 1 illustrates the interplay between the policy and these two components during imagination. We first describe the autoencoder and the Transformer in Sections 2.1 and 2.2, respectively. Section 2.3 then details the procedure to learn the policy and value functions in imagination. Appendix A provides a comprehensive description of model architectures and hyperparameters. Algorithm 1 summarizes the training protocol.
46
+
47
+ # 2.1 FROM IMAGE OBSERVATIONS TO TOKENS
48
+
49
+ The discrete autoencoder $( E , D )$ learns a symbolic language of its own to represent high-dimensional images as a small number of tokens. The back and forth between frames and tokens is illustrated with green arrows in Figure 1.
50
+
51
+ ![](images/cf908a17f2f0e987d055822a42e60010df408a9dfccbe5d18ef0bc5b81439629.jpg)
52
+ Figure 3: Pixel perfect predictions in Pong. The top row displays a test trajectory collected in the real environment. The bottom row depicts the reenactment of that trajectory inside the world model. More precisely, we condition the world model with the first two frames of the true sequence, in green. We then sequentially feed it the true actions and let it imagine the subsequent frames. After only 120 games of training, the world model perfectly simulates the ball’s trajectory and players’ movements. Notably, it also captures the game mechanic of updating the scoreboard after winning an exchange, as shown in the blue box.
53
+
54
+ More precisely, the encoder $E : \mathbb { R } ^ { h \times w \times 3 } \{ 1 , \dots , N \} ^ { K }$ converts an input image $x _ { t }$ into $K$ tokens from a vocabulary of size $N$ . Let $\mathcal { E } = \{ \bar { e } _ { i } \} _ { i = 1 } ^ { N } \in \bar { \mathbb { R } } ^ { N \times d }$ be the corresponding embedding table of $d$ -dimensional vectors. The input image $x _ { t }$ is first passed through a Convolutional Neural Network (CNN) (LeCun et al., 1989) producing output $\bar { y _ { t } } \in \mathbb { R } ^ { K \times d }$ . We then obtain the output tokens $z _ { t } = ( z _ { t } ^ { 1 } , \dots , z _ { t } ^ { K } ) \in \{ 1 , \dots , { \dot { N } } \} ^ { K }$ as $z _ { t } ^ { \bar { k } } = \mathrm { \bar { a r g m i n } } _ { i } \| y _ { t } ^ { k } - e _ { i } \| _ { 2 }$ , the index of the closest embedding vector in $\mathcal { E }$ (Van Den Oord et al., 2017; Esser et al., 2021). Conversely, the CNN decoder $D : \{ 1 , \ldots , N \} ^ { K } \to \mathbb { R } ^ { \dot { h } \times w \times 3 }$ turns $K$ tokens back into an image.
55
+
56
+ This discrete autoencoder is trained on previously collected frames, with an equally weighted combination of a $L _ { 1 }$ reconstruction loss, a commitment loss (Van Den Oord et al., 2017; Esser et al., 2021), and a perceptual loss (Esser et al., 2021; Johnson et al., 2016; Larsen et al., 2016). We use a straight-through estimator (Bengio et al., 2013) to enable backpropagation training.
57
+
58
+ # 2.2 MODELING DYNAMICS
59
+
60
+ At a high level, the Transformer $G$ captures the environment dynamics by modeling the language of the discrete autoencoder over time. Its central role of unfolding imagination is highlighted with the blue arrows in Figure 1.
61
+
62
+ Specifically, $G$ operates over sequences of interleaved frame and action tokens. An input sequence $( z _ { 0 } ^ { \bar { 1 } } , \ldots , \bar { z } _ { 0 } ^ { K } , a _ { 0 } , z _ { 1 } ^ { 1 } , \ldots , z _ { 1 } ^ { K } , a _ { 1 } , \ldots , z _ { t } ^ { 1 } , \ldots , z _ { t } ^ { K } , a _ { t } )$ is obtained from the raw sequence $( x _ { 0 } , a _ { 0 } , x _ { 1 } , a _ { 1 } , \dots , x _ { t } , a _ { t } )$ by encoding the frames with $E$ , as described in Section 2.1.
63
+
64
+ At each time step $t$ , the Transformer models the three following distributions:
65
+
66
+ $$
67
+ \begin{array} { r l } & { \mathrm { T r a n s i t i o n : } \quad \hat { z } _ { t + 1 } \sim p _ { G } \big ( \hat { z } _ { t + 1 } \big | z _ { \le t } , a _ { \le t } \big ) \mathrm { w i t h } \hat { z } _ { t + 1 } ^ { k } \sim p _ { G } \big ( \hat { z } _ { t + 1 } ^ { k } \mid z _ { \le t } , a _ { \le t } , z _ { t + 1 } ^ { < k } \big ) } \\ & { \mathrm { R e w a r d : } \quad \quad \hat { r } _ { t } \sim p _ { G } \big ( \hat { r } _ { t } \mid z _ { \le t } , a _ { \le t } \big ) } \\ & { \mathrm { T e r m i n a t i o n : } \quad \hat { d } _ { t } \sim p _ { G } \big ( \hat { d } _ { t } \mid z _ { \le t } , a _ { \le t } \big ) } \end{array}
68
+ $$
69
+
70
+ Note that the conditioning for the $k$ -th token also includes $z _ { t + 1 } ^ { < k } : = ( z _ { t + 1 } ^ { 1 } , \dots , z _ { t + 1 } ^ { k - 1 } )$ , the tokens that
71
+
72
+ We train $G$ in a self-supervised manner on segments of $L$ time steps, sampled from past experience. We use a cross-entropy loss for the transition and termination predictors, and a mean-squared error loss or a cross-entropy loss for the reward predictor, depending on the reward function.
73
+
74
+ # 2.3 LEARNING IN IMAGINATION
75
+
76
+ Together, the discrete autoencoder $( E , D )$ and the Transformer $G$ form a world model, capable of imagination. The policy $\pi$ , depicted with purple arrows in Figure 1, exclusively learns in this imagination MDP.
77
+
78
+ ![](images/38730f40fa882948b9610ee92a0ffac78f19d740108d41e5bcf2b2cf84e1e86b.jpg)
79
+ Figure 4: Imagining rewards and episode ends in Breakout (top) and Gopher (bottom). Each row depicts an imagined trajectory initialized with a single frame from the real environment. Yellow boxes indicate frames where the world model predicts a positive reward. In Breakout, it captures that breaking a brick yields rewards, and the brick is correctly removed from the following frames. In Gopher, the player has to protect the carrots from rodents. The world model successfully internalizes that plugging a hole or killing an enemy leads to rewards. Predicted episode terminations are highlighted with red boxes. The world model accurately reflects that missing the ball in Breakout, or letting an enemy reach the carrots in Gopher, will result in the end of an episode.
80
+
81
+ At time step $t$ , the policy observes a reconstructed image observation $\hat { x } _ { t }$ and samples action $a _ { t } \sim$ $\pi ( \boldsymbol { a } _ { t } | \hat { \boldsymbol { x } } _ { \le t } )$ . The world model then predicts the reward $\hat { r } _ { t }$ , the episode end $\hat { d } _ { t }$ , and the next observation $\hat { x } _ { t + 1 } = \overset { - } { D } ( \hat { z } _ { t + 1 } )$ , with $\hat { z } _ { t + 1 } \sim p _ { G } ( \hat { z } _ { t + 1 } \mid z _ { 0 } , a _ { 0 } , \hat { z } _ { 1 } , a _ { 1 } , \dots , \hat { z } _ { t } , a _ { t } )$ . This imagination procedure is initialized with a real observation $x _ { 0 }$ sampled from past experience, and is rolled out for $H$ steps, the imagination horizon hyperparameter. We stop if an episode end is predicted before reaching the horizon. Figure 1 illustrates the imagination procedure.
82
+
83
+ As we roll out imagination for a fixed number of steps, we cannot simply use a Monte Carlo estimate for the expected return. Hence, to bootstrap the rewards that the agent would get beyond a given time step, we have a value network $V$ that estimates $\begin{array} { r } { V ( \hat { x } _ { t } ) \simeq \mathbb { E } _ { \pi } \big [ \sum _ { \tau \geq t } \gamma ^ { \tau - t } \hat { r } _ { \tau } \big ] } \end{array}$ .
84
+
85
+ Many actor-critic methods could be employed to train $\pi$ and $V$ in imagination (Sutton & Barto, 2018; Kaiser et al., 2020; Hafner et al., 2020). For the sake of simplicity, we opt for the learning objectives and hyperparameters of DreamerV2 (Hafner et al., 2021), that delivered strong performance in Atari games. Appendix B gives a detailed breakdown of the reinforcement learning objectives.
86
+
87
+ # 3 EXPERIMENTS
88
+
89
+ Sample-efficient reinforcement learning is a growing field with multiple benchmarks in complex visual environments (Hafner, 2022; Kanervisto et al., 2022). In this work, we focus on the well established Atari 100k benchmark (Kaiser et al., 2020). We present the benchmark and its baselines in Section 3.1. We describe the evaluation protocol and discuss the results in Section 3.2. Qualitative examples of the world model’s capabilities are given in Section 3.3.
90
+
91
+ Table 1: Returns on the 26 games of Atari $1 0 0 \mathrm { k }$ after 2 hours of real-time experience, and humannormalized aggregate metrics. Bold numbers indicate the top methods without lookahead search while underlined numbers specify the overall best methods. IRIS outperforms learning-only methods in terms of number of superhuman games, mean, interquartile mean (IQM), and optimality gap.
92
+
93
+ <table><tr><td colspan="3"></td><td colspan="2">Lookahead search</td><td colspan="5">No lookahead search</td></tr><tr><td>Game</td><td>Random</td><td>Human</td><td>MuZero</td><td>EfficientZero</td><td>SimPLe</td><td>CURL</td><td>DrQ</td><td>SPR</td><td>IRIS (ours)</td></tr><tr><td>Alien</td><td>227.8</td><td>7127.7</td><td>530.0</td><td>808.5</td><td>616.9</td><td>711.0</td><td>865.2</td><td>841.9</td><td>420.0</td></tr><tr><td>Amidar</td><td>5.8</td><td>1719.5</td><td>38.8</td><td>148.6</td><td>74.3</td><td>113.7</td><td>137.8</td><td>179.7</td><td>143.0</td></tr><tr><td>Assault</td><td>222.4</td><td>742.0</td><td>500.1</td><td>1263.1</td><td>527.2</td><td>500.9</td><td>579.6</td><td>565.6</td><td>1524.4</td></tr><tr><td>Asterix</td><td>210.0</td><td>8503.3</td><td>1734.0</td><td>25557.8</td><td>1128.3</td><td>567.2</td><td>763.6</td><td>962.5</td><td>853.6</td></tr><tr><td>BankHeist</td><td>14.2</td><td>753.1</td><td>192.5</td><td>351.0</td><td>34.2</td><td>65.3</td><td>232.9</td><td>345.4</td><td>53.1</td></tr><tr><td>BattleZone</td><td>2360.0</td><td>37187.5</td><td>7687.5</td><td>13871.2</td><td>4031.2</td><td>8997.8</td><td>10165.3</td><td>14834.1</td><td>13074.0</td></tr><tr><td>Boxing</td><td>0.1</td><td>12.1</td><td>15.1</td><td>52.7</td><td>7.8</td><td>0.9</td><td>9.0</td><td>35.7</td><td>70.1</td></tr><tr><td>Breakout</td><td>1.7</td><td>30.5</td><td>48.0</td><td>414.1</td><td>16.4</td><td>2.6</td><td>19.8</td><td>19.6</td><td>83.7</td></tr><tr><td>ChopperCommand</td><td>811.0</td><td>7387.8</td><td>1350.0</td><td>1117.3</td><td>979.4</td><td>783.5</td><td>844.6</td><td>946.3</td><td>1565.0</td></tr><tr><td>CrazyClimber</td><td>10780.5</td><td>35829.4</td><td>56937.0</td><td>83940.2</td><td>62583.6</td><td>9154.4</td><td>21539.0</td><td>36700.5</td><td>59324.2</td></tr><tr><td>DemonAttack</td><td>152.1</td><td>1971.0</td><td>3527.0</td><td>13003.9</td><td>208.1</td><td>646.5</td><td>1321.5</td><td>517.6</td><td>2034.4</td></tr><tr><td>Freeway</td><td>0.0</td><td>29.6</td><td>21.8</td><td>21.8</td><td>16.7</td><td>28.3</td><td>20.3</td><td>19.3</td><td>31.1</td></tr><tr><td>Frostbite</td><td>65.2</td><td>4334.7</td><td>255.0</td><td>296.3</td><td>236.9</td><td>1226.5</td><td>1014.2</td><td>1170.7</td><td>259.1</td></tr><tr><td>Gopher</td><td>257.6</td><td>2412.5</td><td>1256.0</td><td>3260.3</td><td>596.8</td><td>400.9</td><td>621.6</td><td>660.6</td><td>2236.1</td></tr><tr><td>Hero</td><td>1027.0</td><td>30826.4</td><td>3095.0</td><td>9315.9</td><td>2656.6</td><td>4987.7</td><td>4167.9</td><td>5858.6</td><td>7037.4</td></tr><tr><td>Jamesbond</td><td>29.0</td><td>302.8</td><td>87.5</td><td>517.0</td><td>100.5</td><td>331.0</td><td>349.1</td><td>366.5</td><td>462.7</td></tr><tr><td>Kangaroo</td><td>52.0</td><td>3035.0</td><td>62.5</td><td>724.1</td><td>51.2</td><td>740.2</td><td>1088.4</td><td>3617.4</td><td>838.2</td></tr><tr><td>Krull</td><td>1598.0</td><td>2665.5</td><td>4890.8</td><td>5663.3</td><td>2204.8</td><td>3049.2</td><td>4402.1</td><td>3681.6</td><td>6616.4</td></tr><tr><td>KungFuMaster</td><td>258.5</td><td>22736.3</td><td>18813.0</td><td>30944.8</td><td>14862.5</td><td>8155.6</td><td>11467.4</td><td>14783.2</td><td>21759.8</td></tr><tr><td>MsPacman</td><td>307.3</td><td>6951.6</td><td>1265.6</td><td>1281.2</td><td>1480.0</td><td>1064.0</td><td>1218.1</td><td>1318.4</td><td>999.1</td></tr><tr><td>Pong</td><td>-20.7</td><td>14.6</td><td>-6.7</td><td>20.1</td><td>12.8</td><td>-18.5</td><td>-9.1</td><td>-5.4</td><td>14.6</td></tr><tr><td>PrivateEye</td><td>24.9</td><td>69571.3</td><td>56.3</td><td>96.7</td><td>35.0</td><td>81.9</td><td>3.5</td><td>86.0</td><td>100.0</td></tr><tr><td>Qbert</td><td>163.9</td><td>13455.0</td><td>3952.0</td><td>13781.9</td><td>1288.8</td><td>727.0</td><td>1810.7</td><td>866.3</td><td>745.7</td></tr><tr><td>RoadRunner</td><td>11.5</td><td>7845.0</td><td>2500.0</td><td>17751.3</td><td>5640.6</td><td>5006.1</td><td>11211.4</td><td>12213.1</td><td>9614.6</td></tr><tr><td>Seaquest</td><td>68.4</td><td>42054.7</td><td>208.0</td><td>1100.2</td><td>683.3</td><td>315.2</td><td>352.3</td><td>558.1</td><td>661.3</td></tr><tr><td>UpNDown</td><td>533.4</td><td>11693.2</td><td>2896.9</td><td>17264.2</td><td>3350.3</td><td>2646.4</td><td>4324.5</td><td>10859.2</td><td>3546.2</td></tr><tr><td>#Superhuman (↑)</td><td>0</td><td>N/A</td><td>5</td><td>14</td><td>1</td><td>2</td><td>3</td><td>6</td><td>10</td></tr><tr><td>Mean (↑)</td><td>0.000</td><td>1.000</td><td>0.562</td><td>1.943</td><td>0.332</td><td>0.261</td><td>0.465</td><td>0.616</td><td>1.046</td></tr><tr><td>Median (↑)</td><td>0.000</td><td>1.000</td><td>0.227</td><td>1.090</td><td>0.134</td><td>0.092</td><td>0.313</td><td>0.396</td><td>0.289</td></tr><tr><td>IQM (↑)</td><td>0.000</td><td>1.000</td><td>N/A</td><td>N/A</td><td>0.130</td><td>0.113</td><td>0.280</td><td>0.337</td><td>0.501</td></tr><tr><td>Optimality Gap (↓)</td><td>1.000</td><td>0.000</td><td>N/A</td><td>N/A</td><td>0.729</td><td>0.768</td><td>0.631</td><td>0.577</td><td>0.512</td></tr></table>
94
+
95
+ # 3.1 BENCHMARK AND BASELINES
96
+
97
+ Atari $1 0 0 \mathrm { k }$ consists of 26 Atari games (Bellemare et al., 2013a) with various mechanics, evaluating a wide range of agent capabilities. In this benchmark, an agent is only allowed $1 0 0 \mathrm { k }$ actions in each environment. This constraint is roughly equivalent to 2 hours of human gameplay. By way of comparison, unconstrained Atari agents are usually trained for 50 million steps, a 500 fold increase in experience.
98
+
99
+ Multiple baselines were compared on the Atari $1 0 0 \mathrm { k }$ benchmark. SimPLe (Kaiser et al., 2020) trains a policy with PPO (Schulman et al., 2017) in a video generation model. CURL (Laskin et al., 2020) develops off-policy agents from high-level image features obtained with contrastive learning. DrQ (Yarats et al., 2021) augments input images and averages Q-value estimates over several transformations. SPR (Schwarzer et al., 2021) enforces consistent representations of input images across augmented views and neighbouring time steps. The aforementioned baselines carry additional techniques to improve performance, such as prioritized experience replay (Schaul et al., 2016), epsilon-greedy scheduling, or data augmentation.
100
+
101
+ We make a distinction between methods with and without lookahead search. Indeed, algorithms relying on search at decision time (Silver et al., 2016; 2018; Schrittwieser et al., 2020) can vastly improve agent performance, but they come at a premium in computational resources and code complexity. MuZero (Schrittwieser et al., 2020) and EfficientZero (Ye et al., 2021) are the current standard for search-based methods in Atari 100k. MuZero leverages Monte Carlo Tree Search (MCTS) (Kocsis & Szepesvári, 2006; Coulom, 2007) as a policy improvement operator, by unrolling multiple hypothetical trajectories in the latent space of a world model. EfficientZero improves upon MuZero by introducing a self-supervised consistency loss, predicting returns over short horizons in one shot, and correcting off-policy trajectories with its world model.
102
+
103
+ ![](images/ca7e5d04425677b6749a6330b5e40609554692de8dd4f2bacccead0c45322d21.jpg)
104
+ Figure 5: Mean, median, and interquartile mean human normalized scores, computed with stratified bootstrap confidence intervals. 5 runs for IRIS and SimPLe, 100 runs for SPR, CURL, and $_ \mathrm { D r Q }$ (Agarwal et al., 2021).
105
+
106
+ ![](images/e8907b9ad2ffe6c7768e78221a70f85c1653a0f8857bf48919d84c54e74b7c87.jpg)
107
+
108
+ ![](images/63aae36330bd375d4ff6d603ec2fe857fae857cb9cbba47d4cd2d259d61667f6.jpg)
109
+
110
+ (a) Performance profiles, i.e. fraction of runs above a given human normalized score.
111
+
112
+ (b) Probabilities of improvement, i.e. how likely it is for IRIS to outperform baselines on any game.
113
+
114
+ Figure 6: Performance profiles (left) and probabilities of improvement (right) (Agarwal et al., 2021).
115
+
116
+ # 3.2 RESULTS
117
+
118
+ The human normalized score is the established measure of performance in Atari 100k. It is defined as $\frac { s c o r e _ { - } a g e n t - s c o r e _ { - } r a n d o m } { s c o r e _ { - } h u m a n - s c o r e _ { - } r a n d o m }$ , where score_random comes from a random policy, and score_human is obtained from human players (Wang et al., 2016).
119
+
120
+ Table 1 displays returns across games and human-normalized aggregate metrics. For MuZero and EfficientZero, we report the averaged results published by Ye et al. (2021) (3 runs). We use results from the Atari 100k case study conducted by Agarwal et al. (2021) for the other baselines (100 new runs for CURL, DrQ, SPR, and 5 existing runs for SimPLe). Finally, we evaluate IRIS by computing an average over 100 episodes collected at the end of training for each game (5 runs).
121
+
122
+ Agarwal et al. (2021) discuss the limitations of mean and median scores, and show that substantial discrepancies arise between standard point estimates and interval estimates in RL benchmarks. Following their recommendations, we summarize in Figure 5 the human normalized scores with stratified bootstrap confidence intervals for mean, median, and interquartile mean (IQM). For finer comparisons, we also provide performance profiles and probabilities of improvement in Figure 6.
123
+
124
+ With the equivalent of only two hours of gameplay, IRIS achieves a superhuman mean score of 1.046 $( + 7 0 \% )$ , an IQM of 0.501 $( + 4 9 \% )$ , an optimality gap of 0.512 $( + 1 1 \% )$ , and outperforms human players on 10 out of 26 games $( + 6 7 \% )$ , where the relative improvements are computed with respect to SPR (Schwarzer et al., 2021). These results constitute a new state of the art for methods without lookahead search in the Atari 100k benchmark. We also note that IRIS outperforms MuZero, although the latter was not designed for the sample-efficient regime.
125
+
126
+ ![](images/b79b3711c6ebcd8a035be66b49570f1b820306b9d86c63bb14fc07c7b9212939.jpg)
127
+ Figure 7: Three consecutive levels in the games Frostbite (left) and Krull (right). In our experiments, the world model struggles to simulate subsequent levels in Frostbite, but not in Krull. Indeed, exiting the first level in Frostbite requires a long and unlikely sequence of actions to first build the igloo, and then go back to it from the bottom of the screen. Such rare events prevent the world model from internalizing new aspects of the game, which will therefore not be experienced by the policy in imagination. While Krull features more diverse levels, the world model successfully reflects this variety, and IRIS even sets a new state of the art in this environment. This is likely due to more frequent transitions from one stage to the next in Krull, resulting in a sufficient coverage of each level.
128
+
129
+ In addition, performance profiles (Figure 6a) reveal that IRIS is on par with the strongest baselines for its bottom $50 \%$ of games, at which point it stochastically dominates (Agarwal et al., 2021; Dror et al., 2019) the other methods. Similarly, the probability of improvement is greater than 0.5 for all baselines (Figure 6b).
130
+
131
+ In terms of median score, IRIS overlaps with other methods (Figure 5). Interestingly, Schwarzer et al. (2021) note that the median is only influenced by a few decisive games, as evidenced by the width of the confidence intervals for median scores, even with 100 runs for DrQ, CURL and SPR.
132
+
133
+ We observe that IRIS is particularly strong in games that do not suffer from distributional shifts as the training progresses. Examples of such games include Pong, Breakout, and Boxing. On the contrary, the agent struggles when a new level or game mechanic is unlocked through an unlikely event. This sheds light on a double exploration problem. IRIS has to first discover a new aspect of the game for its world model to internalize it. Only then may the policy rediscover and exploit it. Figure 7 details this phenomenon in Frostbite and Krull, two games with multiple levels. In summary, as long as transitions between levels do not depend on low-probability events, the double exploration problem does not hinder performance.
134
+
135
+ Another kind of games difficult to simulate are visually challenging environments where capturing small details is important. As discussed in Appendix E, increasing the number of tokens to encode frames improves performance, albeit at the cost of increased computation.
136
+
137
+ # 3.3 WORLD MODEL ANALYSIS
138
+
139
+ As IRIS learns behaviors entirely in its imagination, the quality of the world model is the cornerstone of our approach. For instance, it is key that the discrete autoencoder correctly reconstructs elements like a ball, a player, or an enemy. Similarly, the potential inability of the Transformer to capture important game mechanics, like reward attribution or episode termination, can severely hamper the agent’s performance. Hence, no matter the amount of imagined trajectories, the agent will learn suboptimal policies if the world model is flawed.
140
+
141
+ While Section 3.2 provides a quantitative evaluation, we aim to complement the analysis with qualitative examples of the abilities of the world model. Figure 2 shows the generation of many plausible futures in the face of uncertainty. Figure 3 depicts pixel-perfect predictions in Pong. Finally, we illustrate in Figure 4 predictions for rewards and episode terminations, which are crucial to the reinforcement learning objective.
142
+
143
+ # 4 RELATED WORK
144
+
145
+ # LEARNING IN THE IMAGINATION OF WORLD MODELS
146
+
147
+ The idea of training policies in a learnt model of the world was first investigated in tabular environments (Sutton & Barto, 2018). Ha & Schmidhuber (2018) showed that simple visual environments could be simulated with autoencoders and recurrent networks. SimPLe (Kaiser et al., 2020) demonstrated that a PPO policy (Schulman et al., 2017) trained in a video prediction model outperformed humans in some Atari games. Improving upon Dreamer (Hafner et al., 2020), DreamerV2 (Hafner et al., 2021) was the first agent learning in imagination to achieve human-level performance in the Atari 50M benchmark. Its world model combines a convolutional autoencoder with a recurrent state-space model (RSSM) (Hafner et al., 2019) for latent dynamics learning. More recently, Chen et al. (2022) explored a variant of DreamerV2 where a Transformer replaces the recurrent network in the RSSM and Seo et al. (2022) enhance DreamerV2 in the setting where an offline dataset of videos is available for pretraining.
148
+
149
+ # REINFORCEMENT LEARNING WITH TRANSFORMERS
150
+
151
+ Following spectacular advances in natural language processing (Manning & Goldie, 2022), the reinforcement learning community has recently stepped into the realm of Transformers. Parisotto et al. (2020) make the observation that the standard Transformer architecture is difficult to optimize with RL objectives. The authors propose to replace residual connections by gating layers to stabilize the learning procedure. Our world model does not require such modifications, which is most likely due to its self-supervised learning objective. The Trajectory Transformer (Janner et al., 2021) and the Decision Transformer (Chen et al., 2021) represent offline trajectories as a static dataset of sequences, and the Online Decision Transformer (Zheng et al., 2022) extends the latter to the online setting. The Trajectory Transformer is trained to predict future returns, states and actions. At inference time, it can thus plan for the optimal action with a reward-driven beam search, yet the approach is limited to low-dimensional states. On the contrary, Decision Transformers can handle image inputs but cannot be easily extended as world models. Ozair et al. (2021) introduce an offline variant of MuZero (Schrittwieser et al., 2020) capable of handling stochastic environments by performing an hybrid search with a Transformer over both actions and trajectory-level discrete latent variables.
152
+
153
+ # IDEO GENERATION WITH DISCRETE AUTOENCODERS AND TRANSFORMER
154
+
155
+ VQGAN (Esser et al., 2021) and DALL-E (Ramesh et al., 2021) use discrete autoencoders to compress a frame into a small sequence of tokens, that a transformer can then model autoregressively. Other works extend the approach to video generation. GODIVA (Wu et al., 2021) models sequences of frames instead of a single frame for text conditional video generation. VideoGPT (Yan et al., 2021) introduces video-level discrete autoencoders, and Transformers with spatial and temporal attention patterns, for unconditional and action conditional video generation.
156
+
157
+ # 5 CONCLUSION
158
+
159
+ We introduced IRIS, an agent that learns purely in the imagination of a world model composed of a discrete autoencoder and an autoregressive Transformer. IRIS sets a new state of the art in the Atari $1 0 0 \mathrm { k }$ benchmark for methods without lookahead search. We showed that its world model acquires a deep understanding of game mechanics, resulting in pixel perfect predictions in some games. We also illustrated the generative capabilities of the world model, providing a rich gameplay experience when training in imagination. Ultimately, with minimal tuning compared to existing battle-hardened agents, IRIS opens a new path towards efficiently solving complex environments.
160
+
161
+ In the future, IRIS could be scaled up to computationally demanding and challenging tasks that would benefit from the speed of its world model. Besides, its policy currently learns from reconstructed frames, but it could probably leverage the internal representations of the world model. Another exciting avenue of research would be to combine learning in imagination with MCTS. Indeed, both approaches deliver impressive results, and their contributions to agent performance might be complementary.
162
+
163
+ # REPRODUCIBILITY STATEMENT
164
+
165
+ The different components and their training objectives are introduced in Section 2 and Appendix B. We describe model architectures and list hyperparameters in Appendix A. We specify the resources used to produce our results in Appendix G. Algorithm 1 makes explicit the interplay between components in the training loop. In Section 3.2, we provide the source of the reported results for the baselines, as well as the evaluation protocol.
166
+
167
+ The code is part of the supplementary materials, and will be open-sourced to ensure reproducible results and foster future research. Minimal dependencies are required to run the codebase and we provide a thorough user guide to get started. Training and evaluation can be launched with simple commands, customization is possible with configuration files, and we include scripts to visualize agents playing and let users interact with the world model.
168
+
169
+ # ETHICS STATEMENT
170
+
171
+ The development of autonomous agents for real-world environments raises many safety and environmental concerns. During its training period, an agent may cause serious harm to individuals and damage its surroundings. It is our belief that learning in the imagination of world models greatly reduces the risks associated with training new autonomous agents. Indeed, in this work, we propose a world model architecture capable of accurately modeling environments with very few samples. However, in a future line of research, one could go one step further and leverage existing data to eliminate the necessity of interacting with the real world.
172
+
173
+ # ACKNOWLEDGMENTS
174
+
175
+ We would like to thank Maxim Peter, Bálint Máté, Daniele Paliotta, Atul Sinha, and Alexandre Dupuis for insightful discussions and comments. Vincent Micheli was supported by the Swiss National Science Foundation under grant number FNS-187494.
176
+
177
+ # REFERENCES
178
+
179
+ Rishabh Agarwal, Max Schwarzer, Pablo Samuel Castro, Aaron C Courville, and Marc Bellemare. Deep reinforcement learning at the edge of the statistical precipice. Advances in neural information processing systems, 34:29304–29320, 2021.
180
+
181
+ Marc G Bellemare, Yavar Naddaf, Joel Veness, and Michael Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47: 253–279, 2013a.
182
+
183
+ Marc G Bellemare, Yavar Naddaf, Joel Veness, and Michael Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47: 253–279, 2013b.
184
+
185
+ Yoshua Bengio, Nicholas Léonard, and Aaron Courville. Estimating or propagating gradients through stochastic neurons for conditional computation. arXiv preprint arXiv:1308.3432, 2013.
186
+
187
+ Christopher Berner, Greg Brockman, Brooke Chan, Vicki Cheung, Przemysław D˛ebiak, Christy Dennison, David Farhi, Quirin Fischer, Shariq Hashme, Chris Hesse, et al. Dota 2 with large scale deep reinforcement learning. arXiv preprint arXiv:1912.06680, 2019.
188
+
189
+ Noam Brown, Anton Bakhtin, Adam Lerer, and Qucheng Gong. Combining deep reinforcement learning and search for imperfect-information games. Advances in neural information processing systems, 33:17057–17069, 2020a.
190
+
191
+ 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, 2020b.
192
+
193
+ Chang Chen, Yi-Fu Wu, Jaesik Yoon, and Sungjin Ahn. Transdreamer: Reinforcement learning with transformer world models. arXiv preprint arXiv:2202.09481, 2022.
194
+
195
+ Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Misha Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. Advances in neural information processing systems, 34, 2021.
196
+
197
+ Rémi Coulom. Computing “elo ratings” of move patterns in the game of go. ICGA journal, 30(4): 198–208, 2007.
198
+
199
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), 2019.
200
+
201
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021.
202
+
203
+ Rotem Dror, Segev Shlomov, and Roi Reichart. Deep dominance-how to properly compare deep neural models. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 2773–2785, 2019.
204
+
205
+ Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12873–12883, 2021.
206
+
207
+ F. A. Gers, J. Schmidhuber, and F. Cummins. Learning to forget: Continual prediction with LSTM. Neural Computation, 12(10):2451–2471, 2000.
208
+
209
+ David Ha and Jürgen Schmidhuber. Recurrent world models facilitate policy evolution. Advances in neural information processing systems, 31, 2018.
210
+
211
+ Danijar Hafner. Benchmarking the spectrum of agent capabilities. In International Conference on Learning Representations, 2022.
212
+
213
+ Danijar Hafner, Timothy Lillicrap, Ian Fischer, Ruben Villegas, David Ha, Honglak Lee, and James Davidson. Learning latent dynamics for planning from pixels. In International conference on machine learning, pp. 2555–2565. PMLR, 2019.
214
+
215
+ Danijar Hafner, Timothy Lillicrap, Jimmy Ba, and Mohammad Norouzi. Dream to control: Learning behaviors by latent imagination. In International Conference on Learning Representations, 2020.
216
+
217
+ Danijar Hafner, Timothy P Lillicrap, Mohammad Norouzi, and Jimmy Ba. Mastering atari with discrete world models. In International Conference on Learning Representations, 2021.
218
+
219
+ Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16000–16009, 2022.
220
+
221
+ Matteo Hessel, Joseph Modayil, Hado Van Hasselt, Tom Schaul, Georg Ostrovski, Will Dabney, Dan Horgan, Bilal Piot, Mohammad Azar, and David Silver. Rainbow: Combining improvements in deep reinforcement learning. In Thirty-second AAAI conference on artificial intelligence, 2018.
222
+
223
+ Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Computation, 9(8): 1735–1780, 1997.
224
+
225
+ Michael Janner, Qiyang Li, and Sergey Levine. Offline reinforcement learning as one big sequence modeling problem. Advances in neural information processing systems, 34, 2021.
226
+
227
+ 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.
228
+
229
+ Łukasz Kaiser, Mohammad Babaeizadeh, Piotr Miłos, Błazej Osi ˙ nski, Roy H Campbell, Konrad ´ Czechowski, Dumitru Erhan, Chelsea Finn, Piotr Kozakowski, Sergey Levine, et al. Model based reinforcement learning for atari. In International Conference on Learning Representations, 2020.
230
+
231
+ Anssi Kanervisto, Stephanie Milani, Karolis Ramanauskas, Nicholay Topin, Zichuan Lin, Junyou Li, Jianing Shi, Deheng Ye, Qiang Fu, Wei Yang, Weijun Hong, Zhongyue Huang, Haicheng Chen, Guangjun Zeng, Yue Lin, Vincent Micheli, Eloi Alonso, François Fleuret, Alexander Nikulin, Yury Belousov, Oleg Svidchenko, and Aleksei Shpilman. Minerl diamond 2021 competition: Overview, results, and lessons learned. In Proceedings of the NeurIPS 2021 Competitions and Demonstrations Track, Proceedings of Machine Learning Research, 2022. URL https://proceedings.mlr. press/v176/kanervisto22a.html.
232
+
233
+ Steven Kapturowski, Georg Ostrovski, John Quan, Remi Munos, and Will Dabney. Recurrent experience replay in distributed reinforcement learning. In International conference on learning representations, 2019.
234
+
235
+ Andrej Karpathy. minGPT: A minimal PyTorch re-implementation of the OpenAI GPT (Generative Pretrained Transformer) training, 2020. URL https://github.com/karpathy/minGPT.
236
+
237
+ Levente Kocsis and Csaba Szepesvári. Bandit based monte-carlo planning. In European conference on machine learning, 2006.
238
+
239
+ Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 66–71, 2018.
240
+
241
+ Anders Boesen Lindbo Larsen, Søren Kaae Sønderby, Hugo Larochelle, and Ole Winther. Autoencoding beyond pixels using a learned similarity metric. In International conference on machine learning, pp. 1558–1566. PMLR, 2016.
242
+
243
+ Michael Laskin, Aravind Srinivas, and Pieter Abbeel. CURL: Contrastive unsupervised representations for reinforcement learning. In International Conference on Machine Learning, pp. 5639–5650. PMLR, 2020.
244
+
245
+ Yann LeCun, Bernhard Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne Hubbard, and Lawrence D Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1(4):541–551, 1989.
246
+
247
+ Christopher Manning and Anna Goldie. Cs224n natural language processing with deep learning, 2022.
248
+
249
+ 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.
250
+
251
+ Volodymyr Mnih, Adria Puigdomenech Badia, Mehdi Mirza, Alex Graves, Timothy Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International conference on machine learning, pp. 1928–1937. PMLR, 2016.
252
+
253
+ Sherjil Ozair, Yazhe Li, Ali Razavi, Ioannis Antonoglou, Aaron Van Den Oord, and Oriol Vinyals. Vector quantized models for planning. In International Conference on Machine Learning, pp. 8302–8313. PMLR, 2021.
254
+
255
+ Emilio Parisotto, Francis Song, Jack Rae, Razvan Pascanu, Caglar Gulcehre, Siddhant Jayakumar, Max Jaderberg, Raphael Lopez Kaufman, Aidan Clark, Seb Noury, et al. Stabilizing transformers for reinforcement learning. In International Conference on Machine Learning, pp. 7487–7498. PMLR, 2020.
256
+
257
+ Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training, 2018.
258
+
259
+ Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners, 2019.
260
+
261
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21:1–67, 2020.
262
+
263
+ Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pp. 8821–8831. PMLR, 2021.
264
+
265
+ Tom Schaul, John Quan, Ioannis Antonoglou, and David Silver. Prioritized experience replay. In International Conference on Learning Representations, 2016.
266
+
267
+ Martin Schmid, Matej Moravcik, Neil Burch, Rudolf Kadlec, Josh Davidson, Kevin Waugh, Nolan Bard, Finbarr Timbers, Marc Lanctot, Zach Holland, et al. Player of games. arXiv preprint arXiv:2112.03178, 2021.
268
+
269
+ Julian Schrittwieser, Ioannis Antonoglou, Thomas Hubert, Karen Simonyan, L. 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. Nature, 588(7839): 604–609, 2020.
270
+
271
+ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
272
+
273
+ Mike Schuster and Kaisuke Nakajima. Japanese and korean voice search. In 2012 IEEE international conference on acoustics, speech and signal processing (ICASSP), pp. 5149–5152. IEEE, 2012.
274
+
275
+ Max Schwarzer, Ankesh Anand, Rishab Goel, R Devon Hjelm, Aaron Courville, and Philip Bachman. Data-efficient reinforcement learning with self-predictive representations. In International Conference on Learning Representations, 2021.
276
+
277
+ Younggyo Seo, Kimin Lee, Stephen L James, and Pieter Abbeel. Reinforcement learning with actionfree pre-training from videos. In International Conference on Machine Learning, pp. 19561–19579. PMLR, 2022.
278
+
279
+ 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.
280
+
281
+ David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, et al. A general reinforcement learning algorithm that masters chess, shogi, and go through self-play. Science, 362(6419): 1140–1144, 2018.
282
+
283
+ Richard S. Sutton and Andrew G. Barto. Reinforcement Learning: An Introduction. A Bradford Book, Cambridge, MA, USA, 2018.
284
+
285
+ Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. Advances in neural information processing systems, 30, 2017.
286
+
287
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
288
+
289
+ Oriol Vinyals, Igor Babuschkin, Wojciech M Czarnecki, Michaël Mathieu, Andrew Dudzik, Junyoung Chung, David H Choi, Richard Powell, Timo Ewalds, Petko Georgiev, et al. Grandmaster level in StarCraft II using multi-agent reinforcement learning. Nature, 575(7782):350–354, 2019.
290
+
291
+ Ziyu Wang, Tom Schaul, Matteo Hessel, Hado Hasselt, Marc Lanctot, and Nando Freitas. Dueling network architectures for deep reinforcement learning. In International conference on machine learning, pp. 1995–2003. PMLR, 2016.
292
+
293
+ Chenfei Wu, Lun Huang, Qianxi Zhang, Binyang Li, Lei Ji, Fan Yang, Guillermo Sapiro, and Nan Duan. Godiva: Generating open-domain videos from natural descriptions. arXiv preprint arXiv:2104.14806, 2021.
294
+
295
+ Roman V Yampolskiy. Artificial Intelligence Safety and Security. Chapman & Hall/CRC, 2018.
296
+
297
+ Wilson Yan, Yunzhi Zhang, Pieter Abbeel, and Aravind Srinivas. Videogpt: Video generation using vq-vae and transformers. arXiv preprint arXiv:2104.10157, 2021.
298
+
299
+ Denis Yarats, Ilya Kostrikov, and Rob Fergus. Image augmentation is all you need: Regularizing deep reinforcement learning from pixels. In International Conference on Learning Representations, 2021.
300
+
301
+ Weirui Ye, Shaohuai Liu, Thanard Kurutach, Pieter Abbeel, and Yang Gao. Mastering atari games with limited data. Advances in neural information processing systems, 34, 2021.
302
+
303
+ Qinqing Zheng, Amy Zhang, and Aditya Grover. Online decision transformer. In International Conference on Machine Learning, pp. 27042–27059. PMLR, 2022.
304
+
305
+ # A MODELS AND HYPERPARAMETERS
306
+
307
+ # A.1 DISCRETE AUTOENCODER
308
+
309
+ Our discrete autoencoder is based on the implementation of VQGAN (Esser et al., 2021). We removed the discriminator, essentially turning the VQGAN into a vanilla VQVAE (Van Den Oord et al., 2017) with an additional perceptual loss (Johnson et al., 2016; Larsen et al., 2016).
310
+
311
+ The training objective is the following:
312
+
313
+ $$
314
+ \begin{array} { r } { \dot { z } ( E , D , \mathcal { E } ) = \left\| x - D ( z ) \right\| _ { 1 } + \left\| \operatorname { s g } ( E ( x ) ) - \mathcal { E } ( z ) \right\| _ { 2 } ^ { 2 } + \left\| \operatorname { s g } ( \mathcal { E } ( z ) ) - E ( x ) \right\| _ { 2 } ^ { 2 } + \mathcal { L } _ { p e r c e p t u a l } ( x , D ( z ) ) } \end{array}
315
+ $$
316
+
317
+ Here, the first term is the reconstruction loss, the next two terms constitute the commitment loss (where $\operatorname { s g } ( \cdot )$ is the stop-gradient operator), and the last term is the perceptual loss.
318
+
319
+ Table 2: Encoder / Decoder hyperparameters. We list the hyperparameters for the encoder, the same ones apply for the decoder.
320
+
321
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Frame dimensions (h,w)</td><td>64 × 64</td></tr><tr><td>Layers</td><td>4</td></tr><tr><td>Residual blocks per layer</td><td>2</td></tr><tr><td>Channels in convolutions</td><td>64</td></tr><tr><td>Self-attention layers at resolution</td><td>8/16</td></tr></table>
322
+
323
+ Table 3: Embedding table hyperparameters.
324
+
325
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Vocabulary size (N)</td><td>512</td></tr><tr><td>Tokens per frame (K)</td><td>16</td></tr><tr><td>Token embedding dimension (d)</td><td>512</td></tr></table>
326
+
327
+ Note that during experience collection in the real environment, frames still go through the autoencoder to keep the input distribution of the policy unchanged. See Algorithm 1 for details.
328
+
329
+ # A.2 TRANSFORMER
330
+
331
+ Our autoregressive Transformer is based on the implementation of minGPT (Karpathy, 2020). It takes as input a sequence of $L ( K + 1 )$ tokens and embeds it into a $L ( K + 1 ) \times D$ tensor using an $A \times D$ embedding table for actions, and a $N \times D$ embedding table for frames tokens. This tensor is forwarded through $M$ Transformer blocks. We use GPT2-like blocks (Radford et al., 2019), i.e. each block consists of a self-attention module with layer normalization of the input, wrapped with a residual connection, followed by a per-position multi-layer perceptron with layer normalization of the input, wrapped with another residual connection.
332
+
333
+ Table 4: Transformer hyperparameters
334
+
335
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Timesteps (L)</td><td>20</td></tr><tr><td>Embedding dimension (D)</td><td>256</td></tr><tr><td>Layers (M)</td><td>10</td></tr><tr><td>Attention heads</td><td>4</td></tr><tr><td>Weight decay</td><td>0.01</td></tr><tr><td>Embedding dropout</td><td>0.1</td></tr><tr><td>Attention dropout</td><td>0.1</td></tr><tr><td>Residual dropout</td><td>0.1</td></tr></table>
336
+
337
+ # A.3 ACTOR-CRITIC
338
+
339
+ The weights of the actor and critic are shared except for the last layer. The actor-critic takes as input a $6 4 \times 6 4 \times 3$ frame, and forwards it through a convolutional block followed by an LSTM cell (Mnih et al., 2016; Hochreiter & Schmidhuber, 1997; Gers et al., 2000). The convolutional block consists of the same layer repeated four times: a 3x3 convolution with stride 1 and padding 1, a ReLU activation, and $2 \mathbf { x } 2$ max-pooling with stride 2. The dimension of the LSTM hidden state is 512. Before starting the imagination procedure from a given frame, we burn-in (Kapturowski et al., 2019) the 20 previous frames to initialize the hidden state.
340
+
341
+ Table 5: Training loop & Shared hyperparameters
342
+
343
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Epochs # Collection epochs Environment steps per epoch</td><td>600 500</td></tr><tr><td>Collection epsilon-greedy Eval sampling temperature Start autoencoder after epochs Start transformer after epochs Start actor-critic after epochs Autoencoder batch size Transformer batch size</td><td>200 0.01 0.5 5 25 50 256 64</td></tr><tr><td>Actor-critic batch size Training steps per epoch Learning rate Optimizer Adam β1 Adam β2 Max gradient norm</td><td>64 200 1e-4 Adam 0.9 0.999 10.0</td></tr></table>
344
+
345
+ # B ACTOR-CRITIC LEARNING OBJECTIVES
346
+
347
+ We follow Dreamer (Hafner et al., 2020; 2021) in using the generic $\lambda$ -return, that balances bias and variance, as the regression target for the value network. Given an imagined trajectory $( \hat { x } _ { 0 } , a _ { 0 } , \hat { r } _ { 0 } , \hat { d } _ { 0 } , \dots , \hat { x } _ { H - 1 } , a _ { H - 1 } , \hat { r } _ { H - 1 } , \hat { \dot { d } } _ { H - 1 } , \hat { x } _ { H } )$ , the $\lambda$ -return can be defined recursively as follows:
348
+
349
+ $$
350
+ \Lambda _ { t } = \left\{ \begin{array} { l l l } { \hat { r } _ { t } + \gamma ( 1 - \hat { d } _ { t } ) \Big [ ( 1 - \lambda ) V ( \hat { x } _ { t + 1 } ) + \lambda \Lambda _ { t + 1 } \Big ] } & { \mathrm { i f } } & { t < H } \\ { V ( \hat { x } _ { H } ) } & { \mathrm { i f } } & { t = H } \end{array} \right.
351
+ $$
352
+
353
+ The value network $V$ is trained to minimize ${ \mathcal { L } } _ { V }$ , the expected squared difference with $\lambda$ -returns over imagined trajectories.
354
+
355
+ $$
356
+ \mathcal { L } _ { V } = \mathbb { E } _ { \pi } \Big [ \sum _ { t = 0 } ^ { H - 1 } \big ( V ( \hat { x } _ { t } ) - \mathrm { s g } ( \Lambda _ { t } ) \big ) ^ { 2 } \Big ]
357
+ $$
358
+
359
+ Here, $\operatorname { s g } ( \cdot )$ denotes the gradient stopping operation, meaning that the target is a constant in the gradient-based optimization, as classically established in the literature (Mnih et al., 2015; Hessel et al., 2018; Hafner et al., 2020).
360
+
361
+ As large amounts of trajectories are generated in the imagination MDP, we can use a straightforward reinforcement learning objective for the policy, such as REINFORCE (Sutton & Barto, 2018). To reduce the variance of REINFORCE gradients, we use the value $V ( \hat { x } _ { t } )$ as a baseline (Sutton & Barto, 2018). We also add a weighted entropy maximization objective to maintain a sufficient exploration. The actor is trained to minimize the following REINFORCE objective over imagined trajectories:
362
+
363
+ $$
364
+ \mathcal { L } _ { \pi } = - \mathbb { E } _ { \pi } \Big [ \sum _ { t = 0 } ^ { H - 1 } \log ( \pi ( a _ { t } | \hat { x } _ { \le t } ) ) \mathrm { s g } ( \Lambda _ { t } - V ( \hat { x } _ { t } ) ) + \eta \mathcal { H } ( \pi ( a _ { t } | \hat { x } _ { \le t } ) ) \Big ]
365
+ $$
366
+
367
+ Table 6: RL training hyperparameters
368
+
369
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Imagination horizon (H)</td><td>20</td></tr><tr><td>Y</td><td>0.995</td></tr><tr><td>入</td><td>0.95</td></tr><tr><td>m</td><td>0.001</td></tr></table>
370
+
371
+ # C OPTIMALITY GAP
372
+
373
+ ![](images/c64a9e4bd73202ca0fbc593f6ed780aadb95d4bba0ccf138c0966f3fd4430366.jpg)
374
+ Figure 8: Optimality gap, lower is better. The amount by which the algorithm fails to reach a human-level score (Agarwal et al., 2021).
375
+
376
+ # D IRIS ALGORITHM
377
+
378
+ # Algorithm 1: IRIS
379
+
380
+ Procedure training_loop(): for epochs do collect_experience(steps_collect) for steps_world_model do update_world_model() for steps_behavior do update_behavior()
381
+
382
+ Procedure collect_experience $( n )$ : $x _ { 0 } \gets$ env.reset() for $t = 0$ to $n - 1$ do $\hat { x } _ { t } \gets D ( E ( x _ { t } ) )$ // forward frame through discrete autoencoder Sample $a _ { t } \sim \pi ( a _ { t } | \hat { x } _ { t } )$ $x _ { t + 1 } , r _ { t } , d _ { t } \gets \mathsf { e n v . s t e p } ( a _ { t } )$ if $d _ { t } = 1$ then $\lfloor x _ { t + 1 } \gets \mathrm { e n v . r e s e t \ ( ) }$ ) $\mathcal { D } \mathcal { D } \cup \{ x _ { t } , a _ { t } , r _ { t } , d _ { t } \} _ { t = 0 } ^ { n - 1 }$
383
+
384
+ Procedure update_world_model():
385
+
386
+ Sample Compu $\{ x _ { t } , a _ { t } , r _ { t } , d _ { t } \} _ { t = \tau } ^ { \tau + L - 1 } \sim \mathcal { D }$ for $z _ { t } : = E ( x _ { t } )$ $\hat { x } _ { t } : = D ( z _ { t } )$ $t = \tau , \dots , \tau + L - 1$
387
+ Update $E$ and $D$
388
+ Compute $p _ { G } ( \hat { z } _ { t + 1 } , \hat { r } _ { t } , \hat { d } _ { t } \mid z _ { \tau } , a _ { \tau } , \ldots , z _ { t } , a _ { t } ) \mathrm { f o r } t = \tau , \ldots , \tau + L - 1$
389
+ Update $G$
390
+
391
+ Procedure update_behavior():
392
+
393
+ Sample $x _ { 0 } \sim \mathcal { D }$
394
+ $z _ { 0 } \gets E ( x _ { 0 } )$
395
+ $\hat { x } _ { 0 } \gets D ( z _ { 0 } )$
396
+ for $t = 0$ to $H - 1$ do Sample $a _ { t } \sim \pi ( a _ { t } | \hat { x } _ { t } )$ Sample $\hat { z } _ { t + 1 } , \hat { r } _ { t } , \hat { d } _ { t } \sim p _ { G } ( \hat { z } _ { t + 1 } , \hat { r } _ { t } , \hat { d } _ { t } \mid z _ { 0 } , a _ { 0 } , \ldots , \hat { z } _ { t } , a _ { t } )$ $\hat { x } _ { t + 1 } \gets D ( \hat { z } _ { t + 1 } )$
397
+ Compute $V ( \hat { x } _ { t } )$ for $t = 0 , \ldots , H$
398
+ Update $\pi$ and $V$
399
+
400
+ The sequence length of the Transformer is determined by the number of tokens used to encode a single frame and the number of timesteps in memory. Increasing the number of tokens per frame results in better reconstructions, although it requires more compute and memory.
401
+
402
+ This tradeoff is particularly important in visually challenging games with a high number of possible configurations, where the discrete autoencoder struggles to properly encode frames with only 16 tokens. For instance, Figure 9 shows that, when increasing the number of tokens per frame to 64 in Alien, the discrete autoencoder correctly reconstructs the player, its enemies, and rewards.
403
+
404
+ ![](images/2cb1ad8ce9a69ae586c09a8d299af51d6d3bca617c48db3bbfb0c63ef72f5423.jpg)
405
+ Figure 9: Tradeoff between the number of tokens per frame and reconstructions quality in Alien. Each column displays a $6 4 \times 6 4$ frame from the real environment (top), its reconstruction with a discrete encoding of 16 tokens (center), and its reconstruction with a discrete encoding of 64 tokens (bottom). In Alien, the player is the dark blue character, and the enemies are the large colored sprites. With 16 tokens per frame, the autoencoder often erases the player, switches colors, and misplaces rewards. When increasing the amount of tokens, it properly reconstructs the frame.
406
+
407
+ Table 7 displays the final performance of IRIS trained with 64 tokens per frame in three games. Interestingly, even though the world model is more accurate, the performance in Alien only increases marginally $( + 3 6 \% )$ . This observation suggests that Alien poses a hard reinforcement learning problem, as evidenced by the low performance of other baselines in that game. On the contrary, IRIS greatly benefits from having more tokens per frame for Asterix $( + 1 2 1 \% )$ and BankHeist $( + 4 3 2 \% )$ ).
408
+
409
+ Table 7: Returns on Alien, Asterix, and BankHeist with 64 tokens per frame instead of 16.
410
+
411
+ <table><tr><td>Game</td><td>Random</td><td>Human</td><td>SimPLe</td><td>CURL</td><td>DrQ</td><td>SPR</td><td>IRIS (16 tokens)</td><td>IRIS (64 tokens)</td></tr><tr><td>Alien</td><td>227.8</td><td>7127.7</td><td>616.9</td><td>711.0</td><td>865.2</td><td>841.9</td><td>420.0</td><td>570.0</td></tr><tr><td>Asterix</td><td>210.0</td><td>8503.3</td><td>1128.3</td><td>567.2</td><td>763.6</td><td>962.5</td><td>853.6</td><td>1890.4</td></tr><tr><td>BankHeist</td><td>14.2</td><td>753.1</td><td>34.2</td><td>65.3</td><td>232.9</td><td>345.4</td><td>53.1</td><td>282.5</td></tr></table>
412
+
413
+ # F BEYOND THE SAMPLE-EFFICIENT SETTING
414
+
415
+ IRIS can be scaled up by increasing the number of tokens used to encode frames, adding capacity to the model, taking more optimization steps per environment steps, or using more data. In this experiment, we investigate data scaling properties by increasing the number of environment steps from $1 0 0 \mathrm { k }$ to 10M. However, to maintain a training time within our computational resources, we lower the ratio of optimization steps per environment steps from 1:1 to 1:50. As a consequence, the results of this experiment at $1 0 0 \mathrm { k }$ frames would be worse than those reported in the paper.
416
+
417
+ Table 8: Increasing the number of environment steps from 100k to 10M.
418
+
419
+ <table><tr><td>Game</td><td>Random</td><td>Human</td><td>IRIS (100k)</td><td>IRIS (10M)</td></tr><tr><td>Alien</td><td>227.8</td><td>7127.7</td><td>420.0</td><td>1003.1</td></tr><tr><td>Amidar</td><td>5.8</td><td>1719.5</td><td>143.0</td><td>213.4</td></tr><tr><td>Assault</td><td>222.4</td><td>742.0</td><td>1524.4</td><td>9355.6</td></tr><tr><td>Asterix</td><td>210.0</td><td>8503.3</td><td>853.6</td><td>6861.0</td></tr><tr><td>BankHeist</td><td>14.2</td><td>753.1</td><td>53.1</td><td>921.6</td></tr><tr><td>BattleZone</td><td>2360.0</td><td>37187.5</td><td>13074.0</td><td>34562.5</td></tr><tr><td>Boxing</td><td>0.1</td><td>12.1</td><td>70.1</td><td>98.0</td></tr><tr><td>Breakout</td><td>1.7</td><td>30.5</td><td>83.7</td><td>493.9</td></tr><tr><td>ChopperCommand</td><td>811.0</td><td>7387.8</td><td>1565.0</td><td>9814.0</td></tr><tr><td>CrazyClimber</td><td>10780.5</td><td>35829.4</td><td>59324.2</td><td>111068.8</td></tr><tr><td>DemonAttack</td><td>152.1</td><td>1971.0</td><td>2034.4</td><td>96218.6</td></tr><tr><td>Freeway</td><td>0.0</td><td>29.6</td><td>31.1</td><td>34.0</td></tr><tr><td>Frostbite</td><td>65.2</td><td>4334.7</td><td>259.1</td><td>290.3</td></tr><tr><td>Gopher</td><td>257.6</td><td>2412.5</td><td>2236.1</td><td>97370.6</td></tr><tr><td>Hero</td><td>1027.0</td><td>30826.4</td><td>7037.4</td><td>19212.0</td></tr><tr><td>Jamesbond</td><td>29.0</td><td>302.8</td><td>462.7</td><td>5534.4</td></tr><tr><td>Kangaroo</td><td>52.0</td><td>3035.0</td><td>838.2</td><td>1793.8</td></tr><tr><td>Krull</td><td>1598.0</td><td>2665.5</td><td>6616.4</td><td>7344.0</td></tr><tr><td>KungFuMaster</td><td>258.5</td><td>22736.3</td><td>21759.8</td><td>39643.8</td></tr><tr><td>MsPacman</td><td>307.3</td><td>6951.6</td><td>999.1</td><td>1233.0</td></tr><tr><td>Pong</td><td>-20.7</td><td>14.6</td><td>14.6</td><td>21.0</td></tr><tr><td>PrivateEye</td><td>24.9</td><td>69571.3</td><td>100.0</td><td>100.0</td></tr><tr><td>Qbert</td><td>163.9</td><td>13455.0</td><td>745.7</td><td>4012.1</td></tr><tr><td>RoadRunner</td><td>11.5</td><td>7845.0</td><td>9614.6</td><td>30609.4</td></tr><tr><td>Seaquest</td><td>68.4</td><td>42054.7</td><td>661.3</td><td>1815.0</td></tr><tr><td>UpNDown</td><td>533.4</td><td>11693.2</td><td>3546.2</td><td>114690.1</td></tr><tr><td>#Superhuman (↑)</td><td>0</td><td>N/A</td><td>10</td><td>15</td></tr><tr><td>Mean (↑)</td><td>0.000</td><td>1.000</td><td>1.046</td><td>7.488</td></tr><tr><td>Median (↑)</td><td>0.000</td><td>1.000</td><td>0.289</td><td>1.207</td></tr><tr><td>IQM (↑)</td><td>0.000</td><td>1.000</td><td>0.501</td><td>2.239</td></tr><tr><td>Optimality Gap (↓)</td><td>1.000</td><td>0.000</td><td>0.512</td><td>0.282</td></tr></table>
420
+
421
+ Table 8 illustrates that increasing the number of environment steps from $1 0 0 \mathrm { k }$ to 10M drastically improves performance for most games, providing evidence that IRIS could be scaled up beyond the sample-efficient regime. On some games, more data only yields marginal improvements, most likely due to hard exploration problems or visually challenging domains that would benefit from a higher number of tokens to encode frames (Appendix E).
422
+
423
+ # G COMPUTATIONAL RESOURCES
424
+
425
+ For each Atari environment, we repeatedly trained IRIS with 5 different random seeds. We ran our experiments with 8 Nvidia A100 40GB GPUs. With two Atari environments running on the same GPU, training takes around 7 days, resulting in an average of 3.5 days per environment.
426
+
427
+ SimPLe (Kaiser et al., 2020), the only baseline that involves learning in imagination, trains for 3 weeks with a P100 GPU on a single environment. As for SPR (Schwarzer et al., 2021), the strongest baseline without lookahead search, it trains notably fast in 4.6 hours with a P100 GPU.
428
+
429
+ Regarding baselines with lookahead search, MuZero (Schrittwieser et al., 2020) originally used 40 TPUs for 12 hours to train in a single Atari environment. Ye et al. (2021) train both EfficientZero and their reimplementation of MuZero in 7 hours with 4 RTX 3090 GPUs. EfficientZero’s implementation relies on a distributed infrastructure with CPU and GPU threads running in parallel, and a $\mathrm { C } { + } { + } I$ Cython implementation of MCTS. By contrast, IRIS and the baselines without lookahead search rely on straightforward single GPU / single CPU implementations.
430
+
431
+ # H EXPLORATION IN FREEWAY
432
+
433
+ The reward function in Freeway is sparse since the agent is only rewarded when it completely crosses the road. In addition, bumping into cars will drag it down, preventing it from smoothly ascending the highway. This poses an exploration problem for newly initialized agents because a random policy will almost surely never obtain a non-zero reward with a $1 0 0 \mathrm { k }$ frames budget.
434
+
435
+ ![](images/676fa0be6259e8d392e4880b54a96a08e8f9585755fcdad6d6d5346cb65c2b09.jpg)
436
+ Figure 10: A game of Freeway. Cars will bump the player down, making it very unlikely to cross the road and be rewarded for random policies.
437
+
438
+ The solution to this problem is actually straightforward and simply requires stretches of time when the UP action is oversampled. Most Atari $1 0 0 \mathrm { k }$ baselines fix the issue with epsilon-greedy schedules and argmax action selection, where at some point the network configuration will be such that the UP action is heavily favored. In this work, we opted for the simpler strategy of having a fixed epsilon-greedy parameter and sampling from the policy. However, we lowered the sampling temperature from 1 to 0.01 for Freeway, in order to avoid random walks that would not be conducive to learning in the early stages of training. As a consequence, once it received its first few rewards through exploration, IRIS was able to internalize the sparse reward function in its world model.
md/dev/vhKaBdOOobB/vhKaBdOOobB.md ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GhostNetV2: Enhance Cheap Operation with Long-Range Attention
2
+
3
+ Yehui Tang1,2, Kai $\mathbf { H a n } ^ { 2 }$ , Jianyuan $\mathbf { G u o } ^ { 2 , 3 }$ , Chang $\mathbf { X } \mathbf { u } ^ { 3 }$ , Chao $\mathbf { X } \mathbf { u } ^ { 1 }$ , Yunhe Wang2∗
4
+
5
+ 1School of Artificial Intelligence, Peking University 2Huawei Noah’s Ark Lab 3School of Computer Science, University of Sydney yhtang@pku.edu.cn, {kai.han, yunhe.wang} $@$ huawei.com
6
+
7
+ # Abstract
8
+
9
+ Light-weight convolutional neural networks (CNNs) are specially designed for applications on mobile devices with faster inference speed. The convolutional operation can only capture local information in a window region, which prevents performance from being further improved. Introducing self-attention into convolution can capture global information well, but it will largely encumber the actual speed. In this paper, we propose a hardware-friendly attention mechanism (dubbed DFC attention) and then present a new GhostNetV2 architecture for mobile applications. The proposed DFC attention is constructed based on fully-connected layers, which can not only execute fast on common hardware but also capture the dependence between long-range pixels. We further revisit the expressiveness bottleneck in previous GhostNet and propose to enhance expanded features produced by cheap operations with DFC attention, so that a GhostNetV2 block can aggregate local and long-range information simultaneously. Extensive experiments demonstrate the superiority of GhostNetV2 over existing architectures. For example, it achieves $7 5 . 3 \%$ top-1 accuracy on ImageNet with 167M FLOPs, significantly suppressing GhostNetV1 $( 7 4 . 5 \% )$ with a similar computational cost. The source code will be available at https://github.com/huawei-noah/Efficient-AI-Backbones/ tree/master/ghostnetv2_pytorch and https://gitee.com/mindspore/ models/tree/master/research/cv/ghostnetv2.
10
+
11
+ # 1 Introduction
12
+
13
+ In computer vision, the architecture of deep neural network plays a vital role for various tasks, such as image classification [19, 10], object detection [27, 26], and video analysis [18]. In the past decade, the network architecture has been evolving rapidly, and a series of milestones including AlexNet [19], GoogleNet [29], ResNet [10] and EfficientNet [32] have been developed. These networks have pushed the performances of a wide range of visual tasks to a high level.
14
+
15
+ To deploy neural networks on edge devices like smartphone and wearable devices, we need to consider not only the performance of a model, but also its efficiency especially the actual inference speed. Matrix multiplications occupy the main part of computational cost and parameters. Developing lightweight models is a promising approach to reduce the inference latency. MobileNet [13] factorizes a standard convolution into depthwise convolution and point-wise convolution, which reduces the computational cost drastically. MobileNetV2 [28] and MobileNetV3 [12] further introduce the inverted residual block and improve the network architecture. ShuffleNet [42] utilizes the shuffle operation to encourage the information exchange between channel groups. GhostNet [8] proposes the cheap operation to reduce feature redundancy in channels. WaveMLP [33] replaces the complex
16
+
17
+ ![](images/4dfb7db1276b674cd6b0dc84fddfb3b50171de63a502196b83216bbbee60dd74.jpg)
18
+ Figure 1: Top-1 accuracy vs.FLOPs on ImageNet Figure 2: Top-1 accuracy vs.latency on ImageNet dataset. dataset.
19
+
20
+ self-attention module with a simple Multi-Layer Perceptron (MLP) to reduce the computational cost.
21
+ These light-weight neural networks have been applied in many mobile applications.
22
+
23
+ Nevertheless, the convolution-based light-weight models are weak in modeling long-range dependency, which limits further performance improvement. Recently, transformer-like models are introduced to computer vision, in which the self-attention module can capture the global information. The typical self-attention module requires quadratic complexity w.r.t. the size of feature’s shape and is not computationally friendly. Moreover, plenty of feature splitting and reshaping operations are required to calculate the attention map. Though their theoretical complexity is negligible, these operations incur more memory usage and longer latency in practice. Thus, utilizing vanilla self-attention in light-weight models is not friendly for mobile deployment. For example, MobileViT with massive self-attention operations is more than $7 \times$ slower than MobileNetV2 on ARM devices [23].
24
+
25
+ In this paper, we propose a new attention mechanism (dubbed DFC attention) to capture the longrange spatial information, while keeping the implementation efficiency of light-weight convolutional neural networks. Only fully connected (FC) layers participate in generating the attention maps for simplicity. Specifically, a FC layer is decomposed into horizontal FC and vertical FC to aggregate pixels in a 2D feature map of CNN. The two FC layers involve pixels in a long range along their respective directions, and stacking them will produce a global receptive field. Moreover, starting from ate-of-the-art GhostNet, we revisit its representation bottleneck and enhance the intermediate features with the DFC attention. Then we construct a new light-weight vision backbone, GhostNetV2. Compared with the existing architectures, it can achieve a better tread-off between accuracy and inference speed (as shown in Figures 1 and 2).
26
+
27
+ # 2 Related Work
28
+
29
+ It is a challenge to design a light-weight neural architecture with fast inference speed and high performance simultaneously [16, 41, 13, 40, 35]. SqueezeNet [16] proposes three strategies to design a compact model, i.e., replacing $3 \times 3$ filters with $1 \times 1$ filers, decreasing the number of input channels to $3 x 3$ filters, and down-sampling late in the network to keep large feature maps. These principles are constructive, especially the usage of $1 \times 1$ convolution. MobileNetV1 [13] replaces almost all the $3 \times 3$ filers with $1 \times 1$ kernel and depth-wise separable convolutions, which dramatically reduces the computational cost. MobileNetV2 [28] further introduces the residual connection to the light-weight model, and constructs an inverted residual structure, where the intermediate layer of a block has more channels than its input and output. To keep representation ability, a part of non-linear functions are removed. MobileNeXt [44] rethinks the necessary of inverted bottleneck, and claims that the classic bottleneck structure can also achieve high performance. Considering the $1 \times 1$ convolution account for a substantial part of computational cost, ShuffleNet [42] replace it with group convolution. The channel shuffle operation to help the information flowing across different groups. By investigating the factors that affect the practical running speed, ShuffleNet V2 [22] proposes a hardware-friendly new block. By leveraging the feature’s redundancy, GhostNet [8] replaces half channels in $1 \times 1$ convolution with cheap operations. Until now, GhostNet has been the SOTA light-weight model with a good trade-off between accuracy and speed.
30
+
31
+ Besides manual design, a series of methods try to search for a light-weight architecture. For example, FBNet [39] designs a hardware-aware searching strategy, which can directly find a good trade-off between accuracy and speed on a specific hardware. Based on the inverted residual bottleneck, MnasNet [31], MobileNetV3 [12] search the architecture parameters,such as model width, model depth, convolutional filter’s size, etc. Though NAS based methods achieve high performance, their success is based on well-designed search spaces and architectural units. Automatic searching and manual design can be combined to find a better architecture.
32
+
33
+ # 3 Preliminary
34
+
35
+ # 3.1 A Brief Review of GhostNet
36
+
37
+ GhostNet [8] is SOTA light-weight model designed for efficient inference on mobile devices. Its main component is the Ghost module, which can replace the original convolution by generating more feature maps from cheap operations. Given input feature $X \in \mathbf { \mathbb { R } } ^ { H \times W \times C }$ with height $H$ , width $W$ and channel’s number $C$ , a typical Ghost module can replace a standard convolution by two steps. Firstly, a $1 \times 1$ convolution is used to generate the intrinsic feature, i.e.,
38
+
39
+ $$
40
+ Y ^ { \prime } = X * F _ { 1 \times 1 } ,
41
+ $$
42
+
43
+ where $^ *$ denotes the convolution operation. $F _ { 1 \times 1 }$ is the point-wise convolution, and $Y ^ { \prime } \in$ $\mathbb { R } ^ { H \times W \times C _ { o u t } ^ { \prime } }$ is the intrinsic features, whose sizes are usually smaller than the original output features, i.e., $C _ { o u t } ^ { \prime } < C _ { o u t }$ . Then cheap operations (e.g., depth-wise convolution) are used to generate more features based on the intrinsic features. The two parts of features are concatenated along the channel dimension, i.e.,
44
+
45
+ $$
46
+ Y = \mathrm { C o n c a t } ( [ Y ^ { \prime } , Y ^ { \prime } * F _ { d p } ] ) ,
47
+ $$
48
+
49
+ where $F _ { d p }$ is the depth-wise convolutional filter, and $Y \in \mathbb { R } ^ { H \times W \times C _ { o u t } }$ is the output feature. Though Ghost module can reduce the computational cost significantly, the representation ability is inevitably weakened. The relationship between spatial pixels is vital to make accurate recognition. While in GhostNet, the spatial information is only captured by the cheap operations (usually implemented by $3 \times 3$ depth-wise convolution) for half of the features. The remaining features are just produced by $1 \times 1$ point-wise convolution, without any interaction with other pixels. The weak ability to capture the spatial information may prevent performance from being further improved.
50
+
51
+ A block of GhostNet is constructed by stacking two Ghost modules (shown in Figure 4(a)). Similar to MobileNetV2 [28], it is also an inverted bottleneck, i.e., the first Ghost module acts as an expansion layer to increase the number of output channels, and the second Ghost module reduces the channels’ number to match the shortcut path.
52
+
53
+ # 3.2 Revisit Attention for Mobile Architecture
54
+
55
+ Originating from the NLP field [36], attention-based models are introduced to computer vision recently [6, 9, 34, 7]. For example, ViT [6] uses the standard transformer model stacked by self-attention modules and MLP modules. Wang et al.insert the selfattention operation into convolutional neural networks to capture the nonlocal information [37]. A typical at
56
+
57
+ Table 1: The comparison of theoretical FLOPs and practical latency.
58
+
59
+ <table><tr><td>Model</td><td>Top-1 Acc. (%)</td><td>FLOPs (M)</td><td>Latency (ms)</td></tr><tr><td>GhostNet</td><td>73.9</td><td>141</td><td>31.1</td></tr><tr><td>+ Self Attention [23]</td><td>74.4</td><td>172</td><td>72.3</td></tr><tr><td>+ DFC Attention (Ours)</td><td>75.3</td><td>167</td><td>37.5</td></tr></table>
60
+
61
+ tention module usually has a quadratic complexity w.r.t. the feature’s size, which is unscalable to high-resolution images in downstream tasks such as object detection and semantic segmentation.
62
+
63
+ A mainstream strategy to reduce attention’s complexity is splitting images into multiple windows and implementing the attention operation inside windows or crossing windows. For example, Swin Transformer [21] splits the original feature into multiple non-overlapped windows, and the selfattention is calculated within the local windows. MobileViT [23] also unfolds the feature into non-overlapping patches and calculates the attention across these patches. For the 2D feature map in CNN, implementing the feature splitting and attention calculation involves plenty of tensor reshaping and transposing operations. whose theoretical complexity is negligible. In a large model (e.g., Swin-B [21] with several billion FLOPs) with high complexity, these operations only occupy a few portions of the total inference time. While for the light-weight models, their deploying latency cannot be overlooked.
64
+
65
+ ![](images/55e57c902a4eb8201da39bd90f5d57ef56ec399a138309da373658e612c184e3.jpg)
66
+ Figure 3: The information flow of DFC attention. The horizontal and vertical FC layers capture the long-range information along the two directions, respectively.
67
+
68
+ For an intuitive understanding, we equip the GhostNet model with the self-attention used in MobileViT [23] and measure the latency on Huawei P30 (Kirin 980 CPU) with TFLite tool. We use the standard input’s resolution of ImageNet, i.e., $2 2 4 \times 2 2 4$ , and show the results in Table 1. The attention mechanism only adds about $20 \%$ theoretical FLOPs, but requires $2 \times$ inference time on a mobile device. The large difference between theoretical and practical complexity shows that it is necessary to design a hard-ware friendly attention mechanism for fast implementation on mobile devices.
69
+
70
+ # 4 Approach
71
+
72
+ # 4.1 DFC Attention for Mobile Architecture
73
+
74
+ In this section, we will discuss how to design an attention module for mobile CNNs. A desired attention is expected to have the following properties:
75
+
76
+ • Long-range. It is vital to capture the long-range spatial information for attention to enhance the representation ability, as a light-weight CNN (e.g., MobileNet [13], GhostNet [8]) usually adopts small convolution filters (e.g., $1 \times 1$ convolution) to save computational cost. Deployment-efficient. The attention module should be extremely efficient to avoid slowing the inference down. Expensive transformations with high FLOPs or hardware-unfriendly operations are unexpected.
77
+ • Concept-simple. To keep the model’s generalization on diverse tasks, the attention module should be conceptually-simple with little dainty design.
78
+
79
+ Though self-attention operations [6, 24, 21] can model the long-range dependence well, they are not deployment-efficient as discussed in the above section. Compared with them, fully-connected (FC) layers with fixed weights are simpler and easier to implement, which can also be used to generate attention maps with global receptive fields. The detailed computational process is illustrated as follows.
80
+
81
+ Given a feature $Z ~ \in ~ \mathbb { R } ^ { H \times W \times C }$ , it can be seen as $H W$ tokens $z _ { i } ~ \in ~ \mathbb { R } ^ { C }$ , i.e., $Z =$ $\{ z _ { 1 1 } , z _ { 1 2 } , \cdots , z _ { H W } \}$ . A direct implementation of FC layer to generate the attention map is formulated as:
82
+
83
+ $$
84
+ { \pmb a } _ { h w } = \sum _ { h ^ { \prime } , w ^ { \prime } } F _ { h w , h ^ { \prime } w ^ { \prime } } \odot { \pmb z } _ { h ^ { \prime } w ^ { \prime } } ,
85
+ $$
86
+
87
+ where $\odot$ is element-wise multiplication, $F$ is the learnable weights in the FC layer, and $A =$ $\{ { \pmb a } _ { 1 1 } , { \pmb a } _ { 1 2 } , \cdot \cdot \cdot , { \pmb a } _ { H W } \}$ is the generated attention map. Eq 3 can capture the global information by aggregating all the tokens together with learnable weights, which is much simpler than the typical self-attention [36] as well. However, its computational process still requires quadratic complexity $w . r . t .$ feature’s size $( i . e . , \mathcal { O } ( H ^ { 2 } W ^ { 2 } ) ) ^ { 2 }$ , which is unacceptable in practical scenarios especially when the input images are of high resolutions. For example, the 4-th layer of GhostNet has a feature map with 3136 $( 5 6 \times 5 6 )$ tokens, which incurs prohibitively high complexity to calculate the attention map. Actually, feature maps in a CNN are usually of low-rank [30, 17], it is unnecessary to connect all the input and output tokens in different spatial locations densely. The feature’s 2D shape naturally provides a perspective to reduce the computation of FC layers, i.e., decomposing Eq. 3 into two FC layers and aggregating features along the horizontal and vertical directions, respectively. It can be formulated as:
88
+
89
+ ![](images/8cd52b015ec18ba43d07d2908d7bdd6237e182d7acfef92b5bb9f6b0134e1adf.jpg)
90
+ Figure 4: The diagrams of blocks in GhostNetV1 and GhostNetV2. Ghost block is an inverted residual bottleneck containing two Ghost modules, where DFC attention enhances the expanded features to improve expressiveness ability.
91
+
92
+ $$
93
+ \begin{array} { l } { { \displaystyle { \pmb a } _ { h w } ^ { \prime } = \sum _ { h ^ { \prime } = 1 } ^ { H } F _ { h , h ^ { \prime } w } ^ { H } \odot { \boldsymbol z } _ { h ^ { \prime } w } , h = 1 , 2 , \cdots , H , w = 1 , 2 , \cdots , W , } } \\ { { \displaystyle { \pmb a } _ { h w } = \sum _ { w ^ { \prime } = 1 } ^ { W } F _ { w , h w ^ { \prime } } ^ { W } \odot { \boldsymbol a } _ { h w ^ { \prime } } ^ { \prime } , h = 1 , 2 , \cdots , H , w = 1 , 2 , \cdots , W , } } \end{array}
94
+ $$
95
+
96
+ where $F ^ { H }$ and $F ^ { W }$ are transformation weights. Taking the original feature $Z$ as input, Eq. 4 and Eq. 5 are applied to the features sequentially, capturing the long-range dependence along the two directions, respectively. We dub this operation as decoupled fully connected (DFC) attention, whose information flow is shown in Figure 3. Owing to the decoupling of horizontal and vertical transformations, the computational complexity of the attention module can be reduced to $\mathcal { O } ( H ^ { 2 } W + H W ^ { 2 } )$ . In the full attention (Eq. 3), all the patches in a square region participate in the calculation of the focused patch directly. In DFC attention, a patch is directly aggregated by patches in its vertical/horizontal lines, while other patches participate in the generation of those patches in the vertical/horizontal lines, having an indirect relationship with the focused token. Thus the calculation of a patch also involves all the patches in the square region.
97
+
98
+ Eqs. 4 and 5 denote the general formulation of DFC attention, which aggregates pixels along horizontal and vertical directions, respectively. By sharing a part of transformation weights, it can be conveniently implemented with convolutions, leaving out the time-consuming tensor reshaping and transposing operations that affect the practical inference speed. To process input images with varying resolutions, the filter’s size can be decoupled with feature map’s size, i.e., two depth-wise convolutions with kernel sizes $1 \times K _ { H }$ and $K _ { W } \times 1$ are sequentially applied on the input feature. When implemented with convolution, the theoretical complexity of DFC attention is denoted as $\mathcal { O } ( K _ { H } H W + K _ { W } H W )$ . This strategy is well supported by tools such as TFLite and ONNX for fast inference on mobile devices.
99
+
100
+ # 4.2 GhosetNet V2
101
+
102
+ In this section, we use the DFC attention to improve the representation ability of lightweight models and then present the new vision backbone, GhostNetV2.
103
+
104
+ Enhancing Ghost module. As discussed in 3.1, only half of features in Ghost module (Eqs. 1 and 2) interact with other pixels, which damages its ability to capture spatial information. Hence we use DFC attention to enhance Ghost module’s output feature $Y$ for capturing long-range dependence among different spatial pixels.
105
+
106
+ The input feature $X \in \mathbb { R } ^ { H \times W \times C }$ is sent to two branches, i.e., one is the Ghost module to produce output feature $Y$ (Eqs. 1 and 2), and the other is the DFC module to generate attention map $A$ (Eqs. 4 and 5). Recalling that in a typical self-attention [36], linear transformation layers are used to transform input feature into query and key for calculating attention maps. Similarly, we also implement a $1 \times 1$ convolution to convert module’s input $X$ into DFC’s input $Z$ . The final output $O \in \bar { \mathbb { R } ^ { H \times W \times C } }$ of the module is the product of two branch’s output, i.e.,
107
+
108
+ $$
109
+ O = { \mathrm { S i g m o i d } } ( A ) \odot { \mathcal { V } } ( X ) ,
110
+ $$
111
+
112
+ where $\odot$ is the element-wise multiplication and Sigmoid is the scaling function to normalize the attention map $A$ into range $( 0 , 1 )$ .
113
+
114
+ The information aggregation process is shown in Figure 5. With the same input, the Ghost module and DFC attention are two parallel branches extracting information from different perspectives. The output is their element-wise product, which contains information from both features of the Ghost module and attentions of the DFC attention module. The calculation of each attention value involves patches in a large range so that the output feature can contain information from these patches.
115
+
116
+ Feature downsampling. As Ghost module (Eqs. 1 and 2) is an extremely efficient operation, directly paralleling the DFC attention with it will introduces extra computational cost. Hence we reduce the feature’s size by down-sampling it both horizontally and vertically, so that all the operations in DFC attention can be conducted on the smaller features. By default, the width and height are both scaled to half of their original lengths, which reduces $7 5 \%$ FLOPs of DFC attention. Then produced feature map is then upsampled to the original size to match the feature’s size in Ghost branch. We naively use the average pooling and bilinear interpolation for downsampling and upsampling, respectively. Noticing that directly implementing sigmoid (or hard sigmoid) function will incur longer latency, we also deploy
117
+
118
+ ![](images/10c8e357bbe18f2de5f0da8324d6a6897ddae6e0fa2ccb058e05ffa22cc5be44.jpg)
119
+ Figure 5: The information aggregation process of different patches.
120
+
121
+ the sigmoid function on the downsampled features to accelerate practical inference. Though the value of attention maps may not be limited in range (0,1) strictly, we empirically find that its impact on the final performance is negligible.
122
+
123
+ GhostV2 bottleneck. GhostNet adopts an inverted residual bottleneck containing two Ghost modules, where the first module produces expanded features with more channels, while the second one reduces channel’s number to get output features. This inverted bottleneck naturally decouples the “expressiveness” and “capacity” of a model [28]. The former is measured by the expanded features while the latter is reflected by the input/output domains of a block. The original Ghost module generates partial features via cheap operations, which damages both the expressiveness and the capacity. By investigating the performance difference of equipping DFC attention on the expanded features or output features (Table 8 in Section 5.4), we find that enhancing ‘expressiveness’ is more effective. Hence we only multiply the expanded features with DFC attention.
124
+
125
+ Figure 4(b) shows the diagram of GhostV2 bottleneck. A DFC attention branch is parallel with the first Ghost module to enhance the expanded features. Then the enhanced features are sent to the second Ghost module for producing output features. It captures the long-range dependence between pixels in different spatial locations and enhances the model’s expressiveness.
126
+
127
+ Table 2: Comparison of SOTA light-weight models over classification accuracy, the number of parameters and FLOPs on ImageNet dataset.
128
+
129
+ <table><tr><td>Model</td><td>Params (M)</td><td>FLOPs (M)</td><td>Top-1 Acc. (%)</td><td>Top-5 Acc. (%)</td></tr><tr><td>MobileNetV1 0.5× [13]</td><td>1.3</td><td>150</td><td>63.3</td><td>84.9</td></tr><tr><td>MobileNetV2 0.6× [28]</td><td>2.2</td><td>141</td><td>66.7</td><td>-</td></tr><tr><td>ShuffleNetV11.0× (g=3) [42]</td><td>1.9</td><td>138</td><td>67.8</td><td>87.7</td></tr><tr><td>ShuffleNetV21.0× [22]</td><td>2.3</td><td>146</td><td>69.4</td><td>88.9</td></tr><tr><td>MobileNetV3-L 0.75×[12]</td><td>4.0</td><td>155</td><td>73.3</td><td>1</td></tr><tr><td>GhostNetV11.0× [8]</td><td>5.2</td><td>141</td><td>73.9</td><td>91.4</td></tr><tr><td>GhostNetV1 1.1× [8]</td><td>5.9</td><td>168</td><td>74.5</td><td>92.0</td></tr><tr><td>GhostNetV2 1.0×</td><td>6.1</td><td>167</td><td>75.3</td><td>92.4</td></tr><tr><td>MobileNetV11.0×[13]</td><td>4.2</td><td>575</td><td>70.6</td><td>-</td></tr><tr><td>MobileNetV21.0× [28]</td><td>3.5</td><td>300</td><td>72.8</td><td>90.8</td></tr><tr><td>ShuffleNetV21.5× [22]</td><td>3.5</td><td>299</td><td>72.6</td><td>90.6</td></tr><tr><td>FE-Net 1.0× [3]</td><td>3.7</td><td>301</td><td>72.9</td><td></td></tr><tr><td>FBNet-B [39]</td><td>4.5</td><td>295</td><td>74.1</td><td>-</td></tr><tr><td>ProxylessNAS[1]</td><td>4.1</td><td>320</td><td>74.6</td><td>- 92.2</td></tr><tr><td>MnasNet-A1[31]</td><td>3.9</td><td>312</td><td>75.2</td><td>92.5</td></tr><tr><td>MnasNet-A2 [31]</td><td>4.8</td><td>340</td><td>75.6</td><td>92.7</td></tr><tr><td>MobileNetV3-L 1.0×[12]</td><td>5.4</td><td>219</td><td>75.2</td><td>-</td></tr><tr><td>MobileNeXt 1.0× [44]</td><td>3.4</td><td>300</td><td>74.0</td><td></td></tr><tr><td>MobileNeXt+ 1.0× [44]</td><td>3.94</td><td>330</td><td>76.1</td><td>=</td></tr><tr><td>GhostNetV1 1.3× [8]</td><td>7.3</td><td>226</td><td>75.7</td><td>=</td></tr><tr><td>GhostNetV1 1.4× [8]</td><td>8.2</td><td>264</td><td>76.1</td><td>92.7</td></tr><tr><td>GhostNetV2 1.3×</td><td>8.9</td><td>269</td><td>76.9</td><td>92.9 93.4</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>FBNet-C[39] EfficientNet-B0[32]</td><td>5.5</td><td>375</td><td>74.9</td><td>-</td></tr><tr><td></td><td>5.3</td><td>390</td><td>77.1</td><td>93.3</td></tr><tr><td>MnasNet-A3 [31]</td><td>5.2</td><td>403</td><td>76.7</td><td>93.3</td></tr><tr><td>MobileNetV3-L 1.25×[12]</td><td>7.5</td><td>355</td><td>76.6</td><td>-</td></tr><tr><td>MobileNeXt+ 1.1× [44]</td><td>4.28</td><td>420</td><td>76.7</td><td>=</td></tr><tr><td>MobileViT-XS[23]</td><td>2.3</td><td>700</td><td>74.8</td><td>-</td></tr><tr><td>GhostNetV1 1.7× [8]</td><td>11.0</td><td>378</td><td>77.2</td><td>93.4</td></tr><tr><td>GhostNetV2 1.6×</td><td>12.3</td><td>399</td><td>77.8</td><td>93.8</td></tr></table>
130
+
131
+ # 5 Experiments
132
+
133
+ In this section, we empirically investigate the proposed GhostNetV2 model. We conduct experiments on the image classification task with the large-scale ImageNet dataset [5]. To validate its generalization, we use GhostNetV2 as backbone and embed it into a light-weight object detection scheme YOLOV3 [26]. Models with different backbone are compared on MS COCO dataset [20]. At last, we conduct extensive ablation experiments for better understanding GhostNetV2. The practical latency is measured on Huawei P30 (Kirin 980 CPU) with TFLite tool.
134
+
135
+ # 5.1 Image Classification on ImageNet
136
+
137
+ Setting. The classification experiments are conducted on the benchmark ImageNet (ILSVRC 2012) dataset, which contains 1.28M training images and 50K validation images from 1000 classes. We follow the training setting in [8] and report results with single crop on ImageNet dataset. All the experiments are conducted with PyTorch [25] and MindSpore [15].
138
+
139
+ Results. The performance comparison of different models on ImageNet is shown in Table 2, Figure 1 and Figure 2. Several light-weight models are selected as the competing methods. GhostNet [8], MobileNetV2 [28], MobileNetV3 [12], and ShuffleNet [42] are widely-used light-weight CNN models with SOTA performance. By combing CNN and Transformer, MobileViT [24] is a new backbone presented recently. Compared with them, GhostNetV2 achieves significantly higher performance with lower computational cost. For example, GhostNetV2 achieves $7 5 . 3 \%$ top-1 accuracy with only 167 FLOPs, which significantly outperform GhostNet V1 $( 7 4 . 5 \% )$ with similar computational cost (167M FLOPs).
140
+
141
+ Table 3: Results of object detection on MS COCO dataset. YOLOv3 [26] is used as the detection head.
142
+
143
+ <table><tr><td>Backbone</td><td>Resolution</td><td>Backbone FLOPs (M)</td><td>AP</td><td>AP50</td><td>AP75</td><td>APs</td><td>APM</td><td>APL</td></tr><tr><td>MobileNetV2 1.0×[28] GhostNet V1 1.1×</td><td>320× 230</td><td>613 338</td><td>22.2 21.8</td><td>41.9 41.2</td><td>21.4 20.8</td><td>6.0 5.7</td><td>23.6 22.3</td><td>35.8 37.3</td></tr><tr><td>GhostNetV2 1.0×</td><td></td><td>342</td><td>22.3</td><td>41.4</td><td>21.9</td><td>6.0</td><td>22.8</td><td>38.1</td></tr><tr><td>MobileNetV2 1.0× [28]</td><td>416 × 416</td><td>1035</td><td>23.9</td><td>45.4</td><td>22.6</td><td>10.6</td><td>25.1</td><td>34.9</td></tr><tr><td>GhostNet V1 1.1×</td><td></td><td>567</td><td>23.4</td><td>45.2</td><td>21.9</td><td>9.8</td><td>24.4</td><td>34.9</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>GhostNetV2 1.0×</td><td></td><td>571</td><td>24.1</td><td>45.7</td><td>23.0</td><td>10.4</td><td>25.0</td><td>36.1</td></tr></table>
144
+
145
+ Table 4: Effectiveness of DFC attention with MobileNetV2 on ImageNet dataset.
146
+
147
+ <table><tr><td>Model</td><td>Params (M)</td><td>FLOPs (M)</td><td>Top-1 Acc. (%)</td><td>Top-5 Acc. (%)</td></tr><tr><td>MobileNetV2 1.0 ×</td><td>3.5</td><td>300</td><td>72.8</td><td>90.8</td></tr><tr><td>MobileNetV2 1.1 ×</td><td>4.1</td><td>338</td><td>73.0</td><td>90.0</td></tr><tr><td>MobileNetV21.1 × + SE[14]</td><td>4.0</td><td>338</td><td>73.8</td><td>91.0</td></tr><tr><td>MobileNetV21.1 × +CBAM[38]</td><td>4.0</td><td>338</td><td>74.0</td><td>91.4</td></tr><tr><td>MobileNetV2 1.1 × + CA[11]</td><td>4.1</td><td>350</td><td>74.5</td><td>91.8</td></tr><tr><td>MobileNetV2 1.0 × + DFC (Ours)</td><td>4.3</td><td>344</td><td>75.4</td><td>92.4</td></tr></table>
148
+
149
+ Practical Inference Speed. Considering the light-weight model is designed for mobile applications, we practically measure the inference latency of different models on an arm-based mobile phone, using the TFLite tool [4]. Owing to the deploying efficiency of DFC attention, GhostNetV2 also achieves a good trade-off between accuracy and practical speed. For example, with similar inference latency (e.g., $3 7 ~ \mathrm { m s }$ ), GhostNetV2 achieves $7 5 . 3 \%$ top-1 accuracy, which is obviously GhostNet V1 with $7 4 . 5 \%$ top-1 accuracy.
150
+
151
+ # 5.2 Object Detection on COCO
152
+
153
+ Setting. To validate the generalization of GhostNetV2, we further conduct experiments on the object detection task. The experiments are conducted on MS COCO 2017 dataset, composing of $1 1 8 \mathrm { k }$ training images and $5 \mathrm { k }$ validation images. We embed different backbone into a widely-used detection head, YOLOv3 [26] and follow the default training strategy provided by MMDetection 3. Specifically, based on the pre-trained weights on ImageNet, the models are fine-tuned with SGD optimizer for 30 epochs. The batchsize is set to 192 and initial learning to 0.003. The experiments are conducted with input resolutions $3 2 0 \times 3 2 0$ .
154
+
155
+ Results. Table 3 compares the proposed GhostNetV2 model with GhostNet V1. With different input resolutions, GhostNetV2 shows obvious superiority to the GhostNet V1. For example, with similar computational cost (i.e., 340M FLOPs with $3 2 0 \times 3 2 0$ input resolution), GhostNetV2 achieves $2 2 . 3 \%$ mAP, which suppresses GhostNet V1 by $0 . 5 \mathrm { m A P } .$ . We conclude that capturing the long-range dependence is also vital for downstream tasks, and the proposed DFC attention can effectively endow a large receptive field to the Ghost module, and then construct a more powerful and efficient block.
156
+
157
+ # 5.3 Semantic Segmentation on ADE20K
158
+
159
+ We conduct semantic segmentation experiments on ADE20K [43], which contains $2 0 \mathrm { k }$ training, 2k validation, and 3k testing images with 150 semantic categories. We use the DeepLabV3 [2] model as the segmentation head, and follow the default training setting of MMSegmentation 4. From the pre-trained weights on ImageNet, the models are fine-tuned for 160000 iterations with crop size $5 1 2 \times 5 1 2$ . Table 5 show the results with different backbones. In the semantic tasks, GhostNetV2 also achieves significantly higher performance than GhostNetV1, which illustrates the university of GhostNetV2 over different tasks.
160
+
161
+ Table 5: Results of semantic segmentation on ADE20K dataset.
162
+
163
+ <table><tr><td rowspan=1 colspan=1>Backbone</td><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Backbone FLOPs (M)|mIoU (%)</td><td rowspan=1 colspan=1>mIoU (%)</td></tr><tr><td rowspan=1 colspan=1>MobileNetV2 1.0× [28]GhostNet V1 1.1×GhostNetV2 1.0×</td><td rowspan=1 colspan=1>DeepLabV3</td><td rowspan=1 colspan=1>300168167</td><td rowspan=1 colspan=1>34.0834.1735.52</td></tr></table>
164
+
165
+ Table 7: The location for implementing DFC attention.
166
+
167
+ <table><tr><td>Stage</td><td>Top1-Acc. (%)</td><td>Params (M)</td><td>FLOPs (M)</td></tr><tr><td>None</td><td>73.9</td><td>5.2</td><td>141</td></tr><tr><td>1</td><td>74.8</td><td>5.3</td><td>150</td></tr><tr><td>2</td><td>75.0</td><td>5.4</td><td>152</td></tr><tr><td>3</td><td>74.7</td><td>5.8</td><td>147</td></tr><tr><td>All</td><td>75.3</td><td>5.8</td><td>168</td></tr></table>
168
+
169
+ Table 8: Enhancing expressiveness or capacity.
170
+
171
+ <table><tr><td>Model</td><td>Top1-Acc. (%)</td><td>Params (M)</td><td>FLOPs (M)</td></tr><tr><td>Baseline</td><td>73.9 (+0.0)</td><td>5.2</td><td>141</td></tr><tr><td>Expressiveness</td><td>75.3 (+1.4)</td><td>6.1</td><td>167</td></tr><tr><td>Capacity</td><td>74.8 (+0.9)</td><td>6.1</td><td>162</td></tr><tr><td>Both</td><td>75.5 (+1.6)</td><td>7.0</td><td>188</td></tr></table>
172
+
173
+ # 5.4 Ablation Studies
174
+
175
+ In this section, we conduct extensive experiments to investigate the impact of each component in GhostNetV2. The experiments are conducted with GhostNetV2 $1 \times$ on ImageNet.
176
+
177
+ Experiments with other models. As a universal module, the DFC attention can also be embedded into other architectures for enhancing their performance. The resultsof MobileNetV2 with different attention modules are shown in Table 4. SE [14] and CBAM [38] are two widely-used attention modules, and CA [11] is a SOTA method presented recently. The proposed DFC attention achieves higher performance than these existing methods. For example, the proposed DFC attention improves the top-1 accuracy of MobileNetV2 by $2 . 4 \%$ , which suppresses CA $( 1 . 5 \% )$ by a large margin.
178
+
179
+ The impact of kernel size in DFC attention. We split the GhostNetV2 architecture into 3 stages by the feature’s size, and apply
180
+
181
+ Table 6: The impact of kernel size in DFC attention.
182
+
183
+ <table><tr><td>Kernel sizes</td><td>Top1-Acc. (%)</td></tr><tr><td>(3,3,3) (7,5,5) (7,7,5) (9,7,5)</td><td>74.8 75.0 74.2</td></tr></table>
184
+
185
+ DFC attention with different kernel size (Table 6). The kernel sizes $1 \times 3$ and $3 \times 1$ cannot capture the long-range dependence well, which results in the worst performance (i.e., $7 4 . 8 \%$ ). Increasing the kernel size to capture the longer range information can significantly improve the performance.
186
+
187
+ The location for implementing DFC attention. The GhostNetV2 model can be split into 4 stages by the feature’s size, and we empirically investigate how the implementing location affects the final performance. The results are shown in Table 7, which empirically shows that the DFC attention can improve performance when implementing it on any stage. Exhaustively adjusting or searching for proper locations has the potential to further improve the trade-off between accuracy and computational cost, which exceeds the scope of this paper. By default, we deploy the DFC attention on all the layers.
188
+
189
+ Table 9: The impact of scaling function. ‘BF’ and ‘AF’ denote implementing the scaling function before or after the up-sampling operation, respectively.
190
+
191
+ <table><tr><td>Scaling function</td><td>Top1-Acc. (%)</td><td>FLOPs (M)</td><td>Latency (ms)</td></tr><tr><td>Sigmoid (BF)</td><td>75.3</td><td>167</td><td>37.5</td></tr><tr><td>Hard simoid (BF)</td><td>75.2</td><td>167</td><td>36.8</td></tr><tr><td>Clip (BF)</td><td>74.9</td><td>167</td><td>36.7</td></tr><tr><td>Sigmoid (AF)</td><td>75.3</td><td>167</td><td>40.7</td></tr><tr><td>Hard simoid (AF)</td><td>75.2</td><td>167</td><td>39.6</td></tr><tr><td>Clip (AF)</td><td>75.0</td><td>167</td><td>38.5</td></tr></table>
192
+
193
+ The impact of scaling function. For an attention model, it is necessary to scale the feature maps into range (0,1), which can stabilize the training process. Though the theoretical complexity is negligible, these element-wise operations still incur extra latency. Table 9 investigates how the scaling function affects the final performance and latency. Though sigmoid and hard sigmoid functions bring obvious performance improvement, directly implementing them on the large feature maps incur long latency.
194
+
195
+ Implementing them before up-sampling is much more efficient but results in similar accuracy. By default, we use the sigmoid function and put it before the up-sampling operation.
196
+
197
+ Enhancing expressiveness or capacity. We implement the DFC attention on two Ghost modules and show the results in Table 8. As discussed in Section 4.2, the former enhances expanded features (expressiveness) while the latter improves the block’s capacity. With similar computational costs, enhancing the expanded features brings $1 . 4 \%$ top-1 accuracy improvement, which is much higher than enhancing the output feature. Though enhancing both of the features can further improve the performance, the computational cost also increases accordingly. By default, we only enhance the expanded features in an inverse residual bottleneck.
198
+
199
+ The resizing functions for up-sampling and down-sampling. Multiple functions can conduct the up-sampling and downsampling operations, and we investigate several widely-used functions, i.e., average pooling, max pooling, bilinear interpolation for down-sampling, and bilinear, bicubic interpolations for up-sampling (Table 10). The performance of GhostNetV2 is robust to the choice of resizing functions, i.e., all of these methods achieve similar accuracies in ImageNet. Their differences mainly lie in practical deploying efficiency
200
+
201
+ Table 10: The resizing functions for down-sampling and up-sampling, denoted as $ { ^ 6 } \mathrm { D } ^ { \prime }$ and ‘U’, respectively.
202
+
203
+ <table><tr><td>Resizing function</td><td>Top1-Acc. (%)</td><td>FLOPs (M)</td><td>Latency (ms)</td></tr><tr><td>Average Pooling (D)</td><td>75.4</td><td>167</td><td>38.4</td></tr><tr><td>Max Pooling (D)</td><td>75.3</td><td>167</td><td>37.5</td></tr><tr><td>Bilinear (D)</td><td>75.3</td><td>167</td><td>38.7</td></tr><tr><td>Bilinear (U)</td><td>75.3</td><td>167</td><td>37.5</td></tr><tr><td>Bicubic (U)</td><td>75.4</td><td>167</td><td>39.9</td></tr></table>
204
+
205
+ on mobile devices. Maxing pooling is slightly more efficient than average pooling (37.5 ms vs.38.4 ms), and bilinear interpolation is faster than the bicubic one $( 3 7 . 5 \ \mathrm { m s } \ \nu s . 3 9 . 9 \ \mathrm { m s } )$ . Thus we choose the maxing pooling for down-sampling and bilinear interpolation for up-sampling by default.
206
+
207
+ Visualization of decoupled attention and full attention. We visualize the decoupled attention produced by stacking vertical and horizontal attentions and compare it with full attention. In low layers, the decoupled attention shows some cross-shaped patterns, indicating patches from the vertical/horizontal lines participate more. As the depth increases, the pattern of the attention map diffuses and becomes more similar to the full attention.
208
+
209
+ ![](images/377433e2652cec2b6160133e3a5b0c50e3d22633cd8138ef334116deb77b337e.jpg)
210
+ Figure 6: Visualization of attention maps.
211
+
212
+ # 6 Conclusion
213
+
214
+ This paper proposes a hardware-friendly DFC attention and presents a new GhostNetV2 architecture for mobile applications. The DFC attention can capture the dependence between pixels in long-range spatial locations, which significantly enhances the expressiveness ability of light-weight models. It decomposes a FC layer into horizontal FC and vertical FC, which has large receptive fields along the two directions, respectively. Equipped this computation-efficient and deployment-simple modules, GhostNetV2 can achieve a better trade-off between accuracy and speed. Extensive experiments on benchmark datasets (e.g., ImageNet, MS COCO) validate the superiority of GhostNetV2.
215
+
216
+ Acknowledgment. This work is supported by National Natural Science Foundation of China under Grant No.61876007, Australian Research Council under Project DP210101859 and the University of Sydney SOAR Prize. We gratefully acknowledge the support of MindSpore, CANN(Compute Architecture for Neural Networks) and Ascend AI Processor used for this research.
217
+
218
+ # References
219
+
220
+ [1] Han Cai, Ligeng Zhu, and Song Han. Proxylessnas: Direct neural architecture search on target task and hardware. In ICLR, 2019.
221
+ [2] Liang-Chieh Chen, George Papandreou, Florian Schroff, and Hartwig Adam. Rethinking atrous convolution for semantic image segmentation. arXiv preprint arXiv:1706.05587, 2017. [3] Weijie Chen, Di Xie, Yuan Zhang, and Shiliang Pu. All you need is a few shifts: Designing efficient convolutional neural networks for image classification. In CVPR, 2019. [4] Robert David, Jared Duke, Advait Jain, Vijay Janapa Reddi, Nat Jeffries, Jian Li, Nick Kreeger, Ian Nappier, Meghna Natraj, Tiezhen Wang, et al. Tensorflow lite micro: Embedded machine learning for tinyml systems. Proceedings of Machine Learning and Systems, 3:800–811, 2021. [5] 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, pages 248–255. Ieee, 2009. [6] 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. [7] Kai Han, Jianyuan Guo, Yehui Tang, and Yunhe Wang. Pyramidtnt: Improved transformer-in-transformer baselines with pyramid architecture. arXiv preprint arXiv:2201.00978, 2022. [8] Kai Han, Yunhe Wang, Qi Tian, Jianyuan Guo, Chunjing Xu, and Chang Xu. Ghostnet: More features from cheap operations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 1580–1589, 2020. [9] Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer. Advances in Neural Information Processing Systems, 34:15908–15919, 2021.
222
+ [10] 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.
223
+ [11] 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.
224
+ [12] 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.
225
+ [13] Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
226
+ [14] 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.
227
+ [15] Huawei. Mindspore. https://www.mindspore.cn/, 2020.
228
+ [16] Forrest N Iandola, Song Han, Matthew W Moskewicz, Khalid Ashraf, William J Dally, and Kurt Keutzer. Squeezenet: Alexnet-level accuracy with $5 0 \mathrm { x }$ fewer parameters and $< 0 . 5 \mathrm { m b }$ model size. arXiv preprint arXiv:1602.07360, 2016.
229
+ [17] Max Jaderberg, Andrea Vedaldi, and Andrew Zisserman. Speeding up convolutional neural networks with low rank expansions. arXiv preprint arXiv:1405.3866, 2014.
230
+ [18] Andrej Karpathy, George Toderici, Sanketh Shetty, Thomas Leung, Rahul Sukthankar, and Li Fei-Fei. Large-scale video classification with convolutional neural networks. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pages 1725–1732, 2014.
231
+ [19] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 25, 2012.
232
+ [20] 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.
233
+ [21] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10012–10022, 2021.
234
+ [22] Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, and Jian Sun. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In Proceedings of the European conference on computer vision (ECCV), pages 116–131, 2018.
235
+ [23] Sachin Mehta and Mohammad Rastegari. Mobilevit: light-weight, general-purpose, and mobile-friendly vision transformer. arXiv preprint arXiv:2110.02178, 2021.
236
+ [24] Sachin Mehta and Mohammad Rastegari. Mobilevit: Light-weight, general-purpose, and mobile-friendly vision transformer. In International Conference on Learning Representations, 2022.
237
+ [25] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32, 2019.
238
+ [26] Joseph Redmon and Ali Farhadi. Yolov3: An incremental improvement. arXiv preprint arXiv:1804.02767, 2018.
239
+ [27] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems, 28, 2015.
240
+ [28] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4510–4520, 2018.
241
+ [29] 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, pages 1–9, 2015.
242
+ [30] Cheng Tai, Tong Xiao, Yi Zhang, Xiaogang Wang, et al. Convolutional neural networks with low-rank regularization. arXiv preprint arXiv:1511.06067, 2015.
243
+ [31] 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, pages 2820–2828, 2019.
244
+ [32] Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International conference on machine learning, pages 6105–6114. PMLR, 2019.
245
+ [33] Yehui Tang, Kai Han, Jianyuan Guo, Chang Xu, Yanxi Li, Chao Xu, and Yunhe Wang. An image patch is a wave: Phase-aware vision mlp. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10935–10944, 2022.
246
+ [34] Yehui Tang, Kai Han, Chang Xu, An Xiao, Yiping Deng, Chao Xu, and Yunhe Wang. Augmented shortcuts for vision transformers. Advances in Neural Information Processing Systems, 34:15316–15327, 2021.
247
+ [35] Yehui Tang, Yunhe Wang, Yixing Xu, Dacheng Tao, Chunjing Xu, Chao Xu, and Chang Xu. Scop: Scientific control for reliable neural network pruning. Advances in Neural Information Processing Systems, 33:10936–10947, 2020.
248
+ [36] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
249
+ [37] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7794–7803, 2018.
250
+ [38] Sanghyun Woo, Jongchan Park, Joon-Young Lee, and In So Kweon. Cbam: Convolutional block attention module. In Proceedings of the European conference on computer vision (ECCV), pages 3–19, 2018.
251
+ [39] 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, pages 10734–10742, 2019.
252
+ [40] Yixing Xu, Kai Han, Chang Xu, Yehui Tang, Chunjing Xu, and Yunhe Wang. Learning frequency domain approximation for binary neural networks. Advances in Neural Information Processing Systems, 34:25553–25565, 2021.
253
+ [41] Yixing Xu, Yunhe Wang, Hanting Chen, Kai Han, Chunjing Xu, Dacheng Tao, and Chang Xu. Positiveunlabeled compression on the cloud. Advances in Neural Information Processing Systems, 32, 2019.
254
+ [42] Xiangyu Zhang, Xinyu Zhou, Mengxiao Lin, and Jian Sun. Shufflenet: An extremely efficient convolutional neural network for mobile devices. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 6848–6856, 2018.
255
+
256
+ [43] Bolei Zhou, Hang Zhao, Xavier Puig, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Scene parsing through ade20k dataset. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 633–641, 2017.
257
+
258
+ [44] 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.
259
+
260
+ # Checklist
261
+
262
+ 1. For all authors...
263
+
264
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 1.
265
+ (b) Did you describe the limitations of your work? [Yes]
266
+ (c) Did you discuss any potential negative societal impacts of your work? [No] No potential negative societal impacts.
267
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
268
+
269
+ 2. If you are including theoretical results...
270
+
271
+ (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]
272
+
273
+ 3. If you ran experiments...
274
+
275
+ (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]
276
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
277
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
278
+ (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]
279
+
280
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
281
+
282
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
283
+ (b) Did you mention the license of the assets? [No]
284
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
285
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
286
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
287
+
288
+ 5. If you used crowdsourcing or conducted research with human subjects...
289
+
290
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
291
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
292
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]