ZHANGYUXUAN-zR commited on
Commit
2a751b6
·
verified ·
1 Parent(s): 22e2b4c

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. parse/train/H1WgVz-AZ/H1WgVz-AZ.md +434 -0
  2. parse/train/H1WgVz-AZ/H1WgVz-AZ_content_list.json +0 -0
  3. parse/train/H1WgVz-AZ/H1WgVz-AZ_middle.json +0 -0
  4. parse/train/H1WgVz-AZ/H1WgVz-AZ_model.json +0 -0
  5. parse/train/HkxJpnVtPr/HkxJpnVtPr.md +0 -0
  6. parse/train/HkxJpnVtPr/HkxJpnVtPr_content_list.json +0 -0
  7. parse/train/HkxJpnVtPr/HkxJpnVtPr_middle.json +0 -0
  8. parse/train/HkxJpnVtPr/HkxJpnVtPr_model.json +0 -0
  9. parse/train/JXAyJeYqUkZ/JXAyJeYqUkZ.md +248 -0
  10. parse/train/JXAyJeYqUkZ/JXAyJeYqUkZ_content_list.json +1045 -0
  11. parse/train/JXAyJeYqUkZ/JXAyJeYqUkZ_middle.json +0 -0
  12. parse/train/JXAyJeYqUkZ/JXAyJeYqUkZ_model.json +0 -0
  13. parse/train/LyjH88yV7F/LyjH88yV7F.md +215 -0
  14. parse/train/LyjH88yV7F/LyjH88yV7F_content_list.json +1040 -0
  15. parse/train/LyjH88yV7F/LyjH88yV7F_middle.json +0 -0
  16. parse/train/LyjH88yV7F/LyjH88yV7F_model.json +0 -0
  17. parse/train/S1gUsoR9YX/S1gUsoR9YX_middle.json +0 -0
  18. parse/train/S1gUsoR9YX/S1gUsoR9YX_model.json +0 -0
  19. parse/train/l2UWXn5iBQI/l2UWXn5iBQI_middle.json +0 -0
  20. parse/train/l2UWXn5iBQI/l2UWXn5iBQI_model.json +0 -0
  21. vlm/test/2dnO3LLiJ1/0.png +3 -0
  22. vlm/test/2dnO3LLiJ1/1.png +3 -0
  23. vlm/test/2dnO3LLiJ1/10.png +3 -0
  24. vlm/test/2dnO3LLiJ1/11.png +3 -0
  25. vlm/test/2dnO3LLiJ1/12.png +3 -0
  26. vlm/test/2dnO3LLiJ1/13.png +3 -0
  27. vlm/test/2dnO3LLiJ1/14.png +3 -0
  28. vlm/test/2dnO3LLiJ1/15.png +3 -0
  29. vlm/test/2dnO3LLiJ1/16.png +3 -0
  30. vlm/test/2dnO3LLiJ1/17.png +3 -0
  31. vlm/test/2dnO3LLiJ1/18.png +3 -0
  32. vlm/test/2dnO3LLiJ1/19.png +3 -0
  33. vlm/test/2dnO3LLiJ1/2.png +3 -0
  34. vlm/test/2dnO3LLiJ1/20.png +3 -0
  35. vlm/test/2dnO3LLiJ1/3.png +3 -0
  36. vlm/test/2dnO3LLiJ1/4.png +3 -0
  37. vlm/test/2dnO3LLiJ1/5.png +3 -0
  38. vlm/test/2dnO3LLiJ1/6.png +3 -0
  39. vlm/test/2dnO3LLiJ1/7.png +3 -0
  40. vlm/test/2dnO3LLiJ1/8.png +3 -0
  41. vlm/test/2dnO3LLiJ1/9.png +3 -0
  42. vlm/test/6M5G5hNiAU/0.png +3 -0
  43. vlm/test/6M5G5hNiAU/1.png +3 -0
  44. vlm/test/6M5G5hNiAU/10.png +3 -0
  45. vlm/test/6M5G5hNiAU/11.png +3 -0
  46. vlm/test/6M5G5hNiAU/12.png +3 -0
  47. vlm/test/6M5G5hNiAU/13.png +3 -0
  48. vlm/test/6M5G5hNiAU/14.png +3 -0
  49. vlm/test/6M5G5hNiAU/15.png +3 -0
  50. vlm/test/6M5G5hNiAU/16.png +3 -0
