ZHANGYUXUAN-zR commited on
Commit
121a6e6
·
verified ·
1 Parent(s): 18f66a9

Add files using upload-large-folder tool

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/5uIL1E8h1E/5uIL1E8h1E.md +539 -0
  2. md/dev/GkDbQb6qu_r/GkDbQb6qu_r.md +281 -0
  3. md/dev/JYtwGwIL7ye/JYtwGwIL7ye.md +347 -0
  4. md/dev/LKEYuYNOqx/LKEYuYNOqx.md +381 -0
  5. md/dev/OboQ71j1Bn/OboQ71j1Bn.md +595 -0
  6. md/dev/T__V3uLix7V/T__V3uLix7V.md +418 -0
  7. md/dev/XtyeppctGgc/XtyeppctGgc.md +311 -0
  8. md/dev/fvLLcIYmXb/fvLLcIYmXb.md +412 -0
  9. md/dev/g6We1SwaY9/g6We1SwaY9.md +273 -0
  10. md/dev/p40XRfBX96/p40XRfBX96.md +0 -0
  11. md/dev/zT5T9gHpGI/zT5T9gHpGI.md +0 -0
  12. parse/train/-OrwaD3bG91/images/0294a4d81ac5ba0b88d700af4e1fbf8304e0099061bf33f6c1ecf26a590fbe7d.jpg +3 -0
  13. parse/train/-OrwaD3bG91/images/1900ff5a7e1b5a04b03832649b9fdf09dad1f97f7f92fd103e915552ff77f0aa.jpg +3 -0
  14. parse/train/-OrwaD3bG91/images/9f738e4e0f330137f939be30ce289f818ad9b77d6373ce40f4a55cc1cb8a2f01.jpg +3 -0
  15. parse/train/-OrwaD3bG91/images/c39447023d7968d0529aa7c9857d7a8c0207ab8047cb80e05a5eb2ac492b89c9.jpg +3 -0
  16. parse/train/5PiSFHhRe2C/5PiSFHhRe2C.md +374 -0
  17. parse/train/5PiSFHhRe2C/5PiSFHhRe2C_content_list.json +1773 -0
  18. parse/train/5PiSFHhRe2C/5PiSFHhRe2C_middle.json +0 -0
  19. parse/train/5PiSFHhRe2C/5PiSFHhRe2C_model.json +0 -0
  20. parse/train/BJluy2RcFm/images/18e886262616e1c9bfe7a189c9b3c4fd3028bf38e1388c318a98a91eb7062f50.jpg +3 -0
  21. parse/train/BJluy2RcFm/images/267e4b7e3e24eb55a1ad7e95cfa7e9fa41e88f6fed8ec08fea9c0558e32d53bb.jpg +3 -0
  22. parse/train/BJluy2RcFm/images/27bc2ee190da7355754c6b891b168efb2d5ffb85660bc67300dc3b528129f51a.jpg +3 -0
  23. parse/train/BJluy2RcFm/images/325cac69de58fcb72ac585f5fb3c86afb03b85a0edbf512ea0a6237da7855622.jpg +3 -0
  24. parse/train/BJluy2RcFm/images/3aba158ed181e6bf50ff4a7a4e66eaaeb7136e9469834bd4af80c542107478ff.jpg +3 -0
  25. parse/train/BJluy2RcFm/images/463815139293208ff16127a835dcd0fb1f31a4b135c7edcb0b31e77089185545.jpg +3 -0
  26. parse/train/BJluy2RcFm/images/47934a0e4f6e43911f4a0677fed4519eda6f8cd8a757aefbb7e17c17ec45b283.jpg +3 -0
  27. parse/train/BJluy2RcFm/images/4d727296ce1ece41abfd3ea0427f7d127132e3aabf80b1d4eb72764474c92548.jpg +3 -0
  28. parse/train/BJluy2RcFm/images/603b9665e7b89ab08fc651eb6fc70bd7ffe511ee4d6493f26ecaab820d8a9555.jpg +3 -0
  29. parse/train/BJluy2RcFm/images/94088a8b8158576965f944ea6c7827e2f21628d83144ab6b425e91dc43d351ff.jpg +3 -0
  30. parse/train/BJluy2RcFm/images/952f5b0e473c8e8632225e1ec8632d7bbceebfc7b98b46062f4be71e498b8f3c.jpg +3 -0
  31. parse/train/BJluy2RcFm/images/9570c0aa71cdbf11645849cf86a52c8281c5776992c8c1abccb47999bc9da043.jpg +3 -0
  32. parse/train/BJluy2RcFm/images/968b9434d4804c19ada3ba21e462db1ba0d57e98fe4117b3117e6fe566acd210.jpg +3 -0
  33. parse/train/BJluy2RcFm/images/b0c5d49f87161525f0cc5fae19fa3142f6f9d6fdc7d6e76ffc8416894be06202.jpg +3 -0
  34. parse/train/BJluy2RcFm/images/c5295bdc6083be5e0f004d6d242ffc48b694c46a77260d75497fc3ebb22cc89b.jpg +3 -0
  35. parse/train/BJluy2RcFm/images/d9d44cfc3b890d1aaf2e7e09c5e4c3908acfa08e29bf3268558fa8979c0a4181.jpg +3 -0
  36. parse/train/BJluy2RcFm/images/ec54e86548a327fe40e98021bb14187bda06ff605cbc114f31bdb17767bbb5e4.jpg +3 -0
  37. parse/train/BJluy2RcFm/images/f53a1582c0886f5fc0f990259f15f206da91284a893af278993a54b567df1fc8.jpg +3 -0
  38. parse/train/BJluy2RcFm/images/fd50908ad3d0c35dd0dbf651e96fc584bb8ee5e666cba364a73b1eb833c19851.jpg +3 -0
  39. parse/train/BkgYPREtPr/images/2db61d4c7cd446225dce7fad6b657e5a8d27ccb6264178107d8c0dd003bb4cf1.jpg +3 -0
  40. parse/train/BkgYPREtPr/images/30befd7f3e22c1057a74b4852ef1e47cad7607a2e215fa16b4a2ed2f0248acd7.jpg +3 -0
  41. parse/train/BkgYPREtPr/images/6ec24284f2451ad19209823b16df140fe83f04db57f66c66e7e98db402039766.jpg +3 -0
  42. parse/train/BkgYPREtPr/images/7b7bb98223bf60995a9561b0de16df794c5e546d0f725610f8929d8788c2820f.jpg +3 -0
  43. parse/train/BkgYPREtPr/images/8699677295953d1b33056a30bb781e87e8c5814e60712547ba6548c7cd1a6c22.jpg +3 -0
  44. parse/train/BkgYPREtPr/images/8d17a8628a2a6f06c646c610501e284776252ee3ad7cd82d34e7c2cae9a59e6b.jpg +3 -0
  45. parse/train/BkgYPREtPr/images/9b538b538f589912be7bd4e31d61df851eaba2304128f8d044ea9a3e9b6b14d1.jpg +3 -0
  46. parse/train/BkgYPREtPr/images/a4d5a8735c9908ce554111cd99e4d42141eb26b34d6b6888ec707c6db08c2010.jpg +3 -0
  47. parse/train/BkgYPREtPr/images/bbaeba665ea1002237902872be91be4781ac031084d7c72a423e4eeb25d119d4.jpg +3 -0
  48. parse/train/BkgYPREtPr/images/cb56bf396bf47fe754d999814b417f0522e368d1714a8ac510a59784118e024e.jpg +3 -0
  49. parse/train/BkgYPREtPr/images/f62e89bb33fe289a5f0df489810eb6209ccf44ce6fa9a5ef14f8343c4eac118a.jpg +3 -0
  50. parse/train/BylRkAEKDH/images/070a15449a27181a3c1e893558aed730219294866599521e3cd5885f84ab1b62.jpg +3 -0
md/dev/5uIL1E8h1E/5uIL1E8h1E.md ADDED
@@ -0,0 +1,539 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Residual Scheduling: A New Reinforcement Learning Approach to Solving Job Shop Scheduling Problem
2
+
3
+ Anonymous Author(s)
4
+ Affiliation
5
+ Address
6
+ email
7
+
8
+ # Abstract
9
+
10
+ 1 Job-shop scheduling problem (JSP) is a mathematical optimization problem widely
11
+ 2 used in industries like manufacturing, and flexible JSP (FJSP) is also a common
12
+ 3 variant. Since they are NP-hard, it is intractable to find the optimal solution for
13
+ 4 all cases within reasonable times. Thus, it becomes important to develop efficient
14
+ 5 heuristics to solve JSP/FJSP. A kind of method of solving scheduling problems
15
+ 6 is construction heuristics, which constructs scheduling solutions via heuristics.
16
+ 7 Recently, many methods for construction heuristics leverage deep reinforcement
17
+ 8 learning (DRL) with graph neural networks (GNN). In this paper, we propose a new
18
+ 9 approach, named residual scheduling, to solving JSP/FJSP. In this new approach,
19
+ 10 we remove irrelevant machines and jobs such as those finished, such that the states
20
+ 11 include the remaining (or relevant) machines and jobs only. Our experiments show
21
+ 12 that our approach reaches state-of-the-art (SOTA) among all known construction
22
+ 13 heuristics on most well-known open JSP and FJSP benchmarks. In addition, we
23
+ 14 also observe that even though our model is trained for scheduling problems of
24
+ 15 smaller sizes, our method still performs well for scheduling problems of large sizes.
25
+ 16 Interestingly in our experiments, our approach even reaches zero gap for 49 among
26
+ 17 50 JSP instances whose job numbers are more than 150 on 20 machines.
27
+
28
+ # 18 1 Introduction
29
+
30
+ 19 The job-shop scheduling problem (JSP) is a mathematical optimization (MO) problem widely used in
31
+ 20 many industries, like manufacturing (Zhang et al., 2020; Waschneck et al., 2016). For example, a
32
+ 21 semiconductor manufacturing process can be viewed as a complex JSP problem (Waschneck et al.,
33
+ 22 2016), where a set of given jobs are assigned to a set of machines under some constraints to achieve
34
+ 23 some expected goals such as minimizing makespan which is focused on in this paper. While there are
35
+ 24 many variants of JSP (Abdolrazzagh-Nezhad and Abdullah, 2017), we also consider an extension
36
+ 25 called flexible JSP (FJSP) where job operations can be done on designated machines.
37
+ 26 A generic approach to solving MO problems is to use mathematical programming, such as mixed
38
+ 27 integer linear programming (MILP) and constraint satisfaction problem (CSP). Two popular generic
39
+ 28 MO solvers for solving MO are OR-Tools (Perron and Furnon, 2019) and IBM ILOG CPLEX
40
+ 29 Optimizer (abbr. CPLEX) (Cplex, 2009). However, both JSP and FJSP, as well as many other MO
41
+ 30 problems, have been shown to be NP-hard (Garey and Johnson, 1979; Lageweg et al., 1977). That
42
+ 31 said, it is unrealistic and intractable to find the optimal solution for all cases within reasonable times.
43
+ 32 These tools can obtain the optimal solutions if sufficient time (or unlimited time) is given; otherwise,
44
+ 33 return best-effort solutions during the limited time, which usually have gaps to the optimum. When
45
+ 34 problems are scaled up, the gaps usually grow significantly.
46
+ 35 In practice, some heuristics (Gupta and Sivakumar, 2006; Haupt, 1989) or approximate methods
47
+ 36 (Jansen et al., 2000) were used to cope with the issue of intractability. A simple greedy approach is to
48
+ 37 use the heuristics following the so-called priority dispatching rule (PDR) (Haupt, 1989) to construct
49
+ 38 solutions. These can also be viewed as a kind of solution construction heuristics or construction
50
+ 39 heuristics. Some of PDR examples are First In First Out (FIFO), Shortest Processing Time (SPT),
51
+ 40 Most WorK Remaining (MWKR), and Most Operation Remaining (MOR). Although these heuristics
52
+ 41 are usually computationally fast, it is hard to design generally effective rules to minimize the gap to
53
+ 42 the optimum, and the derived results are usually far from the optimum.
54
+ 43 Furthermore, a generic approach to automating the design of heuristics is called metaheuristics, such
55
+ 44 as tabu search (Dell’Amico and Trubian, 1993; Saidi-Mehrabad and Fattahi, 2007) , genetic algorithm
56
+ 45 (GA) (Pezzella et al., 2008; Ren and Wang, 2012), and PSO algorithms (Lian et al., 2006; Liu et al.,
57
+ 46 2011). However, metaheuristics still take a high computation time, and it is not ensured to obtain the
58
+ 47 optimal solution either.
59
+ 48 Recently, deep reinforcement learning (DRL) has made several significant successes for some
60
+ 49 applications, such as AlphaGo (Silver et al., 2016), AlphaStar (Vinyals et al., 2019), AlphaTensor
61
+ 50 (Fawzi et al., 2022), and thus it also attracted much attention in the MO problems, including chip
62
+ 51 design (Mirhoseini et al., 2021) and scheduling problems (Zhang et al., 2023). In the past, several
63
+ 52 researchers used DRL methods as construction heuristics, and their methods did improve scheduling
64
+ 53 performance, illustrated as follows. Park et al. (2020) proposed a method based on DQN (Mnih et al.,
65
+ 54 2015) for JSP in semiconductor manufacturing and showed that their DQN model outperformed GA
66
+ 55 in terms of both scheduling performance (namely gap to the optimum on makespan) and computation
67
+ 56 time. Lin et al. (2019) and Luo (2020) proposed different DQN models to decide the scheduling action
68
+ 57 among the heuristic rules and improved the makespan and the tardiness over PDRs, respectively.
69
+ 58 A recent DRL-based approach to solving JSP/FJSP problems is to leverage graph neural networks
70
+ 59 (GNN) to design a size-agnostic representation (Zhang et al., 2020; Park et al., 2021b,a; Song et al.,
71
+ 60 2023). In this approach, graph representation has better generalization ability in larger instances
72
+ 61 and provides a holistic view of scheduling states. Zhang et al. (2020) proposed a DRL method
73
+ 62 with disjunctive graph representation for JSP, called L2D (Learning to Dispatch), and used GNN
74
+ 63 to encode the graph for scheduling decision. Besides, Song et al. (2023) extended their methods
75
+ 64 to FJSP. Park et al. (2021b) used a similar strategy of (Zhang et al., 2020) but with different state
76
+ 65 features and model structure. Park et al. (2021a) proposed a new approach to solving JSP, called
77
+ 66 ScheduleNet, by using a different graph representation and a DRL model with the graph attention for
78
+ 67 scheduling decision. Most of the experiments above showed that their models trained from small
79
+ 68 instances still worked reasonably well for large test instances, and generally better than PDRs. Among
80
+ 69 these methods, ScheduleNet achieved state-of-the-art (SOTA) performance. There are still other
81
+ 70 DRL-based approaches to solving JSP/FJSP problems, but not construction heuristics. Zhang et al.
82
+ 71 (2022) proposes another approach, called Learning to Search (L2S), a kind of search-based heuristics.
83
+ 72 In this paper, we propose a new approach to solving JSP/FJSP, a kind of construction heuristics, also
84
+ 73 based on GNN. In this new approach, we remove irrelevant machines and jobs, such as those finished,
85
+ 74 such that the states include the remaining machines and jobs only. This approach is named residual
86
+ 75 scheduling in this paper to indicate to work on the remaining graph.
87
+ 76 Without irrelevant information, our experiments show that our approach reaches SOTA by outper
88
+ 77 forming the above mentioned construction methods on some well-known open benchmarks, seven
89
+ 78 for JSP and two for FJSP, as described in Section 4. We also observe that even though our model
90
+ 79 is trained for scheduling problems of smaller sizes, our method still performs well for scheduling
91
+ 80 problems of large sizes. Interestingly in our experiments, our approach even reaches zero gap for 49
92
+ 81 among 50 JSP instances whose job numbers are more than 150 on 20 machines.
93
+
94
+ # 82 2 Problem Formulation
95
+
96
+ # 2.1 JSP and FJSP
97
+
98
+ A $n \times m$ JSP instance contains $n$ jobs and $m$ machines. Each job $J _ { j }$ consists of a sequence of $k _ { j }$ operations $\{ O _ { j , 1 } , \dotsc , O _ { j , k _ { j } } \}$ , where operation $O _ { j , i }$ must be started after $O _ { j , i - 1 }$ is finished. One machine can process at most one operation at a time, and preemption is not allowed upon processing operations. In JSP, one operation $O _ { j , i }$ is allowed to be processed on one designated machine, denoted by $M _ { j , i }$ , with a processing time, denoted by $T _ { j , i } ^ { ( o p ) }$ . Table 1 (a) illustrates a $3 \times 3$ JSP instance, where the three jobs have 3, 3, 2 operations respectively, each of which is designated to be processed on
99
+
100
+ 90 one of the three machines $\{ M _ { 1 } , M _ { 2 } , M _ { 3 } \}$ in the table. A solution of a JSP instance is to dispatch all
101
+ 91 operations Oj,i to the corresponding machine Mj,i at time τ (s)j,i , such that the above constraints are
102
+ 92
103
+ 93 While there are different expected goals, such as makespan, tardiness, etc., this paper focuses on
104
+ 94 makespan. Let the first osolution is defined to be $\tau = 0$ in a JSP soluti all operations nitially. , where
105
+ 95 $T ^ { ( m k s p ) } = \operatorname* { m a x } ( \tau _ { j , i } ^ { ( c ) } )$ $O _ { j , i }$ $\tau _ { j , i } ^ { ( c ) } = \tau _ { j , i } ^ { ( s ) } + T _ { j , i } ^ { ( o p ) }$
106
+ 96 denotes the completion time of $O _ { j , i }$ . The makespans for the two solutions illustrated in Figure 1 (a)
107
+ 97 and (b) are 12 and 15 respectively. The objective is to derive a solution that minimizes the makespan
108
+ 98 $T ^ { ( m k s p ) }$ , and the solution of Figure 1 (a) reaches the optimal.
109
+ 99 A $n \times m$ FJSP instance is also a $n \times m$ JSP instance with the following difference. In FJSP,
110
+ 100 all operations $O _ { j , i }$ are allowed to be dispatched to multiple designated machines with designated
111
+ 101 processing times. Table 1 (b) illustrates a $3 \times 3$ FJSP instance, where multiple machines can be
112
+ 102 designated to be processed for one operation. Figure 1 (c) illustrates a solution of an FJSP instance,
113
+ 103 which takes a shorter time than that in Figure 1 (d).
114
+
115
+ Table 1: JSP and FJSP instances
116
+ (b) A $3 \times 3$ FJSP instance
117
+
118
+ <table><tr><td rowspan=1 colspan=1>Job</td><td rowspan=1 colspan=1>Operation</td><td rowspan=1 colspan=1>M1</td><td rowspan=1 colspan=1>M2</td><td rowspan=1 colspan=1>M3</td></tr><tr><td rowspan=3 colspan=1>Job 1</td><td rowspan=1 colspan=1>O1,1</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>O1.2</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>5</td></tr><tr><td rowspan=1 colspan=1>O1.3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>3</td></tr><tr><td rowspan=3 colspan=1>Job 2</td><td rowspan=1 colspan=1>O2,1</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=1 colspan=1>02.2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>02.3</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=2 colspan=1>Job 3</td><td rowspan=1 colspan=1>O3,1</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>03.2</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>2</td></tr></table>
119
+
120
+ (a) A $3 \times 3$ JSP instance
121
+
122
+ <table><tr><td rowspan=1 colspan=1>Job</td><td rowspan=1 colspan=1>Operation</td><td rowspan=1 colspan=1>M1</td><td rowspan=1 colspan=1>M2</td><td rowspan=1 colspan=1>M3</td></tr><tr><td rowspan=3 colspan=1>Job 1</td><td rowspan=1 colspan=1>O1,1</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>O1.2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>5</td></tr><tr><td rowspan=1 colspan=1>O1.3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=3 colspan=1>Job 2</td><td rowspan=1 colspan=1>O2,1</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=1 colspan=1>02,2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>O2,3</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=2 colspan=1>Job 3</td><td rowspan=1 colspan=1>O3,1</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>03.2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>2</td></tr></table>
123
+
124
+ ![](images/54e0e1086515bc311b9d4a17fdee1c89c424b15d95726a4af33fc4a68fbe5ad1.jpg)
125
+ Figure 1: Both (a) and (b) are solutions of the $3 \mathrm { x } 3$ JSP instance in Table 1 (a), and the former has the minimal makespan, 12. Both (c) and (d) are solutions of the $3 \mathrm { x } 3$ FJSP instance in Table 1 (b), and the former has the minimal makespan, 9.
126
+
127
+ # 104 2.2 Construction Heuristics
128
+
129
+ 105 An approach to solving these scheduling problems is to construct solutions step by step in a greedy
130
+ 106 manner, and the heuristics based on this approach is called construction heuristics in this paper. In
131
+ 107 the approach of construction heuristics, a scheduling solution is constructed through a sequence of
132
+ 108 partial solutions in a chronicle order of dispatching operations step by step, defined as follows. The
133
+ 109 $t$ -th partial solution $S _ { t }$ associates with a dispatching time $\tau _ { t }$ and includes a partial set of operations
134
+ 110 that have been dispatched by $\tau _ { t }$ (inclusive) while satisfying the above JSP constraints, and all the
135
+ 111 remaining operations must be dispatched after $\tau _ { t }$ (inclusive). The whole construction starts with $S _ { 0 }$
136
+ 112 where none of operations have been dispatched and the dispatching time is $\tau _ { 0 } = 0$ . For each $S _ { t }$ , a set
137
+ 113 of operations to be chosen for dispatching form a set of pairs of $( M , O )$ , called candidates $C _ { t }$ , where
138
+ 114 operations $O$ are allowed to be dispatched on machines $M$ at $\tau _ { t }$ . An agent (or a heuristic algorithm)
139
+ 115 chooses one from candidates $C _ { t }$ for dispatching, and transits the partial solution to the next $S _ { t + 1 }$ . If
140
+ 116 there exists no operations for dispatching, the whole solution construction process is done and the
141
+ 117 partial solution is a solution, since no further operations are to be dispatched.
142
+ 118 Figure 2 illustrates a solution construction process for the 3x3 JSP instance in Table 1(a), constructed
143
+ 119 through nine partial solutions step by step. The initial partial solution $S _ { 0 }$ starts without any operations
144
+ 120 dispatched as in Figure 2 (a). The initial candidates $C _ { 0 }$ are $\{ ( M _ { 1 } , O _ { 1 , 1 } ) , ( M _ { 3 } , O _ { 2 , 1 } ) , ( \bar { M _ { 1 } } , O _ { 3 , 1 } ) \}$
145
+ 121 Following some heuristic, construct a solution from partial solution $S _ { 0 }$ to $S _ { 9 }$ step by step as in the
146
+ 122 Figure, where the dashed line in red indicate the time $\tau _ { t }$ . The last one $S _ { 9 }$ , the same as the one in
147
+ 123 Figure 1 (a), is a solution, since all operations have been dispatched, and the last operation ends at
148
+ 124 time 12, the makespan of the solution.
149
+ 125 For FJSP, the process of solution construction is almost the same except for that one operation have
150
+ 126 multiple choices from candidates. Besides, an approach based on solution construction can be also
151
+ 127 viewed as the so-called Markov decision process $( M D P )$ , and the MDP formulation for solution
152
+ 128 construction is described in more detail in the appendix.
153
+
154
+ ![](images/cb96d32bb1f5dcecc876eaf54a9e7682b46451e9161fb74084ead5c2b39e2e49.jpg)
155
+ Figure 2: Solution construction, a sequence of partial solutions from $S _ { 0 }$ to $S _ { 8 }$ .
156
+
157
+ # 129 3 Our Approach
158
+
159
+ 130 In this section, we present a new approach, called residual scheduling, to solving scheduling problems.
160
+ 131 We introduce the residual scheduling in Subsection 3.1, describe the design of the graph representation
161
+ 132 in Subsection 3.2, propose a model architecture based on graph neural network in Subsection 3.3 and
162
+ 133 present a method to train this model in Subsection 3.4;
163
+
164
+ # 34 3.1 Residual Scheduling
165
+
166
+ 135 In our approach, the key is to remove irrelevant information, particularly for operations, from states
167
+ 136 (including partial solutions). An important benefit from this is that we do not need to include all
168
+ 137 irrelevant information while training to minimize the makespan. Let us illustrate by the state for the
169
+ 138 partial solution $S _ { 3 }$ at time $\tau _ { 3 } = 3$ in Figure 2 (d). All processing by $\tau _ { 3 }$ are irrelevant to the remaining
170
+ 139 scheduling. Since operations $O _ { 1 , 1 }$ and $O _ { 2 , 1 }$ are both finished and irrelevant the rest of scheduling,
171
+ 140 they can be removed from the state of $S _ { 3 }$ . In addition, operation $O _ { 2 , 2 }$ is dispatched at time 2 (before
172
+ 141 $\tau _ { 3 } = 3$ ) and its processing time is $T _ { 2 , 1 } ^ { ( o p ) } = 4$ , so the operation is marked as ongoing. Thus, the
173
+ 142 operation can be modified to start at $\tau _ { 3 } = 3$ with a processing time . Thus, the modified
174
+ 143 state for $S _ { 3 }$ do not contain both $O _ { 1 , 1 }$ and $O _ { 2 , 1 }$ , and modify $O _ { 2 , 2 }$ as above. Let us consider two more
175
+ 144 examples. For $S _ { 4 }$ , one more operation $O _ { 2 , 2 }$ is dispatched and thus marked as ongoing, however, the
176
+ 145 time $\tau _ { 4 }$ remains unchanged and no more operations are removed. In this case, the state is almost the
177
+ 146 same except for including one more ongoing operation $O _ { 2 , 2 }$ . Then, for $S _ { 5 }$ , two more operations $O _ { 3 , 1 }$
178
+ 147 and $O _ { 2 , 2 }$ are removed and the ongoing operation $O _ { 1 , 2 }$ changes its processing time to the remaining
179
+ 148 time (5-3).
180
+ 149 For residual scheduling, we also reset the dispatching time $\tau = 0$ for all states with partial solutions
181
+ 150 modified as above, so we derive makespans which is also irrelevant to the earlier operations. Given
182
+ 151 a scheduling policy $\pi$ , $T _ { \pi } ^ { ( m k s p ) } ( S )$ is defined to be the makespan derived from an episode starting
183
+ 152 from states $S$ by following $\pi$ , and $T _ { \pi } ^ { ( m k s p ) } ( S , a )$ the makespan by taking action $a$ on $S$ .
184
+
185
+ # 153 3.2 Residual Graph Representation
186
+
187
+ 154 In this paper, our model design is based on graph neural network (GNN), and leverage GNN to
188
+ 155 extract the scheduling decision from the relationship in graph. In this subsection, we present the
189
+ 156 graph representation. Like many other researchers such as Park et al. (2021a), we formulate a partial
190
+ 157 solution into a graph $\mathcal { G } = ( \nu , \mathcal { E } )$ , where $\nu$ is a set of nodes and $\mathcal { E }$ is a set of edges. A node is either a
191
+ 158 machine node $M$ or an operation node $O$ . An edge connects two nodes to represent the relationship
192
+ 159 between two nodes, basically including three kinds of edges, namely operation-to-operation $( O \to O$ ),
193
+ 160 machine-to-operation $M O$ ) and operation-to-machine $( O \to M$ ). All operations in the same
194
+ 161 job are fully connected as $O O$ edges. If an operation $O$ is able to be performed on a machine
195
+ 162 $M$ , there exists both $O \to M$ and $M O$ directed edges. In (Park et al., 2021a), they also let all
196
+ 163 machines be fully connected as $M \to M$ edges. However, our experiments in section 4 show that
197
+ 164 mutual $M \to M$ edges do not help much based on our Residual Scheduling. An illustration for graph
198
+ 165 representation of $S _ { 3 }$ is depicted in Figure 3 (a).
199
+ 166 In the graph representation, all nodes need to include some attributes so that a partial solution $S$ at
200
+ 167 the dispatching time $\tau$ can be supported in the MDP formulation (in the appendix). Note that many of
201
+ 168 the attributes below are normalized to reduce variance. For nodes corresponding to operations $O _ { j , i }$ ,
202
+ 169 we have the following attributes:
203
+ 170 Status $\phi _ { j , i }$ : The operation status $\phi _ { j , i }$ is completed if the operation has been finished by $\tau$ , ongoing if
204
+ 171 the operation is ongoing (i.e., has been dispatched to some machine by $\tau$ and is still being processed
205
+ 172 at $\tau$ ), ready if the operation designated to the machine which is idle has not been dispatched yet and
206
+ 173 its precedent operation has been finished, and unready otherwise. For example, in Figure 3 (a), the
207
+ 174 gray nodes are completed, the red ongoing, the yellow ready and the white unready. In our residual
208
+ 175 scheduling, there exists no completed operations in all partial solutions, since they are removes for
209
+ 176 irrelevance of the rest of scheduling. The attribute is a one-hot vector to represent the current status
210
+ 177 of the operation, which is one of ongoing, ready and unready. Illustration for all states $S _ { 0 }$ to $S _ { 8 }$ are
211
+ 178 shown in the appendix.
212
+ 179 Normalized processing time $\bar { T } _ { j , i } ^ { ( o p ) }$ : Let the maximal processing time be $T _ { m a x } ^ { ( o p ) } = \operatorname* { m a x } _ { \forall j , i } ( T _ { j , i } ^ { ( o p ) } )$
213
+ 180 Then, T¯(op)j,i $\bar { T } _ { j , i } ^ { ( o p ) } = T _ { j , i } ^ { ( o p ) } / T _ { m a x } ^ { ( o p ) }$ . In our residual scheduling, the operations that have been finished are
214
+ 181 removed in partial solutions and therefore their processing time can be ignored; the operations that
215
+ 182 has not been dispatched yet still keep their processing times the same; the operations that are ongoing
216
+ 183 change their processing times to the remaining times after the dispatching time $\tau _ { t }$ . As for FJSP, the
217
+ 184 operations that has not been dispatched yet may have several processing times on different machines,
218
+ 185 and thus we can simply choose the average of these processing times.
219
+
220
+ ![](images/a3a8af5ab1851b807add19a4a2a54f81ec9c7979dcede6e1a0cd5113aacd0d36.jpg)
221
+ Figure 3: Graph representation and networks.
222
+
223
+ ob remaining time , and let the process $\bar { T } _ { j , i } ^ { ( j o b ) }$ : Let the rest of pre for the whole job $J _ { j }$ $T _ { j , i } ^ { ( j o b ) } =$ $\sum _ { \forall i ^ { \prime } \geq i } T _ { j , i ^ { \prime } } ^ { ( o p ) }$ aced by th ing timocessing time for the original jo $j$ $\begin{array} { r } { T _ { j } ^ { ( j o b ) } = \sum _ { \forall i ^ { \prime } } T _ { j , i ^ { \prime } } ^ { ( o p ) } } \end{array}$ . In practice, T ( j ob )j is $j$ $\bar { T } _ { j , i } ^ { ( j o b ) } = T _ { j , i } ^ { ( j o b ) } / T _ { j } ^ { ( j o b ) }$ . For FJSP, since operations $O _ { j , i }$ can be dispatched to different designated machines $M _ { l }$ , say with the processing time T (op)j,i,l , we simply let T (op)j,i be the average of $T _ { j , i , l } ^ { ( o p ) }$ for all $M _ { l }$ .
224
+
225
+ For machine nodes corresponding to machines $M _ { l }$ , we have the following attributes:
226
+
227
+ Machine status $\phi _ { l }$ : The machine status $\phi _ { l }$ is processing if some operation has been dispatched to and is being processed by $M _ { l }$ at $\tau$ , and idle otherwise (no operation is being processed at $\tau$ ). The attribute is a one-hot vector to represent the current status, which is one of processing and idle.
228
+
229
+ Normalized operation processing time $\bar { T } _ { l } ^ { ( m a c ) }$ : On the machine $M _ { l }$ , the processing time $T _ { l } ^ { ( m a c ) }$ is $T _ { j , i } ^ { ( o p ) }$ (the same as the normalized processing time for node $O _ { j , i }$ ) if the machine status is processing, i.e., some ongoing operation $O _ { j , i }$ is being processed but not finished yet, is zero if the machine status is idle. Then, this attribute is normalized to $T _ { m a x } ^ { ( o p ) }$ and thus $\bar { T } _ { l } ^ { ( m a c ) } = T _ { l } ^ { ( m a c ) } / T _ { m a x } ^ { ( o p ) }$ .
230
+
231
+ Now, consider edges in a residual scheduling graph. As described above, there exists three relationship sets for edges, $O O$ , $O \to M$ and $M O$ . First, for the same job, say $J _ { j }$ , all of its operation nodes for $O _ { j , i }$ are fully connected. Note that for residual scheduling the operations finished by the dispatching time $\tau$ are removed and thus have no edges to them. Second, a machine node for $M _ { l }$ is connected to an operation node for $O _ { j , i }$ , if the operation $O _ { j , i }$ is designated to be processed on the machine $M _ { l }$ , which forms two edges $\dot { O } M$ and $M O$ . Both contains the following attribute.
232
+
233
+ Normalized operation processing tim e T¯(edge): The attribute is $\bar { T } _ { j , i , l } ^ { ( e d g e ) } = T _ { j , i } ^ { ( o p ) } / T _ { m a x } ^ { ( o p ) }$ . Here, $T _ { j , i } ^ { ( o p ) } = T _ { j , i , l } ^ { ( o p ) }$ $O _ { j , i }$ $T _ { j , i } ^ { ( o p ) }$ is the remaining time as described above.
234
+
235
+ # 3.3 Graph Neural Network
236
+
237
+ In this subsection, we present our model based on graph neural network (GNN). GNN are a family of deep neural networks (Battaglia et al., 2018) that can learn representation of graph-structured data, widely used in many applications (Lv et al., 2021; Zhou et al., 2020). A GNN aggregates information from node itself and its neighboring nodes and then update the data itself, which allows the GNN to capture the complex relationships within the data graph. For GNN, we choose Graph Isomorphism Network (GIN), which was shown to have strong discriminative power ( $\mathrm { { X u } }$ et al., 2019) and summarily reviewed as follows. Given a graph $\mathcal { G } = ( \nu , \mathcal { E } )$ and $K$ GNN layers $K$ iterations), GIN performs the $k$ -th iterations of updating feature embedding $h ^ { ( k ) }$ for each node $v \in \mathcal V$ :
238
+
239
+ $$
240
+ h _ { v } ^ { ( k ) } = M L P ^ { ( k ) } ( ( 1 + \epsilon ^ { ( k ) } ) h _ { v } ^ { ( k - 1 ) } + \sum _ { u \in N _ { b } ( v ) } h _ { u } ^ { ( k - 1 ) } ) ,
241
+ $$
242
+
243
+ 217 where $h _ { v } ^ { ( k ) }$ is the embedding of node $v$ at the $k$ -th layer, $\epsilon ^ { ( k ) }$ is an arbitrary number that can be
244
+ 218 learned, and $N _ { b } ( v )$ is the neighbors of $v$ via edges in $\mathcal { E }$ . Note that $h _ { v } ^ { ( 0 ) }$ refers to its raw features for
245
+ 219 input. $M L P ^ { ( k ) }$ is a Multi-Layer Perceptron $( M L P )$ for the $k$ -th layer with a batch normalization
246
+ 220 (Ioffe and Szegedy, 2015).
247
+ 221 Furthermore, we actually use heterogeneous GIN, also called HGIN, since there are two types of
248
+ 222 nodes, machine and operation nodes, and three relations, $O O$ , $O \to M$ and $M O$ in the
249
+ 223 graph representation. Although we do not have cross machine relations $M \to M$ as described above,
250
+ 224 updating machine nodes requires to include the update from itself as in (1), that is, there is also one
251
+ 225 more relation $M \to M$ . Thus, HGIN encodes graph information between all relations by using the
252
+ 226 four MLPs as follows,
253
+
254
+ $$
255
+ h _ { v } ^ { ( k + 1 ) } = \sum _ { \mathcal { R } } M L P _ { \mathcal { R } } ^ { ( k + 1 ) } ( ( 1 + \epsilon _ { \mathcal { R } } ^ { ( k + 1 ) } ) h _ { v } ^ { ( k ) } + \sum _ { u \in N _ { \mathcal { R } } ( v ) } h _ { u } ^ { ( k ) } )
256
+ $$
257
+
258
+ where 227 $\mathcal { R }$ is one of the above fo elatio $M L P _ { \mathcal { R } } ^ { ( k ) }$ is the MLP for $\mathcal { R }$ . For example, for $S _ { 0 }$ in Figure 2 (a), the embedding of $M _ { 1 }$ $( k + 1 )$ -st iteration can be derived as follows.
259
+
260
+ $$
261
+ h _ { M _ { 1 } } ^ { ( k + 1 ) } = M L P _ { M M } ^ { ( k + 1 ) } ( ( 1 + \epsilon _ { M M } ^ { ( k + 1 ) } ) h _ { M _ { 1 } } ^ { ( k ) } ) + M L P _ { O M } ^ { ( k + 1 ) } ( h _ { O _ { 1 , 1 } } ^ { ( k ) } + h _ { O _ { 1 , 2 } } ^ { ( k ) } + h _ { O _ { 1 , 3 } } ^ { ( k ) } )
262
+ $$
263
+
264
+ 229 Similarly, the embedding of $O _ { 1 , 1 }$ in the $( k + 1 )$ -st iteration is:
265
+
266
+ $$
267
+ h _ { O _ { 1 , 1 } } ^ { ( k + 1 ) } = M L P _ { O O } ^ { ( k + 1 ) } ( ( 1 + \epsilon _ { O O } ^ { ( k + 1 ) } ) h _ { O _ { 1 , 1 } } ^ { ( k ) } + h _ { O _ { 1 , 2 } } ^ { ( k ) } + h _ { O _ { 1 , 3 } } ^ { ( k ) } ) + M L P _ { M O } ^ { ( k + 1 ) } ( h _ { M _ { 1 } } ^ { ( k ) } )
268
+ $$
269
+
270
+ 230 In our approach, an action includes the two phases, graph embedding phase and action selection phase.
271
+ 231 Let $h _ { \mathcal { G } } ^ { ( k ) }$ denote the whole embedding of the graphs $\mathcal { G }$ , a summation of the embeddings of all nodes,
272
+ 232 $h _ { v } ^ { ( k + 1 ) }$ . In the graph embedding phase, we use an HGIN to encode node and graph embeddings as
273
+ 233 described above. An example with three HGIN layers is illustrated in Figure 3 (b).
274
+
275
+ In the action selection phase, we select an action based on a policy, after node and graph embedding are encoded in the graph embedding phase. The policy is described as follows. First, collect all ready operations $O$ to be dispatched to machines $M$ . Then, for all pairs $( M , O )$ , feed their node embeddings $( h _ { M } ^ { ( k ) } , h _ { O } ^ { ( k ) } )$ into a MLP $S c o r e ( M , O )$ to calculate their scores as shown in Figure 3 (c). The probability of selecting $( M , O )$ is calculated based on a softmax function of all scores, which also serves as the model policy $\pi$ for the current state.
276
+
277
+ # 3.4 Policy-Based RL Training
278
+
279
+ 41 In this paper, we propose to use a policy-based RL training mechanism that follows REINFORCE
280
+ 42 (Sutton and Barto, 2018) to update our model by policy gradient with a normalized advantage
281
+ 43 makespan with respect to a baseline policy $\pi _ { b }$ as follows.
282
+
283
+ $$
284
+ A _ { \pi } ( S , a ) = { \frac { T _ { \pi _ { b } } ^ { ( m k s p ) } ( S , a ) - T _ { \pi } ^ { ( m k s p ) } ( S , a ) } { T _ { \pi _ { b } } ^ { ( m k s p ) } ( S , a ) } }
285
+ $$
286
+
287
+ 244 In this paper, we choose a lightweight PDR, MWKR, as baseline $\pi _ { b }$ , which performed best for
288
+ 245 makespan among all PDRs reported from the previous work (Zhang et al., 2020). In fact, our
289
+ 246 experiment also shows that using MWKR is better than the other PDRs shown in the appendix. The
290
+ 247 model for policy $\pi$ is parametrized by $\theta$ , which is updated by $\nabla _ { \boldsymbol { \theta } } l o g \pi _ { \boldsymbol { \theta } } A _ { \pi _ { \boldsymbol { \theta } } } \bigl ( S _ { t } , a _ { t } \bigr )$ . Our algorithm
291
+ 248 based on REINFORCE is listed in the appendix.
292
+
293
+ # 4 Experiments
294
+
295
+ # 4.1 Experimental Settings and Evaluation Benchmarks
296
+
297
+ In our experiments, the settings of our model are described as follows. All embedding and hidden vectors in our model have a dimension of 256. The model contains three HGIN layers for graph embedding, and an MLP for the score function, as shown in Figure 3 (b) and (c). All MLP networks including those in HGIN and for score contain two hidden layers. The parameters of our model, such as MLP, generally follow the default settings in PyTorch (Paszke et al., 2019) and PyTorch Geometric (Fey and Lenssen, 2019). More settings are in the appendix.
298
+
299
+ Each of our models is trained with one million episodes, each with one scheduling instance. Each instance is generated by following the procedure which is used to generate the TA dataset (Taillard, 1993). Given $( N , M )$ , we use the procedure to generate an $n \times m$ JSP instance by conforming to the following distribution, $n \sim \mathcal { U } ( \bar { 3 } , N )$ , $m \sim \mathcal { U } ( 3 , n )$ , and operation count $k _ { j } = m$ , where $\boldsymbol { \mathcal { U } } ( \boldsymbol { x } , \boldsymbol { y } )$ represents a distribution that uniformly samples an integer in a close interval $[ x , y ]$ at random. The details of designation for machines and processing times refer to (Taillard, 1993) and thus are omitted here. We choose (10,10) for all experiments, since (10,10) generally performs better than the other two as described in the appendix. Following the method described in Subsection 3.4, the model is updated from the above randomly generated instances. For testing our models for JSP and FJSP, seven JSP open benchmarks and two FJSP open benchmarks are used, as listed in the appendix.
300
+
301
+ 67 The performance for a given policy method $\pi$ on an instance is measured by the makespan gap $G$
302
+ 68 defined as
303
+
304
+ $$
305
+ G = \frac { T _ { \pi } ^ { \left( m k s p \right) } - T _ { \pi * } ^ { \left( m k s p \right) } } { T _ { \pi * } ^ { \left( m k s p \right) } }
306
+ $$
307
+
308
+ where 269 $T _ { \pi * } ^ { ( m k s p ) }$ is the optimal makespan or the best-effort makespan, from a mathematical optimization 270 tool, OR-Tools, serving as . By the best-effort makespan, we mean the makespan derived with a
309
+
310
+ Table 2: Average makespan gaps for TA benchmarks.
311
+
312
+ <table><tr><td rowspan=1 colspan=1>Size</td><td rowspan=1 colspan=1>15×15</td><td rowspan=1 colspan=1>20×15</td><td rowspan=1 colspan=1>20×20</td><td rowspan=1 colspan=1>30×15</td><td rowspan=1 colspan=1>30×20</td><td rowspan=1 colspan=1>50×15</td><td rowspan=1 colspan=1>50×20</td><td rowspan=1 colspan=1>100×20</td><td rowspan=1 colspan=1>Aug.</td></tr><tr><td rowspan=1 colspan=1>RS</td><td rowspan=1 colspan=1>0.148</td><td rowspan=1 colspan=1>0.165</td><td rowspan=1 colspan=1>0.169</td><td rowspan=1 colspan=1>0.144</td><td rowspan=1 colspan=1>0.177</td><td rowspan=1 colspan=1>0.067</td><td rowspan=1 colspan=1>0.100</td><td rowspan=2 colspan=1>0.0260.050</td><td rowspan=2 colspan=1>0.1250.150</td></tr><tr><td rowspan=1 colspan=1>RS+op</td><td rowspan=1 colspan=1>0.143</td><td rowspan=1 colspan=1>0.193</td><td rowspan=1 colspan=1>0.159</td><td rowspan=1 colspan=1>0.192</td><td rowspan=1 colspan=1>0.213</td><td rowspan=1 colspan=1>0.123</td><td rowspan=1 colspan=1>0.126</td></tr><tr><td rowspan=1 colspan=1>MWKR</td><td rowspan=2 colspan=1>0.1910.2050.258</td><td rowspan=2 colspan=1>0.2330.2350.328</td><td rowspan=2 colspan=1>0.2180.2170.277</td><td rowspan=2 colspan=1>0.2390.2280.352</td><td rowspan=2 colspan=1>0.2510.2490.344</td><td rowspan=3 colspan=1>0.1680.1730.2410.206</td><td rowspan=3 colspan=1>0.1790.1760.2550.239</td><td rowspan=3 colspan=1>0.0830.0910.1440.135</td><td rowspan=3 colspan=1>0.1950.1970.2750.254</td></tr><tr><td rowspan=1 colspan=1>MORSPT</td></tr><tr><td rowspan=1 colspan=1>FIFO</td><td rowspan=1 colspan=1>0.239</td><td rowspan=1 colspan=1>0.314</td><td rowspan=1 colspan=1>0.273</td><td rowspan=1 colspan=1>0.311</td><td rowspan=1 colspan=1>0.311</td></tr><tr><td rowspan=2 colspan=1>L2DParkSchN</td><td rowspan=2 colspan=1>0.2590.2010.152</td><td rowspan=1 colspan=1>0.300</td><td rowspan=1 colspan=1>0.316</td><td rowspan=1 colspan=1>0.329</td><td rowspan=1 colspan=1>0.336</td><td rowspan=1 colspan=1>0.223</td><td rowspan=1 colspan=1>0.265</td><td rowspan=2 colspan=1>0.1360.0920.066</td><td rowspan=2 colspan=1>0.2700.2210.161</td></tr><tr><td rowspan=1 colspan=1>0.2490.194</td><td rowspan=1 colspan=1>0.2920.172</td><td rowspan=1 colspan=1>0.2460.190</td><td rowspan=1 colspan=1>0.3190.237</td><td rowspan=1 colspan=1>0.1590.138</td><td rowspan=1 colspan=1>0.2120.135</td></tr></table>
313
+
314
+ 271 sufficiently large time limitation, namely half a day with OR-Tools. For comparison in experiments,
315
+ 272 we use a server with Intel Xeon E5-2683 CPU and a single NVIDIA GeForce GTX 1080 Ti GPU.
316
+ 273 Our method uses a CPU thread and a GPU to train and evaluate, while OR-Tools uses eight threads
317
+ 274 to find the solution.
318
+
319
+ # 4.2 Experiments for JSP
320
+
321
+ For JSP, we first train a model based on residual scheduling, named RS. For ablation testing, we also train a model, named $\mathrm { R S + o p }$ , by following the same training method but without removing irrelevant operations. When using these models to solve testing instances, action selection is based on the greedy policy that simply chooses the action $( M , O )$ with the highest score deterministically, obtained from the score network as in Figure 3 (c).
322
+
323
+ 281 For comparison, we consider the three DRL construction heuristics, respectively developed in (Zhang
324
+ 282 et al., 2020) called L2D, (Park et al., 2021b) by Park et al., and (Park et al., 2021a), called ScheduleNet.
325
+ 283 We directly use the performance results of these methods for open benchmarks from their articles.
326
+ 284 For simplicity, they are named L2D, Park and SchN respectively in this paper. We also include some
327
+ 285 construction heuristics based PDR, such as MWKR, MOR, SPT and FIFO. Besides, to derive the
328
+ 286 gaps to the optimum in all cases, OR-Tools serve as $\pi *$ as described in (6).
329
+ 287 Now, let us analyze the performances of RS as follows. Table 2 shows the average makespan gaps
330
+ 288 for each collection of JSP TA benchmarks with sizes, $1 5 { \times } 1 5$ , $2 0 \times 1 5$ , $2 0 \times 2 0$ , $3 0 \times 1 5$ , $3 0 \times 2 0$ , $5 0 \times 1 5$ ,
331
+ 289 $5 0 \times 2 0$ and $1 0 0 \times 2 0$ , where the best performances (the smallest gaps) are marked in bold. In general,
332
+ 290 RS performs the best, and generally outperforms the other methods for all collections by large
333
+ 291 margins, except for that it has slightly higher gaps than ${ \mathrm { R S + o p } }$ for the two collections, $1 5 \times 1 5$ and
334
+ 292 $2 0 \times 2 0$ . In fact, ${ \mathrm { R S + o p } }$ also generally outperforms the rest of methods, except for that it is very
335
+ 293 close to SchN for two collections. For the other six open benchmarks, ABZ, FT, ORB, YN, SWV
336
+ 294 and LA, the performances are similar and thus presented in the appendix. It is concluded that RS
337
+ 295 generally performs better than other construction heuristics by large margins.
338
+
339
+ # 296 4.3 Experiments for FJSP
340
+
341
+ Table 3: Average makespan gaps for FJSP open benchmarks
342
+
343
+ <table><tr><td>Method</td><td>MK</td><td>LA(rdata)</td><td>LA(edata)</td><td>LA(vdata)</td></tr><tr><td>RS</td><td>0.232</td><td>0.099</td><td>0.146</td><td>0.031</td></tr><tr><td>RS+op</td><td>0.254</td><td>0.113</td><td>0.168</td><td>0.029</td></tr><tr><td>DRL-G</td><td>0.254</td><td>0.111</td><td>0.150</td><td>0.040</td></tr><tr><td>MWKR MOR</td><td>0.282 0.296 0.457</td><td>0.125 0.147</td><td>0.149 0.179</td><td>0.051 0.061</td></tr></table>
344
+
345
+ 297 For FJSP, we also train a model based on residual scheduling, named RS, and a ablation version,
346
+ 298 named $\mathrm { R S + o p }$ , without removing irrelevant operations. We compares ours with one DRL construction
347
+ 299 heuristics developed by (Song et al., 2023), called DRL-G, and four PDR-based heuristics, MOR,
348
+ 00 MWKR, SPT and FIFO. We directly use the performance results of these methods for open datasets
349
+ 01 according to the reports from (Song et al., 2023).
350
+ 02 Table 3 shows the average makespan gaps in the four open benchmarks, MK, LA(rdata), LA(edata)
351
+ 03 and LA(vdata). From the table, RS generally outperforms all the other methods for all benchmarks
352
+ 04 by large margins, except for that ${ \mathsf { R S + o p } }$ is slightly better for the benchmark LA(vdata).
353
+
354
+ # 05 5 Discussions
355
+
356
+ In this paper, we propose a new approach, called residual scheduling, to solving JSP an FJSP problems, and the experiments show that our approach reaches SOTA among DRL-based construction heuristics on the above open JSP and FJSP benchmarks. We further discusses three issues: large instances, computation times and further improvement.
357
+
358
+ ![](images/1b83fd2ef9921abe986163a176919527de1940ffe5a722430f846b273b3a20da.jpg)
359
+ Figure 4: Average makespan gaps of JSP instances with different problem sizes.
360
+
361
+ 310 First, from the above experiments particularly for TA benchmark for JSP, we observe that the average
362
+ 311 gaps gets smaller as the number of jobs increases, even if we use the same model trained with
363
+ 312 $\bar { ( \cal N , M ) } = ( 1 0 , 1 0 )$ . In order to investigate size-agnostics, we further generate 13 collections of JSP
364
+ 313 instances of sizes for testing, from $1 5 \times 1 5$ to $2 0 0 \times 2 0$ , and generate 10 instances for each collection
365
+ 314 by using the procedure above. Figure 4 shows the average gaps for these collections for RS and L2D,
366
+ 315 and these collections are listed in the order of sizes in the x-axis. Note that we only show the results
367
+ 316 of L2D in addition to our RS, since L2D is the only open-source among the above DRL heuristics.
368
+ 317 Interestingly, using RS, the average gaps are nearly zero for the collections with sizes larger than 100
369
+ 318 $\times 1 5$ , namely, $1 0 0 \times 1 5$ , $1 0 0 \times 2 0$ , $1 5 0 \times 1 5$ , $2 0 0 \times 1 5$ and $2 0 0 \times 2 0$ . Among the 50 JSP instances
370
+ 319 in the five collections, 49 reaches zero gaps. A strong implication is that our RS approach can be
371
+ 320 scaled up for job sizes and even reach the optimal for sufficient large job count.
372
+ 321 Second, the computation times for RS are relatively small and has low variance like most of other
373
+ 322 construction heuristics. Here, we just use the collection of TA $1 0 0 \mathrm { x } 2 0$ for illustration. It takes about
374
+ 323 30 seconds on average for both RS and $\mathrm { R S + o p }$ , about 28 for L2D and about 444 for SchN. In contrast,
375
+ 324 it takes about 4000 seconds with high variance for OR-tools. The times for other collections are listed
376
+ 325 in more detail in the appendix.
377
+ 326 Third, as proposed by Song et al. (2023), construction heuristics can further improve the gap by
378
+ 327 constructing multiple solutions based on the softmax policy, in addition to the greedy policy. They
379
+ 328 had a version constructing 100 solutions for FJSP, called $\mathrm { \ D R L + 1 0 0 }$ in this paper. In this paper, we
380
+ 329 also implement a RS version for FJSP based on the softmax policy, as described in Subsection 3.3,
381
+ 330 and then use the version, called ${ \mathrm { R S } } { + } 1 0 0 \ $ , to constructing 100 solutions. In Table 4, the experimental
382
+ 331 results show that ${ \mathrm { R S } } { + } 1 0 0 \ $ performs the best, much better than RS, DRL-G and $\mathrm { \ D R L + 1 0 0 }$ . An
383
+ 332 important property for such an improvement is that constructing multiple solutions can be done in
384
+ 333 parallel. That is, for construction heuristics, the solution quality can be improved by adding more
385
+ 334 computation powers.
386
+
387
+ Table 4: Average makespan gaps for FJSP open benchmark.
388
+
389
+ <table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>MK</td><td rowspan=1 colspan=1>LA(rdata)</td><td rowspan=1 colspan=1>LA(edata)</td><td rowspan=1 colspan=1>LA(vdata)</td></tr><tr><td rowspan=1 colspan=1>RSRS+100</td><td rowspan=1 colspan=1>0.2320.154</td><td rowspan=1 colspan=1>0.0990.047</td><td rowspan=1 colspan=1>0.1460.079</td><td rowspan=1 colspan=1>0.0310.007</td></tr><tr><td rowspan=1 colspan=1>DRL-GDRL+100</td><td rowspan=1 colspan=1>0.2540.190</td><td rowspan=1 colspan=1>0.1110.058</td><td rowspan=1 colspan=1>0.1500.082</td><td rowspan=1 colspan=1>0.0400.014</td></tr></table>
390
+
391
+ # References
392
+
393
+ Majid Abdolrazzagh-Nezhad and Salwani Abdullah. 2017. Job Shop Scheduling: Classification, Constraints and Objective Functions. International Journal of Computer and Information Engineering 11, 4 (2017), 429–434.
394
+
395
+ Joseph William Adams, Egon Balas, and Daniel J. Zawack. 1988. The Shifting Bottleneck Procedure for Job Shop Scheduling. Management science 34, 3 (1988), 391–401.
396
+
397
+ David L. Applegate and William J. Cook. 1991. A Computational Study of the Job-Shop Scheduling Problem. INFORMS Journal on Computing 3, 2 (1991), 149–156. https://doi.org/10.1287/ ijoc.3.2.149
398
+
399
+ Peter W. Battaglia, Jessica B. Hamrick, Victor Bapst, Alvaro Sanchez-Gonzalez, Vinícius Flores Zambaldi, Mateusz Malinowski, Andrea Tacchetti, David Raposo, Adam Santoro, Ryan Faulkner, Çaglar Gülçehre, H. Francis Song, Andrew J. Ballard, Justin Gilmer, George E. Dahl, Ashish Vaswani, Kelsey R. Allen, Charles Nash, Victoria Langston, Chris Dyer, Nicolas Heess, Daan Wierstra, Pushmeet Kohli, Matthew M. Botvinick, Oriol Vinyals, Yujia Li, and Razvan Pascanu. 2018. Relational inductive biases, deep learning, and graph networks. CoRR abs/1806.01261 (2018). arXiv:1806.01261 http://arxiv.org/abs/1806.01261
400
+
401
+ Dennis Behnke and Martin Josef Geiger. 2012. Test instances for the flexible job shop scheduling problem with work centers. Arbeitspapier/Research Paper/Helmut-Schmidt-Universität, Lehrstuhl für Betriebswirtschaftslehre, insbes. Logistik-Management (2012).
402
+
403
+ Paolo Brandimarte. 1993. Routing and scheduling in a flexible job shop by tabu search. Ann. Oper. Res. 41, 3 (1993), 157–183. https://doi.org/10.1007/BF02023073
404
+
405
+ IBM ILOG Cplex. 2009. V12. 1: User’s Manual for CPLEX. International Business Machines Corporation 46, 53 (2009), 157.
406
+
407
+ Mauro Dell’Amico and Marco Trubian. 1993. Applying tabu search to the job-shop scheduling problem. Annals of Operations Research 41, 3 (1993), 231–252. https://doi.org/10.1007/ BF02023076
408
+
409
+ Alhussein Fawzi, Matej Balog, Aja Huang, Thomas Hubert, Bernardino Romera-Paredes, Mohammadamin Barekatain, Alexander Novikov, Francisco J R Ruiz, Julian Schrittwieser, Grzegorz Swirszcz, et al. 2022. Discovering faster matrix multiplication algorithms with reinforcement learning. Nature 610, 7930 (2022), 47–53.
410
+
411
+ Matthias Fey and Jan Eric Lenssen. 2019. Fast Graph Representation Learning with PyTorch Geometric, In ICLR Workshop on Representation Learning on Graphs and Manifolds. CoRR abs/1903.02428. arXiv:1903.02428 http://arxiv.org/abs/1903.02428
412
+
413
+ M. R. Garey and David S. Johnson. 1979. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, USA.
414
+
415
+ Amit Kumar Gupta and Appa Iyer Sivakumar. 2006. Job shop scheduling techniques in semiconductor manufacturing. The International Journal of Advanced Manufacturing Technology 27, 11 (2006), 1163–1169.
416
+
417
+ Reinhard Haupt. 1989. A survey of priority rule-based scheduling. Operations-Research-Spektrum 11, 1 (1989), 3–16.
418
+
419
+ Johann Hurink, Bernd Jurisch, and Monika Thole. 1994. Tabu search for the job-shop scheduling problem with multi-purpose machines. Operations-Research-Spektrum 15 (1994), 205–215.
420
+
421
+ Sergey Ioffe and Christian Szegedy. 2015. Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift. In International Conference on Machine Learning (ICML) (JMLR Workshop and Conference Proceedings, Vol. 37), Francis R. Bach and David M. Blei (Eds.). JMLR.org, 448–456. http://proceedings.mlr.press/v37/ioffe15.html
422
+
423
+ 381 Klaus Jansen, Monaldo Mastrolilli, and Roberto Solis-Oba. 2000. Approximation Algorithms for
424
+ 382 Flexible Job Shop Problems. In Latin American Symposium on Theoretical Informatics (Lecture
425
+ 383 Notes in Computer Science, Vol. 1776), Gaston H. Gonnet, Daniel Panario, and Alfredo Viola
426
+ 384 (Eds.). Springer, 68–77. https://doi.org/10.1007/10719839_7
427
+ 385 BJ Lageweg, JK Lenstra, and AHG Rinnooy Kan. 1977. Job-shop scheduling by implicit enumeration.
428
+ 386 Management Science 24, 4 (1977), 441–450.
429
+
430
+ Stephen Lawrence. 1984. Resouce constrained project scheduling: An experimental investigation of heuristic scheduling techniques (Supplement). Graduate School of Industrial Administration, Carnegie-Mellon University (1984).
431
+
432
+ 90 Zhigang Lian, Bin Jiao, and Xingsheng Gu. 2006. A similar particle swarm optimization algorithm
433
+ 91 for job-shop scheduling to minimize makespan. Appl. Math. Comput. 183, 2 (2006), 1008–1017.
434
+ 92 https://doi.org/10.1016/j.amc.2006.05.168
435
+ 93 Chun-Cheng Lin, Der-Jiunn Deng, Yen-Ling Chih, and Hsin-Ting Chiu. 2019. Smart Manufacturing
436
+ 394 Scheduling With Edge Computing Using Multiclass Deep Q Network. IEEE Trans. Ind. Informatics
437
+ 395 15, 7 (2019), 4276–4284. https://doi.org/10.1109/TII.2019.2908210
438
+ 96 Min Liu, Zhi-jiang Sun, Junwei Yan, and Jing-song Kang. 2011. An adaptive annealing genetic
439
+ 97 algorithm for the job-shop planning and scheduling problem. Expert Systems with Applications 38,
440
+ 98 8 (2011), 9248–9255. https://doi.org/10.1016/j.eswa.2011.01.136
441
+ 99 Shu Luo. 2020. Dynamic scheduling for flexible job shop with new job insertions by deep reinforce
442
+ 00 ment learning. Applied Soft Computing 91 (2020), 106208. https://doi.org/10.1016/j.
443
+ 01 asoc.2020.106208
444
+ 402 Mingqi Lv, Zhaoxiong Hong, Ling Chen, Tieming Chen, Tiantian Zhu, and Shouling Ji. 2021.
445
+ 403 Temporal Multi-Graph Convolutional Network for Traffic Flow Prediction. IEEE Transactions
446
+ 404 on Intelligent Transportation Systems 22, 6 (2021), 3337–3348. https://doi.org/10.1109/
447
+ 405 TITS.2020.2983763
448
+ 406 Azalia Mirhoseini, Anna Goldie, Mustafa Yazgan, Joe Wenjie Jiang, Ebrahim M. Songhori, Shen
449
+ 407 Wang, Young-Joon Lee, Eric Johnson, Omkar Pathak, Azade Nazi, Jiwoo Pak, Andy Tong, Kavya
450
+ 408 Srinivasa, Will Hang, Emre Tuncer, Quoc V. Le, James Laudon, Richard Ho, Roger Carpenter, and
451
+ 409 Jeff Dean. 2021. A graph placement methodology for fast chip design. Nature 594, 7862 (2021),
452
+ 410 207–212.
453
+ 411 Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A. Rusu, Joel Veness, Marc G. Belle
454
+ 412 mare, Alex Graves, Martin A. Riedmiller, Andreas Fidjeland, Georg Ostrovski, Stig Petersen,
455
+ 413 Charles Beattie, Amir Sadik, Ioannis Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra,
456
+ 414 Shane Legg, and Demis Hassabis. 2015. Human-level control through deep reinforcement learning.
457
+ 415 Nature 518, 7540 (2015), 529–533. https://doi.org/10.1038/nature14236
458
+
459
+ 416 J.F. Muth and G.L. Thompson. 1963. Industrial Scheduling. Prentice-Hall.
460
+
461
+ 417 In-Beom Park, Jaeseok Huh, Joongkyun Kim, and Jonghun Park. 2020. A Reinforcement Learning
462
+ 418 Approach to Robust Scheduling of Semiconductor Manufacturing Facilities. IEEE Transactions on
463
+ 419 Automation Science and Engineering 17, 3 (2020), 1420–1431. https://doi.org/10.1109/
464
+ 420 TASE.2019.2956762
465
+ 421 Junyoung Park, Sanjar Bakhtiyar, and Jinkyoo Park. 2021a. ScheduleNet: Learn to solve multi-agent
466
+ 422 scheduling problems with reinforcement learning. CoRR abs/2106.03051 (2021). arXiv:2106.03051
467
+ 423 https://arxiv.org/abs/2106.03051
468
+ 424 Junyoung Park, Jaehyeong Chun, Sang Hun Kim, Youngkook Kim, and Jinkyoo Park. 2021b.
469
+ 425 Learning to schedule job-shop problems: representation and policy learning using graph neural
470
+ 426 network and reinforcement learning. International Journal of Production Research 59, 11 (2021),
471
+ 427 3360–3377. https://doi.org/10.1080/00207543.2020.1870013
472
+ 429 Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Köpf, Ed
473
+ 430 ward Z. Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit
474
+ 431 Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. 2019. PyTorch: An Imperative Style, High
475
+ 432 Performance Deep Learning Library. In Neural Information Processing Systems (NeurIPS),
476
+ 433 Hanna M. Wallach, Hugo Larochelle, Alina Beygelzimer, Florence d’Alché-Buc, Emily B. Fox,
477
+ 434 and Roman Garnett (Eds.). 8024–8035. https://proceedings.neurips.cc/paper/2019/
478
+ 435 hash/bdbca288fee7f92f2bfa9f7012727740-Abstract.html
479
+ 436 Laurent Perron and Vincent Furnon. 2019. OR-Tools. Google. https://developers.google.
480
+ 437 com/optimization/
481
+ 438 Ferdinando Pezzella, Gianluca Morganti, and Giampiero Ciaschetti. 2008. A genetic algorithm for
482
+ 439 the Flexible Job-shop Scheduling Problem. Computers and Operations Research 35, 10 (2008),
483
+ 440 3202–3212. https://doi.org/10.1016/j.cor.2007.02.014
484
+ 441 Qing-dao-er-ji Ren and Yuping Wang. 2012. A new hybrid genetic algorithm for job shop scheduling
485
+ 442 problem. Computers and Operations Research 39, 10 (2012), 2291–2299. https://doi.org/
486
+ 443 10.1016/j.cor.2011.12.005
487
+ 444 Mohammad Saidi-Mehrabad and Parviz Fattahi. 2007. Flexible job shop scheduling with tabu search
488
+ 445 algorithms. The International Journal of Advanced Manufacturing Technology 32, 5 (2007),
489
+ 446 563–570.
490
+ 447 David Silver, Aja Huang, Chris J. Maddison, Arthur Guez, Laurent Sifre, George van den Driess
491
+ 448 che, Julian Schrittwieser, Ioannis Antonoglou, Vedavyas Panneershelvam, Marc Lanctot, Sander
492
+ 449 Dieleman, Dominik Grewe, John Nham, Nal Kalchbrenner, Ilya Sutskever, Timothy P. Lillicrap,
493
+ 450 Madeleine Leach, Koray Kavukcuoglu, Thore Graepel, and Demis Hassabis. 2016. Mastering
494
+ 451 the game of Go with deep neural networks and tree search. Nature 529, 7587 (2016), 484–489.
495
+ 452 https://doi.org/10.1038/nature16961
496
+ 453 Wen Song, Xinyang Chen, Qiqiang Li, and Zhiguang Cao. 2023. Flexible Job-Shop Scheduling via
497
+ 454 Graph Neural Network and Deep Reinforcement Learning. IEEE Trans. Ind. Informatics 19, 2
498
+ 455 (2023), 1600–1610. https://doi.org/10.1109/TII.2022.3189725
499
+ 456 Robert H. Storer, S. David Wu, and Renzo Vaccari. 1992. New search spaces for sequencing problems
500
+ 457 with application to job shop scheduling. Management science 38, 10 (1992), 1495–1509.
501
+ 458 Richard S. Sutton and Andrew G. Barto. 2018. Reinforcement Learning: An Introduction (second
502
+ 459 ed.). The MIT Press. http://incompleteideas.net/book/the-book-2nd.html
503
+ 460 Éric D. Taillard. 1993. Benchmarks for basic scheduling problems. european journal of operational
504
+ 461 research 64, 2 (1993), 278–285.
505
+ 462 Oriol Vinyals, Igor Babuschkin, Wojciech M. Czarnecki, Michaël Mathieu, Andrew Dudzik, Junyoung
506
+ 463 Chung, David H. Choi, Richard Powell, Timo Ewalds, Petko Georgiev, Junhyuk Oh, Dan Horgan,
507
+ 464 Manuel Kroiss, Ivo Danihelka, Aja Huang, Laurent Sifre, Trevor Cai, John P. Agapiou, Max
508
+ 465 Jaderberg, Alexander Sasha Vezhnevets, Rémi Leblond, Tobias Pohlen, Valentin Dalibard, David
509
+ 466 Budden, Yury Sulsky, James Molloy, Tom Le Paine, Çaglar Gülçehre, Ziyu Wang, Tobias Pfaff,
510
+ 467 Yuhuai Wu, Roman Ring, Dani Yogatama, Dario Wünsch, Katrina McKinney, Oliver Smith, Tom
511
+ 468 Schaul, Timothy P. Lillicrap, Koray Kavukcuoglu, Demis Hassabis, Chris Apps, and David Silver.
512
+ 469 2019. Grandmaster level in StarCraft II using multi-agent reinforcement learning. Nature 575,
513
+ 470 7782 (2019), 350–354. https://doi.org/10.1038/s41586-019-1724-z
514
+ 471 Bernd Waschneck, Thomas Altenmüller, Thomas Bauernhansl, and Andreas Kyek. 2016. Production
515
+ 472 Scheduling in Complex Job Shops from an Industry 4.0 Perspective: A Review and Challenges
516
+ 473 in the Semiconductor Industry. In Proceedings of the 1st International Workshop on Science,
517
+ 474 Application and Methods in Industry 4.0 (i-KNOW) (CEUR Workshop Proceedings, Vol. 1793),
518
+ 475 Roman Kern, Gerald Reiner, and Olivia Bluder (Eds.). CEUR-WS.org. http://ceur-ws.org/
519
+ 476 Vol-1793/paper3.pdf
520
+ 477 Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. 2019. How Powerful are Graph Neural
521
+ 478 Networks? (2019). https://openreview.net/forum?id=ryGs6iA5Km
522
+ 479 Takeshi Yamada and Ryohei Nakano. 1992. A Genetic Algorithm Applicable to Large-Scale Job
523
+ 480 Shop Problems. In Parallel Problem Solving from Nature 2, (PPSN-II), Reinhard Männer and
524
+ 481 Bernard Manderick (Eds.). Elsevier, 283–292.
525
+ 482 Cong Zhang, Wen Song, Zhiguang Cao, Jie Zhang, Puay Siew Tan, and Chi Xu. 2020. Learning
526
+ 483 to Dispatch for Job Shop Scheduling via Deep Reinforcement Learning. In Neural Information
527
+ 484 Processing Systems (NeurIPS), Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria
528
+ 485 Florina Balcan, and Hsuan-Tien Lin (Eds.). https://proceedings.neurips.cc/paper/
529
+ 486 2020/hash/11958dfee29b6709f48a9ba0387a2431-Abstract.html
530
+ 487 Cong Zhang, Wen Song, Zhiguang Cao, Jie Zhang, Puay Siew Tan, and Chi Xu. 2022. Learning to
531
+ 488 Search for Job Shop Scheduling via Deep Reinforcement Learning. CoRR abs/2211.10936 (2022).
532
+ 489 https://doi.org/10.48550/arXiv.2211.10936 arXiv:2211.10936
533
+ 490 Cong Zhang, Yaoxin Wu, Yining Ma, Wen Song, Zhang Le, Zhiguang Cao, and Jie Zhang. 2023. A
534
+ 491 review on learning to solve combinatorial optimisation problems in manufacturing. IET Collabora
535
+ 492 tive Intelligent Manufacturing 5, 1 (2023), e12072. https://doi.org/10.1049/cim2.12072
536
+ 493 arXiv:https://ietresearch.onlinelibrary.wiley.com/doi/pdf/10.1049/cim2.12072
537
+ 494 Jie Zhou, Ganqu Cui, Shengding Hu, Zhengyan Zhang, Cheng Yang, Zhiyuan Liu, Lifeng Wang,
538
+ 495 Changcheng Li, and Maosong Sun. 2020. Graph neural networks: A review of methods and
539
+ 496 applications. AI Open 1 (2020), 57–81. https://doi.org/10.1016/j.aiopen.2021.01.001
md/dev/GkDbQb6qu_r/GkDbQb6qu_r.md ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CogView2: Faster and Better Text-to-Image Generation via Hierarchical Transformers
2
+
3
+ Ming Ding† Wendi Zheng† Wenyi Hong† Jie Tang†‡ †Tsinghua University ‡BAAI {dm18@mails, jietang@mail}.tsinghua.edu.cn
4
+
5
+ # Abstract
6
+
7
+ Development of transformer-based text-to-image models is impeded by its slow generation and complexity, for high-resolution images. In this work, we put forward a solution based on hierarchical transformers and local parallel autoregressive generation. We pretrain a 6B-parameter transformer with a simple and flexible self-supervised task, a cross-modal general language model (CogLM), and finetune it for fast super-resolution. The new text-to-image system, CogView2, shows competitive generation performance to the concurrent state-of-the-art DALL-E-2, and naturally supports interactive text-guided editing on images.
8
+
9
+ ![](images/f15eee803974184b131ef6662e5a7cbd7037f7e8dac951a2bd6eb7a61859d278.jpg)
10
+ Figure 1: Text-to-Image samples from CogView2, which supports both Chinese and English. The actual input text is in Chinese, translated into English here for better understanding. Codes and a demo website will be updated at https://github.com/THUDM/CogView2.
11
+
12
+ # 1 Introduction
13
+
14
+ Recently, text-to-image generation has been greatly advanced by large-scale pretrained transformers, e.g. DALL-E $\pmb { \left. \left[ 2 6 \right. \right.} $ and CogView $\mathbb { \left[ 3 \right] }$ . These models learn to generate image tokens in an autoregressive way. However, they also suffer from the following disadvantages:
15
+
16
+ Slow generation. Generation of autoregressive models usually is much slower than generation of non-autoregressive models, e.g. GANs $\mathbb { m }$ , with the same FLOPs. Instead of employing a large number of parameters, this shortcoming is mainly attributed to the nature of token-by-token generation used in the autoregressive models cannot exploit the parallel computing ability of GPUs, even after caching hidden states $\mathbb { \left[ \left[ 2 5 \right] \right] }$ . This is a significant limitation.
17
+
18
+ Expensive high-resolution training. The current large-scale pretrained models are generally based on Transformers $\textcircled { \vert \beta 0 \vert }$ , where the attention operation has both time and space complexity of $O ( n ^ { 2 } )$ for training sequences of length $n$ . Within a limited budget, we face a trade-off between the number of parameters, representing the modeling power, and the resolution of the generated images. For this reason, most current text-to-image models choose a resolution of $3 2 \times 3 2$ tokens (usually $2 5 6 \times 2 5 6$ pixels) [3, 26, 11], which is far less dense than the resolution of the real photos.
19
+
20
+ Unidirectionality. For images, autoregressive models, e.g. GPTs, usually generate tokens in rasterscan order. This order shows the best perplexity during the evaluation $\mathbb { H }$ . However, this order makes the models unaware of the tokens below or on the right side during generation, as a result text-guided infilling is not supported. Moreover, the unidirectionality leads to a gap between the pretrained text-to-image models and vision transformers (ViTs) $ { \mathbb { I } }$ based on bidirectional masked prediction, e.g. MAE $\bar { \mathbb { D } }$ and SimMIM [34]—limiting their application on traditional visual tasks, such as image classification and object detection.
21
+
22
+ Present Work. To overcome these defects, we first propose a simple and versatile pretraining method, a Cross-Modal general Language Model (CogLM). Our CogLM masks various types of tokens in the sequence of text and image tokens, and learns to predict them autoregressively. Specifically, (1) if we mask all the image tokens, the task becomes the same as the original CogView [3] in performing a text-to-image generation task; (2) if we mask random patches of image tokens, it works similarly to MAE as an infilling task; (3) if we mask text tokens, the task becomes image captioning.
23
+
24
+ The versatility of CogLM enables us to fine-tune a pretrained CogLM for different downstream tasks, and constructs a hierarchical model, CogView2.There are three steps in the hierarchical generation process as follows:
25
+
26
+ 1. First, we generate a batch of low-resolution images ( $2 0 \times 2 0$ tokens in CogView2) using the pretrained CogLM, and then (optionally) filter out the bad samples based on the perplexity of CogLM image captioning, which is the post-selection method introduced in CogView [3].
27
+ 2. The generated images are mapped into $6 0 \times 6 0$ -token images by a direct super-resolution module fine-tuned from the pretrained CogLM. We use local attention implemented by our customized CUDA kernel to reduce the training expense. The high-resolution images from this step usually have inconsistent textures and lack details.
28
+ 3. These high-resolution images are refined via another iterative super-resolution module finetuned from the pretrained CogLM. Most tokens are re-masked and re-generated in a local parallel autoregressive (LoPAR) way, which is much faster than the original autoregressive generation.
29
+
30
+ How does CogView2 conquer the three defects? First, during pretraining the masked patch prediction task trains CogLM to handle bidirectional context, making it easy to adapt to bidirectional tasks, such as direct and iterative super-resolution. Second, the hierarchical design allows us to care only about the local coherence at a high-resolution level. In this way, the local attention can be leveraged to reduce the training expense. Third, the local parallel autoregressive generation can reduce model run times from 3,600 to 6 (1/600 only), significantly accelerating the generation of high-resolution images. CogView2 is about $1 0 \times$ faster than the CogView (with sliding-window super-resolution) for generating images of similar resolution and better quality.
31
+
32
+ ![](images/d6e98a07487b039e33d25400bba58856644117c1fe9f2d203fd0e5ce574c751c.jpg)
33
+ Figure 2: CogLM. (Left) The sequence consists of both text and image tokens. [BOI] (Begin-OfImage) is the separator token. Mask regions are sampled according to different strategies. Only the second-to-last tokens in the mask regions are predicted to compute the loss. (Right) The mask regions are only implemented by changing the attention mask matrix, without any modification on the input tokens. In the attention mask matrix, rows and columns of all the masked tokens (the 2,3,4,6,7,8 rows and columns) can be extracted together to form a low-triangle attention mask matrix.
34
+
35
+ # 2 Related Work
36
+
37
+ Text-to-image generation for arbitrary inputs is a long-held dream for many cross-modal machinelearning researchers. Most early attempts to address this challenge were based on Generative Adversarial Nets $[ \mathbb { 1 0 } ]$ ; these include AttnGAN [35], DM-GAN $\mathbb { H O }$ , DF-GAN $\left\| \widehat { 2 8 } \right\|$ , et al. Although they can perform vivid synthesis on domain-specific datasets, such as Caltech-UCSD Birds 200, general-domain datasets, such as MS COCO $\bar { \mathbb { E } 7 } \mathbb { I }$ , present great challenges for these methods. DALLE [26], CogView $\pmb { \mathbb { B } } \|$ and similar works [33, 8] leverage VQ-VAE $\bar { \lVert 2 9 rVert }$ to compress an image to a sequence of discrete tokens and pretrain large transformers for autoregressive generation, greatly improving results in the general domain. LAFITE $\pmb { \mathbb { B } } \pmb { \mathrm { 9 } } \|$ learns to invert the pretrained CLIP $\dot { \left[ \left| 2 3 \right| \right] }$ embeddings in the shared space of text and image for text-free training. Recently, many researchers have turned to diffusion models, largely due to the slow generation defect of autoregressive models. One example is Glide $\mathbb { \lVert 1 9 \rVert }$ .
38
+
39
+ Non-autoregressive generation (NAR) is recently a popular topic in natural language generation— see Mask-Predict [9] and GLAT $\dot { \left[ \frac { } { } 2 1 \right] }$ , which explores parallel decoding methods for autoregressivelike models. Generation speed was not an issue in the era when GANs dominated the image generation, but constitutes a considerable challenge for current autoregressive text-to-image models. M6-UFC $\pmb { \mathbb { B } } \pmb { \mathrm { 8 } } \|$ first introduces NAR methods into the VQ-VAE framework, and similar ideas are adopted by VQ-diffusion $\mathbb { m }$ and MaskGIT [1]. A possible drawback of pure NAR methods is that tokens sampled at the meantime might lead to global inconsistency in later steps during the generation of complex scenes. Our method introduces a hierarchical design to combine the consistency merit of autoregressive models and the speed advantage of NAR methods.
40
+
41
+ # 3 Method
42
+
43
+ # 3.1 The Cross-Modal General Language Model
44
+
45
+ While previous self-supervised pretext tasks often target at mask prediction in the computer vision [34, 12], our approach pursues a unification of autoregressive generation and bidirectional context-aware mask prediction.
46
+
47
+ In NLP, the General Language Model (GLM) [6] suggests changing the direct mask prediction into blockwise autoregressive generation. However, directly applying it to images would result in redundancy. For instance, the sizes of the masked image patches are fixed, thus we do not need the capacity of filling blocks of indefinite length as in NLP. Moreover, GLM inserts a sentinel token for each mask region to predict its first token, which greatly increases the sequence length thus restricts the usage of 2D local attention.
48
+
49
+ Based on the analysis above, we present a simpler and more general language model for both text and image data—Cross-modal general Language Model (CogLM). As shown in Figure $\boxed { 2 }$ , CogLM takes as input a concatenation of text and images tokenized by icetk $\mathbb { I } ( \mathrm { S e e } \ S \bigcirc . 2 )$ , whose dictionary contains 20,000 image tokens and 130,000 text (both Chinese and English) tokens. Formally, let $\mathbf { t } = [ t _ { 1 } , . . . , t _ { M } ]$ be the text tokens and $\mathbf { i m } = [ i m _ { 1 } , . . . , i m _ { { N ^ { 2 } } } ]$ be the image tokens, where $M$ and $N ^ { 2 }$ are the lengths of text and image tokens respectively.
50
+
51
+ The crucial step in CogLM is to sample $k$ mask regions $R = \left\{ [ l _ { 0 } , r _ { 0 } ] , . . . , [ l _ { k } , r _ { k } ] \right\}$ according to various strategies. In practice, the following two strategies are used:
52
+
53
+ • (Text-to-Image GPT) The input sequence is $\mathbf { x } = \left[ \mathbf { t } \quad \left[ \mathsf { B O I } \right] \mathbf { i m } \right]$ We mask all the image tokens, which is similar to the pretraining task of CogView [3].
54
+ • (A Combination of Mask Prediction and Image Captioning) The input sequence is $\mathbf { x } =$ $\left[ i m _ { 0 } \dots i m _ { i } \dots i m _ { j } \dots i m _ { N ^ { 2 } } \right. \left. \left[ \mathrm { B } 0 \mathrm { E } / \mathrm { C } \right] \mathrm { \bf { t } } \right]$ , where [BOE],[BOC] are separators meaning beginning-of-English and beginning-of-Chinese used for the corresponding language. we mask random patches and the text tokens. Ideally, the two tasks should be separated; but we combine them together for training efficiency.
55
+
56
+ Instead of replacing the tokens in the mask regions as [MASK], we make no change in the input but build an attention mask $A$ based on the mask regions. All tokens outside mask regions are seen as context and can be attended to by all other tokens. A token in mask regions can only be attended to by the tokens in mask regions and behind it. Specifically,
57
+
58
+ $$
59
+ A [ i , j ] = { \left\{ \begin{array} { l l } { 1 , } & { { \mathrm { i f ~ } } \forall [ l _ { u } , r _ { u } ] \in R , j \notin [ l _ { u } , r _ { u } ] , } \\ { 1 , } & { { \mathrm { i f ~ } } j \leq i { \mathrm { ~ a n d ~ } } \exists u , v { \mathrm { ~ ( i n d i c e s ) } } , i \in [ l _ { u } , r _ { u } ] \in R , j \in [ l _ { v } , r _ { v } ] \in R , } \\ { 0 , } & { { \mathrm { e l s e } } . } \end{array} \right. }
60
+ $$
61
+
62
+ Figure $2$ shows an example of the attention mask matrix of two mask regions.
63
+
64
+ In the mask regions, the model learns to predict the next token. The loss function can be written as follows:
65
+
66
+ $$
67
+ L = \frac { - 1 } { \sum _ { u } r _ { u } - l _ { u } } \sum _ { v } \sum _ { i = l _ { v } } ^ { r _ { v } - 1 } \log p ( x _ { i + 1 } | x _ { \le i } , x _ { c o n t e x t } ) ,
68
+ $$
69
+
70
+ where the $x _ { c o n t e x t }$ denotes the tokens outside the mask regions.
71
+
72
+ A fox is siting on the books.
73
+
74
+ Infilling. Note that the first token in each mask region is not predicted during training. This feature seems to disable CogLM from image infilling or cloze filling in natural language, but this problem actually has a simple solution. During inference, we can move the last context token before each mask region into it, as illustrated in Figure $\textcircled { 3 }$ Although these moved tokens becomes blind spots for mask regions before them, they have few negative effects in practice. To further avoid this minor influence and fully maintain the context information, we deal with each mask region individually. For each region, we move only the last context token before this region, and keep all the known tokens outside the mask regions. Thus, we cannot use the cached hidden states from the previous region, slightly slowing down the multi-region infilling. See Appendix A for samples.
75
+
76
+ Advantages over GPT [22], GLM [6] and MAE [12]. (GPT) The main advantage over GPT is that the modeling of bidirectional contexts is considered in CogLM, which will benefit many tasks relying on global information, e.g. super-resolution in the next section and image classification. The importance of bidirectional context has been verified in the comparison of BERT $\left[ \left[ 2 \right] \right]$ and GPT on GLUE [31]. (GLM) The main advantage over GLM is simplicity. To unify the generation and bidirectional understanding, GLM needs to define many new special tokens and a new type of position embedding, insert a sentinel for each mask region and change the order of input tokens. It destroys the spatial relevance in the image data and excludes the possibility of using 2D local attention or convolution. (MAE) MAE is designed for self-supervised learning on pure image data and is not ready for generation. Even without text, CogLM is more parameter-efficient, because MAE is an encoder-decoder structure. A considerable part of parameters in encoders and decoders are learned for the same function, e.g. extracting basic features from inputs.
77
+
78
+ ![](images/3f9341ff611673f3ffe56e1f37b00403f62839e46e15dcc354298e2c15858ab0.jpg)
79
+ Figure 3: Image Infilling of CogLM. Tokens (viewed as patches) in light green mean mask regions.
80
+
81
+ # 3.2 Pretraining
82
+
83
+ As we have introduced CogLM as a general pretraining framework, in this section, we will describe the details and hyperparameters of our pretrained CogLM.
84
+
85
+ Tokenization. We have developed a unified tokenizer icetk of Image, Chinese and English. As shown in DebertaV2 [13], a large vocabulary (128,000 tokens) offers many benefits. For text, we extract a bilingual vocabulary of 130,000 tokens in icetk and explicitly classify them as Chinese, English, Common or Rare Symbols, so that we can specify the generated language via a sampling mask. The image tokenizer is a 20,000-token first-stage VQ-VAE $\left[ \left[ 2 9 \right] \right]$ , largely following the tokenizer in CogView [3]. Inspired by Esser et al. [7], a term of perceptual loss $ { \mathbb { I } } ^ { \smash { \sum } }$ is added to the reconstruction loss, significantly improving reconstruction performance. (See Appendix for details.)
86
+
87
+ Transformer. The backbone of our pretrained CogLM is a Transformer with Sandwich LayerNorm [3]. The model has 6 billion parameters (48 layers, hidden size 3072, 48 attention heads), trained for 300,000 iterations in FP16 with batch size 4,096. The sequence length is 512, consisting of 400 image tokens, 1 separator and up to 111 text tokens.
88
+
89
+ Masking Strategy. We randomly select a sampling strategy for each training sample. For the mask prediction strategy, the analysis from SimMIM $\overline { { \mathbb { B } \varDelta \mathbf { d } } }$ exhibits the great importance of mask percentage and patch distribution. We follow their results to sample $4 \times 4$ token patches at random until $7 5 \%$ of the tokens are in the mask regions. For bilingual samples, we randomly choose one of the languages during training.
90
+
91
+ # 3.3 Hierarchical Generation
92
+
93
+ Although the pretrained CogLM can generate images from text, the resolution is only $2 0 \times 2 0$ tokens $( 1 6 0 \times 1 6 0$ pixels). The short sequence is intentional, for fast generation. The versatility of CogLM allows us to fine-tune it into super-resolution models. The whole hierarchical pipeline makes up our CogView2 system.
94
+
95
+ Direct super-resolution. In this step, we want a model to map a generated low-resolution image token sequence $\mathbf { i m } ^ { 0 } \in [ 0 , 2 0 0 0 0 ) ^ { 2 0 \times 2 0 }$ to a higher-resolution sequence $\mathbf { i m } ^ { 1 } \in [ 0 , 2 0 0 0 0 ) ^ { 6 0 \times 6 0 }$ . We fine-tune the pretrained CogLM into an encoder-decoder architecture. The input of the encoder is the $2 0 \times 2 0$ sequence of generated image tokens, and the input of the decoder is just a $6 0 \times 6 0$ sequence of [MASK]. We do not follow the original transformer $\bar { \bigtriangledown } ^ { 3 0 \| }$ to add a cross-attention layer, instead we make the tokens in the decoder attend both local tokens in decoder and encoder. This cross-resolution local attention is implemented via a customized CUDA kernel introduced in section $4 . 2 .$ Both encoder and decoder are initialized using the pretrained CogLM. In practice, we find it enough to only fine-tune the weights of the attention layers in the decoder, so that we can fix and share the other parameters between the encoder and decoder to reduce the memory consumption.
96
+
97
+ Although direct mapping is a traditional practice for super-resolution—e.g. SRCNN [4]—it is hardly qualified as generation; it focuses more on texture transformation. The loss function of direct mapping is token-based or pixel-based (MAE), meaning that it predicts or maximizes the marginal distribution $p ( i m _ { i } ^ { 1 } | \mathbf { i m } ^ { 0 } )$ for each token $i$ instead of $p ( \mathbf { i m } ^ { 1 } | \mathbf { i m } ^ { 0 } )$ . As we use cross-entropy loss and a multinomial sampling during generation, we get
98
+
99
+ $\mathbf { i m ^ { 1 } } = [ i m _ { 1 } ^ { 1 } , . . . , i m _ { 6 0 \times 6 0 } ^ { 1 } ] , i m _ { i } ^ { 1 } \sim p _ { \theta } ( i m _ { i } ^ { 1 } | \mathbf { i m ^ { 0 } } ) , i m _ { i } ^ { 1 }$ and $i m _ { j } ^ { 1 }$ are independent if $i \neq j$ .
100
+
101
+ ![](images/7ea6a8d274f3ef0c8bc2e1539f00b53b01c7d6a1723708f01011ab9e5b28abe1.jpg)
102
+ Figure 4: Super-resolution modules. Low-resolution images are mapped into high-resolution images via the direct super-resolution module. In each snapshot during the iterative super-resolution, all tokens of the same color are generated at the same time. All the local windows work in parallel.
103
+
104
+ Therefore, we need to refine $\mathbf { i m } ^ { 1 }$ using another module.
105
+
106
+ Iterative super-resolution. In this step, we aim to refine the initial high-resolution sequence $\mathbf { i m } ^ { 1 }$ into a better one $\mathbf { i m } ^ { 2 }$ . The working principle of the refinement is to break the independence of the generated tokens, while keeping the parallelism. Thus, we propose a local parallel autoregressive (LoPAR) approach.
107
+
108
+ The motivation of LoPAR is that the hierarchical process frees us from global dependence. As long as we maintain $2 5 \% - \mathrm { a }$ ratio from MAE $ [ [ 1 2 ] ] -$ random tokens as context, it is sufficient to recover the global scene of the image. If the re-generated tokens are coherent locally with $2 5 \%$ kept tokens, global coherence is also guaranteed. We mask $7 5 \%$ of the tokens of $\mathbf { i m } ^ { 1 }$ and assume that there is a local window size $\sigma$ ,
109
+
110
+ $$
111
+ \begin{array} { r l } & { p ( \mathbf { i m } _ { i } ^ { 2 } | \mathbf { i m } ^ { 1 } ) = p ( \mathbf { i m } _ { i } ^ { 2 } | \{ \mathbf { i m } _ { j } ^ { 1 } \mid \mathrm { d i s t } ( i , j ) < \sigma \mathrm { a n d } j \mathrm { i s } \mathrm { n o t m a s k e d . } \} ) , } \\ & { p ( \mathbf { i m } _ { i } ^ { 2 } | \mathbf { i m } ^ { 1 } , \mathbf { i m } _ { j } ^ { 2 } ) = p ( \mathbf { i m } _ { i } ^ { 2 } | \mathbf { i m } ^ { 1 } ) \mathrm { i f } \mathrm { d i s t } ( i , j ) > \sigma , } \end{array}
112
+ $$
113
+
114
+ so that local attention is sufficient and tokens from different local windows can be generated in parallel. To further increase the parallelism, we find the local inconsistency usually occurs when directly adjacent (vertically or horizontally) tokens are generated at the same time. We factorize the generation process into different iterations diagonally as in Figure 4 and below:
115
+
116
+ $$
117
+ p ( \mathbf { i m } ^ { 2 } | \mathbf { i m } ^ { 1 } ) = \prod _ { k = 0 } ^ { 2 \sigma - 1 } \big ( \prod _ { i } ^ { \mathrm { \tiny ~ r o w } ( i ) + \mathrm { c o l } ( i ) = k } p ( \mathbf { i m } _ { i } ^ { 2 } | \mathbf { i m } ^ { 1 } , \{ \mathbf { i m } _ { j } ^ { 2 } | \mathrm { \ r o w } ( j ) + \mathrm { c o l } ( j ) < k \} ) \big ) ,
118
+ $$
119
+
120
+ where $\begin{array} { r } { \operatorname { r o w } ( i ) = \lfloor \frac { i - 1 } { 6 0 } \rfloor } \end{array}$ mod $\sigma$ and $\operatorname { c o l } ( i ) = ( i - 1 )$ mod $\sigma$ are the indices of row and column in the local window.
121
+
122
+ To implement the iterative super-resolution module, we fine-tune the pretrained CogLM for 20,000 iterations into a BERT-style masked prediction model on $6 0 \times 6 0$ -token sequences with local attention. The mask ratio is sampled from $\{ 0 . \dot { 2 } , 0 . 4 , 0 . 6 , 0 . 8 , 0 . 9 \}$ for each sample. During inference, we set the local window size to $\sigma = 6$ and compress the iterative process from $2 \sigma - 1$ to 6 iterations by arranging the unmasked tokens and merging the first and final iterations2.
123
+
124
+ # 4 Plug-in Improved Techniques for Transformers
125
+
126
+ # 4.1 Cluster Sampling
127
+
128
+ In autoregressive generation, the sampling strategy over the predicted distribution of the tokens is crucial. Top-k or top-p (nucleus) sampling $[ \overbrace { | 1 4 | }$ are the most common strategies, but suffer from an incomplete truncation problem.
129
+
130
+ The vocabulary of the image tokens is learned by VQVAE $\pmb { \mathbb { Z } } 9 \|$ where the embeddings of some tokens are very similar. To represent the frequent patterns at a finer granularity, we use a large vocabulary of 20,000 tokens, three times larger than that of the previous works [26, 3], further exacerbating the situation. For instance, there are about 42 tokens basically “white” in icetk, which show subtle differences only when connected to some other tokens. Although the sum of the probabilities of these “white” tokens might be large enough, most of them could be filtered by top- $\mathbf { \nabla \cdot k }$ sampling. Figure $\boxed { 5 }$ illustrates the problem.
131
+
132
+ To solve the incomplete sampling problem, we propose cluster sampling. We group the 20,000 tokens into 500 clusters via Kmeans $\dot { \left[ \left| 1 8 \right| \right] }$ based on their vectors in VQVAE. During sampling, we first sample a cluster using top-k sampling based on the sum of probabilities of tokens in the clusters, and then sample in the cluster. All the tokens within a cluster are treated as a whole and will be filtered or kept together, alleviating the incomplete truncation problem.
133
+
134
+ ![](images/1e8d6cf5dc45c9a2c23bcafc4bcdbe113d52d33a3ca88fa451e724e7f9ec59aa.jpg)
135
+ Figure 5: (Best viewed in color.) Incomplete truncation. The same color indicates very similar embeddings of the tokens. The hard truncation of top-k sampling twists the proportion between blue, green and red tokens.
136
+
137
+ # 4.2 Local Attention
138
+
139
+ Locality is one of the most important properties of image data. Local operations, e.g. convolution, dominated the visual computing before ViTs $ { \mathbb { I } }$ . Even attention in the ViTs mainly deals with the interactions between local tokens $ { \left[ \left[ 2 4 \right] \right] }$ . We find it possible to fine-tune the pretrained CogLM using local attention and textual attention, which is generally compatible with the global attention weights from pretraining. However, 2D local attention cannot be implemented efficiently using high-level framework, e.g. Pytorch $\pmb { \mathbb { Z } } 0 \|$ . We develop a customized CUDA kernel to support both 2D local attention, 2D autoregressive local attention and cross-resolution local attention. In the CUDA kernel implementation, we can save half of the computation in the matrix multiplication and do not need a causal attention mask for the autoregressive attention. In the super-resolution modules, we use local attention with the receptive field (RF) of $9 \times 9$ . Figure $\boxed { 6 }$ show the benchmark for a single-head attention with hidden size 64 on a A100 GPU. The advantage of our method will be more obvious in autoregressive scenarios, which is up to $4 0 \times$ faster and consumes $1 \%$ memory than global attention on 4,096 sequences.
140
+
141
+ ![](images/9340553722b0445a74c5b604b1d8f87b4efd6d5d6315c9aa8590fe3d080b2554.jpg)
142
+ (a) Memory consumption for different local attention implementation.
143
+ Figure 6: Comparison between CUDA kernel-based local attention, full attention, and Pytorch implementation based on the unfold (im2col $\mathbb { L } \Sigma \mathbb { I } .$ ) operation. The hidden size in the benchmark is 64.
144
+
145
+ # 4.3 Upweighting Textual Attention
146
+
147
+ Most text-image pairs are weakly relevant in the large training data of CogLM. Even the model perfectly fits the data, it should have a considerable probability to generate irrelevant images. To strengthen the relevance, we leverage the explainability of the attention operation. We add a constant $c$ to the attention scores from any token to the text tokens: (The attention mask is omitted for simplicity)
148
+
149
+ $$
150
+ \operatorname { A t t e n t i o n } ( Q , K , V , A ) = \operatorname { s o f t m a x } ( \frac { Q ^ { T } K } { \sqrt { d } } + [ \underbrace { \ c \dots c } _ { t e x t \ p a r t } \underbrace { 0 \dots 0 } _ { i m a g e \ p a r t } ] ) V .
151
+ $$
152
+
153
+ This technique costs ignorable time consumption but largely improves the textual relevance of the generated images. In practice, $c < 3$ will not influence the quality of the images.
154
+
155
+ # 5 Experiments
156
+
157
+ # 5.1 Dataset
158
+
159
+ Our dataset for pretraining contains about 30 million text-image pairs, mostly overlapping with that of CogView $\pmb { \| } \mathbf { \vec { \tau } }$ . We filter about 5 million text-image pairs from the CogView dataset with some keywords, e.g. “abstract” and “texture”, because they are mostly background images used for design. These images consist of repeating patterns and contribute little to text-to-image generation. We then replenish the dataset with 5 million tag-image pairs. About half the text is translated from English, and both Chinese and English text are kept to train our bilingual CogLM. Only the images whose resolution is at least $4 8 0 \times 4 8 0$ are used to train the super-resolution modules.
160
+
161
+ # 5.2 Machine Evaluation
162
+
163
+ To compare with previous and concurrent works, we follow the most popular benchmark originated from DALL-E $\hat { \left\| 2 6 \right\| }$ , Fréchet Inception Distances and Inception Scores evaluated on MS-COCO [17] 30,000 captions from the validation set are sampled to evaluate the FID. Since each image in COCO has up to 5 different captions, we carefully select the sampled captions to describe different images. We generate 16 samples for each caption (translated into Chinese), and select the best one with the lowest caption perplexity (the Caption Score in $\pmb { \mathbb { B } } \mathbf { l }$ ). Note that FID is not the perfect metric to evaluate CogView2 because (1) the advantage of $\mathrm { C o g V i e w } 2$ is to generate high-resolution images, but we need to resize the images back to $2 5 6 \times 2 5 6$ for meaningful comparison. (2) There are mistakes when translating English captions into Chinese. (3) Our training data contain many single-object images, which are quite different from those in the distribution of COCO (common objects in context).
164
+
165
+ Table 1: Machine Evaluation Results on MS-COCO. (Downsampling CogView2 images to $2 5 6 \times 2 5 6 .$ “\*” means fine-tuning on MS-COCO. “– technique” is the ablation study without this technique. CogView2 achieves the best blurred FIDs over all comparable methods.
166
+
167
+ <table><tr><td>Model</td><td>FID-0</td><td>FID-1</td><td>FID-2</td><td>FID-4</td><td>FID-8</td><td>IS</td></tr><tr><td>AttnGAN* B</td><td>35.2</td><td>44.0</td><td>72.0</td><td>108.0</td><td>100.0</td><td>23.3</td></tr><tr><td>DM-GAN* 四</td><td>26.0</td><td>39.0</td><td>73.0</td><td>119.0</td><td>112.3</td><td>32.2</td></tr><tr><td>DF-GAN* [28]</td><td>26.0</td><td>33.8</td><td>55.9</td><td>91.0</td><td>97.0</td><td>18.7</td></tr><tr><td>DALL-E 2</td><td>27.5</td><td>28.0</td><td>45.5</td><td>83.5</td><td>85.0</td><td>17.9</td></tr><tr><td>CogView 回</td><td>27.1</td><td>19.4</td><td>13.9</td><td>19.4</td><td>23.6</td><td>18.2</td></tr><tr><td>XMC-GAN* [36]</td><td>9.3</td><td>1</td><td>1</td><td>1</td><td>1</td><td>30.5</td></tr><tr><td>NUWA* [ B</td><td>12.9</td><td>13.8</td><td>15.7</td><td>19.3</td><td>24</td><td>27.2</td></tr><tr><td>LAFITE 园</td><td>26.9</td><td>23.0</td><td>18.7</td><td>15.7</td><td>14.8</td><td>26.0</td></tr><tr><td>VQ-diffusion-F* [ □</td><td>13.86</td><td>1</td><td>-</td><td>-</td><td>-</td><td>1</td></tr><tr><td>Make-A-Scene* 回</td><td>7.55</td><td>=</td><td>=</td><td></td><td></td><td>二</td></tr><tr><td>DALL-E-2 [27]</td><td>10.9</td><td>=</td><td></td><td></td><td></td><td>=</td></tr><tr><td>CogView2</td><td>24.0</td><td>19.7</td><td>16.8</td><td>17.2</td><td>17.2</td><td>22.4</td></tr><tr><td>- clustering sampling</td><td>36.4</td><td>32.4</td><td>28.9</td><td>28.5</td><td>30.4</td><td>18.8</td></tr><tr><td>- attention upweighting</td><td>24.6</td><td>20.4</td><td>17.5</td><td>17.9</td><td>18.9</td><td>21.1</td></tr><tr><td>CogView2*</td><td>17.5</td><td>13.4</td><td>10.9</td><td>10.6</td><td>10.4</td><td>25.2</td></tr></table>
168
+
169
+ The results of machine evaluation are demonstrated in Table $\mathbb { \underline { { \Pi } } } .$ We find that fine-tuning CogLM on the MS-COCO dataset will largely improve the FID. During our fine-tuning, FID diminishes from 24.0 (0 iteration) $ 1 9 . 2$ (2,500 iterations) $ 1 7 . 5$ (7,500 iterations). However, we find that the quality (human evaluation) of generation deteriorates. Though the style is similar to COCO, the generation is not as accurate as for the non-fine-tuned version, which also corresponds to the scores in human evaluation in Figure 7.
170
+
171
+ # 5.3 Human Evaluation
172
+
173
+ As the most persuasive metric, we conduct a large-scale human evaluation following the setting in CogView $\bar { \| 3 \| }$ (See Appendix for details). The experiments include a total of 4,600 groups of comparison on COCO captions between some public available text-to-image works, including DFGAN [28], LAFITE [39], CogView [3], CogView2 (including its finetuned version on COCO) and the recovered ground truth after VQVAE. Note that the VQVAE in CogView2 is much better than that in CogView, which makes the recovered ground truth a stronger upper bound. The results are demonstrated in Figure 7. An intriguing finding is that the finetuned CogView2, although with much better FID, performs worse than the original model. We guess that the model might fit the style of complex scenes in COCO, but the generated samples with isolated subjects could be preferred by the annotators.
174
+
175
+ ![](images/7c9af1a5e0f13bd5b620ace0612ad07bd8a0e2562815e06fc73604490635c843.jpg)
176
+ Figure 7: The results of human evaluation. CogView2 performs the best in all the aspects.
177
+
178
+ # 5.4 Analysis of the Speed and FLOPs of LoPAR
179
+
180
+ As discussed in $\ S \bigstar \bigstar$ our motivation is to increase the degree of parallelism for inference acceleration, even with more FLOPs. Autoregressive generation with cached hidden states have the same FLOPs with a teacher-forcing forward step, but is much slower $\mathrm { 8 5 8 m s }$ vs 225.9s in CogView2 scale). For LoPAR, it is exactly $N$ ( $N = 6$ in our setting) times and FLOPs of forward steps. We compare the inference speed of super-resolution stage with different strategies in Table 2.
181
+
182
+ Table 2: The wall-clock time and FLOPs for a 4,096 sequence on an A100-40GB GPU with different AR-related methods. The model configs are the same as the pretrained CogLM 6B.
183
+
184
+ <table><tr><td></td><td>FLOPs</td><td>Time</td><td>Memory (inference)</td></tr><tr><td>Forward (also teacher forcing training)</td><td>1.17 * 1014</td><td>858 ms</td><td>5,041MB</td></tr><tr><td>Autoregressive generation (no cache)</td><td>4.81 * 1017(4095×)</td><td>about 1h</td><td>5,041MB</td></tr><tr><td>Autoregressive generation (cached)</td><td>1.17* 1014(1×)</td><td>225.9s</td><td>4,865MB</td></tr><tr><td>LoPAR</td><td>7.02 * 1014(6×)</td><td>4.89s</td><td>5,041MB</td></tr><tr><td>LoPAR+local attention</td><td>5.82 * 1014</td><td>3.41s</td><td>352MB</td></tr></table>
185
+
186
+ # 6 Discussion
187
+
188
+ Autoregressive or Diffusion? Although GPTs achieved great success in text generation, diffusion models are becoming increasingly popular in image generation. Here we compare diffusion models with autoregressive models from the aspect of speed, the largest disadvantage of the autoregressive models discussed in the section $^ { 1 . }$ With the same architecture, diffusion models require more FLOPs but have a high degree of parallelism. They can also make a trade-off between the quality and time consumption by manually scheduling the stride of sampling. For example, Glide $\dot { [ | 1 9 | }$ samples 250 diffusion steps for evaluation, and 27 steps for interactive sampling, to reduce the latency to 15s.
189
+
190
+ Autoregressive models must generate the image token-by-token, but our LoPAR can upsample the image with a high parallelism degree, so that (potentially) we can reduce the time cost by introducing more hierarchies to design models much faster than diffusion models.
191
+
192
+ Comparison between DALL-E-2 and CogView2. DALL-E-2 [27] is a recently released concurrent work for text-to-image generation on $1 0 2 4 \times 1 0 2 4$ resolution. Its probabilistic model and architecture are quite different from those in CogView2. But both models share the same spirit – hierarchical generation. The difference is that DALL-E-2 adopts an additional third-level super-resolution and a generation prior, which help result in potential quality gain, but also lead to expensive resourceconsuming. CogView2 is able to synthesize similar scenes according to the limited demos of DALL-E-2, e.g. “lion teacher” (Figure $^ { 1 ) }$ vs. “panda scientist” (DALL-E-2), considering CogView2 is trained using only $5 \%$ of the total data (650M text-image pairs) by DALL-E-2. For future, CogView2 can also adopt the third-level super-resolution and the prior, though it is engineering mostly.
193
+
194
+ # 7 Conclusion
195
+
196
+ The breakthrough in the text-to-image domain is made by autoregressive models. However, the slow generation and high complexity hinder researchers attempts to improve the quality in this direction. In this paper, we put forward an approach based on hierarchical transformers to help autoregressive models remedy these disadvantages, and bridge the gap between text-to-image pretraining and recent visual representation learning methods.
197
+
198
+ Broader Impact. The advancement of text-to-image generation, especially text-guided image editing, will ease the creative efforts of artists and designers, while also causing a risk of misinformation, leading to permanent damages to the reliability of web photos. However, it is possible to train a classifier to distinguish the real and CogView2-generated images according to the texture features.
199
+
200
+ # Acknowledgments and Disclosure of Funding
201
+
202
+ We would like to thank Zhao Xue and Sha Yuan for the help on collecting the dataset, Hanxiao Qu for maintaining the machines, and Yue Cao and Chang Zhou for their useful discussion, Zhendong Zhang for releasing an initial version of CUDA local attention.
203
+
204
+ Funding in direct support of this work: GPU hours donated by BAAI, NSFC for Distinguished Young Scholar (61825602).
205
+
206
+ # References
207
+
208
+ [1] H. Chang, H. Zhang, L. Jiang, C. Liu, and W. T. Freeman. Maskgit: Masked generative image transformer. arXiv preprint arXiv:2202.04200, 2022.
209
+ [2] 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.
210
+ [3] M. Ding, Z. Yang, W. Hong, W. Zheng, C. Zhou, D. Yin, J. Lin, X. Zou, Z. Shao, H. Yang, et al. Cogview: Mastering text-to-image generation via transformers. Advances in Neural Information Processing Systems, 34, 2021.
211
+ [4] C. Dong, C. C. Loy, K. He, and X. Tang. Learning a deep convolutional network for image super-resolution. In European conference on computer vision, pages 184–199. Springer, 2014.
212
+ [5] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
213
+ [6] Z. Du, Y. Qian, X. Liu, M. Ding, J. Qiu, Z. Yang, and J. Tang. All nlp tasks are generation tasks: A general pretraining framework. arXiv preprint arXiv:2103.10360, 2021.
214
+ [7] P. Esser, R. Rombach, and B. Ommer. Taming transformers for high-resolution image synthesis. arXiv preprint arXiv:2012.09841, 2020.
215
+ [8] O. Gafni, A. Polyak, O. Ashual, S. Sheynin, D. Parikh, and Y. Taigman. Make-a-scene: Scene-based text-to-image generation with human priors. arXiv preprint arXiv:2203.13131, 2022.
216
+ [9] M. Ghazvininejad, O. Levy, Y. Liu, and L. Zettlemoyer. Mask-predict: Parallel decoding of conditional masked language models. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 6112–6121, 2019.
217
+ [10] I. J. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. Courville, and Y. Bengio. Generative adversarial networks. arXiv preprint arXiv:1406.2661, 2014.
218
+ [11] S. Gu, D. Chen, J. Bao, F. Wen, B. Zhang, D. Chen, L. Yuan, and B. Guo. Vector quantized diffusion model for text-to-image synthesis. CoRR, abs/2111.14822, 2021.
219
+ [12] K. He, X. Chen, S. Xie, Y. Li, P. Dollár, and R. B. Girshick. Masked autoencoders are scalable vision learners. CoRR, abs/2111.06377, 2021.
220
+ [13] P. He, X. Liu, J. Gao, and W. Chen. Deberta: Decoding-enhanced bert with disentangled attention. arXiv preprint arXiv:2006.03654, 2020.
221
+ [14] A. Holtzman, J. Buys, L. Du, M. Forbes, and Y. Choi. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751, 2019.
222
+ [15] Y. Jia, E. Shelhamer, J. Donahue, S. Karayev, J. Long, R. Girshick, S. Guadarrama, and T. Darrell. Caffe: Convolutional architecture for fast feature embedding. In Proceedings of the 22nd ACM international conference on Multimedia, pages 675–678, 2014.
223
+ [16] T. Kudo. Subword regularization: Improving neural network translation models with multiple subword candidates. arXiv preprint arXiv:1804.10959, 2018.
224
+ [17] T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick. Microsoft coco: Common objects in context. In European conference on computer vision, pages 740–755. Springer, 2014.
225
+ [18] J. MacQueen et al. Some methods for classification and analysis of multivariate observations. In Proceedings of the fifth Berkeley symposium on mathematical statistics and probability, volume 1, pages 281–297. Oakland, CA, USA, 1967.
226
+ [19] A. Nichol, P. Dhariwal, A. Ramesh, P. Shyam, P. Mishkin, B. McGrew, I. Sutskever, and M. Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint arXiv:2112.10741, 2021.
227
+ [20] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin, N. Gimelshein, L. Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32, 2019.
228
+ [21] L. Qian, H. Zhou, Y. Bao, M. Wang, L. Qiu, W. Zhang, Y. Yu, and L. Li. Glancing transformer for non-autoregressive 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 1993–2003, 2021.
229
+ [22] A. Radford, J. Wu, R. Child, D. Luan, D. Amodei, and I. Sutskever. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
230
+ [23] 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. arXiv preprint arXiv:2103.00020, 2021.
231
+ [24] M. Raghu, T. Unterthiner, S. Kornblith, C. Zhang, and A. Dosovitskiy. Do vision transformers see like convolutional neural networks? Advances in Neural Information Processing Systems, 34, 2021.
232
+ [25] P. Ramachandran, T. L. Paine, P. Khorrami, M. Babaeizadeh, S. Chang, Y. Zhang, M. A. Hasegawa-Johnson, R. H. Campbell, and T. S. Huang. Fast generation for convolutional autoregressive models. arXiv preprint arXiv:1704.06001, 2017.
233
+ [26] A. Ramesh, M. Pavlov, G. Goh, S. Gray, C. Voss, A. Radford, M. Chen, and I. Sutskever. Zero-shot text-to-image generation. arXiv preprint arXiv:2102.12092, 2021.
234
+ [27] A. Ramesh, P. Dhariwal, A. Nichol, C. Chu, and M. Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022.
235
+ [28] M. Tao, H. Tang, S. Wu, N. Sebe, F. Wu, and X.-Y. Jing. Df-gan: Deep fusion generative adversarial networks for text-to-image synthesis. arXiv preprint arXiv:2008.05865, 2020.
236
+ [29] A. van den Oord, O. Vinyals, and K. Kavukcuoglu. Neural discrete representation learning. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pages 6309–6318, 2017.
237
+ [30] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762, 2017.
238
+ [31] A. Wang, A. Singh, J. Michael, F. Hill, O. Levy, and S. Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. In Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pages 353–355, 2018.
239
+ [32] Z. Wang, E. P. Simoncelli, and A. C. Bovik. Multiscale structural similarity for image quality assessment. In The Thrity-Seventh Asilomar Conference on Signals, Systems & Computers, 2003, volume 2, pages 1398–1402. Ieee, 2003.
240
+ [33] C. Wu, J. Liang, L. Ji, F. Yang, Y. Fang, D. Jiang, and N. Duan. N\" uwa: Visual synthesis pre-training for neural visual world creation. arXiv preprint arXiv:2111.12417, 2021.
241
+ [34] Z. Xie, Z. Zhang, Y. Cao, Y. Lin, J. Bao, Z. Yao, Q. Dai, and H. Hu. Simmim: A simple framework for masked image modeling. CoRR, abs/2111.09886, 2021.
242
+ [35] T. Xu, P. Zhang, Q. Huang, H. Zhang, Z. Gan, X. Huang, and X. He. Attngan: Fine-grained text to image generation with attentional generative adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1316–1324, 2018.
243
+ [36] H. Zhang, J. Y. Koh, J. Baldridge, H. Lee, and Y. Yang. Cross-modal contrastive learning for text-to-image generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 833–842, 2021.
244
+ [37] R. Zhang, P. Isola, A. A. Efros, E. Shechtman, and O. Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 586–595, 2018.
245
+ [38] Z. Zhang, J. Ma, C. Zhou, R. Men, Z. Li, M. Ding, J. Tang, J. Zhou, and H. Yang. M6-ufc: Unifying multi-modal controls for conditional image synthesis. arXiv preprint arXiv:2105.14211, 2021.
246
+ [39] Y. Zhou, R. Zhang, C. Chen, C. Li, C. Tensmeyer, T. Yu, J. Gu, J. Xu, and T. Sun. Lafite: Towards language-free training for text-to-image generation. arXiv preprint arXiv:2111.13792, 2021.
247
+ [40] M. Zhu, P. Pan, W. Chen, and Y. Yang. Dm-gan: Dynamic memory generative adversarial networks for text-to-image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5802–5810, 2019.
248
+
249
+ # Checklist
250
+
251
+ 1. For all authors...
252
+
253
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
254
+ (b) Did you describe the limitations of your work? [Yes] See section 6
255
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes]
256
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
257
+
258
+ 2. If you are including theoretical results...
259
+
260
+ (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]
261
+
262
+ 3. If you ran experiments...
263
+
264
+ (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]
265
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
266
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No]
267
+ (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]
268
+
269
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
270
+
271
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
272
+ (b) Did you mention the license of the assets? [No]
273
+ (c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
274
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No]
275
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
276
+
277
+ 5. If you used crowdsourcing or conducted research with human subjects...
278
+
279
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [Yes]
280
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
281
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes]
md/dev/JYtwGwIL7ye/JYtwGwIL7ye.md ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # THE EFFECTS OF REWARD MISSPECIFICATION: MAPPING AND MITIGATING MISALIGNED MODELS
2
+
3
+ Alexander Pan Caltech
4
+
5
+ Kush Bhatia UC Berkeley
6
+
7
+ Jacob Steinhardt UC Berkeley
8
+
9
+ # ABSTRACT
10
+
11
+ Reward hacking—where RL agents exploit gaps in misspecified reward functions—has been widely observed, but not yet systematically studied. To understand how reward hacking arises, we construct four RL environments with misspecified rewards. We investigate reward hacking as a function of agent capabilities: model capacity, action space resolution, observation space noise, and training time. More capable agents often exploit reward misspecifications, achieving higher proxy reward and lower true reward than less capable agents. Moreover, we find instances of phase transitions: capability thresholds at which the agent’s behavior qualitatively shifts, leading to a sharp decrease in the true reward. Such phase transitions pose challenges to monitoring the safety of ML systems. To address this, we propose an anomaly detection task for aberrant policies and offer several baseline detectors.
12
+
13
+ # 1 INTRODUCTION
14
+
15
+ As reinforcement learning agents are trained with better algorithms, more data, and larger policy models, they are at increased risk of overfitting their objectives (Russell, 2019). Reward hacking, or the gaming of misspecified reward functions by RL agents, has appeared in a variety of contexts, such as game playing (Ibarz et al., 2018), text summarization (Paulus et al., 2018), and autonomous driving (Knox et al., 2021). These examples show that better algorithms and models are not enough; for human-centered applications such as healthcare (Yu et al., 2019), economics (Trott et al., 2021) and robotics (Kober et al., 2013), RL algorithms must be safe and aligned with human objectives (Bommasani et al., 2021; Hubinger et al., 2019).
16
+
17
+ Reward misspecifications occur because real-world tasks have numerous, often conflicting desiderata. In practice, reward designers resort to optimizing a proxy reward that is either more readily measured or more easily optimized than the true reward. For example, consider a recommender system optimizing for users’ subjective well-being (SWB). Because SWB is difficult to measure, engineers rely on more tangible metrics such as click-through rates or watch-time. Optimizing for misspecified proxies led YouTube to overemphasize watch-time and harm user satisfaction (Stray, 2020), as well as to recommended extreme political content to users (Ribeiro et al., 2020).
18
+
19
+ Addressing reward hacking is a first step towards developing human-aligned RL agents and one goal of ML safety (Hendrycks et al., 2021a). However, there has been little systematic work investigating when or how it tends to occur, or how to detect it before it runs awry. To remedy this, we study the problem of reward hacking across four diverse environments: traffic control (Wu et al., 2021), COVID response (Kompella et al., 2020), blood glucose monitoring (Fox et al., 2020), and the Atari game Riverraid (Brockman et al., 2016). Within these environments, we construct nine misspecified proxy reward functions (Section 3).
20
+
21
+ Using our environments, we study how increasing optimization power affects reward hacking, by training RL agents with varying resources such as model size, training time, action space resolution, and observation space noise (Section 4). We find that more powerful agents often attain higher proxy reward but lower true reward, as illustrated in Figure 1. Since the trend in ML is to increase resources exponentially each year (Littman et al., 2021), this suggests that reward hacking will become more pronounced in the future in the absence of countermeasures.
22
+
23
+ ![](images/0716b5dacc343315af119cb36efc33c64b88da690a32a60aed3e6ed1d0b35a52.jpg)
24
+ High mean commute
25
+ Figure 1: An example of reward hacking when cars merge onto a highway. A human-driver model controls the grey cars and an RL policy controls the red car. The RL agent observes positions and velocities of nearby cars (including itself) and adjusts its acceleration to maximize the proxy reward. At first glance, both the proxy reward and true reward appear to incentivize fast traffic flow. However, smaller policy models allow the red car to merge, whereas larger policy models exploit the misspecification by stopping the red car. When the red car stops merging, the mean velocity increases (merging slows down the more numerous grey cars). However, the mean commute time also increases (the red car is stuck). This exemplifies a phase transition: the qualitative behavior of the agent shifts as the model size increases.
26
+
27
+ More worryingly, we observe several instances of phase transitions. In a phase transition, the more capable model pursues a qualitatively different policy that sharply decreases the true reward. Figure 1 illustrates one example: An RL agent regulating traffic learns to stop any cars from merging onto the highway in order to maintain a high average velocity of the cars on the straightaway.
28
+
29
+ Since there is little prior warning of phase transitions, they pose a challenge to monitoring the safety of ML systems. Spurred by this challenge, we propose an anomaly detection task (Hendrycks & Gimpel, 2017; Tack et al., 2020): Can we detect when the true reward starts to drop, while maintaining a low false positive rate in benign cases? We instantiate our proposed task, POLYNOMALY, for the traffic and COVID environments (Section 5). Given a trusted policy with moderate performance, one must detect whether a given policy is aberrant. We provide several baseline anomaly detectors for this task and release our data at https://github.com/aypan17/ reward-misspecification.
30
+
31
+ # 2 RELATED WORK
32
+
33
+ Previous works have focused on classifying different types of reward hacking and sometimes mitigating its effects. One popular setting is an agent on a grid-world with an erroneous sensor. HadfieldMenell et al. (2017) show and mitigate the reward hacking that arises due to an incorrect sensor reading at test time in a $1 0 \mathrm { x } 1 0$ navigation grid world. Leike et al. (2017) show examples of reward hacking in a 3x3 boat race and a $5 \mathrm { x } 7$ tomato watering grid world. Everitt et al. (2017) theoretically study and mitigate reward hacking caused by a faulty sensor.
34
+
35
+ Game-playing agents have also been found to hack their reward. Baker et al. (2020) exhibit reward hacking in a hide-and-seek environment comprising 3-6 agents, 3-9 movable boxes and a few ramps: without a penalty for leaving the play area, the hiding agents learn to endlessly run from the seeking agents. Toromanoff et al. (2019) briefly mention reward hacking in several Atari games (Elevator Action, Kangaroo, Bank Heist) where the agent loops in a sub-optimal trajectory that provides a repeated small reward.
36
+
37
+ Agents optimizing a learned reward can also demonstrate reward hacking. Ibarz et al. (2018) show an agent hacking a learned reward in Atari (Hero, Montezuma’s Revenge, and Private Eye), where optimizing a frozen reward predictor eventually achieves high predicted score and low actual score. Christiano et al. (2017) show an example of reward hacking in the Pong game where the agent learns to hit the ball back and forth instead of winning the point. Stiennon et al. (2020) show that a policy which over-optimizes the learnt reward model for text summarization produces lower quality summarizations when judged by humans.
38
+
39
+ In this section, we describe our four environments (Section 3.1) and taxonomize our nine corresponding misspecified reward functions (Section 3.2).
40
+
41
+ # 3.1 ENVIRONMENTS
42
+
43
+ We chose a diverse set of environments and prioritized complexity of action space, observation space, and dynamics model. Our aim was to reflect real-world constraints in our environments, selecting ones with several desiderata that must be simultaneously balanced. Table 1 provides a summary.
44
+
45
+ Traffic Control. The traffic environment is an autonomous vehicle (AV) simulation that models vehicles driving on different highway networks. The vehicles are either controlled by a RL algorithm or pre-programmed via a human behavioral model. Our misspecifications are listed in Table 1.
46
+
47
+ We use the Flow traffic simulator, implemented by Wu et al. (2021) and Vinitsky et al. (2018), which extends the popular SUMO traffic simulator (Lopez et al., 2018). The simulator uses cars that drive like humans, following the Intelligent Driver Model (IDM) (Treiber et al., 2000), a widely-accepted approximation of human driving behavior. Simulated drivers attempt to travel as fast as possible while tending to decelerate whenever they are too close to the car immediately in front.
48
+
49
+ The RL policy has access to observations only from the AVs it controls. For each AV, the observation space consists of the car’s position, its velocity, and the position and velocity of the cars immediately in front of and behind it. The continuous control action is the acceleration applied to each AV. Figure 4 depicts the Traffic-Mer network, where cars from an on-ramp attempt to merge onto the straightaway. We also use the Traffic-Bot network, where cars (1-4 RL, 10-20 human) drive through a highway bottleneck where lanes decrease from four to two to one.
50
+
51
+ COVID Response. The COVID environment, developed by Kompella et al. (2020), simulates a population using the SEIR model of individual infection dynamics. The RL policymaker adjusts the severity of social distancing regulations while balancing economic health (better with lower regulations) and public health (better with higher regulations), similar in spirit to Trott et al. (2021). The population attributes (proportion of adults, number of hospitals) and infection dynamics (random testing rate, infection rate) are based on data from Austin, Texas.
52
+
53
+ Every day, the environment simulates the infection dynamics and reports testing results to the agent, but not the true infection numbers. The policy chooses one of three discrete actions: INCREASE, DECREASE, or MAINTAIN the current regulation stage, which directly affects the behavior of the population and indirectly affects the infection dynamics. There are five stages in total.
54
+
55
+ Atari Riverraid. The Atari Riverraid environment is run on OpenAI Gym (Brockman et al., 2016). The agent operates a plane which flies over a river and is rewarded by destroying enemies. The agent observes the raw pixel input of the environment. The agent can take one of eighteen discrete actions, corresponding to either movement or shooting within the environment.
56
+
57
+ Glucose Monitoring. The glucose environment, implemented in Fox et al. (2020), is a continuous control problem. It extends a FDA-approved simulator (Man et al., 2014) for blood glucose levels of a patient with Type 1 diabetes. The patient partakes in meals and wears a continuous glucose monitor (CGM), which gives noisy observations of the patient’s glucose levels. The RL agent administers insulin to maintain a healthy glucose level.
58
+
59
+ Every five minutes, the agent observes the patient’s glucose levels and decides how much insulin to administer. The observation space is the previous four hours of glucose levels and insulin dosages.
60
+
61
+ # 3.2 MISSPECIFICATIONS
62
+
63
+ Using the above environments, we constructed nine instances of misspecified proxy rewards. To help interpret these proxies, we taxonomize them as instances of misweighting, incorrect ontology, or incorrect scope. We elaborate further on this taxonimization using the traffic example from Figure 1.
64
+
65
+ Table 1: Reward misspecifications across our four environments. ‘Misalign’ indicates whether the true reward drops and ‘Transition’ indicates whether this corresponds to a phase transition (sharp qualitative change). We observe 5 instances of misalignment and 4 instances of phase transitions. ‘Mis.’ is a misweighting and ’Ont.’ is an ontological misspecification.
66
+
67
+ <table><tr><td>Env.</td><td>Type</td><td>Objective</td><td>Proxy</td><td>Misalign?</td><td>Transition?</td></tr><tr><td rowspan="3">Traffic</td><td>Mis. Mis. Ont.</td><td rowspan="3">minimize commute and accelerations</td><td rowspan="3">underpenalize acceleration underpenalize lane changes</td><td>No Yes</td><td>No Yes</td></tr><tr><td></td><td></td><td></td></tr><tr><td>velocity replaces commute</td><td>Yes</td><td>Yes</td></tr><tr><td rowspan="3">COVID</td><td rowspan="3">Scope Mis.</td><td rowspan="3">balance economic,</td><td rowspan="3">monitor velocity near merge underpenalize health cost</td><td>Yes</td><td>Yes</td></tr><tr><td></td><td></td></tr><tr><td>No</td><td>No Yes</td></tr><tr><td rowspan="3">Atari</td><td rowspan="3">Mis.</td><td rowspan="3">score points under</td><td rowspan="3">ignore political cost downweight movement</td><td>Yes</td><td></td></tr><tr><td></td><td></td></tr><tr><td>No No</td><td>No No</td></tr><tr><td>Glucose</td><td>Ont.</td><td>minimize health risk</td><td>risk in place of cost</td><td>Yes</td><td>No</td></tr></table>
68
+
69
+ • Misweighting. Suppose that the true reward is a linear combination of commute time and acceleration (for reducing carbon emissions). Downweighting the acceleration term thus underpenalizes carbon emissions. In general, misweighting occurs when the proxy and true reward capture the same desiderata, but differ on their relative importance.
70
+ • Ontological. Congestion could be operationalized as either high average commute time or low average vehicle velocity. In general, ontological misspecification occurs when the proxy and true reward use different desiderata to capture the same concept.
71
+ • Scope. If monitoring velocity over all roads is too costly, a city might instead monitor them only over highways, thus pushing congestion to local streets. In general, scope misspecification occurs when the proxy measures desiderata over a restricted domain (e.g. time, space).
72
+
73
+ We include a summary of all nine tasks in Table 1 and provide full details in Appendix A. Table 1 also indicates whether each proxy leads to misalignment (i.e. to a policy with low true reward) and whether it leads to a phase transition (a sudden qualitative shift as model capacity increases). We investigate both of these in Section 4.
74
+
75
+ Evaluation protocol. For each environment and proxy-true reward pair, we train an agent using the proxy reward and evaluate performance according to the true reward. We use PPO (Schulman et al., 2017) to optimize policies for the traffic and COVID environments, SAC (Haarnoja et al., 2018) to optimize the policies for the glucose environment, and torchbeast (Kuttler et al. ¨ , 2019), a PyTorch implementation of IMPALA (Espeholt et al., 2018), to optimize the policies for the Atari environment. When available, we adopt the hyperparameters (except the learning rate and network size) given by the original codebase.
76
+
77
+ # 4 HOW AGENT OPTIMIZATION POWER DRIVES MISALIGNMENT
78
+
79
+ To better understand reward hacking, we study how it emerges as agent optimization power increases. We define optimization power as the effective search space of policies the agent has access to, as implicitly determined by model size, training steps, action space, and observation space.
80
+
81
+ In Section 4.1, we consider the quantitative effect of optimization power for all nine environmentmisspecification pairs; we primarily do this by varying model size, but also use training steps, action space, and observation space as robustness checks. Overall, more capable agents tend to overfit the proxy reward and achieve a lower true reward. We also find evidence of phase transitions on four of the environment-misspecification pairs. For these phase transitions, there is a critical threshold at which the proxy reward rapidly increases and the true reward rapidly drops.
82
+
83
+ In Section 4.2, we further investigate these phase transitions by qualitatively studying the resulting policies. At the transition, we find that the quantitative drop in true reward corresponds to a qualitative shift in policy behavior. Extrapolating visible trends is therefore insufficient to catch all instances of reward hacking, increasing the urgency of research in this area.
84
+
85
+ ![](images/2239da35f19488ff8fa05e9b91d185add90f722e69b8e5e2d8a9f7e4649dcbb3.jpg)
86
+ Figure 2: Increasing the RL policy’s model size decreases true reward on three selected environments. The red line indicates a phase transition.
87
+
88
+ In Section 4.3, we assess the faithfulness of our proxies, showing that reward hacking occurs even though the true and proxy rewards are strongly positively correlated in most cases.
89
+
90
+ # 4.1 QUANTITATIVE EFFECTS VS. AGENT CAPABILITIES
91
+
92
+ As a stand-in for increasing agent optimization power, we first vary the model capacity for a fixed environment and proxy reward. Specifically, we vary the width and depth of the actor and critic networks, changing the parameter count by two to four orders of magnitude depending on the environment. For a given policy, the actor and critic are always the same size.
93
+
94
+ Model Capacity. Our results are shown in Figure 2, with additional plots included in Appendix A. We plot both the proxy (blue) and true (green) reward vs. the number of parameters. As model size increases, the proxy reward increases but the true reward decreases. This suggests that reward designers will likely need to take greater care to specify reward functions accurately and is especially salient given the recent trends towards larger and larger models (Littman et al., 2021).
95
+
96
+ The drop in true reward is sometimes quite sudden. We call these sudden shifts phase transitions, and mark them with dashed red lines in Figure 2. These quantitative trends are reflected in the qualitative behavior of the policies (Section 4.2), which typically also shift at the phase transition.
97
+
98
+ Model capacity is only one proxy for agent capabilities, and larger models do not always lead to more capable agents (Andrychowicz et al., 2020). To check the robustness of our results, we consider several other measures of optimization: observation fidelity, number of training steps, and action space resolution.
99
+
100
+ ![](images/11d930e8f7af759471cf950deec3c75bc1649f3852cebaaa311bdfdf4ada0e39.jpg)
101
+ Figure 3: In addition to parameter count, we consider three other agent capabilities: training steps, action space resolution, and observation noise. In Figure 3a, an increase in the proxy reward comes at the cost of the true reward. In Figure 3b, increasing the granularity (from right to left) causes the agent to achieve similar proxy reward but lower true reward. In Figure 3c, increasing the fidelity of observations (by increasing the random testing rate in the population) tends to decrease the true reward with no clear impact on proxy reward.
102
+
103
+ Number of training steps. Assuming a reasonable RL algorithm and hyperparameters, agents which are trained for more steps have more optimization power. We vary training steps for an agent trained on the Atari environment. The true reward incentivizes staying alive for as many frames as possible while moving smoothly. The proxy reward misweights these considerations by underpenalizing the smoothness constraint. As shown in Figure 3a, optimizing the proxy reward for more steps harms the true reward, after an initial period where the rewards are positively correlated.
104
+
105
+ Action space resolution. Intuitively, an agent that can take more precise actions is more capable. For example, as technology improves, an RL car may make course corrections every millisecond instead of every second. We study action space resolution in the traffic environment by discretizing the output space of the RL agent. Specifically, under resolution level $\varepsilon$ , we round the action $a \in \mathbb { R }$ output by the RL agent to the nearest multiple of $\varepsilon$ and use that as our action. The larger the resolution level $\varepsilon$ , the lower the action space resolution. Results are shown in Figure 3b for a fixed model size. Increasing the resolution causes the proxy reward to remain roughly constant while the true reward decreases.
106
+
107
+ Observation fidelity. Agents with access to better input sensors, like higher-resolution cameras, should make more informed decisions and thus have more optimization power. Concretely, we study this in the COVID environment, where we increase the random testing rate in the population. The proxy reward is a linear combination of the number of infections and severity of social distancing, while the true reward also factors in political cost. As shown in Figure 3c, as the testing rate increases, the model achieves similar proxy reward at the cost of a slightly lower true reward.
108
+
109
+ # 4.2 QUALITATIVE EFFECTS
110
+
111
+ In the previous section, quantitative trends showed that increasing a model’s optimization power often hurts performance on the true reward. We shift our focus to understanding how this decrease happens. In particular, we typically observe a qualitative shift in behavior associated with each of the phase transitions, three of which we describe below.
112
+
113
+ Traffic Control. We focus on the Traffic-Mer environment from Figure 2a, where minimizing average commute time is replaced by maximizing average velocity. In this case, smaller policies learn to merge onto the straightaway by slightly slowing down the other vehicles (Figure 4a). On the other hand, larger policy models stop the AVs to prevent them from merging at all (Figure 4b). This increases the average velocity, because the vehicles on the straightaway (which greatly outnumber vehicles on the on-ramp) do not need to slow down for merging traffic. However, it significantly increases the average commute time, as the passengers in the AV remain stuck.
114
+
115
+ COVID Response. Suppose the RL agent optimizes solely for the public and economic health of a society, without factoring politics into its decision-making. This behavior is shown in Figure 5. The larger model chooses to increase the severity of social distancing restrictions earlier than the smaller model. As a result, larger models are able to maintain low average levels of both ICU usage (a proxy for public health) and social distancing restrictions (a proxy for economic health). These preemptive regulations may however be politically costly, as enforcing restrictions without clear signs of infection may foment public unrest (Boettke & Powell, 2021).
116
+
117
+ ![](images/20c8d45ab80f8a40cdf6b8bd0ca3ec45b66632f220734672169d41f46f91b1ba.jpg)
118
+ Figure 4: The larger model prevents the AVs (in red) from moving to increase the velocity of the human cars (unobserved cars in white and observed cars in blue). However, this greatly increases the average commute per person.
119
+
120
+ ![](images/63dd49680e8fd6b2b6c10f51ce5d1b884d8a5e5355a67c58d0f671ed0bea9a13.jpg)
121
+ Figure 5: For COVID, ICU usage is a proxy for public health and regulation stage is a proxy for economic health. The blue line indicates the maximum stage (right) enforced by the larger policy and the corresponding ICU level (left) at that stage. The red line is the equivalent for the smaller policy. Because the larger policy enforces regulations much sooner than the smaller policy, it maintains both low ICU usage and low regulation stage. However, the larger policy is politically unfavorable: regulations are high even though public signs of infection, such as ICU usage, are low.
122
+
123
+ Atari Riverraid. We create an ontological misspecification by rewarding the plane for staying alive as long as possible while shooting as little as possible: a “pacifist run”. We then measure the game score as the true reward. We find that agents with more parameters typically maneuver more adeptly. Such agents shoot less frequently, but survive for much longer, acquiring points (true reward) due to passing checkpoints. In this case, therefore, the proxy and true rewards are wellaligned so that reward hacking does not emerge as capabilities increase.
124
+
125
+ We did, however, find that some of the agents exploited a bug in the simulator that halts the plane at the beginning of the level. The simulator advances but the plane itself does not move, thereby achieving high pacifist reward.
126
+
127
+ Glucose Monitoring. Consider an RL agent that optimizes solely for a patient’s health, without considering the economic costs of its treatment plans. In this case, the proxy reward is based off of a glycemic risk measure, which reflects the likelihood that a patient will suffer an acute hypoglycemic episode, developed by the medical community (Kovatchev et al., 2000).
128
+
129
+ However, a less economically-privileged patient may opt for the treatment plan with the least expected cost (Herkert et al., 2019; Fralick & Kesselheim, 2019), not the one with the least amount of risk. From this patient’s perspective, the true reward is the expected cost of the treatment plan, which includes the expected cost of hospital visits and the cost of administering the insulin.
130
+
131
+ Although larger model treatments reduce hypoglycemic risk more smaller model treatments, they administer more insulin. Based on the average cost of an ER visit for a hypogylcemic episode $\$ 1350$ from Bronstone & Graham (2016)) and the average cost of a unit of insulin $\mathfrak { F } 0 . 3 2$ from Lee (2020)), we find that it is actually more expensive to pursue the larger model’s treatment.
132
+
133
+ # 4.3 QUANTITATIVE EFFECTS VS PROXY-TRUE REWARD CORRELATION
134
+
135
+ We saw in Sections 4.1 and 4.2 that agents often pursue proxy rewards at the cost of the true reward. Perhaps this only occurs because the proxy is greatly misspecified, i.e., the proxy and true reward are weakly or negatively correlated. If this were the case, then reward hacking may pose less of a threat. To investigate this intuition, we plot the correlation between the proxy and true rewards.
136
+
137
+ The correlation is determined by the state distribution of a given policy, so we consider two types of state distributions. Specifically, for a given model size, we obtain two checkpoints: one that achieves the highest proxy reward during training and one from early in training (less than $1 \%$ of training complete). We call the former the “trained checkpoint” and the latter the “early checkpoint”.
138
+
139
+ ![](images/dd9c6f2c288fd62f89394bb0653bfc424d6c5a337f19c4fe4624d9bd4b79c0b4.jpg)
140
+ Figure 6: Correlations between the proxy and true rewards, along with the reward hacking induced. In Figure 6a, we plot the proxy reward with “•” and the true reward with “ $\times ^ { \dag \mathparagraph }$ . In Figure 6b, we plot the trained checkpoint correlation and the early checkpoint correlation.
141
+
142
+ For a given model checkpoint, we calculate the Pearson correlation $\rho$ between the proxy reward $P$ and true reward $T$ using 30 trajectory rollouts. Reward hacking occurs even though there is significant positive correlation between the true and proxy rewards (see Figure 6). The correlation is lower for the trained model than for the early model, but still high. Further figures are shown in Appendix A.2. Among the four environments tested, only the Traffic-Mer environment with ontological misspecification had negative Pearson correlation.
143
+
144
+ # 5 POLYNOMALY: MITIGATING REWARD MISSPECIFICATION
145
+
146
+ In Section 4, we saw that reward hacking often leads to phase transitions in agent behaviour. Furthermore, in applications like traffic control or COVID response, the true reward may be observed only sporadically or not at all. Blindly optimizing the proxy in these cases can lead to catastrophic failure (Zhuang & Hadfield-Menell, 2020; Taylor, 2016).
147
+
148
+ This raises an important question: Without the true reward signal, how can we mitigate misalignment? We operationalize this as an anomaly detection task: the detector should flag instances of misalignment, thus preventing catastrophic rollouts. To aid the detector, we provide it with a trusted policy: one verified by humans to have acceptable (but not maximal) reward. Our resulting benchmark, POLYNOMALY, is described below.
149
+
150
+ # 5.1 PROBLEM SETUP
151
+
152
+ We train a collection of policies by varying model size on the traffic and COVID environments. For each policy, we estimate the policy’s true reward by averaging over 5 to 32 rollouts. One author labeled each policy as acceptable, problematic, or ambiguous based on its true reward score relative to that of other policies. We include only policies that received a non-ambiguous label.
153
+
154
+ For both environments, we provide a small-to-medium sized model as the trusted policy model, as Section 4.1 empirically illustrates that smaller models achieve reasonable true reward without exhibiting reward hacking. Given the trusted model and a collection of policies, the anomaly detector’s task is to predict the binary label of “acceptable” or “problematic” for each policy.
155
+
156
+ Table 3 in Appendix B.1 summarizes our benchmark. The trusted policy size is a list of the hidden unit widths of the trusted policy network (not including feature mappings).
157
+
158
+ # 5.2 EVALUATION
159
+
160
+ We propose two evaluation metrics for measuring the performance of our anomaly detectors.
161
+
162
+ • Area Under the Receiver Operating Characteristic (AUROC). The AUROC measures the probability that a detector will assign a random anomaly a higher score than a random non-anomalous policy (Davis & Goadrich, 2006). Higher AUROCs indicate stronger detectors.
163
+
164
+ • Max F-1 score. The F-1 score is the harmonic mean of the precision and the recall, so detectors with a high F-1 score have both low false positives and high true negatives. We calculate the max F-1 score by taking the maximum F-1 score over all possible thresholds for the detector.
165
+
166
+ # 5.3 BASELINES
167
+
168
+ In addition to the benchmark datasets described above, we provide baseline anomaly detectors based on estimating distances between policies. We estimate the distance between the trusted policy and the unknown policy based on either the Jensen-Shannon divergence (JSD) or the Hellinger distance. Specifically, we use rollouts to generate empirical action distributions. We compute the distance between these action distributions at each step of the rollout, then aggregate across steps by taking either the mean or the range. For full details, see Appendix B.2. Table 2 reports the AUROC and F-1 scores of several such detectors. We provide full ROC curves in Appendix B.2.
169
+
170
+ <table><tr><td>Baseline Detectors</td><td colspan="2">Mean Jensen-Shannon</td><td colspan="2">Mean Hellinger</td><td colspan="2">Range Hellinger</td></tr><tr><td>Env. - Misspecification</td><td>AUROC</td><td>Max F-1</td><td>AUROC</td><td>Max F-1</td><td>AUROC</td><td>Max F-1</td></tr><tr><td>Traffic-Mer- misweighting</td><td>81.0%</td><td>0.824</td><td>81.0%</td><td>0.824</td><td>76.2%</td><td>0.824</td></tr><tr><td>Traffic-Mer - scope</td><td>74.6%</td><td>0.818</td><td>74.6%</td><td>0.818</td><td>57.1%</td><td>0.720</td></tr><tr><td>Traffic-Mer - ontological</td><td>52.7%</td><td>0.583</td><td>55.4%</td><td>0.646</td><td>71.4%</td><td>0.842</td></tr><tr><td>Traffic-Bot - misweighting</td><td>88.9%</td><td>0.900</td><td>88.9%</td><td>0.900</td><td>74.1%</td><td>0.857</td></tr><tr><td>COVID - ontological</td><td>45.2%</td><td>0.706</td><td>59.5%</td><td>0.750</td><td>88.1%</td><td>0.923</td></tr></table>
171
+
172
+ Table 2: Performance of detectors on different subtasks. Each detector has at least one subtask with AUROC under $60 \%$ , indicating poor performance.
173
+
174
+ We observe that different detectors are better for different tasks, suggesting that future detectors could do better than any of our baselines. Our benchmark and baseline provides a starting point for further research on mitigating reward hacking.
175
+
176
+ # 6 DISCUSSION
177
+
178
+ In this work, we designed a diverse set of environments and proxy rewards, uncovered several instances of phase transitions, and proposed an anomaly detection task to help mitigate these transitions. Our results raise two questions: How can we not only detect phase transitions, but prevent them in the first place? And how should phase transitions shape our approach to safe ML?
179
+
180
+ On preventing phase transitions, anomaly detection already offers one path forward. Once we can detect anomalies, we can potentially prevent them, by using the detector to purge the unwanted behavior (e.g. by including it in the training objective). Similar policy shaping has recently been used to make RL agents more ethical (Hendrycks et al., 2021b). However, since the anomaly detectors will be optimized against by the RL policy, they need to be adversarially robust (Goodfellow et al., 2014). This motivates further work on adversarial robustness and adversarial anomaly detection. Another possible direction is optimizing policies against a distribution of rewards (Brown et al., 2020; Javed et al., 2021), which may prevent over-fitting to a given set of metrics.
181
+
182
+ Regarding safe ML, several recent papers propose extrapolating empirical trends to forecast future ML capabilities (Kaplan et al., 2020; Hernandez et al., 2021; Droppo & Elibol, 2021), partly to avoid unforeseen consequences from ML. While we support this work, our results show that trend extrapolation alone is not enough to ensure the safety of ML systems. To complement trend extrapolation, we need better interpretability methods to identify emergent model behaviors early on, before they dominate performance (Olah et al., 2018). ML researchers should also familiarize themselves with emergent behavior in self-organizing systems (Yates, 2012), which often exhibit similar phase transitions (Anderson, 1972). Indeed, the ubiquity of phase transitions throughout science suggests that ML researchers should continue to expect surprises–and should therefore prepare for them.
183
+
184
+ # ACKNOWLEDGEMENTS
185
+
186
+ We are thankful to Dan Hendrycks and Adam Gleave for helpful discussions about experiments and to Cassidy Laidlaw and Dan Hendrycks for providing valuable feedback on the writing. KB was supported by a JP Morgan AI Fellowship. JS was supported by NSF Award 2031985 and by Open Philanthropy.
187
+
188
+ # REFERENCES
189
+
190
+ Philip W Anderson. More is different. Science, 177(4047):393–396, 1972.
191
+
192
+ Marcin Andrychowicz, Anton Raichuk, Piotr Stanczyk, Manu Orsini, Sertan Girgin, Raphael ´ Marinier, Leonard Hussenot, Matthieu Geist, Olivier Pietquin, and Marcin Michalski. What ´ matters in on-policy reinforcement learning? A large-scale empirical study. arXiv preprint arXiv:2006.05990, 2020.
193
+
194
+ Bowen Baker, Ingmar Kanitscheider, Todor Markov, Yi Wu, Glenn Powell, Bob McGrew, and Igor Mordatch. Emergent tool use from multi-agent autocurricula. In International Conference on Learning Representations, 2020.
195
+
196
+ Peter Boettke and Benjamin Powell. The political economy of the covid-19 pandemic. Southern Economic Journal, 87(4):1090–1106, 2021.
197
+
198
+ Rishi Bommasani et al. On the opportunities and risks of foundation models. arXiv preprint arXiv:2108.07258, 2021.
199
+
200
+ Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym, 2016.
201
+
202
+ Amy Bronstone and Claudia Graham. The potential cost implications of averting severe hypoglycemic events requiring hospitalization in high-risk adults with type 1 diabetes using real-time continuous glucose monitoring. Journal of Diabetes Science and Technology, 10, 2016.
203
+
204
+ Daniel Brown, Russell Coleman, Ravi Srinivasan, and Scott Niekum. Safe imitation learning via fast Bayesian reward inference from preferences. In Proceedings of the 37th International Conference on Machine Learning, 2020.
205
+
206
+ Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. In Advances in Neural Information Processing Systems, 2017.
207
+
208
+ Jesse Davis and Mark Goadrich. The relationship between precision-recall and roc curves. In International Conference on Machine Learning, 2006.
209
+
210
+ Jasha Droppo and Oguz Elibol. Scaling laws for acoustic models. arXiv preprint arXiv:2106.09488, 2021.
211
+
212
+ Lasse Espeholt, Hubert Soyer, Remi Munos, Karen Simonyan, Volodymyr Mnih, Tom Ward, Yotam Doron, Vlad Firoiu, Tim Harley, Iain Robert Dunning, Shane Legg, and Koray Kavukcuoglu. Impala: Scalable distributed deep-rl with importance weighted actor-learner architectures. 2018.
213
+
214
+ Tom Everitt, Victoria Krakovna, Laurent Orseau, and Shane Legg. Reinforcement learning with a corrupted reward channel. In International Joint Conference on Artificial Intelligence, 2017.
215
+
216
+ Ian Fox, Joyce Lee, Rodica Pop-Busui, and Jenna Wiens. Deep reinforcement learning for closedloop blood glucose control. In Machine Learning for Healthcare Conference, 2020.
217
+
218
+ M. Fralick and A. S. Kesselheim. The U.S. Insulin Crisis - Rationing a Lifesaving Medication Discovered in the 1920s. New England Journal of Medicine, 381(19):1793–1795, 2019.
219
+
220
+ Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
221
+
222
+ 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, 2018.
223
+
224
+ Dylan Hadfield-Menell, Smitha Milli, Pieter Abbeel, Stuart J Russell, and Anca Dragan. Inverse reward design. In Advances in Neural Information Processing Systems, 2017.
225
+
226
+ Dan Hendrycks and Kevin Gimpel. A baseline for detecting misclassified and out-of-distribution examples in neural networks. International Conference on Learning Representations, 2017.
227
+
228
+ Dan Hendrycks, Nicholas Carlini, John Schulman, and Jacob Steinhardt. Unsolved problems in ml safety. arXiv preprint arXiv:2109.13916, 2021a.
229
+
230
+ Dan Hendrycks, Mantas Mazeika, Andy Zou, Sahil Patel, Christine Zhu, Jesus Navarro, Dawn Song, Bo Li, and Jacob Steinhardt. What would Jiminy Cricket do? Towards agents that behave morally. 2021b.
231
+
232
+ Darby Herkert, Pavithra Vijayakumar, Jing Luo, Jeremy I. Schwartz, Tracy L. Rabin, Eunice DeFilippo, and Kasia J. Lipska. Cost-related insulin underuse among patients with diabetes. JAMA Internal Medicine, 179(1):112–114, Jan 2019.
233
+
234
+ Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. Scaling laws for transfer. arXiv preprint arXiv:2102.01293, 2021.
235
+
236
+ Evan Hubinger, Chris van Merwijk, Vladimir Mikulik, Joar Skalse, and Scott Garrabrant. Risks from learned optimization in advanced machine learning systems. arXiv preprint arXiv:1906.01820, 2019.
237
+
238
+ Borja Ibarz, J. Leike, Tobias Pohlen, Geoffrey Irving, S. Legg, and Dario Amodei. Reward learning from human preferences and demonstrations in Atari. In Advances in Neural Information Processing Systems, 2018.
239
+
240
+ Zaynah Javed, Daniel S Brown, Satvik Sharma, Jerry Zhu, Ashwin Balakrishna, Marek Petrik, Anca Dragan, and Ken Goldberg. Policy gradient bayesian robust optimization for imitation learning. In Proceedings of the 38th International Conference on Machine Learning, 2021.
241
+
242
+ 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.
243
+
244
+ W. Bradley Knox, Alessandro Allievi, Holger Banzhaf, Felix Schmitt, and Peter Stone. Reward (Mis)design for Autonomous Driving. arXiv e-prints arXiv:2104.13906, 2021.
245
+
246
+ Jens Kober, J Andrew Bagnell, and Jan Peters. Reinforcement learning in robotics: A survey. The International Journal of Robotics Research, 32(11):1238–1274, 2013.
247
+
248
+ Varun Kompella, Roberto Capobianco, Stacy Jong, Jonathan Browne, Spencer Fox, Lauren Meyers, Peter Wurman, and Peter Stone. Reinforcement learning for optimization of covid-19 mitigation policies, 2020.
249
+
250
+ BorIs. P. Kovatchev, Martin Straume, Daniel J. Cox, and Leon.S Farhy. Risk analysis of blood glucose data:a quantitative approach to optimizing the control of insulin dependent diabetes. Journal of Theoretical Medicine, 3(1):1–10, 2000.
251
+
252
+ Heinrich Kuttler, Nantas Nardelli, Thibaut Lavril, Marco Selvatici, Viswanath Sivakumar, Tim ¨ Rocktaschel, and Edward Grefenstette. TorchBeast: A PyTorch Platform for Distributed RL.¨ arXiv preprint arXiv:1910.03552, 2019.
253
+
254
+ Benita Lee. How much does insulin cost? Here’s how 23 brands compare, Nov 2020.
255
+
256
+ Jan Leike, Miljan Martic, Victoria Krakovna, Pedro A. Ortega, Tom Everitt, Andrew Lefrancq, Laurent Orseau, and Shane Legg. AI safety gridworlds, 2017.
257
+
258
+ Michael L. Littman, Ifeoma Ajunwa, Guy Berger, Craig Boutilier, Morgan Currie, Finale DoshiVelez, Gillian Hadfield, Michael C. Horowitz, Charles Isbell, Hiroaki Kitano, Karen Levy, Terah Lyons, Melanie Mitchell, Julie Shah, Steven Sloman, Shannon Vallor, and Toby Walsh. Gathering strength, gathering storms: The one hundred year study on artificial intelligence (AI100) 2021 study panel report. Technical report, Stanford University, Stanford, CA, 2021.
259
+
260
+ Pablo Alvarez Lopez, Michael Behrisch, Laura Bieker-Walz, Jakob Erdmann, Yun-Pang Flotter ¨ od, ¨ Robert Hilbrich, Leonhard Lucken, Johannes Rummel, Peter Wagner, and Evamarie Wießner. ¨ Microscopic traffic simulation using SUMO. In International Conference on Intelligent Transportation Systems, 2018.
261
+
262
+ Chiara Dalla Man, Francesco Micheletto, Dayu Lv, Marc Breton, Boris Kovatchev, and Claudio Cobelli. The UVA/PADOVA type 1 diabetes simulator: New features. Journal of Diabetes Science and Technology, 8(1):26–34, Jan 2014.
263
+
264
+ Chris Olah, Arvind Satyanarayan, Ian Johnson, Shan Carter, Ludwig Schubert, Katherine Ye, and Alexander Mordvintsev. The building blocks of interpretability. Distill, 3(3):e10, 2018.
265
+
266
+ Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive summarization. In International Conference on Learning Representations, 2018.
267
+
268
+ Manoel Horta Ribeiro, Raphael Ottoni, Robert West, Virg´ılio A. F. Almeida, and Wagner Meira. Auditing radicalization pathways on youtube. In Conference on Fairness, Accountability, and Transparency, New York, NY, USA, 2020.
269
+
270
+ Stuart Russell. Human Compatible: Artificial Intelligence and the Problem of Control. Penguin, 2019.
271
+
272
+ John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
273
+
274
+ Nisan Stiennon, Long Ouyang, Jeff Wu, Daniel M Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul Christiano. Learning to summarize from human feedback. arXiv preprint arXiv:2009.01325, 2020.
275
+
276
+ Jonathan Stray. Aligning ai optimization to community well-being. International Journal of Community Well-Being, 3(4):443–463, Dec 2020.
277
+
278
+ Jihoon Tack, Sangwoo Mo, Jongheon Jeong, and Jinwoo Shin. Csi: Novelty detection via contrastive learning on distributionally shifted instances. Advances in Neural Information Processing Systems, 2020.
279
+
280
+ Jessica Taylor. Quantilizers: A safer alternative to maximizers for limited optimization. In AAAI Workshop: AI, Ethics, and Society, 2016.
281
+
282
+ Marin Toromanoff, Emilie Wirbel, and Fabien Moutarde. Is deep reinforcement learning really superhuman on Atari? Leveling the playing field, 2019.
283
+
284
+ Martin Treiber, Ansgar Hennecke, and Dirk Helbing. Congested traffic states in empirical observations and microscopic simulations. Physical review E, 62(2):1805, 2000.
285
+
286
+ Alexander Trott, Sunil Srinivasa, Douwe van der Wal, Sebastien Haneuse, and Stephan Zheng. Building a Foundation for Data-Driven, Interpretable, and Robust Policy Design using the AI Economist. arXiv preprint arXiv:2108.02904, 2021.
287
+
288
+ Eugene Vinitsky, Aboudy Kreidieh, Luc Le Flem, Nishant Kheterpal, Kathy Jang, Cathy Wu, Fangyu Wu, Richard Liaw, Eric Liang, and Alexandre M. Bayen. Benchmarks for reinforcement learning in mixed-autonomy traffic. In Conference on Robot Learning, 2018.
289
+
290
+ Cathy Wu, Abdul Rahman Kreidieh, Kanaad Parvate, Eugene Vinitsky, and Alexandre M. Bayen. Flow: A modular learning framework for mixed autonomy traffic. IEEE Transactions on Robotics, 2021.
291
+
292
+ F Eugene Yates. Self-organizing systems: The emergence of order. Springer Science & Business Media, 2012.
293
+
294
+ Chao Yu, Jiming Liu, and Shamim Nemati. Reinforcement learning in healthcare: A survey. arXiv preprint arXiv:1908.08796, 2019.
295
+
296
+ Simon Zhuang and Dylan Hadfield-Menell. Consequences of misaligned AI. In Advances in Neural Information Processing Systems, 2020.
297
+
298
+ ![](images/76fb28d847f309167b1a3491d0a885781d7f168c53fe1c4c2978c449a2519fbf.jpg)
299
+ Figure 7: Additional model size scatter plots. Observe that not all misspecifications cause misalignment. We plot the proxy reward with $\mathbf { \cdots } _ { \mathbf { 0 } } \mathbf { \cdot } \mathbf { \sigma } $ and the true reward with “ $\mathbf { \nabla } \times \mathbf { \vec { \mathbf { \nabla } } } \mathbf { \vec { \mathbf { \nabla } } }$ . The proxy reward is measured on the left-hand side of each figure and the true reward is measured on the right hand side of each figure.
300
+
301
+ # A.1 EFFECT OF MODEL SIZE
302
+
303
+ We plot the proxy and true reward vs. model size in Figure 7, following the experiment described in Section 4.1.
304
+
305
+ ![](images/fb5bde77c268a894b2f5dc52bdd728fd4b6daac92d2c3a1af6ab8787cf4628e8.jpg)
306
+ Figure 8: Correlations between the proxy and true rewards, along with the reward hacking induced. In the left column, we plot the proxy reward with “•” and the true reward with “ $\mathbf { \vec { \nabla } } \times \mathbf { \vec { \mathbf { \nabla } } } ^ { \mathbf { 3 } }$ . In the right column, we plot the trained checkpoint correlation and the randomly initialized checkpoint correlation.
307
+
308
+ # A.2 CORRELATION BETWEEN PROXY AND TRUE REWARDS
309
+
310
+ We plot the correlation between proxy and true rewards, following the experiment described in Section 4.3. Interestingly, we see that reward hacking still occurs when there is positive correlation between the true and proxy rewards, e.g., in Figures 8a/8b. Unsurprisingly, proxy-true pairs which are highly correlated, e.g., Figure 8c/8d do not exhibit reward hacking. Finally, proxy-true pairs which are negatively correlated, e.g., Figure 8e/8f exhibit the most reward hacking.
311
+
312
+ <table><tr><td>Env. - Misspecification</td><td>#Policies</td><td>#Problematic</td><td>Rollout length</td><td>Trusted policy size</td></tr><tr><td>Traffic-Mer - misweighting</td><td>10</td><td>7</td><td>270</td><td>[96,96]</td></tr><tr><td>Traffic-Mer- scope</td><td>16</td><td>9</td><td>270</td><td>[16,16]</td></tr><tr><td>Traffic-Mer- ontological</td><td>23</td><td>7</td><td>270</td><td>[4]</td></tr><tr><td>Traffic-Bot - misweighting</td><td>12</td><td>9</td><td>270</td><td>[64,64]</td></tr><tr><td>COVID - ontological</td><td>13</td><td>6</td><td>200</td><td>[16,16]</td></tr></table>
313
+
314
+ Table 3: Benchmark statistics. We average over 5 rollouts in traffic and 32 rollouts in COVID.
315
+
316
+ # B POLYNOMALY
317
+
318
+ # B.1 BENCHMARK STATISTICS
319
+
320
+ See Table 3 for Polynomaly’s statistics.
321
+
322
+ # B.2 RECEIVER OPERATING CHARACTERISTIC CURVES
323
+
324
+ We plot the ROC curves for the detectors described in Section 5.3. Our detectors are calculated as follows.
325
+
326
+ Let $P$ and $Q$ represent two probability distributions with $M = { \textstyle { \frac { 1 } { 2 } } } ( P + Q )$ . Then the Jensen-Shannon divergence and the Hellinger distance between them is given by
327
+
328
+ $$
329
+ \begin{array} { r l } & { \mathrm { J S D } ( P | | Q ) : = \cfrac { 1 } { 2 } \mathrm { K L } ( P | | M ) + \cfrac { 1 } { 2 } \mathrm { K L } ( Q | | M ) } \\ & { \mathrm { H e l l i n g e r } ( P , Q ) : = \cfrac { 1 } { 2 } \int \left( \sqrt { d P } - \sqrt { d Q } \right) ^ { 2 } . } \end{array}
330
+ $$
331
+
332
+ Our proposed detectors estimate the distance $\mathcal { D } ( \pi _ { \mathrm { t r u s t e d } } , \pi _ { \mathrm { u n k n o w n } } )$ between the trusted policy $\pi _ { \mathrm { t r u s t e d } }$ and unknown policy $\pi _ { \mathrm { u n k n o w n } }$ as follows: We generate $r$ rollouts of $\pi _ { \mathrm { u n k n o w n } }$ , where $r = 5$ in the traffic environment and $r = 3 2$ in the COVID environment. Every $s$ steps of a rollout, where $s = 1 0$ in the traffic environment and $s = 1$ in the COVID environment, we set $P$ to be the action distribution of $\pi _ { \mathrm { u n k n o w n } }$ given the unknown agent’s state at that timestep in the rollout and $Q$ to be the action distribution of $\pi _ { \mathrm { t r u s t e d } }$ given the unknown agent’s state at that timestep in the rollout. Intuitively, if $P$ and $Q$ are far apart, then the trusted agent would have performed a different action than the unknown agent at that given timestep, indicating a possible case of reward hacking. We then compute either $\bar { \mathrm { J S D } } ( P \Vert Q )$ or Hellinger $( P , Q )$ following Equation (1). These distances are collected every $s$ steps over the entire rollout, and we calculate metrics on these distances (range, mean, etc.) to assign an anomaly score to the untrusted policy.
333
+
334
+ ![](images/7399a39d54aa75762eb6da34ed7e56deb5e64882f2ce5351cb13a0481a60fbb8.jpg)
335
+ Figure 9: ROC curves for Traffic-Mer - misweighting.
336
+
337
+ ![](images/515ed1705c03a3ca9825367f39ff4be0ff426d5b8461ba3c2ab3cc70285f4e69.jpg)
338
+ Figure 10: ROC curves for Traffic-Mer - scope.
339
+
340
+ ![](images/2afd15e0e5d322675944c5520933a1513e0bf00cc8cd9f54865efc5e780be0c7.jpg)
341
+ Figure 11: ROC curves for Traffic-Mer - ontological.
342
+
343
+ ![](images/53f778a7de57400268ec71169ea46402329ce835192620a8a4ff88aed71b8f71.jpg)
344
+ Figure 12: ROC curves for Traffic-Bot - misweighting.
345
+
346
+ ![](images/bad590b3cea2bc46f6fdf6090474fb67464619fbe90b8a1e400df7b6dd5a7a2b.jpg)
347
+ Figure 13: ROC curves for COVID - ontological.
md/dev/LKEYuYNOqx/LKEYuYNOqx.md ADDED
@@ -0,0 +1,381 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GENIE: Higher-Order Denoising Diffusion Solvers
2
+
3
+ Tim Dockhorn1,2,3,∗ Arash Vahdat1 Karsten Kreis1
4
+
5
+ 1NVIDIA 2University of Waterloo 3Vector Institute
6
+
7
+ tim.dockhorn@uwaterloo.ca, {avahdat,kkreis}@nvidia.com
8
+
9
+ # Abstract
10
+
11
+ Denoising diffusion models (DDMs) have emerged as a powerful class of generative models. A forward diffusion process slowly perturbs the data, while a deep model learns to gradually denoise. Synthesis amounts to solving a differential equation (DE) defined by the learnt model. Solving the DE requires slow iterative solvers for high-quality generation. In this work, we propose Higher-Order Denoising Diffusion Solvers (GENIE): Based on truncated Taylor methods, we derive a novel higher-order solver that significantly accelerates synthesis. Our solver relies on higher-order gradients of the perturbed data distribution, that is, higher-order score functions. In practice, only Jacobian-vector products (JVPs) are required and we propose to extract them from the first-order score network via automatic differentiation. We then distill the JVPs into a separate neural network that allows us to efficiently compute the necessary higher-order terms for our novel sampler during synthesis. We only need to train a small additional head on top of the first-order score network. We validate GENIE on multiple image generation benchmarks and demonstrate that GENIE outperforms all previous solvers. Unlike recent methods that fundamentally alter the generation process in DDMs, our GENIE solves the true generative DE and still enables applications such as encoding and guided sampling. Project page and code: https://nv-tlabs.github.io/GENIE.
12
+
13
+ # 1 Introduction
14
+
15
+ Denoising diffusion models (DDMs) offer both state-of-the-art synthesis quality and sample diversity in combination with a robust and scalable learning objective. DDMs have been used for image [1–5] and video [6, 7] synthesis, super-resolution [8, 9], deblurring [10, 11], image editing and inpainting [5, 12–14], text-to-image synthesis [15–17], conditional and semantic image generation [18–22], imageto-image translation [14, 23, 24] and for inverse problems in medical imaging [25–31]. They also enable high-quality speech synthesis [32–37], 3D shape generation [38–42], molecular modeling [43– 46], maximum likelihood training [47–50], and more [51–56]. In DDMs, a diffusion process gradually perturbs the data towards random noise, while a deep neural network learns to denoise. Formally, the problem reduces to learning the score function, i.e., the gradient of the log-density of the perturbed data. The (approximate) inverse of the forward diffusion can be described by an ordinary or a stochastic differential equation (ODE or SDE, respectively), defined by the learned score function, and can therefore be used for generation when starting from random noise [47, 57].
16
+
17
+ A crucial drawback of DDMs is that the generative ODE or SDE is typically difficult to solve, due to the complex score function. Therefore, efficient and tailored samplers are required for fast synthesis. In this work, building on the generative ODE [47, 57, 58], we rigorously derive a novel second-order ODE solver using truncated Taylor methods [59]. These higher-order methods require higher-order gradients of the ODE—in our case this includes higher-order gradients of the log-density of the perturbed data, i.e., higher-order score functions. Because such higher-order scores are usually not available, existing works typically use simple first-order solvers or samplers with low accuracy [1, 57, 58, 60], higher-order methods that rely on suboptimal finite difference or other approximations [61–63], or alternative approaches [64–66] for accelerated sampling. Here, we fundamentally avoid such approximations and directly model the higher-order gradient terms: Importantly, our novel Higher-Order Denoising Diffusion Solver (GENIE) relies on Jacobian-vector products (JVPs) involving second-order scores. We propose to calculate these JVPs by automatic differentiation of the regular learnt first-order scores. For computational efficiency, we then distill the entire higher-order gradient of the ODE, including the JVPs, into a separate neural network. In practice, we only need to add a small head to the first-order score network to predict the components of the higher-order ODE gradient. By directly modeling the JVPs we avoid explicitly forming high-dimensional higher-order scores. Intuitively, the higher-order terms in GENIE capture the local curvature of the ODE and enable larger steps when iteratively solving the generative ODE (Fig. 1).
18
+
19
+ ![](images/2fa56efdc3917106559f22cc915f86ecab674151e8c74d8a2bfbd5feb5c5f0e1.jpg)
20
+ Figure 1: Our novel Higher-Order Denoising Diffusion Solver (GENIE) relies on the second truncated Taylor method (TTM) to simulate a (re-parametrized) Probability Flow ODE for sampling from denoising diffusion models. The second TTM captures the local curvature of the ODE’s gradient field and enables more accurate extrapolation and larger step sizes than the first TTM (Euler’s method), which previous methods such as DDIM [58] utilize.
21
+
22
+ Experimentally, we validate GENIE on multiple image modeling benchmarks and achieve state-ofthe-art performance in solving the generative ODE of DDMs with few synthesis steps. In contrast to recent methods that fundamentally modify the generation process of DDMs by training conditional GANs [67] or by distilling the full sampling trajectory [68, 69], GENIE solves the true generative ODE. Therefore, we also show that we can still encode images in the DDM’s latent space, as required for instance for image interpolation, and use techniques such as guided sampling [4, 57, 70].
23
+
24
+ We make the following contributions: (i) We introduce GENIE, a novel second-order ODE solver for fast DDM sampling. (ii) We propose to extract the required higher-order terms from the first-order score model by automatic differentiation. In contrast to existing works, we explicitly work with higher-order scores without finite difference approximations. To the best of our knowledge, GENIE is the first method that explicitly uses higher-order scores for generative modeling with DDMs. (iii) We propose to directly model the necessary JVPs and distill them into a small neural network. (iv) We outperform all previous solvers and samplers for the generative differential equations of DDMs.
25
+
26
+ # 2 Background
27
+
28
+ We consider continuous-time DDMs [1, 57, 71] whose forward process can be described by
29
+
30
+ $$
31
+ p _ { t } ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 } ) = \mathcal { N } ( \mathbf { x } _ { t } ; \alpha _ { t } \mathbf { x } _ { 0 } , \sigma _ { t } ^ { 2 } I ) ,
32
+ $$
33
+
34
+ where $\mathbf { x } _ { 0 } \sim p _ { 0 } ( \mathbf { x } _ { 0 } )$ is drawn from the empirical data distribution and $\mathbf { x } _ { t }$ refers to diffused data samples at time $t \in [ 0 , 1 ]$ along the diffusion process. The functions $\alpha _ { t }$ and $\sigma _ { t }$ are generally chosen such that the logarithmic signal-to-noise ratio [48] $\begin{array} { r } { \log { \frac { \alpha _ { t } ^ { 2 } } { \sigma _ { t } ^ { 2 } } } } \end{array}$ decreases monotonically with $t$ and the data diffuses towards random noise, i.e., $p _ { 1 } ( \mathbf { x } _ { 1 } ) \approx \mathcal { N } ( \mathbf { x } _ { 1 } ; \mathbf { 0 } , \bar { I } )$ . We use variance-preserving [57] diffusion processes for which $\sigma _ { t } ^ { 2 } = 1 - \alpha _ { t } ^ { 2 }$ (however, all methods introduced in this work are applicable to more general DDMs). The diffusion process can then be expressed by the (variance-preserving) SDE
35
+
36
+ $$
37
+ \begin{array} { r } { d \mathbf { x } _ { t } = - \frac { 1 } { 2 } \beta _ { t } \mathbf { x } _ { t } d t + \sqrt { \beta _ { t } } d \mathbf { w } _ { t } , } \end{array}
38
+ $$
39
+
40
+ where diffusi $\begin{array} { r } { \beta _ { t } = - \frac { d } { d t } \log \alpha _ { t } ^ { 2 } } \end{array}$ , f $\mathbf { x } _ { 0 } \sim p _ { 0 } ( \mathbf { x } _ { 0 } )$ and rts th $\mathbf { w } _ { t }$ is a standard Wiener process. A corresponding reverseorward diffusion is given by [57, 72, 73]
41
+
42
+ $$
43
+ \begin{array} { r } { d \mathbf { x } _ { t } = - \frac { 1 } { 2 } \beta _ { t } \left[ \mathbf { x } _ { t } + 2 \nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } ) \right] d t + \sqrt { \beta _ { t } } d \mathbf { w } _ { t } , } \end{array}
44
+ $$
45
+
46
+ and this reverse-time generative SDE is marginally equivalent to the generative ODE [47, 57]
47
+
48
+ $$
49
+ \begin{array} { r } { d \mathbf { x } _ { t } = - \frac { 1 } { 2 } \beta _ { t } \left[ \mathbf { x } _ { t } + \nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } ) \right] d t , } \end{array}
50
+ $$
51
+
52
+ where $\nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } )$ is the score function. Eq. (4) is referred to as the Probability Flow ODE [57], an instance of continuous Normalizing flows [74, 75]. To generate samples from the DDM, one can sample $\mathbf { x } _ { 1 } \sim \mathcal { N } ( \mathbf { x } _ { 1 } ; \mathbf { 0 } , I )$ and numerically simulate either the Probability Flow ODE or the generative SDE, replacing the unknown score function by a learned score model $s _ { \theta } ( \mathbf { x } _ { t } , t ) \approx \nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } )$ .
53
+
54
+ The DDIM solver [58] has been particularly popular to simulate DDMs due to its speed and simplicity. It has been shown that DDIM is Euler’s method applied to an ODE based on a re-parameterization of the Probability Flow ODE [58, 69]: Defining $\begin{array} { r } { \gamma _ { t } = \sqrt { \frac { 1 - \alpha _ { t } ^ { 2 } } { \alpha _ { t } ^ { 2 } } } } \end{array}$ and $\bar { \mathbf { x } } _ { t } = \mathbf { x } _ { t } \sqrt { 1 + \gamma _ { t } ^ { 2 } }$ , we have
55
+
56
+ $$
57
+ \frac { d \bar { \mathbf { x } } _ { t } } { d \gamma _ { t } } = \sqrt { 1 + \gamma _ { t } ^ { 2 } } \frac { d \mathbf { x } _ { t } } { d t } \frac { d t } { d \gamma _ { t } } + \mathbf { x } _ { t } \frac { \gamma _ { t } } { \sqrt { 1 + \gamma _ { t } ^ { 2 } } } = - \frac { \gamma _ { t } } { \sqrt { 1 + \gamma _ { t } ^ { 2 } } } \nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } ) ,
58
+ $$
59
+
60
+ where we inserted Eq. (4) for $\frac { d { \bf x } _ { t } } { d t }$ and used $\begin{array} { r } { \beta ( t ) \frac { d t } { d \gamma _ { t } } = \frac { 2 \gamma _ { t } } { \gamma _ { t } ^ { 2 } + 1 } } \end{array}$ . Letting $\begin{array} { r } { s _ { \theta } ( \mathbf { x } _ { t } , t ) : = - \frac { \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \sigma _ { t } } } \end{array}$ denote a parameterization of the score model, the approximate generative DDIM ODE is then given by
61
+
62
+ $$
63
+ d \bar { \mathbf { x } } _ { t } = \epsilon _ { \theta } \left( \mathbf { x } _ { t } , t \right) d \gamma _ { t } ,
64
+ $$
65
+
66
+ where we used $\begin{array} { r } { \sigma _ { t } = \sqrt { 1 - \alpha _ { t } ^ { 2 } } = \frac { \gamma _ { t } } { \sqrt { \gamma _ { t } ^ { 2 } + 1 } } } \end{array}$ (see App. A for a more detailed derivation of Eq. (6)). The model $\epsilon _ { \theta } ( \mathbf { x } _ { t } , t )$ can be learned by minimizing the score matching objective [1, 76]
67
+
68
+ $$
69
+ \operatorname* { m i n } _ { \pmb { \theta } } \mathbb { E } _ { t \sim \mathcal { U } [ t _ { \mathrm { c u t o f f } } , 1 ] , \mathbf { x } _ { 0 } \sim p ( \mathbf { x } _ { 0 } ) , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , I ) } \left[ g ( t ) \lVert \epsilon - \epsilon _ { \boldsymbol { \theta } } ( \mathbf { x } _ { t } , t ) \rVert _ { 2 } ^ { 2 } \right] , \quad \mathbf { x } _ { t } = \alpha _ { t } \mathbf { x } _ { 0 } + \sigma _ { t } \epsilon ,
70
+ $$
71
+
72
+ for small $0 < t _ { \mathrm { c u t o f f } } \ll 1$ . As is standard practice, we set $g ( t ) = 1$ . Other weighting functions $g ( t )$ are possible; for example, setting $\begin{array} { r } { g ( t ) = \frac { \beta _ { t } } { 2 \sigma _ { t } ^ { 2 } } } \end{array}$ recovers maximum likelihood learning [47–50].
73
+
74
+ # 3 Higher-Order Denoising Diffusion Solver
75
+
76
+ As discussed in Sec. 2, the so-known DDIM solver [58] is simply Euler’s method applied to the DDIM ODE (cf. Eq. (6)). In this work, we apply a higher-order method to the DDIM ODE, building on the truncated Taylor method (TTM) [59]. The $p$ -th TTM is simply the $p$ -th order Taylor polynomial applied to an ODE. For example, for the general $\begin{array} { r } { \frac { d \mathbf { y } } { d t } = \pmb { f } ( \mathbf { y } , t ) } \end{array}$ , the $p$ -th TTM reads as
77
+
78
+ $$
79
+ \mathbf { y } _ { t _ { n + 1 } } = \mathbf { y } _ { t _ { n } } + h _ { n } { \frac { d \mathbf { y } } { d t } } | _ { ( \mathbf { y } _ { t _ { n } } , t _ { n } ) } + \cdot \cdot \cdot + { \frac { 1 } { p ! } } h _ { n } ^ { p } { \frac { d ^ { p } \mathbf { y } } { d t ^ { p } } } | _ { ( \mathbf { y } _ { t _ { n } } , t _ { n } ) } ,
80
+ $$
81
+
82
+ where $h _ { n } = t _ { n + 1 } - t _ { n }$ (see App. B.1 for a truncation error analysis with respect to the exact ODE solution). Note that the first TTM is simply Euler’s method. Applying the second TTM to the DDIM ODE results in the following scheme:
83
+
84
+ $$
85
+ \bar { \mathbf { x } } _ { t _ { n + 1 } } = \bar { \mathbf { x } } _ { t _ { n } } + h _ { n } \epsilon _ { \theta } ( \mathbf { x } _ { t _ { n } } , t _ { n } ) + \frac { 1 } { 2 } h _ { n } ^ { 2 } \frac { d \epsilon _ { \theta } } { d \gamma _ { t } } | _ { ( \mathbf { x } _ { t _ { n } } , t _ { n } ) } ,
86
+ $$
87
+
88
+ where $h _ { n } = \gamma _ { t _ { n + 1 } } - \gamma _ { t _ { n } }$ . Recall that $\begin{array} { r } { \gamma _ { t } = \sqrt { \frac { 1 - \alpha _ { t } ^ { 2 } } { \alpha _ { t } ^ { 2 } } } } \end{array}$ , where the function $\alpha _ { t }$ is a time-dependent hyperparameter of the DDM. The total derivative $\begin{array} { r } { d _ { \gamma _ { t } } \epsilon _ { \theta } : = \frac { d \epsilon _ { \theta } } { d \gamma _ { t } } } \end{array}$ can be decomposed as follows
89
+
90
+ $$
91
+ d _ { \gamma _ { t } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) = \frac { \partial \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \partial \mathbf { x } _ { t } } \frac { d \mathbf { x } _ { t } } { d \gamma _ { t } } + \frac { \partial \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \partial t } \frac { d t } { d \gamma _ { t } } ,
92
+ $$
93
+
94
+ where ∂ϵθ(xt,t) denotes the Jacobian of ϵθ(xt, t) and
95
+
96
+ $$
97
+ \frac { d \mathbf { x } _ { t } } { d \gamma _ { t } } = \frac { \partial \mathbf { x } _ { t } } { \partial \bar { \mathbf { x } } _ { t } } \frac { d \bar { \mathbf { x } } _ { t } } { d \gamma _ { t } } + \frac { \partial \mathbf { x } _ { t } } { \partial \gamma _ { t } } = \frac { 1 } { \sqrt { \gamma _ { t } ^ { 2 } + 1 } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) - \frac { \gamma _ { t } } { 1 + \gamma _ { t } ^ { 2 } } \mathbf { x } _ { t } .
98
+ $$
99
+
100
+ If not explicitly stated otherwise, we refer to the second TTM applied to the DDIM ODE, i.e., the scheme in Eq. (9), as Higher-Order Denoising Diffusion Solver (GENIE). Intuitively, the higher-order gradient terms used in the second TMM model the local curvature of the ODE. This translates into a Taylor formula-based extrapolation that is quadratic in time (cf. Eqs. (8) and (9)) and more accurate than linear extrapolation, as in Euler’s method, thereby enabling larger time steps (see Fig. 1 for a visualization). In App. B, we also discuss the application of the third TTM to the DDIM ODE. We emphasize that TTMs are not restricted to the DDIM ODE and could just as well be applied to the Probability Flow ODE [57] (also see App. B) or neural ODEs [74, 75] more generally.
101
+
102
+ ![](images/6bb6f978f610d0b9ad0c8360c80c2ee271995905931f2e32afad6cfc621481de.jpg)
103
+ Figure 2: Modeling a complex 2D toy distribution: Samples in $( b )$ and (c) are generated via DDIM and GENIE, respectively, with 25 solver steps using the analytical score function of the ground truth distribution.
104
+
105
+ The Benefit of Higher-Order Methods: We showcase the benefit of higher-order methods on a 2D toy distribution (Fig. 2a) for which we know the score function as well as all higher-order derivatives necessary for GENIE analytically. We generate 1k different accurate “ground truth” trajectories $\mathbf { x } _ { t }$ using DDIM with $1 0 \mathrm { k }$ steps. We compare these “ground truth” trajectories to single steps of DDIM and GENIE for varying step sizes $\Delta t$ . We then measure the mean $L _ { 2 }$ -distance of the single steps $\hat { \mathbf { x } } _ { t } ( \Delta t )$ to the “ground truth” trajectories $\mathbf { x } _ { t }$ , and we repeat this experiment for three starting points $t \in \{ 0 . 1 , 0 . 2 , 0 . 5 \}$ . We see (Fig. 3 (top)) that GENIE can use larger step sizes to stay within a certain error tolerance for all starting points $t$ . We further show samples for DDIM and GENIE, using 25 solver steps, in Fig. 2. DDIM has the undesired behavior of sampling low-density regions between modes, whereas GENIE looks like a slightly noisy version of the ground truth distribution (Fig. 2a).
106
+
107
+ Comparison to Multistep Methods: Linear multistep methods are an alternative higher-order method to solve ODEs. Liu et al. [63] applied the well-established Adams–Bashforth [AB, 77] method to the DDIM ODE. AB methods can be derived from TTMs by approximating higher-order derivatives $\frac { d ^ { p } \mathbf { y } } { d t ^ { p } }$ using the finite difference method [78]. For example, the second AB method is obtained from the second TTM by replacing $\textstyle { \frac { d ^ { 2 } \mathbf { y } } { d t ^ { 2 } } }$ with the first-order forward difference approximation $( f ( { \bf y } _ { t _ { n } } , t _ { n } ) - f ( { \bf y } _ { t _ { n - 1 } } , t _ { n - 1 } ) ) / h _ { n - 1 }$ . In Fig. 3 (bottom), we visualize the mean $L _ { 2 }$ -norm of the difference $\xi _ { t } ( \Delta t )$ between the analytical derivative $d _ { \gamma _ { t } } \epsilon _ { \theta }$ and its first-order forward difference approximation for varying step sizes $\Delta t$ for the 2D toy distribution. The approximation is especially poor at small $t$ for which the score function becomes complex (App. E for details on all toy experiments).
108
+
109
+ ![](images/2ad9de1841582ccc50eb5d0fa23d979238a408c542c4fd3cc8dc0127a2d94204.jpg)
110
+ Figure 3: Top: Single step error using analytical score function. Bottom: Norm of difference $\xi _ { t } ( \Delta t )$ between analytical and approximate derivative computed via finite difference method.
111
+
112
+ # 3.1 Learning Higher-Order Derivatives
113
+
114
+ The above observations inspire to apply GENIE to DDMs of more complex and high-dimensional data such as images. Regular DDMs learn a model $\epsilon _ { \theta }$ for the first-order score; however, the higher-order gradient terms required for GENIE (cf. Eq. (10)) are not immediately available to us, unlike in the toy example above. Let us insert Eq. (11) into Eq. (10) and analyze the required terms more closely:
115
+
116
+ $$
117
+ d _ { \gamma _ { t } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) = \frac { 1 } { \sqrt { \gamma _ { t } ^ { 2 } + 1 } } \underbrace { \frac { \partial \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \partial \mathbf { x } _ { t } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } _ { \mathrm { J V P _ { 1 } } } - \frac { \gamma _ { t } } { 1 + \gamma _ { t } ^ { 2 } } \underbrace { \frac { \partial \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \partial \mathbf { x } _ { t } } \mathbf { x } _ { t } } _ { \mathrm { J V P _ { 2 } } } + \frac { \partial \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \partial t } \frac { d t } { d \gamma _ { t } } .
118
+ $$
119
+
120
+ We see that the full derivative decomposes into two JVP terms and one simpler time derivative term. The term $\frac { \partial \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \partial \mathbf { x } _ { t } }$ plays a crucial role in Eq. (12). It can be expressed as
121
+
122
+ $$
123
+ \frac { \partial \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \partial \mathbf { x } _ { t } } = - \sigma _ { t } \frac { \partial \mathbf { s } _ { \theta } ( \mathbf { x } _ { t } , t ) } { \partial \mathbf { x } _ { t } } \approx - \sigma _ { t } \nabla _ { \mathbf { x } _ { t } } ^ { \top } \nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } ) ,
124
+ $$
125
+
126
+ which means that GENIE relies on second-order score functions $\nabla _ { \mathbf { x } _ { t } } ^ { \top } \nabla _ { \mathbf { x } _ { t } } \log p _ { t } ( \mathbf { x } _ { t } )$ under the hood.
127
+
128
+ Given a DDM, that is, given $\epsilon _ { \theta }$ , we could compute the derivative $d _ { \gamma _ { t } } \epsilon _ { \theta }$ for the GENIE scheme in Eq. (9) using automatic differentiation (AD). This would, however, make a single step of GENIE at least twice as costly as DDIM, because we would need a forward pass through the $\epsilon _ { \theta }$ network to compute $\epsilon _ { \theta } ( \mathbf { x } _ { t } , t )$ itself, and another pass to compute the JVPs and the time derivative in Eq. (12). These forward passes cannot be parallelized, since the vector-part of $\mathrm { J V P _ { 1 } }$ in Eq. (12) involves $\epsilon _ { \theta }$ itself, and needs to be known before computing the JVP. To accelerate sampling, this overhead is too expensive.
129
+
130
+ Gradient Distillation: To avoid this overhead, we propose to first distill $d _ { \gamma _ { t } } \epsilon _ { \theta }$ into a separate neural network. During distillation training, we can use the slow AD-based calculation of $d _ { \gamma _ { t } } \epsilon _ { \theta }$ , but during synthesis we call the trained neural network. We build on the observation that the internal representations of the neural network modeling $\epsilon _ { \theta }$ (in our case a U-Net [79] architecture) can be used for downstream tasks [80, 81]: specifically, we provide the last feature layer from the $\epsilon _ { \theta }$ network together with its time embedding as well as $\mathbf { x } _ { t }$ and the output $\epsilon _ { \theta } ( \mathbf { x } _ { t } , t )$ to a small prediction head $k _ { \psi } ( \mathbf { x } _ { t } , t )$ that models the different terms in Eq. (12) (see Fig. 4). The overhead generated by $k _ { \psi }$ is small, for instance less than $2 \%$ for our CIFAR-10 model (also see Sec. 5), and we found this approach to provide excellent performance. Note that in principle we could also train an independent deep neural network, which does not make use of the internal representations of $\epsilon _ { \theta }$ and could therefore theoretically be run in parallel to the $\epsilon _ { \theta }$ model. We justify using small prediction heads over independent neural networks because AD-based distillation training is slow: in each training iteration we first need to call the $\epsilon _ { \theta }$ network, then calculate the JVP terms, and only then can we call the distillation model. By modeling $d _ { \gamma _ { t } } \epsilon _ { \theta }$ via small prediction heads, while reusing the internal representation of the score model, we can make training relatively fast: we only need to train $k _ { \psi }$ for up to 50k iterations. In contrast, training score models from scratch takes roughly an order of magnitude more iterations. We leave training of independent networks to predict $d _ { \gamma _ { t } } \epsilon _ { \theta }$ to future work.
131
+
132
+ ![](images/84e196cce59effec39df1f43f06ce007ed2847fd24211471c891706b6af15d94.jpg)
133
+ Figure 4: Our distilled model $k _ { \psi }$ that predicts the gradient $d _ { \gamma _ { t } } \epsilon _ { \theta }$ is implemented as a small additional output head on top of the first-order score model $\epsilon _ { \theta }$ . Purple layers are used both in $\epsilon _ { \theta }$ and $k _ { \psi }$ ; green layers are specific for $\epsilon _ { \theta }$ and $k _ { \psi }$ .
134
+
135
+ Mixed Network Parameterization: We found that learning $d _ { \gamma _ { t } } \epsilon _ { \theta }$ directly as single output of a neural network can be challenging. Assuming a single data point distribution $p _ { 0 } ( \mathbf { x } _ { 0 } ) = \delta ( \mathbf { x } _ { 0 } = \mathbf { 0 } )$ , for which we know the diffused score function and all higher-order derivatives analytically, we found that the terms in Eq. (12) all behave very differently within the $t \in [ 0 , 1 ]$ interval (for instance, the prefactor of $\mathrm { J V P _ { 1 } }$ in Eq. (12) approaches 1 as $t 0$ , while $\mathrm { J V P _ { 2 } }$ ’s prefactor vanishes). As outlined in detail in App. C.2.3, this simple single data point assumption implies an effective mixed network parameterization, an approach inspired by the “mixed score parametrizations” in Vahdat et al. [49] and Dockhorn et al. [60]. In particular, we model
136
+
137
+ $$
138
+ k _ { \psi } = - \frac { 1 } { \gamma _ { t } } k _ { \psi } ^ { ( 1 ) } + \frac { \gamma _ { t } } { 1 + \gamma _ { t } ^ { 2 } } k _ { \psi } ^ { ( 2 ) } + \frac { 1 } { \gamma _ { t } ( 1 + \gamma _ { t } ^ { 2 } ) } k _ { \psi } ^ { ( 3 ) } \approx d _ { \gamma _ { t } } \epsilon _ { \theta } ,
139
+ $$
140
+
141
+ where $k _ { \psi } ^ { ( i ) } ( \mathbf { x } _ { t } , t ) , i \in \{ 1 , 2 , 3 \}$ , are different output channels of the neural network (i.e. the additional head on top of the $\epsilon _ { \theta }$ network). The three terms in Eq. (14) exactly correspond to the three terms of Eq. (12), in the same order. We show the superior performance of this parametrization in Sec. 5.3.
142
+
143
+ Learning Objective: Ideally, we would like our model $k _ { \psi }$ to match $d _ { \gamma _ { t } } \epsilon _ { \theta }$ exactly, for all $t \in [ 0 , T ]$ and $\mathbf { x } _ { t }$ in the diffused data distribution, which the generative ODE trajectories traverse. This suggests a simple (weighted) $L _ { 2 }$ -loss, similar to regular score matching losses for DDMs [1, 57]:
144
+
145
+ $$
146
+ \operatorname* { m i n } _ { \psi } \mathbb { E } _ { t \sim \mathcal { U } [ t _ { \mathrm { c u t o f f } } , 1 ] , \mathbf { x } _ { 0 } \sim p ( \mathbf { x } _ { 0 } ) , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , I ) } \left[ g _ { \mathrm { d } } ( t ) \| k _ { \psi } ( \alpha _ { t } \mathbf { x } _ { 0 } + \sigma _ { t } \epsilon , t ) - d _ { \gamma _ { t } } \epsilon _ { \theta } ( \alpha _ { t } \mathbf { x } _ { 0 } + \sigma _ { t } \epsilon , t ) \| _ { 2 } ^ { 2 } \right]
147
+ $$
148
+
149
+ for diffused data points $\alpha _ { t } \mathbf { x } _ { 0 } + \sigma _ { t } \mathbf { \epsilon } \mathbf { \epsilon }$ and $g _ { \mathrm { d } } ( t ) = \gamma _ { t } ^ { 2 }$ to counteract the $1 / \gamma _ { t }$ in the first and third terms of Eq. (14). This leads to a roughly constant loss over different time values $t$ . During training we compute $d _ { \gamma _ { t } } \epsilon _ { \theta }$ via AD; however, at inference time we use the learned prediction head $k _ { \psi }$ to approximate $d _ { \gamma _ { t } } \epsilon _ { \theta }$ . In App. C.2.4, we provide pseudo code for training and sampling with heads $k _ { \psi }$ . Note that our distillation objective is consistent and principled: if $k _ { \psi }$ matches $d _ { \gamma _ { t } } \epsilon _ { \theta }$ exactly, the resulting GENIE algorithm recovers the second TTM exactly (extended discussion in App. B.4).
150
+
151
+ Alternative Learning Approaches: As shown in Eq. (13), GENIE relies on second-order score functions. Recently, Meng et al. [82] directly learnt such higher-order scores with higher-order score matching objectives. Directly applying these techniques has the downside that we would need to explicitly form the higher-order score terms $\nabla _ { \mathbf { x } _ { t } } ^ { \top } \epsilon _ { \theta } ( \mathbf { x } _ { t } , \dot { t } )$ , which are very high-dimensional for data such as images. Low-rank approximations are possible, but potentially insufficient for high performance. In our approach, we are avoiding this complication by directly modeling the lower-dimensional JVPs. We found that the methods from Meng et al. [82] can be modified to provide higher-order score matching objectives for the JVP terms required for GENIE and we briefly explored this (see App. D). However, our distillation approach with AD-based higher-order gradients worked much better. Nevertheless, this is an interesting direction for future research. To the best of our knowledge, GENIE is the first solver for the generative differential equations of DDMs that directly uses higher-order scores (in the form of the distilled JVPs) for generative modeling without finite difference or other approximations.
152
+
153
+ # 4 Related Work
154
+
155
+ Accelerated Sampling from DDMs. Several previous works address the slow sampling of DDMs: One line of work reduces and readjusts the timesteps [3, 64] used in time-discretized DDMs [1, 71]. This can be done systematically by grid search [32] or dynamic programming [83]. Bao et al. [65] speed up sampling by defining a new DDM with optimal reverse variances. DDIM [58], discussed in Sec. 2, was also introduced as a method to accelerate DDM synthesis. Further works leverage modern ODE and SDE solvers for fast synthesis from (continuous-time) DDMs: For instance, higher-order Runge–Kutta methods [57, 84] and adaptive step size SDE solvers [62] have been used. These methods are not optimally suited for the few-step synthesis regime, in which GENIE shines; see also Sec. 5. Most closely related to our work is Liu et al. [63], which simulates the DDIM ODE [58] using a higher-order linear multistep method [77]. As shown in Sec. 3, linear multistep methods can be considered an approximation of the TTMs used in GENIE. Furthermore, Tachibana et al. [61] solve the generative SDE via a higher-order Itô–Taylor method [59] and in contrast to our work, they propose to use an “ideal derivative trick” to approximate higher-order score functions. In App. B.2, we show that applying this ideal derivative approximation to the DDIM ODE does not have any effect: the “ideal derivatives” are zero by construction. Note that in GENIE, we in fact use the DDIM ODE, rather than, for example, the regular Probability Flow ODE [57], as the base ODE for GENIE.
156
+
157
+ Alternatively, sampling from DDMs can also be accelerated via learning: For instance, Watson et al. [66] learn parameters of a generalized family of DDMs by optimizing for perceptual output quality. Luhman and Luhman [68] and Salimans and Ho [69] distill a DDIM sampler into a student model, which enables sampling in as few as a single step. Xiao et al. [67] replace DDMs’ Gaussian samplers with expressive generative adversarial networks, similarly allowing for few-step synthesis. GENIE can also be considered a learning-based approach, as we distill a derivative of the generative ODE into a separate neural network. However, in contrast to the mentioned methods, GENIE still solves the true underlying generative ODE, which has major advantages: for instance, it can still be used easily for classifier-guided sampling [4, 57, 70] and to efficiently encode data into latent space—a prerequisite for likelihood calculation [47, 57] and editing applications [17]. Note that the learnt sampler [66] defines a proper probabilistic generalized DDM; however, it isn’t clear how it relates to the generative SDE or ODE and therefore how compatible the method is with applications such as classifier guidance.
158
+
159
+ Other approaches to accelerate DDM sampling change the diffusion itself [60, 85, 86] or train DDMs in the latent space of a Variational Autoencoder [49]. GENIE is complementary to these methods.
160
+
161
+ Higher-Order ODE Gradients beyond DDMs. TTMs [78] and other methods that leverage higherorder gradients are also applied outside the scope of DDMs. For instance, higher-order derivatives can play a crucial role when developing solvers [87] and regularization techniques [88, 89] for neural ODEs [74, 75]. Outside the field of machine learning, higher-order TTMs have been widely studied, for example, to develop solvers for stiff [90] and non-stiff [90, 91] systems.
162
+
163
+ Concurrent Works. Zhang and Chen [92] motivate the DDIM ODE from an exponential integrator perspective applied to the Probability Flow ODE and propose to apply existing solvers from the numerical ODE literature, namely, Runge–Kutta and linear multistepping, to the DDIM ODE directly. Lu et al. [93] similarly recognize the semi-linear structure of the Probability Flow ODE, derive dedicated solvers, and introduce new step size schedulers to accelerate DDM sampling. Karras et al. [94] propose new fast solvers, both deterministic and stochastic, specifically designed for the differential equations arising in DDMs. Both Zhang et al. [95] and Karras et al. [94] realize that the DDIM ODE has “straight line solution trajectories” for spherical normal data and single data points—this exactly corresponds to our derivation that the higher-order terms in the DDIM ODE are zero in such a setting (see App. B.2). Bao et al. [96] learn covariance matrices for DDM sampling using prediction heads somewhat similar to the ones in GENIE; in App. G.1, we thoroughly discuss the differences between GENIE and the method proposed in Bao et al. [96].
164
+
165
+ # 5 Experiments
166
+
167
+ Datasets: We run experiments on five datasets: CIFAR-10 [97] (resolution 32), LSUN Bedrooms [98] (128), LSUN Church-Outdoor [98] (128), (conditional) ImageNet [99] (64), and AFHQv2 [100] (512). On AFHQv2 we only consider the subset of cats; referred to as “Cats” in the remainder of this work.
168
+
169
+ Architectures: Except for CIFAR-10 (we use a checkpoint by Song et al. [57]), we train our own score models using architectures introduced by previous works [1, 4]. The architecture of our prediction heads is based on (modified) BigGAN residual blocks [57, 101]. To minimize computational overhead, we only use a single residual block. See App. C for training and architecture details.
170
+
171
+ Evaluation: We measure sample quality via Fréchet Inception Distance [FID, 102] (see App. F.1).
172
+
173
+ Synthesis Strategy: We simulate the DDIM ODE from $t { = } 1$ up to $t { = } 1 0 ^ { - 3 }$ using evaluation times following a quadratic function (quadratic striding [58]). For variance-preserving DDMs, it can be beneficial to denoise the ODE solver output at the cutoff $t { = } 1 0 ^ { - 3 }$ , i.e., $\begin{array} { r } { \mathbf { x } _ { 0 } = \frac { \mathbf { x } _ { t } - \sigma _ { t } \epsilon _ { \theta } \left( \mathbf { x } _ { t } , t \right) } { \alpha _ { t } } } \end{array}$ [57, 103]. Note that the denoising step involves a score model evaluation, and therefore “loses” a function evaluation that could otherwise be used as an additional step in the ODE solver. To this end, denoising the output of the ODE solver is left as a hyperparameter of our synthesis strategy.
174
+
175
+ Analytical First Step (AFS): Every additional neural network call becomes crucial in the low number of function evaluations (NFEs) regime. We found that we can improve the performance of GENIE and all other methods evaluated on our checkpoints by replacing the learned score with the (analytical) score of $\mathcal { N } ( \mathbf { 0 } , I ) \approx p _ { t = 1 } ( \mathbf { x } _ { t } )$ in the first step of the ODE solver. The “gained” function evaluation can then be used as an additional step in the ODE solver. Similarly to the denoising step mentioned above, AFS is treated as a hyperparameter of our Synthesis Strategy. AFS details in App. F.2.
176
+
177
+ Accounting for Computational Overhead: GENIE has a slightly increased computational overhead compared to other solvers due to the prediction head $k _ { \psi }$ . The computational overhead is increased by $1 . 4 7 \%$ , $2 . 8 3 \%$ , $1 4 . 0 \%$ , and $1 4 . 4 \%$ on CIFAR-10, ImageNet, LSUN Bedrooms, and LSUN ChurchOutdoor, respectively (see also App. C.2.5). This additional overhead is always accounted for implicitly: we divide the NFEs by the computational overhead and round to the nearest integer. For example, on LSUN Bedrooms, we compare baselines with 10/15 NFEs to GENIE with 9/13 NFEs.
178
+
179
+ # 5.1 Image Generation
180
+
181
+ In Fig. 5 we compare our method to the most competitive baselines. In particular, on the same score model checkpoints, we compare GENIE with DDIM [58], S-PNDM [63], and F-PNDM [63]. For these four methods, we only include the best result over the two hyperparameters discussed above, namely, the denoising step and AFS (see App. F.6 for tables with all results). We also include three competitive results from the literature [64–66] that use different checkpoints and sampling strategies: for each method, we include the best result for their respective set of hyperparameters. We do not compare in this figure with Knowledge Distillation [KD, 68], Progressive Distillation [PG, 69] and Denoising Diffusion GANs [DDGAN, 67] as they do not solve the generative ODE/SDE and use fundamentally different sampling approaches with drawbacks discussed in Sec. 4.
182
+
183
+ For $\mathrm { N F E s } \in \{ 1 0 , 1 5 , 2 0 , 2 5 \}$ , GENIE outperforms all baselines (on the same checkpoint) on all four datasets (see detailed results in App. F.6 and GENIE image samples in App. F.7). On CIFAR-10 and (conditional) ImageNet, GENIE also outperforms these baselines for NFE $\mathord { \mathrm { : } } = 5$ , whereas DDIM outperforms GENIE slightly on the LSUN datasets (see tables in App. F.6). GENIE also performs better than the three additional baselines from the literature (which use different checkpoints and sampling strategies) with the exception of the Learned Sampler [LS, 66] on LSUN Bedrooms for $\mathrm { N F E s } { = } 2 0$ . Though LS uses a learned striding schedule on LSUN Bedrooms (whereas GENIE simply uses quadratic striding), the LS’s advantage is most likely due to the different checkpoint. In Tab. 1, we investigate the effect of optimizing the striding schedule, via learning (LS) or grid search (DDIM & GENIE), on CIFAR-10 and find that its significance decreases rapidly with increased NFEs (also see App. F.6 for details). In Tab. 1, we also show additional baseline results; however, we do not include commonly-used adaptive step size solvers in Fig. 5, as they are arguably not well-suited for this low NFE regime: for example, on the same CIFAR-10 checkpoint we use for GENIE, the adaptive SDE solver introduced in Jolicoeur-Martineau et al. [62] obtains an FID of 82.4 at 48 NFEs. Also on the same checkpoint, the adaptive Runge–Kutta 4(5) [84] method applied to the ProbabilityFlow ODE achieves an FID of 13.1 at 38 NFEs (solver tolerances set to $1 0 ^ { - 2 }$ ).
184
+
185
+ ![](images/78b15833e9ea19268d437b4335596de5b81475277c99e91652b7c2adfe6f619a.jpg)
186
+
187
+ ![](images/da7e06b595c1bdc0ecf48721fa115cd3178fce040cfaf2a8f547c48b1067c9eb.jpg)
188
+ Figure 5: Unconditional performance on four popular benchmark datasets. The first four methods use the same score model checkpoints, whereas the last three methods all use different checkpoints. (†): numbers are taken from literature.
189
+ Table 1: Unconditional CIFAR-10 generative performance (measured in FID). Methods above the middle line use the same score model checkpoint; methods below all use different ones. (†): numbers are taken from literature. (\*): methods either learn an optimal striding schedule (Learned Sampler) or do a small grid search over striding schedules (DDIM & GENIE); also see App. F.6
190
+
191
+ <table><tr><td>Method</td><td>NFEs=5</td><td>NFEs=10</td><td>NFEs=15</td><td>NFEs=20</td><td>NFEs=25</td></tr><tr><td>GENIE(ours) (*)</td><td>11.2</td><td>5.28</td><td>4.49</td><td>3.94</td><td>3.64</td></tr><tr><td>GENIE (ours)</td><td>13.9</td><td>5.97</td><td>4.49</td><td>3.94</td><td>3.67</td></tr><tr><td>DDIM[58] (*)</td><td>27.6</td><td>11.2</td><td>7.35</td><td>5.87</td><td>5.16</td></tr><tr><td>DDIM[58]</td><td>29.7</td><td>11.2</td><td>7.35</td><td>5.87</td><td>5.16</td></tr><tr><td>S-PNDM[63]</td><td>35.9</td><td>10.3</td><td>6.61</td><td>5.20</td><td>4.51</td></tr><tr><td>F-PNDM[63]</td><td>N/A</td><td>N/A</td><td>10.3</td><td>5.96</td><td>4.73</td></tr><tr><td>Euler-Maruyama</td><td>325</td><td>230</td><td>164</td><td>112</td><td>80.3</td></tr><tr><td>FastDDIM [64] (t)</td><td>1</td><td>9.90</td><td>-</td><td>5.05</td><td>-</td></tr><tr><td>Learned Sampler 66] (t/*)</td><td>12.4</td><td>7.86</td><td>5.90</td><td>4.72</td><td>4.25</td></tr><tr><td>Learned Sampler [66] (t)</td><td>14.3</td><td>8.15</td><td>5.94</td><td>4.89</td><td>4.47</td></tr><tr><td>Analytic DDIM [65] (t)</td><td>-</td><td>14.0</td><td>-</td><td>-</td><td>5.71</td></tr><tr><td>CLD-SGM[60]</td><td>334</td><td>306</td><td>236</td><td>162</td><td>106</td></tr><tr><td>VESDE-PC[57]</td><td>461</td><td>461</td><td>461</td><td>461</td><td>462</td></tr></table>
192
+
193
+ The results in Fig. 5 suggest that higher-order gradient information, as used in GENIE, can be efficiently leveraged for image synthesis. Despite using small prediction heads our distillation seems to be sufficiently accurate: for reference, replacing the distillation heads with the derivatives computed via AD, we obtain FIDs of 9.22, 4.11, 3.54, 3.46 using 10, 20, 30, and 40 NFEs, respectively (NFEs adjusted assuming an additional computational overhead of $100 \%$ ). As discussed in Sec. 3, linear multistep methods such as S-PNDM [63] and F-PNDM [63] can be considered (finite difference) approximations to TTMs as used in GENIE. These approximations can be inaccurate for large timesteps, which potentially explains their inferior performance when compared to GENIE. When compared to DDIM, the superior performance of GENIE seems to become less significant for large NFE: this is in line with the theory, as higher-order gradients contribute less for smaller step sizes (see the GENIE scheme in Eq. (9)). Approaches such as FastDDIM [64] and AnalyticDDIM [65], which adapt variances and discretizations of discrete-time DDMs, are useful; however, GENIE suggests that rigorous higher-order ODE solvers leveraging the continuous-time DDM formalism are still more powerful. To the best of our knowledge, the only methods that outperform GENIE abandon this ODE or SDE formulation entirely and train NFE-specific models [67, 69] which are optimized for the single use-case of image synthesis.
194
+
195
+ # 5.2 Guidance and Encoding
196
+
197
+ As discussed in Sec. 4, one major drawback of approaches such as KD [68], PG [69] and DDGAN [67] is that they abandon the ODE/SDE formalism, and cannot easily use methods such as classifier(-free) guidance [57, 70] or perform image encoding. However, these techniques can play an important role in synthesizing photorealistic images from DDMs [3, 4, 15, 17], as well as for image editing tasks [12, 17].
198
+
199
+ Classifier-Free Guidance [70]: We replace the unconditional model $\epsilon _ { \theta } ( \mathbf { x } _ { t } , t )$ with $\hat { \epsilon } _ { \theta } ( \mathbf { x } _ { t } , t , c , w ) = ( 1 + w ) \epsilon _ { \theta } ( \mathbf { x } _ { t } , t , c ) -$ $w \epsilon _ { \theta } ( \mathbf { x } _ { t } , t )$ in the DDIM ODE (cf Eq. (6)), where $\epsilon _ { \theta } ( \mathbf { x } _ { t } , t , c )$ is a conditional model and $w > 1 . 0$ is the “guidance scale”. GENIE then requires the derivative
200
+
201
+ ![](images/a7c81a8ba04762e096723835d21c426ac67299bce0e01d2dca2db0977bd15121.jpg)
202
+ Figure 6: Sample quality as a function of guidance scale on ImageNet.
203
+
204
+ ![](images/3c429bd17bd930a87cae4e149e69b8a4cd2c559750055bce4e4f24be870a5954.jpg)
205
+ Figure 8: Encoding and subsequent decoding on LSUN Church-Outdoor. Left: Visual reconstruction. Right: $L _ { 2 }$ -distance to reference in Inception feature space [104], averaged over 100 images.
206
+
207
+ $$
208
+ \begin{array} { r } { d _ { \gamma _ { t } } \hat { \epsilon } _ { \theta } ( \mathbf { x } _ { t } , t , c , w ) = ( 1 + w ) d _ { \gamma _ { t } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t , c ) - w d _ { \gamma _ { t } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) . } \end{array}
209
+ $$
210
+
211
+ for guidance. Hence, we need to distill $d _ { \gamma _ { t } } \mathbf { \epsilon } _ { \theta } ( \mathbf { x } _ { t } , t , c )$ and $d _ { \gamma _ { t } } \mathbf { \epsilon } _ { \theta } ( \mathbf { x } _ { t } , t )$ , for which we could also share parameters [70]. We compare GENIE with DDIM on ImageNet in Fig. 6. GENIE clearly outperforms DDIM, in particular for few NFEs, and GENIE also synthesizes high-quality images (see Fig. 7).
212
+
213
+ Image Encoding: We can use GENIE also to solve the generative ODE in reverse to encode given images. Therefore, we compare GENIE to DDIM on the “encode-decode” task, analyzing reconstructions for different NFEs (used twice for encoding and decoding): We find that GENIE reconstructs images much more accurately (see Fig. 8). For more details on this experiment as well as the guidance experiment above, see App. F.4 and App. F.3, respectively. We also show latent space interpolations for both GENIE and DDIM in App. F.5.
214
+
215
+ # 5.3 Ablation Studies
216
+
217
+ Table 2: CIFAR-10 ablation studies (measured in FID).
218
+
219
+ <table><tr><td>Ablation</td><td>NFEs=5</td><td>NFEs=10</td><td>NFEs=15</td><td>NFEs=20</td><td>NFEs=25</td></tr><tr><td>Standard</td><td>13.9</td><td>6.04</td><td>4.49</td><td>3.94</td><td>3.67</td></tr><tr><td>No mixed</td><td>14.7</td><td>6.32</td><td>4.82</td><td>4.31</td><td>4.10</td></tr><tr><td>No weighting</td><td>14.8</td><td>7.45</td><td>5.89</td><td>5.17</td><td>4.80</td></tr><tr><td>Bigger model</td><td>13.7</td><td>5.58</td><td>4.46</td><td>4.05</td><td>3.77</td></tr></table>
220
+
221
+ We perform ablation studies over architecture and training objective for the prediction heads used in GENIE: In Tab. 2, “No mixed” refers to learning $d _ { \gamma _ { t } } \epsilon _ { \theta }$ directly as single network output without mixed network
222
+
223
+ parameterization; “No weighting” refers to setting $g _ { \mathrm { d } } ( t ) = 1$ in Eq. (15); “Standard” uses both the mixed network parameterization and the weighting function $g _ { \mathrm { d } } ( t ) \stackrel { \cdot } { = } \gamma _ { t } ^ { 2 }$ . We can see that having both the mixed network parametrization and the weighting function is clearly beneficial. We also tested deeper networks in the prediction heads: for “Bigger model” we increased the number of residual blocks from one to two. The performance is roughly on par with “Standard”, and we therefore opted for the smaller head due to the lower computational overhead.
224
+
225
+ # 5.4 Upsampling
226
+
227
+ Table 3: Cats (upsampler) generative performance (measured in FID).
228
+
229
+ <table><tr><td>Method</td><td>NFEs=5</td><td>NFEs=10</td><td>NFEs=15</td></tr><tr><td>GENIE (ours)</td><td>5.53</td><td>4.90</td><td>4.83</td></tr><tr><td>DDIM [58]</td><td>9.47</td><td>6.64</td><td>5.85</td></tr><tr><td>S-PNDM[63]</td><td>14.6</td><td>11.0</td><td>8.83</td></tr><tr><td>F-PNDM [[63]</td><td>N/A</td><td>N/A</td><td>11.7</td></tr></table>
230
+
231
+ Cascaded diffusion model pipelines [2] and DDM-based super-resolution [8] have become crucial ingredients in DDMs for large-scale image generation [105]. Hence, we also explore the applicability of GENIE in this setting. We train a $1 2 8 \times 1 2 8$ base model as well as a $1 2 8 \times 1 2 8 \to 5 1 2 \times 5 1 2$ diffusion upsampler [2, 8] on
232
+
233
+ Cats. In Tab. 3, we compare the generative performance of GENIE to other fast samplers for the upsampler (in isolation). We find that GENIE performs very well on this task: with only five NFEs GENIE outperforms all other methods at $\mathrm { N F E s } { = } 1 5$ . We show upsampled samples for GENIE with $\mathrm { N F E s } { = } 5$ in Fig. 9. For more quantitative and qualitative results, we refer to App. F.6 and App. F.7, respectively. Training and inference details for the score model and the GENIE prediction head, for both base model and upsampler, can be found in App. C.
234
+
235
+ ![](images/1f8da56958a3893eba42484c8c83ad8c44ce8fe9311b671d4095b82218275ccc.jpg)
236
+ Figure 9: High-resolution images generated with the $1 2 8 \times 1 2 8 \to 5 1 2 \times 5 1 2$ GENIE upsampler using only five neural network calls. For the two images at the top, the upsampler is conditioned on test images from the Cats dataset. For the two images at the bottom, the upsampler is conditioned on samples from the $1 2 8 \times 1 2 8$ GENIE base model (generated using 25 NFEs); an upsampler neural network evaluation is roughly four times as expensive as a base model evaluation.
237
+
238
+ # 6 Conclusions
239
+
240
+ We introduced GENIE, a higher-order ODE solver for DDMs. GENIE improves upon the commonly used DDIM solver by capturing the local curvature of its ODE’s gradient field, which allows for larger step sizes when solving the ODE. We further propose to distill the required higher-order derivatives into a small prediction head—which we can efficiently call during inference—on top of the first-order score network. A limitation of GENIE is that it is still slightly slower than approaches that abandon the differential equation framework of DDMs altogether, which, however, comes at the considerable cost of preventing applications such as guided sampling. To overcome this limitation, future work could leverage even higher-order gradients to accelerate sampling from DDMs even further (also see App. G.2).
241
+
242
+ Broader Impact. Fast synthesis from DDMs, the goal of GENIE, can potentially make DDMs an attractive method for promising interactive generative modeling applications, such as digital content creation or real-time audio synthesis, and also reduce DDMs’ environmental footprint by decreasing the computational load during inference. Although we validate GENIE on image synthesis, it could also be utilized for other tasks, which makes its broader societal impact application-dependent. In that context, it is important that practitioners apply an abundance of caution to mitigate impacts given generative modeling can also be used for malicious purposes, discussed for instance in Vaccari and Chadwick [106], Nguyen et al. [107], Mirsky and Lee [108].
243
+
244
+ # Acknowledgements
245
+
246
+ This work was funded by NVIDIA. Tim Dockhorn acknowledges additional funding from the Vector Institute Research Grant, not in direct support of this work. We thank Yaoliang Yu for discussions.
247
+
248
+ # References
249
+
250
+ [1] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising Diffusion Probabilistic Models. In Advances in Neural Information Processing Systems, 2020.
251
+ [2] Jonathan Ho, Chitwan Saharia, William Chan, David J Fleet, Mohammad Norouzi, and Tim Salimans. Cascaded Diffusion Models for High Fidelity Image Generation. arXiv:2106.15282, 2021. [3] Alexander Quinn Nichol and Prafulla Dhariwal. Improved Denoising Diffusion Probabilistic Models. In International Conference on Machine Learning, 2021.
252
+ [4] Prafulla Dhariwal and Alex Nichol. Diffusion Models Beat GANs on Image Synthesis. In Neural Information Processing Systems, 2021. [5] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-Resolution Image Synthesis with Latent Diffusion Models. arXiv:2112.10752, 2021.
253
+ [6] Ruihan Yang, Prakhar Srivastava, and Stephan Mandt. Diffusion Probabilistic Modeling for Video Generation. arXiv:2203.09481, 2022.
254
+ [7] Jonathan Ho, Tim Salimans, Alexey Gritsenko, William Chan, Mohammad Norouzi, and David J. Fleet. Video Diffusion Models. arXiv:2204.03458, 2022.
255
+ [8] Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J Fleet, and Mohammad Norouzi. Image Super-Resolution via Iterative Refinement. arXiv:2104.07636, 2021. [9] Haoying Li, Yifan Yang, Meng Chang, Huajun Feng, Zhihai Xu, Qi Li, and Yueting Chen. SRDiff: Single Image Super-Resolution with Diffusion Probabilistic Models. arXiv:2104.14951, 2021.
256
+ [10] Jay Whang, Mauricio Delbracio, Hossein Talebi, Chitwan Saharia, Alexandros G. Dimakis, and Peyman Milanfar. Deblurring via Stochastic Refinement. arXiv:2112.02475, 2021.
257
+ [11] Bahjat Kawar, Michael Elad, Stefano Ermon, and Jiaming Song. Denoising Diffusion Restoration Models. arXiv:2201.11793, 2022.
258
+ [12] Chenlin Meng, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, and Stefano Ermon. SDEdit: Image Synthesis and Editing with Stochastic Differential Equations. arXiv:2108.01073, 2021.
259
+ [13] Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, and Luc Van Gool. RePaint: Inpainting using Denoising Diffusion Probabilistic Models. arXiv:2201.09865, 2022.
260
+ [14] Chitwan Saharia, William Chan, Huiwen Chang, Chris A. Lee, Jonathan Ho, Tim Salimans, David J. Fleet, and Mohammad Norouzi. Palette: Image-to-Image Diffusion Models. arXiv:2111.05826, 2021.
261
+ [15] 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 TextGuided Diffusion Models. arXiv:2112.10741, 2021.
262
+ [16] Omri Avrahami, Dani Lischinski, and Ohad Fried. lended Diffusion for Text-driven Editing of Natural Images. arXiv:2111.14818, 2021.
263
+ [17] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical TextConditional Image Generation with CLIP Latents. arXiv:2204.06125, 2022.
264
+ [18] Jooyoung Choi, Sungwon Kim, Yonghyun Jeong, Youngjune Gwon, and Sungroh Yoon. ILVR: Conditioning Method for Denoising Diffusion Probabilistic Models. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2021.
265
+ [19] Kushagra Pandey, Avideep Mukherjee, Piyush Rai, and Abhishek Kumar. DiffuseVAE: Efficient, Controllable and High-Fidelity Generation from Low-Dimensional Latents. arXiv:2201.00308, 2022.
266
+ [20] Konpat Preechakul, Nattanat Chatthee, Suttisak Wizadwongsa, and Supasorn Suwajanakorn. Diffusion Autoencoders: Toward a Meaningful and Decodable Representation. arXiv:2111.15640, 2021.
267
+ [21] Xihui Liu, Dong Huk Park, Samaneh Azadi, Gong Zhang, Arman Chopikyan, Yuxiao Hu, Humphrey Shi, Anna Rohrbach, and Trevor Darrell. More Control for Free! Image Synthesis with Semantic Diffusion Guidance. arXiv:2112.05744, 2021.
268
+ [22] Georgios Batzolis, Jan Stanczuk, Carola-Bibiane Schönlieb, and Christian Etmann. Conditional Image Generation with Score-Based Diffusion Models. arXiv:2111.13606, 2021.
269
+ [23] Hiroshi Sasaki, Chris G. Willcocks, and Toby P. Breckon. UNIT-DDPM: UNpaired Image Translation with Denoising Diffusion Probabilistic Models. arXiv:2104.05358, 2021.
270
+ [24] Xuan Su, Jiaming Song, Chenlin Meng, and Stefano Ermon. Dual Diffusion Implicit Bridges for Image-to-Image Translation. arXiv:2203.08382, 2022.
271
+ [25] Yang Song, Liyue Shen, Lei Xing, and Stefano Ermon. Solving Inverse Problems in Medical Imaging with Score-Based Generative Models. In International Conference on Learning Representations, 2022.
272
+ [26] Cheng Peng, Pengfei Guo, S. Kevin Zhou, Vishal Patel, and Rama Chellappa. Towards performant and reliable undersampled MR reconstruction via diffusion model sampling. arXiv:2203.04292, 2022.
273
+ [27] Yutong Xie and Quanzheng Li. Measurement-conditioned Denoising Diffusion Probabilistic Model for Under-sampled Medical Image Reconstruction. arXiv:2203.03623, 2022.
274
+ [28] Guanxiong Luo, Martin Heide, and Martin Uecker. MRI Reconstruction via Data Driven Markov Chain with Joint Uncertainty Estimation. arXiv:2202.01479, 2022.
275
+ [29] Hyungjin Chung and Jong Chul Ye. Score-based diffusion models for accelerated MRI. arXiv:2110.05243, 2021.
276
+ [30] Dewei Hu, Yuankai K. Tao, and Ipek Oguz. Unsupervised Denoising of Retinal OCT with Diffusion Probabilistic Model. arXiv:2201.11760, 2022.
277
+ [31] Hyungjin Chung, Byeongsu Sim, and Jong Chul Ye. Come-Closer-Diffuse-Faster: Accelerating Conditional Diffusion Models for Inverse Problems through Stochastic Contraction. arXiv:2112.05146, 2021.
278
+ [32] 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, 2021.
279
+ [33] 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.
280
+ [34] 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.
281
+ [35] 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:2106.09660, 2021.
282
+ [36] 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.
283
+ [37] Songxiang Liu, Dan Su, and Dong Yu. DiffGAN-TTS: High-Fidelity and Efficient Text-to-Speech with Denoising Diffusion GANs. arXiv:2201.11972, 2022.
284
+ [38] 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.
285
+ [39] 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.
286
+ [40] 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.
287
+ [41] 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, 2022.
288
+ [42] Emilien Dupont, Hyunjik Kim, S. M. Ali Eslami, Danilo Rezende, and Dan Rosenbaum. From data to functa: Your data point is a function and you should treat it like one. arXiv:2201.12204, 2022.
289
+ [43] Chence Shi, Shitong Luo, Minkai Xu, and Jian Tang. Learning gradient fields for molecular conformation generation. In International Conference on Machine Learning, 2021.
290
+ [44] Minkai Xu, Lantao Yu, Yang Song, Chence Shi, Stefano Ermon, and Jian Tang. GeoDiff: A Geometric Diffusion Model for Molecular Conformation Generation. In International Conference on Learning Representations, 2022.
291
+ [45] Tian Xie, Xiang Fu, Octavian-Eugen Ganea, Regina Barzilay, and Tommi S. Jaakkola. Crystal Diffusion Variational Autoencoder for Periodic Material Generation. In International Conference on Learning Representations, 2022.
292
+ [46] Jaehyeong Jo, Seul Lee, and Sung Ju Hwang. Score-based Generative Modeling of Graphs via the System of Stochastic Differential Equations. arXiv:2202.02514, 2022.
293
+ [47] Yang Song, Conor Durkan, Iain Murray, and Stefano Ermon. Maximum Likelihood Training of ScoreBased Diffusion Models. In Neural Information Processing Systems (NeurIPS), 2021.
294
+ [48] Diederik P Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational Diffusion Models. In Advances in Neural Information Processing Systems, 2021.
295
+ [49] Arash Vahdat, Karsten Kreis, and Jan Kautz. Score-based Generative Modeling in Latent Space. In Neural Information Processing Systems (NeurIPS), 2021.
296
+ [50] Chin-Wei Huang, Jae Hyun Lim, and Aaron Courville. A Variational Perspective on Diffusion-Based Generative Models and Score Matching. In Neural Information Processing Systems (NeurIPS), 2021.
297
+ [51] Chenhao Niu, Yang Song, Jiaming Song, Shengjia Zhao, Aditya Grover, and Stefano Ermon. Permutation invariant graph generation via score-based generative modeling. In International Conference on Artificial Intelligence and Statistics, 2020.
298
+ [52] Jongmin Yoon, Sung Ju Hwang, and Juho Lee. Adversarial Purification with Score-based Generative Models. In International Conference on Machine Learning, 2021.
299
+ [53] Yusuke Tashiro, Jiaming Song, Yang Song, and Stefano Ermon. CSDI: Conditional Score-based Diffusion Models for Probabilistic Time Series Imputation. In Advances in Neural Information Processing Systems, 2021.
300
+ [54] Valentin De Bortoli, Emile Mathieu, Michael Hutchinson, James Thornton, Yee Whye Teh, and Arnaud Doucet. Riemannian Score-Based Generative Modeling. arXiv:2202.02763, 2022.
301
+ [55] Pedro Sanchez and Sotirios A. Tsaftaris. Diffusion Causal Models for Counterfactual Estimation. In First Conference on Causal Learning and Reasoning, 2022.
302
+ [56] Weili Nie, Brandon Guo, Yujia Huang, Chaowei Xiao, Arash Vahdat, and Anima Anandkumar. Diffusion Models for Adversarial Purification. In International Conference on Machine Learning (ICML), 2022.
303
+ [57] 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.
304
+ [58] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising Diffusion Implicit Models. In International Conference on Learning Representations, 2021.
305
+ [59] Peter E. Kloeden and Eckhard Platen. Numerical Solution of Stochastic Differential Equations. Springer, Berlin, 1992.
306
+ [60] Tim Dockhorn, Arash Vahdat, and Karsten Kreis. Score-Based Generative Modeling with CriticallyDamped Langevin Diffusion. In International Conference on Learning Representations, 2022.
307
+ [61] Hideyuki Tachibana, Mocho Go, Muneyoshi Inahara, Yotaro Katayama, and Yotaro Watanabe. Itô- Taylor Sampling Scheme for Denoising Diffusion Probabilistic Models using Ideal Derivatives. arXiv:2112.13339, 2021.
308
+ [62] 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:2105.14080, 2021.
309
+ [63] Luping Liu, Yi Ren, Zhijie Lin, and Zhou Zhao. Pseudo Numerical Methods for Diffusion Models on Manifolds. In International Conference on Learning Representations, 2022.
310
+ [64] Zhifeng Kong and Wei Ping. On Fast Sampling of Diffusion Probabilistic Models. arXiv:2106.00132, 2021.
311
+ [65] 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.
312
+ [66] 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.
313
+ [67] Zhisheng Xiao, Karsten Kreis, and Arash Vahdat. Tackling the Generative Learning Trilemma with Denoising Diffusion GANs. In International Conference on Learning Representations, 2022.
314
+ [68] Eric Luhman and Troy Luhman. Knowledge Distillation in Iterative Generative Models for Improved Sampling Speed. arXiv:2101.02388, 2021.
315
+ [69] Tim Salimans and Jonathan Ho. Progressive Distillation for Fast Sampling of Diffusion Models. In International Conference on Learning Representations, 2022.
316
+ [70] Jonathan Ho and Tim Salimans. Classifier-Free Diffusion Guidance. In NeurIPS 2021 Workshop on Deep Generative Models and Downstream Applications, 2021.
317
+ [71] Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep Unsupervised Learning using Nonequilibrium Thermodynamics. In International Conference on Machine Learning, 2015.
318
+ [72] Brian DO Anderson. Reverse-time diffusion equation models. Stochastic Processes and their Applications, 12(3):313–326, 1982.
319
+ [73] Ulrich G Haussmann and Etienne Pardoux. Time Reversal of Diffusions. The Annals of Probability, pages 1188–1205, 1986.
320
+ [74] Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural Ordinary Differential Equations. Advances in Neural Information Processing Systems, 2018.
321
+ [75] Will Grathwohl, Ricky T. Q. Chen, Jesse Bettencourt, Ilya Sutskever, and David Duvenaud. FFJORD: Free-form Continuous Dynamics for Scalable Reversible Generative Models. International Conference on Learning Representations, 2019.
322
+ [76] Pascal Vincent. A Connection Between Score Matching and Denoising Autoencoders. Neural Computation, 23(7):1661–1674, 2011.
323
+ [77] John Charles Butcher. Numerical Methods for Ordinary Differential Equations. John Wiley & Sons, 2016.
324
+ [78] Peter E Kloeden and Eckhard Platen. Numerical Solution of Stochastic Differential Equations. Springer, 1992.
325
+ [79] 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.
326
+ [80] Jooyoung Choi, Jungbeom Lee, Chaehun Shin, Sungwon Kim, Hyunwoo Kim, and Sungroh Yoon. Perception Prioritized Training of Diffusion Models. arXiv:2204.00227, 2022.
327
+ [81] Dmitry Baranchuk, Andrey Voynov, Ivan Rubachev, Valentin Khrulkov, and Artem Babenko. LabelEfficient Semantic Segmentation with Diffusion Models. In International Conference on Learning Representations, 2022.
328
+ [82] Chenlin Meng, Yang Song, Wenzhe Li, and Stefano Ermon. Estimating High Order Gradients of the Data Distribution by Denoising. Advances in Neural Information Processing Systems, 34, 2021.
329
+ [83] Daniel Watson, Jonathan Ho, Mohammad Norouzi, and William Chan. Learning to Efficiently Sample from Diffusion Probabilistic Models. arXiv:2106.03802, 2021.
330
+ [84] 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.
331
+ [85] Eliya Nachmani, Robin San Roman, and Lior Wolf. Non Gaussian Denoising Diffusion Models. arXiv:2106.07582, 2021. [86] Max WY Lam, Jun Wang, Rongjie Huang, Dan Su, and Dong Yu. Bilateral Denoising Diffusion Models. arXiv:2108.11514, 2021.
332
+ [87] Franck Djeumou, Cyrus Neary, Eric Goubault, Sylvie Putot, and Ufuk Topcu. Taylor-Lagrange Neural Ordinary Differential Equations: Toward Fast Training and Evaluation of Neural ODEs. arXiv:2201.05715, 2022. [88] Jacob Kelly, Jesse Bettencourt, Matthew J Johnson, and David K Duvenaud. Learning differential equations that are easy to solve. Advances in Neural Information Processing Systems, 33:4370–4380, 2020. [89] Chris Finlay, Jörn-Henrik Jacobsen, Levon Nurbekyan, and Adam Oberman. How to train your neural ODE: the world of Jacobian and kinetic regularization. In International conference on machine learning, pages 3154–3164. PMLR, 2020. [90] YF Chang and George Corliss. ATOMFT: solving ODEs and DAEs using Taylor series. Computers & Mathematics with Applications, 28(10-12):209–233, 1994. [91] George Corliss and YF Chang. Solving ordinary differential equations using Taylor series. ACM Transactions on Mathematical Software (TOMS), 8(2):114–144, 1982. [92] Qinsheng Zhang and Yongxin Chen. Fast Sampling of Diffusion Models with Exponential Integrator. arXiv:2204.13902, 2022. [93] 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:2206.00927, 2022. [94] Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the Design Space of DiffusionBased Generative Models. arXiv:2206.00364, 2022. [95] Qinsheng Zhang, Molei Tao, and Yongxin Chen. gDDIM: Generalized denoising diffusion implicit models. arXiv:2206.05564, 2022. [96] Fan Bao, Chongxuan Li, Jiacheng Sun, Jun Zhu, and Bo Zhang. Estimating the Optimal Covariance with Imperfect Mean in Diffusion Probabilistic Models. arXiv:2206.07309, 2022. [97] Alex Krizhevsky. Learning Multiple Layers of Features from Tiny Images. Technical report, University of Toronto, 2009.
333
+ [98] Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser, and Jianxiong Xiao. LSUN: Construction of a Large-scale Image Dataset using Deep Learning with Humans in the Loop. arXiv preprint arXiv:1506.03365, 2015. [99] 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.
334
+ [100] Yunjey Choi, Youngjung Uh, Jaejun Yoo, and Jung-Woo Ha. StarGAN v2: Diverse Image Synthesis for Multiple Domains. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 8188–8197, 2020.
335
+ [101] Andrew Brock, Jeff Donahue, and Karen Simonyan. Large Scale GAN Training for High Fidelity Natural Image Synthesis. In International Conference on Learning Representations, 2019.
336
+ [102] 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 I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017.
337
+ [103] Alexia Jolicoeur-Martineau, Rémi Piché-Taillefer, Ioannis Mitliagkas, and Remi Tachet des Combes. Adversarial score matching and improved sampling for image generation. In International Conference on Learning Representations, 2021.
338
+ [104] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the Inception Architecture for Computer Vision. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pages 2818–2826, 2016.
339
+ [105] 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:2205.11487, 2022.
340
+ [106] 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.
341
+ [107] 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:1909.11573, 2021.
342
+ [108] Yisroel Mirsky and Wenke Lee. The Creation and Detection of Deepfakes: A Survey. ACM Comput. Surv., 54(1), 2021.
343
+ [109] Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral Normalization for Generative Adversarial Networks. In International Conference on Learning Representations (ICLR), 2018.
344
+ [110] Diederik P Kingma and Jimmy Ba. Adam: A Method for Stochastic Optimization. In International Conference on Learning Representations, 2015.
345
+ [111] Mehdi SM Sajjadi, Olivier Bachem, Mario Lucic, Olivier Bousquet, and Sylvain Gelly. Assessing Generative Models via Precision and Recall. Advances in Neural Information Processing Systems, 31, 2018.
346
+ [112] Tuomas Kynkäänniemi, Tero Karras, Samuli Laine, Jaakko Lehtinen, and Timo Aila. Improved Precision and Recall Metric for Assessing Generative Models. Advances in Neural Information Processing Systems, 32, 2019.
347
+
348
+ # Checklist
349
+
350
+ 1. For all authors...
351
+
352
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
353
+ (b) Did you describe the limitations of your work? [Yes] See Sec. 6.
354
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See Sec. 6.
355
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
356
+
357
+ 2. If you are including theoretical results...
358
+
359
+ (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 higher-order solver for sampling from denoising diffusion generative models.
360
+ (b) Did you include complete proofs of all theoretical results? [N/A]
361
+
362
+ 3. If you ran experiments...
363
+
364
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [No] We will provide code and instructions to reproduce all experiments in the near future.
365
+ (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 Appendix, including all hyperparameters.
366
+ (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 generative modeling literature, we do not report error bars. Furthermore, we avoid running similar setups repeatedly to save computational resources.
367
+ (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. F.8.
368
+
369
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
370
+
371
+ (a) If your work uses existing assets, did you cite the creators? [Yes] On CIFAR10, we use a checkpoint provided by Song et al. [57]. For baseline comparisons, we run publicly available code: in particular, we make use of the repositories https://github.com/yang-song/score_sde_pytorch and https://github. com/nv-tlabs/CLD-SGM from previous, publicly available papers, which we cite (Song et al. [57] and Dockhorn et al. [60], respectively). We also cite all used datasets: CIFAR-10 [97], LSUN Bedrooms [98], LSUN Church-Outdoor [98], ImageNet [99], and AFHQv2 [100].
372
+ (b) Did you mention the license of the assets? [Yes] In the Appendix, we mention the licenses of all codes we are running for baseline comparisons and evaluation. See App. F.1.
373
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
374
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
375
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] We are only using publicly available datasets, which have been widely used in the generative modeling literature as standard benchmarks (CIFAR-10, ImageNet, LSUN Church-Outdoor, LSUN Bedrooms, AFHQv2) and avoid using face image datasets.
376
+
377
+ 5. If you used crowdsourcing or conducted research with human subjects...
378
+
379
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
380
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
381
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/OboQ71j1Bn/OboQ71j1Bn.md ADDED
@@ -0,0 +1,595 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # REDUCE, REUSE, RECYCLE: COMPOSITIONAL GENERATION WITH ENERGY-BASED DIFFUSION MODELS AND MCMC
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Since their introduction, diffusion models have quickly become the prevailing approach to generative modeling in many domains. They can be interpreted as learning the gradients of a time-varying sequence of log-probability density functions. This interpretation has motivated classifier-based and classifier-free guidance as methods for post-hoc control of diffusion models. In this work, we build upon these ideas using the score-based interpretation of diffusion models, and explore alternative ways to condition, modify, and reuse diffusion models for tasks involving compositional generation and guidance. In particular, we investigate why certain types of composition fail using current techniques and present a number of solutions. We conclude that the sampler (not the model) is responsible for this failure and propose new samplers, inspired by MCMC, which enable successful compositional generation. Further, we propose an energy-based parameterization of diffusion models which enables the use of new compositional operators and more sophisticated, Metropolis-corrected samplers. Intriguingly we find these samplers lead to notable improvements in compositional generation across a wide variety of problems such as classifier-guided ImageNet modeling and compositional text-to-image generation.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ In recent years, tremendous progress has been made in generative modeling across a variety of domains (Brown et al., 2020; Brock et al., 2018; Ho et al., 2020). These models now serve as powerful priors for downstream applications such as code generation (Li et al., 2022), text-to-image generation (Saharia et al., 2022), question-answering (Brown et al., 2020) and many more. However, to fit this complex data, generative models have grown inexorably larger (requiring 10’s or even 100’s of billions of parameters) (Kaplan et al., 2020) and require datasets containing non-negligible fractions of the entire internet, making it costly and difficult to train and or finetune such models. Despite this, some of the most compelling applications of large generative models do not rely on finetuning. For example, prompting (Brown et al., 2020) has been a successful strategy to selectively extract insights from large models. In this paper, we explore an alternative to finetuning and prompting, through which we may repurpose the underlying prior learned by generative models for downstream tasks.
12
+
13
+ Diffusion Models (Sohl-Dickstein et al., 2015; Song & Ermon, 2019; Ho et al., 2020) are a recently popular approach to generative modeling which have demonstrated a favorable combination of scalability, sample quality, and log-likelihood. A key feature of diffusion models is the ability for their sampling to be “guided” after training. This involves combining the pre-trained Diffusion Model $p _ { \theta } ( x )$ with a predictive model $p _ { \theta } ( y | x )$ to generate samples from $p _ { \theta } ( x | y )$ . This predictive model can be either explicitly defined (such as a pre-trained classifier) (Sohl-Dickstein et al., 2015; Dhariwal & Nichol, 2021) or an implicit predictive model defined through the combination of a conditional and unconditional generative model (Ho & Salimans, 2022). These forms of conditioning are particularly appealing (especially the former) as they allow us to reuse pre-trained generative models for many downstream applications, beyond those considered at training time.
14
+
15
+ These conditioning methods are a form of model composition, i.e. combining probabilistic models together to create new models. Compositional models have a long history back to early work on Mixtures-Of-Experts (Jacobs et al., 1991) and Product-Of-Experts models (Hinton, 2002; Mayraz &
16
+
17
+ ![](images/e319142d3909a1775051d2649b2726a3b96107e89f1adbd0fbb4ad3ca99ee902.jpg)
18
+ Figure 1: Creating new models through composition. Simple operators enable diffusion models to be composed without retraining in settings such (a) products, (b) classifier conditioning, (c) compositional text-toimage generation with a product (left) and a mixture (right). All samples generated by trained models.
19
+
20
+ Hinton, 2000). Here, many simple models or predictors were combined to increase their capacity. Much of this early work on model composition was done in the context of Energy-Based Models (Hinton, 2002), an alternative class of generative model which bears many similarities to diffusion models.
21
+
22
+ In this work, we explore the ways that diffusion models can be reused and composed with oneanother. First, we introduce a set of methods which allow pre-trained diffusion models to be composed, with one-another and with other models, to create new models without retraining. Second, we illustrate how existing methods for composing diffusion models are not fully correct, and propose a remedy to these issues with MCMC-derived sampling. Next, we propose the use of an energy-based parameterization for diffusion models, where the unnormalized density of each reverse diffusion distribution is explicitly modeled. We illustrate how this parameterization enables both additional ways to compose diffusion models, as well as the use of more powerful Metropolis-adjusted MCMC samplers. Finally, we demonstrate the effectiveness of our approach in settings from 2D data to high-resolution text-to-image generation. An illustration of our domains can be found in Figure 1.
23
+
24
+ # 2 BACKGROUND
25
+
26
+ # 2.1 DIFFUSION MODELS
27
+
28
+ Diffusion models seek to model a data distribution $q ( x _ { 0 } )$ . We augment this distribution with auxiliary variables $\{ x _ { t } \} _ { t = 1 } ^ { T }$ defining a Gaussian diffusion $q ( x _ { 0 } , \dots , x _ { T } ) = q ( x _ { 0 } ) q ( x _ { 1 } | x _ { 0 } ) \dots q ( x _ { T } | x _ { T - 1 } )$ where each transition is defined $q ( x _ { t } | x _ { t - 1 } ) = \mathcal { N } ( x _ { t } ; \sqrt { 1 - \beta _ { t } } x _ { t - 1 } , \beta _ { t } \bar { I } )$ for some $0 < \beta _ { t } \le 1$ . This transition first scales down $x _ { t - 1 }$ by $\sqrt { 1 - \beta _ { t } }$ and then adds Gaussian noise of variance $\beta _ { t }$ . For large enough $T$ , we will have $q ( x _ { T } ) \approx \mathcal { N } ( 0 , I )$ .
29
+
30
+ Our model takes the form $p _ { \theta } ( x _ { t - 1 } | x _ { t } )$ and seeks to learn the reverse distribution of $q ( x _ { t } | x _ { t - 1 } )$ which seeks to denoise $x _ { t }$ to $x _ { t - 1 }$ . In the limit of small $\beta _ { t }$ this reversal becomes Gaussian (Sohl-Dickstein et al., 2015) so we parameterize our model $p _ { \theta } ( x _ { t - 1 } | x _ { t } ) = \mathcal { N } ( x _ { t - 1 } ; \mu _ { \theta } ( x _ { t } , t ) , \tilde { \beta } _ { t } I )$ with:
31
+
32
+ $$
33
+ \begin{array} { r } { \mu _ { \theta } ( x _ { t } , t ) = \frac { 1 } { \sqrt { \alpha _ { t } } } \left( x _ { t } - \frac { \beta _ { t } } { \sqrt { 1 - { { \bar { \alpha } } _ { t } } } } \epsilon _ { \theta } ( x _ { t } , t ) \right) . } \end{array}
34
+ $$
35
+
36
+ where $\epsilon _ { \theta } ( x _ { t } , t )$ is a neural network, and $\alpha _ { t } , \bar { \alpha } _ { t } , \tilde { \beta } _ { t }$ are functions of $\{ \beta _ { t } \} _ { t = 1 } ^ { T }$
37
+
38
+ A useful feature of the diffusion process $q$ is that we can analytically derive any time marginal $q ( x _ { t } | x _ { 0 } ) = \mathcal { N } ( x _ { t } ; \sqrt { 1 - \sigma _ { t } ^ { 2 } } x _ { 0 } , \sigma _ { t } ^ { 2 } I )$ where again $\sigma _ { t }$ is a function of $\{ \beta _ { t } \} _ { t = 1 } ^ { T }$ . We can sample $x _ { t }$ from this distribution using reparameterization, i.e $x _ { t } ( x _ { 0 } , \epsilon ) = \sqrt { 1 - \sigma _ { t } ^ { 2 } } x _ { 0 } + \sigma _ { t } \epsilon$ where $\epsilon \sim \mathcal { N } ( 0 , I )$ . Exploiting this, diffusion models are typically trained with the loss
39
+
40
+ $$
41
+ \begin{array} { r } { \mathcal { L } ( \theta ) = \sum _ { t = 1 } ^ { T } \mathcal { L } _ { t } ( \theta ) , \qquad \mathcal { L } _ { t } ( \theta ) = \mathbb { E } _ { q ( x _ { 0 } ) , N ( \epsilon ; 0 , I ) } \left[ | | \epsilon - \epsilon _ { \theta } ( x _ { t } ( x _ { 0 } , \epsilon ) , t ) | | ^ { 2 } \right] . } \end{array}
42
+ $$
43
+
44
+ Once $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ is trained, we recover $\mu _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ with Equation 1 to parameterize $p _ { \theta } ( x _ { t - 1 } | x _ { t } )$ and perform ancestral sampling (also known as the reverse process) to reverse the diffusion, i.e sample $\overline { { x _ { T } } } \sim \mathcal { N } ( 0 , I )$ , then for $t = T - 1 1$ , sample $x _ { t - 1 } \sim p _ { \theta } ( x _ { t - 1 } | x _ { t } )$ . A more detailed description can be found in Appendix B.
45
+
46
+ # 2.2 ENERGY-BASED MODELS AND MCMC SAMPLING
47
+
48
+ Energy-Based Models (EBMs) are a class of probabilistic model which parameterize a distribution as $\begin{array} { r } { p _ { \theta } ( x ) = \frac { e ^ { f _ { \theta } ( x ) } } { Z ( \theta ) } } \end{array}$ where the normalizing constant $\begin{array} { r } { Z ( \theta ) = \int e ^ { f _ { \theta } ( x ) } d x } \end{array}$ is not modeled. Choosing not to model this quantity gives the model much more flexibility but comes with considerable limitations. We can no longer efficiently compute likelihoods or draw samples from the model. This complicates training, as most generative models are trained by maximizing likelihood.
49
+
50
+ One popular method for EBM training is denoising score matching. This approach minimizes the Fisher Divergence1 between the model and a Gaussian-smoothed version of the data distribution $\begin{array} { r } { q _ { \sigma } ( x ) = \int q ( x ^ { \prime } ) \mathcal { N } ( x ; x ^ { \prime } , \sigma ^ { 2 } I ) d x ^ { \prime } } \end{array}$ by minimizing the following objective
51
+
52
+ $$
53
+ \mathcal { I } _ { \sigma } ( \theta ) = \mathbb { E } _ { q ( x ) N ( \epsilon ; 0 , I ) } \left[ \big | \big | \frac { \epsilon } { \sigma } + \nabla _ { x } f _ { \theta } ( x + \sigma \epsilon ) \big | \big | ^ { 2 } \right] .
54
+ $$
55
+
56
+ When minimized, this ensures that $e ^ { f _ { \theta } ( x ) } \propto q _ { \sigma } ( x )$ and therefore $\nabla _ { x } f _ { \theta } ( x ) = \nabla _ { x } \log { q _ { \sigma } ( x ) }$ . To estimate likelihoods or sample from our model, we must rely on approximate methods, such as MCMC sampling or numerical ODE integration. MCMC works by simulating a Markov chain beginning at $x _ { 0 } \sim p ( x _ { 0 } )$ and using a transition distribution $x _ { t } \sim k ( \bar { x } _ { t } | x _ { t - 1 } )$ . If $k ( \cdot | \cdot )$ has certain properties, namely invariance w.r.t. the target and ergodicity, then as $t \to \infty$ , $x _ { t }$ converges to a sample from our target distribution.
57
+
58
+ Perhaps the most popular MCMC sampling algorithm for EBMs is Unadjusted Langevin Dynamics (ULA) (Roberts & Tweedie, 1996; Du & Mordatch, 2019; Nijkamp et al., 2020) which is defined by
59
+
60
+ $$
61
+ \begin{array} { r } { k ( x _ { t } | x _ { t - 1 } ) = N \left( x _ { t } ; x _ { t - 1 } + \frac { \sigma ^ { 2 } } { 2 } \nabla _ { x } f _ { \theta } ( x _ { t - 1 } ) , \sigma ^ { 2 } I \right) . } \end{array}
62
+ $$
63
+
64
+ This resembles a step of gradient ascent (with step-size $\frac { \sigma ^ { 2 } } { 2 }$ ) with added Gaussian noise of variance $\sigma ^ { 2 }$ . This transition is based on a discretization of the Langevin SDE. In the limit of infinitesimally small $\sigma$ this approach will draw exact samples. To handle the error accrued when using larger step sizes, a Metropolis correction can be added giving the Metropolis-Adjusted-Langevin-Algorithm (MALA) (Besag, 1994). With Metropolis correction, we first generate a proposed update $\hat { x } \sim$ $k ( x | x _ { t - 1 } )$ , then with probability $\begin{array} { r } { \operatorname* { m i n } \left( 1 , \frac { e ^ { f _ { \theta } ( \hat { x } ) } } { e ^ { f _ { \theta } ( x _ { t - 1 } ) } } \frac { k \left( x _ { t - 1 } | \hat { x } \right) } { k \left( \hat { x } | x _ { t - 1 } \right) } \right) } \end{array}$ we set $\boldsymbol { x } _ { t } = \boldsymbol { \hat { x } }$ , otherwise $x _ { t } = x _ { t - 1 }$ .
65
+
66
+ Hamiltonian Monte Carlo (HMC) (Duane et al., 1987; Neal, 1996) is a more advanced MCMC sampling method which augments the state-space with auxiliary momentum variables and numerically integrates energy-conserving Hamiltonian dynamics to advance the sampler. HMC is typically applied with a Metropolis correction, but an approximate variant can be used without it (U-HMC) (Geffner & Domke, 2021). See Appendix C.1 for details of HMC variants we use.
67
+
68
+ # 2.3 RELATIONSHIP BETWEEN DIFFUSION MODELS AND EBMS
69
+
70
+ Diffusion models and EBMs are closely related. For instance, Song & Ermon (2019) uses an EBM perspective to propose a close cousin to diffusion models. We can see from inspection that the training objective of diffusion models is identical (up to a constant) to the denoising score matching objective
71
+
72
+ $$
73
+ \sigma _ { t } ^ { 2 } \mathcal { I } _ { \sigma _ { t } } ( \theta ) = \mathbb { E } _ { q ( x ) \mathcal { N } ( \epsilon ; 0 , I ) } \left[ | | \epsilon + \sigma _ { t } \nabla _ { x } f _ { \theta } ( x + \sigma _ { t } \epsilon ) | | ^ { 2 } \right] = \mathcal { L } _ { t } ( \theta )
74
+ $$
75
+
76
+ where we have replaced $\epsilon _ { \theta } ( x , t )$ with $- \sigma _ { t } \nabla _ { x } f _ { \theta } ( x + \sigma _ { t } \epsilon )$ . Thus by training $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ to minimize Equation 2, we can recover the diffused data distribution score with ∇x log qσ(x) ≈ − ϵθ(x,t)σ . From this, we can define $\epsilon _ { \theta } ( x , t ) = \nabla _ { x } f _ { \theta } ( x , t )$ (the derivative of an explicitly defined scalar function) to learn a noise-conditional potential function $f _ { \boldsymbol { \theta } } ( x , t )$ . We later demonstrate the benefits of this in two ways; it enables the use of more sophisticated sampling algorithms and more forms of composition.
77
+
78
+ # 2.4 CONTROLLABLE GENERATION
79
+
80
+ It may be convenient to train a model of $p ( x )$ where $x$ is, say, the distribution of all images, but in practice we often want to generate samples from $p ( x | y )$ where $y$ is some attribute, label, or feature. This can be accomplished within the framework of diffusion models by introducing a learned
81
+
82
+ predictive model $p _ { \theta } ( y | x ; t )$ , i.e a time-conditional model of the distribution of some feature $y$ given $x$ . We can then exploit Bayes’ rule to notice that (for $\lambda = 1$ ),
83
+
84
+ $$
85
+ \nabla _ { x } \log p _ { \theta } ( x | y ; t ) = \nabla _ { x } \log p _ { \theta } ( x ; t ) + \lambda \nabla _ { x } \log p _ { \theta } ( y | x ; t ) .
86
+ $$
87
+
88
+ In practice, when using the right side of Equation 6 for sampling, it is beneficial to increase the ‘guidance scale’ $\lambda$ to be $> 1$ (Dhariwal & Nichol, 2021). Thus, we can re-purpose the unconditional diffusion model and turn it into a conditional model.
89
+
90
+ If instead of a classifier, we have a both an unconditional diffusion model $\nabla _ { x } \log p _ { \theta } ( x ; t )$ and a conditional diffusion model $\nabla _ { x } \log p _ { \theta } ( x | y ; t )$ , we can again utilize Bayes’ rule to derive an implicit predictive model’s gradients
91
+
92
+ $$
93
+ \nabla _ { x } \log p _ { \theta } ( y | x ; t ) = \nabla _ { x } \log p _ { \theta } ( x | y ; t ) - \nabla _ { x } \log p _ { \theta } ( x ; t )
94
+ $$
95
+
96
+ which can be used to replace the explicit model in Equation 6, giving what is known as classifier-free guidance (Ho & Salimans, 2022). This method has led to incredible performance, but comes at a cost to modularity. This contrasts with the classifier-guidance setting, where we only need to train a single (costly) generative model. We can then attach any predictive model we would like to for conditioning. This is beneficial as it is often much easier and cheaper to train predictive models than a flexible generative model. In the classifier-free setting, we must know exactly which $y$ we would like to condition on, and incorporate these labels into model training. In both guidance settings, we use our (possibly implicit) predictive model to modify the learned score of our model. We then perform diffusion model sampling as we would in the unconditional setting. We will see later that even in toy settings, this is often not the optimal thing to do.
97
+
98
+ # 3 COMPOSITIONAL GENERATION BEYOND GUIDANCE
99
+
100
+ Most work on conditional diffusion models has come in the form of classifier or classifier-free guidance, but these are far from the only ways we can compose distributions to obtain new models. These ideas have been studied primarily in the context of EBMs because most compositional operators leave the resulting distribution unnormalized. We outline various options below.
101
+
102
+ Products: We can take a product of $N$ distributions and re-normalize to create a new distribution, roughly equivalent to the “intersection” of the composite distributions,
103
+
104
+ $$
105
+ \begin{array} { r } { q ^ { \mathrm { p r o d } } ( x ) = \frac { 1 } { Z } \prod _ { i = 1 } ^ { N } q ^ { i } ( x ) , \qquad Z = \int \prod _ { i = 1 } ^ { N } q ^ { i } ( x ) d x . } \end{array}
106
+ $$
107
+
108
+ Regions of high probability under $q ^ { \mathrm { p r o d } } ( x )$ will typically have high probability under all $q ^ { i } ( x )$ . A simple product model can be seen in Figure 2. These ideas were initially proposed to increase the capacity of weaker models by allowing individual “experts” to model specific features in the input (Hinton, 2002), and were recently demonstrated at scale in the image domain using Deep Energy-Based Models (Du et al., 2020a).
109
+
110
+ The approaches to guidance discussed in Section 2.4 define product models with only two experts. The first models the relative density of the input data and the second models the conditional probability of $y$ . Combining these by a product models likely inputs which have the desired property $y$ . This form of composition has become popular for diffusion models since they do not directly model the probability, but instead the gradient of the log-probability which can also be composed in this way.
111
+
112
+ Mixtures: Complementary to the product or intersection is the mixture or union of multiple distributions. We can combine $N$ distributions through a mixture to create a new distribution equivalent to the union of the concepts captured in each distribution
113
+
114
+ $$
115
+ \begin{array} { r } { q ^ { \mathrm { m i x } } ( x ) = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } q ^ { i } ( x ) } \end{array}
116
+ $$
117
+
118
+ where regions of high probability consist of regions of high probability under any $q ^ { i } ( x )$ . We cannot compose score-functions to define mixtures (unlike products). Instead, we need a model which specifies probability. Generating from mixtures of energy based models requires knowing the ratio of normalizers between the models. In our experiments, we assume this ratio is 1. A simple compositional mixture model can be seen in Figure 2.
119
+
120
+ Negation: Finally, given two distributions $p _ { 0 } ( x )$ and $p _ { 1 } ( x )$ , we can explicitly invert the density of $p _ { 1 } ( x )$ with respect to $p _ { 0 } ( x )$ , which constructs a new distribution which assigns high likelihood to points in $p _ { 0 } ( x )$ that are not in $p _ { 1 } ( x )$ (Du et al., 2020a), where $\alpha$ controls the degree we invert $p _ { 1 } ( x )$ (we use $\alpha = 0 . 5$ in our experiments).
121
+
122
+ ![](images/3b058e38c0a52dd0c4de8b4c338a59265fea6f03565646084366161750c0614b.jpg)
123
+ Figure 2: An illustration of product and mixture compositional models, and the improved sampling performance of MCMC in both cases. Left to right: Component distributions, ground truth composed distribution, reverse diffusion samples, HMC samples. Top: product, bottom: mixture. Reverse diffusion fails to sample from composed models.
124
+
125
+ $$
126
+ \begin{array} { r } { q ^ { \mathrm { n e g } } ( x ) \propto \frac { q ^ { 0 } ( x ) } { q ^ { 1 } ( x ) ^ { \alpha } } . } \end{array}
127
+ $$
128
+
129
+ We can combine negation with our previous operators, in a nested manner to construct complex combinations of distributions (Figure 5).
130
+
131
+ In section 2.3, we showed how diffusion models can be interpreted as approximating the gradient $\nabla _ { x } \log { q ( x ) }$ , but do not learn an explicit model of the log-likelihood $\log q ( x )$ . This means with the standard $\epsilon _ { \theta } ( x , t )$ -parameterization we can, in theory, utilize product and negation composition, but not mixture composition.
132
+
133
+ # 4 SCALING COMPOSITIONAL GENERATION WITH DIFFUSION MODELS
134
+
135
+ While highly compositional, EBMs present many challenges. The lack of a normalized probability function makes training, evaluation, and sampling very difficult. Much progress has been made to scale these models (Du & Mordatch, 2019; Nijkamp et al., 2020; Grathwohl et al., 2019; Du et al., 2020b; Grathwohl et al., 2021), but EBMs still lag behind other approaches in terms of efficiency and scalability. In contrast, diffusion models have demonstrated very impressive scalability. Fortuitously, diffusion models have similarities to EBMs, such as their training objective and their score-based interpretation, which makes many forms of composition readily applicable.
136
+
137
+ Unfortunately, when two diffusion models are composed into, for example, a product model $q ^ { \mathrm { p r o d } } ( x ) \propto \dot { q ^ { 1 } } ( x ) q ^ { 2 } ( x )$ , issues arise if the model which reverses the diffusion uses a score estimate obtained by adding the score estimates of the two models. We see in Figure 2 that composing two models in such a way leads indeed to sub-par samples. This is because to sample from this product distribution using standard reverse diffusion (Song et al., 2021), one would need to compute instead the score of the diffused target product distribution given by
138
+
139
+ $$
140
+ \begin{array} { r } { \nabla _ { x } \log \tilde { q } _ { t } ^ { \mathrm { p r o d } } ( x _ { t } ) = \nabla _ { x } \log \left( \int d x _ { 0 } q ^ { 1 } ( x _ { 0 } ) q ^ { 2 } ( x _ { 0 } ) q ( x _ { t } | x _ { 0 } ) \right) . } \end{array}
141
+ $$
142
+
143
+ For $t > 0$ , this quantity is not equal to the sum of the scores of the two models which is given by
144
+
145
+ $$
146
+ \begin{array} { r } { \nabla _ { x } \log q _ { t } ^ { \mathrm { p r o d } } ( x _ { t } ) = \nabla _ { x } \log \left( \int d x _ { 0 } q ^ { 1 } ( x _ { 0 } ) q ( x _ { t } | x _ { 0 } ) \right) + \nabla _ { x } \log \left( \int d x _ { 0 } q ^ { 2 } ( x _ { 0 } ) q ( x _ { t } | x _ { 0 } ) \right) . } \end{array}
147
+ $$
148
+
149
+ Therefore, plugging the composed score function into the standard ancestral sampling procedure discussed in Section 2.1, which we refer to as “reverse diffusion,” does not correspond to sampling from the composed model, and thus reverse diffusion sampling will generate incorrect samples from composed distributions. This effect can be seen in Figure 2, with details in Appendix D.
150
+
151
+ The score of the distribution $q _ { t } ^ { \mathrm { p r o d } } ( x _ { t } )$ in Equation 12 is easy to compute, unlike that of $\tilde { q } _ { t } ^ { \mathrm { p r o d } } ( x _ { t } )$ from Equation 11. In addition, $q _ { t } ^ { \mathrm { p r o d } } ( x _ { t } )$ describes a sequence of distributions which smoothly interpolate between $q ^ { \mathrm { p r o d } } ( x )$ at $t = 0$ and $\mathcal { N } ( 0 , I )$ at $t = T$ , though this sequence of distributions does not correspond to the distributions that result from the standard forward diffusion process described in Section 2.1, leading the reverse diffusion sampling to generate poor samples. We discuss how we may utilize MCMC samplers, which use our knowledge of $\nabla _ { x } \log { q _ { t } ^ { \mathrm { p r o d } } ( x _ { t } ) }$ , to correctly sample from intermediate distributions $\tilde { q } _ { t } ^ { \mathrm { p r o d } } ( x _ { t } )$ , leading to accurate composed sample generation.
152
+
153
+ # 4.1 IMPROVING SAMPLING WITH MCMC
154
+
155
+ In order to sample from $q ^ { \mathrm { p r o d } } ( x )$ using the combined score function from Equation 12, we can use annealed MCMC sampling, described below in Algorithm 1. This method applies MCMC transition kernels to a sequence of distributions which begins with a known, tractable distribution and concludes at our target distribution. Annealed MCMC has a long history enabling sampling from very complex distributions (Neal, 2001; Song & Ermon, 2019).
156
+
157
+ <table><tr><td></td><td>Model Sampler</td><td colspan="3">Product</td><td colspan="3">Mixture</td></tr><tr><td></td><td></td><td>RAISE↑</td><td>LL↑</td><td>Var↓</td><td>ln(MMD)↓</td><td>LL↑</td><td>Var↓</td></tr><tr><td></td><td>Reverse</td><td>1.55</td><td>-6.47</td><td>0.063</td><td></td><td></td><td>=</td></tr><tr><td>Score</td><td>ULA</td><td>2.37</td><td>1.79</td><td>0.026</td><td></td><td></td><td>=</td></tr><tr><td></td><td>U-HMC</td><td>2.52</td><td>2.40</td><td>0.021</td><td></td><td></td><td></td></tr><tr><td></td><td>Reverse (equal steps)</td><td>2.27</td><td>-2.92</td><td>0.046</td><td>=</td><td>=</td><td>-</td></tr><tr><td></td><td>Reverse</td><td>1.37</td><td>-6.03</td><td>0.064</td><td>-3.84</td><td>-2.17</td><td>0.020</td></tr><tr><td></td><td>ULA</td><td>2.36</td><td>1.84</td><td>0.027</td><td>-4.21</td><td>0.57</td><td>0.013</td></tr><tr><td>EBM</td><td>MALA</td><td>2.64</td><td>2.73</td><td>0.013</td><td>-4.38</td><td>1.29</td><td>0.008</td></tr><tr><td></td><td>U-HMC</td><td>2.63</td><td>2.45</td><td>0.022</td><td>-4.69</td><td>1.03</td><td>0.010</td></tr><tr><td></td><td>HMC</td><td>2.71</td><td>2.72</td><td>0.009</td><td>-4.48</td><td>1.30</td><td>0.007</td></tr></table>
158
+
159
+ Table 1: Quantitative results on 2D composition. Energy based parameterization enables mixture compositional models, and MCMC sampling leads to better samples from compositional diffusion models.
160
+
161
+ We explore two types of transition kernels $k _ { t } ( \cdot | \cdot )$ based on Langevin Dynamics (Equation 4) and HMC. When using the standard $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ -parameterization, we do not have access to an explicitly defined energy-function meaning we cannot utilize any MCMC sampler with Metropolis corrections. Thus, we only utilize the ULA and U-HMC samplers described in Section 2.2. These samplers are not exact, but can in practice generate good results. In the next section we detail how Metropolis corrections may be incorporated. Full details of our samplers can be found in Appendix C.1. While continuous time sampling in diffusion models Song et al. (2021) is also referred to as ULA, the MCMC sampling procedure is run across time
162
+
163
+ # Algorithm 1 Annealed MCMC
164
+
165
+ Input: Transition kernels $k _ { t } ( \cdot | \cdot )$ , Initial
166
+ distribution $p _ { T } ( \cdot )$ , Number of steps $N$
167
+ $x r \sim p _ { T } ( x )$ # Initialize.
168
+ for $t = T , \dots , 0$ do for $i = 1 , \ldots , N$ do $x _ { t } \sim k _ { t } ( \cdot | x _ { t } )$ end for $x _ { t - 1 } = x _ { t }$
169
+ end for
170
+ return x0
171
+
172
+ (and corresponds to the same sampling procedure as discretized diffusion discussed in Section 2.1), as opposed to being used to sample from each intermediate distribution q˜prodt ( . Thus applying continuous sampling gives the same issues as reverse diffusion sampling.
173
+
174
+ We can see again in Figure 2 that applying this MCMC sampling procedure allows samples from the composed distribution to be faithfully generated with no modification to the underlying diffusion models. Quantitative results can be found in Table 1 which further imply that the choice of sampler may be responsible for prior failures in compositional generation with diffusion models.
175
+
176
+ # 4.2 ENERGY-BASED PARAMETERIZATION
177
+
178
+ As noted in Section 3, we are unable to use mixture composition without an explicitly parameterized likelihood function. But, if we parameterize a potential function $f _ { \theta } ( x , t )$ and implicitly define $\epsilon _ { \theta } ( x , t ) = \nabla _ { x } f _ { \theta } ( x , t )$ we can recover an explicit estimate of the (unnormalized) log-likelihood – enabling us to utilize all presented forms for model composition.
179
+
180
+ Additionally, an explicit estimate of log-likelihood enables the use of more accurate samplers. As explained above, with the standard $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ -parameterization we can only utilize unadjusted samplers. While they can perform well in practice, there exist many distributions from which they cannot generate decent samples (Roberts & Tweedie, 1996) such as targets with lighter-than-Gaussian tails where the ULA chain is transient. Additionally, for an accurate approximation to the Langevin SDE, ULA will need increasingly small stepsizes as the curvature of the log-likelihood gradient increases which can lead to arbitrarily slow mixing (Durmus & Moulines, 2019). In these settings a Metropolis correction can greatly improve sample quality and convergence. Again this issue can be solved by defining $\epsilon _ { \theta } ( x , t ) = \nabla _ { x } f _ { \theta } ( x , t )$ for some explicitly defined scalar potential function $f _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ .
181
+
182
+ Energy-based parameterizations have been explored in the past (Salimans & Ho, 2021) and were found to perform comparably to score-based models for unconditional generative modeling. In that setting the score parameterization is then preferable as computing the gradient of the energy requires more computation. In the compositional setting, however, the additional flexibility enabled by explicit (unnormalized) log-probability estimation motivates a re-exploration of the energy-parameterization.
183
+
184
+ ![](images/17d85044c3b8849e7fab51be1678ab0ee00be24a391f698285ed722c9fdd8dc2.jpg)
185
+ Figure 3: (a) Composition enables the positions of multiple shapes to be simultaneously controlled, while training only conditions on the location of one object per image. Reverse diffusion samples place shapes in incorrect locations. MCMC generates samples that satisfy all constraints. (b) Metropolis adjustment significantly improves generation performance across sampling steps. As more MCMC steps are run (at each timestep), generation accuracy of combinations of 5 cubes improves significantly.
186
+
187
+ We explored a number of energy-based parameterizations for diffusion models and ran a pilot study on ImageNet. In this study we found it best to parameterize the log probability as $f _ { \theta } ( x , t ) \dot { { \bf \theta } } = - | | s _ { \theta } \overline { { ( x , t ) } } | | ^ { 2 }$ , where $s _ { \theta } ( x , t )$ is a vector-output neural network, like those used in $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ -parameterized diffusion models. Full details on our study can be found in Appendix E. From here on, all energy-based diffusion models take the above form.
188
+
189
+ Our energy-parameterized models enable us to use MALA and HMC samplers which produce our best compositional generation results by a large margin. An additional benefit of these samplers is that, through monitoring their acceptance rates, we are able to derive an effective automated method for tuning their hyper-parameters (a notoriously difficult task prior) which is not available for unadjusted samplers. Details of our samplers and tuning procedures can be found in Appendix C.1.
190
+
191
+ # 5 EXPERIMENTS
192
+
193
+ We experiment with various model parameterizations and sampling schemes for compositional generation with diffusion models. We first investigate these ideas on some illustrative 2D datasets, then move to the image domain with an artificial dataset of shapes. Here, we compose a model conditioned on the location of a single shape with itself to condition on the location of all of the shapes in the image. After this we experiment with classifier guidance on the ImageNet dataset. Finally, we self-compose text-to-image models to generate from compositions of various text prompts. Full details of all experiments can be found in Appendix G. Throughout we compare our proposed improvements with a score-parameterized model using standard reverse diffusion sampling. We note that this baseline is exactly the approach of Liu et al. (2022).
194
+
195
+ # 5.1 2D DENSITIES
196
+
197
+ We train diffusion models using both parameterizations and study the impact of various sampling approaches for compositional generation. Samples are evaluated using RAISE (Burda et al., 2015) (which gives lower bounds on log-likelihood) and $\mathbf { M M D } ^ { 2 }$ , LL (log-likelihood of generated samples under composed distribution), and Var (L2 difference of variance of GMMs fit on generated samples compared to GMMs of the composed distribution). Results can be found in Table 1 and visualizations can be seen in Figure 2. All MCMC sampling methods improve sample quality and likelihood, with Metropolis adjusted methods performing the best. All MCMC experiments use the same number of score function evaluations. We include a baseline, labeled “Reverse (equal steps)” which is a diffusion model trained with more steps such that reverse diffusion sampling has the same cost as our MCMC samplers. We see that simply adding more time-steps does not solve compositional sampling.
198
+
199
+ # 5.2 COMPOSING CUBES
200
+
201
+ Next, we train models on a dataset of images containing between 1 and 5 examples of various shapes taken from CLEVR (Johnson et al., 2017). We train our models to fit $p ( x | y )$ where $y$ is the location of one of the shapes in the image. We then compose this conditional model with itself to create a product model which defines the distribution of images conditioned on $c$ shapes as
202
+
203
+ ![](images/2cfc6ef18e34277e46354121c22d0afa7e309308989f6606b15d53e01dc2c92c.jpg)
204
+ Figure 4: Classifier-guided generation on ImageNet. HMC leads to higher fidelity and more class-identified images than reverse diffusion sampling.
205
+
206
+ <table><tr><td>Model</td><td>Sampler</td><td>Inception Score ↑</td><td>FID↓</td><td>Accuracy ↑</td></tr><tr><td rowspan="3">Score</td><td>Reverse</td><td>29.10</td><td>30.46</td><td>18.64</td></tr><tr><td>LA</td><td>29.35</td><td>30.49</td><td>65.81</td></tr><tr><td>U-HMC</td><td>32.19</td><td>26.89</td><td>89.93</td></tr><tr><td rowspan="5">EBM</td><td>Reverse</td><td>28.05</td><td>33.58</td><td>18.60</td></tr><tr><td>LA</td><td>28.12</td><td>33.45</td><td>66.28</td></tr><tr><td>MALA</td><td>30.43</td><td>32.22</td><td>83.65</td></tr><tr><td>U-HMC</td><td>31.39</td><td>32.08</td><td>90.83</td></tr><tr><td>HMC</td><td>33.46</td><td>30.52</td><td>94.61</td></tr></table>
207
+
208
+ Table 2: MCMC Sampling enables more compositional cube generation on CLEVR.
209
+
210
+ <table><tr><td>Model</td><td>Sampler</td><td colspan="5">Combinations</td></tr><tr><td></td><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr><td></td><td>Reverse</td><td>70.8</td><td>68.2</td><td>66.3</td><td>64.1</td><td>57.4</td></tr><tr><td>Score</td><td>ULA</td><td>75.0</td><td>73.4</td><td>71.8</td><td>67.9</td><td>60.2</td></tr><tr><td></td><td>U-HMC</td><td>79.1</td><td>76.0</td><td>73.6</td><td>71.1</td><td>62.3</td></tr><tr><td></td><td>Reverse</td><td>71.0</td><td>67.1</td><td>62.5</td><td>58.1</td><td>51.0</td></tr><tr><td></td><td>ULA</td><td>81.3</td><td>71.8</td><td>66.6</td><td>59.6</td><td>54.8</td></tr><tr><td>EBM</td><td>MALA</td><td>85.4</td><td>74.4</td><td>71.1</td><td>65.6</td><td>63.9</td></tr><tr><td></td><td>U-HMC</td><td>84.5</td><td>81.3</td><td>79.2</td><td>74.2</td><td>68.1</td></tr><tr><td></td><td>HMC</td><td>91.6</td><td>82.9</td><td>80.1</td><td>76.5</td><td>72.7</td></tr></table>
211
+
212
+ # Table 3: MCMC Sampling enables better classifier guidance on ${ \bf 1 2 8 x 1 2 8 }$ ImageNet dataset.
213
+
214
+ $$
215
+ \log p _ { \theta } ( x | y _ { 1 } , \dots , y _ { c } ) = \log p _ { \theta } ( x ) + \sum _ { i = 1 } ^ { c } \left( \log p _ { \theta } ( x | y _ { i } ) - \log p _ { \theta } ( x ) \right) .
216
+ $$
217
+
218
+ We then sample using various methods, where for each number of combination of cubes, the same number of score function evaluations are used, and evaluate each by the fraction of samples which have all objects placed in the correct location (as determined by a learned classifier). Results can be found in Table 2, where we see MCMC sampling leads to improvements and the Metropolis adjustment enabled by the energy-based parameterization leads to further improvements. We qualitatively illustrate results in Figure 3, and see more accurate generations with more steps of sampling, with more substantial increases with Metropolis adjustment.
219
+
220
+ # 5.3 CLASSIFIER CONDITIONING
221
+
222
+ Next, we train unconditional diffusion models and a noise-conditioned classifier on ImageNet. We compose these models as
223
+
224
+ $$
225
+ \nabla _ { \boldsymbol { x } } \log { p _ { \boldsymbol { \theta } } ( \boldsymbol { x } | \boldsymbol { y } , t ) } = \nabla _ { \boldsymbol { x } } \log { p _ { \boldsymbol { \theta } } ( \boldsymbol { x } | t ) } + \nabla _ { \boldsymbol { x } } \log { p _ { \boldsymbol { \theta } } ( \boldsymbol { y } | \boldsymbol { x } , t ) } .
226
+ $$
227
+
228
+ and sample using the corresponding score functions. We compare various samplers and model parameterizations on classifier accuracy, FID (Heusel et al., 2017) and Inception Score. Quantitative results can be seen in Table 3 and qualitative results seen in Figure 4. We find that MCMC improves performance over reverse sampling, with further improvements from Metropolis corrections.
229
+
230
+ # 5.4 TEXT-2-IMAGE
231
+
232
+ Perhaps the most well-known results achieved with diffusion models are in text-to-image generation (Ramesh et al., 2022; Saharia et al., 2022). Here we model $p _ { \theta } \mathrm { ( } x _ { \mathrm { i m a g e } } | y _ { \mathrm { t e x t } } \mathrm { ) }$ . While generated images generated are photo-realistic, they can fail to generate images from prompts which specify multiple concepts at a time (Liu et al., 2022) such as $y _ { \mathrm { t e x t } } = { } ^ { \ast } \mathrm { A }$ horse on a sandy beach or a grass plain on a not sunny day′′. To deal with these issues we can dissect the prompt into smaller components $y _ { 1 } , \ldots , y _ { c }$ , parameterize models conditioned on each component $p _ { \theta } ( x | y _ { i } )$ and compose these models using our introduced operators. We can parse the above example into
233
+
234
+ “A horse” AND (“A sandy beach” OR “Grass plains”) AND (NOT “Sunny”)
235
+
236
+ which can be used to define the following (unnormalized) distribution
237
+
238
+ $$
239
+ p _ { \theta } ^ { \mathrm { c o m p } } ( x | y _ { \mathrm { t e x t } } ) \underset { \sim } { \sim } \frac { p _ { \theta } ( x | ^ { \ast } \mathrm { A } \mathrm { h o r s e } ^ { \cdot \ast } ) \left[ \frac { 1 } { 2 } p _ { \theta } ( x | ^ { \ast } \mathrm { A } \mathrm { s a n d y } \mathrm { b e a c h } ^ { \cdot \ast } ) + \frac { 1 } { 2 } p _ { \theta } ( x | ^ { \ast } \mathrm { G r a s s } \mathrm { p l a i n s } ^ { \cdot \ast } ) \right] } { p _ { \theta } ( x | ^ { \ast } \mathrm { S u n n y } ^ { \prime } ) ^ { \alpha } }
240
+ $$
241
+
242
+ Liu et al. (2022) demonstrated that composing models this way can improve the efficacy of these kinds of generations, but was restricted to composition using classifier-free guidance. We train a
243
+
244
+ ![](images/2a15afd56676a0d2412690f421933cf678a1b434bcb3b129ab0f2d857d5a134b.jpg)
245
+ Figure 5: Energy based parameterization enables high-resolution compositional text-to-image synthesis.
246
+
247
+ energy-parameterized diffusion model for text conditional 64x64 image generation and illustrate composed results in Figure 5 (upsampled to $1 0 2 4 \mathrm { x } 1 0 2 4 ,$ ). We find that composition enables more faithful generations of scenes in Figure 6 with more results in Appendix A.
248
+
249
+ ![](images/a8563d2ff94e18860887b533bd40d910214c5ca2c2780232891039d74b2ddf8c.jpg)
250
+ Figure 6: Composing text descriptions enables more accurate scene generation.
251
+
252
+ # 6 DISCUSSION
253
+
254
+ Limitations. Our work demonstrates that diffusion models, in combination with MCMC-based sampling procedures, can be composed in novel ways capable of generating high-quality samples. However, our proposed solutions have a number of drawbacks. First, more sophisticated MCMC samplers come at a higher cost than the standard sampling approach and can take 5-times longer to generate samples than typical diffusion sampling. Second, we have shown that energy-parameterized models enable the use of more sophisticated sampling techniques, garnering further improvements. Unfortunately, this requires a second backward-pass through the model to compute the derivative implicitly, leading them to have double the memory and compute cost of score-parameterized models.
255
+
256
+ While these are considerable drawbacks, we note the focus of this work is to demonstrate that such things are possible within the framework of diffusion models. We believe there is much that can be done to achieve the benefits of our sampling procedures at less cost such as distillation (Salimans & Ho, 2022) and easier-to-differentiate neural networks (Chen & Duvenaud, 2019).
257
+
258
+ Finally we note that not all models can be effectively composed together. For example if we wanted to model the product of $\mathcal { N } ( - 1 0 , 1 ) \mathcal { N } ( 1 0 , 1 )$ , the resulting distribution’s support is far outside the support of the constituent models. To accurately model this, our constituent models would need to be near-perfect far outside the training distribution. Thus it is unlikely for good results to be obtained. The same care should be taken in the text-2-image setting with, for example, contradicting prompts.
259
+
260
+ Conclusion. In this work we have explored the ways that pretrained diffusion models can be composed to model new distributions. We demonstrate ways that na¨ıve implementations fail, and present two ways that performance can be improved: MCMC sampling and energy-parameterized diffusion models. We find our proposed methods lead to notable improvement across a variety of domains, scales, and different compositional operators.
261
+
262
+ # REFERENCES
263
+
264
+ Julian Besag. Comments on “Representations of knowledge in complex systems” by U. Grenander and MI Miller. J. Roy. Statist. Soc. Ser. B, 56(591-592):4, 1994. 3
265
+
266
+ Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale GAN training for high fidelity natural image synthesis. arXiv preprint arXiv:1809.11096, 2018. 1
267
+
268
+ 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. 1
269
+
270
+ Yuri Burda, Roger Grosse, and Ruslan Salakhutdinov. Accurate and conservative estimates of mrf log-likelihood using reverse annealing. In Artificial Intelligence and Statistics, pp. 102–110. PMLR, 2015. 7
271
+
272
+ Ricky TQ Chen and David K Duvenaud. Neural networks with cheap differential operators. Advances in Neural Information Processing Systems, 32, 2019. 9
273
+
274
+ Prafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat GANs on image synthesis. In Advances in Neural Information Processing Systems, 2021. 1, 4
275
+
276
+ Yilun Du and Igor Mordatch. Implicit generation and generalization in energy-based models. arXiv preprint arXiv:1903.08689, 2019. 3, 5, 18
277
+
278
+ Yilun Du, Shuang Li, and Igor Mordatch. Compositional visual generation with energy based models. Advances in Neural Information Processing Systems, 33:6637–6647, 2020a. 4, 5
279
+
280
+ Yilun Du, Shuang Li, Joshua Tenenbaum, and Igor Mordatch. Improved contrastive divergence training of energy based models. arXiv preprint arXiv:2012.01316, 2020b. 5
281
+
282
+ Simon Duane, Anthony D Kennedy, Brian J Pendleton, and Duncan Roweth. Hybrid Monte Carlo. Physics letters B, 195(2):216–222, 1987. 3
283
+
284
+ Alain Durmus and Eric Moulines. High-dimensional Bayesian inference via the unadjusted Langevin algorithm. Bernoulli, 25(4A):2854–2882, 2019. 6
285
+
286
+ Tomas Geffner and Justin Domke. MCMC variational inference via uncorrected Hamiltonian annealing. Advances in Neural Information Processing Systems, 34:639–651, 2021. 3
287
+
288
+ Will Grathwohl, Kuan-Chieh Wang, Jorn-Henrik Jacobsen, David Duvenaud, Mohammad Norouzi, ¨ and Kevin Swersky. Your classifier is secretly an energy based model and you should treat it like one. arXiv preprint arXiv:1912.03263, 2019. 5
289
+
290
+ Will Grathwohl, Jacob Jin Kelly, Milad Hashemi, Mohammad Norouzi, Kevin Swersky, and David Duvenaud. No MCMC for me: Amortized sampling for fast and stable training of energy-based models. In International Conference on Learning Representations, 2021. 5
291
+
292
+ 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. 8
293
+
294
+ Geoffrey E Hinton. Training products of experts by minimizing contrastive divergence. Neural Computation, 14(8):1771–1800, 2002. 1, 2, 4
295
+
296
+ Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022. 1, 4
297
+
298
+ Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020. 1, 20, 21
299
+
300
+ Robert A Jacobs, Michael I Jordan, Steven J Nowlan, and Geoffrey E Hinton. Adaptive mixtures of local experts. Neural Computation, 3(1):79–87, 1991. 1
301
+
302
+ Justin Johnson, Bharath Hariharan, Laurens Van Der Maaten, Li Fei-Fei, C Lawrence Zitnick, and Ross Girshick. Clevr: A diagnostic dataset for compositional language and elementary visual reasoning. In Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, pp. 2901–2910, 2017. 7
303
+
304
+ 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. 1
305
+
306
+ Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Remi Leblond, Tom ´ Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, et al. Competition-level code generation with alphacode. arXiv preprint arXiv:2203.07814, 2022. 1
307
+
308
+ Nan Liu, Shuang Li, Yilun Du, Josh Tenenbaum, and Antonio Torralba. Learning to compose visual relations. Advances in Neural Information Processing Systems, 34, 2021. 20
309
+
310
+ Nan Liu, Shuang Li, Yilun Du, Antonio Torralba, and Joshua B Tenenbaum. Compositional visual generation with composable diffusion models. arXiv preprint arXiv:2206.01714, 2022. 7, 8
311
+
312
+ Guy Mayraz and Geoffrey E Hinton. Recognizing hand-written digits using hierarchical products of experts. Advances in Neural Information Processing Systems, 13, 2000. 1
313
+
314
+ Radford M Neal. Monte Carlo implementation. In Bayesian Learning for Neural Networks, pp. 55–98. Springer, 1996. 3, 14, 15, 16
315
+
316
+ Radford M Neal. Annealed importance sampling. Statistics and Computing, 11(2):125–139, 2001. 6
317
+
318
+ Erik Nijkamp, Mitch Hill, Tian Han, Song-Chun Zhu, and Ying Nian Wu. On the anatomy of mcmc-based maximum likelihood learning of energy-based models. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 5272–5280, 2020. 3, 5, 18
319
+
320
+ Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022. 8
321
+
322
+ Gareth O Roberts and Richard L Tweedie. Exponential convergence of Langevin distributions and their discrete approximations. Bernoulli, pp. 341–363, 1996. 3, 6
323
+
324
+ 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. 1, 8
325
+
326
+ Tim Salimans and Jonathan Ho. Should ebms model the energy or the score? In Energy Based Models Workshop-ICLR 2021, 2021. 6, 18
327
+
328
+ Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. arXiv preprint arXiv:2202.00512, 2022. 9
329
+
330
+ Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pp. 2256–2265. PMLR, 2015. 1, 2
331
+
332
+ Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in Neural Information Processing Systems, 32, 2019. 1, 3, 6
333
+
334
+ 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. 5, 6, 17
335
+
336
+ Hongyi Zhang, Yann N Dauphin, and Tengyu Ma. Fixup initialization: Residual learning without normalization. arXiv preprint arXiv:1901.09321, 2019. 20
337
+
338
+ # Appendix
339
+
340
+ In this appendix, we present additional text-to-image results in Section A. We present detailed derivations of diffusion models in Section B. We present additional information on MCMC sampling in Section C.1. We provide additional derivations on composing diffusion models in Section D. We discuss different parameterizations of energy based diffusion models in Section E. We further provide additional example 2D compositions in Section F. Finally, we provide experimental details in Section G.
341
+
342
+ # A TEXT-TO-IMAGE RESULTS
343
+
344
+ We present additional use cases of composing models in different text-to-image domains. First, in Figure A1, we illustrate how composing two separate energy parameterized diffusion models enables us to more accurately generate images that have more detailed information in the caption. Next, in Figure A2, we illustrate how composing two separate energy parameterized diffusion models further enable us to accurately generate images with the correct colors assigned to each object. We further show in Figure A3 how composing the negation of one energy parameterized diffusion model with another other enables us to generate images where one commonly occurring co-founding factor does occur (i.e. a sandy beach without coastal water). Finally, we illustrate in Figure A4, how composing multiple diffusion models enables us to render the number of objects in a scene accurately.
345
+
346
+ ![](images/97c0bf123e3c015a3bcd1f74d6a3ba0c74f732c744e61cbde1a5ba54b67dc81b.jpg)
347
+ Figure A1: By composing energy based diffusion models, we can render more detailed information in images. In the above images, we can more accurately render details such as Central Park (top) or the effect of snowing (bottom).
348
+
349
+ ![](images/f487ea0a145e2d5a6ebb1381cab3f50126e5df4e2a2c547ab9d39ae4719bcd22.jpg)
350
+ Figure A2: By composing energy based diffusion models, we can more accurately render different colors of objects in a scene.
351
+
352
+ # B DETAILED DERIVATION OF DIFFUSION MODELS
353
+
354
+ Diffusion models seek to model a data distribution $q ( x _ { 0 } )$ (written this way for notational convenience) and define a series of latent variables $x _ { 1 } , \dots , x _ { T }$ generated from a Markov process $x _ { t } \sim q ( x _ { t } | x _ { t - 1 } )$ where
355
+
356
+ $$
357
+ q ( x _ { t } | x _ { t - 1 } ) = N \left( x _ { t } ; \sqrt { 1 - \beta _ { t } } x _ { t - 1 } , \beta _ { t } I \right) .
358
+ $$
359
+
360
+ A unique and useful property of this process is that all time marginals $q ( x _ { t } | x _ { 0 } )$ can be computed in closed form and are Gaussian
361
+
362
+ $$
363
+ q ( x _ { t } | x _ { 0 } ) = { \mathcal { N } } \left( x _ { t } ; { \sqrt { 1 - \sigma _ { t } ^ { 2 } } } x _ { 0 } , \sigma _ { t } ^ { 2 } I \right) .
364
+ $$
365
+
366
+ where $\sigma _ { t } ^ { 2 } = 1 - \bar { \alpha } _ { t }$ and $\begin{array} { r } { \bar { \alpha } _ { t } = \prod _ { t = 1 } ^ { T } ( 1 - \beta _ { t } ) } \end{array}$ . We can see that if all $\beta _ { t } ~ > ~ 0$ , then as $t \infty$ $q ( x _ { t } | x _ { 0 } ) { \overset { } { \to } } { \mathcal { N } } ( x _ { t } ; 0 , I )$ .
367
+
368
+ We seek to train a model $p _ { \theta } ( x _ { t - 1 } | x _ { t } )$ which reverses $q ( x _ { t } | x _ { t - 1 } )$ step-wise with a parametric model. We can analytically derive the variance of the reversal as $\begin{array} { r } { \tilde { \beta } _ { t } = \frac { 1 - \bar { \alpha } _ { t - 1 } } { 1 - \bar { \alpha } _ { t } } } \end{array}$ 1−α¯t−1 and define
369
+
370
+ $$
371
+ p _ { \theta } ( x _ { t } | x _ { t + 1 } ) = \mathcal { N } ( x _ { t } ; \mu _ { \theta } ( x _ { t - 1 } , t ) , \tilde { \beta } _ { t } I )
372
+ $$
373
+
374
+ and set $p ( x _ { T } ) = \mathcal { N } ( 0 , I )$ . We train this model to maximize a variational bound on the marginal likelihood
375
+
376
+ $$
377
+ \begin{array} { r l r } { { \log p _ { \theta } ( x _ { 0 } ) \geq { \mathbf E } _ { q ( x _ { 1 } , \dots , x _ { T } | x _ { 0 } ) } [ \log p _ { \theta } ( x _ { 0 } | x _ { 1 } ) + \sum _ { t = 1 } ^ { T } { D _ { K L } ( q ( x _ { t } | x _ { t - 1 } , x _ { 0 } ) | | p ( x _ { t } | | x _ { t - 1 } ) ) } } } \\ & { } & { + { D _ { K L } ( q ( x _ { T } | x _ { 0 } ) | | p ( x _ { T } ) ) } ] . } \end{array}
378
+ $$
379
+
380
+ ![](images/97483bdb0cce6ccf6854f297ede1fbe5b048eaf3ebdac470949060c514476bad.jpg)
381
+ Figure A3: By composing an energy parameterized diffusion model with the negation of another energy parameterized diffusion model, we can render images in unusual configurations not typically found in the data.
382
+
383
+ The first term lacks parameters and the final is approximately 0 from the convergence of the $q$ -process so we focus on the middle terms.
384
+
385
+ Typically, the model $\mu _ { \theta } ( x _ { t - t } , t )$ is not parameterized to predict the mean of $x _ { t }$ . Instead it is parameterized to predict the noise added to $x _ { t }$ to arrive at $x _ { t - 1 }$ . This motivates the following parameterization
386
+
387
+ $$
388
+ \mu _ { \theta } ( x _ { t } , t ) = \frac { 1 } { \sqrt { \alpha _ { t } } } \left( x _ { t } - \frac { \beta _ { t } } { \sqrt { 1 - \bar { \alpha } _ { t } } } \epsilon _ { \theta } ( x _ { t } , t ) \right) .
389
+ $$
390
+
391
+ In this form we can rewrite the important terms in the objective as
392
+
393
+ $$
394
+ D _ { K L } ( q ( x _ { t } | x _ { t - 1 } , x _ { 0 } ) | | p ( x _ { t } | | x _ { t - 1 } ) ) = - C _ { t } \mathbf { E } _ { q ( x _ { 0 } ) , N ( \epsilon ; 0 , I ) } \left[ | | \epsilon - \epsilon _ { \theta } ( x _ { t } , t ) | | ^ { 2 } \right] = C _ { t } \mathcal { L } ( x , \sigma )
395
+ $$
396
+
397
+ where $C _ { t }$ is a time-dependent constant. Typically these are dropped and all objectives are weighted equally.
398
+
399
+ Once we finish training, we can draw samples from our model by first sampling $x _ { T } \sim p ( x _ { T } )$ and then equentially sampling $x _ { t } = \mu _ { \theta } ( x _ { t - 1 } , t ) + \sqrt { \tilde { \beta } _ { t } } \epsilon$ where $\epsilon \sim \mathcal { N } ( 0 , I )$ .
400
+
401
+ # C MCMC SAMPLING DETAILS
402
+
403
+ # C.1 HAMILTONIAN MONTE-CARLO AND ITS VARIANTS
404
+
405
+ Hamiltonian Monte-Carlo (Neal, 1996) seeks to sample from an unnormalized probability distribution $\log p ( x ) = f ( x ) + \log Z$ . To do this, we augment our distribution over $x$ with auxillury variables $v$ and define the joint distribution $p ( x , v ) = p ( x ) \mathcal { N } ( v ; 0 , M )$ where the covariance $M$ is known as the “mass-matrix.” We now seek to draw samples $x , v \sim p ( x , v )$ and since $x$ and $v$ are independent under the joint, we can simply throw away our $v$ samples leaving us with a sample $x \sim p ( x )$ .
406
+
407
+ ![](images/33bfde1f9d20ade462b5cc2b09f14a0a4964f4a1e41214ab90a135b401948f6d.jpg)
408
+ Figure A4: By composing multiple energy parameterized diffusion models, we can more accurately render the underlying number of objects in ascene.
409
+
410
+ Like other MCMC methods we sequentially update a particle $( x ^ { i } , v ^ { i } )$ in such a way that as $i \to \infty$ we arrive at a sample from $p ( x , v )$ . For a step of HMC, starting at $( x ^ { i } , v ^ { i } )$ we first sample $v ^ { i \prime } \sim \mathcal { N } ( v ^ { i } ; 0 , M )$ since the target distribution factorizes and $p ( v )$ is known and tractable. We then integrate a likelihood-conserving ODE defined on $x , v$ known as “Hamiltoninan Dynamics.” We can use the likelihood-preserving leapfrog integrator which will guarentee that the transition distribution is symmetric, i.e $k ( x ^ { \prime } , v ^ { \prime } | \bar { x } , v ) ^ { \top } = \bar { k } ( x , v | \bar { x } ^ { \prime } , v ^ { \prime } )$ . Thus, the Metropolis acceptance probability simplifies to $\begin{array} { r } { \operatorname* { m i n } \left( 1 , \frac { p ( x ^ { \prime } , v ^ { \prime } ) } { p ( x , v ) } \right) } \end{array}$ . An overview of the HMC algorithm can be found in Algorithm 2. We refer the reader to Neal (1996) for a more complete description of the algorithm.
411
+
412
+ # Algorithm 2 Hamiltonian Monte-Carlo
413
+
414
+ <table><tr><td colspan="2">Input: Initial state x°,Mass matrix M, Number of steps N,Number leapfrog steps L,step-size ∈</td></tr><tr><td colspan="2">fori=1,...,N do</td></tr><tr><td>Sample vi ~ N(0, M)</td><td># Sample momentum</td></tr><tr><td>x&#x27;,uu =Leapfrog(xi-1, ,U²;,L)</td><td>#Integrate dynamics with stepsize e for L steps</td></tr><tr><td>α = min p(x,&#x27;) 1, p(xi-1,0)</td><td># Compute acceptance probability</td></tr><tr><td colspan="2">With probability a</td></tr><tr><td colspan="2"></td></tr><tr><td colspan="2">set xi= x&#x27;</td></tr><tr><td colspan="2">else</td></tr><tr><td colspan="2">set xi=xi-1</td></tr></table>
415
+
416
+ Since our $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ parameterized models do not admit an explicit likelihood function, we use an unadjusted variant of HMC (U-HMC) where the accept/reject step is simply ignored.
417
+
418
+ We can see in Algorithm 2 that at every step, the momentum is re-sampled. This can be sub-optimal, as the momentum determines the initial direction of $x$ ’s movement and if a good direction is found, it may be beneficial to continue in that direction. To deal with this, Neal (1996) proposes a variant of HMC where the momentum $v$ is partially retained between sampling steps. We add an additional sampler parameter $\gamma \in [ 0 , 1 ]$ (known as the “damping-factor”) which controls the amount to which $v$ is retained. When $\gamma$ is close to 1, $v$ is mostly kept and when it is near 0, $v$ is mostly refreshed. This variant is summarized in Algorithm 3. The potentially confusing momentum negations ensure the validity of the sampler. Intuitively, when the proposal is accepted, the momentum is retained and when it is rejected the momentum is flipped. For this reason, one should maintain a reasonably high acceptance rate when using this approch.
419
+
420
+ Algorithm 3 Hamiltonian Monte-Carlo with Partial Momentum Refreshment
421
+
422
+ <table><tr><td>damping-factor y</td><td>Input: Initial state xo,Mass matrix M,Number of steps N,Number leapfrog steps L,step-size</td></tr><tr><td>Sample v° ~ N(0, M)</td><td>#Sample initial momentum</td></tr><tr><td>for i= 1,...,N do</td><td></td></tr><tr><td>λ~ N(0,M)</td><td></td></tr><tr><td>u(i-1)&#x27;=γv-1+√1-γ²x</td><td>#Partially refresh momentum</td></tr><tr><td>x&#x27;,v&#x27;=Leapfrog(x𝑖-1,u(i-1)&#x27;;∈,L)</td><td># Integrate dynamics with stepsize εfor L steps</td></tr><tr><td>u&#x27;=-v&#x27; # Negate momentum</td><td></td></tr><tr><td>a = min (1, p(x&#x27;,u&#x27;)</td><td></td></tr><tr><td>p(xi-1,u(i-1)1))</td><td># Compute acceptance probability</td></tr><tr><td>With probability a</td><td></td></tr><tr><td>set xi= x&#x27;,v = U&#x27;</td><td></td></tr><tr><td>else</td><td></td></tr><tr><td>set xi= xi-1,v²= v(i-1)1</td><td></td></tr><tr><td></td><td></td></tr><tr><td>U²=-ui # Negate momentum</td><td></td></tr><tr><td>end for</td><td></td></tr><tr><td>xN</td><td></td></tr><tr><td>return</td><td></td></tr></table>
423
+
424
+ # C.2 MCMC TUNING
425
+
426
+ A crucial component to ensure successful MCMC sampling in diffusion models is the choice of step sizes for samplers. We initialize step sizes for all samplers at each distribution $t$ to be roughly proportional to the $\beta _ { t }$ noise values added to distribution $t$ in the diffusion process.
427
+
428
+ To tune step sizes across timesteps for both HMC and MALA samplers, to set step sizes at each timestep $t$ to be constant multiplied by $\beta _ { t }$ . We searched different constants to multiply $\beta _ { t }$ , and chose a value so that the average acceptance rate of MALA and HMC samplers across timesteps is approximately $60 \%$ and $70 \%$ respectively. For un-adjusted variants of these samplers, we set step sizes to be the same as adjusted samplers, and found limited gains when step sizes were specifically tuned towards the un-adjusted samplers. We utilize a mass matrix of $\beta _ { t }$ for HMC samplers.
429
+
430
+ Precise details on the exact MCMC steps sizes used in experiments can be detailed in Section G.
431
+
432
+ # C.3 MCMC IMPLEMENTATION DETAILS
433
+
434
+ When initially running MCMC sampling on diffusion models in the image domain, we found that our samplers tended to converge to images which had uniform textures. After experimentation, we found that the primary cause of this issue was fact that by default, typical implementations of the reverse diffusion process clip samples at intermediate time-steps of sampling to be between $^ { - 1 }$ and 1. To enable proper MCMC sampling, we found that it was important to not clip intermediate values of diffusion sampling.
435
+
436
+ When running MCMC sampling on image domains, we further found that it was helpful for mixing to run a single step of the reverse process to initialize MCMC sampling, before running many steps of MCMC sampling at each timestep $t$ , and in all MCMC sampling settings on the image domain, we run one step of the reverse process before running MCMC sampling. Such a MCMC sampling procedure is similar to the predictor-corrector sampling procedure introduced in (Song et al., 2021) for alleviating discretization errors when sampling continuous time diffusion models.
437
+
438
+ # D COMPOSITIONAL DIFFUSIONS
439
+
440
+ In Equations 11 and 12, we demonstrate that for diffused distributions $\{ q _ { t } ^ { i } ( x _ { t } ) \}$ where $q _ { t } ^ { i } ( x _ { t } ) =$ $\begin{array} { r } { \int q ^ { i } ( \overline { { x } } _ { 0 } ) q ( x _ { t } | x _ { 0 } ) d x _ { 0 } } \end{array}$ , the diffusion of the product of $q ^ { i }$ ’s is not the same as the product of the diffusions, meaning plugging the product of diffusions into standard reverse diffusion sampling will not draw samples from the product model. We present similar results for tempering and predictive model composition.
441
+
442
+ D.1 SAMPLING FROM A TEMPERED VERSION OF $q$ USING DIFFUSION?
443
+
444
+ It is tempting to believe that we can sample from a tempered/annealed version of the data distribution
445
+
446
+ $$
447
+ q ^ { \lambda } ( x ) \propto q ( x ) ^ { \lambda }
448
+ $$
449
+
450
+ using the tempered diffused data distribution $\lambda \nabla \log _ { t } q ( x _ { t } )$ but this is incorrect. For this procedure to be correct, we would need to have $\nabla \log q _ { t } ^ { \lambda } ( x _ { t } ) = \lambda \nabla \log q _ { t } ( x _ { t } )$ for all $t$ . However, while we do have $\nabla \log q _ { 0 } ^ { \lambda } ( { x } _ { 0 } ) = \lambda \nabla \log q _ { 0 } ( { x } _ { 0 } )$ , this equality does not hold for $t > 0$
451
+
452
+ $$
453
+ \begin{array} { l c l } { \nabla \log q _ { t } ^ { \lambda } ( x _ { t } ) } & { = } & { \nabla \log \displaystyle \int q ^ { \lambda } ( x _ { 0 } ) q ( x _ { t } | x _ { 0 } ) d x _ { 0 } } \\ & { \nmid } & { \nmid } \\ & { \nmid } & { \times \mathrm { ~ \lambda ~ } \nabla \log \displaystyle \int q ( x _ { 0 } ) q ( x _ { t } | x _ { 0 } ) d x _ { 0 } } \\ & { = } & { \lambda \nabla \log q _ { t } ( x _ { t } ) . } \end{array}
454
+ $$
455
+
456
+ # D.2 GUIDANCE
457
+
458
+ For conditional generation, we should use in the reverse diffusion the score of the diffused conditional distribution $\nabla \log q _ { t } ( x _ { t } | y )$ where
459
+
460
+ $$
461
+ q _ { t } ( x _ { t } | y ) = \int q ( x _ { 0 } | y ) q ( x _ { t } | x _ { 0 } ) d x _ { 0 } .
462
+ $$
463
+
464
+ We also have
465
+
466
+ $$
467
+ \nabla \log q _ { t } ( x _ { t } | y ) = \nabla \log q _ { t } ( x _ { t } ) + \nabla \log q _ { t } ( y | x _ { t } )
468
+ $$
469
+
470
+ so that
471
+
472
+ $$
473
+ \nabla \log q _ { t } ( y | x _ { t } ) : = \nabla \log q _ { t } ( x _ { t } | y ) - \nabla \log q _ { t } ( x _ { t } )
474
+ $$
475
+
476
+ allows you to do guidance without having to train say a classifier if $y$ is categorical.
477
+
478
+ In practice, it was found that using in the reverse time diffusion the score
479
+
480
+ $$
481
+ \nabla \log q _ { t } ( x _ { t } ) + \lambda \nabla \log q _ { t } ( y | x _ { t } )
482
+ $$
483
+
484
+ generates much nicer images for $\lambda > 1$ . However, it is also often claimed that it samples from a modified posterior where the likelihood has been annealed. This is incorrect. For a modified posterior with annealed likelihood, we would have
485
+
486
+ $$
487
+ q ^ { \lambda } ( x _ { 0 } | y ) \propto q ( x _ { 0 } | y ) \left\{ q ( y | x _ { 0 } ) \right\} ^ { \lambda }
488
+ $$
489
+
490
+ and it is not true again that
491
+
492
+ $$
493
+ \begin{array} { r c l } { \nabla \log q _ { t } ^ { \lambda } ( x _ { t } | y ) } & { = } & { \nabla \log \displaystyle \int q ^ { \lambda } ( x _ { 0 } | y ) q ( x _ { t } | x _ { 0 } ) d x _ { 0 } } \\ & { \neq } & { \nabla \log q _ { t } ( x _ { t } ) + \lambda \nabla \log q _ { t } ( y | x _ { t } ) . } \end{array}
494
+ $$
495
+
496
+ # D.3 SAMPLING FROM COMPOSED DISTRIBUTIONS
497
+
498
+ We can see that products, tempering, and guidance applied to diffused distributions do not give diffusions of the modified target distributions. Thus, we should not expect to arrive at our desired result by applying a sampling procedure which reverses a diffusion applied to the target distribution. Thankfully, as stated in Section 4, these operators do give us a sequence of distributions which anneals from $\mathcal { N } ( 0 , I )$ to the composed target which means we can utilize the family of annealed MCMC sampling methods mentioned in Section 4.1 to draw samples from our composed models in all of these settings, directly using the available score estimate.
499
+
500
+ # E ENERGY-BASED PARAMETERIZATIONS
501
+
502
+ As mentioned in section 4.2, when using the $\epsilon _ { \theta } ( x , t )$ parameterization, we can recover an estimate of the time-conditional score function with $\begin{array} { r } { \nabla _ { \boldsymbol { x } } \log p _ { t } ( \boldsymbol { x } ) \approx - \frac { \epsilon _ { \theta } ( \boldsymbol { x } , t ) } { \sigma _ { t } } } \end{array}$ . This estimate of the log-likelihood gradient can be used for MCMC sampling methods which only require the log-likelihood gradient – such as ULA or U-HMC. These methods can work well, but will never generate exact samples when using non-zero step-sizes. Exact samplers can be derived from approximate samplers like the above methods using Metropolis corrections. Unfortunately, even if the samplers’ transition distribution $k _ { i } ( \cdot , \cdot )$ does not require $\log p _ { \theta } ( x _ { t } )$ evaluation, the Metropolis correction probability:
503
+
504
+ $$
505
+ \operatorname* { m i n } \left( 1 , \frac { e ^ { f _ { \theta } ( \hat { x } ) } } { e ^ { f _ { \theta } ( x _ { t - 1 } ) } } \frac { k ( x _ { t - 1 } | \hat { x } ) } { k ( \hat { x } | x _ { t - 1 } ) } \right)
506
+ $$
507
+
508
+ does. Futhermore, when we only have an estimate of the score at our disposal, we are only able to compose models using products.
509
+
510
+ To enable the use of Metropolis corrections and more compositional operators, we propose to change the parameterization of our diffusion model. Instead of using a neural net $\epsilon _ { \theta } ( x , t ) : \bar { \{ \mathbb { R } ^ { d } \times \mathbb { N } \} } \to \bar { \mathbb { R } ^ { d } }$ , we define a scalar-output neural network $f _ { \theta } ( x , t ) : \{ \mathbb { R } ^ { d } \times \bar { \mathbb { N } } \} \mathbb { R }$ . We then compute the gradient of this function and define $\epsilon _ { \theta } ( x , t ) = \nabla _ { x } f _ { \theta } ( x , t )$ . From here, we use this implicitly-defined $\epsilon _ { \theta } ( x )$ as in standard diffusion modeare also able to recover recover which $\begin{array} { r } { \nabla _ { \boldsymbol { x } } \log p _ { t } ( \boldsymbol { x } ) \approx - \frac { \epsilon _ { \theta } ( \boldsymbol { x } , t ) } { \sigma _ { t } } } \end{array}$ , but now wef Metropolis $\begin{array} { r } { \log p _ { t } ( x ) \approx - \frac { f _ { \theta } ( x , t ) } { \sigma _ { t } } + \log Z } \end{array}$
511
+ corrected sampling.
512
+
513
+ Much prior work on EBMs parameterizes $f _ { \boldsymbol { \theta } } ( x , t )$ using a feed-forward neural network, whose final layer has a single output (Nijkamp et al., 2020; Du & Mordatch, 2019). Salimans & Ho (2021) compare this approach with the standard $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ parameterization and find the $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ parameterization to perform better for unconditional image generation. We believe this has to do with the relative sparsity of the gradients of feed-forward neural networks. This can cause difficulties when training to optimize a function of their implicitly computed gradients.
514
+
515
+ Intriguingly, Salimans & Ho (2021) also explore a more structured energy function definition inspired by denoising autoencoders:
516
+
517
+ $$
518
+ f _ { \theta } ^ { D A E } ( x , t ) = - \frac { 1 } { 2 } \vert \vert x - s _ { \theta } ( x , t ) \vert \vert ^ { 2 }
519
+ $$
520
+
521
+ where $s _ { \theta } ( x , t ) : \{ \mathbb { R } ^ { d } \times \mathbb { N } \} \to \mathbb { R } ^ { d }$ is a neural network (identical to the standard $\epsilon _ { \theta } ( x , t ) )$ ) model. We can simply evaluate the gradients of this function to obtain
522
+
523
+ $$
524
+ \nabla _ { x } f _ { \theta } ^ { D A E } ( x , t ) = ( x - s _ { \theta } ( x , t ) ) - ( x - s _ { \theta } ( x , t ) ) \nabla _ { x } s _ { \theta } ( x , t ) .
525
+ $$
526
+
527
+ In their study, this parameterization was found to perform near identically to the $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ parameterization while admitting an explicit energy function. We believe this energy parameterization performs better because its gradients include the feed-forward network $s _ { \theta } ( x , t )$ , making optimization easier. Salimans & Ho (2021) conclude that the $\boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \boldsymbol { x } , t )$ parameterization should be favored since the computing $\nabla _ { x } f _ { \theta } ^ { D A E } ( x , t )$ requires computing $\nabla s _ { \theta } ( x , t )$ which requires an extra backward pass through the neural network, increasing compute.
528
+
529
+ We reexamine this energy parameterization and two other choices now that our application motivates having access to an explicit energy function. The other parameterizations are based different transformations of the $s _ { \theta } ( x , t )$ architecture; the negative L2 norm (L2) and an inner product (IP). They are
530
+
531
+ defined as:
532
+
533
+ $$
534
+ \begin{array} { r c l } { { f _ { \theta } ^ { L 2 } ( x , t ) } } & { { = } } & { { \displaystyle - \frac { 1 } { 2 } | | s _ { \theta } ( x , t ) | | ^ { 2 } } } \\ { { \nabla _ { x } f ^ { L 2 } ( x , t ) } } & { { = } } & { { \displaystyle - s _ { \theta } ( x , t ) \nabla _ { x } s _ { \theta } ( x , t ) } } \end{array}
535
+ $$
536
+
537
+ and:
538
+
539
+ $$
540
+ \begin{array} { r c l } { { f _ { \theta } ^ { I P } ( x , t ) } } & { { = } } & { { { x ^ { T } s _ { \theta } ( x , t ) } } } \\ { { \nabla _ { x } f ^ { I P } ( x , t ) } } & { { = } } & { { s _ { \theta } ( x , t ) + x ^ { T } \nabla _ { x } s _ { \theta } ( x , t ) . } } \end{array}
541
+ $$
542
+
543
+ We train models with each parameterization on ImageNet and compare using FID for unconditional sampling. Results can be seen in Table A1. We see that L2 and Inner-Product perform the best, but are both outperformed by the standard parameterization. We initially experimented with these two parameterizations but found that the L2-norm parameterization to be more stable for compositional sampling due, we believe, to the fact that the energy-function is bounded above meaning that MCMC sampling is incapable of running off to infinity to increase likelihood.
544
+
545
+ Table A1: FID (1k samples) of various energy-parameterizations on unconditional ImageNet generation.
546
+
547
+ <table><tr><td colspan="3">Parameterization ∈θ(x,t)</td></tr><tr><td>(1) DAE 97.4</td><td>(2)L2 Norm 91.5</td><td>(3) Inner-Product | 90.9 86.7</td></tr></table>
548
+
549
+ # F SYNTHETIC DISTRIBUTION COMPOSITIONS
550
+
551
+ Mixture We provide additional 2D illustrations of mixtures of two diffusion models in Figure A5.
552
+ We find that HMC sampling enables more accurate mixtures of different synthetic distributions.
553
+
554
+ ![](images/338e6c6a7dd7c357631290644720c829e3d176fbbd00a5a22297c26173aa4e08.jpg)
555
+ Figure A5: Examples of mixture applied to diffusion models. Left to right: Component distributions, reverse diffusion, HMC sampling. Reverse diffusion fails to sample accurately from mixed distributions distributions.
556
+
557
+ Negation We provide additional 2D illustrations of negating two diffusion model with respect to each other in Figure A7. We find that HMC sampling enables accurate negations of different sythetic distributions.
558
+
559
+ ![](images/55963e4abfacce6fab91050a8f0316825523a8bdca454b6206986a0879a3b063.jpg)
560
+ Figure A6: Examples of negation applied to diffusion models. Left to right: Component distributions, reverse diffusion, HMC sampling. Reverse diffusion fails to sample accurately from negated distributions.
561
+
562
+ Failure Cases Next we illustrate a failure case of composition using our approach in Figure A7. Our approach fails to generate the product of two distribution when they are disjoint with respect to each other.
563
+
564
+ ![](images/29b13b8e41f9d2f5bb30dd2e97dc196d72cbe5f8948aea267dae7ef8bf47a6ad.jpg)
565
+ Figure A7: Failure Cases of Our Approach. Left to right: Component distributions, reverse diffusion, HMC sampling. Our approach fails to generate products of distributions with no overlap.
566
+
567
+ # G EXPERIMENTAL DETAILS
568
+
569
+ We provide detailed experimental details including underlying quantitative metrics, training details, and architectures on 2D synthetic, CLEVR, ImageNet, and test-to-image settings below. To enable stable training of energy-based diffusion models in image settings, we clip gradient norms to be less than 10, and initialize convolutional layers using zero-initialization (Zhang et al., 2019).
570
+
571
+ Synthetic Datasets For synthetic datasets, we train both score and energy based diffusion models using a small residual MLP model with 4 residual blocks, with a internal hidden dimension of 128 dimensions. We train models for 15000 iterations (10 minutes on a 8 TPUv2 cores) using the Adam optimizer with learning rate of 1e-3, and train diffusion models on 100 discrete timesteps with linear schedule of $\beta$ values.
572
+
573
+ When evaluating product of diffusion models, we generate two separate distributions, where train two separate diffusion models. In our first distribution, we construct a GMM of 8 Gaussians in a ring of radius 0.5 around the origin, with each Gaussian having a standard deviation of 0.3. In our second dataset, we construct a uniform distribution of points with $x$ between -0.1 and 0.1 and $y$ between -1 and 1. When evaluating mixture diffusion models, we generate one distribution consisting of a mixture of 3 Gaussian with standard deviation 0.03 and centers at $\left( - 0 . 2 5 , 0 . 5 \right)$ , $( - 0 . 2 5 , 0 . 0 )$ , $\left( - 0 . 2 5 , - 0 . 5 \right)$ , and another distribution consisting of a mixture of 3 Gaussian with standard deviation 0.03 and centers at (0.25, 0.5), (0.25, 0.0), (0.25, −0.5).
574
+
575
+ To construct MCMC samplers from models on synthetic datasets, we run 3 steps of HMC per timestep, with 3 leapfrog steps per step of HMC. We run 10 steps of MALA sampling per timestep. We found that MCMC performed robustly in the 2D dimensional setting and set the step size of MALA to be 0.002 across all distributions and the step size of HMC to be 0.03 across all distributions (with a mass matrix of 1)
576
+
577
+ CLEVR For CLEVR, we generated a dataset of $2 0 0 , 0 0 0 \ 6 4 \times 6 4$ images with between 1 to 5 different cubes using dataset generation code in (Liu et al., 2021). To evaluate the accuracy in which generated images had cubes at each specified position, we trained a binary classifier on these images, and marked a cube as correctly generated if the confidence of the binary confidence of classifier is greater than 0.5.
578
+
579
+ To parameterize our diffusion architecture, we follow the architecture of (Ho et al., 2020), where we use a base hidden dimension of 128, and multiply the hidden dimensions by [1, 2, 3, 4] at different resolutions of the image. We utilize 3 residual blocks at each resolution of the image. We trained diffusion models with 100 discrete timesteps with a linear $\beta$ schedule. CLEVR models were trained for 20000 iterations with a batch size of 1024 using the Adam optimizer with step size 1e-4, corresponding to roughly 8 hours on 8 TPUv2 cores.
580
+
581
+ To initialize MCMC sampling on the CLEVR domain, at each timestep, before applying MCMC sampling, we run one step of the reverse process in the trained diffusion model. We run 40 steps of MCMC sampling per timestep for MALA samplers, and 13 steps of HMC sampling (with 3 leapfrog step per HMC step) (with the mass matrix of HMC samplers set to $\beta$ ). We use HMC with partial momentum refreshment, and use a dampening coefficient of 0.9 across HMC iterations. MALA step sizes are set to $0 . 0 3 5 * \beta _ { t }$ , and HMC step sizes are set to $0 . 1 * \beta _ { t }$
582
+
583
+ ImageNet For ImageNet, we train an unconditional diffusion model $1 2 8 \times 1 2 8$ images. We train diffusion models for 1 million iterations of ImageNet with a batch size of 64 (3 days on 16 TPUv2 cores), using Adam optimizer with learning rate 1e-4, for 1 million iterations. We train diffusion models with 1000 discrete timesteps using the
584
+
585
+ On the ImageNet dataset, we report three seperate metrics. To report classifier accuracy, we feed generated sample into a ImageNet classifier trained on clean images, and label a image as correctly generated if the classifier of a generated image having the specified class is greater than $50 \%$ . We further report the Inception Score and FID, which are calculated on 50000 generated samples.
586
+
587
+ We follow the architecture of (Ho et al., 2020), where we use a base hidden dimension of 128 and multiply the hidden dimensions by $[ 1 , 1 , 2 , 3 , 4 ]$ at the different resolution of the image. We utilize 2 residual blocks at each resolution of the image.
588
+
589
+ To initialize MCMC sampling on the ImageNet domain, at each timestep, before applying MCMC sampling, we run one step of the reverse process in the trained diffusion model. We run 6 steps of MCMC sampling per timestep for MALA samplers, and 2 steps of HMC sampling (with 3 leapfrog steps per HMC step and with the mass matrix of HMC samplers set to $\beta$ ). MALA step sizes are set to $0 . 5 * \beta _ { t }$ , and HMC step sizes are set to $0 . 6 * \beta _ { t } ^ { 1 }$ .5
590
+
591
+ Text-to-Image For text-to-image models, we train models for one week on an internal text/image dataset consisting of 400 million images using 32 TPUv3 cores, with a training data batch size of 256. We train our energy-based text-to-image model using a total of 1000 timesteps with a cosine beta schedule. We follow the architecture of (Ho et al., 2020), where we use a base hidden dimension of 256, and multiply the hidden dimensions by $[ 1 , 2 , 3 , 4 ]$ at different resolution of the image. We utilize 3 residual blocks at each resolution of the image.
592
+
593
+ To upsample images from $6 4 \times 6 4$ resolution to $1 0 2 4 \times 1 0 2 4$ resolution, we utilize two trained unconditional diffusion models, one trained to upsample from $6 4 \times 6 4$ resolution to $2 5 6 \times 2 5 6$ resolution and one trained to upsample from $2 5 6 \times 2 5 6$ resolution to $1 0 2 4 \times 1 0 2 4$ resolution.
594
+
595
+ To initialize MCMC sampling on the text-to-image domain, at each timestep, before applying MCMC sampling, we run one step of the reverse process in the trained diffusion model. We ran 2 steps of HMC sampling per timestep, with 3 leapfrog step per HMC step and a mass matrix of HMC samplers set to $\beta$ ). We use HMC with partial momentum refreshment, and use a dampening coefficient of 0.9 across HMC iterations. HMC step sizes are set to $0 . 1 * \beta _ { t }$
md/dev/T__V3uLix7V/T__V3uLix7V.md ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # REGIONVIT: REGIONAL-TO-LOCAL ATTENTION FOR VISION TRANSFORMERS
2
+
3
+ Chun-Fu (Richard) Chen, Rameswar Panda, Quanfu Fan MIT-IBM Watson AI Lab chenrich@us.ibm.com, rpanda@ibm.com, qfan@us.ibm.com
4
+
5
+ # ABSTRACT
6
+
7
+ Vision transformer (ViT) has recently shown its strong capability in achieving comparable results to convolutional neural networks (CNNs) on image classification. However, vanilla ViT simply inherits the same architecture from the natural language processing directly, which is often not optimized for vision applications. Motivated by this, in this paper, we propose a new architecture that adopts the pyramid structure and employ novel regional-to-local attention rather than global self-attention in vision transformers. More specifically, our model first generates regional tokens and local tokens from an image with different patch sizes, where each regional token is associated with a set of local tokens based on the spatial location. The regional-to-local attention includes two steps: first, the regional self-attention extracts global information among all regional tokens and then the local self-attention exchanges the information among one regional token and the associated local tokens via self-attention. Therefore, even though local self-attention confines the scope in a local region but it can still receive global information. Extensive experiments on four vision tasks, including image classification, object and keypoint detection, semantics segmentation and action recognition, show that our approach outperforms or is on par with state-of-the-art ViT variants including many concurrent works. Our source codes and models are available at https://github.com/IBM/RegionViT.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Transformers (Vaswani et al., 2017) based on self-attention come naturally with the ability to learn long-range dependencies in sequential data. As important as it is to language modeling (Devlin et al., 2019), such ability is also highly desired for many vision tasks where contextual modeling plays a significant role. For this reason, self-attention and transformers have been receiving an increasing attention in the vision community (Bello, 2021; Srinivas et al., 2021; Zhao et al., 2020; Ramachandran et al., 2019a; Bello et al., 2019; Hu et al., 2019; Ramachandran et al., 2019b; Wang et al., 2018). Especially, the recent Vision Transformers (ViT) (Dosovitskiy et al., 2021) demonstrates comparable image classification results against the firmly established and prevalent CNNs in computer vision (He et al., 2016; Tan & Le, 2019; Brock et al., 2021), albeit relying on a huge amount of training data. It has since then led to an explosion of interest in further investigating its potential for a wide variety of vision applications (Wu et al., 2021; Wang et al., 2021; Heo et al., 2021; Zhang et al., 2021a; Li et al., 2021; Graham et al., 2021; Liu et al., 2021; Chu et al., 2021a; Yan et al., 2021; Chen et al., 2021b).
12
+
13
+ The ViT inherits the entire architecture from the vanilla transformer (Vaswani et al., 2017), which is designed for natural language processing tasks, and some of those designs thus may not meet the needs of vision tasks. For example, the transformer has an isotropic network structure with a fixed number of tokens and unchanged embedding size, which loses the capability to model the context with different scales and allocates computations at different scales. As opposed to this, a majority of CNNs adopt a popular pyramid architecture to compute multi-scale features efficiently. Recent vision transformers such as PVT (Wang et al., 2021) and PiT (Heo et al., 2021) also follow a similar pyramid structure as CNNs, showing improvement on both computation and memory efficiency as well as on model accuracy. Another critical bottleneck of the transformer is that the self-attention module has a quadratic cost in memory and computation with regard to the sequence length (i.e., the number of tokens). This issue is even worse in ViT as images are 2-D, suggesting a quadratic relationship between the number of tokens and image resolution. As a result, ViT indicates a quadruple complexity w.r.t image resolution. The highly compute- and memory-intensive self-attention makes it challenging to train vision transformer models at fine-grained patch sizes. It also significantly undermines the applications of these models to tasks such as object detection and semantic segmentation, which benefit from or require fine feature information computed from high-resolution images.
14
+
15
+ To address the aforementioned computational limitations of vision transformers, in this work, we develop a memoryfriendly and efficient self-attention method for transformer models to reach their promising potential for vision applications. We propose a novel coarse-to-fine mechanism to compute self-attention in a hierarchical way. Specifically, our approach first divides the input image into a group of non-overlapping patches of large size (e.g., $2 8 \times 2 8 )$ ), on which regional tokens are computed via linear projection. Similarly, local tokens are created for each region using a smaller patch size (e.g., $4 \times 4 )$ . We then use a standard transformer to process regional and local tokens separately. To enable communication between the two types of tokens, we first perform self-attention on regional tokens (regional attention) and then jointly attend to the local tokens of each region including their associated regional token (local attention). By doing so, regional tokens pass global contextual information to local tokens efficiently while being able to effectively learn from local tokens themselves. For clarity, we represent this two-stage attention mechanism as Regional-to-Local Attention, or $R 2 L$ attention for short (see Figure 1 for an illustration). Since both regional and local attention involve much fewer tokens, our R2L attention requires substantially less memory than regular global self-attention used in vision transformers. For example, in our default setting, the memory saving using
16
+
17
+ ![](images/be438c75eaab31cb96439f283128309a198fe8950d097322f0c0e7274132054b.jpg)
18
+ Figure 1: Regional-to-Local Attention for Vision Transformers. (a) ViT uses a fixed patch size through the whole network, (b) PVT adopts a pyramid structure to gradually enlarge the patch size in the network. Both ViT and PVT uses all tokens in self-attention, which are computationaland memory-intensive. (c) Our proposed approach combines a pyramid structure with an efficient regional-to-local (R2L) attention mechanism to reduce computation and memory usage. Our approach divides the input image into two groups of tokens, regional tokens of large patch size (red) and local ones of small patch size (black). The two types of tokens communicate efficiently through R2L attention, which jointly attends to the local tokens in the same region and the associated regional token. Note that the numbers denote the patch sizes at each stage of a model.
19
+
20
+ R2L attention can be up to as much as $73 \%$ . We demonstrate the effectiveness of our approach on image classification and several downstream vision tasks including object detection and action recognition.
21
+
22
+ To summarize, our key contributions in this work are as follows:
23
+
24
+ 1. We propose a new vision transformer (RegionViT) based on regional-to-local attention to learn both local and global features. Our proposed regional-to-local attention alleviates the overhead of standard global attention (too many tokens) and the weakness of pure local attention (no interaction between regions) used in existing vision transformers.
25
+ 2. Our regional-to-local attention reduces the memory complexity significantly as compared to standard self-attention, leading to a savings in memory complexity by about $\dot { \mathcal { O } } ( N / M ^ { 2 } )$ , where $M$ is the window size of a region and $N$ is the total number of tokens. This effectively allows us to train a more deep network for better performance while with comparable complexity.
26
+ 3. Our models outperform or on par with several concurrent works on vision transformer that exploit pyramid structure for image classification. Experiments also demonstrate that our models work well on several downstream classification tasks, including object detection and action recognition.
27
+
28
+ # 2 RELATED WORK
29
+
30
+ CNNs with Attention. Attention has been widely used for enhancing the features in CNNs, e.g., SENet (Hu et al., 2018) and CBAM (Woo et al., 2018). Various methods have been proposed that combine self-attention with CNNs (Bello, 2021; Srinivas et al., 2021; Zhao et al., 2020; Ramachandran et al., 2019a; Bello et al., 2019; Hu et al., 2019; Ramachandran et al., 2019b; Wang et al., 2018). E.g., SAN (Zhao et al., 2020) and SASA (Ramachandran et al., 2019a) attempts to replace all convolutional layers with local self-attention network. While these works show promising results, their complexity is relatively high due to the self-attention. On the other hand, BoTNet (Srinivas et al., 2021) replaces few convolutional layers with a slightly-modified self-attention to balance computation and accuracy. LambdaNet work (Bello, 2021) uses the approximated self-attention to reduce the overhead of selfattention and make the network efficient. Few works use attention approach to define the regional of interest for the fine-grained visual recognition (Zheng et al., 2020; Ding et al., 2021; Wharton et al., 2021). In contrast, our model utilizes regional-to-local attention to alleviate the workload of global self-attention by local attention while still keeping the global information via regional attention.
31
+
32
+ Table 1: Comparison to related works. Most works use non-overlapped windows to group tokens, and then propose the corresponding methods to assure the information exchange among regions.
33
+
34
+ <table><tr><td>Methods</td><td>Structure</td><td>Attention Types</td><td>Windows of Local Attention</td><td>Handling Non-overlapped Regions</td><td>Global Tokens</td></tr><tr><td>ViT (Dosovitskiy et al.,2021)</td><td>Isotropic</td><td>Global</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>PVT (Wang et al., 2021)</td><td>Pyramid</td><td>Global</td><td>N/A</td><td>N/A</td><td>N/A</td></tr><tr><td>Swin (Liu et al.,2021)</td><td>Pyramid</td><td>Local</td><td>Strictly Non-overlapped</td><td>Shifting the window</td><td>None</td></tr><tr><td>ViL (Zhang et al., 2021a)</td><td>Pyramid</td><td>Local + Global</td><td>Overlapped</td><td>N/A1</td><td>One learnable token</td></tr><tr><td>Twins (Chu et al., 2021a)</td><td>Pyramid</td><td>Local + Global</td><td>Non-overlapped</td><td>GA</td><td>Subsampled from local tokens</td></tr><tr><td>RegionViT (Ours)</td><td>Pyramid</td><td>Local + Regional</td><td>Non-overlapped</td><td>Regional-to-local attention</td><td>Regional tokens</td></tr></table>
35
+
36
+ GA: global attention. 1 : not applicable as ViL used overlapped windows.
37
+
38
+ Vision Transformer. ViT (Dosovitskiy et al., 2021) has recently achieved comparable results to CNNs when using a huge amount of data, e.g., JFT300M (Sun et al., 2017). DeiT (Touvron et al., 2020; Wightman, 2019) subsequently proposes an efficient training scheme that allows vision transformer to work on par with CNNs while training only on ImageNet1K (Deng et al., 2009). Despite promising performance of ViT, the architecture is directly borrowed from natural language processing, which might not be suitable for vision applications. Motivated by this, two main line of research works have been developed to improve ViT. One is to enhance different components of the vision transformer (Yuan et al., 2021; Han et al., 2021; Touvron et al., 2021; Jiang et al., 2021) while still using isotropic structure (i.e., fixed token numbers and channel dimension) like ViT, e.g., while T2T-ViT (Yuan et al., 2021) introduces a Tokens-to-Token (T2T) transformation to encode local structure for each token, CrossViT propose a dual-path architecture, each with different scales, to learn multi-scale features (Chen et al., 2021a). CaiT (Touvron et al., 2021) proposes a layer-scalar to train a deeper network for better performance and LV-ViT (Jiang et al., 2021) modified how the model is trained when CutMix (Yun et al., 2019) augmentation is applied on ViT. Another parallel thread for improving vision transformer is in incorporating CNN-like pyramid structure into ViT (Wu et al., 2021; Wang et al., 2021; Heo et al., 2021; Zhang et al., 2021a; Li et al., 2021; Graham et al., 2021; Liu et al., 2021; Chu et al., 2021a; Yan et al., 2021; Chen et al., 2021b). PVT (Wang et al., 2021) and PiT (Heo et al., 2021) introduce the pyramid structure into ViT, which makes them more suitable for objection detection as it can provide multi-scale features. LocalViT (Li et al., 2021) and ConT (Yan et al., 2021) mix convolutions with self-attention to encode locality information. Swin (Liu et al., 2021), ViL (Zhang et al., 2021a) and Twins (Chu et al., 2021a) limited the self-attention into a local region and then propose different methods to allow the interaction among each local region. Our model also utilizes pyramid structure and limits the self-attention in a local region; while we propose the regional-to-local attention to exchange the information among each region efficiently.
39
+
40
+ Difference from PVT, Swin, ViL and Twins. Table 1 summarizes the difference between our proposed approach, RegionViT with the closely related works. PVT (Wang et al., 2021) uses pyramid structure but the scope of self-attention is still global. While ViL (Zhang et al., 2021a) limits self-attention into a local region, they adopt overlapping windows as convolutions to process all the tokens. On the other hand, Swin (Liu et al., 2021), Twins (Chu et al., 2021a) and ours adopt non-overlapped windows. While Swin shifts the position of windows alternatively in the consecutive transformer encoder to allow the interaction between regions, Twins subsamples local tokens as the global tokens, and then use the global tokens as the keys for self-attention to achieve the interaction between regions. By contrast, our proposed method utilizes a extra set of regional tokens with regional-to-local attention to perform self-attention on regional tokens only for the global information and then each regional token is sent to the associated local tokens to pass the global information. One major difference from others is that the local self-attention in our approach includes one extra regional token to exchange the global information with local tokens.
41
+
42
+ # 3 METHOD
43
+
44
+ Our method is built on top of a vision transformer, so we first present a brief background of ViT and then describe our method (RegionViT) on regional-to-local attention for vision transformers.
45
+
46
+ ![](images/4f51e129978441e6204aba5ef5a836f32d26b9a369736a313e286198ad637a3c.jpg)
47
+ Figure 2: Architecture of the proposed RegionViT. Two paths are in our proposed network, including regional tokens and local tokens, and their information is exchanged in the regional-to-local (R2L) transformer encoders. In the end, we average all regional tokens and use it for the classification. The tensor shape here is computed based on that regional tokens take a patch of $2 8 ^ { 2 }$ and local tokens take a patch of $4 ^ { 2 }$ .
48
+
49
+ Vision Transformer. As opposed to CNN-based approaches for image classification, ViT is a purely attention-based counterpart, borrowed from NLP. It consists of stacked transformer encoders, each of which contains a multihead self-attention (MSA) and a feed-forward network (FFN) with layer normalization and residual shortcut. To classify an image, ViT first splits it into patches of fixed size, e.g. $1 6 \times 1 6$ , and then transforms them into tokens by linear projection. A class token is additionally prepended to the patch tokens to form the input sequence. Before the token are fed into transformer encoders, a learnable absolute positional embedding is added to each token to learn the position information. At the end of the network, the class token is used as the final feature representation for classification. Mathematically, ViT can be expressed as
50
+
51
+ $$
52
+ \begin{array} { r l } & { \mathbf { x } _ { 0 } = [ \mathbf { x } _ { c l s } | | \mathbf { x } _ { p a t c h } ] + \mathbf { x } _ { p o s } } \\ & { \mathbf { y } _ { k } = \mathbf { x } _ { k - 1 } + \mathtt { M S A } \big ( \mathtt { L N } ( \mathbf { x } _ { k - 1 } ) \big ) , \mathbf { x } _ { k } = \mathbf { y } _ { k } + \mathtt { F F N } \big ( \mathtt { L N } \big ( \mathbf { y } _ { k } \big ) \big ) , } \end{array}
53
+ $$
54
+
55
+ where $\mathbf { x } _ { c l s } ~ \in ~ \mathbb { R } ^ { 1 \times C }$ and $\mathbf { x } _ { p a t c h } \in \mathbb { R } ^ { N \times C }$ are the class token and patch tokens respectively and $\mathbf { x } _ { p o s } \in \mathbb { R } ^ { ( 1 + N ) \times C }$ is the position embedding, and $\left[ \left| \left| \right. \right] \right.$ denotes the tensor concatenation. $k , N$ and $C$ are the layer index, the number of patch tokens and dimension of the embedding, respectively.
56
+
57
+ While the vanilla ViT is ideally capable of learning global interaction among all the patch tokens, the memory complexity of self-attention becomes high when there are many tokens as the complexity is quadratically linear to the length of the input sequence. Moreover, the use of isotropic structure limits the capability of extending the vanilla ViT model to many vision applications that require high-resolution details, e.g., object detection. To address these issues, we propose regional-to-local attention for vision transformer, RegionViT for short.
58
+
59
+ An Overview of Our Proposed Approach (RegionViT). Figure 2 illustrates the architecture of the proposed vision transformer, which consists of two tokenization processes that convert an image into regional (upper path) and local tokens (lower path). Each tokenization is a convolution with different patch sizes, e.g., in Figure 2, the patch size of regional tokens is $2 8 ^ { 2 }$ while $4 ^ { 2 }$ is used for local tokens with dimensions projected to $C$ , which means that one regional token covers $7 ^ { 2 }$ local tokens based on the spatial locality, leading to the window size of a local region to $7 ^ { 2 }$ . At stage 1, two sets of tokens are passed through the proposed regional-to-local transformer encoders. However, for the later stages, to balance the computational load and to have feature maps at different resolutions, we deploy a downsampling process to halve the spatial resolution while doubling the channel dimension like CNN on both regional and local tokens before going to the next stage. Finally, at the end of the network, we average the remaining regional tokens as the final embedding for the classification while the detection uses all local tokens at each stage since it provides more fine-grained location information. By having the pyramid structure, the ViT can generate multi-scale features and hence it could be easily extended to more vision applications, e.g., object detection, rather than image classification only. We explain the main components of the regional-to-local transformer encoder in the next section.
60
+
61
+ Regional-to-Local Transformer Encoder. Figure 3 shows the proposed regional-to-local (R2L) transformer encoder which includes R2L attention and feed-forward network (FFN). Specifically, within R2L attention, the regional self-attention (RSA) first involves all regional tokens to learn the global information efficiently as the number of regional tokens is few and then local self-attention (LSA) takes the local tokens with the associated regional token to learn local feature while the involved regional token could provide global information at the same time. Both RSA and LSA are multihead self-attention (MSA) but with different input tokens. Finally, the FFN is applied to enhance the features. We also add layer normalization (LN) and residual shortcuts as in standard transformer encoders. Mathematically, given the regional and local tokens, $\mathbf { x } _ { r } ^ { d - 1 }$ and $\mathbf { x } _ { l } ^ { d - 1 }$ as the inputs at layer $d$ , the R2L transformer encoder can be expressed as:
62
+
63
+ $$
64
+ \begin{array} { r l } & { \mathbf { y } _ { r } ^ { d } = \mathbf { x } _ { r } ^ { d - 1 } + \mathtt { R S A } \big ( \mathrm { L N } ( \mathbf { x } _ { r } ^ { d - 1 } ) \big ) , \mathbf { y } _ { i , j } ^ { d } = [ \mathbf { y } _ { r _ { i , j } } ^ { d } | | \{ \mathbf { x } _ { l _ { i , j , m , n } } ^ { d - 1 } \} _ { m , n \in M } ] } \\ & { \mathbf { z } _ { i , j } ^ { d } = \mathbf { y } _ { i , j } ^ { d } + \mathtt { L S A } \big ( \mathrm { L N } ( \mathbf { y } _ { i , j } ^ { d } ) \big ) , \mathbf { x } _ { i , j } ^ { d } = \mathbf { z } _ { i , j } ^ { d } + \mathtt { F F N } \big ( \mathrm { L N } ( \mathbf { z } _ { i , j } ^ { d } ) \big ) } \end{array}
65
+ $$
66
+
67
+ where $i , j$ are the spatial index with respect to regional tokens while $m , n$ are the index of local token in the window size $\bar { M } ^ { 2 }$ . Note that the input of LSA, $\mathbf { y } _ { i , j } ^ { d }$ , includes one regional token and corresponding local tokens, and thus, the information between local and regional tokens are exchanged; on the other hand, the outputs, $\mathbf { x } _ { r } ^ { d }$ and $\mathbf { x } _ { l } ^ { d }$ , can be extracted from $\mathbf { x } _ { i , j } ^ { d }$ like the top-right equation.
68
+
69
+ The RSA exchanges information among all tokens, which covers the context of the whole image; while the LSA combines the features among the tokens belonging to the spatial region, including both regional and local tokens. Since the regions are divided by non-overlapped windows, the RSA is also designed to exchange the information among regions where the LSA takes one regional token and then combines with it the local tokens in the same region. In such a case, all local tokens are still capable of getting global information while being more focused on local neighbors. It is worth noting that the weights are shared be
70
+
71
+ ![](images/b24588ed075ddb0fab57df5144e35582830e656d60d057cf0a2c111269b41fbc.jpg)
72
+ Figure 3: Illustration of Regional-to-Local (R2L) Transformer Encoder. All regional tokens are first passed through regional self-attention (RSA) to exchange the information among regions and then local self-attention (LSA) performs parallel self-attention where each takes one regional token and corresponding local tokens. After that, all the tokens are passed through the feed-forward network and split back to the regional and local tokens. RSA and LSA share the same weights.
73
+
74
+ tween RSA and LSA except for the layer normalization; therefore, the number of parameters won’t increase significantly when compared to the standard transformer encoder. With these two attentions, the R2L can effectively and efficiently exchange information among all regional and local tokens. In particular, the self-attention on regional tokens aims to extract high-level information and act as a bridge to pass information of local tokens from one region to other regions. On the other hand, the R2L attention focus on local contextual information with one regional token.
75
+
76
+ Moreover, the R2L transformer encoder can further reduce the memory complexity significantly. The memory complexity of a self-attention is $\mathcal { O } ( N ^ { 2 } )$ , where $N$ is the number of local tokens. When a region contains $M$ local tokens, and there are $N / M$ regions, the memory complexity is $\mathcal { O } ( ( M + 1 \bar { ) } ^ { 2 } \times ( N / M ) )$ ; while the complexity from the attention on regional tokens is $\mathcal { O } ( ( N / M ) ^ { 2 } )$ . Hence, the overall complexity becomes $\mathcal { \dot { O } } ( ( M { \dot { } } 1 ) ^ { 2 } \times ( N / M ) + ( N / M ) ^ { 2 } )$ . E.g., the main component of RegionViT is stage 3, where $M$ is 49 and $N$ is 196; therefore, the memory complexity saving is $\sim 7 3 \%$ . The saving of each model and each stage is varied based on the model configuration.
77
+
78
+ Relative Position Bias. The locality is an important clue for understanding visual content; therefore, instead of adding absolute position embedding used by the vanilla ViT, we introduce the relative position bias into the attention map of R2L attention since relative position between patches (or pixels) are more important than the absolution position as objects in the images can be placed in an arbitrary way (Ramachandran et al., 2019a; Liu et al., 2021). We only add this bias to the attention between local tokens and not the attention between regional tokens and local tokens. Specifically, for a given pair of local tokens at location, $( x _ { m } , y _ { m } ) , ( x _ { n } , y _ { n } )$ , the attention value $a$ can be expressed as
79
+
80
+ $$
81
+ a _ { ( x _ { m } , y _ { m } ) , ( x _ { n } , y _ { n } ) } = \mathtt { s o f t m a x } \left( q _ { ( x _ { m } , y _ { m } ) } k _ { ( x _ { n } , y _ { n } ) } ^ { T } + b _ { ( x _ { m } - x _ { n } , y _ { m } - y _ { n } ) } \right) ,
82
+ $$
83
+
84
+ where is taken from a learnable parameter $B \in \mathbb { R } ^ { 2 M - 1 \times 2 M - 1 }$ , where $M$ is the m n m n window size of a region. The first term $q _ { ( x _ { m } , y _ { m } ) } k _ { ( x _ { n } , y _ { n } ) } ^ { T }$ is the attention value based on their content.
85
+
86
+ With relative position bias, our model does not require the absolute positional embedding as vanilla ViT since this relative position bias helps to encode the position information.
87
+
88
+ Downsampling. The spatial and channel dimension are changed along different stages of our network by simply applying $3 \times 3$ depth-wise convolution with stride 2 for halving the resolution and doubling the channel dimension for both regional and local tokens (weights are shared) (Heo et al., 2021). We also test with regular convolutions but it does not improve the accuracy with increased complexity.
89
+
90
+ Table 2: Model architectures of RegionViT. For all networks, the dimension per head is 32 and the expanding ratio $r$ in FFN is 4. The patch size of local tokens is always 4 while the patch size of regional tokens is $4 \times M$ .
91
+
92
+ <table><tr><td>Model</td><td colspan="2">Tokenization Local Regional</td><td>Window size (M)</td><td>Dimension (C)</td><td># of Encoders at each stage</td></tr><tr><td>RegionViT-Ti</td><td>3-conv</td><td>linear</td><td>7</td><td>{64,128,256,512}</td><td>{2,2,8,2}</td></tr><tr><td>RegionViT-S</td><td>3-conv</td><td>linear</td><td>7</td><td>{96,192,384,768}</td><td>{2,2,8,2}</td></tr><tr><td>RegionViT-M</td><td>1-conv</td><td>linear</td><td>7</td><td>{96,192,384,768}</td><td>{2,2,14,2}</td></tr><tr><td>RegionViT-B</td><td>1-conv</td><td>linear</td><td>7</td><td>{128,256,512,1024}</td><td>{2,2,14,2}</td></tr></table>
93
+
94
+ 1-conv: Conv(out=C, $k { = } 8$ , $s { = } 4$ , $\overline { { { \bf p } { = } 3 } } )$ . 3-conv: Conv(out=C/4, $\overline { { \mathbf { k } = 3 } }$ , $\overline { { \mathsf { s } { = } 2 } }$ , $\mathrm { p } { = } 1$ ) Conv(out=C/2, $\overline { { \mathbf { k } = 3 } }$ , s=2, p=1) Conv(out=C, $\mathrm { k } = 3$ , $\mathrm { s } { = } 1$ , $\mathbf { p } { = } 1 ,$ ), where C is the channel dimension of the first block. LayerNorm and GeLU are added between Conv.
95
+
96
+ Input Tokenization. The tokenization for local tokens can be implemented by using a $4 \times 4$ convolution with channel size $C$ and stride 4 (i.e. non-overlapped). However, as pointed out in T2T (Yuan et al., 2021), CrossViT (Chen et al., 2021a), and PiT (Heo et al., 2021), using a stronger but still simple subnetwork for the tokenization could further improve the performance, especially for the smaller models. Thus, we adopt two input tokenizations in our model, one still contains only one convolutional layer and another one contains three convolutional layers (see Table 2 for details).
97
+
98
+ Regional Tokens. We adopt a simple approach to generate regional tokens, that is, using linear projection with larger patch sizes in comparison to the patch size for the local tokens. E.g., as shown in Figure 2, the patch size for local tokens is $4 \times 4$ , we simply use patch size $2 8 \times 2 8$ to split the image and then project each patch linearly to generate regional tokens.
99
+
100
+ Table 2 shows our RegionViT models with different configurations. By default, the window size is 7 while we also experiment with a larger window size (14), those models are annotated with $^ +$ .
101
+
102
+ # 4 EXPERIMENTS
103
+
104
+ # 4.1 IMAGE CLASSIFICATION
105
+
106
+ Datasets. We use ImageNet1K (Deng et al., 2009) (IN1K) and ImageNet21K (Deng et al., 2009) (IN21K) to validate our method. ImageNet1K contains 1.28 million training images and 50k validation images over 1k classes, and ImageNet21K is a large-scale dataset that consists of around 14 million images over 21,841 classes. We use all images for training and then finetune the model on ImageNet1K. Moreover, we also perform the transfer learning from ImageNet1K to five downstream datasets, including CIFAR10 (Krizhevsky et al., 2009), CIFAR100 (Krizhevsky et al., 2009), IIIPets (Parkhi et al., 2012), StandfordCars (Krause et al., 2013) and ChestXRay8 (Wang et al., 2017).
107
+
108
+ Training and Evaluation. We follow DeiT (Touvron et al., 2020) to train our models on IN1K except that we use batch size 4,096 with a base learning rate 0.004 and the warm-up epochs is 50. We adopt the AdamW (Loshchilov & Hutter, 2019) optimizer with cosine learning rate scheduler (Loshchilov & Hutter, 2017). We apply Mixup (Zhang et al., 2018), CutMix (Yun et al., 2019), RandomErasing (Zhong et al., 2020), label smoothing (Szegedy et al., 2016), RandAugment (Cubuk et al., 2020) and instance repetition (Hoffer et al., 2020). During training, we random cropped a $2 2 4 \times 2 2 4$ region and take a $2 2 4 \times 2 2 4$ center crop after resizing the shorter side to 256 for evaluation. We used a similar setting for IN21K and transfer learning, and more details can be found in Section A.1.
109
+
110
+ Table 3: Comparisons with recent pyramid-like structure-based ViT models on ImageNet1K. The bold numbers indicate the best number within each section.
111
+
112
+ <table><tr><td>Model</td><td>Params (M)</td><td>FLOPs (G)</td><td>Acc. (%)</td></tr><tr><td>PiT-XS (Heo et al., 2021)</td><td>10.6</td><td>1.4</td><td>78.1</td></tr><tr><td>ConT-S(Yan et al.,2021)</td><td>10.1</td><td>1.5</td><td>76.5</td></tr><tr><td>PVT-T(Wang et al.,2021)</td><td>13.2</td><td>1.9</td><td>75.1</td></tr><tr><td>ConViT-Ti+ (d&#x27;Ascoli et al., 2021)</td><td>10.0</td><td>2.0</td><td>76.7</td></tr><tr><td>Twins-SVT-S (Chu et al.,2021a)</td><td>24.0</td><td>2.8</td><td>81.7</td></tr><tr><td>PiT-S (Heo et al., 2021)</td><td>23.5</td><td>2.9</td><td>80.9</td></tr><tr><td>ConT-M(Yan et al., 2021)</td><td>19.2</td><td>3.1</td><td>80.2</td></tr><tr><td>Twins-PCPVT-S (Chu et al., 2021a)</td><td>24.1</td><td>3.7</td><td>81.2</td></tr><tr><td>PVT-S (Wang et al., 2021)</td><td>24.5</td><td>3.8</td><td>79.8</td></tr><tr><td>RegionViT-Ti</td><td>13.8</td><td>2.4</td><td>80.4</td></tr><tr><td>RegionViT-Ti+</td><td>14.3</td><td>2.7</td><td>81.5</td></tr><tr><td>DeiT-S (Touvron et al., 2020)</td><td>22.1</td><td>4.6</td><td>79.9</td></tr><tr><td>CvT-13 (Wu et al.,2021)</td><td>20.0</td><td>4.5</td><td>81.6</td></tr><tr><td>Swin-T (Liu et al., 2021)</td><td>29.0</td><td>4.5</td><td>81.3</td></tr><tr><td>LocalViT-S (Li et al.,2021)</td><td>22.4</td><td>4.6</td><td>80.8</td></tr><tr><td>ViL-S (Zhang et al., 2021a)</td><td>24.6</td><td>4.9</td><td>82.0</td></tr><tr><td>Visformer-S (Chen et al.,2021b)</td><td>40.2</td><td>4.9</td><td>82.3</td></tr><tr><td>ConViT-S (d&#x27;Ascoli et al.,2021)</td><td>27.0</td><td>5.4</td><td>81.3</td></tr><tr><td>NesT-S (Zhang et al., 2021b)</td><td>17.0</td><td>5.8</td><td>81.5</td></tr><tr><td>RegionViT-S</td><td>30.6</td><td>5.3</td><td>82.6</td></tr><tr><td>RegionViT-S+</td><td>31.3</td><td>5.7</td><td>83.3</td></tr></table>
113
+
114
+ <table><tr><td>Model</td><td>Params (M)</td><td>FLOPs (G)</td><td>Acc. (%)</td></tr><tr><td>ConT-M(Yan et al., 2021)</td><td>39.6</td><td>6.4</td><td>81.8</td></tr><tr><td>Twins-PCPVT-B (Chu et al.,2021a)</td><td>43.8</td><td>6.4</td><td>82.7</td></tr><tr><td>PVT-M(Wang et al., 2021)</td><td>44.2</td><td>6.7</td><td>81.2</td></tr><tr><td>CvT-21(Wu et al.,2021)</td><td>32.0</td><td>7.1</td><td>82.5</td></tr><tr><td>Twins-SVT-B (Chu et al., 2021a)</td><td>56</td><td>8.3</td><td>83.2</td></tr><tr><td>ViL-M (Zhang et al.,2021a)</td><td>39.7</td><td>8.7</td><td>83.3</td></tr><tr><td>Swin-S (Liu et al., 2021)</td><td>50.0</td><td>8.7</td><td>83.0</td></tr><tr><td>PVT-L (Wang et al.,2021)</td><td>61.4</td><td>9.8</td><td>81.7</td></tr><tr><td>ConViT-S+ (d&#x27;Ascoli et al., 2021)</td><td>48.0</td><td>10.0</td><td>82.2</td></tr><tr><td>NesT-S (Zhang et al., 2021b)</td><td>38.0</td><td>10.4</td><td>83.3</td></tr><tr><td>RegionViT-M</td><td>41.2</td><td>7.4</td><td>83.1</td></tr><tr><td>RegionViT-M+</td><td>42.0</td><td>7.9</td><td>83.4</td></tr><tr><td>DeiT-B (Touvron et al.,2020)</td><td>86.6</td><td>17.6</td><td>81.8</td></tr><tr><td>PiT-B (Heo et al., 2021)</td><td>73.8</td><td>12.5</td><td>82.0</td></tr><tr><td>ViL-B (Zhang et al., 2021a)</td><td>55.7</td><td>13.4</td><td>83.2</td></tr><tr><td>Twins-SVT-L(Chu et al.,2021a)</td><td>99.2</td><td>14.8</td><td>83.7</td></tr><tr><td>Swin-B (Liu et al.,2021)</td><td>88.0</td><td>15.4</td><td>83.5</td></tr><tr><td>ConViT-B (d&#x27;Ascoli et al.,2021)</td><td>86.0</td><td>17.0</td><td>82.4</td></tr><tr><td>NesT-B (Zhang et al., 2021b)</td><td>68.0</td><td>17.9</td><td>83.8</td></tr><tr><td>RegionViT-B</td><td>72.7</td><td>13.0</td><td>83.2</td></tr><tr><td>RegionViT-B+</td><td>73.8</td><td>13.6</td><td>83.8</td></tr></table>
115
+
116
+ Table 4: Results on IN1K with IN21K and transfer learning.
117
+
118
+ <table><tr><td>Model</td><td>Params (M)</td><td>FLOPs (G)</td><td>Acc. (%)</td></tr><tr><td>ViL-B</td><td>55.7</td><td>43.7</td><td>86.0</td></tr><tr><td>Swin-L</td><td>197.0</td><td>103.9</td><td>87.3</td></tr><tr><td>CvT-W24</td><td>277</td><td>193.2</td><td>87.7</td></tr><tr><td>RegionViT-B+</td><td>76.5</td><td>42.6</td><td>86.5</td></tr></table>
119
+
120
+ (b) Transfer learning on downstream tasks.
121
+
122
+ <table><tr><td></td><td>CIFAR10</td><td>CIFAR100</td><td>Pet</td><td>StanfordCars</td><td>ChestXRay8</td></tr><tr><td>DeiT-S</td><td>99.1</td><td>90.9</td><td>94.9</td><td>91.5</td><td>55.4</td></tr><tr><td>DeiT-B</td><td>99.1</td><td>90.8</td><td>94.4</td><td>91.7</td><td>55.8</td></tr><tr><td>RegionViT-S</td><td>98.9</td><td>90.0</td><td>95.3</td><td>92.8</td><td>57.8</td></tr><tr><td>RegionViT-M</td><td>99.0</td><td>90.8</td><td>95.5</td><td>91.9</td><td>58.3</td></tr></table>
123
+
124
+ Table 5: Object detection performance on MS COCO val2017 with $1 \times$ and $3 \times$ schedule. The bold number indicates the best number within the section, and for MaskRCNN, both $\mathsf { A P } ^ { b }$ and $\mathsf { A P } ^ { m }$ are annotated.
125
+
126
+ <table><tr><td rowspan="2">Backbone</td><td>Params</td><td>FLOPs</td><td rowspan="2">RetineNet</td><td rowspan="2">3× AP</td><td rowspan="2">Params (M)</td><td rowspan="2">FLOPs</td><td rowspan="2"></td><td colspan="4">MaskRCNN</td></tr><tr><td>(M)</td><td>1× AP</td><td>(G)</td><td>1× APb |APm</td><td>APb</td><td>3× APm</td></tr><tr><td>ResNet50</td><td>37.7</td><td>234</td><td>36.3</td><td>39.0</td><td>44.2</td><td>260.0</td><td>38.0</td><td>34.4</td><td>41.0</td><td></td></tr><tr><td>ConT-M (Yan et al.,2021)</td><td>27.0</td><td>217.2</td><td>39.3</td><td>1</td><td>1</td><td>1</td><td>40.5</td><td>38.1</td><td>1</td><td>37.1 1</td></tr><tr><td>PVT-S (Wang et al., 2021)</td><td>34.2</td><td></td><td>40.4</td><td>42.2</td><td>44.1</td><td></td><td>40.4</td><td>37.8</td><td>43.0</td><td>39.6</td></tr><tr><td>ViL-S (Zhang et al., 2021a)</td><td>35.7</td><td>252.2</td><td>41.6</td><td>42.9</td><td>45.0</td><td>174.3</td><td>41.8</td><td>38.5</td><td>43.4</td><td>39.6</td></tr><tr><td>Swin-T (Liu et al., 2021)</td><td>38.5</td><td>245</td><td>41.5</td><td>43.9</td><td>47.8</td><td>264</td><td>42.2</td><td>39.1</td><td>46.0</td><td>41.6</td></tr><tr><td>Twins-SVT-S (w/PEG) (Chu et al.,2021a)</td><td>34.3</td><td>209</td><td>43.0</td><td>45.6</td><td>44.0</td><td>228</td><td>43.5</td><td>40.3</td><td>46.8</td><td>42.6</td></tr><tr><td>RegionViT-S</td><td>40.8</td><td>192.6</td><td>42.2</td><td>45.8</td><td>50.1</td><td>171.3</td><td>42.5</td><td>39.5</td><td>46.3</td><td>42.3</td></tr><tr><td>RegionViT-S+</td><td>41.5</td><td>204.2</td><td>43.1</td><td>46.9</td><td>50.9</td><td>182.9</td><td>43.5</td><td>40.4</td><td>47.3</td><td>43.4</td></tr><tr><td>RegionViT-S+ w/PEG</td><td>41.6</td><td>204.3</td><td>43.9</td><td>46.7</td><td>50.9</td><td>183.0</td><td>44.2</td><td>40.8</td><td>47.6</td><td>43.4</td></tr><tr><td>ResNet101</td><td>56.7</td><td>315</td><td>38.5</td><td>40.9</td><td>63.2</td><td>336</td><td>40.4</td><td>36.4</td><td>42.8</td><td>38.5</td></tr><tr><td>ResNeXt101-32x4d</td><td>56.4</td><td>319.1</td><td>39.9</td><td>41.4</td><td>62.8</td><td>340</td><td>41.9</td><td>37.5</td><td>44.0</td><td>39.2</td></tr><tr><td>PVT-M(Wang et al., 2021)</td><td>53.9</td><td></td><td>41.9</td><td>43.2</td><td>63.9</td><td></td><td>42.0</td><td>39.0</td><td>44.2</td><td>40.5</td></tr><tr><td>ViL-M (Zhang et al.,2021a)</td><td>50.8</td><td>338.9</td><td>42.9</td><td>43.7</td><td>60.1</td><td>261.1</td><td>43.4</td><td>39.7</td><td>44.6</td><td>40.7</td></tr><tr><td>Swin-S (Liu et al., 2021)</td><td>59.8</td><td>335</td><td>44.5</td><td>46.3</td><td>69.1</td><td>354</td><td>44.8</td><td>40.9</td><td>47.6</td><td>42.8</td></tr><tr><td>Twins-SVT-B (w/PEG) (Chu et al., 2021a)</td><td>67.0</td><td>322</td><td>45.3</td><td>46.9</td><td>76.3</td><td>340</td><td>45.2</td><td>41.5</td><td>48.0</td><td>43.0</td></tr><tr><td>RegionViT-B</td><td>83.4</td><td>308.9</td><td>43.3</td><td>46.1</td><td>92.2</td><td>287.9</td><td>43.5</td><td>40.1</td><td>47.2</td><td>43.0</td></tr><tr><td>RegionViT-B+</td><td>84.4</td><td>328.1</td><td>44.2</td><td>46.9</td><td>93.2</td><td>307.1</td><td>44.5</td><td>41.0</td><td>48.1</td><td>43.5</td></tr><tr><td>RegionViT-B+ w/PEG</td><td>84.5</td><td>328.2</td><td>44.6</td><td>46.9</td><td>93.2</td><td>307.2</td><td>45.4</td><td>41.6</td><td>48.3</td><td>43.5</td></tr><tr><td>ResNeXt101-64x4d</td><td>95.5</td><td>473</td><td>41.0</td><td>1</td><td>101.9</td><td>493</td><td>42.8</td><td>38.4</td><td></td><td></td></tr><tr><td>PVT-L (Wang et al., 2021)</td><td>71.1</td><td>345</td><td>42.6</td><td></td><td>81.0</td><td>364</td><td>42.9</td><td>39.5</td><td>1</td><td>1</td></tr><tr><td>ViL-B (Zhang et al., 2021a)</td><td>66.7</td><td>443.0</td><td>44.3</td><td>44.7</td><td>76.1</td><td>365.1</td><td>45.1</td><td>41.0</td><td>45.7</td><td>41.3</td></tr><tr><td>Swin-B (Liu et al.,2021)</td><td>98.4</td><td>477</td><td>44.7</td><td>1</td><td>107.2</td><td>496</td><td>45.5</td><td>41.3</td><td>二</td><td></td></tr><tr><td>Twins-SVT-L (w/ PEG) (Chu et al.,2021a)</td><td>110.9</td><td>455</td><td>45.7</td><td></td><td>119.7</td><td>474</td><td>45.9</td><td>41.6</td><td></td><td>1</td></tr><tr><td>RegionViT-B+ w/PEGt</td><td>84.5</td><td>506.4</td><td>46.1</td><td>48.2</td><td>93.2</td><td>464.4</td><td>46.3</td><td>42.4</td><td>49.2</td><td>44.5</td></tr></table>
127
+
128
+ The reported results of Swin are from Twins as the original paper does not include resutls with ImageNet1K weights. †: input resolution is $\overline { { 8 9 6 \times 1 3 4 4 } }$
129
+
130
+ Results on ImageNet1K. Table 3 shows the results on ImageNet1K where the methods listed all adopt CNN-like pyramid structure into the ViT and are all very recent and concurrent works. For the smaller models (Ti, S), RegionViT achieves a better trade-off between accuracy and complexity (parameters or FLOPs); on the other hand, for the larger models (M and B), it obtains better accuracy while having fewer FLOPs and parameters. The efficiency of RegionViT comes from the proposed R2L transformer encoder, and hence with such efficiency, it enables the network to be wide and deep for better accuracy with comparable complexity.
131
+
132
+ Results on ImageNet21K. Table 4a shows that our model achieves a good accuracy-efficiency tradeoff with ImageNet21K for pretraining. RegionViT- $\mathbf { \cdot B + }$ only needs $2 5 \%$ parameters and FLOPs compared to CvT-W24 (Wu et al., 2021) and half parameters and FLOPs to Swin-L (Liu et al., 2021).
133
+
134
+ Results on Transfer Learning. Table 4b shows the transfer learning results with ImageNet1K pretrained weights. Our model outperforms DeiT (Touvron et al., 2020) by $2 \sim 3 \%$ on ChestXRay8, which has a larger domain gap from ImageNet1K than other four datasets. We think this is because the hierarchical feature models could provide better generalization for the domain gap compared to DeiT which uses isotropic spatial resolution throughout the whole network.
135
+
136
+ # 4.2 OBJECT DETECTION AND SEMANTIC SEGMENTATION
137
+
138
+ Dataset. We use MS COCO 2017 to validate our models (Lin et al., 2014) on object detection. COCO 2017 dataset contains 118K images for training and 5K images for validation across 80 categories. We also test our model on keypoint detection and results are shown in Sec. B. On the other hand, we validate our model with semantic segmentation on ADE20K (Zhou et al., 2017). The ADE20K dataset contains $2 0 \mathrm { k }$ images in the training set, 2k images for validation.
139
+
140
+ Training and Evaluation. For object detection, we adopt RetinaNet (Lin et al., 2017) and MaskRCNN (He et al., 2017) as our detection framework. We simply replace the backbone with RegionViT, and then output the local tokens at each stages as multi-scale features for the detector. The regional tokens are not used in the detection. Before sending the features to the detector framework, we add new layer normalization layers to normalize the features. We use RegionViT-S and RegionViT-B as the backbone and the weights are initialized from ImageNet1K pretraining. The shorter side and longer side of the input image is resized to 672 and 1,120, respectively. We train our models based on the settings in $1 \times$ and $3 \times$ schedule in Detectron2 (Wu et al., 2019) for object detection. More training details could be found in A.2. For semantic segmentation, we adopt Semantic FPN as the framework (Kirillov et al., 2019) and use RegionViT as the backbone. We initialize models with ImageNet1K weights, and mostly follow the training receipt in Twins’ paper (Chu et al., 2021a). More training details can be found in Sec. A.3.
141
+
142
+ Results on Object Detection. Table 5 compares RegionViT with other methods. For the smaller models, RegionViT-S and RegionViT- $^ { S + }$ achieve similar accuracy while being moderately efficient in terms of FLOPs. We find that the position encoding generator (PEG) proposed by (Chu et al., 2021b) could help the detection accuracy substantially, so we also provide the results with PEG, which are also used in Twins (Chu et al., 2021a). For the middle size models with RetinaNet, RegionViT-B are slightly worse than Twins with $1 \times$ schedule; however, our model catches up the performance with $3 \times$ schedule. When comparing the large models under similar FLOPs (RegionViT- $\mathbf { \cdot B + }$ w/ $\mathrm { P E G \dag }$ ), we further train our model with the similar resolution used by other works, and observe that our models outperform all others while being more parameter efficient (models marked with $\dagger$ in Table 5).
143
+
144
+ Results on Semantic Segmentation. Table 6 compares ours to Swin (Liu et al., 2021) and Twins. As PEG is useful for object detection, we show the results with PEG. Our models achieved significant improvement with similar FLOPs for both models. This suggests that the proposed R2L attention can effectively model global context.
145
+
146
+ Table 6: Performance on semantic segmentation.
147
+
148
+ <table><tr><td>Model</td><td>FLOPs (G)</td><td>Params (M)</td><td>mIoU (%)</td></tr><tr><td>Swin-T*</td><td>46</td><td>31.9</td><td>41.5</td></tr><tr><td>Twins-SVT-S</td><td>37</td><td>28.3</td><td>43.2</td></tr><tr><td>RegionViT-S+ (w/PEG)</td><td>37</td><td>35.7</td><td>45.3</td></tr><tr><td>Swin-S*</td><td>70</td><td>53.2</td><td>45.2</td></tr><tr><td>Twins-SVT-B</td><td>67</td><td>60.4</td><td>45.3</td></tr><tr><td>RegionViT-B+ (w/PEG)</td><td>67</td><td>78.3</td><td>47.5</td></tr></table>
149
+
150
+ ∗ : Numbers are cited from the reproduced results of Twins’ paper.
151
+
152
+ # 4.3 ACTION RECOGNITION
153
+
154
+ Datasets and Setup. We validate our approach on Kinetics400 (K400) (Kay et al., 2017) and Something-Something V2 (SSV2) (Goyal et al., 2017). We adopt the divided-space-time attention in TimeSformer (Bertasius et al., 2021) as the temporal modeling to perform action recognition experiments. More details could be found in Sec. A.4.
155
+
156
+ Results. Table 7 shows that with RegionViT as the backbone, the model can be much more efficient with competitive accuracy to TimeSformer, which uses vanilla ViT as the backbone. RegionViT-M could reduce more than $50 \%$ FLOPs and parameters than the TimeS
157
+
158
+ Table 7: Performance on action recognition.
159
+
160
+ <table><tr><td>Model</td><td>FLOPs* (G)</td><td>Params (M)</td><td>K400 Acc. (%)</td><td>SSV2 Acc.(%)</td></tr><tr><td>TimeSformer</td><td>197</td><td>121.4</td><td>75.8</td><td>59.5</td></tr><tr><td>x TimeSformer†</td><td>197</td><td>121.4</td><td>77.1</td><td>59.2</td></tr><tr><td>RegionViT-S</td><td>59.4</td><td>42.9</td><td>76.6</td><td>59.7</td></tr><tr><td>RegionViT-M</td><td>83.1</td><td>57.5</td><td>77.6</td><td>59.8</td></tr></table>
161
+
162
+ ∗ : FLOPs of single crop, †: retrained with the same setting.
163
+
164
+ former. This not only shows the importance of spatial modeling in action recognition but also validates that our proposed model can also be extended for efficient action recognition.
165
+
166
+ # 4.4 ABLATION STUDY
167
+
168
+ We perform the following experiments to verify the effectiveness of different components in RegionViT. All experiments are conducted based on RegionViT-S.
169
+
170
+ Regional Tokens. Table 8 shows the results with and without regional tokens on three tasks, and Table A5 includes FLOPs and parameters comparison. For image classification, the regional tokens provide around $0 . 4 \%$ improvement with negligible overhead in both compu
171
+
172
+ Table 8: Ablation on regional tokens.
173
+
174
+ <table><tr><td>Dataset Regional Tokens</td><td>IN1K Acc.</td><td colspan="2">MS COCO MaskRCNN RetinaNet</td><td>ADE20K SemanticFPN</td></tr><tr><td></td><td></td><td>(APb/APm) 40.5/37.8</td><td>(APb) 40.7</td><td>(mIoU) 42.3</td></tr><tr><td>N Y</td><td>82.2 82.6</td><td>42.5/39.5</td><td>42.2</td><td>43.7</td></tr></table>
175
+
176
+ tations $( 6 \% )$ and parameters $( 0 . 7 \% )$ . On the other hand, the regional tokens clearly improve the performance of object detection and semantic segmentation with negligible overhead ( $< 2 \%$ on both FLOPs and parameters). This is because dense prediction tasks require more multi-scale features with global contextual information (provided by the regional tokens) than image classification.
177
+
178
+ Downsampling. Table 9 shows different approaches for downsampling the patches. $3 \times 3$ kernel size achieves better results than $2 \times 2$ convolution, because the kernel is non-overlapped with $2 \times 2$ convolution, which limits the interac
179
+
180
+ Table 9: Different downsampling approaches.
181
+
182
+ <table><tr><td>Downsampling</td><td>Params</td><td>FLOPs (G)</td><td>IN1K Acc. (%)</td></tr><tr><td>2×2 convolution</td><td>32.1</td><td>5.5</td><td>82.3</td></tr><tr><td>3×3 convolution</td><td>34.1</td><td>5.7</td><td>82.5</td></tr><tr><td> 3×3 depth-wise conv.</td><td>30.6</td><td>5.3</td><td>82.6</td></tr></table>
183
+
184
+ tion among local tokens. Moreover, using regular convolution does not improve the performance but increases computations and parameters. Thus, we use $3 \times 3$ depthwise convolution for downsampling.
185
+
186
+ Weight sharing between RSA and LSA as well as downsampling. Table 10 shows the results with and without weight sharing. As seen from the table, using separated weights for RSA and LSA only slightly improves the accuracy
187
+
188
+ but significantly increases the model size. This suggests sharing parameters between RSA and LSA suffices for learning local and global information in our approach.
189
+
190
+ Table 10: Weight sharing.
191
+
192
+ <table><tr><td>Weight sharing</td><td>Params</td><td>FLOPs (G)</td><td>IN1K Acc. (%)</td></tr><tr><td>N</td><td>40.4</td><td>5.3</td><td>82.7</td></tr><tr><td>Y</td><td>30.6</td><td>5.3</td><td>82.6</td></tr></table>
193
+
194
+ Keys in LSA. Table 11 studies the number of regional tokens in LSA. When using all regional tokens in the LSA, it provides the local tokens the possibility to explore all global information. Nonetheless, this model only improves $0 . 1 \%$ but
195
+
196
+ Table 11: Keys in LSA.
197
+
198
+ <table><tr><td>Regional tokens</td><td>Params</td><td>FLOPs (G)</td><td>IN1K Acc. (%)</td></tr><tr><td>All</td><td>30.6</td><td>6.0</td><td>82.7</td></tr><tr><td> Corresponding</td><td>30.6</td><td>5.3</td><td>82.6</td></tr></table>
199
+
200
+ with $13 \%$ more computations, which suggests that when considering the regional tokens, the one associated with the current region is sufficient to achieve good performance.
201
+
202
+ Position information. Table 12 compares performance of different combinations of absolute position embedding (APE) and relative position bias (RPB). The models with RPB achieve better accuracy with similar FLOPs and parameters. Although the model with APE could slightly im
203
+
204
+ Table 12: Different position information.
205
+
206
+ <table><tr><td>Abs. pos.</td><td>Rel. pos.</td><td>Params (M)</td><td>FLOPs (G)</td><td>IN1K Acc. (%)</td></tr><tr><td>N</td><td>N</td><td>30.6</td><td>5.3</td><td>82.4</td></tr><tr><td>Y</td><td>N</td><td>30.9</td><td>5.3</td><td>82.2</td></tr><tr><td>Y</td><td>Y</td><td>30.9</td><td>5.3</td><td>82.7</td></tr><tr><td>N</td><td>Y</td><td>30.6</td><td>5.3</td><td>82.6</td></tr></table>
207
+
208
+ prove the performance, it limits the model to run at a fixed resolution, which is not suitable for vision tasks where image size could be varied. Thus, we only adopt the relative position bias in our models.
209
+
210
+ Overlapped windows. Table 13 compares the results with and without overlapped windows. The overlapping ratio of neighboring windows is $50 \%$ and hence this model allows more interactions among local tokens. It improves
211
+
212
+ Table 13: Overlapped windows.
213
+
214
+ <table><tr><td>Model</td><td>Params</td><td>FLOPs (G)</td><td>IN1K Acc. (%)</td></tr><tr><td>overlapped</td><td>30.6</td><td>18.8</td><td>82.8</td></tr><tr><td> non-overlapped</td><td>30.6</td><td>5.3</td><td>82.6</td></tr></table>
215
+
216
+ RegionViT-S by $0 . 2 \%$ but increases the FLOPs by $3 . 5 \times$ . This suggests that the information exchange between the border of windows is sufficiently covered by the proposed R2L attention.
217
+
218
+ Comparison between R2L attention and shifted-window attention. Table 14 shows the comparison between shifted-window attention (Liu et al., 2021) and proposed R2L attention. R2L attention outperforms shifted-window
219
+
220
+ attention by $0 . 7 \%$ , which shows that our proposed R2L attention can effectively model global information to achieve good performance.
221
+
222
+ Table 14: Comparison of different attentions.
223
+
224
+ <table><tr><td>Model</td><td>Params</td><td>FLOPs (G)</td><td>IN1K Acc. (%)</td></tr><tr><td>Shifted-window</td><td>29.0</td><td>4.5</td><td>81.3</td></tr><tr><td>R2L</td><td>32.1</td><td>5.2</td><td>82.0</td></tr></table>
225
+
226
+ # 5 CONCLUSION
227
+
228
+ In this paper, we propose a new ViT architecture that exploits the pyramid structure used in most of CNNs to provide multi-scale features and hence, the models can be more easily extended to different vision applications, like object detection. Moreover, the proposed regional-to-local attention relaxes the memory overhead of performing self-attention on the fine-grained image tokens by limiting the scope of attention but still keeping the capability to explore global information. Extensive experiments on several standard benchmark datasets well demonstrate that our proposed models outperform or are on par with many concurrent ViT variants on four vision applications, including image classification, object and keypoint detection, semantic segmentation and action recognition.
229
+
230
+ # ETHICS STATEMENT
231
+
232
+ Our work introduces a memory-friendly and efficient self-attention method for transformer models, which have wide-ranging applications to image classification, object detection, human activity recognition, etc. By improving efficiency, our work can have a positive effect on these applications in society, allowing faster processing. E.g., this could enable faster responses to detected events such as medical emergencies or detecting defects in manufacturing parts. Lower computation costs could also save energy and therefore have a positive impact on the environment. Negative impacts of our research are difficult to predict, however, it shares many of the pitfalls associated with deep classification models. E.g., Image and video classification systems have negative implications on privacy and could be used by malicious actors or governments to infringe on the privacy of citizens. Future research into private and ethical aspects of visual recognition is an important direction.
233
+
234
+ # REPRODUCIBILITY STATEMENT
235
+
236
+ In order to reproduce our results, we describe the details of the hyperparameters used in our training in Appendix A for all the tasks and we also attach our codes for image classification as part of the supplemental material. We will publicly release all the codes and models after acceptance. In the attached codes, we set all the hyperparameters as their default value, so that users can re-run our experiments with exactly the same hyperparameters. The README file also describes the requirement to build necessary Python environment for running the codes.
237
+
238
+ # REFERENCES
239
+
240
+ Irwan Bello. Lambdanetworks: Modeling long-range interactions without attention. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum? id=xTJEN-ggl1b.
241
+
242
+ Irwan Bello, Barret Zoph, Ashish Vaswani, Jonathon Shlens, and Quoc V Le. Attention augmented convolutional networks. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 3286–3295, 2019.
243
+
244
+ Gedas Bertasius, Heng Wang, and Lorenzo Torresani. Is Space-Time Attention All You Need for Video Understanding? arXiv.org, February 2021.
245
+
246
+ Andrew Brock, Soham De, Samuel L Smith, and Karen Simonyan. High-Performance Large-Scale Image Recognition Without Normalization. arXiv, 2021.
247
+
248
+ Chun-Fu Chen, Quanfu Fan, and Rameswar Panda. CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image Classification. arXiv.org, March 2021a.
249
+
250
+ Zhengsu Chen, Lingxi Xie, Jianwei Niu, Xuefeng Liu, Longhui Wei, and Qi Tian. Visformer: The Vision-friendly Transformer. arxiv.org, April 2021b.
251
+
252
+ Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Twins: Revisiting Spatial Attention Design in Vision Transformers. arXiv.org, April 2021a.
253
+
254
+ Xiangxiang Chu, Zhi Tian, Bo Zhang, Xinlong Wang, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Conditional Positional Encodings for Vision Transformers. arXiv, 2021b.
255
+
256
+ Ekin Dogus Cubuk, Barret Zoph, Jon Shlens, and Quoc Le. RandAugment: Practical Automated Data Augmentation with a Reduced Search Space. In H Larochelle, M Ranzato, R Hadsell, M F Balcan, and H Lin (eds.), Advances in Neural Information Processing Systems, pp. 18613–18624. Curran Associates, Inc., 2020.
257
+
258
+ Stephane d’Ascoli, Hugo Touvron, Matthew Leavitt, Ari Morcos, Giulio Biroli, and Levent Sagun. ´ ConViT: Improving Vision Transformers with Soft Convolutional Inductive Biases. arXiv.org, cs.CV, 03 2021. URL arXiv.org.
259
+
260
+ Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
261
+
262
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https: //www.aclweb.org/anthology/N19-1423.
263
+
264
+ Yifeng Ding, Zhanyu Ma, Shaoguo Wen, Jiyang Xie, Dongliang Chang, Zhongwei Si, Ming Wu, and Haibin Ling. Ap-cnn: Weakly supervised attention pyramid convolutional neural network for fine-grained visual classification. IEEE Transactions on Image Processing, 30:2826–2836, 2021. doi: 10.1109/TIP.2021.3055617.
265
+
266
+ Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021. URL https://openreview. net/forum?id=YicbFdNTTy.
267
+
268
+ 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 ICCV, 2017.
269
+
270
+ Ben Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Herve J ´ egou, ´ and Matthijs Douze. LeViT: a Vision Transformer in ConvNet’s Clothing for Faster Inference. arXiv.org, April 2021.
271
+
272
+ Kai Han, An Xiao, Enhua Wu, Jianyuan Guo, Chunjing Xu, and Yunhe Wang. Transformer in transformer. arXiv preprint arXiv:2103.00112, 2021.
273
+
274
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep Residual Learning for Image Recognition. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2016.
275
+
276
+ Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask r-cnn. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), Oct 2017.
277
+
278
+ Byeongho Heo, Sangdoo Yun, Dongyoon Han, Sanghyuk Chun, Junsuk Choe, and Seong Joon Oh. Rethinking Spatial Dimensions of Vision Transformers. arXiv.org, March 2021.
279
+
280
+ Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
281
+
282
+ Han Hu, Zheng Zhang, Zhenda Xie, and Stephen Lin. Local relation networks for image recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 3464–3473, 2019.
283
+
284
+ J. Hu, L. Shen, and G. Sun. Squeeze-and-excitation networks. In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7132–7141, 2018. doi: 10.1109/CVPR.2018.00745.
285
+
286
+ Zihang Jiang, Qibin Hou, Li Yuan, Daquan Zhou, Xiaojie Jin, Anran Wang, and Jiashi Feng. Token Labeling: Training a $8 5 . 4 \%$ Top-1 Accuracy Vision Transformer with 56M Parameters on ImageNet. arxiv.org, 04 2021. URL arxiv.org.
287
+
288
+ 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:1705.06950, 2017.
289
+
290
+ Alexander Kirillov, Ross Girshick, Kaiming He, and Piotr Dollar. Panoptic feature pyramid networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2019.
291
+
292
+ 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.
293
+
294
+ Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
295
+
296
+ Yawei Li, Kai Zhang, Jiezhang Cao, Radu Timofte, and Luc Van Gool. LocalViT: Bringing Locality to Vision Transformers. arXiv.org, April 2021.
297
+
298
+ 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 David ´ Fleet, Tomas Pajdla, Bernt Schiele, and Tinne Tuytelaars (eds.), Computer Vision – ECCV 2014: 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V, pp. 740–755. Springer International Publishing, Cham, 2014.
299
+
300
+ Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense object detection. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), Oct 2017.
301
+
302
+ 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.org, March 2021.
303
+
304
+ Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. In International Conference on Learning Representations, 2017.
305
+
306
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id= Bkg6RiCqY7.
307
+
308
+ Omkar M. Parkhi, Andrea Vedaldi, Andrew Zisserman, and C. V. Jawahar. Cats and dogs. In IEEE Conference on Computer Vision and Pattern Recognition, 2012.
309
+
310
+ Prajit Ramachandran, Niki Parmar, Ashish Vaswani, Irwan Bello, Anselm Levskaya, and Jon Shlens. Stand-Alone Self-Attention in Vision Models. In H Wallach, H Larochelle, A Beygelzimer, F d Alch e Buc, E Fox, and R Garnett (eds.), Advances in Neural Information Processing Systems. Curran Associates, Inc., 2019a.
311
+
312
+ Prajit Ramachandran, Niki Parmar, Ashish Vaswani, Irwan Bello, Anselm Levskaya, and Jonathon Shlens. Stand-alone self-attention in vision models. arXiv preprint arXiv:1906.05909, 2019b.
313
+
314
+ Aravind Srinivas, Tsung-Yi Lin, Niki Parmar, Jonathon Shlens, Pieter Abbeel, and Ashish Vaswani. Bottleneck transformers for visual recognition. arXiv preprint arXiv:2101.11605, 2021.
315
+
316
+ C. Sun, A. Shrivastava, S. Singh, and A. Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In 2017 IEEE International Conference on Computer Vision (ICCV), pp. 843–852, 2017. doi: 10.1109/ICCV.2017.97.
317
+
318
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2016.
319
+
320
+ Mingxing Tan and Quoc Le. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, pp. 6105–6114, Long Beach, California, USA, June 2019. PMLR.
321
+
322
+ Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve´ Jegou. Training data-efficient image transformers & distillation through attention. ´ arXiv preprint arXiv:2012.12877, 2020.
323
+
324
+ Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Herve J ´ egou. Going ´ deeper with Image Transformers. arXiv.org, cs.CV, 03 2021. URL arXiv.org.
325
+
326
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, ukasz Kaiser, and Illia Polosukhin. Attention is All you Need. In I Guyon, U V Luxburg, S Bengio, H Wallach, R Fergus, S Vishwanathan, and R Garnett (eds.), Advances in Neural Information Processing Systems. Curran Associates, Inc., 2017.
327
+
328
+ 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, 2021.
329
+
330
+ Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7794–7803, 2018.
331
+
332
+ Xiaosong Wang, Yifan Peng, Le Lu, Zhiyong Lu, Mohammadhadi Bagheri, and Ronald M Summers. Chestx-ray8: Hospital-scale chest $\mathbf { X }$ -ray database and benchmarks on weakly-supervised classification and localization of common thorax diseases. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2097–2106, 2017.
333
+
334
+ Zachary Wharton, Ardhendu Behera, and Asish Bera. An attention-driven hierarchical multi-scale representation for visual recognition, 2021.
335
+
336
+ Ross Wightman. Pytorch image models. https://github.com/rwightman/ pytorch-image-models, 2019.
337
+
338
+ 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), September 2018.
339
+
340
+ Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. CvT: Introducing Convolutions to Vision Transformers. arXiv.org, March 2021.
341
+
342
+ Yuxin Wu, Alexander Kirillov, Francisco Massa, Wan-Yen Lo, and Ross Girshick. Detectron2. https://github.com/facebookresearch/detectron2, 2019.
343
+
344
+ Haotian Yan, Zhe Li, Weijian Li, Changhu Wang, Ming Wu, and Chuang Zhang. ConTNet: Why not use convolution and transformer at the same time? arXiv.org, April 2021.
345
+
346
+ Li Yuan, Yunpeng Chen, Tao Wang, Weihao Yu, Yujun Shi, Francis EH Tay, Jiashi Feng, and Shuicheng Yan. Tokens-to-token vit: Training vision transformers from scratch on imagenet, 2021.
347
+
348
+ Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. CutMix: Regularization Strategy to Train Strong Classifiers With Localizable Features. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), October 2019.
349
+
350
+ Hongyi Zhang, Moustapha Cisse, Yann N. Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In International Conference on Learning Representations, 2018. URL https: //openreview.net/forum?id=r1Ddp1-Rb.
351
+
352
+ Pengchuan Zhang, Xiyang Dai, Jianwei Yang, Bin Xiao, Lu Yuan, Lei Zhang, and Jianfeng Gao. Multi-Scale Vision Longformer: A New Vision Transformer for High-Resolution Image Encoding. arXiv.org, March 2021a.
353
+
354
+ Zizhao Zhang, Han Zhang, Long Zhao, Ting Chen, and Tomas Pfister. Aggregating Nested Transformers. arXiv, 2021b.
355
+
356
+ Hengshuang Zhao, Jiaya Jia, and Vladlen Koltun. Exploring self-attention for image recognition. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
357
+
358
+ Heliang Zheng, Jianlong Fu, Zheng-Jun Zha, Jiebo Luo, and Tao Mei. Learning Rich Part Hierarchies With Progressive Attention Networks for Fine-Grained Image Recognition. IEEE Transactions on Image Processing, 29:476–488, 2020. ISSN 1057-7149. doi: 10.1109/tip.2019.2921876.
359
+
360
+ Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random Erasing Data Augmentation. Proceedings of the AAAI Conference on Artificial Intelligence, 34(07):13001–13008, April 2020.
361
+
362
+ 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 (CVPR), July 2017.
363
+
364
+ Table A1: Details of training settings for image classification on ImageNet1K and ImageNet21K.
365
+
366
+ <table><tr><td></td><td>IN1K</td><td>IN21K</td><td>Finetune to IN1K@384²</td><td>Transfer</td></tr><tr><td>Batch size</td><td>4,096</td><td>4,096</td><td>1,024</td><td>768</td></tr><tr><td>Epochs</td><td>300</td><td>120</td><td>30</td><td>1,000</td></tr><tr><td>Optimizer</td><td>AdamW</td><td>AdamW</td><td>AdamW</td><td>SGD</td></tr><tr><td>Weight Decay</td><td>0.05</td><td>0.01</td><td>1e-8</td><td>1e-4</td></tr><tr><td>Linear-rate Scheduler (Initial LR)</td><td>Cosine (0.004)</td><td>Cosine (0.001)</td><td>Cosine (0.0002)</td><td>Cosine (0.01)</td></tr><tr><td>Warmup Epochs</td><td>50</td><td>5</td><td>0</td><td>5</td></tr><tr><td>Warmup linear-rate</td><td></td><td>Linear (1e-6)</td><td></td><td></td></tr><tr><td>Scheduler (Initial LR)</td><td colspan="4"></td></tr><tr><td>Data Aug.</td><td colspan="4">RandAugment (m=9,n=2)</td></tr><tr><td>Mixup (α)</td><td colspan="4">0.8</td></tr><tr><td>CutMix (α) Random Erasing</td><td colspan="4">1.0 0.25</td></tr><tr><td>Instance</td><td colspan="4"></td></tr><tr><td>Repetition*</td><td colspan="4">3</td></tr><tr><td>Drop-path</td><td colspan="4">0.1</td></tr><tr><td>Label Smoothing</td><td colspan="4">0.0 0.1</td></tr></table>
367
+
368
+ ∗: disabled for RegionViT-Ti.
369
+
370
+ # APPENDIX
371
+
372
+ Summary This appendix contains the following additional details. First, in Sec. A, we describe the training details on image classification, object and keypoint detection, semantic segmentation and action recognition separately. Then, we provide detailed results on object detection and ablation studies. The supplementary materials include our codes to reproduce our results on image classification and the README file in the attached codes (RegionViT Code.zip) also provides the detailed instructions to train and evaluate the networks.
373
+
374
+ # A TRAINING DETAILS
375
+
376
+ # A.1 IMAGE CLASSIFICATION
377
+
378
+ We follow DeiT (Touvron et al., 2020) to train our models on ImageNet1K (Deng et al., 2009) except that we use batch size 4,096 with base learning rate 0.004 and the warm-up epochs is 50. We adopt the AdamW (Loshchilov & Hutter, 2019) optimizer with cosine learning rate scheduler (Loshchilov & Hutter, 2017). We apply Mixup (Zhang et al., 2018), CutMix (Yun et al., 2019), RandomErasing (Zhong et al., 2020), label smoothing (Szegedy et al., 2016), RandAugment (Cubuk et al., 2020) and instance repetition (Hoffer et al., 2020). During training, we randomly crop a $2 2 4 \times 2 2 4$ region and take a $2 2 4 \times 2 2 4$ center crop after resizing the shorter side to 256 for evaluation. While pretraining on ImageNet21K (Deng et al., 2009), we use similar settings with slight modifications. We train the model using 120 epochs with 5 epochs for warmup, weight-decay of 0.01 and base learning rate of 0.001. For transfer learning experiments, we finetune the ImageNet1K pretrained models with 1,000 epochs, batch size of 768, learning rate of 0.01, SGD optimizer, weight decay of 0.0001, and using the same data augmentation in training on ImageNet1K. During evaluation, we resize the shorter side of an image to 256 and then take a $2 2 4 \times 2 2 4$ region at the center and report top-1 accuracy. For finetuning experiments from ImageNet21K, we finetune the models with higher resolution of $3 8 4 \times 3 8 4$ , for 30 epochs with cosine learning rate scheduler, base linear rate of 0.002, weight-decay of 1e-8. Moreover, as it is trained on larger resolution, we adjust the window size $M$ to have the same number of regional tokens at the first stage, e.g., we change the window size to 12 for the the models trained at $2 2 4 \times 2 2 4$ with window size 7. We adopt the bicubic interpolation to upsample the weights of tokenizations and relative position bias. During evaluation, we directly resize the shorter side to 384 and then take center $3 8 4 \times 3 8 4$ crop. We trained the models with 32 GPUs.
379
+
380
+ Table A2: Object detection performance on the COCO val2017 with $1 \times$ schedule. The bold number indicates the best number within the section, and for MaskRCNN, both $\mathsf { A P } ^ { b }$ and $\mathbf { A P } ^ { m }$ are annotated.
381
+
382
+ <table><tr><td rowspan="2">Backbone</td><td>Params (M)</td><td rowspan="2">FLOPs (G)</td><td rowspan="2">AP AP50</td><td colspan="6">RetineNet AP75 APs</td><td rowspan="2">Params</td><td colspan="2">FLOPs</td><td colspan="4">MaskRCNN AP5</td></tr><tr><td></td><td>1</td><td></td><td></td><td>APM</td><td>APL</td><td>(M)</td><td>(G)</td><td>APb</td><td>AP</td><td>APm</td><td>AP0</td><td>APm5</td></tr><tr><td>ResNet50</td><td>37.7</td><td>234</td><td>36.3</td><td>55.3</td><td>38.6</td><td>19.3</td><td>40.0</td><td>48.8</td><td>44.2</td><td>260.0</td><td>38.0</td><td>58.6</td><td>41.4</td><td>34.4</td><td>55.1</td><td>36.7</td></tr><tr><td>ConT-M(Yan et al.,2021)</td><td>27.0</td><td>217.2</td><td>39.3</td><td>59.3</td><td>41.8</td><td>23.1</td><td>43.1</td><td>51.9</td><td></td><td></td><td>40.5</td><td></td><td>一</td><td>38.1</td><td></td><td></td></tr><tr><td>PVT-S (Wang et al.,2021)</td><td>34.2</td><td></td><td>40.4</td><td>61.3</td><td>43.0</td><td>25.0</td><td>42.9</td><td>55.7</td><td>44.1</td><td></td><td>40.4</td><td>62.9</td><td>43.8</td><td>37.8</td><td>60.1</td><td>40.3</td></tr><tr><td>ViL-S (Zhang et al.,2021a)</td><td>35.7</td><td>252.2</td><td>41.6</td><td>62.5</td><td>44.1</td><td>24.9</td><td>44.6</td><td>56.2</td><td>45.0</td><td>174.3</td><td>41.8</td><td>64.1</td><td>45.1</td><td>38.5</td><td>61.1</td><td>41.4</td></tr><tr><td>Swin-T(Liu et al.,2021)</td><td>38.5</td><td>245</td><td>41.5</td><td>62.1</td><td>44.2</td><td>25.1</td><td>44.9</td><td>55.5</td><td>47.8</td><td>264</td><td>42.2</td><td>64.6</td><td>46.2</td><td>39.1</td><td>61.6</td><td>42.0</td></tr><tr><td>Twins-SVT-S(w/PEG)(Chu etal.,21a)</td><td>34.3</td><td>209</td><td>43.0</td><td>64.2</td><td>46.3</td><td>28.0</td><td>46.4</td><td>57.5</td><td>44.0</td><td>228</td><td>43.5</td><td>66.0</td><td>47.3</td><td>40.3</td><td>63.2</td><td>43.4</td></tr><tr><td>RegionViT-S</td><td>40.8</td><td>192.6</td><td>42.2</td><td>64.1</td><td>45.1</td><td>27.5</td><td>45.4</td><td>55.3</td><td>50.1</td><td>171.3</td><td>42.5</td><td>65.8</td><td>46.1</td><td>39.5</td><td>62.8</td><td>42.2</td></tr><tr><td>RegionViT-S+</td><td>41.5</td><td>204.2</td><td>43.1</td><td>64.8</td><td>46.2</td><td>29.6</td><td>46.6</td><td>56.1</td><td>50.9</td><td>182.9</td><td>43.5</td><td>66.9</td><td>47.5</td><td>40.4</td><td>63.7</td><td>43.4</td></tr><tr><td>RegionViT-S+W/PEG</td><td>41.6</td><td>204.3</td><td>43.9</td><td>65.5</td><td>47.3</td><td>28.5</td><td>47.3</td><td>57.9</td><td>50.9</td><td>183.0</td><td>44.2</td><td>67.3</td><td>48.2</td><td>40.8</td><td>64.1</td><td>44.0</td></tr><tr><td>ResNet101</td><td></td><td>315</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>57.7</td><td>38.8</td></tr><tr><td>ResNeXt101-32x4d</td><td>56.7 56.4</td><td>319.1</td><td>38.5 39.9</td><td>57.8 59.6</td><td>41.2 42.7</td><td>21.4 22.3</td><td>42.6 44.2</td><td>51.1 52.5</td><td>63.2</td><td>336</td><td>40.4 41.9</td><td>61.1 62.5</td><td>44.2</td><td>36.4 37.5</td><td>59.4</td><td>40.2</td></tr><tr><td>PVT-M(Wang et al.,2021)</td><td>53.9</td><td></td><td>41.9</td><td>63.1</td><td>44.3</td><td>25.0</td><td>44.9</td><td>57.6</td><td>62.8 63.9</td><td>340</td><td>42.0</td><td>64.4</td><td>45.9 45.6</td><td>39.0</td><td>61.6</td><td>42.1</td></tr><tr><td>ViL-M(Zhang et al.,021a)</td><td>50.8</td><td>338.9</td><td>42.9</td><td>64.0</td><td>45.4</td><td>27.0</td><td>46.1</td><td>57.2</td><td>60.1</td><td>261.1</td><td>43.4</td><td>65.9</td><td>47.0</td><td>39.7</td><td>62.8</td><td>42.1</td></tr><tr><td>Swin-S (Liu et al.,2021)</td><td>59.8</td><td>335</td><td>44.5</td><td>65.7</td><td>47.5</td><td>27.4</td><td>48.0</td><td>59.9</td><td>69.1</td><td>354</td><td>44.8</td><td>66.6</td><td>48.9</td><td>40.9</td><td>63.4</td><td>44.2</td></tr><tr><td>Twins-SVT-B(w/PEG)(Chu etal.,221a)</td><td>67.0</td><td>322</td><td>45.3</td><td>66.7</td><td>48.1</td><td>28.5</td><td>48.9</td><td>60.6</td><td>76.3</td><td>340</td><td>45.2</td><td>67.6</td><td>49.3</td><td>41.5</td><td>64.5</td><td>44.8</td></tr><tr><td>RegionViT-B</td><td>83.4</td><td>308.9</td><td>43.3</td><td>65.2</td><td>46.4</td><td>29.2</td><td>46.4</td><td>57.0</td><td>92.2</td><td>287.9</td><td>43.5</td><td>66.7</td><td>47.4</td><td>40.1</td><td>63.4</td><td>43.0</td></tr><tr><td>RegionViT-B+</td><td>84.4</td><td>328.1</td><td>44.2</td><td>66.2</td><td>47.1</td><td>29.2</td><td>47.5</td><td>58.6</td><td>93.2</td><td>307.1</td><td>44.5</td><td>67.6</td><td>48.7</td><td>41.0</td><td>64.4</td><td>43.9</td></tr><tr><td>RegionViT-B+ W/PEG</td><td>84.5</td><td>328.2</td><td>44.6</td><td>66.4</td><td>47.6</td><td>29.6</td><td>47.6</td><td>59.0</td><td>93.2</td><td>307.2</td><td>45.4</td><td>68.4</td><td>49.6</td><td>41.6</td><td>65.2</td><td>44.8</td></tr><tr><td>ResNeXt101-64x4d</td><td>95.5</td><td>473</td><td>41.0</td><td>60.9</td><td>44.0</td><td>23.9</td><td>45.2</td><td>54.0</td><td>101.9</td><td>493</td><td>42.8</td><td>63.8</td><td>47.3</td><td>38.4</td><td>60.6</td><td>41.3</td></tr><tr><td>PVT-L (Wang et al., 2021)</td><td>71.1</td><td>345</td><td>42.6</td><td>63.7</td><td>45.4</td><td>25.8</td><td>46.0</td><td>58.4</td><td>81.0</td><td>364</td><td>42.9</td><td>65.0</td><td>46.6</td><td>39.5</td><td>61.9</td><td>42.5</td></tr><tr><td>ViL-B (Zhang et al., 2021a)</td><td>66.7</td><td>443.0</td><td>44.3</td><td>65.5</td><td>47.1</td><td>28.9</td><td>47.9</td><td>58.3</td><td>76.1</td><td>365.1</td><td>45.1</td><td>67.2</td><td>49.3</td><td>41.0</td><td>64.3</td><td>44.2</td></tr><tr><td>Swin-B (Liu etal.,2021)</td><td>98.4</td><td>477</td><td>44.7</td><td>65.9</td><td>49.2</td><td>1</td><td>1</td><td>1</td><td>107.2</td><td>496</td><td>45.5</td><td>1</td><td>1</td><td>41.3</td><td>1</td><td>1</td></tr><tr><td>Twins-SVT-L (w/PEG) (Chu et al.,2021a)</td><td>110.9</td><td>455</td><td>45.7</td><td>67.1</td><td>49.2</td><td>一</td><td>一</td><td>一</td><td>119.7</td><td>474</td><td>45.9</td><td>一</td><td>一</td><td>41.6 42.4</td><td>66.2</td><td>45.6</td></tr><tr><td>RegionViT-B+W/PEGt</td><td>84.5</td><td>506.4</td><td>46.1</td><td>68.0</td><td>49.5</td><td>30.5</td><td>49.9</td><td>60.1</td><td>93.2</td><td>464.4</td><td>46.3</td><td>69.1</td><td>51.2</td></table>
383
+
384
+ The reported results of Swin (Liu et al., 2021) are from Twins (Chu et al., 2021a) as the original paper does not include resutls with ImageNet1K weights. †: input resolution is 896×1344.
385
+
386
+ # A.2 OBJECT DETECTION AND KEYPOINT DETECTION
387
+
388
+ We adopt RetinaNet (Lin et al., 2017) and MaskRCNN (He et al., 2017) as our detection framework and use KeypoinyRCNN for keypoint detection, and we simply replace the backbone with RegionViT, and then output the local tokens at each stages as multi-scale features for the detector. The regional tokens are not used in the detection. Before sending the features to the detector framework, we add new layer normalization layers to normalize the features. We use RegionViT-S and RegionViT-B as the backbone and the weights are initialized from ImageNet1K pretraining. We train our models based on the settings in $1 \times$ schedule in Detectron2 (Wu et al., 2019), i.e., the batch size is 16 and the learning rate is set to 0.0001 which drops $1 0 \times$ at the 60,000-th and 80,000-th iteration. We use AdamW optimizer with weight-decay of 0.05, and resize the shorter and longer side of an image to 672 and 1,120, respectively. We also adopt drop-path when finetuning the detector, with a rate set to 0.2 for both RetinaNet and MaskRCNN. We trained the models with 8 GPUs. When training with longer schedule $( 3 \times )$ , we adopt stronger data augmentation (multi-scale training) used in Swin (Liu et al., 2021) or Twins (Chu et al., 2021a) rather than fixed-size training used in $1 \times$ schedule.
389
+
390
+ # A.3 SEMANTIC SEGMENTATION
391
+
392
+ We adopt Semantic FPN as our semantic segmentation framework (Kirillov et al., 2019) by replacing the backbone network with RegionViT like the object detection task. We train the models with ImageNet1K pretrained weights. We mostly follow the training receipt in Twins (Chu et al., 2021a) The shorter side of the image is resized to 448 and the longer side won’t exceed 1792, and then we crop a $4 4 8 \times 4 4 8$ region for training. During the evaluation, we take the whole image after resizing as illustrated above. We train the model with AdamW optimizer with learning rate 1e-4 for 80k iterations, and the learning rate is decayed with poly schedule (power is 0.9). The weight decay and drop-path rate is 0.05 and 0.2, respectively. We trained all models with 8 GPUs.
393
+
394
+ # A.4 ACTION RECOGNITION
395
+
396
+ We adopt the divided-space-time attention in TimeSformer (Bertasius et al., 2021) as the temporal modeling to perform action recognition experiments. More specifically, we plugin the temporal attention before every R2L transformer encoder and finetune the model pretrained with ImageNet1K (instead of ImageNet21K). We use the AdamW optimizer (Loshchilov & Hutter, 2019) with base linear rate of 2e-4 and weight-decay of 0.0001. We apply the same Mixup (Zhang et al., 2018), CutMix (Yun et al., 2019) and drop path (Tan & Le, 2019) in the image classification. For the input, we uniformly sample 8 frames from the whole video and the $2 2 4 \times 2 2 4$ region is cropped after shorter side of images is resized to the range of 256 to 320, resulting the size of the input video as $8 \times 2 2 4 \times 2 2 4$ . During evaluation, we use the same way to sample frames but take $3 2 2 4 \times 2 2 4$ spatial crops (top-left, center and bottom-right) after resizing shorter side of image to 256, and then ensemble the predictions as final prediction for the input video. We trained the models with 16 GPUs.
397
+
398
+ Table A3: Object detection performance on the COCO val2017 with $3 \times$ schedule. The bold number indicates the best number within the section, and for MaskRCNN, both $\mathsf { A P } ^ { b }$ and $\mathbf { A P } ^ { m }$ are annotated.
399
+
400
+ <table><tr><td rowspan="2">Backbone</td><td rowspan="2">Params (M)</td><td rowspan="2">FLOPs (G)</td><td rowspan="2">AP AP50</td><td colspan="5">RetineNet AP75|APs</td><td rowspan="2">Params (M)</td><td rowspan="2">FLOPs G</td><td colspan="2">APb</td><td colspan="5">MaskRCNN</td></tr><tr><td></td><td></td><td></td><td>APM|</td><td>APL</td><td></td><td></td><td>AP</td><td>AP5</td><td>|APm</td><td>AP</td><td>APm5</td></tr><tr><td>ResNet50</td><td>37.7</td><td>234</td><td>39.0</td><td>58.4</td><td>41.8</td><td>22.4</td><td>42.8</td><td>51.6</td><td>44.2</td><td>260.0</td><td>41.0</td><td>61.7</td><td>44.9</td><td>37.1</td><td></td><td>58.4</td><td>40.1</td></tr><tr><td>PVT-S (Wang etal.,2021)</td><td>34.2</td><td>1</td><td>42.2</td><td>62.7</td><td>45.0</td><td>26.2</td><td>45.2</td><td>57.2</td><td></td><td>44.1</td><td>245</td><td>43.0</td><td>65.3</td><td>46.9</td><td>39.9</td><td>62.5</td><td>42.8</td></tr><tr><td>ViL-S (Zhang etal.,2021a)</td><td>35.7</td><td>252.2</td><td>42.9</td><td>63.8</td><td>45.6</td><td>27.8</td><td>46.4</td><td>56.3</td><td>45.0</td><td></td><td>174.3</td><td>43.4</td><td>64.9</td><td>47.0</td><td>39.6</td><td>62.1</td><td>42.4</td></tr><tr><td>Swin-T(Liu et al., 2021)</td><td>38.5</td><td>245</td><td>43.9</td><td>64.8</td><td>47.1</td><td>28.4</td><td>47.2</td><td>57.8</td><td>47.8</td><td></td><td>264</td><td>46.0</td><td>68.2</td><td>50.2</td><td>41.6</td><td>65.1</td><td>44.8</td></tr><tr><td>Twins-SVT-S (w/PEG)(Chu et al., 2021a)</td><td>34.3</td><td>209</td><td>45.6</td><td>67.1</td><td>48.6</td><td>29.8</td><td>49.3</td><td>60.0</td><td>44.0</td><td>228</td><td></td><td>46.8</td><td>69.2</td><td>51.2</td><td>42.6</td><td>66.3</td><td>45.8</td></tr><tr><td>RegionViT-S</td><td>40.8</td><td>192.6</td><td>45.8</td><td>67.2</td><td>49.2</td><td>30.0</td><td>50.0</td><td>60.5</td><td>50.1</td><td>171.3</td><td></td><td>46.3</td><td>68.8</td><td>50.6</td><td>42.3</td><td>65.5</td><td>45.7</td></tr><tr><td>RegionViT-S+</td><td>41.5</td><td>204.2</td><td>46.9</td><td>68.3</td><td>50.7</td><td>31.1</td><td>51.0</td><td>62.0</td><td>50.9</td><td></td><td>182.9</td><td>47.3</td><td>69.5</td><td>52.0</td><td>43.1</td><td>66.4</td><td>46.7</td></tr><tr><td>RegionViT-S+ w/PEG</td><td>41.6</td><td>204.3</td><td>46.7</td><td>68.2</td><td>50.2</td><td>30.7</td><td>50.8</td><td>62.4</td><td></td><td>50.9</td><td>183.0</td><td>47.6</td><td>70.0</td><td>52.0</td><td>43.4</td><td>67.1</td><td>47.0</td></tr><tr><td>ResNet101</td><td>56.7</td><td>315</td><td>40.9</td><td></td><td>44.0</td><td></td><td></td><td></td><td></td><td>63.2</td><td>336</td><td>42.8</td><td></td><td>47.1</td><td>38.5</td><td>60.1</td><td>41.3</td></tr><tr><td>ResNeXt101-32x4d</td><td>56.4</td><td>319.1</td><td>41.4</td><td>60.1 61.0</td><td>44.3</td><td>23.7 23.9</td><td>45.0 45.5</td><td>53.8 53.7</td><td></td><td>62.8</td><td>340</td><td>44.0</td><td>63.2 64.4</td><td>48.0</td><td>39.2</td><td>61.4</td><td>41.9</td></tr><tr><td>PVT-M(Wang etal.,021)</td><td>53.9</td><td>1</td><td>43.2</td><td>63.8</td><td>46.1</td><td>27.3</td><td>46.3</td><td>58.9</td><td>63.9</td><td></td><td>302</td><td>44.2</td><td>66.0</td><td>48.2</td><td>40.5</td><td>63.1</td><td>43.5</td></tr><tr><td>ViL-M(Zhang etal.,2021a)</td><td>50.8</td><td>338.9</td><td>43.7</td><td>64.6</td><td>46.4</td><td>27.9</td><td>47.1</td><td>56.9</td><td>60.1</td><td></td><td>261.1</td><td>44.6</td><td>66.3</td><td>48.5</td><td>40.7</td><td>63.8</td><td>43.7</td></tr><tr><td>Swin-S (Liuetal.,221)</td><td>59.8</td><td>335</td><td>46.3</td><td>67.4</td><td>49.8</td><td>31.1</td><td>50.3</td><td>60.9</td><td>69.1</td><td></td><td>354</td><td>47.6</td><td>69.4</td><td>52.5</td><td>42.8</td><td>66.5</td><td>46.4</td></tr><tr><td>Twins-SVT-B (w/ PEG)(Chu et al., 2021a)</td><td>67.0</td><td>322</td><td>46.9</td><td>68.0</td><td>50.2</td><td>31.7</td><td>50.3</td><td>61.8</td><td>76.3</td><td></td><td>340</td><td>48.0</td><td>69.5</td><td>52.7</td><td>43.0</td><td>66.8</td><td>46.6</td></tr><tr><td>RegionViT-B</td><td>83.4</td><td>308.9</td><td>46.1</td><td>67.8</td><td>49.1</td><td>31.5</td><td>50.2</td><td>61.2</td><td>92.2</td><td></td><td>287.9</td><td>47.2</td><td>69.1</td><td>51.7</td><td>43.0</td><td>66.4</td><td>46.5</td></tr><tr><td>RegionViT-B+</td><td>84.4</td><td>328.1</td><td>46.9</td><td>68.6</td><td>50.1</td><td>30.8</td><td>50.7</td><td>62.6</td><td></td><td>93.2</td><td>307.1</td><td>48.1</td><td>70.2</td><td>52.5</td><td>43.5</td><td>67.1</td><td>47.1</td></tr><tr><td>RegionViT-B+ W/PEG</td><td>84.5</td><td>328.2</td><td>46.9</td><td>68.3</td><td>50.3</td><td>31.1</td><td>50.5</td><td>62.4</td><td>93.2</td><td></td><td>307.2</td><td>48.3</td><td>70.1</td><td>52.8</td><td>43.5</td><td>67.1</td><td>47.0</td></tr><tr><td>ViL-B(Zhang etal.,2021a)</td><td>66.7</td><td>443.0</td><td>44.7</td><td>65.5</td><td>47.6</td><td>29.9</td><td>48.0</td><td>58.1</td><td>76.1</td><td></td><td>365.1</td><td>45.7</td><td>67.2</td><td>49.9</td><td>41.3</td><td>64.4</td><td>44.5</td></tr><tr><td>RegionViT-B+w/PEGt</td><td>84.5</td><td>506.4</td><td>48.2</td><td>69.9</td><td>51.5</td><td>34.3</td><td>51.5</td><td>61.7</td><td></td><td>93.2</td><td>464.4</td><td>49.2</td><td>71.0</td><td>53.7</td><td>44.5</td><td>68.4</td><td>48.3</td></tr></table>
401
+
402
+ he reported results of Swin (Liu et al., 2021) are from Twins (Chu et al., 2021a) as the original paper does not include resutls with ImageNet1K weights. †: input resolution is 896×1344.
403
+
404
+ Table A4: Performance on person keypoint detection.
405
+
406
+ <table><tr><td>Model</td><td>FLOPs (G)</td><td>Params (M)</td><td>bbox AP (%)</td><td>keypoint AP (%)</td></tr><tr><td>ResNet-50</td><td>137.7</td><td>59.1</td><td>53.6</td><td>64.0</td></tr><tr><td> RegionViT-S+ (w/ PEG)</td><td>172.2</td><td>65.7</td><td>56.0</td><td>66.1</td></tr></table>
407
+
408
+ # B MORE DETAILED RESULTS
409
+
410
+ We provided more details of some Tables shown in the main paper here. Table A2 and Table A3 include more metrics as compared to Table 5. Table A4 shows the results on keypoint detection. RegionViT outperforms ResNet-50 with moderate increases in FLOPs and parameters. This suggests that RegionViT can model the global context in keypoint detection as well. Table A5 includes complexity comparison for the ablation study on regional tokens as shown in Table 8.
411
+
412
+ Table A5: Performance w/ and w/o regional tokens on RegionViT-S.
413
+
414
+ <table><tr><td></td><td></td><td></td><td>Regional TokensFLOPs (G) Params (M)ImageNet1K Acc.(%)</td></tr><tr><td>N</td><td>5.0</td><td>30.4</td><td>82.2</td></tr><tr><td>Y</td><td>5.3</td><td>30.6</td><td>82.6</td></tr><tr><td>MaskRCNN</td><td></td><td></td><td>MS COCO (APb/APm)</td></tr><tr><td>N</td><td>168.5</td><td>49.9</td><td>40.5/37.8</td></tr><tr><td>Y</td><td>171.3</td><td>50.1</td><td>42.2/39.0</td></tr><tr><td>RetinaNet</td><td></td><td></td><td>MS COCO (APb)</td></tr><tr><td>N</td><td>189.8</td><td>40.5</td><td>40.7</td></tr><tr><td>Y</td><td>192.6</td><td>40.8</td><td>41.7</td></tr><tr><td>SemanticFPN</td><td></td><td></td><td>ADE20K (mIoU)</td></tr><tr><td>N</td><td>36.8</td><td>34.7</td><td>42.3</td></tr><tr><td>Y</td><td>37.3</td><td>35.0</td><td>43.7</td></tr></table>
415
+
416
+ Table A6: Throughput comparison.
417
+
418
+ <table><tr><td>Model</td><td>Acc. (%)</td><td>Params (M)</td><td>FLOPs (G)</td><td>Throughput (images/sec)</td></tr><tr><td>Swin-T</td><td>81.3</td><td>29.0</td><td>4.5</td><td>1129</td></tr><tr><td>Swin-S</td><td>83.0</td><td>50.0</td><td>8.7</td><td>710</td></tr><tr><td>RegionViT-S</td><td>82.6</td><td>30.6</td><td>5.3</td><td>823</td></tr><tr><td>RegionViT-M</td><td>83.1</td><td>41.2</td><td>7.4</td><td>706</td></tr></table>
md/dev/XtyeppctGgc/XtyeppctGgc.md ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Scaling & Shifting Your Features: A New Baseline for Efficient Model Tuning
2
+
3
+ Dongze Lian1∗ Daquan Zhou1,2∗ Jiashi Feng2 Xinchao Wang1 1National University of Singapore 2ByteDance {dongze,xinchao}@nus.edu.sg {zhoudaquan21,jshfeng}@gmail.com
4
+
5
+ # Abstract
6
+
7
+ Existing fine-tuning methods either tune all parameters of the pre-trained model (full fine-tuning), which is not efficient, or only tune the last linear layer (linear probing), which suffers a significant accuracy drop compared to the full fine-tuning. In this paper, we propose a new parameter-efficient fine-tuning method termed as SSF, representing that researchers only need to Scale and Shift the deep Features extracted by a pre-trained model to catch up with the performance of full finetuning. In this way, SSF also surprisingly outperforms other parameter-efficient fine-tuning approaches even with a smaller number of tunable parameters. Furthermore, different from some existing parameter-efficient fine-tuning methods (e.g., Adapter or VPT) that introduce the extra parameters and computational cost in the training and inference stages, SSF only adds learnable parameters during the training stage, and these additional parameters can be merged into the original pre-trained model weights via re-parameterization in the inference phase. With the proposed SSF, our model obtains $2 . 4 6 \%$ $( 9 0 . 7 2 \%$ vs. $8 8 . 5 4 \%$ ) and $1 1 . 4 8 \%$ $7 3 . 1 0 \%$ vs. $6 5 . 5 7 \%$ ) performance improvement on FGVC and VTAB-1k in terms of Top-1 accuracy compared to the full fine-tuning but only fine-tuning about $0 . 3 { \bf M }$ parameters. We also conduct amounts of experiments in various model families (CNNs, Transformers, and MLPs) and datasets. Results on 26 image classification datasets in total and 3 robustness & out-of-distribution datasets show the effectiveness of SSF. Code is available at https://github.com/dongzelian/SSF.
8
+
9
+ # 1 Introduction
10
+
11
+ With the popularity of the data-driven methods in the deep learning community, the dataset scale and the model size have both got huge explosions. There is a tendency to explore large models and then adopt these pre-trained models in downstream tasks to achieve better performance and faster convergence, which gradually becomes a common way.
12
+
13
+ However, the current procedure depends on full fine-tuning heavily, where all the parameters of the model are updated. It inevitably causes the model to be over-fitted to the small target dataset and thus cannot be used for other tasks after the fine-tuning. As a result, the device will need to save a dedicated set of model parameters for each task, which causes a huge amount of storage space, especially for today’s large models (e.g., ViT-G/14 [11] 1.8G, CoAtNet [5] 2.4G).
14
+
15
+ A simple solution for the above problem is linear probing [16], where only the last head layer is fine-tuned. However, this practice usually yields inferior performance compared to the full fine-tuning proxy. Motivated by the success of the parameter-efficient fine-tuning strategy with prompt in the field of natural language processing (NLP) [21, 32, 23, 19], the recent work implements a similar proxy on vision tasks [29], termed as Visual Prompt Tuning (VPT). Specifically, VPT [29] proposes to insert learnable prompts as inputs and append them to the original image tokens. These prompts
16
+
17
+ <table><tr><td>Method</td><td>Acc.</td><td>Params. (M)</td><td>Unified parameter space</td><td>No extra inference params.</td></tr><tr><td>Full fine-tuning</td><td>93.82</td><td>85.88</td><td>√</td><td>√</td></tr><tr><td>Linear probing</td><td>88.70</td><td>0.08</td><td>√</td><td>√</td></tr><tr><td>Adapter [21] VPT [29]</td><td>93.34</td><td>0.31</td><td>√</td><td>×</td></tr><tr><td></td><td>93.17</td><td>0.54</td><td>×</td><td>×</td></tr><tr><td>SSF (ours)</td><td>93.99</td><td>0.28</td><td>√</td><td>√</td></tr></table>
18
+
19
+ Table 1: Characteristics of different finetuning methods. Acc. means the Top-1 accuracy $( \% )$ on CIFAR-100 with a pre-trained ViT-B/16 for tuning. Params. means the learnable parameters at fine-tuning. Our SSF has a unified learnable parameter space and does not require extra inference parameters while obtaining superior performance.
20
+
21
+ ![](images/613ec6be12fb156c003ed7e7f147c704dda8789d3d95f22888e0c4be8b147b49.jpg)
22
+ Figure 1: Performance comparisons of seven finetuning methods with a pre-trained ViT-B/16 model on the FGVC dataset and VTAB-1k benchmark. Our SSF (red dots) achieves state-of-the-art performance only with about $0 . 3 { \bf M }$ average learnable parameters.
23
+
24
+ will interact with the image tokens by performing self-attention and are updated during the fine-tuning process. In this manner, a significant performance improvement can be achieved in downstream tasks compared to a linear probing proxy. Nevertheless, compared to the full fine-tuning and linear probing, it additionally raises two issues: i) VPT tunes the number of prompts for different tasks, which introduces a task-dependent learnable parameter space. The fine-tuning performance is sensitive to the number of prompts for each task and needs to be carefully designed. Too few or too many prompts might either degrade the accuracy of fine-tuning or increase the redundancy of the computation (e.g., 200 prompts on Clevr/count vs. 1 prompt on Flowers102); ii) VPT [29], as well as other Adapter-based methods [21, 42], introduces additional parameters and computational cost in the inference phase compared to the original pre-trained model. For instance, VPT introduces additional inputs for self-attention with image tokens. Adapter-based methods insert additional modules into the pre-trained model. These methods change the specific backbone architecture or the input of the network, which might result in frequent structure modifications and heavy workload, especially for those models that are already deployed in edge devices (e.g., mobile phones).
25
+
26
+ To cope with the above issues, we attempt to find a general proxy for parameter-efficient finetuning, where the learnable parameter space is unified (task-independent) and no additional inference parameters are introduced. Inspired by some feature modulation methods [58, 25, 45], we propose a new parameter-efficient fine-tuning method named SSF, where you only need to Scale and Shift your deep Features extracted by a pre-trained model for fine-tuning. The intuition behind our approach come from the fact that the upstream datasets and downstream datasets have different data distributions [50]. Therefore, it is difficult to apply the model weights trained in the upstream dataset to the downstream dataset. For instance, a naive linear probing strategy with keeping the weights of backbone frozen will cause performance degradation. To alleviate the above problem, SSF introduces scale parameters and shift parameters, which could be considered as variance and mean to modulate the features of the downstream dataset extracted with the pre-trained model on the upstream dataset, such that the modulated feature falls in a discriminative space. These scale parameters and shift parameters do not depend on any input and have a unified learnable parameter space for different tasks. Another advantage of SSF is that it only introduces linear transformations because we scale and shift the extracted features. These linear transformations could be further merged into the original pre-trained weight via model re-parameterization [10] in the inference phase, thus avoiding the extra parameters and FLOPs for downstream tasks. For a deployed model in edge devices, only the updated weights after fine-tuning need to be uploaded instead of changing the backbone architecture. Table 1 shows the specific characteristics comparisons between SSF and other fine-tuning methods. SSF is simple, effective, and efficient, which also conforms to Occam’s Razor principle. Therefore, we explore this new baseline and find that it surprisingly outperforms all other parameter-efficient fine-tuning methods.
27
+
28
+ We evaluate our method on 26 classification datasets in total and 3 robustness & out-of-distribution datasets. SSF obtains state-of-the-art performance compared to other parameter-efficient fine-tuning methods with the trainable parameters and accuracy trade-off (Table 1 and Figure 1). Compared to the full fine-tuning, our method obtains $2 . 4 6 \%$ $9 0 . 7 2 \%$ vs. $8 8 . 5 4 \%$ ) and $1 1 . 4 8 \%$ ( $7 3 . 1 0 \%$ vs. $6 5 . 5 7 \%$ ) performance improvement on FGVC and VTAB-1k in terms of Top-1 accuracy but only with about $0 . 3 { \bf M }$ trainable parameters. Furthermore, our SSF does not require additional parameters during the inference phase. It is plug-and-play and is very easy to extend to various model families (CNNs, Transformers, and MLPs). Our SSF establishes a new baseline and we hope that it brings more insight into the field of the efficient model tuning.
29
+
30
+ # 2 Related Work
31
+
32
+ # 2.1 Model Families
33
+
34
+ Convolution has been used for a long time as the main module to extract the image features in computer vision tasks, and CNN-based architectures have been studied [49, 18, 59, 39, 60, 37, 63] with extension on graph-based data [62, 61, 36]. Recently, another architecture family, Transformer, has gained widespread attention owing to its great success in NLP [56, 8, 23]. Following this direction, Dosovitskiy et al. [11] first employ a transformer in the domain of computer vision and introduce a new architecture paradigm, ViT, which achieves promising results [64, 48]. Subsequently, various transformer-based models, such as DeiT [53] and Swin Transformer [38], are introduced and shown to be effective on a variety of tasks such as object detection, semantic segmentation, action recognition [40], etc. In another line, Tolstikhin et al. [52] propose a pure MLP-based architecture, and subsequent papers [20, 33] have interestingly demonstrated that the MLP-based architectures can catch up to transformers. However, in addition to the well-designed modules, their excellent performance is also attributed to the deployment of large-scale models. Given a large-scale model pre-trained on a large dataset, how to perform parameter-efficient fine-tuning in downstream tasks is essential but is currently less explored. In this paper, we propose SSF as a new baseline and show its promising performance with comprehensive validation in a wide variety of tasks.
35
+
36
+ # 2.2 Pre-training and Fine-tuning
37
+
38
+ Early models [18, 24, 22, 59, 51] are usually pre-trained on the ImageNet-1K dataset, and then fine-tuned on downstream tasks to achieve faster convergence [17] or better performance. Such a procedure is called pre-training and fine-tuning, or transfer learning. Recent works tend to employ larger models (e.g., ViT [11] and Swin Transformer V2 [38]) and train them on larger datasets (e.g., ImageNet-21K and JFT-300M) in pursuit of better performance. Both in the domains of NLP and computer vision, these large models [8, 38, 47, 15, 69, 70] achieve enormous performance improvements compared to the small-scale models and provide pre-trained weights for downstream tasks. Some other works attempt to explore how to efficiently fine-tune the pre-trained models [13, 71] on the target tasks. For instance, given a target task, SpotTune [13] investigates which layers need to be fine-tuned. Touvron et al. [54] find that fine-tuning the weights of the attention layers and freezing weights of the other parts is sufficient to adapt the vision transformers to other downstream tasks. Some works also propose to insert adapters into the network to fine-tune in a parameter-efficient way. These adapters can be a small non-linear network [21], a hyper-network that generates model weights [43], or a compactor [42] which performs a low-rank decomposition to reduce the parameters. Some works have also tried to only update the bias term [2, 66]. More recently, VPT [29] proposes to insert a small number of learnable parameters (prompts) and optimize them while freezing the backbone, which achieves significant performance improvement compared to the full fine-tuning. During the submission of this work, some methods [3, 68] are also proposed for parameter-efficient fine-tuning, e.g., inserting a adapter module or neural prompt search. Different from all the above works, we propose to scale and shift deep features extracted by a pre-trained model, which is simple but effective and outperforms other parameter-efficient fine-tuning methods.
39
+
40
+ # 2.3 Feature Modulation
41
+
42
+ Many works have attempted to modulate features to obtain better performance. The most relevant ones to our work are various normalization methods [26, 1, 58]. BN, LN, and GN usually normalize the features and then transform them linearly with scale and shift factors to modulate feature distribution, which has been verified to be effective in amounts of tasks. STN [28] introduces a learnable module to spatially transform feature maps. In the field of image generation, AdaIN [25] generates scale and shift factors to characterize specific image styles. Self-modulation [4] shows GANs benefit from self-modulation layers in the generator. In vision-language tasks, Conditional BN [6] and FiLM [45] are often utilized to modulate the features of two modalities. Unlike some algorithms such as BN, our SSF is not limited to the modulation of normalization layer, and it has a different motivation that is to alleviate the distribution mismatch between upstream tasks and downstream tasks for parameter-efficient fine-tuning. As a comparison, we also conduct experiments in Sec. 4.3 and show that our SSF is more effective compared to only tuning the normalization layer. Compared to STN, AdaIN, FiLM and so on, our method is input-independent and these scale and shift parameters model the distribution of the whole dataset so that they can be absorbed into the original pre-trained model weights in the inference phase.
43
+
44
+ # 2.4 Model Re-parameterization
45
+
46
+ Model re-parameterization has been a common practice to improve inference efficiency. One of the representative techniques is batch normalization folding used in the model compression algorithms [27]. The parameters introduced by the batch normalization layers [26] are merged into the convolutional layers usually stacked before them. This technique is further utilized to merge different branches of networks into a new branch [65, 10, 9]. Similarly, our SSF fully adopts linear transformations, which allows the scale and shift parameters in the training phase to be merged into the original pre-trained model weights, thus avoiding the introduction of the extra parameters and computational cost during the inference phase.
47
+
48
+ # 3 Approach
49
+
50
+ # 3.1 Preliminaries
51
+
52
+ Transformers. In a vision transformer (ViT) [11], an RGB image $I \in \mathbb { R } ^ { 3 \times H \times W }$ is divided into $N \times N$ non-overlapping patches, and then these image patches appended a class token are fed into an embedding layer followed by the $L$ -layer vision transformer blocks with self-attention as the core operation. The input $\boldsymbol { x } \in \mathbb { R } ^ { ( N ^ { \hat { 2 } } + 1 ) \times d }$ , where $d$ is the embedding dimension, is first transformed to keys $K \in \mathbb { R } ^ { ( N ^ { 2 } + 1 ) \times d }$ , values $V \in \mathbb { R } ^ { ( N ^ { 2 } + 1 ) \times d }$ , and queries $\bar { Q ^ { \prime } } \in \mathbb { R } ^ { ( N ^ { 2 } + 1 ) \times d }$ . After that, we can calculate a global self-attention by
53
+
54
+ $$
55
+ \mathrm { A t t e n t i o n } ( Q , K , V ) = \mathrm { S o f t m a x } ( \frac { Q K ^ { T } } { \sqrt { d } } ) V .
56
+ $$
57
+
58
+ The output of the attention layer will be fed to a two-layer MLP to extract information in the channel dimension.
59
+
60
+ Adapter. Adapter [21] is inserted into the transformer layer for efficient fine-tuning. It is a bottleneck module with a few trainable parameters, which contains a down-projection to reduce the feature dimension, a non-linear activation function, and an up-projection to project back to the original dimension. Therefore, given the input $\boldsymbol { x } \in \mathbb { R } ^ { ( N ^ { 2 } + 1 ) \times d }$ , the output is calculated by
61
+
62
+ $$
63
+ \mathrm { o u t } = [ W ^ { \mathrm { u p } } \phi ( W ^ { \mathrm { d o w n } } x ^ { T } ) ] ^ { T } ,
64
+ $$
65
+
66
+ where $W ^ { \mathrm { d o w n } } \in \mathbb { R } ^ { d ^ { \prime } \times d }$ (where $d ^ { \prime } \ll d ,$ ), $\phi$ , and $W ^ { \mathrm { u p } } \in \mathbb { R } ^ { d \times d ^ { \prime } }$ represent the down-projection matrix, non-linear function, and up-projection matrix, respectively.
67
+
68
+ VPT. VPT [29] inserts some learnable parameters (i.e., prompts) into the input space after the embedding layer. These prompts interact with the original image tokens by performing self-attention. During the fine-tuning, the weights of the backbone network are kept frozen and only the parameters of the prompts are updated. VPT-Shallow inserts prompts in the first layer while VPT-Deep inserts prompts in all the layers of the transformer. Assuming that the input is $\overline { { x } } \in \mathbb { R } ^ { ( N ^ { 2 } + 1 ) \times d }$ , denote the inserted prompts as $\dot { \boldsymbol { p } } \in \mathbb { R } ^ { n \times d }$ , where $n$ is the number of prompts, the combined tokens $x ^ { \prime }$ is
69
+
70
+ $$
71
+ x ^ { \prime } = [ x ; p ] ,
72
+ $$
73
+
74
+ where $x ^ { \prime } \in \mathbb { R } ^ { ( N ^ { 2 } + n + 1 ) \times d }$ will be fed into the transformer block for self-attention (Eq. (1)).
75
+
76
+ # 3.2 Scaling and Shifting Your Features for Fine-tuning
77
+
78
+ Different from the above methods, we introduce both the scale and shift factors to modulate deep features extracted by a pre-trained model with linear transformation to match the distribution of a target dataset, as mentioned in Sec. 1. Five main properties are covered in our method: i) SSF achieves on-par performance with the full fine-tuning strategy; ii) all downstream tasks can be inputted to the model independently without relying on any other task; iii) the model only needs to fine-tune very few parameters; iv) unlike VPT [29], which adjusts the number of prompts for each task, the set of parameters for fine-tuning in SSF does not change as the task changes, making it feasible to further fine-tune the parameters later by adding more tasks for multi-task learning or continuous learning2; v) thanks to the linear transformation, SSF avoids the introduction of the extra parameters and computational cost during the inference phase, making our method zero overhead.
79
+
80
+ The design of SSF. SSF performs the linear transformation to modulate the features for parameter-efficient fine-tuning as shown in Figure 2. In Figure 2 (a), given a model pre-trained in the upstream task, we insert SSF-ADA3 after each operation (OP) of the network to modulate features. There are $K$ OPs in total and these operations might contain multi-head self-attention (MSA), MLP and layer normalization (LN), etc. During the fine-tuning, the pre-trained weights in these operations are kept frozen and the SSFADA parameters are kept updated. The specific SSF-ADA structure is shown in Figure2 (c), where the features output from the previous operation are performed dot product with a scale factor and then summed with a shift factor, which are input-independent. Formally, given the input $\boldsymbol { x } \in \bar { \mathbb { R } } ^ { ( N ^ { 2 } + 1 ) \times d }$ , the output $\boldsymbol { y } \in \mathbb { R } ^ { ( N ^ { 2 } + 1 ) \times d }$ (is also the input of the next operation) is calculated by
81
+
82
+ ![](images/247e0c69b62a1b61b9db9dfd09e25ffebf382c56ff9d7c30d74421196ce8672e.jpg)
83
+ Figure 2: The overall pipeline of SSF. (a) Training pipeline via SSF, where an OP means an operation, e.g., MSA, MLP or LN. (b) A pre-trained model or inference pipeline. (c) Our SSF-ADA.
84
+
85
+ $$
86
+ y = \gamma \odot x + \beta ,
87
+ $$
88
+
89
+ where $\gamma \in \mathbb { R } ^ { d }$ and $\beta \in \mathbb { R } ^ { d }$ are the scale and shift factors, respectively. $\odot$ is the dot product.
90
+
91
+ Re-parameterization. Since SSF-ADA is a completely linear transformation, we can re-parameterize it by absorbing the scale and shift terms into the previous linear layer as follows
92
+
93
+ $$
94
+ y = \gamma \odot x + \beta = \gamma \odot ( w * t + b ) + \beta = ( \gamma \odot w ) * t + \gamma \odot b + \beta ,
95
+ $$
96
+
97
+ where $w$ and $b$ are the weight and bias terms, respectively. $^ *$ represents the ‘convolution’ operation in the convolutional layer or the ‘multiplication’ operation in the MLP layer. $t$ is the input of the previous linear layer. Since $w$ and $b$ are frozen and $\gamma$ and $\beta$ are updated in the fine-tuning, $\gamma$ and $\beta$ can be merged into the original parameter space ( $\dot { } w$ and $b$ ) in the inference stage through the above formulation. From this perspective, our SSF-ADA makes it possible to perform downstream tasks without adding any extra parameters and computational costs, as shown in Figure2 (b).
98
+
99
+ Discussion. The first question is why we want the input $\gamma$ and $\beta$ to be input-independent. As FiLM [45] and AdaIN [25] show, we could obtain $\gamma$ and $\beta$ by conditioning an image sample, however, this might cause two shortcomings. One is that we want $\gamma$ and $\beta$ to be input-independent to represent the distribution of the whole downstream dataset so that we can modify the previous weight distribution to fit the downstream dataset by modulating the feature. Secondly, the conditional input requires the introduction of some additional networks (e.g., MLPs) to generate $\gamma$ and $\beta$ , which introduces more trainable parameters. More importantly, to better generate $\gamma$ and $\beta$ , a non-linear activation function might be required, which will lead to the intractability of the re-parameterization. Therefore, we directly perform a fully linear transformation to merge the $\gamma$ and $\beta$ factors into the original pre-trained weights, so that weights can be easily uploaded to the edge devices without any modification of the backbone architecture.
100
+
101
+ The second question is which operations should be followed by SSF-ADA. Our experience is that you can insert SSF-ADA after each operation with a linear coefficient in ViT. Although we can search for some optimal layers or operations with Neural Architecture Search (NAS) [46, 35, 14, 34], to reduce the number of the trainable parameters, we believe that our method will produce better results (or not worse than NAS) without introducing too many trainable parameters that can be merged for inference, as will be shown in Sec. 4.3.
102
+
103
+ # 3.3 Complexity Analysis
104
+
105
+ We also compare the complexity of Adapter, VPT and our SSF. Take a ViT as an example, the dimension and number of the tokens are $d$ and $N ^ { 2 }$ . Assuming that Adapter projects features from $d$ -dim to $d ^ { \prime }$ -dim (where $d ^ { \prime } \ll d _ { , }$ ) so that the extra trainable parameters are $\bar { 2 } d d ^ { \prime }$ in each layer,
106
+
107
+ VPT inserts $n$ prompts to obtain nd extra parameters in each layer, and SSF inserts SSF-ADA after each operation with a linear coefficient to obtain md extra parameters in each layer, when the total number of layers is $L$ , the complexity of Adapter, VPT and SSF is shown in Table 2. The specific number of additional parameters used by
108
+
109
+ Table 2: The complexity comparisons of Adapter [21], VPT [29] and our SSF. ‘ $( 1 ) ^ { \prime }$ : the same parameters and FLOPs for training and inference; $\mathbf { \eta } ^ { \mathrm { ( 0 ) } } \mathbf { : }$ no additional parameters and FLOPs are required for inference.
110
+
111
+ <table><tr><td>Method</td><td>Adapter</td><td>VPT-Shallow</td><td>VPT-Deep</td><td>SSF (ours)</td></tr><tr><td># Extra Params.</td><td>2Ldd&#x27; (1)</td><td>nd(1)</td><td>nLd(1)</td><td>mLd (0)</td></tr><tr><td>#Extra FLOPs</td><td>2N² Ldd&#x27; (1)</td><td></td><td>2n(2N² +n)d(1) | 2n(2N²+n)Ld(1)</td><td>mN²Ld (0)</td></tr></table>
112
+
113
+ Adapter, VPT and SSF depends on the values of $d ^ { \prime }$ , $n$ and $m$ . However, in practice, SSF outperforms Adapter and VPT-Deep even with slightly fewer parameters in the training stage as we will see in Sec. 4. Further, in the inference stage, borrowing the model re-parameterization strategy, the extra parameters and FLOPs of SSF are zero. However, the complexity of Adapter and VPT remain the same compared to the training, which establishes the strengths of our approach.
114
+
115
+ # 4 Experiments
116
+
117
+ # 4.1 Experimental Settings
118
+
119
+ Datasets. We mainly conduct our experiments on a series of datasets that can be categorized into three types as detailed below:
120
+
121
+ FGVC. Following VPT [29], we employ five Fine-Grained Visual Classification (FGVC) datasets to evaluate the effectiveness of our proposed SSF, which consists of CUB-200-2011 [57], NABirds [55], Oxford Flowers [44], Stanford Dogs [30] and Stanford Cars [12].
122
+
123
+ VTAB-1k. VTAB-1k benchmark is introduced in [67], which contains 19 tasks from diverse domains: i) Natural images that are captured by standard cameras; ii) Specialized images that are captured by non-standard cameras, e.g., remote sensing and medical cameras; iii) Structured images that are synthesized from simulated environments. This benchmark contains a variety of tasks (e.g., object counting, depth estimation) from different image domains and each task only contains 1,000 training samples, thus is extremely challenging.
124
+
125
+ General Image Classification Datasets. We also validate the effectiveness of SSF on general image classification tasks. We choose the CIFAR-100 [31] and ImageNet-1K [7] datasets as evaluation datasets, where CIFAR-100 contains 60,000 images with 100 categories. ImageNet-1K contains 1.28M training images and 50K validation images with 1,000 categories, which are very large datasets for object recognition.
126
+
127
+ Models. For a fair comparison, we follow VPT [29] and mainly select ViT-B/16 [11] model pretrained on ImageNet-21K as the initialization for fine-tuning. In addition, we also generalize our method to backbones of different model families, including the recent Swin Transformer [38] (SwinB), ConvNeXt-B [39] and AS-MLP-B [33]. The former builds a hierarchical transformer-based architecture, and the latter two belong to CNN-based architecture and MLP-based architecture respectively.
128
+
129
+ Baselines. We first compare our method with the two basic fine-tuning methods: i) full fine-tuning, where all parameters of the models are updated at fine-tuning; ii) linear probing, where only the parameters of the classification head (an MLP layer) are updated. We also compare our method with recent parameter-efficient fine-tuning methods: iii) Adapter [21], where a new adapter structure with up-projection, non-linear function, and down-projection is inserted into the transformer and only the parameters of this new module are updated; iv) Bias [66], where all the bias terms of parameters are updated; v) VPT [29], where the prompts are inserted into transformers as the input tokens and they are updated at fine-tuning.
130
+
131
+ Implementation Details. For the FGVC datasets, we process the image with a randomly resize crop to $2 2 4 \times 2 2 4$ and a random horizontal flip for data augmentation. For VTAB-1k, we directly resize the image to $2 2 4 \times 2 2 4$ , following the default settings in VTAB [67]. For CIFAR-100 and ImageNet1K, we follow the fine-tuning setting of ViT-B/16 in [11], where the stronger data augmentation strategies are adopted. We employ the AdamW [41] optimizer to fine-tune models for 100 epochs for CIFAR-100, and 30 epochs for ImageNet-1K. The cosine decay strategy is adopted for the learning rate schedule, and the linear warm-up is used in the first 10 epochs for CIFAR-100 and 5 epochs for ImageNet-1K.
132
+
133
+ <table><tr><td rowspan=1 colspan=2>DatasetMethod</td><td rowspan=1 colspan=1>CUB-200-2011</td><td rowspan=1 colspan=1>NABirds</td><td rowspan=1 colspan=1>OxfordFlowers</td><td rowspan=1 colspan=1>StanfordDogs</td><td rowspan=1 colspan=1>StanfordCars</td><td rowspan=1 colspan=1>Mean</td><td rowspan=1 colspan=1>Params.(M)</td></tr><tr><td rowspan=1 colspan=2>Full fine-tuningLinear probing</td><td rowspan=1 colspan=1>87.385.3</td><td rowspan=1 colspan=1>82.775.9</td><td rowspan=1 colspan=1>98.897.9</td><td rowspan=1 colspan=1>89.486.2</td><td rowspan=1 colspan=1>84.551.3</td><td rowspan=1 colspan=1>88.5479.32</td><td rowspan=1 colspan=1>85.980.18</td></tr><tr><td rowspan=2 colspan=2>Adapter [21]Bias [66]VPT-Shallow [29]</td><td rowspan=1 colspan=1>87.188.4</td><td rowspan=1 colspan=1>84.384.2</td><td rowspan=1 colspan=1>98.598.8</td><td rowspan=1 colspan=1>89.891.2</td><td rowspan=1 colspan=1>68.679.4</td><td rowspan=1 colspan=1>85.6788.41</td><td rowspan=1 colspan=1>0.410.28</td></tr><tr><td rowspan=1 colspan=1>VPT-Shallow [29]</td><td rowspan=2 colspan=1>86.788.5</td><td rowspan=2 colspan=1>78.884.2</td><td rowspan=2 colspan=1>98.499.0</td><td rowspan=2 colspan=1>90.790.2</td><td rowspan=2 colspan=1>68.783.6</td><td rowspan=2 colspan=1>84.6289.11</td><td rowspan=2 colspan=1>0.250.85</td></tr><tr><td rowspan=1 colspan=2>VPT-Deep [29]</td></tr><tr><td rowspan=1 colspan=2>SSF (ours)</td><td rowspan=1 colspan=1>89.5</td><td rowspan=1 colspan=1>85.7</td><td rowspan=1 colspan=1>99.6</td><td rowspan=1 colspan=1>89.6</td><td rowspan=1 colspan=1>89.2</td><td rowspan=1 colspan=1>90.72</td><td rowspan=1 colspan=1>0.39</td></tr></table>
134
+
135
+ Table 3: Performance comparisons on five FGVC datasets with ViT-B/16 models pre-trained on ImageNet-21K.
136
+
137
+ <table><tr><td></td><td colspan="5">Natural Specialized</td><td colspan="5">Structured</td></tr><tr><td>Dataset Method</td><td>CEIATIP0 Crreeaer 0</td><td>rmeii</td><td>L63uns NHAS 3</td><td>rrarar gan Bto.AI P5ss55</td><td>Phrroiar Ceeretlrt</td><td>TTsisrlsr Cresisttla poresidsp qTTa</td><td>szhTI1111 puorssitst</td><td>SrHTIPt</td><td></td><td>) sr</td></tr><tr><td>Full fine-tuning [29] Linear probing [29] Adapter [21]</td><td>68.9 87.7 63.485.0</td><td>64.3 97.2 63.2 97.0 63.2 97.7</td><td>86.987.438.8 86.336.651.0 87.0 34.6 50.8</td><td>79.7 95.7 84.2 78.587.5 76.3 88.0 73.1</td><td>73.9 68.6 74.0 70.5</td><td>56.358.6 41.7 65.5 34.330.6 33.2 55.4 37.4 31.2 53.2</td><td>57.546.7 12.520.0 30.3</td><td>25.729.1 9.619.2 22.1</td><td>52.94</td><td>65.57 85.84 0.04</td></tr><tr><td>Bias[66] VPT-Shallow [29] VPT-Deep [29]</td><td>74.1 86.1 72.887.059.2 77.7 86.9</td><td>97.5 62.6 97.5</td><td>85.359.9 51.4 87.374.5 51.2</td><td>78.7 91.672.9 78.2 92.075.6</td><td>45.7 69.8 72.9 50.5 68.4 68.5</td><td>61.5 55.6 32.4 55.9 58.640.5 67.1</td><td>25.4 13.8 66.640.0 68.7 36.1 20.2</td><td>15.7 25.1 34.1</td><td>55.82 62.05 64.85</td><td>0.27 0.14 0.11</td></tr><tr><td>SSF (ours)</td><td>78.890.8</td><td>65.8 98.0 88.3 78.1</td><td>49.6</td><td>81.896.1 83.4</td><td>60.046.5 69.0 92.6 75.199.4 91.8 90.2 52.9|87.4 95.987.4 75.5|75.9 62.3 53.380.6 77.3 54.9 29.5 37.9|73.10</td><td>72.8 73.647.9</td><td>32.9</td><td>37.8</td><td>69.43</td><td>0.60 0.24</td></tr></table>
138
+
139
+ Table 4: Performance comparisons on the VTAB-1k benchmark with ViT-B/16 models pre-trained on ImageNet-21K.
140
+
141
+ # 4.2 Performance Comparisons on Image Classification
142
+
143
+ We compare the performance of our SSF and other baseline methods in 26 image classification tasks and the results on FGVC and VTAB-1k are shown in Table 3 and Table 4 (also see Figure 1), respectively, and the results on CIFAR-100 and ImageNet-1K are shown in Table 5, which are evaluated in Top-1 accuracy $( \% )$ . In these three tables, the bold font shows the best accuracy of all methods and the underline font shows the second best accuracy.
144
+
145
+ We have the following findings by observing them: i) In Table 3 and Table 4, where the last column is the average of the fine-tuned parameters for each method on the corresponding datasets, our SSF outperforms VPT [29] and other parameter-efficient fine-tuning methods, and even achieves better performance than full fine-tuning, which is mainly owing to the linear transformation applied on the features. Specifically, SSF obtains $1 . 8 1 \%$ $( 9 0 . 7 2 \%$ vs. $8 9 . 1 1 \%$ and $2 . 4 6 \%$ $9 0 . 7 2 \%$ vs. $8 8 . 5 4 \%$ ) accuracy improvement on five FGVC datasets, and $5 . 2 9 \%$ $7 3 . 1 0 \%$ vs. $6 9 . 4 3 \%$ ) and $1 1 . 4 8 \%$ $7 3 . 1 0 \%$ vs. $6 5 . 5 7 \%$ ) improvement on the VTAB-1k benchmark compared to VPT and full fine-tuning. Meanwhile, SSF also uses fewer trainable parameters compared to VPT-Deep in both datasets (0.39M vs. 0.85M, 0.24M vs. 0.60M). SSF maintains a unified learnable parameter space for different tasks with a few parameters while VPT [29] needs to design the different number of prompts for each task, which also shows the conciseness of our approach; ii) In Table 5, i.e., in CIFAR-100 and ImageNet-1K, SSF and other parameter-efficient fine-tuning methods have difficulty in achieving the similar performance to the full fine-tuning, probably because these datasets have sufficient data to prevent over-fitting of the model, especially in ImageNet-1K. In contrast, in the VTAB-1k benchmark, the amount of data is not very large (e.g., only 1,000 training images), which might cause over-fitting of the model for the full fine-tuning. Nevertheless, in CIFAR-100 and ImageNet-1K, our SSF still outperforms previous parameter-efficient fine-tuning methods (Adapter, Bias, and VPT), which shows the effectiveness of our method; iii) In Table 5, the results of our SSF with Swin Transformer, ConvNeXt, and AS-MLP models consistently outperform those of other parameter-efficient fine-tuning methods, which also verifies the effectiveness of SSF on a wide variety of models.
146
+
147
+ Computational cost. To validate the efficiency of our method, we show the computational cost of SSF in Figure 3. We employ a batch size of 16 for the training stage and inference stage, and use mixed precision training. All running results in Figure 3 are measured in a single GeForce RTX 2080Ti GPU. We can see that SSF has similar training time and training memory with VPT but with less inference time and inference memory. Here, we show the computational cost of VPT with 200/50 prompts (the same number of prompts to obtain the performance in Table 5) for VPT-Shallow and VPT-Deep, respectively. When adding the number of prompts, the time cost and memory will be larger but our SSF achieves zero-overhead inference, which is more advantageous.
148
+
149
+ <table><tr><td>Model</td><td colspan="3">ViT-B/16 [11]</td><td colspan="4">Swin-B [38]</td><td colspan="4">ConvNeXt-B [39]</td><td colspan="2">|AS-MLP-B [33]</td></tr><tr><td>Dataset</td><td>CEIPPIII0 ) :seaed</td><td>Teege</td><td>) &#x27;seed</td><td>CEI-AIPI1</td><td>Jr) &#x27;sr</td><td>Teee</td><td>) &#x27;sirN</td><td>CEIPPIII0</td><td>Jr) &#x27;rN</td><td>Trenege ) &#x27;seed</td><td>CEIPPIPI0</td><td></td><td>n) &#x27;se.d</td></tr><tr><td>Method Full fine-tuning Linear probing</td><td>93.82 85.88 88.70</td><td>0.08 82.04</td><td>83.58 86.57 0.77</td><td>89.27</td><td>93.85 86.858 0.10</td><td>83.25</td><td>1.03</td><td>85.20 88.03|94.14 87.67 89.20</td><td>0.10</td><td>85.80 88.85 84.05</td><td>1.03</td><td>89.96 79.04</td><td>86.83 0.10</td></tr><tr><td>Adapter [21] Bias[66] VPT-Shallow [29]</td><td>93.34 93.39 90.38</td><td>0.31 82.72 0.18 82.74 0.23 82.08</td><td>1.00 0.87 0.92</td><td>92.49 92.19 90.02</td><td>0.33 0.24 0.13</td><td>83.82 83.92 83.29</td><td>1.26 1.16 1.05</td><td>92.86 92.80 -</td><td>0.45 0.23</td><td>84.49 84.63 -</td><td>1.37 31.16 -</td><td>88.01 87.46 ·</td><td>0.33 0.26 ·</td></tr><tr><td>VPT-Deep [29] SSF (ours)</td><td>93.17 93.99</td><td>0.54 82.45 0.28 83.10</td><td>1.23 0.97</td><td>92.62 193.06</td><td>0.70 0.37</td><td>83.44 84.40</td><td>1.63 1.29</td><td>- 193.45</td><td>1 0.36</td><td>- 84.85</td><td>- 1.28</td><td>: 88.28</td><td>- 0.37</td></tr></table>
150
+
151
+ Table 5: Performance comparisons on CIFAR-100 and ImageNet-1K with various model families, where ViT-B/16, Swin-B, and ConvNeXt-B are pre-trained on ImageNet-21K, and AS-MLP-B is pre-trained on ImageNet-1K.
152
+
153
+ ![](images/89f4621c4d080085b8619165d09e34921423f5f00a635bd4afb1c6da319be0a2.jpg)
154
+ Figure 3: Computational cost of different tuning methods. From left to right: training time, training memory, test time, and test memory.
155
+
156
+ # 4.3 The Impacts of Different Designs
157
+
158
+ As the core operation of SSF, we thoroughly evaluate how SSF-ADA affects results, e.g., the insertion locations, the initialization of SSF-ADA and its components. We conduct experiments to analyze the impacts of different designs for fine-tuning. All experiments are implemented with pre-trained ViT-B/16 models on CIFAR-100 and the results are shown in Table 6.
159
+
160
+ The impact of the number of layers. We directly insert SSF-ADA into different layers to evaluate the effect of inserting layers, and the results are shown in table 6a. The values in the #layers column indicate the number of layers with SSF-ADA, where #layers-0 represents linear probing. From the first and second rows, we find that the results will improve from $8 8 . 7 0 \%$ to $9 2 . 6 9 \%$ and grow with a small number of trainable parameters (0.08M vs. 0.11M) when only inserting SSF-ADA into the first two layers. Keep adding SSF-ADA in the subsequent layers will make the results better. The growth of the results is almost linear with the number of layers of inserted SSF-ADA. Therefore, we directly choose to insert SSF-ADA into all (12) layers of vision transformer to bring the best results $( 9 3 . 9 9 \% )$ with 0.28M trainable parameters.
161
+
162
+ The impact of the different insertion locations. Based on the different operations of ViT, we evaluate the impact of the insertion locations of SSF-ADA. We separately remove SSF-ADA after these operations and the results are shown in Table 6b. We find that removing the SSF-ADA in the MLP operation achieves inferior results than removing those in the Attention operation $( 9 3 . 4 6 \%$ vs. $9 3 . 6 9 \%$ with comparable trainable parameters (0.19M vs. 0.21M), which suggests that performing feature modulation for the MLP operation might be more important. Although one can use NAS to search for the importance of different operations and thereby insert SSF-ADA in specific locations, the results might not be better than inserting SSF-ADA in all operations. Therefore, in order to obtain excellent performance, we do not perform NAS but directly insert SSF-ADA into all operations.
163
+
164
+ <table><tr><td>#layers</td><td>Acc.</td><td>Params.</td><td>location</td><td>Acc. Params.</td><td>initialization</td><td>Acc.</td><td></td><td>case</td><td>Acc. Params.</td></tr><tr><td>0</td><td>88.70</td><td>0.08</td><td>w/o. mlp</td><td>93.46 0.19</td><td>random</td><td>[90.11</td><td>w/o. scale</td><td>93.49</td><td>0.18</td></tr><tr><td>2</td><td>92.69</td><td>0.11</td><td>w/o.attn</td><td>93.69 0.21</td><td>constant</td><td>93.91</td><td>w/o. shift</td><td>93.74</td><td>0.18</td></tr><tr><td>4</td><td>93.30</td><td>0.15</td><td>w/o.embed</td><td>93.91 0.28</td><td>uniform</td><td>93.87</td><td>only norm</td><td>93.26</td><td>0.11</td></tr><tr><td>8</td><td>93.60</td><td>0.22</td><td>w/o.norm</td><td>93.80 0.25</td><td>trunc_normal</td><td>93.93</td><td>scalar scale</td><td>93.59</td><td>0.18</td></tr><tr><td>12 (ours)</td><td>93.99</td><td>0.28</td><td>ours</td><td>93.99 0.28</td><td>normal (ours)</td><td>93.99</td><td>ours</td><td>93.99</td><td>0.28</td></tr><tr><td colspan="2">(a)</td><td></td><td>(b)</td><td></td><td>(c)</td><td></td><td></td><td>(d)</td><td></td></tr></table>
165
+
166
+ Table 6: The impacts of different designs. (a) The impact of the number of layers with SSF-ADA. (b) The impacts of the different insertion locations of SSF-ADA. (c) The impacts of initialization. (d) The impacts of different components. Acc.: Top-1 accuracy $( \% )$ ; Params.: parameters (M).
167
+
168
+ The impact of initialization. We also investigate how different ways of initializing the scale and shift factors affect performance in Table 6c. In our experiments, we first randomly initialize both scale and shift parameters with a mean value of zero, but find that the performance is inferior $( 9 0 . 1 1 \% )$ and cannot converge in some experiments. After that, we randomly initialize the scale factor with a mean value of one and find better performance, which implies that the weights of a pre-trained model should not be completely disrupted in the fine-tuning, instead, we should start from this pre-trained model to optimize our model. Experiments show that using the normal initialization achieves the best performance, where the mean values of the scale factor and shift factor are one and zero, respectively.
169
+
170
+ The impact of different components. We also evaluate the impacts of different components in SSF-ADA and the results are shown in Table 6d. We find that removing the scale term yields worse performance than removing the shift term with the same trainable parameters, which shows that the scale term might be more important than the shift term. Also, note that the difference between ‘w/o. scale’ and the ‘Bias’ method in Table 5 is that we fine-tune the model with an additional shift term in ‘w/o. scale’, while ‘Bias’ fine-tunes the model based on the original biases, suggesting that fine-tuning the model in a res-like manner can obtain slightly better performance $( 9 3 . 4 9 \%$ vs. $9 3 . 3 9 \%$ ). We also try to only fine-tune all scale and shift factors in the normalization layer (LN), or fine-tune the model with SSF but set the scale term as a scalar. These experiments yield inferior performance than SSF $9 3 . 2 6 \%$ vs. $9 3 . 9 9 \%$ , $9 3 . 5 9 \%$ vs. $9 3 . 9 9 \%$ ), but could probably be considered as an alternative due to the fact that they only use about half of the trainable parameters of SSF.
171
+
172
+ # 4.4 Performance Comparisons on Robustness and OOD Datasets
173
+
174
+ We also conduct experiments to analyze the robustness and Out-Of-Distribution (OOD) ability of our SSF method with the following datasets: ImageNet-A, ImageNet-R and ImageNet-C. Please refer to Appendix for their details. We perform the robustness and OOD evaluation on these three datasets with the fine-tuned models on ImageNet-1K. All experimental results are listed in Table 7.
175
+
176
+ From this table, we can see that our SSF obtains better performance than VPT and other parameter-efficient fine-tuning methods on three datasets, which shows our fine-tuning method has stronger robust
177
+
178
+ Table 7: Performance comparisons on robustness and out-of-distribution datasets. ‘IN’ means ImageNet. The performance on IN-1K, IN-A and IN-R is evaluated in Top-1 accuracy $( \% )$ . The performance on IN-C is evaluated in mCE (mean corruption error). The lower $( \downarrow )$ , the better.
179
+
180
+ <table><tr><td></td><td>Dataset</td><td rowspan="2">IN-1K (↑)</td><td rowspan="2">IN-A (↑)</td><td rowspan="2">IN-R (↑)</td><td rowspan="2">IN-C (↓)</td></tr><tr><td>Method</td><td></td></tr><tr><td colspan="2">Full fine-tuning</td><td>83.58</td><td>34.49</td><td>51.29</td><td>46.47</td></tr><tr><td colspan="2">Linear probing</td><td>82.04</td><td>33.91</td><td>52.87</td><td>46.91</td></tr><tr><td colspan="2">Adapter [21]</td><td>82.72</td><td>42.21</td><td>54.13</td><td>42.65</td></tr><tr><td colspan="2">Bias [66]</td><td>82.74</td><td>42.12</td><td>55.94</td><td>41.90</td></tr><tr><td colspan="2">VPT-Shallow [29]</td><td>82.08</td><td>30.93</td><td>53.72</td><td>46.88</td></tr><tr><td colspan="2">VPT-Deep [29]</td><td>82.45</td><td>39.10</td><td>53.54</td><td>43.10</td></tr><tr><td colspan="2">SSF (ours)</td><td>83.10</td><td>45.88</td><td>56.77</td><td>41.47</td></tr></table>
181
+
182
+ ness and out-of-distribution generalization. Furthermore, although SSF has lower accuracy than full fine-tuning on ImageNet-1K, the performance on ImageNet-A, ImageNet-R and ImageNet-C is better, which also shows the performance between ImageNet-1K and ImageNet-A/R/C is not absolutely positive relevant. Such improvements in robustness and OOD datasets might come from the fact that SSF freezes most of the pre-trained parameters, which maximally preserves the knowledge learned from the large-scale dataset and thus maintains a better generalization ability.
183
+
184
+ # 4.5 Visualization and Analysis
185
+
186
+ Although our goal is to modulate the features extracted by a pre-trained model, the scale and shift parameters are input-independent indeed. Therefore, these parameters can also be regarded as encoding information of the whole downstream dataset. After re-parameterization, these scale and shift parameters are absorbed into the original model weights. To better understand information learned by the SSF, we visualize the distributions of weights and biases before and after finetuning via SSF in Figure 4a. We can see that the scale and shift parameters adjust the original weights and biases, and change the distribution of weights and biases to fit the downstream task.
187
+
188
+ ![](images/1732345a26a5fa74985966322a92d0ce4ad77eec09595f26ab1354fb42428702.jpg)
189
+ Figure 4: Comparisons of parameter distribution between the original pre-trained model and different fine-tuning methods. The first row shows weight distribution and the second row is bias distribution. The blue histograms show the original pre-trained model, and the orange ones show the fine-tuned model via SSF in (a) and full fine-tuned model in (b).
190
+
191
+ As a comparison, we also visualize the original weight distribution and the weight distribution after full fine-tuning in Figure 4b, from which we can find an interesting phenomenon that full fine-tuning does not change the distribution of weights and biases much, but probably only a small portion of the values is changed. It is worth noting that although SSF does not match the weight distribution of full fine-tuning, it achieves better performance $9 3 . 9 9 \%$ vs. $9 3 . 8 2 \%$ in Table 5) on CIFAR-100.
192
+
193
+ To further investigate why SSF can achieve superior performance, beyond weight distribution, we also visualize the feature similarities between full fine-tuning and linear probing, full fine-tuning and VPT-Deep, full fine-tuning and SSF, as shown in Figure 5. In the last layer, SSF has the most similar feature to full fine-tuning and the accuracy is also the closest. This shows that even if the weight distribution learned by SSF is different from full fine-tuning, SSF is also able to extract the features of the images in the downstream task very well, which validates the effectiveness of our method.
194
+
195
+ ![](images/d51c3872ae3cde7269450362c50ffb3e382bf0e22bd6e5dc549ce6434b9cc2ea.jpg)
196
+ Figure 5: The visualization of the feature similarities between full fine-tuning and linear probing, full fine-tuning and VPT-Deep, full finetuning and SSF, in different layers of ViT-B/16.
197
+
198
+ # 5 Conclusion
199
+
200
+ In this paper, we focus on parameter-efficient fine-tuning and propose an SSF method to scale and shift the features extracted by a pre-trained model. The intuition behind our method comes from alleviating the distribution mismatch between upstream tasks and downstream tasks by modulating deep features. SSF surprisingly outperforms other parameter-efficient fine-tuning approaches with a small number of learnable parameters. Besides, the introduced scale and shift parameters during the fine-tuning can be merged into the original pre-trained model weights via re-parameterization in the inference phase, thereby avoiding extra parameters and FLOPs. With the proposed SSF method, our model obtains $2 . 4 6 \%$ $9 0 . 7 2 \%$ vs. $8 8 . 5 4 \%$ ) and $1 1 . 4 8 \%$ $7 3 . 1 0 \%$ vs. $6 5 . 5 7 \%$ ) performance improvement on FGVC and VTAB-1k in terms of Top-1 accuracy compared to the full fine-tuning but only fine-tuning about $0 . 3 { \bf M }$ parameters. Experiments on 26 image classification datasets in total and 3 robustness & out-of-distribution datasets with various model families (CNNs, Transformers, and MLPs) show the effectiveness of SSF, which establishes a new baseline.
201
+
202
+ # Acknowledgement
203
+
204
+ The authors acknowledge the support from the Singapore National Research Foundation (“CogniVision – Energy-autonomous always-on cognitive and attentive cameras for distributed real-time vision with milliwatt power consumption” grant NRF-CRP20-2017-0003) – www.green-ic.org/ CogniVision. Xinchao Wang is the corresponding author.
205
+
206
+ # References
207
+
208
+ [1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
209
+ [2] Han Cai, Chuang Gan, Ligeng Zhu, and Song Han. Tinytl: Reduce memory, not parameters for efficient on-device learning. In H. Larochelle, M. Ranzato, R. Hadsell, M.F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 11285–11297. Curran Associates, Inc., 2020.
210
+ [3] 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.
211
+ [4] Ting Chen, Mario Lucic, Neil Houlsby, and Sylvain Gelly. On self modulation for generative adversarial networks. In International Conference on Learning Representations (ICLR), 2019.
212
+ [5] Zihang Dai, Hanxiao Liu, Quoc V Le, and Mingxing Tan. Coatnet: Marrying convolution and attention for all data sizes. Advances in Neural Information Processing Systems, 34:3965–3977, 2021.
213
+ [6] Harm De Vries, Florian Strub, Jérémie Mary, Hugo Larochelle, Olivier Pietquin, and Aaron C Courville. Modulating early visual processing by language. Advances in Neural Information Processing Systems, 30, 2017.
214
+ [7] 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 the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 248–255, 2009.
215
+ [8] 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.
216
+ [9] Xiaohan Ding, Chunlong Xia, Xiangyu Zhang, Xiaojie Chu, Jungong Han, and Guiguang Ding. Repmlp: Re-parameterizing convolutions into fully-connected layers for image recognition. arXiv preprint arXiv:2105.01883, 2021.
217
+ [10] Xiaohan Ding, Xiangyu Zhang, Ningning Ma, Jungong Han, Guiguang Ding, and Jian Sun. Repvgg: Making vgg-style convnets great again. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 13733–13742, 2021.
218
+ [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 (ICLR), 2021.
219
+ [12] Timnit Gebru, Jonathan Krause, Yilun Wang, Duyun Chen, Jia Deng, and Li Fei-Fei. Finegrained car detection for visual census estimation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 31, 2017.
220
+ [13] Yunhui Guo, Honghui Shi, Abhishek Kumar, Kristen Grauman, Tajana Rosing, and Rogerio Feris. Spottune: transfer learning through adaptive fine-tuning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 4805–4814, 2019.
221
+ [14] Zichao Guo, Xiangyu Zhang, Haoyuan Mu, Wen Heng, Zechun Liu, Yichen Wei, and Jian Sun. Single path one-shot neural architecture search with uniform sampling. In European Conference on Computer Vision, pages 544–560. Springer, 2020.
222
+ [15] 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, pages 16000–16009, 2022.
223
+ [16] Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 9729–9738, 2020.
224
+ [17] Kaiming He, Ross Girshick, and Piotr Dollár. Rethinking imagenet pre-training. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 4918–4927, 2019.
225
+ [18] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 770–778, 2016.
226
+ [19] Xuehai He, Chunyuan Li, Pengchuan Zhang, Jianwei Yang, and Xin Eric Wang. Parameterefficient fine-tuning for vision transformers. arXiv preprint arXiv:2203.16329, 2022.
227
+ [20] Qibin Hou, Zihang Jiang, Li Yuan, Ming-Ming Cheng, Shuicheng Yan, and Jiashi Feng. Vision permutator: A permutable mlp-like architecture for visual recognition. arXiv preprint arXiv:2106.12368, 2021.
228
+ [21] 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, pages 2790–2799. PMLR, 2019.
229
+ [22] Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, To Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
230
+ [23] 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.
231
+ [24] Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4700–4708, 2017.
232
+ [25] Xun Huang and Serge Belongie. Arbitrary style transfer in real-time with adaptive instance normalization. In Proceedings of the IEEE international conference on computer vision, pages 1501–1510, 2017.
233
+ [26] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International conference on machine learning, pages 448–456. PMLR, 2015.
234
+ [27] Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, and Dmitry Kalenichenko. Quantization and training of neural networks for efficient integer-arithmetic-only inference. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2704–2713, 2018.
235
+ [28] Max Jaderberg, Karen Simonyan, Andrew Zisserman, et al. Spatial transformer networks. Advances in neural information processing systems, 28, 2015.
236
+ [29] Menglin Jia, Luming Tang, Bor-Chun Chen, Claire Cardie, Serge Belongie, Bharath Hariharan, and Ser-Nam Lim. Visual prompt tuning. In European Conference on Computer Vision (ECCV), 2022.
237
+ [30] Aditya Khosla, Nityananda Jayadevaprakash, Bangpeng Yao, and Fei-Fei Li. Novel dataset for fine-grained image categorization: Stanford dogs. In Proc. CVPR Workshop on Fine-Grained Visual Categorization (FGVC), volume 2. Citeseer, 2011.
238
+ [31] Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009.
239
+ [32] Xiang Lisa Li and Percy Liang. Prefix-tuning: Optimizing continuous prompts for generation. arXiv preprint arXiv:2101.00190, 2021.
240
+ [33] Dongze Lian, Zehao Yu, Xing Sun, and Shenghua Gao. As-mlp: An axial shifted mlp architecture for vision. In International Conference on Learning Representations (ICLR), 2022.
241
+ [34] Dongze Lian, Yin Zheng, Yintao Xu, Yanxiong Lu, Leyu Lin, Peilin Zhao, Junzhou Huang, and Shenghua Gao. Towards fast adaptation of neural architectures with meta learning. In International Conference on Learning Representations (ICLR), 2020.
242
+ [35] Hanxiao Liu, Karen Simonyan, and Yiming Yang. Darts: Differentiable architecture search. In International Conference on Learning Representations (ICLR), 2019.
243
+ [36] Huihui Liu, Yiding Yang, and Xinchao Wang. Overcoming catastrophic forgetting in graph neural networks. In AAAI Conference on Artificial Intelligence, 2021.
244
+ [37] Songhua Liu, Jingwen Ye, Sucheng Ren, and Xinchao Wang. Dynast: Dynamic sparse transformer for exemplar-guided image generation. In Proceedings of the European Conference on Computer Vision, 2022.
245
+ [38] 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 International Conference on Computer Vision (ICCV), 2021.
246
+ [39] Zhuang Liu, Hanzi Mao, Chao-Yuan Wu, Christoph Feichtenhofer, Trevor Darrell, and Saining Xie. A convnet for the 2020s. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
247
+ [40] Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video swin transformer. arXiv preprint arXiv:2106.13230, 2021.
248
+ [41] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019.
249
+ [42] Rabeeh Karimi Mahabadi, James Henderson, and Sebastian Ruder. Compacter: Efficient low-rank hypercomplex adapter layers. arXiv preprint arXiv:2106.04647, 2021.
250
+ [43] Rabeeh Karimi Mahabadi, Sebastian Ruder, Mostafa Dehghani, and James Henderson. Parameter-efficient multi-task fine-tuning for transformers via shared hypernetworks. arXiv preprint arXiv:2106.04489, 2021. number of classes. In 2008 Sixth Indian Conference on Computer Vision, Graphics & Image Processing, pages 722–729. IEEE, 2008.
251
+ [45] 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.
252
+ [46] Hieu Pham, Melody Guan, Barret Zoph, Quoc Le, and Jeff Dean. Efficient neural architecture search via parameters sharing. In International conference on machine learning, pages 4095– 4104. PMLR, 2018.
253
+ [47] 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.
254
+ [48] Sucheng Ren, Daquan Zhou, Shengfeng He, Jiashi Feng, and Xinchao Wang. Shunted selfattention via multi-scale token aggregation. In IEEE Conference on Computer Vision and Pattern Recognition, 2022.
255
+ [49] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations (ICLR), 2015.
256
+ [50] Baochen Sun, Jiashi Feng, and Kate Saenko. Return of frustratingly easy domain adaptation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 30, 2016.
257
+ [51] Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning (ICML), pages 6105–6114, 2019.
258
+ [52] Ilya Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Daniel Keysers, Jakob Uszkoreit, Mario Lucic, et al. MLP-Mixer: An all-mlp architecture for vision. arXiv preprint arXiv:2105.01601, 2021.
259
+ [53] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. In International Conference on Machine Learning (ICML), 2021.
260
+ [54] Hugo Touvron, Matthieu Cord, Alaaeldin El-Nouby, Jakob Verbeek, and Hervé Jégou. Three things everyone should know about vision transformers. arXiv preprint arXiv:2203.09795, 2022.
261
+ [55] Grant Van Horn, Steve Branson, Ryan Farrell, Scott Haber, Jessie Barry, Panos Ipeirotis, Pietro Perona, and Serge Belongie. Building a bird recognition app and large scale dataset with citizen scientists: The fine print in fine-grained dataset collection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 595–604, 2015.
262
+ [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 Advances in Neural Information Processing Systems (NeurIPS), 2017.
263
+ [57] Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge Belongie. The caltech-ucsd birds-200-2011 dataset. 2011.
264
+ [58] Yuxin Wu and Kaiming He. Group normalization. In Proceedings of the European conference on computer vision (ECCV), pages 3–19, 2018.
265
+ [59] Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), July 2017.
266
+ [60] Xingyi Yang, Jingwen Ye, and Xinchao Wang. Factorizing knowledge in neural networks. In Proceedings of the European Conference on Computer Vision, 2022.
267
+ [61] Yiding Yang, Zunlei Feng, Mingli Song, and Xinchao Wang. Factorizable graph convolutional networks. In Conference on Neural Information Processing Systems, 2020.
268
+ [62] Yiding Yang, Jiayan Qiu, Mingli Song, Dacheng Tao, and Xinchao Wang. Distilling knowledge from graph convolutional networks. In IEEE Conference on Computer Vision and Pattern Recognition, 2020.
269
+ [63] Jingwen Ye, Yifang Fu, Jie Song, Xingyi Yang, Songhua Liu, Xin Jin, Mingli Song, and Xinchao Wang. Learning with recoverable forgetting. In Proceedings of the European Conference on Computer Vision, 2022.
270
+ [64] Weihao Yu, Mi Luo, Pan Zhou, Chenyang Si, Yichen Zhou, Xinchao Wang, Jiashi Feng, and Shuicheng Yan. Metaformer is actually what you need for vision. In IEEE Conference on Computer Vision and Pattern Recognition, 2022.
271
+ [65] Sergey Zagoruyko and Nikos Komodakis. Diracnets: Training very deep neural networks without skip-connections. arXiv preprint arXiv:1706.00388, 2017.
272
+ [66] Elad Ben Zaken, Shauli Ravfogel, and Yoav Goldberg. Bitfit: Simple parameter-efficient fine-tuning for transformer-based masked language-models. arXiv preprint arXiv:2106.10199, 2021.
273
+ [67] Xiaohua Zhai, Joan Puigcerver, Alexander Kolesnikov, Pierre Ruyssen, Carlos Riquelme, Mario Lucic, Josip Djolonga, Andre Susano Pinto, Maxim Neumann, Alexey Dosovitskiy, et al. A large-scale study of representation learning with the visual task adaptation benchmark. arXiv preprint arXiv:1910.04867, 2019.
274
+ [68] Yuanhan Zhang, Kaiyang Zhou, and Ziwei Liu. Neural prompt search. arXiv preprint arXiv:2206.04673, 2022.
275
+ [69] Daquan Zhou, Bingyi Kang, Xiaojie Jin, Linjie Yang, Xiaochen Lian, Zihang Jiang, Qibin Hou, and Jiashi Feng. DeepViT: Towards deeper vision transformer. arXiv preprint arXiv:2103.11886, 2021.
276
+ [70] Daquan Zhou, Zhiding Yu, Enze Xie, Chaowei Xiao, Anima Anandkumar, Jiashi Feng, and Jose M Alvarez. Understanding the robustness in vision transformers. arXiv preprint arXiv:2204.12451, 2022.
277
+ [71] Kaiyang Zhou, Jingkang Yang, Chen Change Loy, and Ziwei Liu. Learning to prompt for vision-language models. arXiv preprint arXiv:2109.01134, 2021.
278
+
279
+ # Checklist
280
+
281
+ 1. For all authors...
282
+
283
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See abstract, introduction and experiments.
284
+ (b) Did you describe the limitations of your work? [Yes] See appendix.
285
+ (c) Did you discuss any potential negative societal impacts of your work? [Yes] See appendix.
286
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
287
+
288
+ 2. If you are including theoretical results...
289
+
290
+ (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]
291
+
292
+ 3. 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] See abstract and experiments.
295
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See experiments.
296
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A] A part of the experiments is tested several times.
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 experiments.
298
+
299
+ 4. 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]
303
+ (c) Did you include any new assets either in the supplemental material or as a URL? [Yes]
304
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
305
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See appendix.
306
+
307
+ 5. If you used crowdsourcing or conducted research with human subjects...
308
+
309
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
310
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
311
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
md/dev/fvLLcIYmXb/fvLLcIYmXb.md ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AS-MLP: AN AXIAL SHIFTED MLP ARCHITECTURE FOR VISION
2
+
3
+ Dongze Lian∗, Zehao $\mathbf { V } \mathbf { u } ^ { * }$
4
+ ShanghaiTech University
5
+ {liandz,yuzh}@shanghaitech.edu.cn
6
+ Xing Sun
7
+ Youtu Lab, Tencent
8
+ {winfredsun}@tencent.com
9
+ Shenghua Gao†
10
+ ShanghaiTech University &
11
+ Shanghai Engineering Research Center of Intelligent Vision and Imaging &
12
+ Shanghai Engineering Research Center of Energy Efficient and Custom AI IC
13
+ {gaoshh}@shanghaitech.edu.cn
14
+
15
+ # ABSTRACT
16
+
17
+ An Axial Shifted MLP architecture (AS-MLP) is proposed in this paper. Different from MLP-Mixer, where the global spatial feature is encoded for information flow through matrix transposition and one token-mixing MLP, we pay more attention to the local features interaction. By axially shifting channels of the feature map, ASMLP is able to obtain the information flow from different axial directions, which captures the local dependencies. Such an operation enables us to utilize a pure MLP architecture to achieve the same local receptive field as CNN-like architecture. We can also design the receptive field size and dilation of blocks of AS-MLP, etc, in the same spirit of convolutional neural networks. With the proposed ASMLP architecture, our model obtains $8 3 . 3 \%$ Top-1 accuracy with 88M parameters and 15.2 GFLOPs on the ImageNet-1K dataset. Such a simple yet effective architecture outperforms all MLP-based architectures and achieves competitive performance compared to the transformer-based architectures (e.g., Swin Transformer) even with slightly lower FLOPs. In addition, AS-MLP is also the first MLP-based architecture to be applied to the downstream tasks (e.g., object detection and semantic segmentation). The experimental results are also impressive. Our proposed AS-MLP obtains $5 1 . 5 \mathrm { m A P }$ on the COCO validation set and $4 9 . 5 \mathrm { M S }$ mIoU on the ADE20K dataset, which is competitive compared to the transformer-based architectures. Our AS-MLP establishes a strong baseline of MLP-based architecture. Code is available at https://github.com/svip-lab/AS-MLP.
18
+
19
+ # 1 INTRODUCTION
20
+
21
+ In the past decade, Convolutional Neural Networks (CNNs) (Krizhevsky et al., 2012; He et al., 2016) have received widespread attention and have become the de-facto standard for computer vision. Furthermore, with the in-depth exploration and research on self-attention, transformer-based architectures have also gradually emerged, and have surpassed CNN-based architectures in natural language processing (e.g., Bert (Devlin et al., 2018)) and vision understanding (e.g., ViT (Dosovitskiy et al., 2021), DeiT (Touvron et al., 2021b)) with amounts of training data. Recently, Tolstikhin et al. (2021) first propose MLP-based architecture, where almost all network parameters are learned from MLP (linear layer). It achieves amazing results, which is comparable with CNN-like models.
22
+
23
+ Such promising results drive our exploration of MLP-based architecture. In the MLP-Mixer (Tolstikhin et al., 2021), the model obtains the global receptive field through matrix transposition and token-mixing projection such that the long-range dependencies are covered. However, this rarely makes full use of the local information, which is very important in CNN-like architecture (Simonyan & Zisserman, 2015; He et al., 2016) because not all pixels need long-range dependencies, and the local information focuses more on extracting the low-level features. In the transformer-based architectures, Swin Transformer (Liu et al., 2021b) computes the self-attention in a window $( 7 \times 7 )$ instead of the global receptive field, which is similar to directly using a convolution layer with a large kernel size $( 7 \times 7 )$ to cover the local receptive field. Some other papers have also already emphasized the advantages of local receptive fields, and introduced local information in the transformer, such as Localvit (Li et al., 2021), NesT (Zhang et al., 2021), etc. Driven by these ideas, we mainly explore the influence of locality on MLP-based architectures.
24
+
25
+ In order to introduce locality into the MLP-based architecture, one of the simplest and most intuitive ideas is to add a window to the MLP-Mixer, and then perform a token-mixing projection of the local features within the window, just as done in Swin Transformer (Liu et al., 2021b) and LINMAPPER (Fang et al., 2021). However, if we divide the window (e.g., $7 \times 7 ~ ,$ ) and perform the token-mixing projection in the window, then the linear layer has the $4 9 \times 4 9$ parameters shared between windows, which greatly limits the model capacity and thus affects the learning of parameters and final results. Conversely, if the linear layer is not shared between windows, the model weights trained with fixed image size cannot be adapted to downstream tasks with various input sizes because unfixed input sizes will cause a mismatch in the number of windows.
26
+
27
+ Therefore, a more ideal way to introduce locality is to directly model the relationship between a feature point and its surrounding feature points at any position, without the need to set a fixed window (and window size) in advance. To aggregate the features of different spatial positions in the same position and model their relationships, inspired by (Wu et al., 2018; Lin et al., 2019; Wang et al., 2020; Ho et al., 2019), we propose an axial shift strategy for MLP-based architecture, where we spatially shift features in both horizontal and vertical directions. Such an approach not only aggregates features from different locations, but also makes the feature channel only need to be divided into $k$ groups instead of $k ^ { 2 }$ groups to obtain a receptive field of size $k \times k$ with the help of axial operation. After that, a channel-mixing MLP combines these features, enabling the model to obtain local dependencies. It also allows us to design MLP structure as the same as the convolutional kernel, for instance, to design the kernel size and dilation rate.
28
+
29
+ Based on the axial shift strategy, we design Axial Shifted MLP architecture, named AS-MLP. Our AS-MLP obtains $8 3 . 3 \%$ Top-1 accuracy with 88M parameters and 15.2 GFLOPs in the ImageNet1K dataset without any extra training data. Such a simple yet effective method outperforms all MLP-based architectures and achieves competitive performance compared to the transformer-based architectures. It is also worth noting that the model weights in MLP-Mixer trained with fixed image size cannot be adapted to downstream tasks with various input sizes because the token-mixing MLP has a fixed dimension. On the contrary, the AS-MLP architecture can be transferred to downstream tasks (e.g., object detection) due to the design of axial shift. As far as we know, it is also the first work to apply MLP-based architecture to the downstream task. With the pre-trained model in the ImageNet-1K dataset, AS-MLP obtains $5 1 . 5 \mathrm { m A P }$ on the COCO validation set and 49.5 MS mIoU on the ADE20K dataset, which is competitive compared to the transformer-based architectures.
30
+
31
+ # 2 RELATED WORK
32
+
33
+ CNN-based Architectures. Since AlexNet (Krizhevsky et al., 2012) won the ImageNet competition in 2012, the CNN-based architectures have gradually been utilized to automatically extract image features instead of hand-crafted features. Subsequently, the VGG network (Simonyan & Zisserman, 2015) is proposed, which purely uses a series of $3 \times 3$ convolution and fully connected layers. ResNet (He et al., 2016) utilizes the residual connection to transfer features in different layers, which alleviates the gradient vanishing and obtains superior performance. Some papers make further improvements to the convolution operation in CNN-based architecture, such as dilated convolution (Yu & Koltun, 2016) and deformable convolution (Dai et al., 2017). EfficientNet (Tan & Le, 2019; 2021) introduces neural architecture search into CNN to search for a suitable network structure. These architectures build the CNN family and are used extensively in computer vision tasks.
34
+
35
+ Transformer-based Architectures. Transformer is first proposed in (Vaswani et al., 2017), where the attention mechanism is utilized to model the relationship between features from the different spatial positions. Subsequently, the popularity of BERT (Devlin et al., 2018) in NLP also promotes the research on transformer in the field of vision. ViT (Dosovitskiy et al., 2021) uses a transformer framework to extract visual features, where an image is divided into $1 6 \times 1 6$ patches and the convolution layer is completely abandoned. It shows that the transformer-based architecture can perform well in large-scale datasets (e.g., JFT-300M). After that, DeiT (Touvron et al., 2021b) carefully designs training strategies and data augmentation to further improve performance on the small datasets (e.g., ImageNet-1K). DeepViT (Zhou et al., 2021) and CaiT (Touvron et al., 2021c) consider the optimization problem when the network deepens, and train a deeper transformer network. CrossViT (Chen et al., 2021a) combines the local patch and global patch by using two vision transformers. CPVT (Chu et al., 2021b) uses a conditional position encoding to effectively encode the spatial positions of patches. LeViT (Graham et al., 2021) improves ViT from many aspects, including the convolution embedding, extra non-linear projection and batch normalization, etc. Transformer-LS (Zhu et al., 2021) proposes a long-range attention and a short-term attention to model long sequences for both language and vision tasks. Some papers also design hierarchical backbone to extract spatial features at different scales, such as PVT (Wang et al., 2021), Swin Transformer (Liu et al., 2021b), Twins (Chu et al., 2021a) and NesT (Zhang et al., 2021), which can be applied to downstream tasks.
36
+
37
+ ![](images/7bc0a6174566e4ae149019444920a776e8ffad7bf1c7e706e49dcbd970a22af1.jpg)
38
+ Figure 1: A tiny version of the overall Axial Shifted MLP (AS-MLP) architecture.
39
+
40
+ MLP-based Architectures. MLP-Mixer (Tolstikhin et al., 2021) designs a very concise framework that utilizes matrix transposition and MLP to transmit information between spatial features, and obtains promising performance. The concurrent work FF (Melas-Kyriazi, 2021) also applies a similar network architecture and reaches similar conclusions. Subsequently, Res-MLP (Touvron et al., 2021a) is proposed, which also obtains impressive performance with residual MLP only trained on ImageNet-1K. gMLP (Liu et al., 2021a) and EA (Guo et al., 2021) introduce Spatial Gating Unit (SGU) and the external attention to improve the performance of the pure MLP-based architecture, respectively. Recently, Container (Gao et al., 2021) proposes a general network that unifies convolution, transformer, and MLP-Mixer. $S ^ { 2 }$ -MLP (Yu et al., 2021) uses spatial-shift MLP for feature exchange. ViP (Hou et al., 2021). proposes a Permute-MLP layer for spatial information encoding to capture long-range dependencies. Different from these work, we focus on capturing the local dependencies with axially shifting features in the spatial dimension, which obtains better performance and can be applied to the downstream tasks. Besides, the closest concurrent work with us, CycleMLP (Chen et al., 2021b) and $S ^ { 2 }$ -MLPv2 (Yu et al., 2021) are also proposed. $S ^ { 2 }$ -MLPv2 improves $S ^ { 2 }$ -MLP and CycleMLP designs Cycle Fully-Connected Layer (Cycle FC) to obtain a larger receptive field than Channel FC.
41
+
42
+ # 3 THE AS-MLP ARCHITECTURE
43
+
44
+ # 3.1 OVERALL ARCHITECTURE
45
+
46
+ Figure 1 shows our Axial Shifted MLP (AS-MLP) architecture, which refers to the style of Swin Transformer (Liu et al., 2021b). Given an RGB image $I \in \mathbb { R } ^ { 3 \times H \times W }$ , where $H$ and $W$ are the height and width of the image, respectively, AS-MLP performs the patch partition operation, which splits the original image into multiple patch tokens with the patch size of $4 \times 4$ , thus the combination of all tokens has the size of $4 8 \times \frac { \mathbf { \dot { H } } } { 4 } \times \frac { \mathbf { \dot { W } } } { 4 }$ . AS-MLP has four stages in total and there are different numbers of AS-MLP blocks in different stages. Figure 1 only shows the tiny versxion of AS-MLP, and other variants will be discussed in Sec. 3.4. All the tokens in the previous step will go through these four stages, and the final output feature will be used for image classification. In Stage 1, a linear embedding and the AS-MLP blocks are adopted for each token. The output has the dimension of $\begin{array} { r } { C \times \frac { H } { 4 } \times \frac { W } { 4 } } \end{array}$ , where $C$ is the number of channels. Stage 2 first performs patch merging on the features outputted from the previous stage, which groups the neighbor $2 \times 2$ patches to obtain a the size of , followed $4 C \times \frac { H } { 8 } \times \frac { W } { 8 }$ and then a linear layer is adopted to warp the feature size tod AS-MLP blocks. Stage 3 and Stage 4 have similar structures $2 C \times \frac { H } { 8 } \times \frac { W } { 8 }$ to Stage 2, and the hierarchical representations will be generated in these stages.
47
+
48
+ ![](images/893579b97b82df95082f799137c8a88b5be7f565961b1629db338d4b4aa46b57.jpg)
49
+ Figure 2: (a) shows the structure of the AS-MLP block; (b) shows the horizontal shift, where the arrows indicate the steps, and the number in each box is the index of the feature.
50
+
51
+ # 3.2 AS-MLP BLOCK
52
+
53
+ The core operation of AS-MLP architecture is the AS-MLP block, which is illustrated in Figure 2a. It mainly consists of the Norm layer, Axial Shift operation, MLP, and residual connection. In the Axial Shift operation, we utilize the channel projection, vertical shift, and horizontal shift to extract features, where the channel projection maps the feature with a linear layer. Vertical shift and horizontal shift are responsible for the feature translation along the spatial directions.
54
+
55
+ As shown in Figure 2b, we take the horizontal shift as an example. The input has the dimension of $C \times h \times w$ . For convenience, we omit $h$ and assume $C = 3$ , $w = 5$ in this figure. When the shift size is 3, the input feature is split into three parts and they are shifted by $\{ - 1 , 0 , 1 \}$ units along the horizontal direction, respectively. In this operation, zero padding is performed (indicated by gray blocks), and we also discuss the experimental results of using other padding methods in Sec. 4. After that, the features in the dashed box will be taken out and used for the next channel projection. The same operation is also performed in the vertical shift. In the process of both shifts, since the feature performs different shift units, the information from different spatial positions can be combined together. In the next channel projection operation, information from different spatial locations can fully flow and interact. The code of AS-MLP block is listed in Alg. 1.
56
+
57
+ Complexity. In the transformer-based architecture, the multi-head self-attention (MSA) is usually adopted, where the attention between tokens is computed. Swin Transformer (Liu et al., 2021b) introduces a window to partition the image and propose window multi-head self-attention (W-MSA), which only considers the computation within this window. It significantly reduces the computation complexity. However, in the AS-MLP block, without the concept of the window, we only Axially Shift (AS) the feature from the previous layer, which does not require any multiplication and addition operations. Further, the time cost of Axial Shift is very low and almost irrelevant to the shift size. Given a feature map (is usually named patches in transformer) with the dimension of $C \times h \times w$ , each Axial shift operation in Figure 2a only has four channel projection operations, which has the computation complexity $4 h w C ^ { 2 }$ . If the window size in Swin Transformer (Liu et al., 2021b) is $M$ , the complexities of MSA, W-MSA and AS are as follows:
58
+
59
+ $$
60
+ \left\{ \begin{array} { l l } { \Omega ( \mathbf { M S A } ) = 4 h w C ^ { 2 } + 2 ( h w ) ^ { 2 } C , } \\ { \Omega ( \mathbf { W } \mathbf { - M S A } ) = 4 h w C ^ { 2 } + 2 M ^ { 2 } h w C , } \\ { \Omega ( \mathbf { A S } ) = 4 h w C ^ { 2 } . } \end{array} \right.
61
+ $$
62
+
63
+ Therefore, the AS-MLP architecture has slightly less complexity than Swin Transformer. The specific complexity calculation of each layer is shown in Appendix A.2.
64
+
65
+ 3.3 COMPARISONS BETWEEN AS-MLP, CONVOLUTION, TRANSFORMER AND MLP-MIXER
66
+
67
+ In this section, we compare AS-MLP with the recent distinct building blocks used in computer vision, e.g., the standard convolution, Swin Transformer, and MLP-Mixer. Although these modules are explored in completely different routes, from the perspective of calculation, they are all based on a given output location point, and the output depends on the weighted sum of different sampling location features (multiplication and addition operation). These sampling location features include local dependencies (e.g., convolution) and long-range dependencies (e.g., MLP-Mixer). Figure 3 shows the main differences of these modules in the sampling location. Given an input feature map $X \in \mathbb { R } ^ { H \times W \times C }$ , the outputs $Y _ { i , j }$ with different operations in position $( i , j )$ are as follows:
68
+
69
+ # Algorithm 1 Code of AS-MLP Block in a PyTorch-like style.
70
+
71
+ # norm: normalization layer # proj: channel projection # actn: activation layer
72
+
73
+ import torch import torch.nn.functional as F def shift(x, dim): $\qquad \times \quad =$ F.pad(x, "constant", 0) $\qquad \times \quad =$ torch.chunk(x, shift_size, 1) $\qquad \times \quad =$ [ torch.roll(x_s, shift, dim) for x_s, shift in zip(x, range(-pad, pad+1))] $\qquad \times \quad =$ torch.cat $( \mathbf { x } , \mathbf { \mu } \_ { 1 } )$ return x[:, :, pad:-pad, pad:-pad]
74
+
75
+ def as_mlp_block $\mathbf { \tau } ( \mathbf { x } )$ : shortcut $= \times$ $\qquad \times \quad =$ norm(x) $\qquad \times \quad =$ actn(norm(proj(x))) $\mathrm { ~ ~ \times ~ } _ { - } \mathrm { 1 } \mathrm { r } \mathrm { ~ ~ = ~ }$ actn(proj(shift(x, 3))) x_td $=$ actn(proj(shift(x, 2))) x = x_lr + x_td $\qquad \times \quad =$ proj(norm(x)) return x + shortcut
76
+
77
+ ![](images/26cc2c812e703f1780338926a05f2cb5fec08d748f9f7a9e92310e4ca8d790be.jpg)
78
+ Figure 3: The different sampling locations of convolution, Swin Transformer, MLP-Mixer, and AS-MLP. e.g., AS-MLP $s = 3$ , $d = 1$ ) shows the sampling locations when the shift size is 3 and dilation is 1.
79
+
80
+ Convolution. For convolution operation, a sliding kernel with the shape of $k \times k$ (receptive field region $\mathcal { R }$ ) is performed on $X$ to obtain the output $Y _ { i , j } ^ { \mathrm { c o n v } }$ :
81
+
82
+ $$
83
+ Y _ { i , j } ^ { \mathrm { c o n v } } = \sum _ { ( m , n ) \in { \mathcal R } } X _ { i + m , j + n , : } W _ { m , n , : } ^ { \mathrm { c o n v } } ,
84
+ $$
85
+
86
+ where $W ^ { \mathrm { c o n v } } \in \mathbb { R } ^ { k \times k \times C }$ is the learnable weight. $h$ and $w$ are the height and width of $X$ , respectively. As shown in Figure 3, the convolution operation has a local receptive field, thus it is more suitable at extracting features with the local dependencies.
87
+
88
+ Swin Transformer. Swin Transformer introduces a window into the transformer-based architecture to cover the local attention. The input $X$ from a window is embedded to obtain $Q , K , V$ matrix, and the output $Y _ { \mathrm { s w i n } }$ is the attention combination of features within the window:
89
+
90
+ $$
91
+ Y _ { i , j } ^ { \mathrm { s w i n } } = \mathrm { S o f t m a x } ( Q ( X _ { i , j } ) K ( X ) ^ { T } / \sqrt { d } ) V ( X ) .
92
+ $$
93
+
94
+ The introduction of locality further improves the performance of the transformer-based architecture and reduces the computational complexity.
95
+
96
+ MLP-Mixer. MLP-Mixer abandons the attention opera token-mixing MLP is appended to obtain the output It first transposes the input : $X$ , and then $Y _ { i , j } ^ { \mathrm { m i x e r } }$
97
+
98
+ $$
99
+ \begin{array} { r } { Y _ { i , j } ^ { \mathrm { m i x e r } } = ( X ^ { T } W _ { i W + j } ^ { \mathrm { m i x e r } } ) ^ { T } , } \end{array}
100
+ $$
101
+
102
+ where $W ^ { \mathrm { m i x e r } } \in \mathbb { R } ^ { h w \times h w }$ is the learnable weight in token-mixing MLP. MLP-Mixer perceives the global information only with matrix transposition and MLP.
103
+
104
+ AS-MLP. AS-MLP axially shifts the feature map as shown in Figure 2b. Given the input $X$ , shift size $s$ and dilation rate $d$ , $X$ is first divided into $s$ splits in the horizontal and vertical direction. After the axial shift in Figure 2b, the output $Y _ { i , j } ^ { \mathrm { a s } }$ is:
105
+
106
+ $$
107
+ Y _ { i , j } ^ { \mathrm { a s } } = \sum _ { c = 0 } ^ { C } X _ { i + \lfloor \frac { c } { \lceil C / s \rceil } \rfloor - \lfloor \frac { s } { 2 } \rfloor \cdot d , j , c } W _ { c } ^ { \mathrm { a s } \cdot \mathrm { h } } + \sum _ { c = 0 } ^ { C } X _ { i , j + \lfloor \frac { c } { \lceil C / s \rceil } \rfloor - \lfloor \frac { s } { 2 } \rfloor \cdot d , c } W _ { c } ^ { \mathrm { a s } \cdot \mathrm { v } }
108
+ $$
109
+
110
+ where $W ^ { \mathrm { a s \mathrm { - } h } } , W ^ { \mathrm { a s \mathrm { - } v } } \in \mathbb { R } ^ { C }$ are the learnable weights of channel projection in the horizontal and vertical directions (here we omit activation function and bias). Unlike MLP-Mixer, we pay more attention to the local dependencies through axial shift of features and channel projection. Such an operation is closely related to Shift (Wu et al., 2018) and TSM (Lin et al., 2019). However, our method has the following characteristics: i) we use axial shift in the horizontal and vertical directions, which focuses more on the information exchange in two directions; ii) the proposed network is built upon Swin transformer and pure MLP-based architecture, where only linear layer is used and BN is replaced by LN; iii) as will be shown in Sec. 4, our network achieves superior performance, which shows the effectiveness of our method. Although such an operation can be implemented in the original shift (Wu et al., 2018), the feature channel needs to split into $k ^ { 2 }$ groups to achieve a receptive field of size $k \times k$ . However, the axial operation makes the feature channel only need to be divided into $k$ groups instead of $k ^ { 2 }$ groups, which reduces the complexity.
111
+
112
+ <table><tr><td>Network</td><td>Input Resolution</td><td>Top-1 (%)</td><td>Params</td><td>FLOPs</td><td>Throughput (image/s)</td></tr><tr><td colspan="6">CNN-based</td></tr><tr><td>RegNetY-8GF (Radosavovic et al.,2020)</td><td>224× 224</td><td>81.7</td><td>39M</td><td>8.0G</td><td>591.6</td></tr><tr><td>RegNetY-16GF(Radosavovic et al.,2020)</td><td>224× 224</td><td>82.9</td><td>84M</td><td>15.9G</td><td>334.7</td></tr><tr><td>EfficientNet-B5 (Tan&amp;Le,2019)</td><td>456 × 456</td><td>83.6</td><td>30M</td><td>9.9G</td><td>169.1</td></tr><tr><td colspan="6">Transformer-based</td></tr><tr><td>ViT-B/16 (Dosovitskiy et al., 2021)</td><td>384×384</td><td>77.9</td><td>86M</td><td>55.5G</td><td>85.9</td></tr><tr><td>DeiT-B/16 (Touvron et al.,2021b)</td><td>224× 224</td><td>81.8</td><td>86M</td><td>17.6G</td><td>292.3</td></tr><tr><td>PVT-Large (Wang et al.,2021)</td><td>224 × 224</td><td>82.3</td><td>61M</td><td>9.8G</td><td>-</td></tr><tr><td>Swin-T (Liu et al.,2021b)</td><td>224 × 224</td><td>81.3</td><td>29M</td><td>4.5G</td><td>755.2</td></tr><tr><td>Swin-S (Liu et al.,2021b)</td><td>224 × 224</td><td>83.0</td><td>50M</td><td>8.7G</td><td>436.9</td></tr><tr><td>Swin-B (Liu et al.,2021b)</td><td>224 × 224</td><td>83.3</td><td>88M</td><td>15.4G</td><td>278.1</td></tr><tr><td>Swin-B (Liu et al.,2021b)</td><td>384×384</td><td>84.2</td><td>88M</td><td>47.0G</td><td>84.7</td></tr><tr><td colspan="6">MLP-based</td></tr><tr><td>gMLP-S (Liu et al.,2021a)</td><td>224× 224</td><td>79.4</td><td>20M</td><td>4.5G</td><td></td></tr><tr><td>ViP-Small/14 (Hou et al.,2021)</td><td>224× 224</td><td>80.5</td><td>30M</td><td>-</td><td>789.0</td></tr><tr><td>ViP-Small/7 (Hou et al.,2021)</td><td>224×224</td><td>81.5</td><td>25M</td><td>■</td><td>719.0</td></tr><tr><td>AS-MLP-T(ours)</td><td>224×224</td><td>81.3</td><td>28M</td><td>4.4G</td><td>1047.7</td></tr><tr><td>Mixer-B/16 (Tolstikhin et al., 2021)</td><td>224× 224</td><td>76.4</td><td>59M</td><td>11.7G</td><td>=</td></tr><tr><td>FF (Melas-Kyriazi,2021)</td><td>224× 224</td><td>74.9</td><td>62M</td><td>11.4G</td><td>-</td></tr><tr><td>ResMLP-36 (Touvron et al.,2021a)</td><td>224× 224</td><td>79.7</td><td>45M</td><td>8.9G</td><td>478.7</td></tr><tr><td>S²-MLP-wide(Yu et al.,2021)</td><td>224× 224</td><td>80.0</td><td>68M</td><td>13.0G</td><td>-</td></tr><tr><td>S²-MLP-deep (Yu et al.,2021)</td><td>224× 224</td><td>80.7</td><td>51M</td><td>9.7G</td><td>=</td></tr><tr><td>ViP-Medium/7 (Hou et al.,2021)</td><td>224×224</td><td>82.7</td><td>55M</td><td>-</td><td>418.0</td></tr><tr><td>AS-MLP-S (ours)</td><td>224× 224</td><td>83.1</td><td>50M</td><td>8.5G</td><td>619.5</td></tr><tr><td>gMLP-B (Liu et al.,2021a)</td><td>224× 224</td><td>81.6</td><td>73M</td><td>15.8G</td><td>-</td></tr><tr><td>ViP-Large/7 (Hou et al.,2021)</td><td>224× 224</td><td>83.2</td><td>88M</td><td></td><td>298.0</td></tr><tr><td>AS-MLP-B (ours)</td><td>224× 224</td><td>83.3</td><td>88M</td><td>15.2G</td><td>455.2</td></tr><tr><td>AS-MLP-B (ours)</td><td>384× 384</td><td>84.3</td><td>88M</td><td>44.6G</td><td>179.2</td></tr></table>
113
+
114
+ Table 1: The experimental results of different networks on ImageNet-1K. Throughput is measured with the batch size of 64 on a single V100 GPU (32GB). The more complete accuracy and throughput comparisons are listed in Appendix B.2.
115
+
116
+ # 3.4 VARIANTS OF AS-MLP ARCHITECTURE
117
+
118
+ Figure 1 only shows the tiny version of our AS-MLP architecture. Following DeiT (Touvron et al., 2021b) and Swin Transformer (Liu et al., 2021b), we also stack different number of AS-MLP blocks (the number of blocks in four stages) and expand the channel dimension $C$ in Figure 1) to obtain variants of the AS-MLP architecture of different model sizes, which are AS-MLP-Tiny (AS-MLPT), AS-MLP-Small (AS-MLP-S) and AS-MLP-Base (AS-MLP-B), respectively. The specific configuration is as follows:
119
+
120
+ • AS-MLP-T: $C = 9 6$ , the number of blocks in four stages $= \{ 2 , 2 , 6 , 2 \}$ ;
121
+ • AS-MLP-S: $C = 9 6$ , the number of blocks in four stages $= \{ 2 , 2 , 1 8 , 2 \}$ ;
122
+ • AS-MLP-B: $C = 1 2 8$ , the number of blocks in four stages $= \{ 2 , 2 , 1 8 , 2 \}$ .
123
+
124
+ The detailed configurations can be found in Appendix A.1. Table 1 in Sec. 4 shows Top-1 accuracy, model size (Params), computation complexity (FLOPs) and throughput of different variants.
125
+
126
+ # 4 EXPERIMENTS
127
+
128
+ # 4.1 IMAGE CLASSIFICATION ON THE IMAGENET-1K DATASET
129
+
130
+ Settings. To evaluate the effectiveness of our AS-MLP, we conduct experiments of the image classification on the ImageNet-1K benchmark, which is collected in (Deng et al., 2009). It contains 1.28M training images and 20K validation images from a total of 1000 classes. We report the experimental results with single-crop Top-1 accuracy. We use an initial learning rate of 0.001 with cosine decay and 20 epochs of linear warm-up. The AdamW (Loshchilov & Hutter, 2019) optimizer is employed to train the whole model for 300 epochs with a batch size of 1024. Following the training strategy of Swin Transformer (Liu et al., 2021b), we also use label smoothing (Szegedy et al., 2016) with a smooth ratio of 0.1 and DropPath (Huang et al., 2016) strategy.
131
+
132
+ Results. All image classification results are shown in Table 1. We divide all network architectures into CNN-based, Transformer-based and MLP-based architectures. The input resolution is $2 2 4 \times 2 2 4$ . Our proposed AS-MLP outperforms other MLP-based architectures when keeping similar parameters and FLOPs. e.g., AS-MLP-S obtains higher top-1 accuracy $( 8 3 . 1 \% )$ with fewer parameters than Mixer-B/16 (Tolstikhin et al., 2021) $( 7 6 . 4 \% )$ and ViP-Medium/7 (Hou et al., 2021) $( 8 2 . 7 \% )$ . Furthermore, it achieves competitive performance compared with transformer-based architectures, e.g., AS-MLP-B $( 8 3 . 3 \% )$ vs. Swin-B (Liu et al., 2021b) $( 8 3 . 3 \% )$ , which shows the effectiveness of our AS-MLP architecture.
133
+
134
+ Results of Mobile Setting. In addition to standard experiments, we also compare the results of AS-MLP in the mobile setting, which is shown in Table 2. We build the Swin (mobile) model and AS-MLP (mobile) model with similar parameters (about
135
+
136
+ <table><tr><td>Method</td><td>Top-1(%)</td><td>Top-5 (%)</td><td>Params</td></tr><tr><td>Swin (mobile)</td><td>75.11</td><td>92.50</td><td>11.2M</td></tr><tr><td>AS-MLP (mobile)</td><td>76.05</td><td>92.81</td><td>9.6M</td></tr></table>
137
+
138
+ Table 2: The result comparisons of the mobile setting.
139
+
140
+ 10M). The specific network details can be found in Appendix A.3. The experimental results show that our model significantly exceeds Swin Transformer (Liu et al., 2021b) in the mobile setting ( $7 6 . 0 5 \%$ vs. $7 5 . 1 1 \%$ ).
141
+
142
+ # 4.2 THE CHOICE AND IMPACT OF AS-MLP BLOCK
143
+
144
+ The core component in the AS-MLP block is the axial shift. We perform experiments to analyze the choices of different configurations of the AS-MLP block, its connection types and the impact of AS-MLP block. All ablations are conducted based on the AS-MLP-T, as shown in the setting of Sec. 3.4.
145
+
146
+ <table><tr><td>Connection type</td><td>Structure</td><td>Top-1 (%)</td><td>Top-5 (%)</td></tr><tr><td rowspan="4">Serial</td><td>(1,1)→(1,1)</td><td>74.32</td><td>91.46</td></tr><tr><td>(3,3)→(3,3)</td><td>81.21</td><td>95.42</td></tr><tr><td>(5,5)→(5,5)</td><td>81.28</td><td>95.58</td></tr><tr><td>(7,7)→(7,7)</td><td>81.17</td><td>95.54</td></tr><tr><td rowspan="4">Parallel</td><td>(1,1) + (1,1)</td><td>74.17</td><td>91.13</td></tr><tr><td>(3,3)+ (3,3)</td><td>81.26</td><td>95.48</td></tr><tr><td>(5,5)+(5,5)</td><td>81.34</td><td>95.56</td></tr><tr><td>(7,7) + (7,7)</td><td>81.32</td><td>95.55</td></tr></table>
147
+
148
+ Table 3: Choices of different configurations and connection types.
149
+
150
+ <table><tr><td>Shift size</td><td>Padding method</td><td>d.r.</td><td>Top-1 (%)</td><td>Top-5 (%)</td></tr><tr><td>(1,1)</td><td>N/A</td><td></td><td>74.17</td><td>91.13</td></tr><tr><td>(3,3)</td><td>No /Circular padding</td><td>11</td><td>81.04</td><td>95.37</td></tr><tr><td>(3,3)</td><td>Zero padding</td><td>1</td><td>81.26</td><td>95.48</td></tr><tr><td>(3,3)</td><td>Reflect padding</td><td></td><td>81.14</td><td>95.37</td></tr><tr><td>(3,3)</td><td>Replicate padding</td><td>11</td><td>81.14</td><td>95.42</td></tr><tr><td>(3,3)</td><td>Zero padding</td><td></td><td>80.50</td><td>95.12</td></tr><tr><td>(5,5)</td><td>Zero padding</td><td>22</td><td>80.57</td><td>95.12</td></tr><tr><td>(5,5)</td><td>Zero padding</td><td>1</td><td>81.34</td><td>95.56</td></tr><tr><td>(7,7)</td><td>Zero padding</td><td></td><td>81.32</td><td>95.55</td></tr><tr><td>(9,9)</td><td>Zero padding</td><td>1</td><td>81.16</td><td>95.45</td></tr></table>
151
+
152
+ (a) The impacts of the different configurations of the AS-MLP architecture. d.r. means dilation rate.
153
+
154
+ (b) The impacts of the different connection types.
155
+ $\because$ means serial and $\cdot _ { + } ,$ means parallel.
156
+
157
+ Different Configurations of AS-MLP Block. In order to encourage the information flow from different channels in the spatial dimension, the features from the horizontal shift and the vertical shift are aggregated together in Figure 2. We evaluate the influence of different configurations of AS-MLP block, including shift size, padding method, and dilation rate, which are similar to the configuration of a convolution kernel. All experiments of different configurations are shown in Table 3a. We have three findings as follows: i) ‘Zero padding’ is more suitable for the design of AS-MLP block than other padding methods1; ii) increasing the dilation rate slightly reduces the performance of AS-MLP, which is consistent with CNN-based architecture. Dilation is usually used for semantic segmentation rather than image classification; iii) when expanding the shift size, the accuracy will increase first and then decrease. A possible reason is that the receptive field is enlarged (shift size $= 5$ or 7) such that AS-MLP pays attention to the global dependencies, but when shift size is 9, the network pays too much attention to the global dependencies, thus neglecting the extraction of local features, which leads to lower accuracy. Therefore, we use the configuration (shift size $= 5$ , zero padding, dilation rate $= 1$ ) in all experiments, including object detection and semantic segmentation.
158
+
159
+ Connection Type. We also compare the different connection types of AS-MLP block, such as serial connection and parallel connection, and the results are shown in Table 3b. Parallel connection consistently outperforms serial connection in terms of different shift sizes, which shows the effectiveness of the parallel connection. When the shift size is 1, the serial connection is better but it is not representative because only channel-mixing MLP is used.
160
+
161
+ The Impact of AS-MLP Block. We also evaluate the impact of AS-MLP block in Table 4. Here we design five baselines: i) Global-MLP; ii) AxialMLP; iii) Window-MLP; iv) shift size (5, 1); v) shift size (1, 5). The first three baselines are designed from the perspective of how to use MLP for feature fusion at different positions, and the latter two are designed from the perspective of the axial shift in a single direction. The specific settings are listed in Appendix A.5. The results in Table 4 show that our AS-MLP block with shift size (5, 5) outperforms other baselines.
162
+
163
+ Table 4: The impact of AS-MLP block.
164
+
165
+ <table><tr><td>Method</td><td>Top-1(%)|Method</td><td>Top-1 (%)</td></tr><tr><td>Global-MLP</td><td>79.81</td><td>(5,1) 78.37</td></tr><tr><td>Axial-MLP</td><td>79.69</td><td>(1,5) 78.45</td></tr><tr><td>Window-MLP</td><td>78.40</td><td>(5,5) 81.34</td></tr></table>
166
+
167
+ <table><tr><td>Backbone</td><td>Ap</td><td>AP</td><td>AP5</td><td>APm</td><td>AP</td><td>AP</td><td>Params</td><td>FLOPs</td></tr><tr><td colspan="9">Mask R-CNN (3×)</td></tr><tr><td>ResNet50 (He et al.,2016)</td><td>41.0</td><td>61.7</td><td>44.9</td><td>37.1</td><td>58.4</td><td>40.1</td><td>44M</td><td>260G</td></tr><tr><td>PVT-Small (Wang et al., 2021)</td><td>43.0</td><td>65.3</td><td>46.9</td><td>39.9</td><td>62.5</td><td>42.8</td><td>44M</td><td>245G</td></tr><tr><td>Swin-T (Liu et al., 2021b)</td><td>46.0</td><td>68.2</td><td>50.2</td><td>41.6</td><td>65.1</td><td>44.8</td><td>48M</td><td>267G</td></tr><tr><td>AS-MLP-T (ours)</td><td>46.0</td><td>67.5</td><td>50.7</td><td>41.5</td><td>64.6</td><td>44.5</td><td>48M</td><td>260G</td></tr><tr><td>ResNet101 (He et al.,2016)</td><td>42.8</td><td>63.2</td><td>47.1</td><td>38.5</td><td>60.1</td><td>41.3</td><td>63M</td><td>336G</td></tr><tr><td>PVT-Medium (Wang et al.,2021)</td><td>44.2</td><td>66.0</td><td>48.2</td><td>40.5</td><td>63.1</td><td>43.5</td><td>64M</td><td>302G</td></tr><tr><td>Swin-S (Liu et al.,2021b)</td><td>48.5</td><td>70.2</td><td>53.5</td><td>43.3</td><td>67.3</td><td>46.6</td><td>69M</td><td>359G</td></tr><tr><td>AS-MLP-S (ours)</td><td>47.8</td><td>68.9</td><td>52.5</td><td>42.9</td><td>66.4</td><td>46.3</td><td>69M</td><td>346G</td></tr><tr><td colspan="9">Cascade Mask R-CNN (3×)</td></tr><tr><td>DeiT-S (Touvron et al.,2021b) ResNet50 (He et al.,2016)</td><td>48.0 46.3</td><td>67.2 64.3</td><td>51.7 50.5</td><td>41.4 40.1</td><td>64.2 61.7</td><td>44.3 43.4</td><td>80M 82M</td><td>889G 739G</td></tr><tr><td>Swin-T (Liu et al., 2021b)</td><td>50.5</td><td>69.3</td><td>54.9</td><td>43.7</td><td>66.6</td><td>47.1</td><td>86M</td><td>745G</td></tr><tr><td>AS-MLP-T (ours)</td><td>50.1</td><td>68.8</td><td>54.3</td><td>43.5</td><td>66.3</td><td>46.9</td><td>86M</td><td>739G</td></tr><tr><td>ResNext101-32 (Xie et al., 2017)</td><td>48.1</td><td>66.5</td><td>52.4</td><td>41.6</td><td>63.9</td><td>45.2</td><td>101M</td><td>819G</td></tr><tr><td>Swin-S (Liu et al., 2021b)</td><td>51.8</td><td>70.4</td><td>56.3</td><td>44.7</td><td>67.9</td><td>48.5</td><td>107M</td><td>838G</td></tr><tr><td>AS-MLP-S (ours)</td><td>51.1</td><td>69.8</td><td>55.6</td><td>44.2</td><td>67.3</td><td>48.1</td><td>107M</td><td>824G</td></tr><tr><td>ResNext101-64 (Xie et al.,2017)</td><td>48.3</td><td>66.4</td><td>52.3</td><td>41.7</td><td>64.0</td><td>45.1</td><td>140M</td><td>972G</td></tr><tr><td>Swin-B (Liu et al., 2021b)</td><td>51.9</td><td>70.9</td><td>56.5</td><td>45.0</td><td>68.4</td><td>48.7</td><td>145M</td><td>982G</td></tr><tr><td></td><td></td><td>70.0</td><td>56.0</td><td>44.7</td><td>67.8</td><td>48.4</td><td>145M</td><td></td></tr><tr><td>AS-MLP-B (ours)</td><td>51.5</td><td></td><td></td><td></td><td></td><td></td><td></td><td>961G</td></tr></table>
168
+
169
+ Table 5: The object detection and instance segmentation results of different backbones with $3 \mathbf { x }$ schedule on the COCO val2017 dataset. The results with 1x schedule are listed in Appendix B.1.
170
+
171
+ # 4.3 OBJECT DETECTION ON COCO
172
+
173
+ The experimental setting is listed in Appendix A.4, and the results are shown in Table 5. It is worth noting that we do not compare our method with MLP-Mixer (Tolstikhin et al., 2021) because it uses a fixed spatial dimension for token-mixing MLP, which cannot be transferred to the object detection. As far as we know, we are the first work to apply MLP-based architecture to object detection. Our AS-MLP achieves comparable performance with Swin Transformer in the similar resource limitation. To be specific, Cascade Mask R-CNN $^ +$ Swin-B achieves $5 1 . 9 \mathrm { A P } ^ { b }$ with 145M parameters and 982 GFLOPs, and Cascade Mask R-CNN $^ +$ AS-MLP-B obtains $5 1 . 5 \mathsf { A P } ^ { b }$ with 145M parameters and 961 GFLOPs. The visualizations of object detection are shown in Appendix C.
174
+
175
+ # 4.4 SEMANTIC SEGMENTATION ON ADE20K
176
+
177
+ The experimental setting is listed in Appendix A.4 and Table 6 shows the performance of our ASMLP on the ADE20K dataset. Note that we are also the first to apply the MLP-based architecture to semantic segmentation. With slightly lower FLOPs, AS-MLP-T achieves better result than Swin-T (46.5 vs. 45.8 MS mIoU). For the large model, UperNet $^ +$ Swin-B has 49.7 MS mIoU with 121M parameters and 1188 GFLOPs, and UperNet $^ +$ AS-MLP-B has 49.5 MS mIoU with 121M parameters and 1166 GFLOPs, which also shows the effectiveness of our AS-MLP architecture in processing the downstream task. The visualizations of semantic segmentation are shown in Appendix C.
178
+
179
+ Table 6: The semantic segmentation results of different backbones on the ADE20K validation set.
180
+
181
+ <table><tr><td>Method</td><td>Backbone</td><td>val MS mIoU</td><td>Params</td><td>FLOPs</td></tr><tr><td>DANet (Fu et al., 2019a)</td><td>ResNet-101</td><td>45.2</td><td>69M</td><td>1119G</td></tr><tr><td>DeepLabv3+ (Chen et al.,2018)</td><td>ResNet-101</td><td>44.1</td><td>63M</td><td>1021G</td></tr><tr><td>ACNet (Fu et al.,2019b)</td><td>ResNet-101</td><td>45.9</td><td>-</td><td>1</td></tr><tr><td>DNL (Yin et al., 2020)</td><td>ResNet-101</td><td>46.0</td><td>69M</td><td>1249G</td></tr><tr><td>OCRNet (Yuan et al.,2020)</td><td>ResNet-101</td><td>45.3</td><td>56M</td><td>923G</td></tr><tr><td>UperNet (Xiao et al.,2018)</td><td>ResNet-101</td><td>44.9</td><td>86M</td><td>1029G</td></tr><tr><td>OCRNet (Yuan et al.,2020)</td><td>HRNet-w48</td><td>45.7</td><td>71M</td><td>664G</td></tr><tr><td>DeepLabv3+ (Chen et al.,2018)</td><td>ResNeSt-101</td><td>46.9</td><td>66M</td><td>1051G</td></tr><tr><td>DeepLabv3+ (Chen et al.,2018)</td><td>ResNeSt-200</td><td>48.4</td><td>88M</td><td>1381G</td></tr><tr><td>UperNet (Xiao et al., 2018)</td><td>Swin-T (Liu et al., 2021b) AS-MLP-T (ours)</td><td>45.8</td><td>60M</td><td>945G</td></tr><tr><td>UperNet (Xiao et al., 2018)</td><td>Swin-S (Liu et al., 2021b)</td><td>46.5 49.5</td><td>60M 81M</td><td>937G 1038G</td></tr><tr><td></td><td>AS-MLP-S (ours)</td><td>49.2</td><td>81M</td><td>1024G</td></tr><tr><td>UperNet (Xiao et al., 2018)</td><td>Swin-B (Liu et al.,2021b) AS-MLP-B (ours)</td><td>49.7 49.5</td><td>121M 121M</td><td>1188G 1166G</td></tr></table>
182
+
183
+ # 4.5 VISUALIZATION
184
+
185
+ We visualize the heatmap of learned features from Swin Transformer and AS-MLP in Figure 4, where the first column shows the image from ImageNet, and the second column shows the activation heatmap of the last layer of Swin transformer (Swin-B). The third, fourth, and fifth columns respectively indicate the response after the horizontal shift (AS-MLP (h)), the vertical shift (AS-MLP (v)) and the combination of both in the last layer of AS-MLP (AS-MLPB). From Figure 4, one can see that i) AS-MLP can better focus on object regions compared to Swin transformer; ii) AS-MLP (h) can better focus on the vertical part of objects (as shown in the second row) because it shifts feature in the horizontal direction. It is more reasonable because the shift in the horizontal direction can cover the edge of the vertical part, which is more helpful for recognizing the object. Sim
186
+
187
+ ![](images/e6ffe365d77646daca07fdd7d15e242d84e3dcaef1a38baa1e47c22f26b9c2c7.jpg)
188
+ Figure 4: The visualization of features from Swin Transformer and our AS-MLP.
189
+
190
+ ilarly, AS-MLP (v) can better focus on the horizontal part of objects (as shown in the fourth row).
191
+
192
+ # 5 CONCLUSION AND FUTURE WORK
193
+
194
+ In this paper, we propose an axial shifted MLP architecture, named AS-MLP, for vision. Compared with MLP-Mixer, we pay more attention to the local features extraction and make full use of the channel interaction between different spatial positions through a simple feature axial shift. With the proposed AS-MLP, we further improve the performance of MLP-based architecture and the experimental results are impressive. Our model obtains $8 3 . 3 \%$ Top-1 accuracy with 88M parameters and 15.2 GFLOPs on the ImageNet-1K dataset. Such a simple yet effective method outperforms all MLP-based architectures and achieves competitive performance compared to the transformerbased architectures even with slightly lower FLOPs. We are also the first work to apply AS-MLP to the downstream tasks (e.g., object detection and semantic segmentation). The results are also competitive or even better compared to transformer-based architectures, which shows the ability of MLP-based architectures in handling downstream tasks.
195
+
196
+ For future work, we will investigate the effectiveness of AS-MLP in natural language processing, and further explore the performance of AS-MLP on downstream tasks.
197
+
198
+ # ACKNOWLEDGEMENT
199
+
200
+ We would like to thank Ke Li, Hao Cheng and Weixin Luo for their valuable discussions and feedback. This work was supported by National Key R&D Program of China (2018AAA0100704), NSFC #61932020, #62172279, Science and Technology Commission of Shanghai Municipality (Grant No. 20ZR1436000), and “Shuguang Program” supported by Shanghai Education Development Foundation and Shanghai Municipal Education Commission.
201
+
202
+ # REFERENCES
203
+
204
+ Zhaowei Cai and Nuno Vasconcelos. Cascade R-CNN: Delving into high quality object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 6154–6162, 2018.
205
+
206
+ 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 (ECCV), pp. 213–229. Springer, 2020.
207
+
208
+ Chun-Fu (Richard) Chen, Quanfu Fan, and Rameswar Panda. CrossViT: Cross-attention multiscale vision transformer for image classification. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 357–366, October 2021a.
209
+
210
+ Kai Chen, Jiaqi Wang, Jiangmiao Pang, Yuhang Cao, Yu Xiong, Xiaoxiao Li, Shuyang Sun, Wansen Feng, Ziwei Liu, Jiarui Xu, et al. MMDetection: Open mmlab detection toolbox and benchmark. arXiv preprint arXiv:1906.07155, 2019.
211
+
212
+ Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam. Encoderdecoder with atrous separable convolution for semantic image segmentation. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 801–818, 2018.
213
+
214
+ Shoufa Chen, Enze Xie, Chongjian Ge, Ding Liang, and Ping Luo. Cyclemlp: A mlp-like architecture for dense prediction. arXiv preprint arXiv:2107.10224, 2021b.
215
+
216
+ Xiangxiang Chu, Zhi Tian, Yuqing Wang, Bo Zhang, Haibing Ren, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Twins: Revisiting the design of spatial attention in vision transformers. In Advances in Neural Information Processing Systems (NeurIPS), 2021a.
217
+
218
+ Xiangxiang Chu, Zhi Tian, Bo Zhang, Xinlong Wang, Xiaolin Wei, Huaxia Xia, and Chunhua Shen. Conditional positional encodings for vision transformers. arXiv preprint arXiv:2102.10882, 2021b.
219
+
220
+ MMSegmentation Contributors. MMSegmentation: Openmmlab semantic segmentation toolbox and benchmark. https://github.com/open-mmlab/mmsegmentation, 2020.
221
+
222
+ Jifeng Dai, Haozhi Qi, Yuwen Xiong, Yi Li, Guodong Zhang, Han Hu, and Yichen Wei. Deformable convolutional networks. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), pp. 764–773, 2017.
223
+
224
+ 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 the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 248–255, 2009.
225
+
226
+ 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.
227
+
228
+ 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 (ICLR), 2021.
229
+
230
+ Yuxin Fang, Xinggang Wang, Rui Wu, Jianwei Niu, and Wenyu Liu. What makes for hierarchical vision transformer? arXiv preprint arXiv:2107.02174, 2021.
231
+
232
+ Jun Fu, Jing Liu, Haijie Tian, Yong Li, Yongjun Bao, Zhiwei Fang, and Hanqing Lu. Dual attention network for scene segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 3146–3154, 2019a.
233
+
234
+ Jun Fu, Jing Liu, Yuhang Wang, Yong Li, Yongjun Bao, Jinhui Tang, and Hanqing Lu. Adaptive context network for scene parsing. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), pp. 6748–6757, 2019b.
235
+
236
+ Peng Gao, Jiasen Lu, Hongsheng Li, Roozbeh Mottaghi, and Aniruddha Kembhavi. Container: Context aggregation network. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
237
+
238
+ Benjamin Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Herve Jegou, and Matthijs Douze. Levit: A vision transformer in convnet’s clothing for faster inference. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 12259– 12269, 2021.
239
+
240
+ Meng-Hao Guo, Zheng-Ning Liu, Tai-Jiang Mu, and Shi-Min Hu. Beyond self-attention: External attention using two linear layers for visual tasks. arXiv preprint arXiv:2105.02358, 2021.
241
+
242
+ 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.
243
+
244
+ 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 (CVPR), pp. 770–778, 2016.
245
+
246
+ Kaiming He, Georgia Gkioxari, Piotr Dollar, and Ross Girshick. Mask R-CNN. In ´ Proceedings of the IEEE International Conference on Computer Vision (ICCV), pp. 2961–2969, 2017.
247
+
248
+ Jonathan Ho, Nal Kalchbrenner, Dirk Weissenborn, and Tim Salimans. Axial attention in multidimensional transformers. arXiv preprint arXiv:1912.12180, 2019.
249
+
250
+ Qibin Hou, Zihang Jiang, Li Yuan, Ming-Ming Cheng, Shuicheng Yan, and Jiashi Feng. Vision permutator: A permutable mlp-like architecture for visual recognition. arXiv preprint arXiv:2106.12368, 2021.
251
+
252
+ Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European Conference on Computer Vision (ECCV), pp. 646–661. Springer, 2016.
253
+
254
+ 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.
255
+
256
+ Yawei Li, Kai Zhang, Jiezhang Cao, Radu Timofte, and Luc Van Gool. Localvit: Bringing locality to vision transformers. arXiv preprint arXiv:2104.05707, 2021.
257
+
258
+ 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, pp. 7083–7093, 2019.
259
+
260
+ Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C Lawrence Zitnick. Microsoft COCO: Common objects in context. In ´ European Conference on Computer Vision (ECCV), pp. 740–755. Springer, 2014.
261
+
262
+ Hanxiao Liu, Zihang Dai, David R So, and Quoc V Le. Pay attention to mlps. arXiv preprint arXiv:2105.08050, 2021a.
263
+
264
+ 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 International Conference on Computer Vision (ICCV), 2021b.
265
+
266
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019.
267
+
268
+ Luke Melas-Kyriazi. Do you even need attention? a stack of feed-forward layers does surprisingly well on imagenet. arXiv preprint arXiv:2105.02723, 2021.
269
+
270
+ Ilija Radosavovic, Raj Prateek Kosaraju, Ross Girshick, Kaiming He, and Piotr Dollar. Designing ´ network design spaces. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
271
+
272
+ Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations (ICLR), 2015.
273
+
274
+ Peize Sun, Rufeng Zhang, Yi Jiang, Tao Kong, Chenfeng Xu, Wei Zhan, Masayoshi Tomizuka, Lei Li, Zehuan Yuan, Changhu Wang, et al. Sparse R-CNN: End-to-end object detection with learnable proposals. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 14454–14463, 2021.
275
+
276
+ Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2818–2826, 2016.
277
+
278
+ Mingxing Tan and Quoc Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning (ICML), pp. 6105–6114, 2019.
279
+
280
+ Mingxing Tan and Quoc V Le. Efficientnetv2: Smaller models and faster training. In International Conference on Machine Learning (ICML), 2021.
281
+
282
+ Ilya Tolstikhin, Neil Houlsby, Alexander Kolesnikov, Lucas Beyer, Xiaohua Zhai, Thomas Unterthiner, Jessica Yung, Daniel Keysers, Jakob Uszkoreit, Mario Lucic, et al. MLP-Mixer: An all-mlp architecture for vision. arXiv preprint arXiv:2105.01601, 2021.
283
+
284
+ Hugo Touvron, Piotr Bojanowski, Mathilde Caron, Matthieu Cord, Alaaeldin El-Nouby, Edouard Grave, Armand Joulin, Gabriel Synnaeve, Jakob Verbeek, and Herve J ´ egou. ResMLP: ´ Feedforward networks for image classification with data-efficient training. arXiv preprint arXiv:2105.03404, 2021a.
285
+
286
+ Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Herve J ´ egou. Training data-efficient image transformers & distillation through attention. In ´ International Conference on Machine Learning (ICML), 2021b.
287
+
288
+ Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Herve J ´ egou. Go-´ ing deeper with image transformers. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), 2021c.
289
+
290
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
291
+
292
+ Huiyu Wang, Yukun Zhu, Bradley Green, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen. Axial-deeplab: Stand-alone axial-attention for panoptic segmentation. In European Conference on Computer Vision (ECCV), 2020.
293
+
294
+ 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 Proceedings of the IEEE International Conference on Computer Vision (ICCV), 2021.
295
+
296
+ Bichen Wu, Alvin Wan, Xiangyu Yue, Peter Jin, Sicheng Zhao, Noah Golmant, Amir Gholaminejad, Joseph Gonzalez, and Kurt Keutzer. Shift: A zero flop, zero parameter alternative to spatial convolutions. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 9127–9135, 2018.
297
+
298
+ Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, and Jian Sun. Unified perceptual parsing for scene understanding. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 418–434, 2018.
299
+
300
+ Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), July 2017.
301
+
302
+ Minghao Yin, Zhuliang Yao, Yue Cao, Xiu Li, Zheng Zhang, Stephen Lin, and Han Hu. Disentangled non-local neural networks. In European Conference on Computer Vision (ECCV), pp. 191–207. Springer, 2020.
303
+
304
+ Fisher Yu and Vladlen Koltun. Multi-scale context aggregation by dilated convolutions. In International Conference on Learning Representations (ICLR), 2016.
305
+
306
+ Tan Yu, Xu Li, Yunfeng Cai, Mingming Sun, and Ping Li. $S ^ { 2 }$ -MLP: Spatial-shift mlp architecture for vision. arXiv preprint arXiv:2106.07477, 2021.
307
+
308
+ 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. In Proceedings of the IEEE International Conference on Computer Vision (ICCV), 2021.
309
+
310
+ Yuhui Yuan, Xilin Chen, and Jingdong Wang. Object-contextual representations for semantic segmentation. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part VI 16, pp. 173–190. Springer, 2020.
311
+
312
+ Zizhao Zhang, Han Zhang, Long Zhao, Ting Chen, and Tomas Pfister. Aggregating nested transformers. arXiv preprint arXiv:2105.12723, 2021.
313
+
314
+ Daquan Zhou, Bingyi Kang, Xiaojie Jin, Linjie Yang, Xiaochen Lian, Zihang Jiang, Qibin Hou, and Jiashi Feng. DeepViT: Towards deeper vision transformer. arXiv preprint arXiv:2103.11886, 2021.
315
+
316
+ Chen Zhu, Wei Ping, Chaowei Xiao, Mohammad Shoeybi, Tom Goldstein, Anima Anandkumar, and Bryan Catanzaro. Long-short transformer: Efficient transformers for language and vision. arXiv preprint arXiv:2107.02192, 2021.
317
+
318
+ # A THE ARCHITECTURE DETAILS
319
+
320
+ # A.1 THE DETAILED CONFIGURATIONS OF DIFFERENT ARCHITECTURES
321
+
322
+ We show the detailed configurations of different architectures in Table 7, where we assume the size of the input image is $2 2 4 \times 2 2 4$ . The second column shows the output size of the image after each stage. Following Swin Transformer (Liu et al., 2021b), we use “Concat $n \times n ^ { \prime \prime }$ to indicate a concatenation of $n \times n$ neighboring features in a patch. “shift size (5, 5)” means that the shift size in the horizontal and vertical directions is 5.
323
+
324
+ Table 7: The detailed configurations of different architectures.
325
+
326
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>downsp. rate(output size)</td><td rowspan=1 colspan=2>AS-MLP-T</td><td rowspan=1 colspan=3>AS-MLP-S</td><td rowspan=1 colspan=3>AS-MLP-B</td></tr><tr><td rowspan=2 colspan=1>stage 1</td><td rowspan=2 colspan=1>4×(56×56)</td><td rowspan=1 colspan=2>concat 4×4, 96-d, LN</td><td rowspan=1 colspan=3>concat 4×4, 96-d,LN</td><td rowspan=1 colspan=3>concat 4×4,128-d,LN</td></tr><tr><td rowspan=1 colspan=1>shift size (5,5),dim 96</td><td rowspan=1 colspan=1>×2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>shift size (5,5),dim 96</td><td rowspan=1 colspan=1>×2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>shift size (5,5),dim 128</td><td rowspan=1 colspan=1>×2</td></tr><tr><td rowspan=2 colspan=1>stage 2</td><td rowspan=2 colspan=1>8×(28×28)</td><td rowspan=1 colspan=2>concat 2×2,192-d,LN</td><td rowspan=1 colspan=3>concat 2×2,192-d,LN</td><td rowspan=1 colspan=3>concat 2×2, 256-d ,LN</td></tr><tr><td rowspan=1 colspan=1>shift size (5,5),dim 192</td><td rowspan=1 colspan=1>×2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>shift size (5,5),dim 192</td><td rowspan=1 colspan=1>×2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>shift size (5,5),dim 256</td><td rowspan=1 colspan=1>×2</td></tr><tr><td rowspan=2 colspan=1>stage 3</td><td rowspan=2 colspan=1>16×(14×14)</td><td rowspan=1 colspan=2>concat 2×2,384-d,LN</td><td rowspan=1 colspan=3>concat 2×2,384-d,LN</td><td rowspan=1 colspan=3>concat 2×2,512-d,LN</td></tr><tr><td rowspan=1 colspan=1>shift size (5,5),dim 384</td><td rowspan=1 colspan=1>×6</td><td rowspan=1 colspan=2>shift size (5,5),dim 384</td><td rowspan=1 colspan=1>×18</td><td rowspan=1 colspan=2>shift size (5,5),dim 512</td><td rowspan=1 colspan=1>×18</td></tr><tr><td rowspan=2 colspan=1> stage 4</td><td rowspan=2 colspan=1>32×(7×7)</td><td rowspan=1 colspan=2>concat 2×2, 768-d ,LN</td><td rowspan=1 colspan=3>concat 2×2,768-d,LN</td><td rowspan=1 colspan=3>concat 2×2,1024-d,LN</td></tr><tr><td rowspan=1 colspan=1>shift size (5,5),dim 768</td><td rowspan=1 colspan=1>×2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>[shift size (5,5),dim 768</td><td rowspan=1 colspan=1>×2</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>[shift size (5,5),dim 1024</td><td rowspan=1 colspan=1>×2</td></tr><tr><td rowspan=1 colspan=2>Params</td><td rowspan=1 colspan=2>28M</td><td rowspan=1 colspan=3>50M</td><td rowspan=1 colspan=3>88M</td></tr><tr><td rowspan=1 colspan=2>FLOPs</td><td rowspan=1 colspan=2>4.4G</td><td rowspan=1 colspan=3>8.5G</td><td rowspan=1 colspan=3>15.2G</td></tr></table>
327
+
328
+ # A.2 THE COMPUTATIONAL COMPLEXITY OF AS-MLP ARCHITECTURE
329
+
330
+ In this section, we show the specific computational complexity in each layer of AS-MLP architecture. The symbol definition is first given as follows. An input image: $\dot { I ^ { \mathrm { ~ ~ } } } \in \mathbb { R } ^ { 3 \times H \times W }$ ; patch size $( p , p )$ ; the number of blocks in four stages: $\{ n _ { 1 } , n _ { 2 } , n _ { 3 } , n _ { 4 } \}$ ; Channel dimension $C$ ; MLP ratio: $r$ . The specific computational complexity is shown in Table 8, where only convolution operation is computed.
331
+
332
+ Table 8: The computational complexity of the AS-MLP Architecture.
333
+
334
+ <table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>Stage 1</td><td rowspan=1 colspan=2>Stage 2</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Linear embedding</td><td rowspan=1 colspan=1>AS-MLP block</td><td rowspan=1 colspan=1>Patch merging</td><td rowspan=1 colspan=1>AS-MLP block</td></tr><tr><td rowspan=1 colspan=1>ParamsFLOPs</td><td rowspan=1 colspan=1>3Cp23Cp2HWpp</td><td rowspan=1 colspan=1>(4+ 2r)C²n1(4+2r)C2HW,n1pp</td><td rowspan=1 colspan=1>8C2802W2p2p</td><td rowspan=1 colspan=1>(4+ 2r)4C²n2(4+2r)4C2n22p2p</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=2>Stage 3</td><td rowspan=1 colspan=2>Stage 4</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Patch merging</td><td rowspan=1 colspan=1>AS-MLP block</td><td rowspan=1 colspan=1>Patch merging</td><td rowspan=1 colspan=1>AS-MLP block</td></tr><tr><td rowspan=1 colspan=1>ParamsFLOPs</td><td rowspan=1 colspan=1>32C232C2W4p4p</td><td rowspan=1 colspan=1>(4 + 2r)16C²n3(4+2r)16C2n</td><td rowspan=1 colspan=1>128C2128C2W8p8p</td><td rowspan=1 colspan=1>(4 + 2r)64C²n4(4+2r)64C2n48p8p</td></tr></table>
335
+
336
+ # A.3 THE NETWORK DETAILS IN THE MOBILE SETTING
337
+
338
+ In addition to AS-MLP-T, AS-MLP-S, and AS-MLP-B, we also design AS-MLP in the mobile setting. For a fair comparison, we modify the Swin Transformer correspondingly to adopt to the mobile setting. The configurations are as follow:
339
+
340
+ • Swin (mobile): $C = 6 4$ , the number of blocks in four stages $= \{ 2 , 2 , 2 , 2 \}$ , the number of heads $= \{ 2 , 4 , 8 , 1 6 \}$ ; • AS-MLP (mobile): $C = 6 4$ , the number of blocks in four stages $= \{ 2 , 2 , 2 , 2 \}$ ;
341
+
342
+ A.4 THE SETTINGS OF OBJECT DETECTION AND SEMANTIC SEGMENTATION
343
+
344
+ Object Detection on COCO. For the object detection and instance segmentation, we employ mmdetection (Chen et al., 2019) as the framework and COCO (Lin et al., 2014) as the evaluation dataset, which consists of 118K training data and 5K validation data. We compare the performance of our AS-MLP with other backbones on COCO. Following Swin Transformer (Liu et al., 2021b), we consider two typical object detection frameworks: Mask R-CNN (He et al., 2017) and Cascade R-CNN (Cai & Vasconcelos, 2018). The training strategies are as follows: optimizer (AdamW), learning rate (0.0001), weight decay (0.05), and batch size (2 imgs/per $\mathrm { G P U } \times 8$ GPUs). We utilize the typical multi-scale training strategy (Carion et al., 2020; Sun et al., 2021) (the shorter side is between 480 and 800 and the longer side is at most 1333). All backbones are initialized with weights pre-trained on ImageNet-1K and all models are trained with 3x schedule (36 epochs).
345
+
346
+ Semantic Segmentation on ADE20K. Following Swin Transformer (Liu et al., 2021b), we conduct experiments of AS-MLP on the challenging semantic segmentation dataset, ADE20K, which contains 20,210 training images and 2,000 validation images. We utilize UperNet (Xiao et al., 2018) and AS-MLP backbone as our main experimental results. The framework is based on mmsegmentation (Contributors, 2020). The training strategies are as follows: optimizer (AdamW), learning rate $( 6 \times 1 0 ^ { - 5 } )$ ), weight decay (0.01), and batch size (2 imgs/per $\mathrm { G P U } \times 8$ GPUs). We utilize random horizontal flipping, random re-scaling within ratio range [0.5, 2.0] and random photometric distortion as data augmentation. The input image resolution is $5 1 2 \times 5 1 2$ , the stochastic depth ratio is set as 0.3 and all models are initialized with weights pre-trained on ImageNet-1K and are trained 160K iterations.
347
+
348
+ # A.5 BASELINES
349
+
350
+ We list the specific configurations of baselines in Sec. 4.2 as follows.
351
+
352
+ • Global-MLP: following MLP-Mixer (Tolstikhin et al., 2021), we use global MLP (tokenmixing MLP) along with full spatial size instead of AS-MLP block in our architecture configurations. For Global-MLP, the model weights trained with fixed image size cannot be adapted to downstream tasks with various input sizes.
353
+ • Axial-MLP: built upon Global-MLP, Axial-MLP employs two axial MLPs along with horizontal and vertical directions instead of global MLP. Similar to Global-MLP, the model weights trained with fixed image size cannot be adapted to downstream tasks with various input sizes.
354
+ • Window-MLP: as stated in Sec 1, we set fixed window $( 7 \times 7 )$ in our architecture configurations and perform MLP operations within the window.
355
+ • Shift size (5, 1): horizontal shift is 5 and vertical shift is 1 in AS-MLP block.
356
+ • Shift size $( 1 , 5 )$ : horizontal shift is 1 and vertical shift is 5 in AS-MLP block.
357
+
358
+ # A.6 DIFFERENCES BETWEEN AS-MLP AND TSM
359
+
360
+ We elaborate the differences between AS-MLP and TSM as follows.
361
+
362
+ • TSM performs a shift in the temporal dimension and, as stated in (Lin et al., 2019), they target the temporal dimension for efficient video understanding. However, we explore the shift from a spatial perspective, for the more general tasks, such as image classification, object detection, and segmentation.
363
+
364
+ Table 9: The object detection and instance segmentation results of different backbones with 1x schedule on the COCO val2017 dataset. Mask R-CNN and Cascade Mask R-CNN frameworks are employed.
365
+
366
+ <table><tr><td>Backbone</td><td>APb</td><td>AP</td><td>AP5</td><td>APm</td><td>AP</td><td>AP7</td><td>Params</td><td>FLOPs</td></tr><tr><td colspan="9">Mask R-CNN (1×)</td></tr><tr><td>ResNet50 (He et al., 2016)</td><td>38.0</td><td>58.6</td><td>41.4</td><td>34.4</td><td>55.1</td><td>36.7</td><td>44M</td><td>260G</td></tr><tr><td>PVT-Small(Wang et al., 2021)</td><td>40.4</td><td>62.9</td><td>43.8</td><td>37.8</td><td>60.1</td><td>40.3</td><td>44M</td><td>245G</td></tr><tr><td>Swin-T (Liu et al.,2021b)</td><td>43.7</td><td>66.6</td><td>47.7</td><td>39.8</td><td>63.3</td><td>42.7</td><td>48M</td><td>267G</td></tr><tr><td>AS-MLP-T (ours)</td><td>44.0</td><td>66.0</td><td>48.5</td><td>40.0</td><td>62.8</td><td>43.1</td><td>48M</td><td>260G</td></tr><tr><td>ResNet101 (He et al., 2016)</td><td>40.4</td><td>61.1</td><td>44.2</td><td>36.4</td><td>57.7</td><td>38.8</td><td>63M</td><td>336G</td></tr><tr><td>PVT-Medium (Wang et al.,2021)</td><td>42.0</td><td>64.4</td><td>45.6</td><td>39.0</td><td>61.6</td><td>42.1</td><td>64M</td><td>302G</td></tr><tr><td>AS-MLP-S (ours)</td><td>46.7</td><td>68.8</td><td>51.4</td><td>42.0</td><td>65.6</td><td>45.2</td><td>69M</td><td>346G</td></tr><tr><td colspan="9">Cascade Mask R-CNN (1×)</td></tr><tr><td>ResNet50 (He et al., 2016)</td><td>46.3</td><td>64.3</td><td>50.5</td><td>40.1</td><td>61.7</td><td>43.4</td><td>82M</td><td>739G</td></tr><tr><td>Swin-T (Liu et al.,2021b)</td><td>48.1</td><td>67.1</td><td>52.2</td><td>41.7</td><td>64.4</td><td>45.0</td><td>86M</td><td>745G</td></tr><tr><td>AS-MLP-T (ours)</td><td>48.4</td><td>67.1</td><td>52.6</td><td>42.0</td><td>64.5</td><td>45.3</td><td>86M</td><td>739G</td></tr><tr><td>AS-MLP-S (ours)</td><td>50.5</td><td>69.4</td><td>54.7</td><td>43.7</td><td>66.9</td><td>47.3</td><td>107M</td><td>824G</td></tr><tr><td>AS-MLP-B (ours)</td><td>51.1</td><td>70.0</td><td>55.6</td><td>44.2</td><td>67.4</td><td>47.8</td><td>145M</td><td>961G</td></tr></table>
367
+
368
+ • TSM shows that shifting too many channels in a network will significantly hurt the spatial modeling ability and result in performance degradation. However, Table reftable: ablation(a) shows that as the shift size increases, the channel needs to be divided into more parts, but the performance does not decrease significantly. This suggests that the argument of TSM is not obvious in the pure MLP architecture.
369
+
370
+ • Our motivation is quite different. TSM is designed to be more effective and efficient on video. Our motivation is derived from Swin Transformer’s exploration of the local receptive field of the transformer. We use shift to explore the local receptive field of MLP. Also, ASMLP is the first MLP-based architecture for object detection and semantic segmentation with the help of such a method. Furthermore, we use axial shift to reduce the complexity of the shift split.
371
+
372
+ # B MORE EXPERIMENTS
373
+
374
+ # B.1 MORE EXPERIMENTAL RESULTS ON COCO
375
+
376
+ Table 5 lists the object detection and instance segmentation results of different backbones with $3 \mathbf { x }$ schedule (36 epochs). For a complete comparison, we also conduct experiments with 1x schedule (12 epochs). The results are shown in Table 9. Our AS-MLP-T outperforms Swin-T (Liu et al., 2021b) under the Mask R-CNN (44.0 vs. $4 3 . 7 \mathrm { A P } ^ { b }$ ) and Cascade Mask R-CNN (48.4 vs. $4 8 . 1 \mathrm { \ A P } ^ { b }$ ) frameworks.
377
+
378
+ # B.2 THE COMPLETE CLASSIFICATION ACCURACY AND THROUGHPUT COMPARISON
379
+
380
+ Table 10 shows the complete accuracy comparison with other state-of-the-art architectures on the ImageNet-1K dataset. In addition, Table 1 shows the throughput results of the AS-MLP architecture measured with the batch size 64 on a single V100 GPU (32GB). In order to make a fair comparison with other papers, we also conduct a thorough evaluation of throughput. The results are shown in Figure 5, where we list the throughputs when the batch size is 1, 4, 8, 16, 32, 64, 128, respectively.
381
+
382
+ <table><tr><td>Network</td><td>Input Resolution</td><td>Top-1 (%)</td><td>Params</td><td>FLOPs</td><td>Throughput (image /s)</td></tr><tr><td colspan="6">CNN-based</td></tr><tr><td>RegNetY-8GF (Radosavovic et al.,2020)</td><td>224× 224</td><td>81.7</td><td>39M</td><td>8.0G</td><td>591.6</td></tr><tr><td>RegNetY-16GF (Radosavovic et al., 2020)</td><td>224× 224</td><td>82.9</td><td>84M</td><td>15.9G</td><td>334.7</td></tr><tr><td>EfficientNet-B3 (Tan&amp;Le,2019)</td><td>300 ×300</td><td>81.6</td><td>12M</td><td>1.8G</td><td>732.1</td></tr><tr><td>EfficientNet-B5 (Tan &amp;Le,2019)</td><td>456×456</td><td>83.6</td><td>30M</td><td>9.9G</td><td>169.1</td></tr><tr><td colspan="6">Transformer-based</td></tr><tr><td>ViT-B/16 (Dosovitskiy et al., 2021)</td><td>384×384</td><td>77.9</td><td>86M</td><td>55.5G</td><td>85.9</td></tr><tr><td>DeiT-B/16 (Touvron et al.,2021b)</td><td>224× 224</td><td>81.8</td><td>86M</td><td>17.6G</td><td>292.3</td></tr><tr><td>PVT-Large (Wang et al., 2021)</td><td>224× 224</td><td>82.3</td><td>61M</td><td>9.8G</td><td>-</td></tr><tr><td>CPVT-B (Chu et al.,2021b)</td><td>224× 224</td><td>82.3</td><td>88M</td><td>17.6G</td><td>285.5</td></tr><tr><td>TNT-B (Han et al.,2021)</td><td>224× 224</td><td>82.8</td><td>66M</td><td>14.1G</td><td>-</td></tr><tr><td>T2T-ViTt-24 (Yuan et al.,2021) CaiT-S36 (Touvron et al., 2021c)</td><td>224× 224</td><td>82.6</td><td>65M</td><td>15.0G 13.9G</td><td>1</td></tr><tr><td>Swin-T (Liu et al., 2021b)</td><td>224× 224 224× 224</td><td>83.3 81.3</td><td>68M 29M</td><td>4.5G</td><td>-</td></tr><tr><td>Swin-S (Liu et al., 2021b)</td><td>224× 224</td><td>83.0</td><td>50M</td><td></td><td>755.2</td></tr><tr><td></td><td>224× 224</td><td></td><td>88M</td><td>8.7G</td><td>436.9</td></tr><tr><td>Swin-B (Liu et al., 2021b)</td><td>224× 224</td><td>83.3 83.8</td><td>68M</td><td>15.4G</td><td>278.1</td></tr><tr><td>Nest-B (Zhang et al.,2021)</td><td></td><td></td><td></td><td>17.9G</td><td>235.8</td></tr><tr><td>Container (Gao et al.,2021)</td><td>224× 224</td><td>82.7</td><td>22M</td><td>8.1G</td><td>347.8</td></tr><tr><td>Swin-B (Liu et al., 2021b)</td><td>384× 384</td><td>84.2</td><td>88M</td><td>47.0G</td><td>84.7</td></tr><tr><td colspan="6">MLP-based</td></tr><tr><td>gMLP-S (Liu et al., 2021a)</td><td>224× 224</td><td>79.4</td><td>20M</td><td>4.5G</td><td></td></tr><tr><td>ViP-Small/14 (Hou et al.,2021)</td><td>224× 224</td><td>80.5</td><td>30M</td><td>1</td><td>789.0</td></tr><tr><td>ViP-Small/7 (Hou et al., 2021)</td><td>224× 224</td><td>81.5</td><td>25M</td><td>1</td><td>719.0</td></tr><tr><td>AS-MLP-T (ours)</td><td>224× 224</td><td>81.3</td><td>28M</td><td>4.4G</td><td>1047.7</td></tr><tr><td>Mixer-B/16 (Tolstikhin et al.,2021)</td><td>224× 224</td><td>76.4</td><td>59M</td><td>11.7G</td><td>-</td></tr><tr><td>FF (Melas-Kyriazi,2021)</td><td>224× 224</td><td>74.9</td><td>62M</td><td>11.4G</td><td>=</td></tr><tr><td>ResMLP-36 (Touvron et al., 2021a)</td><td>224× 224</td><td>79.7</td><td>45M</td><td>8.9G</td><td>478.7</td></tr><tr><td>S²-MLP-wide (Yu et al., 2021)</td><td>224× 224</td><td>80.0</td><td>68M</td><td>13.0G</td><td>-</td></tr><tr><td>S²-MLP-deep (Yu et al., 2021)</td><td>224× 224</td><td>80.7</td><td>51M</td><td>9.7G</td><td>1</td></tr><tr><td>ViP-Medium/7 (Hou et al.,2021)</td><td>224× 224</td><td>82.7</td><td>55M</td><td>=</td><td>418.0</td></tr><tr><td>AS-MLP-S (ours)</td><td>224× 224</td><td>83.1</td><td>50M</td><td>8.5G</td><td>619.5</td></tr><tr><td>gMLP-B (Liu et al., 2021a)</td><td>224× 224</td><td>81.6</td><td>73M</td><td>15.8G</td><td>=</td></tr><tr><td>ViP-Large/7 (Hou et al., 2021)</td><td>224× 224</td><td>83.2</td><td>88M</td><td>=</td><td>298.0</td></tr><tr><td>AS-MLP-B (ours)</td><td>224× 224</td><td>83.3</td><td>88M</td><td>15.2G</td><td>455.2</td></tr><tr><td>AS-MLP-B (ours)</td><td>384× 384</td><td>84.3</td><td>88M</td><td>44.6G</td><td>179.2</td></tr></table>
383
+
384
+ Table 10: The complete experimental results of different networks on ImageNet-1K. Throughput is measured with the batch size of 64 on a single V100 GPU (32GB).
385
+
386
+ # B.3 EVALUATION ACCURACY
387
+
388
+ In Figure 6, we visualize the evaluation accuracy of AS-MLP and Swin transformer on the ImageNet, COCO and ADE20K datasets during training. For image classification on ImageNet, AS-MLP-T keeps pace with Swin-T in each epoch and they finally converge to the similar accuracy (81.3 vs. 81.3). For object detection and semantic segmentation on COCO and ADE20K, we can see that AS-MLP-T achieves better performance than Swin-T in the early stage, and keeps winning during the training process.
389
+
390
+ # B.4 COMPARISONS TO SHIFTRESNET
391
+
392
+ In this section, we compare the performance with ShiftResNet (Wu et al., 2018) in Table 11. The results of ShiftResNet50 with different configurations are from Table 3 of ShiftResNet paper (Wu et al., 2018). Our AS-MLP (mobile) achieves better accuracy with fewer parameters.
393
+
394
+ ![](images/93dfc13e15a3fa5828b20d2eb81788993c9f8d814a871ccc83b63295a661df29.jpg)
395
+ Figure 5: The throughput curve when the batch size is 1, 4, 8, 16, 32, 64, 128, respectively.
396
+
397
+ ![](images/0b6dac475ded2f870c70d972ef50546233a3edd1a62616c8a1483e51f1cd65dd.jpg)
398
+ Figure 6: The evaluation accuracy of AS-MLP and Swin transformer on the ImageNet, COCO and ADE20K datasets during training.
399
+
400
+ # C THE VISUALIZATION OF RESULTS ON COCO AND ADE20K
401
+
402
+ We visualize the object detection and instance segmentation results on the COCO dataset in Figure 7, where the Cascade Mask R-CNN model with the AS-MLP-T backbone is used. We also visualize the semantic segmentation results on the ADE20K dataset in Figure 8, where we utilize the UperNet model with the AS-MLP-T backbone. The object can be detected and segmented correctly.
403
+
404
+ Table 11: The comparisons with ShiftResNet.
405
+
406
+ <table><tr><td>Method</td><td>Top-1 (%)</td><td>Top-5 (%)</td><td>Params</td></tr><tr><td>ShiftResNet50-0</td><td>70.6</td><td>89.9</td><td>6M</td></tr><tr><td>ShiftResNet50-1</td><td>73.7</td><td>91.8</td><td>11M</td></tr><tr><td>ShiftResNet50-2</td><td>75.6</td><td>92.8</td><td>22M</td></tr><tr><td>AS-MLP (mobile)</td><td>76.05</td><td>92.81</td><td>9.6M</td></tr><tr><td>AS-MLP-T</td><td>81.34</td><td>95.56</td><td>28M</td></tr></table>
407
+
408
+ ![](images/b81e28e4479b84288ba40c30ae74c66d9d02867187b5db855ef38d6502acd216.jpg)
409
+ Figure 7: The object detection and instance segmentation results on the COCO dataset.
410
+
411
+ ![](images/509c2d382862e93da504833b9e943750894492063c669d8f2458903c3d67c16e.jpg)
412
+ Figure 8: The semantic segmentation results on the ADE20K dataset.
md/dev/g6We1SwaY9/g6We1SwaY9.md ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BLIP-Diffusion: Pre-trained Subject Representation for Controllable Text-to-Image Generation and Editing
2
+
3
+ Dongxu Li†, Junnan $\mathbf { L i } ^ { \dagger }$ , Steven C.H. Hoi† Salesforce AI Research †Corresponding authors: {li.d,junnan.li,shoi}@salesforce.com https://github.com/salesforce/LAVIS/tree/main/projects/blip-diffusion
4
+
5
+ ![](images/54551f9d56f8e12f71fdc3afaf90e2ae708f7987be3119cbf57e7f6eed53ec2a.jpg)
6
+ Figure 1: Leveraging the pre-trained subject representation, BLIP-Diffusion enables subject-driven generation under efficient fine-tuning or zero-shot setups. The model can also serve as a foundation subject-driven textto-image generation model and supports applications such as controlled generation and image editing, when combined with techniques such as ControlNet [1] and prompt-to-prompt [2].
7
+
8
+ # Abstract
9
+
10
+ Subject-driven text-to-image generation models create novel renditions of an input subject based on text prompts. Existing models suffer from lengthy fine-tuning and difficulties preserving the subject fidelity. To overcome these limitations, we introduce BLIP-Diffusion, a new subject-driven image generation model that supports multimodal control which consumes inputs of subject images and text prompts. Unlike other subject-driven generation models, BLIP-Diffusion introduces a new multimodal encoder which is pre-trained to provide subject representation. We first pre-train the multimodal encoder following BLIP-2 to produce visual representation aligned with the text. Then we design a subject representation learning task which enables a diffusion model to leverage such visual representation and generates new subject renditions. Compared with previous methods such as DreamBooth, our model enables zero-shot subject-driven generation, and efficient fine-tuning for customized subject with up to $2 0 \mathrm { x }$ speedup. We also show that BLIP-Diffusion can be flexibly combined with existing techniques such as ControlNet and prompt-toprompt to enable novel subject-driven generation and editing applications.
11
+
12
+ # 1 Introduction
13
+
14
+ Text-to-image generation models have developed significantly and enabled creation of high-quality images based on textual prompts [3–7]. One of their applications is subject-driven generation, which aims to render novel renditions of an input subject while preserving its appearance. The common approach to subject-driven generation [8–11] is through inverting subject visuals into text embedding space. Specifically, with a pretrained text-to-image generation model, a placeholder text embedding is optimized to reconstruct a set of subject images. The embedding is then composed into natural language prompts to create different subject renditions. One known inefficiency of this approach is that it requires reiterating hundreds [9, 10] or thousands [8] tedious fine-tuning steps for each new subject, which hinders it from efficiently scaling to a wide range of subjects.
15
+
16
+ We attribute such inefficiency to the fact that most pre-trained text-to-image models do not natively support multimodal control - using both images and texts as control input. As a result, it becomes challenging to learn subject representation that aligns with the text space while capturing the subject visuals with high fidelity. To overcome these limitations, we introduce BLIP-Diffusion, the first subject-driven text-to-image generation model with pre-trained generic subject representation, which enables subject-driven generation in zero-shot or with few-step fine-tuning. Our model builds upon a vision-language encoder (i.e. BLIP-2 [12]) and a latent diffusion model [6] (i.e. Stable Diffusion). The BLIP-2 encoder takes as input the subject image and its category text; it produces text-aligned subject representation as output. We then infix the subject representation in the prompt embedding to guide the latent diffusion model for subject-driven image generation and editing.
17
+
18
+ To enable controllable and high-fidelity generation, we propose a new two-stage pre-training strategy to learn generic subject representation. In the first pre-training stage, we perform multimodal representation learning, which enforces BLIP-2 to produce text-aligned visual features based on the input image. In the second pre-training stage, we design a subject representation learning task where the diffusion model learns to generate novel subject renditions based on the input visual features. To achieve this, we curate pairs of input-target images with the same subject appearing in different contexts. Specifically, we synthesize input images by composing the subject with a random background. During pre-training, we feed the synthetic input image and the subject class label through BLIP-2 to obtain the multimodal embeddings as subject representation. The subject representation is then combined with a text prompt to guide the generation of the target image.
19
+
20
+ Benefiting from the pre-trained subject representation, BLIP-Diffusion achieves promising zeroshot subject-driven generation results and superior fine-tuning efficiency. For example, BLIPDiffusion takes 40-120 fine-tuning steps to specialize for a given subject, achieving up to $2 0 \mathrm { x }$ speedup compared to DreamBooth [9]. Furthermore, BLIP-Diffusion inherits behaviours of the constituent latent diffusion model and can be flexibly extended to support various subject-driven generative applications without further training. Following the prompt-to-prompt [2] approach, BLIPDiffusion enables editing images with subject-specific visuals. When combined with ControlNet [1], it enables subject-driven generation with various additional structure control.
21
+
22
+ # 2 Related Work
23
+
24
+ # 2.1 Diffusion Models for Text-to-Image Generation
25
+
26
+ Diffusion models [3, 4, 6, 7, 13–15] generate images by progressively denoising a random variable drawn from a Gaussian distribution. In this work, we are particularly interested in the pre-trained text-to-image latent diffusion models [6]. Given a latent variable $z$ and its noisy version $z _ { t }$ obtained by gradually adding noises to $z$ for $t$ steps, latent diffusion models optimize the following objective:
27
+
28
+ $$
29
+ \mathbb { E } _ { z , c , \epsilon \sim \mathcal { N } ( 0 , 1 ) , t } \Big [ | | \epsilon - \epsilon _ { \theta } \big ( z _ { t } , t \big ) | | _ { 2 } ^ { 2 } \Big ] ,
30
+ $$
31
+
32
+ which is the squared error between the added noise $\epsilon$ and the predicted noise $\epsilon _ { \theta } ( z _ { t } , t )$ by a neural model $\epsilon _ { \theta }$ at time step $t$ , given $c$ a text prompt as condition. During training, the latent variable $z$ is obtained by passing the image into a pre-trained encoder [16]. For inference, a decoder is employed to convert the denoised latent into an image. In addition to text prompts, our model also conditions on subject representation, rendering an image generation architecture with multimodal conditions.
33
+
34
+ ![](images/43d9521e8066d8bb1f94b525e5062de5514f1c3473b4784dbe3a58397e8648e6.jpg)
35
+ Figure 2: Illustration of the two-staged pre-training for BLIP-Diffusion. Left: in the multimodal representation learning stage, we follow prior work [12] and pretrain BLIP-2 encoder to obtain text-aligned image representation. Right: in the subject representation learning stage, we synthesize input images by composing subjects with random background. The BLIP-2 is then tasked to produce subject prompt embedding, which is later used by the latent diffusion model to generate output subject image. The image encoder remains frozen during pre-training.
36
+
37
+ # 2.2 Subject-driven Text-to-Image Generation
38
+
39
+ Given a few images of a subject, the task of subject-driven text-to-image generation aims at generating the subject in novel context based on text prompts. In the era of diffusion models, Textual Inversion [8] proposes to represent visual concepts using a placeholder text embedding, and optimize the embedding to reconstruct the subject images. DreamBooth [9] shares a similar methodology while additionally fine-tunes the diffusion model, which leads to better expressiveness and subject fidelity. One known drawback for both methods is their lengthy fine-tuning time for each new subject, which prevents the approaches from easily scaling up. More recent efforts attempt to reduce the required time and effort for fine-tuning. Concurrent to our effort, the work [11, 17, 18] pre-train the diffusion model on domain-specific images, such as cat and human face images. These models provide class-specific prior for generation thus being more efficient for fine-tuning. However, they are also constrained to a narrow list of subject categories and are not able to easily generalize to generic subjects. The work SuTI [19] proposes a knowledge distillation approach, which learns zero-shot generation from millions of fine-tuned expert models. Their model shows less flexibility in subject poses and is likely to be distracted by the background of the input images. In contrast, the pre-trained representation in our model is generic to a wide range of subjects, while generalizing efficiently to different subjects.
40
+
41
+ # 3 Method
42
+
43
+ We propose BLIP-Diffusion, the first image diffusion model that features multimodal control through built-in generic pre-trained subject representation. Specifically, we adapt BLIP-2 encoder to extract multimodal subject representation, which is later used together with text prompt to guide generation.
44
+
45
+ We aim to learn subject representation that captures the subject-specific visual appearances while in the meantime aligns well with the text prompt. To this end, we propose a two-staged pre-training strategy as shown in Figure 2. First, a multimodal representation learning stage produces text-aligned generic image representation. Second, a subject representation learning stage prompts the diffusion model with text and subject representation for subject-driven generation. In this section, we delineate the model design and pre-training strategies.
46
+
47
+ # 3.1 Multimodal Representation Learning with BLIP-2
48
+
49
+ We use Stable Diffusion [6] as the latent diffusion model, which relies on CLIP [20] text encoder to produce prompt embeddings. In order to guide the generation using both text and subject representation as prompt, it is important that the subject embedding and the text embedding are well-aligned to ensure they can cooperate with each other. Inspired by the recent vision-language pre-trained model BLIP-2 [12], which produces high-quality text-aligned visual representation, we decide to adapt it to extract text-aligned subject representation.
50
+
51
+ Specifically, as shown in Figure 2a, we employ two main modules from BLIP-2 to learn multimodal representation: a frozen pre-trained image encoder to extract generic image features, and a multimodal encoder (i.e. Q-Former) for image-text alignment. The multimodal encoder is a transformer that accepts a fixed number of learnable query tokens and an input text. The query tokens interact with text through self-attention layers, and interact with frozen image features through cross-attention layers, and produces text-aligned image features as output. The output is of the same dimension as the number of query tokens. Empirically, we find that the originally implemented 32 output features often overpower the CLIP text embeddings when used in combination for image generation. Therefore, we instead half the number of query tokens and output 16 features.
52
+
53
+ ![](images/df01ba7f8af9cb332c0660cd6cfe46b83fa48dc55643ad6b927c6744a7b63127.jpg)
54
+ Figure 3: Left: example training image pairs, target images (top) and input images (bottom) with random background. Images are from the OpenImage dataset [22]. Right: comparison between the subject-driven image generation of our model (top), and image variations from DALLE-2 [4] (bottom). We prompt our model with the text prompt “a dog" and the subject representation, while feeding the input image into DALLE-2 for variation generation. Our model learns subject representation with minimal background information encoded, which enables faithful and flexible control when used together with text prompts.
55
+
56
+ Following BLIP-2 pre-training, we jointly train three vision-language pre-training objectives, including an image-text contrastive learning (ITC) loss that aligns the text and image representation by maximizing their mutual information, an image-grounded text generation (ITG) loss that generates texts for input images, and an image-text matching (ITM) loss that captures fine-grained imagetext alignment via a binary prediction. We conduct multimodal representation learning on generic image-text paired data, which allows the model to learn a diverse set of visual and textual concepts.
57
+
58
+ # 3.2 Subject Representation Learning with Stable Diffusion
59
+
60
+ As the result of the multimodal representation learning, we obtain text-aligned visual representation of the input image. These features capture the generic semantic information of the input image. However, they are not specifically tailored to serve as guidance for the diffusion model. To this end, the subject representation learning stage aims to enable the diffusion model to leverage such visual representation, and generate different renditions of the subjects when combining with text prompts. In particular, we consider two desired properties when injecting the subject representation into a diffusion model. First, we expect the subject representation to well coordinate with the text prompts for the purpose of text-guided subject-driven generation. In this regard, prior methods [9, 18, 19] do not address the text prompts during training. They are thus not directly suitable to be used for scalable pre-training. Second, the behavior of the underlying diffusion model should ideally be maintained. This allows the subject-driven generation model to take advantage of techniques built on top of the original model on the fly, such as image editing and structure-controlled generation.
61
+
62
+ Model Architecture. The proposed model architecture is shown in Figure 2b. We connect the output of the BLIP-2 multimodal encoder to the input of the diffusion model’s text encoder. During pretraining, the multimodal encoder takes as input a subject image and a text of the subject category, and produces a category-aware subject visual representation. We then transform the subject representation using a feed-forward layer consisting of two linear layers with GELU [21] activation in-between. The projected features are appended to the text prompt token embeddings as a soft visual subject prompt. Specifically, when combining the text token and subject embeddings, we use the template “[text prompt], the [subject text] is [subject prompt]". We pass text tokens through the CLIP embedding layer to obtain text token embeddings. We then concatenate subject embeddings and text token embeddings before passing them to the subsequent CLIP model layers. The resultant CLIP embeddings serve as guidance for the diffusion model to generate the output image. The soft visual prompt makes minimal architectural change to the underlying diffusion model, rendering an effective solution to inject subject representation while in the meantime largely inherits the modeling capabilities of the underlying diffusion model.
63
+
64
+ Subject-generic Pre-training with Prompted Context Generation. We aim to pre-train the model such that it learns to represent generic subjects from the input image. To this end, a naive approach is to use the same image as both input to the multimodal encoder and output to the diffusion model as in [8, 9]. However, our preliminary experiments suggest that this leads to trivial solutions where generations are significantly interfered by the background in the inputs, or even models copying the input image as output, rendering generations not respecting the text prompts. On the other hand, while it is possible to collect multiple images of the same subject in different context, and thereby using different images as input and target, such an approach is laborious to scale up to generic subjects.
65
+
66
+ ![](images/b19929c739648ada38082cb177e63f9f3ea53b595a0462b2debe2d9ea8a989dc.jpg)
67
+ Figure 4: Left: BLIP-Diffusion cooperates with ControlNet for structure and subject controllable generation. Our model maintains the modeling capabilities of the underlying diffusion model and requires no re-training of the ControlNet parameters. Right: combined with cross-attention control techniques present in prompt-toprompt, our model can be used for subject-driven image editing. The figure illustrates one denoising step where we mix latent maps generated with and without subject representation.
68
+
69
+ To address these issues, we propose a new pre-training task for learning subject-generic representation, called prompted context generation, where we curate input-target training pairs by synthesizing images of the subject in random background. The model takes the synthesized subject image as input, and aims to generate the original subject image as output according to a text prompt. Specifically, given an image containing a subject, we first feed the image and a category text of the subject to a text-prompted segmentation model CLIPSeg [23] with confidence thresholding. We then build a trimap by taking the segmentation map with higher confidence as the known foreground, the lower confidence as the uncertain region and the rest as the known background. Given the trimap, we use closed-form matting [24, 25] to extract the foreground, namely the subject. Then we compose the extracted subject onto a random background image via alpha blending. Finally, we use the synthetic image as the input and the original subject image as the output to serve as one training image pair.
70
+
71
+ As shown in Figure 3, such synthetic pairs effectively separate the foreground subject and the background context, preventing the subject-irrelevant information from being encoded in the subject prompt. In this way, we encourage the diffusion model to consider jointly the subject prompt and the text prompt for generation, leading to a pre-trained model that can be faithfully and flexibly controlled by both the subject image and the text prompt.
72
+
73
+ During pre-training, we freeze the image encoder and jointly train the BLIP-2 multimodal encoder along with the text encoder and U-Net of the latent diffusion model. To better preserve the original text-to-image generation capability, we find it beneficial to randomly drop the subject prompt at a $1 5 \%$ probability while using only text prompts to guide the diffusion.
74
+
75
+ # 3.3 Fine-tuning and Controllable Inference
76
+
77
+ The pre-trained subject representation enables both zero-shot generation and efficient fine-tuning for specific custom subjects. In addition, our model provides high-level visual control while inheriting the modeling capabilities of the underlying diffusion model. This enables us to leverage established image generation and editing techniques on the fly with BLIP-Diffusion as the foundation generation model. Below we first describe the efficient few-step subject-specific fine-tuning for custom subject generation. Then we present the extension capabilities of BLIP-Diffusion by incorporating existing techniques including ControlNet [1] and prompt-to-prompt image editing [2].
78
+
79
+ Subject-specific Fine-tuning and Inference. The pre-trained generic subject representation enables efficient fine-tuning for highly personalized subjects. Given a few subject images and the subject category text, we first use the multimodal encoder to obtain the subject representation individually. We then initialize the subject prompt embedding using the mean subject representation of all the subject images. In this way, we cache the subject prompt embedding without needing a forward pass of the multimodal encoder during fine-tuning. The diffusion model is fine-tuned to generate subject images as target by considering the text prompt embedding and the mean subject embedding. We also freeze the text encoder of the diffusion model, which we find helpful to counteract overfitting to target images. We use batch size 3 and a constant learning rate of 5e-5 with AdamW [26] optimizer across all the subjects, and generally observe decent results after 40-120 training steps, which takes 20-40 seconds to complete on a single A100 GPU.
80
+
81
+ Structure-controlled Generation with ControlNet. Our model introduces a multimodal conditioning mechanism for subject-control. In the meanwhile, the architecture is also compatible to integrate with ControlNet [1] to achieve simultaneous structure-controlled and subject-controlled generation. Figure 4 illustrates such integration, where we attach the U-Net of the pre-trained ControlNet to that of BLIP-Diffusion via residuals. In this way, the model takes into account the input structure condition, such as edge maps and depth maps, in addition to the subject cues. Since our model inherits the architecture of the original latent diffusion model, we observe satisfying generations using off-the-shelf integration with pre-trained ControlNet without further training.
82
+
83
+ Subject-driven Editing with Attention Control. Our model combines subject prompt embeddings with text prompt embeddings for multimodal controlled generation. Inspired by prompt-to-prompt [2], our model enables subject-driven image editing by manipulating the cross-attention maps of prompt tokens. In Figure 4, we show such capability where the model edits the original image with subjectspecific visuals. For this purpose, we assume the generation process of the original image is known, or can be derived via inversion [13, 27] for real images. To edit the image, we first specify text tokens to edit, for example the token “dog”. Next, we use the cross-attention maps of the specified token to extract automatically a mask for regions to edit. In order to preserve the layout and semantics in unedited regions, we keep the attention maps from the original generation while generating new attention maps for the inserted subject embeddings. We mix the denoising latents at each step based on the extracted editing mask. Namely, latents of the unedited regions are from the original generation whereas latents of the edited regions are from the subject-driven generation. In this way, we obtain the edited image with subject-specific visuals while also preserving the unedited regions.
84
+
85
+ # 4 Experiments
86
+
87
+ # 4.1 Pre-training Datasets and Details.
88
+
89
+ For multimodal representation learning, we follow BLIP-2 [12] and pretrain the model on 129M image-text pairs, including 115M image-text pairs from LAION [28] with CapFilt [29] captions, COCO [30], Visual Genome [31] and Conceptual Captions [32, 33]. We use $\mathrm { V i T _ { L a r g e } }$ from CLIP [20] as the image encoder, and initialize Q-Former with BERTbase [34]. As aforementioned, we use 16 queries to learn subject representation. Other training hyperparameters follow [29].
90
+
91
+ For subject representation learning, we use a subset of 292K images from OpenImage-V6 [22], each containing a salient subject. We also remove images with human-related subjects. We use BLIP-2 $\mathrm { O P T } _ { 6 . 7 \mathrm { B } }$ to generate captions as text prompts. We obtain a set of 59K background images from the web to synthesize subject inputs. We use Stable Diffusion v1-5 as the foundation diffusion model. We use a total batch size 16 with a constant learning rate 2e-6 for 500K steps using AdamW [26] optimizer, taking 6 days to finish on 16 A100 40Gb GPUs. More details on hyperparameters and data filtering procedure are included in Appendix for reference.
92
+
93
+ # 4.2 Experimental Results
94
+
95
+ Main Qualitative Results. In Figure 5, we show qualitative generation results of BLIP-Diffusion. Thanks to the pre-trained subject representation, our model facilitates zero-shot subject-driven generation (row #1), producing meaningful results even for highly customized subjects. The model also enables efficient fine-tuning (row $\# 3 – 6$ ), demonstrating high-fidelity generation for re-contextulization, artistic stlyization, textual modification, property modification and accessorization. Compared with existing solutions, BLIP-Diffusion requires much less fine-tuning effort, usually 40-120 steps which are up to $\mathbf { x } 2 0$ times more efficient than previous work [8, 9]. In addition, when combining with ControlNet (row #7-8), our model can achieve simultaneous control over structure and subject. Finally, our model can introduce subject information into image editing pipeline, enable to edit images with specific subject visuals (row #9-10). These applications demonstrate potentials of using BLIP-Diffusion as a foundation text-to-image generation model with multimodal controls.
96
+
97
+ ![](images/f7b38a3f4da072e310e1759f7b7c75385c59cc8419a2b90e4f152f76c17e413b.jpg)
98
+ Figure 5: Qualitative results categorized by generative capabilities. The pre-trained subject representation enables zero-shot subject-driven generation (row #1-2) and efficient, high-fidelity finetuning (row #3-6). Our model can also serve as a foundation text-to-image generation model and leverages on the fly exsiting techniques developed on latent diffusion models. Combining with ControlNet (row #7-8), BLIP-Diffusion enables controllable generation using both subject and structure conditions; combining with prompt-to-prompt (row #9-10), our model achieves subject-driven image editing by manipulating cross-attention maps.
99
+
100
+ ![](images/65d07a1d634d21aa09a3fb51bedf5430a4b2f6f855e6ad06ae9fa8953936f1c7.jpg)
101
+ Figure 6: Qualitative comparison between BLIP-Diffusion with text-driven image generation methods [8, 9] and the image editing method [35]. Our model achieves high subject fidelity and prompt relevance, while needing significantly fewer finetuning steps. Example subject images from the dreambooth dataset [9] are shown, which are also used as source images for InstructPix2Pix to edit.
102
+
103
+ ![](images/7a02468d63316a7cf879b17686dcd054f02ef1f14bd5589f5464c3e2f6a534b7.jpg)
104
+
105
+ Table 1: Left: Quantitative comparisons on DreamBench. We report average metrics and differences across 10 experiment runs with different set of random seeds, in zero-shot (ZS) and fine-tuning (FT) setups. Right: Alignment metrics in zero-shot (red) and fine-tuning (blue) setups for sample subjects.
106
+
107
+ <table><tr><td>Methods</td><td>DINO</td><td>CLIP-I</td><td>CLIP-T</td></tr><tr><td>Real Images (Oracle)</td><td>0.774</td><td>0.885</td><td>-</td></tr><tr><td>Textual Inversion [8]</td><td>0.569</td><td>0.780</td><td>0.255</td></tr><tr><td>Re-Imagen [36]</td><td>0.600</td><td>0.740</td><td>0.270</td></tr><tr><td>DreamBooth [9]</td><td>0.668</td><td>0.803</td><td>0.305</td></tr><tr><td>- 100 fine-tuning steps</td><td>0.396</td><td>0.698</td><td>0.322</td></tr><tr><td>- 300 fine-tuning steps</td><td>0.500</td><td>0.733</td><td>0.319</td></tr><tr><td>Ours (ZS)</td><td>0.594 (±0.004)</td><td>0.779 (±0.003)</td><td>0.300 (±0.002)</td></tr><tr><td>Ours (FT,avg.&lt;80 steps)</td><td>0.670 (±0.004)</td><td>0.805 (±0.002)</td><td>0.302 (±0.001)</td></tr></table>
108
+
109
+ Comparisons on DreamBooth Dataset. We compare BLIP-Diffusion with methods [8, 9, 35, 36] (details in appendix) on DreamBooth dataset [9], containing 30 subjects, each with 4-7 images. In Figure 6, we show qualitative comparisons. Our model achieves significantly better subject fidelity than Textual Inversion, Re-Imagen and InstructPix2Pix. Compared with DreamBooth, our model exhibits comparable or better generation quality while requiring a significant lower number of fine-tuning iterations, which validates the effectiveness of our pre-trained subject representation.
110
+
111
+ In Table 1, we follow [9] and report DINO [37], CLIP-I [20] and CLIP-T scores. DINO and CLIP-I scores measure subject alignment and CLIP-T measures image-text alignment (see appendix for detailed description of the metrics). We generate 4 images for each text prompt, amounting in total 3,000 images for all the subjects. We repeat generations with 10 fixed set of random seeds and report average scores. The overall results are consistent with the qualitative findings, where BLIPDiffusion is superior to Textual Inversion and Re-Imagen while showing comparable performance to DreamBooth while requiring less fine-tuning effort. In particular, our zero-shot generations are better
112
+
113
+ <table><tr><td>Ablation Setups</td><td>DINO</td><td>CLIP-I</td><td>CLIP-T</td></tr><tr><td>BLIP-Diffusion (250K steps)</td><td>0.566</td><td>0.773</td><td>0.299</td></tr><tr><td>- w/o multimodal pre-training</td><td>0.521 √</td><td>0.743↓</td><td>0.290↓</td></tr><tr><td>- w/o training text encoder</td><td>0.568个</td><td>0.782个</td><td>0.288↓</td></tr><tr><td>- w/o subject text</td><td>0.565↓</td><td>0.772↓</td><td>0.298↓</td></tr><tr><td>- w/o subject dropping</td><td>0.559↓</td><td>0.766↓</td><td>0.291↓</td></tr></table>
114
+
115
+ ![](images/6f57bb4a67e1f2c67c8b7898983825579a1b0cbff2e4b58175f782ac34bf2241.jpg)
116
+
117
+ Table 2: Left: Ablation results. Right: Effect of subject representation learning with varying pre-training steps.
118
+
119
+ ![](images/23f9279123af5126f8b0965d330cb12f7304493ff6c6126ab951874e501bcbfc.jpg)
120
+ Figure 7: Attention visualization of subject representation. Leftmost is the generation using prompt “a robot/car" with subject representation injected. The learned subject embeddings capture both local (red) and holistic (blue) subject visuals. Subjects are from the DreamBench [9] dataset.
121
+
122
+ than fine-tuned Textual Inversion results. Additionally, we show per-subject metrics and observe that fine-tuning significantly improves subject alignment. In the meanwhile, fine-tuning also improves image-text alignment on average. When fine-tuning harms the image-text alignment, it is due to the model overfitting to target inputs thus resulting in generations irrespective of the text prompt. This is in particular an issue when the provided subject images are of limited visual diversity.
123
+
124
+ Aesthetics Measures. We use LAION aesthetic scorer to measure the visual quality of the generations. The aesthetic scorer predicts a score bounded between 0 and 10 using CLIP ViT-L/14 features, where 10 represents the highest aesthetic score. We calculate the aesthetic scores for 3,000 generations on the DreamBooth dataset and report comparison results with those produced by DreamBooth. As indicated in Table 3, results show that our model shows a clear advantage over DreamBooth models in terms of the aesthetic scores. In addition, results also demonstrate that fine-tuning is beneficial to promote high-quality generations.
125
+
126
+ Ablation Studies. We conduct ablation studies using 250K subject representation learning steps. Table 2 shows zero-shot evaluation results. Our findings are: (i) it is critical to conduct multimodal representation learning (Section 3.1), which bridges the representation gap between subject embeddings and text prompt embeddings. (ii) freezing text encoder of the diffusion model worsens the interaction between subject embedding and text embedding. This leads to generations copying subject inputs and not respecting the text prompts. Despite leading to higher subject alignment scores, it does not allow text control, falsifying the task of text-to-image generation. (iii) Giving subject text to the multimodal encoder is helpful to inject class-specific visual priors, thereby leading to moderate improvement in metrics. (iv) Pre-training with random subject embedding dropping helps to better preserve the diffusion model’s generation ability, thus benefiting the results. We further demonstrate the effect of subject representation learning. The figure (right) shows that both image-text alignment and subject alignment improve with growing pre-training steps of subject representation learning.
127
+
128
+ Subject Representation Visualization. It is observed that pixels are attracted more to embeddings that describe them [2]. Following this observation, in Figure 7, we visualize the learned subject embeddings using cross-attention maps. The figure shows that the learned embeddings encode
129
+
130
+ <table><tr><td>Models</td><td>Aesthetic Scores</td></tr><tr><td>BLIP-Diffusion (fine-tuned)</td><td>6.50</td></tr><tr><td>BLIP-Diffusion (zero-shot)</td><td>6.43</td></tr><tr><td>DreamBooth</td><td>6.20</td></tr></table>
131
+
132
+ Table 3: Aesthetic scores comparison between BLIP-Diffusion models and DreamBooth models. Our models show a quantitative advantage over DreamBooth models.
133
+
134
+ fine-grained yet different aspects of the subject. For example, certain embeddings (e.g. 0, 3, 4, 10-13) tend to focus on more local features while others (e.g. 1, 14) encode more holistic visuals. This demonstrates the complimentary effect of employing multiple subject embeddings.
135
+
136
+ Limitations. Our model suffers from common failures of subject-driven generation models, such as incorrect context synthesis, overfitting to training set as detailed in [9]. In addition, it inherits some weakness of the underlying diffusion model, which may fail to understand text prompts and fine-grained composition relations. We show some of such failure examples in Figure 8. Despite the limitations, the proposed technique is generic to harvest future development of diffusion models.
137
+
138
+ # 5 Conclusion
139
+
140
+ This paper proposed BLIP-Diffusion, a new text-to-image diffusion model with built-in multimodal control capabilities powered by BLIP-2 [12]. The model is pre-trained using a two-stage strategy to learn progressively multimodal subject representation, which facilitates high-fidelity zero-shot and efficient fine-tuned subject-driven generation. BLIP-Diffusion produces better zero-shot generations than fine-tuned models such as Textual Inversion. It also achieves up to $2 0 \mathrm { x }$ fine-tuning speed up than best prior methods with comparable generation quality. In addition, it can work in conjunction with other established techniques, such as ControlNet and prompt-to-prompt, for image generation and editing with simultaneous structure and subject control. We consider BLIP-Diffusion as an important step towards building foundational text-to-image generation model with multimodal control.
141
+
142
+ # Acknowledgement
143
+
144
+ We thank colleagues at Salesforce AI Research for support and discussions, and anonymous program committee members for their voluntary reviews and valuable feedback.
145
+
146
+ # References
147
+
148
+ [1] Lvmin Zhang and Maneesh Agrawala. Adding conditional control to text-to-image diffusion models. arXiv preprint arXiv:2302.05543, 2023.
149
+ [2] Amir Hertz, Ron Mokady, Jay Tenenbaum, Kfir Aberman, Yael Pritch, and Daniel Cohen-Or. Prompt-toprompt image editing with cross attention control. arXiv preprint arXiv:2208.01626, 2022.
150
+ [3] Alexander Quinn 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. In International Conference on Machine Learning, pages 16784–16804. PMLR, 2022.
151
+ [4] 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.
152
+ [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.
153
+ [6] 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.
154
+ [7] 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-toimage diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022.
155
+ [8] Rinon Gal, Yuval Alaluf, Yuval Atzmon, Or Patashnik, Amit H Bermano, Gal Chechik, and Daniel Cohen-Or. An image is worth one word: Personalizing text-to-image generation using textual inversion. arXiv preprint arXiv:2208.01618, 2022.
156
+ [9] Nataniel Ruiz, Yuanzhen Li, Varun Jampani, Yael Pritch, Michael Rubinstein, and Kfir Aberman. Dreambooth: Fine tuning text-to-image diffusion models for subject-driven generation. arXiv preprint arXiv:2208.12242, 2022.
157
+ [10] Nupur Kumari, Bingliang Zhang, Richard Zhang, Eli Shechtman, and Jun-Yan Zhu. Multi-concept customization of text-to-image diffusion. arXiv preprint arXiv:2212.04488, 2022.
158
+ [11] Rinon Gal, Moab Arar, Yuval Atzmon, Amit H Bermano, Gal Chechik, and Daniel Cohen-Or. Designing an encoder for fast personalization of text-to-image models. arXiv preprint arXiv:2302.12228, 2023.
159
+ [12] 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.
160
+ [13] Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations, 2021.
161
+ [14] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840–6851, 2020.
162
+ [15] Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, volume 34, pages 8780–8794. Curran Associates, Inc., 2021.
163
+ [16] Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
164
+ [17] Xuhui Jia, Yang Zhao, Kelvin CK Chan, Yandong Li, Han Zhang, Boqing Gong, Tingbo Hou, Huisheng Wang, and Yu-Chuan Su. Taming encoder for zero fine-tuning image customization with text-to-image diffusion models. arXiv preprint arXiv:2304.02642, 2023.
165
+ [18] Jing Shi, Wei Xiong, Zhe Lin, and Hyun Joon Jung. Instantbooth: Personalized text-to-image generation without test-time finetuning. arXiv preprint arXiv:2304.03411, 2023.
166
+ [19] Wenhu Chen, Hexiang Hu, Yandong Li, Nataniel Ruiz, Xuhui Jia, Ming-Wei Chang, and William W Cohen. Subject-driven text-to-image generation via apprenticeship learning. arXiv preprint arXiv:2304.00186, 2023.
167
+ [20] 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.
168
+ [21] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
169
+ [22] Alina Kuznetsova, Hassan Rom, Neil Alldrin, Jasper Uijlings, Ivan Krasin, Jordi Pont-Tuset, Shahab Kamali, Stefan Popov, Matteo Malloci, Alexander Kolesnikov, et al. The open images dataset v4: Unified image classification, object detection, and visual relationship detection at scale. International Journal of Computer Vision, 128(7):1956–1981, 2020.
170
+ [23] Timo Lüddecke and Alexander Ecker. Image segmentation using text and image prompts. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 7086–7096, 2022.
171
+ [24] Anat Levin, Dani Lischinski, and Yair Weiss. A closed-form solution to natural image matting. IEEE transactions on pattern analysis and machine intelligence, 30(2):228–242, 2007.
172
+ [25] Thomas Germer, Tobias Uelwer, Stefan Conrad, and Stefan Harmeling. Pymatting: A python library for alpha matting. Journal of Open Source Software, 5(54):2481, 2020.
173
+ [26] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2017.
174
+ [27] Bram Wallace, Akash Gokul, and Nikhil Naik. Edict: Exact diffusion inversion via coupled transformations. arXiv preprint arXiv:2211.12446, 2022.
175
+ [28] Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki. Laion-400m: Open dataset of clip-filtered 400 million image-text pairs. arXiv preprint arXiv:2111.02114, 2021.
176
+ [29] 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.
177
+ [30] 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.
178
+ [31] Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A Shamma, et al. Visual genome: Connecting language and vision using crowdsourced dense image annotations. International journal of computer vision, 123:32–73, 2017.
179
+ [32] 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.
180
+ [33] Soravit Changpinyo, Piyush Sharma, Nan Ding, and Radu Soricut. Conceptual $1 2 \mathrm { m }$ : Pushing web-scale image-text pre-training to recognize long-tail visual concepts. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3558–3568, 2021.
181
+ [34] Jacob Devlin Ming-Wei Chang Kenton and Lee Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of NAACL-HLT, pages 4171–4186, 2019.
182
+ [35] Tim Brooks, Aleksander Holynski, and Alexei A Efros. Instructpix2pix: Learning to follow image editing instructions. arXiv preprint arXiv:2211.09800, 2022.
183
+ [36] Wenhu Chen, Hexiang Hu, Chitwan Saharia, and William W Cohen. Re-imagen: Retrieval-augmented text-to-image generator. arXiv preprint arXiv:2209.14491, 2022.
184
+ [37] Mathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In Proceedings of the IEEE/CVF international conference on computer vision, pages 9650–9660, 2021.
185
+ [38] Vicente Ordonez, Girish Kulkarni, and Tamara Berg. Im2text: Describing images using 1 million captioned photographs. Advances in neural information processing systems, 24, 2011.
186
+ [39] Luping Liu, Yi Ren, Zhijie Lin, and Zhou Zhao. Pseudo numerical methods for diffusion models on manifolds. In International Conference on Learning Representations, 2022.
187
+
188
+ # A Appendix
189
+
190
+ # A.1 Broader Impact
191
+
192
+ Image generation models are susceptible to be used as tools for generating false content or prompting misinformation. Subject-driven generation could be misused as a tool for generating fake image of individuals. To mitigate this issue, our model has been trained on generic objects where personrelated subjects have been purposely removed from the training data. This makes the model weaker at generating fake images using person as subject control.
193
+
194
+ Our model is built using the pre-trained Stable Diffusion model trained on web-scraped datasets. Therefore, our model inherits some of its shortcomings, such as generating biased contents with social stereotypes, or other NSFW contents if used inappropriately. Our model’s ability to precisely control the generation subject can help mitigate certain biases. We can use NSFW detectors to block potential inappropriate content from being generated. Nevertheless, we strongly caution against using our model directly in user-facing applications without a careful inspection of the model’s output. Proper content moderation and regulation are highly advised to prevent undesirable consequence.
195
+
196
+ # A.2 Failure Cases Analysis
197
+
198
+ In Figure 8, we outline common failure cases of the model. Our model suffers from issues observed for prior subject-driven generation models as outlined in [9], including incorrect context synthesis, overfitting to training set. In addition, it subsumes some weakness of the underlying diffusion model, such as failing to address text prompts or generating fine-grained composition relations.
199
+
200
+ ![](images/67a5bbdfa648fa43b52eb959b366216c2a0410d1d7540d19b268ce5b428e8736.jpg)
201
+ Figure 8: Example failure generations. Subject images used for finetuning are shown on the left.
202
+
203
+ # A.3 Competing Methods
204
+
205
+ We compare BLIP-Diffusion with fine-tuning based [8, 9] and retrieval-augmented [36] subject-driven generation models on the public DreamBench dataset [9]. We also compare qualitatively with the image editing method InstructPix2Pix [35]. We briefly introduce these methods below.
206
+
207
+ • Textual Inversion [8]: a fine-tuning method which optimizes a placeholder embedding to
208
+ reconstruct the training set of subject images. It requires 3,000 training steps for learning a new concept, which takes around 30 minutes on an A100 GPU.
209
+ • DreamBooth [9]: a fine-tuning method similar to textual inversion. In addition to the placeholder embedding, it also optimizes parameters of the U-Net for a total budget of around 800 steps. We report intermediate results using 100 and 300 fine-tuning steps, while refer to metrics reported by the authors for full model comparison. Fine-tuning DreamBooth on a new concept costs around 6 minutes on an A100 GPU.
210
+ • Re-Imagen: a retrieval-augmented model, which takes the subject images as references and attend to them to generate new images. While the model requires no tuning, it significantly underperforms other models. The model is not publicly available, thus we do not have access to qualitative examples for comparison.
211
+ • InstructPix2Pix: an image editing model, which takes as input the source image and an editing instruction to generate edited images. Although it does not represent explicitly subjects, it can be used for applications such as subject re-contextualization and property modification. Therefore, we also include it for qualitative comparison. In particular, we experiment with both low (1.0) and high (1.5) image guidance scales, where a low image guidance scale preserves less the subject while promotes the text alignment; a high image guidance scale preserves better the original image yet is more likely to overlook the editing instruction.
212
+
213
+ # A.4 Evaluation Metrics
214
+
215
+ We adopt metrics proposed in DreamBooth [9] for evaluation, including DINO, CLIP-I and CLIP-T scores. Among them, DINO and CLIP-I scores are used to measure subject fidelity and CLIP-T is used to measure image-text alignment. DINO score is the average pairwise cosine similaity between the ViT-S/16 DINO embeddings of the generated and real images. CLIP-I score is the average pairwise CLIP ViT-B/32 image embeddings of the generated and real images. It is considered that DINO score is the preferred metric for measuring subject fidelity as it is sensitive to the differences between subjects of the same class. CLIP-T score is the average cosine similarity between prompt and image CLIP embeddings.
216
+
217
+ To better evaluate and compare subject-driven text-to-image models, it is suggested that these metrics should be considered jointly to avoid biased conclusion. For example, a model that naively copies the training set images will produce high DINO and CLIP-I scores with low CLIP-T scores. In the other case, a vanilla text-to-image generation model without subject knowledge, e.g. stable diffusion, will produce high CLIP-T scores with poor subject alignment. Both models are not considered desirable for the subject-driven text-to-image generation task.
218
+
219
+ # A.5 Pre-training Datasets
220
+
221
+ For multimodal representation learning, we use the same pre-training data as by BLIP-2, totaling 129M images. This includes COCO [30], Visual Genome [31], CC3M [32], CC12M [33], SBU [38] and 115M images from LAION400M [28]. We also employ the synthetic captions created using CapFilt method [29] for web images. We refer interested readers to Section 3.4 in the BLIP-2 paper [12] for details of the data bootstrapping configurations.
222
+
223
+ For subject representation learning, we use a subset of OpenImage-V6. We filter the data using the annotations provided by the dataset. In particular, we discard a sample if it satisfies one of the following cases: (i) a group of objects of the same class appear in the image; (ii) the image is taken from inside of the subject; (iii) the object is of aspect ratios larger than 2; (iv) objects occupy a too large (0.8) or too small (0.3) area relative to the image; (v) human-related subject, including boy, girl, person, man, mammal, woman, human body, human head, human hair, human arm, human face, human leg, human hand, human foot, human eye, human mouth, human nose, human ear, clothing, suit; (vi) cluttered objects, including tree, plant, houseplant, desk, table, poster and billboard. This results in 292K images for subject representation learning.
224
+
225
+ # A.6 Fine-tuning, Inference and Evaluation on DreamBooth Dataset
226
+
227
+ For all fine-tuning experiments, we use AdamW [26] optimizer with constant learning rate 5e-6 and no warm-up steps. We use batch size 3, adam beta1 0.9, adam beta2 0.999, adam epsilon 1e-8 and weight decay 0.01. We fine-tune models on a single A100 (40Gb) GPU and select checkpoints manually based on a set of validation prompts. We report the number of iterations for each subject on DreamBench below, on average 76 steps, taking around 40 seconds to complete on a single A100.
228
+
229
+ For inference, we use PNDM scheduler [39] for 100 denoising steps. We use a fixed guidance scale 7.5 for all experiments.
230
+
231
+ Table 4: Number of fine-tuning steps for DreamBench subjects.
232
+
233
+ <table><tr><td>backpack</td><td>110</td><td>backpack-dog</td><td>110</td><td>bear-plushie</td><td>110</td></tr><tr><td>bowl</td><td>40</td><td>can</td><td>70</td><td>candle</td><td>80</td></tr><tr><td>cat</td><td>40</td><td>cat2</td><td>50</td><td>clock</td><td>120</td></tr><tr><td>colorful-sneaker</td><td>80</td><td>dog</td><td>50</td><td>dog2</td><td>50</td></tr><tr><td>dog3</td><td>40</td><td>dog5</td><td>20</td><td>dog6</td><td>40</td></tr><tr><td>dog7</td><td>50</td><td>dog8</td><td>40</td><td>duck-toy</td><td>60</td></tr><tr><td>fancy-boot</td><td>50</td><td>grey-sloth-plushie</td><td>70</td><td>monster-toy</td><td>120</td></tr><tr><td>pink-sunglasses</td><td>90</td><td>poop-emoji</td><td>90</td><td>rc-car</td><td>120</td></tr><tr><td>red-cartoon</td><td>70</td><td>robot-toy</td><td>110</td><td>shiny-sneaker</td><td>80</td></tr><tr><td> teapot</td><td>120</td><td>vase</td><td>120</td><td>wolf-plushie</td><td>80</td></tr></table>
234
+
235
+ In Table 5 and 6, we report average metrics across 10 experiment runs for each subject in the dataset, in zero-shot and fine-tuning setups, respectively.
236
+
237
+ # A.7 Zero-shot Subject-driven Image Manipulation
238
+
239
+ Our model is able to extract subject features to guide the generation. In addition to applications of subject-driven generations and editing, we show that such pre-trained subject representation enables intriguing and useful applications of zero-shot image manipulation, including subject interpolation and subject-driven style transfer.
240
+
241
+ Subject Interpolation. It is also possible to blend two subject representation to generate subjects with a hybrid appearance. This can be achieved by traversing the embedding trajectory between subjects. In Figure 9, we create bilinear interpolations among 4 different subject representations, and render the interpolated subject in a novel context. As the figure shows, the subject appearance blends along the trajectory and fits naturally with the environment. This is useful when multiple subjects are used as reference to guide the generation. For example, subject interpolation can be used in joint with subject-driven style transfer to create hybrid style from multiple guiding subjects.
242
+
243
+ Table 5: Average metrics for each subject on DreamBench in zero-shot setup.
244
+
245
+ <table><tr><td> Subject</td><td>backpack</td><td>backpack-dog</td><td>bear-plushie</td><td>berry-bowl</td><td>can</td><td>candle</td></tr><tr><td>DINO</td><td>0.452</td><td>0.467</td><td>0.634</td><td>0.750</td><td>0.540</td><td>0.395</td></tr><tr><td>CLIP-I</td><td>0.782</td><td>0.712</td><td>0.739</td><td>0.792</td><td>0.641</td><td>0.710</td></tr><tr><td>CLIP-T</td><td>0.320</td><td>0.310</td><td>0.304</td><td>0.257</td><td>0.314</td><td>0.316</td></tr><tr><td> Subject</td><td>cat</td><td>cat2</td><td>clock</td><td>colorful-sneaker</td><td>dog</td><td>dog2</td></tr><tr><td>DINO</td><td>0.760</td><td>0.703</td><td>0.402</td><td>0.680</td><td>0.780</td><td>0.730</td></tr><tr><td>CLIP-I</td><td>0.835</td><td>0.854</td><td>0.735</td><td>0.769</td><td>0.849</td><td>0.831</td></tr><tr><td>CLIP-T</td><td>0.306</td><td>0.286</td><td>0.303</td><td>0.298</td><td>0.310</td><td>0.307</td></tr><tr><td> Subject</td><td>dog3</td><td>dog5</td><td>dog6</td><td>dog7</td><td>dog8</td><td>duck-toy</td></tr><tr><td>DINO</td><td>0.558</td><td>0.705</td><td>0.763</td><td>0.656</td><td>0.641</td><td>0.665</td></tr><tr><td>CLIP-I</td><td>0.747</td><td>0.788</td><td>0.867</td><td>0.817</td><td>0.816</td><td>0.840</td></tr><tr><td>CLIP-T</td><td>0.310</td><td>0.313</td><td>0.288</td><td>0.309</td><td>0.307</td><td>0.287</td></tr><tr><td colspan="7">Subject fancy-boot grey-sloth-plushie monster-toy pink-sunglasses j</td></tr><tr><td>DINO</td><td>0.538</td><td>0.632</td><td>0.490</td><td>0.599</td><td>poop-emoji 0.494</td><td>rc-car 0.569</td></tr><tr><td>CLIP-I</td><td>0.800</td><td>0.755</td><td>0.734</td><td>0.836</td><td>0.689</td><td>0.761</td></tr><tr><td>CLIP-T</td><td>0.291</td><td>0.315</td><td>0.293</td><td>0.308</td><td>0.307</td><td>0.281</td></tr><tr><td>Subject 1</td><td>tred-cartoon</td><td>robot-toy</td><td>shiny-sneaker</td><td>teapot</td><td>vase</td><td>wolf-plushie</td></tr><tr><td>DINO</td><td>0.697</td><td>0.534</td><td>0.668</td><td>0.451</td><td>0.471</td><td>0.463</td></tr><tr><td>CLIP-I</td><td>0.826</td><td>0.787</td><td>0.759</td><td>0.804</td><td>0.786</td><td>0.737</td></tr><tr><td>CLIP-T</td><td>0.263</td><td>0.315</td><td>0.294</td><td>0.314</td><td>0.262</td><td>0.327</td></tr></table>
246
+
247
+ Subject-driven Style Transfer. When provided with a subject, the model can encode the appearance style of it and transfer to other subjects. We refer such an application as subject-driven style transfer. In Figure 10 and 11, we generate stylized reference subjects with the aid of edge-guided ControlNet. The styles are hinted by the guiding subjects. Specifically, we feed BLIP-2 with guiding subjects and their category texts, e.g. fire, flower, glass, vase, ball, bread, to extract the subject representation. In this application, guiding subjects serve as alternative of textual prompts to specify styles. This is useful especially when a style is non-trivial to describe by natural languages accurately.
248
+
249
+ # A.8 Additional Qualitative Results and Subject Fidelity Showcasing
250
+
251
+ In Figure 12 to 14, we provide additional qualitative results on DreamBench subjects and prompts. We show the reference subject image in the first column. In the rest columns, we provide generated renditions. To showcase subject fidelity and photorealism, we purposely mix one genuine subject image in and leave for interested readers to figure out. Read the captions to verify.
252
+
253
+ Table 6: Average metrics for each subject on DreamBench in fine-tuning setup.
254
+
255
+ <table><tr><td> Subject</td><td>backpack</td><td>backpack-dog</td><td>bear-plushie</td><td>berry-bowl</td><td>can</td><td>candle</td></tr><tr><td>DINO</td><td>0.551</td><td>0.639</td><td>0.693</td><td>0.808</td><td>0.618</td><td>0.519</td></tr><tr><td>CLIP-I</td><td>0.839</td><td>0.760</td><td>0.752</td><td>0.829</td><td>0.695</td><td>0.752</td></tr><tr><td>CLIP-T</td><td>0.320</td><td>0.317</td><td>0.307</td><td>0.254</td><td>0.313</td><td>0.311</td></tr><tr><td> Subject</td><td>cat</td><td>cat2</td><td>clock</td><td>colorful-sneaker</td><td>dog</td><td>dog2</td></tr><tr><td>DINO</td><td>0.806</td><td>0.747</td><td>0.479</td><td>0.739</td><td>0.821</td><td>0.793</td></tr><tr><td>CLIP-I</td><td>0.869</td><td>0.864</td><td>0.784</td><td>0.805</td><td>0.860</td><td>0.841</td></tr><tr><td>CLIP-T</td><td>0.306</td><td>0.284</td><td>0.305</td><td>0.320</td><td>0.313</td><td>0.307</td></tr><tr><td>Subject</td><td>dog3</td><td>dog5</td><td>dog6</td><td>dog7</td><td>dog8</td><td>duck-toy</td></tr><tr><td>DINO</td><td>0.573</td><td>0.727</td><td>0.834</td><td>0.672</td><td>0.723</td><td>0.699</td></tr><tr><td>CLIP-I</td><td>0.751</td><td>0.801</td><td>0.891</td><td>0.823</td><td>0.823</td><td>0.838</td></tr><tr><td>CLIP-T</td><td>0.312</td><td>0.311</td><td>0.280</td><td>0.310</td><td>0.310</td><td>0.284</td></tr><tr><td colspan="5">Subject fancy-boot grey-sloth-plushie monster-toy</td><td>pink-sunglassesl S poop-emoji</td><td>rc-car</td></tr><tr><td>DINO</td><td>0.649</td><td>0.717</td><td>0.566</td><td>0.625</td><td>0.627</td><td>0.651</td></tr><tr><td>CLIP-I</td><td>0.827</td><td>0.780</td><td>0.743</td><td>0.826</td><td>0.784</td><td>0.775</td></tr><tr><td>CLIP-T</td><td>0.299</td><td>0.322</td><td>0.292</td><td>0.312</td><td>0.290</td><td>0.288</td></tr><tr><td colspan="5">Subject red-cartoon robot-toy</td><td>teapot vase</td><td>wolf-plushie</td></tr><tr><td>DINO</td><td>0.788</td><td>0.626</td><td>0.757</td><td>0.484</td><td>0.628</td><td>0.599</td></tr><tr><td>CLIP-I</td><td>0.882</td><td>0.803</td><td>0.804</td><td>0.819</td><td>0.812</td><td>0.760</td></tr><tr><td>CLIP-T</td><td>0.262</td><td>0.316</td><td>0.297</td><td>0.331</td><td>0.261</td><td>0.325</td></tr></table>
256
+
257
+ ![](images/ca33453c391d802a35a224ad8a0a5016a8aa6d409175c77d11ce5951e3f2b1d1.jpg)
258
+ Figure 9: Zero-shot subject interpolation. We interpolate subject representation and use the same denoising and decoder network for generation. The intermediate subject representation naturally blends the subject appearance, while fitting coherently into the new context.
259
+
260
+ ![](images/5df7f3677a45247115e50a4caeec1054e7e9e62e42d167b95d389e10006b4368.jpg)
261
+ Figure 10: Zero-shot subject-driven stylization. We show guiding subject images on top. In the rest rows, we show reference subjects and their canny maps on left, and stylized reference subjects by column.
262
+
263
+ ![](images/2782ce31f167be31385d787f811eb733e8bd0762a4c08e1777d40c03fe859574.jpg)
264
+ Figure 11: (Cont.) Zero-shot subject-driven stylization. We show guiding subject images on top. In the rest rows, we show reference subjects and their canny maps on left, and stylized reference subjects by column.
265
+
266
+ ![](images/cf7d32c2e7c42d51e309faf0552be2dddd6dff4b87167ec02a81206dc673afa5.jpg)
267
+ Figure 12: Additional qualitative results using DreamBench subjects and prompts. To showcase subject fidelity and photorealism, we mix one genuine subject image in the generations for readers to figure out. Zoom-in and read the captions to verify.
268
+
269
+ ![](images/612308d8e3be916587fcd7726e20766a1bf08f418fa9ad0b99324b1d8263a46e.jpg)
270
+ Figure 13: (Cont.) Additional qualitative results using DreamBench subjects and prompts. To showcase subject fidelity and photorealism, we mix one genuine subject image in the generations for readers to figure out. Zoom-in and read the captions to verify.
271
+
272
+ ![](images/f7432705c3728d927a89650afbf70caa961e6332e6b0bd5ed3e0b8d2caba512d.jpg)
273
+ Figure 14: (Cont.) Additional qualitative results using DreamBench subjects and prompts. To showcase subject fidelity and photorealism, we mix one genuine subject image in the generations for readers to figure out. Zoom-in and read the captions to verify.
md/dev/p40XRfBX96/p40XRfBX96.md ADDED
The diff for this file is too large to render. See raw diff
 
md/dev/zT5T9gHpGI/zT5T9gHpGI.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/-OrwaD3bG91/images/0294a4d81ac5ba0b88d700af4e1fbf8304e0099061bf33f6c1ecf26a590fbe7d.jpg ADDED

Git LFS Details

  • SHA256: a83458dffaa6a2306fbfa673b06d5767fd3a2b0292d78dfbc9b98fff9d77f7ce
  • Pointer size: 130 Bytes
  • Size of remote file: 40 kB
parse/train/-OrwaD3bG91/images/1900ff5a7e1b5a04b03832649b9fdf09dad1f97f7f92fd103e915552ff77f0aa.jpg ADDED

Git LFS Details

  • SHA256: 6bd496c3305fbbab24bfe29a5eb54e71c731a33b2fa48f329bed0957a52e68b3
  • Pointer size: 130 Bytes
  • Size of remote file: 42.4 kB
parse/train/-OrwaD3bG91/images/9f738e4e0f330137f939be30ce289f818ad9b77d6373ce40f4a55cc1cb8a2f01.jpg ADDED

Git LFS Details

  • SHA256: f734e15dbdf1f24c17fb7df75980f21ace89bd65f2b9222bb51a6502ac46e50f
  • Pointer size: 130 Bytes
  • Size of remote file: 75.8 kB
parse/train/-OrwaD3bG91/images/c39447023d7968d0529aa7c9857d7a8c0207ab8047cb80e05a5eb2ac492b89c9.jpg ADDED

Git LFS Details

  • SHA256: 93b5fe00fdbd201ed5f235123fd439c8c47108199b9cb7a6af3e25a7ae8d16d7
  • Pointer size: 130 Bytes
  • Size of remote file: 60.1 kB
parse/train/5PiSFHhRe2C/5PiSFHhRe2C.md ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # META AUXILIARY LABELS WITH CONSTITUENTBASED TRANSFORMER FOR ASPECT-BASED SENTIMENT ANALYSIS
2
+
3
+ Anonymous authors Paper under double-blind review
4
+
5
+ # ABSTRACT
6
+
7
+ Aspect based sentiment analysis (ABSA) is a challenging natural language processing task that could benefit from syntactic information. Previous work exploit dependency parses to improve performance on the task, but this requires the existence of good dependency parsers. In this paper, we build a constituent-based transformer for ABSA that can induce constituents without constituent parsers. We also apply meta auxiliary learning to generate labels on edges between tokens, supervised by the objective of the ABSA task. Without input from dependency parsers, our models outperform previous work on three Twitter data sets and match previous work closely on two review data sets.
8
+
9
+ # 1 INTRODUCTION
10
+
11
+ Aspect-based Sentiment Analysis (ABSA) is the task of predicting sentiment polarity towards observed aspects in a sentence. Recent work (Bai et al., 2020; Huang & Carley, 2019; Sun et al., 2019; Wang et al., 2020) used syntactic information from dependency parses to achieve new stateof-the-art results on benchmark ABSA data sets. However, these works (i) assumed the existence of good dependency parsers, and (ii) could not further optimize the pre-defined dependency labels for downstream performance of ABSA. Motivated by these limitations, we propose to induce syntactic information with supervision from the ABSA task.
12
+
13
+ To take syntax into account, we aim to induce the necessary syntactic information for the ABSA task with inductive biases. We first design a Constituent-based Transformer (ConsTrans) to group tokens into constituents supervised by the ABSA objective. We argue that the formation of constituents provides a hierarchical structure of the sentence that is suitable for sentiment analysis. For example, in the sentence “Chinese dumplings in this restaurant taste very good” with the aspect term “Chinese dumplings”, it is important to accurately assign the phrase “taste very good” to the aspect.
14
+
15
+ Next, as seen in Figure 1, even though the dependency graph structures for both sentences are identical, the sentiment towards “Chelsea” is positive for the input sentence on the left and negative for the one on the right. Therefore, the type of syntactic relationship between tokens would be useful to identify the sentiment towards the aspect term. Hence, we further extend ConsTrans into a Relational Constituent-based Transformer (RelConsTrans) to learn relation embeddings between every pair of tokens in the input sentence. We find that simply adding relation embedding fails to outperform ConsTrans. Inspired by Liu et al. (2019), we further extend RelConsTrans to supervise the relation embedding with an auxiliary label generator (RelConsTransLG). In previous work (e.g. Bai et al., 2020; Huang & Carley, 2019), the dependency parser played the role of the auxiliary label generator. However, such dependency parsers were not trained to provide auxiliary labels meant to improve ABSA. RelConsTransLG enables us to train the auxiliary label generator alongside the primary task to generate auxiliary labels that could directly enhance the performance of ABSA.
16
+
17
+ We evaluate our models on five data sets - restaurant and laptop reviews (Pontiki et al., 2014), ACL14 Twitter14 data (Dong et al., 2014), Twitter15 and Twitter17 from a multi-modal ABSA data set (Yu & Jiang, 2019). Compared against previous work which used dependency parsers, our models outperform them on all the Twitter data sets and matched previous work closely on the review data sets even without the use of constituent or dependency parser.
18
+
19
+ ![](images/f57e000dccb28e324dcabde6487f92da0967ffdecdf4a9cae1be5853934df60f.jpg)
20
+
21
+ ![](images/94484a4d51f973d547de9dfe3b3688aa232259c0ec362f977c1f2e2329844785.jpg)
22
+ Figure 1: Dependency parse labels as auxiliary labels that help sentiment disambiguation. Tokens in bold and underlined are the aspect terms. Example taken from Bai et al. (2020).
23
+ (a) ConsTrans Encoder Stack: dotted arrows refer to lower attention weights between tokens from different constituents.
24
+ (b) A lower ConsTrans layer: the shaded region is different from the vanilla Transformer.
25
+
26
+ # 2 MODEL FORMULATION
27
+
28
+ Given a sentence of $m$ tokens, $s = \{ w _ { 0 } , \ldots , w _ { m - 1 } \}$ , and a target aspect, $t = \left\{ w _ { j } , \ldots , w _ { j + q - 1 } \right\}$ of length $q$ , the objective of ABSA is to predict the sentiment polarity $y \in \{$ {negative, neutral, positive $\}$ towards the target aspect $t$ mentioned in sentence $s$ . In all our models, we use the pretrained BERT (Devlin et al., 2018) model (BERT-base-uncased) to obtain contextual embeddings as inputs to our model, and we fine tune it together with the model. We format the input to the BERT model as a e pair: obtai $[ C L S ] + s + [ S E P ] + t + [ S E P ]$ . We represent each tokenas input to our model. O $w _ { i }$ with the representationbase model is a 4-layer $h _ { i } ^ { b e r t , 1 2 }$
29
+ transformer on this representation, similar to the baseline Transformer(B) in Bai et al. (2020). In the rest of this section, we describe the modifications we make to this transformer to build our three proposed models, ConsTrans, RelConsTrans and RelConsTransLG.
30
+
31
+ # 2.1 CONSTITUENT-BASED TRANSFORMER (ConsTrans)
32
+
33
+ ConsTrans contains a stack of 4 Transformer encoder layers (Vaswani et al., 2017) with Multi-Head Attention (MHA) and a point-wise feed forward sub-layer in each layer. As illustrated in Figure 2a, the encoder stack of ConsTrans is grouped into two parts - the lower layers and the upper layers. In all our experiments, we have 2 layers each in both the lower and upper layers. The main difference between a vanilla Transformer network and ConsTrans is that the attention scores computed in the MHA layer between a pair of tokens are adjusted based on the probability that the two tokens belong to the same constituent. In the lower layers, attention weights are adjusted such that greater attention weights are assigned to tokens within the same constituent. This adjustment is not imposed at upper layers of the encoder to allow for longer range interactions.
34
+
35
+ Figure 2b shows a single encoder layer from the lower layers of the encoder stack. The shaded region in the figure, which emphasizes the difference from a vanilla Transformer encoder layer, contains three components: the MHA which provides the vanilla attention scores, the constituent probability scorer, and finally the adjusted MHA scorer that computes the final attention.
36
+
37
+ Constituent Probability Scorer Kim et al. (2020b) found that tokens from the same constituent tend to exhibit similar attention distributions. Hence we propose to determine the probability that a pair of tokens belong to the same constituent by the similarity of their attention distributions. We use the scaled dot-product attention (Vaswani et al., 2017) in the MHA layer to first obtain the attention
38
+
39
+ distributions of a token:
40
+
41
+ $$
42
+ \alpha _ { i , j } ^ { l z } = \frac { \exp { F ^ { l z } ( h _ { i } ^ { l } , h _ { j } ^ { l } ) } } { \sum _ { j ^ { \prime } } \exp { F ^ { l z } ( h _ { i } ^ { l } , h _ { j ^ { \prime } } ^ { l } ) } } ; \quad F ^ { l z } ( h _ { i } ^ { l } , h _ { j } ^ { l } ) = \frac { ( W _ { Q } ^ { l z } h _ { i } ^ { l } ) ( W _ { K } ^ { l z } h _ { j } ^ { l } ) ^ { T } } { \sqrt { d _ { k } } } ,
43
+ $$
44
+
45
+ where $W _ { Q } ^ { l z } \in \mathbb { R } ^ { d _ { m o d e l } , d _ { q } }$ and $W _ { K } ^ { l z } \in \mathbb { R } ^ { d _ { m o d e l } , d _ { k } }$ are projection layers that project the query and key to the various attention heads with dimension $d _ { q }$ and $d _ { k }$ respectively. The attention distribution for token $i$ at layer $l$ and attention head $z$ is then defined to be the vector $\alpha _ { i } ^ { l z } = [ \alpha _ { i j } ^ { l z } ] _ { j }$ . To obtain the attention distribution similarity for two tokens, $i$ and $j$ , we concatenate the attention patterns of the pair before passing it through a projection layer:
46
+
47
+ $$
48
+ s i m _ { i , j } ^ { l z } = \sqrt { \sigma ( W _ { \alpha } [ \alpha _ { i } ^ { l z } , \alpha _ { j } ^ { l z } ] ) \times \sigma ( W _ { \alpha } [ \alpha _ { j } ^ { l z } , \alpha _ { i } ^ { l z } ] ) }
49
+ $$
50
+
51
+ where $s i m _ { i , j } ^ { l z }$ refers to the attention distribution similarity score for token $i$ and token $j$ in layer $l$ for attention head $z$ , $W _ { \alpha } \in \mathbb { R } ^ { d , 1 }$ is a linear projection, [: , :] refers to the concatenation function and $\sigma$ the sigmoid function so that $s i m _ { i , j } ^ { l z } \in [ \bar { 0 , 1 } ]$ . We also note that this ensures $s i m _ { i , j } ^ { l z } = s i m _ { j , i } ^ { l z }$
52
+
53
+ We then use the attention distribution similarity scores to compute the probability that a pair of tokens belong to the same constituent. The base probability $c _ { i , j } ^ { ' l z }$ , that tokens $i$ and $j$ belong to the same constituent, is computed as follows:
54
+
55
+ $$
56
+ c _ { i , j } ^ { ' l z } = \left\{ \prod _ { k = 0 } ^ { j - i } s i m _ { i + k , i + k + 1 } ^ { l z } \quad j \leq i \right.
57
+ $$
58
+
59
+ This formulation considers the probability that tokens spanned by the two tokens $i$ and $j$ form a contiguous constituent. Moreover, since $\dot { s } i m _ { i , j } ^ { l z } \in [ 0 , 1 ]$ , the probability that two tokens are in the same constituent would decrease monotonically with the distance between $i$ and $j$ . To encourage the induced constituents to be consistent across layers, the final constituent probabilities obtained at the current layer would be the weighted sum of itself and constituent probabilities from the previous layer:
60
+
61
+ $$
62
+ c _ { i , j } ^ { l z } = \lambda * c _ { i , j } ^ { ' l z } + \left( 1 - \lambda \right) * c _ { i , j } ^ { ' l - 1 , z } ,
63
+ $$
64
+
65
+ where $\lambda \in [ 0 , 1 ]$ is a hyper-parameter that we tune.
66
+
67
+ Adjusted Attention in the Lower Constituent Layers Finally, we adjust the attention scores between a pair of tokens according to the probability that the pair belongs to the same constituent, through a softmax layer:
68
+
69
+ $$
70
+ \alpha _ { i , j } ^ { ' l z } = \frac { \exp c _ { i , j } ^ { l z } * \alpha _ { i , j } ^ { l z } } { \sum _ { j ^ { \prime } } \exp c _ { i , j } ^ { l z } * \alpha _ { i , j ^ { \prime } } ^ { l z } }
71
+ $$
72
+
73
+ where $\alpha _ { i , j } ^ { ' l z }$ denotes the adjusted attention score for token $i$ and $j$ for layer $l$ and attention head $z$
74
+
75
+ # 2.2 RELATIONAL CONSTITUENT-BASED TRANSFORMER (RelConsTrans)
76
+
77
+ We extend ConsTrans with the objective of learning relation embedding between pairs of tokens. For each pair of tokens, the goal is to learn an embedding that represents the syntactic relation between the pair. To generate the relation embedding, we learn a non-linear projection for the concatenation of the representation for the tokens:
78
+
79
+ $$
80
+ r _ { i , j } = W _ { r 2 } E L U ( W _ { r 1 } [ h _ { i } , h _ { j } ] ) ,
81
+ $$
82
+
83
+ where $r _ { i , j }$ is the learnt embedding for token $i$ and token $j$ , $E L U$ is the exponential linear unit, $h _ { i }$ and $h _ { j }$ are BERT embeddings for token $i$ and $j$ respectively. The learnt embedding would be included in two ways - during attention computation and during information propagation stage.
84
+
85
+ Relation-aware Attention Computation To perform relation-aware attention computation, we make the following changes to the adjusted scaled dot-product attention formulation in Equation 1 before adjusting the attention scores with constituent probability as in Equation 5:
86
+
87
+ ![](images/68f7341739d50c71930d36b84c5c19ea207dede4f9001672b318819c0d5b9a88.jpg)
88
+ Figure 3: Oveview of Relational Constituent-based Transformer and Relation Label Generator.
89
+
90
+ $$
91
+ \alpha _ { i , j } ^ { l z } = \frac { \exp F ^ { l z } ( h _ { i } ^ { l } , h _ { j } ^ { l } ) } { \sum _ { j ^ { \prime } } \exp F ^ { l z } ( h _ { i } ^ { l } , h _ { j ^ { \prime } } ^ { l } ) } ; \quad F ^ { l z } ( h _ { i } ^ { l } , h _ { j } ^ { l } ) = \frac { ( W _ { Q } ^ { l z } h _ { i } ^ { l } ) ( W _ { K } ^ { l z } h _ { j } ^ { l } + W _ { K r } ^ { l } r _ { i j } ) ^ { T } } { \sqrt { d _ { k } } }
92
+ $$
93
+
94
+ where $W _ { K r } ^ { l } \in \mathbb { R } ^ { d _ { r } , d _ { k } }$ projects the learnt relation embedding $r _ { i j }$ and is shared across attention heads. The attention weights would be determined by both textual features, $h _ { j } ^ { l }$ , and syntactic relation represented by $r _ { i j }$ .
95
+
96
+ Relation-aware information propagation The attention weights obtained from Equation 7 would then be used to weigh the contribution of other tokens in updating the representation of a token, $h _ { i } ^ { l }$ with the following equation:
97
+
98
+ $$
99
+ h _ { i } ^ { l + 1 } = W _ { p } ^ { l } [ \sum _ { j } \alpha _ { i , j } ^ { ' l 1 } * ( W _ { V } ^ { l z } h _ { j } ^ { l } + W _ { V r } ^ { l } r _ { i j } ) ] _ { z }
100
+ $$
101
+
102
+ where $W _ { V } ^ { l z } \in \mathbb R ^ { d _ { m o d e l } , d _ { v } }$ is a projection layer that project the value vector to various attention heads with dimension $d _ { v }$ . $W _ { p } ^ { l } \in \mathbb R ^ { d _ { v } , d _ { m o d e l } }$ projects the concatenation of vectors from each attention head to size $d _ { m o d e l }$ for layer $l$ . $W _ { V r } ^ { l } \in \mathbb { R } ^ { d _ { r } , d _ { v } }$ is a projection layer and is shared across attention heads. Therefore, both textual and syntactic and features would be propagated from one token to another.
103
+
104
+ # 2.3 RelConsTrans WITH LABEL GENERATOR (RelConsTransLG)
105
+
106
+ We found that RelConsTrans fails to outperform ConsTrans, possibly due to a lack of guidance on how the relation embedding should be learned. Previous work (e.g., Bai et al., 2020) used the dependency parser as an auxiliary label generator to improve ABSA. To avoid the need for a dependency parser, we propose to meta learn a relation label generator that would be trained alongside the primary task to generate auxiliary labels optimal for enhancing the performance of ABSA. An overview of the Relational Constituent-based Transformer with the Relation Generator (RelConsTransLG) is shown in Figure 3. The relation label generator, trained in a self-supervised manner (Liu et al., 2019), would produce relation labels to guide the learning of the relation embedding.
107
+
108
+ As syntax information has been shown to be useful for ABSA in previous work (e.g., Bai et al., 2020), we design our relation label generator to encourage the generation of syntax related labels as relation labels with supervision from the ABSA task. Hewitt & Manning (2019) showed that the L2 distance of a linear projection of token embeddings obtained from BERT could recover the parse tree distances between the tokens. Therefore, we learn a linear transformation of the word representation space with the intention of learning syntactic relatedness. The learned syntactic relatedness would then be used as the ground truth for the L2 norm of the relation embedding. Different from Hewitt & Manning (2019), we do not use ground truth labels to train the relation label generator. Instead, we learn this linear projection in a meta learning manner.
109
+
110
+ For a pair of tokens $i$ and $j$ , we learn a linear projection for the BERT representation:
111
+
112
+ $$
113
+ l _ { i j } = W _ { 1 } ( h _ { i } ^ { b e r t , n } - h _ { j } ^ { b e r t , n } ) + b _ { 1 } ,
114
+ $$
115
+
116
+ where $l _ { i j }$ is a scalar relation label for token $i$ and $j$ , $W _ { 1 }$ and $b _ { 1 }$ are the weights and bias of the linear transformation layer. hbert,ni r epresents the embedding of token $i$ from the $n ^ { t h }$ layer of the BERT
117
+
118
+ <table><tr><td rowspan="2">Data Set</td><td colspan="3">Positive</td><td colspan="3">Neutral</td><td colspan="3">Negative</td></tr><tr><td>Train</td><td>Dev</td><td>Test</td><td>Train</td><td>Dev</td><td>Test</td><td>Train</td><td>Dev</td><td>Test</td></tr><tr><td>Restaurant</td><td>2164</td><td>-</td><td>728</td><td>637</td><td>-</td><td>196</td><td>807</td><td>-</td><td>196</td></tr><tr><td>Laptop</td><td>994</td><td>、</td><td>341</td><td>464</td><td>-</td><td>169</td><td>870</td><td>-</td><td>128</td></tr><tr><td>Twitter14</td><td>1561</td><td>-</td><td>173</td><td>3127</td><td>-</td><td>346</td><td>1560</td><td>1</td><td>173</td></tr><tr><td>Twitter15</td><td>928</td><td>303</td><td>317</td><td>1883</td><td>670</td><td>607</td><td>368</td><td>149</td><td>113</td></tr><tr><td>Twitter17</td><td>1508</td><td>515</td><td>493</td><td>1638</td><td>517</td><td>573</td><td>416</td><td>144</td><td>168</td></tr><tr><td>Twitter14 (AS)</td><td>1538</td><td>-</td><td>190</td><td>3300</td><td>-</td><td>173</td><td>1445</td><td>-</td><td>288</td></tr></table>
119
+
120
+ Table 1: Statistics of the 5 benchmark data sets. TS refers to splitting the data by aspect.
121
+
122
+ model. As different layers of BERT appear to represent different types of information as shown by Tenney et al. (2019), we could recover different information by selecting different BERT layers (different $n$ ). In our experiments, we fixed the value of $n$ to 6 for all data sets.
123
+
124
+ Meta Training Relation Label Generator To guide the training of the embedding, we minimize the mean square error (MSE) of the generated label and the L2 norm of the relation embedding:
125
+
126
+ $$
127
+ M S E ( l , r ) = \sum _ { i . j } ( \| r _ { i j } \| _ { 2 } - l _ { i j } ) ^ { 2 } .
128
+ $$
129
+
130
+ Drawing inspiration from recent work by Liu et al. (2019), we train our label generator using the loss from ABSA with the goal of generating relation labels $l _ { i j }$ to directly optimize for the performance of the main task.
131
+
132
+ Let $\theta _ { m a i n }$ be the parameters of our main model, RelConsTrans. To update the parameters of $\theta _ { m a i n }$ , we aim to minimize a multi-task loss – cross-entropy loss, $L$ from the ABSA prediction task and the MSE loss described in Equation 10:
133
+
134
+ $$
135
+ \operatorname * { a r g m i n } _ { \theta _ { m a i n } } ( L ( \hat { y } , y ) + M S E ( l , r ) ) .
136
+ $$
137
+
138
+ Let $\theta _ { m a i n } ^ { + }$ be the weights of the RelConsTrans after one gradient update step of gradient descent:
139
+
140
+ $$
141
+ \theta _ { m a i n } ^ { + } = \theta _ { m a i n } - \alpha _ { m a i n } \nabla _ { \theta _ { m a i n } } \underset { \theta _ { m a i n } } { \arg \operatorname* { m i n } } ( L ( \hat { y } , y ) + M S E ( l , r ) ) ,
142
+ $$
143
+
144
+ where $\alpha _ { m a i n }$ is the learning rate to train the RelConsTrans. Note that the MSE from the relation embedding would not be used to train the relation label generator. Therefore, the parameters of the relation label generator, $\theta _ { a u x }$ should be updated by solely the loss from ABSA:
145
+
146
+ $$
147
+ \underset { \theta _ { a u x } } { \arg \operatorname* { m i n } } ( L ( \hat { y } , y ) ) ,
148
+ $$
149
+
150
+ To update the weights of the generator, a second order derivative is computed. While this formulation was inspired by Liu et al. (2019), the second-order derivative trick used in our model was also used in a number of other meta-learning frameworks such as Finn et al. (2017).
151
+
152
+ We train the two models in tandem, over a few iterations. We found it useful to train $\theta _ { m a i n }$ and $\theta _ { a u x }$ with separate training sets. For each data set, we took a subset of the cases which contain two or more aspects (meta-train set) in the same sentence for training $\theta _ { a u x }$ . This subset is removed from the main training set (train set) used to train the main RelConsTrans. More details of the meta-train set would be provided in the appendix A.1.
153
+
154
+ # 3 RESULTS AND ANALYSIS
155
+
156
+ We conducted experiments on 5 benchmark data sets - restaurant reviews, laptop reviews from SemEval 2014 (Pontiki et al., 2014), ACL14 Twitter14 data set (Dong et al., 2014) and Twitter15 and Twitter17 from a multi-modal ABSA data set by (Yu & Jiang, 2019). For analysis, we ran additional experiments on a split of the Twitter14 data set by aspect. We summarize the statistics of the data in Table 1. For data sets with development sets, we perform model selection on the development sets.
157
+
158
+ For Restaurant, Laptop and Twitter14, we compare against published results from BERT-PT $\mathrm { { \Delta X u } }$ et al., 2019), BERT-SPC (Song et al., 2019), AEN-BERT (Song et al., 2019), SDGCN-BERT (Zhao et al., 2020), Transformer(B) (Bai et al., 2020), RGAT-Bai (Bai et al., 2020), RGAT-Wang (Wang et al., 2020), DGEDT-BERT (Tang et al., 2020) and LCFS-ASC-CDW (Phan & Ogunbona, 2020). The Transformer(B) is a baseline model used by Bai et al. (2020), and is the baseline vanilla Transformer on which ConsTrans is built upon. For Twitter 15 and Twitter17, we compare against published results in (Yu & Jiang, 2019): MemNet (Tang et al., 2016), RAM (Chen et al., 2017), MGAN (Fan et al., 2018), BERT, BERT $^ +$ BL (Yu & Jiang, 2019) and TomBERT (Yu & Jiang, 2019).
159
+
160
+ Table 2: Accuracy and F-score (F1) for 5 data sets: In the left (resp. right) table, systems marked \* are those that used dependency parses (resp. multi-modal information). The best Macro F1 for each data set is in bold. For significance tests, we compare against RGAT-Wang(re-run), TomBERT and BERT $\scriptstyle + \mathrm { B L }$ . Our results are significant against RGAT-Wang(re-run) and BERT $\scriptstyle \cdot + \mathbf { B } \mathbf { L }$ . Twitter17 was significant against TomBERT (which used image data in addition to text data) but not Twitter15.
161
+
162
+ <table><tr><td>Data Set</td><td colspan="2">Restaurant</td><td colspan="2">Laptop</td><td colspan="2">Twitter14</td></tr><tr><td>Model</td><td>Acc</td><td>F1</td><td>Acc</td><td>F1</td><td>Acc</td><td>F1</td></tr><tr><td>BERT-PT</td><td>85.0</td><td>77.0</td><td>78.1</td><td>75.1</td><td></td><td>-</td></tr><tr><td>BERT-SPC</td><td>84.5</td><td>77.0</td><td>79.0</td><td>75.0</td><td>73.6</td><td>72.1</td></tr><tr><td>AEN-BERT</td><td>83.1</td><td>73.8</td><td>79.9</td><td>76.3</td><td>74.7</td><td>73.1</td></tr><tr><td>SDGCN-BERT</td><td>83.6</td><td>76.5</td><td>81.4</td><td>78.3</td><td>=</td><td>-</td></tr><tr><td>Transformer(B)</td><td>84.9</td><td>77.9</td><td>79.3</td><td>76.1</td><td>-</td><td>-</td></tr><tr><td>RGAT-Bai*</td><td>86.6</td><td>80.5</td><td>81.3</td><td>78.6</td><td>75.8</td><td>74.7</td></tr><tr><td>RGAT-Wang*</td><td>86.6</td><td>81.4</td><td>78.2</td><td>74.1</td><td>76.2</td><td>74.9</td></tr><tr><td>RGAT-Wang (re-run)*</td><td>85.7</td><td>79.1</td><td>79.0</td><td>75.6</td><td>73.6</td><td>73.1</td></tr><tr><td>DGEDT-BERT*</td><td>86.3</td><td>80.0</td><td>79.8</td><td>75.6</td><td>77.9</td><td>75.4</td></tr><tr><td>LCFS-ASC-CDW*</td><td>86.7</td><td>80.3</td><td>80.5</td><td>77.1</td><td>-</td><td>-</td></tr><tr><td>ConsTrans</td><td>85.8</td><td>80.8</td><td>80.6</td><td>77.2</td><td>76.6</td><td>75.0</td></tr><tr><td>RelConsTrans</td><td>85.4</td><td>79.3</td><td>80.1</td><td>76.4</td><td>75.9</td><td>74.7</td></tr><tr><td>RelConsTransLG</td><td>86.7</td><td>81.4</td><td>81.0</td><td>78.1</td><td>76.9</td><td>75.5</td></tr></table>
163
+
164
+ <table><tr><td>Data Set Model</td><td>Twitter15 Acc</td><td>F1</td><td>Twitter17 Acc</td><td>F1</td></tr><tr><td>AE-LSTM</td><td>70.3</td><td>63.4</td><td>61.7</td><td>58.0</td></tr><tr><td>MemNet</td><td>70.1</td><td>61.8</td><td>64.2</td><td>60.9</td></tr><tr><td>RAM</td><td>70.7</td><td>63.1</td><td>64.4</td><td>61.0</td></tr><tr><td>MGAN</td><td>71.2</td><td>64.2</td><td>64.8</td><td>61.5</td></tr><tr><td>BERT</td><td>74.2</td><td>68.9</td><td>68.2</td><td>65.2</td></tr><tr><td>BERT+BL</td><td>74.3</td><td>70.0</td><td>68.9</td><td>66.1</td></tr><tr><td>TomBERT*</td><td>77.2</td><td>71.8</td><td>70.5</td><td>68.0</td></tr><tr><td>ConsTrans</td><td>76.5</td><td>72.5</td><td>69.3</td><td>68.2</td></tr><tr><td>RelConsTrans</td><td>76.9</td><td>71.6</td><td>69.0</td><td>67.7</td></tr><tr><td>RelConsTransLG</td><td>76.8</td><td>73.3</td><td>69.8</td><td>68.5</td></tr></table>
165
+
166
+ For the Restaurant and Twitter14 data sets, we outperform all previous work that did not require dependency parsers by competitive margins (4.8 F-score for Restaurant and $2 . 4 \mathrm { F } \cdot$ -score for Twitter14). Our results on the Laptop data (78.1) is also close to the state-of-the-art results (78.3) achieved by SDGCN-BERT. Furthermore, comparing results with models that require a dependency parser, we also outperform a number of models while closely matching the results of others. For Twitter15 and Twitter17, we see in Table 2 that our best model outperforms previous work that uses only textual content by a margin (3.3 F-score for Twitter15 and 2.4 F-Score for Twitter17). Our model also outperforms TomBERT, the multi-modal models for Twitter15 and Twitter17.
167
+
168
+ To conduct statistical significance tests, we attempt to reproduce the results published for RGATWang, TomBERT and BERT $\mathrm { + B L }$ . For RGAT-Wang, we could not reproduce their published results (with their recommended settings), and hence we can only conduct the test against the results we obtain with their open source code, shown as RGAT-Wang(re-run) in Table 2. We run the randomization test (Yeh, 2000) with 100,000 shuffles. We found that RelConsTransLG outperforms RGATWang(re-run) and BERT $\scriptstyle + \mathrm { B L }$ significantly $( p < 0 . 1 5 )$ . RelConsTransLG significantly outperforms TomBERT (which has additional access to image data) for Twitter17, but not Twitter15.
169
+
170
+ When comparing our proposed ConsTrans model to a vanilla Transformer, we observe that ConsTrans outperforms the vanilla Transformer model for both the Restaurant and Laptop data sets. This suggests that it is indeed useful to induce constituents for ABSA. Lastly, comparing ConsTrans and RelConsTransLG, we observe that RelConsTransLG consistently outperforms ConsTrans for all the data sets. This suggests that our meta-learnt label generator is able to generate useful auxiliary labels for ConsTrans for the ABSA task.
171
+
172
+ # 3.1 ANALYSIS
173
+
174
+ In this section, we provide findings from ablation studies and analysis of our proposed models.
175
+
176
+ Grammar Induction We derive constituent trees with the constituent probabilities to verify if the derived trees resemble ground truth constituent trees. In Figure 4, we show an example where our derived constituent tree shows a similar structure to the ground truth constituency tree. Notably, we are able to accurately recall the aspect term, “jessica alba” as a constituent. The algorithm to derive constituent trees and more examples are provided in Appendix A.4 and A.6 respectively.
177
+
178
+ ![](images/5ecf3c166cd5c2d8abe39f6a37ace0de288864f8232c85df256ec6823b6ab954.jpg)
179
+ Figure 4: Example of derived constituent Tree by ConsTrans (Left) and constituent Tree from Berkeley Neural Parser (Kitaev & Klein, 2018) (Right).
180
+
181
+ We postulate that the ability of ConsTrans to group aspect terms into noun phrases should improve its ABSA accuracy. To study our hypothesis, we looked at ConsTrans’s ability to recall the entire aspect term as a noun phrase. For simplicity, we only look at records where aspect terms were not broken down into sub-word tokens. For Twitter17, we found that ConsTrans achieves 67.8 recall rate for correctly predicted instances and 62.2 for incorrect instances. The Pearson correlation coefficient between prediction accuracy and recall rate was significant (with $\mathfrak { p } < 0 . 2 )$ ), indicating the usefulness of being able to induce good constituents for ABSA.
182
+
183
+ Generalibility of RelConsTransLG The key argument by Liu et al. (2019) for designing an additional label generator is to increase the generalizability of the main model. To test the generalizability of RelConsTransLG, we create a more challenging version of Twitter14 by splitting the data such that the train and test set comprises of different aspect terms. The statistics of the data after splitting by aspect (denoted by AS) is shown in Table 1. We further split the train set by aspect terms to create a meta-train set to train the label generator in RelConsTransLG. Therefore, the relation label generator is trained to generate relation labels that enhance the performance of data with foreign aspect terms. In this AS setting, RelConsTransLG achieves a F-score of 64.3 while ConsTrans achieved a F-score of 62.8. Our designed framework mimics the actual train and test setting and is therefore able to increase the generalizabillity of RelConsTransLG.
184
+
185
+ Different layers of BERT as input Tenney et al. (2019) found that different BERT layers encapsulate different information useful for various NLP tasks. Therefore, we experimented with using all 12 layers of BERT as input to the label generator to study the impact on the F-score. The graph for the F-score against BERT layer $( n )$ is provided in Appendix A.3. Using representation from the $6 ^ { t h }$ layer of BERT yields the best results for the restaurant data set and we are able to consistently outperform models that do not use dependency parses for all value of $n$ chosen. Furthermore, this is an indication that syntactic information is indeed useful for ABSA since lower layers of BERT were found to encapsulate syntactic information.
186
+
187
+ Interpreting learnt relation labels Our relation label generator is designed to encourage the generation of syntax related labels. To verify the hypothesis that generated relation label is related to syntax, we reconstruct the dependency parses using the learnt relation embedding. Interestingly, while Dozat & Manning (2017) have found that the L2 norm of relation embedding resembles syntactic distance (i.e., a lower norm means stronger dependency), we found that our learned relation embedding exhibits an opposite phenomenon: a higher L2 norm indicates a stronger dependency. We hypothesize that relation embedding with higher L2 norm would influence attention weights to a greater extent. Therefore, the L2 norm of our learnt relation embedding would represent syntactic relatedness rather than syntactic distance. We then construct parse trees by linking tokens with highest L2 norm of their relation embedding as detailed in Appendix A.5.
188
+
189
+ Manual inspection of these records suggest that while a full parse tree was not induced, we are able to recover most of adjective-noun relations. As seen in Figure 5, we are able to retrieve the relation of (“pleasant”, “staff”) and (“friendly”, “staff”). This is expected since understanding adjectivenoun relations would be most important to ABSA compared to other types of relations. Therefore, training RelConsTransLG with supervision from solely ABSA would yield this behaviour.
190
+
191
+ Furthermore, to look at the ability of RelConsTransLG to link relevant adjective terms, we engaged two annotators to annotate the adjective terms relevant to each aspect term for the test set for the
192
+
193
+ ![](images/7328ff57d88b6e8ff997330a5ea9422df27283b0d3b6d2dd1a058c0a675abd86.jpg)
194
+ Figure 5: Examples of induced dependency parses Tree by RelConsTransLG (Top arrows) and ground truth dependency parses (bottom arrows) from StanfordNLP https://corenlp.run/. Arrows in grey are for opinion terms accurately linked to the aspect term “staff”.
195
+
196
+ Restaurant data. The annotators reconciled their differing opinions and gave each record a final label. Records with no clear opinion terms was given a ”None” label. There were 1,120 records annotated and 811 had annotated adjective terms. We rank the relatedness of tokens with the aspect term by the L2 norm of the relation embedding and compare it with ground truth ranks. Ground truth ranks were obtained by ranking tokens with their syntactic distance obtained from StanfordNLP dependency parser (Chen & Manning, 2014) with tied rank taken into account. For records where the adjective term was more than 1 syntactic distance away, we obtain an equal or smaller rank than the syntactic distance in $6 3 . 5 \%$ of the cases. Compared against position offset ranks, we obtain an equal or small rank than the number of position offsets in $6 5 . 0 \%$ of the cases.
197
+
198
+ # 4 RELATED WORK
199
+
200
+ Sentiment analysis (Pang & Lee, 2008) is a well studied natural language processing problem. Early works applied sentiment analysis to product reviews as a text classification problem. However, a review or social media post could express different sentiments to different aspects, and the task of aspect-based sentiment analysis aims at a finer classification of sentiment towards specific aspects (Dong et al., 2014) or aspects (Pontiki et al., 2016).
201
+
202
+ Recent work on ABSA has shown that the use of dependency parses for ABSA helps to improve performance (Bai et al., 2020; Huang & Carley, 2019; Sun et al., 2019; Wang et al., 2020). However, supervised dependency parsers require a substantial amount of annotated data, and might perform badly for out-of-domain (e.g., social media) or low-resource languages. On the other hand, it has been shown that contextual embeddings such as BERT (Devlin et al., 2018) contain significant information that could be useful to parsers (Clark et al., 2019; Kim et al., 2020a). Previous work such as Hewitt & Manning (2019) have shown that a linear projection is sufficient to recover syntactic information from BERT embedding. In this paper, we show that we can achieve similar ABSA performance without supervised parsers, by leveraging on BERT which was trained with raw data.
203
+
204
+ Previous work on unsupervised grammar induction such as Shen et al. (2019); Kim et al. (2019) aims to induce grammar from raw data. Our primary objective is not to induce grammar, but to encourage the model to learn to perform the ABSA task by learning the causal edge dependencies between constituents. We show that our approach is able to achieve results that rivals those obtained by models that have access to supervised dependency parsers.
205
+
206
+ In this work, we applied meta auxiliary learning (Liu et al., 2019) which learns to generate auxiliary labels, supervised by the primary task. While Liu et al. (2019) failed to interpret the auxiliary labels for the computer vision tasks they worked on, we showed that in our case, the induced auxiliary labels can be interpreted as syntactic relatedness to a certain extent.
207
+
208
+ # 5 CONCLUSION
209
+
210
+ In this paper, we apply a meta auxiliary learning approach to the ABSA task, and we show that the induced relations between phrases are interpretable and supports the primary task of sentiment analysis. We show that learning the auxiliary labels improve results over our baselines on all five data sets. Without using dependency parsers, our approach performs competitively compared to previous work that used dependency parses as input.
211
+
212
+ # REFERENCES
213
+
214
+ Xuefeng Bai, Pengbo Liu, and Yue Zhang. Exploiting typed syntactic dependencies for targeted sentiment classification using graph attention neural network. CoRR, abs/2002.09685, 2020. URL https://arxiv.org/abs/2002.09685.
215
+
216
+ Danqi Chen and Christopher Manning. A fast and accurate dependency parser using neural networks. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 740–750, Doha, Qatar, October 2014. Association for Computational Linguistics. doi: 10.3115/v1/D14-1082. URL https://www.aclweb.org/anthology/ D14-1082.
217
+
218
+ Peng Chen, Zhongqian Sun, Lidong Bing, and Wei Yang. Recurrent attention network on memory for aspect sentiment analysis. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pp. 452–461, Copenhagen, Denmark, September 2017. Association for Computational Linguistics. doi: 10.18653/v1/D17-1047. URL https://www. aclweb.org/anthology/D17-1047.
219
+
220
+ Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D. Manning. What does BERT look at? an analysis of bert’s attention. CoRR, abs/1906.04341, 2019. URL http://arxiv.org/ abs/1906.04341.
221
+
222
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. CoRR, abs/1810.04805, 2018. URL http://arxiv.org/abs/1810.04805.
223
+
224
+ Li Dong, Furu Wei, Chuanqi Tan, Duyu Tang, Ming Zhou, and Ke Xu. Adaptive recursive neural network for target-dependent twitter sentiment classification. In Proceedings of the 52nd Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 49–54, Baltimore, Maryland, June 2014. Association for Computational Linguistics. doi: 10.3115/v1/ P14-2009. URL https://www.aclweb.org/anthology/P14-2009.
225
+
226
+ Timothy Dozat and Christopher D. Manning. Deep biaffine attention for neural dependency parsing. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL https: //openreview.net/forum?id ${ . } = { }$ Hk95PK9le.
227
+
228
+ Feifan Fan, Yansong Feng, and Dongyan Zhao. Multi-grained attention network for aspect-level sentiment classification. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 3433–3442, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1380. URL https://www.aclweb. org/anthology/D18-1380.
229
+
230
+ Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. CoRR, abs/1703.03400, 2017. URL http://arxiv.org/abs/1703. 03400.
231
+
232
+ John Hewitt and Christopher D. Manning. A structural probe for finding syntax in word representations. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4129–4138, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1419. URL https://www.aclweb.org/anthology/ N19-1419.
233
+
234
+ Binxuan Huang and Kathleen Carley. Syntax-aware aspect level sentiment classification with graph attention networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 5469–5477, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/D19-1549. URL https://www.aclweb.org/ anthology/D19-1549.
235
+
236
+ Taeuk Kim, Jihun Choi, Daniel Edmiston, and Sang goo Lee. Are pre-trained language models aware of phrases? simple but strong baselines for grammar induction. In International Conference on Learning Representations, 2020a. URL https://openreview.net/forum?id= H1xPR3NtPB.
237
+
238
+ Taeuk Kim, Jihun Choi, Daniel Edmiston, and Sang goo Lee. Are pre-trained language models aware of phrases? simple but strong baselines for grammar induction. In International Conference on Learning Representations, 2020b. URL https://openreview.net/forum?id $=$ H1xPR3NtPB.
239
+
240
+ Yoon Kim, Alexander Rush, Lei Yu, Adhiguna Kuncoro, Chris Dyer, and Gabor Melis. Unsu- ´ pervised recurrent neural network grammars. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 1105–1117, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1114. URL https://www.aclweb.org/anthology/N19-1114.
241
+
242
+ Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Yoshua Bengio and Yann LeCun (eds.), 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http: //arxiv.org/abs/1412.6980.
243
+
244
+ Nikita Kitaev and Dan Klein. Constituency parsing with a self-attentive encoder. CoRR, abs/1805.01052, 2018. URL http://arxiv.org/abs/1805.01052.
245
+
246
+ Shikun Liu, Andrew J. Davison, and Edward Johns. Self-supervised generalisation with meta auxiliary learning. CoRR, abs/1901.08933, 2019. URL http://arxiv.org/abs/1901.08933.
247
+
248
+ Bo Pang and Lillian Lee. Opinion mining and sentiment analysis. Foundations and Trends in Information Retrieval, 2(1-2):1–135, 2008.
249
+
250
+ Minh Hieu Phan and Philip O. Ogunbona. Modelling context and syntactical features for aspectbased sentiment analysis. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 3211–3220, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.293. URL https://www.aclweb.org/ anthology/2020.acl-main.293.
251
+
252
+ Maria Pontiki, Dimitris Galanis, John Pavlopoulos, Harris Papageorgiou, Ion Androutsopoulos, and Suresh Manandhar. SemEval-2014 task 4: Aspect based sentiment analysis. In Proceedings of the 8th International Workshop on Semantic Evaluation (SemEval 2014), pp. 27–35, Dublin, Ireland, August 2014. Association for Computational Linguistics. doi: 10.3115/v1/S14-2004. URL https://www.aclweb.org/anthology/S14-2004.
253
+
254
+ Maria Pontiki, Dimitrios Galanis, Haris Papageorgiou, Ion Androutsopoulos, Suresh Manandhar, Mohammad Al-Smadi, Mahmoud Al-Ayyoub, Yanyan Zhao, Bing Qin, Orphee De Clercq, et al. ´ Semeval-2016 task 5: Aspect based sentiment analysis. In 10th International Workshop on Semantic Evaluation (SemEval 2016), 2016.
255
+
256
+ Yikang Shen, Shawn Tan, Alessandro Sordoni, and Aaron Courville. Ordered neurons: Integrating tree structures into recurrent neural networks. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ B1l6qiR5F7.
257
+
258
+ Youwei Song, Jiahai Wang, Tao Jiang, Zhiyue Liu, and Yanghui Rao. Attentional encoder network for targeted sentiment classification. CoRR, abs/1902.09314, 2019. URL http://arxiv. org/abs/1902.09314.
259
+
260
+ Kai Sun, Richong Zhang, Samuel Mensah, Yongyi Mao, and Xudong Liu. Aspect-level sentiment analysis via convolution over dependency tree. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 5679–5688, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/D19-1569. URL https://www.aclweb.org/anthology/D19-1569.
261
+
262
+ Duyu Tang, Bing Qin, and Ting Liu. Aspect level sentiment classification with deep memory network. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 214–224, Austin, Texas, November 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1021. URL https://www.aclweb.org/anthology/ D16-1021.
263
+
264
+ Hao Tang, Donghong Ji, Chenliang Li, and Qiji Zhou. Dependency graph enhanced dualtransformer structure for aspect-based sentiment classification. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 6578–6588, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.588. URL https://www.aclweb.org/anthology/2020.acl-main.588.
265
+
266
+ Ian Tenney, Dipanjan Das, and Ellie Pavlick. BERT rediscovers the classical NLP pipeline. CoRR, abs/1905.05950, 2019. URL http://arxiv.org/abs/1905.05950.
267
+
268
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. CoRR, abs/1706.03762, 2017. URL http://arxiv.org/abs/1706.03762.
269
+
270
+ Kai Wang, Weizhou Shen, Yunyi Yang, Xiaojun Quan, and Rui Wang. Relational graph attention network for aspect-based sentiment analysis. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, 2020. doi: 10.18653/v1/2020.acl-main.295. URL http://dx.doi.org/10.18653/v1/2020.acl-main.295.
271
+
272
+ Hu Xu, Bing Liu, Lei Shu, and Philip Yu. BERT post-training for review reading comprehension and aspect-based sentiment analysis. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 2324–2335, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1242. URL https://www.aclweb.org/anthology/N19-1242.
273
+
274
+ Alexander Yeh. More accurate tests for the statistical significance of result differences. In Proceedings of the 18th Conference on Computational Linguistics - Volume 2, COLING ’00, pp. 947–953, USA, 2000. Association for Computational Linguistics. doi: 10.3115/992730.992783. URL https://doi.org/10.3115/992730.992783.
275
+
276
+ Jianfei Yu and Jing Jiang. Adapting BERT for target-oriented multimodal sentiment classification. In Sarit Kraus (ed.), Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence, IJCAI 2019, Macao, China, August 10-16, 2019, pp. 5408–5414. ijcai.org, 2019. doi: 10.24963/ijcai.2019/751. URL https://doi.org/10.24963/ijcai.2019/751.
277
+
278
+ Pinlong Zhao, Linlin Hou, and Ou Wu. Modeling sentiment dependencies with graph convolutional networks for aspect-level sentiment classification. Knowledge-Based Systems, 193:105443, 2020.
279
+
280
+ # A APPENDIX
281
+
282
+ # A.1 META-SPLITTING DATA SET
283
+
284
+ To generate the meta-train set, we first obtain a subset of samples with multiple aspects of differing sentiment from the full train set. $80 \%$ of this subset would then be used as the meta-train set. For Twitter2014 (AS), we sampled this meta-train set by aspects. The intention is to train the Relation Label Generator to generate labels that can encourage the model to accurately link relevant opinion terms to the aspect term through challenging samples. The statistics of the meta-train set is provided in Table 3.
285
+
286
+ <table><tr><td>Data set</td><td>Positive</td><td>Neutral</td><td>Negative</td><td>Total</td></tr><tr><td>Restaurant</td><td>195</td><td>163</td><td>162</td><td>520</td></tr><tr><td>Laptop</td><td>85</td><td>98</td><td>61</td><td>244</td></tr><tr><td>Twitter2014</td><td>265</td><td>567</td><td>301</td><td>1133</td></tr><tr><td>Twitter2015</td><td>123</td><td>161</td><td>56</td><td>340</td></tr><tr><td>Twitter2017</td><td>320</td><td>470</td><td>111</td><td>901</td></tr><tr><td>Twitter2014 (AS)</td><td>207</td><td>253</td><td>254</td><td>714</td></tr></table>
287
+
288
+ Table 3: Statistics of the meta-train sets. AS refers to splitting the data by aspect.
289
+
290
+ # A.2 IMPLEMENTATION DETAILS
291
+
292
+ In all experiments, we used the ADAM optimizer (Kingma & Ba, 2015) with a learning rate of $1 0 ^ { - 5 }$ to optimize the models (ConsTrans, RelConsTrans, RelConsTransLG and the relation label generator). The BERT model was fine-tuned together with the main model built on top of it. We used 6 multi-head attention heads and the size of the hidden layer was set to be 384. We stacked 4 encoder layers. Lower layers are defined to be the first 2 layers in the encoder stack while the last 2 layers are higher layers. Dropout was applied to all input embeddings. The L2 penalisation term for the model’s parameters was set to be 1e-5. The size of the learnt embedding for each relation label was set to be 786 and a batch size of 4 was used to train all the models.
293
+
294
+ # A.3 DIFFERENT LAYERS OF BERT
295
+
296
+ The graph for Macro F-score against BERT layer $( n )$ is shown in Figure 6. Using representation from the $6 ^ { t h }$ layer of BERT yields the best results for the restaurant data set and we used the $6 ^ { t h }$ layer of BERT as input to the relation label generator for all the other data sets.
297
+
298
+ ![](images/e1bd1ff89f8e6d3a3a9a7c30856f2dd66b56b661e81c6af25fe48d8257cf8886.jpg)
299
+ Figure 6: Macro F-score on Restaurant data set with different BERT layer as input to LG.
300
+
301
+ # A.4 ALGORITHM TO DERIVE CONSTITUENT TREES
302
+
303
+ To derive constituent trees, we iteratively split the input constituents into 2 parts till each constituent is only made up of only 1 token. The breaking point is defined to be the point where the probability of being in the same constituent for token $i$ and $i + 1$ is the lowest. We use the constituent probability from the second layer of our encoder stack to find the breaking point.
304
+
305
+ # Algorithm 1 Unsupervised constituent tree derivation
306
+
307
+ 1: $m \gets$ Constituent layer chosen
308
+ 2: $x \gets$ Input tokens
309
+ 3: $p $ Constituent probability from layer m for current constituent
310
+ 4: $s t a c k = [ x ]$
311
+ 5: constituents = []
312
+ 6:
313
+ 7: procedure GETCONSTTREE $( x , p )$
314
+ 8: while len(stack) $! = 0$ do
315
+ 9: current const ← stack[0]
316
+ 10: $p _ { 0 } $ constituent probabilities for current const
317
+ 11: $\mathbf { b } = \mathbf { a r g m i n } ( b _ { 0 } )$ . Find the breaking poin
318
+ 12: l $f t _ { - } c o n s t = \mathbf { x } [ : \mathbf { b } ]$
319
+ 13: right const = x[b:]
320
+ 14: if len(left const) $> 1$ then
321
+ 15: add lef t const to constituents
322
+ 16: end if
323
+ 17: if len(right const) $> 1$ then
324
+ 18: add right const to constituents
325
+ 19: end if
326
+ 20: add lef t const and right const to constituents
327
+ 21: end while
328
+ 22: Return constituents
329
+ 23: end procedure
330
+
331
+ # A.5 ALGORITHM TO INDUCE DEPENDENCY PARSES
332
+
333
+ To recover parse trees, we iteratively linked tokens to another token with the highest L2 norm for the learnt relation embedding. We do not allow tokens to be linked multiple times.
334
+
335
+ # Algorithm 2 Unsupervised dependency parse tree induction
336
+
337
+ 1: procedure GETDEPNTREE $( x , p )$
338
+ 2: depen labels $= [ ]$
339
+ 3: relation norm The L2 norm of learnt embedding
340
+ 4: for $j 1$ to lengthx do
341
+ 5: current max $=$ max(relation norm)
342
+ 6: $i$ , $j =$ position(current max);
343
+ 7: add $( i , j )$ to depen labels
344
+ 8: relation norm[:, $\mathrm { j } ] = - \infty$ ;
345
+ 9: relation norm[j, $\mathrm { i } ] = - \infty$ ;
346
+ 10: end for
347
+ 11: Return depen labels
348
+ 12: end procedure
349
+
350
+ # A.6 EXAMPLES OF DERIVED CONSTITUENT TREES
351
+
352
+ We provide more examples of constituent trees derived from ConsTrans. In general, while we were not able to fully replicate ground truth constituent trees, we noticed that the model was able to recall noun phrases reasonably.
353
+
354
+ ![](images/f508c6d8bad2ac83439dbadb799c15148146bd3f14900d021262fd26a1789537.jpg)
355
+ Figure 7: Example of derived constituent Tree by ConsTrans with aspect term “ $@$ Jullia webber”.
356
+
357
+ ![](images/d91a9f8c4c6023759ee09237d8542a38ea91a1b791b9efe30394a60d351a3715.jpg)
358
+ Figure 8: Example of derived constituent Tree by ConsTrans with aspect term “ $@$ golden state warriors”.
359
+
360
+ ![](images/d8eb1eac665e47afaef1db091c5d25c7e7873f21ea0a84675602b49194d5fc97.jpg)
361
+ Figure 9: Example of derived constituent Tree by ConsTrans with aspect term “sadiq Kahn’s”.
362
+
363
+ # A.7 EXAMPLES OF INDUCED DEPENDENCY PARSE TREES
364
+
365
+ We provide more examples of induced dependency parses from RelConsTransLG. While our induced parse trees were not identical to ground truth parse trees, we were able to link adjective terms to noun phrases reasonably.
366
+
367
+ ![](images/db1b0ccd5378fbb9f9e95ce4cdc5366f77e9740c16143acd41489a68060d9ff4.jpg)
368
+ Figure 10: Examples of induced dependency parses Tree by RelConsTransLG (Top arrows) and ground truth dependency parses (bottom arrows) from StanfordNLP https://corenlp.run/. Arrows in grey are for opinion terms accurately linked to the aspect term “place”.
369
+
370
+ ![](images/861a1d5ef8075da5b3ed4ce5f0670fdcb6492a01191918fda410beb344598307.jpg)
371
+ Figure 11: Examples of induced dependency parses Tree by RelConsTransLG (Top arrows) and ground truth dependency parses (bottom arrows) from StanfordNLP https://corenlp.run/. Arrows in grey are for opinion terms accurately linked to the aspect term “owner”.
372
+
373
+ ![](images/c4df5d9fcec537e1b26f6645ea0d5f6fc2dfbf8b30828d26cbcfb3fa4cc570ba.jpg)
374
+ Figure 12: Examples of induced dependency parses Tree by RelConsTransLG (Top arrows) and ground truth dependency parses (bottom arrows) from StanfordNLP https://corenlp.run/. Arrows in grey are for opinion terms accurately linked to the aspect term “calamari”.
parse/train/5PiSFHhRe2C/5PiSFHhRe2C_content_list.json ADDED
@@ -0,0 +1,1773 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "META AUXILIARY LABELS WITH CONSTITUENTBASED TRANSFORMER FOR ASPECT-BASED SENTIMENT ANALYSIS ",
5
+ "text_level": 1,
6
+ "bbox": [
7
+ 174,
8
+ 99,
9
+ 821,
10
+ 171
11
+ ],
12
+ "page_idx": 0
13
+ },
14
+ {
15
+ "type": "text",
16
+ "text": "Anonymous authors Paper under double-blind review ",
17
+ "bbox": [
18
+ 183,
19
+ 195,
20
+ 398,
21
+ 223
22
+ ],
23
+ "page_idx": 0
24
+ },
25
+ {
26
+ "type": "text",
27
+ "text": "ABSTRACT ",
28
+ "text_level": 1,
29
+ "bbox": [
30
+ 454,
31
+ 261,
32
+ 544,
33
+ 275
34
+ ],
35
+ "page_idx": 0
36
+ },
37
+ {
38
+ "type": "text",
39
+ "text": "Aspect based sentiment analysis (ABSA) is a challenging natural language processing task that could benefit from syntactic information. Previous work exploit dependency parses to improve performance on the task, but this requires the existence of good dependency parsers. In this paper, we build a constituent-based transformer for ABSA that can induce constituents without constituent parsers. We also apply meta auxiliary learning to generate labels on edges between tokens, supervised by the objective of the ABSA task. Without input from dependency parsers, our models outperform previous work on three Twitter data sets and match previous work closely on two review data sets. ",
40
+ "bbox": [
41
+ 233,
42
+ 290,
43
+ 764,
44
+ 415
45
+ ],
46
+ "page_idx": 0
47
+ },
48
+ {
49
+ "type": "text",
50
+ "text": "1 INTRODUCTION ",
51
+ "text_level": 1,
52
+ "bbox": [
53
+ 176,
54
+ 440,
55
+ 336,
56
+ 457
57
+ ],
58
+ "page_idx": 0
59
+ },
60
+ {
61
+ "type": "text",
62
+ "text": "Aspect-based Sentiment Analysis (ABSA) is the task of predicting sentiment polarity towards observed aspects in a sentence. Recent work (Bai et al., 2020; Huang & Carley, 2019; Sun et al., 2019; Wang et al., 2020) used syntactic information from dependency parses to achieve new stateof-the-art results on benchmark ABSA data sets. However, these works (i) assumed the existence of good dependency parsers, and (ii) could not further optimize the pre-defined dependency labels for downstream performance of ABSA. Motivated by these limitations, we propose to induce syntactic information with supervision from the ABSA task. ",
63
+ "bbox": [
64
+ 174,
65
+ 470,
66
+ 825,
67
+ 569
68
+ ],
69
+ "page_idx": 0
70
+ },
71
+ {
72
+ "type": "text",
73
+ "text": "To take syntax into account, we aim to induce the necessary syntactic information for the ABSA task with inductive biases. We first design a Constituent-based Transformer (ConsTrans) to group tokens into constituents supervised by the ABSA objective. We argue that the formation of constituents provides a hierarchical structure of the sentence that is suitable for sentiment analysis. For example, in the sentence “Chinese dumplings in this restaurant taste very good” with the aspect term “Chinese dumplings”, it is important to accurately assign the phrase “taste very good” to the aspect. ",
74
+ "bbox": [
75
+ 174,
76
+ 575,
77
+ 825,
78
+ 674
79
+ ],
80
+ "page_idx": 0
81
+ },
82
+ {
83
+ "type": "text",
84
+ "text": "Next, as seen in Figure 1, even though the dependency graph structures for both sentences are identical, the sentiment towards “Chelsea” is positive for the input sentence on the left and negative for the one on the right. Therefore, the type of syntactic relationship between tokens would be useful to identify the sentiment towards the aspect term. Hence, we further extend ConsTrans into a Relational Constituent-based Transformer (RelConsTrans) to learn relation embeddings between every pair of tokens in the input sentence. We find that simply adding relation embedding fails to outperform ConsTrans. Inspired by Liu et al. (2019), we further extend RelConsTrans to supervise the relation embedding with an auxiliary label generator (RelConsTransLG). In previous work (e.g. Bai et al., 2020; Huang & Carley, 2019), the dependency parser played the role of the auxiliary label generator. However, such dependency parsers were not trained to provide auxiliary labels meant to improve ABSA. RelConsTransLG enables us to train the auxiliary label generator alongside the primary task to generate auxiliary labels that could directly enhance the performance of ABSA. ",
85
+ "bbox": [
86
+ 174,
87
+ 681,
88
+ 825,
89
+ 847
90
+ ],
91
+ "page_idx": 0
92
+ },
93
+ {
94
+ "type": "text",
95
+ "text": "We evaluate our models on five data sets - restaurant and laptop reviews (Pontiki et al., 2014), ACL14 Twitter14 data (Dong et al., 2014), Twitter15 and Twitter17 from a multi-modal ABSA data set (Yu & Jiang, 2019). Compared against previous work which used dependency parsers, our models outperform them on all the Twitter data sets and matched previous work closely on the review data sets even without the use of constituent or dependency parser. ",
96
+ "bbox": [
97
+ 176,
98
+ 854,
99
+ 823,
100
+ 924
101
+ ],
102
+ "page_idx": 0
103
+ },
104
+ {
105
+ "type": "image",
106
+ "img_path": "images/f57e000dccb28e324dcabde6487f92da0967ffdecdf4a9cae1be5853934df60f.jpg",
107
+ "image_caption": [],
108
+ "image_footnote": [],
109
+ "bbox": [
110
+ 302,
111
+ 101,
112
+ 694,
113
+ 156
114
+ ],
115
+ "page_idx": 1
116
+ },
117
+ {
118
+ "type": "image",
119
+ "img_path": "images/94484a4d51f973d547de9dfe3b3688aa232259c0ec362f977c1f2e2329844785.jpg",
120
+ "image_caption": [
121
+ "Figure 1: Dependency parse labels as auxiliary labels that help sentiment disambiguation. Tokens in bold and underlined are the aspect terms. Example taken from Bai et al. (2020). ",
122
+ "(a) ConsTrans Encoder Stack: dotted arrows refer to lower attention weights between tokens from different constituents. ",
123
+ "(b) A lower ConsTrans layer: the shaded region is different from the vanilla Transformer. "
124
+ ],
125
+ "image_footnote": [],
126
+ "bbox": [
127
+ 176,
128
+ 209,
129
+ 794,
130
+ 395
131
+ ],
132
+ "page_idx": 1
133
+ },
134
+ {
135
+ "type": "text",
136
+ "text": "2 MODEL FORMULATION ",
137
+ "text_level": 1,
138
+ "bbox": [
139
+ 176,
140
+ 449,
141
+ 400,
142
+ 464
143
+ ],
144
+ "page_idx": 1
145
+ },
146
+ {
147
+ "type": "text",
148
+ "text": "Given a sentence of $m$ tokens, $s = \\{ w _ { 0 } , \\ldots , w _ { m - 1 } \\}$ , and a target aspect, $t = \\left\\{ w _ { j } , \\ldots , w _ { j + q - 1 } \\right\\}$ of length $q$ , the objective of ABSA is to predict the sentiment polarity $y \\in \\{$ {negative, neutral, positive $\\}$ towards the target aspect $t$ mentioned in sentence $s$ . In all our models, we use the pretrained BERT (Devlin et al., 2018) model (BERT-base-uncased) to obtain contextual embeddings as inputs to our model, and we fine tune it together with the model. We format the input to the BERT model as a e pair: obtai $[ C L S ] + s + [ S E P ] + t + [ S E P ]$ . We represent each tokenas input to our model. O $w _ { i }$ with the representationbase model is a 4-layer $h _ { i } ^ { b e r t , 1 2 }$ \ntransformer on this representation, similar to the baseline Transformer(B) in Bai et al. (2020). In the rest of this section, we describe the modifications we make to this transformer to build our three proposed models, ConsTrans, RelConsTrans and RelConsTransLG. ",
149
+ "bbox": [
150
+ 173,
151
+ 479,
152
+ 825,
153
+ 621
154
+ ],
155
+ "page_idx": 1
156
+ },
157
+ {
158
+ "type": "text",
159
+ "text": "2.1 CONSTITUENT-BASED TRANSFORMER (ConsTrans) ",
160
+ "text_level": 1,
161
+ "bbox": [
162
+ 174,
163
+ 638,
164
+ 565,
165
+ 652
166
+ ],
167
+ "page_idx": 1
168
+ },
169
+ {
170
+ "type": "text",
171
+ "text": "ConsTrans contains a stack of 4 Transformer encoder layers (Vaswani et al., 2017) with Multi-Head Attention (MHA) and a point-wise feed forward sub-layer in each layer. As illustrated in Figure 2a, the encoder stack of ConsTrans is grouped into two parts - the lower layers and the upper layers. In all our experiments, we have 2 layers each in both the lower and upper layers. The main difference between a vanilla Transformer network and ConsTrans is that the attention scores computed in the MHA layer between a pair of tokens are adjusted based on the probability that the two tokens belong to the same constituent. In the lower layers, attention weights are adjusted such that greater attention weights are assigned to tokens within the same constituent. This adjustment is not imposed at upper layers of the encoder to allow for longer range interactions. ",
172
+ "bbox": [
173
+ 173,
174
+ 664,
175
+ 825,
176
+ 790
177
+ ],
178
+ "page_idx": 1
179
+ },
180
+ {
181
+ "type": "text",
182
+ "text": "Figure 2b shows a single encoder layer from the lower layers of the encoder stack. The shaded region in the figure, which emphasizes the difference from a vanilla Transformer encoder layer, contains three components: the MHA which provides the vanilla attention scores, the constituent probability scorer, and finally the adjusted MHA scorer that computes the final attention. ",
183
+ "bbox": [
184
+ 174,
185
+ 796,
186
+ 823,
187
+ 853
188
+ ],
189
+ "page_idx": 1
190
+ },
191
+ {
192
+ "type": "text",
193
+ "text": "Constituent Probability Scorer Kim et al. (2020b) found that tokens from the same constituent tend to exhibit similar attention distributions. Hence we propose to determine the probability that a pair of tokens belong to the same constituent by the similarity of their attention distributions. We use the scaled dot-product attention (Vaswani et al., 2017) in the MHA layer to first obtain the attention ",
194
+ "bbox": [
195
+ 174,
196
+ 867,
197
+ 823,
198
+ 924
199
+ ],
200
+ "page_idx": 1
201
+ },
202
+ {
203
+ "type": "text",
204
+ "text": "distributions of a token: ",
205
+ "bbox": [
206
+ 174,
207
+ 103,
208
+ 331,
209
+ 117
210
+ ],
211
+ "page_idx": 2
212
+ },
213
+ {
214
+ "type": "equation",
215
+ "img_path": "images/c683b1d9f7423835c03c7beafa7a776559b3bf58d6a9f10162dfe802fbed782d.jpg",
216
+ "text": "$$\n\\alpha _ { i , j } ^ { l z } = \\frac { \\exp { F ^ { l z } ( h _ { i } ^ { l } , h _ { j } ^ { l } ) } } { \\sum _ { j ^ { \\prime } } \\exp { F ^ { l z } ( h _ { i } ^ { l } , h _ { j ^ { \\prime } } ^ { l } ) } } ; \\quad F ^ { l z } ( h _ { i } ^ { l } , h _ { j } ^ { l } ) = \\frac { ( W _ { Q } ^ { l z } h _ { i } ^ { l } ) ( W _ { K } ^ { l z } h _ { j } ^ { l } ) ^ { T } } { \\sqrt { d _ { k } } } ,\n$$",
217
+ "text_format": "latex",
218
+ "bbox": [
219
+ 274,
220
+ 123,
221
+ 722,
222
+ 162
223
+ ],
224
+ "page_idx": 2
225
+ },
226
+ {
227
+ "type": "text",
228
+ "text": "where $W _ { Q } ^ { l z } \\in \\mathbb { R } ^ { d _ { m o d e l } , d _ { q } }$ and $W _ { K } ^ { l z } \\in \\mathbb { R } ^ { d _ { m o d e l } , d _ { k } }$ are projection layers that project the query and key to the various attention heads with dimension $d _ { q }$ and $d _ { k }$ respectively. The attention distribution for token $i$ at layer $l$ and attention head $z$ is then defined to be the vector $\\alpha _ { i } ^ { l z } = [ \\alpha _ { i j } ^ { l z } ] _ { j }$ . To obtain the attention distribution similarity for two tokens, $i$ and $j$ , we concatenate the attention patterns of the pair before passing it through a projection layer: ",
229
+ "bbox": [
230
+ 173,
231
+ 170,
232
+ 826,
233
+ 246
234
+ ],
235
+ "page_idx": 2
236
+ },
237
+ {
238
+ "type": "equation",
239
+ "img_path": "images/6f82e15670b26fc925b5171367dfa4d98ac1de99512311da812ade28d86f3a0e.jpg",
240
+ "text": "$$\ns i m _ { i , j } ^ { l z } = \\sqrt { \\sigma ( W _ { \\alpha } [ \\alpha _ { i } ^ { l z } , \\alpha _ { j } ^ { l z } ] ) \\times \\sigma ( W _ { \\alpha } [ \\alpha _ { j } ^ { l z } , \\alpha _ { i } ^ { l z } ] ) }\n$$",
241
+ "text_format": "latex",
242
+ "bbox": [
243
+ 338,
244
+ 253,
245
+ 658,
246
+ 281
247
+ ],
248
+ "page_idx": 2
249
+ },
250
+ {
251
+ "type": "text",
252
+ "text": "where $s i m _ { i , j } ^ { l z }$ refers to the attention distribution similarity score for token $i$ and token $j$ in layer $l$ for attention head $z$ , $W _ { \\alpha } \\in \\mathbb { R } ^ { d , 1 }$ is a linear projection, [: , :] refers to the concatenation function and $\\sigma$ the sigmoid function so that $s i m _ { i , j } ^ { l z } \\in [ \\bar { 0 , 1 } ]$ . We also note that this ensures $s i m _ { i , j } ^ { l z } = s i m _ { j , i } ^ { l z }$ ",
253
+ "bbox": [
254
+ 174,
255
+ 290,
256
+ 825,
257
+ 337
258
+ ],
259
+ "page_idx": 2
260
+ },
261
+ {
262
+ "type": "text",
263
+ "text": "We then use the attention distribution similarity scores to compute the probability that a pair of tokens belong to the same constituent. The base probability $c _ { i , j } ^ { ' l z }$ , that tokens $i$ and $j$ belong to the same constituent, is computed as follows: ",
264
+ "bbox": [
265
+ 174,
266
+ 342,
267
+ 825,
268
+ 386
269
+ ],
270
+ "page_idx": 2
271
+ },
272
+ {
273
+ "type": "equation",
274
+ "img_path": "images/5fa8fea324e97af530e15605b620f70a55d737c47a9af48cbbd4fd490f255430.jpg",
275
+ "text": "$$\nc _ { i , j } ^ { ' l z } = \\left\\{ \\prod _ { k = 0 } ^ { j - i } s i m _ { i + k , i + k + 1 } ^ { l z } \\quad j \\leq i \\right.\n$$",
276
+ "text_format": "latex",
277
+ "bbox": [
278
+ 372,
279
+ 393,
280
+ 625,
281
+ 436
282
+ ],
283
+ "page_idx": 2
284
+ },
285
+ {
286
+ "type": "text",
287
+ "text": "This formulation considers the probability that tokens spanned by the two tokens $i$ and $j$ form a contiguous constituent. Moreover, since $\\dot { s } i m _ { i , j } ^ { l z } \\in [ 0 , 1 ]$ , the probability that two tokens are in the same constituent would decrease monotonically with the distance between $i$ and $j$ . To encourage the induced constituents to be consistent across layers, the final constituent probabilities obtained at the current layer would be the weighted sum of itself and constituent probabilities from the previous layer: ",
288
+ "bbox": [
289
+ 173,
290
+ 443,
291
+ 825,
292
+ 526
293
+ ],
294
+ "page_idx": 2
295
+ },
296
+ {
297
+ "type": "equation",
298
+ "img_path": "images/0c817f33270bdabba0b167de42039e0eaab658116999662702988ecaf70cb486.jpg",
299
+ "text": "$$\nc _ { i , j } ^ { l z } = \\lambda * c _ { i , j } ^ { ' l z } + \\left( 1 - \\lambda \\right) * c _ { i , j } ^ { ' l - 1 , z } ,\n$$",
300
+ "text_format": "latex",
301
+ "bbox": [
302
+ 383,
303
+ 526,
304
+ 612,
305
+ 549
306
+ ],
307
+ "page_idx": 2
308
+ },
309
+ {
310
+ "type": "text",
311
+ "text": "where $\\lambda \\in [ 0 , 1 ]$ is a hyper-parameter that we tune. ",
312
+ "bbox": [
313
+ 176,
314
+ 554,
315
+ 506,
316
+ 569
317
+ ],
318
+ "page_idx": 2
319
+ },
320
+ {
321
+ "type": "text",
322
+ "text": "Adjusted Attention in the Lower Constituent Layers Finally, we adjust the attention scores between a pair of tokens according to the probability that the pair belongs to the same constituent, through a softmax layer: ",
323
+ "bbox": [
324
+ 173,
325
+ 585,
326
+ 825,
327
+ 627
328
+ ],
329
+ "page_idx": 2
330
+ },
331
+ {
332
+ "type": "equation",
333
+ "img_path": "images/c6135918bc61974ff87d5b3cdace09f4284b6028a40e8d6cbe448c3bcc5269e7.jpg",
334
+ "text": "$$\n\\alpha _ { i , j } ^ { ' l z } = \\frac { \\exp c _ { i , j } ^ { l z } * \\alpha _ { i , j } ^ { l z } } { \\sum _ { j ^ { \\prime } } \\exp c _ { i , j } ^ { l z } * \\alpha _ { i , j ^ { \\prime } } ^ { l z } }\n$$",
335
+ "text_format": "latex",
336
+ "bbox": [
337
+ 408,
338
+ 627,
339
+ 591,
340
+ 667
341
+ ],
342
+ "page_idx": 2
343
+ },
344
+ {
345
+ "type": "text",
346
+ "text": "where $\\alpha _ { i , j } ^ { ' l z }$ denotes the adjusted attention score for token $i$ and $j$ for layer $l$ and attention head $z$ ",
347
+ "bbox": [
348
+ 171,
349
+ 674,
350
+ 803,
351
+ 689
352
+ ],
353
+ "page_idx": 2
354
+ },
355
+ {
356
+ "type": "text",
357
+ "text": "2.2 RELATIONAL CONSTITUENT-BASED TRANSFORMER (RelConsTrans) ",
358
+ "text_level": 1,
359
+ "bbox": [
360
+ 176,
361
+ 705,
362
+ 683,
363
+ 722
364
+ ],
365
+ "page_idx": 2
366
+ },
367
+ {
368
+ "type": "text",
369
+ "text": "We extend ConsTrans with the objective of learning relation embedding between pairs of tokens. For each pair of tokens, the goal is to learn an embedding that represents the syntactic relation between the pair. To generate the relation embedding, we learn a non-linear projection for the concatenation of the representation for the tokens: ",
370
+ "bbox": [
371
+ 173,
372
+ 733,
373
+ 825,
374
+ 790
375
+ ],
376
+ "page_idx": 2
377
+ },
378
+ {
379
+ "type": "equation",
380
+ "img_path": "images/f6bd59b52cf79702b86ee8d2dc8a5c17483717761f0b0c8562bae7e6c77945fa.jpg",
381
+ "text": "$$\nr _ { i , j } = W _ { r 2 } E L U ( W _ { r 1 } [ h _ { i } , h _ { j } ] ) ,\n$$",
382
+ "text_format": "latex",
383
+ "bbox": [
384
+ 393,
385
+ 797,
386
+ 602,
387
+ 815
388
+ ],
389
+ "page_idx": 2
390
+ },
391
+ {
392
+ "type": "text",
393
+ "text": "where $r _ { i , j }$ is the learnt embedding for token $i$ and token $j$ , $E L U$ is the exponential linear unit, $h _ { i }$ and $h _ { j }$ are BERT embeddings for token $i$ and $j$ respectively. The learnt embedding would be included in two ways - during attention computation and during information propagation stage. ",
394
+ "bbox": [
395
+ 174,
396
+ 821,
397
+ 825,
398
+ 866
399
+ ],
400
+ "page_idx": 2
401
+ },
402
+ {
403
+ "type": "text",
404
+ "text": "Relation-aware Attention Computation To perform relation-aware attention computation, we make the following changes to the adjusted scaled dot-product attention formulation in Equation 1 before adjusting the attention scores with constituent probability as in Equation 5: ",
405
+ "bbox": [
406
+ 174,
407
+ 881,
408
+ 823,
409
+ 924
410
+ ],
411
+ "page_idx": 2
412
+ },
413
+ {
414
+ "type": "image",
415
+ "img_path": "images/68f7341739d50c71930d36b84c5c19ea207dede4f9001672b318819c0d5b9a88.jpg",
416
+ "image_caption": [
417
+ "Figure 3: Oveview of Relational Constituent-based Transformer and Relation Label Generator. "
418
+ ],
419
+ "image_footnote": [],
420
+ "bbox": [
421
+ 300,
422
+ 99,
423
+ 696,
424
+ 231
425
+ ],
426
+ "page_idx": 3
427
+ },
428
+ {
429
+ "type": "equation",
430
+ "img_path": "images/86fad71f3a4f330946c9eccdcf9b94098211ccb7faed6b04ef02ff69432d417e.jpg",
431
+ "text": "$$\n\\alpha _ { i , j } ^ { l z } = \\frac { \\exp F ^ { l z } ( h _ { i } ^ { l } , h _ { j } ^ { l } ) } { \\sum _ { j ^ { \\prime } } \\exp F ^ { l z } ( h _ { i } ^ { l } , h _ { j ^ { \\prime } } ^ { l } ) } ; \\quad F ^ { l z } ( h _ { i } ^ { l } , h _ { j } ^ { l } ) = \\frac { ( W _ { Q } ^ { l z } h _ { i } ^ { l } ) ( W _ { K } ^ { l z } h _ { j } ^ { l } + W _ { K r } ^ { l } r _ { i j } ) ^ { T } } { \\sqrt { d _ { k } } }\n$$",
432
+ "text_format": "latex",
433
+ "bbox": [
434
+ 240,
435
+ 290,
436
+ 758,
437
+ 330
438
+ ],
439
+ "page_idx": 3
440
+ },
441
+ {
442
+ "type": "text",
443
+ "text": "where $W _ { K r } ^ { l } \\in \\mathbb { R } ^ { d _ { r } , d _ { k } }$ projects the learnt relation embedding $r _ { i j }$ and is shared across attention heads. The attention weights would be determined by both textual features, $h _ { j } ^ { l }$ , and syntactic relation represented by $r _ { i j }$ . ",
444
+ "bbox": [
445
+ 174,
446
+ 340,
447
+ 823,
448
+ 386
449
+ ],
450
+ "page_idx": 3
451
+ },
452
+ {
453
+ "type": "text",
454
+ "text": "Relation-aware information propagation The attention weights obtained from Equation 7 would then be used to weigh the contribution of other tokens in updating the representation of a token, $h _ { i } ^ { l }$ with the following equation: ",
455
+ "bbox": [
456
+ 173,
457
+ 400,
458
+ 825,
459
+ 443
460
+ ],
461
+ "page_idx": 3
462
+ },
463
+ {
464
+ "type": "equation",
465
+ "img_path": "images/1a7de497db36d96341bd2ac28be1745f173c8f505adbeeeb8b6cb76b54b5310e.jpg",
466
+ "text": "$$\nh _ { i } ^ { l + 1 } = W _ { p } ^ { l } [ \\sum _ { j } \\alpha _ { i , j } ^ { ' l 1 } * ( W _ { V } ^ { l z } h _ { j } ^ { l } + W _ { V r } ^ { l } r _ { i j } ) ] _ { z }\n$$",
467
+ "text_format": "latex",
468
+ "bbox": [
469
+ 351,
470
+ 449,
471
+ 645,
472
+ 483
473
+ ],
474
+ "page_idx": 3
475
+ },
476
+ {
477
+ "type": "text",
478
+ "text": "where $W _ { V } ^ { l z } \\in \\mathbb R ^ { d _ { m o d e l } , d _ { v } }$ is a projection layer that project the value vector to various attention heads with dimension $d _ { v }$ . $W _ { p } ^ { l } \\in \\mathbb R ^ { d _ { v } , d _ { m o d e l } }$ projects the concatenation of vectors from each attention head to size $d _ { m o d e l }$ for layer $l$ . $W _ { V r } ^ { l } \\in \\mathbb { R } ^ { d _ { r } , d _ { v } }$ is a projection layer and is shared across attention heads. Therefore, both textual and syntactic and features would be propagated from one token to another. ",
479
+ "bbox": [
480
+ 174,
481
+ 489,
482
+ 825,
483
+ 553
484
+ ],
485
+ "page_idx": 3
486
+ },
487
+ {
488
+ "type": "text",
489
+ "text": "2.3 RelConsTrans WITH LABEL GENERATOR (RelConsTransLG) ",
490
+ "text_level": 1,
491
+ "bbox": [
492
+ 174,
493
+ 568,
494
+ 620,
495
+ 583
496
+ ],
497
+ "page_idx": 3
498
+ },
499
+ {
500
+ "type": "text",
501
+ "text": "We found that RelConsTrans fails to outperform ConsTrans, possibly due to a lack of guidance on how the relation embedding should be learned. Previous work (e.g., Bai et al., 2020) used the dependency parser as an auxiliary label generator to improve ABSA. To avoid the need for a dependency parser, we propose to meta learn a relation label generator that would be trained alongside the primary task to generate auxiliary labels optimal for enhancing the performance of ABSA. An overview of the Relational Constituent-based Transformer with the Relation Generator (RelConsTransLG) is shown in Figure 3. The relation label generator, trained in a self-supervised manner (Liu et al., 2019), would produce relation labels to guide the learning of the relation embedding. ",
502
+ "bbox": [
503
+ 173,
504
+ 593,
505
+ 825,
506
+ 707
507
+ ],
508
+ "page_idx": 3
509
+ },
510
+ {
511
+ "type": "text",
512
+ "text": "As syntax information has been shown to be useful for ABSA in previous work (e.g., Bai et al., 2020), we design our relation label generator to encourage the generation of syntax related labels as relation labels with supervision from the ABSA task. Hewitt & Manning (2019) showed that the L2 distance of a linear projection of token embeddings obtained from BERT could recover the parse tree distances between the tokens. Therefore, we learn a linear transformation of the word representation space with the intention of learning syntactic relatedness. The learned syntactic relatedness would then be used as the ground truth for the L2 norm of the relation embedding. Different from Hewitt & Manning (2019), we do not use ground truth labels to train the relation label generator. Instead, we learn this linear projection in a meta learning manner. ",
513
+ "bbox": [
514
+ 173,
515
+ 712,
516
+ 825,
517
+ 839
518
+ ],
519
+ "page_idx": 3
520
+ },
521
+ {
522
+ "type": "text",
523
+ "text": "For a pair of tokens $i$ and $j$ , we learn a linear projection for the BERT representation: ",
524
+ "bbox": [
525
+ 174,
526
+ 844,
527
+ 730,
528
+ 859
529
+ ],
530
+ "page_idx": 3
531
+ },
532
+ {
533
+ "type": "equation",
534
+ "img_path": "images/4607a679cdad1234e30c9159889bb88b3afb5ec31a3b2f389bff3c51c86b93bd.jpg",
535
+ "text": "$$\nl _ { i j } = W _ { 1 } ( h _ { i } ^ { b e r t , n } - h _ { j } ^ { b e r t , n } ) + b _ { 1 } ,\n$$",
536
+ "text_format": "latex",
537
+ "bbox": [
538
+ 385,
539
+ 866,
540
+ 611,
541
+ 887
542
+ ],
543
+ "page_idx": 3
544
+ },
545
+ {
546
+ "type": "text",
547
+ "text": "where $l _ { i j }$ is a scalar relation label for token $i$ and $j$ , $W _ { 1 }$ and $b _ { 1 }$ are the weights and bias of the linear transformation layer. hbert,ni r epresents the embedding of token $i$ from the $n ^ { t h }$ layer of the BERT ",
548
+ "bbox": [
549
+ 176,
550
+ 892,
551
+ 823,
552
+ 924
553
+ ],
554
+ "page_idx": 3
555
+ },
556
+ {
557
+ "type": "table",
558
+ "img_path": "images/9e41327be778415a792e091e0a083318697f47e95cf18fbb7f6ab87023a597d6.jpg",
559
+ "table_caption": [],
560
+ "table_footnote": [],
561
+ "table_body": "<table><tr><td rowspan=\"2\">Data Set</td><td colspan=\"3\">Positive</td><td colspan=\"3\">Neutral</td><td colspan=\"3\">Negative</td></tr><tr><td>Train</td><td>Dev</td><td>Test</td><td>Train</td><td>Dev</td><td>Test</td><td>Train</td><td>Dev</td><td>Test</td></tr><tr><td>Restaurant</td><td>2164</td><td>-</td><td>728</td><td>637</td><td>-</td><td>196</td><td>807</td><td>-</td><td>196</td></tr><tr><td>Laptop</td><td>994</td><td>、</td><td>341</td><td>464</td><td>-</td><td>169</td><td>870</td><td>-</td><td>128</td></tr><tr><td>Twitter14</td><td>1561</td><td>-</td><td>173</td><td>3127</td><td>-</td><td>346</td><td>1560</td><td>1</td><td>173</td></tr><tr><td>Twitter15</td><td>928</td><td>303</td><td>317</td><td>1883</td><td>670</td><td>607</td><td>368</td><td>149</td><td>113</td></tr><tr><td>Twitter17</td><td>1508</td><td>515</td><td>493</td><td>1638</td><td>517</td><td>573</td><td>416</td><td>144</td><td>168</td></tr><tr><td>Twitter14 (AS)</td><td>1538</td><td>-</td><td>190</td><td>3300</td><td>-</td><td>173</td><td>1445</td><td>-</td><td>288</td></tr></table>",
562
+ "bbox": [
563
+ 271,
564
+ 101,
565
+ 728,
566
+ 199
567
+ ],
568
+ "page_idx": 4
569
+ },
570
+ {
571
+ "type": "text",
572
+ "text": "Table 1: Statistics of the 5 benchmark data sets. TS refers to splitting the data by aspect. ",
573
+ "bbox": [
574
+ 207,
575
+ 209,
576
+ 785,
577
+ 224
578
+ ],
579
+ "page_idx": 4
580
+ },
581
+ {
582
+ "type": "text",
583
+ "text": "model. As different layers of BERT appear to represent different types of information as shown by Tenney et al. (2019), we could recover different information by selecting different BERT layers (different $n$ ). In our experiments, we fixed the value of $n$ to 6 for all data sets. ",
584
+ "bbox": [
585
+ 174,
586
+ 250,
587
+ 825,
588
+ 292
589
+ ],
590
+ "page_idx": 4
591
+ },
592
+ {
593
+ "type": "text",
594
+ "text": "Meta Training Relation Label Generator To guide the training of the embedding, we minimize the mean square error (MSE) of the generated label and the L2 norm of the relation embedding: ",
595
+ "bbox": [
596
+ 173,
597
+ 308,
598
+ 821,
599
+ 337
600
+ ],
601
+ "page_idx": 4
602
+ },
603
+ {
604
+ "type": "equation",
605
+ "img_path": "images/23c9a711321f379e5647a2e843e74c0887f28901b190f72cb9f7c18ddbd50785.jpg",
606
+ "text": "$$\nM S E ( l , r ) = \\sum _ { i . j } ( \\| r _ { i j } \\| _ { 2 } - l _ { i j } ) ^ { 2 } .\n$$",
607
+ "text_format": "latex",
608
+ "bbox": [
609
+ 385,
610
+ 342,
611
+ 612,
612
+ 377
613
+ ],
614
+ "page_idx": 4
615
+ },
616
+ {
617
+ "type": "text",
618
+ "text": "Drawing inspiration from recent work by Liu et al. (2019), we train our label generator using the loss from ABSA with the goal of generating relation labels $l _ { i j }$ to directly optimize for the performance of the main task. ",
619
+ "bbox": [
620
+ 173,
621
+ 382,
622
+ 825,
623
+ 424
624
+ ],
625
+ "page_idx": 4
626
+ },
627
+ {
628
+ "type": "text",
629
+ "text": "Let $\\theta _ { m a i n }$ be the parameters of our main model, RelConsTrans. To update the parameters of $\\theta _ { m a i n }$ , we aim to minimize a multi-task loss – cross-entropy loss, $L$ from the ABSA prediction task and the MSE loss described in Equation 10: ",
630
+ "bbox": [
631
+ 173,
632
+ 431,
633
+ 825,
634
+ 473
635
+ ],
636
+ "page_idx": 4
637
+ },
638
+ {
639
+ "type": "equation",
640
+ "img_path": "images/91ae360fd0fcf02dace1c5dc2c51d4fec37ab893089f02d6fab7b1c9624da94e.jpg",
641
+ "text": "$$\n\\operatorname * { a r g m i n } _ { \\theta _ { m a i n } } ( L ( \\hat { y } , y ) + M S E ( l , r ) ) .\n$$",
642
+ "text_format": "latex",
643
+ "bbox": [
644
+ 390,
645
+ 478,
646
+ 607,
647
+ 506
648
+ ],
649
+ "page_idx": 4
650
+ },
651
+ {
652
+ "type": "text",
653
+ "text": "Let $\\theta _ { m a i n } ^ { + }$ be the weights of the RelConsTrans after one gradient update step of gradient descent: ",
654
+ "bbox": [
655
+ 173,
656
+ 512,
657
+ 805,
658
+ 529
659
+ ],
660
+ "page_idx": 4
661
+ },
662
+ {
663
+ "type": "equation",
664
+ "img_path": "images/a086b546d798964aacdd3f41c498650a946e5afc0a3f9fd9d0e3e65627d0837a.jpg",
665
+ "text": "$$\n\\theta _ { m a i n } ^ { + } = \\theta _ { m a i n } - \\alpha _ { m a i n } \\nabla _ { \\theta _ { m a i n } } \\underset { \\theta _ { m a i n } } { \\arg \\operatorname* { m i n } } ( L ( \\hat { y } , y ) + M S E ( l , r ) ) ,\n$$",
666
+ "text_format": "latex",
667
+ "bbox": [
668
+ 282,
669
+ 535,
670
+ 714,
671
+ 563
672
+ ],
673
+ "page_idx": 4
674
+ },
675
+ {
676
+ "type": "text",
677
+ "text": "where $\\alpha _ { m a i n }$ is the learning rate to train the RelConsTrans. Note that the MSE from the relation embedding would not be used to train the relation label generator. Therefore, the parameters of the relation label generator, $\\theta _ { a u x }$ should be updated by solely the loss from ABSA: ",
678
+ "bbox": [
679
+ 174,
680
+ 568,
681
+ 825,
682
+ 611
683
+ ],
684
+ "page_idx": 4
685
+ },
686
+ {
687
+ "type": "equation",
688
+ "img_path": "images/c3980c20df38167ae021da12e399019ad23ae8178fb67c8c33c2a32fb159794d.jpg",
689
+ "text": "$$\n\\underset { \\theta _ { a u x } } { \\arg \\operatorname* { m i n } } ( L ( \\hat { y } , y ) ) ,\n$$",
690
+ "text_format": "latex",
691
+ "bbox": [
692
+ 437,
693
+ 616,
694
+ 560,
695
+ 643
696
+ ],
697
+ "page_idx": 4
698
+ },
699
+ {
700
+ "type": "text",
701
+ "text": "To update the weights of the generator, a second order derivative is computed. While this formulation was inspired by Liu et al. (2019), the second-order derivative trick used in our model was also used in a number of other meta-learning frameworks such as Finn et al. (2017). ",
702
+ "bbox": [
703
+ 174,
704
+ 647,
705
+ 825,
706
+ 690
707
+ ],
708
+ "page_idx": 4
709
+ },
710
+ {
711
+ "type": "text",
712
+ "text": "We train the two models in tandem, over a few iterations. We found it useful to train $\\theta _ { m a i n }$ and $\\theta _ { a u x }$ with separate training sets. For each data set, we took a subset of the cases which contain two or more aspects (meta-train set) in the same sentence for training $\\theta _ { a u x }$ . This subset is removed from the main training set (train set) used to train the main RelConsTrans. More details of the meta-train set would be provided in the appendix A.1. ",
713
+ "bbox": [
714
+ 174,
715
+ 696,
716
+ 825,
717
+ 767
718
+ ],
719
+ "page_idx": 4
720
+ },
721
+ {
722
+ "type": "text",
723
+ "text": "3 RESULTS AND ANALYSIS ",
724
+ "text_level": 1,
725
+ "bbox": [
726
+ 176,
727
+ 787,
728
+ 413,
729
+ 804
730
+ ],
731
+ "page_idx": 4
732
+ },
733
+ {
734
+ "type": "text",
735
+ "text": "We conducted experiments on 5 benchmark data sets - restaurant reviews, laptop reviews from SemEval 2014 (Pontiki et al., 2014), ACL14 Twitter14 data set (Dong et al., 2014) and Twitter15 and Twitter17 from a multi-modal ABSA data set by (Yu & Jiang, 2019). For analysis, we ran additional experiments on a split of the Twitter14 data set by aspect. We summarize the statistics of the data in Table 1. For data sets with development sets, we perform model selection on the development sets. ",
736
+ "bbox": [
737
+ 174,
738
+ 818,
739
+ 825,
740
+ 888
741
+ ],
742
+ "page_idx": 4
743
+ },
744
+ {
745
+ "type": "text",
746
+ "text": "For Restaurant, Laptop and Twitter14, we compare against published results from BERT-PT $\\mathrm { { \\Delta X u } }$ et al., 2019), BERT-SPC (Song et al., 2019), AEN-BERT (Song et al., 2019), SDGCN-BERT (Zhao et al., 2020), Transformer(B) (Bai et al., 2020), RGAT-Bai (Bai et al., 2020), RGAT-Wang (Wang et al., 2020), DGEDT-BERT (Tang et al., 2020) and LCFS-ASC-CDW (Phan & Ogunbona, 2020). The Transformer(B) is a baseline model used by Bai et al. (2020), and is the baseline vanilla Transformer on which ConsTrans is built upon. For Twitter 15 and Twitter17, we compare against published results in (Yu & Jiang, 2019): MemNet (Tang et al., 2016), RAM (Chen et al., 2017), MGAN (Fan et al., 2018), BERT, BERT $^ +$ BL (Yu & Jiang, 2019) and TomBERT (Yu & Jiang, 2019). ",
747
+ "bbox": [
748
+ 173,
749
+ 895,
750
+ 823,
751
+ 924
752
+ ],
753
+ "page_idx": 4
754
+ },
755
+ {
756
+ "type": "table",
757
+ "img_path": "images/e73b155ca6591a7866998613388216be961ef76085ad3bb41b0e27ca387ef65e.jpg",
758
+ "table_caption": [
759
+ "Table 2: Accuracy and F-score (F1) for 5 data sets: In the left (resp. right) table, systems marked \\* are those that used dependency parses (resp. multi-modal information). The best Macro F1 for each data set is in bold. For significance tests, we compare against RGAT-Wang(re-run), TomBERT and BERT $\\scriptstyle + \\mathrm { B L }$ . Our results are significant against RGAT-Wang(re-run) and BERT $\\scriptstyle \\cdot + \\mathbf { B } \\mathbf { L }$ . Twitter17 was significant against TomBERT (which used image data in addition to text data) but not Twitter15. "
760
+ ],
761
+ "table_footnote": [],
762
+ "table_body": "<table><tr><td>Data Set</td><td colspan=\"2\">Restaurant</td><td colspan=\"2\">Laptop</td><td colspan=\"2\">Twitter14</td></tr><tr><td>Model</td><td>Acc</td><td>F1</td><td>Acc</td><td>F1</td><td>Acc</td><td>F1</td></tr><tr><td>BERT-PT</td><td>85.0</td><td>77.0</td><td>78.1</td><td>75.1</td><td></td><td>-</td></tr><tr><td>BERT-SPC</td><td>84.5</td><td>77.0</td><td>79.0</td><td>75.0</td><td>73.6</td><td>72.1</td></tr><tr><td>AEN-BERT</td><td>83.1</td><td>73.8</td><td>79.9</td><td>76.3</td><td>74.7</td><td>73.1</td></tr><tr><td>SDGCN-BERT</td><td>83.6</td><td>76.5</td><td>81.4</td><td>78.3</td><td>=</td><td>-</td></tr><tr><td>Transformer(B)</td><td>84.9</td><td>77.9</td><td>79.3</td><td>76.1</td><td>-</td><td>-</td></tr><tr><td>RGAT-Bai*</td><td>86.6</td><td>80.5</td><td>81.3</td><td>78.6</td><td>75.8</td><td>74.7</td></tr><tr><td>RGAT-Wang*</td><td>86.6</td><td>81.4</td><td>78.2</td><td>74.1</td><td>76.2</td><td>74.9</td></tr><tr><td>RGAT-Wang (re-run)*</td><td>85.7</td><td>79.1</td><td>79.0</td><td>75.6</td><td>73.6</td><td>73.1</td></tr><tr><td>DGEDT-BERT*</td><td>86.3</td><td>80.0</td><td>79.8</td><td>75.6</td><td>77.9</td><td>75.4</td></tr><tr><td>LCFS-ASC-CDW*</td><td>86.7</td><td>80.3</td><td>80.5</td><td>77.1</td><td>-</td><td>-</td></tr><tr><td>ConsTrans</td><td>85.8</td><td>80.8</td><td>80.6</td><td>77.2</td><td>76.6</td><td>75.0</td></tr><tr><td>RelConsTrans</td><td>85.4</td><td>79.3</td><td>80.1</td><td>76.4</td><td>75.9</td><td>74.7</td></tr><tr><td>RelConsTransLG</td><td>86.7</td><td>81.4</td><td>81.0</td><td>78.1</td><td>76.9</td><td>75.5</td></tr></table>",
763
+ "bbox": [
764
+ 173,
765
+ 101,
766
+ 511,
767
+ 268
768
+ ],
769
+ "page_idx": 5
770
+ },
771
+ {
772
+ "type": "table",
773
+ "img_path": "images/f1b715233e9b40b5d977a62abe44b4ab565871fc89a4e9093e8f86484a580ac5.jpg",
774
+ "table_caption": [],
775
+ "table_footnote": [],
776
+ "table_body": "<table><tr><td>Data Set Model</td><td>Twitter15 Acc</td><td>F1</td><td>Twitter17 Acc</td><td>F1</td></tr><tr><td>AE-LSTM</td><td>70.3</td><td>63.4</td><td>61.7</td><td>58.0</td></tr><tr><td>MemNet</td><td>70.1</td><td>61.8</td><td>64.2</td><td>60.9</td></tr><tr><td>RAM</td><td>70.7</td><td>63.1</td><td>64.4</td><td>61.0</td></tr><tr><td>MGAN</td><td>71.2</td><td>64.2</td><td>64.8</td><td>61.5</td></tr><tr><td>BERT</td><td>74.2</td><td>68.9</td><td>68.2</td><td>65.2</td></tr><tr><td>BERT+BL</td><td>74.3</td><td>70.0</td><td>68.9</td><td>66.1</td></tr><tr><td>TomBERT*</td><td>77.2</td><td>71.8</td><td>70.5</td><td>68.0</td></tr><tr><td>ConsTrans</td><td>76.5</td><td>72.5</td><td>69.3</td><td>68.2</td></tr><tr><td>RelConsTrans</td><td>76.9</td><td>71.6</td><td>69.0</td><td>67.7</td></tr><tr><td>RelConsTransLG</td><td>76.8</td><td>73.3</td><td>69.8</td><td>68.5</td></tr></table>",
777
+ "bbox": [
778
+ 524,
779
+ 116,
780
+ 766,
781
+ 253
782
+ ],
783
+ "page_idx": 5
784
+ },
785
+ {
786
+ "type": "text",
787
+ "text": "",
788
+ "bbox": [
789
+ 174,
790
+ 377,
791
+ 825,
792
+ 462
793
+ ],
794
+ "page_idx": 5
795
+ },
796
+ {
797
+ "type": "text",
798
+ "text": "For the Restaurant and Twitter14 data sets, we outperform all previous work that did not require dependency parsers by competitive margins (4.8 F-score for Restaurant and $2 . 4 \\mathrm { F } \\cdot$ -score for Twitter14). Our results on the Laptop data (78.1) is also close to the state-of-the-art results (78.3) achieved by SDGCN-BERT. Furthermore, comparing results with models that require a dependency parser, we also outperform a number of models while closely matching the results of others. For Twitter15 and Twitter17, we see in Table 2 that our best model outperforms previous work that uses only textual content by a margin (3.3 F-score for Twitter15 and 2.4 F-Score for Twitter17). Our model also outperforms TomBERT, the multi-modal models for Twitter15 and Twitter17. ",
799
+ "bbox": [
800
+ 173,
801
+ 468,
802
+ 825,
803
+ 580
804
+ ],
805
+ "page_idx": 5
806
+ },
807
+ {
808
+ "type": "text",
809
+ "text": "To conduct statistical significance tests, we attempt to reproduce the results published for RGATWang, TomBERT and BERT $\\mathrm { + B L }$ . For RGAT-Wang, we could not reproduce their published results (with their recommended settings), and hence we can only conduct the test against the results we obtain with their open source code, shown as RGAT-Wang(re-run) in Table 2. We run the randomization test (Yeh, 2000) with 100,000 shuffles. We found that RelConsTransLG outperforms RGATWang(re-run) and BERT $\\scriptstyle + \\mathrm { B L }$ significantly $( p < 0 . 1 5 )$ . RelConsTransLG significantly outperforms TomBERT (which has additional access to image data) for Twitter17, but not Twitter15. ",
810
+ "bbox": [
811
+ 174,
812
+ 588,
813
+ 823,
814
+ 685
815
+ ],
816
+ "page_idx": 5
817
+ },
818
+ {
819
+ "type": "text",
820
+ "text": "When comparing our proposed ConsTrans model to a vanilla Transformer, we observe that ConsTrans outperforms the vanilla Transformer model for both the Restaurant and Laptop data sets. This suggests that it is indeed useful to induce constituents for ABSA. Lastly, comparing ConsTrans and RelConsTransLG, we observe that RelConsTransLG consistently outperforms ConsTrans for all the data sets. This suggests that our meta-learnt label generator is able to generate useful auxiliary labels for ConsTrans for the ABSA task. ",
821
+ "bbox": [
822
+ 174,
823
+ 691,
824
+ 825,
825
+ 775
826
+ ],
827
+ "page_idx": 5
828
+ },
829
+ {
830
+ "type": "text",
831
+ "text": "3.1 ANALYSIS ",
832
+ "text_level": 1,
833
+ "bbox": [
834
+ 174,
835
+ 795,
836
+ 285,
837
+ 809
838
+ ],
839
+ "page_idx": 5
840
+ },
841
+ {
842
+ "type": "text",
843
+ "text": "In this section, we provide findings from ablation studies and analysis of our proposed models. ",
844
+ "bbox": [
845
+ 171,
846
+ 821,
847
+ 790,
848
+ 837
849
+ ],
850
+ "page_idx": 5
851
+ },
852
+ {
853
+ "type": "text",
854
+ "text": "Grammar Induction We derive constituent trees with the constituent probabilities to verify if the derived trees resemble ground truth constituent trees. In Figure 4, we show an example where our derived constituent tree shows a similar structure to the ground truth constituency tree. Notably, we are able to accurately recall the aspect term, “jessica alba” as a constituent. The algorithm to derive constituent trees and more examples are provided in Appendix A.4 and A.6 respectively. ",
855
+ "bbox": [
856
+ 174,
857
+ 854,
858
+ 823,
859
+ 924
860
+ ],
861
+ "page_idx": 5
862
+ },
863
+ {
864
+ "type": "image",
865
+ "img_path": "images/5ecf3c166cd5c2d8abe39f6a37ace0de288864f8232c85df256ec6823b6ab954.jpg",
866
+ "image_caption": [
867
+ "Figure 4: Example of derived constituent Tree by ConsTrans (Left) and constituent Tree from Berkeley Neural Parser (Kitaev & Klein, 2018) (Right). "
868
+ ],
869
+ "image_footnote": [],
870
+ "bbox": [
871
+ 202,
872
+ 97,
873
+ 795,
874
+ 213
875
+ ],
876
+ "page_idx": 6
877
+ },
878
+ {
879
+ "type": "text",
880
+ "text": "We postulate that the ability of ConsTrans to group aspect terms into noun phrases should improve its ABSA accuracy. To study our hypothesis, we looked at ConsTrans’s ability to recall the entire aspect term as a noun phrase. For simplicity, we only look at records where aspect terms were not broken down into sub-word tokens. For Twitter17, we found that ConsTrans achieves 67.8 recall rate for correctly predicted instances and 62.2 for incorrect instances. The Pearson correlation coefficient between prediction accuracy and recall rate was significant (with $\\mathfrak { p } < 0 . 2 )$ ), indicating the usefulness of being able to induce good constituents for ABSA. ",
881
+ "bbox": [
882
+ 174,
883
+ 277,
884
+ 825,
885
+ 375
886
+ ],
887
+ "page_idx": 6
888
+ },
889
+ {
890
+ "type": "text",
891
+ "text": "Generalibility of RelConsTransLG The key argument by Liu et al. (2019) for designing an additional label generator is to increase the generalizability of the main model. To test the generalizability of RelConsTransLG, we create a more challenging version of Twitter14 by splitting the data such that the train and test set comprises of different aspect terms. The statistics of the data after splitting by aspect (denoted by AS) is shown in Table 1. We further split the train set by aspect terms to create a meta-train set to train the label generator in RelConsTransLG. Therefore, the relation label generator is trained to generate relation labels that enhance the performance of data with foreign aspect terms. In this AS setting, RelConsTransLG achieves a F-score of 64.3 while ConsTrans achieved a F-score of 62.8. Our designed framework mimics the actual train and test setting and is therefore able to increase the generalizabillity of RelConsTransLG. ",
892
+ "bbox": [
893
+ 174,
894
+ 390,
895
+ 825,
896
+ 530
897
+ ],
898
+ "page_idx": 6
899
+ },
900
+ {
901
+ "type": "text",
902
+ "text": "Different layers of BERT as input Tenney et al. (2019) found that different BERT layers encapsulate different information useful for various NLP tasks. Therefore, we experimented with using all 12 layers of BERT as input to the label generator to study the impact on the F-score. The graph for the F-score against BERT layer $( n )$ is provided in Appendix A.3. Using representation from the $6 ^ { t h }$ layer of BERT yields the best results for the restaurant data set and we are able to consistently outperform models that do not use dependency parses for all value of $n$ chosen. Furthermore, this is an indication that syntactic information is indeed useful for ABSA since lower layers of BERT were found to encapsulate syntactic information. ",
903
+ "bbox": [
904
+ 174,
905
+ 545,
906
+ 825,
907
+ 657
908
+ ],
909
+ "page_idx": 6
910
+ },
911
+ {
912
+ "type": "text",
913
+ "text": "Interpreting learnt relation labels Our relation label generator is designed to encourage the generation of syntax related labels. To verify the hypothesis that generated relation label is related to syntax, we reconstruct the dependency parses using the learnt relation embedding. Interestingly, while Dozat & Manning (2017) have found that the L2 norm of relation embedding resembles syntactic distance (i.e., a lower norm means stronger dependency), we found that our learned relation embedding exhibits an opposite phenomenon: a higher L2 norm indicates a stronger dependency. We hypothesize that relation embedding with higher L2 norm would influence attention weights to a greater extent. Therefore, the L2 norm of our learnt relation embedding would represent syntactic relatedness rather than syntactic distance. We then construct parse trees by linking tokens with highest L2 norm of their relation embedding as detailed in Appendix A.5. ",
914
+ "bbox": [
915
+ 174,
916
+ 672,
917
+ 825,
918
+ 811
919
+ ],
920
+ "page_idx": 6
921
+ },
922
+ {
923
+ "type": "text",
924
+ "text": "Manual inspection of these records suggest that while a full parse tree was not induced, we are able to recover most of adjective-noun relations. As seen in Figure 5, we are able to retrieve the relation of (“pleasant”, “staff”) and (“friendly”, “staff”). This is expected since understanding adjectivenoun relations would be most important to ABSA compared to other types of relations. Therefore, training RelConsTransLG with supervision from solely ABSA would yield this behaviour. ",
925
+ "bbox": [
926
+ 174,
927
+ 819,
928
+ 823,
929
+ 888
930
+ ],
931
+ "page_idx": 6
932
+ },
933
+ {
934
+ "type": "text",
935
+ "text": "Furthermore, to look at the ability of RelConsTransLG to link relevant adjective terms, we engaged two annotators to annotate the adjective terms relevant to each aspect term for the test set for the ",
936
+ "bbox": [
937
+ 176,
938
+ 895,
939
+ 823,
940
+ 924
941
+ ],
942
+ "page_idx": 6
943
+ },
944
+ {
945
+ "type": "image",
946
+ "img_path": "images/7328ff57d88b6e8ff997330a5ea9422df27283b0d3b6d2dd1a058c0a675abd86.jpg",
947
+ "image_caption": [
948
+ "Figure 5: Examples of induced dependency parses Tree by RelConsTransLG (Top arrows) and ground truth dependency parses (bottom arrows) from StanfordNLP https://corenlp.run/. Arrows in grey are for opinion terms accurately linked to the aspect term “staff”. "
949
+ ],
950
+ "image_footnote": [],
951
+ "bbox": [
952
+ 318,
953
+ 102,
954
+ 681,
955
+ 179
956
+ ],
957
+ "page_idx": 7
958
+ },
959
+ {
960
+ "type": "text",
961
+ "text": "Restaurant data. The annotators reconciled their differing opinions and gave each record a final label. Records with no clear opinion terms was given a ”None” label. There were 1,120 records annotated and 811 had annotated adjective terms. We rank the relatedness of tokens with the aspect term by the L2 norm of the relation embedding and compare it with ground truth ranks. Ground truth ranks were obtained by ranking tokens with their syntactic distance obtained from StanfordNLP dependency parser (Chen & Manning, 2014) with tied rank taken into account. For records where the adjective term was more than 1 syntactic distance away, we obtain an equal or smaller rank than the syntactic distance in $6 3 . 5 \\%$ of the cases. Compared against position offset ranks, we obtain an equal or small rank than the number of position offsets in $6 5 . 0 \\%$ of the cases. ",
962
+ "bbox": [
963
+ 173,
964
+ 266,
965
+ 825,
966
+ 392
967
+ ],
968
+ "page_idx": 7
969
+ },
970
+ {
971
+ "type": "text",
972
+ "text": "4 RELATED WORK ",
973
+ "text_level": 1,
974
+ "bbox": [
975
+ 176,
976
+ 416,
977
+ 343,
978
+ 433
979
+ ],
980
+ "page_idx": 7
981
+ },
982
+ {
983
+ "type": "text",
984
+ "text": "Sentiment analysis (Pang & Lee, 2008) is a well studied natural language processing problem. Early works applied sentiment analysis to product reviews as a text classification problem. However, a review or social media post could express different sentiments to different aspects, and the task of aspect-based sentiment analysis aims at a finer classification of sentiment towards specific aspects (Dong et al., 2014) or aspects (Pontiki et al., 2016). ",
985
+ "bbox": [
986
+ 174,
987
+ 452,
988
+ 825,
989
+ 521
990
+ ],
991
+ "page_idx": 7
992
+ },
993
+ {
994
+ "type": "text",
995
+ "text": "Recent work on ABSA has shown that the use of dependency parses for ABSA helps to improve performance (Bai et al., 2020; Huang & Carley, 2019; Sun et al., 2019; Wang et al., 2020). However, supervised dependency parsers require a substantial amount of annotated data, and might perform badly for out-of-domain (e.g., social media) or low-resource languages. On the other hand, it has been shown that contextual embeddings such as BERT (Devlin et al., 2018) contain significant information that could be useful to parsers (Clark et al., 2019; Kim et al., 2020a). Previous work such as Hewitt & Manning (2019) have shown that a linear projection is sufficient to recover syntactic information from BERT embedding. In this paper, we show that we can achieve similar ABSA performance without supervised parsers, by leveraging on BERT which was trained with raw data. ",
996
+ "bbox": [
997
+ 174,
998
+ 529,
999
+ 825,
1000
+ 655
1001
+ ],
1002
+ "page_idx": 7
1003
+ },
1004
+ {
1005
+ "type": "text",
1006
+ "text": "Previous work on unsupervised grammar induction such as Shen et al. (2019); Kim et al. (2019) aims to induce grammar from raw data. Our primary objective is not to induce grammar, but to encourage the model to learn to perform the ABSA task by learning the causal edge dependencies between constituents. We show that our approach is able to achieve results that rivals those obtained by models that have access to supervised dependency parsers. ",
1007
+ "bbox": [
1008
+ 174,
1009
+ 661,
1010
+ 823,
1011
+ 731
1012
+ ],
1013
+ "page_idx": 7
1014
+ },
1015
+ {
1016
+ "type": "text",
1017
+ "text": "In this work, we applied meta auxiliary learning (Liu et al., 2019) which learns to generate auxiliary labels, supervised by the primary task. While Liu et al. (2019) failed to interpret the auxiliary labels for the computer vision tasks they worked on, we showed that in our case, the induced auxiliary labels can be interpreted as syntactic relatedness to a certain extent. ",
1018
+ "bbox": [
1019
+ 176,
1020
+ 738,
1021
+ 823,
1022
+ 792
1023
+ ],
1024
+ "page_idx": 7
1025
+ },
1026
+ {
1027
+ "type": "text",
1028
+ "text": "5 CONCLUSION ",
1029
+ "text_level": 1,
1030
+ "bbox": [
1031
+ 176,
1032
+ 819,
1033
+ 318,
1034
+ 835
1035
+ ],
1036
+ "page_idx": 7
1037
+ },
1038
+ {
1039
+ "type": "text",
1040
+ "text": "In this paper, we apply a meta auxiliary learning approach to the ABSA task, and we show that the induced relations between phrases are interpretable and supports the primary task of sentiment analysis. We show that learning the auxiliary labels improve results over our baselines on all five data sets. Without using dependency parsers, our approach performs competitively compared to previous work that used dependency parses as input. ",
1041
+ "bbox": [
1042
+ 174,
1043
+ 854,
1044
+ 823,
1045
+ 924
1046
+ ],
1047
+ "page_idx": 7
1048
+ },
1049
+ {
1050
+ "type": "text",
1051
+ "text": "REFERENCES ",
1052
+ "text_level": 1,
1053
+ "bbox": [
1054
+ 176,
1055
+ 102,
1056
+ 285,
1057
+ 117
1058
+ ],
1059
+ "page_idx": 8
1060
+ },
1061
+ {
1062
+ "type": "text",
1063
+ "text": "Xuefeng Bai, Pengbo Liu, and Yue Zhang. Exploiting typed syntactic dependencies for targeted sentiment classification using graph attention neural network. CoRR, abs/2002.09685, 2020. URL https://arxiv.org/abs/2002.09685. ",
1064
+ "bbox": [
1065
+ 176,
1066
+ 127,
1067
+ 823,
1068
+ 169
1069
+ ],
1070
+ "page_idx": 8
1071
+ },
1072
+ {
1073
+ "type": "text",
1074
+ "text": "Danqi Chen and Christopher Manning. A fast and accurate dependency parser using neural networks. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 740–750, Doha, Qatar, October 2014. Association for Computational Linguistics. doi: 10.3115/v1/D14-1082. URL https://www.aclweb.org/anthology/ D14-1082. ",
1075
+ "bbox": [
1076
+ 173,
1077
+ 181,
1078
+ 825,
1079
+ 252
1080
+ ],
1081
+ "page_idx": 8
1082
+ },
1083
+ {
1084
+ "type": "text",
1085
+ "text": "Peng Chen, Zhongqian Sun, Lidong Bing, and Wei Yang. Recurrent attention network on memory for aspect sentiment analysis. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pp. 452–461, Copenhagen, Denmark, September 2017. Association for Computational Linguistics. doi: 10.18653/v1/D17-1047. URL https://www. aclweb.org/anthology/D17-1047. ",
1086
+ "bbox": [
1087
+ 173,
1088
+ 263,
1089
+ 825,
1090
+ 334
1091
+ ],
1092
+ "page_idx": 8
1093
+ },
1094
+ {
1095
+ "type": "text",
1096
+ "text": "Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D. Manning. What does BERT look at? an analysis of bert’s attention. CoRR, abs/1906.04341, 2019. URL http://arxiv.org/ abs/1906.04341. ",
1097
+ "bbox": [
1098
+ 173,
1099
+ 347,
1100
+ 825,
1101
+ 388
1102
+ ],
1103
+ "page_idx": 8
1104
+ },
1105
+ {
1106
+ "type": "text",
1107
+ "text": "Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. CoRR, abs/1810.04805, 2018. URL http://arxiv.org/abs/1810.04805. ",
1108
+ "bbox": [
1109
+ 173,
1110
+ 401,
1111
+ 823,
1112
+ 444
1113
+ ],
1114
+ "page_idx": 8
1115
+ },
1116
+ {
1117
+ "type": "text",
1118
+ "text": "Li Dong, Furu Wei, Chuanqi Tan, Duyu Tang, Ming Zhou, and Ke Xu. Adaptive recursive neural network for target-dependent twitter sentiment classification. In Proceedings of the 52nd Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 49–54, Baltimore, Maryland, June 2014. Association for Computational Linguistics. doi: 10.3115/v1/ P14-2009. URL https://www.aclweb.org/anthology/P14-2009. ",
1119
+ "bbox": [
1120
+ 173,
1121
+ 455,
1122
+ 825,
1123
+ 526
1124
+ ],
1125
+ "page_idx": 8
1126
+ },
1127
+ {
1128
+ "type": "text",
1129
+ "text": "Timothy Dozat and Christopher D. Manning. Deep biaffine attention for neural dependency parsing. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL https: //openreview.net/forum?id ${ . } = { }$ Hk95PK9le. ",
1130
+ "bbox": [
1131
+ 174,
1132
+ 537,
1133
+ 823,
1134
+ 594
1135
+ ],
1136
+ "page_idx": 8
1137
+ },
1138
+ {
1139
+ "type": "text",
1140
+ "text": "Feifan Fan, Yansong Feng, and Dongyan Zhao. Multi-grained attention network for aspect-level sentiment classification. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 3433–3442, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1380. URL https://www.aclweb. org/anthology/D18-1380. ",
1141
+ "bbox": [
1142
+ 173,
1143
+ 606,
1144
+ 825,
1145
+ 678
1146
+ ],
1147
+ "page_idx": 8
1148
+ },
1149
+ {
1150
+ "type": "text",
1151
+ "text": "Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. CoRR, abs/1703.03400, 2017. URL http://arxiv.org/abs/1703. 03400. ",
1152
+ "bbox": [
1153
+ 173,
1154
+ 689,
1155
+ 823,
1156
+ 731
1157
+ ],
1158
+ "page_idx": 8
1159
+ },
1160
+ {
1161
+ "type": "text",
1162
+ "text": "John Hewitt and Christopher D. Manning. A structural probe for finding syntax in word representations. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4129–4138, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1419. URL https://www.aclweb.org/anthology/ N19-1419. ",
1163
+ "bbox": [
1164
+ 173,
1165
+ 743,
1166
+ 825,
1167
+ 827
1168
+ ],
1169
+ "page_idx": 8
1170
+ },
1171
+ {
1172
+ "type": "text",
1173
+ "text": "Binxuan Huang and Kathleen Carley. Syntax-aware aspect level sentiment classification with graph attention networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 5469–5477, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/D19-1549. URL https://www.aclweb.org/ anthology/D19-1549. ",
1174
+ "bbox": [
1175
+ 174,
1176
+ 839,
1177
+ 825,
1178
+ 924
1179
+ ],
1180
+ "page_idx": 8
1181
+ },
1182
+ {
1183
+ "type": "text",
1184
+ "text": "Taeuk Kim, Jihun Choi, Daniel Edmiston, and Sang goo Lee. Are pre-trained language models aware of phrases? simple but strong baselines for grammar induction. In International Conference on Learning Representations, 2020a. URL https://openreview.net/forum?id= H1xPR3NtPB. ",
1185
+ "bbox": [
1186
+ 174,
1187
+ 103,
1188
+ 825,
1189
+ 159
1190
+ ],
1191
+ "page_idx": 9
1192
+ },
1193
+ {
1194
+ "type": "text",
1195
+ "text": "Taeuk Kim, Jihun Choi, Daniel Edmiston, and Sang goo Lee. Are pre-trained language models aware of phrases? simple but strong baselines for grammar induction. In International Conference on Learning Representations, 2020b. URL https://openreview.net/forum?id $=$ H1xPR3NtPB. ",
1196
+ "bbox": [
1197
+ 174,
1198
+ 169,
1199
+ 825,
1200
+ 226
1201
+ ],
1202
+ "page_idx": 9
1203
+ },
1204
+ {
1205
+ "type": "text",
1206
+ "text": "Yoon Kim, Alexander Rush, Lei Yu, Adhiguna Kuncoro, Chris Dyer, and Gabor Melis. Unsu- ´ pervised recurrent neural network grammars. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 1105–1117, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1114. URL https://www.aclweb.org/anthology/N19-1114. ",
1207
+ "bbox": [
1208
+ 174,
1209
+ 234,
1210
+ 825,
1211
+ 320
1212
+ ],
1213
+ "page_idx": 9
1214
+ },
1215
+ {
1216
+ "type": "text",
1217
+ "text": "Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In Yoshua Bengio and Yann LeCun (eds.), 3rd International Conference on Learning Representations, ICLR 2015, San Diego, CA, USA, May 7-9, 2015, Conference Track Proceedings, 2015. URL http: //arxiv.org/abs/1412.6980. ",
1218
+ "bbox": [
1219
+ 174,
1220
+ 329,
1221
+ 825,
1222
+ 386
1223
+ ],
1224
+ "page_idx": 9
1225
+ },
1226
+ {
1227
+ "type": "text",
1228
+ "text": "Nikita Kitaev and Dan Klein. Constituency parsing with a self-attentive encoder. CoRR, abs/1805.01052, 2018. URL http://arxiv.org/abs/1805.01052. ",
1229
+ "bbox": [
1230
+ 173,
1231
+ 395,
1232
+ 821,
1233
+ 424
1234
+ ],
1235
+ "page_idx": 9
1236
+ },
1237
+ {
1238
+ "type": "text",
1239
+ "text": "Shikun Liu, Andrew J. Davison, and Edward Johns. Self-supervised generalisation with meta auxiliary learning. CoRR, abs/1901.08933, 2019. URL http://arxiv.org/abs/1901.08933. ",
1240
+ "bbox": [
1241
+ 174,
1242
+ 433,
1243
+ 821,
1244
+ 462
1245
+ ],
1246
+ "page_idx": 9
1247
+ },
1248
+ {
1249
+ "type": "text",
1250
+ "text": "Bo Pang and Lillian Lee. Opinion mining and sentiment analysis. Foundations and Trends in Information Retrieval, 2(1-2):1–135, 2008. ",
1251
+ "bbox": [
1252
+ 173,
1253
+ 472,
1254
+ 823,
1255
+ 501
1256
+ ],
1257
+ "page_idx": 9
1258
+ },
1259
+ {
1260
+ "type": "text",
1261
+ "text": "Minh Hieu Phan and Philip O. Ogunbona. Modelling context and syntactical features for aspectbased sentiment analysis. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 3211–3220, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.293. URL https://www.aclweb.org/ anthology/2020.acl-main.293. ",
1262
+ "bbox": [
1263
+ 173,
1264
+ 510,
1265
+ 825,
1266
+ 580
1267
+ ],
1268
+ "page_idx": 9
1269
+ },
1270
+ {
1271
+ "type": "text",
1272
+ "text": "Maria Pontiki, Dimitris Galanis, John Pavlopoulos, Harris Papageorgiou, Ion Androutsopoulos, and Suresh Manandhar. SemEval-2014 task 4: Aspect based sentiment analysis. In Proceedings of the 8th International Workshop on Semantic Evaluation (SemEval 2014), pp. 27–35, Dublin, Ireland, August 2014. Association for Computational Linguistics. doi: 10.3115/v1/S14-2004. URL https://www.aclweb.org/anthology/S14-2004. ",
1273
+ "bbox": [
1274
+ 173,
1275
+ 589,
1276
+ 825,
1277
+ 661
1278
+ ],
1279
+ "page_idx": 9
1280
+ },
1281
+ {
1282
+ "type": "text",
1283
+ "text": "Maria Pontiki, Dimitrios Galanis, Haris Papageorgiou, Ion Androutsopoulos, Suresh Manandhar, Mohammad Al-Smadi, Mahmoud Al-Ayyoub, Yanyan Zhao, Bing Qin, Orphee De Clercq, et al. ´ Semeval-2016 task 5: Aspect based sentiment analysis. In 10th International Workshop on Semantic Evaluation (SemEval 2016), 2016. ",
1284
+ "bbox": [
1285
+ 173,
1286
+ 670,
1287
+ 825,
1288
+ 727
1289
+ ],
1290
+ "page_idx": 9
1291
+ },
1292
+ {
1293
+ "type": "text",
1294
+ "text": "Yikang Shen, Shawn Tan, Alessandro Sordoni, and Aaron Courville. Ordered neurons: Integrating tree structures into recurrent neural networks. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id $\\underline { { \\underline { { \\mathbf { \\Pi } } } } }$ B1l6qiR5F7. ",
1295
+ "bbox": [
1296
+ 174,
1297
+ 736,
1298
+ 825,
1299
+ 779
1300
+ ],
1301
+ "page_idx": 9
1302
+ },
1303
+ {
1304
+ "type": "text",
1305
+ "text": "Youwei Song, Jiahai Wang, Tao Jiang, Zhiyue Liu, and Yanghui Rao. Attentional encoder network for targeted sentiment classification. CoRR, abs/1902.09314, 2019. URL http://arxiv. org/abs/1902.09314. ",
1306
+ "bbox": [
1307
+ 174,
1308
+ 787,
1309
+ 825,
1310
+ 830
1311
+ ],
1312
+ "page_idx": 9
1313
+ },
1314
+ {
1315
+ "type": "text",
1316
+ "text": "Kai Sun, Richong Zhang, Samuel Mensah, Yongyi Mao, and Xudong Liu. Aspect-level sentiment analysis via convolution over dependency tree. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 5679–5688, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/D19-1569. URL https://www.aclweb.org/anthology/D19-1569. ",
1317
+ "bbox": [
1318
+ 173,
1319
+ 839,
1320
+ 825,
1321
+ 924
1322
+ ],
1323
+ "page_idx": 9
1324
+ },
1325
+ {
1326
+ "type": "text",
1327
+ "text": "Duyu Tang, Bing Qin, and Ting Liu. Aspect level sentiment classification with deep memory network. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 214–224, Austin, Texas, November 2016. Association for Computational Linguistics. doi: 10.18653/v1/D16-1021. URL https://www.aclweb.org/anthology/ D16-1021. ",
1328
+ "bbox": [
1329
+ 174,
1330
+ 103,
1331
+ 825,
1332
+ 172
1333
+ ],
1334
+ "page_idx": 10
1335
+ },
1336
+ {
1337
+ "type": "text",
1338
+ "text": "Hao Tang, Donghong Ji, Chenliang Li, and Qiji Zhou. Dependency graph enhanced dualtransformer structure for aspect-based sentiment classification. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 6578–6588, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.588. URL https://www.aclweb.org/anthology/2020.acl-main.588. ",
1339
+ "bbox": [
1340
+ 173,
1341
+ 183,
1342
+ 825,
1343
+ 253
1344
+ ],
1345
+ "page_idx": 10
1346
+ },
1347
+ {
1348
+ "type": "text",
1349
+ "text": "Ian Tenney, Dipanjan Das, and Ellie Pavlick. BERT rediscovers the classical NLP pipeline. CoRR, abs/1905.05950, 2019. URL http://arxiv.org/abs/1905.05950. ",
1350
+ "bbox": [
1351
+ 173,
1352
+ 262,
1353
+ 821,
1354
+ 291
1355
+ ],
1356
+ "page_idx": 10
1357
+ },
1358
+ {
1359
+ "type": "text",
1360
+ "text": "Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. CoRR, abs/1706.03762, 2017. URL http://arxiv.org/abs/1706.03762. ",
1361
+ "bbox": [
1362
+ 174,
1363
+ 299,
1364
+ 823,
1365
+ 342
1366
+ ],
1367
+ "page_idx": 10
1368
+ },
1369
+ {
1370
+ "type": "text",
1371
+ "text": "Kai Wang, Weizhou Shen, Yunyi Yang, Xiaojun Quan, and Rui Wang. Relational graph attention network for aspect-based sentiment analysis. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, 2020. doi: 10.18653/v1/2020.acl-main.295. URL http://dx.doi.org/10.18653/v1/2020.acl-main.295. ",
1372
+ "bbox": [
1373
+ 173,
1374
+ 351,
1375
+ 825,
1376
+ 407
1377
+ ],
1378
+ "page_idx": 10
1379
+ },
1380
+ {
1381
+ "type": "text",
1382
+ "text": "Hu Xu, Bing Liu, Lei Shu, and Philip Yu. BERT post-training for review reading comprehension and aspect-based sentiment analysis. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 2324–2335, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1242. URL https://www.aclweb.org/anthology/N19-1242. ",
1383
+ "bbox": [
1384
+ 173,
1385
+ 416,
1386
+ 825,
1387
+ 501
1388
+ ],
1389
+ "page_idx": 10
1390
+ },
1391
+ {
1392
+ "type": "text",
1393
+ "text": "Alexander Yeh. More accurate tests for the statistical significance of result differences. In Proceedings of the 18th Conference on Computational Linguistics - Volume 2, COLING ’00, pp. 947–953, USA, 2000. Association for Computational Linguistics. doi: 10.3115/992730.992783. URL https://doi.org/10.3115/992730.992783. ",
1394
+ "bbox": [
1395
+ 174,
1396
+ 510,
1397
+ 825,
1398
+ 565
1399
+ ],
1400
+ "page_idx": 10
1401
+ },
1402
+ {
1403
+ "type": "text",
1404
+ "text": "Jianfei Yu and Jing Jiang. Adapting BERT for target-oriented multimodal sentiment classification. In Sarit Kraus (ed.), Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence, IJCAI 2019, Macao, China, August 10-16, 2019, pp. 5408–5414. ijcai.org, 2019. doi: 10.24963/ijcai.2019/751. URL https://doi.org/10.24963/ijcai.2019/751. ",
1405
+ "bbox": [
1406
+ 173,
1407
+ 575,
1408
+ 825,
1409
+ 632
1410
+ ],
1411
+ "page_idx": 10
1412
+ },
1413
+ {
1414
+ "type": "text",
1415
+ "text": "Pinlong Zhao, Linlin Hou, and Ou Wu. Modeling sentiment dependencies with graph convolutional networks for aspect-level sentiment classification. Knowledge-Based Systems, 193:105443, 2020. ",
1416
+ "bbox": [
1417
+ 173,
1418
+ 641,
1419
+ 823,
1420
+ 670
1421
+ ],
1422
+ "page_idx": 10
1423
+ },
1424
+ {
1425
+ "type": "text",
1426
+ "text": "A APPENDIX ",
1427
+ "text_level": 1,
1428
+ "bbox": [
1429
+ 176,
1430
+ 102,
1431
+ 297,
1432
+ 117
1433
+ ],
1434
+ "page_idx": 11
1435
+ },
1436
+ {
1437
+ "type": "text",
1438
+ "text": "A.1 META-SPLITTING DATA SET ",
1439
+ "text_level": 1,
1440
+ "bbox": [
1441
+ 176,
1442
+ 132,
1443
+ 408,
1444
+ 147
1445
+ ],
1446
+ "page_idx": 11
1447
+ },
1448
+ {
1449
+ "type": "text",
1450
+ "text": "To generate the meta-train set, we first obtain a subset of samples with multiple aspects of differing sentiment from the full train set. $80 \\%$ of this subset would then be used as the meta-train set. For Twitter2014 (AS), we sampled this meta-train set by aspects. The intention is to train the Relation Label Generator to generate labels that can encourage the model to accurately link relevant opinion terms to the aspect term through challenging samples. The statistics of the meta-train set is provided in Table 3. ",
1451
+ "bbox": [
1452
+ 174,
1453
+ 159,
1454
+ 825,
1455
+ 242
1456
+ ],
1457
+ "page_idx": 11
1458
+ },
1459
+ {
1460
+ "type": "table",
1461
+ "img_path": "images/eb1aafd104d185c6d8768eb1ec4cb8d32ffbd8b6153c7fe3c8b421a60d190a61.jpg",
1462
+ "table_caption": [],
1463
+ "table_footnote": [],
1464
+ "table_body": "<table><tr><td>Data set</td><td>Positive</td><td>Neutral</td><td>Negative</td><td>Total</td></tr><tr><td>Restaurant</td><td>195</td><td>163</td><td>162</td><td>520</td></tr><tr><td>Laptop</td><td>85</td><td>98</td><td>61</td><td>244</td></tr><tr><td>Twitter2014</td><td>265</td><td>567</td><td>301</td><td>1133</td></tr><tr><td>Twitter2015</td><td>123</td><td>161</td><td>56</td><td>340</td></tr><tr><td>Twitter2017</td><td>320</td><td>470</td><td>111</td><td>901</td></tr><tr><td>Twitter2014 (AS)</td><td>207</td><td>253</td><td>254</td><td>714</td></tr></table>",
1465
+ "bbox": [
1466
+ 302,
1467
+ 252,
1468
+ 694,
1469
+ 356
1470
+ ],
1471
+ "page_idx": 11
1472
+ },
1473
+ {
1474
+ "type": "text",
1475
+ "text": "Table 3: Statistics of the meta-train sets. AS refers to splitting the data by aspect. ",
1476
+ "bbox": [
1477
+ 233,
1478
+ 366,
1479
+ 763,
1480
+ 382
1481
+ ],
1482
+ "page_idx": 11
1483
+ },
1484
+ {
1485
+ "type": "text",
1486
+ "text": "A.2 IMPLEMENTATION DETAILS ",
1487
+ "text_level": 1,
1488
+ "bbox": [
1489
+ 176,
1490
+ 405,
1491
+ 410,
1492
+ 420
1493
+ ],
1494
+ "page_idx": 11
1495
+ },
1496
+ {
1497
+ "type": "text",
1498
+ "text": "In all experiments, we used the ADAM optimizer (Kingma & Ba, 2015) with a learning rate of $1 0 ^ { - 5 }$ to optimize the models (ConsTrans, RelConsTrans, RelConsTransLG and the relation label generator). The BERT model was fine-tuned together with the main model built on top of it. We used 6 multi-head attention heads and the size of the hidden layer was set to be 384. We stacked 4 encoder layers. Lower layers are defined to be the first 2 layers in the encoder stack while the last 2 layers are higher layers. Dropout was applied to all input embeddings. The L2 penalisation term for the model’s parameters was set to be 1e-5. The size of the learnt embedding for each relation label was set to be 786 and a batch size of 4 was used to train all the models. ",
1499
+ "bbox": [
1500
+ 173,
1501
+ 430,
1502
+ 825,
1503
+ 542
1504
+ ],
1505
+ "page_idx": 11
1506
+ },
1507
+ {
1508
+ "type": "text",
1509
+ "text": "A.3 DIFFERENT LAYERS OF BERT ",
1510
+ "text_level": 1,
1511
+ "bbox": [
1512
+ 176,
1513
+ 559,
1514
+ 428,
1515
+ 573
1516
+ ],
1517
+ "page_idx": 11
1518
+ },
1519
+ {
1520
+ "type": "text",
1521
+ "text": "The graph for Macro F-score against BERT layer $( n )$ is shown in Figure 6. Using representation from the $6 ^ { t h }$ layer of BERT yields the best results for the restaurant data set and we used the $6 ^ { t h }$ layer of BERT as input to the relation label generator for all the other data sets. ",
1522
+ "bbox": [
1523
+ 174,
1524
+ 584,
1525
+ 825,
1526
+ 627
1527
+ ],
1528
+ "page_idx": 11
1529
+ },
1530
+ {
1531
+ "type": "image",
1532
+ "img_path": "images/e1bd1ff89f8e6d3a3a9a7c30856f2dd66b56b661e81c6af25fe48d8257cf8886.jpg",
1533
+ "image_caption": [
1534
+ "Figure 6: Macro F-score on Restaurant data set with different BERT layer as input to LG. "
1535
+ ],
1536
+ "image_footnote": [],
1537
+ "bbox": [
1538
+ 356,
1539
+ 655,
1540
+ 620,
1541
+ 790
1542
+ ],
1543
+ "page_idx": 11
1544
+ },
1545
+ {
1546
+ "type": "text",
1547
+ "text": "A.4 ALGORITHM TO DERIVE CONSTITUENT TREES ",
1548
+ "text_level": 1,
1549
+ "bbox": [
1550
+ 178,
1551
+ 842,
1552
+ 534,
1553
+ 856
1554
+ ],
1555
+ "page_idx": 11
1556
+ },
1557
+ {
1558
+ "type": "text",
1559
+ "text": "To derive constituent trees, we iteratively split the input constituents into 2 parts till each constituent is only made up of only 1 token. The breaking point is defined to be the point where the probability of being in the same constituent for token $i$ and $i + 1$ is the lowest. We use the constituent probability from the second layer of our encoder stack to find the breaking point. ",
1560
+ "bbox": [
1561
+ 174,
1562
+ 867,
1563
+ 825,
1564
+ 924
1565
+ ],
1566
+ "page_idx": 11
1567
+ },
1568
+ {
1569
+ "type": "text",
1570
+ "text": "Algorithm 1 Unsupervised constituent tree derivation ",
1571
+ "text_level": 1,
1572
+ "bbox": [
1573
+ 178,
1574
+ 103,
1575
+ 524,
1576
+ 117
1577
+ ],
1578
+ "page_idx": 12
1579
+ },
1580
+ {
1581
+ "type": "text",
1582
+ "text": "1: $m \\gets$ Constituent layer chosen \n2: $x \\gets$ Input tokens \n3: $p $ Constituent probability from layer m for current constituent \n4: $s t a c k = [ x ]$ \n5: constituents = [] \n6: \n7: procedure GETCONSTTREE $( x , p )$ \n8: while len(stack) $! = 0$ do \n9: current const ← stack[0] \n10: $p _ { 0 } $ constituent probabilities for current const \n11: $\\mathbf { b } = \\mathbf { a r g m i n } ( b _ { 0 } )$ . Find the breaking poin \n12: l $f t _ { - } c o n s t = \\mathbf { x } [ : \\mathbf { b } ]$ \n13: right const = x[b:] \n14: if len(left const) $> 1$ then \n15: add lef t const to constituents \n16: end if \n17: if len(right const) $> 1$ then \n18: add right const to constituents \n19: end if \n20: add lef t const and right const to constituents \n21: end while \n22: Return constituents \n23: end procedure ",
1583
+ "bbox": [
1584
+ 174,
1585
+ 122,
1586
+ 818,
1587
+ 445
1588
+ ],
1589
+ "page_idx": 12
1590
+ },
1591
+ {
1592
+ "type": "text",
1593
+ "text": "A.5 ALGORITHM TO INDUCE DEPENDENCY PARSES ",
1594
+ "text_level": 1,
1595
+ "bbox": [
1596
+ 174,
1597
+ 497,
1598
+ 542,
1599
+ 511
1600
+ ],
1601
+ "page_idx": 12
1602
+ },
1603
+ {
1604
+ "type": "text",
1605
+ "text": "To recover parse trees, we iteratively linked tokens to another token with the highest L2 norm for the learnt relation embedding. We do not allow tokens to be linked multiple times. ",
1606
+ "bbox": [
1607
+ 173,
1608
+ 534,
1609
+ 823,
1610
+ 561
1611
+ ],
1612
+ "page_idx": 12
1613
+ },
1614
+ {
1615
+ "type": "text",
1616
+ "text": "Algorithm 2 Unsupervised dependency parse tree induction ",
1617
+ "text_level": 1,
1618
+ "bbox": [
1619
+ 173,
1620
+ 603,
1621
+ 568,
1622
+ 619
1623
+ ],
1624
+ "page_idx": 12
1625
+ },
1626
+ {
1627
+ "type": "text",
1628
+ "text": "1: procedure GETDEPNTREE $( x , p )$ \n2: depen labels $= [ ]$ \n3: relation norm The L2 norm of learnt embedding \n4: for $j 1$ to lengthx do \n5: current max $=$ max(relation norm) \n6: $i$ , $j =$ position(current max); \n7: add $( i , j )$ to depen labels \n8: relation norm[:, $\\mathrm { j } ] = - \\infty$ ; \n9: relation norm[j, $\\mathrm { i } ] = - \\infty$ ; \n10: end for \n11: Return depen labels \n12: end procedure ",
1629
+ "bbox": [
1630
+ 178,
1631
+ 622,
1632
+ 580,
1633
+ 792
1634
+ ],
1635
+ "page_idx": 12
1636
+ },
1637
+ {
1638
+ "type": "text",
1639
+ "text": "A.6 EXAMPLES OF DERIVED CONSTITUENT TREES ",
1640
+ "text_level": 1,
1641
+ "bbox": [
1642
+ 174,
1643
+ 845,
1644
+ 537,
1645
+ 858
1646
+ ],
1647
+ "page_idx": 12
1648
+ },
1649
+ {
1650
+ "type": "text",
1651
+ "text": "We provide more examples of constituent trees derived from ConsTrans. In general, while we were not able to fully replicate ground truth constituent trees, we noticed that the model was able to recall noun phrases reasonably. ",
1652
+ "bbox": [
1653
+ 176,
1654
+ 882,
1655
+ 825,
1656
+ 924
1657
+ ],
1658
+ "page_idx": 12
1659
+ },
1660
+ {
1661
+ "type": "image",
1662
+ "img_path": "images/f508c6d8bad2ac83439dbadb799c15148146bd3f14900d021262fd26a1789537.jpg",
1663
+ "image_caption": [
1664
+ "Figure 7: Example of derived constituent Tree by ConsTrans with aspect term “ $@$ Jullia webber”. "
1665
+ ],
1666
+ "image_footnote": [],
1667
+ "bbox": [
1668
+ 173,
1669
+ 97,
1670
+ 826,
1671
+ 270
1672
+ ],
1673
+ "page_idx": 13
1674
+ },
1675
+ {
1676
+ "type": "image",
1677
+ "img_path": "images/d91a9f8c4c6023759ee09237d8542a38ea91a1b791b9efe30394a60d351a3715.jpg",
1678
+ "image_caption": [
1679
+ "Figure 8: Example of derived constituent Tree by ConsTrans with aspect term “ $@$ golden state warriors”. "
1680
+ ],
1681
+ "image_footnote": [],
1682
+ "bbox": [
1683
+ 173,
1684
+ 329,
1685
+ 826,
1686
+ 531
1687
+ ],
1688
+ "page_idx": 13
1689
+ },
1690
+ {
1691
+ "type": "image",
1692
+ "img_path": "images/d8eb1eac665e47afaef1db091c5d25c7e7873f21ea0a84675602b49194d5fc97.jpg",
1693
+ "image_caption": [
1694
+ "Figure 9: Example of derived constituent Tree by ConsTrans with aspect term “sadiq Kahn’s”. "
1695
+ ],
1696
+ "image_footnote": [],
1697
+ "bbox": [
1698
+ 236,
1699
+ 603,
1700
+ 758,
1701
+ 801
1702
+ ],
1703
+ "page_idx": 13
1704
+ },
1705
+ {
1706
+ "type": "text",
1707
+ "text": "A.7 EXAMPLES OF INDUCED DEPENDENCY PARSE TREES ",
1708
+ "text_level": 1,
1709
+ "bbox": [
1710
+ 176,
1711
+ 854,
1712
+ 578,
1713
+ 868
1714
+ ],
1715
+ "page_idx": 13
1716
+ },
1717
+ {
1718
+ "type": "text",
1719
+ "text": "We provide more examples of induced dependency parses from RelConsTransLG. While our induced parse trees were not identical to ground truth parse trees, we were able to link adjective terms to noun phrases reasonably. ",
1720
+ "bbox": [
1721
+ 174,
1722
+ 881,
1723
+ 825,
1724
+ 924
1725
+ ],
1726
+ "page_idx": 13
1727
+ },
1728
+ {
1729
+ "type": "image",
1730
+ "img_path": "images/db1b0ccd5378fbb9f9e95ce4cdc5366f77e9740c16143acd41489a68060d9ff4.jpg",
1731
+ "image_caption": [
1732
+ "Figure 10: Examples of induced dependency parses Tree by RelConsTransLG (Top arrows) and ground truth dependency parses (bottom arrows) from StanfordNLP https://corenlp.run/. Arrows in grey are for opinion terms accurately linked to the aspect term “place”. "
1733
+ ],
1734
+ "image_footnote": [],
1735
+ "bbox": [
1736
+ 236,
1737
+ 103,
1738
+ 761,
1739
+ 196
1740
+ ],
1741
+ "page_idx": 14
1742
+ },
1743
+ {
1744
+ "type": "image",
1745
+ "img_path": "images/861a1d5ef8075da5b3ed4ce5f0670fdcb6492a01191918fda410beb344598307.jpg",
1746
+ "image_caption": [
1747
+ "Figure 11: Examples of induced dependency parses Tree by RelConsTransLG (Top arrows) and ground truth dependency parses (bottom arrows) from StanfordNLP https://corenlp.run/. Arrows in grey are for opinion terms accurately linked to the aspect term “owner”. "
1748
+ ],
1749
+ "image_footnote": [],
1750
+ "bbox": [
1751
+ 235,
1752
+ 284,
1753
+ 761,
1754
+ 380
1755
+ ],
1756
+ "page_idx": 14
1757
+ },
1758
+ {
1759
+ "type": "image",
1760
+ "img_path": "images/c4df5d9fcec537e1b26f6645ea0d5f6fc2dfbf8b30828d26cbcfb3fa4cc570ba.jpg",
1761
+ "image_caption": [
1762
+ "Figure 12: Examples of induced dependency parses Tree by RelConsTransLG (Top arrows) and ground truth dependency parses (bottom arrows) from StanfordNLP https://corenlp.run/. Arrows in grey are for opinion terms accurately linked to the aspect term “calamari”. "
1763
+ ],
1764
+ "image_footnote": [],
1765
+ "bbox": [
1766
+ 235,
1767
+ 467,
1768
+ 763,
1769
+ 575
1770
+ ],
1771
+ "page_idx": 14
1772
+ }
1773
+ ]
parse/train/5PiSFHhRe2C/5PiSFHhRe2C_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/5PiSFHhRe2C/5PiSFHhRe2C_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/BJluy2RcFm/images/18e886262616e1c9bfe7a189c9b3c4fd3028bf38e1388c318a98a91eb7062f50.jpg ADDED

Git LFS Details

  • SHA256: d18ef8a479d6ed6ac8b17e9cad658a130f0ab2e7be68c31d9fbb78b15055ccdc
  • Pointer size: 130 Bytes
  • Size of remote file: 35.6 kB
parse/train/BJluy2RcFm/images/267e4b7e3e24eb55a1ad7e95cfa7e9fa41e88f6fed8ec08fea9c0558e32d53bb.jpg ADDED

Git LFS Details

  • SHA256: 14a7a5fbd3f4b7e9e9315afe7455dc7c6cf6de3e98f2942f6fd8bad9bf5de712
  • Pointer size: 130 Bytes
  • Size of remote file: 94.9 kB
parse/train/BJluy2RcFm/images/27bc2ee190da7355754c6b891b168efb2d5ffb85660bc67300dc3b528129f51a.jpg ADDED

Git LFS Details

  • SHA256: 7320baefdfd832d5ddd0d49d9ee12c63686c738bf5640c323c7feaf16dba5d52
  • Pointer size: 130 Bytes
  • Size of remote file: 53 kB
parse/train/BJluy2RcFm/images/325cac69de58fcb72ac585f5fb3c86afb03b85a0edbf512ea0a6237da7855622.jpg ADDED

Git LFS Details

  • SHA256: f887f88c37c5a3738d5a2b467d73c0a087ebe0153f7c3098686cc074c33745c3
  • Pointer size: 130 Bytes
  • Size of remote file: 22.1 kB
parse/train/BJluy2RcFm/images/3aba158ed181e6bf50ff4a7a4e66eaaeb7136e9469834bd4af80c542107478ff.jpg ADDED

Git LFS Details

  • SHA256: 677fe0d29bd806ed882a9d2b22de2ca29bf3fa06eebcd6c9b9dcb3426bc503e1
  • Pointer size: 130 Bytes
  • Size of remote file: 29.1 kB
parse/train/BJluy2RcFm/images/463815139293208ff16127a835dcd0fb1f31a4b135c7edcb0b31e77089185545.jpg ADDED

Git LFS Details

  • SHA256: 113012b7bb33f7f4284410694c0c2eb68353e638ac7202461a0a5d9d59b908c8
  • Pointer size: 130 Bytes
  • Size of remote file: 55.2 kB
parse/train/BJluy2RcFm/images/47934a0e4f6e43911f4a0677fed4519eda6f8cd8a757aefbb7e17c17ec45b283.jpg ADDED

Git LFS Details

  • SHA256: 2176a8cfc8b5e9d8a9b3d9b80de809c8c3531cc68001f1cf285466677ae0048d
  • Pointer size: 130 Bytes
  • Size of remote file: 10.5 kB
parse/train/BJluy2RcFm/images/4d727296ce1ece41abfd3ea0427f7d127132e3aabf80b1d4eb72764474c92548.jpg ADDED

Git LFS Details

  • SHA256: 8cbcde2a2dab9b4bf5340caee254f5f4f130b16bc3ed91f5418488a82ab85b85
  • Pointer size: 130 Bytes
  • Size of remote file: 15.5 kB
parse/train/BJluy2RcFm/images/603b9665e7b89ab08fc651eb6fc70bd7ffe511ee4d6493f26ecaab820d8a9555.jpg ADDED

Git LFS Details

  • SHA256: e7ac350cb5df16983b7780059c69de47c700522a9431a7026138acb1310bcbed
  • Pointer size: 129 Bytes
  • Size of remote file: 4.94 kB
parse/train/BJluy2RcFm/images/94088a8b8158576965f944ea6c7827e2f21628d83144ab6b425e91dc43d351ff.jpg ADDED

Git LFS Details

  • SHA256: bb603c927de8ebbbd09ad383f42b2966f2e8a25a5ee0ed1f7fa619a9f3cc7770
  • Pointer size: 131 Bytes
  • Size of remote file: 128 kB
parse/train/BJluy2RcFm/images/952f5b0e473c8e8632225e1ec8632d7bbceebfc7b98b46062f4be71e498b8f3c.jpg ADDED

Git LFS Details

  • SHA256: af7154d902fe9390b5639c25440f75a931558996843583455f223f4e62bbdc33
  • Pointer size: 129 Bytes
  • Size of remote file: 7.71 kB
parse/train/BJluy2RcFm/images/9570c0aa71cdbf11645849cf86a52c8281c5776992c8c1abccb47999bc9da043.jpg ADDED

Git LFS Details

  • SHA256: ccedb0cb4fe8397e8c2b1197147a7cf6d0c6c90b370d78588ed34a85813feaf5
  • Pointer size: 130 Bytes
  • Size of remote file: 11.6 kB
parse/train/BJluy2RcFm/images/968b9434d4804c19ada3ba21e462db1ba0d57e98fe4117b3117e6fe566acd210.jpg ADDED

Git LFS Details

  • SHA256: 78e6fbe71f3795400034c14d89102da8c7541d7926054dfd5f1dd634c0c60b1a
  • Pointer size: 130 Bytes
  • Size of remote file: 54.6 kB
parse/train/BJluy2RcFm/images/b0c5d49f87161525f0cc5fae19fa3142f6f9d6fdc7d6e76ffc8416894be06202.jpg ADDED

Git LFS Details

  • SHA256: 67d779798b90e313c54f151ce8e719b9dd4e242a1932af6148837877cf60654f
  • Pointer size: 129 Bytes
  • Size of remote file: 8.59 kB
parse/train/BJluy2RcFm/images/c5295bdc6083be5e0f004d6d242ffc48b694c46a77260d75497fc3ebb22cc89b.jpg ADDED

Git LFS Details

  • SHA256: 337b28690b548f5b85edbdbe4c9a3acfbdb855d1ee12ecdf2ca9f44bd6eb7339
  • Pointer size: 129 Bytes
  • Size of remote file: 9.48 kB
parse/train/BJluy2RcFm/images/d9d44cfc3b890d1aaf2e7e09c5e4c3908acfa08e29bf3268558fa8979c0a4181.jpg ADDED

Git LFS Details

  • SHA256: 57ed5e6da7991fac5548399144639c67bbbc456a36d24f13ce517c5ca1358dec
  • Pointer size: 130 Bytes
  • Size of remote file: 22.9 kB
parse/train/BJluy2RcFm/images/ec54e86548a327fe40e98021bb14187bda06ff605cbc114f31bdb17767bbb5e4.jpg ADDED

Git LFS Details

  • SHA256: 0aaf0d13df8a04fad82ff53758e1f19c25c2ecf7b71df320e66acda461b651f0
  • Pointer size: 129 Bytes
  • Size of remote file: 2.35 kB
parse/train/BJluy2RcFm/images/f53a1582c0886f5fc0f990259f15f206da91284a893af278993a54b567df1fc8.jpg ADDED

Git LFS Details

  • SHA256: df4c8c8a3da92a5f991ac6013285820a78834f3ad12426d7b6376ceca5976070
  • Pointer size: 130 Bytes
  • Size of remote file: 10.4 kB
parse/train/BJluy2RcFm/images/fd50908ad3d0c35dd0dbf651e96fc584bb8ee5e666cba364a73b1eb833c19851.jpg ADDED

Git LFS Details

  • SHA256: 58250737d67d8c53e1d916744d50739a5262f3ab47fce0312969cf2a45a9d52c
  • Pointer size: 131 Bytes
  • Size of remote file: 129 kB
parse/train/BkgYPREtPr/images/2db61d4c7cd446225dce7fad6b657e5a8d27ccb6264178107d8c0dd003bb4cf1.jpg ADDED

Git LFS Details

  • SHA256: eaba4079d192d16e935938030e3980215ef66c9c6f9f79f20c115c666d91eb27
  • Pointer size: 129 Bytes
  • Size of remote file: 4.84 kB
parse/train/BkgYPREtPr/images/30befd7f3e22c1057a74b4852ef1e47cad7607a2e215fa16b4a2ed2f0248acd7.jpg ADDED

Git LFS Details

  • SHA256: 7a3daa93b1c77fb3e754b4ecb6562389898b5874f654c6a9579d874369917957
  • Pointer size: 130 Bytes
  • Size of remote file: 53.4 kB
parse/train/BkgYPREtPr/images/6ec24284f2451ad19209823b16df140fe83f04db57f66c66e7e98db402039766.jpg ADDED

Git LFS Details

  • SHA256: 9251e5d061778154905c2c259626efa589588c4eda3deafc9b896ef3cf64892f
  • Pointer size: 130 Bytes
  • Size of remote file: 57.2 kB
parse/train/BkgYPREtPr/images/7b7bb98223bf60995a9561b0de16df794c5e546d0f725610f8929d8788c2820f.jpg ADDED

Git LFS Details

  • SHA256: c4b0294a022d84b8d19c4e73c3c69b86604d22177287eeb46cc46935258277fc
  • Pointer size: 130 Bytes
  • Size of remote file: 60.7 kB
parse/train/BkgYPREtPr/images/8699677295953d1b33056a30bb781e87e8c5814e60712547ba6548c7cd1a6c22.jpg ADDED

Git LFS Details

  • SHA256: 6480ee545a5660bfc51394d8713fef776cfde7b3ef29585e1e6d1677b8c4223d
  • Pointer size: 131 Bytes
  • Size of remote file: 143 kB
parse/train/BkgYPREtPr/images/8d17a8628a2a6f06c646c610501e284776252ee3ad7cd82d34e7c2cae9a59e6b.jpg ADDED

Git LFS Details

  • SHA256: 211d3af55cf0802a42b93a7d138c76252aae59a94426e99997d2e1cc0aeed53b
  • Pointer size: 130 Bytes
  • Size of remote file: 21.1 kB
parse/train/BkgYPREtPr/images/9b538b538f589912be7bd4e31d61df851eaba2304128f8d044ea9a3e9b6b14d1.jpg ADDED

Git LFS Details

  • SHA256: d0f27d346f30b384b4cb72dac74909e28adc62c76d3311cea53bd737bcff2259
  • Pointer size: 130 Bytes
  • Size of remote file: 41.2 kB
parse/train/BkgYPREtPr/images/a4d5a8735c9908ce554111cd99e4d42141eb26b34d6b6888ec707c6db08c2010.jpg ADDED

Git LFS Details

  • SHA256: f3e6bbd8ad6ed3a45b61ed49d404615723900e8973f4a12967a817cc564abfe0
  • Pointer size: 129 Bytes
  • Size of remote file: 4.71 kB
parse/train/BkgYPREtPr/images/bbaeba665ea1002237902872be91be4781ac031084d7c72a423e4eeb25d119d4.jpg ADDED

Git LFS Details

  • SHA256: 59c843d20dc832c7d7de05b4d68904b2fff1c0524639f057fc7684be312d2148
  • Pointer size: 129 Bytes
  • Size of remote file: 5.66 kB
parse/train/BkgYPREtPr/images/cb56bf396bf47fe754d999814b417f0522e368d1714a8ac510a59784118e024e.jpg ADDED

Git LFS Details

  • SHA256: 07bb3da58d167f25bd30440d7d47f58c1cafb75b105f6e104a6ab1e05b9ae904
  • Pointer size: 130 Bytes
  • Size of remote file: 82.7 kB
parse/train/BkgYPREtPr/images/f62e89bb33fe289a5f0df489810eb6209ccf44ce6fa9a5ef14f8343c4eac118a.jpg ADDED

Git LFS Details

  • SHA256: 58d3ec7b56373f2a75b90accf70b4ff4f68fdf8e20571a018d8e281d89e3d507
  • Pointer size: 130 Bytes
  • Size of remote file: 35.5 kB
parse/train/BylRkAEKDH/images/070a15449a27181a3c1e893558aed730219294866599521e3cd5885f84ab1b62.jpg ADDED

Git LFS Details

  • SHA256: df51b90248232478dcc81c9745eb04c19c2ce4ea1f2bf850e70658a561971853
  • Pointer size: 129 Bytes
  • Size of remote file: 3.58 kB