parse/train/H1WgVz-AZ/H1WgVz-AZ.md ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LEARNING APPROXIMATE INFERENCE NETWORKS FOR STRUCTURED PREDICTION
2
+
3
+ Lifu Tu Kevin Gimpel
4
+ Toyota Technological Institute at Chicago, Chicago, IL, 60637, USA
5
+ {lifu,kgimpel}@ttic.edu
6
+
7
+ # ABSTRACT
8
+
9
+ Structured prediction energy networks (SPENs; Belanger & McCallum 2016) use neural network architectures to define energy functions that can capture arbitrary dependencies among parts of structured outputs. Prior work used gradient descent for inference, relaxing the structured output to a set of continuous variables and then optimizing the energy with respect to them. We replace this use of gradient descent with a neural network trained to approximate structured argmax inference. This “inference network” outputs continuous values that we treat as the output structure. We develop large-margin training criteria for joint training of the structured energy function and inference network. On multi-label classification we report speed-ups of $1 0 { - } 6 0 \mathrm { x }$ compared to (Belanger et al., 2017) while also improving accuracy. For sequence labeling with simple structured energies, our approach performs comparably to exact inference while being much faster at test time. We then demonstrate improved accuracy by augmenting the energy with a “label language model” that scores entire output label sequences, showing it can improve handling of long-distance dependencies in part-of-speech tagging. Finally, we show how inference networks can replace dynamic programming for test-time inference in conditional random fields, suggestive for their general use for fast inference in structured settings.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Energy-based modeling (LeCun et al., 2006) associates a scalar measure of compatibility to each configuration of input and output variables. Given an input $_ { \textbf { \em x } }$ , the predicted output $\hat { \textbf { \textit { y } } }$ is chosen by minimizing an energy function $E ( \pmb { x } , \hat { \pmb { y } } )$ . For structured prediction, the parameterization of the energy function can leverage domain knowledge about the structured output space. However, learning and prediction become complex.
14
+
15
+ Structured prediction energy networks (SPENs; Belanger & McCallum 2016) use an energy function to score structured outputs, and perform inference by using gradient descent to iteratively optimize the energy with respect to the outputs. Belanger et al. (2017) develop an “end-to-end” method that unrolls an approximate energy minimization algorithm into a fixed-size computation graph that is trainable by gradient descent. After learning the energy function, however, they still must use gradient descent for test-time inference.
16
+
17
+ We replace the gradient descent approach with a neural network trained to do inference, which we call an inference network. It can have any architecture such that it takes an input $_ { \textbf { \em x } }$ and returns an output interpretable as a $\textbf { { y } }$ . As in prior work, we relax $\textbf { { y } }$ from discrete to continuous. For multi-label classification, we use a feed-forward network that outputs a vector. We assign a single label to each dimension of the vector, interpreting its value as the probability of predicting that label. For sequence labeling, we output a distribution over predicted labels at each position in the sequence. We adapt the energy functions such that they can operate with both discrete ground truth outputs and outputs generated by our inference networks.
18
+
19
+ We define large-margin training objectives to jointly train energy functions and inference networks. Our training objectives resemble the alternating optimization framework of generative adversarial networks (GANs; Goodfellow et al. 2014): the inference network is analogous to the generator and the energy function is analogous to the discriminator. Our approach avoids argmax computations, making training and test-time inference faster than standard SPENs. We experiment with multi-label classification using the same setup as Belanger & McCallum (2016), demonstrating speed-ups of $1 0 \mathrm { x }$ in training time and $6 0 \mathrm { x }$ in test-time inference while also improving accuracy.
20
+
21
+ We then design a SPEN and inference network for sequence labeling by using recurrent neural networks (RNNs). We perform comparably to a conditional random field (CRF; Lafferty et al. 2001) when using the same energy function, with faster test-time inference. We also experiment with a richer energy that includes a “label language model” that scores entire output label sequences using an RNN, showing it can improve handling of long-distance dependencies in part-of-speech tagging. Finally, we show how inference networks can replace dynamic programming for test-time inference with CRFs, suggestive for the general use of inference networks to speed up inference in traditional structured prediction settings.
22
+
23
+ # 2 STRUCTURED PREDICTION ENERGY NETWORKS
24
+
25
+ We denote the space of inputs by $\mathcal { X }$ . For a given input $\mathbf { \boldsymbol { x } } \in \mathcal { X }$ , we denote the space of legal structured outputs by $\mathcal { V } ( \pmb { x } )$ . We denote the entire space of structured outputs by $\mathcal { V } = \cup _ { \pmb { x } \in \mathcal { X } } \mathcal { V } ( \pmb { x } )$ . A SPEN defines an energy function $E _ { \Theta } : \mathcal { X } \times \mathcal { Y } \mathbb { R }$ parameterized by $\Theta$ that uses a functional architecture to compute a scalar energy for an input/output pair.
26
+
27
+ We describe the SPEN for multi-label classification (MLC) from Belanger & McCallum (2016). Here, $_ { \textbf { \em x } }$ is a fixed-length feature vector. We assume there are $L$ labels, each of which can be on or off for each input, so $\mathcal { V } ( \pmb { x } ) = \{ 0 , 1 \} ^ { L }$ for all $_ { \textbf { \em x } }$ . The energy function is the sum of two terms: $E _ { \Theta } ( { \pmb x } , { \pmb y } ) = E ^ { l o c } ( { \pmb x } , { \pmb y } ) + \dot { E } ^ { l a b } ( { \pmb y } )$ . $E ^ { l o c } ( { \pmb x } , { \pmb y } )$ is the sum of linear models:
28
+
29
+ $$
30
+ E ^ { l o c } ( { \pmb x } , { \pmb y } ) = \sum _ { i = 1 } ^ { L } y _ { i } b _ { i } ^ { \top } F ( { \pmb x } )
31
+ $$
32
+
33
+ where $b _ { i }$ is a parameter vector for label $i$ and $F ( { \pmb x } )$ is a multi-layer perceptron computing a feature representation for the input $_ { \textbf { \em x } }$ . $E ^ { l a b } ( { \pmb y } )$ scores $\textbf { { y } }$ independent of $_ { \textbf { \em x } }$ :
34
+
35
+ $$
36
+ E ^ { l a b } ( { \pmb y } ) = c _ { 2 } ^ { \top } g ( C _ { 1 } { \pmb y } )
37
+ $$
38
+
39
+ where $c _ { 2 }$ is a parameter vector, $g$ is an elementwise non-linearity function, and $C _ { 1 }$ is a parameter matrix. After learning the energy function, prediction minimizes energy:
40
+
41
+ $$
42
+ \pmb { \hat { y } } = \underset { \pmb { y } \in \mathscr { y } ( \pmb { x } ) } { \mathrm { a r g m i n } } E _ { \Theta } ( \pmb { x } , \pmb { y } )
43
+ $$
44
+
45
+ However, solving Eq. (3) requires combinatorial algorithms because $\mathcal { V }$ is a discrete structured space. This becomes intractable when $E _ { \Theta }$ does not decompose into a sum over small “parts” of $\textbf { { y } }$ . Belanger & McCallum (2016) relax this problem by allowing the discrete vector $\textbf { { y } }$ to be continuous. We use $\mathcal { { V } } _ { R }$ to denote the relaxed output space. For MLC, $\begin{array} { r } { \breve { y } _ { R } ( { \pmb x } ) = [ 0 , 1 ] ^ { L } } \end{array}$ . They solve the relaxed problem by using gradient descent to iteratively optimize the energy with respect to $\textbf { { y } }$ . Since they train with a structured large-margin objective, repeated inference is required during learning. They note that using gradient descent for this inference step is time-consuming and makes learning less stable. So Belanger et al. (2017) propose an “end-to-end” learning procedure inspired by Domke (2012). This approach performs backpropagation through each step of gradient descent. We compare to both methods in our experiments below.
46
+
47
+ # 3 INFERENCE NETWORKS FOR SPENS
48
+
49
+ Belanger & McCallum (2016) relaxed $\textbf { { y } }$ from a discrete to a continuous vector and used gradient descent for inference. We also relax $\textbf { { y } }$ but we use a different strategy to approximate inference. We define an inference network $\mathbf { A } _ { \Psi } ( \pmb { x } )$ parameterized by $\Psi$ and train it with the goal that
50
+
51
+ $$
52
+ \mathbf { A } _ { \Psi } ( \pmb { x } ) \approx \underset { \pmb { y } \in \mathcal { V } _ { R } ( \pmb { x } ) } { \mathrm { a r g m i n } } E _ { \Theta } ( \pmb { x } , \pmb { y } )
53
+ $$
54
+
55
+ Given an energy function $E _ { \Theta }$ and a dataset $X$ of inputs, we solve the following optimization problem:
56
+
57
+ $$
58
+ \hat { \Psi } \underset { \Psi } { \mathrm { a r g m i n } } \sum _ { \pmb { x } \in X } E _ { \Theta } ( \pmb { x } , \mathbf { A } _ { \Psi } ( \pmb { x } ) )
59
+ $$
60
+
61
+ The architecture of $\mathbf { A } _ { \Psi }$ will depend on the task. For MLC, the same set of labels is applicable to every input, ${ \bf { S 0 } } \ y$ has the same length for all inputs. So, we can use a feed-forward network for $\mathbf { A } _ { \Psi }$ with a vector output, treating each dimension as the prediction for a single label. For sequence labeling, each $_ { \textbf { \em x } }$ (and therefore each $\textbf { { y } }$ ) can have a different length, so we must use a network architecture for $\mathbf { A } _ { \Psi }$ that permits different lengths of predictions. We use an RNN that returns a vector at each position of $_ { \textbf { \em x } }$ . We interpret this vector as a probability distribution over output labels at that position.
62
+
63
+ We note that the output of $\mathbf { A } _ { \Psi }$ must be compatible with the energy function, which is typically defined in terms of the original discrete output space $\mathcal { V }$ . This may require generalizing the energy function to be able to operate both on elements of $\mathcal { V }$ and $\mathcal { V } _ { R }$ . For MLC, no change is required. For sequence labeling, the change is straightforward and is described below in Section 7.2.1.
64
+
65
+ # 4 JOINT TRAINING OF SPENS AND INFERENCE NETWORKS
66
+
67
+ Belanger & McCallum (2016) propose a structured hinge loss for training SPENs:
68
+
69
+ $$
70
+ \operatorname* { m i n } _ { \Theta } \sum _ { \langle x _ { i } , y _ { i } \rangle \in \mathcal { D } } \left[ \operatorname* { m a x } _ { y \in \mathcal { V } _ { R } ( \pmb { x } ) } \left( \triangle ( \pmb { y } , \pmb { y } _ { i } ) - E _ { \Theta } ( \pmb { x } _ { i } , \pmb { y } ) + E _ { \Theta } ( \pmb { x } _ { i } , \pmb { y } _ { i } ) \right) \right] _ { + }
71
+ $$
72
+
73
+ where $\mathcal { D }$ is the set of training pairs, $[ f ] _ { + } = \operatorname* { m a x } ( 0 , f )$ , and $\triangle ( \pmb { y } , \pmb { y } ^ { \prime } )$ is a structured cost function that returns a nonnegative value indicating the difference between $\textbf { { y } }$ and $\boldsymbol { y } ^ { \prime }$ . This loss is often referred to as “margin-rescaled” structured hinge loss (Taskar et al., 2004; Tsochantaridis et al., 2005).
74
+
75
+ However, this loss is expensive to minimize for structured models because of the “cost-augmented” inference step $( \operatorname* { m a x } _ { \pmb { y } \in \mathcal { y } _ { R } ( \pmb { x } ) } )$ . In prior work with SPENs, this step used gradient descent. We replace this with a cost-augmented inference network ${ \bf A } _ { \Phi } ( { \pmb x } )$ . As suggested by the notation, the cost-augmented inference network $\mathbf { A } _ { \Phi }$ and the inference network $\mathbf { A } _ { \Psi }$ will typically have the same functional form, but use different parameters $\Phi$ and $\Psi$ . We write our new optimization problem as:
76
+
77
+ $$
78
+ \operatorname* { m i n } _ { \Theta } \operatorname* { m a x } _ { \Phi } \sum _ { \langle \pmb { x } _ { i } , \pmb { y } _ { i } \rangle \in \mathcal { D } } \left[ \triangle ( \mathbf { A } _ { \Phi } ( \pmb { x } _ { i } ) , \pmb { y } _ { i } ) - E _ { \Theta } ( \pmb { x } _ { i } , \mathbf { A } _ { \Phi } ( \pmb { x } _ { i } ) ) + E _ { \Theta } ( \pmb { x } _ { i } , \pmb { y } _ { i } ) \right] _ { + }
79
+ $$
80
+
81
+ We treat this optimization problem as a minimax game and find a saddle point for the game. Following Goodfellow et al. (2014), we implement this using an iterative numerical approach. We alternatively optimize $\Phi$ and $\Theta$ , holding the other fixed. Optimizing $\Phi$ to completion in the inner loop of training is computationally prohibitive and may lead to overfitting. So we alternate between one mini-batch for optimizing $\Phi$ and one for optimizing $\Theta$ . We also add $L _ { 2 }$ regularization terms for $\Theta$ and $\Phi$ .
82
+
83
+ The objective for the cost-augmented inference network is:
84
+
85
+ $$
86
+ \hat { \Phi } \underset { \Phi } { \mathrm { a r g m a x } } [ \bigtriangleup ( \mathbf { A } _ { \Phi } ( \boldsymbol { x } _ { i } ) , \pmb { y } _ { i } ) - E _ { \Theta } ( \boldsymbol { x } _ { i } , \mathbf { A } _ { \Phi } ( \boldsymbol { x } ) _ { i } ) + E _ { \Theta } ( \boldsymbol { x } _ { i } , \pmb { y } _ { i } ) ] _ { + }
87
+ $$
88
+
89
+ That is, we update $\Phi$ so that $\mathbf { A } _ { \Phi }$ yields an output that has low energy and high cost, in order to mimic cost-augmented inference. The energy parameters $\Theta$ are kept fixed. There is an analogy here to the generator in GANs: $\mathbf { A } _ { \Phi }$ is trained to produce a high-cost structured output that is also appealing to the current energy function. To help stabilize training of $\Phi$ , we add several terms to this objective, discussed below in Section 5.
90
+
91
+ The objective for the energy function is:
92
+
93
+ $$
94
+ \hat { \Theta } \underset { \Theta } { \mathrm { a r g m i n } } [ \triangle ( \mathbf { A } _ { \Phi } ( \pmb { x } _ { i } ) , \pmb { y } _ { i } ) - E _ { \Theta } ( \pmb { x } _ { i } , \mathbf { A } _ { \Phi } ( \pmb { x } _ { i } ) ) + E _ { \Theta } ( \pmb { x } _ { i } , \pmb { y } _ { i } ) ] _ { + } + \lambda \| \Theta \| _ { 2 } ^ { 2 }
95
+ $$
96
+
97
+ That is, we update $\Theta$ so as to widen the gap between the cost-augmented and ground truth outputs. There is an analogy here to the discriminator in GANs. The energy function is updated so as to enable it to distinguish “fake” outputs produced by $\mathbf { A } _ { \Phi }$ from real outputs $\mathbf { \nabla } _ { \mathbf { \psi } _ { j } } \mathbf { \sigma } _ { j } \mathbf { \sigma } _ { j } $ .
98
+
99
+ Training iterates between updating $\Phi$ and $\Theta$ using the objectives above.
100
+
101
+ # 4.1 TEST-TIME INFERENCE
102
+
103
+ After training, we want to use an inference network $\mathbf { A } _ { \Psi }$ defined in Eq. (4). However, training only gives us a cost-augmented inference network $\mathbf { A } _ { \Phi }$ . Since $\mathbf { A } _ { \Psi }$ and $\mathbf { A } _ { \Phi }$ have the same functional form, we can use $\Phi$ to initialize $\Psi$ , then do additional training on $\mathbf { A } _ { \Psi }$ as in Eq. (5) where $X$ is the training or validation set. This step helps the resulting inference network to produce outputs with lower energy, as it is no longer affected by the cost function. Since this procedure does not use the output labels of the $_ { \textbf { \em x } }$ ’s in $X$ , it could also be applied to the test data in a transductive setting.
104
+
105
+ # 4.2 VARIATIONS AND SPECIAL CASES
106
+
107
+ This approach also permits us to use large-margin structured prediction with slack rescaling (Tsochantaridis et al., 2005). Slack rescaling can yield higher accuracies than margin rescaling, but requires “cost-scaled” inference during training which is intractable for many classes of output structures. However, we can use our notion of inference networks to circumvent this tractability issue and approximately optimize the slack-rescaled hinge loss, yielding the following optimization problem:
108
+
109
+ $$
110
+ \operatorname* { m i n } _ { \Theta } \operatorname* { m a x } _ { \Phi } \sum _ { \langle \mathbf { x } _ { i } , \mathbf { y } _ { i } \rangle \in \mathcal { D } } \bigtriangleup ( \mathbf { A } _ { \Phi } ( \mathbf { x } _ { i } ) , \mathbf { y } _ { i } ) [ 1 - E _ { \Theta } ( \mathbf { x } _ { i } , \mathbf { A } _ { \Phi } ( \mathbf { x } _ { i } ) ) + E _ { \Theta } ( \mathbf { x } _ { i } , \mathbf { y } _ { i } ) ] _ { + }
111
+ $$
112
+
113
+ Using the same argument as above, we can also break this into alternating optimization of $\Phi$ and $\Theta$ .
114
+
115
+ We can optimize a structured perceptron (Collins, 2002) version by using the margin-rescaled hinge loss (Eq. (7)) and fixing $\begin{array} { r } { \triangle ( \mathbf { A } _ { \Phi } ( \pmb { x } _ { i } ) , \pmb { y } _ { i } ) = 0 } \end{array}$ . When using this loss, the cost-augmented inference network is actually a test-time inference network, because the cost is always zero, so using this loss may lessen the need to retune the inference network after training.
116
+
117
+ When we fix $\begin{array} { r } { \triangle ( \mathbf { A } _ { \Phi } ( \pmb { x } _ { i } ) , \pmb { y } _ { i } ) = 1 } \end{array}$ , then margin-rescaled hinge is equivalent to slack-rescaled hinge. While using $\triangle = 1$ is not useful in standard max-margin training with exact argmax inference (because the cost has no impact on optimization when fixed to a positive constant), it is potentially useful in our setting. Consider our SPEN objectives with $\triangle = 1$ :
118
+
119
+ $$
120
+ [ 1 - E _ { \Theta } ( { \pmb x } _ { i } , { \pmb A } _ { \Phi } ( { \pmb x } _ { i } ) ) + E _ { \Theta } ( { \pmb x } _ { i } , { \pmb y } _ { i } ) ] _ { + }
121
+ $$
122
+
123
+ There will always be a nonzero difference between the two energies because ${ \bf A } _ { \Phi } ( { \pmb x } _ { i } )$ will never exactly equal the discrete vector $\mathbf { \nabla } _ { \mathbf { \mathcal { Y } } _ { i } }$ . Since there is no explicit minimization over all discrete vectors $\textbf { { y } }$ , this case is more similar to a “contrastive” hinge loss which seeks to make the energy of the true output lower than the energy of a particular “negative sample” by a margin of at least 1.
124
+
125
+ In our experiments, we will compare four hinge losses for training SPENs: margin-rescaled (Eq. (7)), slack-rescaled (Eq. (10)), perceptron (margin-rescaled with $\triangle = 0$ ), and contrastive $\triangle = 1$ ).
126
+
127
+ # 5 IMPROVING TRAINING FOR INFERENCE NETWORKS
128
+
129
+ We found that the alternating nature of the optimization led to difficulties during training. Similar observations have been noted about other alternative optimization settings, especially those underlying generative adversarial networks (Salimans et al., 2016). Below we describe several techniques we found to help stabilize training, which are optional terms added to the objective in Eq. (8).
130
+
131
+ $L _ { 2 }$ Regularization: We use $L _ { 2 }$ regularization, adding the penalty term $\| \Phi \| _ { 2 } ^ { 2 }$ with coefficient $\lambda _ { 1 }$
132
+
133
+ Entropy Regularization: We add an entropy-based regularizer $\mathrm { l o s s } _ { \mathrm { H } } ( \mathbf { A } _ { \Phi } ( \pmb { x } ) )$ defined for the problem under consideration. For MLC, the output of $\mathbf { A } _ { \Phi } ( \pmb { x } )$ is a vector of scalars in [0, 1], one for each label, where the scalar is interpreted as a label probability. The entropy regularizer $\mathrm { l o s s } _ { \mathrm { H } }$ is the sum of the entropies over these label binary distributions. For sequence labeling, where the length of $_ { \textbf { \em x } }$ is $N$ and where there are $L$ unique labels, the output of ${ \bf A } _ { \Phi } ( { \pmb x } )$ is a length- $N$ sequence of length- $L$ vectors, each of which represents the distribution over the $L$ labels at that position in $_ { \textbf { \em x } }$ . Then, $\mathrm { l o s s } _ { \mathrm { H } }$ is the sum of entropies of these label distributions across positions in the sequence.
134
+
135
+ When tuning the coefficient $\lambda _ { 2 }$ for this regularizer, we consider both positive and negative values, permitting us to favor either low- or high-entropy distributions as the task prefers.1
136
+
137
+ Local Cross Entropy Loss: We add a local (non-structured) cross entropy $\mathrm { l o s s } _ { \mathrm { C E } } ( \mathbf { A } _ { \Phi } ( \pmb { x } _ { i } ) , \pmb { y } _ { i } )$ defined for the problem under consideration. We only experiment with this loss for sequence labeling.
138
+
139
+ It is the sum of the label cross entropy losses over all positions in the sequence. This loss provides more explicit feedback to the inference network, helping the optimization procedure to find a solution that minimizes the energy function while also correctly classifying individual labels. It can also be viewed as a multi-task loss for the inference network.
140
+
141
+ Regularization Toward Pretrained Inference Network: We add the penalty $\lVert \Phi - \Phi _ { 0 } \rVert _ { 2 } ^ { 2 }$ where $\Phi _ { 0 }$ is a pretrained network, e.g., a local classifier trained to independently predict each part of $\textbf { { y } }$ .
142
+
143
+ Each additional term has its own tunable hyperparameter. Finally we obtain:
144
+
145
+ $$
146
+ \begin{array} { r } { \hat { \Phi } \underset { \Phi } { \operatorname { a r g m a x } } \ [ \triangle ( \mathbf { A } _ { \Phi } ( \boldsymbol { x } _ { i } ) , \boldsymbol { y } _ { i } ) - E _ { \Theta } ( \boldsymbol { x } _ { i } , \mathbf { A } _ { \Phi } ( \boldsymbol { x } _ { i } ) ) + E _ { \Theta } ( \boldsymbol { x } _ { i } , \boldsymbol { y } _ { i } ) ] _ { + } - \lambda _ { 1 } \| \Phi \| _ { 2 } ^ { 2 } } \\ { + \lambda _ { 2 } \mathrm { l o s s } _ { \mathrm { H } } ( \mathbf { A } _ { \Phi } ( \boldsymbol { x } _ { i } ) ) - \lambda _ { 3 } \mathrm { l o s s } _ { \mathrm { C E } } ( \mathbf { A } _ { \Phi } ( \boldsymbol { x } _ { i } ) , \boldsymbol { y } _ { i } ) - \lambda _ { 4 } \| \Phi - \Phi _ { 0 } \| _ { 2 } ^ { 2 } } \end{array}
147
+ $$
148
+
149
+ # 6 RELATED WORK
150
+
151
+ Our methods are reminiscent of other alternating optimization problems like that underlying generative adversarial networks (GANs; Goodfellow et al. 2014). GANs are based on a minimax game and have a value function that one agent (a discriminator $D$ ) seeks to maximize and another (a generator $G$ ) seeks to minimize. By their analysis, a log loss discriminator converges to a degenerate uniform solution. When using hinge loss, we can get a non-degenerate discriminator while matching the data distribution (Dai et al., 2017; Zhao et al., 2016). Our formulation is closer to this hinge loss version of the GAN.
152
+
153
+ Our approach is also related to knowledge distillation (Ba & Caruana, 2014; Hinton et al., 2015), which refers to strategies in which one model (a “student”) is trained to mimic another (a “teacher”). Typically, the teacher is a larger, more accurate model but which is too computationally expensive to use at test time. Urban et al. (2016) train shallow networks using image classification data labeled by an ensemble of deep teacher nets. Geras et al. (2016) train a convolutional network to mimic an LSTM for speech recognition. Others have explored knowledge distillation for sequence-to-sequence learning (Kim & Rush, 2016) and parsing (Kuncoro et al., 2016).
154
+
155
+ Since we train a single inference network for an entire dataset, our approach is also related to “amortized inference” (Srikumar et al., 2012; Gershman & Goodman, 2014; Paige & Wood, 2016; Chang et al., 2015). Such methods precompute or save solutions to subproblems for faster overall computation. Our inference networks likely devote more modeling capacity to the most frequent substructures in the data. A kind of inference network is used in variational autoencoders (Kingma & Welling, 2013) to approximate posterior inference in generative models.
156
+
157
+ Our methods are also related to work in structured prediction that seeks to approximate structured models with factorized ones, e.g., mean-field approximations in graphical models (Koller & Friedman, 2009; Krähenbühl & Koltun, 2011). Like our use of inference networks, there have been efforts in designing differentiable approximations of combinatorial search procedures (Martins & Kreutzer, 2017; Goyal et al., 2018) and structured losses for training with them (Wiseman & Rush, 2016). Since we relax discrete output variables to be continuous, there is also a connection to recent work that focuses on structured prediction with continuous valued output variables (Wang et al., 2016). They also propose a formulation that yields an alternating optimization problem, but it is based on proximal methods.
158
+
159
+ There are other settings in which gradient descent is used for inference, e.g., image generation applications like DeepDream (Mordvintsev et al., 2015) and neural style transfer (Gatys et al., 2015), as well as machine translation (Hoang et al., 2017). In these and related settings, gradient descent has started to be replaced by inference networks, especially for image transformation tasks (Johnson et al., 2016; Li & Wand, 2016). Our results below provide more evidence for making this transition. An alternative to what we pursue here would be to obtain an easier convex optimization problem for inference via input convex neural networks (Amos et al., 2017).
160
+
161
+ Table 1: Test F1 when comparing methods on multi-label classification datasets.
162
+
163
+ <table><tr><td></td><td>Bibtex</td><td>Bookmarks</td><td>Delicious</td><td>avg.</td></tr><tr><td>MLP</td><td>38.9</td><td>33.8</td><td>37.8</td><td>36.8</td></tr><tr><td>SPEN (BM16)</td><td>42.2</td><td>34.4</td><td>37.5</td><td>38.0</td></tr><tr><td>SPEN (E2E)</td><td>38.1</td><td>33.9</td><td>34.4</td><td>35.5</td></tr><tr><td>SPEN (InfNet)</td><td>42.2</td><td>37.6</td><td>37.5</td><td>39.1</td></tr></table>
164
+
165
+ # 7 EXPERIMENTS
166
+
167
+ In Sec. 7.1 we compare our approach to previous work on training SPENs for MLC. We compare accuracy and speed, finding our approach to outperform prior work. We then perform experiments with sequence labeling tasks in Sec. 7.2.
168
+
169
+ # 7.1 MULTI-LABEL CLASSIFICATION
170
+
171
+ We use the MLC datasets used by Belanger & McCallum (2016): Bibtex, Delicious, and Bookmarks. Dataset statistics are shown in Table 7 in the Appendix. For Bibtex and Delicious, we follow Belanger and McCallum and tune the hyperparameters using a different sampling of train and test data, then use the standard train/test split for final experimentation using the tuned hyperparameters. For Bookmarks, we use the same train/dev/test split as (Belanger & McCallum, 2016). For evaluation, we report the example averaged (macro averaged) F1 measure.
172
+
173
+ We use the SPEN for MLC described in Section 2 and also used by Belanger & McCallum (2016). For the feature representation network $F ( { \pmb x } )$ , we use feed-forward networks with two hidden layers, using their same layer widths: 150 for Bibtex/Bookmarks and 250 for Delicious. We pretrain the feature networks $F ( { \dot { \mathbf { x } } } )$ by minimizing independent-label cross entropy for 10 epochs using Adam (Kingma & Ba, 2014) with learning rate 0.001. While training SPENs, we only update the parameters of the energy function $( \Theta )$ and the inference network $( \Phi )$ , keeping the feature network parameters $F ( { \pmb x } )$ fixed. We use Adam with learning rate 0.001 to train $\Theta$ and $\Phi$ .
174
+
175
+ The inference networks are feed-forward networks with two hidden layers, using the same architectures as the feature networks $F ( { \pmb x } )$ . This permits us to initialize inference network parameters $\Phi$ using pretrained feature network parameters. For the output, we use an affine transformation layer with a sigmoid nonlinearity function, so the output values are in the range $( 0 , 1 )$ . We interpret each value as the probability of predicting the corresponding label. We obtain discrete predictions by thresholding at a threshold $\tau$ tuned to maximize F1 on the development data. We add three terms to the inference network objective from Section 5: $L _ { 2 }$ regularization, entropy regularization, and regularization toward the pretrained feature network. Margin rescaling and slack rescaling use squared $L _ { 2 }$ distance for $\triangle$ . Additional details are provided in Sec. 9.1 in the appendix.
176
+
177
+ Comparison to Prior Work. Table 1 shows results comparing to prior work. The MLP and “SPEN (BM16)” baseline results are taken from (Belanger & McCallum, 2016). We obtained the “SPEN (E2E)” (Belanger et al., 2017) results by running the code available from the authors on these datasets. This method constructs a recurrent neural network that performs gradient-based minimization of the energy with respect to $\textbf { { y } }$ . They noted in their software release that, while this method is more stable, it is prone to overfitting and actually performs worse than the original SPEN. We indeed find this to be the case, as SPEN (E2E) underperforms SPEN (BM16) on all three datasets.
178
+
179
+ Our method (“SPEN (InfNet)”) achieves the best average performance across the three datasets. It performs especially well on Bookmarks, which is the largest of the three. Our results use the contrastive hinge loss and retune the inference network on the development data after the energy is trained; these decisions were made based on the tuning described in Sec. 9.1, but all four hinge losses led to similarly strong results.
180
+
181
+ Speed Comparison. Table 2 compares training and test-time inference speed among the different methods. We only report speeds of methods that we ran.2 The SPEN (E2E) times were obtained using code obtained from Belanger and McCallum. We suspect that SPEN (BM16) training would be comparable to or slower than SPEN (E2E). Our method can process examples during training about 10 times as fast as the end-to-end SPEN, and 60-130 times as fast during test-time inference. In fact, at test time, our method is roughly the same speed as the MLP baseline, since our inference networks use the same architecture as the feature networks which form the MLP baseline. Compared to the MLP, the training of our method takes significantly more time overall because of joint training of the energy function and inference network, but fortunately the test-time inference is comparable.
182
+
183
+ Table 2: Training and test-time inference speed comparison (examples/sec).
184
+
185
+ <table><tr><td rowspan="2"></td><td colspan="3">Training Speed (examples/sec)</td><td colspan="3">Testing Speed (examples/sec)</td></tr><tr><td>Bibtex</td><td>Bookmarks</td><td>Delicious</td><td>Bibtex</td><td>Bookmarks</td><td>Delicious</td></tr><tr><td>MLP</td><td>21670</td><td>19591</td><td>26158</td><td>90706</td><td>92307</td><td>113750</td></tr><tr><td>SPEN (E2E)</td><td>551</td><td>559</td><td>383</td><td>1420</td><td>1401</td><td>832</td></tr><tr><td>SPEN (InfNet)</td><td>5533</td><td>5467</td><td>4667</td><td>94194</td><td>88888</td><td>112148</td></tr></table>
186
+
187
+ # 7.2 SEQUENCE LABELING
188
+
189
+ We also evaluate our methods on sequence labeling. We report experiments with Twitter part-ofspeech (POS) tagging here. Named entity recognition experiments are reported in the Appendix.
190
+
191
+ # 7.2.1 ENERGY FUNCTIONS FOR SEQUENCE LABELING
192
+
193
+ The input space $\mathcal { X }$ is now the set of all sequences of symbols drawn from a vocabulary. For an input sequence $_ { \textbf { \em x } }$ of length $N$ , where there are $L$ possible output labels for each position in $_ { \textbf { \em x } }$ , the output space $\mathcal { V } ( \pmb { x } )$ is $[ L ] ^ { \widetilde { N } }$ , where the notation $[ q ]$ represents the set containing the first $q$ positive integers. We define $\pmb { y } = \langle y _ { 1 } , y _ { 2 } , . . , y _ { N } \rangle$ where each $y _ { i }$ ranges over possible output labels, i.e., $y _ { i } \in [ L ]$ .
194
+
195
+ When defining our energy for sequence labeling, we take inspiration from bidirectional LSTMs (BLSTMs; Hochreiter $\&$ Schmidhuber 1997) and conditional random fields (CRFs; Lafferty et al. 2001). A “linear chain” CRF uses two types of features: one capturing the connection between an output label and $_ { \textbf { \em x } }$ and the other capturing the dependence between neighboring output labels. We use a BLSTM to compute feature representations for $_ { \textbf { \em x } }$ . We use $f ( \pmb { x } , t ) \in \mathbb { R } ^ { d }$ to denote the “input feature vector” for position $t$ , defining it to be the $d$ -dimensional BLSTM hidden vector at $t$ .
196
+
197
+ We then define the following energy function:
198
+
199
+ $$
200
+ E _ { \Theta } ( \pmb { x } , \pmb { y } ) = - \left( \sum _ { t } U _ { y _ { t } } ^ { \top } f ( \pmb { x } , t ) + \sum _ { t } W _ { y _ { t - 1 } , y _ { t } } \right)
201
+ $$
202
+
203
+ where $U _ { i } \in \mathbb { R } ^ { d }$ is a parameter vector for label $i$ and the parameter matrix $W \in \mathbb { R } ^ { L \times L }$ contains label pair parameters. The full set of parameters $\Theta$ includes the $U _ { i }$ vectors, $W$ , and the parameters of the BLSTM. The above energy only permits discrete $\textbf { { y } }$ . For the general case that permits relaxing $\textbf { { y } }$ to be continuous, we treat each $y _ { t }$ as a vector. It will be one-hot for the ground truth $\textbf { { y } }$ and will be a vector of label probabilities for relaxed $\textbf { { y } }$ ’s. Then the general energy function is:
204
+
205
+ $$
206
+ E _ { \Theta } ( \pmb { x } , \pmb { y } ) = - \left( \sum _ { t } \sum _ { i = 1 } ^ { L } y _ { t , i } \left( U _ { i } ^ { \top } f ( \pmb { x } , t ) \right) + \sum _ { t } y _ { t - 1 } ^ { \top } W y _ { t } \right)
207
+ $$
208
+
209
+ where $y _ { t , i }$ is the $i$ th entry of the vector $y _ { t }$ . In the discrete case, this entry is 1 for a single $i$ and 0 for all others, so this energy reduces to Eq. (12) in that case. In the continuous case, this scalar indicates the probability of the tth position being labeled with label $i$ . For the label pair terms in this general energy function, we use a bilinear product between the vectors $y _ { t - 1 }$ and $y _ { t }$ using parameter matrix $W$ , which also reduces to Eq. (12) when they are one-hot vectors.
210
+
211
+ Tag Language Model. In order to capture long-distance dependencies in an entire sequence of labels, we train a “tag language model” on a large corpus of automatically-tagged tweets, then include a term in the energy function representing the log-probability of the given tag sequence under this tag language model. Details are provided below in Section 7.2.4.
212
+
213
+ Table 3: Comparison of SPEN hinge losses and showing the impact of retuning (Twitter POS validation accuracies). Inference networks are trained with the cross entropy term.
214
+
215
+ <table><tr><td>SPEN hinge loss</td><td colspan="2">validation accuracy (%)</td></tr><tr><td></td><td>-retuning 89.1</td><td>+retuning</td></tr><tr><td>margin rescaling slack rescaling</td><td>89.4</td><td>89.3</td></tr><tr><td>perceptron (MR,△= 0)</td><td>89.2</td><td>89.6</td></tr><tr><td></td><td>88.8</td><td>89.4</td></tr><tr><td>contrastive (△= 1)</td><td></td><td>89.0</td></tr></table>
216
+
217
+ Table 4: Twitter POS accuracies of BLSTM, CRF, and SPEN (InfNet), using our tuned SPEN configuration (slack-rescaled hinge, inference network trained with cross entropy term). Though slowest to train, the SPEN matches the test-time speed of the BLSTM while achieving the highest accuracies.
218
+
219
+ <table><tr><td></td><td>validation accuracy (%)</td><td>test accuracy (%)</td><td>training speed (examples/sec)</td><td>testing speed (examples/sec)</td></tr><tr><td>BLSTM</td><td>88.6</td><td>88.8</td><td>385</td><td>1250</td></tr><tr><td>CRF</td><td>89.1</td><td>89.2</td><td>250</td><td>500</td></tr><tr><td>SPEN (InfNet)</td><td>89.6</td><td>89.8</td><td>125</td><td>1250</td></tr></table>
220
+
221
+ # 7.2.2 EXPERIMENTAL SETUP
222
+
223
+ For Twitter part-of-speech (POS) tagging, we use the annotated data from Gimpel et al. (2011) and Owoputi et al. (2013) which contains $L = 2 5$ POS tags. For training, we combine the 1000- tweet OCT27TRAIN set and the 327-tweet OCT27DEV set. For validation, we use the 500-tweet OCT27TEST set and for testing we use the 547-tweet DAILY547 test set. We use 100-dimensional skip-gram embeddings trained on 56 million English tweets with word2vec (Mikolov et al., 2013).3
224
+
225
+ We use a BLSTM to compute the “input feature vector” $f ( { \pmb x } , t )$ for each position $t$ , using hidden vectors of dimensionality $d = 1 0 0$ . We also use BLSTMs for the inference networks. The output layer of the inference network is a softmax function, so at every position, the inference network produces a distribution over labels at that position. We train inference networks using stochastic gradient descent (SGD) with momentum and train the energy parameters using Adam. For $\triangle$ , we use $L _ { 1 }$ distance. We tune hyperparameters on the validation set; full details of tuning are provided in the appendix. We found that the cross entropy stabilization term worked well for this setting; details and an empirical comparison are provided in Section 9.2.1.
226
+
227
+ We compare to standard BLSTM and CRF baselines. We train the BLSTM baseline to minimize per-token log loss; this is often called a “BLSTM tagger”. We train a CRF baseline using the energy in Eq. (12) with the standard conditional log-likelihood objective using the standard dynamic programming algorithms (forward-backward) to compute gradients during training. Further details are provided in the appendix.
228
+
229
+ # 7.2.3 RESULTS
230
+
231
+ Loss Function Comparison. Table 3 shows results when comparing SPEN training objectives. We see a larger difference among losses here than for MLC tasks. When using the perceptron loss, there is no margin, which leads to overfitting: 89.4 on validation, 88.6 on test (not shown in the table). The contrastive loss, which strives to achieve a margin of 1, does better on test (89.0). We also see here that margin rescaling and slack rescaling both outperform the contrastive hinge, unlike the MLC tasks. We suspect that in the case in which each input/output has a different length, using a cost that captures length is more important.
232
+
233
+ Comparison to Standard Baselines. Table 4 compares our final tuned SPEN configuration to two standard baselines: a BLSTM tagger and a CRF. The SPEN achieves higher validation and test accuracies with faster test-time inference. While our method is slower than the baselines during training, it is faster than the CRF at test time, operating at essentially the same speed as the BLSTM baseline while being more accurate.
234
+
235
+ Table 5: Twitter POS validation/test accuracies when adding tag language model (TLM) energy term to a SPEN trained with margin-rescaled hinge.
236
+
237
+ <table><tr><td></td><td>val. accuracy (%)</td><td>test accuracy (%)</td></tr><tr><td>-TLM</td><td>89.8</td><td>89.6</td></tr><tr><td>+TLM</td><td>89.9</td><td>90.2</td></tr></table>
238
+
239
+ Here, the SPEN and CRF are using the same functional form for their energy functions, namely the energy given in Eq. (13). We note that the SPEN outperforms the CRF, despite using the same form for the energy. There are two factors that can explain this. First, the losses are different. The CRF uses conditional log-likelihood while the SPEN results here use slack-rescaled hinge, which outperforms the other hinge loss variants (Table 3). Second, the stabilization terms used when training the inference network may be providing a regularizing effect for the model. Our motivation for these experiments was to show the impact of these differences while keeping the form of the energy function fixed. We now turn to richer energies.
240
+
241
+ 7.2.4 TOWARDS GLOBAL ENERGIES: TAG LANGUAGE MODELS FOR TWITTER POS TAGGING
242
+
243
+ The above results only use the pairwise energy; no results used the tag language model (TLM). To compute the TLM energy term, we first automatically tag unlabeled tweets, then train an LSTM language model on the automatic tag sequences. When doing so, we define the input tag embeddings to be $L$ -dimensional one-hot vectors specifying the tags in the training sequences. This is nonstandard compared to standard language modeling. In standard language modeling, we train on observed sequences and compute likelihoods of other fully-observed sequences. However, in our case, we train on tag sequences but we want to use the same model on sequences of tag distributions produced by an inference network. We train the TLM on sequences of one-hot vectors and then use it to compute likelihoods of sequences of tag distributions. Further details about training are provided in Section 9.2.2 in the appendix.
244
+
245
+ We define an additional energy term $E ^ { \mathrm { T L M } } ( y )$ based on the pretrained TLM. If the argument $\textbf { { y } }$ consisted of one-hot vectors, we could simply compute its likelihood. However, to support relaxed $\textbf { { y } }$ ’s, we need to define a more general function:
246
+
247
+ $$
248
+ E ^ { \mathrm { T L M } } ( \pmb { y } ) = - \sum _ { t = 1 } ^ { | \pmb { y } | + 1 } \log ( \pmb { y } _ { t } ^ { \top } \mathrm { T L M } ( \langle \pmb { y } _ { 0 } , . . . , \pmb { y } _ { t - 1 } \rangle ) )
249
+ $$
250
+
251
+ where $y _ { 0 }$ is the start-of-sequence symbol, $y _ { \vert \pmb { y } \vert + 1 }$ is the end-of-sequence symbol, and $\mathrm { T L M } \big ( \langle y _ { 0 } , . . . , y _ { t - 1 } \rangle \big )$ returns the softmax distribution over tags at position $t$ (under the pretrained tag language model) given the preceding tag vectors. When each $y _ { t }$ is a one-hot vector, this energy reduces to the negative log-likelihood of the tag sequence specified by $\textbf { { y } }$ .
252
+
253
+ We define the new joint energy as the sum of the energy function in Eq. (13) and the TLM energy function in Eq. (14). During learning, we keep the TLM parameters fixed to their pretrained values, but we tune the weight of the TLM energy (over the set $\{ 0 . 1 , 0 . 2 , 0 . 5 \} )$ in the joint energy. We train SPENs with the new joint energy using the margin-rescaled hinge, training the inference network with the cross entropy term.
254
+
255
+ Table 5 shows results.4 Adding the TLM energy leads to a gain of 0.6 on the test set. Other settings showed more variance; when using slack-rescaled hinge, we found a small drop on test, while when simply training inference networks for a fixed, pretrained joint energy with tuned mixture coefficient, we found a gain of 0.3 on test when adding the TLM energy. We investigated the improvements and found some to involve corrections that seemingly stem from handling non-local dependencies better. Table 10 in the appendix shows examples in which the model with the TLM appears to be better at using the broader context when making tagging decisions. These results suggest that our method of training inference networks can be used to add rich features to structured prediction, though we leave a thorough exploration of global energies to future work.
256
+
257
+ Table 6: Comparison of test-time inference algorithms for a trained CRF (Twitter POS tagging). We show the test accuracy for the inference network setting that does best on validation. All inference networks use the same architecture and therefore have essentially the same speed.
258
+
259
+ <table><tr><td>test-time inference algorithm</td><td>val. accuracy (%)</td><td>test accuracy (%)</td><td>speed (examples/sec)</td></tr><tr><td>Viterbialgorithm</td><td>89.1</td><td>89.2</td><td>500</td></tr><tr><td>Inference network + cross entropy</td><td>89.7</td><td>89.5</td><td>1250</td></tr><tr><td>Inference network+ entropy</td><td>89.6</td><td></td><td></td></tr><tr><td>Inference network + squared L2 distance</td><td>88.9</td><td></td><td></td></tr></table>
260
+
261
+ # 7.2.5 BEYOND SPENS: INFERENCE NETWORKS FOR STRUCTURED PREDICTION
262
+
263
+ We note that inference networks can be used for any prediction problem. We now explore the use of an inference network to approximate test-time inference for a trained CRF. The results are shown in Table 6. All results use the same trained CRF energy function (Eq. (12)), trained to minimize log loss using the forward-backward algorithm for exact inference during training. The first row shows accuracy and speed when using Viterbi for test-time inference, which is the same setting as the “CRF” row in Table 4. Subsequent rows show results when training inference networks to mimic Viterbi with various stabilization terms. When training these inference networks, we train them on the training set and tune based on early stopping on the validation set. The energy stays fixed while inference networks are trained.
264
+
265
+ When using either entropy or cross entropy, our inference networks outperform Viterbi while doubling its speed. When using the squared $L _ { 2 }$ distance term (which regularizes the inference network toward the pretrained BLSTM), the accuracy reduces to be closer to that of the BLSTM, which reaches $8 8 . 6 \%$ on validation (see Table 4). When using no stabilization terms for the inference network, learning fails, reaching $1 3 . 7 \%$ on the development set, showing the importance of using some stabilization term while training the inference network.
266
+
267
+ These results show promise for training inference networks to speed up combinatorial algorithms for structured prediction and other domains.
268
+
269
+ # 8 CONCLUSIONS AND FUTURE WORK
270
+
271
+ We presented ways to jointly train structured energy functions and inference networks using largemargin objectives. The energy function captures arbitrary dependencies among the labels, while the inference networks learns to capture the properties of the energy in an efficient manner, yielding fast test-time inference. Future work includes exploring the space of network architectures for inference networks to balance accuracy and efficiency, experimenting with additional global terms in structured energy functions, and exploring richer structured output spaces such as trees and sentences.
272
+
273
+ # ACKNOWLEDGMENTS
274
+
275
+ We thank the anonymous reviewers, David Belanger, Weiran Wang and Zheng Cai. We also thank NVIDIA Corporation for donating GPUs used in this research.
276
+
277
+ # REFERENCES
278
+
279
+ Brandon Amos, Lei Xu, and J. Zico Kolter. Input convex neural networks. In Proc. of ICML, 2017.
280
+
281
+ Jimmy Ba and Rich Caruana. Do deep nets really need to be deep? In Advances in NIPS, 2014.
282
+
283
+ David Belanger and Andrew McCallum. Structured prediction energy networks. In Proc. of ICML, 2016.
284
+
285
+ David Belanger, Bishan Yang, and Andrew McCallum. End-to-end learning for structured prediction energy networks. In Proc. of ICML, 2017.
286
+
287
+ Kai-Wei Chang, Shyam Upadhyay, Gourab Kundu, and Dan Roth. Structural learning with amortized inference. In Proc. of AAAI, 2015.
288
+
289
+ Michael Collins. Discriminative training methods for hidden Markov models: Theory and experiments with perceptron algorithms. In Proc. of EMNLP, 2002.
290
+
291
+ Zihang Dai, Amjad Almahairi, Bachman Philip, Eduard Hovy, and Aaron Courville. Calibrating energy-based generative adversarial networks. In Proc. of ICLR, 2017.
292
+
293
+ Justin Domke. Generic methods for optimization-based modeling. In Proc. of AISTATS, 2012.
294
+
295
+ Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge. A neural algorithm of artistic style. CoRR, abs/1508.06576, 2015.
296
+
297
+ Krzysztof J. Geras, Abdel rahman Mohamed, Rich Caruana, Gregor Urban, Shengjie Wang, Ozlem Aslan, Matthai Philipose, Matthew Richardson, and Charles Sutton. Blending LSTMs into CNNs. In Proc. of ICLR (workshop track), 2016.
298
+
299
+ Samuel Gershman and Noah Goodman. Amortized inference in probabilistic reasoning. In Proc. of the Cognitive Science Society, 2014.
300
+
301
+ Kevin Gimpel, Nathan Schneider, Brendan O’Connor, Dipanjan Das, Daniel Mills, Jacob Eisenstein, Michael Heilman, Dani Yogatama, Jeffrey Flanigan, and Noah A. Smith. Part-of-speech tagging for Twitter: annotation, features, and experiments. In Proc. of ACL, 2011.
302
+
303
+ Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in NIPS, 2014.
304
+
305
+ Kartik Goyal, Graham Neubig, Chris Dyer, and Taylor Berg-Kirkpatrick. A continuous relaxation of beam search for end-to-end training of neural sequence models. In Proc. of AAAI, 2018.
306
+
307
+ Geoffrey Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. In NIPS Deep Learning Workshop, 2015.
308
+
309
+ Cong Duy Vu Hoang, Gholamreza Haffari, and Trevor Cohn. Towards decoding as continuous optimisation in neural machine translation. In Proc. of EMNLP, 2017.
310
+
311
+ Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Computation, 1997.
312
+
313
+ Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In Proc. of ECCV, 2016.
314
+
315
+ Yoon Kim and Alexander M. Rush. Sequence-level knowledge distillation. In Proc. of EMNLP, 2016.
316
+
317
+ Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. CoRR, abs/1412.6980, 2014.
318
+
319
+ Diederik Kingma and Max Welling. Auto-encoding variational Bayes. CoRR, abs/1312.6114, 2013.
320
+
321
+ Daphne Koller and Nir Friedman. Probabilistic Graphical Models: Principles and Techniques. 2009.
322
+
323
+ Philipp Krähenbühl and Vladlen Koltun. Efficient inference in fully connected CRFs with Gaussian edge potentials. In Advances in NIPS, 2011.
324
+
325
+ Adhiguna Kuncoro, Miguel Ballesteros, Lingpeng Kong, Chris Dyer, and Noah A. Smith. Distilling an ensemble of greedy dependency parsers into one MST parser. In Proc. of EMNLP, 2016.
326
+
327
+ John D. Lafferty, Andrew McCallum, and Fernando C. N. Pereira. Conditional random fields: Probabilistic models for segmenting and labeling sequence data. In Proc. of ICML, 2001.
328
+
329
+ Yann LeCun, Sumit Chopra, Raia Hadsell, Marc’Aurelio Ranzato, and Fu-Jie Huang. A tutorial on energy-based learning. In Predicting Structured Data. MIT Press, 2006.
330
+
331
+ Chuan Li and Michael Wand. Precomputed real-time texture synthesis with Markovian generative adversarial networks. CoRR, abs/1604.04382, 2016.
332
+
333
+ Xuezhe Ma and Eduard Hovy. End-to-end sequence labeling via bi-directional LSTM-CNNs-CRF. In Proc. of ACL, 2016.
334
+
335
+ André F. T. Martins and Julia Kreutzer. Learning what’s easy: Fully differentiable neural easy-first taggers. In Proc. of EMNLP, 2017.
336
+
337
+ Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. Distributed representations of words and phrases and their compositionality. In Advances in NIPS, 2013.
338
+
339
+ Alexander Mordvintsev, Christopher Olah, and Mike Tyka. DeepDream-a code example for visualizing neural networks. Google Research, 2015.
340
+
341
+ Olutobi Owoputi, Brendan O’Connor, Chris Dyer, Kevin Gimpel, Nathan Schneider, and Noah A. Smith. Improved part-of-speech tagging for online conversational text with word clusters. In Proc. of NAACL, 2013.
342
+
343
+ Brooks Paige and Frank Wood. Inference networks for sequential Monte Carlo in graphical models. In Proc. of ICML, 2016.
344
+
345
+ Jeffrey Pennington, Richard Socher, and Christopher D. Manning. GloVe: Global vectors for word representation. In Proc. of EMNLP, 2014.
346
+
347
+ Gabriel Pereyra, George Tucker, Jan Chorowski, Lukasz Kaiser, and Geoffrey E. Hinton. Regularizing neural networks by penalizing confident output distributions. CoRR, 2017.
348
+
349
+ Lev Ratinov and Dan Roth. Design challenges and misconceptions in named entity recognition. In Proc. of CoNLL, 2009.
350
+
351
+ Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, Xi Chen, and Xi Chen. Improved techniques for training GANs. In Advances in NIPS, 2016.
352
+
353
+ Vivek Srikumar, Gourab Kundu, and Dan Roth. On amortizing inference cost for structured prediction. In Proc. of EMNLP, 2012.
354
+
355
+ Ben Taskar, Carlos Guestrin, and Daphne Koller. Max-margin Markov networks. In Advances in NIPS, 2004.
356
+
357
+ Erik F. Tjong Kim Sang and Fien De Meulder. Introduction to the CoNLL-2003 shared task: Language-independent named entity recognition. In Proc. of CONLL, 2003.
358
+
359
+ Ioannis Tsochantaridis, Thorsten Joachims, Thomas Hofmann, and Yasemin Altun. Large margin methods for structured and interdependent output variables. JMLR, 2005.
360
+
361
+ Lifu Tu, Kevin Gimpel, and Karen Livescu. Learning to embed words in context for syntactic tasks. In Proc. of RepL4NLP, 2017.
362
+
363
+ Gregor Urban, Krzysztof J. Geras, Samira Ebrahimi Kahou, Ozlem Aslan, Shengjie Wang, Rich Caruana, Abdel-rahman Mohamed, Matthai Philipose, and Matthew Richardson. Do deep convolutional nets really need to be deep? arXiv preprint arXiv:1603.05691, 2016.
364
+
365
+ Shenlong Wang, Sanja Fidler, and Raquel Urtasun. Proximal deep structured models. In Advances in NIPS, 2016.
366
+
367
+ Sam Wiseman and Alexander M. Rush. Sequence-to-sequence learning as beam-search optimization. In Proc. of EMNLP, 2016.
368
+
369
+ Junbo Jake Zhao, Michaël Mathieu, and Yann LeCun. Energy-based generative adversarial network. CoRR, 2016.
370
+
371
+ Table 7: Statistics of the multi-label classification datasets.
372
+
373
+ <table><tr><td></td><td>#labels</td><td># features</td><td>#train</td><td>#dev</td><td>#test</td></tr><tr><td>Bibtex</td><td>159</td><td>1836</td><td>4836</td><td>-</td><td>2515</td></tr><tr><td>Bookmarks</td><td>208</td><td>2151</td><td>48000</td><td>12000</td><td>27856</td></tr><tr><td>Delicious</td><td>982</td><td>501</td><td>12896</td><td>-</td><td>3185</td></tr></table>
374
+
375
+ Table 8: Development F1 for Bookmarks when comparing hinge losses for SPEN (InfNet) and whether to retune the inference network.
376
+
377
+ <table><tr><td>hinge loss</td><td>-retuning</td><td>+retuning</td></tr><tr><td>margin rescaling</td><td>38.51</td><td>38.68</td></tr><tr><td>slack rescaling</td><td>38.57</td><td>38.62</td></tr><tr><td>perceptron (MR,△= 0)</td><td>38.55</td><td>38.70</td></tr><tr><td>contrastive (△= 1)</td><td>38.80</td><td>38.88</td></tr></table>
378
+
379
+ # 9 APPENDIX
380
+
381
+ # 9.1 MULTI-LABEL CLASSIFICATION
382
+
383
+ Table 7 shows dataset statistics for the multi-label classification datasets.
384
+
385
+ Hyperparameter Tuning. We tune $\lambda$ (the $L _ { 2 }$ regularization strength for $\Theta$ ) over the set $\{ 0 . 0 1 , 0 . 0 0 1 , 0 . 0 0 0 1 \}$ . The classification threshold $\tau$ is chosen from $[ 0 , 0 . 0 1 , 0 . 0 2 , 0 . 0 3 , 0 . 0 4 , 0 . 0 5 , 0 . 1 , 0 . 1 5 , 0 . 2 , 0 . 2 5 ,$ 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75] as also done by Belanger & McCallum (2016). We tune the coefficients for the three stabilization terms for the inference network objective from Section 5 over the follow ranges: $L _ { 2 }$ regularization $( \lambda _ { 1 } ~ \in ~ \{ 0 . 0 1 , 0 . 0 0 1 , 0 . 0 0 0 1 \} )$ ), entropy regularization $\mathbf { \lambda } ) _ { 2 } ~ = ~ 1 )$ , and regularization toward the pretrained feature network $( \dot { \lambda } _ { 4 } \in \{ 0 , 1 , 1 0 \} )$ ).
386
+
387
+ Comparison of Loss Functions and Impact of Inference Network Retuning. Table 8 shows results comparing the four loss functions from Section 4.2 on the development set for Bookmarks, the largest of the three datasets. We find performance to be highly similar across the losses, with the contrastive loss appearing slightly better than the others.
388
+
389
+ After training, we “retune” the inference network as specified by Eq. (5) on the development set for 20 epochs using a smaller learning rate of 0.00001. Table 8 shows slightly higher F1 for all losses with retuning. We were surprised to see that the final cost-augmented inference network performs well as a test-time inference network. This suggests that by the end of training, the cost-augmented network may be approaching the argmin and that there may not be much need for retuning.
390
+
391
+ When using $\triangle = 0$ or 1, retuning leads to the same small gain as when using the margin-rescaled or slack-rescaled losses. Here the gain is presumably from adjusting the inference network for other inputs rather than from converting it from a cost-augmented to a test-time inference network.
392
+
393
+ # 9.2 TWITTER POS TAGGING
394
+
395
+ # 9.2.1 HYPERPARAMETER TUNING
396
+
397
+ When training inference networks and SPENs for Twitter POS tagging, we use the following hyperparameter tuning. We tune the inference network learning rate $( \{ 0 . 1 , 0 . 0 5 , 0 . 0 2 , 0 . 0 1 , 0 . 0 0 5 , 0 . 0 0 1 \} )$ ), $L _ { 2 }$ regularization $( \lambda _ { 1 } \in \{ 0 , 1 { \mathrm { e } } - 3 , 1 { \mathrm { e } } - 4 , 1 { \mathrm { e } } - 5 , 1 { \mathrm { e } } - { \bar { 6 } } , 1 { \mathrm { e } } - { \bar { 7 } } \} )$ ), the entropy regularization term $( \lambda _ { 2 } \in \{ 0 . 1 , 0 . 5 , 1 , 2 , 5 , 1 0 \} )$ , the cross entropy regularization term $( \lambda _ { 3 } \in \{ 0 . 1 , 0 . 5 , 1 , 2 , 5 , 1 0 \} )$ , and the squared L2 distance $( \bar { \lambda } _ { 4 } \in \{ 0 , 0 . 1 , 0 . 2 , \bar { 0 . 5 } , 1 , 2 , 1 0 \} )$ ). We train the energy functions with Adam with a learning rate of 0.001 and $L _ { 2 }$ regularization $( \lambda _ { 1 } \in \{ 0 , 1 \mathrm { { e } - 3 , 1 \mathrm { { e } - 4 , 1 \mathrm { { e } - 5 } , 1 \mathrm { { e } - 6 } , 1 \mathrm { { e } - 7 } \} ) } }$ .
398
+
399
+ Table 9 compares the use of the cross entropy and entropy stabilization terms when training inference networks for a SPEN with margin-rescaled hinge. Cross entropy works better than entropy in this setting, though retuning permits the latter to bridge the gap more than halfway.
400
+
401
+ Table 9: Comparison of inference network stabilization terms and showing impact of retuning when training SPENs with margin-rescaled hinge (Twitter POS validation accuracies).
402
+
403
+ <table><tr><td></td><td colspan="2">validation accuracy (%)</td></tr><tr><td>inference network stabilization terms</td><td>-retuning</td><td>+retuning</td></tr><tr><td>cross entropy</td><td>89.1</td><td>89.3</td></tr><tr><td>entropy</td><td>84.2</td><td>86.8</td></tr></table>
404
+
405
+ Table 10: Examples of improvements in Twitter POS tagging when using tag language model (TLM). In all of these examples, the predicted tag when using the TLM matches the gold standard.
406
+
407
+ <table><tr><td colspan="2"></td><td colspan="2">predicted tags</td></tr><tr><td>#</td><td>tweet (target word in bold)</td><td>-TLM</td><td>+TLM</td></tr><tr><td>1</td><td>... that&#x27;s a t-17, technically . does that count as top-25 ?</td><td>determiner</td><td>pronoun</td></tr><tr><td>2</td><td>... lol you know im down like 4 flats on a cadillac ... lol...</td><td>adjective</td><td>preposition</td></tr><tr><td>3</td><td>... them who he is : he wants her to like him for his pers..</td><td>preposition</td><td>verb</td></tr><tr><td>4</td><td>I wonder when Nic Cage is going to film &quot; Another Something</td><td>noun</td><td>verb</td></tr><tr><td>5</td><td>Something Las Vegas &quot; . Cut my hair, gag and bore me</td><td>noun</td><td>verb</td></tr><tr><td>6 7</td><td>... they had their fun,we hd ours !;) lmaooo &quot; Logic will get you from A to B . Imagination will take you</td><td>proper noun verb</td><td>verb</td></tr><tr><td></td><td>everywhere .&quot; - Albert Einstein .</td><td></td><td>noun</td></tr><tr><td>8</td><td>lmao I&#x27;m not a sheep who listens to it cos everyone else does ..</td><td>verb</td><td>preposition</td></tr><tr><td>9</td><td>Noo its not cuss you have swag andd you wont look dumb !..</td><td>noun</td><td>coord. conj.</td></tr></table>
408
+
409
+ When training CRFs, we use SGD with momentum. We tune the learning rate (over $\{ 0 . 1 , 0 . 0 5 , 0 . 0 2 , 0 . 0 1 , 0 . 0 0 5 , 0 . 0 0 1 \}$ ) and $L _ { 2 }$ regularization coefficient (over $\{ 0 , 1 \mathrm { e } - 3 , 1 \mathrm { e } - 4 , 1 \mathrm { e } -$ $5 , 1 \mathrm { e } - 6 , 1 \mathrm { e } - 7 \}$ ). For all methods, we use early stopping based on validation accuracy.
410
+
411
+ # 9.2.2 TAG LANGUAGE MODEL DETAILS AND ANALYSIS
412
+
413
+ To obtain training data for training the tag language model, we run the Twitter POS tagger from Owoputi et al. (2013) on a dataset of 303K randomly-sampled English tweets. We train the tag language model on 300K tweets and use the remaining 3K for tuning hyperparameters and early stopping. We train an LSTM language model on the tag sequences using stochastic gradient descent with momentum and early stopping on the validation set. We used a dropout rate of 0.5 for the LSTM hidden layer. We tune the learning rate $( \{ 0 . 1 , 0 . 2 , 0 . 5 , 1 . 0 \} )$ , the number of LSTM layers $( \{ 1 , 2 \} )$ , and the hidden layer size $( \{ 5 0 , 1 0 0 , 2 0 0 \} )$ ).
414
+
415
+ Table 10 shows examples in which our SPEN that includes the TLM appears to be using broader context when making tagging decisions. These are examples from the test set labeled by two models: the SPEN without the TLM (which achieves $8 9 . 6 \%$ accuracy, as shown in Table 5) and the SPEN with the TLM (which reaches $9 0 . 2 \%$ accuracy). In example 1, the token “that” is predicted to be a determiner based on local context, but is correctly labeled a pronoun when using the TLM. This example is difficult because of the noun/verb tag ambiguity of the next word (“count”) and its impact on the tag for “that”. Examples 2 and 3 show two corrections for the token “like”, which is a highly ambiguous word in Twitter POS tagging. The broader context makes it much clearer which tag is intended.
416
+
417
+ The next two examples (4 and 5) are cases of noun/verb ambiguity that are resolvable with larger context. The last four examples show improvements for nonstandard word forms. The shortened form of “had” (example 6) is difficult to tag due to its collision with “HD” (high-definition), but the model with the TLM is able to tag it correctly. In example 7, the ambiguous token “b” is frequently used as a short form of “be” on Twitter, and since it comes after “to” in this context, the verb interpretation is encouraged. However, the broader context makes it clear that it is not a verb and the TLM-enriched model tags it correctly. The words in the last two examples are nonstandard word forms that were not observed in the training data, which is likely the reason for their erroneous predictions. When using the TLM, we can better handle these rare forms based on the broader context.
418
+
419
+ Table 11: Named entity recognition F1 of BLSTM, CRF, and SPEN (InfNet) with slack-rescaled hinge where inference networks used cross entropy stabilization term. Though slowest to train, the SPEN matches the test-time speed of the BLSTM while improving F1 by 2 points, though it lags behind the CRF.
420
+
421
+ <table><tr><td></td><td>validation F1</td><td>test F1</td><td>training speed (examples/sec)</td><td>testing speed (examples/sec)</td></tr><tr><td>BLSTM</td><td>88.30</td><td>83.02</td><td>385</td><td>1042</td></tr><tr><td>CRF</td><td>91.31</td><td>87.15</td><td>222</td><td>454</td></tr><tr><td>SPEN (InfNet)</td><td>89.98</td><td>85.06</td><td>118</td><td>1025</td></tr></table>
422
+
423
+ # 9.2.3 LEARNED PAIRWISE POTENTIAL MATRIX
424
+
425
+ ![](images/28cdae28d8e710e4818ba3c338be0b1442bf330857c6db3da42ee019ad439d1e.jpg)
426
+ Figure 1: Learned pairwise potential matrix for Twitter POS tagging.
427
+
428
+ Figure 1 shows the learned pairwise potential matrix $W$ in Twitter POS tagging. We can see strong correlations between labels in neighborhoods. For example, an adjective (A) is more likely to be followed by a noun (N) than a verb (V) (see row labeled “A” in the figure).
429
+
430
+ # 9.3 NAMED ENTITY RECOGNITION
431
+
432
+ For named entity recognition (NER), we perform experiments on the English data from the CoNLL 2003 shared task (Tjong Kim Sang & De Meulder, 2003). This task contains sentences annotated with named entities and their types, containing 14987 training sentences, 3466 in the development set, and 3684 in the test set. There are four named entity types: PERSON, LOCATION, ORGANIZATION, and MISC. We use the BIOES tagging scheme instead of the original BIO2, following prior work (Ratinov & Roth, 2009; Ma & Hovy, 2016). There are $L = 1 7$ classes. We use 100-dimensional pretrained GloVe (Pennington et al., 2014) embeddings trained on 6 billion words from Wikipedia and web text, which work better than other pretrained embeddings (Ma & Hovy, 2016).
433
+
434
+ Results are shown in Table 11. We see a large 4-point gap between the BLSTM and CRF, suggesting the importance of structured information for this problem. Though the SPEN still lags behind the CRF in F1, it matches the test-time speed of the BLSTM while improving F1 by 2 points.
parse/train/H1WgVz-AZ/H1WgVz-AZ_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/H1WgVz-AZ/H1WgVz-AZ_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/H1WgVz-AZ/H1WgVz-AZ_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/HkxJpnVtPr/HkxJpnVtPr.md ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/HkxJpnVtPr/HkxJpnVtPr_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/HkxJpnVtPr/HkxJpnVtPr_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/HkxJpnVtPr/HkxJpnVtPr_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/JXAyJeYqUkZ/JXAyJeYqUkZ.md ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CoAtNet: Marrying Convolution and Attention for All Data Sizes
2
+
3
+ Zihang Dai, Hanxiao Liu, Quoc V. Le, Mingxing Tan Google Research, Brain Team {zihangd,hanxiaol,qvl,tanmingxing}@google.com
4
+
5
+ # Abstract
6
+
7
+ Transformers have attracted increasing interests in computer vision, but they still fall behind state-of-the-art convolutional networks. In this work, we show that while Transformers tend to have larger model capacity, their generalization can be worse than convolutional networks due to the lack of the right inductive bias. To effectively combine the strengths from both architectures, we present CoAtNets (pronounced “coat” nets), a family of hybrid models built from two key insights: (1) depthwise Convolution and self-Attention can be naturally unified via simple relative attention; (2) vertically stacking convolution layers and attention layers in a principled way is surprisingly effective in improving generalization, capacity and efficiency. Experiments show that our CoAtNets achieve state-of-the-art performance under different resource constraints across various datasets: Without extra data, CoAtNet achieves $8 6 . 0 \%$ ImageNet top-1 accuracy; When pre-trained with 13M images from ImageNet-21K, our CoAtNet achieves $8 8 . 5 6 \%$ top-1 accuracy, matching ViT-huge pre-trained with 300M images from JFT-300M while using $2 3 \mathrm { x }$ less data; Notably, when we further scale up CoAtNet with JFT-3B, it achieves $9 0 . 8 8 \%$ top-1 accuracy on ImageNet, establishing a new state-of-the-art result.
8
+
9
+ # 1 Introduction
10
+
11
+ Since the breakthrough of AlexNet [1], Convolutional Neural Networks (ConvNets) have been the dominating model architecture for computer vision [2, 3, 4, 5]. Meanwhile, with the success of self-attention models like Transformers [6] in natural language processing [7, 8], many previous works have attempted to bring in the power of attention into computer vision [9, 10, 11, 12]. More recently, Vision Transformer (ViT) [13] has shown that with almost1 only vanilla Transformer layers, one could obtain reasonable performance on ImageNet-1K [14] alone. More importantly, when pre-trained on large-scale weakly labeled JFT-300M dataset [15], ViT achieves comparable results to state-of-the-art (SOTA) ConvNets, indicating that Transformer models potentially have higher capacity at scale than ConvNets.
12
+
13
+ While ViT has shown impressive results with enormous JFT 300M training images, its performance still falls behind ConvNets in the low data regime. For example, without extra JFT-300M pre-training, the ImageNet accuracy of ViT is still significantly lower than ConvNets with comparable model size [5] (see Table 13). Subsequent works use special regularization and stronger data augmentation to improve the vanilla ViT [16, 17, 18], yet none of these ViT variants could outperform the SOTA convolution-only models on ImageNet classification given the same amount of data and computation [19, 20]. This suggests that vanilla Transformer layers may lack certain desirable inductive biases possessed by ConvNets, and thus require significant amount of data and computational resource to compensate. Not surprisingly, many recent works have been trying to incorporate the inductive biases of ConvNets into Transformer models, by imposing local receptive fields for attention layers [21, 22] or augmenting the attention and FFN layers with implicit or explicit convolutional operations [23, 24, 25]. However, these approaches are either ad-hoc or focused on injecting a particular property, lacking a systematic understanding of the respective roles of convolution and attention when combined.
14
+
15
+ In this work, we systematically study the problem of hybridizing convolution and attention from two fundamental aspects in machine learning – generalization and model capacity. Our study shows that convolutional layers tend to have better generalization with faster converging speed thanks to their strong prior of inductive bias, while attention layers have higher model capacity that can benefit from larger datasets. Combining convolutional and attention layers can achieve better generalization and capacity; however, a key challenge here is how to effectively combine them to achieve better trade-offs between accuracy and efficiency. In this paper, we investigate two key insights: First, we observe that the commonly used depthwise convolution can be effectively merged into attention layers with simple relative attention; Second, simply stacking convolutional and attention layers, in a proper way, could be surprisingly effective to achieve better generalization and capacity. Based on these insights, we propose a simple yet effective network architecture named CoAtNet, which enjoys the strengths from both ConvNets and Transformers.
16
+
17
+ Our CoAtNet achieves SOTA performances under comparable resource constraints across different data sizes. Specifically, under the low-data regime, CoAtNet inherits the great generalization property of ConvNets thanks to the favorable inductive biases. Moreover, given abundant data, CoAtNet not only enjoys the superior scalability of Transformer models, but also achieves faster convergence and thus improved efficiency. When only ImageNet-1K is used for training, CoAtNet achieves $8 6 . 0 \%$ top-1 accuracy, matching the prior art NFNet [20] under similar computation resource and training conditions. Further, when pre-trained on ImageNet-21K with about 10M images, CoAtNet reaches $8 8 . 5 6 \%$ top-1 accuracy when finetuned on ImageNet-1K, matching the ViT-Huge pre-trained on JFT-300M, a $2 3 \times$ larger dataset. Finally, when JFT-3B is used for pre-training, CoAtNet exhibits better efficiency compared to ViT, and pushes the ImageNet-1K top-1 accuracy to $9 0 . 8 8 \%$ while using $1 . 5 \mathrm { x }$ less computation of the prior art set by ViT-G/14 [26].
18
+
19
+ # 2 Model
20
+
21
+ In the section, we focus on the question of how to “optimally” combine the convolution and transformer. Roughly speaking, we decompose the question into two parts:
22
+
23
+ 1. How to combine the convolution and self-attention within one basic computational block? 2. How to vertically stack different types of computational blocks together to form a complete network?
24
+
25
+ The rationale of the decomposition will become clearer as we gradually reveal our design choices.
26
+
27
+ # 2.1 Merging Convolution and Self-Attention
28
+
29
+ For convolution, we mainly focus on the MBConv block [27] which employs depthwise convolution [28] to capture the spatial interaction. A key reason of this choice is that both the FFN module in Transformer and MBConv employ the design of “inverted bottleneck”, which first expands the channel size of the input by $4 \mathbf { x }$ and later project the the $4 \mathbf { x }$ -wide hidden state back to the original channel size to enable residual connection.
30
+
31
+ Besides the similarity of inverted bottleneck, we also notice that both depthwise convolution and self-attention can be expressed as a per-dimension weighted sum of values in a pre-defined receptive field. Specifically, convolution relies on a fixed kernel to gather information from a local receptive field
32
+
33
+ $$
34
+ y _ { i } = \sum _ { j \in \mathcal { L } ( i ) } w _ { i - j } \odot x _ { j } \quad \mathrm { ( d e p t h w i s e c o n v o l u t i o n ) } ,
35
+ $$
36
+
37
+ where $x _ { i } , y _ { i } \in \mathbb { R } ^ { D }$ are the input and output at position $i$ respectively, and $\mathcal { L } ( i )$ denotes a local neighborhood of $i$ , e.g., a 3x3 grid centered at $i$ in image processing.
38
+
39
+ In comparison, self-attention allows the receptive field to be the entire spatial locations and computes the weights based on the re-normalized pairwise similarity between the pair $( x _ { i } , x _ { j } )$ : 2
40
+
41
+ $$
42
+ y _ { i } = \sum _ { j \in \mathcal { G } } \underbrace { \frac { \exp { \left( x _ { i } ^ { \top } x _ { j } \right) } } { \sum _ { k \in \mathcal { G } } \exp { \left( x _ { i } ^ { \top } x _ { k } \right) } } } _ { A _ { i , j } } x _ { j } \quad \mathrm { ( s e l f - a t t e n t i o n ) } ,
43
+ $$
44
+
45
+ where $\mathcal { G }$ indicates the global spatial space. Before getting into the question of how to best combine them, it is worthwhile to compare their relative strengths and weaknesses, which helps to figure out the good properties we hope to retain.
46
+
47
+ • First of all, the depthwise convolution kernel $w _ { i - j }$ is an input-independent parameter of static value, while the attention weight $A _ { i , j }$ dynamically depends on the representation of the input. Hence, it is much easier for the self-attention to capture complicated relational interactions between different spatial positions, a property that we desire most when processing high-level concepts. However, the flexibility comes with a risk of easier overfitting, especially when data is limited. • Secondly, notice that given any position pair $( i , j )$ , the corresponding convolution weight $w _ { i - j }$ only cares about the relative shift between them, i.e. $i - j$ , rather than the specific values of $i$ or $j$ . This property is often referred to translation equivalence, which has been found to improve generalization under datasets of limited size [29]. Due to the usage of absolution positional embeddings, standard Transformer (ViT) lacks this property. This partially explains why ConvNets are usually better than Transformers when the dataset is not enormously large. • Finally, the size of the receptive field is one of the most crucial differences between self-attention and convolution. Generally speaking, a larger receptive field provides more contextual information, which could lead to higher model capacity. Hence, the global receptive field has been a key motivation to employ self-attention in vision. However, a large receptive field requires significantly more computation. In the case of global attention, the complexity is quadratic w.r.t. spatial size, which has been a fundamental trade-off in applying self-attention models.
48
+
49
+ Table 1: Desirable properties found in convolution or self-attention.
50
+
51
+ <table><tr><td>Properties</td><td>Convolution</td><td>Self-Attention</td></tr><tr><td>Translation Equivariance</td><td>√</td><td></td></tr><tr><td>Input-adaptive Weighting</td><td></td><td>√</td></tr><tr><td>Global Receptive Field</td><td></td><td></td></tr></table>
52
+
53
+ Given the comparison above, an ideal model should be able to combine the 3 desirable properties in Table 1. With the similar form of depthwise convolution in Eqn. (1) and self-attention in Eqn. (2), a straightforward idea that could achieve this is simply to sum a global static convolution kernel with the adaptive attention matrix, either after or before the Softmax normalization, i.e.,
54
+
55
+ $$
56
+ y _ { i } ^ { \mathrm { p o s t } } = \sum _ { j \in \mathcal { G } } \left( \frac { \exp \left( x _ { i } ^ { \top } x _ { j } \right) } { \sum _ { k \in \mathcal { G } } \exp \left( x _ { i } ^ { \top } x _ { k } \right) } + w _ { i - j } \right) x _ { j } \ \mathrm { ~ o r ~ } \ y _ { i } ^ { \mathrm { p e } } = \sum _ { j \in \mathcal { G } } \frac { \exp \left( x _ { i } ^ { \top } x _ { j } + w _ { i - j } \right) } { \sum _ { k \in \mathcal { G } } \exp \left( x _ { i } ^ { \top } x _ { k } + w _ { i - k } \right) } x _ { j } .
57
+ $$
58
+
59
+ Interestingly, while the idea seems overly simplified, the pre-normalization version $y ^ { \mathrm { p r e } }$ corresponds to a particular variant of relative self-attention [30, 31]. In this case, the attention weight $A _ { i , j }$ is decided jointly by the $w _ { i - j }$ of translation equivariance and the input-adaptive $x _ { i } ^ { \top } x _ { j }$ , which can enjoy both effects depending on their relative magnitudes. Importantly, note that in order to enable the global convolution kernel without blowing up the number of parameters, we have reloaded the notation of $w _ { i - j }$ as a scalar (i.e., $w \in \mathbb { R } ^ { O ( | \mathcal { G } | ) }$ ) rather than a vector in Eqn. (1). Another advantage of the scalar formulation of $w$ is that retrieving $w _ { i - j }$ for all $( i , j )$ is clearly subsumed by computing the pairwise dot-product attention, hence resulting in minimum additional cost (see Appendix A.1). Given the benefits, we will use the Transformer block with the pre-normalization relative attention variant in Eqn. (3) as the key component of the proposed CoAtNet model.
60
+
61
+ # 2.2 Vertical Layout Design
62
+
63
+ After figuring out a neat way to combine convolution and attention, we next consider how to utilize it to stack an entire network.
64
+
65
+ As we have discuss above, the global context has a quadratic complexity w.r.t. the spatial size. Hence, if we directly apply the relative attention in Eqn. (3) to the raw image input, the computation will be excessively slow due to the large number of pixels in any image of common sizes. Hence, to construct a network that is feasible in practice, we have mainly three options:
66
+
67
+ (A) Perform some down-sampling to reduce the spatial size and employ the global relative attention after the feature map reaches manageable level.
68
+ (B) Enforce local attention, which restricts the global receptive field $\mathcal { G }$ in attention to a local field $\mathcal { L }$ just like in convolution [22, 21].
69
+ (C) Replace the quadratic Softmax attention with certain linear attention variant which only has a linear complexity w.r.t. the spatial size [12, 32, 33].
70
+
71
+ We briefly experimented with option (C) without getting a reasonably good result. For option (B), we found that implementing local attention involves many non-trivial shape formatting operations that requires intensive memory access. On our accelerator of choice (TPU), such operation turns out to be extremely slow [34], which not only defeats the original purpose of speeding up global attention, but also hurts the model capacity. Hence, as some recent work has studied this variant [22, 21], we will focus on option (A) and compare our results with theirs in our empirical study (Section 4).
72
+
73
+ For option (A), the down-sampling can be achieved by either (1) a convolution stem with aggressive stride (e.g., stride 16x16) as in ViT or (2) a multi-stage network with gradual pooling as in ConvNets. With these choices, we derive a search space of 5 variants and compare them in controlled experiments.
74
+
75
+ • When the ViT Stem is used, we directly stack $L$ Transformer blocks with relative attention, which we denote as $\mathrm { V I T } _ { \mathrm { R E L } }$ .
76
+ • When the multi-stage layout is used, we mimic ConvNets to construct a network of 5 stages (S0, S1, S2, S3 & S4), with spatial resolution gradually decreased from S0 to S4. At the beginning of each stage, we always reduce the spatial size by $2 \mathbf { x }$ and increase the number of channels (see Appendix A.1 for the detailed down-sampling implementation). The first stage S0 is a simple 2-layer convolutional Stem and S1 always employs MBConv blocks with squeeze-excitation (SE), as the spatial size is too large for global attention. Starting from S2 through S4, we consider either the MBConv or the Transformer block, with a constraint that convolution stages must appear before Transformer stages. The constraint is based on the prior that convolution is better at processing local patterns that are more common in early stages. This leads to 4 variants with increasingly more Transformer stages, C-C-C-C, C-C-C-T, C-C-T-T and C-T-T-T, where C and T denote Convolution and Transformer respectively.
77
+
78
+ To systematically study the design choices, we consider two fundamental aspects generalization capability and model capacity: For generalization, we are interested in the gap between the training loss and the evaluation accuracy. If two models have the same training loss, then the model with higher evaluation accuracy has better generalization capability, since it can generalize better to unseen evaluation dataset. Generalization capability is particularly important to data efficiency when training data size is limited. For model capacity, we measure the ability to fit large training datasets. When training data is abundant and overfitting is not an issue, the model with higher capacity will achieve better final performance after reasonable training steps. Note that, since simply increasing the model size can lead to higher model capacity, to perform a meaningful comparison, we make sure the model sizes of the 5 variants are comparable.
79
+
80
+ To compare the generalization and model capacity, we train different variants of hybrid models on ImageNet-1K (1.3M) and JFT $\left( > 3 0 0 \mathbf { M } \right)$ dataset for 300 and 3 epochs respectively, both without any regularization or augmentation. The training loss and evaluation accuracy on both datasets are summarized in Figure 1.
81
+
82
+ • From the ImageNet-1K results, a key observation is that, in terms of generalization capability (i.e., gap between train and evaluation metrics), we have
83
+
84
+ $$
85
+ \mathrm { C \mathrm { - } C \mathrm { - } C \mathrm { - } C \approx C \mathrm { - } C \mathrm { - } C \mathrm { - } T \ge C \mathrm { - } C \mathrm { - } T \mathrm { - } T > C \mathrm { - } T \mathrm { - } T \mathrm { - } T \gg V \mathrm { I } \mathrm { T } _ { \mathrm { R E L } } . }
86
+ $$
87
+
88
+ ![](images/8e4cc944c4e098b4c2962d8c1e585910035ad5a220c25df539ba8f057d9c47df.jpg)
89
+ Figure 1: Comparison for model generalization and capacity under different data size. For fair comparison, all models have similar parameter size and computational cost.
90
+
91
+ Particularly, $\mathrm { V I T } _ { \mathrm { R E L } }$ is significantly worse than variants by a large margin, which we conjecture is related to the lack of proper low-level information processing in its aggressive down-sampling Stem. Among the multi-stage variants, the overall trend is that the more convolution stages the model has, the smaller the generalization gap is.
92
+
93
+ • As for model capacity, from the JFT comparison, both the train and evaluation metrics at the end of the training suggest the following ranking:
94
+
95
+ $$
96
+ \mathrm { C - C \mathrm { - } T \mathrm { - } T \approx C \mathrm { - } T \mathrm { - } T \mathrm { - } T > V I T _ { R E L } > C \mathrm { - } C \mathrm { - } C \mathrm { - } T > C \mathrm { - } C \mathrm { - } C \mathrm { - } C \mathrm { - } C \mathrm { . } }
97
+ $$
98
+
99
+ Importantly, this suggests that simply having more Transformer blocks does NOT necessarily mean higher capacity for visual processing. On one hand, while initially worse, $\mathrm { V I T } _ { \mathrm { R E L } }$ ultimately catch up with the two variants with more MBConv stages, indicating the capacity advantage of Transformer blocks. On the other hand, both C-C-T-T and C-T-T-T clearly outperforming $\mathrm { V I T } _ { \mathrm { R E L } }$ suggest that the ViT stem with an aggressive stride may have lost too much information and hence limit the model capacity. More interestingly, the fact that C-C-T-T $\approx \mathbf { C }$ -T-T-T indicates the for processing low-level information, static local operations like convolution could be as capable as adaptive global attention mechanism, while saving computation and memory usage substantially.
100
+
101
+ Finally, to decide between C-C-T-T and C-T-T-T, we conduct another transferability test3 — we finetune the two JFT pre-trained models above on ImageNet-1K for 30 epochs and compare their transfer performances. From Table 2, it turns out that C-C-T-T achieves a clearly better transfer accuracy than C-T-T-T, despite the same pre-training performance.
102
+
103
+ Table 2: Transferability test results.
104
+
105
+ <table><tr><td>Metric</td><td>C-C-T-T</td><td>C-T-T-T</td></tr><tr><td>Pre-training Precision@1 (JFT)</td><td>34.40</td><td>34.36</td></tr><tr><td>Transfer Accuracy 224x224</td><td>82.39</td><td>81.78</td></tr><tr><td>Transfer Accuracy 384x384</td><td>84.23</td><td>84.02</td></tr></table>
106
+
107
+ Taking generalization, model capacity, transferability and efficiency into consideration, we adapt the C-C-T-T multi-stage layout for CoAtNet. More model details are included in Appendix A.1.
108
+
109
+ # 3 Related Work
110
+
111
+ Convolutional network building blocks. Convolutional Networks (ConvNets) have been the dominating neural architectures for many computer vision tasks. Traditionally, regular convolutions, such as ResNet blocks [3], are popular in large-scale ConvNets; in contrast, depthwise convolutions [28] are popular in mobile platforms due to its lower computational cost and smaller parameter size [27]. Recent works show that an improved inverted residual bottlenecks (MBConv [27, 35]), which is built upon depthwise convolutions, can achieve both high accuracy and better efficiency [5, 19]. As discussed in Section 2, due to the strong connection between MBConv and Transformer blocks , this paper mostly employs MBConv as convolution building blocks.
112
+
113
+ Self-attention and Transformers. With the key ingredients of self-attention, Transformers have been widely adopted for neural language processing and speech understanding. As an early work, stand-alone self-attention network [34] shows self-attention alone can work well for different vision tasks, though with some practical difficulties. Recently, ViT [13] applies a vanilla Transformer to ImageNet classification, and achieves impressive results after pre-training on a large-scale JFT dataset. However, ViT still largely lags behind state-of-the-art ConvNets when training data is limited. Following that, many recent works have been focused on improving vision Transformers for data efficiency and model efficiency. For a more comprehensive review of vision Transformers, we refer readers to the dedicated surveys [36, 37].
114
+
115
+ Relative attention. Under the general name of relative attention, there have been various variants in literature [30, 38, 39, 34, 40, 31]. Generally speaking, we can separate them into two categories: (a) the input-dependent version where the extra relative attention score is a function of the input states $f ( \bar { x } _ { i } , x _ { j } , \bar { i } - j )$ , and (b) the input-independent version $f ( i - j )$ . The variant in CoAtNet belongs to the input-independent version, and is similar to the one used in T5 [31], but unlike T5, we neither share the relative attention parameters across layers nor use the bucketing mechanism. As a benefit of the input independence, obtaining $f ( i - j )$ for all $( i , j )$ pairs is computationally much cheaper than the input-dependent version on TPU. In addition, at inference time, this only needs to be computed once and cached for future use. A recent work [22] also utilizes such an input-independent parameterization, but it restricts the receptive field to a local window.
116
+
117
+ Combining convolution and self-attention. The idea of combining convolution and self-attention for vision recognition is not new. A common approach is to augment the ConvNet backbone with explicit self-attention or non-local modules [9, 10, 11, 12], or to replace certain convolution layers with standard self-attention [11] or a more flexible mix of linear attention and convolution [41]. While self-attention usually improves the accuracy, they often come with extra computational cost and hence are often regarded as an add-on to the ConvNets, similar to squeeze-and-excitation [42] module. In comparison, after the success of ViT and ResNet-ViT [13], another popular line of research starts with a Transformer backbone and tries to incorporate explicit convolution or some desirable properties of convolution into the Transformer backbone [25, 24, 23, 22, 21, 43, 44].
118
+
119
+ While our work also belongs to this category, we show that our relative attention instantiation is a natural mixture of depthwise convolution and content-based attention with minimum additional cost. More importantly, starting from the perspectives of generalization and model capacity, we take a systematic approach to the vertical layout design and show how and why different network stages prefer different types of layers. Therefore, compared to models that simply use an off-the-shelf ConvNet as the stem layer, such as ResNet-ViT [13], CoAtNet also scales the Convolution stage (S2) when the overall size increases. On the other hand, compared to models employing local attention [22, 21], CoAtNet consistently uses full attention for S3 & S4 to ensure the model capacity, as S3 occupies the majority of the computation and parameters.
120
+
121
+ # 4 Experiments
122
+
123
+ In this section, we compare CoAtNet with previous results under comparable settings. For completeness, all the hyper-parameters not mentioned here are included in Appendix A.2.
124
+
125
+ # 4.1 Experiment Setting
126
+
127
+ CoAtNet model family. To compare with existing models of different sizes, we also design a family of CoAtNet models as summarized in Table 3. Overall, we always double the number of channels from S1 to S4, while ensuring the width of the Stem S0 to be smaller or equal to that of S1. Also, for simplicity, when increasing the depth of the network, we only scale the number of blocks in S2 and S3.
128
+
129
+ Evaluation Protocol. Our experiments focus on image classification. To evaluate the performance of the model across different data sizes, we utilize three datasets of increasingly larger sizes, namely ImageNet-1K (1.28M images), ImageNet-21K (12.7M images) and JFT (300M images). Following previous works, we first pre-train our models on each of the three datasets at resolution 224 for 300, 90 and 14 epochs respectively. Then, we finetune the pre-trained models on ImageNet-1K at the desired resolutions for 30 epochs and obtain the corresponding evaluation accuracy. One exception is the ImageNet-1K performance at resolution 224, which can be directly obtained at the end of pre-training. Note that similar to other models utilizing Transformer blocks, directly evaluating models pre-trained on ImageNet-1K at a larger resolution without finetuning usually leads to performance drop. Hence, finetuning is always employed whenever input resolution changes.
130
+
131
+ Table 3: L denotes the number of blocks and D denotes the hidden dimension (#channels). For all Conv and MBConv blocks, we always use the kernel size 3. For all Transformer blocks, we set the size of each attention head to 32, following [22]. The expansion rate for the inverted bottleneck is always 4 and the expansion (shrink) rate for the SE is always 0.25.
132
+
133
+ <table><tr><td> Stages</td><td>Size</td><td>CoAtNet-0</td><td></td><td>CoAtNet-1</td><td>CoAtNet-2</td><td></td><td>CoAtNet-3</td><td>CoAtNet-4</td></tr><tr><td>S0-Conv</td><td>1/2</td><td>L=2 D=64</td><td>L=2</td><td>D=64</td><td>L=2</td><td>D=128 L=2</td><td>D=192</td><td>L=2 D=192</td></tr><tr><td>S1-MbConv</td><td>1/4</td><td>L=2 D=96</td><td>L=2</td><td>D=96</td><td>L=2 D=128</td><td>L=2</td><td>D=192</td><td>L=2 D=192</td></tr><tr><td>S2-MBConv</td><td>1/8</td><td>L=3 D=192</td><td>L=6</td><td>D=192</td><td>L=6 D=256</td><td>L=6</td><td>D=384</td><td>L=12 D=384</td></tr><tr><td>S3-TFMRel</td><td>1/16</td><td>L=5 D=384</td><td>L=14</td><td>D=384</td><td>L=14 D=512</td><td>L=14</td><td>D=768</td><td>L=28 D=768</td></tr><tr><td>S4-TFMRel</td><td>1/32</td><td>L=2 D=768</td><td>L=2</td><td>D=768</td><td>L=2 D=1024</td><td>L=2</td><td>D=1536</td><td>L=2 D=1536</td></tr></table>
134
+
135
+ Data Augmentation & Regularization. In this work, we only consider two widely used data augmentations, namely RandAugment [45] and MixUp [46], and three common techniques, including stochastic depth [47], label smoothing [48] and weight decay [49], to regularize the model. Intuitively, the specific hyper-parameters of the augmentation and regularization methods depend on model size and data scale, where strong regularization is usually applied for larger models and smaller dataset.
136
+
137
+ Under the general principle, a complication under the current paradigm is how to adjust the regularization for pre-training and finetuning as data size can change. Specifically, we have an interesting observation that if a certain type of augmentation is entirely disabled during pre-training, simply turning it on during fine-tuning would most likely harm the performance rather than improving. We conjecture this could be related to data distribution shift. As a result, for certain runs of the proposed model, we deliberately apply RandAugment and stochastic depth of a small degree when pre-training on the two larger datasets, ImageNet21-K and JFT. Although such regularization can harm the pre-training metrics, this allows more versatile regularization and augmentation during finetuning, leading to improved down-stream performances.
138
+
139
+ # 4.2 Main Results
140
+
141
+ ![](images/cf1567b93b834a38bb5d149ee37f969799ca7bcd6b3f63af756a7cd673e8c469.jpg)
142
+ Figure 2: Accuracy-to-FLOPs scaling curve under ImageNet-1K only setting at $2 2 4 \mathbf { x } 2 2 4$ .
143
+
144
+ ![](images/f8c09d4a039db4e8c22000a3a3a66bae5de7e541a68ec3f2c6a6234546bf4ac2.jpg)
145
+ Figure 3: Accuracy-to-Params scaling curve under ImageNet- $2 1 \mathrm { K } \Rightarrow$ ImageNet-1K setting.
146
+
147
+ ImageNet-1K The experiment results with only the ImageNet-1K dataset are shown in Table 4. Under similar conditions, the proposed CoAtNet models not only outperform ViT variants, but also match the best convolution-only architectures, i.e., EfficientNet-V2 and NFNets. Additionally, we also visualize the all results at resolution $2 2 4 \mathbf { x } 2 2 4$ in Fig. 2. As we can see, CoAtNet scales much better than previous model with attention modules.
148
+
149
+ Table 4: Model performance on ImageNet. 1K only denotes training on ImageNet-1K only; $2 1 \mathtt { K } + 1 \mathtt { K }$ denotes pre-training on ImageNet-21K and finetuning on ImageNet-1K; PT-RA denotes applying RandAugment during 21K pre-training, and E150 means 150 epochs of 21K pre-training, which is longer than the standard 90 epochs. More results are in Appendix A.3.
150
+
151
+ <table><tr><td colspan="2">Models</td><td>Eval Size</td><td>#Params</td><td>#FLOPs</td><td colspan="2">ImageNet Top-1 Accuracy</td></tr><tr><td rowspan="5">Conv Only</td><td></td><td></td><td></td><td></td><td>1K only</td><td>21K+1K</td></tr><tr><td>EfficientNet-B7</td><td>600²</td><td>66M</td><td>37B</td><td>84.7</td><td>-</td></tr><tr><td>EfficientNetV2-L</td><td>480²</td><td>121M</td><td>53B</td><td>85.7</td><td>86.8</td></tr><tr><td>NFNet-F3</td><td>4162²</td><td>255M</td><td>114.8B</td><td>85.7</td><td>=</td></tr><tr><td>NFNet-F5</td><td>5442</td><td>377M</td><td>289.8B</td><td>86.0</td><td>1</td></tr><tr><td rowspan="4">ViT-Stem TFM</td><td>DeiT-B</td><td>3842</td><td>86M</td><td>55.4B</td><td>83.1</td><td>-</td></tr><tr><td>ViT-L/16</td><td>384²</td><td>304M</td><td>190.7B</td><td>-</td><td>85.3</td></tr><tr><td>CaiT-S-36</td><td>384²</td><td>68M</td><td>48.0B</td><td>85.0</td><td></td></tr><tr><td>DeepViT-L</td><td>224²</td><td>55M</td><td>12.5B</td><td>83.1</td><td>-</td></tr><tr><td rowspan="2">Multi-stage TFM</td><td>Swin-B</td><td>384²</td><td>88M</td><td>47.0B</td><td>84.2</td><td>86.0</td></tr><tr><td>Swin-L</td><td>384²</td><td>197M</td><td>103.9B</td><td>-</td><td>86.4</td></tr><tr><td rowspan="5">Conv+TFM</td><td>BotNet-T7</td><td>3842</td><td>75.1M</td><td>45.8B</td><td>84.7</td><td>-</td></tr><tr><td>LambdaResNet-420</td><td>320²</td><td>-</td><td>=</td><td>84.8</td><td></td></tr><tr><td>T2T-ViT-24</td><td>224²</td><td>64.1M</td><td>15.0B</td><td>82.6</td><td>=</td></tr><tr><td>CvT-21</td><td>384²</td><td>32M</td><td>24.9B</td><td>83.3</td><td>-</td></tr><tr><td>CvT-W24</td><td>3842</td><td>277M</td><td>193.2B</td><td>-</td><td>87.7</td></tr><tr><td rowspan="19">Conv+TFM (ours)</td><td>CoAtNet-0 CoAtNet-1</td><td>224²</td><td>25M</td><td>4.2B</td><td>81.6</td><td>=</td></tr><tr><td></td><td>224²</td><td>42M</td><td>8.4B</td><td>83.3</td><td>-</td></tr><tr><td>CoAtNet-2 CoAtNet-3</td><td>224²</td><td>75M</td><td>15.7B</td><td>84.1</td><td>87.1</td></tr><tr><td></td><td>2242</td><td>168M</td><td>34.7B</td><td>84.5</td><td>87.6</td></tr><tr><td>CoAtNet-0</td><td>384²</td><td>25M</td><td>13.4B</td><td>83.9</td><td>-</td></tr><tr><td>CoAtNet-1</td><td>3842</td><td>42M</td><td>27.4B</td><td>85.1</td><td>-</td></tr><tr><td>CoAtNet-2</td><td>384²</td><td>75M</td><td>49.8B</td><td>85.7</td><td>87.1</td></tr><tr><td>CoAtNet-3</td><td>384²</td><td>168M</td><td>107.4B</td><td>85.8</td><td>87.6</td></tr><tr><td>CoAtNet-4</td><td>384²</td><td>275M</td><td>189.5B</td><td>-</td><td>87.9</td></tr><tr><td>+ PT-RA</td><td>384²</td><td>275M</td><td>189.5B</td><td></td><td>88.3</td></tr><tr><td>+ PT-RA-E150</td><td>3842</td><td>275M</td><td>189.5B</td><td></td><td>88.4</td></tr><tr><td>CoAtNet-2</td><td>5122</td><td>75M</td><td>96.7B</td><td>85.9</td><td>87.3</td></tr><tr><td>CoAtNet-3</td><td>512²</td><td>168M</td><td>203.1B</td><td>86.0</td><td>87.9</td></tr><tr><td>CoAtNet-4</td><td>512²</td><td>275M</td><td>360.9B</td><td>-</td><td>88.1</td></tr><tr><td>+ PT-RA</td><td>512²</td><td>275M</td><td>360.9B</td><td>=</td><td>88.4</td></tr><tr><td>+ PT-RA-E150</td><td>5122</td><td>275M</td><td>360.9B</td><td>=</td><td>88.56</td></tr></table>
152
+
153
+ ImageNet-21K As we can see from Table 4 and Fig. 3, when ImageNet-21K is used for pretraining, the advantage of CoAtNet becomes more obvious, substantially outperforming all previous models. Notably, the best CoAtNet variant achieves a top-1 accuracy of $8 8 . 5 6 \%$ , matching the ViTH/14 performance of $8 8 . 5 5 \%$ , which requires pre-training the $2 . 3 \mathbf { x }$ larger ViT model on a $2 3 \mathrm { x }$ larger proprietary weakly labeled dataset (JFT) for $2 . 2 \mathbf { x }$ more steps. This marks a dramatic improvement in both data efficiency and computation efficiency.
154
+
155
+ JFT Finally, in Table 5, we further evaluate CoAtNet under the large-scale data regime with JFT300M and JFT-3B. Encouragingly, our CoAtNet-4 can almost match the best previous performance with JFT-300M set by NFNet- $\mathrm { F 4 + }$ , while being $2 \mathbf { x }$ more efficient in terms of both TPU training time and parameter count. When we scale up the model to consume similar training resource as NFNet- $. \mathrm { F 4 + }$ , CoAtNet-5 reaches $8 9 . 7 7 \%$ on top-1 accuracy, outperforming previous results under comparable settings.
156
+
157
+ Moreover, as we further push the training resource towards the level used by ViT-G/14 and utilize the same JFT-3B dataset of an even larger size [26], with over $4 \mathbf { x }$ less computation, CoAtNet-6 is able to match the performance of $\mathrm { V i T - G } / 1 4$ of $9 0 . 4 5 \%$ , and with $1 . 5 \mathrm { x }$ less computation, CoAtNet-7 achieves $8 9 . 7 7 \%$ on top-1 accuracy $9 0 . 8 8 \%$ , achieving the new state-of-the-art performance.
158
+
159
+ Table 5: Performance Comparison on large-scale JFT dataset. TPUv3-core-days denotes the pretraining time, Top-1 Accuracy denotes the finetuned accuracy on ImageNet. Note that the last 3 rows use a larger dataset JFT-3B [26] for pre-training, while others use JFT-300M [15]. See Appendix A.2 for the size details of CoAtNet-5/6/7. †: Down-sampling in the MBConv block is achieved by stride-2 Depthwise Convolution. ⇧: ViT-G/14 computation consumption is read from Fig. 1 of the paper [26].
160
+
161
+ <table><tr><td>Models</td><td>Eval Size</td><td>#Params</td><td>#FLOPs</td><td>TPUv3-core-days</td><td>Top-1 Accuracy</td></tr><tr><td>ResNet + ViT-L/16</td><td>3842</td><td>330M</td><td>=</td><td>1</td><td>87.12</td></tr><tr><td>ViT-L/16</td><td>5122</td><td>307M</td><td>364B</td><td>0.68K</td><td>87.76</td></tr><tr><td>ViT-H/14</td><td>5182</td><td>632M</td><td>1021B</td><td>2.5K</td><td>88.55</td></tr><tr><td>NFNet-F4+</td><td>5122</td><td>527M</td><td>367B</td><td>1.86K</td><td>89.2</td></tr><tr><td>CoAtNet-3t</td><td>3842</td><td>168M</td><td>114B</td><td>0.58K</td><td>88.52</td></tr><tr><td>CoAtNet-3t</td><td>5122</td><td>168M</td><td>214B</td><td>0.58K</td><td>88.81</td></tr><tr><td>CoAtNet-4</td><td>5122</td><td>275M</td><td>361B</td><td>0.95K</td><td>89.11</td></tr><tr><td>CoAtNet-5</td><td>5122</td><td>688M</td><td>812B</td><td>1.82K</td><td>89.77</td></tr><tr><td>ViT-G/14</td><td>5182</td><td>1.84B</td><td>5160B</td><td>&gt;30K</td><td>90.45</td></tr><tr><td>CoAtNet-6</td><td>5122</td><td>1.47B</td><td>1521B</td><td>6.6K</td><td>90.45</td></tr><tr><td>CoAtNet-7</td><td>5122</td><td>2.44B</td><td>2586B</td><td>20.1K</td><td>90.88</td></tr></table>
162
+
163
+ # 4.3 Ablation Studies
164
+
165
+ In this section, we will ablate our design choices for CoAtNet.
166
+
167
+ Firstly, we study the importance of the relative attention from combining convolution and attention into a single computation unit. Specifically, we compare two models, one with the relative attention and the other without, under both the ImageNet-1K alone and ImageNet-21K transfer setting. As we can see from Table 6, when only the ImageNet-1K is used, relative attention clearly outperforms the standard attention, indicating a better generalization. In addition, under the ImageNet-21K transfer setting, the relative attention variant achieves a substantially better transfer accuracy, despite their very close pre-training performances. This suggests the main advantage of relative attention in visual processing is not in higher capacity but in better generalization.
168
+
169
+ Table 6: Ablation on relative attention.
170
+
171
+ <table><tr><td>Seting</td><td>Metric</td><td>With Rel-Attn</td><td>Without Rel-Attn</td></tr><tr><td rowspan="2">ImageNet-1K</td><td>Accuracy (2242)</td><td>84.1</td><td>83.8</td></tr><tr><td>Accuracy (3842)</td><td>85.7</td><td>85.3</td></tr><tr><td rowspan="2">ImageNet-21K →ImageNet-1K</td><td>Pre-train Precision@1 (224²)</td><td>53.0</td><td>52.8</td></tr><tr><td>Finetune Accuracy (384²)</td><td>87.9</td><td>87.4</td></tr></table>
172
+
173
+ Table 7: Ablation on architecture layout.
174
+
175
+ <table><tr><td>Setting</td><td>Models</td><td>Layout</td><td>Top-1 Accuracy</td></tr><tr><td rowspan="3">ImageNet-1K</td><td>VO: CoAtNet-2</td><td>[2,2,6,14,2]</td><td>84.1</td></tr><tr><td>V1: S2← S3</td><td>[2,2, 2,18,2]</td><td>83.4</td></tr><tr><td>V2: S2→ S3</td><td>[2,2,8,12,2]</td><td>84.0</td></tr><tr><td>ImageNet-21K</td><td>VO: CoAtNet-3</td><td>[2,2,6,14,2]</td><td>53.0 -→87.6</td></tr><tr><td>⇒ImageNet-1K</td><td>V1: S2 ← S3</td><td>[2,2,2,18,2]</td><td>53.0 -→87.4</td></tr></table>
176
+
177
+ Secondly, as S2 with MBConv blocks and S3 with relative Transformer blocks occupy most of the computation of the CoAtNet, a question to ask is how to split the computation between S2 (MBConv) and S3 (Transformer) to achieve a good performance. In practice, it boils down to deciding the number of blocks to have in each stage, which we will refer to as “layout” design. For this purpose, we compare a few different layouts that we experimented with in Table 7.
178
+
179
+ Table 8: Ablation on head size and normalization type.
180
+
181
+ <table><tr><td>Setting</td><td>Models</td><td>Image Size</td><td>Top-1 Accuracy</td></tr><tr><td rowspan="3">ImageNet-1K</td><td>CoAtNet-2</td><td>2242</td><td>84.1</td></tr><tr><td>Head size: 32 → 64</td><td>2242</td><td>83.9</td></tr><tr><td>Norm type: 1 BN →LN</td><td>2242</td><td>84.1</td></tr><tr><td rowspan="2">ImageNet-21K ⇒ ImageNet-1K</td><td>CoAtNet-3</td><td>3842</td><td>87.9</td></tr><tr><td>Norm type: BN →→ LN</td><td>384²</td><td>87.8</td></tr></table>
182
+
183
+ • If we keep the total number of blocks in S2 and S3 fixed and vary the number in each stage, we observe that V0 is a sweet spot between V1 and V2. Basically, having more Transformer blocks in S3 generally leads to better performance until the number of MBConv blocks in S2 is too small to generalize well.
184
+
185
+ • To further evaluate whether the sweet spot also holds in the transfer setting, where a higher capacity is often regarded more important, we further compare V0 and V1 under the ImageNet21K transferring to ImageNet-1K setup. Interestingly, despite that V1 and V0 have the same performance during ImageNet-21K pre-training, the transfer accuracy of V1 clearly falls behind V0. Again, this suggests the importance of convolution in achieving good transferability and generalization.
186
+
187
+ Lastly, we study two choices of model details, namely the dimension of each attention (default to 32) head as well as the type of normalization (default to BatchNorm) used in MBConv blocks. From Table 8, we can see increasing head size from 32 to 64 can slightly hurt performance, though it actually improves the TPU speed by a significant amount. In practice, this will be a quality-speed trade-off one can make. On the other hand, BatchNorm and LayerNorm have almost the same performance, while BatchNorm is $10 - 2 0 \%$ faster on TPU depending on the per-core batch size.
188
+
189
+ # 5 Conclusion
190
+
191
+ In this paper, we systematically study the properties of convolutions and Transformers, which leads to a principled way to combine them into a new family of models named CoAtNet. Extensive experiments show that CoAtNet enjoys both good generalization like ConvNets and superior model capacity like Transformers, achieving state-of-the-art performances under different data sizes and computation budgets.
192
+
193
+ Note that this paper currently focuses on ImageNet classification for model development. However, we believe our approach is applicable to broader applications like object detection and semantic segmentation. We will leave them for future work.
194
+
195
+ # References
196
+
197
+ [1] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems, pages 1097–1105, 2012.
198
+ [2] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015.
199
+ [3] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
200
+ [4] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1–9, 2015.
201
+ [5] Mingxing Tan and Quoc V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. ICML, 2019.
202
+ [6] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762, 2017.
203
+ [7] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
204
+ [8] Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
205
+ [9] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7794–7803, 2018.
206
+ [10] 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, pages 3286–3295, 2019.
207
+ [11] 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.
208
+ [12] Zhuoran Shen, Mingyuan Zhang, Haiyu Zhao, Shuai Yi, and Hongsheng Li. Efficient attention: Attention with linear complexities. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 3531–3539, 2021.
209
+ [13] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
210
+ [14] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A largescale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. Ieee, 2009.
211
+ [15] Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In Proceedings of the IEEE international conference on computer vision, pages 843–852, 2017.
212
+ [16] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. arXiv preprint arXiv:2012.12877, 2020.
213
+ [17] Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Hervé Jégou. Going deeper with image transformers. arXiv preprint arXiv:2103.17239, 2021.
214
+ [18] Daquan Zhou, Bingyi Kang, Xiaojie Jin, Linjie Yang, Xiaochen Lian, Qibin Hou, and Jiashi Feng. Deepvit: Towards deeper vision transformer. arXiv preprint arXiv:2103.11886, 2021.
215
+ [19] Mingxing Tan and Quoc V Le. Efficientnetv2: Smaller models and faster training. ICML, 2021.
216
+ [20] Andrew Brock, Soham De, Samuel L Smith, and Karen Simonyan. High-performance largescale image recognition without normalization. arXiv preprint arXiv:2102.06171, 2021.
217
+ [21] Ashish Vaswani, Prajit Ramachandran, Aravind Srinivas, Niki Parmar, Blake Hechtman, and Jonathon Shlens. Scaling local self-attention for parameter efficient visual backbones. arXiv preprint arXiv:2103.12731, 2021.
218
+ [22] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030, 2021.
219
+ [23] Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. Cvt: Introducing convolutions to vision transformers. arXiv preprint arXiv:2103.15808, 2021.
220
+ [24] Ben Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Hervé Jégou, and Matthijs Douze. Levit: a vision transformer in convnet’s clothing for faster inference. arXiv preprint arXiv:2104.01136, 2021.
221
+ [25] 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. arXiv preprint arXiv:2101.11986, 2021.
222
+ [26] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. arXiv preprint arXiv:2106.04560, 2021.
223
+ [27] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4510–4520, 2018.
224
+ [28] Laurent Sifre. Rigid-motion scattering for image classification. Ph.D. thesis section 6.2, 2014.
225
+ [29] Mirgahney Mohamed, Gabriele Cesa, Taco S Cohen, and Max Welling. A data and compute efficient design for limited-resources deep learning. arXiv preprint arXiv:2004.09691, 2020.
226
+ [30] Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. arXiv preprint arXiv:1803.02155, 2018.
227
+ [31] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019.
228
+ [32] Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In International Conference on Machine Learning, pages 5156–5165. PMLR, 2020.
229
+ [33] Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. Rethinking attention with performers. arXiv preprint arXiv:2009.14794, 2020.
230
+ [34] 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, 2019.
231
+ [35] Mingxing Tan, Bo Chen, Ruoming Pang, Vijay Vasudevan, Mark Sandler, Andrew Howard, and Quoc V Le. Mnasnet: Platform-aware neural architecture search for mobile. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2820–2828, 2019.
232
+ [36] Kai Han, Yunhe Wang, Hanting Chen, Xinghao Chen, Jianyuan Guo, Zhenhua Liu, Yehui Tang, An Xiao, Chunjing Xu, Yixing Xu, et al. A survey on visual transformer. arXiv preprint arXiv:2012.12556, 2020.
233
+ [37] Salman Khan, Muzammal Naseer, Munawar Hayat, Syed Waqas Zamir, Fahad Shahbaz Khan, and Mubarak Shah. Transformers in vision: A survey. arXiv preprint arXiv:2101.01169, 2021.
234
+ [38] Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Noam Shazeer, Ian Simon, Curtis Hawthorne, Andrew M Dai, Matthew D Hoffman, Monica Dinculescu, and Douglas Eck. Music transformer. arXiv preprint arXiv:1809.04281, 2018.
235
+ [39] Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc V Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. arXiv preprint arXiv:1901.02860, 2019.
236
+ [40] Yao-Hung Hubert Tsai, Shaojie Bai, Makoto Yamada, Louis-Philippe Morency, and Ruslan Salakhutdinov. Transformer dissection: A unified understanding of transformer’s attention via the lens of kernel. arXiv preprint arXiv:1908.11775, 2019.
237
+ [41] Irwan Bello. Lambdanetworks: Modeling long-range interactions without attention. arXiv preprint arXiv:2102.08602, 2021.
238
+ [42] Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7132–7141, 2018.
239
+ [43] Kun Yuan, Shaopeng Guo, Ziwei Liu, Aojun Zhou, Fengwei Yu, and Wei Wu. Incorporating convolution designs into visual transformers. arXiv preprint arXiv:2103.11816, 2021.
240
+ [44] Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. arXiv preprint arXiv:2102.12122, 2021.
241
+ [45] Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pages 702–703, 2020.
242
+ [46] Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017.
243
+ [47] Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European conference on computer vision, pages 646–661. Springer, 2016.
244
+ [48] 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.
245
+ [49] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
246
+ [50] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European conference on computer vision, pages 630–645. Springer, 2016.
247
+ [51] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016.
248
+ [52] Zihang Dai, Guokun Lai, Yiming Yang, and Quoc V Le. Funnel-transformer: Filtering out sequential redundancy for efficient language processing. arXiv preprint arXiv:2006.03236, 2020.
parse/train/JXAyJeYqUkZ/JXAyJeYqUkZ_content_list.json ADDED
@@ -0,0 +1,1045 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "CoAtNet: Marrying Convolution and Attention for All Data Sizes ",
5
+ "text_level": 1,
6
+ "bbox": [
7
+ 214,
8
+ 122,
9
+ 785,
10
+ 171
11
+ ],
12
+ "page_idx": 0
13
+ },
14
+ {
15
+ "type": "text",
16
+ "text": "Zihang Dai, Hanxiao Liu, Quoc V. Le, Mingxing Tan Google Research, Brain Team {zihangd,hanxiaol,qvl,tanmingxing}@google.com ",
17
+ "bbox": [
18
+ 307,
19
+ 220,
20
+ 691,
21
+ 263
22
+ ],
23
+ "page_idx": 0
24
+ },
25
+ {
26
+ "type": "text",
27
+ "text": "Abstract ",
28
+ "text_level": 1,
29
+ "bbox": [
30
+ 462,
31
+ 299,
32
+ 535,
33
+ 315
34
+ ],
35
+ "page_idx": 0
36
+ },
37
+ {
38
+ "type": "text",
39
+ "text": "Transformers have attracted increasing interests in computer vision, but they still fall behind state-of-the-art convolutional networks. In this work, we show that while Transformers tend to have larger model capacity, their generalization can be worse than convolutional networks due to the lack of the right inductive bias. To effectively combine the strengths from both architectures, we present CoAtNets (pronounced “coat” nets), a family of hybrid models built from two key insights: (1) depthwise Convolution and self-Attention can be naturally unified via simple relative attention; (2) vertically stacking convolution layers and attention layers in a principled way is surprisingly effective in improving generalization, capacity and efficiency. Experiments show that our CoAtNets achieve state-of-the-art performance under different resource constraints across various datasets: Without extra data, CoAtNet achieves $8 6 . 0 \\%$ ImageNet top-1 accuracy; When pre-trained with 13M images from ImageNet-21K, our CoAtNet achieves $8 8 . 5 6 \\%$ top-1 accuracy, matching ViT-huge pre-trained with 300M images from JFT-300M while using $2 3 \\mathrm { x }$ less data; Notably, when we further scale up CoAtNet with JFT-3B, it achieves $9 0 . 8 8 \\%$ top-1 accuracy on ImageNet, establishing a new state-of-the-art result. ",
40
+ "bbox": [
41
+ 233,
42
+ 332,
43
+ 766,
44
+ 551
45
+ ],
46
+ "page_idx": 0
47
+ },
48
+ {
49
+ "type": "text",
50
+ "text": "1 Introduction ",
51
+ "text_level": 1,
52
+ "bbox": [
53
+ 176,
54
+ 575,
55
+ 310,
56
+ 593
57
+ ],
58
+ "page_idx": 0
59
+ },
60
+ {
61
+ "type": "text",
62
+ "text": "Since the breakthrough of AlexNet [1], Convolutional Neural Networks (ConvNets) have been the dominating model architecture for computer vision [2, 3, 4, 5]. Meanwhile, with the success of self-attention models like Transformers [6] in natural language processing [7, 8], many previous works have attempted to bring in the power of attention into computer vision [9, 10, 11, 12]. More recently, Vision Transformer (ViT) [13] has shown that with almost1 only vanilla Transformer layers, one could obtain reasonable performance on ImageNet-1K [14] alone. More importantly, when pre-trained on large-scale weakly labeled JFT-300M dataset [15], ViT achieves comparable results to state-of-the-art (SOTA) ConvNets, indicating that Transformer models potentially have higher capacity at scale than ConvNets. ",
63
+ "bbox": [
64
+ 174,
65
+ 607,
66
+ 825,
67
+ 732
68
+ ],
69
+ "page_idx": 0
70
+ },
71
+ {
72
+ "type": "text",
73
+ "text": "While ViT has shown impressive results with enormous JFT 300M training images, its performance still falls behind ConvNets in the low data regime. For example, without extra JFT-300M pre-training, the ImageNet accuracy of ViT is still significantly lower than ConvNets with comparable model size [5] (see Table 13). Subsequent works use special regularization and stronger data augmentation to improve the vanilla ViT [16, 17, 18], yet none of these ViT variants could outperform the SOTA convolution-only models on ImageNet classification given the same amount of data and computation [19, 20]. This suggests that vanilla Transformer layers may lack certain desirable inductive biases possessed by ConvNets, and thus require significant amount of data and computational resource to compensate. Not surprisingly, many recent works have been trying to incorporate the inductive biases of ConvNets into Transformer models, by imposing local receptive fields for attention layers [21, 22] or augmenting the attention and FFN layers with implicit or explicit convolutional operations [23, 24, 25]. However, these approaches are either ad-hoc or focused on injecting a particular property, lacking a systematic understanding of the respective roles of convolution and attention when combined. ",
74
+ "bbox": [
75
+ 174,
76
+ 738,
77
+ 826,
78
+ 877
79
+ ],
80
+ "page_idx": 0
81
+ },
82
+ {
83
+ "type": "text",
84
+ "text": "",
85
+ "bbox": [
86
+ 174,
87
+ 90,
88
+ 825,
89
+ 147
90
+ ],
91
+ "page_idx": 1
92
+ },
93
+ {
94
+ "type": "text",
95
+ "text": "In this work, we systematically study the problem of hybridizing convolution and attention from two fundamental aspects in machine learning – generalization and model capacity. Our study shows that convolutional layers tend to have better generalization with faster converging speed thanks to their strong prior of inductive bias, while attention layers have higher model capacity that can benefit from larger datasets. Combining convolutional and attention layers can achieve better generalization and capacity; however, a key challenge here is how to effectively combine them to achieve better trade-offs between accuracy and efficiency. In this paper, we investigate two key insights: First, we observe that the commonly used depthwise convolution can be effectively merged into attention layers with simple relative attention; Second, simply stacking convolutional and attention layers, in a proper way, could be surprisingly effective to achieve better generalization and capacity. Based on these insights, we propose a simple yet effective network architecture named CoAtNet, which enjoys the strengths from both ConvNets and Transformers. ",
96
+ "bbox": [
97
+ 174,
98
+ 154,
99
+ 825,
100
+ 319
101
+ ],
102
+ "page_idx": 1
103
+ },
104
+ {
105
+ "type": "text",
106
+ "text": "Our CoAtNet achieves SOTA performances under comparable resource constraints across different data sizes. Specifically, under the low-data regime, CoAtNet inherits the great generalization property of ConvNets thanks to the favorable inductive biases. Moreover, given abundant data, CoAtNet not only enjoys the superior scalability of Transformer models, but also achieves faster convergence and thus improved efficiency. When only ImageNet-1K is used for training, CoAtNet achieves $8 6 . 0 \\%$ top-1 accuracy, matching the prior art NFNet [20] under similar computation resource and training conditions. Further, when pre-trained on ImageNet-21K with about 10M images, CoAtNet reaches $8 8 . 5 6 \\%$ top-1 accuracy when finetuned on ImageNet-1K, matching the ViT-Huge pre-trained on JFT-300M, a $2 3 \\times$ larger dataset. Finally, when JFT-3B is used for pre-training, CoAtNet exhibits better efficiency compared to ViT, and pushes the ImageNet-1K top-1 accuracy to $9 0 . 8 8 \\%$ while using $1 . 5 \\mathrm { x }$ less computation of the prior art set by ViT-G/14 [26]. ",
107
+ "bbox": [
108
+ 173,
109
+ 325,
110
+ 825,
111
+ 478
112
+ ],
113
+ "page_idx": 1
114
+ },
115
+ {
116
+ "type": "text",
117
+ "text": "2 Model ",
118
+ "text_level": 1,
119
+ "bbox": [
120
+ 174,
121
+ 505,
122
+ 259,
123
+ 521
124
+ ],
125
+ "page_idx": 1
126
+ },
127
+ {
128
+ "type": "text",
129
+ "text": "In the section, we focus on the question of how to “optimally” combine the convolution and transformer. Roughly speaking, we decompose the question into two parts: ",
130
+ "bbox": [
131
+ 173,
132
+ 540,
133
+ 823,
134
+ 569
135
+ ],
136
+ "page_idx": 1
137
+ },
138
+ {
139
+ "type": "text",
140
+ "text": "1. How to combine the convolution and self-attention within one basic computational block? 2. How to vertically stack different types of computational blocks together to form a complete network? ",
141
+ "bbox": [
142
+ 200,
143
+ 574,
144
+ 825,
145
+ 622
146
+ ],
147
+ "page_idx": 1
148
+ },
149
+ {
150
+ "type": "text",
151
+ "text": "The rationale of the decomposition will become clearer as we gradually reveal our design choices. ",
152
+ "bbox": [
153
+ 169,
154
+ 628,
155
+ 816,
156
+ 645
157
+ ],
158
+ "page_idx": 1
159
+ },
160
+ {
161
+ "type": "text",
162
+ "text": "2.1 Merging Convolution and Self-Attention ",
163
+ "text_level": 1,
164
+ "bbox": [
165
+ 176,
166
+ 667,
167
+ 493,
168
+ 683
169
+ ],
170
+ "page_idx": 1
171
+ },
172
+ {
173
+ "type": "text",
174
+ "text": "For convolution, we mainly focus on the MBConv block [27] which employs depthwise convolution [28] to capture the spatial interaction. A key reason of this choice is that both the FFN module in Transformer and MBConv employ the design of “inverted bottleneck”, which first expands the channel size of the input by $4 \\mathbf { x }$ and later project the the $4 \\mathbf { x }$ -wide hidden state back to the original channel size to enable residual connection. ",
175
+ "bbox": [
176
+ 173,
177
+ 695,
178
+ 825,
179
+ 765
180
+ ],
181
+ "page_idx": 1
182
+ },
183
+ {
184
+ "type": "text",
185
+ "text": "Besides the similarity of inverted bottleneck, we also notice that both depthwise convolution and self-attention can be expressed as a per-dimension weighted sum of values in a pre-defined receptive field. Specifically, convolution relies on a fixed kernel to gather information from a local receptive field ",
186
+ "bbox": [
187
+ 173,
188
+ 771,
189
+ 825,
190
+ 827
191
+ ],
192
+ "page_idx": 1
193
+ },
194
+ {
195
+ "type": "equation",
196
+ "img_path": "images/6674e066791bbf528f350e89a70d47c627c6a3fb12df1f14900957b317ba58ee.jpg",
197
+ "text": "$$\ny _ { i } = \\sum _ { j \\in \\mathcal { L } ( i ) } w _ { i - j } \\odot x _ { j } \\quad \\mathrm { ( d e p t h w i s e c o n v o l u t i o n ) } ,\n$$",
198
+ "text_format": "latex",
199
+ "bbox": [
200
+ 333,
201
+ 832,
202
+ 661,
203
+ 868
204
+ ],
205
+ "page_idx": 1
206
+ },
207
+ {
208
+ "type": "text",
209
+ "text": "where $x _ { i } , y _ { i } \\in \\mathbb { R } ^ { D }$ are the input and output at position $i$ respectively, and $\\mathcal { L } ( i )$ denotes a local neighborhood of $i$ , e.g., a 3x3 grid centered at $i$ in image processing. ",
210
+ "bbox": [
211
+ 174,
212
+ 882,
213
+ 823,
214
+ 912
215
+ ],
216
+ "page_idx": 1
217
+ },
218
+ {
219
+ "type": "text",
220
+ "text": "In comparison, self-attention allows the receptive field to be the entire spatial locations and computes the weights based on the re-normalized pairwise similarity between the pair $( x _ { i } , x _ { j } )$ : 2 ",
221
+ "bbox": [
222
+ 169,
223
+ 90,
224
+ 823,
225
+ 119
226
+ ],
227
+ "page_idx": 2
228
+ },
229
+ {
230
+ "type": "equation",
231
+ "img_path": "images/a9164aac5bb6f55e0bd90b25f31a8559f39a62986021c906fcf5f7116eba58d0.jpg",
232
+ "text": "$$\ny _ { i } = \\sum _ { j \\in \\mathcal { G } } \\underbrace { \\frac { \\exp { \\left( x _ { i } ^ { \\top } x _ { j } \\right) } } { \\sum _ { k \\in \\mathcal { G } } \\exp { \\left( x _ { i } ^ { \\top } x _ { k } \\right) } } } _ { A _ { i , j } } x _ { j } \\quad \\mathrm { ( s e l f - a t t e n t i o n ) } ,\n$$",
233
+ "text_format": "latex",
234
+ "bbox": [
235
+ 333,
236
+ 128,
237
+ 663,
238
+ 188
239
+ ],
240
+ "page_idx": 2
241
+ },
242
+ {
243
+ "type": "text",
244
+ "text": "where $\\mathcal { G }$ indicates the global spatial space. Before getting into the question of how to best combine them, it is worthwhile to compare their relative strengths and weaknesses, which helps to figure out the good properties we hope to retain. ",
245
+ "bbox": [
246
+ 174,
247
+ 195,
248
+ 825,
249
+ 238
250
+ ],
251
+ "page_idx": 2
252
+ },
253
+ {
254
+ "type": "text",
255
+ "text": "• First of all, the depthwise convolution kernel $w _ { i - j }$ is an input-independent parameter of static value, while the attention weight $A _ { i , j }$ dynamically depends on the representation of the input. Hence, it is much easier for the self-attention to capture complicated relational interactions between different spatial positions, a property that we desire most when processing high-level concepts. However, the flexibility comes with a risk of easier overfitting, especially when data is limited. • Secondly, notice that given any position pair $( i , j )$ , the corresponding convolution weight $w _ { i - j }$ only cares about the relative shift between them, i.e. $i - j$ , rather than the specific values of $i$ or $j$ . This property is often referred to translation equivalence, which has been found to improve generalization under datasets of limited size [29]. Due to the usage of absolution positional embeddings, standard Transformer (ViT) lacks this property. This partially explains why ConvNets are usually better than Transformers when the dataset is not enormously large. • Finally, the size of the receptive field is one of the most crucial differences between self-attention and convolution. Generally speaking, a larger receptive field provides more contextual information, which could lead to higher model capacity. Hence, the global receptive field has been a key motivation to employ self-attention in vision. However, a large receptive field requires significantly more computation. In the case of global attention, the complexity is quadratic w.r.t. spatial size, which has been a fundamental trade-off in applying self-attention models. ",
256
+ "bbox": [
257
+ 173,
258
+ 242,
259
+ 826,
260
+ 486
261
+ ],
262
+ "page_idx": 2
263
+ },
264
+ {
265
+ "type": "table",
266
+ "img_path": "images/d75e2fc9a7e5f7449242faadd95d844ba4bb23d1ab343baa75e9dc6fb7c8645c.jpg",
267
+ "table_caption": [
268
+ "Table 1: Desirable properties found in convolution or self-attention. "
269
+ ],
270
+ "table_footnote": [],
271
+ "table_body": "<table><tr><td>Properties</td><td>Convolution</td><td>Self-Attention</td></tr><tr><td>Translation Equivariance</td><td>√</td><td></td></tr><tr><td>Input-adaptive Weighting</td><td></td><td>√</td></tr><tr><td>Global Receptive Field</td><td></td><td></td></tr></table>",
272
+ "bbox": [
273
+ 285,
274
+ 525,
275
+ 702,
276
+ 595
277
+ ],
278
+ "page_idx": 2
279
+ },
280
+ {
281
+ "type": "text",
282
+ "text": "Given the comparison above, an ideal model should be able to combine the 3 desirable properties in Table 1. With the similar form of depthwise convolution in Eqn. (1) and self-attention in Eqn. (2), a straightforward idea that could achieve this is simply to sum a global static convolution kernel with the adaptive attention matrix, either after or before the Softmax normalization, i.e., ",
283
+ "bbox": [
284
+ 178,
285
+ 612,
286
+ 821,
287
+ 667
288
+ ],
289
+ "page_idx": 2
290
+ },
291
+ {
292
+ "type": "equation",
293
+ "img_path": "images/6ad701e539bf342fce3258bfc8889c519cd941777a414d3170d3f20d5b95a53d.jpg",
294
+ "text": "$$\ny _ { i } ^ { \\mathrm { p o s t } } = \\sum _ { j \\in \\mathcal { G } } \\left( \\frac { \\exp \\left( x _ { i } ^ { \\top } x _ { j } \\right) } { \\sum _ { k \\in \\mathcal { G } } \\exp \\left( x _ { i } ^ { \\top } x _ { k } \\right) } + w _ { i - j } \\right) x _ { j } \\ \\mathrm { ~ o r ~ } \\ y _ { i } ^ { \\mathrm { p e } } = \\sum _ { j \\in \\mathcal { G } } \\frac { \\exp \\left( x _ { i } ^ { \\top } x _ { j } + w _ { i - j } \\right) } { \\sum _ { k \\in \\mathcal { G } } \\exp \\left( x _ { i } ^ { \\top } x _ { k } + w _ { i - k } \\right) } x _ { j } .\n$$",
295
+ "text_format": "latex",
296
+ "bbox": [
297
+ 181,
298
+ 676,
299
+ 800,
300
+ 720
301
+ ],
302
+ "page_idx": 2
303
+ },
304
+ {
305
+ "type": "text",
306
+ "text": "Interestingly, while the idea seems overly simplified, the pre-normalization version $y ^ { \\mathrm { p r e } }$ corresponds to a particular variant of relative self-attention [30, 31]. In this case, the attention weight $A _ { i , j }$ is decided jointly by the $w _ { i - j }$ of translation equivariance and the input-adaptive $x _ { i } ^ { \\top } x _ { j }$ , which can enjoy both effects depending on their relative magnitudes. Importantly, note that in order to enable the global convolution kernel without blowing up the number of parameters, we have reloaded the notation of $w _ { i - j }$ as a scalar (i.e., $w \\in \\mathbb { R } ^ { O ( | \\mathcal { G } | ) }$ ) rather than a vector in Eqn. (1). Another advantage of the scalar formulation of $w$ is that retrieving $w _ { i - j }$ for all $( i , j )$ is clearly subsumed by computing the pairwise dot-product attention, hence resulting in minimum additional cost (see Appendix A.1). Given the benefits, we will use the Transformer block with the pre-normalization relative attention variant in Eqn. (3) as the key component of the proposed CoAtNet model. ",
307
+ "bbox": [
308
+ 173,
309
+ 728,
310
+ 825,
311
+ 871
312
+ ],
313
+ "page_idx": 2
314
+ },
315
+ {
316
+ "type": "text",
317
+ "text": "2.2 Vertical Layout Design ",
318
+ "text_level": 1,
319
+ "bbox": [
320
+ 174,
321
+ 92,
322
+ 372,
323
+ 106
324
+ ],
325
+ "page_idx": 3
326
+ },
327
+ {
328
+ "type": "text",
329
+ "text": "After figuring out a neat way to combine convolution and attention, we next consider how to utilize it to stack an entire network. ",
330
+ "bbox": [
331
+ 173,
332
+ 118,
333
+ 823,
334
+ 146
335
+ ],
336
+ "page_idx": 3
337
+ },
338
+ {
339
+ "type": "text",
340
+ "text": "As we have discuss above, the global context has a quadratic complexity w.r.t. the spatial size. Hence, if we directly apply the relative attention in Eqn. (3) to the raw image input, the computation will be excessively slow due to the large number of pixels in any image of common sizes. Hence, to construct a network that is feasible in practice, we have mainly three options: ",
341
+ "bbox": [
342
+ 173,
343
+ 152,
344
+ 825,
345
+ 209
346
+ ],
347
+ "page_idx": 3
348
+ },
349
+ {
350
+ "type": "text",
351
+ "text": "(A) Perform some down-sampling to reduce the spatial size and employ the global relative attention after the feature map reaches manageable level. \n(B) Enforce local attention, which restricts the global receptive field $\\mathcal { G }$ in attention to a local field $\\mathcal { L }$ just like in convolution [22, 21]. \n(C) Replace the quadratic Softmax attention with certain linear attention variant which only has a linear complexity w.r.t. the spatial size [12, 32, 33]. ",
352
+ "bbox": [
353
+ 176,
354
+ 215,
355
+ 825,
356
+ 309
357
+ ],
358
+ "page_idx": 3
359
+ },
360
+ {
361
+ "type": "text",
362
+ "text": "We briefly experimented with option (C) without getting a reasonably good result. For option (B), we found that implementing local attention involves many non-trivial shape formatting operations that requires intensive memory access. On our accelerator of choice (TPU), such operation turns out to be extremely slow [34], which not only defeats the original purpose of speeding up global attention, but also hurts the model capacity. Hence, as some recent work has studied this variant [22, 21], we will focus on option (A) and compare our results with theirs in our empirical study (Section 4). ",
363
+ "bbox": [
364
+ 173,
365
+ 315,
366
+ 825,
367
+ 398
368
+ ],
369
+ "page_idx": 3
370
+ },
371
+ {
372
+ "type": "text",
373
+ "text": "For option (A), the down-sampling can be achieved by either (1) a convolution stem with aggressive stride (e.g., stride 16x16) as in ViT or (2) a multi-stage network with gradual pooling as in ConvNets. With these choices, we derive a search space of 5 variants and compare them in controlled experiments. ",
374
+ "bbox": [
375
+ 174,
376
+ 404,
377
+ 823,
378
+ 446
379
+ ],
380
+ "page_idx": 3
381
+ },
382
+ {
383
+ "type": "text",
384
+ "text": "• When the ViT Stem is used, we directly stack $L$ Transformer blocks with relative attention, which we denote as $\\mathrm { V I T } _ { \\mathrm { R E L } }$ . \n• When the multi-stage layout is used, we mimic ConvNets to construct a network of 5 stages (S0, S1, S2, S3 & S4), with spatial resolution gradually decreased from S0 to S4. At the beginning of each stage, we always reduce the spatial size by $2 \\mathbf { x }$ and increase the number of channels (see Appendix A.1 for the detailed down-sampling implementation). The first stage S0 is a simple 2-layer convolutional Stem and S1 always employs MBConv blocks with squeeze-excitation (SE), as the spatial size is too large for global attention. Starting from S2 through S4, we consider either the MBConv or the Transformer block, with a constraint that convolution stages must appear before Transformer stages. The constraint is based on the prior that convolution is better at processing local patterns that are more common in early stages. This leads to 4 variants with increasingly more Transformer stages, C-C-C-C, C-C-C-T, C-C-T-T and C-T-T-T, where C and T denote Convolution and Transformer respectively. ",
385
+ "bbox": [
386
+ 171,
387
+ 453,
388
+ 825,
389
+ 642
390
+ ],
391
+ "page_idx": 3
392
+ },
393
+ {
394
+ "type": "text",
395
+ "text": "To systematically study the design choices, we consider two fundamental aspects generalization capability and model capacity: For generalization, we are interested in the gap between the training loss and the evaluation accuracy. If two models have the same training loss, then the model with higher evaluation accuracy has better generalization capability, since it can generalize better to unseen evaluation dataset. Generalization capability is particularly important to data efficiency when training data size is limited. For model capacity, we measure the ability to fit large training datasets. When training data is abundant and overfitting is not an issue, the model with higher capacity will achieve better final performance after reasonable training steps. Note that, since simply increasing the model size can lead to higher model capacity, to perform a meaningful comparison, we make sure the model sizes of the 5 variants are comparable. ",
396
+ "bbox": [
397
+ 173,
398
+ 648,
399
+ 825,
400
+ 787
401
+ ],
402
+ "page_idx": 3
403
+ },
404
+ {
405
+ "type": "text",
406
+ "text": "To compare the generalization and model capacity, we train different variants of hybrid models on ImageNet-1K (1.3M) and JFT $\\left( > 3 0 0 \\mathbf { M } \\right)$ dataset for 300 and 3 epochs respectively, both without any regularization or augmentation. The training loss and evaluation accuracy on both datasets are summarized in Figure 1. ",
407
+ "bbox": [
408
+ 174,
409
+ 792,
410
+ 825,
411
+ 849
412
+ ],
413
+ "page_idx": 3
414
+ },
415
+ {
416
+ "type": "text",
417
+ "text": "• From the ImageNet-1K results, a key observation is that, in terms of generalization capability (i.e., gap between train and evaluation metrics), we have ",
418
+ "bbox": [
419
+ 169,
420
+ 854,
421
+ 825,
422
+ 883
423
+ ],
424
+ "page_idx": 3
425
+ },
426
+ {
427
+ "type": "equation",
428
+ "img_path": "images/5f09b3609b6f1eadeb4a99c8e756ab7b3480d39c7a84b75a5be78aad8ba17e00.jpg",
429
+ "text": "$$\n\\mathrm { C \\mathrm { - } C \\mathrm { - } C \\mathrm { - } C \\approx C \\mathrm { - } C \\mathrm { - } C \\mathrm { - } T \\ge C \\mathrm { - } C \\mathrm { - } T \\mathrm { - } T > C \\mathrm { - } T \\mathrm { - } T \\mathrm { - } T \\gg V \\mathrm { I } \\mathrm { T } _ { \\mathrm { R E L } } . }\n$$",
430
+ "text_format": "latex",
431
+ "bbox": [
432
+ 305,
433
+ 896,
434
+ 702,
435
+ 912
436
+ ],
437
+ "page_idx": 3
438
+ },
439
+ {
440
+ "type": "image",
441
+ "img_path": "images/8e4cc944c4e098b4c2962d8c1e585910035ad5a220c25df539ba8f057d9c47df.jpg",
442
+ "image_caption": [
443
+ "Figure 1: Comparison for model generalization and capacity under different data size. For fair comparison, all models have similar parameter size and computational cost. "
444
+ ],
445
+ "image_footnote": [],
446
+ "bbox": [
447
+ 178,
448
+ 90,
449
+ 820,
450
+ 234
451
+ ],
452
+ "page_idx": 4
453
+ },
454
+ {
455
+ "type": "text",
456
+ "text": "Particularly, $\\mathrm { V I T } _ { \\mathrm { R E L } }$ is significantly worse than variants by a large margin, which we conjecture is related to the lack of proper low-level information processing in its aggressive down-sampling Stem. Among the multi-stage variants, the overall trend is that the more convolution stages the model has, the smaller the generalization gap is. ",
457
+ "bbox": [
458
+ 186,
459
+ 297,
460
+ 825,
461
+ 354
462
+ ],
463
+ "page_idx": 4
464
+ },
465
+ {
466
+ "type": "text",
467
+ "text": "• As for model capacity, from the JFT comparison, both the train and evaluation metrics at the end of the training suggest the following ranking: ",
468
+ "bbox": [
469
+ 176,
470
+ 356,
471
+ 823,
472
+ 385
473
+ ],
474
+ "page_idx": 4
475
+ },
476
+ {
477
+ "type": "equation",
478
+ "img_path": "images/db72680f50180e0871b5c7bce1cdd56ab51755cadb71545f3fb276d6f9b0b410.jpg",
479
+ "text": "$$\n\\mathrm { C - C \\mathrm { - } T \\mathrm { - } T \\approx C \\mathrm { - } T \\mathrm { - } T \\mathrm { - } T > V I T _ { R E L } > C \\mathrm { - } C \\mathrm { - } C \\mathrm { - } T > C \\mathrm { - } C \\mathrm { - } C \\mathrm { - } C \\mathrm { - } C \\mathrm { . } }\n$$",
480
+ "text_format": "latex",
481
+ "bbox": [
482
+ 307,
483
+ 391,
484
+ 702,
485
+ 407
486
+ ],
487
+ "page_idx": 4
488
+ },
489
+ {
490
+ "type": "text",
491
+ "text": "Importantly, this suggests that simply having more Transformer blocks does NOT necessarily mean higher capacity for visual processing. On one hand, while initially worse, $\\mathrm { V I T } _ { \\mathrm { R E L } }$ ultimately catch up with the two variants with more MBConv stages, indicating the capacity advantage of Transformer blocks. On the other hand, both C-C-T-T and C-T-T-T clearly outperforming $\\mathrm { V I T } _ { \\mathrm { R E L } }$ suggest that the ViT stem with an aggressive stride may have lost too much information and hence limit the model capacity. More interestingly, the fact that C-C-T-T $\\approx \\mathbf { C }$ -T-T-T indicates the for processing low-level information, static local operations like convolution could be as capable as adaptive global attention mechanism, while saving computation and memory usage substantially. ",
492
+ "bbox": [
493
+ 186,
494
+ 415,
495
+ 825,
496
+ 526
497
+ ],
498
+ "page_idx": 4
499
+ },
500
+ {
501
+ "type": "text",
502
+ "text": "Finally, to decide between C-C-T-T and C-T-T-T, we conduct another transferability test3 — we finetune the two JFT pre-trained models above on ImageNet-1K for 30 epochs and compare their transfer performances. From Table 2, it turns out that C-C-T-T achieves a clearly better transfer accuracy than C-T-T-T, despite the same pre-training performance. ",
503
+ "bbox": [
504
+ 176,
505
+ 531,
506
+ 825,
507
+ 588
508
+ ],
509
+ "page_idx": 4
510
+ },
511
+ {
512
+ "type": "table",
513
+ "img_path": "images/c21bffeded81866fc6229e3aca114c77d365b7c6effb04ceec185d4089ddb3a2.jpg",
514
+ "table_caption": [
515
+ "Table 2: Transferability test results. "
516
+ ],
517
+ "table_footnote": [],
518
+ "table_body": "<table><tr><td>Metric</td><td>C-C-T-T</td><td>C-T-T-T</td></tr><tr><td>Pre-training Precision@1 (JFT)</td><td>34.40</td><td>34.36</td></tr><tr><td>Transfer Accuracy 224x224</td><td>82.39</td><td>81.78</td></tr><tr><td>Transfer Accuracy 384x384</td><td>84.23</td><td>84.02</td></tr></table>",
519
+ "bbox": [
520
+ 300,
521
+ 612,
522
+ 692,
523
+ 683
524
+ ],
525
+ "page_idx": 4
526
+ },
527
+ {
528
+ "type": "text",
529
+ "text": "Taking generalization, model capacity, transferability and efficiency into consideration, we adapt the C-C-T-T multi-stage layout for CoAtNet. More model details are included in Appendix A.1. ",
530
+ "bbox": [
531
+ 173,
532
+ 696,
533
+ 825,
534
+ 726
535
+ ],
536
+ "page_idx": 4
537
+ },
538
+ {
539
+ "type": "text",
540
+ "text": "3 Related Work ",
541
+ "text_level": 1,
542
+ "bbox": [
543
+ 174,
544
+ 744,
545
+ 321,
546
+ 762
547
+ ],
548
+ "page_idx": 4
549
+ },
550
+ {
551
+ "type": "text",
552
+ "text": "Convolutional network building blocks. Convolutional Networks (ConvNets) have been the dominating neural architectures for many computer vision tasks. Traditionally, regular convolutions, such as ResNet blocks [3], are popular in large-scale ConvNets; in contrast, depthwise convolutions [28] are popular in mobile platforms due to its lower computational cost and smaller parameter size [27]. Recent works show that an improved inverted residual bottlenecks (MBConv [27, 35]), which is built upon depthwise convolutions, can achieve both high accuracy and better efficiency [5, 19]. As discussed in Section 2, due to the strong connection between MBConv and Transformer blocks , this paper mostly employs MBConv as convolution building blocks. ",
553
+ "bbox": [
554
+ 173,
555
+ 775,
556
+ 826,
557
+ 887
558
+ ],
559
+ "page_idx": 4
560
+ },
561
+ {
562
+ "type": "text",
563
+ "text": "Self-attention and Transformers. With the key ingredients of self-attention, Transformers have been widely adopted for neural language processing and speech understanding. As an early work, stand-alone self-attention network [34] shows self-attention alone can work well for different vision tasks, though with some practical difficulties. Recently, ViT [13] applies a vanilla Transformer to ImageNet classification, and achieves impressive results after pre-training on a large-scale JFT dataset. However, ViT still largely lags behind state-of-the-art ConvNets when training data is limited. Following that, many recent works have been focused on improving vision Transformers for data efficiency and model efficiency. For a more comprehensive review of vision Transformers, we refer readers to the dedicated surveys [36, 37]. ",
564
+ "bbox": [
565
+ 174,
566
+ 90,
567
+ 825,
568
+ 215
569
+ ],
570
+ "page_idx": 5
571
+ },
572
+ {
573
+ "type": "text",
574
+ "text": "Relative attention. Under the general name of relative attention, there have been various variants in literature [30, 38, 39, 34, 40, 31]. Generally speaking, we can separate them into two categories: (a) the input-dependent version where the extra relative attention score is a function of the input states $f ( \\bar { x } _ { i } , x _ { j } , \\bar { i } - j )$ , and (b) the input-independent version $f ( i - j )$ . The variant in CoAtNet belongs to the input-independent version, and is similar to the one used in T5 [31], but unlike T5, we neither share the relative attention parameters across layers nor use the bucketing mechanism. As a benefit of the input independence, obtaining $f ( i - j )$ for all $( i , j )$ pairs is computationally much cheaper than the input-dependent version on TPU. In addition, at inference time, this only needs to be computed once and cached for future use. A recent work [22] also utilizes such an input-independent parameterization, but it restricts the receptive field to a local window. ",
575
+ "bbox": [
576
+ 173,
577
+ 229,
578
+ 825,
579
+ 368
580
+ ],
581
+ "page_idx": 5
582
+ },
583
+ {
584
+ "type": "text",
585
+ "text": "Combining convolution and self-attention. The idea of combining convolution and self-attention for vision recognition is not new. A common approach is to augment the ConvNet backbone with explicit self-attention or non-local modules [9, 10, 11, 12], or to replace certain convolution layers with standard self-attention [11] or a more flexible mix of linear attention and convolution [41]. While self-attention usually improves the accuracy, they often come with extra computational cost and hence are often regarded as an add-on to the ConvNets, similar to squeeze-and-excitation [42] module. In comparison, after the success of ViT and ResNet-ViT [13], another popular line of research starts with a Transformer backbone and tries to incorporate explicit convolution or some desirable properties of convolution into the Transformer backbone [25, 24, 23, 22, 21, 43, 44]. ",
586
+ "bbox": [
587
+ 174,
588
+ 382,
589
+ 825,
590
+ 507
591
+ ],
592
+ "page_idx": 5
593
+ },
594
+ {
595
+ "type": "text",
596
+ "text": "While our work also belongs to this category, we show that our relative attention instantiation is a natural mixture of depthwise convolution and content-based attention with minimum additional cost. More importantly, starting from the perspectives of generalization and model capacity, we take a systematic approach to the vertical layout design and show how and why different network stages prefer different types of layers. Therefore, compared to models that simply use an off-the-shelf ConvNet as the stem layer, such as ResNet-ViT [13], CoAtNet also scales the Convolution stage (S2) when the overall size increases. On the other hand, compared to models employing local attention [22, 21], CoAtNet consistently uses full attention for S3 & S4 to ensure the model capacity, as S3 occupies the majority of the computation and parameters. ",
597
+ "bbox": [
598
+ 174,
599
+ 513,
600
+ 825,
601
+ 638
602
+ ],
603
+ "page_idx": 5
604
+ },
605
+ {
606
+ "type": "text",
607
+ "text": "4 Experiments ",
608
+ "text_level": 1,
609
+ "bbox": [
610
+ 174,
611
+ 657,
612
+ 312,
613
+ 674
614
+ ],
615
+ "page_idx": 5
616
+ },
617
+ {
618
+ "type": "text",
619
+ "text": "In this section, we compare CoAtNet with previous results under comparable settings. For completeness, all the hyper-parameters not mentioned here are included in Appendix A.2. ",
620
+ "bbox": [
621
+ 174,
622
+ 688,
623
+ 823,
624
+ 717
625
+ ],
626
+ "page_idx": 5
627
+ },
628
+ {
629
+ "type": "text",
630
+ "text": "4.1 Experiment Setting ",
631
+ "text_level": 1,
632
+ "bbox": [
633
+ 174,
634
+ 732,
635
+ 348,
636
+ 747
637
+ ],
638
+ "page_idx": 5
639
+ },
640
+ {
641
+ "type": "text",
642
+ "text": "CoAtNet model family. To compare with existing models of different sizes, we also design a family of CoAtNet models as summarized in Table 3. Overall, we always double the number of channels from S1 to S4, while ensuring the width of the Stem S0 to be smaller or equal to that of S1. Also, for simplicity, when increasing the depth of the network, we only scale the number of blocks in S2 and S3. ",
643
+ "bbox": [
644
+ 174,
645
+ 757,
646
+ 825,
647
+ 827
648
+ ],
649
+ "page_idx": 5
650
+ },
651
+ {
652
+ "type": "text",
653
+ "text": "Evaluation Protocol. Our experiments focus on image classification. To evaluate the performance of the model across different data sizes, we utilize three datasets of increasingly larger sizes, namely ImageNet-1K (1.28M images), ImageNet-21K (12.7M images) and JFT (300M images). Following previous works, we first pre-train our models on each of the three datasets at resolution 224 for 300, 90 and 14 epochs respectively. Then, we finetune the pre-trained models on ImageNet-1K at the desired resolutions for 30 epochs and obtain the corresponding evaluation accuracy. One exception is the ImageNet-1K performance at resolution 224, which can be directly obtained at the end of pre-training. Note that similar to other models utilizing Transformer blocks, directly evaluating models pre-trained on ImageNet-1K at a larger resolution without finetuning usually leads to performance drop. Hence, finetuning is always employed whenever input resolution changes. ",
654
+ "bbox": [
655
+ 174,
656
+ 842,
657
+ 823,
658
+ 911
659
+ ],
660
+ "page_idx": 5
661
+ },
662
+ {
663
+ "type": "table",
664
+ "img_path": "images/84f510eacc36a4509902c6b3ea9d4f6ed24dfc3c9e12f559c758703dee925573.jpg",
665
+ "table_caption": [
666
+ "Table 3: L denotes the number of blocks and D denotes the hidden dimension (#channels). For all Conv and MBConv blocks, we always use the kernel size 3. For all Transformer blocks, we set the size of each attention head to 32, following [22]. The expansion rate for the inverted bottleneck is always 4 and the expansion (shrink) rate for the SE is always 0.25. "
667
+ ],
668
+ "table_footnote": [],
669
+ "table_body": "<table><tr><td> Stages</td><td>Size</td><td>CoAtNet-0</td><td></td><td>CoAtNet-1</td><td>CoAtNet-2</td><td></td><td>CoAtNet-3</td><td>CoAtNet-4</td></tr><tr><td>S0-Conv</td><td>1/2</td><td>L=2 D=64</td><td>L=2</td><td>D=64</td><td>L=2</td><td>D=128 L=2</td><td>D=192</td><td>L=2 D=192</td></tr><tr><td>S1-MbConv</td><td>1/4</td><td>L=2 D=96</td><td>L=2</td><td>D=96</td><td>L=2 D=128</td><td>L=2</td><td>D=192</td><td>L=2 D=192</td></tr><tr><td>S2-MBConv</td><td>1/8</td><td>L=3 D=192</td><td>L=6</td><td>D=192</td><td>L=6 D=256</td><td>L=6</td><td>D=384</td><td>L=12 D=384</td></tr><tr><td>S3-TFMRel</td><td>1/16</td><td>L=5 D=384</td><td>L=14</td><td>D=384</td><td>L=14 D=512</td><td>L=14</td><td>D=768</td><td>L=28 D=768</td></tr><tr><td>S4-TFMRel</td><td>1/32</td><td>L=2 D=768</td><td>L=2</td><td>D=768</td><td>L=2 D=1024</td><td>L=2</td><td>D=1536</td><td>L=2 D=1536</td></tr></table>",
670
+ "bbox": [
671
+ 173,
672
+ 154,
673
+ 826,
674
+ 244
675
+ ],
676
+ "page_idx": 6
677
+ },
678
+ {
679
+ "type": "text",
680
+ "text": "",
681
+ "bbox": [
682
+ 173,
683
+ 261,
684
+ 826,
685
+ 332
686
+ ],
687
+ "page_idx": 6
688
+ },
689
+ {
690
+ "type": "text",
691
+ "text": "Data Augmentation & Regularization. In this work, we only consider two widely used data augmentations, namely RandAugment [45] and MixUp [46], and three common techniques, including stochastic depth [47], label smoothing [48] and weight decay [49], to regularize the model. Intuitively, the specific hyper-parameters of the augmentation and regularization methods depend on model size and data scale, where strong regularization is usually applied for larger models and smaller dataset. ",
692
+ "bbox": [
693
+ 174,
694
+ 347,
695
+ 825,
696
+ 416
697
+ ],
698
+ "page_idx": 6
699
+ },
700
+ {
701
+ "type": "text",
702
+ "text": "Under the general principle, a complication under the current paradigm is how to adjust the regularization for pre-training and finetuning as data size can change. Specifically, we have an interesting observation that if a certain type of augmentation is entirely disabled during pre-training, simply turning it on during fine-tuning would most likely harm the performance rather than improving. We conjecture this could be related to data distribution shift. As a result, for certain runs of the proposed model, we deliberately apply RandAugment and stochastic depth of a small degree when pre-training on the two larger datasets, ImageNet21-K and JFT. Although such regularization can harm the pre-training metrics, this allows more versatile regularization and augmentation during finetuning, leading to improved down-stream performances. ",
703
+ "bbox": [
704
+ 173,
705
+ 422,
706
+ 826,
707
+ 547
708
+ ],
709
+ "page_idx": 6
710
+ },
711
+ {
712
+ "type": "text",
713
+ "text": "4.2 Main Results ",
714
+ "text_level": 1,
715
+ "bbox": [
716
+ 174,
717
+ 565,
718
+ 305,
719
+ 579
720
+ ],
721
+ "page_idx": 6
722
+ },
723
+ {
724
+ "type": "image",
725
+ "img_path": "images/cf1567b93b834a38bb5d149ee37f969799ca7bcd6b3f63af756a7cd673e8c469.jpg",
726
+ "image_caption": [
727
+ "Figure 2: Accuracy-to-FLOPs scaling curve under ImageNet-1K only setting at $2 2 4 \\mathbf { x } 2 2 4$ . "
728
+ ],
729
+ "image_footnote": [],
730
+ "bbox": [
731
+ 179,
732
+ 601,
733
+ 478,
734
+ 785
735
+ ],
736
+ "page_idx": 6
737
+ },
738
+ {
739
+ "type": "image",
740
+ "img_path": "images/f8c09d4a039db4e8c22000a3a3a66bae5de7e541a68ec3f2c6a6234546bf4ac2.jpg",
741
+ "image_caption": [
742
+ "Figure 3: Accuracy-to-Params scaling curve under ImageNet- $2 1 \\mathrm { K } \\Rightarrow$ ImageNet-1K setting. "
743
+ ],
744
+ "image_footnote": [],
745
+ "bbox": [
746
+ 513,
747
+ 602,
748
+ 813,
749
+ 785
750
+ ],
751
+ "page_idx": 6
752
+ },
753
+ {
754
+ "type": "text",
755
+ "text": "ImageNet-1K The experiment results with only the ImageNet-1K dataset are shown in Table 4. Under similar conditions, the proposed CoAtNet models not only outperform ViT variants, but also match the best convolution-only architectures, i.e., EfficientNet-V2 and NFNets. Additionally, we also visualize the all results at resolution $2 2 4 \\mathbf { x } 2 2 4$ in Fig. 2. As we can see, CoAtNet scales much better than previous model with attention modules. ",
756
+ "bbox": [
757
+ 174,
758
+ 842,
759
+ 825,
760
+ 911
761
+ ],
762
+ "page_idx": 6
763
+ },
764
+ {
765
+ "type": "table",
766
+ "img_path": "images/07c0ff9e9c5c785f3c33e97ba94f2023e40f027155a317dec4e0af0e0e53d4b3.jpg",
767
+ "table_caption": [
768
+ "Table 4: Model performance on ImageNet. 1K only denotes training on ImageNet-1K only; $2 1 \\mathtt { K } + 1 \\mathtt { K }$ denotes pre-training on ImageNet-21K and finetuning on ImageNet-1K; PT-RA denotes applying RandAugment during 21K pre-training, and E150 means 150 epochs of 21K pre-training, which is longer than the standard 90 epochs. More results are in Appendix A.3. "
769
+ ],
770
+ "table_footnote": [],
771
+ "table_body": "<table><tr><td colspan=\"2\">Models</td><td>Eval Size</td><td>#Params</td><td>#FLOPs</td><td colspan=\"2\">ImageNet Top-1 Accuracy</td></tr><tr><td rowspan=\"5\">Conv Only</td><td></td><td></td><td></td><td></td><td>1K only</td><td>21K+1K</td></tr><tr><td>EfficientNet-B7</td><td>600²</td><td>66M</td><td>37B</td><td>84.7</td><td>-</td></tr><tr><td>EfficientNetV2-L</td><td>480²</td><td>121M</td><td>53B</td><td>85.7</td><td>86.8</td></tr><tr><td>NFNet-F3</td><td>4162²</td><td>255M</td><td>114.8B</td><td>85.7</td><td>=</td></tr><tr><td>NFNet-F5</td><td>5442</td><td>377M</td><td>289.8B</td><td>86.0</td><td>1</td></tr><tr><td rowspan=\"4\">ViT-Stem TFM</td><td>DeiT-B</td><td>3842</td><td>86M</td><td>55.4B</td><td>83.1</td><td>-</td></tr><tr><td>ViT-L/16</td><td>384²</td><td>304M</td><td>190.7B</td><td>-</td><td>85.3</td></tr><tr><td>CaiT-S-36</td><td>384²</td><td>68M</td><td>48.0B</td><td>85.0</td><td></td></tr><tr><td>DeepViT-L</td><td>224²</td><td>55M</td><td>12.5B</td><td>83.1</td><td>-</td></tr><tr><td rowspan=\"2\">Multi-stage TFM</td><td>Swin-B</td><td>384²</td><td>88M</td><td>47.0B</td><td>84.2</td><td>86.0</td></tr><tr><td>Swin-L</td><td>384²</td><td>197M</td><td>103.9B</td><td>-</td><td>86.4</td></tr><tr><td rowspan=\"5\">Conv+TFM</td><td>BotNet-T7</td><td>3842</td><td>75.1M</td><td>45.8B</td><td>84.7</td><td>-</td></tr><tr><td>LambdaResNet-420</td><td>320²</td><td>-</td><td>=</td><td>84.8</td><td></td></tr><tr><td>T2T-ViT-24</td><td>224²</td><td>64.1M</td><td>15.0B</td><td>82.6</td><td>=</td></tr><tr><td>CvT-21</td><td>384²</td><td>32M</td><td>24.9B</td><td>83.3</td><td>-</td></tr><tr><td>CvT-W24</td><td>3842</td><td>277M</td><td>193.2B</td><td>-</td><td>87.7</td></tr><tr><td rowspan=\"19\">Conv+TFM (ours)</td><td>CoAtNet-0 CoAtNet-1</td><td>224²</td><td>25M</td><td>4.2B</td><td>81.6</td><td>=</td></tr><tr><td></td><td>224²</td><td>42M</td><td>8.4B</td><td>83.3</td><td>-</td></tr><tr><td>CoAtNet-2 CoAtNet-3</td><td>224²</td><td>75M</td><td>15.7B</td><td>84.1</td><td>87.1</td></tr><tr><td></td><td>2242</td><td>168M</td><td>34.7B</td><td>84.5</td><td>87.6</td></tr><tr><td>CoAtNet-0</td><td>384²</td><td>25M</td><td>13.4B</td><td>83.9</td><td>-</td></tr><tr><td>CoAtNet-1</td><td>3842</td><td>42M</td><td>27.4B</td><td>85.1</td><td>-</td></tr><tr><td>CoAtNet-2</td><td>384²</td><td>75M</td><td>49.8B</td><td>85.7</td><td>87.1</td></tr><tr><td>CoAtNet-3</td><td>384²</td><td>168M</td><td>107.4B</td><td>85.8</td><td>87.6</td></tr><tr><td>CoAtNet-4</td><td>384²</td><td>275M</td><td>189.5B</td><td>-</td><td>87.9</td></tr><tr><td>+ PT-RA</td><td>384²</td><td>275M</td><td>189.5B</td><td></td><td>88.3</td></tr><tr><td>+ PT-RA-E150</td><td>3842</td><td>275M</td><td>189.5B</td><td></td><td>88.4</td></tr><tr><td>CoAtNet-2</td><td>5122</td><td>75M</td><td>96.7B</td><td>85.9</td><td>87.3</td></tr><tr><td>CoAtNet-3</td><td>512²</td><td>168M</td><td>203.1B</td><td>86.0</td><td>87.9</td></tr><tr><td>CoAtNet-4</td><td>512²</td><td>275M</td><td>360.9B</td><td>-</td><td>88.1</td></tr><tr><td>+ PT-RA</td><td>512²</td><td>275M</td><td>360.9B</td><td>=</td><td>88.4</td></tr><tr><td>+ PT-RA-E150</td><td>5122</td><td>275M</td><td>360.9B</td><td>=</td><td>88.56</td></tr></table>",
772
+ "bbox": [
773
+ 171,
774
+ 140,
775
+ 843,
776
+ 645
777
+ ],
778
+ "page_idx": 7
779
+ },
780
+ {
781
+ "type": "text",
782
+ "text": "ImageNet-21K As we can see from Table 4 and Fig. 3, when ImageNet-21K is used for pretraining, the advantage of CoAtNet becomes more obvious, substantially outperforming all previous models. Notably, the best CoAtNet variant achieves a top-1 accuracy of $8 8 . 5 6 \\%$ , matching the ViTH/14 performance of $8 8 . 5 5 \\%$ , which requires pre-training the $2 . 3 \\mathbf { x }$ larger ViT model on a $2 3 \\mathrm { x }$ larger proprietary weakly labeled dataset (JFT) for $2 . 2 \\mathbf { x }$ more steps. This marks a dramatic improvement in both data efficiency and computation efficiency. ",
783
+ "bbox": [
784
+ 174,
785
+ 681,
786
+ 826,
787
+ 766
788
+ ],
789
+ "page_idx": 7
790
+ },
791
+ {
792
+ "type": "text",
793
+ "text": "JFT Finally, in Table 5, we further evaluate CoAtNet under the large-scale data regime with JFT300M and JFT-3B. Encouragingly, our CoAtNet-4 can almost match the best previous performance with JFT-300M set by NFNet- $\\mathrm { F 4 + }$ , while being $2 \\mathbf { x }$ more efficient in terms of both TPU training time and parameter count. When we scale up the model to consume similar training resource as NFNet- $. \\mathrm { F 4 + }$ , CoAtNet-5 reaches $8 9 . 7 7 \\%$ on top-1 accuracy, outperforming previous results under comparable settings. ",
794
+ "bbox": [
795
+ 174,
796
+ 792,
797
+ 825,
798
+ 877
799
+ ],
800
+ "page_idx": 7
801
+ },
802
+ {
803
+ "type": "text",
804
+ "text": "Moreover, as we further push the training resource towards the level used by ViT-G/14 and utilize the same JFT-3B dataset of an even larger size [26], with over $4 \\mathbf { x }$ less computation, CoAtNet-6 is able to match the performance of $\\mathrm { V i T - G } / 1 4$ of $9 0 . 4 5 \\%$ , and with $1 . 5 \\mathrm { x }$ less computation, CoAtNet-7 achieves $8 9 . 7 7 \\%$ on top-1 accuracy $9 0 . 8 8 \\%$ , achieving the new state-of-the-art performance. ",
805
+ "bbox": [
806
+ 174,
807
+ 883,
808
+ 821,
809
+ 911
810
+ ],
811
+ "page_idx": 7
812
+ },
813
+ {
814
+ "type": "table",
815
+ "img_path": "images/4da8c9ad6e7a2eb2d4e66c521d47f928929362333fe2c47dcf4ccbd3f89040eb.jpg",
816
+ "table_caption": [
817
+ "Table 5: Performance Comparison on large-scale JFT dataset. TPUv3-core-days denotes the pretraining time, Top-1 Accuracy denotes the finetuned accuracy on ImageNet. Note that the last 3 rows use a larger dataset JFT-3B [26] for pre-training, while others use JFT-300M [15]. See Appendix A.2 for the size details of CoAtNet-5/6/7. †: Down-sampling in the MBConv block is achieved by stride-2 Depthwise Convolution. ⇧: ViT-G/14 computation consumption is read from Fig. 1 of the paper [26]. "
818
+ ],
819
+ "table_footnote": [],
820
+ "table_body": "<table><tr><td>Models</td><td>Eval Size</td><td>#Params</td><td>#FLOPs</td><td>TPUv3-core-days</td><td>Top-1 Accuracy</td></tr><tr><td>ResNet + ViT-L/16</td><td>3842</td><td>330M</td><td>=</td><td>1</td><td>87.12</td></tr><tr><td>ViT-L/16</td><td>5122</td><td>307M</td><td>364B</td><td>0.68K</td><td>87.76</td></tr><tr><td>ViT-H/14</td><td>5182</td><td>632M</td><td>1021B</td><td>2.5K</td><td>88.55</td></tr><tr><td>NFNet-F4+</td><td>5122</td><td>527M</td><td>367B</td><td>1.86K</td><td>89.2</td></tr><tr><td>CoAtNet-3t</td><td>3842</td><td>168M</td><td>114B</td><td>0.58K</td><td>88.52</td></tr><tr><td>CoAtNet-3t</td><td>5122</td><td>168M</td><td>214B</td><td>0.58K</td><td>88.81</td></tr><tr><td>CoAtNet-4</td><td>5122</td><td>275M</td><td>361B</td><td>0.95K</td><td>89.11</td></tr><tr><td>CoAtNet-5</td><td>5122</td><td>688M</td><td>812B</td><td>1.82K</td><td>89.77</td></tr><tr><td>ViT-G/14</td><td>5182</td><td>1.84B</td><td>5160B</td><td>&gt;30K</td><td>90.45</td></tr><tr><td>CoAtNet-6</td><td>5122</td><td>1.47B</td><td>1521B</td><td>6.6K</td><td>90.45</td></tr><tr><td>CoAtNet-7</td><td>5122</td><td>2.44B</td><td>2586B</td><td>20.1K</td><td>90.88</td></tr></table>",
821
+ "bbox": [
822
+ 173,
823
+ 156,
824
+ 834,
825
+ 358
826
+ ],
827
+ "page_idx": 8
828
+ },
829
+ {
830
+ "type": "text",
831
+ "text": "",
832
+ "bbox": [
833
+ 174,
834
+ 372,
835
+ 823,
836
+ 401
837
+ ],
838
+ "page_idx": 8
839
+ },
840
+ {
841
+ "type": "text",
842
+ "text": "4.3 Ablation Studies ",
843
+ "text_level": 1,
844
+ "bbox": [
845
+ 174,
846
+ 416,
847
+ 328,
848
+ 431
849
+ ],
850
+ "page_idx": 8
851
+ },
852
+ {
853
+ "type": "text",
854
+ "text": "In this section, we will ablate our design choices for CoAtNet. ",
855
+ "bbox": [
856
+ 174,
857
+ 441,
858
+ 581,
859
+ 457
860
+ ],
861
+ "page_idx": 8
862
+ },
863
+ {
864
+ "type": "text",
865
+ "text": "Firstly, we study the importance of the relative attention from combining convolution and attention into a single computation unit. Specifically, we compare two models, one with the relative attention and the other without, under both the ImageNet-1K alone and ImageNet-21K transfer setting. As we can see from Table 6, when only the ImageNet-1K is used, relative attention clearly outperforms the standard attention, indicating a better generalization. In addition, under the ImageNet-21K transfer setting, the relative attention variant achieves a substantially better transfer accuracy, despite their very close pre-training performances. This suggests the main advantage of relative attention in visual processing is not in higher capacity but in better generalization. ",
866
+ "bbox": [
867
+ 173,
868
+ 462,
869
+ 825,
870
+ 574
871
+ ],
872
+ "page_idx": 8
873
+ },
874
+ {
875
+ "type": "table",
876
+ "img_path": "images/00ceb486f1a8197ca19a9f75354b351e896ee887a8c0a4bb90f5cf09fdd07a32.jpg",
877
+ "table_caption": [
878
+ "Table 6: Ablation on relative attention. "
879
+ ],
880
+ "table_footnote": [],
881
+ "table_body": "<table><tr><td>Seting</td><td>Metric</td><td>With Rel-Attn</td><td>Without Rel-Attn</td></tr><tr><td rowspan=\"2\">ImageNet-1K</td><td>Accuracy (2242)</td><td>84.1</td><td>83.8</td></tr><tr><td>Accuracy (3842)</td><td>85.7</td><td>85.3</td></tr><tr><td rowspan=\"2\">ImageNet-21K →ImageNet-1K</td><td>Pre-train Precision@1 (224²)</td><td>53.0</td><td>52.8</td></tr><tr><td>Finetune Accuracy (384²)</td><td>87.9</td><td>87.4</td></tr></table>",
882
+ "bbox": [
883
+ 192,
884
+ 597,
885
+ 800,
886
+ 691
887
+ ],
888
+ "page_idx": 8
889
+ },
890
+ {
891
+ "type": "table",
892
+ "img_path": "images/06fc157c275539a26e5cec13a54703dca4447c0c9a577af5fa97836a983d1abe.jpg",
893
+ "table_caption": [
894
+ "Table 7: Ablation on architecture layout. "
895
+ ],
896
+ "table_footnote": [],
897
+ "table_body": "<table><tr><td>Setting</td><td>Models</td><td>Layout</td><td>Top-1 Accuracy</td></tr><tr><td rowspan=\"3\">ImageNet-1K</td><td>VO: CoAtNet-2</td><td>[2,2,6,14,2]</td><td>84.1</td></tr><tr><td>V1: S2← S3</td><td>[2,2, 2,18,2]</td><td>83.4</td></tr><tr><td>V2: S2→ S3</td><td>[2,2,8,12,2]</td><td>84.0</td></tr><tr><td>ImageNet-21K</td><td>VO: CoAtNet-3</td><td>[2,2,6,14,2]</td><td>53.0 -→87.6</td></tr><tr><td>⇒ImageNet-1K</td><td>V1: S2 ← S3</td><td>[2,2,2,18,2]</td><td>53.0 -→87.4</td></tr></table>",
898
+ "bbox": [
899
+ 227,
900
+ 723,
901
+ 766,
902
+ 828
903
+ ],
904
+ "page_idx": 8
905
+ },
906
+ {
907
+ "type": "text",
908
+ "text": "Secondly, as S2 with MBConv blocks and S3 with relative Transformer blocks occupy most of the computation of the CoAtNet, a question to ask is how to split the computation between S2 (MBConv) and S3 (Transformer) to achieve a good performance. In practice, it boils down to deciding the number of blocks to have in each stage, which we will refer to as “layout” design. For this purpose, we compare a few different layouts that we experimented with in Table 7. ",
909
+ "bbox": [
910
+ 174,
911
+ 842,
912
+ 826,
913
+ 911
914
+ ],
915
+ "page_idx": 8
916
+ },
917
+ {
918
+ "type": "table",
919
+ "img_path": "images/622bb1939958732b44fe6505260003f83b893fe0388e4f1de344e047e3c173b0.jpg",
920
+ "table_caption": [
921
+ "Table 8: Ablation on head size and normalization type. "
922
+ ],
923
+ "table_footnote": [],
924
+ "table_body": "<table><tr><td>Setting</td><td>Models</td><td>Image Size</td><td>Top-1 Accuracy</td></tr><tr><td rowspan=\"3\">ImageNet-1K</td><td>CoAtNet-2</td><td>2242</td><td>84.1</td></tr><tr><td>Head size: 32 → 64</td><td>2242</td><td>83.9</td></tr><tr><td>Norm type: 1 BN →LN</td><td>2242</td><td>84.1</td></tr><tr><td rowspan=\"2\">ImageNet-21K ⇒ ImageNet-1K</td><td>CoAtNet-3</td><td>3842</td><td>87.9</td></tr><tr><td>Norm type: BN →→ LN</td><td>384²</td><td>87.8</td></tr></table>",
925
+ "bbox": [
926
+ 225,
927
+ 99,
928
+ 767,
929
+ 208
930
+ ],
931
+ "page_idx": 9
932
+ },
933
+ {
934
+ "type": "text",
935
+ "text": "• If we keep the total number of blocks in S2 and S3 fixed and vary the number in each stage, we observe that V0 is a sweet spot between V1 and V2. Basically, having more Transformer blocks in S3 generally leads to better performance until the number of MBConv blocks in S2 is too small to generalize well. ",
936
+ "bbox": [
937
+ 174,
938
+ 233,
939
+ 823,
940
+ 289
941
+ ],
942
+ "page_idx": 9
943
+ },
944
+ {
945
+ "type": "text",
946
+ "text": "• To further evaluate whether the sweet spot also holds in the transfer setting, where a higher capacity is often regarded more important, we further compare V0 and V1 under the ImageNet21K transferring to ImageNet-1K setup. Interestingly, despite that V1 and V0 have the same performance during ImageNet-21K pre-training, the transfer accuracy of V1 clearly falls behind V0. Again, this suggests the importance of convolution in achieving good transferability and generalization. ",
947
+ "bbox": [
948
+ 173,
949
+ 291,
950
+ 825,
951
+ 373
952
+ ],
953
+ "page_idx": 9
954
+ },
955
+ {
956
+ "type": "text",
957
+ "text": "Lastly, we study two choices of model details, namely the dimension of each attention (default to 32) head as well as the type of normalization (default to BatchNorm) used in MBConv blocks. From Table 8, we can see increasing head size from 32 to 64 can slightly hurt performance, though it actually improves the TPU speed by a significant amount. In practice, this will be a quality-speed trade-off one can make. On the other hand, BatchNorm and LayerNorm have almost the same performance, while BatchNorm is $10 - 2 0 \\%$ faster on TPU depending on the per-core batch size. ",
958
+ "bbox": [
959
+ 174,
960
+ 381,
961
+ 825,
962
+ 463
963
+ ],
964
+ "page_idx": 9
965
+ },
966
+ {
967
+ "type": "text",
968
+ "text": "5 Conclusion ",
969
+ "text_level": 1,
970
+ "bbox": [
971
+ 174,
972
+ 483,
973
+ 299,
974
+ 500
975
+ ],
976
+ "page_idx": 9
977
+ },
978
+ {
979
+ "type": "text",
980
+ "text": "In this paper, we systematically study the properties of convolutions and Transformers, which leads to a principled way to combine them into a new family of models named CoAtNet. Extensive experiments show that CoAtNet enjoys both good generalization like ConvNets and superior model capacity like Transformers, achieving state-of-the-art performances under different data sizes and computation budgets. ",
981
+ "bbox": [
982
+ 174,
983
+ 513,
984
+ 825,
985
+ 583
986
+ ],
987
+ "page_idx": 9
988
+ },
989
+ {
990
+ "type": "text",
991
+ "text": "Note that this paper currently focuses on ImageNet classification for model development. However, we believe our approach is applicable to broader applications like object detection and semantic segmentation. We will leave them for future work. ",
992
+ "bbox": [
993
+ 174,
994
+ 590,
995
+ 823,
996
+ 632
997
+ ],
998
+ "page_idx": 9
999
+ },
1000
+ {
1001
+ "type": "text",
1002
+ "text": "References ",
1003
+ "text_level": 1,
1004
+ "bbox": [
1005
+ 174,
1006
+ 90,
1007
+ 266,
1008
+ 106
1009
+ ],
1010
+ "page_idx": 10
1011
+ },
1012
+ {
1013
+ "type": "text",
1014
+ "text": "[1] Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems, pages 1097–1105, 2012. \n[2] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015. \n[3] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016. \n[4] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1–9, 2015. \n[5] Mingxing Tan and Quoc V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. ICML, 2019. \n[6] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762, 2017. \n[7] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018. \n[8] Tom B Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020. \n[9] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7794–7803, 2018. \n[10] 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, pages 3286–3295, 2019. \n[11] 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. \n[12] Zhuoran Shen, Mingyuan Zhang, Haiyu Zhao, Shuai Yi, and Hongsheng Li. Efficient attention: Attention with linear complexities. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 3531–3539, 2021. \n[13] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020. \n[14] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A largescale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. Ieee, 2009. \n[15] Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In Proceedings of the IEEE international conference on computer vision, pages 843–852, 2017. \n[16] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. arXiv preprint arXiv:2012.12877, 2020. \n[17] Hugo Touvron, Matthieu Cord, Alexandre Sablayrolles, Gabriel Synnaeve, and Hervé Jégou. Going deeper with image transformers. arXiv preprint arXiv:2103.17239, 2021. \n[18] Daquan Zhou, Bingyi Kang, Xiaojie Jin, Linjie Yang, Xiaochen Lian, Qibin Hou, and Jiashi Feng. Deepvit: Towards deeper vision transformer. arXiv preprint arXiv:2103.11886, 2021. \n[19] Mingxing Tan and Quoc V Le. Efficientnetv2: Smaller models and faster training. ICML, 2021. \n[20] Andrew Brock, Soham De, Samuel L Smith, and Karen Simonyan. High-performance largescale image recognition without normalization. arXiv preprint arXiv:2102.06171, 2021. \n[21] Ashish Vaswani, Prajit Ramachandran, Aravind Srinivas, Niki Parmar, Blake Hechtman, and Jonathon Shlens. Scaling local self-attention for parameter efficient visual backbones. arXiv preprint arXiv:2103.12731, 2021. \n[22] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. arXiv preprint arXiv:2103.14030, 2021. \n[23] Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang. Cvt: Introducing convolutions to vision transformers. arXiv preprint arXiv:2103.15808, 2021. \n[24] Ben Graham, Alaaeldin El-Nouby, Hugo Touvron, Pierre Stock, Armand Joulin, Hervé Jégou, and Matthijs Douze. Levit: a vision transformer in convnet’s clothing for faster inference. arXiv preprint arXiv:2104.01136, 2021. \n[25] 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. arXiv preprint arXiv:2101.11986, 2021. \n[26] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. arXiv preprint arXiv:2106.04560, 2021. \n[27] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4510–4520, 2018. \n[28] Laurent Sifre. Rigid-motion scattering for image classification. Ph.D. thesis section 6.2, 2014. \n[29] Mirgahney Mohamed, Gabriele Cesa, Taco S Cohen, and Max Welling. A data and compute efficient design for limited-resources deep learning. arXiv preprint arXiv:2004.09691, 2020. \n[30] Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. arXiv preprint arXiv:1803.02155, 2018. \n[31] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. arXiv preprint arXiv:1910.10683, 2019. \n[32] Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In International Conference on Machine Learning, pages 5156–5165. PMLR, 2020. \n[33] Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. Rethinking attention with performers. arXiv preprint arXiv:2009.14794, 2020. \n[34] 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, 2019. \n[35] Mingxing Tan, Bo Chen, Ruoming Pang, Vijay Vasudevan, Mark Sandler, Andrew Howard, and Quoc V Le. Mnasnet: Platform-aware neural architecture search for mobile. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2820–2828, 2019. \n[36] Kai Han, Yunhe Wang, Hanting Chen, Xinghao Chen, Jianyuan Guo, Zhenhua Liu, Yehui Tang, An Xiao, Chunjing Xu, Yixing Xu, et al. A survey on visual transformer. arXiv preprint arXiv:2012.12556, 2020. \n[37] Salman Khan, Muzammal Naseer, Munawar Hayat, Syed Waqas Zamir, Fahad Shahbaz Khan, and Mubarak Shah. Transformers in vision: A survey. arXiv preprint arXiv:2101.01169, 2021. \n[38] Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Noam Shazeer, Ian Simon, Curtis Hawthorne, Andrew M Dai, Matthew D Hoffman, Monica Dinculescu, and Douglas Eck. Music transformer. arXiv preprint arXiv:1809.04281, 2018. \n[39] Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc V Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. arXiv preprint arXiv:1901.02860, 2019. \n[40] Yao-Hung Hubert Tsai, Shaojie Bai, Makoto Yamada, Louis-Philippe Morency, and Ruslan Salakhutdinov. Transformer dissection: A unified understanding of transformer’s attention via the lens of kernel. arXiv preprint arXiv:1908.11775, 2019. \n[41] Irwan Bello. Lambdanetworks: Modeling long-range interactions without attention. arXiv preprint arXiv:2102.08602, 2021. \n[42] Jie Hu, Li Shen, and Gang Sun. Squeeze-and-excitation networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7132–7141, 2018. \n[43] Kun Yuan, Shaopeng Guo, Ziwei Liu, Aojun Zhou, Fengwei Yu, and Wei Wu. Incorporating convolution designs into visual transformers. arXiv preprint arXiv:2103.11816, 2021. \n[44] Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. arXiv preprint arXiv:2102.12122, 2021. \n[45] Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pages 702–703, 2020. \n[46] Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017. \n[47] Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European conference on computer vision, pages 646–661. Springer, 2016. \n[48] 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. \n[49] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017. \n[50] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European conference on computer vision, pages 630–645. Springer, 2016. \n[51] Dan Hendrycks and Kevin Gimpel. Gaussian error linear units (gelus). arXiv preprint arXiv:1606.08415, 2016. \n[52] Zihang Dai, Guokun Lai, Yiming Yang, and Quoc V Le. Funnel-transformer: Filtering out sequential redundancy for efficient language processing. arXiv preprint arXiv:2006.03236, 2020. ",
1015
+ "bbox": [
1016
+ 173,
1017
+ 119,
1018
+ 828,
1019
+ 914
1020
+ ],
1021
+ "page_idx": 10
1022
+ },
1023
+ {
1024
+ "type": "text",
1025
+ "text": "",
1026
+ "bbox": [
1027
+ 171,
1028
+ 45,
1029
+ 828,
1030
+ 917
1031
+ ],
1032
+ "page_idx": 11
1033
+ },
1034
+ {
1035
+ "type": "text",
1036
+ "text": "",
1037
+ "bbox": [
1038
+ 171,
1039
+ 85,
1040
+ 828,
1041
+ 631
1042
+ ],
1043
+ "page_idx": 12
1044
+ }
1045
+ ]
parse/train/JXAyJeYqUkZ/JXAyJeYqUkZ_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/JXAyJeYqUkZ/JXAyJeYqUkZ_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/LyjH88yV7F/LyjH88yV7F.md ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Learning Graph Models for Retrosynthesis Prediction
2
+
3
+ Vignesh Ram Somnath1
4
+
5
+ Charlotte Bunne1
6
+
7
+ Connor W. Coley2
8
+
9
+ Andreas Krause1 Regina Barzilay3
10
+
11
+ 1Department of Computer Science, ETH 2Department of Chemical Engineering, MIT 3Computer Science and Artificial Intelligence Lab, MIT 1{vsomnath, bunnec, krausea}@ethz.ch, 2ccoley@mit.edu, 3regina@csail.mit.edu
12
+
13
+ # Abstract
14
+
15
+ Retrosynthesis prediction is a fundamental problem in organic synthesis, where the task is to identify precursor molecules that can be used to synthesize a target molecule. A key consideration in building neural models for this task is aligning model design with strategies adopted by chemists. Building on this viewpoint, this paper introduces a graph-based approach that capitalizes on the idea that the graph topology of precursor molecules is largely unaltered during a chemical reaction. The model first predicts the set of graph edits transforming the target into incomplete molecules called synthons. Next, the model learns to expand synthons into complete molecules by attaching relevant leaving groups. This decomposition simplifies the architecture, making its predictions more interpretable, and also amenable to manual correction. Our model achieves a top-1 accuracy of $5 3 . 7 \%$ , outperforming previous template-free and semi-template-based methods.
16
+
17
+ # 1 Introduction
18
+
19
+ Retrosynthesis prediction, first formalized by E. J. Corey [Corey, 1991] is a fundamental problem in organic synthesis that attempts to identify a series of chemical transformations for synthesizing a target molecule. In the single-step formulation, the task is to identify a set of reactant molecules given a target. Beyond simple reactions, many practical tasks involving complex organic molecules are difficult even for expert chemists. As a result, substantial experimental exploration is needed to cover for deficiencies of analytical approaches. This has motivated interest in computer-assisted retrosynthesis [Corey and Wipke, 1969], with a recent surge in machine learning methods [Chen et al., 2019, Coley et al., 2017b, Dai et al., 2019, Zheng et al., 2019, Genheden et al., 2020].
20
+
21
+ Computationally, the main challenge is how to explore the combinatorial space of reactions that can yield the target molecule. Largely, previous methods for retrosynthesis prediction can be divided into template-based [Coley et al., 2017b, Dai et al., 2019, Segler and Waller, 2017] and template-free [Chen et al., 2019, Zheng et al., 2019] approaches. Template-based methods match a target molecule against a large set of templates, which are molecular subgraph patterns that highlight changes during a chemical reaction. Despite their interpretability, these methods fail to generalize to new reactions. Template-free methods bypass templates by learning a direct mapping from the SMILES [Weininger, 1988] representations of the product to reactants. Despite their greater generalization potential, these methods generate reactant SMILES character by character, increasing generation complexity.
22
+
23
+ ![](images/e988f2e4a9f13ae6fa41934806006c24c87183942b7fd7f824274aee3a6237f9.jpg)
24
+ Figure 1: Overview of Our Approach. a. Edit Prediction. We train a model to learn a distribution over possible graph edits. In this case, the correct edit corresponds to breaking the bond marked in red. Applying this edit produces two synthons. b. Synthon Completion. Another model is trained to pick candidate leaving groups (blue) for each synthon from a discrete vocabulary, which are then attached to produce the final reactants.
25
+
26
+ Another important consideration in building retrosynthesis models is aligning model design with strategies adopted by expert chemists. These strategies are influenced by fundamental properties of chemical reactions, independent of complexity level: (i.) the product atoms are always a subset of the reactant atoms1, and (ii.) the molecular graph topology is largely unaltered from products to reactants. For example, in the standard retrosynthesis dataset, only $6 . 3 \%$ of the atoms in the product undergo any change in connectivity.
27
+
28
+ This consideration has received more attention in recent semi-template-based methods [Shi et al., 2020, Yan et al., 2020], that generate reactants from a product in two stages: (i.) first identify intermediate molecules called synthons, (ii.) and then complete synthons into reactants by sequential generation of atoms or SMILES characters.. Our model GRAPHRETRO also uses a similar workflow. However, we avoid sequential generation for completing synthons by instead selecting subgraphs called leaving groups from a precomputed vocabulary. This vocabulary is constructed during preprocessing by extracting subgraphs that differ between a synthon and the corresponding reactant. The vocabulary has a small size (170 for USPTO-50k) indicating remarkable redundancy, while covering $9 9 . 7 \%$ of the test set. Operating at the level of these subgraphs greatly reduces the complexity of reactant generation, with improved empirical performance. This formulation also simplifies our architecture, and makes our predictions more transparent, interpretable and amenable to manual correction.
29
+
30
+ The benchmark dataset for evaluating retrosynthesis models is USPTO-50k [Schneider et al., 2016], which consists of 50000 reactions across 10 reaction classes. The dataset contains an unexpected shortcut towards predicting the edit, in that the product atom with atom-mapping 1 is part of the edit in $7 5 \%$ of the cases, allowing predictions that depend on the position of the atom to overestimate performance. We canonicalize the product SMILES and remap the existing dataset, thereby removing the shortcut. On this remapped dataset, GRAPHRETRO achieves a top-1 accuracy of $5 3 . 7 \%$ when the reaction class is not known, outperforming both template-free and semi-template-based methods.
31
+
32
+ # 2 Related Work
33
+
34
+ Retrosynthesis Prediction Existing machine learning methods for retrosynthesis prediction can be divided into template-based, template-free and recent semi-template-based approaches.
35
+
36
+ Template-Based: Templates are either hand-crafted by experts [Hartenfeller et al., 2011, Szymkuc´ et al., 2016], or extracted algorithmically from large databases Coley et al. [2017a], Law et al. [2009]. Exhaustively applying large template sets is expensive due to the involved subgraph matching procedure. Template-based methods therefore utilize different ways of prioritizing templates, by either learning a conditional distribution over the template set [Segler and Waller, 2017], ranking templates based on molecular similarities to precedent reactions [Coley et al., 2017b] or directly modelling the joint distribution of templates and reactants using logic variables [Dai et al., 2019]. Despite their interpretability, these methods fail to generalize outside their rule set.
37
+
38
+ Template-Free: Template-free methods [Liu et al., 2017, Zheng et al., 2019, Chen et al., 2019] learn a direct transformation from products to reactants using architectures from neural machine translation and a string based representation of molecules called SMILES [Weininger, 1988]. Linearizing molecules as strings does not utilize the inherently rich chemical structure. In addition, the reactant SMILES are generated from scratch, character by character. Attempts have been made to improve validity by adding a syntax correcter [Zheng et al., 2019] and a mixture model to improve diversity of suggestions [Chen et al., 2019], but the performance remains worse than [Dai et al., 2019] on the standard retrosynthesis dataset. Sun et al. [2021] formulate retrosynthesis using energy-based models, with additional parameterizations and loss terms to enforce the duality between forward (reaction prediction) and backward (retrosynthesis) prediction.
39
+
40
+ Semi-Template-Based: Our work is closely related to recently proposed semi-template-based methods [Shi et al., 2020, Yan et al., 2020], which first identify synthons and then expand synthons into reactants through sequential generation using either a graph generative model [Shi et al., 2020] or a Transformer [Yan et al., 2020]. To reduce the complexity of reactant generation, we instead complete synthons using subgraphs called leaving groups selected from a precomputed vocabulary. This allows us to view synthon completion as a classification problem instead of a generative one. We also utilize the dependency graph between possible edits, and update edit predictions using a message passing network (MPN) [Gilmer et al., 2017] on this graph. Both innovations together yield a $4 . 8 \%$ and $3 . 3 \%$ performance improvement respectively over previous semi-template-based methods.
41
+
42
+ Reaction Center Identification The reaction center covers a small number of participating atoms involved in the reaction. Our work is also related to models that predict reaction outcomes by learning to rank atom pairs based on their likelihood to be in the reaction center [Coley et al., 2019, Jin et al., 2017]. The task of identifying the reaction center is related to the step of deriving the synthons in our formulation. Our work departs from [Coley et al., 2019, Jin et al., 2017] as we utilize the property that new bond formations occur rarely $( \sim 0 . 1 \% )$ from products to synthons, allowing us to predict a score only for existing bonds and atoms and reduce prediction complexity from $O ( N ^ { \bar { 2 } } )$ to $O ( N )$ . We also utilize the dependency graph between possible edits, and update edit predictions using a MPN on this graph.
43
+
44
+ Utilizing Substructures Substructures have been utilized in various tasks from sentence generation by fusing phrases to molecule generation and optimization [Jin et al., 2018, 2020]. Our work is closely related to [Jin et al., 2020] which uses precomputed substructures as building blocks for property-conditioned molecule generation. However, instead of precomputing, synthons —analogous building blocks for reactants— are indirectly learnt during training.
45
+
46
+ # 3 Model Design
47
+
48
+ Our approach leverages the property that graph topology is largely unaltered from products to reactants. To achieve this, we first derive suitable building blocks from the product called synthons, and then complete them into valid reactants by adding specific functionalities called leaving groups. These derivations, called edits, are characterized by modifications to bonds or hydrogen counts on atoms. We first train a neural network to predict a score for possible edits (Section 3.1). The edit with the highest score is then applied to the product to obtain synthons. Since the number of unique leaving groups are small, we model leaving group selection as a classification problem over a precomputed vocabulary (Section 3.2). To produce candidate reactants, we attach the predicted leaving group to the corresponding synthon through chemically constrained rules. The overall process is outlined in Figure 1. Before describing the two modules, we introduce relevant preliminaries that set the background for the remainder of the paper.
49
+
50
+ Retrosynthesis Prediction A retrosynthesis pair $R$ is described by a pair of molecular graphs $( \mathcal { G } _ { p } , \mathcal { G } _ { r } )$ , where $\mathcal { G } _ { p }$ are the products and $\mathcal { G } _ { r }$ the reactants. A molecular graph is described as $\mathcal { G } = \mathbf { \bar { \rho } } ( \mathcal { V } , \mathcal { E } )$ with atoms $\nu$ as nodes and bonds $\mathcal { E }$ as edges. Prior work has focused on the single product case, while reactants can have multiple connected components, i.e. $\mathcal { G } _ { r } = \{ \mathcal { G } _ { r _ { c } } \} _ { c = 1 } ^ { C }$ . Retrosynthesis pairs are atom-mapped so that each product atom has a unique corresponding reactant atom. The retrosynthesis task then, is to infer $\{ \mathcal { G } _ { r _ { c } } \} _ { c = 1 } ^ { C }$ given $\mathcal { G } _ { p }$ .
51
+
52
+ Edits Edits consist of (i.) atom pairs $\left\{ \left( a _ { i } , a _ { j } \right) \right\}$ where the bond type changes from products to reactants, and (ii.) atoms $\left\{ { a } _ { i } \right\}$ where the number of hydrogens attached to the atom change from products to reactants. We denote the set of edits by $E$ . Since retrosynthesis pairs in the training set are atom-mapped, edits can be automatically identified by comparing the atoms and atom pairs in the product to their corresponding reactant counterparts.
53
+
54
+ Synthons and Leaving Groups Applying edits $E$ to the product $\mathcal { G } _ { p }$ results in incomplete molecules called synthons. Synthons are analogous to rationales or building blocks, which are expanded into valid reactants by adding specific functionalities called leaving groups that are responsible for its reactivity. We denote synthons by $\mathcal { G } _ { s }$ and leaving groups by $\mathcal { G } _ { l }$ . We further assume that synthons and leaving groups have the same number of connected components as the reactants, i.e $\mathcal { G } _ { s } \doteq \{ \mathcal { G } _ { s _ { c } } \} _ { c = 1 } ^ { C }$ and $\mathcal { G } _ { l } = \{ \mathcal { G } _ { l _ { c } } ^ { \star } \} _ { c = 1 } ^ { C }$ . This assumption holds for $9 9 . 9 7 \%$ reactions in the training set.
55
+
56
+ Formally, our model generates reactants by first predicting the set of edits $E$ that transform $\mathcal { G } _ { p }$ into $\mathcal { G } _ { s }$ , followed by predicting a leaving group $\mathcal { G } _ { l _ { c } }$ to attach to each synthon $\mathcal { G } _ { s _ { c } }$ . The model is defined as
57
+
58
+ $$
59
+ P ( \mathcal G _ { r } | \mathcal G _ { p } ) = \sum _ { E , \mathcal G _ { l } } P ( E | \mathcal G _ { p } ) P ( \mathcal G _ { l } | \mathcal G _ { p } , \mathcal G _ { s } ) ,
60
+ $$
61
+
62
+ where $\mathcal { G } _ { s } , \mathcal { G } _ { r }$ are deterministic given $E , { \mathcal { G } } _ { l }$ , and $\mathcal { G } _ { p }$ .
63
+
64
+ # 3.1 Edit Prediction
65
+
66
+ For a given retrosynthesis pair $R = ( \mathcal G _ { p } , \mathcal G _ { r } )$ , we predict an edit score only for existing bonds and atoms, instead of every atom pair as in [Coley et al., 2019, Jin et al., 2017]. This choice is motivated by the low frequency $( \sim 0 . 1 \% )$ of new bond formations in the training set examples. Coupled with the sparsity of molecular graphs, this reduces the prediction complexity from $O ( N ^ { 2 } )$ to $O ( N )$ for a product with $N$ atoms. Our edit prediction model has variants tailored to single and multiple edit prediction. Since $9 5 \%$ of the training set consists of single edit examples, the remainder of this section describes the setup for single edit prediction. A detailed description of our multiple edit prediction model can be found in Appendix ??.
67
+
68
+ Each bond $( u , v )$ in $\mathcal { G } _ { p }$ is associated with a label $y _ { u v k } \in \{ 0 , 1 \}$ indicating whether its bond type $k$ has changed from the products to reactants. Each atom $u$ is associated with a label $y _ { u } \in \{ 0 , \bar { 1 } \}$ indicating a change in hydrogen count. We predict edit scores using representations that are learnt using a graph encoder.
69
+
70
+ Graph Encoder To obtain atom representations, we use a variant of the message passing network (MPN) described in [Gilmer et al., 2017]. Each atom $u$ has a feature vector $\mathbf { x } _ { u }$ indicating its atom type, degree and other properties. Each bond $( u , v )$ has a feature vector $\mathbf { x } _ { u v }$ indicating its aromaticity, bond type and ring membership. For simplicity, we denote the encoding process by $\mathrm { M P N } ( \cdot )$ and describe architectural details in Appendix ??. The MPN computes atom representations $\{ \mathbf { c } _ { u } | u \in \mathcal { G } \}$ via
71
+
72
+ $$
73
+ \{ \mathbf { c } _ { u } \} = \mathrm { M P N } ( \mathcal { G } , \{ \mathbf { x } _ { u } \} , \{ \mathbf { x } _ { u v } \} _ { v \in \mathcal { N } ( u ) } ) ,
74
+ $$
75
+
76
+ where $\mathcal { N } ( u )$ denotes the neighbors of atom $u$ . The graph representation $\mathbf { c } _ { \mathcal { G } }$ is an aggregation of atom representations, i.e. $\mathbf { c } _ { \mathcal { G } } = \dot { \sum _ { { u } \in \mathcal { V } } } \mathbf { c } _ { u }$ . When $\mathcal { G }$ has connected components $\left\{ { \mathcal { G } } _ { i } \right\}$ , we get a set of graph representations $\left\{ \mathbf { c } _ { \mathcal { G } _ { i } } \right\}$ . For a bond $( u , v )$ , we define its representation $\mathbf { c } _ { u v } = ( \operatorname { A B S } ( \mathbf { c } _ { u } , \mathbf { c } _ { v } ) | | \mathbf { c } _ { u } + \mathbf { c } _ { v } )$ , where ABS denotes absolute difference and $| |$ refers to concatenation. This ensures our representations are permutation invariant. These representations are then used to predict atom and bond edit scores using corresponding neural networks,
77
+
78
+ $$
79
+ \begin{array} { r } { \boldsymbol { s } _ { u } = \mathbf { u _ { a } } ^ { T } \boldsymbol { \tau } ( \mathbf { W _ { a } } \mathbf { c } _ { u } + b ) \quad } \\ { \boldsymbol { s } _ { u v k } = \mathbf { u _ { k } } ^ { T } \boldsymbol { \tau } ( \mathbf { W _ { k } } \mathbf { c } _ { u v } + b _ { k } ) , } \end{array}
80
+ $$
81
+
82
+ where $\tau ( \cdot )$ is the ReLU activation function.
83
+
84
+ Updating Bond Edit Scores Unlike a typical classification problem where the labels are independent, edits can have possible dependencies between each other. For example, bonds part of a stable system such as an aromatic ring have a greater tendency to remain unchanged (label 0). We attempt to leverage such dependencies to update initial edit scores. To this end, we build a graph with bonds $( u , v )$ as nodes, and introduce an edge between bonds sharing an atom. We use another $\mathrm { M P N } ( \cdot )$ on this graph to learn aggregated neighborhood messages $\mathbf { m } _ { u v }$ , and update the edit scores $s _ { u v k }$ in a manner similar to how LSTMs update representations,
85
+
86
+ $$
87
+ \begin{array} { r l } & { f _ { u v k } = \sigma ( \mathbf { W _ { k x } ^ { f } } \mathbf { x } _ { u v } + \mathbf { W _ { k m } ^ { f } } \mathbf { m } _ { u v } ) } \\ & { i _ { u v k } = \sigma ( \mathbf { W _ { k x } ^ { i } } \mathbf { x } _ { u v } + \mathbf { W _ { k m } ^ { i } } \mathbf { m } _ { u v } ) } \\ & { \tilde { m } _ { u v k } = \mathbf { u _ { m } } \tau ( \mathbf { W _ { k x } ^ { m } } \mathbf { x } _ { u v } + \mathbf { W _ { k m } ^ { m } } \mathbf { m } _ { u v } ) } \\ & { \tilde { s } _ { u v k } = f _ { u v k } \cdot s _ { u v k } + i _ { u v k } \cdot \tilde { m } _ { u v k } . } \end{array}
88
+ $$
89
+
90
+ Training We train by minimizing the cross-entropy loss over possible bond and atom edits
91
+
92
+ $$
93
+ \mathcal { L } _ { e } = - \sum _ { ( \mathcal { G } _ { p } , E ) } \left( \sum _ { ( ( u , v ) , k ) \in E } y _ { u v k } \mathrm { l o g } ( \widetilde s _ { u v k } ) + \sum _ { u \in E } y _ { u } \mathrm { l o g } ( s _ { u } ) \right) .
94
+ $$
95
+
96
+ The cross-entropy loss enforces the model to learn a distribution over possible edits instead of reasoning about each edit independently, as with the binary cross entropy loss used in [Jin et al., 2017, Coley et al., 2019].
97
+
98
+ # 3.2 Synthon Completion
99
+
100
+ Synthons are completed into valid reactants by adding specific functionalities called leaving groups. This involves two complementary tasks: (i.) selecting the appropriate leaving group, and (ii.) attaching the leaving group to the synthon. As ground truth leaving groups are not directly provided, we extract the leaving groups and construct a vocabulary $\mathcal { X }$ of unique leaving groups during preprocessing.
101
+
102
+ The vocabulary has a limited size ( $| \mathcal { X } | = 1 7 0$ for a standard dataset with 50, 000 examples, and 72000 synthons) indicating the redundancy of leaving groups used in accomplishing retrosynthetic transformations. This redundancy also allows us to formulate leaving group selection as a classification problem over $\mathcal { X }$ , while retaining the ability to generate diverse reactants using different combinations of leaving groups.
103
+
104
+ Vocabulary Construction Before constructing the vocabulary, we align connected components of synthon and reactant graphs by comparing atom mapping overlaps. Using aligned pairs $\mathcal { G } _ { s _ { c } } =$ $( \gamma _ { s _ { c } } , \mathcal { E } _ { s _ { c } } )$ and $\mathcal { G } _ { r _ { c } } = ( \nu _ { r _ { c } } , \mathcal { E } _ { r _ { c } } )$ as input, the leaving group vocabulary $\mathcal { X }$ is constructed by extracting subgraphs $\mathcal { G } _ { l _ { c } } = ( \nu _ { l _ { c } } , \mathcal { E } _ { l _ { c } } )$ such that $\smash { \gamma _ { l _ { c } } = \gamma _ { r _ { c } } \setminus \gamma _ { s _ { c } } }$ . Atoms $\left\{ { a } _ { i } \right\}$ in the leaving groups that attach to synthons are marked with a special symbol. We also add three tokens to $\mathcal { X }$ namely START, which indicates the start of synthon completion, END, which indicates that there is no leaving group to add and PAD, which is used to handle variable numbers of synthon components in a minibatch.
105
+
106
+ Leaving Group Selection For synthon component $c \leq C$ , where $C$ is the number of connected components in the synthon graph, we use three inputs for leaving group selection – the product representation $\mathbf { c } _ { \mathcal { G } _ { p } }$ , the synthon component representation $\mathbf { c } _ { \mathcal { G } _ { s _ { c } } }$ , and the leaving group representation for the previous synthon component, ${ \bf e } _ { l _ { c - 1 } }$ . The product and synthon representations are learnt using the $\mathrm { M P N } ( \cdot )$ . For each $x _ { i } \in { \mathcal { X } }$ , representations can be learnt by either training independent embedding vectors (ind) or by treating each $x _ { i }$ as a subgraph and using the $\mathrm { M P N } ( \cdot )$ (shared). In the shared setting, we use the same $\mathrm { M P N } ( \cdot )$ as the product and synthons.
107
+
108
+ The leaving group probabilities are then computed by combining $\mathbf { c } _ { \mathcal { G } _ { p } } , \mathbf { c } _ { \mathcal { G } _ { s _ { c } } }$ and $\mathbf { e } _ { l _ { c - 1 } }$ via a single layer neural network and softmax function
109
+
110
+ $$
111
+ \hat { q } _ { l _ { c } } = \mathrm { s o f t m a x } \left( \mathbf { U } \tau \left( \mathbf { W } _ { 1 } \mathbf { c } _ { \mathcal { G } _ { p } } + \mathbf { W } _ { 2 } \mathbf { c } _ { \mathcal { G } _ { s _ { c } } } + \mathbf { W } _ { 3 } \mathbf { e } _ { l _ { \left( c - 1 \right) } } \right) \right) ,
112
+ $$
113
+
114
+ where $\hat { q } _ { l _ { c } }$ is distribution learnt over $\mathcal { X }$ . Using the representation of the previous leaving group ${ \bf e } _ { l _ { c - 1 } }$ allows the model to understand combinations of leaving groups that generate the desired product from the reactants. We also include the product representation $\mathbf { c } _ { \mathcal { G } _ { p } }$ as the synthon graphs are derived from the product graph.
115
+
116
+ Training For step $c$ , given the one hot encoding of the true leaving group $q _ { l _ { c } }$ , we minimize the cross-entropy loss
117
+
118
+ $$
119
+ \mathcal { L } _ { s } = \sum _ { c = 1 } ^ { C } \mathcal { L } ( \hat { q } _ { l _ { c } } , q _ { l _ { c } } ) .
120
+ $$
121
+
122
+ Training utilizes teacher-forcing [Williams and Zipser, 1989] so that the model makes predictions given correct histories. During inference, at every step, we use the representation of leaving group from the previous step with the highest predicted probability.
123
+
124
+ Leaving Group Attachment Attaching leaving groups to synthons is a deterministic process and not learnt during training. The task involves identification of the type of bonds to add between attaching atoms in the leaving group (marked during vocabulary construction), and the atom(s) participating in the edit. These bonds can be inferred by applying the valency constraint, which determines the maximum number of neighbors for each atom. The attachment process does not modify any stereochemistry. Given synthons and leaving groups, the attachment process has a $100 \%$ accuracy. The detailed procedure is described in Appendix ??.
125
+
126
+ # 3.3 Inference
127
+
128
+ Inference is performed using beam search with a log-likelihood scoring function. For a beam width $n$ , we select $n$ edits with highest scores and apply them to the product to obtain $n$ synthons, where each synthon can consist of multiple connected components. The synthons form the nodes for beam search. Each node maintains a cumulative score by aggregating the log-likelihoods of the edit and predicted leaving groups. Leaving group inference starts with a connected component for each synthon, and selects $n$ leaving groups with highest log-likelihoods. From the $n ^ { 2 }$ possibilities, we select $n$ nodes with the highest cumulative scores. This process is repeated until all nodes have a leaving group predicted for each synthon component.
129
+
130
+ # 4 Evaluation
131
+
132
+ Evaluating retrosynthesis models is challenging as multiple sets of reactants can be generated from the same product. To deal with this, previous works [Coley et al., 2017b, Dai et al., 2019] evaluate the ability of the model to recover retrosynthetic strategies recorded in the dataset.
133
+
134
+ Data We use the benchmark dataset USPTO-50k [Schneider et al., 2016] for all our experiments. The dataset contains 50, 000 atom-mapped reactions across 10 reaction classes. We use the same dataset version and splits as provided by [Dai et al., 2019]. The USPTO-50k dataset contains a shortcut in that the product atom with atom-mapping 1 is part of the edit in $\sim 7 5 \%$ of the cases. If the product SMILES is not canonicalized, predictions utilizing operations that depend on the position of the atom or bond will be able to use the shortcut, and overestimate performance. We canonicalize the product SMILES, and reassign atom-mappings to the reactant atoms based on the canonical ordering, which removes the shortcut. Details on the remapping procedure can be found in Appendix ??.
135
+
136
+ Evaluation We use the top- $\mathbf { \nabla } \cdot n$ accuracy $( n = 1 , 3 , 5 , 1 0 )$ ) as our evaluation metric, defined as the fraction of examples where the recorded reactants are suggested by the model with rank $\leq n$ . Following prior work [Coley et al., 2017b, Zheng et al., 2019, Dai et al., 2019], we compute the accuracy by comparing the canonical SMILES of predicted reactants to the ground truth. Atom-mapping is excluded from this comparison, but stereochemistry, which describes the relative orientation of atoms in the molecule, is retained. The evaluation is carried out for two settings, with the reaction class being known or unknown.
137
+
138
+ Table 1: Top- $n$ exact match accuracy. Best values within each section are highlighted in bold.
139
+
140
+ <table><tr><td rowspan="3">Model</td><td colspan="8">Top-n Accuracy (%)</td></tr><tr><td colspan="4">Reaction class known</td><td colspan="4">Reaction class unknown</td></tr><tr><td>1</td><td>3</td><td>5</td><td>10</td><td>1</td><td>3</td><td>5</td><td>10</td></tr><tr><td colspan="9">Template-Based</td></tr><tr><td>RETROSIM [Coley et al.,2017b]</td><td>52.9</td><td>73.8</td><td>81.2</td><td>88.1</td><td>37.3</td><td>54.7</td><td>63.3</td><td>74.1</td></tr><tr><td>NEURALSYM [Segler and Waller,2017]</td><td>55.3</td><td>76.0</td><td>81.4</td><td>85.1</td><td>44.4</td><td>65.3</td><td>72.4</td><td>78.9</td></tr><tr><td>GLN [Dai et ai., 2019]</td><td>64.2</td><td>79.1</td><td>85.2</td><td>90.0</td><td>52.5</td><td>69.0</td><td>75.6</td><td>83.7</td></tr><tr><td>DUALTB [Sun et al.,2021]</td><td>67.7</td><td>84.8</td><td>88.9</td><td>92.0</td><td>55.2</td><td>74.6</td><td>80.5</td><td>86.9</td></tr><tr><td colspan="9">Template-Free</td></tr><tr><td>SCROP [Zheng et al.,2019]</td><td>59.0</td><td>74.8</td><td>78.1</td><td>81.1</td><td>43.7</td><td>60.0</td><td>65.2</td><td>68.7</td></tr><tr><td>LV-TRANSFORMER [Chen et al.,2019]</td><td>-</td><td>-</td><td>-</td><td>-</td><td>40.5</td><td>65.1</td><td>72.8</td><td>79.4</td></tr><tr><td>DUALTF [Sun et al., 2021]</td><td>65.7</td><td>81.9</td><td>84.7</td><td>85.9</td><td>53.6</td><td>70.7</td><td>74.6</td><td>77.0</td></tr><tr><td colspan="9">Semi-Template-Based</td></tr><tr><td>G2Gs [Shi et al.,2020]</td><td>61.0</td><td>81.3</td><td>86.0</td><td>88.7</td><td>48.9</td><td>67.6</td><td>72.5</td><td>75.5</td></tr><tr><td>RETROXPERT [Yan et al.,2020]</td><td>62.1</td><td>75.8</td><td>78.5</td><td>80.9</td><td>50.4</td><td>61.1</td><td>62.3</td><td>63.4</td></tr><tr><td>GRAPHRETRO (ours)</td><td>63.9</td><td>81.5</td><td>85.2</td><td>88.1</td><td>53.7</td><td>68.3</td><td>72.2</td><td>75.5</td></tr></table>
141
+
142
+ Baselines For evaluating overall performance, we compare GRAPHRETRO to nine baselines — four template-based, three template-free, and two semi-template-based methods. These include:
143
+
144
+ Template-Based: RETROSIM Coley et al. [2017b] ranks templates for a given target molecule by computing molecular similarities to precedent reactions. NEURALSYM [Segler and Waller, 2017] trains a model to rank templates given a target molecule. GLN [Dai et al., 2019] models the joint distribution of templates and reactants in a hierarchical fashion using logic variables. DUALTB [Sun et al., 2021] uses an energy-based model formulation for retrosynthesis, with additional parameterizations and loss terms to enforce the duality between forward (reaction prediction) and backward (retrosynthesis prediction). Inference is carried out using reactant candidates obtained by applying an extracted template set to the products.
145
+
146
+ Template-Free: SCROP [Zheng et al., 2019], LV-TRANSFORMER [Chen et al., 2019] and DUALTF [Sun et al., 2021] use the Transformer architecture [Vaswani et al., 2017] to output reactant SMILES given a product SMILES. To improve the validity of their suggestions, SCROP include a second Transformer that functions as a syntax correcter. LV-TRANSFORMER uses a latent variable mixture model to improve diversity of suggestions. DUALTF utilizes additional parameterizations and loss terms to enforce the duality between forward (reaction prediction) and backward (retrosynthesis prediction).
147
+
148
+ Semi-Template-Based: G2GS [Shi et al., 2020] and RETROXPERT [Yan et al., 2020] first identify synthons, and then expand the synthons into reactants by either sequential generation of atoms and bonds (G2Gs), or using the Transformer architecture (RETROXPERT). The training dataset for the Transformer in [Yan et al., 2020] is augmented with incorrectly predicted synthons with the goal of learning a correction mechanism.
149
+
150
+ Results for NEURALSYM are taken from [Dai et al., 2019]. The authors in [Yan et al., 2020] report their performance being affected by the dataset leakage2. Thus, we use the most recent results from their website on the canonicalized dataset. For remaining baselines, we directly use the values reported in their paper. For the synthon completion module, we use the ind configuration given its better empirical performance.
151
+
152
+ # 4.1 Overall Performance
153
+
154
+ Reaction class unknown As shown in Table 1, when the reaction class is unknown, GRAPHRETRO outperforms G2GS by $4 . 8 \%$ and and RETROXPERT by $3 . 3 \%$ in top-1 accuracy. Performance improvements are also seen for larger $n$ , except for $n = 5$ . Barring DUALTB, the top-1 accuracy is also better than other template-free and template-based methods. For larger $n$ , one reason for lower top- $n$ accuracies than most template-based methods is that templates already contain combinations of leaving group patterns. In contrast, our model learns to discover these during training. A second hypothesis to this end is that simply adding log-likelihood scores from edit prediction and synthon completion models may be suboptimal and bias the beam search in the direction of the more dominating term. We leave it to future work to investigate scoring functions that rank the attachment.
155
+
156
+ Reaction class known When the reaction class is known, GRAPHRETRO outperforms G2GS and RETROXPERT by a margin of $3 \%$ and $2 \%$ respectively in top-1 accuracy. GRAPHRETRO also outperforms all the template-free methods in top- $^ n$ accuracy. for GRAPHRETRO are also better than most template-based and template-free methods. When the reaction class is known, RETROSIM and GLN restrict template sets corresponding to the reaction class, thus improving performance. The increased edit prediction performance (Section 4.2) for GRAPHRETRO helps outweigh this factor, achieving comparable or better performance till $n = 5$ .
157
+
158
+ # 4.2 Individual Module Performance
159
+
160
+ To gain more insight into the working of GRAPHRETRO, we evaluate the top- $\boldsymbol { n }$ accuracy $\mathbf { \nabla } _ { n } =$ $1 , 2 , 3 , 5 )$ of edit prediction and synthon completion modules, along with corresponding ablation studies, with results shown in Table 2.
161
+
162
+ Edit Prediction For the edit prediction module, we compare the true edit(s) to top- $\boldsymbol { n }$ edits predicted by the model. We also consider two ablation studies, one where we directly use the initial edit scores without updating them, and the other where we predict edits using atom-pairs instead of existing bonds and atoms. Both design choices lead to improvements in performance, as shown in Table 2. We hypothesize that the larger improvement compared to edit prediction using atom-pairs is due to the easier optimization procedure, with lesser imbalance between labels 1 and 0.
163
+
164
+ Synthon Completion For evaluating the synthon completion module, we first apply the true edits to obtain synthons, and compare the true leaving groups to top- $\mathbf { \nabla } \cdot n$ leaving groups predicted by the model. We test the performance of both the ind and shared configurations. Both configurations perform similarly, and are able to identify $\sim 9 7 \%$ (close to its upper bound of $9 9 . 7 \%$ ) of the true leaving groups in its top-5 choices, when the reaction class is known. The top-1, 3 and 5 accuracies of the synthon completion for unknown reaction classes for G2Gs are $6 1 . 1 \%$ , $8 1 . 5 \%$ and $8 6 . 7 \%$ respectively, while ours are $7 5 . 6 \%$ , $9 2 . 5 \%$ and $9 6 . 1 \%$ , indicating a $10 \%$ performance improvement using a classification formulation over the generative one adopted by G2Gs.
165
+
166
+ Table 2: Performance Study of edit prediction and synthon completion modules
167
+
168
+ <table><tr><td rowspan="3"> Setting</td><td colspan="8">Top-n Accuracy (%)</td></tr><tr><td colspan="4">Reaction class known</td><td colspan="4">Reaction class unknown</td></tr><tr><td>1</td><td>2</td><td>3</td><td>5</td><td>1</td><td>2</td><td>3</td><td>5</td></tr><tr><td>Edit Prediction</td><td>84.6</td><td>92.2</td><td>93.7</td><td>94.5</td><td>70.8</td><td>85.1</td><td>89.5</td><td>92.7</td></tr><tr><td>- without edit score updates</td><td>84.3</td><td>92.1</td><td>93.7</td><td>94.5</td><td>70.1</td><td>84.8</td><td>89.4</td><td>92.6</td></tr><tr><td>- predicting on atom pairs</td><td>81.9</td><td>89.5</td><td>90.9</td><td>92.1</td><td>68.6</td><td>83.2</td><td>88.3</td><td>91.8</td></tr><tr><td>Synthon Completion (ind)</td><td>77.4</td><td>89.5</td><td>94.2</td><td>97.6</td><td>75.6</td><td>87.4</td><td>92.5</td><td>96.1</td></tr><tr><td>Synthon Completion (shared)</td><td>76.9</td><td>89.6</td><td>93.9</td><td>97.4</td><td>74.9</td><td>87.7</td><td>92.9</td><td>96.3</td></tr></table>
169
+
170
+ # 4.3 Example Predictions
171
+
172
+ In Figure 2, we visualize the model predictions and the ground truth for three cases. Figure 2a shows an example where the model identifies both the edits and leaving groups correctly. In Figure 2b, the correct edit is identified but the predicted leaving groups are incorrect. We hypothesize this is due to the fact that in the training set, leaving groups attaching to the carbonyl carbon $\scriptstyle ( \mathbf { C } = \mathbf { O } )$ are small (e.g. -OH, - $\mathrm { - N H _ { 2 } }$ , halides). The true leaving group in this example, however, is large. The model is unable to reason about this and predicts the small leaving group -I. In Figure 2c, the model identifies the edit and consequently the leaving group incorrectly. This highlights a limitation of our model. If the edit is predicted incorrectly, the model cannot suggest the true precursors.
173
+
174
+ # 4.4 Limitations
175
+
176
+ The simplified and interpretable construction of GRAPHRETRO comes with certain limitations. First, the overall performance of the model is limited by the performance of the edit prediction step. If the predicted edit is incorrect, the true reactants cannot be salvaged. This limitation is partly remedied by our model design, that allows for user intervention to correct the edit. Second, our method is reliant on atom-mapping for extracting edits and leaving groups. Extracting edits directly based on substructure matching currently suffer from false positives, and heuristics to correct for these result in correct edits in only ${ \sim } 9 0 \%$ of the cases. Third, our formulation assumes that we have as many synthons as reactants, which is violated in some reactions. We leave it to future work to extend the model to realize a single reactant from multiple synthons, and introduce more chemically meaningful edit correction mechanisms.
177
+
178
+ ![](images/9df65c90e84b75ac55b8dc08692726ee93cf492df4b05d29c79c8c792f98fccd.jpg)
179
+ Figure 2: Example Predictions. The true edit and incorrect edit (if any) are highlighted in green and red respectively. The true and predicted leaving groups are highlighted in blue. a. Correctly predicted example by the model. b. Correctly predicted edit but incorrectly predicted leaving groups. c. Incorrectly predicted edit and leaving group.
180
+
181
+ # 5 Conclusion
182
+
183
+ Previous methods for single-step retrosynthesis either restrict prediction to a template set, are insensitive to molecular graph structure or generate molecules from scratch. We address these shortcomings by introducing a graph-based semi-template-based model inspired by a chemist’s workflow, enhancing the interpretability of retrosynthesis models. Given a target molecule, we first identify synthetic building blocks (synthons) which are then realized into valid reactants, thus avoiding molecule generation from scratch. Our model outperforms previous semi-template-methods by significant margins on the benchmark dataset. Future work aims to extend the model to realize a single reactant from multiple synthons, and introduce more chemically meaningful components to improve the synergy between such tools for retrosynthesis prediction and a practitioner’s expertise.
184
+
185
+ # Acknowledgements
186
+
187
+ This research was supported by the Machine Learning for Pharmaceutical Discovery and Synthesis Consortium at MIT. V.R.S. was also supported by the Zeno Karl Schindler Foundation. C.B. was supported by the Swiss National Science Foundation under the National Center of Competence in Research (NCCR) Catalysis under grant agreement 51NF40 180544. We thank the Leonhard scientific computing cluster at ETH Zürich for providing computational resources.
188
+
189
+ # References
190
+
191
+ B. Chen, T. Shen, T. S. Jaakkola, and R. Barzilay. Learning to Make Generalizable and Diverse Predictions for Retrosynthesis. In Submission, 2019.
192
+ C. W. Coley, R. Barzilay, T. S. Jaakkola, W. H. Green, and K. F. Jensen. Prediction of Organic Reaction Outcomes Using Machine Learning. In ACS Central Science. ACS Publications, 2017a.
193
+ C. W. Coley, L. Rogers, W. H. Green, and K. F. Jensen. Computer-Assisted Retrosynthesis Based on Molecular Similarity. ACS Central Science, 3, 2017b.
194
+ C. W. Coley, W. Jin, L. Rogers, T. F. Jamison, T. S. Jaakkola, W. H. Green, R. Barzilay, and K. F. Jensen. A graph-convolutional neural network model for the prediction of chemical reactivity. Chemical Science, 10, 2019.
195
+ E. Corey and W. T. Wipke. Computer-assisted design of complex organic syntheses. Science, 166 (3902):178–192, 1969.
196
+ E. J. Corey. The Logic of Chemical Synthesis: Multistep Synthesis of Complex Carbogenic Molecules (Nobel Lecture). Angewandte Chemie International Edition, 30, 1991.
197
+ H. Dai, C. Li, C. Coley, B. Dai, and L. Song. Retrosynthesis Prediction with Conditional Graph Logic Network. In Advances in Neural Information Processing Systems (NeurIPS), volume 32, 2019.
198
+ S. Genheden, A. Thakkar, V. Chadimová, J.-L. Reymond, O. Engkvist, and E. Bjerrum. Aizynthfinder: a fast, robust and flexible open-source software for retrosynthetic planning. Journal of cheminformatics, 12(1):1–9, 2020.
199
+ J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals, and G. E. Dahl. Neural Message Passing for Quantum Chemistry. In International Conference on Machine Learning (ICML), volume 70, 2017.
200
+ M. Hartenfeller, M. Eberle, P. Meier, C. Nieto-Oberhuber, K.-H. Altmann, G. Schneider, E. Jacoby, and S. Renner. A Collection of Robust Organic Synthesis Reactions for In Silico Molecule Design. In Journal of Chemical Information and Modeling, volume 51. ACS Publications, 2011.
201
+ W. Jin, C. Coley, R. Barzilay, and T. Jaakkola. Predicting Organic Reaction Outcomes with WeisfeilerLehman Network. In Advances in Neural Information Processing Systems (NeurIPS), volume 30, 2017.
202
+ W. Jin, R. Barzilay, and T. Jaakkola. Junction Tree Variational Autoencoder for Molecular Graph Generation. In International Conference on Machine Learning (ICML), volume 32, 2018.
203
+ W. Jin, R. Barzilay, and T. Jaakkola. Composing Molecules with Multiple Property Constraints. In International Conference on Machine Learning (ICML), 2020.
204
+ J. Law, Z. Zsoldos, A. Simon, D. Reid, Y. Liu, S. Y. Khew, A. P. Johnson, S. Major, R. A. Wade, and H. Y. Ando. Route Designer: A Retrosynthetic Analysis Tool Utilizing Automated Retrosynthetic Rule Generation. Journal of Chemical Information and Modeling, 49, 2009.
205
+ B. Liu, B. Ramsundar, P. Kawthekar, J. Shi, J. Gomes, Q. Luu Nguyen, S. Ho, J. Sloane, P. Wender, and V. Pande. Retrosynthetic Reaction Prediction Using Neural Sequence-to-Sequence Models. In ACS Central Science, volume 3. ACS Publications, 2017.
206
+ N. Schneider, N. Stiefl, and G. A. Landrum. What’s What: The (Nearly) Definitive Guide to Reaction Role Assignment. In Journal of Chemical Information and Modeling, volume 56. ACS Publications, 2016.
207
+ M. H. Segler and M. P. Waller. Neural-Symbolic Machine Learning for Retrosynthesis and Reaction Prediction. Chemistry–A European Journal, 23, 2017.
208
+ C. Shi, M. Xu, H. Guo, M. Zhang, and J. Tang. A graph to graphs framework for retrosynthesis prediction, 2020.
209
+ R. Sun, H. Dai, L. Li, S. Kearnes, and B. Dai. Energy-based view of retrosynthesis, 2021. URL https://openreview.net/forum?id $\equiv$ 0Hj3tFCSjUd.
210
+ S. Szymkuc, E. P. Gajewska, T. Klucznik, K. Molga, P. Dittwald, M. Startek, M. Bajczyk, and ´ B. A. Grzybowski. Computer-assisted synthetic planning: The end of the beginning. Angewandte Chemie International Edition, 55(20):5904–5937, 2016.
211
+ A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is All You Need. In Advances in Neural Information Processing Systems (NeurIPS), volume 30, 2017.
212
+ D. Weininger. SMILES, a Chemical Language and Information System. Journal of Chemical Information and Computer Sciences, 28, 1988.
213
+ R. J. Williams and D. Zipser. A Learning Algorithm for Continually Running Fully Recurrent Neural Networks. In Neural Computation, volume 1. MIT Press, 1989.
214
+ C. Yan, Q. Ding, P. Zhao, S. Zheng, J. YANG, Y. Yu, and J. Huang. Retroxpert: Decompose retrosynthesis prediction like a chemist. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 11248–11258. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/file/ 819f46e52c25763a55cc642422644317-Paper.pdf.
215
+ S. Zheng, J. Rao, Z. Zhang, J. Xu, and Y. Yang. Predicting Retrosynthetic Reactions using SelfCorrected Transformer Neural Networks. In Journal of Chemical Information and Modeling. ACS Publications, 2019.
parse/train/LyjH88yV7F/LyjH88yV7F_content_list.json ADDED
@@ -0,0 +1,1040 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "Learning Graph Models for Retrosynthesis Prediction ",
5
+ "text_level": 1,
6
+ "bbox": [
7
+ 330,
8
+ 122,
9
+ 666,
10
+ 172
11
+ ],
12
+ "page_idx": 0
13
+ },
14
+ {
15
+ "type": "text",
16
+ "text": "Vignesh Ram Somnath1 ",
17
+ "bbox": [
18
+ 228,
19
+ 226,
20
+ 392,
21
+ 241
22
+ ],
23
+ "page_idx": 0
24
+ },
25
+ {
26
+ "type": "text",
27
+ "text": "Charlotte Bunne1 ",
28
+ "bbox": [
29
+ 455,
30
+ 224,
31
+ 578,
32
+ 241
33
+ ],
34
+ "page_idx": 0
35
+ },
36
+ {
37
+ "type": "text",
38
+ "text": "Connor W. Coley2 ",
39
+ "bbox": [
40
+ 642,
41
+ 224,
42
+ 769,
43
+ 241
44
+ ],
45
+ "page_idx": 0
46
+ },
47
+ {
48
+ "type": "text",
49
+ "text": "Andreas Krause1 Regina Barzilay3 ",
50
+ "bbox": [
51
+ 369,
52
+ 261,
53
+ 629,
54
+ 276
55
+ ],
56
+ "page_idx": 0
57
+ },
58
+ {
59
+ "type": "text",
60
+ "text": "1Department of Computer Science, ETH 2Department of Chemical Engineering, MIT 3Computer Science and Artificial Intelligence Lab, MIT 1{vsomnath, bunnec, krausea}@ethz.ch, 2ccoley@mit.edu, 3regina@csail.mit.edu ",
61
+ "bbox": [
62
+ 186,
63
+ 289,
64
+ 815,
65
+ 347
66
+ ],
67
+ "page_idx": 0
68
+ },
69
+ {
70
+ "type": "text",
71
+ "text": "Abstract ",
72
+ "text_level": 1,
73
+ "bbox": [
74
+ 462,
75
+ 382,
76
+ 535,
77
+ 400
78
+ ],
79
+ "page_idx": 0
80
+ },
81
+ {
82
+ "type": "text",
83
+ "text": "Retrosynthesis prediction is a fundamental problem in organic synthesis, where the task is to identify precursor molecules that can be used to synthesize a target molecule. A key consideration in building neural models for this task is aligning model design with strategies adopted by chemists. Building on this viewpoint, this paper introduces a graph-based approach that capitalizes on the idea that the graph topology of precursor molecules is largely unaltered during a chemical reaction. The model first predicts the set of graph edits transforming the target into incomplete molecules called synthons. Next, the model learns to expand synthons into complete molecules by attaching relevant leaving groups. This decomposition simplifies the architecture, making its predictions more interpretable, and also amenable to manual correction. Our model achieves a top-1 accuracy of $5 3 . 7 \\%$ , outperforming previous template-free and semi-template-based methods. ",
84
+ "bbox": [
85
+ 233,
86
+ 419,
87
+ 766,
88
+ 584
89
+ ],
90
+ "page_idx": 0
91
+ },
92
+ {
93
+ "type": "text",
94
+ "text": "1 Introduction ",
95
+ "text_level": 1,
96
+ "bbox": [
97
+ 174,
98
+ 618,
99
+ 310,
100
+ 636
101
+ ],
102
+ "page_idx": 0
103
+ },
104
+ {
105
+ "type": "text",
106
+ "text": "Retrosynthesis prediction, first formalized by E. J. Corey [Corey, 1991] is a fundamental problem in organic synthesis that attempts to identify a series of chemical transformations for synthesizing a target molecule. In the single-step formulation, the task is to identify a set of reactant molecules given a target. Beyond simple reactions, many practical tasks involving complex organic molecules are difficult even for expert chemists. As a result, substantial experimental exploration is needed to cover for deficiencies of analytical approaches. This has motivated interest in computer-assisted retrosynthesis [Corey and Wipke, 1969], with a recent surge in machine learning methods [Chen et al., 2019, Coley et al., 2017b, Dai et al., 2019, Zheng et al., 2019, Genheden et al., 2020]. ",
107
+ "bbox": [
108
+ 174,
109
+ 654,
110
+ 825,
111
+ 765
112
+ ],
113
+ "page_idx": 0
114
+ },
115
+ {
116
+ "type": "text",
117
+ "text": "Computationally, the main challenge is how to explore the combinatorial space of reactions that can yield the target molecule. Largely, previous methods for retrosynthesis prediction can be divided into template-based [Coley et al., 2017b, Dai et al., 2019, Segler and Waller, 2017] and template-free [Chen et al., 2019, Zheng et al., 2019] approaches. Template-based methods match a target molecule against a large set of templates, which are molecular subgraph patterns that highlight changes during a chemical reaction. Despite their interpretability, these methods fail to generalize to new reactions. Template-free methods bypass templates by learning a direct mapping from the SMILES [Weininger, 1988] representations of the product to reactants. Despite their greater generalization potential, these methods generate reactant SMILES character by character, increasing generation complexity. ",
118
+ "bbox": [
119
+ 174,
120
+ 771,
121
+ 825,
122
+ 896
123
+ ],
124
+ "page_idx": 0
125
+ },
126
+ {
127
+ "type": "image",
128
+ "img_path": "images/e988f2e4a9f13ae6fa41934806006c24c87183942b7fd7f824274aee3a6237f9.jpg",
129
+ "image_caption": [
130
+ "Figure 1: Overview of Our Approach. a. Edit Prediction. We train a model to learn a distribution over possible graph edits. In this case, the correct edit corresponds to breaking the bond marked in red. Applying this edit produces two synthons. b. Synthon Completion. Another model is trained to pick candidate leaving groups (blue) for each synthon from a discrete vocabulary, which are then attached to produce the final reactants. "
131
+ ],
132
+ "image_footnote": [],
133
+ "bbox": [
134
+ 174,
135
+ 103,
136
+ 812,
137
+ 292
138
+ ],
139
+ "page_idx": 1
140
+ },
141
+ {
142
+ "type": "text",
143
+ "text": "Another important consideration in building retrosynthesis models is aligning model design with strategies adopted by expert chemists. These strategies are influenced by fundamental properties of chemical reactions, independent of complexity level: (i.) the product atoms are always a subset of the reactant atoms1, and (ii.) the molecular graph topology is largely unaltered from products to reactants. For example, in the standard retrosynthesis dataset, only $6 . 3 \\%$ of the atoms in the product undergo any change in connectivity. ",
144
+ "bbox": [
145
+ 174,
146
+ 404,
147
+ 825,
148
+ 488
149
+ ],
150
+ "page_idx": 1
151
+ },
152
+ {
153
+ "type": "text",
154
+ "text": "This consideration has received more attention in recent semi-template-based methods [Shi et al., 2020, Yan et al., 2020], that generate reactants from a product in two stages: (i.) first identify intermediate molecules called synthons, (ii.) and then complete synthons into reactants by sequential generation of atoms or SMILES characters.. Our model GRAPHRETRO also uses a similar workflow. However, we avoid sequential generation for completing synthons by instead selecting subgraphs called leaving groups from a precomputed vocabulary. This vocabulary is constructed during preprocessing by extracting subgraphs that differ between a synthon and the corresponding reactant. The vocabulary has a small size (170 for USPTO-50k) indicating remarkable redundancy, while covering $9 9 . 7 \\%$ of the test set. Operating at the level of these subgraphs greatly reduces the complexity of reactant generation, with improved empirical performance. This formulation also simplifies our architecture, and makes our predictions more transparent, interpretable and amenable to manual correction. ",
155
+ "bbox": [
156
+ 174,
157
+ 494,
158
+ 825,
159
+ 646
160
+ ],
161
+ "page_idx": 1
162
+ },
163
+ {
164
+ "type": "text",
165
+ "text": "The benchmark dataset for evaluating retrosynthesis models is USPTO-50k [Schneider et al., 2016], which consists of 50000 reactions across 10 reaction classes. The dataset contains an unexpected shortcut towards predicting the edit, in that the product atom with atom-mapping 1 is part of the edit in $7 5 \\%$ of the cases, allowing predictions that depend on the position of the atom to overestimate performance. We canonicalize the product SMILES and remap the existing dataset, thereby removing the shortcut. On this remapped dataset, GRAPHRETRO achieves a top-1 accuracy of $5 3 . 7 \\%$ when the reaction class is not known, outperforming both template-free and semi-template-based methods. ",
166
+ "bbox": [
167
+ 174,
168
+ 652,
169
+ 825,
170
+ 750
171
+ ],
172
+ "page_idx": 1
173
+ },
174
+ {
175
+ "type": "text",
176
+ "text": "2 Related Work ",
177
+ "text_level": 1,
178
+ "bbox": [
179
+ 174,
180
+ 770,
181
+ 321,
182
+ 786
183
+ ],
184
+ "page_idx": 1
185
+ },
186
+ {
187
+ "type": "text",
188
+ "text": "Retrosynthesis Prediction Existing machine learning methods for retrosynthesis prediction can be divided into template-based, template-free and recent semi-template-based approaches. ",
189
+ "bbox": [
190
+ 173,
191
+ 801,
192
+ 823,
193
+ 830
194
+ ],
195
+ "page_idx": 1
196
+ },
197
+ {
198
+ "type": "text",
199
+ "text": "Template-Based: Templates are either hand-crafted by experts [Hartenfeller et al., 2011, Szymkuc´ et al., 2016], or extracted algorithmically from large databases Coley et al. [2017a], Law et al. [2009]. Exhaustively applying large template sets is expensive due to the involved subgraph matching procedure. Template-based methods therefore utilize different ways of prioritizing templates, by either learning a conditional distribution over the template set [Segler and Waller, 2017], ranking templates based on molecular similarities to precedent reactions [Coley et al., 2017b] or directly modelling the joint distribution of templates and reactants using logic variables [Dai et al., 2019]. Despite their interpretability, these methods fail to generalize outside their rule set. ",
200
+ "bbox": [
201
+ 181,
202
+ 843,
203
+ 825,
204
+ 886
205
+ ],
206
+ "page_idx": 1
207
+ },
208
+ {
209
+ "type": "text",
210
+ "text": "",
211
+ "bbox": [
212
+ 197,
213
+ 92,
214
+ 825,
215
+ 174
216
+ ],
217
+ "page_idx": 2
218
+ },
219
+ {
220
+ "type": "text",
221
+ "text": "Template-Free: Template-free methods [Liu et al., 2017, Zheng et al., 2019, Chen et al., 2019] learn a direct transformation from products to reactants using architectures from neural machine translation and a string based representation of molecules called SMILES [Weininger, 1988]. Linearizing molecules as strings does not utilize the inherently rich chemical structure. In addition, the reactant SMILES are generated from scratch, character by character. Attempts have been made to improve validity by adding a syntax correcter [Zheng et al., 2019] and a mixture model to improve diversity of suggestions [Chen et al., 2019], but the performance remains worse than [Dai et al., 2019] on the standard retrosynthesis dataset. Sun et al. [2021] formulate retrosynthesis using energy-based models, with additional parameterizations and loss terms to enforce the duality between forward (reaction prediction) and backward (retrosynthesis) prediction. ",
222
+ "bbox": [
223
+ 183,
224
+ 183,
225
+ 825,
226
+ 321
227
+ ],
228
+ "page_idx": 2
229
+ },
230
+ {
231
+ "type": "text",
232
+ "text": "Semi-Template-Based: Our work is closely related to recently proposed semi-template-based methods [Shi et al., 2020, Yan et al., 2020], which first identify synthons and then expand synthons into reactants through sequential generation using either a graph generative model [Shi et al., 2020] or a Transformer [Yan et al., 2020]. To reduce the complexity of reactant generation, we instead complete synthons using subgraphs called leaving groups selected from a precomputed vocabulary. This allows us to view synthon completion as a classification problem instead of a generative one. We also utilize the dependency graph between possible edits, and update edit predictions using a message passing network (MPN) [Gilmer et al., 2017] on this graph. Both innovations together yield a $4 . 8 \\%$ and $3 . 3 \\%$ performance improvement respectively over previous semi-template-based methods. ",
233
+ "bbox": [
234
+ 183,
235
+ 330,
236
+ 825,
237
+ 468
238
+ ],
239
+ "page_idx": 2
240
+ },
241
+ {
242
+ "type": "text",
243
+ "text": "Reaction Center Identification The reaction center covers a small number of participating atoms involved in the reaction. Our work is also related to models that predict reaction outcomes by learning to rank atom pairs based on their likelihood to be in the reaction center [Coley et al., 2019, Jin et al., 2017]. The task of identifying the reaction center is related to the step of deriving the synthons in our formulation. Our work departs from [Coley et al., 2019, Jin et al., 2017] as we utilize the property that new bond formations occur rarely $( \\sim 0 . 1 \\% )$ from products to synthons, allowing us to predict a score only for existing bonds and atoms and reduce prediction complexity from $O ( N ^ { \\bar { 2 } } )$ to $O ( N )$ . We also utilize the dependency graph between possible edits, and update edit predictions using a MPN on this graph. ",
244
+ "bbox": [
245
+ 174,
246
+ 487,
247
+ 825,
248
+ 613
249
+ ],
250
+ "page_idx": 2
251
+ },
252
+ {
253
+ "type": "text",
254
+ "text": "Utilizing Substructures Substructures have been utilized in various tasks from sentence generation by fusing phrases to molecule generation and optimization [Jin et al., 2018, 2020]. Our work is closely related to [Jin et al., 2020] which uses precomputed substructures as building blocks for property-conditioned molecule generation. However, instead of precomputing, synthons —analogous building blocks for reactants— are indirectly learnt during training. ",
255
+ "bbox": [
256
+ 174,
257
+ 631,
258
+ 825,
259
+ 702
260
+ ],
261
+ "page_idx": 2
262
+ },
263
+ {
264
+ "type": "text",
265
+ "text": "3 Model Design ",
266
+ "text_level": 1,
267
+ "bbox": [
268
+ 174,
269
+ 724,
270
+ 320,
271
+ 742
272
+ ],
273
+ "page_idx": 2
274
+ },
275
+ {
276
+ "type": "text",
277
+ "text": "Our approach leverages the property that graph topology is largely unaltered from products to reactants. To achieve this, we first derive suitable building blocks from the product called synthons, and then complete them into valid reactants by adding specific functionalities called leaving groups. These derivations, called edits, are characterized by modifications to bonds or hydrogen counts on atoms. We first train a neural network to predict a score for possible edits (Section 3.1). The edit with the highest score is then applied to the product to obtain synthons. Since the number of unique leaving groups are small, we model leaving group selection as a classification problem over a precomputed vocabulary (Section 3.2). To produce candidate reactants, we attach the predicted leaving group to the corresponding synthon through chemically constrained rules. The overall process is outlined in Figure 1. Before describing the two modules, we introduce relevant preliminaries that set the background for the remainder of the paper. ",
278
+ "bbox": [
279
+ 174,
280
+ 758,
281
+ 825,
282
+ 911
283
+ ],
284
+ "page_idx": 2
285
+ },
286
+ {
287
+ "type": "text",
288
+ "text": "Retrosynthesis Prediction A retrosynthesis pair $R$ is described by a pair of molecular graphs $( \\mathcal { G } _ { p } , \\mathcal { G } _ { r } )$ , where $\\mathcal { G } _ { p }$ are the products and $\\mathcal { G } _ { r }$ the reactants. A molecular graph is described as $\\mathcal { G } = \\mathbf { \\bar { \\rho } } ( \\mathcal { V } , \\mathcal { E } )$ with atoms $\\nu$ as nodes and bonds $\\mathcal { E }$ as edges. Prior work has focused on the single product case, while reactants can have multiple connected components, i.e. $\\mathcal { G } _ { r } = \\{ \\mathcal { G } _ { r _ { c } } \\} _ { c = 1 } ^ { C }$ . Retrosynthesis pairs are atom-mapped so that each product atom has a unique corresponding reactant atom. The retrosynthesis task then, is to infer $\\{ \\mathcal { G } _ { r _ { c } } \\} _ { c = 1 } ^ { C }$ given $\\mathcal { G } _ { p }$ . ",
289
+ "bbox": [
290
+ 173,
291
+ 90,
292
+ 825,
293
+ 176
294
+ ],
295
+ "page_idx": 3
296
+ },
297
+ {
298
+ "type": "text",
299
+ "text": "Edits Edits consist of (i.) atom pairs $\\left\\{ \\left( a _ { i } , a _ { j } \\right) \\right\\}$ where the bond type changes from products to reactants, and (ii.) atoms $\\left\\{ { a } _ { i } \\right\\}$ where the number of hydrogens attached to the atom change from products to reactants. We denote the set of edits by $E$ . Since retrosynthesis pairs in the training set are atom-mapped, edits can be automatically identified by comparing the atoms and atom pairs in the product to their corresponding reactant counterparts. ",
300
+ "bbox": [
301
+ 173,
302
+ 189,
303
+ 825,
304
+ 260
305
+ ],
306
+ "page_idx": 3
307
+ },
308
+ {
309
+ "type": "text",
310
+ "text": "Synthons and Leaving Groups Applying edits $E$ to the product $\\mathcal { G } _ { p }$ results in incomplete molecules called synthons. Synthons are analogous to rationales or building blocks, which are expanded into valid reactants by adding specific functionalities called leaving groups that are responsible for its reactivity. We denote synthons by $\\mathcal { G } _ { s }$ and leaving groups by $\\mathcal { G } _ { l }$ . We further assume that synthons and leaving groups have the same number of connected components as the reactants, i.e $\\mathcal { G } _ { s } \\doteq \\{ \\mathcal { G } _ { s _ { c } } \\} _ { c = 1 } ^ { C }$ and $\\mathcal { G } _ { l } = \\{ \\mathcal { G } _ { l _ { c } } ^ { \\star } \\} _ { c = 1 } ^ { C }$ . This assumption holds for $9 9 . 9 7 \\%$ reactions in the training set. ",
311
+ "bbox": [
312
+ 173,
313
+ 275,
314
+ 825,
315
+ 359
316
+ ],
317
+ "page_idx": 3
318
+ },
319
+ {
320
+ "type": "text",
321
+ "text": "Formally, our model generates reactants by first predicting the set of edits $E$ that transform $\\mathcal { G } _ { p }$ into $\\mathcal { G } _ { s }$ , followed by predicting a leaving group $\\mathcal { G } _ { l _ { c } }$ to attach to each synthon $\\mathcal { G } _ { s _ { c } }$ . The model is defined as ",
322
+ "bbox": [
323
+ 171,
324
+ 364,
325
+ 823,
326
+ 393
327
+ ],
328
+ "page_idx": 3
329
+ },
330
+ {
331
+ "type": "equation",
332
+ "img_path": "images/e5989ffe48f40113cab8f00a06662537b577c1fdbf3a8f9d8153b9ad86f85418.jpg",
333
+ "text": "$$\nP ( \\mathcal G _ { r } | \\mathcal G _ { p } ) = \\sum _ { E , \\mathcal G _ { l } } P ( E | \\mathcal G _ { p } ) P ( \\mathcal G _ { l } | \\mathcal G _ { p } , \\mathcal G _ { s } ) ,\n$$",
334
+ "text_format": "latex",
335
+ "bbox": [
336
+ 364,
337
+ 407,
338
+ 632,
339
+ 443
340
+ ],
341
+ "page_idx": 3
342
+ },
343
+ {
344
+ "type": "text",
345
+ "text": "where $\\mathcal { G } _ { s } , \\mathcal { G } _ { r }$ are deterministic given $E , { \\mathcal { G } } _ { l }$ , and $\\mathcal { G } _ { p }$ . ",
346
+ "bbox": [
347
+ 173,
348
+ 449,
349
+ 509,
350
+ 465
351
+ ],
352
+ "page_idx": 3
353
+ },
354
+ {
355
+ "type": "text",
356
+ "text": "3.1 Edit Prediction ",
357
+ "text_level": 1,
358
+ "bbox": [
359
+ 174,
360
+ 481,
361
+ 318,
362
+ 496
363
+ ],
364
+ "page_idx": 3
365
+ },
366
+ {
367
+ "type": "text",
368
+ "text": "For a given retrosynthesis pair $R = ( \\mathcal G _ { p } , \\mathcal G _ { r } )$ , we predict an edit score only for existing bonds and atoms, instead of every atom pair as in [Coley et al., 2019, Jin et al., 2017]. This choice is motivated by the low frequency $( \\sim 0 . 1 \\% )$ of new bond formations in the training set examples. Coupled with the sparsity of molecular graphs, this reduces the prediction complexity from $O ( N ^ { 2 } )$ to $O ( N )$ for a product with $N$ atoms. Our edit prediction model has variants tailored to single and multiple edit prediction. Since $9 5 \\%$ of the training set consists of single edit examples, the remainder of this section describes the setup for single edit prediction. A detailed description of our multiple edit prediction model can be found in Appendix ??. ",
369
+ "bbox": [
370
+ 173,
371
+ 506,
372
+ 825,
373
+ 619
374
+ ],
375
+ "page_idx": 3
376
+ },
377
+ {
378
+ "type": "text",
379
+ "text": "Each bond $( u , v )$ in $\\mathcal { G } _ { p }$ is associated with a label $y _ { u v k } \\in \\{ 0 , 1 \\}$ indicating whether its bond type $k$ has changed from the products to reactants. Each atom $u$ is associated with a label $y _ { u } \\in \\{ 0 , \\bar { 1 } \\}$ indicating a change in hydrogen count. We predict edit scores using representations that are learnt using a graph encoder. ",
380
+ "bbox": [
381
+ 173,
382
+ 625,
383
+ 825,
384
+ 681
385
+ ],
386
+ "page_idx": 3
387
+ },
388
+ {
389
+ "type": "text",
390
+ "text": "Graph Encoder To obtain atom representations, we use a variant of the message passing network (MPN) described in [Gilmer et al., 2017]. Each atom $u$ has a feature vector $\\mathbf { x } _ { u }$ indicating its atom type, degree and other properties. Each bond $( u , v )$ has a feature vector $\\mathbf { x } _ { u v }$ indicating its aromaticity, bond type and ring membership. For simplicity, we denote the encoding process by $\\mathrm { M P N } ( \\cdot )$ and describe architectural details in Appendix ??. The MPN computes atom representations $\\{ \\mathbf { c } _ { u } | u \\in \\mathcal { G } \\}$ via ",
391
+ "bbox": [
392
+ 173,
393
+ 695,
394
+ 825,
395
+ 779
396
+ ],
397
+ "page_idx": 3
398
+ },
399
+ {
400
+ "type": "equation",
401
+ "img_path": "images/b517ef315352815d369d32f3af958c21a2ae42d976e66bdc837220e4bb39c388.jpg",
402
+ "text": "$$\n\\{ \\mathbf { c } _ { u } \\} = \\mathrm { M P N } ( \\mathcal { G } , \\{ \\mathbf { x } _ { u } \\} , \\{ \\mathbf { x } _ { u v } \\} _ { v \\in \\mathcal { N } ( u ) } ) ,\n$$",
403
+ "text_format": "latex",
404
+ "bbox": [
405
+ 367,
406
+ 794,
407
+ 629,
408
+ 813
409
+ ],
410
+ "page_idx": 3
411
+ },
412
+ {
413
+ "type": "text",
414
+ "text": "where $\\mathcal { N } ( u )$ denotes the neighbors of atom $u$ . The graph representation $\\mathbf { c } _ { \\mathcal { G } }$ is an aggregation of atom representations, i.e. $\\mathbf { c } _ { \\mathcal { G } } = \\dot { \\sum _ { { u } \\in \\mathcal { V } } } \\mathbf { c } _ { u }$ . When $\\mathcal { G }$ has connected components $\\left\\{ { \\mathcal { G } } _ { i } \\right\\}$ , we get a set of graph representations $\\left\\{ \\mathbf { c } _ { \\mathcal { G } _ { i } } \\right\\}$ . For a bond $( u , v )$ , we define its representation $\\mathbf { c } _ { u v } = ( \\operatorname { A B S } ( \\mathbf { c } _ { u } , \\mathbf { c } _ { v } ) | | \\mathbf { c } _ { u } + \\mathbf { c } _ { v } )$ , where ABS denotes absolute difference and $| |$ refers to concatenation. This ensures our representations are permutation invariant. These representations are then used to predict atom and bond edit scores using corresponding neural networks, ",
415
+ "bbox": [
416
+ 174,
417
+ 825,
418
+ 825,
419
+ 911
420
+ ],
421
+ "page_idx": 3
422
+ },
423
+ {
424
+ "type": "equation",
425
+ "img_path": "images/43a6f38c88896496f6b8c1e00b965fa739609189983ee4e111bdef371168642c.jpg",
426
+ "text": "$$\n\\begin{array} { r } { \\boldsymbol { s } _ { u } = \\mathbf { u _ { a } } ^ { T } \\boldsymbol { \\tau } ( \\mathbf { W _ { a } } \\mathbf { c } _ { u } + b ) \\quad } \\\\ { \\boldsymbol { s } _ { u v k } = \\mathbf { u _ { k } } ^ { T } \\boldsymbol { \\tau } ( \\mathbf { W _ { k } } \\mathbf { c } _ { u v } + b _ { k } ) , } \\end{array}\n$$",
427
+ "text_format": "latex",
428
+ "bbox": [
429
+ 400,
430
+ 87,
431
+ 596,
432
+ 131
433
+ ],
434
+ "page_idx": 4
435
+ },
436
+ {
437
+ "type": "text",
438
+ "text": "where $\\tau ( \\cdot )$ is the ReLU activation function. ",
439
+ "bbox": [
440
+ 176,
441
+ 142,
442
+ 457,
443
+ 157
444
+ ],
445
+ "page_idx": 4
446
+ },
447
+ {
448
+ "type": "text",
449
+ "text": "Updating Bond Edit Scores Unlike a typical classification problem where the labels are independent, edits can have possible dependencies between each other. For example, bonds part of a stable system such as an aromatic ring have a greater tendency to remain unchanged (label 0). We attempt to leverage such dependencies to update initial edit scores. To this end, we build a graph with bonds $( u , v )$ as nodes, and introduce an edge between bonds sharing an atom. We use another $\\mathrm { M P N } ( \\cdot )$ on this graph to learn aggregated neighborhood messages $\\mathbf { m } _ { u v }$ , and update the edit scores $s _ { u v k }$ in a manner similar to how LSTMs update representations, ",
450
+ "bbox": [
451
+ 173,
452
+ 172,
453
+ 825,
454
+ 270
455
+ ],
456
+ "page_idx": 4
457
+ },
458
+ {
459
+ "type": "equation",
460
+ "img_path": "images/190ca6c12e9d0551c6c507ca3bb0a358e64c6db98378f96a20d19207a9bfc801.jpg",
461
+ "text": "$$\n\\begin{array} { r l } & { f _ { u v k } = \\sigma ( \\mathbf { W _ { k x } ^ { f } } \\mathbf { x } _ { u v } + \\mathbf { W _ { k m } ^ { f } } \\mathbf { m } _ { u v } ) } \\\\ & { i _ { u v k } = \\sigma ( \\mathbf { W _ { k x } ^ { i } } \\mathbf { x } _ { u v } + \\mathbf { W _ { k m } ^ { i } } \\mathbf { m } _ { u v } ) } \\\\ & { \\tilde { m } _ { u v k } = \\mathbf { u _ { m } } \\tau ( \\mathbf { W _ { k x } ^ { m } } \\mathbf { x } _ { u v } + \\mathbf { W _ { k m } ^ { m } } \\mathbf { m } _ { u v } ) } \\\\ & { \\tilde { s } _ { u v k } = f _ { u v k } \\cdot s _ { u v k } + i _ { u v k } \\cdot \\tilde { m } _ { u v k } . } \\end{array}\n$$",
462
+ "text_format": "latex",
463
+ "bbox": [
464
+ 369,
465
+ 284,
466
+ 629,
467
+ 362
468
+ ],
469
+ "page_idx": 4
470
+ },
471
+ {
472
+ "type": "text",
473
+ "text": "Training We train by minimizing the cross-entropy loss over possible bond and atom edits ",
474
+ "bbox": [
475
+ 169,
476
+ 375,
477
+ 781,
478
+ 390
479
+ ],
480
+ "page_idx": 4
481
+ },
482
+ {
483
+ "type": "equation",
484
+ "img_path": "images/d39b464af053c1ddc554cc80cf10fc8a8cf6434c8681b4503820a67f7447deed.jpg",
485
+ "text": "$$\n\\mathcal { L } _ { e } = - \\sum _ { ( \\mathcal { G } _ { p } , E ) } \\left( \\sum _ { ( ( u , v ) , k ) \\in E } y _ { u v k } \\mathrm { l o g } ( \\widetilde s _ { u v k } ) + \\sum _ { u \\in E } y _ { u } \\mathrm { l o g } ( s _ { u } ) \\right) .\n$$",
486
+ "text_format": "latex",
487
+ "bbox": [
488
+ 287,
489
+ 402,
490
+ 710,
491
+ 454
492
+ ],
493
+ "page_idx": 4
494
+ },
495
+ {
496
+ "type": "text",
497
+ "text": "The cross-entropy loss enforces the model to learn a distribution over possible edits instead of reasoning about each edit independently, as with the binary cross entropy loss used in [Jin et al., 2017, Coley et al., 2019]. ",
498
+ "bbox": [
499
+ 174,
500
+ 467,
501
+ 825,
502
+ 510
503
+ ],
504
+ "page_idx": 4
505
+ },
506
+ {
507
+ "type": "text",
508
+ "text": "3.2 Synthon Completion ",
509
+ "text_level": 1,
510
+ "bbox": [
511
+ 174,
512
+ 526,
513
+ 356,
514
+ 542
515
+ ],
516
+ "page_idx": 4
517
+ },
518
+ {
519
+ "type": "text",
520
+ "text": "Synthons are completed into valid reactants by adding specific functionalities called leaving groups. This involves two complementary tasks: (i.) selecting the appropriate leaving group, and (ii.) attaching the leaving group to the synthon. As ground truth leaving groups are not directly provided, we extract the leaving groups and construct a vocabulary $\\mathcal { X }$ of unique leaving groups during preprocessing. ",
521
+ "bbox": [
522
+ 173,
523
+ 553,
524
+ 825,
525
+ 609
526
+ ],
527
+ "page_idx": 4
528
+ },
529
+ {
530
+ "type": "text",
531
+ "text": "The vocabulary has a limited size ( $| \\mathcal { X } | = 1 7 0$ for a standard dataset with 50, 000 examples, and 72000 synthons) indicating the redundancy of leaving groups used in accomplishing retrosynthetic transformations. This redundancy also allows us to formulate leaving group selection as a classification problem over $\\mathcal { X }$ , while retaining the ability to generate diverse reactants using different combinations of leaving groups. ",
532
+ "bbox": [
533
+ 174,
534
+ 614,
535
+ 825,
536
+ 685
537
+ ],
538
+ "page_idx": 4
539
+ },
540
+ {
541
+ "type": "text",
542
+ "text": "Vocabulary Construction Before constructing the vocabulary, we align connected components of synthon and reactant graphs by comparing atom mapping overlaps. Using aligned pairs $\\mathcal { G } _ { s _ { c } } =$ $( \\gamma _ { s _ { c } } , \\mathcal { E } _ { s _ { c } } )$ and $\\mathcal { G } _ { r _ { c } } = ( \\nu _ { r _ { c } } , \\mathcal { E } _ { r _ { c } } )$ as input, the leaving group vocabulary $\\mathcal { X }$ is constructed by extracting subgraphs $\\mathcal { G } _ { l _ { c } } = ( \\nu _ { l _ { c } } , \\mathcal { E } _ { l _ { c } } )$ such that $\\smash { \\gamma _ { l _ { c } } = \\gamma _ { r _ { c } } \\setminus \\gamma _ { s _ { c } } }$ . Atoms $\\left\\{ { a } _ { i } \\right\\}$ in the leaving groups that attach to synthons are marked with a special symbol. We also add three tokens to $\\mathcal { X }$ namely START, which indicates the start of synthon completion, END, which indicates that there is no leaving group to add and PAD, which is used to handle variable numbers of synthon components in a minibatch. ",
543
+ "bbox": [
544
+ 173,
545
+ 700,
546
+ 825,
547
+ 799
548
+ ],
549
+ "page_idx": 4
550
+ },
551
+ {
552
+ "type": "text",
553
+ "text": "Leaving Group Selection For synthon component $c \\leq C$ , where $C$ is the number of connected components in the synthon graph, we use three inputs for leaving group selection – the product representation $\\mathbf { c } _ { \\mathcal { G } _ { p } }$ , the synthon component representation $\\mathbf { c } _ { \\mathcal { G } _ { s _ { c } } }$ , and the leaving group representation for the previous synthon component, ${ \\bf e } _ { l _ { c - 1 } }$ . The product and synthon representations are learnt using the $\\mathrm { M P N } ( \\cdot )$ . For each $x _ { i } \\in { \\mathcal { X } }$ , representations can be learnt by either training independent embedding vectors (ind) or by treating each $x _ { i }$ as a subgraph and using the $\\mathrm { M P N } ( \\cdot )$ (shared). In the shared setting, we use the same $\\mathrm { M P N } ( \\cdot )$ as the product and synthons. ",
554
+ "bbox": [
555
+ 173,
556
+ 814,
557
+ 825,
558
+ 911
559
+ ],
560
+ "page_idx": 4
561
+ },
562
+ {
563
+ "type": "text",
564
+ "text": "The leaving group probabilities are then computed by combining $\\mathbf { c } _ { \\mathcal { G } _ { p } } , \\mathbf { c } _ { \\mathcal { G } _ { s _ { c } } }$ and $\\mathbf { e } _ { l _ { c - 1 } }$ via a single layer neural network and softmax function ",
565
+ "bbox": [
566
+ 173,
567
+ 90,
568
+ 823,
569
+ 119
570
+ ],
571
+ "page_idx": 5
572
+ },
573
+ {
574
+ "type": "equation",
575
+ "img_path": "images/d2fa89696df25b480905fd11b89872899b1206510d6da72f11724cb4e151b106.jpg",
576
+ "text": "$$\n\\hat { q } _ { l _ { c } } = \\mathrm { s o f t m a x } \\left( \\mathbf { U } \\tau \\left( \\mathbf { W } _ { 1 } \\mathbf { c } _ { \\mathcal { G } _ { p } } + \\mathbf { W } _ { 2 } \\mathbf { c } _ { \\mathcal { G } _ { s _ { c } } } + \\mathbf { W } _ { 3 } \\mathbf { e } _ { l _ { \\left( c - 1 \\right) } } \\right) \\right) ,\n$$",
577
+ "text_format": "latex",
578
+ "bbox": [
579
+ 305,
580
+ 131,
581
+ 691,
582
+ 151
583
+ ],
584
+ "page_idx": 5
585
+ },
586
+ {
587
+ "type": "text",
588
+ "text": "where $\\hat { q } _ { l _ { c } }$ is distribution learnt over $\\mathcal { X }$ . Using the representation of the previous leaving group ${ \\bf e } _ { l _ { c - 1 } }$ allows the model to understand combinations of leaving groups that generate the desired product from the reactants. We also include the product representation $\\mathbf { c } _ { \\mathcal { G } _ { p } }$ as the synthon graphs are derived from the product graph. ",
589
+ "bbox": [
590
+ 174,
591
+ 164,
592
+ 825,
593
+ 219
594
+ ],
595
+ "page_idx": 5
596
+ },
597
+ {
598
+ "type": "text",
599
+ "text": "Training For step $c$ , given the one hot encoding of the true leaving group $q _ { l _ { c } }$ , we minimize the cross-entropy loss ",
600
+ "bbox": [
601
+ 173,
602
+ 233,
603
+ 823,
604
+ 263
605
+ ],
606
+ "page_idx": 5
607
+ },
608
+ {
609
+ "type": "equation",
610
+ "img_path": "images/c5878d96a04183a5e264e043e021073accc4e3106f900490a5939023894394b7.jpg",
611
+ "text": "$$\n\\mathcal { L } _ { s } = \\sum _ { c = 1 } ^ { C } \\mathcal { L } ( \\hat { q } _ { l _ { c } } , q _ { l _ { c } } ) .\n$$",
612
+ "text_format": "latex",
613
+ "bbox": [
614
+ 428,
615
+ 275,
616
+ 570,
617
+ 319
618
+ ],
619
+ "page_idx": 5
620
+ },
621
+ {
622
+ "type": "text",
623
+ "text": "Training utilizes teacher-forcing [Williams and Zipser, 1989] so that the model makes predictions given correct histories. During inference, at every step, we use the representation of leaving group from the previous step with the highest predicted probability. ",
624
+ "bbox": [
625
+ 174,
626
+ 330,
627
+ 823,
628
+ 372
629
+ ],
630
+ "page_idx": 5
631
+ },
632
+ {
633
+ "type": "text",
634
+ "text": "Leaving Group Attachment Attaching leaving groups to synthons is a deterministic process and not learnt during training. The task involves identification of the type of bonds to add between attaching atoms in the leaving group (marked during vocabulary construction), and the atom(s) participating in the edit. These bonds can be inferred by applying the valency constraint, which determines the maximum number of neighbors for each atom. The attachment process does not modify any stereochemistry. Given synthons and leaving groups, the attachment process has a $100 \\%$ accuracy. The detailed procedure is described in Appendix ??. ",
635
+ "bbox": [
636
+ 173,
637
+ 387,
638
+ 825,
639
+ 484
640
+ ],
641
+ "page_idx": 5
642
+ },
643
+ {
644
+ "type": "text",
645
+ "text": "3.3 Inference ",
646
+ "text_level": 1,
647
+ "bbox": [
648
+ 174,
649
+ 501,
650
+ 279,
651
+ 515
652
+ ],
653
+ "page_idx": 5
654
+ },
655
+ {
656
+ "type": "text",
657
+ "text": "Inference is performed using beam search with a log-likelihood scoring function. For a beam width $n$ , we select $n$ edits with highest scores and apply them to the product to obtain $n$ synthons, where each synthon can consist of multiple connected components. The synthons form the nodes for beam search. Each node maintains a cumulative score by aggregating the log-likelihoods of the edit and predicted leaving groups. Leaving group inference starts with a connected component for each synthon, and selects $n$ leaving groups with highest log-likelihoods. From the $n ^ { 2 }$ possibilities, we select $n$ nodes with the highest cumulative scores. This process is repeated until all nodes have a leaving group predicted for each synthon component. ",
658
+ "bbox": [
659
+ 174,
660
+ 525,
661
+ 826,
662
+ 637
663
+ ],
664
+ "page_idx": 5
665
+ },
666
+ {
667
+ "type": "text",
668
+ "text": "4 Evaluation ",
669
+ "text_level": 1,
670
+ "bbox": [
671
+ 174,
672
+ 656,
673
+ 295,
674
+ 672
675
+ ],
676
+ "page_idx": 5
677
+ },
678
+ {
679
+ "type": "text",
680
+ "text": "Evaluating retrosynthesis models is challenging as multiple sets of reactants can be generated from the same product. To deal with this, previous works [Coley et al., 2017b, Dai et al., 2019] evaluate the ability of the model to recover retrosynthetic strategies recorded in the dataset. ",
681
+ "bbox": [
682
+ 174,
683
+ 686,
684
+ 825,
685
+ 728
686
+ ],
687
+ "page_idx": 5
688
+ },
689
+ {
690
+ "type": "text",
691
+ "text": "Data We use the benchmark dataset USPTO-50k [Schneider et al., 2016] for all our experiments. The dataset contains 50, 000 atom-mapped reactions across 10 reaction classes. We use the same dataset version and splits as provided by [Dai et al., 2019]. The USPTO-50k dataset contains a shortcut in that the product atom with atom-mapping 1 is part of the edit in $\\sim 7 5 \\%$ of the cases. If the product SMILES is not canonicalized, predictions utilizing operations that depend on the position of the atom or bond will be able to use the shortcut, and overestimate performance. We canonicalize the product SMILES, and reassign atom-mappings to the reactant atoms based on the canonical ordering, which removes the shortcut. Details on the remapping procedure can be found in Appendix ??. ",
692
+ "bbox": [
693
+ 174,
694
+ 742,
695
+ 825,
696
+ 854
697
+ ],
698
+ "page_idx": 5
699
+ },
700
+ {
701
+ "type": "text",
702
+ "text": "Evaluation We use the top- $\\mathbf { \\nabla } \\cdot n$ accuracy $( n = 1 , 3 , 5 , 1 0 )$ ) as our evaluation metric, defined as the fraction of examples where the recorded reactants are suggested by the model with rank $\\leq n$ . Following prior work [Coley et al., 2017b, Zheng et al., 2019, Dai et al., 2019], we compute the accuracy by comparing the canonical SMILES of predicted reactants to the ground truth. Atom-mapping is excluded from this comparison, but stereochemistry, which describes the relative orientation of atoms in the molecule, is retained. The evaluation is carried out for two settings, with the reaction class being known or unknown. ",
703
+ "bbox": [
704
+ 176,
705
+ 869,
706
+ 825,
707
+ 911
708
+ ],
709
+ "page_idx": 5
710
+ },
711
+ {
712
+ "type": "table",
713
+ "img_path": "images/b50491b8ada14574c6239d28c43d14386b5d359906cdb5f2c186422249a03113.jpg",
714
+ "table_caption": [
715
+ "Table 1: Top- $n$ exact match accuracy. Best values within each section are highlighted in bold. "
716
+ ],
717
+ "table_footnote": [],
718
+ "table_body": "<table><tr><td rowspan=\"3\">Model</td><td colspan=\"8\">Top-n Accuracy (%)</td></tr><tr><td colspan=\"4\">Reaction class known</td><td colspan=\"4\">Reaction class unknown</td></tr><tr><td>1</td><td>3</td><td>5</td><td>10</td><td>1</td><td>3</td><td>5</td><td>10</td></tr><tr><td colspan=\"9\">Template-Based</td></tr><tr><td>RETROSIM [Coley et al.,2017b]</td><td>52.9</td><td>73.8</td><td>81.2</td><td>88.1</td><td>37.3</td><td>54.7</td><td>63.3</td><td>74.1</td></tr><tr><td>NEURALSYM [Segler and Waller,2017]</td><td>55.3</td><td>76.0</td><td>81.4</td><td>85.1</td><td>44.4</td><td>65.3</td><td>72.4</td><td>78.9</td></tr><tr><td>GLN [Dai et ai., 2019]</td><td>64.2</td><td>79.1</td><td>85.2</td><td>90.0</td><td>52.5</td><td>69.0</td><td>75.6</td><td>83.7</td></tr><tr><td>DUALTB [Sun et al.,2021]</td><td>67.7</td><td>84.8</td><td>88.9</td><td>92.0</td><td>55.2</td><td>74.6</td><td>80.5</td><td>86.9</td></tr><tr><td colspan=\"9\">Template-Free</td></tr><tr><td>SCROP [Zheng et al.,2019]</td><td>59.0</td><td>74.8</td><td>78.1</td><td>81.1</td><td>43.7</td><td>60.0</td><td>65.2</td><td>68.7</td></tr><tr><td>LV-TRANSFORMER [Chen et al.,2019]</td><td>-</td><td>-</td><td>-</td><td>-</td><td>40.5</td><td>65.1</td><td>72.8</td><td>79.4</td></tr><tr><td>DUALTF [Sun et al., 2021]</td><td>65.7</td><td>81.9</td><td>84.7</td><td>85.9</td><td>53.6</td><td>70.7</td><td>74.6</td><td>77.0</td></tr><tr><td colspan=\"9\">Semi-Template-Based</td></tr><tr><td>G2Gs [Shi et al.,2020]</td><td>61.0</td><td>81.3</td><td>86.0</td><td>88.7</td><td>48.9</td><td>67.6</td><td>72.5</td><td>75.5</td></tr><tr><td>RETROXPERT [Yan et al.,2020]</td><td>62.1</td><td>75.8</td><td>78.5</td><td>80.9</td><td>50.4</td><td>61.1</td><td>62.3</td><td>63.4</td></tr><tr><td>GRAPHRETRO (ours)</td><td>63.9</td><td>81.5</td><td>85.2</td><td>88.1</td><td>53.7</td><td>68.3</td><td>72.2</td><td>75.5</td></tr></table>",
719
+ "bbox": [
720
+ 171,
721
+ 116,
722
+ 826,
723
+ 366
724
+ ],
725
+ "page_idx": 6
726
+ },
727
+ {
728
+ "type": "text",
729
+ "text": "",
730
+ "bbox": [
731
+ 173,
732
+ 392,
733
+ 825,
734
+ 448
735
+ ],
736
+ "page_idx": 6
737
+ },
738
+ {
739
+ "type": "text",
740
+ "text": "Baselines For evaluating overall performance, we compare GRAPHRETRO to nine baselines — four template-based, three template-free, and two semi-template-based methods. These include: ",
741
+ "bbox": [
742
+ 174,
743
+ 465,
744
+ 825,
745
+ 494
746
+ ],
747
+ "page_idx": 6
748
+ },
749
+ {
750
+ "type": "text",
751
+ "text": "Template-Based: RETROSIM Coley et al. [2017b] ranks templates for a given target molecule by computing molecular similarities to precedent reactions. NEURALSYM [Segler and Waller, 2017] trains a model to rank templates given a target molecule. GLN [Dai et al., 2019] models the joint distribution of templates and reactants in a hierarchical fashion using logic variables. DUALTB [Sun et al., 2021] uses an energy-based model formulation for retrosynthesis, with additional parameterizations and loss terms to enforce the duality between forward (reaction prediction) and backward (retrosynthesis prediction). Inference is carried out using reactant candidates obtained by applying an extracted template set to the products. ",
752
+ "bbox": [
753
+ 181,
754
+ 507,
755
+ 825,
756
+ 619
757
+ ],
758
+ "page_idx": 6
759
+ },
760
+ {
761
+ "type": "text",
762
+ "text": "Template-Free: SCROP [Zheng et al., 2019], LV-TRANSFORMER [Chen et al., 2019] and DUALTF [Sun et al., 2021] use the Transformer architecture [Vaswani et al., 2017] to output reactant SMILES given a product SMILES. To improve the validity of their suggestions, SCROP include a second Transformer that functions as a syntax correcter. LV-TRANSFORMER uses a latent variable mixture model to improve diversity of suggestions. DUALTF utilizes additional parameterizations and loss terms to enforce the duality between forward (reaction prediction) and backward (retrosynthesis prediction). ",
763
+ "bbox": [
764
+ 183,
765
+ 626,
766
+ 825,
767
+ 722
768
+ ],
769
+ "page_idx": 6
770
+ },
771
+ {
772
+ "type": "text",
773
+ "text": "Semi-Template-Based: G2GS [Shi et al., 2020] and RETROXPERT [Yan et al., 2020] first identify synthons, and then expand the synthons into reactants by either sequential generation of atoms and bonds (G2Gs), or using the Transformer architecture (RETROXPERT). The training dataset for the Transformer in [Yan et al., 2020] is augmented with incorrectly predicted synthons with the goal of learning a correction mechanism. ",
774
+ "bbox": [
775
+ 183,
776
+ 729,
777
+ 825,
778
+ 799
779
+ ],
780
+ "page_idx": 6
781
+ },
782
+ {
783
+ "type": "text",
784
+ "text": "Results for NEURALSYM are taken from [Dai et al., 2019]. The authors in [Yan et al., 2020] report their performance being affected by the dataset leakage2. Thus, we use the most recent results from their website on the canonicalized dataset. For remaining baselines, we directly use the values reported in their paper. For the synthon completion module, we use the ind configuration given its better empirical performance. ",
785
+ "bbox": [
786
+ 176,
787
+ 813,
788
+ 823,
789
+ 882
790
+ ],
791
+ "page_idx": 6
792
+ },
793
+ {
794
+ "type": "text",
795
+ "text": "4.1 Overall Performance ",
796
+ "text_level": 1,
797
+ "bbox": [
798
+ 174,
799
+ 90,
800
+ 357,
801
+ 106
802
+ ],
803
+ "page_idx": 7
804
+ },
805
+ {
806
+ "type": "text",
807
+ "text": "Reaction class unknown As shown in Table 1, when the reaction class is unknown, GRAPHRETRO outperforms G2GS by $4 . 8 \\%$ and and RETROXPERT by $3 . 3 \\%$ in top-1 accuracy. Performance improvements are also seen for larger $n$ , except for $n = 5$ . Barring DUALTB, the top-1 accuracy is also better than other template-free and template-based methods. For larger $n$ , one reason for lower top- $n$ accuracies than most template-based methods is that templates already contain combinations of leaving group patterns. In contrast, our model learns to discover these during training. A second hypothesis to this end is that simply adding log-likelihood scores from edit prediction and synthon completion models may be suboptimal and bias the beam search in the direction of the more dominating term. We leave it to future work to investigate scoring functions that rank the attachment. ",
808
+ "bbox": [
809
+ 173,
810
+ 121,
811
+ 825,
812
+ 246
813
+ ],
814
+ "page_idx": 7
815
+ },
816
+ {
817
+ "type": "text",
818
+ "text": "Reaction class known When the reaction class is known, GRAPHRETRO outperforms G2GS and RETROXPERT by a margin of $3 \\%$ and $2 \\%$ respectively in top-1 accuracy. GRAPHRETRO also outperforms all the template-free methods in top- $^ n$ accuracy. for GRAPHRETRO are also better than most template-based and template-free methods. When the reaction class is known, RETROSIM and GLN restrict template sets corresponding to the reaction class, thus improving performance. The increased edit prediction performance (Section 4.2) for GRAPHRETRO helps outweigh this factor, achieving comparable or better performance till $n = 5$ . ",
819
+ "bbox": [
820
+ 174,
821
+ 271,
822
+ 825,
823
+ 368
824
+ ],
825
+ "page_idx": 7
826
+ },
827
+ {
828
+ "type": "text",
829
+ "text": "4.2 Individual Module Performance ",
830
+ "text_level": 1,
831
+ "bbox": [
832
+ 174,
833
+ 396,
834
+ 436,
835
+ 411
836
+ ],
837
+ "page_idx": 7
838
+ },
839
+ {
840
+ "type": "text",
841
+ "text": "To gain more insight into the working of GRAPHRETRO, we evaluate the top- $\\boldsymbol { n }$ accuracy $\\mathbf { \\nabla } _ { n } =$ $1 , 2 , 3 , 5 )$ of edit prediction and synthon completion modules, along with corresponding ablation studies, with results shown in Table 2. ",
842
+ "bbox": [
843
+ 174,
844
+ 426,
845
+ 825,
846
+ 468
847
+ ],
848
+ "page_idx": 7
849
+ },
850
+ {
851
+ "type": "text",
852
+ "text": "Edit Prediction For the edit prediction module, we compare the true edit(s) to top- $\\boldsymbol { n }$ edits predicted by the model. We also consider two ablation studies, one where we directly use the initial edit scores without updating them, and the other where we predict edits using atom-pairs instead of existing bonds and atoms. Both design choices lead to improvements in performance, as shown in Table 2. We hypothesize that the larger improvement compared to edit prediction using atom-pairs is due to the easier optimization procedure, with lesser imbalance between labels 1 and 0. ",
853
+ "bbox": [
854
+ 173,
855
+ 493,
856
+ 825,
857
+ 577
858
+ ],
859
+ "page_idx": 7
860
+ },
861
+ {
862
+ "type": "text",
863
+ "text": "Synthon Completion For evaluating the synthon completion module, we first apply the true edits to obtain synthons, and compare the true leaving groups to top- $\\mathbf { \\nabla } \\cdot n$ leaving groups predicted by the model. We test the performance of both the ind and shared configurations. Both configurations perform similarly, and are able to identify $\\sim 9 7 \\%$ (close to its upper bound of $9 9 . 7 \\%$ ) of the true leaving groups in its top-5 choices, when the reaction class is known. The top-1, 3 and 5 accuracies of the synthon completion for unknown reaction classes for G2Gs are $6 1 . 1 \\%$ , $8 1 . 5 \\%$ and $8 6 . 7 \\%$ respectively, while ours are $7 5 . 6 \\%$ , $9 2 . 5 \\%$ and $9 6 . 1 \\%$ , indicating a $10 \\%$ performance improvement using a classification formulation over the generative one adopted by G2Gs. ",
864
+ "bbox": [
865
+ 173,
866
+ 603,
867
+ 825,
868
+ 714
869
+ ],
870
+ "page_idx": 7
871
+ },
872
+ {
873
+ "type": "table",
874
+ "img_path": "images/a7464e4972dde4bef7b44f291b1851eda3f6ff349da317bc359b2a73e891edfc.jpg",
875
+ "table_caption": [
876
+ "Table 2: Performance Study of edit prediction and synthon completion modules "
877
+ ],
878
+ "table_footnote": [],
879
+ "table_body": "<table><tr><td rowspan=\"3\"> Setting</td><td colspan=\"8\">Top-n Accuracy (%)</td></tr><tr><td colspan=\"4\">Reaction class known</td><td colspan=\"4\">Reaction class unknown</td></tr><tr><td>1</td><td>2</td><td>3</td><td>5</td><td>1</td><td>2</td><td>3</td><td>5</td></tr><tr><td>Edit Prediction</td><td>84.6</td><td>92.2</td><td>93.7</td><td>94.5</td><td>70.8</td><td>85.1</td><td>89.5</td><td>92.7</td></tr><tr><td>- without edit score updates</td><td>84.3</td><td>92.1</td><td>93.7</td><td>94.5</td><td>70.1</td><td>84.8</td><td>89.4</td><td>92.6</td></tr><tr><td>- predicting on atom pairs</td><td>81.9</td><td>89.5</td><td>90.9</td><td>92.1</td><td>68.6</td><td>83.2</td><td>88.3</td><td>91.8</td></tr><tr><td>Synthon Completion (ind)</td><td>77.4</td><td>89.5</td><td>94.2</td><td>97.6</td><td>75.6</td><td>87.4</td><td>92.5</td><td>96.1</td></tr><tr><td>Synthon Completion (shared)</td><td>76.9</td><td>89.6</td><td>93.9</td><td>97.4</td><td>74.9</td><td>87.7</td><td>92.9</td><td>96.3</td></tr></table>",
880
+ "bbox": [
881
+ 173,
882
+ 767,
883
+ 826,
884
+ 909
885
+ ],
886
+ "page_idx": 7
887
+ },
888
+ {
889
+ "type": "text",
890
+ "text": "4.3 Example Predictions ",
891
+ "text_level": 1,
892
+ "bbox": [
893
+ 174,
894
+ 92,
895
+ 356,
896
+ 106
897
+ ],
898
+ "page_idx": 8
899
+ },
900
+ {
901
+ "type": "text",
902
+ "text": "In Figure 2, we visualize the model predictions and the ground truth for three cases. Figure 2a shows an example where the model identifies both the edits and leaving groups correctly. In Figure 2b, the correct edit is identified but the predicted leaving groups are incorrect. We hypothesize this is due to the fact that in the training set, leaving groups attaching to the carbonyl carbon $\\scriptstyle ( \\mathbf { C } = \\mathbf { O } )$ are small (e.g. -OH, - $\\mathrm { - N H _ { 2 } }$ , halides). The true leaving group in this example, however, is large. The model is unable to reason about this and predicts the small leaving group -I. In Figure 2c, the model identifies the edit and consequently the leaving group incorrectly. This highlights a limitation of our model. If the edit is predicted incorrectly, the model cannot suggest the true precursors. ",
903
+ "bbox": [
904
+ 173,
905
+ 116,
906
+ 825,
907
+ 228
908
+ ],
909
+ "page_idx": 8
910
+ },
911
+ {
912
+ "type": "text",
913
+ "text": "4.4 Limitations ",
914
+ "text_level": 1,
915
+ "bbox": [
916
+ 174,
917
+ 243,
918
+ 294,
919
+ 258
920
+ ],
921
+ "page_idx": 8
922
+ },
923
+ {
924
+ "type": "text",
925
+ "text": "The simplified and interpretable construction of GRAPHRETRO comes with certain limitations. First, the overall performance of the model is limited by the performance of the edit prediction step. If the predicted edit is incorrect, the true reactants cannot be salvaged. This limitation is partly remedied by our model design, that allows for user intervention to correct the edit. Second, our method is reliant on atom-mapping for extracting edits and leaving groups. Extracting edits directly based on substructure matching currently suffer from false positives, and heuristics to correct for these result in correct edits in only ${ \\sim } 9 0 \\%$ of the cases. Third, our formulation assumes that we have as many synthons as reactants, which is violated in some reactions. We leave it to future work to extend the model to realize a single reactant from multiple synthons, and introduce more chemically meaningful edit correction mechanisms. ",
926
+ "bbox": [
927
+ 173,
928
+ 268,
929
+ 825,
930
+ 407
931
+ ],
932
+ "page_idx": 8
933
+ },
934
+ {
935
+ "type": "image",
936
+ "img_path": "images/9df65c90e84b75ac55b8dc08692726ee93cf492df4b05d29c79c8c792f98fccd.jpg",
937
+ "image_caption": [
938
+ "Figure 2: Example Predictions. The true edit and incorrect edit (if any) are highlighted in green and red respectively. The true and predicted leaving groups are highlighted in blue. a. Correctly predicted example by the model. b. Correctly predicted edit but incorrectly predicted leaving groups. c. Incorrectly predicted edit and leaving group. "
939
+ ],
940
+ "image_footnote": [],
941
+ "bbox": [
942
+ 267,
943
+ 417,
944
+ 710,
945
+ 743
946
+ ],
947
+ "page_idx": 8
948
+ },
949
+ {
950
+ "type": "text",
951
+ "text": "5 Conclusion ",
952
+ "text_level": 1,
953
+ "bbox": [
954
+ 174,
955
+ 838,
956
+ 299,
957
+ 856
958
+ ],
959
+ "page_idx": 8
960
+ },
961
+ {
962
+ "type": "text",
963
+ "text": "Previous methods for single-step retrosynthesis either restrict prediction to a template set, are insensitive to molecular graph structure or generate molecules from scratch. We address these shortcomings by introducing a graph-based semi-template-based model inspired by a chemist’s workflow, enhancing the interpretability of retrosynthesis models. Given a target molecule, we first identify synthetic building blocks (synthons) which are then realized into valid reactants, thus avoiding molecule generation from scratch. Our model outperforms previous semi-template-methods by significant margins on the benchmark dataset. Future work aims to extend the model to realize a single reactant from multiple synthons, and introduce more chemically meaningful components to improve the synergy between such tools for retrosynthesis prediction and a practitioner’s expertise. ",
964
+ "bbox": [
965
+ 174,
966
+ 869,
967
+ 825,
968
+ 911
969
+ ],
970
+ "page_idx": 8
971
+ },
972
+ {
973
+ "type": "text",
974
+ "text": "",
975
+ "bbox": [
976
+ 174,
977
+ 92,
978
+ 825,
979
+ 174
980
+ ],
981
+ "page_idx": 9
982
+ },
983
+ {
984
+ "type": "text",
985
+ "text": "Acknowledgements ",
986
+ "text_level": 1,
987
+ "bbox": [
988
+ 176,
989
+ 194,
990
+ 338,
991
+ 210
992
+ ],
993
+ "page_idx": 9
994
+ },
995
+ {
996
+ "type": "text",
997
+ "text": "This research was supported by the Machine Learning for Pharmaceutical Discovery and Synthesis Consortium at MIT. V.R.S. was also supported by the Zeno Karl Schindler Foundation. C.B. was supported by the Swiss National Science Foundation under the National Center of Competence in Research (NCCR) Catalysis under grant agreement 51NF40 180544. We thank the Leonhard scientific computing cluster at ETH Zürich for providing computational resources. ",
998
+ "bbox": [
999
+ 174,
1000
+ 224,
1001
+ 825,
1002
+ 295
1003
+ ],
1004
+ "page_idx": 9
1005
+ },
1006
+ {
1007
+ "type": "text",
1008
+ "text": "References ",
1009
+ "text_level": 1,
1010
+ "bbox": [
1011
+ 174,
1012
+ 314,
1013
+ 266,
1014
+ 330
1015
+ ],
1016
+ "page_idx": 9
1017
+ },
1018
+ {
1019
+ "type": "text",
1020
+ "text": "B. Chen, T. Shen, T. S. Jaakkola, and R. Barzilay. Learning to Make Generalizable and Diverse Predictions for Retrosynthesis. In Submission, 2019. \nC. W. Coley, R. Barzilay, T. S. Jaakkola, W. H. Green, and K. F. Jensen. Prediction of Organic Reaction Outcomes Using Machine Learning. In ACS Central Science. ACS Publications, 2017a. \nC. W. Coley, L. Rogers, W. H. Green, and K. F. Jensen. Computer-Assisted Retrosynthesis Based on Molecular Similarity. ACS Central Science, 3, 2017b. \nC. W. Coley, W. Jin, L. Rogers, T. F. Jamison, T. S. Jaakkola, W. H. Green, R. Barzilay, and K. F. Jensen. A graph-convolutional neural network model for the prediction of chemical reactivity. Chemical Science, 10, 2019. \nE. Corey and W. T. Wipke. Computer-assisted design of complex organic syntheses. Science, 166 (3902):178–192, 1969. \nE. J. Corey. The Logic of Chemical Synthesis: Multistep Synthesis of Complex Carbogenic Molecules (Nobel Lecture). Angewandte Chemie International Edition, 30, 1991. \nH. Dai, C. Li, C. Coley, B. Dai, and L. Song. Retrosynthesis Prediction with Conditional Graph Logic Network. In Advances in Neural Information Processing Systems (NeurIPS), volume 32, 2019. \nS. Genheden, A. Thakkar, V. Chadimová, J.-L. Reymond, O. Engkvist, and E. Bjerrum. Aizynthfinder: a fast, robust and flexible open-source software for retrosynthetic planning. Journal of cheminformatics, 12(1):1–9, 2020. \nJ. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals, and G. E. Dahl. Neural Message Passing for Quantum Chemistry. In International Conference on Machine Learning (ICML), volume 70, 2017. \nM. Hartenfeller, M. Eberle, P. Meier, C. Nieto-Oberhuber, K.-H. Altmann, G. Schneider, E. Jacoby, and S. Renner. A Collection of Robust Organic Synthesis Reactions for In Silico Molecule Design. In Journal of Chemical Information and Modeling, volume 51. ACS Publications, 2011. \nW. Jin, C. Coley, R. Barzilay, and T. Jaakkola. Predicting Organic Reaction Outcomes with WeisfeilerLehman Network. In Advances in Neural Information Processing Systems (NeurIPS), volume 30, 2017. \nW. Jin, R. Barzilay, and T. Jaakkola. Junction Tree Variational Autoencoder for Molecular Graph Generation. In International Conference on Machine Learning (ICML), volume 32, 2018. \nW. Jin, R. Barzilay, and T. Jaakkola. Composing Molecules with Multiple Property Constraints. In International Conference on Machine Learning (ICML), 2020. \nJ. Law, Z. Zsoldos, A. Simon, D. Reid, Y. Liu, S. Y. Khew, A. P. Johnson, S. Major, R. A. Wade, and H. Y. Ando. Route Designer: A Retrosynthetic Analysis Tool Utilizing Automated Retrosynthetic Rule Generation. Journal of Chemical Information and Modeling, 49, 2009. \nB. Liu, B. Ramsundar, P. Kawthekar, J. Shi, J. Gomes, Q. Luu Nguyen, S. Ho, J. Sloane, P. Wender, and V. Pande. Retrosynthetic Reaction Prediction Using Neural Sequence-to-Sequence Models. In ACS Central Science, volume 3. ACS Publications, 2017. \nN. Schneider, N. Stiefl, and G. A. Landrum. What’s What: The (Nearly) Definitive Guide to Reaction Role Assignment. In Journal of Chemical Information and Modeling, volume 56. ACS Publications, 2016. \nM. H. Segler and M. P. Waller. Neural-Symbolic Machine Learning for Retrosynthesis and Reaction Prediction. Chemistry–A European Journal, 23, 2017. \nC. Shi, M. Xu, H. Guo, M. Zhang, and J. Tang. A graph to graphs framework for retrosynthesis prediction, 2020. \nR. Sun, H. Dai, L. Li, S. Kearnes, and B. Dai. Energy-based view of retrosynthesis, 2021. URL https://openreview.net/forum?id $\\equiv$ 0Hj3tFCSjUd. \nS. Szymkuc, E. P. Gajewska, T. Klucznik, K. Molga, P. Dittwald, M. Startek, M. Bajczyk, and ´ B. A. Grzybowski. Computer-assisted synthetic planning: The end of the beginning. Angewandte Chemie International Edition, 55(20):5904–5937, 2016. \nA. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin. Attention is All You Need. In Advances in Neural Information Processing Systems (NeurIPS), volume 30, 2017. \nD. Weininger. SMILES, a Chemical Language and Information System. Journal of Chemical Information and Computer Sciences, 28, 1988. \nR. J. Williams and D. Zipser. A Learning Algorithm for Continually Running Fully Recurrent Neural Networks. In Neural Computation, volume 1. MIT Press, 1989. \nC. Yan, Q. Ding, P. Zhao, S. Zheng, J. YANG, Y. Yu, and J. Huang. Retroxpert: Decompose retrosynthesis prediction like a chemist. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 11248–11258. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/file/ 819f46e52c25763a55cc642422644317-Paper.pdf. \nS. Zheng, J. Rao, Z. Zhang, J. Xu, and Y. Yang. Predicting Retrosynthetic Reactions using SelfCorrected Transformer Neural Networks. In Journal of Chemical Information and Modeling. ACS Publications, 2019. ",
1021
+ "bbox": [
1022
+ 171,
1023
+ 329,
1024
+ 828,
1025
+ 896
1026
+ ],
1027
+ "page_idx": 9
1028
+ },
1029
+ {
1030
+ "type": "text",
1031
+ "text": "",
1032
+ "bbox": [
1033
+ 169,
1034
+ 83,
1035
+ 826,
1036
+ 665
1037
+ ],
1038
+ "page_idx": 10
1039
+ }
1040
+ ]
parse/train/LyjH88yV7F/LyjH88yV7F_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/LyjH88yV7F/LyjH88yV7F_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/S1gUsoR9YX/S1gUsoR9YX_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/S1gUsoR9YX/S1gUsoR9YX_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/l2UWXn5iBQI/l2UWXn5iBQI_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/train/l2UWXn5iBQI/l2UWXn5iBQI_model.json ADDED
The diff for this file is too large to render. See raw diff
 
vlm/test/2dnO3LLiJ1/0.png ADDED

Git LFS Details

  • SHA256: 5057fce41539590857c4424c0760d93bccf4a6f495c257debf47e462c759a97e
  • Pointer size: 131 Bytes
  • Size of remote file: 654 kB
vlm/test/2dnO3LLiJ1/1.png ADDED

Git LFS Details

  • SHA256: 4cd6dc52b7920e029c7c4b15ff0c4163fc7e1a380ef06a69c742551a0f793b4e
  • Pointer size: 131 Bytes
  • Size of remote file: 632 kB
vlm/test/2dnO3LLiJ1/10.png ADDED

Git LFS Details

  • SHA256: 842c4b057aa28556d5a9e4b6c9e13be420ae66894e6f6e6ef96e6e54c1a7f5a2
  • Pointer size: 131 Bytes
  • Size of remote file: 444 kB
vlm/test/2dnO3LLiJ1/11.png ADDED

Git LFS Details

  • SHA256: e4a7bb9c804e3fa799b03ba70cf08942b76435234dc2bd3c346aa4657a19a7ea
  • Pointer size: 131 Bytes
  • Size of remote file: 372 kB
vlm/test/2dnO3LLiJ1/12.png ADDED

Git LFS Details

  • SHA256: 452f03cb962217a70f9411ea6c1abca6c67e0a6692ec1d06e89b77f38b05b067
  • Pointer size: 131 Bytes
  • Size of remote file: 553 kB
vlm/test/2dnO3LLiJ1/13.png ADDED

Git LFS Details

  • SHA256: 555d0004c01144d553f9fc486fd86530ff427e1ec2c5efe918b3d318e0e7231e
  • Pointer size: 131 Bytes
  • Size of remote file: 439 kB
vlm/test/2dnO3LLiJ1/14.png ADDED

Git LFS Details

  • SHA256: 96b4fcef680220de612a23943cea3c8099bf85d7738d0e1f53bbbfaa3f5f1098
  • Pointer size: 131 Bytes
  • Size of remote file: 386 kB
vlm/test/2dnO3LLiJ1/15.png ADDED

Git LFS Details

  • SHA256: a140d67966fe393ccea979ca4333e3b7ba19cdb9c01d47806e844d8114d48df4
  • Pointer size: 131 Bytes
  • Size of remote file: 529 kB
vlm/test/2dnO3LLiJ1/16.png ADDED

Git LFS Details

  • SHA256: 273dcc6ba82a966972fa599a4cc328a0d313d9f20b1b4887fb2963ff92f8cf86
  • Pointer size: 131 Bytes
  • Size of remote file: 311 kB
vlm/test/2dnO3LLiJ1/17.png ADDED

Git LFS Details

  • SHA256: 2fe6268102876839853eef59643dafe39ea74108b523474afe7c6102fb1bc167
  • Pointer size: 130 Bytes
  • Size of remote file: 43.6 kB
vlm/test/2dnO3LLiJ1/18.png ADDED

Git LFS Details

  • SHA256: 871d2285634f642d00272d144df9447a64b82724dfecb8391c71b361de46cc92
  • Pointer size: 132 Bytes
  • Size of remote file: 1.24 MB
vlm/test/2dnO3LLiJ1/19.png ADDED

Git LFS Details

  • SHA256: 6ff458f98cd3d034c3038e04a8b09c700c2cfb9d2f548c95fb9356de8067f594
  • Pointer size: 132 Bytes
  • Size of remote file: 1.25 MB
vlm/test/2dnO3LLiJ1/2.png ADDED

Git LFS Details

  • SHA256: f719e54cfa72564ec541682d10d2e97360e609fbe1729e18bbed028b47598c89
  • Pointer size: 131 Bytes
  • Size of remote file: 558 kB
vlm/test/2dnO3LLiJ1/20.png ADDED

Git LFS Details

  • SHA256: 722f102b167450ab6c64a3c6d5c00c2bd7afe4acaae67cf9eac5deb9cb8f9464
  • Pointer size: 132 Bytes
  • Size of remote file: 1.39 MB
vlm/test/2dnO3LLiJ1/3.png ADDED

Git LFS Details

  • SHA256: 35b7acb7afb9ac23bf9515c8221592be3bec7e69b01bc98b17a6d047bc960c64
  • Pointer size: 131 Bytes
  • Size of remote file: 545 kB
vlm/test/2dnO3LLiJ1/4.png ADDED

Git LFS Details

  • SHA256: 7f8d1b95d954a73742751d119f712dbdae8dbba29f6222299d1e599808f898c9
  • Pointer size: 131 Bytes
  • Size of remote file: 476 kB
vlm/test/2dnO3LLiJ1/5.png ADDED

Git LFS Details

  • SHA256: 975507481961424affaa44bd0f4581139a9935634647319a4cb98a316ef9f216
  • Pointer size: 131 Bytes
  • Size of remote file: 523 kB
vlm/test/2dnO3LLiJ1/6.png ADDED

Git LFS Details

  • SHA256: ac3657ec91b747860329f948a8dcbb308bb868af65ffdccced2f7ef91bc6dc12
  • Pointer size: 131 Bytes
  • Size of remote file: 573 kB
vlm/test/2dnO3LLiJ1/7.png ADDED

Git LFS Details

  • SHA256: c8b8a8db58ecfb8d1339a66b9e0805cda774ba2f6262b8c269c92431fadaf6f8
  • Pointer size: 131 Bytes
  • Size of remote file: 599 kB
vlm/test/2dnO3LLiJ1/8.png ADDED

Git LFS Details

  • SHA256: 34b6700083921f6a0e66e2964f80506f0e528bd0fb7e162dfaf8261e25180b70
  • Pointer size: 131 Bytes
  • Size of remote file: 634 kB
vlm/test/2dnO3LLiJ1/9.png ADDED

Git LFS Details

  • SHA256: e475407d3b50dde3f39b0d9fb4a4f290c2543ccef57c031046d75ebff2087825
  • Pointer size: 131 Bytes
  • Size of remote file: 503 kB
vlm/test/6M5G5hNiAU/0.png ADDED

Git LFS Details

  • SHA256: 674b607eb66d8801873d8f13f69a7547fb0bb7ad2a7b5816f5009cac144ff4bd
  • Pointer size: 131 Bytes
  • Size of remote file: 518 kB
vlm/test/6M5G5hNiAU/1.png ADDED

Git LFS Details

  • SHA256: 75aa5492d8ee17e94b68ed996e7a8607ec02fa4d400f88e268c9e983611d3ca9
  • Pointer size: 131 Bytes
  • Size of remote file: 557 kB
vlm/test/6M5G5hNiAU/10.png ADDED

Git LFS Details

  • SHA256: 034bd0cb6377b1143b0e7fec086c3f2426e2e761495dd893802de3442a60ac4e
  • Pointer size: 131 Bytes
  • Size of remote file: 563 kB
vlm/test/6M5G5hNiAU/11.png ADDED

Git LFS Details

  • SHA256: 4295622174ff8192245de800ff6a1392eba72f740816e92b68d5940f19238ddf
  • Pointer size: 131 Bytes
  • Size of remote file: 600 kB
vlm/test/6M5G5hNiAU/12.png ADDED

Git LFS Details

  • SHA256: 7748b58e2553c553f7ab667da33aaea76ead2dffb90b2b5f216153e452d0d075
  • Pointer size: 131 Bytes
  • Size of remote file: 239 kB
vlm/test/6M5G5hNiAU/13.png ADDED

Git LFS Details

  • SHA256: f0e33155419fc98c22d123a43b1f1321b62080e0ec27e4a6ceb96b2b5b2e7297
  • Pointer size: 131 Bytes
  • Size of remote file: 434 kB
vlm/test/6M5G5hNiAU/14.png ADDED

Git LFS Details

  • SHA256: 4c8a81ce9ddbf0a0676be8cd76bfe2ac6b112082f6a5a1de45cee6904c6d9bd2
  • Pointer size: 131 Bytes
  • Size of remote file: 451 kB
vlm/test/6M5G5hNiAU/15.png ADDED

Git LFS Details

  • SHA256: 406c77bc0ea653ec70512b70bfc65837110cceacf8b83bec29693f7e00a1bdf9
  • Pointer size: 131 Bytes
  • Size of remote file: 376 kB
vlm/test/6M5G5hNiAU/16.png ADDED

Git LFS Details

  • SHA256: 68ef0d771c96cc88c477dbc45387f9c0369a7feb7524d278a7e7239d50929f99
  • Pointer size: 131 Bytes
  • Size of remote file: 362 kB