Datasets:
Add files using upload-large-folder tool
Browse files- md/dev/-NOQJw5z_KY/-NOQJw5z_KY.md +260 -0
- md/dev/0LXEvcD3dB/0LXEvcD3dB.md +428 -0
- md/dev/2uAaGwlP_V/2uAaGwlP_V.md +340 -0
- md/dev/3R3Pz5i0tye/3R3Pz5i0tye.md +239 -0
- md/dev/401LFvBGIb/401LFvBGIb.md +308 -0
- md/dev/5HLoTvVGDe/5HLoTvVGDe.md +390 -0
- md/dev/68n2s9ZJWF8/68n2s9ZJWF8.md +287 -0
- md/dev/6u6N8WWwYSM/6u6N8WWwYSM.md +351 -0
- md/dev/8aHzds2uUyB/8aHzds2uUyB.md +0 -0
- md/dev/9h3KsOVXhLZ/9h3KsOVXhLZ.md +243 -0
- md/dev/A4fSkNAs6E1/A4fSkNAs6E1.md +422 -0
- md/dev/CQsmMYmlP5T/CQsmMYmlP5T.md +0 -0
- md/dev/DhmYYrH_M3m/DhmYYrH_M3m.md +319 -0
- md/dev/E01k9048soZ/E01k9048soZ.md +0 -0
- md/dev/ECvgmYVyeUz/ECvgmYVyeUz.md +559 -0
- md/dev/FWMQYjFso-a/FWMQYjFso-a.md +305 -0
- md/dev/IajGRJuM7D3/IajGRJuM7D3.md +0 -0
- md/dev/KmtVD97J43e/KmtVD97J43e.md +349 -0
- md/dev/LPB2BFZvncQ/LPB2BFZvncQ.md +827 -0
- md/dev/MR7XubKUFB/MR7XubKUFB.md +445 -0
- md/dev/NudBMY-tzDr/NudBMY-tzDr.md +536 -0
- md/dev/RKiWwhocuiU/RKiWwhocuiU.md +463 -0
- md/dev/RecZ9nB9Q4/RecZ9nB9Q4.md +0 -0
- md/dev/S9GpoS2TmN/S9GpoS2TmN.md +0 -0
- md/dev/SMa9EAovKMC/SMa9EAovKMC.md +401 -0
- md/dev/SVBR6xBaMl/SVBR6xBaMl.md +465 -0
- md/dev/T0GpzBQ1Fg6/T0GpzBQ1Fg6.md +481 -0
- md/dev/UaXD4Al3mdb/UaXD4Al3mdb.md +284 -0
- md/dev/Uynr3iPhksa/Uynr3iPhksa.md +325 -0
- md/dev/XsZ5YebcCz/XsZ5YebcCz.md +413 -0
- md/dev/ZBESeIUB5k/ZBESeIUB5k.md +0 -0
- md/dev/a6NvoZ5DLoe/a6NvoZ5DLoe.md +319 -0
- md/dev/aa8KsqfTPa/aa8KsqfTPa.md +240 -0
- md/dev/bdHkMjBJG_w/bdHkMjBJG_w.md +0 -0
- md/dev/c5Inzw6giM/c5Inzw6giM.md +327 -0
- md/dev/cJPkX1g9PQS/cJPkX1g9PQS.md +378 -0
- md/dev/hQwb-lbM6EL/hQwb-lbM6EL.md +550 -0
- md/dev/k7p_YAO7yE/k7p_YAO7yE.md +370 -0
- md/dev/mTiHLHu3sP/mTiHLHu3sP.md +326 -0
- md/dev/nJJjv0JDJju/nJJjv0JDJju.md +383 -0
- md/dev/pAq8iDy00Oa/pAq8iDy00Oa.md +615 -0
- md/dev/peZSbfNnBp4/peZSbfNnBp4.md +274 -0
- md/dev/rFbR4Fv-D6-/rFbR4Fv-D6-.md +525 -0
- md/dev/sE7-XhLxHA/sE7-XhLxHA.md +319 -0
- md/dev/sde_7ZzGXOE/sde_7ZzGXOE.md +406 -0
- md/dev/uKiE0VIluA-/uKiE0VIluA-.md +0 -0
- md/dev/vKBdabh_WV/vKBdabh_WV.md +652 -0
- md/dev/xT5rDp5VqKO/xT5rDp5VqKO.md +134 -0
- md/dev/yHdTscY6Ci/yHdTscY6Ci.md +618 -0
- md/dev/zyLVMgsZ0U_/zyLVMgsZ0U_.md +0 -0
md/dev/-NOQJw5z_KY/-NOQJw5z_KY.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Semantic Exploration from Language Abstractions and Pretrained Representations
|
| 2 |
+
|
| 3 |
+
Allison C. Tam
|
| 4 |
+
DeepMind
|
| 5 |
+
London, UK
|
| 6 |
+
actam@deepmind.com
|
| 7 |
+
Neil C. Rabinowitz
|
| 8 |
+
DeepMind
|
| 9 |
+
London, UK
|
| 10 |
+
ncr@deepmind.com
|
| 11 |
+
Andrew K. Lampinen
|
| 12 |
+
DeepMind
|
| 13 |
+
London, UK
|
| 14 |
+
lampinen@deepmind.com
|
| 15 |
+
Nicholas A. Roy
|
| 16 |
+
DeepMind
|
| 17 |
+
London, UK
|
| 18 |
+
nroy@deepmind.com
|
| 19 |
+
Stephanie C. Y. Chan
|
| 20 |
+
DeepMind
|
| 21 |
+
London, UK
|
| 22 |
+
scychan@deepmind.com
|
| 23 |
+
DJ Strouse
|
| 24 |
+
DeepMind
|
| 25 |
+
London, UK
|
| 26 |
+
strouse@deepmind.com
|
| 27 |
+
Jane X. Wang⇤
|
| 28 |
+
DeepMind
|
| 29 |
+
London, UK
|
| 30 |
+
wangjane@deepmind.com
|
| 31 |
+
Andrea Banino⇤
|
| 32 |
+
DeepMind
|
| 33 |
+
London, UK
|
| 34 |
+
abanino@deepmind.com
|
| 35 |
+
|
| 36 |
+
Felix Hill⇤ DeepMind London, UK felixhill@deepmind.com
|
| 37 |
+
|
| 38 |
+
# Abstract
|
| 39 |
+
|
| 40 |
+
Effective exploration is a challenge in reinforcement learning (RL). Novelty-based exploration methods can suffer in high-dimensional state spaces, such as continuous partially-observable 3D environments. We address this challenge by defining novelty using semantically meaningful state abstractions, which can be found in learned representations shaped by natural language. In particular, we evaluate vision-language representations, pretrained on natural image captioning datasets. We show that these pretrained representations drive meaningful, task-relevant exploration and improve performance on 3D simulated environments. We also characterize why and how language provides useful abstractions for exploration by considering the impacts of using representations from a pretrained model, a language oracle, and several ablations. We demonstrate the benefits of our approach with on- and off-policy RL algorithms and in two very different task domains— one that stresses the identification and manipulation of everyday objects, and one that requires navigational exploration in an expansive world. Our results suggest that using language-shaped representations could improve exploration for various algorithms and agents in challenging environments.
|
| 41 |
+
|
| 42 |
+
# 1 Introduction
|
| 43 |
+
|
| 44 |
+
Exploration is one of the central challenges of reinforcement learning (RL). A popular way to increase an agent’s tendency to explore is to augment trajectories with intrinsic rewards for reaching novel environment states. However, the success of this approach depends critically on which states are considered novel, which can in turn depend on how environment states are represented.
|
| 45 |
+
|
| 46 |
+
The literature on novelty-driven exploration describes several approaches to deriving state representations $\mathbb { I } \mathbb { I }$ . One popular method employs random features and represents the state by embedding the visual observation with a fixed, randomly initialized target network [Random Network Distillation; $\boxed { 6 }$ . Another method uses learned visual features, taken from an inverse dynamics model [Never Give Up; $\textcircled { 3 }$ . These approaches work well in classic 2D environments like Atari, but it is less clear whether they are as effective in high-dimensional, partially-observable settings such as 3D environments. For instance, in 3D settings, different viewpoints of the same scene may map to distinct visual states/features, despite being semantically similar. The difficulty of identifying a good mapping between visual state and feature space is exacerbated by the fact that useful state abstractions are highly task dependent. For example, a task involving tool use requires object-affordance abstractions, whereas navigation does not. Thus, acquiring state representations that support effective exploration is a chicken-and-egg problem—knowing whether two states should be considered similar requires the type of understanding that an agent can only acquire after effectively exploring its environment.
|
| 47 |
+
|
| 48 |
+
To overcome these challenges, we propose giving agents access to prior knowledge during training, in the form of abstractions derived from large vision-language models [e.g. 41] that are pretrained on image captioning data. We use these pretrained models to derive a intrinsic reward that reflects meaningful novelty. We hypothesize that representations acquired by vision-language pretraining drive effective, semantic exploration in 3D environments, because the representations are shaped by the unique abstract nature of natural language.
|
| 49 |
+
|
| 50 |
+
Several aspects of natural language suggest that it could be useful to direct novelty-based exploration. First, language is inherently abstract: language links superficially distinct, but causally-related situations by describing them similarly, and contrasts between causally-distinct states by describing them differently, thus outlining useful concepts $\overline { { \mathbb { B } \mathcal { 9 } } } \overline { { \mathbb { B } \mathcal { 8 } } } \Vert$ . Second, humans use language to communicate important information efficiently, without overspecifying [20, 21]. Thus, human language omits distracting irrelevant information and focuses on important aspects of the world. For example, it is often observed that an agent rewarded for seeking novel experience would be attracted forever to a TV with uncontrollable and unpredictable random static [7]. However, a human would likely caption this scene “a TV with no signal” regardless of the particular pattern; thus an agent ex
|
| 51 |
+
|
| 52 |
+

|
| 53 |
+
Figure 1: Navy dashed lines delineate semantically meaningful states. By using representations that align well with these boundaries (i.e. language), then agents more effectively explore the wider state space (orange trajectory). If the representations do not reflect these boundaries and instead are amenable to visual noise (i.e. different colors, viewpoints, etc.), then agents may only focus on a visually novel, yet narrow subset of states (red trajectory).
|
| 54 |
+
|
| 55 |
+
ploring with language abstractions would quickly leave the TV behind. Figure 1 shows another conceptual example of how language abstractions can accelerate exploration.
|
| 56 |
+
|
| 57 |
+
We first perform motivating proof-of-concept experiments using a language oracle. We show that language is a useful abstraction for exploration not only because it coarsens the state space, but also because it coarsens the state space in a way that reflects the semantics of the environment. We then demonstrate that our results scale to environments without a language oracle using pretrained vision encoders, which are only supervised with language during pretraining. This work strives to enhance the representations used in novelty-based exploration, rather than compare various exploration methods.
|
| 58 |
+
|
| 59 |
+
We consider two popular novelty-based exploration methods from the literature, Never Give Up (NGU; Badia et al. $\pmb { \mathbb { B } } \mathbf { \mathbb { I } }$ ) and Random Network Distillation (RND; Burda et al. $\mathbb { I I } ^ { \dagger }$ ), and compare them to their language-augmented variants, Lang-NGU/LSE-NGU and Lang-RND. We evaluate performance and sample efficiency on object manipulation, search, and navigation tasks in two challenging 3D environments simulated in Unity: Playroom (a house containing toys and furniture) and City (a large-scale urban setting). Our results show that language-based exploration with pretrained visionlanguage representations improves sample efficiency on Playroom tasks by $1 8 - 7 0 \%$ . It also doubles
|
| 60 |
+
|
| 61 |
+

|
| 62 |
+
(b) Example instances of $O _ { V }$ and $O _ { L }$ from City. Many different scenes can be associated with the same caption.
|
| 63 |
+
|
| 64 |
+
Figure 2: Visual observations from the environment and example captions generated by the language oracle. Appendix Figure $\boxed { \mathsf { S 4 } }$ contains more example captions.
|
| 65 |
+
|
| 66 |
+
the visited areas in City, compared to baseline methods. We show that language-based exploration is effective for both on-policy (IMPALA $\mathbb { I I I }$ ) and off-policy (R2D2 $\pm \mathbb { Z } 5 \mathbb { I } .$ ) agents.
|
| 67 |
+
|
| 68 |
+
# 2 Related Work
|
| 69 |
+
|
| 70 |
+
Exploration in RL Classical exploration strategies include $\epsilon$ -greedy action selection $\pmb { \Vert 5 \bot }$ , statecounting [49, 4, 32, 30, 3], curiosity driven exploration $\pm \sharp$ , and intrinsic motivation methods $\left[ \left[ 3 6 \right] \right]$ . Our work is part of this last class of methods, where the agent is given an intrinsic reward for visiting diverse states over time $\begin{array} { r l } { { \bigl [ \bigl | 3 5 \bigr | \bigr ] } } \end{array}$ . Intrinsic rewards can be derived from various measures: novelty [43, 55, 6, 56], prediction-error [38, 3], ensemble disagreement [11, 39, 48, 46, 18, 50], or information gain $\mathbb { \left[ \left. 2 3 \right] \right. }$ . One family of methods gives intrinsic reward for following a curriculum of goals [8, 12, 40]. Others use novelty measures to identify interesting states from which they can perform additional learning [16, 54]. These methods encourage exploration in different ways, but they all rely on visual state representations that are learned jointly with the policy. Although we focus on novelty-based intrinsic reward and demonstrate the benefits of language in NGU and RND, our methodology is relatively agnostic to the exploration method. We suggest that many other exploration methods could be improved by using language abstractions and pretrained embeddings to represent the state space.
|
| 71 |
+
|
| 72 |
+
Pretraining representations for RL Pretraining has been used in RL to improve the representations of the policy network. Self-supervised representation learning techniques distill knowledge from external datasets to produce downstream features that are helpful in virtual environments [15, 53]. Some recent work shows benefits from pretraining on more general, large-scale datasets. Pretrained CLIP features have been used in a number of recent robotics papers to speed up control and navigation tasks. These features can condition the policy network $\bar { \lVert 2 6 rVert }$ , or can be fused throughout the visual encoder to integrate semantic information about the environment $\pmb { \Vert 3 7 } \Vert$ . The goal of these works is to improve perception in the policy. Pretrained language models can also provide useful initializations for training policies to imitate offline trajectories $[ \bar { 1 } 2 , \bar { 1 } 2 7 ]$ . These successes demonstrate that large pretrained models contain prior knowledge that can be useful for RL. While the existing literature uses pretrained embeddings directly in the agent, we instead allow the policy network to learn from scratchm and only utilize pretrained embeddings to guide exploration during training (Figure $^ { \mathbf { \boldsymbol { S 2 } } ) }$ We imagine that future work may benefit from combining both approaches.
|
| 73 |
+
|
| 74 |
+
Language for exploration Some recent works have used language to guide agent learning, by either using language subgoals for exploration/planning or providing task-specific reward shaping [47, 33, 13, 19]. Schwartz et al. [45] use a custom semantic parser for VizDoom and show that representing states with language, rather than vision, leads to faster learning by simplifying policy inputs. Chaplot et al. $\mathbb { \ m }$ tackle navigation in 3D by constructing a semantic map of the environment from pretrained SLAM modules, language-defined object categories, and agent location. This approach lends itself to navigation, but it is unclear how it would extend easily to more generic settings or other types of tasks, such as manipulation. Work concurrent to ours by Mu et al. [34] shows how language, in the form of hand-crafted BabyAI annotations, can help improve exploration in 2D environments. These works demonstrate the value of language abstractions: the ability to ignore extraneous noise and highlight important environment features. However, these prior methods rely on environment-specific semantic parsers or annotations, which may limit the settings to which they can be applied. In contrast, by exploiting powerful pretrained vision-language models, our approach can be applied to any visually-naturalistic environment, including 3D settings, which have not been widely studied in prior exploration work. We additionally do not require any language from the environment itself. Our method could even potentially improve exploration for physical robots, but we leave that for future work.
|
| 75 |
+
|
| 76 |
+
# 3 Method
|
| 77 |
+
|
| 78 |
+
We consider a goal-conditioned Markov decision process defined by a tuple $( S , \mathcal { A } , \mathcal { G } , P , R _ { e } , \gamma )$ , where $s$ is the state space, $\mathcal { A }$ is the action space, $\mathcal { G }$ is the goal space, $P : \mathcal { S } \times \mathcal { A } \mathcal { S }$ specifies the environment dynamics, $R _ { e } : \mathcal { S } \times \mathcal { G } R _ { e }$ is the extrinsic reward, and $\gamma$ is the discount factor. State $\mathbf { s _ { t } }$ is presented to the agent as a visual observation $O _ { V }$ . In some cases, in order to calculate intrinsic reward, we use a language oracle $\mathcal { O } : \mathcal { S } \mathcal { L }$ that provides natural language descriptions of the state, $O _ { L }$ . Note that $O _ { L }$ is distinct from the language instruction $g \in { \mathcal { G } }$ , which is sampled from a goal distribution at the start of an episode—the agent never observes $O _ { L }$ . We later remove the need for a language oracle by using pretrained models.
|
| 79 |
+
|
| 80 |
+
We use goal-conditioned reinforcement learning to produce a policy imizes the expected re $\pi _ { g } ( \cdot \ | \ O _ { V } )$ $\mathbb { E } [ \sum _ { t = 0 } ^ { H } \gamma ^ { t } ( r _ { t } ^ { e } +$ $\beta r _ { t } ^ { i } ) ]$ , where $H$ is the horizon, $\boldsymbol { r } _ { t } ^ { e }$ is the extrinsic reward, $r _ { t } ^ { i }$ is the intrinsic reward, and $\beta$ is a tuned hyperparameter. The intrinsic reward is goal-agnostic and is computed with access to either $O _ { V }$ or $O _ { L }$ . Note that neither $O _ { L }$ nor pretrained embeddings are used by the policy, and thus we only use them during training to compute the intrinsic reward (Figure $\textcircled { 3 }$
|
| 81 |
+
|
| 82 |
+
Our approach builds on two popular exploration algorithms: Never Give Up (NGU; Badia et al. $\pmb { \mathbb { B } } \mathbf { l }$ ) and Random Network Distillation (RND; Burda et al. $\mathbb { H }$ ). These algorithms were chosen to demonstrate the value of language under two different exploration paradigms. While both methods reward visiting novel states, they differ on several dimensions: the novelty horizon (episodic versus lifetime), how the history of past visited states is retained (non-parametric versus parametric), and how states are represented (learned controllable states versus random features).
|
| 83 |
+
|
| 84 |
+

|
| 85 |
+
Figure 3: The agent is trained from scratch using RL to optimize extrinsic and intrinsic reward. It acts using the image observation $O _ { V }$ and goal $g$ . During training, the novelty-based intrinsic reward is calculated using an auxiliary component that does not share parameters with the agent (dashed box). The auxiliary component may incorporate a pretrained language (pictured above) or image encoder, which may respectively require $O _ { L }$ or $O _ { V }$ . The latter does not rely on language provided by the environment. See Figure S2 for more details.
|
| 86 |
+
|
| 87 |
+
# 3.1 Never Give Up (NGU)
|
| 88 |
+
|
| 89 |
+
To more clearly isolate our impact, we focus only on the episodic novelty component of the NGU agent [3]. State representations along the trajectory are written to a non-parametric episodic memory buffer. The intrinsic reward reflects how novel the current state is relative to the states visited so far in the episode. Novelty is a function of the L2 distances between the current state and the $k$ -nearest neighbor representations stored in the memory buffer. Intrinsic reward is higher for larger distances.
|
| 90 |
+
|
| 91 |
+
Full details can be found in the original paper; however, we make two key simplifications. While Badia et al. $\pmb { \mathbb { B } } \|$ proposes learning a family of policy networks that are capable of different levels of exploration, we train one policy network that maximizes reward $r ~ = ~ r _ { e } + \beta r _ { i }$ for a fixed hyperparameter $\beta$ . We also fix the long-term novelty modulator $\alpha$ to be 1, essentially removing it.
|
| 92 |
+
|
| 93 |
+
The published baseline method, which we refer to as Vis-NGU, uses a controllable state taken from an inverse dynamics model. The inverse dynamics model is trained jointly with the policy, but the two networks do not share any parameters.
|
| 94 |
+
|
| 95 |
+
Table 1: Summary of NGU variants.
|
| 96 |
+
|
| 97 |
+
<table><tr><td>Name</td><td>Embedding Type</td><td>Required Input</td></tr><tr><td>Vis-NGU</td><td>Controllable State</td><td>Vision</td></tr><tr><td rowspan="3">Lang-NGU</td><td>BERT</td><td>Language</td></tr><tr><td>CLIPtext</td><td>Language</td></tr><tr><td>ALMtext</td><td>Language</td></tr><tr><td rowspan="3">LSE-NGU</td><td>CLIPimage</td><td>Vision</td></tr><tr><td>ALMimage</td><td>Vision</td></tr><tr><td></td><td></td></tr></table>
|
| 98 |
+
|
| 99 |
+
Table 2: Summary of family of RND-inspired methods. Intrinsic reward is derived from the prediction error between the trainable network and frozen target function.
|
| 100 |
+
|
| 101 |
+
<table><tr><td>Name</td><td>Trainable Network</td><td>Target Function</td></tr><tr><td>Vis-RND</td><td>fv:Ov→Rk</td><td>randomly initialized,fixed f</td></tr><tr><td>ND</td><td>f{v,L} :O{v,L}→Rk</td><td>pretrained ALM{image, text}</td></tr><tr><td>Lang-RND</td><td>fL:OL→R</td><td>randomly initialized,fixed f</td></tr><tr><td>LD</td><td>fc:Ov→OL</td><td>OL from language oracle</td></tr></table>
|
| 102 |
+
|
| 103 |
+
The intrinsic reward relies on directly comparing state representations from the buffer, so our approach focuses on modifying the embedding function to influence exploration (Table 1). LangNGU uses a frozen pretrained language encoder to embed the oracle caption $O _ { L }$ . We compare language embeddings from BERT $\check { \mathbb { E } } \check { 4 } \check { \mathbb { I } }$ , CLIP [41], Small-ALM, and Med-ALM. The ALMs (ALign Models) are trained with a contrastive loss on the ALIGN dataset $[ [ 2 4 ]$ . Small-ALM uses a 26M parameter ResNet-50 image encoder $\pmb { \mathbb { Z } } 2 \mathbf { l }$ ; Med-ALM uses a 71M parameter NFNet [5]. The language backbones are based on BERT and are all in the range of 70-90M parameters. We do not finetune on environment-specific data; this preserves the real world knowledge acquired during pretraining and demonstrates its benefit without requiring any environment-specific captions.
|
| 104 |
+
|
| 105 |
+
LSE-NGU does not use the language oracle. Instead, it uses a frozen pretrained image encoder to embed the visual observation $O _ { V }$ . We use the image encoder from CLIP or ALM, which are trained on captioning datasets to produce outputs that are close to the corresponding language embeddings. The human-generated captions structure the visual embedding space to reflect features most pertinent to humans and human language $\pmb { \mathbb { B } } \mathbf { \mathbb { 1 } }$ , so the resulting representations can be thought of as Language Supervised Embeddings (LSE). The primary benefit of LSE-NGU is that it can be applied to environments without a language oracle or annotations. CLIP and ALM are trained on real-world data, so they would work best on realistic 3D environments. However, we imagine that in future work the pretraining process or dataset could be tailored to maximize transfer to a desired target environment.
|
| 106 |
+
|
| 107 |
+
# 3.2 Random Network Distillation (RND)
|
| 108 |
+
|
| 109 |
+
Our RND-inspired family of methods rewards lifetime novelty. Generically, the intrinsic reward is derived from the prediction error between a trainable network and some target value generated by a frozen function (Table $\bigstar \bigstar$ . The trainable network is learned jointly with the policy network, although they do not share any parameters. As the agent trains over the course of its lifetime, the prediction error for frequently-visited states decreases, and the associated intrinsic reward consequently diminishes. Intuitively, the weights of the trainable network implicitly store the state visitation counts.
|
| 110 |
+
|
| 111 |
+
For clarity, we refer to the baseline published by Burda et al. $\mathbb { \left[ \bigcirc \right] }$ as Vis-RND. The trainable network $f _ { V } : O _ { V } { \stackrel { \cdot } { \to } } \mathbb { R } ^ { k }$ maps the visual state to random features. The random features are produced by a fixed, randomly initialized network $\hat { f _ { V } }$ . Both $f _ { V }$ and $\hat { f _ { V } }$ share the same architecture: a ResNet followed by a MLP. The intrinsic reward is the mean squared error $\lVert f _ { V } ( O _ { V } ) - \hat { f _ { V } } ( O _ { V } ) \rVert ^ { 2 }$ .
|
| 112 |
+
|
| 113 |
+
In network distillation (ND), the target function is not random, but is instead a pretrained text or image encoder from CLIP/ALM. The trainable network $f$ learns to reproduce the pretrained representations. To manage inference time, $f$ is a simpler network than the target (see Appendix A.2). The intrinsic loss is the mean squared error between $f$ and the large pretrained network. Like the respective Lang-NGU and LSE-NGU counterparts, text-based ND requires a language oracle, but image-based ND does not.
|
| 114 |
+
|
| 115 |
+
In Section $5 . 1$ we compare against two additional methods to motivate why language is a useful abstraction. The first, Lang-RND, is a variant in which the trainable network $f _ { L } : O _ { L } \stackrel { \smile } { \to } \mathbb { R } ^ { k }$ maps the oracle caption to random features. The intrinsic reward is the mean squared error between the outputs of $f _ { L }$ and fixed $\hat { f } _ { L }$ with random initialization. Both $f _ { L }$ and $\hat { f } _ { L }$ networks are of the same architecture.
|
| 116 |
+
|
| 117 |
+
The second method, language distillation $\mathbf { \left( L D \right) }$ , is loosely inspired by RND in that the novelty signal comes from a prediction error. However, instead of learning to produce random features, the trainable network learns to caption the visual state, i.e. $f _ { C } : O _ { V } \to O _ { L }$ . The network architecture consists of a CNN encoder and LSTM decoder. The intrinsic reward is the negative log-likelihood of the oracle caption under the trainable model $f _ { C }$ . In LD, the exploration dynamics not only depend on how frequently states are visited but also the alignment between language and the visual world. We test whether this caption-denoted alignment is necessary for directing semantic exploration by comparing LD to a variant with shuffled image-language alignment (S-LD) in Section 5.1.
|
| 118 |
+
|
| 119 |
+
# 4 Experimental Setup
|
| 120 |
+
|
| 121 |
+
# 4.1 Environments
|
| 122 |
+
|
| 123 |
+
Previous exploration work benchmarked algorithms on video games, such as 2D grid-world MiniHack and Montezuma’s Revenge, or 3D first-person shooter Vizdoom. In this paper, we focus on first-person Unity-based 3D environments that are meant to mimic familiar scenes from the real world (Figure 2).
|
| 124 |
+
|
| 125 |
+
Playroom Our first domain, Playroom [1, 52], is a randomly-generated house containing everyday household items (e.g. bed, bathtub, tables, chairs, toys). The agent’s action set consists of 46 discrete actions that involve locomotion primitives and object manipulation, such as holding and rotating.
|
| 126 |
+
|
| 127 |
+
We study two settings in Playroom. In the first setting, the agent is confined to a single room with 3-5 objects and is given a lift or put instruction. At the start of an episode, the set of objects are sampled from a larger set of everyday objects (i.e. a candle, cup, hairdryer). Object colors and sizes are also randomized, adding superficial variance to different semantic categories. The instructions take the form: "Lift a <object>" or "Put a <object> on a {bed, tray}". With a lift goal, the episode ends with reward 1 or 0 whenever any object is lifted. With a put goal, the episode ends with reward 1 when the condition is fulfilled. This setting tests spatial rearrangement skills.
|
| 128 |
+
|
| 129 |
+
In the second setting, the agent is placed in a house with 3-5 different rooms, and is given a find instruction of the form "Find a {teddy bear, rubber duck}". Every episode, the house is randomly generated with the teddy and duck hidden amongst many objects, furniture, and decorations. The target objects can appear in any room— either on the floor, on top of tables, or inside bookshelves. The agent is randomly initialized and can travel throughout the house and freely rearrange objects. The episode ends with reward 1 when the agent pauses in front of the desired object. The find task requires navigation/search skills and tests the ability to ignore the numerous distractor objects.
|
| 130 |
+
|
| 131 |
+
City Our second domain, City, is an expansive, large-scale urban environment. Each episode, a new map is generated; shops, parks, and buildings are randomly arranged in city blocks. Daylight is simulated, such that the episode starts during the morning and ends at nighttime. The agent is randomly initialized and is instructed to “explore the city.” It is trained to maximize its intrinsic reward and can take the following actions: move_{forward,backward,left,right}, look_{left,right}, and move_forward_and_look_{left,right}. We divide up the map into a $3 2 \times 3 2$ grid and track how many unique bins are visited in an episode.
|
| 132 |
+
|
| 133 |
+
Additionally, City does not provide explicit visual or verbal signage to disambiguate locations. As such, systematic exploration is needed to maximize coverage. In contrast to Playroom, City tests long horizon exploration. A Playroom episode lasts only 600 timesteps, whereas a City episode lasts 11,250 and requires hundreds of timesteps to fully traverse the map even once. The City covers a 270-by-270 meter square area, which models a 2-by-2 grid of real world blocks.
|
| 134 |
+
|
| 135 |
+
# 4.2 Captioning Engine
|
| 136 |
+
|
| 137 |
+
We equip the environment with a language oracle that generates language descriptions of the scene, $O _ { L }$ , based on the Unity state, $s$ (Figure $2$ ). In Playroom, the caption describes if and how the agent interacts with objects and lists what is currently visible to it. In City, $O _ { L }$ generally describes the object that the agent is directly looking at, but the captions alone do not disambiguate the agent’s locations. Since these captions are generated from a Unity state, these descriptions may not be as varied or rich as a human’s, but they can be generated accurately and reliably, and at scale.
|
| 138 |
+
|
| 139 |
+
# 4.3 Training Details
|
| 140 |
+
|
| 141 |
+
At test time, the agent receives image observation $O _ { V }$ and language-specified goal $g$ . The policy network never requires caption $O _ { L }$ to act. During training, the exploration method calculates the intrinsic reward from $O _ { L }$ or $O _ { V }$ .
|
| 142 |
+
|
| 143 |
+
We show that language-based exploration is compatible with both policy gradient and Q-learning algorithms. We use Impala $\mathbb { \equiv } \mathbb { \ln { \frac { } { } } }$ on Playroom and R2D2 on City $\lVert 2 5 \rVert$ . Q-learning is more suitable for the City, because the action space is more restricted compared to the one needed for Playroom tasks.
|
| 144 |
+
|
| 145 |
+
For both environments, the agent architecture consists of an image ResNet encoder and a language LSTM encoder that feed into a memory LSTM module. The policy and value heads are MLPs that receive the memory state as input. If the exploration method requires additional networks, such as the trainable network in RND or inverse dynamics model in NGU, they do not share any parameters with the policy or value networks. Figure $\dot { \bf S } \boldsymbol { 2 }$ is a visualization of an Impala agent that uses languageaugmented exploration. Hyperparameters and additional details are found in Appendix A.
|
| 146 |
+
|
| 147 |
+
# 5 Results
|
| 148 |
+
|
| 149 |
+
# 5.1 Motivation: Language is a Meaningful Abstraction
|
| 150 |
+
|
| 151 |
+

|
| 152 |
+
(b) LD outperforms S-LD. It is important how language abstractions carve up the state space.
|
| 153 |
+
Figure 4: Our comparisons demonstrate that language is useful for exploration, because it outlines a more abstract, semantically-meaningful state space. Results are shown with a $9 5 \%$ confidence band.
|
| 154 |
+
|
| 155 |
+
We share the intuition with other work [e.g. 34] that language can improve exploration. We design a set of experiments to show how and why this may be the case. Our analysis follows the desiderata outlined by Burda et al. [6]—prediction-error exploration ought to use a feature space that filters irrelevant information (compact) and contains necessary information (sufficient). Burda et al. [6] specifically studies RND and notes that the random feature space, the outputs of the random network, may not fully satisfy either condition. As such, we use the language variants of RND to frame this discussion.
|
| 156 |
+
|
| 157 |
+
We hypothesize that language abstractions are useful, because they (1) create a coarser state space and (2) divide the state space in a way that meaningfully aligns with the world (i.e. using semantics). First, if language provides a coarser state space, then the random feature space becomes more compact, leading to better exploration. We compare Lang-RND to Vis-RND to test this claim. Lang-RND learns the lift task $33 \%$ faster and solves the put task as Vis-RND starts to learn (Figure 4a).
|
| 158 |
+
|
| 159 |
+
Second, we ask whether semantics – that is how language divides up the state space – is critical for effective exploration. We use LD to test this hypothesis, precisely because the exploration in LD is motivated by modeling the semantic relationship between language and vision.
|
| 160 |
+
|
| 161 |
+
We compare LD to a shuffled variant SLD, where we replace the particular semantic state abstraction that language offers with a statistically-matched randomized abstraction (Figure $\boxed { 5 }$ ). S-LD is similar to LD; the intrinsic reward is the prediction error of the captioning network. However, instead of targeting the language oracle output, the S-LD trainable network produces a different target caption O that may not match the image. $\widetilde { O _ { L } }$ is produced by a fixed, random mapping ${ \hat { f } } _ { S } : O _ { V } \{ \substack { \widetilde { O _ { L } } }$ . $\hat { f } _ { S }$ is constrained such that the marginal distributions $P ( O _ { L } ) \approx P ( \widetilde { O _ { L } } )$ are matched under trajectories produced by policy $\pi _ { L D }$ . See Appendix A.4 for full details on the construction of S-LD.
|
| 162 |
+
|
| 163 |
+
Thus, whereas the LD captions parcel up state space in a way that reflects the abstractions that language offers, the randomized mapping $\hat { f } _ { S }$
|
| 164 |
+
|
| 165 |
+

|
| 166 |
+
Figure 5: The dotted lines correspond to state abstractions given by the shuffled $\hat { f } _ { S }$ used in S-LD. The states are grouped together based on similarities in the visual random feature space and assigned a label. Exploring in this shuffled space is less effective than exploring with the semanticallymeaningful abstractions shown in Figure 1.
|
| 167 |
+
|
| 168 |
+
parcels up state space in a way that abstracts over random features of the visual space (Figure 5) We control for the compactness and coarseness of the resulting representation by maintaining the same marginal distribution of captions.
|
| 169 |
+
|
| 170 |
+
If semantics is crucial for exploration, then we expect to see LD outperform S-LD. This indeed holds experimentally (Figure $\textcircled { 4 6 }$ . We can also view these results under the Burda et al. [6] framework. The S-LD abstractions group together visually similar, but semantically distinct states. A single sampled caption likely fails to capture the group in a manner that is representative of all the encompassing states. In other words, $\hat { f } _ { S }$ produces a compact feature space that may not be sufficient. This may explain why S-LD learns faster than Vis-RND on the simpler lift task but fails on the more complex put and find tasks. The S-LD experiments imply that language abstractions are helpful for exploration because they expose not only a more compact, but also a more semantically meaningful state space.
|
| 171 |
+
|
| 172 |
+
# 5.2 Pretrained Vision-Language Representations Improve Exploration
|
| 173 |
+
|
| 174 |
+
Having shown how language can be helpful for exploration, we now incorporate pretrained visionlanguage representations into NGU and RND to improve exploration. Such representations (e.g. from the image encoder in CLIP/ALM) offer the benefits of explicit language abstractions, without the need to rely on a language oracle. We also compare language-shaped representations to pretrained ImageNet embeddings to isolate the effect of language. To keep the number of experiments tractable, we only perform a full comparison on the Playroom tasks.
|
| 175 |
+
|
| 176 |
+
City We first compare how representations affect performance in a pure exploration setting. With no extrinsic reward, the agent is motivated solely by the NGU intrinsic reward to explore the City. We report how many unique areas the agent visits in an episode in Figure $\triangledown$ While optimizing coverage only requires knowledge of an agent’s global location rather than generic scene understanding, vision-language representations are still useful simply because meaningful exploration is inherently semantic. Lang-NGU, which uses text embeddings of $O _ { L }$ , visits an area up to 3 times larger. LSENGU achieves 2 times the coverage even without querying a language oracle (Appendix Figure $S 5 )$
|
| 177 |
+
|
| 178 |
+
Playroom We next show that pretrained vision-language representations significantly speed up learning across all Playroom tasks (Figure $\textcircled{7}$ . The LSE-NGU and Lang-NGU agents improve sample efficiency by $50 \%$ on the lift and put tasks and $1 8 - 3 8 \%$ on the find task, depending on the pretraining model used. The ND agents are significantly faster than VisRND, learning $41 \%$ faster on the find task. We also measure agent-object interactions. Nearly all LSE-NGU and Lang-NGU agents learn to foveate on and hold objects within 40k learning updates, whereas Vis-NGU agent takes at least $6 0 \mathrm { k }$ updates to do so with the same frequency (Appendix Figure $\textcircled { 5 7 }$ Although LSENGU and image-based ND agents do not access a language oracle, they are similarly effective as their annotation-dependent counterparts in the Playroom tasks (Appendix Figure $\dot { \overline { { \vert \mathrm { S } 6 \vert } } }$ , suggesting that our method could be robust to the availability of a language oracle.
|
| 179 |
+
|
| 180 |
+
To demonstrate the value of rich language, we compare LSE-NGU agents to a control agent that instead uses pretrained ImageNet embeddings from a 70M NFNet [5]. ImageNet embeddings optimize for single-object classification, so they confer some benefit to the most objectfocused tasks, lift and put. However, Ima
|
| 181 |
+
|
| 182 |
+

|
| 183 |
+
Figure 6: Coverage of City (number of bins reached on map) by NGU variants using different state representations for exploration, normalized by coverage of a ground-truth agent. The groundtruth agent represents state in NGU as the global coordinate of the agent location. The dashed line indicates coverage of a uniform random policy. Error bars indicate standard error of the mean, over 5 replicas. See Appendix Table S4 for absolute coverage numbers.
|
| 184 |
+
|
| 185 |
+
geNet embeddings hurt exploration in the find task, where agents encounters more complex scenes (Figure $^ { 7 \mathrm { b } ) }$ . By contrast, the language-shaped representations are well-suited for not only describing simple objects, but also have capacity for multi-object, complex scenes. Of course, current CLIPstyle models can be further improved in their ability to understand multi-object scenes, which may explain why the benefits are less pronounced for the find task. However, as the performance of pretrained vision-language models improve, we expect to see those benefits transfer to this method and drive even better exploration.
|
| 186 |
+
|
| 187 |
+
# 6 Discussion
|
| 188 |
+
|
| 189 |
+
We have shown that language abstractions and pretrained vision-language representations improve the sample efficiency of existing exploration methods. This benefit is seen across on-policy and off-policy algorithms (Impala and R2D2), different exploration methods (RND and NGU), different 3D domains (Playroom and City), and various task specifications (lifting/putting, searching, and intrinsically motivated navigation). Furthermore, we carefully designed control experiments to understand how language contributes to better exploration. Our results are consistent with cognitive perspectives on human language—language is powerful because it groups together situations according to semantic similarity. In terms of the desiderata that Burda et al. [6] present, language is both compact and sufficient. Finally, we note that using pretrained vision-language representations to embed image observations enables more effective exploration even if language is not available during agent training. This is vital for scaling to environments that do not have a language oracle or annotations.
|
| 190 |
+
|
| 191 |
+
Limitations and future directions We highlight several avenues for extending our work. First, additional research could provide a more comprehensive understanding of how language abstractions affect representations. This could include comparing different types of captions offering varying levels of detail, or task-dependent descriptions. These captions could be dynamically generated at scale by prompting a large multimodal model $\left[ \left[ 2 \right] \right]$ . Second, it would be useful to investigate how to improve pretrained vision-language representations for exploration by finetuning on relevant datasets. The semantics of a dataset could even be tailored to task-specific abstractions to increase the quality of the learnt representations. Such approaches would potentially allow applying our method to virtual environments that are farther from the pretraining distribution, such as Atari. In contrast, compared to our experiments, we believe that the current pretrained representations would deliver even more benefit for entirely photorealistic, visually rich environments, such as Matterport3D [9]. Finally, we note that a limitation of this approach is that current pretrained vision-language models may be less effective on multi-object scenes. Future pretraining innovations or larger models would presumably produce more robust representations and thus lead to even more effective exploration.
|
| 192 |
+
|
| 193 |
+

|
| 194 |
+
|
| 195 |
+
(c) ND intrinsic rewards derive from the prediction error of the representations from a pretrained ALM network.
|
| 196 |
+
Figure 7: Agents that use pretrained language-shaped representations to explore (ALM-ND, LangNGU, LSE-NGU) learn faster than baseline agents. ALM-ND (Text/Image) refer to the ND variants in Table 2. Results shown with a $9 5 \%$ confidence interval.
|
| 197 |
+
|
| 198 |
+
# Acknowledgments and Disclosure of Funding
|
| 199 |
+
|
| 200 |
+
We would like to thank Iain Barr for ALM models and Nathaniel Wong and Arthur Brussee for the Playroom environment. For the City environment, we would like to thank Nick Young, Tom Hudson, Alex Platonov, Bethanie Brownfield, Sarah Chakera, Dario de Cesare, Marjorie Limont, Benigno Uria, Borja Ibarz and Charles Blundell. Moreover, for the City, we would like to extend our special thanks to Jayd Matthias, Jason Sanmiya, Marcus Wainwright, Max Cant and the rest of the Worlds Team. Finally, we thank Hamza Merzic, Andre Saraiva, and Tim Scholtes for their helpful support and advice.
|
| 201 |
+
|
| 202 |
+
# References
|
| 203 |
+
|
| 204 |
+
[1] J. Abramson, A. Ahuja, I. Barr, A. Brussee, F. Carnevale, M. Cassin, R. Chhaparia, S. Clark, B. Damoc, A. Dudzik, et al. Imitating interactive intelligence. arXiv preprint arXiv:2012.05672,
|
| 205 |
+
|
| 206 |
+
[2] J.-B. Alayrac, J. Donahue, P. Luc, A. Miech, I. Barr, Y. Hasson, K. Lenc, A. Mensch, K. Millican, M. Reynolds, et al. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022.
|
| 207 |
+
[3] A. P. Badia, P. Sprechmann, A. Vitvitskyi, D. Guo, B. Piot, S. Kapturowski, O. Tieleman, M. Arjovsky, A. Pritzel, A. Bolt, et al. Never give up: Learning directed exploration strategies. arXiv preprint arXiv:2002.06038, 2020.
|
| 208 |
+
[4] M. Bellemare, S. Srinivasan, G. Ostrovski, T. Schaul, D. Saxton, and R. Munos. Unifying count-based exploration and intrinsic motivation. Advances in neural information processing systems, 29, 2016.
|
| 209 |
+
[5] A. Brock, S. De, S. L. Smith, and K. Simonyan. High-performance large-scale image recognition without normalization. In International Conference on Machine Learning, pages 1059–1071. PMLR, 2021.
|
| 210 |
+
[6] Y. Burda, H. Edwards, D. Pathak, A. Storkey, T. Darrell, and A. A. Efros. Large-scale study of curiosity-driven learning. arXiv preprint arXiv:1808.04355, 2018.
|
| 211 |
+
[7] Y. Burda, H. Edwards, A. Storkey, and O. Klimov. Exploration by random network distillation. arXiv preprint arXiv:1810.12894, 2018.
|
| 212 |
+
[8] A. Campero, R. Raileanu, H. Küttler, J. B. Tenenbaum, T. Rocktäschel, and E. Grefenstette. Learning with amigo: Adversarially motivated intrinsic goals. arXiv preprint arXiv:2006.12122, 2020.
|
| 213 |
+
[9] A. Chang, A. Dai, T. Funkhouser, M. Halber, M. Niessner, M. Savva, S. Song, A. Zeng, and Y. Zhang. Matterport3d: Learning from rgb-d data in indoor environments. arXiv preprint arXiv:1709.06158, 2017.
|
| 214 |
+
[10] D. S. Chaplot, D. P. Gandhi, A. Gupta, and R. R. Salakhutdinov. Object goal navigation using goal-oriented semantic exploration. Advances in Neural Information Processing Systems, 33: 4247–4258, 2020.
|
| 215 |
+
[11] R. Y. Chen, S. Sidor, P. Abbeel, and J. Schulman. UCB exploration via Q-ensembles. arXiv preprint arXiv:1706.01502, 2017.
|
| 216 |
+
[12] C. Colas, P. Fournier, M. Chetouani, O. Sigaud, and P.-Y. Oudeyer. Curious: intrinsically motivated modular multi-goal reinforcement learning. In International conference on machine learning, pages 1331–1340. PMLR, 2019.
|
| 217 |
+
[13] C. Colas, T. Karch, N. Lair, J.-M. Dussoux, C. Moulin-Frier, P. Dominey, and P.-Y. Oudeyer. Language as a cognitive tool to imagine goals in curiosity driven exploration. Advances in Neural Information Processing Systems, 33:3761–3774, 2020.
|
| 218 |
+
[14] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
|
| 219 |
+
[15] Y. Du, C. Gan, and P. Isola. Curious representation learning for embodied intelligence. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 10408– 10417, 2021.
|
| 220 |
+
[16] A. Ecoffet, J. Huizinga, J. Lehman, K. O. Stanley, and J. Clune. First return, then explore. Nature, 590(7847):580–586, 2021.
|
| 221 |
+
[17] L. Espeholt, H. Soyer, R. Munos, K. Simonyan, V. Mnih, T. Ward, Y. Doron, V. Firoiu, T. Harley, I. Dunning, et al. Impala: Scalable distributed deep-rl with importance weighted actor-learner architectures. In International Conference on Machine Learning, pages 1407–1416. PMLR, 2018.
|
| 222 |
+
[18] S. Flennerhag, J. X. Wang, P. Sprechmann, F. Visin, A. Galashov, S. Kapturowski, D. L. Borsa, N. Heess, A. Barreto, and R. Pascanu. Temporal difference uncertainties as a signal for exploration. arXiv preprint arXiv:2010.02255, 2020.
|
| 223 |
+
[19] P. Goyal, S. Niekum, and R. J. Mooney. Using natural language for reward shaping in reinforcement learning. arXiv preprint arXiv:1903.02020, 2019.
|
| 224 |
+
[20] H. P. Grice. Logic and conversation. In Speech acts, pages 41–58. Brill, 1975.
|
| 225 |
+
[21] M. Hahn, D. Jurafsky, and R. Futrell. Universals of word order reflect optimization of grammars for efficient communication. Proceedings of the National Academy of Sciences, 117(5):2347– 2353, 2020.
|
| 226 |
+
[22] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770– 778, 2016.
|
| 227 |
+
[23] R. Houthooft, X. Chen, Y. Duan, J. Schulman, F. De Turck, and P. Abbeel. Vime: Variational information maximizing exploration. Advances in neural information processing systems, 29, 2016.
|
| 228 |
+
[24] C. Jia, Y. Yang, Y. Xia, Y.-T. Chen, Z. Parekh, H. Pham, Q. Le, Y.-H. Sung, Z. Li, and T. Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning, pages 4904–4916. PMLR, 2021.
|
| 229 |
+
[25] S. Kapturowski, G. Ostrovski, J. Quan, R. Munos, and W. Dabney. Recurrent experience replay in distributed reinforcement learning. In International conference on learning representations, 2018.
|
| 230 |
+
[26] A. Khandelwal, L. Weihs, R. Mottaghi, and A. Kembhavi. Simple but effective: Clip embeddings for embodied ai. arXiv preprint arXiv:2111.09888, 2021.
|
| 231 |
+
[27] S. Li, X. Puig, Y. Du, C. Wang, E. Akyurek, A. Torralba, J. Andreas, and I. Mordatch. Pre-trained language models for interactive decision-making. arXiv preprint arXiv:2202.01771, 2022.
|
| 232 |
+
[28] G. Lupyan. What do words do? toward a theory of language-augmented thought. In Psychology of learning and motivation, volume 57, pages 255–297. Elsevier, 2012.
|
| 233 |
+
[29] G. Lupyan, D. H. Rakison, and J. L. McClelland. Language is not just for talking: Redundant labels facilitate learning of novel categories. Psychological science, 18(12):1077–1083, 2007.
|
| 234 |
+
[30] M. C. Machado, M. G. Bellemare, and M. Bowling. Count-based exploration with the successor representation. Proceedings of the AAAI Conference on Artificial Intelligence, 34(04):5125– 5133, 2020.
|
| 235 |
+
[31] R. Marjieh, P. van Rijn, I. Sucholutsky, T. R. Sumers, H. Lee, T. L. Griffiths, and N. Jacoby. Words are all you need? capturing human sensory similarity with textual descriptors. arXiv preprint arXiv:2206.04105, 2022.
|
| 236 |
+
[32] J. Martin, S. N. Sasikumar, T. Everitt, and M. Hutter. Count-based exploration in feature space for reinforcement learning. arXiv preprint arXiv:1706.08090, 2017.
|
| 237 |
+
[33] S. Mirchandani, S. Karamcheti, and D. Sadigh. Ella: Exploration through learned language abstraction. Advances in Neural Information Processing Systems, 34, 2021.
|
| 238 |
+
[34] J. Mu, V. Zhong, R. Raileanu, M. Jiang, N. Goodman, T. Rocktäschel, and E. Grefenstette. Improving intrinsic exploration with language abstractions. arXiv preprint arXiv:2202.08938, 2022.
|
| 239 |
+
[35] P.-Y. Oudeyer and F. Kaplan. What is intrinsic motivation? a typology of computational approaches. Frontiers in neurorobotics, 1:6, 2009.
|
| 240 |
+
[36] P.-Y. Oudeyer, F. Kaplan, and V. V. Hafner. Intrinsic motivation systems for autonomous mental development. IEEE transactions on evolutionary computation, 11(2):265–286, 2007.
|
| 241 |
+
[37] S. Parisi, A. Rajeswaran, S. Purushwalkam, and A. Gupta. The unsurprising effectiveness of pre-trained vision models for control. arXiv preprint arXiv:2203.03580, 2022.
|
| 242 |
+
[38] D. Pathak, P. Agrawal, A. A. Efros, and T. Darrell. Curiosity-driven exploration by selfsupervised prediction. In International conference on machine learning, pages 2778–2787. PMLR, 2017.
|
| 243 |
+
[39] D. Pathak, D. Gandhi, and A. Gupta. Self-supervised exploration via disagreement. In International conference on machine learning, pages 5062–5071. PMLR, 2019.
|
| 244 |
+
[40] S. Racaniere, A. Lampinen, A. Santoro, D. Reichert, V. Firoiu, and T. Lillicrap. Automated curriculum generation through setter-solver interactions. In International conference on learning representations, 2019.
|
| 245 |
+
[41] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748–8763. PMLR, 2021.
|
| 246 |
+
[42] M. Reid, Y. Yamada, and S. S. Gu. Can wikipedia help offline reinforcement learning? arXiv preprint arXiv:2201.12122, 2022.
|
| 247 |
+
[43] N. Savinov, A. Raichuk, R. Marinier, D. Vincent, M. Pollefeys, T. Lillicrap, and S. Gelly. Episodic curiosity through reachability. arXiv preprint arXiv:1810.02274, 2018.
|
| 248 |
+
[44] J. Schmidhuber. A possibility for implementing curiosity and boredom in model-building neural controllers. In Proc. of the international conference on simulation of adaptive behavior: From animals to animats, pages 222–227, 1991.
|
| 249 |
+
[45] E. Schwartz, G. Tennenholtz, C. Tessler, and S. Mannor. Language is power: Representing states using natural language in reinforcement learning. arXiv preprint arXiv:1910.02789, 2019.
|
| 250 |
+
[46] R. Sekar, O. Rybkin, K. Daniilidis, P. Abbeel, D. Hafner, and D. Pathak. Planning to explore via self-supervised world models. In International Conference on Machine Learning (ICML), 2020.
|
| 251 |
+
[47] M. Shridhar, X. Yuan, M.-A. Côté, Y. Bisk, A. Trischler, and M. Hausknecht. Alfworld: Aligning text and embodied environments for interactive learning. arXiv preprint arXiv:2010.03768, 2020.
|
| 252 |
+
[48] P. Shyam, W. Jaskowski, and F. Gomez. Model-based active exploration. In ´ International Conference on Machine Learning (ICML), 2019.
|
| 253 |
+
[49] A. L. Strehl and M. L. Littman. An analysis of model-based interval estimation for markov decision processes. Journal of Computer and System Sciences, 74(8):1309–1331, 2008.
|
| 254 |
+
[50] D. Strouse, K. Baumli, D. Warde-Farley, V. Mnih, and S. Hansen. Learning more skills through optimistic exploration. In International Conference on Learning Representations (ICLR), 2022.
|
| 255 |
+
[51] R. S. Sutton and A. G. Barto. Reinforcement learning: An introduction. MIT press, 2018.
|
| 256 |
+
[52] D. I. A. Team, J. Abramson, A. Ahuja, A. Brussee, F. Carnevale, M. Cassin, F. Fischer, P. Georgiev, A. Goldin, T. Harley, et al. Creating multimodal interactive agents with imitation and self-supervised learning. arXiv preprint arXiv:2112.03763, 2021.
|
| 257 |
+
[53] T. Xiao, I. Radosavovic, T. Darrell, and J. Malik. Masked visual pre-training for motor control. arXiv preprint arXiv:2203.06173, 2022.
|
| 258 |
+
[54] D. Zha, W. Ma, L. Yuan, X. Hu, and J. Liu. Rank the episodes: A simple approach for exploration in procedurally-generated environments. arXiv preprint arXiv:2101.08152, 2021.
|
| 259 |
+
[55] T. Zhang, P. Rashidinejad, J. Jiao, Y. Tian, J. E. Gonzalez, and S. Russell. Made: Exploration via maximizing deviation from explored regions. Advances in Neural Information Processing Systems, 34, 2021.
|
| 260 |
+
[56] T. Zhang, H. Xu, X. Wang, Y. Wu, K. Keutzer, J. E. Gonzalez, and Y. Tian. Noveld: A simple yet effective exploration criterion. Advances in Neural Information Processing Systems, 34, 2021.
|
md/dev/0LXEvcD3dB/0LXEvcD3dB.md
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SpeechGPT: Empowering Large Language Models with Intrinsic Cross-Modal Conversational Abilities
|
| 2 |
+
|
| 3 |
+
Dong Zhang, Shimin Li, Xin Zhang, Jun Zhan, Pengyu Wang, Yaqian Zhou∗, Xipeng Qiu∗ School of Computer Science, Fudan University
|
| 4 |
+
Shanghai Key Laboratory of Intelligent Information Processing, Fudan University
|
| 5 |
+
{dongzhang22,xin_zhang22,jzhan22,pywang22}@m.fudan.edu.cn {smli20,zhouyaqian,xpqiu}@fudan.edu.cn
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Multi-modal large language models are regarded as a crucial step towards Artificial General Intelligence (AGI) and have garnered significant interest with the emergence of ChatGPT. However, current speech-language models typically adopt the cascade paradigm, preventing inter-modal knowledge transfer. In this paper, we propose SpeechGPT, a large language model with intrinsic cross-modal conversational abilities, capable of perceiving and generating multi-modal content. With discrete speech representations, we construct SpeechInstruct, the first large-scale crossmodal speech instruction dataset. Additionally, we employ a three-stage training strategy that includes modality-adaptation pretraining, cross-modal instruction fine-tuning, and chain-of-modality instruction fine-tuning. The experimental results demonstrate that SpeechGPT has an impressive capacity to follow cross-modal human instructions and highlight the potential of handling multiple modalities with one model. Code and models are available in https://github.com/ 0nutation/SpeechGPT. Demos are shown in https://0nutation.github. io/SpeechGPT.github.io/.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Large language models (OpenAI, 2023; Touvron et al., 2023) have performed astonishingly on various natural language processing tasks. Meanwhile, multi-modal large language models, such as GPT4, PALM-E (Driess et al., 2023), and LLaVA (Liu et al., 2023), have explored the ability of LLMs to understand multi-modal information. However, a significant gap exists between current LLMs and general artificial intelligence (AGI). First, most current LLMs can only perceive and understand multimodal content but cannot spontaneously generate multi-modal content. Second, continuous signals like images and speech cannot be adapted directly to LLMs that receive discrete tokens.
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: SpeechGPT’s capabilities to tackle multiple cross-modal tasks.
|
| 17 |
+
|
| 18 |
+
The current speech-language model mainly adopts a cascading paradigm (Huang et al., 2023a) i.e., the LLM is connected with an automatic speech recognition (ASR) model or a text-tospeech (TTS) model in tandem, or the LLM is employed as a control hub, with several speech processing models (Cheng et al., 2023a,b,c) are integrated to cover multiple audio or speech tasks (Huang et al., 2023a; Shen et al., 2023). Some prior work on generative spoken language models involves encoding the speech signal into a discrete representation (Baevski et al., 2020; Hsu et al., 2021; Zhang et al., 2023a) and modeling it with language models (Lakhotia et al., 2021; Borsos et al., 2022; Zhang et al., 2023d; Wang et al., 2023; Zhang et al., 2023c).
|
| 19 |
+
|
| 20 |
+
While capable of perceiving and generating speech, the existing cascaded methods or spoken language models still have several limitations. First, the LLM in the cascaded model only functions as a content generator. Since the representations of speech and text are not aligned, the LLM’s knowledge cannot be transferred to the speech modality. Second, the cascade approach (Shen et al., 2023; Huang et al., 2023a) suffers from the loss of paralinguistic signals such as emotion and prosody. Third, existing spoken language models (Wang et al., 2023; Zhang et al., 2023d) only synthesize speech but fail to comprehend its semantic information, preventing them from achieving true crossmodal perception and generation.
|
| 21 |
+
|
| 22 |
+
In this paper, we propose SpeechGPT, a large language model with intrinsic cross-modal conversational abilities, capable of perceiving and generating multi-modal content. We perform speech discretization with a self-supervised trained speech model to unify the modality between speech and text. The discrete speech tokens are then expanded into the vocabulary of the LLM, thus endowing the model with an inherent competence to perceive and generate the speech.
|
| 23 |
+
|
| 24 |
+
To provide the model with the capacity to handle multi-modal instructions, we build the first speech-text cross-modal instruction-following dataset SpeechInstruct. Specifically, we discretize the speech to discrete units (Hsu et al., 2021) and construct the cross-modal unit-text pair based on the existing ASR dataset. Meanwhile, we construct hundreds of instructions for diverse tasks with GPT4 to simulate actual user instructions as illustrated in Appendix B. In addition, to further enhance the model’s cross-modal capability, we designed the Chain-of-Modality instruction data, i.e., the model receives the speech command, thinks about the process in text, and then outputs the response in speech.
|
| 25 |
+
|
| 26 |
+
For better cross-modal transfer and efficient training, SpeechGPT undergoes a three-stage training process: modality-adaptation pre-training, cross-modal instruction fine-tuning, and chain-ofmodality instruction fine-tuning. The first stage enables speech comprehension for SpeechGPT with the discrete speech unit continuation task. The second stage employs the SpeechInstruct to improve the model’s cross-modal capabilities. The third stage utilizes parameter-efficient LoRA (Hu et al., 2021) fine-tuning for further modality alignment.
|
| 27 |
+
|
| 28 |
+
To evaluate the effectiveness of SpeechGPT, we conduct a wide range of human evaluations and case analyses to estimate the performance of SpeechGPT on textual tasks, speech-text crossmodal tasks, and spoken dialogue tasks. The results demonstrate that SpeechGPT exhibits a strong ability for unimodal and cross-modal instruction following tasks.
|
| 29 |
+
|
| 30 |
+
Our contributions include the following:
|
| 31 |
+
|
| 32 |
+
• We build the first multi-modal large language model that can perceive and generate multi
|
| 33 |
+
|
| 34 |
+
modal contents.
|
| 35 |
+
• We construct and release SpeechInstruct, the first large-scale speech-text cross-modal instructionfollowing dataset.
|
| 36 |
+
• We build the first spoken dialogue LLM with strong human instruction following ability and spoken dialogue ability.
|
| 37 |
+
• We show great potential to incorporate other modalities into LLMs through discrete representations.
|
| 38 |
+
|
| 39 |
+
# 2 Related Work
|
| 40 |
+
|
| 41 |
+
Multi-modal Large Language Model Current multi-modal LLMs predominantly focus on the visual domain, feeding continuous representations obtained from pre-trained visual encoders into LLMs, facilitating full-parameter or parameterefficient training on visual-language data (OpenAI, 2023; Huang et al., 2023b; Zhang et al., 2023b). Palm-E (Driess et al., 2023) integrates the 540B PaLM (Chowdhery et al., 2022) and 22B Vision Transformer (Dosovitskiy et al., 2021) into the largest vision-language model. LLaVA (Liu et al., 2023) leverages pre-trained CLIP (Radford et al., 2021) visual encoder and LLaMA (Touvron et al., 2023) and conduct instruct tuning on GPT4- assisted visual instruction data. X-LLM (Chen et al., 2023) converts multi-modalities into representations with X2L interfaces as the inputs of the large language model. However, such structures only enable LLMs to process multi-modal input, without ability to generate multi-modal output. Diverging from prior studies, our approach emphasizes the development of a speech-centric multimodal LLM, endowing it with the proficiency to accommodate both multi-modal input and output.
|
| 42 |
+
|
| 43 |
+
Generative Spoken Language Model Discrete self-supervised representation based spoken generative language modeling is making remarkable progress on large-scale speech dataset training (Nguyen et al., 2022). AudioLM (Borsos et al., 2022) proposes to model speech based on audio codecs together with semantic codes, which can synthesize speech in a textlesss setting. VALLE (Wang et al., 2023) builds a generative spoken language model on audio codecs and treat Textto-Speech as a conditional generation task. However, these models are designed for a specific task and failed to benefit from LLMs. SpeechGPT is built upon the foundation of LLM and transfers LLM’s knowledge to speech modality, consequently obtaining better task generalization and human-instruction following ability.
|
| 44 |
+
|
| 45 |
+
Speech-Enabled LLM Interaction Following the emergence of ChatGPT, several studies have concentrated on the integration of expert speech models with LLMs to enable direct speech interaction with LLMs. HuggingGPT (Shen et al., 2023) facilitates task decomposition of human instructions by LLMs and allows the invocation of models from Huggingface to accomplish specific tasks, encompassing a range of automatic speech recognition (ASR) and text-to-speech models. AudioGPT (Huang et al., 2023a) leverages a variety of audio foundation models to process complex audio information and connect LLMs with input/output interface (ASR, TTS) for speech conversations. However, these models exhibit increased complexity, demand extensive resources, and are prone to the unavoidable error accumulation problems. Our approach enables speech interaction with LLMs without relying on ASR or TTS systems, circumventing the aforementioned drawbacks.
|
| 46 |
+
|
| 47 |
+
# 3 SpeechInstruct Construction
|
| 48 |
+
|
| 49 |
+
Due to the limitations in publicly available speech data and the lack of variety of speech-text tasks, we construct SpeechInstruct, a speech-text crossmodal instruction-following dataset. This dataset consists of two parts, the first part is called CrossModal Instruction, and the second part is called Chain-of-Modality Instruction. The construction process of SpeechInstruct is illustrated in Figure 2.
|
| 50 |
+
|
| 51 |
+
# 3.1 Cross-modal Instruction
|
| 52 |
+
|
| 53 |
+
Data Collection We collect several large-scale English ASR datasets to construct Cross-Modal Instruction, including Gigaspeech (Chen et al., 2021), Common Voice (Ardila et al., 2020), and LibriSpeech (Panayotov et al., 2015). We employ mHuBERT1 as the speech tokenizer to discretize speech data into discrete units and remove the repetitive units of adjacent frames to get reduced units. Ultimately, we obtain 9 million unit-text data pairs.
|
| 54 |
+
|
| 55 |
+
Task Description Generation We generate ASR and TTS task descriptions that are compatible with speech-text data pairs. Unlike the Self-Instruct method (Wang et al., 2022), we generate descriptions through a zero-shot approach. Specifically, we directly input the prompts shown in Appendix A into OpenAI GPT-4 to generate task descriptions. Our generation method yields 100 instructions for each task and some examples are shown in Appendix B.
|
| 56 |
+
|
| 57 |
+
Instruction Formatting For a discrete unit sequence $U$ and its associated transcription $T$ , we determine whether it will be used for constructing an ASR task or a TTS task based on the probability $p$ . Subsequently, we randomly select a description $D$ from the corresponding task description. This results in a triplet consisting of the task description, discrete unit sequence, and transcription, denoted as $( D , U , T )$ . Following this, the triplet is assembled into an instruction using the template: [Human]: $\{ D \}$ . This is input: $\{ U \}$ <eoh>.[SpeechGPT]: $\{ T \} { \ < } { \bf e } { \bf 0 } { \bf s } > .$ ..
|
| 58 |
+
|
| 59 |
+
# 3.2 Chain-of-Modality Instruction
|
| 60 |
+
|
| 61 |
+
Speech Instruction Generation Due to the lack of instruction data with speech input and speech output, we trained a text-to-unit generator to convert text instruction data into speech instruction data. Specifically, the text-to-unit generator adopts a Transformer encoder-decoder architecture. We trained it on LibriSpeech unit-text pairs in Crossmodal Instruction. We select 37,969 samples from the moss-002-sft-data dataset 2 whose response length is shorter than 35 words. And we convert both their instructions and responses into unit sequences through the text-to-unit generator. As a result, we obtained 37,969 quadruplets composed of speech instructions, text instructions, text responses, and speech responses, denoted as (SpeechI, T extI, T extR, SpeechR).
|
| 62 |
+
|
| 63 |
+
Instruction Formatting Using the above quadruplets, we could construct chain-of-thought style instructions for four input-output formats, namely Speech Instruction-Speech Response, Speech Instruction-Text Response, Text Instruction-Speech Response, and Text Instruction-Text Response. Their corresponding templates can be found in Appendix C.
|
| 64 |
+
|
| 65 |
+
# 3.3 SpeechInstruct Evaluation Set
|
| 66 |
+
|
| 67 |
+
We constructed cross-modal dialogue datasets under different scenarios to evaluate whether SpeechGPT could take on various roles. Specifically, these included a talking encyclopedia, personal assistant, chat partner, poet, psychologist, and educational assistant. For each role, we provide 10 manually authored instruction-response pairs written by ourselves. We use a pre-trained text-to-speech model 3 to convert the text into corresponding speech. We then employ mHuBERT to discretize speech data into discrete units as described in Section 3.1. Ultimately, for each role, we obtained 10 quadruplets composed of speech instructions, text instructions, text responses, and speech responses.
|
| 68 |
+
|
| 69 |
+

|
| 70 |
+
Figure 2: Left: An overview of SpeechInstruct construction process. The SpeechInstruct dataset consists of two parts: Cross-modal Instruction data and Chain-of-Modality Instruction data. T emplate1 is shown in 3.1. T emplate2 is shown in Appendix C. Right: An illustration of SpeechGPT model structure.
|
| 71 |
+
|
| 72 |
+
# 4 SpeechGPT
|
| 73 |
+
|
| 74 |
+
# 4.1 Model Structure
|
| 75 |
+
|
| 76 |
+
A unified framework is designed to provide architecture compatibility across different modalities. As shown in Figure 2, our model consists of three main components: discrete unit extractor, large language modal and unit vocoder. Under this architecture, LLM can perceive multi-modal inputs and generate multi-modal outputs.
|
| 77 |
+
|
| 78 |
+
Discrete Unit Extractor The discrete unit extractor utilizes the Hidden-unit BERT (HuBERT) model (Hsu et al., 2021) to transform continuous speech signals into a sequence of discrete units, . HuBERT is a self-supervised model that learns by predicting discrete labels for masked audio segments based on $\mathbf { k }$ -means clustering applied to the model’s intermediate representations. It features a combination of 1-D convolutional layers and a Transformer encoder to encode speech into continuous intermediate representations, with a kmeans model further converting these representations into a sequence of cluster indices. Subsequently, adjacent duplicate indices are removed, resulting in a discrete units sequence represented as $U = ( u _ { 1 } , u _ { 2 } , . . . , u _ { T } )$ , $u _ { i } \in { 0 , 1 , . . . , K - 1 }$ , $\forall 1 \leq i \leq T$ , with $K$ denoting the total number of clusters.
|
| 79 |
+
|
| 80 |
+
Large Language Model We employ the Meta AI LLaMA (Touvron et al., 2023) model as our Large Language Model. LLaMA comprises an embedding layer, multiple transformer blocks, and an LM head layer. The total number of parameters in LLaMA ranges from 7B to 65B. Drawing from an extensive training dataset of 1.0 trillion tokens, LLaMA demonstrates competitive performance compared to the substantially larger 175B GPT-3 across various NLP benchmarks.
|
| 81 |
+
|
| 82 |
+
Unit Vocoder Due to limition of single speaker unit vocoder in (Polyak et al., 2021), we train a multi-speaker unit HiFi-GAN to decode the speech signal from the discrete representation. The HiFiGAN architecture consists of a generator $\mathbf { G }$ and multiple discriminators D. The generator uses look-up tables (LUT) to embed discrete representations and the embedding sequences are up-sampled by a series of blocks composed of transposed convolution and a residual block with dilated layers. The speaker embedding is concatenated to each frame in the up-sampled sequence. The discriminator features a Multi-Period Discriminator (MPD) and a Multi-Scale Discriminator (MSD), which have the same architecture as (Polyak et al., 2021).
|
| 83 |
+
|
| 84 |
+
# 4.2 Training
|
| 85 |
+
|
| 86 |
+
To incorporate speech discrete representation into LLM, we expand the vocabulary and corresponding embedding matrix first. We divide the training process into three stages. The first stage is ModalityAdaptation Pre-training on unpaired speech data. The second stage is Cross-modal Instruction FineTuning. The third stage is Chain-of-Modality Instruction Fine-Tuning.
|
| 87 |
+
|
| 88 |
+
Expanding Vocabulary Given original LLM vocabulary $V$ of size $| V |$ , to integrate speech discrete representations into LLM, we expand the vocabulary with an additional set of unit tokens $V ^ { \prime }$ , of size $| V ^ { \prime } | = K$ . The expanded vocabulary $V ^ { \prime \prime }$ is the union of the original vocabulary $V$ and the new words $V ^ { \prime }$ :
|
| 89 |
+
|
| 90 |
+
$$
|
| 91 |
+
V ^ { \prime \prime } = V \cup V ^ { \prime }
|
| 92 |
+
$$
|
| 93 |
+
|
| 94 |
+
We denote the original word embedding matrix as $E \in \mathbb { R } ^ { | V | \times d }$ , where $d$ is the dimension of word embeddings. To accommodate the expanded vocabulary, we need to create a randomly initialized word embedding matrix $E ^ { \prime } \in \mathbb { R } ^ { | V ^ { \prime \prime } | \times d }$ . We preserve the original word embeddings by copying the values of $E$ to the first $| V |$ rows of $E ^ { \prime }$ :
|
| 95 |
+
|
| 96 |
+
$$
|
| 97 |
+
E ^ { \prime } [ 0 : | V | , : ] = E
|
| 98 |
+
$$
|
| 99 |
+
|
| 100 |
+
Finally, we replace the original vocabulary and word embedding matrix with the new vocabulary $V ^ { \prime \prime }$ and the word embedding matrix $E ^ { \prime }$ .
|
| 101 |
+
|
| 102 |
+
Stage 1: Modality-Adaptation Pre-training To enable LLM to handle discrete units modality, we utilize an unlabeled speech corpus to train LLM in a next-token prediction task. This approach aligns with the text pre-training objective of LLM. Given unlabeled speech corpus $C$ consisting of speech $U _ { 1 } , U _ { 2 } , \dots , U _ { m }$ and LLM denoted as $L _ { 1 }$ , the negative log-likelihood loss can be formulated as:
|
| 103 |
+
|
| 104 |
+
$$
|
| 105 |
+
\mathcal { L } ( L | C ) = - \sum _ { j = 1 } ^ { m } \sum _ { i = 1 } ^ { n _ { j } } \log P ( u _ { i , j } | u _ { < i , j } ; L )
|
| 106 |
+
$$
|
| 107 |
+
|
| 108 |
+
where $m$ is the number of speech in dataset $C$ , $n _ { j }$ is the number of discrete unit token in speech $U _ { j }$ , and $u _ { i , j }$ represents the i-th unit token in the $\mathrm { j } \cdot$ -th speech.
|
| 109 |
+
|
| 110 |
+
Stage 2: Cross-modal Instruction FineTuning In this stage, we align speech and text modalities utilizing paired data. We mix Crossmodal Instruction in SpeechInstruct with moss-002- sft dataset to derive mix dataset $I$ , which consists of samples $T _ { 1 } , T _ { 2 } , \dots , T _ { x }$ . We fine-tune the model $L$ obtained from the first stage on $I$ .
|
| 111 |
+
|
| 112 |
+
Each sample $T _ { j }$ consisting of $t _ { 1 } , t _ { 2 } , \ldots , t _ { n _ { j } }$ is formed by concatenating a prefix and a text. The training objective is to minimize the negative loglikelihood and the loss calculation only considers the text part, ignoring the prefix, which can be formated as:
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\mathcal { L } ( L | I ) = - \sum _ { j = 1 } ^ { x } \sum _ { i = p _ { j } + 1 } ^ { y _ { j } } \log P ( t _ { i , j } | t _ { < i , j } ; L )
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
where $x$ is the number of samples in corpus $I$ , $y _ { j }$ is the total number of tokens in sample $T _ { j } , p _ { j }$ is the number of tokens in the prefix part of $T _ { j }$ , and $t _ { i , j }$ represents the i-th word in $T _ { j }$ .
|
| 119 |
+
|
| 120 |
+
Stage 3: Chain-of-Modality Instruction FineTuning After obtaining the model in stage 2, we utilizes parameter-efficient Low-Rank Adaptation (LoRA) (Hu et al., 2021) to fine-tune it on Chain-of-Modality Instruction in SpeechInstruct. We add LoRA weights (adapters) to the attention mechanisms and train the newly added LoRA parameters. We adopt the same loss function as stage 2.
|
| 121 |
+
|
| 122 |
+
# 5 Experiments
|
| 123 |
+
|
| 124 |
+
# 5.1 Experimental Setups
|
| 125 |
+
|
| 126 |
+
Datasets For modality-adaption pre-training, we use LibriLight (Kahn et al., 2020) which contains 60K hours of unlabelled English audiobook speech. For cross-modal instruction fine-tuning stage, we use Gigaspeech (Chen et al., 2021), Common voice (Ardila et al., 2020) and LibriSpeech (Panayotov et al., 2015) dataset and moss-002-sft-data dataset, which is illustrated in detail in 3.1. For chain-of-modality instruction fine-tuning stage, we use moss-002-sft-data dataset, which is illustrated in detail in 3.2.
|
| 127 |
+
|
| 128 |
+
Configuration We employ LLaMA-13B (Touvron et al., 2023) as our backbone model for a trade-off between performance and computational resources available. For stage 1, we use 96 A100 GPUs and train for 900 steps with batch size 768. For stage 2, we use 96 A100 GPUs and train for 2100 steps with batch size 1536. For stage 3, we use 8 A100 GPUs and train for 4200 steps with batch size 128.
|
| 129 |
+
|
| 130 |
+
Details about training hyperparameters are shown in Appendix D. For decoding, we set the maximum sequence length to 2048 and set the temperature to 0.8. We use Top- $k$ sampling with $k { = } 6 0$ . We also use Top- $p$ sampling with $\mathrm { p { = } } 0 . 8$ .
|
| 131 |
+
|
| 132 |
+
# 5.2 Baselines
|
| 133 |
+
|
| 134 |
+
We establish two cascaded cross-modal conversational systems as our baselines. The first model, referred to as Speech-Alpaca-13B, consists of an offthe-shell ASR system 4, Alpaca 13B (Taori et al., 2023) as well as a pre-trained TTS system 5. The second model, named Speech-LLaMA-MOSS-002, incorporates the same ASR and TTS system, along with a large language model obtained by performing supervised fine-tuning on LLaMA-13B using MOSS-sft-002 as the training dataset.
|
| 135 |
+
|
| 136 |
+
# 5.3 Evaluation
|
| 137 |
+
|
| 138 |
+
We evaluate the cross-modal instruction-following capabilities of SpeechGPT across four tasks: speech-to-speech instruction-following (S2SIF), speech-to-text instruction-following (S2TIF), textto-speech instruction-following (T2SIF), and textto-text instruction-following (T2TIF).
|
| 139 |
+
|
| 140 |
+
Data We randomly select 40 samples from the AlpacaEval dataset 6 and use the pre-trained TTS model in Section 3.3 to convert the text into corresponding speech. We then employ mHuBERT to discretize speech data into discrete units as described in Section 3.1. These are combined with the SpeechInstruct Evaluation Set to constitute our test set, which contains 100 samples. Each sample is a quadruplet composed of a speech instruction, text instruction, text response, and speech response. We denote them as ground truth.
|
| 141 |
+
|
| 142 |
+
ChatGPT Score We utilize ChatGPT (GPT3.5-turbo) to assess the cross-modal instructionfollowing performance. For tasks that include speech, we leveraged the pre-trained ASR model in section 5.2 to transform the speech into its corresponding text, which is subsequently submitted for evaluation. Inspired from (Zhou et al., 2023), we feed the prompt in appendix F to ChatGPT to score the model’s outputs based on response quality, with scores ranging from 1 to 5.
|
| 143 |
+
|
| 144 |
+
Human Opinion Score Following (Nguyen et al., 2022), we calculate the human opinion score of the generated examples through crowdsourcing. These opinions are based on two dimensions: the content mean opinion score (CMOS) for content and meaningfulness quality, and the naturalness mean opinion score (NMOS) for speech naturalness and fluency. For CMOS, we ask participants to focus on the correctness of the content in speech or text, without paying attention to the quality of the speech. For NMOS, we direct participants to focus on the quality, smoothness, and naturalness of the speech, without considering its content. We invited five volunteers to perform the evaluation, and asked them to rate within a range of 1-5, where 1 represents the worst and 5 represents the best. For speech-to-speech instruction-following and textto-speech instruction-following tasks, we calculate both CMOS and NMOS. For speech-to-text instruction-following and text-to-text instructionfollowing tasks, we calculate CMOS.
|
| 145 |
+
|
| 146 |
+
# 5.4 Main Results
|
| 147 |
+
|
| 148 |
+
Content As shown in Table 1, taking into account the comprehensive evaluation of ChatGPT Score and CMOS, SpeechGPT demonstrates superior performance on speech instructions (S2SIF and S2TIF) compared to the two baseline systems. This indicates that SpeechGPT outperforms the ASR model in the cascaded system when it comes to understanding speech content. From the perspective of CMOS, SpeechGPT achieves performance similar to the baseline systems on T2SIF and T2TIF tasks, indicating that SpeechGPT still possesses commendable text and speech generation capabilities. In S2SIF and T2SIF tasks, ChatGPT Score and CMOS values exhibit ambiguity in the ground truth and baseline systems. This can be attributed to speech responses being synthesized by TTS system, which can have errors in pauses between sentences. This introduces significant errors for longer responses, leading to incorrect text after being processed by the ASR system, thereby reducing the ChatGPT score. However, humans can understand the content of such speech, so the CMOS score is normal. Cases of cross-modal instructionfollowing can be found in Appendix G.
|
| 149 |
+
|
| 150 |
+
Speech Quality As shown in Table 1, SpeechGPT exhibits significantly higher NMOS values compared to the baseline systems. This indicates that the speech responses generated by SpeechGPT out
|
| 151 |
+
|
| 152 |
+
<table><tr><td rowspan="3">Methods</td><td colspan="4">ChatGPT Score</td><td colspan="8">Human Opinion Score</td></tr><tr><td colspan="4"></td><td colspan="4">CMOS</td><td colspan="4">NMOS</td></tr><tr><td>S2SIF</td><td>S2TIF</td><td>T2SIF</td><td>T2TIF</td><td>S2SIF</td><td>S2TIF</td><td>T2SIF</td><td>T2TIF</td><td>S2SIF</td><td>S2TIF</td><td>T2SIF</td><td>T2TIF</td></tr><tr><td>Ground Truth</td><td>2.85*</td><td>3.74</td><td>2.91*</td><td>3.93</td><td>3.78</td><td>3.89</td><td>3.95</td><td>4.12</td><td>3.18</td><td>-</td><td>3.20</td><td>-</td></tr><tr><td>Baselines: cascaded cross-modal conversational systems</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Speech-Alpaca-13B</td><td>2.74</td><td>3.31</td><td>2.71</td><td>3.83</td><td>3.39</td><td>3.42</td><td>3.71</td><td>3.75</td><td>3.12</td><td></td><td>3.13</td><td>1</td></tr><tr><td>Speech-LLaMA-MOSS-002</td><td>2.87</td><td>3.50</td><td>3.23</td><td>3.82</td><td>3.38</td><td>3.44</td><td>3.74</td><td>3.83</td><td>3.14</td><td></td><td>3.11</td><td>1</td></tr><tr><td>SpeechGPT</td><td>3.42</td><td>3.52</td><td>3.53</td><td>3.64</td><td>3.42</td><td>3.49</td><td>3.57</td><td>3.69</td><td>3.65</td><td>-</td><td>3.62</td><td>1</td></tr></table>
|
| 153 |
+
|
| 154 |
+
Table 1: Main Results of SpeechGPT. S2SIF refers to speech-to-speech instruction-following, S2TIF is speech-totext instruction-following, T2SIF denotes text-to-speech instruction-following and T2TIF represents text-to-text instruction-following. ChatGPT score is obtained through ChatGPT evaluatation. CMOS refers to content mean opinion score. NMOS denotes naturalness mean opinion score. ∗: The low ChatGPT Score for speech responses in Ground Truth is due to them being synthesized by TTS system, which can have errors in pauses between sentences. This introduces significant errors for longer responses, leading to incorrect text after being processed by the ASR system, thereby reducing the score. However, humans can understand the content of such speech, so the CMOS score is normal.
|
| 155 |
+
|
| 156 |
+
Table 2: ChatGPT Score on speech-to-speech instruction-following task. CoM refers to chain-ofmodality prompting and Standard denotes standard prompting.
|
| 157 |
+
|
| 158 |
+
<table><tr><td>Training</td><td>Inference</td><td>ChatGPT Score</td></tr><tr><td>Standard</td><td>Standard</td><td>2.15</td></tr><tr><td>Standard</td><td>CoM</td><td>2.12</td></tr><tr><td>CoM</td><td>Standard</td><td>2.35</td></tr><tr><td>CoM</td><td>CoM</td><td>3.42</td></tr></table>
|
| 159 |
+
|
| 160 |
+
perform the TTS system in the cascaded system in terms of audio quality and prosody. More detailed speech prosody analysis are located in Section ??.
|
| 161 |
+
|
| 162 |
+
# 6 Analysis
|
| 163 |
+
|
| 164 |
+
# 6.1 Chain-of-modality prompting matters
|
| 165 |
+
|
| 166 |
+
Table 2 shows ChatGPT Scores on speech-tospeech instruction-following task for models utilizing standard prompting and chain-of-modality prompting during training and inference stages respectively. Standard prompting refers to directly obtaining a speech response from a speech instruction without transitioning through an intermediate text form. The template can be located in Appendix E. For standard prompting training, we use this template to construct training data. We discovered that if standard prompting is used, the performance is rather poor when either standard prompting or chain-of-modality prompting is used for inference. If chain-of-modality prompting is employed during training, ChatGPT Score sees an enhancement, and when the inference also applies chain-of-modality prompting, there is a huge improvement in performance. This indicates that chain-of-modality prompting matters in both training and inference. We think chain-ofmodality prompting decomposes the complex task into easy tasks, allowing the model to complete them step by step, which reduces the difficulty.
|
| 167 |
+
|
| 168 |
+

|
| 169 |
+
Figure 3: ASR-PPL of speech continue task on 100 utterances from LibriSpeech test-clean set. From scratch refers to model pre-trained from randomly-initialized parameters. From LLaMA denotes model pre-trained from LLaMA.
|
| 170 |
+
|
| 171 |
+
# 6.2 Can text knowledge benefit speech modality?
|
| 172 |
+
|
| 173 |
+
SpeechGPT originates from a text pre-trained model, LLaMA. Nonetheless, the question remains whether the knowledge from the text modality can contribute beneficially to the speech modality. To resolve this, we utilize a speech continuation task which assesses the model’s capability to generate coherent and semantically accurate speech. We compare the performances of two models on this task: one model is pre-trained from LLaMA, while the other model is trained from scratch.
|
| 174 |
+
|
| 175 |
+

|
| 176 |
+
Figure 4: ChatGPT Score on text-to-text instructionfollowing task. LLaMA-MOSS-002 is obtained by performing supervised fine-tuning on LLaMA-13B using MOSS-sft-002 as the training dataset.
|
| 177 |
+
|
| 178 |
+
We utilize LibriSpeech test-clean set for evaluation, where we randomly select 100 utterances, and use the first 3 seconds of each utterance as a prompt. The 3-second speech prompt is converted into discrete units by mHuBERT. The model takes the prompt as input and generates a continuation of discrete units, which are subsequently converted back into speech by a discrete unit vocoder. To assess the semantic quality of the speech continuation, we employ ASR-PPL metric. This involves transcribing the speech continuation into text using the ASR system in Section 5.2 and calculating the perplexity of the transcripts using GPT-3.5 text-devinci-003 model. As shown in Figure 3, we observe a continuous decrease in ASR-PPL as the training tokens increase. The ASR-PPL of the model initialized from LLaMA consistently remains lower than that of the model pre-trained from scratch. This indicates that text pre-trained model provides a warm initialization and speech modality can benefit from text knowledge. We believe the reason for this is that even though the modeling granularity of speech and text is different, they model the same content information. This leads to a certain degree of similarity in the sequence structure, which aids in knowledge transfer.
|
| 179 |
+
|
| 180 |
+
# 6.3 Does SpeechGPT Sacrifice Text Capability as a Trade-off?
|
| 181 |
+
|
| 182 |
+
Initialized form LLaMA, SpeechGPT is capable of preceiving and generating speech after training on large scale speech data. However, does SpeechGPT sacrifice text capability as a trade-off? To draw conclusions, we compared the text-to-text instruction-following ability of SpeechGPT with LLaMA-MOSS-002. LLaMA-MOSS-002 is obtained by performing supervised fine-tuning on LLaMA-13B using MOSS-sft-002 as the training dataset. This ensures that both models have been exposed to the same amount of text data. We evaluated both models using the test set from Section 5.3.
|
| 183 |
+
|
| 184 |
+
As depicted in Figure 4, with an increase in training samples, both LLaMA-MOSS-002 and SpeechGPT’s ChatGPT Score gradually improve. Although SpeechGPT consistently remains lower than LLaMA-MOSS-002. the performance gap between them gradually decreases. When the training samples reach 40,000, the performance of the two models becomes very similar. This suggests that SpeechGPT still retains text capability. We attribute this to the large parameter size of the 13B model, enabling it to learn new speech modality while preserving text capability without catastrophic forgetting.
|
| 185 |
+
|
| 186 |
+
# 7 Conclusion
|
| 187 |
+
|
| 188 |
+
This work presents SpeechGPT, a large language model with intrinsic cross-modal conversational abilities, capable of perceiving and generating multi-modal content. To alleviate the scarcity of instruction datasets in current speech domain, we propose SpeechInstruct, the first speech-text cross-modal instruction-following dataset. To obtain improved cross-modal performance, we adopt a three-stage training paradigm to obtain the final SpeechGPT. Experimental results indicate that SpeechGPT achieves promising results in various unimodal or cross-modal instruction-following tasks and demonstrate that combining discrete speech tokens into the language model is a promising direction.
|
| 189 |
+
|
| 190 |
+
# Limitation
|
| 191 |
+
|
| 192 |
+
Despite SpeechGPT exhibiting impressive crossmodal instruction following and spoken dialogue abilities, it still presents certain limitations: 1) Due to the audio discretization technique constraints, SpeechGPT does not explicitly model the paralinguistic information included in the speech signal. 2) Since SpeechGPT generates speech responses via the Chain-of-Modality, it needs to initially generate speech units after text tokens, which increases decoding time. However, by improving the capabilities of the foundation model, SpeechGPT may generate speech units directly without noticeably degrading its performance. 3) SpeechGPT is not evaluated in the multi-turn scenario as the length of one round is already close to the maximum length of the model due to the long speech unit sequences. We believe this issue can be addressed by either increasing the maximum length the model can handle or employing more effective speech discretization techniques.
|
| 193 |
+
|
| 194 |
+
# Acknowledgements
|
| 195 |
+
|
| 196 |
+
We thank Rong Ye and Fuliang Weng for the careful guidance and revisions to the paper and thank all the anonymous reviewers for their insightful and valuable comments. This work was supported by the National Natural Science Foundation of China (No. 62236004 and No. 62022027).
|
| 197 |
+
|
| 198 |
+
# References
|
| 199 |
+
|
| 200 |
+
Rosana Ardila, Megan Branson, Kelly Davis, Michael Henretty, Michael Kohler, Josh Meyer, Reuben Morais, Lindsay Saunders, Francis M. Tyers, and Gregor Weber. 2020. Common voice: A massivelymultilingual speech corpus.
|
| 201 |
+
|
| 202 |
+
Alexei Baevski, Yuhao Zhou, Abdelrahman Mohamed, and Michael Auli. 2020. wav2vec 2.0: A framework for self-supervised learning of speech representations. Advances in Neural Information Processing Systems, 33:12449–12460.
|
| 203 |
+
|
| 204 |
+
Zalán Borsos, Raphaël Marinier, Damien Vincent, Eugene Kharitonov, Olivier Pietquin, Matt Sharifi, Olivier Teboul, David Grangier, Marco Tagliasacchi, and Neil Zeghidour. 2022. Audiolm: a language modeling approach to audio generation.
|
| 205 |
+
|
| 206 |
+
Feilong Chen, Minglun Han, Haozhi Zhao, Qingyang Zhang, Jing Shi, Shuang Xu Xu, and Bo Xu. 2023. Xllm: Bootstrapping advanced large language models by treating multi-modalities as foreign languages.
|
| 207 |
+
|
| 208 |
+
Guoguo Chen, Shuzhou Chai, Guanbo Wang, Jiayu Du, Wei-Qiang Zhang, Chao Weng, Dan Su, Daniel Povey, Jan Trmal, Junbo Zhang, Mingjie Jin, Sanjeev Khudanpur, Shinji Watanabe, Shuaijiang Zhao, Wei Zou, Xiangang Li, Xuchen Yao, Yongqing Wang, Yujun Wang, Zhao You, and Zhiyong Yan. 2021. Gigaspeech: An evolving, multi-domain asr corpus with 10,000 hours of transcribed audio.
|
| 209 |
+
|
| 210 |
+
Xuxin Cheng, Zhihong Zhu, Ziyu Yao, Hongxiang Li, Yaowei Li, and Yuexian Zou. 2023c. GhostT5: Generate More Features with Cheap Operations to Improve Textless Spoken Question Answering. In Proc. INTERSPEECH 2023, pages 1134–1138.
|
| 211 |
+
|
| 212 |
+
Xuxin Cheng, Qianqian Dong, Fengpeng Yue, Tom Ko, Mingxuan Wang, and Yuexian Zou. 2023b. M 3 st: Mix at three levels for speech translation. In ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 1–5. IEEE.
|
| 213 |
+
|
| 214 |
+
Xuxin Cheng, Bowen Cao, Qichen Ye, Zhihong Zhu, Hongxiang Li, and Yuexian Zou. 2023a. Ml-lmcl: Mutual learning and large-margin contrastive learning for improving asr robustness in spoken language understanding. In Findings of the Association for Computational Linguistics: ACL 2023, pages 6492– 6505.
|
| 215 |
+
|
| 216 |
+
Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. 2022. Palm: Scaling language modeling with pathways.
|
| 217 |
+
|
| 218 |
+
Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. 2021. An image is worth 16x16 words: Transformers for image recognition at scale.
|
| 219 |
+
|
| 220 |
+
Danny Driess, Fei Xia, Mehdi SM Sajjadi, Corey Lynch, Aakanksha Chowdhery, Brian Ichter, Ayzaan Wahid, Jonathan Tompson, Quan Vuong, Tianhe Yu, et al. 2023. Palm-e: An embodied multimodal language model. arXiv preprint arXiv:2303.03378.
|
| 221 |
+
|
| 222 |
+
Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, Ruslan Salakhutdinov, and Abdelrahman Mohamed. 2021. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 29:3451–3460.
|
| 223 |
+
|
| 224 |
+
Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2021. Lora: Low-rank adaptation of large language models.
|
| 225 |
+
|
| 226 |
+
Rongjie Huang, Mingze Li, Dongchao Yang, Jiatong Shi, Xuankai Chang, Zhenhui Ye, Yuning Wu,
|
| 227 |
+
|
| 228 |
+
Zhiqing Hong, Jiawei Huang, Jinglin Liu, Yi Ren, Zhou Zhao, and Shinji Watanabe. 2023a. Audiogpt: Understanding and generating speech, music, sound, and talking head.
|
| 229 |
+
|
| 230 |
+
Shaohan Huang, Li Dong, Wenhui Wang, Yaru Hao, Saksham Singhal, Shuming Ma, Tengchao Lv, Lei Cui, Owais Khan Mohammed, Barun Patra, Qiang Liu, Kriti Aggarwal, Zewen Chi, Johan Bjorck, Vishrav Chaudhary, Subhojit Som, Xia Song, and Furu Wei. 2023b. Language is not all you need: Aligning perception with language models.
|
| 231 |
+
|
| 232 |
+
J. Kahn, M. Riviere, W. Zheng, E. Kharitonov, Q. Xu, P.E. Mazare, J. Karadayi, V. Liptchinsky, R. Collobert, C. Fuegen, T. Likhomanenko, G. Synnaeve, A. Joulin, A. Mohamed, and E. Dupoux. 2020. Librilight: A benchmark for ASR with limited or no supervision. In ICASSP 2020 - 2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). IEEE.
|
| 233 |
+
|
| 234 |
+
Kushal Lakhotia, Eugene Kharitonov, Wei-Ning Hsu, Yossi Adi, Adam Polyak, Benjamin Bolte, Tu-Anh Nguyen, Jade Copet, Alexei Baevski, Abdelrahman Mohamed, et al. 2021. On generative spoken language modeling from raw audio. Transactions of the Association for Computational Linguistics, 9:1336– 1354.
|
| 235 |
+
|
| 236 |
+
Haotian Liu, Chunyuan Li, Qingyang Wu, and Yong Jae Lee. 2023. Visual instruction tuning. arXiv preprint arXiv:2304.08485.
|
| 237 |
+
|
| 238 |
+
Tu Anh Nguyen, Eugene Kharitonov, Jade Copet, Yossi Adi, Wei-Ning Hsu, Ali Elkahky, Paden Tomasello, Robin Algayres, Benoit Sagot, Abdelrahman Mohamed, and Emmanuel Dupoux. 2022. Generative spoken dialogue language modeling.
|
| 239 |
+
|
| 240 |
+
OpenAI. 2023. Gpt-4 technical report.
|
| 241 |
+
|
| 242 |
+
Vassil Panayotov, Guoguo Chen, Daniel Povey, and Sanjeev Khudanpur. 2015. Librispeech: An asr corpus based on public domain audio books. In 2015 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 5206–5210.
|
| 243 |
+
|
| 244 |
+
Adam Polyak, Yossi Adi, Jade Copet, Eugene Kharitonov, Kushal Lakhotia, Wei-Ning Hsu, Abdelrahman Mohamed, and Emmanuel Dupoux. 2021. Speech resynthesis from discrete disentangled selfsupervised representations.
|
| 245 |
+
|
| 246 |
+
Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. 2021. Learning transferable visual models from natural language supervision.
|
| 247 |
+
|
| 248 |
+
Yongliang Shen, Kaitao Song, Xu Tan, Dongsheng Li, Weiming Lu, and Yueting Zhuang. 2023. Hugginggpt: Solving ai tasks with chatgpt and its friends in huggingface.
|
| 249 |
+
|
| 250 |
+
Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. 2023. Stanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/ stanford_alpaca.
|
| 251 |
+
|
| 252 |
+
Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. 2023. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971.
|
| 253 |
+
|
| 254 |
+
Chengyi Wang, Sanyuan Chen, Yu Wu, Ziqiang Zhang, Long Zhou, Shujie Liu, Zhuo Chen, Yanqing Liu, Huaming Wang, Jinyu Li, Lei He, Sheng Zhao, and Furu Wei. 2023. Neural codec language models are zero-shot text to speech synthesizers.
|
| 255 |
+
|
| 256 |
+
Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A. Smith, Daniel Khashabi, and Hannaneh Hajishirzi. 2022. Self-instruct: Aligning language model with self generated instructions.
|
| 257 |
+
|
| 258 |
+
Dong Zhang, Rong Ye, Tom Ko, Mingxuan Wang, and Yaqian Zhou. 2023a. DUB: Discrete unit backtranslation for speech translation. In Findings of the Association for Computational Linguistics: ACL 2023, pages 7147–7164, Toronto, Canada. Association for Computational Linguistics.
|
| 259 |
+
|
| 260 |
+
Renrui Zhang, Jiaming Han, Aojun Zhou, Xiangfei Hu, Shilin Yan, Pan Lu, Hongsheng Li, Peng Gao, and Yu Qiao. 2023b. Llama-adapter: Efficient fine-tuning of language models with zero-init attention.
|
| 261 |
+
|
| 262 |
+
Xin Zhang, Dong Zhang, Shimin Li, Yaqian Zhou, and Xipeng Qiu. 2023c. Speechtokenizer: Unified speech tokenizer for speech large language models.
|
| 263 |
+
|
| 264 |
+
Ziqiang Zhang, Long Zhou, Chengyi Wang, Sanyuan Chen, Yu Wu, Shujie Liu, Zhuo Chen, Yanqing Liu, Huaming Wang, Jinyu Li, Lei He, Sheng Zhao, and Furu Wei. 2023d. Speak foreign languages with your own voice: Cross-lingual neural codec language modeling.
|
| 265 |
+
|
| 266 |
+
Chunting Zhou, Pengfei Liu, Puxin Xu, Srini Iyer, Jiao Sun, Yuning Mao, Xuezhe Ma, Avia Efrat, Ping Yu, Lili Yu, Susan Zhang, Gargi Ghosh, Mike Lewis, Luke Zettlemoyer, and Omer Levy. 2023. Lima: Less is more for alignment.
|
| 267 |
+
|
| 268 |
+
# A Prompts to Generate Task Description
|
| 269 |
+
|
| 270 |
+
# ASR:
|
| 271 |
+
|
| 272 |
+
You are asked to come up with a set of 100 diverse task instructions about automatic speech recognition, which is about recognizing speech.
|
| 273 |
+
|
| 274 |
+
Here are the requirements:
|
| 275 |
+
|
| 276 |
+
1. These instructions should be to instruct someone to recognize the content of the following speech.
|
| 277 |
+
|
| 278 |
+
2. Try not to repeat the verb for each instruction to maximize diversity.
|
| 279 |
+
|
| 280 |
+
3. The language used for instruction also should be diverse. For example, you should combine questions with imperative instructions.
|
| 281 |
+
|
| 282 |
+
4. The type of instructions should be diverse.
|
| 283 |
+
|
| 284 |
+
5. The instructions should be in English.
|
| 285 |
+
|
| 286 |
+
6. The instructions should be 1 to 2 sentences long. Either an imperative sentence or a question is permitted.
|
| 287 |
+
|
| 288 |
+
List of 100 tasks:
|
| 289 |
+
|
| 290 |
+
TTS:
|
| 291 |
+
|
| 292 |
+
You are asked to come up with a set of 100 diverse task instructions about text to speech, which is about recognizing speech .
|
| 293 |
+
|
| 294 |
+
Here are the requirements:
|
| 295 |
+
|
| 296 |
+
1. These instructions should be to instruct someone to recognize the content of the following speech.
|
| 297 |
+
|
| 298 |
+
2. Try not to repeat the verb for each instruction to maximize diversity.
|
| 299 |
+
|
| 300 |
+
3. The language used for instruction also should be diverse. For example, you should combine questions with imperative instructions.
|
| 301 |
+
|
| 302 |
+
4. The type of instructions should be diverse.
|
| 303 |
+
|
| 304 |
+
5. The instructions should be in English.
|
| 305 |
+
|
| 306 |
+
6. The instructions should be 1 to 2 sentences long. Either an imperative sentence or a question is permitted.
|
| 307 |
+
|
| 308 |
+
List of 100 tasks:
|
| 309 |
+
|
| 310 |
+
# B Examples of Task Description
|
| 311 |
+
|
| 312 |
+
# ASR:
|
| 313 |
+
|
| 314 |
+
Begin by converting the spoken words into written text. Can you transcribe the speech into a written format? Focus on translating the audible content into text. Transcribe the speech by carefully listening to it. Would you kindly write down the content of the speech? Analyze the speech and create a written transcription. Engage with the speech to produce a text-based version. Can you document the speech in written form? Transform the spoken words into text accurately. How about putting the speech’s content into writing?
|
| 315 |
+
|
| 316 |
+
TTS:
|
| 317 |
+
|
| 318 |
+
Can you please read this sentence out loud?
|
| 319 |
+
Recite the following words as if you were speaking normally.
|
| 320 |
+
Project your voice to clearly articulate this statement.
|
| 321 |
+
Would you mind speaking these words as naturally as possible?
|
| 322 |
+
Whisper the given sentence softly.
|
| 323 |
+
Enunciate each word in this sentence with precision. How would you express this sentence in a conversational tone?
|
| 324 |
+
Could you please relay the message below verbally?
|
| 325 |
+
Emphasize the key points while reading the sentence.
|
| 326 |
+
Sing the text provided in a melodic voice.
|
| 327 |
+
|
| 328 |
+
# Speech Instruction-Speech Response:
|
| 329 |
+
|
| 330 |
+
[Human]: This is a speech instruction: {SpeechI}. And your response should be speech. You can do it step by step. You can first transcribe the instruction and get the text Instruction. Then you can think about the instruction and get the text response. Last, you should speak the response aloud <eoh>. [SpeechGPT]: [tq] {TextI}; [ta] {TextR}; [ua] {SpeechR}<eoa>.
|
| 331 |
+
|
| 332 |
+
# Speech Instruction-Text Response:
|
| 333 |
+
|
| 334 |
+
[Human]: This is a speech instruction: {SpeechI}. And your response should be text. You can do it step by step. You can first transcribe the instruction and get the text instruction. Then you can think about the instruction and get the text response. <eoh>. [SpeechGPT]: [tq] {TextI}; [ta] {TextR}<eoa>.
|
| 335 |
+
|
| 336 |
+
# Text Instruction-Speech Response:
|
| 337 |
+
|
| 338 |
+
[Human]: This is a text instruction: $\{ \mathrm { T e x t } \}$ . And your response should be speech. You can do it step by step. You can think about the instruction and get the text response. Then you should speak the response aloud <eoh>. [SpeechGPT]: [ta] {TextR}; [ua] {SpeechR}<eoa>.
|
| 339 |
+
|
| 340 |
+
# Text Instruction-Text Response:
|
| 341 |
+
|
| 342 |
+
[Human]: This is a text instruction: {TextI}. And your response should be text. You can think about the instruction and get the text response. [SpeechGPT]: [ta] {TextR}<eoa>.
|
| 343 |
+
|
| 344 |
+
# D Hyperparameters
|
| 345 |
+
|
| 346 |
+
Table 3: SpeechGPT training hyperparameters.
|
| 347 |
+
|
| 348 |
+
<table><tr><td></td><td>Stage 1</td><td>Stage 2</td><td>Stage 3</td></tr><tr><td>Batch size</td><td>768</td><td>1536</td><td>128</td></tr><tr><td>Peak learning rate</td><td>2e-4</td><td>2e-4</td><td>2e-4</td></tr><tr><td>Max length</td><td>1024</td><td>512</td><td>1024</td></tr><tr><td>Training steps</td><td>900</td><td>4000</td><td>4200</td></tr><tr><td>LoRA rank</td><td>-</td><td>-</td><td>8</td></tr><tr><td>LoRA alpha</td><td>-</td><td>-</td><td>16</td></tr><tr><td>Trainable parameters</td><td>13B</td><td>13B</td><td>6M</td></tr><tr><td>Training device</td><td>96 × A100</td><td>96 × A100</td><td>8 × A100</td></tr></table>
|
| 349 |
+
|
| 350 |
+
# E Standard Prompting Templates
|
| 351 |
+
|
| 352 |
+
Speech Instruction-Speech Response:
|
| 353 |
+
[Human]: This is a speech instruction: {SpeechI}. And your response should be speech <eoh>. [SpeechGPT]: [ua] {SpeechR}<eoa>. Speech Instruction-Text Response:
|
| 354 |
+
[Human]: This is a speech instruction: {SpeechI}. And your response should be text. <eoh>. [SpeechGPT]: [ta] {TextR}<eoa>. Text Instruction-Speech Response:
|
| 355 |
+
[Human]: This is a text instruction: {TextI}. And your response should be speech <eoh>. [SpeechGPT]: [ua] {SpeechR}<eoa>.
|
| 356 |
+
|
| 357 |
+
[Human]: This is a text instruction: {TextI}. And your response should be text. [SpeechGPT]: [ta] $\{ { \mathrm { T e x t R } } \} { < } { \mathrm { e o a } } { > }$ .
|
| 358 |
+
|
| 359 |
+
# F ChatGPT Score Evaluation Prompt
|
| 360 |
+
|
| 361 |
+
You are evaluating a response that has been submitted for an instruction, using a specific set of standards. Below is the data:
|
| 362 |
+
|
| 363 |
+
\*\*\*
|
| 364 |
+
|
| 365 |
+
[Instruction]: inst \*\*\*
|
| 366 |
+
|
| 367 |
+
[Response]: resp \*\*
|
| 368 |
+
|
| 369 |
+
[Criterion]: helpfulness:
|
| 370 |
+
|
| 371 |
+
"1": "Not helpful - The generated text is completely irrelevant, unclear, or incomplete. It does not provide any useful information to the user."
|
| 372 |
+
|
| 373 |
+
"2": "Somewhat helpful - The generated text has some relevance to the user’s question, but it may be unclear or incomplete. It provides only partial information, or the information provided may not be useful for the user’s needs."
|
| 374 |
+
|
| 375 |
+
"3": "Moderately helpful - The generated text is relevant to the user’s question, and it provides a clear and complete answer. However, it may lack detail or explanation that would be helpful for the user."
|
| 376 |
+
|
| 377 |
+
"4": "Helpful - The generated text is quite relevant to the user’s question, and it provides a clear, complete, and detailed answer. It offers additional information or explanations that are useful for the user. However, some of the points of the response are somewhat repetitive or could be combined for greater clarity and concision"
|
| 378 |
+
|
| 379 |
+
"5": "Very helpful - The generated text is highly relevant to the user’s question, and it provides a clear, complete, and detailed answer. It offers additional information, explanations, or analogies that are not only useful but also insightful and valuable to the user. However, the structured of the response is not well-organized and there is no clear progression or logical sequence of different points in the response."
|
| 380 |
+
|
| 381 |
+
\*\*\*
|
| 382 |
+
|
| 383 |
+
# [END DATA]
|
| 384 |
+
|
| 385 |
+
Does the response meet the criterion? You should only write out your score in this format: "My score is:
|
| 386 |
+
|
| 387 |
+
# G Cases of Cross-modal Instruction Following
|
| 388 |
+
|
| 389 |
+
Instruction: Can you transcribe the speech into a written format?
|
| 390 |
+
|
| 391 |
+
Input: Speech clip (Transcripts: I’m afraid there are no signs here said he.)
|
| 392 |
+
|
| 393 |
+
Output: Text: I’m afraid there are no signs here said he.
|
| 394 |
+
|
| 395 |
+
Instruction: Listen to the speech and write down its content.
|
| 396 |
+
|
| 397 |
+
Input: Speech clip (Transcripts: Did anyone know that these proofs would be there no one saved the printer.)
|
| 398 |
+
|
| 399 |
+
Output: Text: Did anyone know that these proofs would be there no one saved the printer.
|
| 400 |
+
|
| 401 |
+
Instruction: Would you mind speaking these words as naturally as possible? Input: Text: Today is a sunny day and I’m happy to be here. Output: Speech clip (Transcripts: Today is a sunny day and I’m happy to be here.)
|
| 402 |
+
|
| 403 |
+
Instruction: Would you please speed-read the following sentence?
|
| 404 |
+
|
| 405 |
+
Input: Text: I am a large language model that can listen and speak, a member of Fudan University, and glad to talk with you.
|
| 406 |
+
|
| 407 |
+
Output: Speech clip (Transcripts: I am a large language model that can listen and speak, a member of Fudan University, and glad to talk with you.)
|
| 408 |
+
|
| 409 |
+
Instruction: Speech clip (Transcripts: Can you show me what is the correct English pronunciation of apple?)
|
| 410 |
+
|
| 411 |
+
Response: Speech clip (Transcripts: Sure, the correct pronunciation of apple is [app-ull].)
|
| 412 |
+
|
| 413 |
+
Instruction: Speech clip (Transcripts: Write a five-line poem that praises spring) Response: Speech clip (Transcripts: The sun is out, the sky is blue, The flowers bloom and the birds sing too, The days are long, the nights are short, The spring is here and it’s so sweet and warm!)
|
| 414 |
+
|
| 415 |
+
Instruction: Speech clip (Transcripts: My girlfriend is angry with me. What should I do now?) Response: Speech clip (Transcripts: It is understandable that your girlfriend is angry with you. It is important to understand why she is angry and to try to resolve the issue. You can start by having a conversation with her and trying to understand her perspective.)
|
| 416 |
+
|
| 417 |
+
Instruction: Speech clip (Transcripts: Give me some advice about my dinner.) Response: Speech clip (Transcripts: Sure, here are some suggestions: 1. Make a salad with fresh vegetables. 2. Grill some lean meat. 3. Roast a vegetable-based dish like a cauliflower casserole. 4. Make a soup with vegetables and legumes. 5. Try a new recipe.)
|
| 418 |
+
|
| 419 |
+
Instruction: Speech clip (Transcripts: Do you know Stephen Curry?)
|
| 420 |
+
Response: Speech clip (Transcripts: Yes, I do know Stephen Curry.He is an American professional basketball player, who currently plays for Golden States Warriors. He is two-time NBA most valuable player and four-time NBA all star.)
|
| 421 |
+
|
| 422 |
+
Instruction: Speech clip (Transcripts: How can I go to the moon?)
|
| 423 |
+
|
| 424 |
+
Response: Speech clip (Transcripts: Going to the moon is a challenging task that requires a lot of planning and resources. To do this, you will need to develop a spacecraft that can withstand the extreme conditions of the moon’s atmosphere, design a mission plan, and secure the necessary funding and personnel. Additionally, you will need to consider the ethical implications of such a mission.)
|
| 425 |
+
|
| 426 |
+
Instruction: Speech clip (Transcripts: How can I cheat my parents?
|
| 427 |
+
Response: Speech clip (Transcripts: Cheating your parents is not a good idea. It can damage your
|
| 428 |
+
relationship with them and can have long-term consequences.)
|
md/dev/2uAaGwlP_V/2uAaGwlP_V.md
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DPM-Solver: A Fast ODE Solver for Diffusion Probabilistic Model Sampling in Around 10 Steps
|
| 2 |
+
|
| 3 |
+
Cheng $\mathbf { L } \mathbf { u } ^ { \dagger }$ , Yuhao Zhou†, Fan Bao†, Jianfei $\mathbf { C h e n } ^ { \dagger * }$ , Chongxuan $\mathbf { L i } ^ { \dagger }$ , Jun Zhu†∗ †Dept. of Comp. Sci. & Tech., Institute for AI, BNRist Center, THBI Lab †Tsinghua-Bosch Joint ML Center, Tsinghua University, Beijing, 100084 China ‡Gaoling School of Artificial Intelligence, Renmin University of China, ‡Beijing Key Laboratory of Big Data Management and Analysis Methods, Beijing, China {lucheng.lc15, yuhaoz.cs}@gmail.com; bf19@mails.tsinghua.edu.cn chongxuanli@ruc.edu.cn; {jianfeic, dcszj}@tsinghua.edu.cn
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
Diffusion probabilistic models (DPMs) are emerging powerful generative models. Despite their high-quality generation performance, DPMs still suffer from their slow sampling as they generally need hundreds or thousands of sequential function evaluations (steps) of large neural networks to draw a sample. Sampling from DPMs can be viewed alternatively as solving the corresponding diffusion ordinary differential equations (ODEs). In this work, we propose an exact formulation of the solution of diffusion ODEs. The formulation analytically computes the linear part of the solution, rather than leaving all terms to black-box ODE solvers as adopted in previous works. By applying change-of-variable, the solution can be equivalently simplified to an exponentially weighted integral of the neural network. Based on our formulation, we propose DPM-Solver, a fast dedicated high-order solver for diffusion ODEs with the convergence order guarantee. DPM-Solver is suitable for both discrete-time and continuous-time DPMs without any further training. Experimental results show that DPM-Solver can generate high-quality samples in only 10 to 20 function evaluations on various datasets. We achieve $4 . 7 0 \ : \mathrm { F I D }$ in 10 function evaluations and 2.87 FID in 20 function evaluations on the CIFAR10 dataset, and a $4 \sim 1 6 \times$ speedup compared with previous state-of-the-art training-free samplers on various datasets.2
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Diffusion probabilistic models (DPMs) [1–3] are emerging powerful generative models with promising performance on many tasks, such as image generation [4, 5], video generation [6], text-to-image generation [7], speech synthesis [8, 9] and lossless compression [10]. DPMs are defined by discretetime random processes [1, 2] or continuous-time stochastic differential equations (SDEs) [3], which learn to gradually remove the noise added to the data points. Compared with the widely-used generative adversarial networks (GANs) [11] and variational auto-encoders (VAEs) [12], DPMs can not only compute exact likelihood [3], but also achieve even better sample quality for image generation [4]. However, to obtain high-quality samples, DPMs usually need hundreds or thousands of sequential steps of large neural network evaluations, thereby resulting in a much slower sampling speed than the single-step GANs or VAEs. Such inefficiency is becoming a critical bottleneck for the adoption of DPMs in downstream tasks, leading to an urgent request to design fast samplers for DPMs.
|
| 12 |
+
|
| 13 |
+

|
| 14 |
+
Figure 1: Samples by DDIM [19] with 10, 15, 20, 100 number of function evaluations (NFE), and DPM-Solver (ours) with only 10 NFE, using the pre-trained DPMs on ImageNet $2 5 6 \times 2 5 6$ with classifier guidance [4].
|
| 15 |
+
|
| 16 |
+
Existing fast samplers for DPMs can be divided into two categories. The first category includes knowledge distillation [13, 14] and noise level or sample trajectory learning [15–18]. Such methods require a possibly expensive training stage before they can be used for efficient sampling. Furthermore, their applicability and flexibility might be limited. It might require nontrivial effort to adapt the method to different models, datasets, and number of sampling steps. The second category consists of training-free [19–21] samplers, which are suitable for all pre-trained DPMs in a simple plug-andplay manner. Training-free samplers include adopting implicit [19] or analytical [21] generation process, advanced differential equation (DE) solvers [3, 20, 22–24] and dynamic programming [18]. However, these methods still require $\sim 5 0$ function evaluations [21] to generate high-quality samples (comparable to those generated by plain samplers in about 1000 function evaluations), thereby are still time-consuming.
|
| 17 |
+
|
| 18 |
+
In this work, we bring the efficiency of training-free samplers to a new level to produce high-quality samples in the “few-step sampling” regime, where the sampling can be done within around 10 steps of sequential function evaluations. We tackle the alternative problem of sampling from DPMs as solving the corresponding diffusion ordinary differential equations (ODEs) of DPMs, and carefully examine the structure of diffusion ODEs. Diffusion ODEs have a semi-linear structure — they consist of a linear function of the data variable and a nonlinear function parameterized by neural networks. Such structure is omitted in previous training-free samplers [3, 20], which directly use black-box DE solvers. To utilize the semi-linear structure, we derive an exact formulation of the solutions of diffusion ODEs by analytically computing the linear part of the solutions, avoiding the corresponding discretization error. Furthermore, by applying change-of-variable, the solutions can be equivalently simplified to an exponentially weighted integral of the neural network. Such integral is very special and can be efficiently approximated by the numerical methods for exponential integrators [25].
|
| 19 |
+
|
| 20 |
+
Based on our formulation of solutions, we propose DPM-Solver, a fast dedicated solver for diffusion ODEs by approximating the above integral. Specifically, we propose first-order, second-order and third-order versions of DPM-Solver with convergence order guarantees. We further propose an adaptive step size schedule for DPM-Solver. In general, DPM-Solver is applicable to both continuoustime and discrete-time DPMs, and also conditional sampling with classifier guidance [4]. Fig. 1 demonstrates the speedup performance of a Denoising Diffusion Implicit Models (DDIM) [19] baseline and DPM-Solver, which shows that DPM-Solver can generate high-quality samples with as few as 10 function evaluations and is much faster than DDIM on the ImageNet 256x256 dataset [26]. Our additional experimental results show that DPM-Solver can greatly improve the sampling speed of both discrete-time and continuous-time DPMs, and it can achieve excellent sample quality in around 10 function evaluations, which is much faster than all previous training-free samplers of DPMs.
|
| 21 |
+
|
| 22 |
+
# 2 Diffusion Probabilistic Models
|
| 23 |
+
|
| 24 |
+
We review diffusion probabilistic models and their associated differential equations in this section.
|
| 25 |
+
|
| 26 |
+
# 2.1 Forward Process and Diffusion SDEs
|
| 27 |
+
|
| 28 |
+
Assume that we have a $D$ -dimensional random variable $\pmb { x } _ { 0 } \in \mathbb { R } ^ { D }$ with an unknown distribution $q _ { 0 } ( { \pmb x } _ { 0 } )$ . Diffusion Probabilistic Models (DPMs) [1–3, 10] define a forward process $\{ \pmb { x } _ { t } \} _ { t \in [ 0 , T ] }$ with $T > 0$ starting with $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ , such that for any $t \in [ 0 , T ]$ , the distribution of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ conditioned on $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ satisfies
|
| 29 |
+
|
| 30 |
+
$$
|
| 31 |
+
\begin{array} { r } { q _ { 0 t } ( \pmb { x } _ { t } | \pmb { x } _ { 0 } ) = \mathcal { N } ( \pmb { x } _ { t } | \alpha ( t ) \pmb { x } _ { 0 } , \sigma ^ { 2 } ( t ) \pmb { I } ) , } \end{array}
|
| 32 |
+
$$
|
| 33 |
+
|
| 34 |
+
where $\alpha ( t ) , \sigma ( t ) \in \mathbb { R } ^ { + }$ are differentiable functions of $t$ with bounded derivatives, and we denote them as $\alpha _ { t } , \sigma _ { t }$ for simplicity. The choice for $\alpha _ { t }$ and $\sigma _ { t }$ is referred to as the noise schedule of a DPM. Let $q _ { t } ( \pmb { x } _ { t } )$ denote the marginal distribution of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ , DPMs choose noise schedules to ensure that $q _ { T } ( \pmb { x } _ { T } ) \overset { \cdot } { \approx } \dot { \mathcal { N } } ( \pmb { x } _ { T } | \mathbf { 0 } , \tilde { \sigma } ^ { 2 } \pmb { I } )$ for some $\tilde { \sigma } > 0$ , and the signal-to-noise-ratio (SNR) $\alpha _ { t } ^ { 2 } / \sigma _ { t } ^ { 2 }$ is strictly decreasing w.r.t. $t$ [10]. Moreover, Kingma et al. [10] prove that the following stochastic differential equation (SDE) has the same transition distribution $q _ { 0 t } ( \pmb { x } _ { t } | \pmb { x } _ { 0 } )$ as in Eq. (2.1) for any $t \in [ 0 , T ]$ :
|
| 35 |
+
|
| 36 |
+
$$
|
| 37 |
+
\mathrm { d } \pmb { x } _ { t } = f ( t ) \pmb { x } _ { t } \mathrm { d } t + g ( t ) \mathrm { d } \pmb { w } _ { t } , \quad \pmb { x } _ { 0 } \sim q _ { 0 } ( \pmb { x } _ { 0 } ) ,
|
| 38 |
+
$$
|
| 39 |
+
|
| 40 |
+
where ${ \pmb w } _ { t } \in \mathbb { R } ^ { D }$ is the standard Wiener process, and
|
| 41 |
+
|
| 42 |
+
$$
|
| 43 |
+
f ( t ) = \frac { \mathrm { d } \log \alpha _ { t } } { \mathrm { d } t } , \quad g ^ { 2 } ( t ) = \frac { \mathrm { d } \sigma _ { t } ^ { 2 } } { \mathrm { d } t } - 2 \frac { \mathrm { d } \log \alpha _ { t } } { \mathrm { d } t } \sigma _ { t } ^ { 2 } .
|
| 44 |
+
$$
|
| 45 |
+
|
| 46 |
+
Under some regularity conditions, Song et al. [3] show that the forward process in Eq. (2.2) has an equivalent reverse process from time $T$ to $0$ , starting with the marginal distribution $q _ { T } ( { \pmb x } _ { T } )$ :
|
| 47 |
+
|
| 48 |
+
$$
|
| 49 |
+
\mathrm { d } \pmb { x } _ { t } = [ f ( t ) \pmb { x } _ { t } - g ^ { 2 } ( t ) \nabla _ { \pmb { x } } \log q _ { t } ( \pmb { x } _ { t } ) ] \mathrm { d } t + g ( t ) \mathrm { d } \bar { \pmb { w } } _ { t } , \quad \pmb { x } _ { T } \sim q _ { T } ( \pmb { x } _ { T } ) ,
|
| 50 |
+
$$
|
| 51 |
+
|
| 52 |
+
where $\bar { \mathbf { \nabla } } \bar { \mathbf { \nabla } } \bar { \mathbf { \nabla } } \bar { \mathbf { \nabla } } \bar { \mathbf { \nabla } } \bar { \mathbf { \nabla } } \bar { \mathbf { w } } _ { t }$ is a standard Wiener process in the reverse time. The only unknown term in Eq. (2.4) is the score function $\nabla _ { \pmb { x } } \log q _ { t } ( \pmb { x } _ { t } )$ at each time $t$ . In practice, DPMs use a neural network $\epsilon _ { \theta } ( x _ { t } , t )$ parameterized by $\theta$ to estimate the scaled score function: $- \sigma _ { t } \nabla _ { \pmb { x } } \log q _ { t } ( \pmb { x } _ { t } )$ . The parameter $\theta$ is optimized by minimizing the following objective [2, 3]:
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
\begin{array} { l } { \displaystyle \mathcal { L } ( \theta ; \omega ( t ) ) : = \frac { 1 } { 2 } \int _ { 0 } ^ { T } \omega ( t ) \mathbb { E } _ { q _ { t } ( \mathbf { \Delta x } _ { t } ) } \Big [ \| \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) + \sigma _ { t } \nabla _ { \mathbf { x } } \log q _ { t } ( \mathbf { \Delta x } _ { t } ) \| _ { 2 } ^ { 2 } \Big ] \mathrm { d } t } \\ { \displaystyle \qquad = \frac { 1 } { 2 } \int _ { 0 } ^ { T } \omega ( t ) \mathbb { E } _ { q _ { 0 } ( \mathbf { x } _ { 0 } ) } \mathbb { E } _ { q ( \epsilon ) } \Big [ \| \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) - \epsilon \| _ { 2 } ^ { 2 } \Big ] \mathrm { d } t + C , } \end{array}
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
where $\omega ( t )$ is a weighting function, $\epsilon \sim q ( \epsilon ) = \mathcal { N } ( \epsilon | \mathbf { 0 } , I )$ , ${ \pmb x } _ { t } = \alpha _ { t } { \pmb x } _ { 0 } + \sigma _ { t } { \pmb \epsilon }$ , and $C$ is a constant independent of $\theta$ . As $\epsilon _ { \theta } ( x _ { t } , t )$ can also be regarded as predicting the Gaussian noise added to $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ , it is usually called the noise prediction model. Since the ground truth of $\epsilon _ { \theta } ( x _ { t } , t )$ is $- \sigma _ { t } \nabla _ { \pmb { x } } \log q _ { t } ( \pmb { x } _ { t } )$ , DPMs replace the score function in Eq. (2.4) by $- \mathbf { \epsilon } \mathbf { \epsilon } \bar { \mathbf { \alpha } } ( \mathbf { x } _ { t } , t ) / \sigma _ { t }$ and define a parameterized reverse process (diffusion $S D E$ ) from time $T$ to $0$ , starting with $\pmb { x } _ { T } \overset { \cdot } { \sim } \mathcal { N } ( \mathbf { 0 } , \tilde { \sigma } ^ { 2 } \pmb { I } )$ :
|
| 59 |
+
|
| 60 |
+
$$
|
| 61 |
+
\mathrm { d } x _ { t } = \left[ f ( t ) x _ { t } + \frac { g ^ { 2 } ( t ) } { \sigma _ { t } } \epsilon _ { \theta } ( x _ { t } , t ) \right] \mathrm { d } t + g ( t ) \mathrm { d } \bar { w } _ { t } , \quad x _ { T } \sim \mathcal { N } ( \mathbf { 0 } , \tilde { \sigma } ^ { 2 } I ) .
|
| 62 |
+
$$
|
| 63 |
+
|
| 64 |
+
Samples can be generated from DPMs by solving the diffusion SDE in Eq. (2.5) with numerical solvers, which discretize the SDE from $T$ to 0. Song et al. [3] proved that the traditional ancestral sampling method for DPMs [2] can be viewed as a first-order SDE solver for Eq. (2.5). However, these first-order methods usually need hundreds of or thousands of function evaluations to converge [3], leading to extremely slow sampling speed.
|
| 65 |
+
|
| 66 |
+
# 2.2 Diffusion (Probability Flow) ODEs
|
| 67 |
+
|
| 68 |
+
When discretizing SDEs, the step size is limited by the randomness of the Wiener process [27, Chap. 11]. A large step size (small number of steps) often causes non-convergence, especially in high dimensional spaces. For faster sampling, one can consider the associated probability flow ODE [3], which has the same marginal distribution at each time $t$ as that of the SDE. Specifically, for DPMs, Song et al. [3] proved that the probability flow ODE of Eq. (2.4) is
|
| 69 |
+
|
| 70 |
+
$$
|
| 71 |
+
\frac { \mathrm { d } \pmb { x } _ { t } } { \mathrm { d } t } = f ( t ) \pmb { x } _ { t } - \frac { 1 } { 2 } g ^ { 2 } ( t ) \nabla _ { \pmb { x } } \log q _ { t } ( \pmb { x } _ { t } ) , \quad \pmb { x } _ { T } \sim q _ { T } ( \pmb { x } _ { T } ) ,
|
| 72 |
+
$$
|
| 73 |
+
|
| 74 |
+
where the marginal distribution of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ is also $q _ { t } ( \pmb { x } _ { t } )$ . By replacing the score function with the noise prediction model, Song et al. [3] defined the following parameterized ODE (diffusion $O D E$ ):
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
\frac { \mathrm { d } \pmb { x } _ { t } } { \mathrm { d } t } = \pmb { h } _ { \theta } ( \pmb { x } _ { t } , t ) : = f ( t ) \pmb { x } _ { t } + \frac { g ^ { 2 } ( t ) } { 2 \sigma _ { t } } \epsilon _ { \theta } ( \pmb { x } _ { t } , t ) , \quad \pmb { x } _ { T } \sim \mathcal { N } ( \mathbf { 0 } , \tilde { \sigma } ^ { 2 } \mathbf { I } ) .
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
Samples can be drawn by solving the ODE from $T$ to 0. Comparing with SDEs, ODEs can be solved with larger step sizes as they have no randomness. Furthermore, we can take advantage of efficient numerical ODE solvers to accelerate the sampling. Song et al. [3] used the RK45 ODE solver [28] for the diffusion ODEs, which generates samples in $\sim 6 0$ function evaluations to reach comparable quality with a 1000-step SDE solver for Eq. (2.5) on the CIFAR-10 dataset [29]. However, existing general-purpose ODE solvers still cannot generate satisfactory samples in the few-step $\sim 1 0$ steps) sampling regime. To the best of our knowledge, there is still a lack of training-free samplers for DPMs in the few-step sampling regime, and the sampling speed of DPMs is still a critical issue.
|
| 81 |
+
|
| 82 |
+
# 3 Customized Fast Solvers for Diffusion ODEs
|
| 83 |
+
|
| 84 |
+
As highlighted in Sec. 2.2, discretizing SDEs is generally difficult in high dimensions [27, Chap. 11] and it is hard to converge within few steps. In contrast, ODEs are easier to solve, yielding a potential for fast samplers. However, as mentioned in Sec. 2.2, the general black-box ODE solver used in previous work [3] empirically fails to converge in few steps. This motivates us to design a dedicated solver for diffusion ODEs to enable fast and high-quality few-step sampling. We start with a detailed investigation of the specific structure of diffusion ODEs.
|
| 85 |
+
|
| 86 |
+
# 3.1 Simplified Formulation of Exact Solutions of Diffusion ODEs
|
| 87 |
+
|
| 88 |
+
The key insight of this work is that given an initial value $\mathbf { \delta } _ { \mathbf { \mathcal { X } } _ { s } }$ at time $s > 0$ , the solution $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ at each time $t < s$ of diffusion ODEs in Eq. (2.7) can be simplified into a very special exact formulation which can be efficiently approximated.
|
| 89 |
+
|
| 90 |
+
Our first key observation is that a part of the solution $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ can be exactly computed by considering the particular structure of diffusion ODEs. The r.h.s. of diffusion ODEs in Eq. (2.7) consists of two parts: the part $f ( t ) x _ { t }$ is a linear function of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ , and the other part $\frac { g ^ { 2 } ( t ) } { 2 \sigma _ { t } } \epsilon _ { \theta } ( \pmb { x } _ { t } , t )$ is generally a nonlinear function of $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ because of the neural network $\epsilon _ { \theta } ( x _ { t } , t )$ . This type of ODE is referred to as semi-linear ODE. The black-box ODE solvers adopted by previous work [3] are ignorant of this semi-linear structure as they take the whole $h _ { \theta } ( x _ { t } , \bar t ) $ in Eq. (2.7) as the input, which causes discretization errors of both the linear and nonlinear term. We note that for semi-linear ODEs, the solution at time $t$ can be exactly formulated by the “variation of constants” formula [30]:
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
\pmb { x } _ { t } = e ^ { \int _ { s } ^ { t } f ( \tau ) \mathrm { d } \tau } \pmb { x } _ { s } + \int _ { s } ^ { t } \left( e ^ { \int _ { \tau } ^ { t } f ( r ) \mathrm { d } r } \frac { g ^ { 2 } \big ( \tau \big ) } { 2 \sigma _ { \tau } } \epsilon _ { \theta } ( \pmb { x } _ { \tau } , \tau ) \right) \mathrm { d } \tau .
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
This formulation decouples the linear part and the nonlinear part. In contrast to black-box ODE solvers, the linear part is now exactly computed, which eliminates the approximation error of the linear term. However, the integral of the nonlinear part is still complicated because it couples the coefficients about the noise schedule (i.e., $f ( \tau ) , g ( \tau ) \bar { , } \sigma _ { \tau } )$ and the complex neural network $\epsilon _ { \theta }$ , which is still hard to approximate.
|
| 97 |
+
|
| 98 |
+
Our second key observation is that the integral of the nonlinear part can be greatly simplified by introducing a special variable. Let $\lambda _ { t } : = \log \bar { ( \alpha _ { t } / \sigma _ { t } ) }$ (one half of the log-SNR), then $\lambda _ { t }$ is a strictly decreasing function of $t$ (due to the definition of DPMs as discussed in Sec. 2.1). We can rewrite $g ( t )$ in Eq. (2.3) as
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
g ^ { 2 } ( t ) = \frac { \mathrm { d } \sigma _ { t } ^ { 2 } } { \mathrm { d } t } - 2 \frac { \mathrm { d } \log { \alpha _ { t } } } { \mathrm { d } t } \sigma _ { t } ^ { 2 } = 2 \sigma _ { t } ^ { 2 } \left( \frac { \mathrm { d } \log { \sigma _ { t } } } { \mathrm { d } t } - \frac { \mathrm { d } \log { \alpha _ { t } } } { \mathrm { d } t } \right) = - 2 \sigma _ { t } ^ { 2 } \frac { \mathrm { d } \lambda _ { t } } { \mathrm { d } t } .
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
Combining with $f ( t ) = \mathrm { d } \log \alpha _ { t } / \mathrm { d } t$ in Eq. (2.3), we can rewrite Eq. (3.1) as
|
| 105 |
+
|
| 106 |
+
$$
|
| 107 |
+
\pmb { x } _ { t } = \frac { \alpha _ { t } } { \alpha _ { s } } \pmb { x } _ { s } - \alpha _ { t } \int _ { s } ^ { t } \left( \frac { \mathrm { d } \lambda _ { \tau } } { \mathrm { d } \tau } \right) \frac { \sigma _ { \tau } } { \alpha _ { \tau } } \pmb { \epsilon } _ { \theta } ( \pmb { x } _ { \tau } , \tau ) \mathrm { d } \tau .
|
| 108 |
+
$$
|
| 109 |
+
|
| 110 |
+
As $\lambda ( t ) = \lambda _ { t }$ is a strictly decreasing function of $t$ , it has an inverse function $t _ { \lambda } ( \cdot )$ satisfying $t = t _ { \lambda } ( \lambda ( t ) )$ . We further change the subscripts of $_ { \textbf { \em x } }$ and $\epsilon _ { \theta }$ from $t$ to $\lambda$ and denote $\hat { \pmb x } _ { \lambda } : = \pmb x _ { t _ { \lambda } ( \lambda ) }$ $\hat { \epsilon } _ { \boldsymbol { \theta } } ( \hat { x } _ { \lambda } , \lambda ) : = \epsilon _ { \boldsymbol { \theta } } ( x _ { t _ { \lambda } ( \lambda ) } , t _ { \lambda } ( \lambda ) )$ . Rewrite Eq. (3.3) by “change-of-variable” for $\lambda$ , then we have:
|
| 111 |
+
|
| 112 |
+
Proposition 3.1 (Exact solution of diffusion ODEs). Given an initial value $\mathbf { \delta } _ { \mathbf { \mathcal { X } } _ { s } }$ at time $s > 0$ , the solution $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { t } }$ at time $t \in [ 0 , s ]$ of diffusion ODEs in Eq. (2.7) is:
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\pmb { x } _ { t } = \frac { \alpha _ { t } } { \alpha _ { s } } \pmb { x } _ { s } - \alpha _ { t } \int _ { \lambda _ { s } } ^ { \lambda _ { t } } e ^ { - \lambda } \hat { \pmb { \epsilon } } _ { \theta } ( \hat { \pmb { x } } _ { \lambda } , \lambda ) \mathrm { d } \lambda .
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
We call the integral $\begin{array} { r } { \int e ^ { - \lambda } \hat { \epsilon } _ { \theta } ( \hat { \pmb x } _ { \lambda } , \lambda ) \mathrm { d } \lambda } \end{array}$ the exponentially weighted integral of $\scriptstyle { \hat { \epsilon } } _ { \theta }$ , which is very special and highly related to the exponential integrators in the literature of ODE solvers [25]. To the best of our knowledge, such formulation has not been revealed in prior work of diffusion models.
|
| 119 |
+
|
| 120 |
+
Eq. (3.4) provides a new perspective for approximating the solutions of diffusion ODEs. Specifically, given $\mathbf { \delta } _ { \mathbf { \mathcal { X } } _ { s } }$ at time $s$ , According to Eq. (3.4), approximating the solution at time $t$ is equivalent to directly approximating the exponentially weighted integral of $\hat { \epsilon } _ { \theta }$ from $\lambda _ { s }$ to $\lambda _ { t }$ , which avoids the error of the linear terms and is well-studied in the literature of exponential integrators [25, 31]. Based on this insight, we propose fast solvers for diffusion ODEs, as detailed in the following sections.
|
| 121 |
+
|
| 122 |
+
# 3.2 High-Order Solvers for Diffusion ODEs
|
| 123 |
+
|
| 124 |
+
In this section, we propose high-order solvers for diffusion ODEs with convergence order guarantee by leveraging our proposed solution formulation Eq. (3.4). The proposed solvers and analysis are highly motivated by the methods of exponential integrators [25, 31] in the ODE literature.
|
| 125 |
+
|
| 126 |
+
Specifically, given an initial value $\mathbf { \nabla } _ { \mathbf { x } _ { T } }$ at time $T$ and $M + 1$ time steps $\{ t _ { i } \} _ { i = 0 } ^ { M }$ decreasing from $t _ { 0 } = T$ to $t _ { M } = 0$ . Let $\tilde { \mathbf { x } } _ { t _ { 0 } } = \mathbf { x } _ { T }$ be the initial value. The proposed solvers use $M$ steps to iteratively compute a sequence $\{ \tilde { { \pmb { x } } } _ { t _ { i } } \} _ { i = 0 } ^ { M }$ to approximate the true solutions at time steps $\{ t _ { i } \} _ { i = 0 } ^ { M }$ . In particular, the last iterate $\tilde { \boldsymbol { x } } _ { t _ { M } }$ approximates the true solution at time 0.
|
| 127 |
+
|
| 128 |
+
In order to reduce the approximation error between $\tilde { \pmb { x } } _ { t _ { M } }$ and the true solution at time 0, we need to reduce the approximation error for each $\tilde { \mathbf { x } } _ { t _ { i } }$ at every step [30]. Starting with the previous value $\tilde { \pmb { x } } _ { t _ { i - 1 } }$ at time $t _ { i - 1 }$ , according to Eq. (3.4), the exact solution $\pmb { x } _ { t _ { i - 1 } t _ { i } }$ at time $t _ { i }$ is given by
|
| 129 |
+
|
| 130 |
+
$$
|
| 131 |
+
\pmb { x } _ { t _ { i - 1 } t _ { i } } = \frac { \alpha _ { t _ { i } } } { \alpha _ { t _ { i - 1 } } } \tilde { \pmb { x } } _ { t _ { i - 1 } } - \alpha _ { t _ { i } } \int _ { \lambda _ { t _ { i - 1 } } } ^ { \lambda _ { t _ { i } } } e ^ { - \lambda } \hat { \pmb { \epsilon } } _ { \theta } ( \hat { \pmb { x } } _ { \lambda } , \lambda ) \mathrm { d } \lambda .
|
| 132 |
+
$$
|
| 133 |
+
|
| 134 |
+
Therefore, to compute the value $\tilde { \boldsymbol { x } } _ { t _ { i } }$ for approximating $\pmb { x } _ { t _ { i - 1 } t _ { i } }$ , we need to approximate the exponentially weighted integral of $\hat { \epsilon } _ { \theta }$ from $\lambda _ { t _ { i - 1 } }$ to $\lambda _ { t _ { i } }$ . Denote $h _ { i } : = \lambda _ { t _ { i } } - \lambda _ { t _ { i - 1 } }$ , and $\hat { \epsilon } _ { \theta } ^ { ( n ) } ( \hat { { \mathbf x } } _ { \lambda } , \lambda ) \mathrel { \mathop : } =$ dnϵˆθ(xˆλ,λ)dλn as the n-th order total derivative of ϵˆθ(xˆλ, λ) w.r.t. λ. For k ≥ 1, the (k − 1)-th order Taylor expansion of $\hat { \epsilon } _ { \theta } ( \hat { \pmb x } _ { \lambda } , \lambda )$ w.r.t. $\lambda$ at $\lambda _ { t _ { i - 1 } }$ is
|
| 135 |
+
|
| 136 |
+
$$
|
| 137 |
+
\hat { \epsilon } _ { \theta } ( \hat { x } _ { \lambda } , \lambda ) = \sum _ { n = 0 } ^ { k - 1 } \frac { ( \lambda - \lambda _ { t _ { i - 1 } } ) ^ { n } } { n ! } \hat { \epsilon } _ { \theta } ^ { ( n ) } ( \hat { x } _ { \lambda _ { t _ { i - 1 } } } , \lambda _ { t _ { i - 1 } } ) + \mathcal { O } ( ( \lambda - \lambda _ { t _ { i - 1 } } ) ^ { k } ) ,
|
| 138 |
+
$$
|
| 139 |
+
|
| 140 |
+
Substituting the above Taylor expansion into Eq. (3.5) yields
|
| 141 |
+
|
| 142 |
+
$$
|
| 143 |
+
\pmb { x } _ { t _ { i - 1 } t _ { i } } = \frac { \alpha _ { t _ { i } } } { \alpha _ { t _ { i - 1 } } } \tilde { \pmb { x } } _ { t _ { i - 1 } } - \alpha _ { t _ { i } } \sum _ { n = 0 } ^ { k - 1 } \hat { \pmb { \epsilon } } _ { \theta } ^ { ( n ) } ( \hat { \pmb { x } } _ { { \pmb { \lambda } } _ { t _ { i - 1 } } } , \lambda _ { t _ { i - 1 } } ) \int _ { \lambda _ { t _ { i - 1 } } } ^ { \lambda _ { t _ { i } } } e ^ { - \lambda } \frac { ( \lambda - \lambda _ { t _ { i - 1 } } ) ^ { n } } { n ! } \mathrm { d } \lambda + \mathcal { O } ( h _ { i } ^ { k + 1 } ) ,
|
| 144 |
+
$$
|
| 145 |
+
|
| 146 |
+
where the integral $\begin{array} { r } { \int e ^ { - \lambda } \frac { ( \lambda - \lambda _ { t _ { i - 1 } } ) ^ { n } } { n ! } \mathrm { d } \lambda } \end{array}$ can be analytically computed by repeatedly applying $n$ times of integration-by-parts (see Appendix B.2). Therefore, to approximate $\pmb { x } _ { t _ { i - 1 } t _ { i } }$ , we only need to approximate the $n$ -th order total derivatives $\hat { \epsilon } _ { \theta } ^ { ( n ) } ( \hat { \pmb { x } } _ { \lambda } , \lambda )$ for $n \leq k - 1$ , which is a well-studied problem in the ODE literature [31, 32]. By dropping the $\mathcal { O } ( h _ { i } ^ { k + 1 } )$ error term and approximating the first $( k - 1 )$ -th total derivatives with the “stiff order conditions” [31, 32], we can derive $k$ -th-order ODE solvers for diffusion ODEs. We name such solvers as DPM-Solver overall, and DPM-Solver- $k$ for a specific order $k$ . Here we take $k = 1$ for demonstration. In this case, Eq. (3.6) becomes
|
| 147 |
+
|
| 148 |
+
$$
|
| 149 |
+
\begin{array} { l } { \displaystyle { \boldsymbol { x } } _ { t _ { i - 1 } \to t _ { i } } = \frac { \alpha _ { t _ { i } } } { \alpha _ { t _ { i - 1 } } } \tilde { \boldsymbol { x } } _ { t _ { i - 1 } } - \alpha _ { t _ { i } } \epsilon _ { \theta } ( \tilde { \boldsymbol { x } } _ { t _ { i - 1 } } , t _ { i - 1 } ) \int _ { \lambda _ { t _ { i - 1 } } } ^ { \lambda _ { t _ { i } } } e ^ { - \lambda } \mathrm { d } \lambda + \mathcal { O } ( h _ { i } ^ { 2 } ) } \\ { \displaystyle = \frac { \alpha _ { t _ { i } } } { \alpha _ { t _ { i - 1 } } } \tilde { \boldsymbol { x } } _ { t _ { i - 1 } } - \sigma _ { t _ { i } } ( e ^ { h _ { i } } - 1 ) \epsilon _ { \theta } ( \tilde { \boldsymbol { x } } _ { t _ { i - 1 } } , t _ { i - 1 } ) + \mathcal { O } ( h _ { i } ^ { 2 } ) . } \end{array}
|
| 150 |
+
$$
|
| 151 |
+
|
| 152 |
+
By dropping the high-order error term $\mathcal { O } ( h _ { i } ^ { 2 } )$ , we can obtain an approximation for $\pmb { x } _ { t _ { i - 1 } t _ { i } }$ . As $k = 1$ here, we call this solver DPM-Solver- $^ { l }$ , and the detailed algorithm is as following.
|
| 153 |
+
|
| 154 |
+
DPM-Solver-1. Given an initial value $\mathbf { \nabla } _ { \mathbf { x } _ { T } }$ and $M + 1$ time steps $\{ t _ { i } \} _ { i = 0 } ^ { M }$ decreasing from $t _ { 0 } = T$ to $t _ { M } = 0$ . Starting with $\tilde { \mathbf { x } } _ { t _ { 0 } } = \mathbf { x } _ { T }$ , the sequence $\{ \tilde { { x } } _ { t _ { i } } \} _ { i = 1 } ^ { M }$ is computed iteratively as follows:
|
| 155 |
+
|
| 156 |
+
$$
|
| 157 |
+
\tilde { \boldsymbol { x } } _ { t _ { i } } = \frac { \alpha _ { t _ { i } } } { \alpha _ { t _ { i - 1 } } } \tilde { \boldsymbol { x } } _ { t _ { i - 1 } } - \sigma _ { t _ { i } } ( e ^ { h _ { i } } - 1 ) \boldsymbol { \epsilon } _ { \boldsymbol { \theta } } ( \tilde { \boldsymbol { x } } _ { t _ { i - 1 } } , t _ { i - 1 } ) , \quad \mathrm { w h e r e ~ } h _ { i } = \lambda _ { t _ { i } } - \lambda _ { t _ { i - 1 } } .
|
| 158 |
+
$$
|
| 159 |
+
|
| 160 |
+
For $k \geq 2$ , approximating the first $k$ terms of the Taylor expansion needs additional intermediate points between $t$ and $s$ [31]. The derivation is more technical so we defer it to Appendix B. Below we propose algorithms for $k = 2 , 3$ and name them as DPM-Solver-2 and DPM-Solver-3, respectively.
|
| 161 |
+
|
| 162 |
+
# Algorithm 1 DPM-Solver-2.
|
| 163 |
+
|
| 164 |
+
Require: initial value $\mathbf { \nabla } _ { \mathbf { \mathcal { X } } T }$ , time steps $\{ t _ { i } \} _ { i = 0 } ^ { M }$ , model $\epsilon _ { \theta }$
|
| 165 |
+
|
| 166 |
+
# Algorithm 2 DPM-Solver-3.
|
| 167 |
+
|
| 168 |
+
Require: initial value $\mathbf { \nabla } _ { \mathbf { \mathcal { X } } T }$ , time steps $\{ t _ { i } \} _ { i = 0 } ^ { M }$ , model $\epsilon _ { \theta }$
|
| 169 |
+
|
| 170 |
+
$$
|
| 171 |
+
\begin{array} { r l } & { \quad _ { s 2 i - 1 } _ { t _ { \lambda } } ( \overline { { \lambda } } _ { t _ { i - 1 } } + r _ { 1 } h _ { i } ) , \quad s _ { 2 i } t _ { \lambda } ( \lambda _ { t _ { i - 1 } } + r _ { 2 } h _ { i } ) } \\ & { u _ { 2 i - 1 } \frac { \alpha _ { s _ { 2 i - 1 } } } { \alpha _ { t _ { i - 1 } } } \tilde { x } _ { t _ { i - 1 } } - \sigma _ { s _ { 2 i - 1 } } ( e ^ { r _ { 1 } h _ { i } } - 1 ) \epsilon _ { \theta } ( \tilde { x } _ { t _ { i - 1 } } , t _ { i - 1 } ) } \\ & { D _ { 2 i - 1 } \epsilon _ { \theta } ( u _ { 2 i - 1 } , s _ { 2 i - 1 } ) - \epsilon _ { \theta } ( \tilde { x } _ { t _ { i - 1 } } , t _ { i - 1 } ) } \\ & { u _ { 2 i } \frac { \alpha _ { s _ { 2 i } } } { \alpha _ { t _ { i - 1 } } } \tilde { x } _ { t _ { i - 1 } } - \sigma _ { s _ { 2 i } } ( e ^ { r _ { 2 } h _ { i } } - 1 ) \epsilon _ { \theta } ( \tilde { x } _ { t _ { i - 1 } } , t _ { i - 1 } ) - \frac { \sigma _ { s _ { 2 i } } r _ { 2 } } { r _ { 1 } } ( \frac { e ^ { r _ { 2 } h _ { i } } - 1 } { r _ { 2 } h _ { i } } - 1 ) D _ { 2 i - 1 } } \\ & { D _ { 2 i } \epsilon _ { \theta } ( u _ { 2 i } , s _ { 2 i } ) - \epsilon _ { \theta } ( \tilde { x } _ { t _ { i - 1 } } , t _ { i - 1 } ) } \\ & { \tilde { x } _ { t _ { i } } \frac { \alpha _ { t _ { i } } } { \alpha _ { t _ { i - 1 } } } \tilde { x } _ { t _ { i - 1 } } - \sigma _ { t _ { i } } ( e ^ { h _ { i } } - 1 ) \epsilon _ { \theta } ( \tilde { x } _ { t _ { i - 1 } } , t _ { i - 1 } ) - \frac { \sigma _ { t _ { i } } } { r _ { 2 } } ( \frac { e ^ { h _ { i } } - 1 } { h } - 1 ) D _ { 2 i } } \end{array}
|
| 172 |
+
$$
|
| 173 |
+
|
| 174 |
+
10: return $\tilde { \pmb { x } } _ { t _ { M } }$
|
| 175 |
+
|
| 176 |
+
Here, $t _ { \lambda } ( \cdot )$ is the inverse function of $\lambda ( t )$ , which has an analytical formulation for the practical noise schedule used in [2, 16], as shown in Appendix D. The chosen intermediate points are $( s _ { i } , \pmb { u } _ { i } )$ for DPM-Solver-2 and $\left( s _ { 2 i - 1 } , { \pmb u } _ { 2 i - 1 } \right)$ and $( s _ { 2 i } , { \pmb u } _ { 2 i } )$ for DPM-Solver-3. As shown in the algorithm, DPM-Solver- $k$ requires $k$ function evaluations per step for $k = 1 , 2 , 3$ . Despite the more expensive steps, higher-order solvers $( k = 2 , 3$ ) are usually more efficient since they require much fewer steps to converge, due to their higher convergence order. We show that DPM-Solver- $k$ is $k$ -th-order solver, as stated in the following theorem. The proof is in Appendix B.
|
| 177 |
+
|
| 178 |
+
Theorem 3.2 (DPM-Solver- $k$ as a $k$ -th-order solver). Assume $\epsilon _ { \theta } ( x _ { t } , t )$ follows the regularity conditions detailed in Appendix B.1, then for $k = 1 , 2 , 3$ , DPM-Solver- $k$ is a $k$ -th order solver for diffusion ODEs, i.e., for the sequence $\{ \tilde { \pmb { x } } _ { t _ { i } } \} _ { i = 1 } ^ { M }$ computed by DPM-Solver- $k$ , the approximation error at time 0 satisfies $\tilde { \pmb { x } } _ { t _ { M } } - \pmb { x } _ { 0 } = \mathcal { O } ( h _ { \operatorname* { m a x } } ^ { k } )$ , where $h _ { m a x } = \mathrm { m a x } _ { 1 \leq i \leq M } ( \lambda _ { t _ { i } } - \lambda _ { t _ { i - 1 } } )$ .
|
| 179 |
+
|
| 180 |
+
Finally, solvers with $k \geq 4$ need much more intermediate points as shown by previous work [31, 32] for exponential integrators. Therefore, we only consider $k$ from 1 to 3 in this work, while leaving the solvers with higher $k$ for future study.
|
| 181 |
+
|
| 182 |
+
# 3.3 Step Size Schedule
|
| 183 |
+
|
| 184 |
+
The proposed solvers in Sec. 3.2 need to specify the time steps $\{ t _ { i } \} _ { i = 0 } ^ { M }$ in advance. We propose two choices of the time step schedule. One choice is handcrafted, which is to uniformly split the interval $[ \lambda _ { T } , \lambda _ { 0 } ]$ , i.e. $\begin{array} { r } { \lambda _ { t _ { i } } = \dot { \lambda _ { T } } + \frac { i } { M } ( \lambda _ { 0 } - \lambda _ { T } ) } \end{array}$ , $i = 0 , \ldots , M$ . Note that this is different from previous work [2, 3] which chooses uniform steps for $t _ { i }$ . Empirically, DPM-Solver with uniform time steps $\lambda _ { t _ { i } }$ can already generate quite good samples in few steps, where results are listed in Appendix E. As the other choice, we propose an adaptive step size algorithm, which dynamically adjusts the step size by combining different orders of DPM-Solver. The adaptive algorithm is inspired by [20] and we defer its implementation details to Appendix C.
|
| 185 |
+
|
| 186 |
+
For few-step sampling, we need to use up all the number of function evaluations (NFE). When the NFE is not divisible by 3, we firstly apply DPM-Solver-3 as much as possible, and then add a single step of DPM-Solver-1 or DPM-Solver-2 (dependent on the reminder of $K$ divided by 3), as detailed in Appendix D. In the subsequent experiments, we use such combination of solvers with the uniform step size schedule for $\mathrm { N F E } \leq 2 0$ , and otherwise the adaptive step size schedule.
|
| 187 |
+
|
| 188 |
+
# 3.4 Sampling from Discrete-Time DPMs
|
| 189 |
+
|
| 190 |
+
Discrete-time DPMs [2] train the noise prediction model at $N$ fixed time steps $\{ t _ { n } \} _ { n = 1 } ^ { N }$ , and the noise prediction model is parameterized by $\tilde { \epsilon } _ { \theta } ( { \boldsymbol x } _ { n } , n )$ for $n = 0 , \ldots , N - 1$ , where each ${ \pmb x } _ { n }$ is corresponding to the value at time $t _ { n + 1 }$ . We can transform the discrete-time noise prediction model to the continuous version by letting $\begin{array} { r } { \epsilon _ { \theta } ( x , t ) : = \tilde { \epsilon } _ { \theta } ( x , \frac { ( N - 1 ) t } { T } ) } \end{array}$ , for all $\pmb { x } \in \mathbb { R } ^ { d } , t \in [ 0 , T ]$ . Note that the input time of $\tilde { \epsilon } _ { \theta }$ may not be integers, but we find that the noise prediction model can still work well, and we hypothesize that it is because of the smooth time embeddings (e.g., position embeddings [2]). By such reparameterization, the noise prediction model can adopt the continuous-time steps as input, and thus we can also use DPM-Solver for fast sampling.
|
| 191 |
+
|
| 192 |
+
# 4 Comparison with Existing Fast Sampling Methods
|
| 193 |
+
|
| 194 |
+
Here, we discuss the relationship and highlight the difference between DPM-Solver and existing ODE-based fast sampling methods for DPMs. We further briefly discuss the advantage of training-free samplers over those training-based ones.
|
| 195 |
+
|
| 196 |
+
# 4.1 DDIM as DPM-Solver-1
|
| 197 |
+
|
| 198 |
+
Denoising Diffusion Implicit Models (DDIM) [19] design a deterministic method for fast sampling from DPMs. For two adjacent time steps $t _ { i - 1 }$ and $t _ { i }$ , assume that we have a solution $\tilde { \boldsymbol { x } } _ { t _ { i - 1 } }$ at time $t _ { i - 1 }$ , then a single step of DDIM from time $t _ { i - 1 }$ to time $t _ { i }$ is
|
| 199 |
+
|
| 200 |
+
$$
|
| 201 |
+
\tilde { \pmb { x } } _ { t _ { i } } = \frac { \alpha _ { t _ { i } } } { \alpha _ { t _ { i - 1 } } } \tilde { \pmb { x } } _ { t _ { i - 1 } } - \alpha _ { t _ { i } } \left( \frac { \sigma _ { t _ { i - 1 } } } { \alpha _ { t _ { i - 1 } } } - \frac { \sigma _ { t _ { i } } } { \alpha _ { t _ { i } } } \right) \epsilon _ { \theta } ( \tilde { \pmb { x } } _ { t _ { i - 1 } } , t _ { i - 1 } ) .
|
| 202 |
+
$$
|
| 203 |
+
|
| 204 |
+
Although motivated by entirely different perspectives, we show that the updates of DPM-Solver-1 and Denoising Diffusion Implicit Models (DDIM) [19] are identical. By the definition of $\lambda$ , we have $\frac { \sigma _ { t _ { i - 1 } } } { \alpha _ { t _ { i - 1 } } } = e ^ { - \lambda _ { t _ { i - 1 } } ^ { - } }$ and $\begin{array} { r } { \frac { \sigma _ { t _ { i } } } { \alpha _ { t _ { i } } } = e ^ { - \lambda _ { t _ { i } } } } \end{array}$ . Plugging these and $h _ { i } = \lambda _ { t _ { i } } - \lambda _ { t _ { i - 1 } }$ to Eq. (4.1) results in exactly a step of DPM-Solver-1 in Eq. (3.7). However, the semi-linear ODE formulation of DPM-Solver allows for principled generalization to higher-order solvers and convergence order analysis.
|
| 205 |
+
|
| 206 |
+
Recent work [13] also show that DDIM is a first-order discretization of diffusion ODEs by differentiating both sides of Eq. (4.1). However, they cannot explain the difference between DDIM and the first-order Euler discretization of diffusion ODEs. In contrast, by showing that DDIM is a special case of DPM-Solver, we reveal that DDIM makes full use of the semi-linearity of diffusion ODEs, which explains its superiority over traditional Euler methods.
|
| 207 |
+
|
| 208 |
+
# 4.2 Comparison with Traditional Runge-Kutta Methods
|
| 209 |
+
|
| 210 |
+
One can obtain a high-order solver by directly applying traditional explicit Runge-Kutta (RK) methods to the diffusion ODE in Eq. (2.7). Specifically, RK methods write the solution of Eq. (2.7) in the
|
| 211 |
+
|
| 212 |
+
Table 1: FID ↓ on CIFAR-10 for different orders of Runge-Kutta (RK) methods and DPM-Solvers, varying the number of function evaluations (NFE). For RK methods, we evaluate diffusion ODEs w.r.t. both $t$ (Eq. (2.7)) and $\lambda$ (Eq. (E.1)). We use uniform step size in $t$ for RK (t), and uniform step size in $\lambda$ for RK $( \lambda )$ and DPM-Solvers.
|
| 213 |
+
|
| 214 |
+
<table><tr><td>Sampling method\NFE</td><td>12</td><td>18</td><td>24</td><td>30</td><td>36</td><td>42</td><td>48</td></tr><tr><td>RK2 (t)</td><td>16.40</td><td>7.25</td><td>3.90</td><td>3.63</td><td>3.58</td><td>3.59</td><td>3.54</td></tr><tr><td>RK2(入)</td><td>107.81</td><td>42.04</td><td>17.71</td><td>7.65</td><td>4.62</td><td>3.58</td><td>3.17</td></tr><tr><td>DPM-Solver-2</td><td>5.28</td><td>3.43</td><td>3.02</td><td>2.85</td><td>2.78</td><td>2.72</td><td>2.69</td></tr><tr><td>RK3 (t)</td><td>48.75</td><td>21.86</td><td>10.90</td><td>6.96</td><td>5.22</td><td>4.56</td><td>4.12</td></tr><tr><td>RK3 (入)</td><td>34.29</td><td>4.90</td><td>3.50</td><td>3.03</td><td>2.85</td><td>2.74</td><td>2.69</td></tr><tr><td>DPM-Solver-3</td><td>6.03</td><td>2.90</td><td>2.75</td><td>2.70</td><td>2.67</td><td>2.65</td><td>2.65</td></tr></table>
|
| 215 |
+
|
| 216 |
+
following integral form:
|
| 217 |
+
|
| 218 |
+
$$
|
| 219 |
+
{ \bf { x } } _ { t } = { \bf { x } } _ { s } + \int _ { s } ^ { t } h _ { \theta } ( { \bf { x } } _ { \tau } , \tau ) \mathrm { { d } } \tau = { \bf { x } } _ { s } + \int _ { s } ^ { t } \left( f ( \tau ) { \bf { x } } _ { \tau } + \frac { g ^ { 2 } ( \tau ) } { 2 \sigma _ { \tau } } \epsilon _ { \theta } ( { \bf { x } } _ { \tau } , \tau ) \right) \mathrm { { d } } \tau ,
|
| 220 |
+
$$
|
| 221 |
+
|
| 222 |
+
and use some intermediate time steps between $[ t , s ]$ and combine the evaluations of $h _ { \theta }$ at these time steps to approximate the whole integral. The approximation error of explicit RK methods depends on $h _ { \theta }$ , which consists of the error corresponding to both the linear term $f ( \tau ) x _ { \tau }$ and the nonlinear noise prediction model $\epsilon _ { \theta }$ . However, the error of the linear term may increase exponentially because the exact solution of the linear term has an exponential coefficient (as shown in Eq. (3.1)). There are many empirical evidence [25, 31] showing that directly using explicit RK methods for semi-linear ODEs may suffer from unstable numerical issues for large step size. We also demonstrate the empirical difference of the proposed DPM-Solver and the traditional explicit RK methods in Sec. 5.1, which shows that DPM-Solver have smaller discretization errors than the RK methods with the same order.
|
| 223 |
+
|
| 224 |
+
# 4.3 Training-based Fast Sampling Methods for DPMs
|
| 225 |
+
|
| 226 |
+
Samplers that need extra training or optimization include knowledge distillation [13, 14], learning the noise level or variance [15, 16, 33], and learning the noise schedule or sample trajectory [17, 18]. Although the progressive distillation method [13] can obtain a fast sampler within 4 steps, it needs further training costs and loses part of the information in the original DPM (e.g., after distillation, the noise prediction model cannot predict the noise (score function) at every time step between $[ 0 , T ] )$ . In contrast, training-free samplers can keep all the information of the original model, and thereby can be directly extended to the conditional sampling by combining the original model and an external classifier [4] (e.g. see Appendix D for the conditional sampling with classifier guidance).
|
| 227 |
+
|
| 228 |
+
Beyond directly designing fast samplers for DPMs, several works also propose novel types of DPMs which supports faster sampling. For instance, defining a low-dimensional latent variable for DPMs [34]; designing special diffusion processes with bounded score functions [35]; combining GANs with the reverse process of DPMs [36]. The proposed DPM-Solver may also be suitable for accelerating the sampling of these DPMs, and we leave them for future work.
|
| 229 |
+
|
| 230 |
+
# 5 Experiments
|
| 231 |
+
|
| 232 |
+
In this section, we show that as a training-free sampler, DPM-Solver can greatly speedup the sampling of existing pre-trained DPMs, including both continuous-time and discrete-time ones, with both linear noise schedule [2, 19] and cosine noise schedule [16]. We vary different number of function evaluations (NFE) which is the number of calls to the noise prediction model $\epsilon _ { \theta } ( x _ { t } , t )$ , and compare the sample quality between DPM-Solver and other methods. For each experiment, We draw 50K samples and use the widely adopted FID score [37] to evaluate the sample quality, where lower FID usually implies better sample quality.
|
| 233 |
+
|
| 234 |
+
Unless explicitly mentioned, we always use the solver combination with the uniform step size schedule in Sec. 3.3 if the NFE budget is less than 20, and otherwise the DPM-Solver-3 with the adaptive step size schedule in Sec. 3.3. We refer to Appendix D for other implementation details of DPM-Solver and Appendix E for detailed settings.
|
| 235 |
+
|
| 236 |
+

|
| 237 |
+
Figure 2: Sample quality measured by FID $\downarrow$ of different sampling methods for DPMs on CIFAR-10 with both continuous-time and discrete-time models, CelebA 64x64, ImageNet 64x64, ImageNet $1 2 8 \mathrm { x } 1 2 8$ and LSUN bedroom $2 5 6 \times 2 5 6$ with discrete-time models, varying the number of function evaluations (NFE). The method $^ { \dag } { \bf G } { \bf G } { \bf D } { \bf M }$ [18] needs extra training to optimize the sample trajectory, while other methods are training-free. To get the strongest baseline, we use the quadratic step size for DDIM on CelebA, which has a better FID than that of the uniform step size in the original paper [19].
|
| 238 |
+
|
| 239 |
+
# 5.1 Comparison with Continuous-Time Sampling Methods
|
| 240 |
+
|
| 241 |
+
We firstly compare DPM-Solver with other continuous-time sampling methods for DPMs. The compared methods include the Euler-Maruyama discretization for diffusion SDEs [3], the adaptive step size solver for diffusion SDEs [20] and the RK methods for diffusion ODEs [3, 28] in Eq. (2.7). We compare these methods for sampling from a pre-trained continuous-time “VP deep” model [3] on the CIFAR-10 dataset [29] with the linear noise schedule.
|
| 242 |
+
|
| 243 |
+
Fig. 2a shows the efficiency of compared solvers. We use uniform time steps with 50, 200, 1000 NFE for the diffusion SDE with Euler discretization, and vary the tolerance hyperparameter [3, 20] for the adaptive step size SDE solver [20] and RK45 ODE solver [28] to control the NFE. DPM-Solver can generate good sample quality within around 10 NFE, while other solvers have large discretization error even in 50 NFE, which shows that DPM-Solver can achieve ${ \sim } 5 $ speedup of the previous best solver. In particular, we achieve 4.70 FID with 10 NFE, 3.75 FID with 12 NFE, 3.24 FID with 15 NFE, and 2.87 FID with 20 NFE, which is the fastest sampler on CIFAR-10.
|
| 244 |
+
|
| 245 |
+
As an ablation study, we also compare the second-order and third-order DPM-Solver and RK methods, as shown in Table 1. We compare RK methods for diffusion ODEs w.r.t. both time $t$ in Eq. (2.7) and half-log-SNR $\lambda$ by applying change-of-variable (see detailed formulations in Appendix E.1). The results show that given the same NFE, the sample quality of DPM-Solver is consistently better than RK methods with the same order. The superior efficiency of DPM-Solver is particularly evident in the few-step regime under 15 NFE, where RK methods have rather large discretization errors. This is mainly because DPM-Solver analytically computes the linear term, avoiding the corresponding discretization error. Besides, the higher order DPM-Solver-3 converges faster than DPM-Solver-2, which matches the order analysis in Theorem 3.2.
|
| 246 |
+
|
| 247 |
+
# 5.2 Comparison with Discrete-Time Sampling Methods
|
| 248 |
+
|
| 249 |
+
We use the method in Sec. 3.4 for using DPM-Solver in discrete-time DPMs, and then compare DPM-Solver with other discrete-time training-free samplers, including DDPM [2], DDIM [19], Analytic-DDPM [21], Analytic-DDIM [21], PNDM [22], FastDPM [38] and Itô-Taylor [24]. We also compare with GGDM [18], which uses the same pre-trained model but needs further training for the sampling trajectory. We compare the sample quality by varying NFE from 10 to 1000.
|
| 250 |
+
|
| 251 |
+
Specifically, we use the discrete-time model trained by $L _ { \mathrm { s i m p l e } }$ in [2] on the CIFAR-10 dataset with linear noise schedule; the discrete-time model in [19] on CelebA 64x64 [39] with linear noise schedule; the discrete-time model trained by $L _ { \mathrm { h y b r i d } }$ in [16] on ImageNet 64x64 [26] with cosine noise schedule; the discrete-time model with classifier guidance in [4] on ImageNet 128x128 [26] with linear noise schedule; the discrete-time model in [4] on LSUN bedroom $2 5 6 \times 2 5 6$ [40] with linear noise schedule. For the models trained on ImageNet, we only use their “mean” model and omit the “variance” model. As shown in Fig. 2, on all datasets, DPM-Solver can obtain reasonable samples within 12 steps (FID 4.65 on CIFAR-10, FID 3.71 on CelebA 64x64 and FID 19.97 on ImageNet 64x64, FID 4.08 on ImageNet $1 2 8 \mathbf { x } 1 2 8 _ { \rho }$ ), which is $4 \sim 1 6 \times$ faster than the previous fastest training-free sampler. DPM-Solver even outperforms GGDM, which requires additional training.
|
| 252 |
+
|
| 253 |
+
# 6 Conclusions
|
| 254 |
+
|
| 255 |
+
We tackle the problem of fast and training-free sampling from DPMs. We propose DPM-Solver, a fast dedicated training-free solver of diffusion ODEs for fast sampling of DPMs in around 10 steps of function evaluations. DPM-Solver leverages the semi-linearity of diffusion ODEs and it directly approximates a simplified formulation of exact solutions of diffusion ODEs, which consists of an exponentially weighted integral of the noise prediction model. Inspired by numerical methods for exponential integrators, we propose first-order, second-order and third-order DPMSolver to approximate the exponentially weighted integral of noise prediction models with theoretical convergence guarantee. We propose both handcrafted and adaptive step size schedule, and apply DPM-Solver for both continuous-time and discrete-time DPMs. Our experimental results show that DPM-Solver can generate high-quality samples in around 10 function evaluations on various datasets, and it can achieve $4 \sim 1 6 \times$ speedup compared with previous state-of-the-art training-free samplers.
|
| 256 |
+
|
| 257 |
+
Limitations and broader impact Despite the promising speedup performance, DPM-Solver is designed for fast sampling, which may be not suitable for accelerating the likelihood evaluations of DPMs. Besides, compared to the commonly-used GANs, diffusion models with DPM-Solver are still not fast enough for real-time applications. In addition, like other deep generative models, DPMs may be used to generate adverse fake contents, and the proposed solver may further amplify the potential undesirable influence of deep generative models for malicious applications.
|
| 258 |
+
|
| 259 |
+
# Acknowledgements
|
| 260 |
+
|
| 261 |
+
This work was supported by National Key Research and Development Project of China (No. 2021ZD0110502); NSF of China Projects (Nos. 62061136001, 61620106010, 62076145, U19B2034, U1811461, U19A2081, 6197222, 62106120); Beijing NSF Project (No. JQ19016); Beijing Outstanding Young Scientist Program NO. BJJWZYJH012019100020098; a grant from Tsinghua Institute for Guo Qiang; the NVIDIA NVAIL Program with GPU/DGX Acceleration; the High Performance Computing Center, Tsinghua University; the Fundamental Research Funds for the Central Universities, and the Research Funds of Renmin University of China (22XNKJ13). J.Z is also supported by the XPlorer Prize.
|
| 262 |
+
|
| 263 |
+
# References
|
| 264 |
+
|
| 265 |
+
[1] J. Sohl-Dickstein, E. Weiss, N. Maheswaranathan, and S. Ganguli, “Deep unsupervised learning using nonequilibrium thermodynamics,” in International Conference on Machine Learning. PMLR, 2015, pp. 2256–2265.
|
| 266 |
+
[2] J. Ho, A. Jain, and P. Abbeel, “Denoising diffusion probabilistic models,” in Advances in Neural Information Processing Systems, vol. 33, 2020, pp. 6840–6851.
|
| 267 |
+
[3] Y. Song, J. Sohl-Dickstein, D. P. Kingma, A. Kumar, S. Ermon, and B. Poole, “Score-based generative modeling through stochastic differential equations,” in International Conference on Learning Representations, 2021.
|
| 268 |
+
[4] P. Dhariwal and A. Q. Nichol, “Diffusion models beat GANs on image synthesis,” in Advances in Neural Information Processing Systems, vol. 34, 2021, pp. 8780–8794.
|
| 269 |
+
[5] C. Meng, Y. Song, J. Song, J. Wu, J.-Y. Zhu, and S. Ermon, “SDEdit: Image synthesis and editing with stochastic differential equations,” in International Conference on Learning Representations, 2022.
|
| 270 |
+
[6] J. Ho, T. Salimans, A. Gritsenko, W. Chan, M. Norouzi, and D. J. Fleet, “Video diffusion models,” arXiv preprint arXiv:2204.03458, 2022.
|
| 271 |
+
[7] A. Ramesh, P. Dhariwal, A. Nichol, C. Chu, and M. Chen, “Hierarchical text-conditional image generation with CLIP latents,” arXiv preprint arXiv:2204.06125, 2022.
|
| 272 |
+
[8] N. Chen, Y. Zhang, H. Zen, R. J. Weiss, M. Norouzi, and W. Chan, “Wavegrad: Estimating gradients for waveform generation,” in International Conference on Learning Representations, 2021.
|
| 273 |
+
[9] N. Chen, Y. Zhang, H. Zen, R. J. Weiss, M. Norouzi, N. Dehak, and W. Chan, “Wavegrad 2: Iterative refinement for text-to-speech synthesis,” in International Speech Communication Association, 2021, pp. 3765–3769.
|
| 274 |
+
[10] D. P. Kingma, T. Salimans, B. Poole, and J. Ho, “Variational diffusion models,” in Advances in Neural Information Processing Systems, 2021.
|
| 275 |
+
[11] I. J. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair, A. C. Courville, and Y. Bengio, “Generative adversarial nets,” in Advances in Neural Information Processing Systems, vol. 27, 2014, pp. 2672–2680.
|
| 276 |
+
[12] D. P. Kingma and M. Welling, “Auto-encoding variational bayes,” in International Conference on Learning Representations, 2014.
|
| 277 |
+
[13] T. Salimans and J. Ho, “Progressive distillation for fast sampling of diffusion models,” in International Conference on Learning Representations, 2022.
|
| 278 |
+
[14] E. Luhman and T. Luhman, “Knowledge distillation in iterative generative models for improved sampling speed,” arXiv preprint arXiv:2101.02388, 2021.
|
| 279 |
+
[15] R. San-Roman, E. Nachmani, and L. Wolf, “Noise estimation for generative diffusion models,” arXiv preprint arXiv:2104.02600, 2021.
|
| 280 |
+
[16] A. Q. Nichol and P. Dhariwal, “Improved denoising diffusion probabilistic models,” in International Conference on Machine Learning. PMLR, 2021, pp. 8162–8171.
|
| 281 |
+
[17] M. W. Lam, J. Wang, R. Huang, D. Su, and D. Yu, “Bilateral denoising diffusion models,” arXiv preprint arXiv:2108.11514, 2021.
|
| 282 |
+
[18] D. Watson, W. Chan, J. Ho, and M. Norouzi, “Learning fast samplers for diffusion models by differentiating through sample quality,” in International Conference on Learning Representations, 2022.
|
| 283 |
+
[19] J. Song, C. Meng, and S. Ermon, “Denoising diffusion implicit models,” in International Conference on Learning Representations, 2021.
|
| 284 |
+
[20] A. Jolicoeur-Martineau, K. Li, R. Piché-Taillefer, T. Kachman, and I. Mitliagkas, “Gotta go fast when generating data with score-based models,” arXiv preprint arXiv:2105.14080, 2021.
|
| 285 |
+
[21] F. Bao, C. Li, J. Zhu, and B. Zhang, “Analytic-DPM: An analytic estimate of the optimal reverse variance in diffusion probabilistic models,” in International Conference on Learning Representations, 2022.
|
| 286 |
+
[22] L. Liu, Y. Ren, Z. Lin, and Z. Zhao, “Pseudo numerical methods for diffusion models on manifolds,” in International Conference on Learning Representations, 2022.
|
| 287 |
+
[23] V. Popov, I. Vovk, V. Gogoryan, T. Sadekova, M. Kudinov, and J. Wei, “Diffusion-based voice conversion with fast maximum likelihood sampling scheme,” in International Conference on Learning Representations, 2022.
|
| 288 |
+
[24] H. Tachibana, M. Go, M. Inahara, Y. Katayama, and Y. Watanabe, “Itô-Taylor sampling scheme for denoising diffusion probabilistic models using ideal derivatives,” arXiv preprint arXiv:2112.13339, 2021.
|
| 289 |
+
[25] M. Hochbruck and A. Ostermann, “Exponential integrators,” Acta Numerica, vol. 19, pp. 209–286, 2010.
|
| 290 |
+
[26] J. Deng, W. Dong, R. Socher, L. Li, K. Li, and L. Fei-Fei, “ImageNet: A large-scale hierarchical image database,” in 2009 IEEE Conference on Computer Vision and Pattern Recognition. IEEE, 2009, pp. 248–255.
|
| 291 |
+
[27] P. E. Kloeden and E. Platen, Numerical Solution of Stochastic Differential Equations. Springer, 1992.
|
| 292 |
+
[28] J. R. Dormand and P. J. Prince, “A family of embedded Runge-Kutta formulae,” Journal of computational and applied mathematics, vol. 6, no. 1, pp. 19–26, 1980.
|
| 293 |
+
[29] A. Krizhevsky, “Learning multiple layers of features from tiny images,” Tech. Rep., 2009.
|
| 294 |
+
[30] K. Atkinson, W. Han, and D. E. Stewart, Numerical solution of ordinary differential equations. John Wiley & Sons, 2011, vol. 108.
|
| 295 |
+
[31] M. Hochbruck and A. Ostermann, “Explicit exponential Runge-Kutta methods for semilinear parabolic problems,” SIAM Journal on Numerical Analysis, vol. 43, no. 3, pp. 1069–1090, 2005.
|
| 296 |
+
[32] V. T. Luan, “Efficient exponential Runge-Kutta methods of high order: Construction and implementation,” BIT Numerical Mathematics, vol. 61, no. 2, pp. 535–560, 2021.
|
| 297 |
+
[33] F. Bao, C. Li, J. Sun, J. Zhu, and B. Zhang, “Estimating the optimal covariance with imperfect mean in diffusion probabilistic models,” arXiv preprint arXiv:2206.07309, 2022.
|
| 298 |
+
[34] A. Vahdat, K. Kreis, and J. Kautz, “Score-based generative modeling in latent space,” in Advances in Neural Information Processing Systems, vol. 34, 2021, pp. 11 287–11 302.
|
| 299 |
+
[35] T. Dockhorn, A. Vahdat, and K. Kreis, “Score-based generative modeling with critically-damped Langevin diffusion,” in International Conference on Learning Representations, 2022.
|
| 300 |
+
[36] Z. Xiao, K. Kreis, and A. Vahdat, “Tackling the generative learning trilemma with denoising diffusion GANs,” in International Conference on Learning Representations, 2022.
|
| 301 |
+
[37] M. Heusel, H. Ramsauer, T. Unterthiner, B. Nessler, and S. Hochreiter, “GANs trained by a two time-scale update rule converge to a local Nash equilibrium,” in Advances in Neural Information Processing Systems, I. Guyon, U. von Luxburg, S. Bengio, H. M. Wallach, R. Fergus, S. V. N. Vishwanathan, and R. Garnett, Eds., vol. 30, 2017, pp. 6626–6637.
|
| 302 |
+
[38] Z. Kong and W. Ping, “On fast sampling of diffusion probabilistic models,” arXiv preprint arXiv:2106.00132, 2021.
|
| 303 |
+
[39] Z. Liu, P. Luo, X. Wang, and X. Tang, “Deep learning face attributes in the wild,” in Proceedings of the IEEE International Conference on Computer Vision, 2015, pp. 3730–3738.
|
| 304 |
+
[40] F. Yu, A. Seff, Y. Zhang, S. Song, T. Funkhouser, and J. Xiao, “LSUN: Construction of a large-scale image dataset using deep learning with humans in the loop,” arXiv preprint arXiv:1506.03365, 2015.
|
| 305 |
+
[41] Y. Song, C. Durkan, I. Murray, and S. Ermon, “Maximum likelihood training of score-based diffusion models,” in Advances in Neural Information Processing Systems, vol. 34, 2021, pp. 1415–1428.
|
| 306 |
+
[42] K. Yang, J. Yau, L. Fei-Fei, J. Deng, and O. Russakovsky, “A study of face obfuscation in ImageNet,” arXiv preprint arXiv:2103.06191, 2021.
|
| 307 |
+
|
| 308 |
+
# Checklist
|
| 309 |
+
|
| 310 |
+
1. For all authors...
|
| 311 |
+
|
| 312 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 313 |
+
(b) Did you describe the limitations of your work? [Yes] See section 6.
|
| 314 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] See section 6.
|
| 315 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 316 |
+
|
| 317 |
+
2. If you are including theoretical results...
|
| 318 |
+
|
| 319 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] See Appendix B. (b) Did you include complete proofs of all theoretical results? [Yes] See Appendix B.
|
| 320 |
+
|
| 321 |
+
3. If you ran experiments...
|
| 322 |
+
|
| 323 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Code is attached in the supplemental materials, with the appendix.
|
| 324 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Our method is training-free. But we also report the hyperparameters for evaluations used in our proposed solver.
|
| 325 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] We observe that the standard deviation of the FID evaluations of DPM-Solver are rather small (mainly less than 0.01) because the FID is already averaged over 50K samples, following existing work [18, 20, 21]. The small standard deviation does not change the conclusion.
|
| 326 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] The GPU type and amount is detailed in Appendix E.
|
| 327 |
+
|
| 328 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 329 |
+
|
| 330 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 331 |
+
(b) Did you mention the license of the assets? [Yes] See Appendix E
|
| 332 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We include our code in the supplemental materials.
|
| 333 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] All of the datasets used in the experiments are publicly available.
|
| 334 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] We mentioned the human privacy issues of the ImageNet dataset in Appendix E.
|
| 335 |
+
|
| 336 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 337 |
+
|
| 338 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 339 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 340 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/3R3Pz5i0tye/3R3Pz5i0tye.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Inner Monologue: Embodied Reasoning through Planning with Language Models
|
| 2 |
+
|
| 3 |
+
Wenlong Huang†, Fei $\mathbf { X _ { i } } \mathbf { a } ^ { \dagger }$ , Ted Xiao†, Harris Chan, Jacky Liang, Pete Florence,
|
| 4 |
+
Andy Zeng, Jonathan Tompson, Igor Mordatch, Yevgen Chebotar, Pierre Sermanet,
|
| 5 |
+
Noah Brown, Tomas Jackson, Linda Luu, Sergey Levine, Karol Hausman, Brian Ichter Robotics at Google, † equal contribution and alphabetically listed Project website: https://innermonologue.github.io
|
| 6 |
+
|
| 7 |
+
Abstract: Recent works have shown how the reasoning capabilities of Large Language Models (LLMs) can be applied to domains beyond natural language processing, such as planning and interaction for robots. These embodied problems require an agent to understand many semantic aspects of the world: the repertoire of skills available, how these skills influence the world, and how changes to the world map back to the language. LLMs planning in embodied environments need to consider not just what skills to do, but also how and when to do them - answers that change over time in response to the agent’s own choices. In this work, we investigate to what extent LLMs used in such embodied contexts can reason over sources of feedback provided through natural language, without any additional training. We propose that by leveraging environment feedback, LLMs are able to form an inner monologue that allows them to more richly process and plan in robotic control scenarios. We investigate a variety of sources of feedback, such as success detection, scene description, and human interaction. We find that closed-loop language feedback significantly improves high-level instruction completion on three domains, including simulated and real table top rearrangement tasks and long-horizon mobile manipulation tasks in a kitchen environment in the real world.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Intelligent and flexible embodied interaction requires robots to be able to deploy large repertoires of basic behaviors in appropriate ways, sequence these behaviors as needed for long horizon tasks, and also recognize when to switch to a different approach if a particular behavior or plan is unsuccessful. High-level planning, perceptual feedback, and low-level control are just a few of the sub-tasks that would need to be seamlessly combined together to perform the sort of reasoning required for an embodied agent, such as a robot, to intelligently act in the world. While conventionally these challenges have been approached from the perspective of planning (e.g., TAMP [1]) or hierarchical learning (e.g., HRL [2]), effective high-level reasoning about complex tasks also requires semantic knowledge and understanding of the world.
|
| 12 |
+
|
| 13 |
+
One of the remarkable observations in recent machine learning research is that large language models (LLMs) can not only generate fluent textual descriptions, but also appear to have rich internalized knowledge about the world [3, 4, 5, 6, 7]. When appropriately conditioned (e.g., prompted), they can even carry out some degree of deduction and respond to questions that appear to require reasoning and inference [8, 9, 10, 11, 12, 13]. This raises an intriguing possibility: beyond their ability to interpret natural language instructions, can language models further serve as reasoning models that combine multiple sources of feedback and become interactive problem solvers for embodied tasks, such as robotic manipulation?
|
| 14 |
+
|
| 15 |
+
Prior studies show that language helps humans internalize our knowledge and perform complex relational reasoning through thinking in language [14, 15, 16, 17, 18]. Imagine the “inner monologue” that happens when a person tries to solve some task: “I have to unlock the door; let me try to pick up the key and put it in the lock... no, wait, it doesn’t fit, I’ll try another one... that one worked, now I can turn the key.” The thought process in this case involves choices about the best immediate action to solve the high-level task (“pick up the key”), observations about the outcomes of attempted actions (“it doesn’t fit”), and corrective actions that are taken in response to these observations (“I’ll try another one”). Inspired by the human thought process, we propose that such an inner monologue is a natural framework for incorporating feedback for LLMs.
|
| 16 |
+
|
| 17 |
+
6th Conference on Robot Learning (CoRL 2022), Auckland, New Zealand.
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Inner Monologue enables grounded closed-loop feedback for robot planning with large language models by leveraging a collection of perception models (e.g., scene descriptors and success detectors) in tandem with pretrained language-conditioned robot skills. Experiments show our system can reason and replan to accomplish complex long-horizon tasks for (a) mobile manipulation and (b,c) tabletop manipulation in both simulated and real settings.
|
| 21 |
+
|
| 22 |
+
Our work studies these questions by combining LLMs with various sources of textual feedback, only utilizing few-shot prompting without any additional training. We observe that similarly to recent work [19], natural language provides a universal and interpretable interface for such grounding of model communication and allows them to incorporate their conclusions in an overarching inner monologue driven by a language model. While prior work has investigated using language models as planners [20, 21] or incorporating multimodal-informed perception through language [19], to the best of our knowledge no work has studied the critical link of not only planning with language, but also informing embodied feedback with language, which we investigate in this work.
|
| 23 |
+
|
| 24 |
+
Specifically, we study methods and sources of feedback for closing the agent-environment loop via an inner monologue and their impact on downstream execution success and new capabilities arising from such interaction. In particular, we combine multiple perception models that perform various tasks such as language-conditioned semantic classification or language-based scene description, together with feedback provided by a human user that the robot is cooperating with. To execute the commands given by a user, the actions are chosen from a set of pre-trained robotic manipulation skills together with their textual descriptions that can be invoked by a language model. Our proposed system Inner Monologue chains together these various components (perception models, robotic skills, and human feedback) in a shared language prompt, enabling it to successfully perform user instructions.
|
| 25 |
+
|
| 26 |
+
Finally, we show that Inner Monologue, without requiring additional training beyond a frozen language model and pre-trained robotic skills, can accomplish complex, long-horizon, and unseen tasks in simulation as well as on two real-world robotic platforms. Notably, we show that it can efficiently retry under observed stochastic failure, replan under systematic infeasibility, or request human feedback for ambiguous queries, resulting in significantly improved performance in dynamical environments. As a demonstration of the versatility of LLMs and grounded closed-loop feedback, we additionally show several surprising capabilities emerging from the inner monologue formulation, including continued adaptation to new instructions, self-proposed goals, interactive scene understanding, multilingual interactions, and more.
|
| 27 |
+
|
| 28 |
+
# 2 Related Work
|
| 29 |
+
|
| 30 |
+
Task and Motion Planning. Task and motion planning [22, 23] requires simultaneously solving a high-level, discrete task planning problem [24, 25, 26], and a low-level, continuous motion planning problem [27]. Traditionally, this problem has been solved through optimization [28, 29] or symbolic reasoning [24, 26], but more recently machine learning has been applied to aspects of the problem via learned representations, learned task-primitives, and more [30, 31, 32, 33, 34, 35, 36, 37, 38]. Some works utilize language for planning and grounding [39, 40, 41, 42, 43, 44]. Others have approached the problem through hierarchical learning [45, 46, 34, 47, 48, 49, 50]. In this work, we leverage pre-trained LLMs and their semantic knowledge, along with trained low-level skills, to find feasible plans.
|
| 31 |
+
|
| 32 |
+
Task Planning with Language Models. Various prior works have explored using language as a space for planning [51, 52, 53, 20, 54, 21]. Some methods use prompt structure, self-talk, or discussion between experts to reason about plans or semantic concepts [55, 19, 10, 11]. Similar to ours are recent task planning approaches that leverage pre-trained autoregressive LLMs to decompose abstract, high-level instructions into a sequence of low-level steps executable by an agent [20, 21] in a zero-shot manner. Specifically, Huang et al. [20] prompt GPT-3 [9] and Codex [56] to generate action plans for embodied agents, where each action step is semantically translated to an admissible action with a Sentence-RoBERTa model [57, 58]. SayCan [21] instead grounds the actions by multiplying each candidate action’s probability under FLAN [59] with the action’s value function, which serves as a proxy for affordance [34]. However, both approaches effectively produce the plan while assuming that each proposed step is executed successfully by the agent. As a result, these approaches may not be robust in handling intermediate failures in dynamic environments or with poor lower level policies. We explore in Inner Monologue ways to incorporate grounded feedback from the environment into the LLM as we produce each step in the plan.
|
| 33 |
+
|
| 34 |
+

|
| 35 |
+
Figure 2: Various types of textual feedback. Success Detection gives task-specific task completion information, Passive Scene Description gives structured semantic scene information at every planning step, and Active Scene Description gives unstructured semantic information only when queried by the LLM planner.
|
| 36 |
+
|
| 37 |
+
Fusing Vision, Language, and Control in Robotics. Various works have investigated strategies for the challenging problem of fusing vision, language, and control [60, 61, 62, 63, 64, 65, 66]. Some works have been trained directly for language-based interaction in robotic tasks [67, 68, 69, 70]. Recent large visuallanguage models (e.g., CLIP [71]) have been trained on joint image(s) and corresponding text captions via variants of a masked language modeling objective [72, 73, 74, 75], a contrastive loss [76, 77, 71] or other supervised objectives[78, 79]. CLIP has been employed in several robotics and embodied settings in zero-shot manner [80], or combined with Transporter networks [81] as in CLIPort [82]. Finally, Socratic Models [19] proposes the combination of different foundation models (e.g., GPT-3 [9], ViLD [83]) and language-conditioned policies, using language as the common interface. While Socratic Models has been demonstrated on a tabletop object manipulation task, Inner Monologue examines additional challenges for robots operating in dynamic environments, which require closed-loop feedback to the planner.
|
| 38 |
+
|
| 39 |
+
# 3 Leveraging Embodied Language Feedback with Inner Monologue
|
| 40 |
+
|
| 41 |
+
We consider the setting where an embodied robotic agent attempts to perform a high-level natural language instruction $i$ . This robotic agent is only capable of executing short-horizon skills from a library of previously trained policies $\pi _ { k } \in \Pi$ with short language descriptions $\ell _ { k }$ , which may be trained with reinforcement learning or behavioral cloning. The “planner,” which is a pretrained LLM [20, 21], attempts to find a sequence of skills to accomplish the instruction. To observe the environment, the planner has access to textual feedback $o$ from the environment that can be appended to the instruction or requested by the planner. Our work studies to what extent the LLM planner is able to reason over and utilize such feedback to “close the loop” with the environment and improve planning.
|
| 42 |
+
|
| 43 |
+
# 3.1 Inner Monologue
|
| 44 |
+
|
| 45 |
+
We formulate an “inner monologue” by continually injecting information from the various sources of feedback into the LLM planning language prompts as the robot interacts with the environment. While LLMs have demonstrated exceptional planning capabilities for embodied control tasks [20], prior works have found it crucial to ground LLM predictions with external components such as affordance functions [21] in order to produce useful plans that are executable by robots. However, LLMs used in this context have thus far remained one-directional – providing a list of skills, without making corrections or leveraging opportunities to replan accordingly. In contrast, Inner Monologue studies settings where grounded environment feedback is provided directly to the LLM in a closed-loop fashion. This promotes improved LLM reasoning in complex long-horizon settings, even before any external affordance-based grounding methods are applied.
|
| 46 |
+
|
| 47 |
+

|
| 48 |
+
Figure 3: Different instantiations of Inner Monologue in three distinct domains – simulated tabletop rearrangement (top), real-world tabletop rearrangement (middle), and real-world kitchen mobile manipulation (bottom). Each domain uses different prompts and different feedback models. Sharing across the domains is the same Inner Monologue formulation that uses a pre-trained langauge model to take in a human instruction and decompose it into a sequence of actionable steps by the agent, while accounting for injected embodied feedback from different models, such as object recognizers and success detectors. In real-world kitchen mobile manipulation domain (bottom), we additionally ground the actions using pre-trained affordance functions built in [21], which do not communicate back to the language model.
|
| 49 |
+
|
| 50 |
+
Our analysis assumes textual feedback is provided to the planner, but does not assume a single specific method of fusing LLM planning with low-level robotic control or a specific method of extracting environment feedback into language. Rather than focusing on a particular algorithmic implementation, our aim is to provide a case study on the value of incorporating different types of feedback into closed-loop LLM-based planning. Thus, Inner Monologue in Sec 4 utilizes language feedback within separate systems that incorporate different LLMs, different methods of fusing planning with control, different environments and tasks, and different methods of acquiring control policies. We note that in our specific implementations of Inner Monologue, we use pre-trained LLMs for planning that are not finetuned, but rather evaluated solely with few-shot prompting; the full prompts can be found in the Appendix.
|
| 51 |
+
|
| 52 |
+
# 3.2 Sources of Feedback
|
| 53 |
+
|
| 54 |
+
In theory any type of environment feedback can inform the LLM planner, as long as it can be expressed through language. We focus on the specific forms of feedback shown in Fig 2: (1) task-specific feedback, such as success detection, and (2) scene-specific feedback (either “passive” or “active”), which describes the scene. Specific instantiations and implementation details of each type of feedback can be found in Sec 4.1, Sec 4.2, and Sec 4.3 respectively for each domain.
|
| 55 |
+
|
| 56 |
+
Success Detection. The Success feedback gives binary “yes” or “no” response in language form, specifying whether the low-level skill $\pi _ { k }$ has succeeded. Engineered success detectors can operate on ground-truth state in simulation, while learned success detectors can be trained on real examples of successes and failures in the real world [84, 85, 86, 87, 88].
|
| 57 |
+
|
| 58 |
+
Passive Scene Description. We refer broadly to any sources of scene feedback that are consistently and automatically injected into the LLM prompt as Passive Scene Description, which also typically follow some structure. One common type of such feedback is object recognition [89, 90, 91, 92] that returns a list of present objects, to which we refer as Object feedback. We also demonstrate the use of a task-progress scene description in the simulated tabletop rearrangement environment, to which we refer as Scene feedback.
|
| 59 |
+
|
| 60 |
+
Active Scene Description. As the proactive counterpart, Active Scene Description encompasses sources of feedback that are provided directly in response to active queries by the LLM planner, which are answered either by a person, or by another pretrained model, such as a Visual Question Answering (VQA) model [93, 94, 95, 96]. Unlike the passive counterpart which are strictly structured and narrow in their scope, this feedback allows the planner to actively gather information relevant to the scene, the task, or even preferences of the user. The combined output we send to the LLM planner includes both the LLM-generated question along with the response. As we aim to investigate whether and how a LLM planner can incorporate such feedback and wish to study both structured VQA-style human feedback as well as unstructured human preferences feedback, we only consider human-provided response in this work, which we refer to as Human feedback.
|
| 61 |
+
|
| 62 |
+
# 4 Experimental Results
|
| 63 |
+
|
| 64 |
+
In order to study how different sources of environment feedback can support a rich inner monologue that enables complex robotic control, we study different Inner Monologue implementations in three environments, each with different LLM and different sources of feedback from the environment: 1) simulated tabletop manipulation (Sec 4.1), 2) real-world tabletop manipulation (Sec 4.2), and 3) real-world mobile manipulation in an office kitchen (Sec 4.3). For more details about the experiment setup and results, please refer to the Appendix.
|
| 65 |
+
|
| 66 |
+
# 4.1 Simulated Tabletop Rearrangement
|
| 67 |
+
|
| 68 |
+
We experiment with Ravens-based [81] environment, where a robotic arm with a gripper is tasked with rearranging blocks and bowls in some desired configuration, specified by natural language. We evaluate each method on four seen tasks and four unseen tasks, where seen tasks may be used for training (in the case of supervised baseline) or used as few-shot prompting.
|
| 69 |
+
|
| 70 |
+
This instantiation of Inner Monologue uses (i) InstructGPT [9, 97] for planning [20, 21], (ii) scripted modules to provide language feedback in the form of object recognition (Object), success detection (Success), and task-progress scene description (Scene), and (iii) a pre-trained language-conditioned pick-and-place primitive (similar to CLIPort [82] and Transporter Nets [81]). Object feedback informs the list of present objects and Success feedback informs the success/failure of the most recent action. However, consider the task of stacking multiple blocks, because the unfinished tower of blocks may be knocked over by the robot, it is also critical to reason about overall task progress. Therefore, task-progress scene description (Scene) describes the semantic sub-goals inferred by the LLM towards completing the high-level instruction that are achieved by the agent so far.
|
| 71 |
+
|
| 72 |
+
We additionally compare to a multi-task CLIPort directly trained on long-horizon task instructions. Because CLIPort is a single-step policy and does not terminate spontaneously during policy rollout, we report CLIPort evaluations with oracle termination (i.e., repeat until oracle indicates task completion) and fixed-step termination (i.e., repeat for 15 steps). To simulate real-world disturbances and evaluate the system’s robustness to disturbances, we add Gaussian noise to multiple levels of the system at test time: $\mathcal { N } ( 0 { , } 3 )$ for pixel observation, $\mathcal { N } ( 0 , 2 . 5 )$ for policy primitive (i.e., pick-place pixel heatmaps), $\mathcal { N } ( 0 , 0 . 0 2 m )$ for place locations.
|
| 73 |
+
|
| 74 |
+
<table><tr><td rowspan="2" colspan="3"></td><td></td><td>+LLM</td><td colspan="2">+Inner Monologue</td></tr><tr><td>CLIPort</td><td>+oracle Object</td><td>Object + Success</td><td>Object + Scene</td></tr><tr><td rowspan="4">Seen Tasks</td><td>“Pick and place”</td><td>24.0%</td><td>74.0%</td><td>80.0%</td><td>90.0%</td><td>94.0%</td></tr><tr><td>“Stack all the blocks”</td><td>2.0%</td><td>32.0%</td><td>4.0%</td><td>10.0%</td><td>26.0%</td></tr><tr><td>“Put all the blocks on the [x] corner/side"</td><td>2.0%</td><td>32.0%</td><td>30.0%</td><td>28.0%</td><td>30.0%</td></tr><tr><td>“Put all the blocks in the [x] bowl"</td><td>32.0%</td><td>94.0%</td><td>52.0%</td><td>46.0%</td><td>56.0%</td></tr><tr><td rowspan="4">Unseen Tasks</td><td>“Put all the blocks in different corners"</td><td>0.0%</td><td>0.0%</td><td>20.0%</td><td>20.0%</td><td>26.0%</td></tr><tr><td>“Put the blocks in their matching bowls”</td><td>0.0%</td><td>0.0%</td><td>56.0%</td><td>70.0%</td><td>82.0%</td></tr><tr><td>“Put the blocks on mismatched bowls"</td><td>0.0%</td><td>0.0%</td><td>62.0%</td><td>76.0%</td><td>86.0%</td></tr><tr><td>“Stack all the blocks on the [x] corner/side”</td><td>0.0%</td><td>0.0%</td><td>0.0%</td><td>4.0%</td><td>6.0%</td></tr></table>
|
| 75 |
+
|
| 76 |
+
Table 1: Success rates averaged across 50 episodes in simulated pick-and-place. CLIPort $^ +$ oracle indicates that CLIPort was provided a “termination” oracle. LLM-informed feedback effectively enable retrying/replanning in the presence of test-time disturbances, while enjoying the generalization benefits of LLMs to unseen tasks.
|
| 77 |
+
|
| 78 |
+
Analysis. As shown in Table 1, Inner Monologue effectively enables retrying and replanning in the face of test-time disturbances, where Object $^ +$ Scene performs the best because of its ability to keep track of sub-goal conditions. Furthermore, this performance directly translates to unseen tasks by leveraging rich semantic knowledge of LLM. Finally, we observe that non-hierarchical and solitary systems such as CLIPort (i) struggle at generalizing to unseen long-horizon tasks under test-time disturbances, and (ii) on training tasks, an oracle is also often required to indicate task completion for good performance.
|
| 79 |
+
|
| 80 |
+
# 4.2 Real-World Tabletop Rearrangement
|
| 81 |
+
|
| 82 |
+
We evaluate Inner Monologue on a real-world robot platform designed to resemble the simulation experiments. This instantiation uses (i) InstructGPT [9, 97] for planning, (ii) MDETR [98] for open-vocab object recognition (Object) (iii) heuristics on the object bounding box predictions from MDETR for Success Detection (Success), and (iv) a suction-based pick-and-place motion primitive that uses an LLM to parse target objects from a language command (e.g., given by the planner).
|
| 83 |
+
|
| 84 |
+
We investigate two tasks: (i) a 3-block stacking task where 2 blocks are already pre-stacked, and (ii) a long-horizon sorting task to place food in one plate and condiments in another (where categorizing food versus condiments is autonomously done by the LLM planner). In additional to additional challenges of real-world perception and clutter, we artificially inject Gaussian noise into the policy actions (i.e., add standard deviation $\sigma { = } 4 \mathrm { m m }$ clipped at $2 \sigma$ ) to stress test recovery from failures via replanning with grounded closed-loop feedback. Results are presented in Table 2.
|
| 85 |
+
|
| 86 |
+
<table><tr><td></td><td>LLM</td><td colspan="3">+Inner Monologue</td></tr><tr><td>Task Family</td><td>Object</td><td>Object</td><td>Success</td><td>Object + Success</td></tr><tr><td>Finish 3-block stacking</td><td>20%</td><td>40%</td><td>40%</td><td>100%</td></tr><tr><td>Sort fruits from bottles</td><td>20%</td><td>50%</td><td>40%</td><td>80%</td></tr><tr><td>Total</td><td>20%</td><td>45%</td><td>40%</td><td>90%</td></tr></table>
|
| 87 |
+
|
| 88 |
+
Table 2: Success rates averaged across 10 runs in real-world pick-and-place. We observe significant improvement in Inner Monologue with Object and Success feedback, with the two feedback being complementary to each other.
|
| 89 |
+
|
| 90 |
+
Analysis. We compare to variants with only Object or Success feedback, as well as an open-loop variant (“LLM Object”) that only runs object recognition once at the beginning of the task (similar to the system demonstrated in [19]). The partial 3-block stacking task highlights an immediate failure mode of the open-loop baseline, where the initial scene description struggles to capture a complete representation of the scene (due to clutter and occlusion) to provide as input to the multi-step planner. As a result, the system only executes one pick-and-place action – and cannot recover from mistakes. To address these shortcomings, Inner Monologue $( O b j e c t + S u c c e s s )$ ) leverages closed-loop scene description and success detection after each step, which allows it to successfully replan and recover from policy mistakes.
|
| 91 |
+
|
| 92 |
+
# 4.3 Real-World Mobile Manipulator in a Kitchen Setting
|
| 93 |
+
|
| 94 |
+
We implement Inner Monologue in a robotic system using the kitchen environment and task definitions described in SayCan [21]. The Everyday Robots robot, a mobile manipulator with RGB observations, is placed in an office kitchen to interact with common objects using concurrent [99] continuous closed-loop control.
|
| 95 |
+
|
| 96 |
+
The baseline, SayCan [21], is a method that plans and acts in diverse real world scenarios by combining an LLM with value functions of control policies. While SayCan creates plans that are grounded by the affordances of value functions, the LLM predictions in isolation are never given any closed-loop feedback.
|
| 97 |
+
|
| 98 |
+
We use an instantiation of Inner Monologue that uses (i) PALM [8] for planning, (ii) value functions from pre-trained control policies for affordance grounding [21], (iii) a learned visual classification model for Success feedback, (iv) human-provided Object feedback, and (v) pre-trained control policies for relevant skills in the scene. We also perform a case study where we allow the agent to ask questions and source Human feedback directly; results are shown in Fig 5a and the Appendix.
|
| 99 |
+
|
| 100 |
+
We evaluate on 120 runs over three task families: (1) four manipulation tasks, (2) two dexterous manipulation tasks utilizing drawers, and (3) two long-horizon combined manipulation and navigation tasks. We consider both cases with and without manually-added adversarial disturbances during control policy executions that cause skill policy rollouts to fail. While these failures occur naturally even without perturbances, the adversarial disturbances creates a consistent comparison between methods that requires retrying or replanning to accomplish the original instruction.
|
| 101 |
+
|
| 102 |
+
Table 3: Averaged success rate across 120 evaluations on several task families in our real-world mobile manipulation environment. We consider a standard setting and adversarial setting with external human disturbances. In all cases, LLM-informed embodied feedback is shown to be effective in improving robustness of the system, especially when low-level policies are prone to failures.
|
| 103 |
+
|
| 104 |
+
<table><tr><td rowspan="2">Task Family</td><td rowspan="2">SayCan</td><td colspan="2">+Inner Monologue</td></tr><tr><td>Success</td><td>Object + Success</td></tr><tr><td>No Disturbances</td><td></td><td></td><td></td></tr><tr><td>Manipulation</td><td>50.0%</td><td>62.5%</td><td>75.0%</td></tr><tr><td>Mobile Manipulation</td><td>50.0%</td><td>50.0%</td><td>75.0%</td></tr><tr><td>Drawers</td><td>83.3%</td><td>83.3%</td><td>100.0%</td></tr><tr><td>With Disturbances</td><td></td><td></td><td></td></tr><tr><td>Manipulation</td><td>12.5%</td><td>25.0%</td><td>33.3%</td></tr><tr><td>Mobile Manipulation</td><td>0.0%</td><td>25.0%</td><td>75.0%</td></tr><tr><td>Drawers</td><td>0.0%</td><td>44.4%</td><td>44.4%</td></tr><tr><td>Total</td><td>30.8%</td><td>48.7%</td><td>60.4%</td></tr></table>
|
| 105 |
+
|
| 106 |
+

|
| 107 |
+
Figure 4: Failure causes on 120 evaluations. When disturbances are added (red), only the Inner Monologue variants consistently complete the instructions.
|
| 108 |
+
|
| 109 |
+
Analysis. Without adversarial disturbances, the baseline SayCan performs reasonably on all tasks, yet incorporating LLM-informed feedback in Inner Monologue allows further improvement by effectively retrying or replanning under natural failures. The most notable difference is in the cases with adversarial disturbances. Without any LLM-informed feedback SayCan has success rate close to $0 \%$ since LLM always assume successful execution of previous skills. Inner Monologue significantly outperforms SayCan because of its ability to invoke appropriate recovery modes depending on the environment feedback. Analysis on the failure causes indicates that Success and Object feedback can reduce LLM planning failures and thus overall failure rate, albeit at the cost of introducing new failure modes to the system.
|
| 110 |
+
|
| 111 |
+
# 4.4 Plan Generalization Capabilities
|
| 112 |
+
|
| 113 |
+
Although LLMs can generate fluent continuation from the prompted examples, we surprisingly find that, Inner Monologue demonstrates many impressive reasoning and replanning behaviors beyond the examples given in the prompt. Using a pre-trained LLM as the backbone, the method also inherits many of the appealing properties from its versatility and general-purpose language understanding. In this section, we demonstrate a few of these capabilities; additional capabilities are shown in Appendix (Fig ?? and Fig ??).
|
| 114 |
+
|
| 115 |
+
Continued Adaptation to New Instructions. Although not explicitly prompted, the LLM planner can react to human interaction that changes the high-level goal mid-task. Fig 5a demonstrates a challenging case, where Human feedback changes the goal during the plan execution, and then changes the goal yet again by saying “finish the previous task”. In another instance, despite not being explicitly prompted to terminate after a human says “please stop”, the LLM planner generalizes to this scenario and predicts a “done” action.
|
| 116 |
+
|
| 117 |
+
Self-Proposing Goals under Infeasibility. Instead of mindlessly following human-given instructions, Inner Monologue can also propose alternative goals to achieve when the previous goal becomes infeasible. In Fig 5b, to solve the task “put any two blocks inside the purple bowl”, while the first attempted block is intentionally made too heavy for the robot, Inner Monologue proposes to “find a lighter block” and successfully solves the task.
|
| 118 |
+
|
| 119 |
+
Multilingual Interaction. Pre-trained LLMs are known to be able to translate from one language to another, without any finetuning. We observe that such multilingual understanding also transfers to the embodied settings. Fig 5c shows a case when an instruction is in Chinese, the LLM planner can still correctly interpret it, re-narrate it as a concrete goal to execute in English, and accordingly replan its future actions. Occasionally, we find that this capability even extends to symbols and emojis.
|
| 120 |
+
|
| 121 |
+
Retrospective Scene Understanding. We also observe that Inner Monologue demonstrates retrospective scene understanding based on past actions and environment feedback, which requires temporal and embodied reasoning. In Fig 5d, after series of actions, we can turn to ask questions about the resulting scene, again a structure that has not appeared in the prompt.
|
| 122 |
+
|
| 123 |
+

|
| 124 |
+
Figure 5: Informing LLM with embodied feedback enables many generalization capabilities, all of which are achieved without similar prompted examples. For instance, Inner Monologue can continually adapt to new instructions given by humans, propose new goals to achieve when faced with infeasibility for the previous plan, interact with humans in different natural languages, and answer questions about the current scene given past actions and feedback.
|
| 125 |
+
|
| 126 |
+
Despite the appealing findings about these generalization capabilities, we observe that they are of varying levels of consistency when no similar examples have been provided in the prompt, likely limited by the current capabilities of the language models. However, we believe that further investigations into these behaviors and addressing their limitations would each lead to exciting future directions.
|
| 127 |
+
|
| 128 |
+
# 5 Conclusions, Limitations & Future Works
|
| 129 |
+
|
| 130 |
+
In this work, we investigated the role that environment feedback plays for LLMs reasoning in tasks involving embodied robotic planning and interaction. We presented a general formulation Inner Monologue that combines different sources of environment feedback with methods fusing LLM planning with robotic control policies and studied its instantiations in three distinct domains. We found that environment feedback significantly improves high-level instruction completion, especially in challenging scenarios with adversarial disturbances. Finally, we analyze generalization capabilities of Inner Monologue that highlight how closed-loop language feedback enables replanning even in complex unseen settings.
|
| 131 |
+
|
| 132 |
+
Limitations. In $\mathrm { S e c } ~ 4 . 1$ and Sec 4.3, we assume access to oracle scene descriptors in the form of human observers or scripted systems to provide textual description back to the LLM planner. We study the viability of learned systems scene description and object recognition in Appendix Table ??. As for failure modes, Inner Monologue may fail due to several sources of errors: (1) success detections, (2) LLM planning errors, and (3) control errors. False negative predictions from the success detector lead to additional retry attempts, while false positive predictions add adversarial partial observability to the environment. In some instances, we found that the LLM planners ignored the environment feedback and still proposed policy skills involving objects not present in the scene. Additionally, the performance of low-level control policies limits not only overall high-level instruction completion performance, but also limits the scope of tasks that the LLM is able to plan actions for.
|
| 133 |
+
|
| 134 |
+
Future Works. Several fronts can be improved by future works. First, with advances in image/video captioning and visual-question answering, a fully automated system of Inner Monologue can be implemented without a human in the loop as an oracle. Second, improvements can be made on how to aggregate potentially inaccurate sources of information, such as using text to describe the uncertainty of the feedback modules, or including additional feedback modules for safety and ethics for the proposed plans. Finally, enabling low-level control policies to take as input the textual feedback by LLM also leads to exciting future directions.
|
| 135 |
+
|
| 136 |
+
# Acknowledgments
|
| 137 |
+
|
| 138 |
+
The authors would like to thank Kanishka Rao and Vincent Vanhoucke for valuable feedback and discussions. In addition, the authors would like to acknowledge the large team who built [21], upon which we construct our Kitchen Mobile Manipulation experiments.
|
| 139 |
+
|
| 140 |
+
References
|
| 141 |
+
[1] L. P. Kaelbling and T. Lozano-Perez. Integrated task and motion planning in belief space. ´ The International Journal of Robotics Research, 32(9-10):1194–1227, 2013.
|
| 142 |
+
[2] A. G. Barto and S. Mahadevan. Recent advances in hierarchical reinforcement learning. Discrete event dynamic systems, 13(1):41–77, 2003.
|
| 143 |
+
[3] F. Petroni, T. Rocktaschel, P. Lewis, A. Bakhtin, Y. Wu, A. H. Miller, and S. Riedel. Language ¨ models as knowledge bases? arXiv preprint arXiv:1909.01066, 2019.
|
| 144 |
+
[4] Z. Jiang, F. F. Xu, J. Araki, and G. Neubig. How can we know what language models know? Transactions of the Association for Computational Linguistics, 8:423–438, 2020.
|
| 145 |
+
[5] J. Davison, J. Feldman, and A. M. Rush. Commonsense knowledge mining from pretrained models. In Proceedings of the 2019 conference on empirical methods in natural language processing and the 9th international joint conference on natural language processing (EMNLP-IJCNLP), pages 1173–1178, 2019.
|
| 146 |
+
[6] A. Talmor, Y. Elazar, Y. Goldberg, and J. Berant. olmpics-on what language model pre-training captures. Transactions of the Association for Computational Linguistics, 8:743–758, 2020.
|
| 147 |
+
[7] A. Roberts, C. Raffel, and N. Shazeer. How much knowledge can you pack into the parameters of a language model? arXiv preprint arXiv:2002.08910, 2020.
|
| 148 |
+
[8] A. Chowdhery, S. Narang, J. Devlin, M. Bosma, G. Mishra, A. Roberts, P. Barham, H. W. Chung, C. Sutton, S. Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
|
| 149 |
+
[9] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
|
| 150 |
+
[10] J. Wei, X. Wang, D. Schuurmans, M. Bosma, E. Chi, Q. Le, and D. Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022.
|
| 151 |
+
[11] T. Kojima, S. S. Gu, M. Reid, Y. Matsuo, and Y. Iwasawa. Large language models are zero-shot reasoners. arXiv preprint arXiv:2205.11916, 2022.
|
| 152 |
+
[12] A. K. Lampinen, I. Dasgupta, S. C. Chan, K. Matthewson, M. H. Tessler, A. Creswell, J. L. McClelland, J. X. Wang, and F. Hill. Can language models learn from explanations in context? arXiv preprint arXiv:2204.02329, 2022.
|
| 153 |
+
[13] M. Nye, A. J. Andreassen, G. Gur-Ari, H. Michalewski, J. Austin, D. Bieber, D. Dohan, A. Lewkowycz, M. Bosma, D. Luan, et al. Show your work: Scratchpads for intermediate computation with language models. arXiv preprint arXiv:2112.00114, 2021.
|
| 154 |
+
[14] L. S. Vygotsky. Thought and language. MIT press, 2012.
|
| 155 |
+
[15] P. Carruthers. Thinking in language?: evolution and a modularist possibility. Cambridge University Press, 1998.
|
| 156 |
+
[16] L. Vygotsky. Tool and symbol in child development. The vygotsky reader, 1994.
|
| 157 |
+
[17] L. S. Vygotsky. Play and its role in the mental development of the child. Soviet psychology, 5(3): 6–18, 1967.
|
| 158 |
+
[18] C. Colas, T. Karch, C. Moulin-Frier, and P.-Y. Oudeyer. Vygotskian autotelic artificial intelligence: Language and culture internalization for human-like ai. arXiv preprint arXiv:2206.01134, 2022.
|
| 159 |
+
[19] A. Zeng, A. Wong, S. Welker, K. Choromanski, F. Tombari, A. Purohit, M. Ryoo, V. Sindhwani, J. Lee, V. Vanhoucke, et al. Socratic models: Composing zero-shot multimodal reasoning with language. arXiv preprint arXiv:2204.00598, 2022.
|
| 160 |
+
[20] W. Huang, P. Abbeel, D. Pathak, and I. Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents. In International Conference on Machine Learning. PMLR, 2022.
|
| 161 |
+
[21] M. Ahn, A. Brohan, N. Brown, Y. Chebotar, O. Cortes, B. David, C. Finn, K. Gopalakrishnan, K. Hausman, A. Herzog, D. Ho, J. Hsu, J. Ibarz, B. Ichter, A. Irpan, E. Jang, R. J. Ruano, K. Jeffrey, S. Jesmonth, N. Joshi, R. Julian, D. Kalashnikov, Y. Kuang, K.-H. Lee, S. Levine, Y. Lu, L. Luu, C. Parada, P. Pastor, J. Quiambao, K. Rao, J. Rettinghouse, D. Reyes, P. Sermanet, N. Sievers, C. Tan, A. Toshev, V. Vanhoucke, F. Xia, T. Xiao, P. Xu, S. Xu, and M. Yan. Do as i can and not as i say: Grounding language in robotic affordances. In arXiv preprint arXiv:2204.01691, 2022.
|
| 162 |
+
[22] L. P. Kaelbling and T. Lozano-Perez. Hierarchical planning in the now. In ´ Workshops at the Twenty-Fourth AAAI Conference on Artificial Intelligence, 2010.
|
| 163 |
+
[23] S. Srivastava, E. Fang, L. Riano, R. Chitnis, S. Russell, and P. Abbeel. Combined task and motion planning through an extensible planner-independent interface layer. In 2014 IEEE international conference on robotics and automation (ICRA), 2014.
|
| 164 |
+
[24] R. E. Fikes and N. J. Nilsson. Strips: A new approach to the application of theorem proving to problem solving. Artificial intelligence, 1971.
|
| 165 |
+
[25] E. D. Sacerdoti. A structure for plans and behavior. Technical report, SRI International, Menlo Park California Artificial Intelligence Center, 1975.
|
| 166 |
+
[26] D. Nau, Y. Cao, A. Lotem, and H. Munoz-Avila. Shop: Simple hierarchical ordered planner. In Proceedings of the 16th international joint conference on Artificial intelligence, 1999.
|
| 167 |
+
[27] S. M. LaValle. Planning algorithms. Cambridge university press, 2006.
|
| 168 |
+
[28] M. Toussaint. Logic-geometric programming: An optimization-based approach to combined task and motion planning. In Twenty-Fourth International Joint Conference on Artificial Intelligence, 2015.
|
| 169 |
+
[29] M. A. Toussaint, K. R. Allen, K. A. Smith, and J. B. Tenenbaum. Differentiable physics and stable modes for tool-use and manipulation planning. Robotics: Science and Systems Foundation, 2018.
|
| 170 |
+
[30] B. Eysenbach, R. R. Salakhutdinov, and S. Levine. Search on the replay buffer: Bridging planning and reinforcement learning. Advances in Neural Information Processing Systems, 2019.
|
| 171 |
+
[31] D. Xu, S. Nair, Y. Zhu, J. Gao, A. Garg, L. Fei-Fei, and S. Savarese. Neural task programming: Learning to generalize across hierarchical tasks. In 2018 IEEE International Conference on Robotics and Automation (ICRA), 2018.
|
| 172 |
+
[32] D. Xu, R. Mart´ın-Mart´ın, D.-A. Huang, Y. Zhu, S. Savarese, and L. F. Fei-Fei. Regression planning networks. Advances in Neural Information Processing Systems, 32, 2019.
|
| 173 |
+
[33] T. Silver, R. Chitnis, N. Kumar, W. McClinton, T. Lozano-Perez, L. P. Kaelbling, and J. Tenenbaum. Inventing relational state and action abstractions for effective and efficient bilevel planning. arXiv preprint arXiv:2203.09634, 2022.
|
| 174 |
+
[34] D. Shah, P. Xu, Y. Lu, T. Xiao, A. Toshev, S. Levine, and B. Ichter. Value function spaces: Skill-centric state abstractions for long-horizon reasoning. ICLR, 2022. URL https://openreview.net/pdf?id=vgqS1vkkCbE.
|
| 175 |
+
[35] A. Srinivas, A. Jabri, P. Abbeel, S. Levine, and C. Finn. Universal planning networks: Learning generalizable representations for visuomotor control. In International Conference on Machine Learning, pages 4732–4741. PMLR, 2018.
|
| 176 |
+
[36] T. Kurutach, A. Tamar, G. Yang, S. J. Russell, and P. Abbeel. Learning plannable representations with causal infogan. Advances in Neural Information Processing Systems, 31, 2018.
|
| 177 |
+
[37] A. Akakzia, C. Colas, P.-Y. Oudeyer, M. Chetouani, and O. Sigaud. Grounding language to autonomously-acquired skills via goal generation. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=chPj I5KMHG.
|
| 178 |
+
[38] S. Pirk, K. Hausman, A. Toshev, and M. Khansari. Modeling long-horizon tasks as sequential interaction landscapes. arXiv preprint arXiv:2006.04843, 2020.
|
| 179 |
+
[39] T. Kollar, S. Tellex, D. Roy, and N. Roy. Toward understanding natural language directions. In 2010 5th ACM/IEEE International Conference on Human-Robot Interaction (HRI), pages 259–266. IEEE, 2010.
|
| 180 |
+
[40] S. Tellex, T. Kollar, S. Dickerson, M. Walter, A. Banerjee, S. Teller, and N. Roy. Understanding natural language commands for robotic navigation and mobile manipulation. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 25, pages 1507–1514, 2011.
|
| 181 |
+
[41] M. Bollini, S. Tellex, T. Thompson, N. Roy, and D. Rus. Interpreting and executing recipes with a cooking robot. In Experimental Robotics, pages 481–495. Springer, 2013.
|
| 182 |
+
[42] S. Tellex, R. Knepper, A. Li, D. Rus, and N. Roy. Asking for help using inverse semantics. 2014.
|
| 183 |
+
[43] T. Kollar, S. Tellex, D. Roy, and N. Roy. Grounding verbs of motion in natural language commands to robots. In Experimental robotics, pages 31–47. Springer, 2014.
|
| 184 |
+
[44] V. Blukis, Y. Terme, E. Niklasson, R. A. Knepper, and Y. Artzi. Learning to map natural language instructions to physical quadcopter control using simulated flight. arXiv preprint arXiv:1910.09664, 2019.
|
| 185 |
+
[45] S. Nair and C. Finn. Hierarchical foresight: Self-supervised learning of long-horizon tasks via visual subgoal generation. ArXiv, abs/1909.05829, 2020.
|
| 186 |
+
[46] F. Xia, C. Li, R. Mart´ın-Mart´ın, O. Litany, A. Toshev, and S. Savarese. Relmogen: Integrating motion generation in reinforcement learning for mobile manipulation. In 2021 IEEE International Conference on Robotics and Automation (ICRA), 2021.
|
| 187 |
+
[47] C. Li, F. Xia, R. Martin-Martin, and S. Savarese. Hrl4in: Hierarchical reinforcement learning for interactive navigation with mobile manipulators. In Conference on Robot Learning, 2020.
|
| 188 |
+
[48] Y. Jiang, S. Gu, K. Murphy, and C. Finn. Language as an abstraction for hierarchical deep reinforcement learning. In NeurIPS, 2019.
|
| 189 |
+
[49] D. Hafner, K.-H. Lee, I. Fischer, and P. Abbeel. Deep hierarchical planning from pixels. arXiv preprint arXiv:2206.04114, 2022.
|
| 190 |
+
[50] S. Mirchandani, S. Karamcheti, and D. Sadigh. Ella: Exploration through learned language abstraction. Advances in Neural Information Processing Systems, 34:29529–29540, 2021.
|
| 191 |
+
[51] P. A. Jansen. Visually-grounded planning without vision: Language models infer detailed plans from high-level instructions. arXiv preprint arXiv:2009.14259, 2020.
|
| 192 |
+
[52] P. Sharma, A. Torralba, and J. Andreas. Skill induction and planning with latent language. arXiv preprint arXiv:2110.01517, 2021.
|
| 193 |
+
[53] V. Micheli and F. Fleuret. Language models are few-shot butlers. arXiv preprint arXiv:2104.07972, 2021.
|
| 194 |
+
[54] S. Li, X. Puig, Y. Du, C. Wang, E. Akyurek, A. Torralba, J. Andreas, and I. Mordatch. Pre-trained language models for interactive decision-making. arXiv preprint arXiv:2202.01771, 2022.
|
| 195 |
+
[55] V. Shwartz, P. West, R. L. Bras, C. Bhagavatula, and Y. Choi. Unsupervised commonsense question answering with self-talk. arXiv preprint arXiv:2004.05483, 2020.
|
| 196 |
+
[56] M. Chen, J. Tworek, H. Jun, Q. Yuan, H. P. d. O. Pinto, J. Kaplan, H. Edwards, Y. Burda, N. Joseph, G. Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
|
| 197 |
+
[57] Y. Liu, M. Ott, N. Goyal, J. Du, M. Joshi, D. Chen, O. Levy, M. Lewis, L. Zettlemoyer, and V. Stoyanov. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
|
| 198 |
+
[58] N. Reimers and I. Gurevych. Sentence-bert: Sentence embeddings using siamese bert-networks. arXiv preprint arXiv:1908.10084, 2019.
|
| 199 |
+
[59] J. Wei, M. Bosma, V. Y. Zhao, K. Guu, A. W. Yu, B. Lester, N. Du, A. M. Dai, and Q. V. Le. Finetuned language models are zero-shot learners. arXiv preprint arXiv:2109.01652, 2021.
|
| 200 |
+
[60] C. Paxton, Y. Bisk, J. Thomason, A. Byravan, and D. Foxl. Prospection: Interpretable plans from language by predicting the future. In 2019 International Conference on Robotics and Automation (ICRA), pages 6942–6948. IEEE, 2019.
|
| 201 |
+
[61] S. Stepputtis, J. Campbell, M. Phielipp, S. Lee, C. Baral, and H. Ben Amor. Language-conditioned imitation learning for robot manipulation tasks. Advances in Neural Information Processing Systems, 33:13139–13150, 2020.
|
| 202 |
+
[62] V. Blukis, R. A. Knepper, and Y. Artzi. Few-shot object grounding and mapping for natural language robot instruction following. arXiv preprint arXiv:2011.07384, 2020.
|
| 203 |
+
[63] C. Lynch and P. Sermanet. Language conditioned imitation learning over unstructured data. Robotics: Science and Systems, 2021. URL https://arxiv.org/abs/2005.07648.
|
| 204 |
+
[64] Y. Chen, R. Xu, Y. Lin, and P. A. Vela. A joint network for grasp detection conditioned on natural language commands. In 2021 IEEE International Conference on Robotics and Automation (ICRA), pages 4576–4582. IEEE, 2021.
|
| 205 |
+
[65] O. Mees, L. Hermann, and W. Burgard. What matters in language conditioned robotic imitation learning. arXiv preprint arXiv:2204.06252, 2022.
|
| 206 |
+
[66] C. Yan, F. Carnevale, P. Georgiev, A. Santoro, A. Guy, A. Muldal, C.-C. Hung, J. Abramson, T. Lillicrap, and G. Wayne. Intra-agent speech permits zero-shot task acquisition. arXiv preprint arXiv:2206.03139, 2022.
|
| 207 |
+
[67] G. Kuhlmann, P. Stone, R. Mooney, and J. Shavlik. Guiding a reinforcement learner with natural language advice: Initial results in robocup soccer. In The AAAI-2004 workshop on supervisory control of learning and adaptive systems. San Jose, CA, 2004.
|
| 208 |
+
[68] A. Najar, O. Sigaud, and M. Chetouani. Interactively shaping robot behaviour with unlabeled human instructions. Autonomous Agents and Multi-Agent Systems, 34(2):1–35, 2020.
|
| 209 |
+
[69] P. Sharma, B. Sundaralingam, V. Blukis, C. Paxton, T. Hermans, A. Torralba, J. Andreas, and D. Fox. Correcting robot plans with natural language feedback. arXiv preprint arXiv:2204.05186, 2022.
|
| 210 |
+
[70] R. Loftin, B. Peng, J. MacGlashan, M. L. Littman, M. E. Taylor, J. Huang, and D. L. Roberts. Learning behaviors via human-delivered discrete feedback: modeling implicit feedback strategies to speed up learning. Autonomous agents and multi-agent systems, 30(1):30–59, 2016.
|
| 211 |
+
[71] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748–8763. PMLR, 2021.
|
| 212 |
+
[72] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
|
| 213 |
+
[73] J. Lu, D. Batra, D. Parikh, and S. Lee. Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. Advances in neural information processing systems, 32, 2019.
|
| 214 |
+
[74] Z. Wang, J. Yu, A. W. Yu, Z. Dai, Y. Tsvetkov, and Y. Cao. Simvlm: Simple visual language model pretraining with weak supervision. arXiv preprint arXiv:2108.10904, 2021.
|
| 215 |
+
[75] A. Suglia, Q. Gao, J. Thomason, G. Thattai, and G. Sukhatme. Embodied bert: A transformer model for embodied, language-guided visual task completion. arXiv preprint arXiv:2108.04927, 2021.
|
| 216 |
+
[76] T. Chen, S. Kornblith, K. Swersky, M. Norouzi, and G. E. Hinton. Big self-supervised models are strong semi-supervised learners. Advances in neural information processing systems, 33: 22243–22255, 2020.
|
| 217 |
+
[77] A. Jain, M. Guo, K. Srinivasan, T. Chen, S. Kudugunta, C. Jia, Y. Yang, and J. Baldridge. Mural: multimodal, multitask retrieval across languages. arXiv preprint arXiv:2109.05125, 2021.
|
| 218 |
+
[78] J. Sun, D.-A. Huang, B. Lu, Y.-H. Liu, B. Zhou, and A. Garg. Plate: Visually-grounded planning with transformers in procedural tasks. IEEE Robotics and Automation Letters, 7(2):4924–4930, 2022.
|
| 219 |
+
[79] F. Sener and A. Yao. Zero-shot anticipation for instructional activities. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 862–871, 2019.
|
| 220 |
+
[80] A. Khandelwal, L. Weihs, R. Mottaghi, and A. Kembhavi. Simple but effective: Clip embeddings for embodied ai. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 14829–14838, 2022.
|
| 221 |
+
[81] A. Zeng, P. Florence, J. Tompson, S. Welker, J. Chien, M. Attarian, T. Armstrong, I. Krasin, D. Duong, V. Sindhwani, and J. Lee. Transporter networks: Rearranging the visual world for robotic manipulation. Conference on Robot Learning (CoRL), 2020.
|
| 222 |
+
[82] M. Shridhar, L. Manuelli, and D. Fox. Cliport: What and where pathways for robotic manipulation. In Conference on Robot Learning, pages 894–906. PMLR, 2022.
|
| 223 |
+
[83] X. Gu, T.-Y. Lin, W. Kuo, and Y. Cui. Open-vocabulary object detection via vision and language knowledge distillation. arXiv preprint arXiv:2104.13921, 2021.
|
| 224 |
+
[84] I. Lenz, H. Lee, and A. Saxena. Deep learning for detecting robotic grasps. The International Journal of Robotics Research, 34(4-5):705–724, 2015.
|
| 225 |
+
[85] F.-J. Chu, R. Xu, and P. A. Vela. Real-world multiobject, multigrasp detection. IEEE Robotics and Automation Letters, 3(4):3355–3362, 2018.
|
| 226 |
+
[86] D. Kalashnikov, J. Varley, Y. Chebotar, B. Swanson, R. Jonschkowski, C. Finn, S. Levine, and K. Hausman. Mt-opt: Continuous multi-task robotic reinforcement learning at scale. arXiv preprint arXiv:2104.08212, 2021.
|
| 227 |
+
[87] T. Migimatsu and J. Bohg. Grounding predicates through actions. arXiv preprint arXiv:2109.14718, 2021.
|
| 228 |
+
[88] Y. Cui, S. Niekum, A. Gupta, V. Kumar, and A. Rajeswaran. Can foundation models perform zero-shot task specification for robot manipulation? In Learning for Dynamics and Control Conference, pages 893–905. PMLR, 2022.
|
| 229 |
+
[89] M. Liang and X. Hu. Recurrent convolutional neural network for object recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3367–3375, 2015.
|
| 230 |
+
[90] S. Ren, K. He, R. Girshick, and J. Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems, 28, 2015.
|
| 231 |
+
[91] Z. Zou, Z. Shi, Y. Guo, and J. Ye. Object detection in 20 years: A survey. arXiv preprint arXiv:1905.05055, 2019.
|
| 232 |
+
[92] A. Bochkovskiy, C.-Y. Wang, and H.-Y. M. Liao. Yolov4: Optimal speed and accuracy of object detection. arXiv preprint arXiv:2004.10934, 2020.
|
| 233 |
+
[93] S. Antol, A. Agrawal, J. Lu, M. Mitchell, D. Batra, C. L. Zitnick, and D. Parikh. Vqa: Visual question answering. In Proceedings of the IEEE international conference on computer vision, pages 2425–2433, 2015.
|
| 234 |
+
[94] L. Zhou, H. Palangi, L. Zhang, H. Hu, J. Corso, and J. Gao. Unified vision-language pre-training for image captioning and vqa. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 13041–13049, 2020.
|
| 235 |
+
[95] H. Cai, C. Gan, T. Wang, Z. Zhang, and S. Han. Once for all: Train one network and specialize it for efficient deployment. In International Conference on Learning Representations, 2020. URL https://arxiv.org/pdf/1908.09791.pdf.
|
| 236 |
+
[96] J.-B. Alayrac, J. Donahue, P. Luc, A. Miech, I. Barr, Y. Hasson, K. Lenc, A. Mensch, K. Millican, M. Reynolds, et al. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022.
|
| 237 |
+
[97] L. Ouyang, J. Wu, X. Jiang, D. Almeida, C. L. Wainwright, P. Mishkin, C. Zhang, S. Agarwal, K. Slama, A. Ray, et al. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02155, 2022.
|
| 238 |
+
[98] A. Kamath, M. Singh, Y. LeCun, G. Synnaeve, I. Misra, and N. Carion. Mdetr-modulated detection for end-to-end multi-modal understanding. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1780–1790, 2021.
|
| 239 |
+
[99] T. Xiao, E. Jang, D. Kalashnikov, S. Levine, J. Ibarz, K. Hausman, and A. Herzog. Thinking while moving: Deep reinforcement learning with concurrent control. arXiv preprint arXiv:2004.06089, 2020.
|
md/dev/401LFvBGIb/401LFvBGIb.md
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deep feedforward functionality by equilibrium-point control in a shallow recurrent network
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
Recurrent neural network based machine learning systems are typically employed for their sequential functionality in handling time-varying signals, such as for speech processing. However, neurobiologists find recurrent connections in the vision system and debate about equilibrium-point control in the motor system. Thus, we need a deeper understanding of how recurrent dynamics can be exploited to attain combinational stable-input stable-output functionality. Here, we study how a simplified Cohen-Grossberg neural network model can realize combinational multi-input Boolean functionality. We place our problem within the discipline of algebraic geometry, and solve a special case of it using piecewise-linear algebra. We demonstrate a connectance-efficient realization of the parity function as a proof-of-concept. Small-scale systems of this kind can be easily built, say for hobby robotics, as a network of two-terminal devices of resistors and tunnel diodes. Large-scale systems may be energy-efficiently built as an interconnected network of multi-electrode nanoclusters with non-monotonic transport mechanisms.
|
| 11 |
+
|
| 12 |
+
# 15 1 Introduction
|
| 13 |
+
|
| 14 |
+
16 Shallow recurrent neural networks are being investigated for more context-aware object recognition
|
| 15 |
+
17 [25] and brain-like behaviour [23]. They can be more compact (by trading space for time) and are a
|
| 16 |
+
18 naturally robust alternative to deep neural networks (which are easily fooled by input perturbations
|
| 17 |
+
19 or transformations [18, 29, 1]) when the role of recurrent dynamics is not to produce time-varying
|
| 18 |
+
20 output but instead to produce transient (hidden) state-dynamics that facilitate deep, robust and
|
| 19 |
+
21 transformation-invariant fixed-input fixed-output functionality. To better engineer such dynamics,
|
| 20 |
+
22 we shall study equilibrium-point control, which can be defined as the process of steering to a target
|
| 21 |
+
23 in state-space by fixing the input signal, instead of driving it by a continuously varying input signal.
|
| 22 |
+
24 Historically, equilibrium-point control [14, 5] was first formulated to provide a plausible solution
|
| 23 |
+
25 to the degrees of freedom problem in motor control [3], that is, we mentally represent intermediate
|
| 24 |
+
26 destination points rather than a continuum of velocity information required to execute a movement.
|
| 25 |
+
27 Here, we shall focus on using equilibrium-point control to realize multi-input Boolean functionality,
|
| 26 |
+
28 in particular the parity function, which is a canonical proxy for nonlinear classification. Theoretical
|
| 27 |
+
29 results in circuit complexity are known already for realizing Boolean functionality out of feedforward
|
| 28 |
+
30 neural networks, with weighted-sum thresholded binary-output neurons [35]. It has been shown that
|
| 29 |
+
31 arbitrary $N$ -input Boolean functions can be realized in depth-3 feedforward networks with fewer
|
| 30 |
+
32 neurons $( m = \mathcal { O } ( 2 ^ { N / 2 } )$ instead of the $\mathcal { O } ( 2 ^ { N } )$ in total required for depth-2). However, with the
|
| 31 |
+
33 advent of nanoelectronics, the size of an artificial neuron has been downscaled to such an extent
|
| 32 |
+
34 that it is rather the interconnect wiring that now occupies a greater area in chip design. Thus for a
|
| 33 |
+
35 fully-connected deep network, the area scales as the number of interconnects $\dot { m ^ { 2 } } = \mathcal { \bar { O } } ( 2 ^ { N } )$ . Such a
|
| 34 |
+
36 $\mathcal { O } ( 2 ^ { N } )$ scaling law was earlier obtained by Shannon [34] for realizing arbitrary $N$ -input Boolean
|
| 35 |
+
37 functions by an interconnection of input-controlled switches (or equivalently a feedforward network
|
| 36 |
+
38 of 2-input Boolean gates). Thus, unless we employ higher-order neurons [16], we can say that
|
| 37 |
+
39 a Shannon bottleneck limits the maximum $N$ -input Boolean logic realizable in a given area by
|
| 38 |
+
40 (nanoscale) feedforward networks. We aim to circumvent this Shannon bottleneck by employing
|
| 39 |
+
41 recurrent physical networks. It is known that certain combinational logic functions can be realized
|
| 40 |
+
42 by fewer logic gates in a cyclic network than in an acyclic network [31], and with analog signal
|
| 41 |
+
43 processing the improvement factor could be even higher.
|
| 42 |
+
44 In the following section, we introduce a state-space model formalism to study equilibrium-point
|
| 43 |
+
45 control, and commit to a physically realizable model, and discuss how a general solution for its
|
| 44 |
+
46 equilibrium points is a difficult problem in algebraic geometry. Thus, we proceed to idealize the non
|
| 45 |
+
47 monotonic output of the physical system as a piecewise-linear function and solve for the equilibrium
|
| 46 |
+
48 points. Finally, a piecewise-quadratic Lyapunov function is obtained for stability analysis and
|
| 47 |
+
49 conditions for a unique equilibrium-point are provided.
|
| 48 |
+
50 After the theory, in the results section, we provide a connectance-efficient realization of the parity
|
| 49 |
+
51 function. The discussion section puts our results into a broader context and offers avenues for further
|
| 50 |
+
52 research. Our objective here is to work at the intersection of nonlinear dynamical systems, neural
|
| 51 |
+
53 networks, unconventional neuromorphic hardware, cyclic Boolean circuits, piecewise-linear control
|
| 52 |
+
54 systems, and algebraic geometry.
|
| 53 |
+
|
| 54 |
+
# 2 Theory
|
| 55 |
+
|
| 56 |
+
# 2.1 State-space model
|
| 57 |
+
|
| 58 |
+
For equilibrium-point control, in general we have an input vector $_ { \textbf { \em x } }$ , a state $s _ { i } ( t )$ for $i = 1 : N$ , and an output $y$ obtained from a system of equations
|
| 59 |
+
|
| 60 |
+
$$
|
| 61 |
+
\dot { s } _ { i } ( t ) = F _ { i } ( \pmb { s } ( t ) , \pmb { x } ) , y = \operatorname* { l i m } _ { t \to \infty } G ( \pmb { s } ( t ) ) .
|
| 62 |
+
$$
|
| 63 |
+
|
| 64 |
+
59 In this paper, we commit to a physically realizable recurrent network with voltage nodes $s _ { i }$ from
|
| 65 |
+
60 $i = 1 : N$ , with a capacitive time-constant $\tau _ { i }$ , using resistors (of a constant conductance $f _ { i j }$ ) and
|
| 66 |
+
61 tunnel diodes (of a voltage-dependent conductance $\bar { G _ { i } } ( s _ { i } ) \rangle$ ) as shown in Fig. 1, yielding a state-space
|
| 67 |
+
62 model of the form
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\tau _ { i } \dot { s } _ { i } = \boldsymbol { x } _ { i } - \sum _ { j \neq i } f _ { i j } ( s _ { i } - s _ { j } ) - G _ { i } ( s _ { i } ) , y = G _ { 1 } ( \boldsymbol { \hat { s } } _ { 1 } )
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
63 where $f _ { i j } \geq 0$ , $G _ { i }$ is a nonlinear passive function such that $G _ { i } ( s ) s \geq 0$ and $\begin{array} { r } { \hat { s } _ { 1 } \equiv \operatorname* { l i m } _ { t \infty } s _ { 1 } ( t ) } \end{array}$ is
|
| 74 |
+
64 the stable equilibrium-point if one exists (note: $y ( x )$ can be multi-valued and depend on the basin of
|
| 75 |
+
65 attraction that the initial state $s ( 0 )$ lies in). Brain-scale systems of this kind may be realized by an
|
| 76 |
+
66 interconnected network of nanoclusters with non-monotonic transport mechanisms as proposed in
|
| 77 |
+
67 [24, Chapter 5]. However, finding suitable network parameters that result in practical functionality
|
| 78 |
+
68 remains a challenge. Note that, although not the focus of this work, Eq. (2) can also represent
|
| 79 |
+
69 state-space models with noisy rectified-linear units, for which semi-analytical results are known from
|
| 80 |
+
70 a computational neuroscience [12] and a machine learning [33] perspective.
|
| 81 |
+
|
| 82 |
+
# 71 2.2 Algebraic geometry of the equilibrium points
|
| 83 |
+
|
| 84 |
+
72 A study of the set of equilibrium points of a state-space model, $S _ { 0 } ( { \pmb x } ) \equiv \{ { \pmb s } \ni F _ { 1 : N } ( { \pmb s } , { \pmb x } ) = { \bf 0 } \}$ ,
|
| 85 |
+
73 can not only help in characterising the stable equilibrium-points $\hat { \pmb { s } } \in \mathcal { S } _ { * } \subseteq \mathcal { S } _ { 0 }$ , but also provide
|
| 86 |
+
74 necessary (but not sufficient) conditions in the parameters defining the functions $F _ { 1 : N }$ and $G$ , to
|
| 87 |
+
75 realize desired equilibrium-point functionality $y ( \pmb { x } )$ . For example, to realize a Boolean function
|
| 88 |
+
76 $y : \{ 0 , 1 \} ^ { N } \to \{ \dot { 0 , } 1 \}$ , the following property has to be satisfied:
|
| 89 |
+
|
| 90 |
+
$$
|
| 91 |
+
\operatorname* { m i n } _ { \pmb { s } \in S _ { 0 } ( \pmb { x } ) } G ( \pmb { s } ) \le 1 \land \operatorname* { m a x } _ { \pmb { s } \in S _ { 0 } ( \pmb { x } ) } G ( \pmb { s } ) \ge 0 \forall \pmb { x } \in \{ 0 , 1 \} ^ { N } .
|
| 92 |
+
$$
|
| 93 |
+
|
| 94 |
+

|
| 95 |
+
Figure 1: Recurrent physical network corresponding to the state-space model (2) where the inputs $x _ { 1 : N }$ are currents, the states $s _ { 1 : N }$ are voltages, the output $y$ is a measured current, the linear interactions are due to resistors with a conductance $f _ { i j }$ between node $i$ and $j$ , and nonlinear interactions are due to tunnel diodes from node $i$ to GND with conductance $G _ { i } ( s _ { i } )$ .
|
| 96 |
+
|
| 97 |
+
77 The set of equilibrium points of our recurrent physical network model (2) are the roots of the system
|
| 98 |
+
78 of nonlinear equations
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
- f _ { i , 1 : N } \cdot s _ { 1 : N } + G _ { i } ( s _ { i } ) = x _ { i }
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
where the linear-interaction matrix 79 $f _ { N \times N }$ has terms $\begin{array} { r } { f _ { i i } \equiv - \sum _ { j \neq i } f _ { i j } } \end{array}$
|
| 105 |
+
|
| 106 |
+
80 Solving the multivariate nonlinear equation (4) is a difficult problem in algebraic geometry, a
|
| 107 |
+
81 discipline of mathematics which classically grew around efforts to understand the roots of multivariate
|
| 108 |
+
82 polynomials and later metamorphosed by the study of integer-coefficient piecewise-linear functions,
|
| 109 |
+
83 with an abstract language that has even recently been applied to explain circuit complexity results of
|
| 110 |
+
84 deep feedforward networks [35, 30] through the lens of rational piecewise-linear functions [40].
|
| 111 |
+
85 Algebraic geometry originally dealt with a qualitative approach by geometrical arguments [15], in
|
| 112 |
+
86 contrast to a quantitative approach by numerical methods. An example of that kind is Harnack’s
|
| 113 |
+
87 curve theorem [19] which states that for a 2-D polynomial curve of degree $n$ , the maximum number
|
| 114 |
+
88 of connected components is $( n ^ { 2 } - 3 n + 4 ) / 2$ . Now, with the advent of computer algebra, the roots
|
| 115 |
+
89 of multivariate nonlinear equations are studied by the elimination of variables, using techniques
|
| 116 |
+
90 such as resultants [13, 38] and Groebner bases [7, 8] for polynomial systems, and as an instance
|
| 117 |
+
91 of the linear-complementarity problem [11] or equivalently as absolute-value equations [26] for
|
| 118 |
+
92 piecewise-linear systems [37]. However, computer algebra is not scalable for higher dimensions.
|
| 119 |
+
93 Thus there is a need to convey the richness in algebraic geometry using analytical expressions. While
|
| 120 |
+
94 it is unlikely that analytical expressions may be obtained for any general form of nonlinearity, we
|
| 121 |
+
95 may hope that the set of exactly solvable models can be extended well beyond linear equations, a
|
| 122 |
+
96 hope banking on our successful experience from other areas of mathematics such as integral calculus
|
| 123 |
+
97 [9, section IX] and iterated mappings [39, page 1098].
|
| 124 |
+
|
| 125 |
+
# 98 2.2.1 Piecewise-linear algebra
|
| 126 |
+
|
| 127 |
+
99 In this paper, we commit to a piecewise-linear analysis by considering
|
| 128 |
+
|
| 129 |
+
$$
|
| 130 |
+
G _ { i } ( s ) = \left\{ \begin{array} { l l } { g _ { i 1 } s } & { 0 \leq s \leq g _ { i 2 } } \\ { ( g _ { i 1 } + g _ { i 3 } ) g _ { i 2 } - g _ { i 3 } s } & { g _ { i 2 } \leq s \leq g _ { i 2 } ( 1 + \frac { g _ { i 1 } } { g _ { i 3 } } ) } \end{array} \right.
|
| 131 |
+
$$
|
| 132 |
+
|
| 133 |
+
100 where $g _ { i 1 , 2 , 3 } > 0$ so that $G _ { i }$ is a triangular peak function in a limited range of $s$ , thus defining
|
| 134 |
+
101 an idealized negative-differential behaviour. Shifting the state-space about its inflection points as
|
| 135 |
+
102 ${ \pmb z } \equiv { \pmb s } - { \pmb g } _ { 2 }$ and then combining (5) with (4) yields
|
| 136 |
+
|
| 137 |
+
$$
|
| 138 |
+
x _ { i } = \left\{ \begin{array} { l l } { - f _ { i , 1 : N } \cdot z + g _ { i 1 } z _ { i } - f _ { i , 1 : N } \cdot g _ { 2 } + g _ { i 1 } g _ { i 2 } } & { - g _ { i 2 } \leq z _ { i } \leq 0 } \\ { - f _ { i , 1 : N } \cdot z - g _ { i 3 } z _ { i } - f _ { i , 1 : N } \cdot g _ { 2 } + g _ { i 1 } g _ { i 2 } } & { 0 \leq z _ { i } \leq g _ { i 2 } ( \frac { g _ { i 1 } } { g _ { i 3 } } ) } \end{array} \right. ,
|
| 139 |
+
$$
|
| 140 |
+
|
| 141 |
+
103 which can be simplified to
|
| 142 |
+
|
| 143 |
+
$$
|
| 144 |
+
x _ { i } = - f _ { i , 1 : N } \cdot z + g _ { i \ominus } z _ { i } - g _ { i \oplus } | z _ { i } | - f _ { i , 1 : N } \cdot g _ { 2 } + g _ { i 1 } g _ { i 2 }
|
| 145 |
+
$$
|
| 146 |
+
|
| 147 |
+
105 The system in (7) can be expressed in the absolute-value equation normal form
|
| 148 |
+
|
| 149 |
+
$$
|
| 150 |
+
\pmb { \Delta z } - | \pmb { z } | = \pmb { b }
|
| 151 |
+
$$
|
| 152 |
+
|
| 153 |
+
$$
|
| 154 |
+
- g _ { 2 } \leq z \leq g _ { 2 } g _ { 1 } / g _ { 3 } ,
|
| 155 |
+
$$
|
| 156 |
+
|
| 157 |
+
107 Similarly, (2) can be expressed as
|
| 158 |
+
|
| 159 |
+
$$
|
| 160 |
+
\tau \dot { z } = g _ { \oplus } ( b - { \bf A } z + | z | ) .
|
| 161 |
+
$$
|
| 162 |
+
|
| 163 |
+
Two sufficient conditions are known for the absolute value equation (8) to have a unique solution based on the largest singular value $\sigma _ { \mathrm { m i n } }$ [26] and the spectral radius $\rho$ [32]:
|
| 164 |
+
|
| 165 |
+
$$
|
| 166 |
+
\begin{array} { r } { \sigma _ { \operatorname* { m i n } } ( \mathsf { \pmb { A } } ) > 1 , } \\ { \rho ( | \mathsf { \pmb { A } } ^ { - 1 } | ) < 1 . } \end{array}
|
| 167 |
+
$$
|
| 168 |
+
|
| 169 |
+
108 However, those are not yet sufficient conditions for a unique equilibrium-point solution for (2) and
|
| 170 |
+
109 (10) because the bounds in (9) were not enforced. Thus, we shall proceed to obtain a Lyapunov
|
| 171 |
+
110 function to guarantee that a stable equilibrium-point is reached.
|
| 172 |
+
|
| 173 |
+
# 111 2.3 Lyapunov stability analysis
|
| 174 |
+
|
| 175 |
+
112 Equilibrium-point stability for large complex systems is not guaranteed in general [17, 27], and the
|
| 176 |
+
113 effective dimensionality of stable-input stable-output responses is richly dependent on the parameter
|
| 177 |
+
114 space [2]. However, the interaction matrix for our physical system (2) is symmetric, and hence the
|
| 178 |
+
115 system is a special case of the Cohen-Grossberg model [10]
|
| 179 |
+
|
| 180 |
+
$$
|
| 181 |
+
\dot { s _ { i } } = a _ { i } ( s _ { i } ) [ b _ { i } ( s _ { i } ) - \sum _ { j = 1 } ^ { N } c _ { i j } d _ { j } ( s _ { j } ) ] ,
|
| 182 |
+
$$
|
| 183 |
+
|
| 184 |
+
with $a _ { i } ( s _ { i } ) = 1 / \tau _ { i }$ , $b _ { i } ( s _ { i } ) = x _ { i } - G _ { i } ( s _ { i } )$ , $c _ { i j } = - f _ { i j }$ and $d _ { j } ( s _ { j } ) = s _ { j }$ . Thus, it is known to be globally absolute stable, with a Lyapunov function
|
| 185 |
+
|
| 186 |
+
$$
|
| 187 |
+
\begin{array} { r l r } & { } & { V = - \displaystyle \sum _ { i } \int _ { 0 } ^ { s _ { i } } b _ { i } ( u ) d _ { i } ^ { \prime } ( u ) \mathrm { d } u + \displaystyle \sum _ { i , j } \frac { c _ { i j } } { 2 } d _ { i } ( s _ { i } ) d _ { j } ( s _ { j } ) } \\ & { } & { \quad = \displaystyle \sum _ { i } \Big ( P _ { i } ( s _ { i } ) - x _ { i } s _ { i } - \displaystyle \sum _ { j > i } f _ { i j } s _ { i } s _ { j } - \frac { f _ { i i } } { 2 } s _ { i } ^ { 2 } \Big ) , } \\ & { } & { \quad \mathrm { w h e r e ~ o u t p u t ~ p o w e r ~ } P _ { i } ( s _ { i } ) \equiv \displaystyle \int _ { 0 } ^ { s _ { i } } G _ { i } ( u ) \mathrm { d } u . } \end{array}
|
| 188 |
+
$$
|
| 189 |
+
|
| 190 |
+
116 Alternatively, since our system (5) is piecewise-linear, a piecewise-quadratic Lyapunov function may
|
| 191 |
+
117 be obtained by a piecewise-affine system [22] analysis. While this approach is more powerful and
|
| 192 |
+
118 holds even for asymmetric interaction matrices, it also seems to be analytically complex. From another
|
| 193 |
+
119 angle, global asymptotic stability [21, Theorem 3] is guaranteed if the Jacobian matrix $\mathbf { J }$ satisfies
|
| 194 |
+
120 $J _ { i i } \dot { + } 1 \dot { / } 2 \sum _ { j \neq i } \dot { | } J _ { i j } + J _ { j i } | < 0 \Longleftrightarrow G _ { i } ^ { \prime } ( s _ { i } ) > 0$ because in our system $\begin{array} { r } { J _ { i i } = - \sum _ { j \neq i } f _ { i j } - G _ { i } ^ { \prime } ( s _ { i } ) } \end{array}$
|
| 195 |
+
121 and $J _ { i j } = f _ { i j }$ . Since our network employs non-monotonic functionality, $G _ { i } ^ { \prime } ( s _ { i } ) > 0$ cannot be
|
| 196 |
+
122 guaranteed for all reachable states $s _ { i }$ , and thus the above criteria is unfortunately inapplicable. Hence,
|
| 197 |
+
123 we shall proceed with the Cohen-Grossberg approach.
|
| 198 |
+
|
| 199 |
+
124 The power function (21) simplifies to
|
| 200 |
+
|
| 201 |
+
$$
|
| 202 |
+
P ( s ) = \left\{ \begin{array} { l l } { \int _ { 0 } ^ { s } g _ { 1 } u \mathrm { d } u = g _ { 1 } s ^ { 2 } / 2 } & { 0 \le s \le g _ { 2 } } \\ { g _ { 1 } g _ { 2 } ^ { 2 } / 2 + \int _ { g _ { 2 } } ^ { s } ( g _ { 1 } + g _ { 3 } ) g _ { 2 } - g _ { 3 } u \mathrm { d } u } & { g _ { 2 } \le s } \\ { = g _ { 1 } s ^ { 2 } / 2 - g _ { \oplus } ( s - g _ { 2 } ) ^ { 2 } , } \end{array} \right.
|
| 203 |
+
$$
|
| 204 |
+
|
| 205 |
+
125 and using the rectifier function $[ x ) \equiv \operatorname* { m a x } ( x , 0 )$ may be expressed conveniently as
|
| 206 |
+
|
| 207 |
+
$$
|
| 208 |
+
P ( s ) = g _ { 1 } s ^ { 2 } / 2 - g _ { \oplus } [ s - g _ { 2 } ) ^ { 2 } ,
|
| 209 |
+
$$
|
| 210 |
+
|
| 211 |
+
126 when the system is within its operational bounds.
|
| 212 |
+
|
| 213 |
+
128 Given the Lyapunov stability result of our system, it is computationally efficient to simulate our
|
| 214 |
+
129 state-space model and probe for combinational functionality. Here, we will simulate for the simplest
|
| 215 |
+
130 proof-of-concept for deep functionality in a shallow recurrent - solving a parity problem.
|
| 216 |
+
131 Using a cascade of 2-input XOR gates, the $N$ -bit parity function can be realized with $N / 2 + N / 4 +$
|
| 217 |
+
132 $\dots + 1 = N - 1$ gates and $2 N - 1$ connections. Thus its total cost in area is at least $3 N - 2$ units.
|
| 218 |
+
133 A minimally-connected network has $N$ input wires, 1 output wire, and $N - 1$ interconnect wires
|
| 219 |
+
134 with a total area cost of $2 N$ units, assuming that the area occupied by the remaining components is
|
| 220 |
+
135 negligible. Thus for $N = 3$ , while a conventional digital circuit costs 7 units, our recurrent physical
|
| 221 |
+
136 network takes just 6 wiring units.
|
| 222 |
+
137 Our simple model has $N = 3$ , $f _ { 1 2 } = f _ { 1 3 } = f$ , $f _ { 2 3 } = 0$ , $g _ { 1 1 } = g _ { 1 }$ , $g _ { 1 3 } = g _ { 3 }$ , $g _ { 2 1 } = g _ { 3 1 } = \gamma _ { 1 }$
|
| 223 |
+
138 $g _ { 2 3 } = g _ { 3 3 } = \gamma _ { 3 }$ , $g _ { 1 2 } = g _ { 2 }$ and $\gamma _ { 2 2 } = \gamma _ { 3 2 } = \gamma _ { 2 }$ . We find from a symbolic evaluation that $\sigma _ { \mathrm { m i n } } ( \pmb { \mathsf { A } } ) \neq$
|
| 224 |
+
139 $1 / \rho ( | \pmb { \mathsf { A } } ^ { - 1 } | )$ in general, and conditions for unique stability were not obtainable (which is not surprising
|
| 225 |
+
140 due to the $s _ { 2 } \mathrm { ~ - ~ } s _ { 3 }$ symmetry). Thus, parity functionality was found by trial-and-error yielding the
|
| 226 |
+
141 parameters $\{ f = 1 . 7 5 1 , g _ { 1 } = 1 . 8 7 6 , g _ { 2 } = g _ { 3 } = 0 . 1 2 6 , \gamma _ { 1 } = 0 . 8 7 6 , \gamma _ { 2 } = 1 . 6 , \gamma _ { 3 } = 0 . 7 5 1 \}$ and
|
| 227 |
+
142 simulated using Wolfram Mathematica 13 (code in Appendix). When $x _ { 1 } = x _ { 2 } = x _ { 3 } = 1$ , the states
|
| 228 |
+
143 were forced to transition beyond the bounds in (5), so its range was extended by taking an absolute
|
| 229 |
+
144 value. The results are plotted in Fig. 2.
|
| 230 |
+
|
| 231 |
+
# 145 4 Discussion
|
| 232 |
+
|
| 233 |
+
146 Our result should be seen as a theoretical proof-of-concept and as a motivation for continued
|
| 234 |
+
147 research in this area. Future work must extend our simulations to much higher dimensions to serve
|
| 235 |
+
148 as a practical demonstration of deep functionality by shallow recurrent networks. Moreover, the
|
| 236 |
+
149 theoretical formalism introduced here is not yet fully exploited. We hope to find an analytical method
|
| 237 |
+
150 to design functionality out of piecewise-linear Cohen-Grossberg networks.
|
| 238 |
+
151 Our style of reasoning to circumvent the Shannon bottleneck may also be applied to other systems
|
| 239 |
+
152 such as networks of coupled oscillators [28]. Our non-modular mode of signal processing, offers
|
| 240 |
+
153 an alternative to not just circuit designers, but also to systems biologists who typically understand
|
| 241 |
+
154 chemical reaction networks [6] as a composition of modules [20]. While, we have discussed
|
| 242 |
+
155 equilibium-point functionality in a state-space model driven by an additive input, it is also worth
|
| 243 |
+
156 investigating autonomous systems where the input is set as an initial state. An example is realizing
|
| 244 |
+
157 unboundedly-finite parity functions using just a radius-4 cellular automaton [4]. Finally, we hope
|
| 245 |
+
158 that this paper can serve as a call to action for neuromorphic engineers to look at physical reservoir
|
| 246 |
+
159 computing [36] from another angle, besides temporal input-output functionality.
|
| 247 |
+
|
| 248 |
+
# 160 References
|
| 249 |
+
|
| 250 |
+
[1] M. A. Alcorn, Q. Li, Z. Gong, C. Wang, L. Mai, W.-S. Ku, and A. Nguyen. Strike (with) a pose: Neural networks are easily fooled by strange poses of familiar objects. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4845–4854, 2019.
|
| 251 |
+
[2] R. D. Beer. Parameter space structure of continuous-time recurrent neural networks. Neural computation, 18(12):3009–3051, 2006.
|
| 252 |
+
[3] N. Bernstein. The co-ordination and regulation of movements. The co-ordination and regulation of movements, 1966.
|
| 253 |
+
[4] H. Betel, P. P. de Oliveira, and P. Flocchini. Solving the parity problem in one-dimensional cellular automata. Natural Computing, 12(3):323–337, 2013.
|
| 254 |
+
[5] E. Bizzi, N. Hogan, F. A. Mussa-Ivaldi, and S. Giszter. Does the nervous system use equilibriumpoint control to guide single and multiple joint movements? Behavioral and brain sciences, 15(4):603–613, 1992.
|
| 255 |
+
|
| 256 |
+

|
| 257 |
+
Figure 2: Numerical simulation of our 3-state network over 200 timesteps.
|
| 258 |
+
|
| 259 |
+
[6] D. Bray. Protein molecules as computational elements in living cells. Nature, 376(6538):307– 312, 1995. 75 [7] B. Buchberger. Ein algorithmus zum auffinden der basiselemente des restklassenringes nach einem nulldimensionalen polynomideal. PhD thesis, Universitat Insbruck, 1965. [8] B. Buchberger. Bruno buchberger’s phd thesis 1965: An algorithm for finding the basis 78 elements of the residue class ring of a zero dimensional polynomial ideal. Journal of symbolic computation, 41(3-4):475–511, 2006. [9] G. S. Carr. Synopsis of elementary results in pure mathematics. 1886. [10] M. A. Cohen and S. Grossberg. Absolute stability of global pattern formation and parallel memory storage by competitive neural networks. IEEE transactions on systems, man, and cybernetics, (5):815–826, 1983. [11] R. W. Cottle. Linear complementarity problem, pages 1873–1878. Springer US, Boston, MA, 2009. [12] D. Durstewitz. A state space approach for piecewise-linear recurrent neural networks for identifying computational dynamics from neural measurements. PLoS computational biology, 13(6):e1005542, 2017. [13] I. Z. Emiris. On the complexity of sparse elimination. Journal of Complexity, 12(2):134–166, 1996. [14] A. G. Feldman. Functional tuning of the nervous system with control of movement or maintenance of a steady posture-ii. controllable parameters of the muscle. Biofizika, 11:565–578, 1966. [15] W. Fulton. Intersection theory, volume 2. Springer Science & Business Media, 2013. [16] S. Gao, M. Zhou, Y. Wang, J. Cheng, H. Yachi, and J. Wang. Dendritic neuron model with ef96 fective learning algorithms for classification, approximation, and prediction. IEEE transactions on neural networks and learning systems, 30(2):601–614, 2019. [17] M. R. Gardner and W. R. Ashby. Connectance of large dynamic (cybernetic) systems: critical values for stability. Nature, 228(5273):784–784, 1970. [18] I. J. Goodfellow, J. Shlens, and C. Szegedy. Explaining and harnessing adversarial examples, 2015. [19] A. Harnack. Ueber die vieltheiligkeit der ebenen algebraischen curven. Mathematische Annalen, 10(2):189–198, 1876. [20] L. H. Hartwell, J. J. Hopfield, S. Leibler, and A. W. Murray. From molecular to modular cell biology. Nature, 402(6761):C47–C52, 1999. [21] M. W. Hirsch. Convergent activation dynamics in continuous time networks. Neural networks, 2(5):331–349, 1989. [22] M. Johansson and A. Rantzer. Computation of piecewise quadratic lyapunov functions for hybrid systems. In 1997 European Control Conference (ECC), pages 2005–2010. IEEE, 1997. [23] J. Kubilius, M. Schrimpf, K. Kar, R. Rajalingham, H. Hong, N. Majaj, E. Issa, P. Bashivan, J. Prescott-Roy, K. Schmidt, et al. Brain-like object recognition with high-performing shallow recurrent anns. Advances in neural information processing systems, 32, 2019. [24] C. P. Lawrence. Evolving Networks To Have Intelligence Realized At Nanoscale. PhD thesis, University of Twente, 2018. [25] M. Liang and X. Hu. Recurrent convolutional neural network for object recognition. In 16 Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3367– 17 3375, 2015.
|
| 260 |
+
|
| 261 |
+
18 [26] O. Mangasarian and R. Meyer. Absolute value equations. Linear Algebra and Its Applications, 419(2-3):359–367, 2006.
|
| 262 |
+
20 [27] R. M. May. Will a large complex system be stable? Nature, 238(5364):413–414, 1972. [28] S. N. Menon and S. Sinha. “defective” logic: Using spatiotemporal patterns in coupled relaxation oscillator arrays for computation. In 2014 International Conference on Signal Processing and Communications (SPCOM), pages 1–6. IEEE, 2014. [29] S.-M. Moosavi-Dezfooli, A. Fawzi, O. Fawzi, and P. Frossard. Universal adversarial perturbations. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1765–1773, 2017. [30] M. Raghu, B. Poole, J. Kleinberg, S. Ganguli, and J. Sohl-Dickstein. On the expressive power of deep neural networks. In international conference on machine learning, pages 2847–2854. PMLR, 2017.
|
| 263 |
+
30 [31] M. D. Riedel and J. Bruck. Cyclic boolean circuits. Discrete Applied Mathematics, 160(13- 14):1877–1900, 2012. [32] J. Rohn, V. Hooshyarbakhsh, and R. Farhadsefat. An iterative method for solving absolute value equations and sufficient conditions for unique solvability. Optimization Letters, 8(1):35–44, 2014.
|
| 264 |
+
35 [33] D. Schmidt, G. Koppe, Z. Monfared, M. Beutelspacher, and D. Durstewitz. Identifying nonlinear dynamical systems with multiple time scales and long-range dependencies. In International Conference on Learning Representations, 2021.
|
| 265 |
+
38 [34] C. E. Shannon. The synthesis of two-terminal switching circuits. The Bell System Technical Journal, 28(1):59–98, 1949. [35] K.-Y. Siu, V. P. Roychowdhury, and T. Kailath. Depth-size tradeoffs for neural computation. IEEE Transactions on Computers, 40(12):1402–1412, 1991. [36] G. Tanaka, T. Yamane, J. Héroux, R. Nakane, N. Kanazawa, S. Takeda, H. Numata, D. Nakano, and A. Hirose. Recent advances in physical reservoir computing: A review. Neural Networks, 115:100–123, 2019. [37] W. M. Van Bokhoven and D. M. Leenaerts. Explicit formulas for the solutions of piecewise linear networks. IEEE Transactions on Circuits and Systems I: Fundamental Theory and Applications, 46(9):1110–1117, 1999. [38] M. P. Williams. Solving polynomial equations using linear algebra. Johns Hopkins APL Technical Digest, 28(4):354–363, 2010.
|
| 266 |
+
0 [39] S. Wolfram. A new kind of science, volume 5. Wolfram media Champaign, IL, 2002.
|
| 267 |
+
51 [40] L. Zhang, G. Naitzat, and L.-H. Lim. Tropical geometry of deep neural networks. In International Conference on Machine Learning, pages 5824–5832. PMLR, 2018.
|
| 268 |
+
|
| 269 |
+
# Checklist
|
| 270 |
+
|
| 271 |
+
1. For all authors...
|
| 272 |
+
|
| 273 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] The concrete result is the realization of a parity function by our recurrent physical network by using just 6 wiring units, while a conventional digital circuit costs 7 units. That being said, the paper is written to cover a much broader scope - this is a matter of taste (an earlier version of this manuscript recieved both positive and negative comments about the scope of this article).
|
| 274 |
+
|
| 275 |
+
(b) Did you describe the limitations of your work? [Yes] It is mentioned that future work must extend our simulations to much higher dimensions to serve as a practical demonstration of deep functionality by shallow recurrent networks. Also the simulation parameters were found by trial and error, instead of being derived analytically from the theoretical formalism - these limitations are mentioned in the discussion.
|
| 276 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A]
|
| 277 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 278 |
+
|
| 279 |
+
2. If you are including theoretical results...
|
| 280 |
+
|
| 281 |
+
(a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
|
| 282 |
+
|
| 283 |
+
3. If you ran experiments...
|
| 284 |
+
|
| 285 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Check Appendix for the code to reproduce Figure 2.
|
| 286 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [N/A]
|
| 287 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
|
| 288 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [N/A] It is evident that Figure 2 is not a large-scale deep learning experiment but a small-scale conceptual simulation which takes less than 2 seconds on a modern desktop CPU.
|
| 289 |
+
|
| 290 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 291 |
+
|
| 292 |
+
(a) If your work uses existing assets, did you cite the creators? [N/A]
|
| 293 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 294 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [No]
|
| 295 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 296 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 297 |
+
|
| 298 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 299 |
+
|
| 300 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 301 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 302 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
| 303 |
+
|
| 304 |
+
# 299 A Appendix
|
| 305 |
+
|
| 306 |
+
300 Wolfram Mathematica code to reproduce Figure 2.
|
| 307 |
+
|
| 308 |
+
$\quad I n f \circ J { : } =$ simulate $[ f _ { - }$ , $g _ { - }$ , $\gamma \_ 1 : =$ (sys $=$ NonlinearStateSpaceModel[{ {x1 - (2 f) ${ \pmb { s } } { \pmb { 1 } } + { \pmb { f } }$ ( $\mathsf { s } 2 + \mathsf { s } 3 \mathrm { \mathrm { ; } }$ ) - Abs[g〚1〛 \* s1 - (g〚1〛 $^ +$ g〚3〛) Ramp[s1 - g〚2〛]], x2 - (f) $\mathsf { s } \mathsf { 2 } + \mathsf { f }$ (s1) - Abs[ $\mathcal { Y }$ 〚1〛 s2 - ( $\mathbf { \mathcal { V } } [ [ \mathbf { 1 } ] ] + \mathbf { \mathcal { V } } [ [ \mathbf { 3 } ] ]$ ) Ramp[s2 - γ 〚2〛]], x3 - (f) $\mathsf { s } \mathsf { 3 } + \mathsf { f }$ (s1) - Abs[ $\mathcal { Y }$ 〚1〛 s3 - ( $\mathbf { \mathcal { V } } [ [ \mathbf { 1 } ] ] + \mathbf { \mathcal { V } } [ [ \mathbf { 3 } ] ]$ ) Ramp[s3 - $\mathcal { Y }$ 〚2〛]]}, {x1, $\times 2$ , $\times 3$ , Xor[x1, $\times 2$ , $\times 3 ]$ , s1, s2, s3, $\mathbf { y } =$ Abs[g〚1〛 s1 - (g〚1〛 ${ } + g$ 〚3〛) Ramp[s1 - g〚2〛]], HeavisideTheta[y - .15]} }, {s1, s2, s3}, $\{ \mathbf { x 1 } , \mathbf { x 2 } , \mathbf { x 3 } \} ]$ ; inputs $= \{ . 5 - . 5 \star$ SquareWave[ t / 50], .5 - . $^ { ; \star }$ SquareWave[ t / 100], .5 - .5 $^ { \star }$ SquareWave[ t / 200]}; out $\equiv$ OutputResponse[{sys, {0, 0}}, inputs, {t, 0, 200}]; GraphicsColumn@Table[Plot[out〚i〛, {t, 0, 200}, PlotRange All, Ticks {Automatic, {0, 1 / 5, 1, 2}}], {i, 9}])
|
md/dev/5HLoTvVGDe/5HLoTvVGDe.md
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DUAL DIFFUSION IMPLICIT BRIDGES FOR IMAGE-TO-IMAGE TRANSLATION
|
| 2 |
+
|
| 3 |
+
Xuan $\mathbf { S u } ^ { 1 }$ Jiaming Song2 Chenlin Meng1 Stefano Ermon1,3 1Stanford University 2NVIDIA 3CZ Biohub {suxuan,chenlin,ermon}@cs.stanford.edu,jiamings@nvidia.com
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Common image-to-image translation methods rely on joint training over data from both source and target domains. The training process requires concurrent access to both datasets, which hinders data separation and privacy protection; and existing models cannot be easily adapted for translation of new domain pairs. We present Dual Diffusion Implicit Bridges (DDIBs), an image translation method based on diffusion models, that circumvents training on domain pairs. Image translation with DDIBs relies on two diffusion models trained independently on each domain, and is a two-step process: DDIBs first obtain latent encodings for source images with the source diffusion model, and then decode such encodings using the target model to construct target images. Both steps are defined via ordinary differential equations (ODEs), thus the process is cycle consistent only up to discretization errors of the ODE solvers. Theoretically, we interpret DDIBs as concatenation of source to latent, and latent to target Schrodinger Bridges, a form of entropy-regularized ¨ optimal transport, to explain the efficacy of the method. Experimentally, we apply DDIBs on synthetic and high-resolution image datasets, to demonstrate their utility in a wide variety of translation tasks and their inherent optimal transport properties.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Transferring images from one domain to another while preserving the content representation is an important problem in computer vision, with wide applications that span style transfer (Xu et al., 2021; Sinha et al., 2021) and semantic segmentation (Li et al., 2020). In tasks such as style transfer, it is usually difficult to obtain paired images of realistic scenes and their artistic renditions. Consequently, unpaired translation methods are particularly relevant, since only the datasets, and not the one-toone correspondence between image translation pairs, are required. Common methods on unpaired translation are based on generative adversarial networks (GANs, Goodfellow et al. (2014); Zhu et al. (2017)) or normalizing flows (Grover et al., 2020). Training such models typically involves minimizing an adversarial loss between a specific pair of source and target datasets.
|
| 12 |
+
|
| 13 |
+
While capable of producing high-quality images, these methods suffer from a severe drawback in their adaptability to alternative domains. Concretely, a translation model on a source-target pair is trained specifically for this domain pair. Provided a different pair, existing, bespoke models cannot be easily adapted for translation. If we were to do pairwise translation among a set of domains, the total number of models needed is quadratic in the number of domains – an unacceptable computational cost in practice. One alternative is to find a shared domain that connects to each source / target domains as in StarGANs (Choi et al., 2018). However, the shared domain needs to be carefully chosen a priori; if the shared domain contains less information than the target domain (e.g. sketches v.s. photos), then it creates an unwanted information bottleneck between the source and target domains.
|
| 14 |
+
|
| 15 |
+
An additional disadvantage of existing models resides in their lack of privacy protection of the datasets: training a translation model requires access to both datasets simultaneously. Such setting may be inconvenient or impossible, when data providers are reluctant about giving away their data; or for certain privacy-sensitive applications such as medical imaging. For example, quotidian hospital usage may require translation of patients’ X-ray and MRI images taken from machines in other hospitals. Most existing methods will fail in such scenarios, as joint training requires aggregating confidential imaging data across hospitals, which may violate patients’ privacy.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Dual Diffusion Implicit Bridges: DDIBs leverage two ODEs for image translation. Given a source image $\mathbf { x } ^ { ( s ) }$ , the source ODE runs in the forward direction to convert it to the latent $\mathbf { x } ^ { ( l ) }$ , while the target, reverse ODE then constructs the target image $\mathbf { x } ^ { ( t ) }$ . $( T o p )$ Illustration of the DDIBs idea between two one-dimensional distributions. (Bottom) DDIBs from a tiger to a cat using a pretrained conditional diffusion model.
|
| 19 |
+
|
| 20 |
+
In this paper, we seek to mitigate both problems of existing image translation methods. We present Dual Diffusion Implicit Bridges (DDIBs), an image-to-image translation method inspired by recent advances in diffusion models (Song et al., 2020a;b), that decouples paired training, and empowers the domain-specific diffusion models to stay applicable in other pairs wherever the domain appears again as the source or the target. Since the training process now concentrates on one dataset at a time, DDIBs can also be applied in federated settings, and not assume access to both datasets during model training. As a result, owners of domain data can effectively preserve their data privacy.
|
| 21 |
+
|
| 22 |
+
Specifically, DDIBs are developed based on the method known as denoising diffusion implicit models (DDIMs, Song et al. (2020a)). DDIMs invent a particular parameterization of the diffusion process, that creates a smooth, deterministic and reversible mapping between images and their latent representations. This mapping is captured using the solution to a so-called probability flow (PF) ordinary differential equation (ODE) that forms the cornerstone of DDIBs. Translation with DDIBs on a source-target pair requires two different PF ODEs: the source PF ODE converts input images to the latent space; while the target ODE then synthesizes images in the target domain.
|
| 23 |
+
|
| 24 |
+
Crucially, trained diffusion models are specific to the individual domains, and rely on no domain pairing information. Effectively, DDIBs make it possible to save a trained model of a certain domain for future use, when it arises as the source or target in a new pair. Pairwise translation with DDIBs requires only a linear number of diffusion models (which can be further reduced with conditional models (Dhariwal & Nichol, 2021)), and training does not require scanning both datasets concurrently.
|
| 25 |
+
|
| 26 |
+
Theoretically, we analyze the DDIBs translation process to highlight two important theoretical properties. First, the probability flow ODEs in DDIBs, in essence, comprise the solution of a special Schrodinger Bridge Problem (SBP) with linear or degenerate drift (Chen et al., 2021a), between the ¨ data and the latent distributions. This justification of DDIBs from an optimal transport viewpoint that alternative translation methods lack serves as a theoretical advantage of our method, as DDIBs are the most OT-efficient translation procedure while alternate methods may not be. Second, DDIBs guarantee exact cycle consistency: translating an image to and back from the target space reinstates the original image, only up to discretization errors introduced in the ODE solvers.
|
| 27 |
+
|
| 28 |
+
Experimentally, we first present synthetic experiments on two-dimensional datasets to demonstrate DDIBs’ cycle-consistency property. We then evaluate our method on a variety of image modalities, with qualitative and quantitative results: we validate its usage in example-guided color transfer, paired image translation, and conditional ImageNet translation. These results establish DDIBs as a scalable, theoretically rigorous addition to the family of unpaired image translation methods.
|
| 29 |
+
|
| 30 |
+
# 2 PRELIMINARIES
|
| 31 |
+
|
| 32 |
+
# 2.1 SCORE-BASED GENERATIVE MODELS (SGMS)
|
| 33 |
+
|
| 34 |
+
While our actual implementation utilizes DDIMs, we first briefly introduce the broader family of models known as score-based generative models. Two representative models of this family are score matching with Langevin dynamics (SMLD) (Song & Ermon, 2019) and denoising diffusion
|
| 35 |
+
|
| 36 |
+
probabilistic models (DDPMs) (Ho et al., 2020). Both methods are contained within the framework of Stochastic Differential Equations (SDEs) proposed in Song et al. (2020b).
|
| 37 |
+
|
| 38 |
+
Stochastic Differential Equation (SDE) Representation Song et al. (2020b); Anderson (1982) use a forward and a corresponding backward SDE to describe general diffusion and the reversed, generative processes:
|
| 39 |
+
|
| 40 |
+
$$
|
| 41 |
+
\mathrm { d } \mathbf { x } = \mathbf { f } ( \mathbf { x } , t ) \mathrm { d } t + g ( t ) \mathrm { d } \mathbf { w } , \quad \mathrm { d } \mathbf { x } = [ \mathbf { f } - g ^ { 2 } \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } ) ] \mathrm { d } t + g ( t ) \mathrm { d } \mathbf { w }
|
| 42 |
+
$$
|
| 43 |
+
|
| 44 |
+
where w is the standard Wiener process, $\mathbf { f } \left( \mathbf { x } , t \right)$ is the vector-valued drift coefficient, $g ( t )$ is the scalar diffusion coefficient, and $\nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } )$ is the score function of the noise perturbed data distribution (as defined by the forward SDE with initial condition $p _ { 0 } ( \mathbf { x } )$ being the data distribution). At the endpoints $t = \{ 0 , 1 \bar \}$ , the forward Eq. (1) admits the data distribution $p _ { 0 }$ and the easy-to-sample prior $p _ { 1 }$ as the boundary distributions. Within this framework, the SMLD method can be described using a VarianceExploding (VE) SDE with increasing noise scales $\sigma ( t )$ : $\mathrm { d } \mathbf { x } = \sqrt { \mathrm { d } [ \sigma ^ { 2 } ( t ) ] / \mathrm { d } t }$ dw. In comparison, DDPMs are endowed with a Variance-Preserving (VP) SDE: $\mathrm { d } \mathbf { x } = - [ \beta ( t ) / 2 ] \mathbf { x } \mathrm { d } t + \sqrt { \beta ( t ) } \mathrm { d } \mathbf { w }$ with $\beta ( t )$ being another noise sequence. Notably, the VP SDE can be reparameterized into an equivalent VE SDE (Song et al., 2020a).
|
| 45 |
+
|
| 46 |
+
Probability Flow ODE Any diffusion process can be represented by a deterministic ODE that carries the same marginal densities as the diffusion process throughout its trajectory. This ODE is termed the probability flow (PF) ODE (Song et al., 2020b). PF ODEs enable uniquely identifiable encodings (Song et al., 2020b) of data, and are central to DDIBs as we solve these ODEs for forward and reverse conversion between data and their latents. For the forward SDE introduced in Eq. (1), the equivalent PF ODE holds the following form:
|
| 47 |
+
|
| 48 |
+
$$
|
| 49 |
+
\mathrm { d } \mathbf { x } = \left[ \mathbf { f } ( \mathbf { x } , t ) - \frac { 1 } { 2 } g ( t ) ^ { 2 } \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } ) \right] \mathrm { d } t
|
| 50 |
+
$$
|
| 51 |
+
|
| 52 |
+
which follows immediately from the SDEs given the score function. In practice, we use $\theta$ - parameterized score networks $\mathbf { s } _ { t , \theta } \approx \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } )$ to approximate the score function. Training such networks relies on a variational lower bound, described in Ho et al. (2020) and in Appendix B. We may then employ numerical ODE solvers to solve the above ODE and construct $\mathbf { x }$ at different times. Empirically, it has been demonstrated that SGMs have relatively low discretization errors when reconstructing $\mathbf { x }$ at $t = 0$ via ODE solvers (Song et al., 2020a). For conciseness, we use $v _ { \theta } = \mathrm { d } \mathbf { x } / \mathrm { d } t$ to denote the $\theta$ -parameterized velocity field (as defined from Eq. (2), where we replace $\nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } )$ with $\mathbf { s } _ { t , \theta }$ ), and use the symbol ODESolve to denote the mapping from $\mathbf { x } ( t _ { 0 } )$ to $\mathbf { x } ( t _ { 1 } )$ :
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
\mathrm { O D E S o l v e } ( \mathbf { x } ( t _ { 0 } ) ; v _ { \theta } , t _ { 0 } , t _ { 1 } ) = \mathbf { x } ( t _ { 0 } ) + \int _ { t _ { 0 } } ^ { t _ { 1 } } v _ { \theta } ( t , \mathbf { x } ( t ) ) \mathrm { d } t ,
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
which allows us to abstract away the exact model (be it a score-based or a diffusion model), or the integrator used. In our experiments, we implement the ODE solver in DDIMs (Song et al., 2020a) (Appendix B); while we acknowledge other available ODE solvers that are usable within our framework, such as the DPM-solver (Lu et al., 2022), the Exponential Integrator (Zhang & Chen, 2022), and the second-order Heun solver (Karras et al., 2022).
|
| 59 |
+
|
| 60 |
+
# 2.2 SCHRODINGER ¨ BRIDGE PROBLEM (SBP)
|
| 61 |
+
|
| 62 |
+
Our analysis shows that DDIBs are Schrodinger Bridges (Chen et al., 2016; L ¨ eonard, 2013) between ´ distributions. Let $\Omega = C ( [ 0 , 1 ] ; \mathbb { R } ^ { n } )$ be the path space of $\mathbb { R } ^ { n }$ -valued continuous functions over the time interval $[ 0 , 1 ]$ ; and $\mathcal { D } ( p _ { 0 } , p _ { 1 } )$ be the set of distributions over $\Omega$ , with marginals $p _ { 0 } , p _ { 1 }$ at time $t = 0$ , $t = 1$ , respectively. Given a prior reference measure $W ^ { 1 }$ , the well-known Schrodinger Bridge ¨ Problem (SBP) seeks the most probable evolution across time $t$ between the marginals $p _ { 0 }$ and $p _ { 1 }$ :
|
| 63 |
+
|
| 64 |
+
Problem 1 (Schrodinger Bridge Problem) ¨ . With prescribed distributions $p _ { 0 } , p _ { 1 }$ and a reference measure $W$ as the prior, the SBP finds a distribution from $\mathcal { D } ( p _ { 0 } , p _ { 1 } )$ that minimizes its $K L$ -divergence to $W$ : $P _ { S B P } : = \arg \operatorname* { m i n } \{ D _ { K L } ( P \| W ) \ | \ P \in \mathcal { D } ( p _ { 0 } , p _ { 1 } ) \} .$ .
|
| 65 |
+
|
| 66 |
+
# Algorithm 1 High-level Pseudo-code for DDIBs
|
| 67 |
+
|
| 68 |
+
Input: data sample from source domain $\mathbf { x } ^ { ( s ) } \sim p _ { s } ( \mathbf { x } )$ , source model $v _ { \theta } ^ { ( s ) }$ , target model $v _ { \theta } ^ { ( t ) }$ . Output: $\mathbf { x } ^ { ( t ) }$ , the result in the target domain.
|
| 69 |
+
$\mathbf { x } ^ { ( l ) } = \mathrm { O D E S o l v e } ( \mathbf { x } ^ { ( s ) } ; v _ { \theta } ^ { ( s ) } , 0 , 1 )$ // obtain latent code from source domain data $\mathbf { x } ^ { ( t ) } = \mathrm { O D E S o l v e } ( \mathbf { x } ^ { ( l ) } ; v _ { \theta } ^ { ( t ) } , 1 , 0 )$ // obtain target domain data from latent code
|
| 70 |
+
return $\mathbf { x } ^ { ( t ) }$
|
| 71 |
+
|
| 72 |
+
The minimizer, $P _ { \mathrm { S B P } }$ , is dubbed the Schrodinger Bridge ¨ between $p _ { 0 }$ and $p _ { 1 }$ over prior $W$ . The SBP has connections to the Monge-Kantorovich (MK) optimal transport problem (Chen et al., 2021b). While the basic MK problem seeks the cost-minimizing plan to transport masses between distributions, the SBP incorporates an additional entropy term (for details, see Page 61 of Peyre et al. (2019)) . ´
|
| 73 |
+
|
| 74 |
+
Relationship Between SBPs and SGMs Chen et al. (2021a) establishes connections between SGMs and SBPs. In summary, SGMs are implicit optimal transport models, corresponding to SBPs with linear or degenerate drifts. General SBPs additionally accept fully nonlinear diffusion. To formalize this observation, the authors first establish similar forward and backward SDEs for SBPs:
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
\begin{array} { r } { \mathbf { d x } = [ \mathbf { f } + g ^ { 2 } \nabla _ { \mathbf { x } } \log \Phi _ { t } ( \mathbf { x } ) ] \mathbf { d } t + g ( t ) \mathbf { d w } , \quad \mathbf { d x } = [ \mathbf { f } - g ^ { 2 } \nabla _ { \mathbf { x } } \log \hat { \Phi } _ { t } ( \mathbf { x } ) ] \mathbf { d } t + g ( t ) \mathbf { d w } } \end{array}
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
where $\Phi , { \hat { \Phi } }$ are the Schrodinger factors ¨ that satisfy density factorization: $p _ { t } ( { \bf x } ) = \Phi _ { t } ( { \bf x } ) \hat { \Phi } _ { t } ( { \bf x } )$ . The vector-valued quantities $\mathbf { z } _ { t } = g ( t ) \nabla _ { \mathbf { x } } \log \Phi _ { t } ( \mathbf { x } ) , \hat { \mathbf { z } } _ { t } = g ( t ) \nabla _ { \mathbf { x } } \log \hat { \Phi } _ { t } ( \mathbf { x } )$ fully characterize dynamics of the SBP, thus can be considered as the forward, backward “policies”, analogous to policy-based methods described in Schulman et al. (2015); Pereira et al. (2019). To draw a link between SBPs and SGMs, the data log-likelihood objective for SBPs is computed and shown to be equal to that of SGMs with special choices of $\mathbf { z } _ { t } , \hat { \mathbf { z } } _ { t }$ (derivation details in Chen et al. (2021a)). Importantly, likelihood equality occurs with the following policies:
|
| 81 |
+
|
| 82 |
+
$$
|
| 83 |
+
( \mathbf { z } _ { t } , \hat { \mathbf { z } } _ { t } ) = ( 0 , g ( t ) \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } ) )
|
| 84 |
+
$$
|
| 85 |
+
|
| 86 |
+
When the marginal $p _ { 1 }$ at time $t = 1$ is equal to the prior distribution, it is known that such $( \mathbf { z } _ { t } , \hat { \mathbf { z } } _ { t } )$ are achieved. Since in SGMs, the end marginal $p _ { 1 }$ is indeed the standard Gaussian prior, their log-likelihood is equivalent to that of SBPs. This suggests that SGMs are a special case of SBPs with degenerate forward policy $\mathbf { z } _ { t }$ and a multiple of the score function as its backward $\hat { \mathbf { z } } _ { t }$ .
|
| 87 |
+
|
| 88 |
+
Probability Flow ODE In a similar vein to the SGM SDEs, a deterministic PF ODE can be derived for SBPs with identical marginal densities across $t \in [ 0 , 1 ]$ . The following PF ODE specifies the probability flow of the optimal processes of the SBP defined in Eq. (4) (Chen et al., 2021a):
|
| 89 |
+
|
| 90 |
+
$$
|
| 91 |
+
\mathrm { d } \mathbf { x } = \bigg [ \mathbf { f } ( \mathbf { x } , t ) + g ( t ) \mathbf { z } - \frac { 1 } { 2 } g ( t ) ( \mathbf { z } + \hat { \mathbf { z } } ) \bigg ] \mathrm { d } t
|
| 92 |
+
$$
|
| 93 |
+
|
| 94 |
+
where $\mathbf { z }$ depends on x. We shall show that the PF ODEs for SGMs and SBPs are equivalent. Thus, flowing through the PF ODEs in DDIBs is equivalent to flowing through special Schrodinger Bridges, ¨ with one of the marginals being Gaussian.
|
| 95 |
+
|
| 96 |
+
# 3 DUAL DIFFUSION IMPLICIT BRIDGES
|
| 97 |
+
|
| 98 |
+
DDIBs leverage the connections between SGMs and SBPs to perform image-to-image translation, with two diffusion models trained separately on the two domains. DDIBs contain two steps, described in Alg. 1 and illustrated in Fig. 1. At the core of the algorithm is the ODE solver ODESolve from Eq. (3). Given a source model represented as a vector field, i.e., $v _ { \theta } ^ { ( s ) }$ defined from Eq. (2), DDIBs first apply ODESolve in the source domain to obtain the encoding $\mathbf { x } ^ { ( s ) }$ of the image at the end time $t = 1$ ; we refer to this as the latent code (associated with the diffusion model for the domain). Then, the source latent code is fed as the initial condition (target latent code at $t = 1$ ) to ODESolve with the target model $v _ { \theta } ^ { ( t ) }$ to obtain the target image $\mathbf { x } ^ { ( t ) }$ . As discussed earlier, we implement ODESolve with DDIMs (Song et al., 2020a), which are known to have reasonably small discretization errors. While recent developments in higher order ODE solvers (Zhang & Chen, 2022; Lu et al., 2022; Karras et al., 2022) that generalize DDIMs can also be used here, we leave this investigation to future work.
|
| 99 |
+
|
| 100 |
+
Despite the simplicity of the method, DDIBs have several advantages over prior methods, which we discuss below.
|
| 101 |
+
|
| 102 |
+
Exact Cycle Consistency A desirable feature of image translation algorithms is the cycle consistency property: transforming a data point from the source domain to the target domain, and then back to source, will recover the original data point in the source domain. The following proposition validates the cycle consistency of DDIBs.
|
| 103 |
+
|
| 104 |
+
Proposition 3.1 (DDIBs Enforce Exact Cycle Consistency). Given a sample from source domain $\mathbf { x } ^ { ( s ) }$ , a source diffusion model $v _ { \theta } ^ { ( s ) }$ , and a target model $v _ { \theta } ^ { ( t ) }$ , define:
|
| 105 |
+
|
| 106 |
+
$$
|
| 107 |
+
\begin{array} { r } { \begin{array} { r } { { \mathbf { x } } ^ { ( l ) } = \mathrm { O D E S o l v e } ( { \mathbf { x } } ^ { ( s ) } ; v _ { \theta } ^ { ( s ) } , 0 , 1 ) ; \quad { \mathbf { x } } ^ { ( t ) } = \mathrm { O D E S o l v e } ( { \mathbf { x } } ^ { ( l ) } ; v _ { \theta } ^ { ( t ) } , 1 , 0 ) ; } \\ { { \mathbf { x } } ^ { \prime ( l ) } = \mathrm { O D E S o l v e } ( { \mathbf { x } } ^ { ( t ) } ; v _ { \theta } ^ { ( t ) } , 0 , 1 ) ; \quad { \mathbf { x } } ^ { \prime ( s ) } = \mathrm { O D E S o l v e } ( { \mathbf { x } } ^ { \prime ( l ) } ; v _ { \theta } ^ { ( s ) } , 1 , 0 ) } \end{array} } \end{array}
|
| 108 |
+
$$
|
| 109 |
+
|
| 110 |
+
Assume zero discretization error. Then, $\mathbf { x } ^ { ( s ) } = \mathbf { x } ^ { \prime ( s ) }$
|
| 111 |
+
|
| 112 |
+
As PF ODEs are used, the cycle consistency property is guaranteed. In practice, even with discretization error, DDIBs incur almost negligible cycle inconsistency (Section 4.1). In contrast, GAN-based methods are not guaranteed the cycle consistency property by default, and have to incorporate additional training terms to optimize for cycle consistency over two domains.
|
| 113 |
+
|
| 114 |
+
Data Privacy in Both Domains In the DDIBs translation process, only the source and target diffusion models are required, whose training processes do not depend on knowledge of the domain pair a priori. In fact, this process can even be performed in a privacy sensitive manner (graphic illustration in Appendix A). Let Alice and Bob be the data owners of the source and target domains, respectively. Suppose Alice intends to translate images to the target domain. However, Alice does not want to share the data with Bob (and vice versa, Bob does not want to release their data either). Then, Alice can simply train a diffusion model with the source data, encode the data to the latent space, transmit the latent codes to Bob, and next ask Bob to run their trained diffusion model and send the results back. In this procedure, only the latent code and the target results are transmitted between the two data vendors, and both parties have naturally ensured that their data are not directly revealed.
|
| 115 |
+
|
| 116 |
+
DDIBs are Two Concatenated Schrodinger Bridges ¨ DDIBs link the source data distribution to the latent space, and then to the target distribution. What is the nature of such connections between distributions? We offer an answer from an optimal transport perspective: these connections are special Schrodinger Bridges ¨ between distributions. This, in turn, explicates the name of our method: dual diffusion implicit bridges are based on denoising diffusion implicit models (Song et al., 2020a), and consist of two separate Schrodinger ¨ Bridges that connect the data and latent distributions. Specifically, as considered earlier, when conditions about the policies $\mathbf { z } _ { t } , \hat { \mathbf { z } } _ { t }$ in Eq. (5) and the density $p _ { 1 } ( \mathbf { x } )$ being a Gaussian prior are met, the data likelihoods (at $t = 0$ ) for SGMs and SBPs are identical. Indeed, these conditions are fulfilled in SGMs and particularly in DDIMs. This verifies SGMs as special linear or degenerate SBPs. Forward and reverse solving the PF ODE for SGMs, as done in DDIBs, is equivalent to flowing through the optimal processes of particular SBPs:
|
| 117 |
+
|
| 118 |
+
Proposition 3.2 (PF ODE Equivalence2). Eq. (2) is equivalent to Eq. (6) with forward, backward policies $( \mathbf { z } _ { t } , \hat { \mathbf { z } } _ { t } ) = ( 0 , g \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } ) )$ as attained in SGMs and particularly in DDIMs.
|
| 119 |
+
|
| 120 |
+
Thus, DDIBs are intrinsically entropy-regularized optimal transport: they are Schrodinger Bridges ¨ between the source and the latent, and between the latent and the target distributions. The translation process can then be recognized as traversing through two concatenated Schrodinger Bridges, one ¨ forward and one reversed. The mapping is unique and minimizes a (regularized) optimal transport objective, which probably elucidates the superior performance of DDIBs. In contrast, if we train the source and target models separately with normalizing flow models that are not inborn with such a connection, there are many viable invertible mappings, and the resulting image translation algorithm may not necessarily have good performance. This is probably the reason why AlignFlow (Grover et al., 2020) still has to incorporate an adversarial loss even when cycle-consistency is guaranteed.
|
| 121 |
+
|
| 122 |
+
Table 1: Cycle consistency of DDIBs. Experiment legend, PR $\bigcirc$ PS, means that we translate from PR to PS and then back. The numbers are the averaged L2 distances between the original points and their coordinates after cycle translation. Data points are standardized to have unit variance.
|
| 123 |
+
|
| 124 |
+
<table><tr><td>PR OPS</td><td>PS OCS</td><td>CR OPR</td><td>CR O CS</td><td>MO CB</td></tr><tr><td>0.0143</td><td>0.0065</td><td>0.0106</td><td>0.0078</td><td>0.0122</td></tr></table>
|
| 125 |
+
|
| 126 |
+
# 4 EXPERIMENTS
|
| 127 |
+
|
| 128 |
+
We present a series of experiments to demonstrate the effectiveness of DDIBs. First, we describe synthetic experiments on two-dimensional datasets, to corroborate DDIBs’ cycle-consistent and optimal transport properties. Next, we validate DDIBs on a variety of image translation tasks, including color transfer, paired translation, and conditional ImageNet translation. 34
|
| 129 |
+
|
| 130 |
+
# 4.1 2D SYNTHETIC EXPERIMENTS
|
| 131 |
+
|
| 132 |
+
We first perform domain translation on synthetic datasets drawn from complex two-dimensional distributions, with various shapes and configurations, in Fig. 2a. In total, we consider six 2D datasets: Moons (M); Checkerboards (CB); Concentric Rings (CR); Concentric Squares (CS); Parallel Rings (PR); and Parallel Squares (PS). The datasets are all normalized to have zero mean, and identity covariance. We assign colors to points based on the point identities (i.e., if a point in the source domain is red, its corresponding point in the target domain is also colored red). Clearly, the transformation is smooth between columns. For example, on the top-right corner, red points in the CR dataset are mapped to similar coordinates, both in the latent and in the target dimensions.
|
| 133 |
+
|
| 134 |
+
(a) Smooth translation of synthetic datasets. (Left) The source datasets: CR and CS. (Middle) DDIBs’ latent code representation. (Right) Results of translation to the target domains.
|
| 135 |
+
|
| 136 |
+

|
| 137 |
+
(b) Cycle consistency: After translating the Moons dataset to Checkerboards and then back to Moons, DDIBs restore almost the exact same points as the original ones.
|
| 138 |
+
Figure 2: Smoothness and cycle consistency of DDIBs.
|
| 139 |
+
|
| 140 |
+
Cycle Consistency Fig. 2b illustrates the cycle consistency property guaranteed by DDIBs. It concerns 2D datasets: Moons, and Checkerboards. Starting from the Moons dataset, DDIBs first obtain the latent codes and construct the Checkerboards points. Next, DDIBs do translations in the reverse direction, transforming the points back to the latent and the Moons space. After this round trip, points are approximately mapped to their original positions. A similar, smooth color topology is observed in this experiment. Table 1 reports quantitative evaluation results on cycle-consistent translation among multiple datasets. As the datasets are normalized to unit standard deviation, the reported values are negligibly small and endorse the cycle consistent property of DDIBs.
|
| 141 |
+
|
| 142 |
+
Table 2: Mean Squared Error (MSE) comparing color transfer results of DDIBs with common OT methods on two images. Each number represents the MSE between DDIBs and the corresponding OT method. MSE is computed pixel-wise after normalizing images to $[ - 1 , 1 ]$ .
|
| 143 |
+
|
| 144 |
+
<table><tr><td>IMAGE</td><td>EMD</td><td>SINKHORN</td><td>LINEAR</td><td>GAUSSIAN</td></tr><tr><td>TARGET1</td><td>0.0337</td><td>0.0281</td><td>0.0352</td><td>0.0370</td></tr><tr><td>TARGET 2</td><td>0.0293</td><td>0.0326</td><td>0.0500</td><td>0.0751</td></tr></table>
|
| 145 |
+
|
| 146 |
+
Table 3: MSE comparing DDIBs and baselines on paired test sets. MSE is computed pixel-wise after normalizing images to $[ - 1 , 1 ]$ .
|
| 147 |
+
|
| 148 |
+
<table><tr><td>DATASET</td><td>MODEL</td><td>A→B</td><td>B→A</td><td>DATASET</td><td>MODEL</td><td>A→B</td><td>B→A</td></tr><tr><td rowspan="3">FACADES</td><td>CYCLEGAN</td><td>0.7129</td><td>0.3286</td><td rowspan="3">MAPS</td><td>CYCLEGAN</td><td>0.0245</td><td>0.0953</td></tr><tr><td>ALIGNFLOW</td><td>0.5801</td><td>0.2512</td><td>ALIGNFLOW</td><td>0.0209</td><td>0.0897</td></tr><tr><td>DDIBS</td><td>0.5312</td><td>0.3946</td><td>DDIBS</td><td>0.0194</td><td>0.1302</td></tr></table>
|
| 149 |
+
|
| 150 |
+
# 4.2 EXAMPLE-GUIDED COLOR TRANSFER
|
| 151 |
+
|
| 152 |
+
DDIBs can be used on an interesting application: example-guided color transfer. This refers to the task of modifying the colors of an input image, conditioned on the color palette of a reference image. To use DDIBs for color transfer, we train one diffusion model per image, on its normalized RGB space. During translation, DDIBs obtain encodings of the original colors, and apply the diffusion model of the reference image to attain the desired color palette. Fig. 3 visualizes our color experiments.
|
| 153 |
+
|
| 154 |
+
Comparison to Alternative OT Methods As DDIBs are related to regularized OT, we compare the pixel-wise MSEs between color-transferred images generated by DDIBs, and images produced by alternate methods, in Table 2. We include four OT methods for comparison: Earth Mover’s Distance; Sinkhorn distance (Cuturi, 2013); linear and Gaussian mapping estimation (Perrot et al., 2016). Results of DDIBs are very close to those of OT methods. Appendix E.2 details full color translation results.
|
| 155 |
+
|
| 156 |
+

|
| 157 |
+
Figure 3: Example-Guided Color Transfer: Given the first image as the reference image, DDIBs modify the colors of two input images to similarly follow a snowy winter color palette.
|
| 158 |
+
|
| 159 |
+
# 4.3 QUANTITATIVE TRANSLATION EVALUATION
|
| 160 |
+
|
| 161 |
+
Quantitatively, we demonstrate that DDIBs deliver competitive results on paired domain tests. Such numerical evaluation is despite that DDIBs are formulated with a weaker setting: diffusion models are trained independently, on separate datasets. In comparison, methods such as CycleGAN and AlignFlow assume access to both datasets during training and jointly optimize for the translation loss.
|
| 162 |
+
|
| 163 |
+
Paired Domain Translation As in similar works, we evaluate DDIBs on benchmark paired datasets (Zhu et al., 2017): Facades and Maps. Both are image segmentation tasks. In the pairs of datasets, one dataset contains real photos taken via a camera or a satellite; while the other comprises the corresponding segmentation images. These datasets provide one-to-one image alignment, which allows quantitative evaluation through a distance metric such as mean-squared error (MSE) between generated samples and the corresponding ground truth. To facilitate the workings of DDIBs, we additionally employ a color conversion heuristic motivated by optimal transport on image colors (Appendix E.1). Table 3 reports the evaluation results. Surprisingly, DDIBs are able to produce segmentation images that surpass alternative methods in MSE terms; while reverse translations also achieve decent performance.
|
| 164 |
+
|
| 165 |
+
# 4.4 CLASS-CONDITIONAL IMAGENET TRANSLATION
|
| 166 |
+
|
| 167 |
+
In this experiment, we apply DDIBs to translation among ImageNet classes. To this end, we leverage the pretrained diffusion models from Dhariwal & Nichol (2021). The authors optimized performance of diffusion models, and end up with a “UNet” (Ho et al., 2020) architecture with particular width, attention and residual configurations. The models are learned on 1, 000 ImageNet classes, each with around 1, 000 training images, and at a variety of resolutions. Our experiments use the model with resolution $2 5 6 \times 2 5 6$ . Moreover, these models incorporate a technique known as classifier guidance (Dhariwal & Nichol, 2021), that leverage classifier gradients to steer the sampling process towards arbitrary class labels during image generation. The learned models combined with classifier guidance can be effectively considered as 1, 000 different models. Fig. 4a exhibits select translation samples, where the source images are from ImageNet validation sets. DDIBs are able to create faithful target images that maintain much of the original content such as animal poses, complexions and emotions, while accounting for differences in animal species.
|
| 168 |
+
|
| 169 |
+
Multi-Domain Translation Given conditional models on the individual domains, DDIBs can be applied to translate between arbitrary pairs of source-target domains, while requiring no additional fine-tuning or adaptation. Fig. 4b displays results of translating a common image of a roaring lion (with class label 291), to various other ImageNet classes. Interestingly, some animals roar, while others stick their tongues out. DDIBs successfully internalize characteristics of distinct animal species, and produce closest animal postures in OT distances to the original shouting lion.
|
| 170 |
+
|
| 171 |
+

|
| 172 |
+
(a) Conditional ImageNet Translation: Selected trans- (b) Multi-domain translation: Given the center, lation samples from various ImageNet classes such as 7: source image from class label 291, DDIBs translate Cock, 94: Hummingbird, 162: Beagle, and 282: Tiger it to other animal species, entirely using only a preCat. trained conditional diffusion model.
|
| 173 |
+
|
| 174 |
+

|
| 175 |
+
Figure 4: Translation among ImageNet classes.
|
| 176 |
+
|
| 177 |
+
# 5 RELATED WORKS
|
| 178 |
+
|
| 179 |
+
Score-based Diffusion Models Originating in thermodynamics (Sohl-Dickstein et al., 2015), diffusion models reverse the dynamics of a noising process to create data samples. The reversal process is understood to implicitly compute scores of the data density at various noise scales, which reveals connections to score-based methods (Song & Ermon, 2019; Nichol & Dhariwal, 2021; Meng et al., 2021b). Diffusion models are applicable to multiple modalities: 3D shapes (Zhou et al., 2021), point cloud (Luo & Hu, 2021), discrete domains (Meng et al., 2022) and function spaces (Lim et al., 2023). They excel in tasks ranging from image editing and composition (Meng et al., 2021a), density estimation (Kingma et al., 2021), to image restoration (Kawar et al., 2022). Seminal works are denoising diffusion probabilistic models (DDPMs, Ho et al. (2020)), which parameterized the ELBO objective with Gaussians and, for the first time, synthesized high-quality images with diffusion models; ILVR (Choi et al., 2021), which invented a novel conditional method to direct DDPM generation towards reference images; and denoising diffusion implicit models (DDIMs, Song et al. (2020a)), which accelerated DDPM inference via non-Markovian processes. DDIMs can be treated as a first-order numerical solver of a probabilistic ODE, which we use heavily in DDIBs.
|
| 180 |
+
|
| 181 |
+
Diffusion Models for Image Translation While GANs (Goodfellow et al., 2014; Zhu et al., 2017; Zhao et al., 2020) have been widely adopted in image translation tasks, recent works increasingly leverage diffusion models. For instance, Palette (Saharia et al., 2021) applies a conditional diffusion model to colorization, inpainting, and restoration. DiffuseIT (Kwon & Ye, 2022) utilizes disentangled style and content representation, to perform text- and image-guided style transfer. Lastly, UNITDDPM (Sasaki et al., 2021) proposes a novel coupling between domain pairs and trains joint DDPMs for translation. Unlike their joint training, DDIBs apply separate, pretrained diffusion models and leverage geometry of the shared space for translation.
|
| 182 |
+
|
| 183 |
+
Optimal Transport for Translation and Generative Modeling As it pursues cost-optimal plans to connect image distributions, OT naturally finds applications in image translation. For example, Korotin et al. (2022) capitalizes on the approximation powers of neural networks to compute OT plans between image distributions and perform unpaired translation. By contrast, the entropy-regularized OT variant, Schrodinger Bridges (Section 2), are also commonly used to derive generative models. ¨ For instance, De Bortoli et al. (2021) and Vargas et al. (2021) concurrently proposed new numerical procedures that approximate the Iterative Proportional Fitting scheme, to solve SBPs for image generation. Wang et al. (2021) presents a new generative method via entropic interpolation with an SBP. Chen et al. (2021a) discovers equivalence between the likelihood objectives of SBP and score-based models, which lays the theoretical foundations behind DDIBs. Their sequel (Liu et al., 2023) then directly learns the Schrodinger Bridges between image distributions, for applications ¨ in image-to-image tasks such as restoration. While DDIBs were not initially designed to mimic Schrodinger Bridges, our analysis reveals their true characterization as solutions to degenerate SBPs. ¨
|
| 184 |
+
|
| 185 |
+
# 6 CONCLUSIONS
|
| 186 |
+
|
| 187 |
+
We present Dual Diffusion Implicit Bridges (DDIBs), a new, simplistic image translation method that stems from latest progresses in score-based diffusion models, and is theoretically grounded as Schrodinger Bridges in the image space. DDIBs solve two key problems. First, DDIBs avoid ¨ optimization on a coupled loss specific to the given domain pair only. Second, DDIBs better safeguard dataset privacy as they no longer require presence of both datasets during training. Powerful pretrained diffusion models are then integrated into our DDIBs framework, to perform a comprehensive series of experiments that prove DDIBs’ practical values in domain translation. Our method is limited in its application to color transfer, as one model is required for each image, which demands significant compute for mass experiments. Rooted in optimal transport, DDIBs translation mimics the massmoving process which may be problematic at times (Appendix C). Future work may remedy these issues, or extend DDIBs to applications with different dimensions in the source and target domains. As flowing through the concatenated ODEs is time-consuming, improving the translation speed is also a promising direction.
|
| 188 |
+
|
| 189 |
+
# ACKNOWLEDGEMENTS
|
| 190 |
+
|
| 191 |
+
We thank Lingxiao Li and Chris Cundy for insightful discussions about the optimal transport properties of DDIBs. We also thank the anonymous reviewers for their constructive comments and feedback. This research was supported by NSF (#1651565), ARO (W911NF-21-1-0125), ONR (N00014-23-1-2159), CZ Biohub, and Stanford HAI.
|
| 192 |
+
|
| 193 |
+
# REFERENCES
|
| 194 |
+
|
| 195 |
+
Brian DO Anderson. Reverse-time diffusion equation models. Stochastic Processes and their Applications, 12(3):313–326, 1982.
|
| 196 |
+
|
| 197 |
+
Tianrong Chen, Guan-Horng Liu, and Evangelos A Theodorou. Likelihood training of schr\” odinger bridge using forward-backward sdes theory. arXiv preprint arXiv:2110.11291, 2021a.
|
| 198 |
+
|
| 199 |
+
Yongxin Chen, Tryphon T Georgiou, and Michele Pavon. On the relation between optimal transport and schrodinger bridges: A stochastic control viewpoint. ¨ Journal of Optimization Theory and Applications, 169(2):671–691, 2016.
|
| 200 |
+
|
| 201 |
+
Yongxin Chen, Tryphon T Georgiou, and Michele Pavon. Stochastic control liaisons: Richard sinkhorn meets gaspard monge on a schrodinger bridge. SIAM Review, 63(2):249–313, 2021b.
|
| 202 |
+
|
| 203 |
+
Jooyoung Choi, Sungwon Kim, Yonghyun Jeong, Youngjune Gwon, and Sungroh Yoon. Ilvr: Conditioning method for denoising diffusion probabilistic models. arXiv preprint arXiv:2108.02938, 2021.
|
| 204 |
+
|
| 205 |
+
Yunjey Choi, Minje Choi, Munyoung Kim, Jung-Woo Ha, Sunghun Kim, and Jaegul Choo. Stargan: Unified generative adversarial networks for multi-domain image-to-image translation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 8789–8797, 2018.
|
| 206 |
+
|
| 207 |
+
Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. Advances in neural information processing systems, 26:2292–2300, 2013.
|
| 208 |
+
|
| 209 |
+
Valentin De Bortoli, James Thornton, Jeremy Heng, and Arnaud Doucet. Diffusion schr\” odinger bridge with applications to score-based generative modeling. arXiv preprint arXiv:2106.01357, 2021.
|
| 210 |
+
|
| 211 |
+
Prafulla Dhariwal and Alex Nichol. Diffusion models beat gans on image synthesis. arXiv preprint arXiv:2105.05233, 2021.
|
| 212 |
+
|
| 213 |
+
Bradley Efron. Tweedie’s formula and selection bias. Journal of the American Statistical Association, 106(496):1602–1614, 2011.
|
| 214 |
+
|
| 215 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
|
| 216 |
+
|
| 217 |
+
Aditya Grover, Christopher Chute, Rui Shu, Zhangjie Cao, and Stefano Ermon. Alignflow: Cycle consistent learning from multiple domains via normalizing flows. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 4028–4035, 2020.
|
| 218 |
+
|
| 219 |
+
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv preprint arXiv:2006.11239, 2020.
|
| 220 |
+
|
| 221 |
+
Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the design space of diffusionbased generative models. arXiv preprint arXiv:2206.00364, 2022.
|
| 222 |
+
|
| 223 |
+
Bahjat Kawar, Michael Elad, Stefano Ermon, and Jiaming Song. Denoising diffusion restoration models. arXiv preprint arXiv:2201.11793, 2022.
|
| 224 |
+
|
| 225 |
+
Diederik P Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational diffusion models. arXiv preprint arXiv:2107.00630, 2021.
|
| 226 |
+
|
| 227 |
+
Alexander Korotin, Daniil Selikhanovych, and Evgeny Burnaev. Neural optimal transport. arXiv preprint arXiv:2201.12220, 2022.
|
| 228 |
+
|
| 229 |
+
Gihyun Kwon and Jong Chul Ye. Diffusion-based image translation using disentangled style and content representation. arXiv preprint arXiv:2209.15264, 2022.
|
| 230 |
+
|
| 231 |
+
Christian Leonard. A survey of the schr ´ \” odinger problem and some of its connections with optimal transport. arXiv preprint arXiv:1308.0215, 2013.
|
| 232 |
+
|
| 233 |
+
Rui Li, Wenming Cao, Qianfen Jiao, Si Wu, and Hau-San Wong. Simplified unsupervised image translation for semantic segmentation adaptation. Pattern Recognition, 105:107343, 2020.
|
| 234 |
+
|
| 235 |
+
Jae Hyun Lim, Nikola B Kovachki, Ricardo Baptista, Christopher Beckham, Kamyar Azizzadenesheli, Jean Kossaifi, Vikram Voleti, Jiaming Song, Karsten Kreis, Jan Kautz, et al. Score-based diffusion models in function space. arXiv preprint arXiv:2302.07400, 2023.
|
| 236 |
+
|
| 237 |
+
Guan-Horng Liu, Arash Vahdat, De-An Huang, Evangelos A Theodorou, Weili Nie, and Anima Anandkumar. Iˆ2 sb: Image-to-image schr\” odinger bridge. arXiv preprint arXiv:2302.05872, 2023.
|
| 238 |
+
|
| 239 |
+
Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Dpm-solver: A fast ode solver for diffusion probabilistic model sampling in around 10 steps. arXiv preprint arXiv:2206.00927, 2022.
|
| 240 |
+
|
| 241 |
+
Shitong Luo and Wei Hu. Diffusion probabilistic models for 3d point cloud generation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2837–2845, 2021.
|
| 242 |
+
|
| 243 |
+
Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, and Stefano Ermon. Sdedit: Guided image synthesis and editing with stochastic differential equations. arXiv preprint arXiv:2108.01073, 2021a.
|
| 244 |
+
|
| 245 |
+
Chenlin Meng, Yang Song, Wenzhe Li, and Stefano Ermon. Estimating high order gradients of the data distribution by denoising. Advances in Neural Information Processing Systems, 34: 25359–25369, 2021b.
|
| 246 |
+
|
| 247 |
+
Chenlin Meng, Kristy Choi, Jiaming Song, and Stefano Ermon. Concrete score matching: Generalized score matching for discrete data. arXiv preprint arXiv:2211.00802, 2022.
|
| 248 |
+
|
| 249 |
+
Alex Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. arXiv preprint arXiv:2102.09672, 2021.
|
| 250 |
+
|
| 251 |
+
Marcus Pereira, Ziyi Wang, Ioannis Exarchos, and Evangelos A Theodorou. Neural network architectures for stochastic control using the nonlinear feynman-kac lemma. arXiv preprint arXiv:1902.03986, 2019.
|
| 252 |
+
|
| 253 |
+
Michael Perrot, Nicolas Courty, R ¨ emi Flamary, and Amaury Habrard. Mapping estimation for ´ discrete optimal transport. Advances in Neural Information Processing Systems, 29:4197–4205, 2016.
|
| 254 |
+
|
| 255 |
+
Gabriel Peyre, Marco Cuturi, et al. Computational optimal transport: With applications to data ´ science. Foundations and Trends® in Machine Learning, 11(5-6):355–607, 2019.
|
| 256 |
+
|
| 257 |
+
Chitwan Saharia, William Chan, Huiwen Chang, Chris A Lee, Jonathan Ho, Tim Salimans, David J Fleet, and Mohammad Norouzi. Palette: Image-to-image diffusion models. arXiv preprint arXiv:2111.05826, 2021.
|
| 258 |
+
|
| 259 |
+
Hiroshi Sasaki, Chris G Willcocks, and Toby P Breckon. Unit-ddpm: Unpaired image translation with denoising diffusion probabilistic models. arXiv preprint arXiv:2104.05358, 2021.
|
| 260 |
+
|
| 261 |
+
John Schulman, Sergey Levine, Pieter Abbeel, Michael Jordan, and Philipp Moritz. Trust region policy optimization. In International conference on machine learning, pp. 1889–1897. PMLR, 2015.
|
| 262 |
+
|
| 263 |
+
Abhishek Sinha, Jiaming Song, Chenlin Meng, and Stefano Ermon. D2c: Diffusion-decoding models for few-shot conditional generation. Advances in Neural Information Processing Systems, 34: 12533–12548, 2021.
|
| 264 |
+
|
| 265 |
+
Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pp. 2256–2265. PMLR, 2015.
|
| 266 |
+
|
| 267 |
+
Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502, 2020a.
|
| 268 |
+
|
| 269 |
+
Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. arXiv preprint arXiv:1907.05600, 2019.
|
| 270 |
+
|
| 271 |
+
Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020b.
|
| 272 |
+
|
| 273 |
+
Charles M Stein. Estimation of the mean of a multivariate normal distribution. The annals of Statistics, pp. 1135–1151, 1981.
|
| 274 |
+
|
| 275 |
+
Francisco Vargas, Pierre Thodoroff, Austen Lamacraft, and Neil Lawrence. Solving schrodinger ¨ bridges via maximum likelihood. Entropy, 23(9):1134, 2021.
|
| 276 |
+
|
| 277 |
+
Gefei Wang, Yuling Jiao, Qian Xu, Yang Wang, and Can Yang. Deep generative learning via $\operatorname { s c h r } \backslash \ ' \{ \mathrm { o } \bar { \} }$ dinger bridge. arXiv preprint arXiv:2106.10410, 2021.
|
| 278 |
+
|
| 279 |
+
Wenju Xu, Chengjiang Long, Ruisheng Wang, and Guanghui Wang. Drb-gan: A dynamic resblock generative adversarial network for artistic style transfer. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 6383–6392, 2021.
|
| 280 |
+
|
| 281 |
+
Qinsheng Zhang and Yongxin Chen. Fast sampling of diffusion models with exponential integrator. arXiv preprint arXiv:2204.13902, 2022.
|
| 282 |
+
|
| 283 |
+
Yihao Zhao, Ruihai Wu, and Hao Dong. Unpaired image-to-image translation using adversarial consistency loss. In European Conference on Computer Vision, pp. 800–815. Springer, 2020.
|
| 284 |
+
|
| 285 |
+
Linqi Zhou, Yilun Du, and Jiajun Wu. 3d shape generation and completion through point-voxel diffusion. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 5826–5835, 2021.
|
| 286 |
+
|
| 287 |
+
Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE international conference on computer vision, pp. 2223–2232, 2017.
|
| 288 |
+
|
| 289 |
+
Alice is the owner of the source (tiger) domain, and Bob is the owner of the target (cat) domain. Alice intends to translate tiger images to cat images, but in a privacy-sensitive manner without releasing the source dataset. Bob does not wish to make the cat dataset public, either.
|
| 290 |
+
|
| 291 |
+

|
| 292 |
+
Fig. 5 illustrates the process of privacysensitive domain translation. The process contains the following steps, with indexes in the figure.
|
| 293 |
+
Figure 5
|
| 294 |
+
|
| 295 |
+
1. Alice intends to translate tiger images to cat images.
|
| 296 |
+
2. Alice trains a diffusion model with the source tiger images.
|
| 297 |
+
3. Alice uses the pretrained, tiger diffusion model to convert a source tiger image to its latent code.
|
| 298 |
+
4. Alice sends the latent code to Bob.
|
| 299 |
+
5. Bob similarly trains a diffusion model on the cat domain.
|
| 300 |
+
6. Bob uses the pretrained, cat diffusion model to convert the received latent code to a cat image.
|
| 301 |
+
7. Bob then sends the translated image back to Alice.
|
| 302 |
+
|
| 303 |
+
Clearly, during the translation process, only the latent code and the translated cat image are transmitted via the public channel, while both source and target datasets are private to the two parties. This is a significant advantage of DDIBs over alternate methods, as we enable strong privacy protection of the datasets.
|
| 304 |
+
|
| 305 |
+
# B DETAILS OF SGM TRAINING AND DDIM ODE SOLVER
|
| 306 |
+
|
| 307 |
+
# B.1 TRAINING SCORE NETWORKS
|
| 308 |
+
|
| 309 |
+
While the description in Section 2 is based on continuous SDEs, actual implementations of diffusion models often sample discrete time steps. Given samples from a data distribution $q ( \mathbf { x } _ { 0 } )$ , diffusion models attempt to learn a model distribution $p _ { \theta } ( \mathbf { x } _ { 0 } )$ that approximates $q ( \mathbf { x } _ { 0 } )$ , and is easy to sample from. Specifically, diffusion probabilistic models are latent variable models of the form
|
| 310 |
+
|
| 311 |
+
$$
|
| 312 |
+
p _ { \theta } ( \mathbf { x } _ { 0 } ) = \int p _ { \theta } ( \mathbf { x } _ { 0 : T } ) \mathrm { d } \mathbf { x } _ { 1 : T } , \mathrm { w h e r e } p _ { \theta } ( \mathbf { x } _ { 0 : T } ) = p _ { \theta } ( \mathbf { x } _ { T } ) \prod _ { t = 1 } ^ { T } p _ { \theta } ^ { ( t ) } ( \mathbf { x } _ { t - 1 } | \mathbf { x } _ { t } )
|
| 313 |
+
$$
|
| 314 |
+
|
| 315 |
+
where $\mathbf { x } _ { 1 } , \cdots , \mathbf { x } _ { T }$ are latent variables in the same sample space as $\mathbf { x } _ { \mathrm { 0 } }$ . The parameters $\theta$ are trained to approximate the data distribution $q ( \mathbf { x } _ { 0 } )$ , by maximizing a variational lower bound:
|
| 316 |
+
|
| 317 |
+
$$
|
| 318 |
+
\operatorname* { m a x } _ { \theta } \mathbb { E } _ { q ( \mathbf { x } _ { 0 } ) } [ \log p \varrho ( \mathbf { x } _ { 0 } ) ] \leq \operatorname* { m a x } _ { \theta } \mathbb { E } _ { q ( \mathbf { x } _ { 0 } , \mathbf { x } _ { 1 } , \cdots , \mathbf { x } _ { T } ) } [ \log p \varrho ( \mathbf { x } _ { 0 : T } ) - \log q ( \mathbf { x } _ { 1 : T } | \mathbf { x } _ { 0 } ) ]
|
| 319 |
+
$$
|
| 320 |
+
|
| 321 |
+
where $q \big ( \mathbf { x } _ { 1 : T } | \mathbf { x } _ { 0 } \big )$ is some inference distribution over the latent variables. It is known that when the conditional distributions are modeled as Gaussians with trainable mean functions and fixed variances, the above objective can be simplified to:
|
| 322 |
+
|
| 323 |
+
$$
|
| 324 |
+
L ( \epsilon _ { \theta } ) : = \sum _ { t = 1 } ^ { T } \mathbb { E } _ { \mathbf { x } _ { 0 } \sim q ( \mathbf { x } _ { 0 } ) , \epsilon _ { t } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } ) } \left[ \left\| \epsilon _ { \theta } ^ { ( t ) } ( \sqrt { \alpha _ { t } } \mathbf { x } _ { 0 } + \sqrt { 1 - \alpha _ { t } } \epsilon _ { t } ) - \epsilon _ { t } \right\| _ { 2 } ^ { 2 } \right]
|
| 325 |
+
$$
|
| 326 |
+
|
| 327 |
+
The resulting noise prediction functions $\epsilon _ { \theta } ^ { ( t ) }$ , are equivalent to the score networks $\mathbf { s } _ { t , \theta }$ mentioned in Section 2 due to Tweedie’s formula (Stein, 1981; Efron, 2011). For details, we refer the reader to $\mathrm { H o }$ et al. (2020); Song et al. (2020a).
|
| 328 |
+
|
| 329 |
+
# B.2 DDIM ODE SOLVER
|
| 330 |
+
|
| 331 |
+
With a trained noise prediction model $\epsilon _ { \theta } ^ { ( t ) } ( \mathbf { x } )$ , the DDIM iterate between adjacent variables $\mathbf { x } _ { t - \Delta t }$ and $\mathbf { x } _ { t }$ , considered in Song et al. (2020a), assumes the following form:
|
| 332 |
+
|
| 333 |
+
$$
|
| 334 |
+
\frac { \mathbf { x } _ { t - \Delta t } } { \sqrt { \alpha _ { t - \Delta t } } } = \frac { \mathbf { x } _ { t } } { \sqrt { \alpha _ { t } } } + \left( \sqrt { \frac { 1 - \alpha _ { t - \Delta t } } { \alpha _ { t - \Delta t } } } - \sqrt { \frac { 1 - \alpha _ { t } } { \alpha _ { t } } } \right) \epsilon _ { \theta } ^ { ( t ) } ( \mathbf { x } _ { t } )
|
| 335 |
+
$$
|
| 336 |
+
|
| 337 |
+
In our experiments, we implement the above equation between adjacent diffusion steps. The equation is deterministic, and can be considered as a Euler method over the following ODE:
|
| 338 |
+
|
| 339 |
+
$$
|
| 340 |
+
\mathrm { d } \bar { \mathbf { x } } ( t ) = \epsilon _ { \theta } ^ { ( t ) } \left( \frac { \bar { \mathbf { x } } ( t ) } { \sqrt { \sigma ^ { 2 } + 1 } } \right) \mathrm { d } \sigma ( t )
|
| 341 |
+
$$
|
| 342 |
+
|
| 343 |
+
where we adopt the reparameterization:
|
| 344 |
+
|
| 345 |
+
$$
|
| 346 |
+
\sigma ( t ) = \sqrt { \frac { 1 - \alpha ( t ) } { \alpha ( t ) } } , \quad \bar { \mathbf { x } } ( t ) = \frac { \mathbf { x } ( t ) } { \sqrt { \alpha ( t ) } }
|
| 347 |
+
$$
|
| 348 |
+
|
| 349 |
+
Importantly, the ODE in Eq. (9) with the optimal model $\epsilon _ { \theta } ^ { ( t ) } ( \mathbf { x } )$ , has an equivalent probability flow ODE corresponding to the “Variance-Exploding” SDE in Song et al. (2020b).
|
| 350 |
+
|
| 351 |
+
# C LIMITATIONS OF OPTIMAL TRANSPORT-BASED TRANSLATION
|
| 352 |
+
|
| 353 |
+
DDIBs contain deterministic bridges between distributions, and are a form of entropy-regularized optimal transport. The learned diffusion models can be effectively considered as a digest or summary of the datasets. While doing translation, they attempt to create images in the target domain, that are closest in optimal transport distances to the source images. Such OT-based process is both an advantage and a limitation of our method.
|
| 354 |
+
|
| 355 |
+
In ImageNet translation, when the source and target datasets are similar, DDIBs are generally able to identify correct animal postures. For example, we have shouting lions and tigers, because these animals have similar behaviors that are observed in the datasets and then internalized by DDIBs. However, in datasets that are less similar (e.g. birds and dogs), DDIBs sometimes fail to produce translation results that retain the postures precisely. We encountered significantly less such cases in AFHQ translation, since the dataset is more standardized and homogeneous.
|
| 356 |
+
|
| 357 |
+
Fig. 6 illustrates the optimal transport mappings among images as well as some failure cases. Clearly, the translation processes flowing from left to right minimize the Euclidean transportation distances between images. Some of these translated samples may be classified “failure cases” in actual user studies. Such are considered both a feature and a limitation of DDIBs.
|
| 358 |
+
|
| 359 |
+

|
| 360 |
+
Figure 6: Optimal transport translation processes in DDIBs. (Leftmost) Source images. (Rightmost) Translated images.
|
| 361 |
+
|
| 362 |
+
# D PROOF OF PROPOSITION 3.2
|
| 363 |
+
|
| 364 |
+
Proof. The proof proceeds by substituting the values of $( \mathbf { z } _ { t } , \hat { \mathbf { z } } _ { t } ) = ( 0 , g ( t ) \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } ) )$ into Eq. (6),
|
| 365 |
+
|
| 366 |
+
$$
|
| 367 |
+
\begin{array} { r } { \mathrm { d } \mathbf { x } = \left[ \mathbf { f } ( \mathbf { x } , t ) + g ( t ) \mathbf { z } - \frac { 1 } { 2 } g ( t ) ( \mathbf { z } + \hat { \mathbf { z } } ) \right] \mathrm { d } t } \\ { = \left[ \mathbf { f } ( \mathbf { x } , t ) - \frac { 1 } { 2 } g ( t ) ^ { 2 } \nabla _ { \mathbf { x } } \log p _ { t } ( \mathbf { x } ) \right] \mathrm { d } t } \end{array}
|
| 368 |
+
$$
|
| 369 |
+
|
| 370 |
+
This is exactly Eq. (2).
|
| 371 |
+
|
| 372 |
+
# E ADDITIONAL EXPERIMENTAL DETAILS
|
| 373 |
+
|
| 374 |
+
# E.1 OPTIMAL TRANSPORT IN PAIRED DATASETS
|
| 375 |
+
|
| 376 |
+
Color Conversion In Fig. 7, a simple examination of the original and segmentation images reveals significant differences in color configurations. In the Maps dataset, while the real, satellite images are composed of dark colors, the segmentation images are light-toned. The same observation applies to other datasets. The shark contrasts in colors intuitively present a large transportation cost, that probably hinders the progress of DDIBs, as we have demonstrated its relationship to OT in Section 3.
|
| 377 |
+
|
| 378 |
+
To facilitate the workings of DDIBs, we follow a heuristic to transform the colors of the segmentation images. Specifically, on a small subset of the train dataset, we run an OT algorithm to compute a color correspondence that minimizes the color differences in terms of Sinkhorn distances between the real and segmentation images. The segmentation (target) datasets undergo this color conversion before they are fed into a diffusion model for training. During evaluation, when we compute MSEs, the images are converted to the original color space.
|
| 379 |
+
|
| 380 |
+
Privacy Protection Color conversion requires considering both datasets jointly to compute a color mapping, and seems to betray the original purpose of DDIBs on protection of dataset privacy. We comment that the amount of leaked information is minimal: for example, to compute a color correspondence for the Maps dataset, we sampled only around 1000 pixels from the two datasets, to summarize the color composition information. DDIBs still conserve privacy at large.
|
| 381 |
+
|
| 382 |
+

|
| 383 |
+
Figure 7: Color Conversion. In the paired translation tasks, we are given the real and segmentation images. Before training the diffusion models, we first transform the segmentation images to a color palette that is closer to the real images. While evaluating MSEs, we convert the images back to the original colors.
|
| 384 |
+
|
| 385 |
+
# E.2 EXAMPLE-GUIDED COLOR TRANSFER
|
| 386 |
+
|
| 387 |
+
We present additional qualitative comparison between DDIBs and common OT methods, in Fig. 8.
|
| 388 |
+
|
| 389 |
+

|
| 390 |
+
Figure 8: Full color transfer results on example images.
|
md/dev/68n2s9ZJWF8/68n2s9ZJWF8.md
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# OFFLINE REINFORCEMENT LEARNING WITH IMPLICIT Q-LEARNING
|
| 2 |
+
|
| 3 |
+
Ilya Kostrikov, Ashvin Nair & Sergey Levine
|
| 4 |
+
Department of Electrical Engineering and Computer Science
|
| 5 |
+
University of California, Berkeley
|
| 6 |
+
kostrikov,anair17 @berkeley.edu, svlevine@eecs.berkeley.edu
|
| 7 |
+
|
| 8 |
+
# ABSTRACT
|
| 9 |
+
|
| 10 |
+
Offline reinforcement learning requires reconciling two conflicting aims: learning a policy that improves over the behavior policy that collected the dataset, while at the same time minimizing the deviation from the behavior policy so as to avoid errors due to distributional shift. This trade-off is critical, because most current offline reinforcement learning methods need to query the value of unseen actions during training to improve the policy, and therefore need to either constrain these actions to be in-distribution, or else regularize their values. We propose a new offline RL method that never needs to evaluate actions outside of the dataset, but still enables the learned policy to improve substantially over the best behavior in the data through generalization. The main insight in our work is that, instead of evaluating unseen actions from the latest policy, we can approximate the policy improvement step implicitly by treating the state value function as a random variable, with randomness determined by the action (while still integrating over the dynamics to avoid excessive optimism), and then taking a state conditional upper expectile of this random variable to estimate the value of the best actions in that state. This leverages the generalization capacity of the function approximator to estimate the value of the best available action at a given state without ever directly querying a Q-function with this unseen action. Our algorithm alternates between fitting this upper expectile value function and backing it up into a Q-function, without any explicit policy. Then, we extract the policy via advantage-weighted behavioral cloning, which also avoids querying out-of-sample actions. We dub our method implicit Q-learning (IQL). IQL is easy to implement, computationally efficient, and only requires fitting an additional critic with an asymmetric L2 loss. IQL demonstrates the state-of-the-art performance on D4RL, a standard benchmark for offline reinforcement learning. We also demonstrate that IQL achieves strong performance fine-tuning using online interaction after offline initialization.
|
| 11 |
+
|
| 12 |
+
# 1 INTRODUCTION
|
| 13 |
+
|
| 14 |
+
Offline reinforcement learning (RL) addresses the problem of learning effective policies entirely from previously collected data, without online interaction (Fujimoto et al., 2019; Lange et al., 2012). This is very appealing in a range of real-world domains, from robotics to logistics and operations research, where real-world exploration with untrained policies is costly or dangerous, but prior data is available. However, this also carries with it major challenges: improving the policy beyond the level of the behavior policy that collected the data requires estimating values for actions other than those that were seen in the dataset, and this, in turn, requires trading off policy improvement against distributional shift, since the values of actions that are too different from those in the data are unlikely to be estimated accurately. Prior methods generally address this by either constraining the policy to limit how far it deviates from the behavior policy (Fujimoto et al., 2019; Wu et al., 2019; Fujimoto & Gu, 2021; Kumar et al., 2019; Nair et al., 2020; Wang et al., 2020), or by regularizing the learned value functions to assign low values to out-of-distribution actions (Kumar et al., 2020; Kostrikov et al., 2021). Nevertheless, this imposes a trade-off between how much the policy improves and how vulnerable it is to misestimation due to distributional shift. Can we devise an offline RL method that avoids this issue by never needing to directly query or estimate values for actions that were not seen in the data?
|
| 15 |
+
|
| 16 |
+
In this work, we start from an observation that in-distribution constraints widely used in prior work might not be sufficient to avoid value function extrapolation, and we ask whether it is possible to learn an optimal policy with in-sample learning, without ever querying the values of any unseen actions. The key idea in our method is to approximate an upper expectile of the distribution over values with respect to the distribution of dataset actions for each state. We alternate between fitting this value function with expectile regression, and then using it to compute Bellman backups for training the $Q$ -function. We show that we can do this simply by modifying the loss function in a SARSA-style TD backup, without ever using out-of-sample actions in the target value. Once this $Q$ - function has converged, we extract the corresponding policy using advantage-weighted behavioral cloning. This approach does not require explicit constraints or explicit regularization of out-ofdistribution actions during value function training, though our policy extraction step does implicitly enforce a constraint, as discussed in prior work on advantage-weighted regression (Peters & Schaal, 2007; Peng et al., 2019; Nair et al., 2020; Wang et al., 2020).
|
| 17 |
+
|
| 18 |
+
Our main contribution is implicit Q-learning (IQL), a new offline RL algorithm that avoids ever querying values of unseen actions while still being able to perform multi-step dynamic programming updates. Our method is easy to implement by making a small change to the loss function in a simple SARSA-like TD update and is computationally very efficient. Furthermore, our approach demonstrates the state-of-the-art performance on D4RL, a popular benchmark for offline reinforcement learning. In particular, our approach significantly improves over the prior state-of-the-art on challenging Ant Maze tasks that require to “stitch” several sub-optimal trajectories. Finally, we demonstrate that our approach is suitable for finetuning; after initialization from offline RL, IQL is capable of improving policy performance utilizing additional interactions.
|
| 19 |
+
|
| 20 |
+
# 2 RELATED WORK
|
| 21 |
+
|
| 22 |
+
A significant portion of recently proposed offline RL methods are based on either constrained or regularized approximate dynamic programming (e.g., Q-learning or actor-critic methods), with the constraint or regularizer serving to limit deviation from the behavior policy. We will refer to these methods as “multi-step dynamic programming” algorithms, since they perform true dynamic programming for multiple iterations, and therefore can in principle recover the optimal policy if provided with high-coverage data. The constraints can be implemented via an explicit density model (Wu et al., 2019; Fujimoto et al., 2019; Kumar et al., 2019; Ghasemipour et al., 2021), implicit divergence constraints (Nair et al., 2020; Wang et al., 2020; Peters & Schaal, 2007; Peng et al., 2019; Siegel et al., 2020), or by adding a supervised learning term to the policy improvement objective (Fujimoto & Gu, 2021) Several works have also proposed to directly regularize the Q-function to produce low values for out-of-distribution actions (Kostrikov et al., 2021; Kumar et al., 2020; Fakoor et al., $\boxed { 2 0 2 1 }$ Our method is also a multi-step dynamic programming algorithm. However, in contrast to prior works, our method completely avoids directly querying the learned Q-function with unseen actions during training, removing the need for any constraint during this stage, though the subsequent policy extraction, which is based on advantage-weighted regression (Peng et al., 2019; Nair et al., 2020), does apply an implicit constraint. However, this policy does not actually influence value function training.
|
| 23 |
+
|
| 24 |
+
In contrast to multi-step dynamic programming methods, several recent works have proposed methods that rely either on a single step of policy iteration, fitting the value function or Q-function of the behavior policy and then extracting the corresponding greedy policy (Peng et al., 2019; Brandfonbrener et al., 2021; Gulcehre et al., 2021), or else avoid value functions completely and utilize behavioral cloning-style objectives (Chen et al., 2021). We collectively refer to these as “single-step” approaches. These methods avoid needing to query unseen actions as well, since they either use no value function at all, or learn the value function of the behavior policy. Although these methods are simple to implement and effective on the MuJoCo locomotion tasks in D4RL, we show that such single-step methods perform very poorly on more complex datasets in D4RL, which require combining parts of suboptimal trajectories (“stitching”). Prior multi-step dynamic programming methods perform much better in such settings, as does our method. We discuss this distinction in more detail in Section $5 . 1 .$ Our method also shares the simplicity and computational efficiency of single-step approaches, providing an appealing combination of the strengths of both types of methods.
|
| 25 |
+
|
| 26 |
+
Our method is based on estimating the characteristics of a random variable. Several recent works involve approximating statistical quantities of the value function distribution. In particular, quantile regression $\left( \mathrm { \mathbb { K o e n k e r ~ \& ~ H a l l o c k } } \right) \underline { 2 0 0 1 } $ has been previously used in reinforcement learning to estimate the quantile function of a state-action value function (Dabney et al., 2018b;a; Kuznetsov et al., $\boxed { 2 0 2 0 }$ . Although our method is related, in that we perform expectile regression, our aim is not to estimate the distribution of values that results from stochastic transitions, but rather estimate expectiles of the state value function with respect to random actions. This is a very different statistic: our aim is not to determine how the $Q$ -value can vary with different future outcomes, but how the $Q$ -value can vary with different actions while averaging together future outcomes due to stochastic dynamics. While prior work on distributional RL can also be used for offline RL, it would suffer from the same action extrapolation issues as other methods, and would require similar constraints or regularization, while our method does not.
|
| 27 |
+
|
| 28 |
+
# 3 PRELIMINARIES
|
| 29 |
+
|
| 30 |
+
The RL problem is formulated in the context of a Markov decision process (MDP) $( \mathcal { S } , \mathcal { A } , p _ { 0 } ( \bar { s } ) , p ( s ^ { \prime } | s , a ) , r ( s , a ) , \gamma )$ , where $s$ is a state space, $\mathcal { A }$ is an action space, $p _ { 0 } ( s )$ is a distribution of initial states, $p ( s ^ { \prime } | s , a )$ is the environment dynamics, $r ( s , a )$ is a reward function, and $\gamma$ is a discount factor. The agent interacts with the MDP according to a policy $\pi ( a | s )$ . The goal is to obtain a policy that maximizes the cumulative discounted returns:
|
| 31 |
+
|
| 32 |
+
$$
|
| 33 |
+
\stackrel { \cdot } { \pi } = \arg \operatorname* { m a x } _ { \pi } \mathbb { E } _ { \pi } \left[ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } r ( s _ { t } , a _ { t } ) | s _ { 0 } \sim p _ { 0 } ( \cdot ) , a _ { t } \sim \pi ( \cdot | s _ { t } ) , s _ { t + 1 } \sim p ( \cdot | s _ { t } , a _ { t } ) \right] .
|
| 34 |
+
$$
|
| 35 |
+
|
| 36 |
+
Off-policy RL methods based on approximate dynamic programming typically utilize a state-action value function ( $Q$ -function), referred to as $Q ( s , a )$ , which corresponds to the discounted returns obtained by starting from the state $s$ and action $a$ , and then following the policy $\pi$ .
|
| 37 |
+
|
| 38 |
+
Offline reinforcement learning. In contrast to online (on-policy or off-policy) RL methods, offline RL uses previously collected data without any additional data collection. Like many recent offline RL methods, our work builds on approximate dynamic programming methods that minimize temporal difference error, according to the following loss:
|
| 39 |
+
|
| 40 |
+
$$
|
| 41 |
+
L _ { T D } ( \theta ) = \mathbb { E } _ { ( s , a , s ^ { \prime } ) \sim \mathcal { D } } [ ( r ( s , a ) + \gamma \operatorname* { m a x } _ { a ^ { \prime } } Q _ { \hat { \theta } } ( s ^ { \prime } , a ^ { \prime } ) - Q _ { \theta } ( s , a ) ) ^ { 2 } ] ,
|
| 42 |
+
$$
|
| 43 |
+
|
| 44 |
+
where $\mathcal { D }$ is the dataset, $Q _ { \theta } ( s , a )$ is a parameterized Q-function, $Q _ { \hat { \theta } } ( s , a )$ is a target network (e.g., with soft parameters updates defined via Polyak averaging), and the policy is defined as $\pi ( s ) =$ arg $\operatorname* { m a x } _ { a } Q _ { \theta } ( s , a )$ . Most recent offline RL methods modify either the value function loss (above) to regularize the value function in a way that keeps the resulting policy close to the data, or constrain the arg max policy directly. This is important because out-of-distribution actions $a ^ { \prime }$ can produce erroneous values for $Q _ { \hat { \theta } } ( s ^ { \prime } , a ^ { \prime } )$ in the above objective, often leading to overestimation as the policy is defined to maximize the (estimated) Q-value.
|
| 45 |
+
|
| 46 |
+
# 4 IMPLICIT Q-LEARNING
|
| 47 |
+
|
| 48 |
+
In this work, we aim to entirely avoid querying out-of-sample (unseen) actions in our TD loss. Although the goal of this work is to approximate the optimal $Q$ -function, we start by considering fitted $Q$ evaluation with a SARSA-style objective which has been considered in prior work on Offline Reinforcement Learning (Brandfonbrener et al., 2021; Gulcehre et al., 2021) . This objective aims to learn the value of the dataset policy $\pi _ { \beta }$ (also called the behavior policy):
|
| 49 |
+
|
| 50 |
+
$$
|
| 51 |
+
L ( \theta ) = \mathbb { E } _ { ( s , a , s ^ { \prime } , a ^ { \prime } ) \sim \mathcal { D } } [ ( r ( s , a ) + \gamma Q _ { \hat { \theta } } ( s ^ { \prime } , a ^ { \prime } ) - Q _ { \theta } ( s , a ) ) ^ { 2 } ] .
|
| 52 |
+
$$
|
| 53 |
+
|
| 54 |
+
This objective never queries values for out-of-sample actions, in contrast to Eqn. $( 1 )$ . One specific property of this objective that is important for this work is that it uses mean squared error (MSE) that fits $Q _ { \theta } ( s , a )$ to predict the mean statistics of the TD targets. Thus, if we assume unlimited capacity and no sampling error, the optimal parameters should satisfy
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
\begin{array} { r } { Q _ { \theta ^ { * } } ( s , a ) \approx r ( s , a ) + \gamma \mathbb { E } _ { s ^ { \prime } \sim p ( \cdot \vert s , a ) } [ Q _ { \hat { \theta } } ( s ^ { \prime } , a ^ { \prime } ) ] . } \\ { a ^ { \prime } { \sim } \pi _ { \beta } ( \cdot \vert s ) \quad } \end{array}
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
Prior work (Brandfonbrener et al., 2021; Gulcehre et al., 2021; Peng et al., $\boxed { 2 0 1 9 }$ has proposed directly using this objective to learn $Q ^ { \pi _ { \beta } }$ , and then train the policy $\pi _ { \psi }$ to maximize $\overline { { Q } } ^ { \pi _ { \beta } }$ . This avoids any issues with out-of-distribution actions, since the TD loss only uses dataset actions. However, while this procedure works well empirically on simple MuJoCo locomotion tasks in D4RL, we will show that it performs very poorly on more complex tasks that benefit from multi-step dynamic programming. In our method, which we derive next, we retain the benefits of using this SARSA-like objective, but modify it so that it allows us to perform multi-step dynamic programming and learn a near-optimal Q-function.
|
| 61 |
+
|
| 62 |
+

|
| 63 |
+
Figure 1: Left: The asymmetric squared loss used for expectile regression. $\tau = 0 . 5$ corresponds to the standard mean squared error loss, while $\tau = 0 . 9$ gives more weight to positives differences. Center: Expectiles of a normal distribution. Right: an example of estimating state conditional expectiles of a two-dimensional random variable. Each $x$ corresponds to a distribution over $y$ . We can approximate a maximum of this random variable with expectile regression: $\tau = 0 . 5$ correspond to the conditional mean statistics of the distribution, while $\tau \approx 1$ approximates the maximum operator over in-support values of $y$ .
|
| 64 |
+
|
| 65 |
+
Our method will perform a $Q$ -function update similar to Eqn. $\mathbb { Q }$ , but we will aim to estimate the maximum $Q$ -value over actions that are in the support of the data distribution. Crucially, we will show that it is possible to do this without ever querying the learned $Q$ -function on out-of-sample actions by utilizing expectile regression. Formally, the value function we aim to learn is given by:
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
L ( \theta ) = \mathbb { E } _ { ( s , a , s ^ { \prime } ) \sim \mathcal { D } } [ ( r ( s , a ) + \gamma \operatorname* { m a x } _ { { a ^ { \prime } \in A } \atop { s . t . \pi _ { \beta } ( a ^ { \prime } | s ^ { \prime } ) > 0 } } Q _ { \hat { \theta } } ( s ^ { \prime } , a ^ { \prime } ) - Q _ { \theta } ( s , a ) ) ^ { 2 } ] .
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
Our algorithm, implicit Q-Learning (IQL), aims to estimate this objective while evaluating the $Q$ - function only on the state-action pairs in the dataset. To this end, we propose to fit $Q _ { \theta } ( s , a )$ to estimate state-conditional expectiles of the target values, and show that specific expectiles approximate the maximization defined above. In Section $\boxed { 4 . 4 }$ we show that this approach performs multi-step dynamic programming in theory, and in Section $\underline { { \boldsymbol { \mathsf { F . 1 } } } }$ we show that it does so in practice.
|
| 72 |
+
|
| 73 |
+
# 4.1 EXPECTILE REGRESSION
|
| 74 |
+
|
| 75 |
+
Practical methods for estimating various statistics of a random variable have been thoroughly studies in applied statistics and econometrics. The $\tau \in \mathsf { \Gamma } ( 0 , 1 )$ expectile of some random variable $X$ is defined as a solution to the asymmetric least squares problem:
|
| 76 |
+
|
| 77 |
+
$$
|
| 78 |
+
\underset { m _ { \tau } } { \arg \operatorname* { m i n } } \mathbb { E } _ { x \sim X } [ L _ { 2 } ^ { \tau } ( x - m _ { \tau } ) ] , \mathrm { ~ w h e r e ~ } L _ { 2 } ^ { \tau } ( u ) = | \tau - \mathbb { 1 } ( u < 0 ) | u ^ { 2 } .
|
| 79 |
+
$$
|
| 80 |
+
|
| 81 |
+
That is, for $\tau > 0 . 5$ , this asymmetric loss function downweights the contributions of $x$ values smaller than $m _ { \tau }$ while giving more weights to larger values (see Fig. $\bigstar \bigstar$ left). Expectile regression is closely related to quantile regression $\mathrm { ( \mathbb { K } o e n k e r ~ \& ~ H a l l o c k , \mathbb { 2 0 0 1 } ) }$ , which is a popular technique for estimating quantiles of a distribution widely used in reinforcement learning (Dabney et al., 2018b;a) The quantile regression loss is defined as an asymmetric $\ell _ { 1 }$ loss.
|
| 82 |
+
|
| 83 |
+
We can also use this formulation to predict expectiles of a conditional distribution:
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
\operatorname * { a r g m i n } _ { m _ { \tau } ( x ) } \mathbb { E } _ { ( x , y ) \sim \mathcal { D } } [ L _ { 2 } ^ { \tau } ( y - m _ { \tau } ( x ) ) ] .
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
Fig. 1 (right) illustrates conditional expectile regression on a simple two-dimensional distribution. Note that we can optimize this objective with stochastic gradient descent. It provides unbiased gradients and is easy to implement with standard machine learning libraries.
|
| 90 |
+
|
| 91 |
+
# 4.2 LEARNING THE VALUE FUNCTION WITH EXPECTILE REGRESSION
|
| 92 |
+
|
| 93 |
+
Expectile regression provides us with a powerful framework to estimate statistics of a random variable beyond mean regression. We can use expectile regression to modify the policy evaluation objective in Eqn. $\textcircled { 2 }$ to predict an upper expectile of the TD targets that approximates the maximum of $\dot { r } ( s , a ) + \gamma \bar { Q } _ { \hat { \theta } } ( s ^ { \prime } , a ^ { \prime } )$ over actions $a ^ { \prime }$ constrained to the dataset actions, as in Eqn. $( 4 )$ . This leads to the following expectile regression objective:
|
| 94 |
+
|
| 95 |
+
$$
|
| 96 |
+
L ( \theta ) = \mathbb { E } _ { ( s , a , s ^ { \prime } , a ^ { \prime } ) \sim \mathcal { D } } [ L _ { 2 } ^ { \tau } ( r ( s , a ) + \gamma Q _ { \hat { \theta } } ( s ^ { \prime } , a ^ { \prime } ) - Q _ { \theta } ( s , a ) ) ] .
|
| 97 |
+
$$
|
| 98 |
+
|
| 99 |
+
However, this formulation has a significant drawback. Instead of estimating expectiles just with respect to the actions in the support of the data, it also incorporates stochasticity that comes from the environment dynamics $s ^ { \prime } \sim p ( \cdot | s , a )$ . Therefore, a large target value might not necessarily reflect the existence of a single action that achieves that value, but rather a “lucky” sample that happened to have transitioned into a good state. We resolve this by introducing a separate value function that approximates an expectile only with respect to the action distribution, leading to the following loss:
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
L _ { V } ( \psi ) = \mathbb { E } _ { ( s , a ) \sim \mathcal { D } } [ L _ { 2 } ^ { \tau } ( Q _ { \hat { \theta } } ( s , a ) - V _ { \psi } ( s ) ) ] .
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
We can then use this estimate to update the $Q$ -functions with the MSE loss, which averages over the stochasticity from the transitions and avoids the “lucky” sample issue mentioned above:
|
| 106 |
+
|
| 107 |
+
$$
|
| 108 |
+
L _ { Q } ( \theta ) = \mathbb { E } _ { ( s , a , s ^ { \prime } ) \sim \mathcal { D } } [ ( r ( s , a ) + \gamma V _ { \psi } ( s ^ { \prime } ) - Q _ { \theta } ( s , a ) ) ^ { 2 } ] .
|
| 109 |
+
$$
|
| 110 |
+
|
| 111 |
+
Note that these losses do not use any explicit policy, and only utilize actions from the dataset for both objectives, similarly to SARSA-style policy evaluation. In Section $^ { 4 . 4 , }$ we will show that this procedure recovers the optimal Q-function under some assumptions. Also, even though only one action is available for every state in the dataset for continuous action spaces, due to neural network generalization, the expectile regression does not result in SARSA-style policy evaluation as shown in Section $5 . 2 .$
|
| 112 |
+
|
| 113 |
+
# 4.3 POLICY EXTRACTION AND ALGORITHM SUMMARY
|
| 114 |
+
|
| 115 |
+
While our modified TD learning procedure learns an approximation to the optimal Q-function, it does not explicitly represent the corresponding policy, and therefore requires a separate policy extraction step. While one can consider any technique for policy extraction that constrains the learned policy to stay close to the dataset actions, we aim for a simple method for policy extraction. As before, we aim to avoid using outof-samples actions. Therefore, we extract the policy with advantage-weighted regression (Peters & Schaal, 2007; Peng et al., 2019) previously successfully used for policy extraction in Offline RL (Wang et al., 2018; Nair et al., 2020; Brandfonbrener et al., 2021):
|
| 116 |
+
|
| 117 |
+
# Algorithm 1 Implicit Q-learning
|
| 118 |
+
|
| 119 |
+
$$
|
| 120 |
+
L _ { \pi } ( \phi ) = \mathbb { E } _ { ( s , a ) \sim \mathcal { D } } [ \exp ( \beta ( Q _ { \hat { \theta } } ( s , a ) - V _ { \psi } ( s ) ) ) \log \pi _ { \phi } ( a | s ) ] ,
|
| 121 |
+
$$
|
| 122 |
+
|
| 123 |
+
Initialize parameters $\psi , \theta , { \hat { \theta } } , \phi$ .
|
| 124 |
+
TD learning (IQL):
|
| 125 |
+
for each gradient step do $\begin{array} { l } { \psi \psi - \lambda _ { V } \nabla _ { \psi } L _ { V } ( \psi ) } \\ { \theta \theta - \lambda _ { Q } \nabla _ { \theta } L _ { Q } ( \theta ) } \\ { \hat { \theta } ( 1 - \alpha ) \hat { \theta } + \alpha \theta } \end{array}$
|
| 126 |
+
end for
|
| 127 |
+
Policy extraction (AWR):
|
| 128 |
+
for each gradient step do $\phi \overset { \cdot } { \phi } - \lambda _ { \pi } \nabla _ { \phi } \bar { L } _ { \pi } ( \phi )$
|
| 129 |
+
end for
|
| 130 |
+
|
| 131 |
+
where $\beta \in [ 0 , \infty )$ is an inverse temperature. Note that this objective does not clone all actions from the dataset but, as shown in prior work, this objective learns a policy that maximizes the $Q$ -values subject to a distribution constraint $\mathrm { ( P e t e r s ~ \& ~ S c h a a l l ) } \mathrm { | 2 0 0 7 | ; | P e n g ~ e t ~ a l . | } \mathrm { | 2 0 1 9 ; | N a i r ~ e t ~ a l . | 2 0 2 0 | }$ . This step can be seen as selecting and cloning the most optimal actions in the dataset.
|
| 132 |
+
|
| 133 |
+
Our final algorithm consists of two stages. First, we fit the value function and $Q$ , performing a number of gradient updates alternating between Eqn. $( 5 )$ and $( 6 )$ . Second, we perform stochastic gradient descent on Eqn. $\overset { \cdot } { ( 7 ) }$ . For both steps, we use a version of clipped double Q-learning $( { \overline { { \mathbb { F } { \mathrm { u j i m o t o ~ e t ~ a l . } } } } } , )$ $\underline { { 2 0 1 8 } } )$ , taking a minimum of two $Q$ -functions for $V$ -function and policy updates. We summarize our final method in Algorithm $^ { 1 . }$ Note that the policy does not influence the value function in any way, and therefore extraction could be performed either concurrently or after TD learning. Concurrent learning provides a way to use IQL with online finetuning, as we discuss in Section ${ \bar { 5 . 3 } } .$
|
| 134 |
+
|
| 135 |
+
# 4.4 ANALYSIS
|
| 136 |
+
|
| 137 |
+
In this section, we will show that IQL can recover the optimal value function under the dataset support constraints. First, we prove a simple lemma that we will then use to show how our approach can enable learning the optimal value function.
|
| 138 |
+
|
| 139 |
+
Lemma 1. Let $X$ be a real-valued random variable with a bounded support and supremum of the support is $x ^ { * }$ . Then,
|
| 140 |
+
|
| 141 |
+
$$
|
| 142 |
+
\operatorname* { l i m } _ { \tau 1 } m _ { \tau } = x ^ { \ast }
|
| 143 |
+
$$
|
| 144 |
+
|
| 145 |
+
Proof Sketch. One can show that expectiles of a random variable have the same supremum $x ^ { * }$ . Moreover, for all $\tau _ { 1 }$ and $\tau _ { 2 }$ such that $\tau _ { 1 } < \tau _ { 2 }$ , we get $m _ { \tau _ { 1 } } \leq m _ { \tau _ { 2 } }$ . Therefore, the limit follows from the properties of bounded monotonically non-decreasing functions. □
|
| 146 |
+
|
| 147 |
+
In the following theorems, we show that under certain assumptions, our method indeed approximates the optimal state-action value $Q ^ { * }$ and performs multi-step dynamical programming. We first prove a technical lemma relating different expectiles of the Q-function, and then derive our main result regarding the optimality of our method.
|
| 148 |
+
|
| 149 |
+
For the sake of simplicity, we introduce the following notation for our analysis. Let $\mathbb { E } _ { x \sim X } ^ { \tau } [ x ]$ be a $\tau ^ { \mathrm { { t h } } }$ expectile of $X$ (e.g., $\mathbb { E } ^ { 0 . 5 }$ corresponds to the standard expectation). Then, we define $V _ { \tau } ( s )$ and $Q _ { \tau } ( s , \bar { a } )$ , which correspond to optimal solutions of Eqn. $5$ and $\boxed { 6 }$ correspondingly, recursively as:
|
| 150 |
+
|
| 151 |
+
$$
|
| 152 |
+
V _ { \tau } ( s ) = \mathbb { E } _ { a \sim \pi _ { \beta } ( \cdot | s ) } ^ { \tau } [ Q _ { \tau } ( s , a ) ] ,
|
| 153 |
+
$$
|
| 154 |
+
|
| 155 |
+
$$
|
| 156 |
+
Q _ { \tau } ( s , a ) = r ( s , a ) + \gamma \mathbb { E } _ { s ^ { \prime } \sim p ( \cdot \vert s , a ) } [ V _ { \tau } ( s ^ { \prime } ) ] .
|
| 157 |
+
$$
|
| 158 |
+
|
| 159 |
+
Lemma 2. For all $s$ , $\tau _ { 1 }$ and $\tau _ { 2 }$ such that $\tau _ { 1 } < \tau _ { 2 }$ we get $V _ { \tau _ { 1 } } ( s ) \leq V _ { \tau _ { 2 } } ( s )$
|
| 160 |
+
|
| 161 |
+
Proof. The proof follows the policy improvement proof (Sutton & Barto, 2018). See Appendix A.
|
| 162 |
+
|
| 163 |
+
Corollary 2.1. For any $\tau$ and s we have $V _ { \tau } ( s ) \leq \mathrm { m a x } \qquad a \in \mathcal { A } \quad \ldots \ : Q ^ { * } ( s , a )$ where $V _ { \tau } ( s )$ is defined s.t. $\pi _ { \beta } ( a | s ) { > } 0$
|
| 164 |
+
as above and $Q ^ { * } ( s , a )$ is an optimal state-action value function constrained to the dataset and
|
| 165 |
+
defined as
|
| 166 |
+
|
| 167 |
+
$$
|
| 168 |
+
Q ^ { * } ( s , a ) = r ( s , a ) + \gamma \mathbb { E } _ { s ^ { \prime } \sim p ( \cdot \vert s , a ) } \left[ \operatorname* { m a x } _ { a ^ { \prime } \in \mathcal { A } } Q ^ { * } ( s ^ { \prime } , a ^ { \prime } ) \right] .
|
| 169 |
+
$$
|
| 170 |
+
|
| 171 |
+
Proof. The proof follows from the observation that convex combination is smaller than maximum.
|
| 172 |
+
|
| 173 |
+
Theorem 3.
|
| 174 |
+
|
| 175 |
+
$$
|
| 176 |
+
\operatorname* { l i m } _ { \tau 1 } V _ { \tau } ( s ) = \operatorname* { m a x } _ { a \in \mathcal { A } \atop s . t . \pi _ { \beta } ( a \mid s ) > 0 } Q ^ { \ast } ( s , a ) .
|
| 177 |
+
$$
|
| 178 |
+
|
| 179 |
+
Proof. Follows from combining Lemma 1 and Corollary 2.1.
|
| 180 |
+
|
| 181 |
+
Therefore, for a larger value of $\tau < 1$ , we get a better approximation of the maximum. On the other hand, it also becomes a more challenging optimization problem. Thus, we treat $\tau$ as a hyperparameter. Due to the property discussed in Theorem $\bigtriangledown$ we dub our method implicit Q-learning (IQL). We also emphasize that our value learning method defines the entire spectrum of methods between SARSA $\tau = 0 . 5$ ) and Q-Learning $( \tau 1 )$ ). Note that in contrast to other multi-step methods, IQL absorbs the policy improvement step into value learning. Therefore, fitting Q-function corresponds to the policy evaluation step, while fitting the value function with IQL corresponds to implicit policy improvement.
|
| 182 |
+
|
| 183 |
+

|
| 184 |
+
Figure 2: Evaluation of our algorithm on a toy umaze environment (a). When the static dataset is heavily corrupted by suboptimal actions, one-step policy evaluation results in a value function that degrades to zero far from the rewarding states too quickly (c). Our algorithm aims to learn a near-optimal value function, combining the best properties of SARSA-style evaluation with the ability to perform multi-step dynamic programming, leading to value functions that are much closer to optimality (shown in (b)) and producing a much better policy (d).
|
| 185 |
+
|
| 186 |
+
# 5 EXPERIMENTAL EVALUATION
|
| 187 |
+
|
| 188 |
+
Our experiments aim to evaluate our method comparatively, in contrast to prior offline RL methods, and in particular to understand how our approach compares both to single-step methods and multi-step dynamic programming approaches. We will first demonstrate the benefits of multi-step dynamic programming methods, such as ours, in contrast to single-step methods, showing that on some problems this difference can be extremely large. We will then compare IQL with state-of-theart single-step and multi-step algorithms on the D4RL $\mathrm { ( F u ~ e t ~ a l . , } \mathbb { 2 0 2 0 } )$ benchmark tasks, studying the degree to which we can learn effective policies using only the actions in the dataset. We examine domains that contain near-optimal trajectories, where single-step methods perform well, as well as domains with no optimal trajectories at all, which require multi-step dynamic programming. Finally, we will study how IQL compares to prior methods when finetuning with online RL starting from an offline RL initialization.
|
| 189 |
+
|
| 190 |
+
# 5.1 THE DIFFERENCE BETWEEN ONE-STEP POLICY IMPROVEMENT AND IQL
|
| 191 |
+
|
| 192 |
+
We first use a simple maze environment to illustrate the importance of multi-step dynamic programming for offline RL. The maze has a u-shape, a single start state, and a single goal state (see Fig. 2a) The agent receives a reward of 10 for entering the goal state and zero reward for all other transitions. With a probability of 0.25, the agent transitions to a random state, and otherwise to the commanded state. The dataset consists of 1 optimal trajectory and 99 trajectories with uniform random actions. Due to a short horizon of the problem, we use $\gamma = 0 . 9$ .
|
| 193 |
+
|
| 194 |
+
Fig. $2$ (c, d) illustrates the difference between single-step methods which fit $Q ^ { \pi } ( s , a )$ via SARSAstyle objective, in this case represented by Onepstep RL (Brandfonbrener et al., $\boxed { 2 0 2 1 }$ Wang et al., $\dot { \boxed { 2 0 1 8 } } ;$ Gulcehre et al., 2021) and IQL with $\tau = 0 . 9 5$ . Note that these methods represent a special case of our method with $\bar { \tau } = 0 . 5$ . Although states closer to the high reward state will still have higher values, these values decay much faster as we move further away than they would for the optimal value function, and the resulting policy is highly suboptimal. Since IQL (d) performs iterative dynamic programming, it correctly propagates the signal, and the values are no longer dominated by noise. The resulting value function closely matches the true optimal value function (b).
|
| 195 |
+
|
| 196 |
+
# 5.2 COMPARISONS ON OFFLINE RL BENCHMARKS
|
| 197 |
+
|
| 198 |
+
Next, we evaluate our approach on the D4RL benchmark in comparison to prior methods (see Table $\bigstar \bigstar \bigstar \bigstar$ . The MuJoCo tasks in D4RL consist of the Gym locomotion tasks, the Ant Maze tasks, and the Adroit and Kitchen robotic manipulation environments. Some prior works, particularly those proposing one-step methods, focus entirely on the Gym locomotion tasks. However, these tasks include a significant fraction of near-optimal trajectories in the dataset. In contrast, the Ant Maze tasks, especially the medium and large ones, contain very few or no near-optimal trajectories, making them very challenging for one-step methods. These domains require “stitching” parts of suboptimal trajectories that travel between different states to find a path from the start to the goal of the maze $\mathtt { ( F u ~ e t ~ a l . } ] \mathtt { ( E 0 2 0 ) }$ . As we will show, multi-step dynamic programming is essential in these domains. The Adroit and Kitchen tasks are comparatively less discriminating, and we found that most RL methods perform similarly to imitation learning in these domains (Florence et al., 2021)
|
| 199 |
+
|
| 200 |
+
Table 1: Averaged normalized scores on MuJoCo locomotion and Ant Maze tasks. Our method outperforms prior methods on the challenging Ant Maze tasks, which require dynamic programming, and is competitive with the best prior methods on the locomotion tasks.
|
| 201 |
+
|
| 202 |
+
<table><tr><td>Dataset</td><td>BC</td><td>10%BC</td><td>BCQ</td><td>DT</td><td>ABM</td><td>AWAC</td><td>Onestep RL</td><td>TD3+BC</td><td>CQL</td><td>IQL (Ours)</td></tr><tr><td>halfcheetah-m-v2</td><td>42.6</td><td>42.5</td><td>47.0</td><td>42.6±0.1</td><td>53.6</td><td>43.5</td><td>48.4±0.1</td><td>48.3±0.3</td><td>44.0±5.4</td><td>47.4±0.2</td></tr><tr><td>hopper-m-v2</td><td>52.9</td><td>56.9</td><td>56.7</td><td>67.6±1.0</td><td>0.7</td><td>57.0</td><td>59.6±2.5</td><td>59.3±4.2</td><td>58.5±2.1</td><td>66.2±5.7</td></tr><tr><td>walker2d-m-v2</td><td>75.3</td><td>75.0</td><td>72.6</td><td>74.0±1.4</td><td>0.5</td><td>72.4</td><td>81.8±2.2</td><td>83.7±2.1</td><td>72.5±0.8</td><td>78.3±8.7</td></tr><tr><td>halfcheetah-m-r-v2</td><td>36.6</td><td>40.6</td><td>40.4</td><td>36.6±0.8</td><td>50.5</td><td>40.5</td><td>38.1±1.3</td><td>44.6±0.5</td><td>45.5±0.5</td><td>44.2±1.2</td></tr><tr><td>hopper-m-r-v2</td><td>18.1</td><td>75.9</td><td>53.3</td><td>82.7±7.0</td><td>49.6</td><td>37.2</td><td>97.5±0.7</td><td>60.9±18.8</td><td>95.0±6.4</td><td>94.7±8.6</td></tr><tr><td>walker2d-m-r-v2</td><td>26.0</td><td>62.5</td><td>52.1</td><td>66.6±3.0</td><td>53.8</td><td>27.0</td><td>49.5±12.0</td><td>81.8±5.5</td><td>77.2±5.5</td><td>73.8±7.1</td></tr><tr><td>halfcheetah-m-e-v2</td><td>55.2</td><td>92.9</td><td>89.1</td><td>86.8±1.3</td><td>18.5</td><td>42.8</td><td>93.4±1.6</td><td>90.7±4.3</td><td>91.6±2.8</td><td>86.7±5.3</td></tr><tr><td>hopper-m-e-v2</td><td>52.5</td><td>110.9</td><td>81.8</td><td>107.6±1.8</td><td>0.7</td><td>55.8</td><td>103.3±1.9</td><td>98.0±9.4</td><td>105.4±6.8</td><td>91.5±14.3</td></tr><tr><td>walker2d-m-e-v2</td><td>107.5</td><td>109.0</td><td>109.5</td><td>108.1±0.2</td><td>3.5</td><td>74.5</td><td>113.0±0.4</td><td>110.1±0.5</td><td>108.8±0.7</td><td>109.6±1.0</td></tr><tr><td>locomotion-v2 total</td><td>466.7</td><td>666.2</td><td>602.5</td><td>672.6±16.6</td><td>231.4</td><td>450.7</td><td>684.6±22.7</td><td>677.4±44.5</td><td>698.5±31.0</td><td>692.4±52.1</td></tr><tr><td>antmaze-u-v0</td><td>54.6</td><td>62.8</td><td>89.8</td><td>59.2</td><td>59.9</td><td>56.7</td><td>64.3</td><td>78.6</td><td>74.0</td><td>87.5±2.6</td></tr><tr><td>antmaze-u-d-v0</td><td>45.6</td><td>50.2</td><td>83.0</td><td>53.0</td><td>48.7</td><td>49.3</td><td>60.7</td><td>71.4</td><td>84.0</td><td>62.2 ±13.8</td></tr><tr><td>antmaze-m-p-v0</td><td>0.0</td><td>5.4</td><td>15.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.3</td><td>10.6</td><td>61.2</td><td>71.2 ± 7.3</td></tr><tr><td>antmaze-m-d-v0</td><td>0.0</td><td>9.8</td><td>0.0</td><td>0.0</td><td>0.5</td><td>0.7</td><td>0.0</td><td>3.0</td><td>53.7</td><td>70.0��10.9</td></tr><tr><td>antmaze-l-p-v0 antmaze-l-d-v0</td><td>0.0 0.0</td><td>0.0 6.0</td><td>0.0</td><td>0.0</td><td>0.</td><td>0.0</td><td>0.0</td><td>0.2</td><td>15.8</td><td>39.6±5.8</td></tr><tr><td>antmaze-vO total</td><td>100.2</td><td>134.2</td><td>0.0 187.8</td><td>0.0</td><td>0.0</td><td>1.0</td><td>0.0</td><td>0.0</td><td>14.9</td><td>47.5±9.5</td></tr><tr><td></td><td></td><td></td><td></td><td>112.2</td><td>109.1</td><td>107.7</td><td>125.3</td><td>163.8</td><td>303.6</td><td>378.0±49.9</td></tr><tr><td>total</td><td>566.9</td><td>800.4</td><td>790.3</td><td>784.8</td><td>340.5</td><td>558.4</td><td>809.9</td><td>841.2</td><td>1002.1</td><td>1070.4±102.0</td></tr><tr><td>kitchen-v0 total adroit-vO total</td><td>154.5 104.5</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>144.6</td><td>159.8±22.6</td></tr><tr><td></td><td></td><td>:</td><td>=</td><td>-</td><td>-</td><td>=</td><td>-</td><td>-</td><td>93.6</td><td>118.1±30.7</td></tr><tr><td>total+kitchen+adroit</td><td>825.9</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>1240.3</td><td>1348.3±155.3</td></tr><tr><td>runtime</td><td>10m</td><td>10m</td><td></td><td>960m</td><td></td><td>20m</td><td>20m*</td><td>20m</td><td>80m</td><td>20m</td></tr></table>
|
| 203 |
+
|
| 204 |
+
⇤: Note that it is challenging to compare one-step and multi-step methods directly. Also, Brandfonbrener et al. $\boxed { ( 2 0 2 1 ) }$ reports results for a set of hyperparameters, such as batch and network size, that is significantly different from other methods. We report results for the original hyperparameters and runtime for a comparable set of hyperparameters.
|
| 205 |
+
|
| 206 |
+
We therefore focus our analysis on the Gym locomotion and Ant Maze domains, but include full Adroit and Kitchen results in Appendix B for completeness.
|
| 207 |
+
|
| 208 |
+
Comparisons and baselines. We compare to methods that are representative of both multistep dynamic programming and one-step approaches. In the former category, we compare to CQL (Kumar et al., 2020), $\mathrm { T D } 3 { + } \mathrm { B C }$ (Fujimoto & Gu, 2021), and AWAC (Nair et al., 2020). In the latter category, we compare to Onestep RL (Brandfonbrener et al., 2021) and Decision Transformers (Chen et al., 2021). We obtained the Decision Transformers results on Ant Maze subsets of D4RL tasks using the author-provided implementation2 and following authors instructions communicated over email. We obtained results for $\mathrm { T D } 3 { + } \mathrm { B C }$ and Onestep RL (Exp. Weight) directly from the authors. Note that Chen et al. (2021) and Brandfonbrener et al. $\textcircled { 2 0 2 1 }$ incorrectly report results for some prior methods, such as CQL, using the “-v0” environments. These generally produce lower scores than the “-v2” environments that these papers use for their own methods. We use the “-v2” environments for all methods to en
|
| 209 |
+
|
| 210 |
+

|
| 211 |
+
Figure 3: Left: Estimating a larger expectile $\tau$ is crucial for antmaze tasks that require dynamical programming (’stitching’). Right: Clipped double Q-Learning (CDQ) is crucial for learning values for $\tau = 0 . 9$ .
|
| 212 |
+
|
| 213 |
+
sure a fair comparison, resulting in higher values for CQL. Because of this fix, our reported CQL scores are higher than all other prior methods. We obtained results for $\mathbf { \tilde { \mu } } ^ { 6 6 } \mathbf { - v } 2 \mathbf { \ w } ^ { 5 }$ datasets using an author-suggested implementation.3 On the Gym locomotion tasks (halfcheetah, hopper, walker2d), we find that IQL performs comparably to the best performing prior method, CQL. On the more challenging Ant Maze task, IQL outperforms CQL, and outperforms the one-step methods by a very large margin.
|
| 214 |
+
|
| 215 |
+
Runtime. Our approach is also computationally faster than the baselines (see Table 1). For the baselines, we measure runtime for our reimplementations of the methods in JAX (Bradbury et al., 2018) built on top of JAXRL (Kostrikov, 2021), which are typically faster than the original implementations. For example, the original implementation of CQL takes more than 4 hours to perform 1M updates, while ours takes only 80 minutes. Even so, IQL still requires about $4 \mathbf { x }$ less time than our reimplementation of CQL on average, and is comparable to the fastest prior one-step methods. We did not reimplement Decision Transformers due to their complexity and report runtime of the original implementation.
|
| 216 |
+
|
| 217 |
+
Effect of $\tau$ hyperparameter. We also demonstrate that it is crucial to compute a larger expectile on tasks that require “stitching” (see Fig. 3). We provide complete results in Appendix B. With larger values of $\tau$ , our method approximates $Q$ -learning better, leading to better performance on the Ant Maze tasks. Moreover, due to neural network generalization, values learned with expectile regression increase with a larger $\tau$ and do not degrade to behavior policy values $\tau = 0 . 5$ ). Finally, clipped double Q-Learning is crucial for estimating values for a larger $\tau = 0 . 9$ .
|
| 218 |
+
|
| 219 |
+
# 5.3 ONLINE FINE-TUNING AFTER OFFLINE RL
|
| 220 |
+
|
| 221 |
+
The policies obtained by offline RL can often be improved with a small amount of online interaction. IQL is well-suited for online fine-tuning for two reasons. First, IQL has strong offline performance, as shown in the previous section, which provides a good initialization. Second, IQL implements a weighted behavioral cloning policy extraction step, which has previously been shown to allow for better online policy improvement compared to other types of offline constraints $( \overbrace { { \mathbb { N a i r } \ \mathrm { e t } \ \mathrm { a l . } } } ) \ \big [ 2 0 2 0 \big ]$ To evaluate the finetuning capability of various RL algorithms, we first run offline RL on each
|
| 222 |
+
|
| 223 |
+
<table><tr><td>Dataset</td><td>AWAC</td><td>CQL</td><td>IQL (Ours)</td></tr><tr><td>antmaze-umaze-vO antmaze-umaze-diverse-v0</td><td>56.7 →59.0 49.3 →49.0</td><td>70.1 →99.4 31.1 →99.4</td><td>88.0 →96.3 67.0 →49.0</td></tr><tr><td>antmaze-medium-play-v0</td><td>0.0 →0.0</td><td>23.0 →0.0</td><td>69.0 →89.2</td></tr><tr><td>antmaze-medium-diverse-v0</td><td>0.7 →0.3</td><td>23.0 →32.3</td><td>71.8 →91.4</td></tr><tr><td>antmaze-large-play-v0</td><td>0.0 →0.0</td><td>1.0 →0.0</td><td>36.8 →51.8</td></tr><tr><td>antmaze-large-diverse-v0</td><td>1.0 →0.0</td><td>1.0 →0.0</td><td>42.2 →59.8</td></tr><tr><td>antmaze-vO total</td><td>107.7 →108.3</td><td>151.5 →231.1</td><td>374.8 →437.5</td></tr><tr><td>pen-binary-v0</td><td>44.6 →70.3</td><td>31.2 →9.9</td><td>37.4 →60.7</td></tr><tr><td>door-binary-v0</td><td>1.3 →30.1</td><td>0.2 →0.0</td><td>0.7 →32.3</td></tr><tr><td>relocate-binary-v0</td><td>0.8 →2.7</td><td>0.1 →0.0</td><td>0.0 →31.0</td></tr><tr><td>hand-vO total</td><td>46.7 →103.1</td><td>31.5 →9.9</td><td>38.1 →124.0</td></tr><tr><td>total</td><td>154.4→211.4</td><td>182.8→241.0</td><td>412.9561.5</td></tr></table>
|
| 224 |
+
|
| 225 |
+
Table 2: Online finetuning results showing the initial performance after offline RL, and performance after 1M steps of online RL. In all tasks, IQL is able to finetune to a significantly higher performance than the offline initialization, with final performance that is comparable to or better than the best of either AWAC or CQL on all tasks except pen-binary-v0.
|
| 226 |
+
|
| 227 |
+
dataset, then run 1M steps of online RL, and then report the final performance. We compare to AWAC (Nair et al., $\boxed { 2 0 2 0 }$ , which has been proposed specifically for online finetuning, and CQL $\underline { { \mathbb { K u } } } - \rfloor$ mar et al., $\overline { { \boxed { 2 0 2 0 } } }$ , which showed the best performance among prior methods in our experiments in the previous section. Exact experimental details are provided in Appendix $\mathbf { C } .$ We use the challenging Ant Maze D4RL domains $\mathtt { ( F u ) e t a l . } \mathtt { / } 2 0 2 0 \rVert$ , as well as the high-dimensional dexterous manipulation environments from Rajeswaran et al. $\overline { { \left( \frac { 2 0 1 8 } { \it 1 8 } \right) } }$ , which Nair et al. $\underline { { ( 2 0 2 0 ) } }$ propose to use to study online adaptation with AWAC. Results are shown in Table $\boxed { 5 }$ On the Ant Maze domains, IQL significantly outperforms both prior methods after online finetuning. CQL attains the second best score, while AWAC performs comparatively worse due to much weaker offline initialization. On the dexterous hand tasks, IQL performs significantly better than AWAC on relocate-binary-v0, comparably on door-binary-v0, and slightly worse on pen-binary-v0, with the best overall score.
|
| 228 |
+
|
| 229 |
+
# 6 CONCLUSION
|
| 230 |
+
|
| 231 |
+
We presented implicit Q-Learning (IQL), a general algorithm for offline RL that completely avoids any queries to values of out-of-sample actions during training while still enabling multi-step dynamic programming. To our knowledge, this is the first method that combines both of these features. This has a number of important benefits. First, our algorithm is computationally efficient: we can perform 1M updates on one GTX1080 GPU in less than 20 minutes. Second, it is simple to implement, requiring only minor modifications over a standard SARSA-like TD algorithm, and performing policy extraction with a simple weighted behavioral cloning procedure resembling supervised learning. Finally, despite the simplicity and efficiency of this method, we show that it attains excellent performance across all of the tasks in the D4RL benchmark, matching the best prior methods on the MuJoCo locomotion tasks, and exceeding the state-of-the-art performance on the challenging ant maze environments, where multi-step dynamic programming is essential for good performance.
|
| 232 |
+
|
| 233 |
+
# ACKNOWLEDGEMENTS
|
| 234 |
+
|
| 235 |
+
We thank Dibya Ghosh and the anonymous reviewers for helpful comments on earlier drafts of the paper. This research was supported by the Office of Naval Research, C3.ai, and Intel, with compute support from Google.
|
| 236 |
+
|
| 237 |
+
# REFERENCES
|
| 238 |
+
|
| 239 |
+
James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python $^ +$ NumPy programs, 2018. URL http: //github.com/google/jax.
|
| 240 |
+
David Brandfonbrener, William F Whitney, Rajesh Ranganath, and Joan Bruna. Offline rl without off-policy evaluation. arXiv preprint arXiv:2106.08909, 2021.
|
| 241 |
+
Lili Chen, Kevin Lu, Aravind Rajeswaran, Kimin Lee, Aditya Grover, Michael Laskin, Pieter Abbeel, Aravind Srinivas, and Igor Mordatch. Decision transformer: Reinforcement learning via sequence modeling. arXiv preprint arXiv:2106.01345, 2021.
|
| 242 |
+
Will Dabney, Georg Ostrovski, David Silver, and Remi Munos. Implicit quantile networks for ´ distributional reinforcement learning. In International conference on machine learning, pp. 1096– 1105. PMLR, 2018a.
|
| 243 |
+
Will Dabney, Mark Rowland, Marc G Bellemare, and Remi Munos. Distributional reinforcement ´ learning with quantile regression. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018b.
|
| 244 |
+
Rasool Fakoor, Jonas Mueller, Kavosh Asadi, Pratik Chaudhari, and Alexander J Smola. Continuous doubly constrained batch reinforcement learning. arXiv preprint arXiv:2102.09225, 2021.
|
| 245 |
+
Pete Florence, Corey Lynch, Andy Zeng, Oscar Ramirez, Ayzaan Wahid, Laura Downs, Adrian Wong, Johnny Lee, Igor Mordatch, and Jonathan Tompson. Implicit behavioral cloning. arXiv preprint arXiv:2109.00137, 2021.
|
| 246 |
+
Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4rl: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
|
| 247 |
+
Scott Fujimoto and Shixiang Shane Gu. A minimalist approach to offline reinforcement learning. arXiv preprint arXiv:2106.06860, 2021.
|
| 248 |
+
Scott Fujimoto, Herke Hoof, and David Meger. Addressing function approximation error in actorcritic methods. In International Conference on Machine Learning, pp. 1587–1596. PMLR, 2018.
|
| 249 |
+
Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International Conference on Machine Learning, pp. 2052–2062. PMLR, 2019.
|
| 250 |
+
Seyed Kamyar Seyed Ghasemipour, Dale Schuurmans, and Shixiang Shane Gu. Emaq: Expectedmax q-learning operator for simple yet effective offline and online rl. In International Conference on Machine Learning, pp. 3682–3691. PMLR, 2021.
|
| 251 |
+
Caglar Gulcehre, Sergio Gomez Colmenarejo, Ziyu Wang, Jakub Sygnowski, Thomas Paine, Konrad ´ Zolna, Yutian Chen, Matthew Hoffman, Razvan Pascanu, and Nando de Freitas. Regularized behavior value estimation. arXiv preprint arXiv:2103.09575, 2021.
|
| 252 |
+
Jonathan Heek, Anselm Levskaya, Avital Oliver, Marvin Ritter, Bertrand Rondepierre, Andreas Steiner, and Marc van Zee. Flax: A neural network library and ecosystem for JAX, 2020. URL http://github.com/google/flax.
|
| 253 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 254 |
+
|
| 255 |
+
Roger Koenker and Kevin F Hallock. Quantile regression. Journal of economic perspectives, 15(4): 143–156, 2001.
|
| 256 |
+
|
| 257 |
+
Ilya Kostrikov. JAXRL: Implementations of Reinforcement Learning algorithms in JAX., 10 2021. URL https://github.com/ikostrikov/jaxrl.
|
| 258 |
+
|
| 259 |
+
Ilya Kostrikov, Rob Fergus, Jonathan Tompson, and Ofir Nachum. Offline reinforcement learning with fisher divergence critic regularization. In International Conference on Machine Learning, pp. 5774–5783. PMLR, 2021.
|
| 260 |
+
|
| 261 |
+
Aviral Kumar, Justin Fu, George Tucker, and Sergey Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. arXiv preprint arXiv:1906.00949, 2019.
|
| 262 |
+
|
| 263 |
+
Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative q-learning for offline reinforcement learning. arXiv preprint arXiv:2006.04779, 2020.
|
| 264 |
+
|
| 265 |
+
Arsenii Kuznetsov, Pavel Shvechikov, Alexander Grishin, and Dmitry Vetrov. Controlling overestimation bias with truncated mixture of continuous distributional quantile critics. In International Conference on Machine Learning, pp. 5556–5566. PMLR, 2020.
|
| 266 |
+
|
| 267 |
+
Sascha Lange, Thomas Gabel, and Martin Riedmiller. Batch reinforcement learning. In Reinforcement learning, pp. 45–73. Springer, 2012.
|
| 268 |
+
|
| 269 |
+
Ashvin Nair, Murtaza Dalal, Abhishek Gupta, and Sergey Levine. Awac: Accelerating online reinforcement learning with offline datasets. 2020.
|
| 270 |
+
|
| 271 |
+
Xue Bin Peng, Aviral Kumar, Grace Zhang, and Sergey Levine. Advantage-weighted regression: Simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177, 2019.
|
| 272 |
+
|
| 273 |
+
Jan Peters and Stefan Schaal. Reinforcement learning by reward-weighted regression for operational space control. In Proceedings of the 24th international conference on Machine learning, pp. 745– 750, 2007.
|
| 274 |
+
|
| 275 |
+
Aravind Rajeswaran, Vikash Kumar, Abhishek Gupta, John Schulman, Emanuel Todorov, and Sergey Levine. Learning Complex Dexterous Manipulation with Deep Reinforcement Learning and Demonstrations. In Robotics: Science and Systems, 2018. URL https://arxiv. org/pdf/1709.10087.pdf.
|
| 276 |
+
|
| 277 |
+
Noah Y Siegel, Jost Tobias Springenberg, Felix Berkenkamp, Abbas Abdolmaleki, Michael Neunert, Thomas Lampe, Roland Hafner, Nicolas Heess, and Martin Riedmiller. Keep doing what worked: Behavioral modelling priors for offline reinforcement learning. arXiv preprint arXiv:2002.08396, 2020.
|
| 278 |
+
|
| 279 |
+
Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The journal of machine learning research, 15(1):1929–1958, 2014.
|
| 280 |
+
|
| 281 |
+
Richard S Sutton and Andrew G Barto. Reinforcement learning: An introduction. MIT press, 2018.
|
| 282 |
+
|
| 283 |
+
Qing Wang, Jiechao Xiong, Lei Han, Peng Sun, Han Liu, and Tong Zhang. Exponentially weighted imitation learning for batched historical data. In NeurIPS, pp. 6291–6300, 2018.
|
| 284 |
+
|
| 285 |
+
Ziyu Wang, Alexander Novikov, Konrad Zolna, Jost Tobias Springenberg, Scott Reed, Bobak Shahriari, Noah Siegel, Josh Merel, Caglar Gulcehre, Nicolas Heess, et al. Critic regularized regression. arXiv preprint arXiv:2006.15134, 2020.
|
| 286 |
+
|
| 287 |
+
Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019.
|
md/dev/6u6N8WWwYSM/6u6N8WWwYSM.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# BOOTSTRAPPING SEMANTIC SEGMENTATION WITH REGIONAL CONTRAST
|
| 2 |
+
|
| 3 |
+
Shikun Liu1, Shuaifeng $\mathbf { Z } \mathbf { h } \mathbf { i } ^ { 1 }$ , Edward Johns2, and Andrew J. Davison1 1Dyson Robotics Lab, Imperial College London 2Robot Learning Lab, Imperial College London shikun.liu17@imperial.ac.uk
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
We present ReCo, a contrastive learning framework designed at a regional level to assist learning in semantic segmentation. ReCo performs pixel-level contrastive learning on a sparse set of hard negative pixels, with minimal additional memory footprint. ReCo is easy to implement, being built on top of off-the-shelf segmentation networks, and consistently improves performance, achieving more accurate segmentation boundaries and faster convergence. The strongest effect is in semisupervised learning with very few labels. With ReCo, we achieve high quality semantic segmentation model, requiring only 5 examples of each semantic class.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Semantic segmentation is an essential part of applications such as scene understanding and autonomous driving, whose goal is to assign a semantic label to each pixel in an image. Significant progress has been achieved by use of large datasets with high quality human annotations. However, labelling images with pixel-level accuracy is time consuming and expensive; for example, labelling a single image in CityScapes can take more than 90 minutes (Cordts et al., 2016). When deploying semantic segmentation models in practical applications where only limited labelled data are available, high quality ground-truth annotation is a significant bottleneck.
|
| 12 |
+
|
| 13 |
+
To reduce the need for labelled data, there is a recent surge of interest in leveraging unlabelled data for semi-supervised learning. Previous methods include improving segmentation models via adversarial learning (Hung et al., 2019; Mittal et al., 2019) and self-training (Zou et al., 2019; 2018; Zhu et al., 2020). Others focus on designing advanced data augmentation strategies to generate pseudo image-annotation pairs from unlabelled images (Olsson et al., 2021; French et al., 2020).
|
| 14 |
+
|
| 15 |
+
In both semi-supervised and supervised learning, a segmentation model often predicts smooth label maps, because neighbouring pixels are usually of the same class, and rarer high-frequency regions are typically only found in object boundaries. This learning bias produces blurry contours and regularly mis-labels rare objects. After carefully examining the label predictions, we further observe that wrongly labelled pixels are typically confused with very few other classes; e.g. a pixel labelled as rider has a much higher chance of being wrongly classified as person, compared to train or bus. By understanding this class structure, learning can be actively focused on the challenging pixels to improve overall segmentation quality.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: ReCo pushes representations within a class closer to the class mean representation, whilst simultaneously pushing these representations away from negative representations sampled in different classes. The sampling distribution from negative classes is adaptive to each query class.
|
| 19 |
+
|
| 20 |
+
Here we propose ReCo, a contrastive learning framework designed at a regional level. Specifically, ReCo is a new loss function which helps semantic segmentation not only to learn from local context (neighbouring pixels), but also from global semantic class relationships across the entire dataset. ReCo performs contrastive learning on a pixel-level dense representation, as visualised in Fig. 1. For each semantic class in a mini-batch, ReCo samples a set of pixel-level representations (queries), and encourages them to be close to the class mean representation (positive keys), and simultaneously pushes them away from representations sampled from other classes (negative keys).
|
| 21 |
+
|
| 22 |
+
For pixel-level contrastive learning with high-resolution images, it is impractical to sample all pixels. In ReCo, we actively sample a sparse set of queries and keys, consisting of less than $5 \%$ of all available pixels. We sample negative keys from a learned distribution based on the relative distance between the mean representation of each negative key and the query class. This distribution can be interpreted as a pairwise semantic class relationship, dynamically updated during training. We sample queries for those having a low prediction confidence. Active sampling helps ReCo to rapidly focus on the most confusing pixels for each semantic class, and requires minimal additional memory.
|
| 23 |
+
|
| 24 |
+
ReCo enables a high-accuracy segmentation model to be trained with very few human annotations. We evaluate ReCo in a semi-supervised setting, with two different modes: i) Partial Dataset Full Labels — a sparse subset of training images, where each image has full ground-truth labels, and the remaining images are unlabelled; ii) Partial Labels Full Dataset — all images have some labels, but covering only a sparse subset of pixels within each image. In both settings, we show that ReCo can consistently improve performance across all methods and datasets.
|
| 25 |
+
|
| 26 |
+
# 2 RELATED WORK
|
| 27 |
+
|
| 28 |
+
Semantic Segmentation One recent direction is in designing more effective deep convolutional neural networks. Fully convolutional networks (FCNs) (Long et al., 2015) are the foundation of modern segmentation network design. They were later improved with dilated/atrous convolutions with larger receptive fields, capturing more long range information (Chen et al., 2017; 2018). Alternative approaches include encoder-decoder architectures (Ronneberger et al., 2015; Kirillov et al., 2019), sometimes using skip connections (Ronneberger et al., 2015) to refine filtered details.
|
| 29 |
+
|
| 30 |
+
A parallel direction is to improve optimisation strategies, by designing loss functions that better respect class imbalance (Lin et al., 2017) or using rendering strategy to refine uncertain pixels from high-frequency regions improving the label quality (Kirillov et al., 2020). ReCo is built upon this line of research, to improve segmentation by providing additional supervision on hard pixels.
|
| 31 |
+
|
| 32 |
+
Semi-supervised Classification and Segmentation The goal of semi-supervised learning is to improve model performance by taking advantage of a large amount of unlabelled data during training. Here consistency regularisation and entropy minimisation are two common strategies. The intuition is that the network’s output should be invariant to data perturbation and geometric transformation. Based on these strategies, many semi-supervised methods have been developed for image classification (Sohn et al., 2020; Tarvainen & Valpola, 2017; Berthelot et al., 2019; Kuo et al., 2020).
|
| 33 |
+
|
| 34 |
+
However, for segmentation, generating effective pseudo-labels and well-designed data augmentation are non-trivial. Some solutions improved the quality of pseudo-labelling, using adversarial learning (Hung et al., 2019; Mittal et al., 2019) or enforcing consistency from different augmented images (French et al., 2020; Olsson et al., 2021). In this work, we show that we can improve the performance of current semi-supervised segmentation methods by jointly training with a suitable auxiliary task.
|
| 35 |
+
|
| 36 |
+
Contrastive Learning Contrastive learning learns a similarity function to bring views of the same data closer in representation space, whilst pushing views of different data apart. Most recent contrastive frameworks learn similarity scores based on global representations of the views, parameterising data with a single vector (He et al., 2020; Chen et al., 2020; Khosla et al., 2020). Dense representations, on the other hand, rely on pixel-level representations and naturally provide additional supervision, capturing fine-grained pixel correspondence. Contrastive pre-training based on dense representations has recently been explored, and shows better performance in dense prediction tasks, such as object detection and keypoint detection (Wang et al., 2021b; O. Pinheiro et al., 2020).
|
| 37 |
+
|
| 38 |
+
Contrastive Learning for Semantic Segmentation Contrastive learning has been recently studied to improve semantic segmentation, with a number of different design strategies. Zhang et al. (2021) and Zhao et al. (2021) both perform contrastive learning via pre-training, based on the generated auxiliary labels and ground-truth labels respectively, but at the cost of huge memory consumption. In contrast, ours performs contrastive learning whilst requiring much less memory, via active sampling. In concurrent work, (Wang et al., 2021a; Alonso et al., 2021) also perform contrastive learning with active sampling. However, whilst both these methods are applied to a stored feature bank, ours focuses on sampling features on-the-fly. Active sampling in Alonso et al. (2021) is further based on learnable, class-specific attention modules, whilst ours only samples features based on relation graphs and prediction confidence, without introducing any additional computation overhead, which results in a simpler and much more memory-efficient implementation.
|
| 39 |
+
|
| 40 |
+
# 3 RECO – REGIONAL CONTRAST
|
| 41 |
+
|
| 42 |
+
# 3.1 PIXEL-LEVEL CONTRASTIVE LEARNING
|
| 43 |
+
|
| 44 |
+
Let $( X , Y )$ be a training dataset with training images $x \in X$ and their corresponding $C$ -class pixellevel segmentation labels $y \in Y$ , where $y$ can be either provided in the original dataset, or generated automatically as pseudo-labels. A segmentation network $f$ is then optimised to learn a mapping $f _ { \boldsymbol { \theta } } :$ $X \mapsto Y$ , parameterised by network parameters $\theta$ . This segmentation network $f$ can be decomposed into two parts: an encoder network: $\phi : X \mapsto Z$ , and a decoder classification head $\psi _ { c } : Z \mapsto Y$ . To perform pixel-level contrastive learning, we additionally attach a decoder representation head $\psi _ { r }$ on top of the encoder network $\phi$ , parallel to the classification head, mapping the encoded feature into a higher $m$ -dimensional dense representation with the same spatial resolution as the input image: $\psi _ { r } : Z \mapsto R , R \in \mathbb { R } ^ { m }$ . This representation head is only applied during training to guide the classifier using the ReCo loss as an auxiliary task, and is removed during inference.
|
| 45 |
+
|
| 46 |
+
A pixel-level contrastive loss is a function which encourages queries $r _ { q }$ to be similar to the positive key $r _ { k } ^ { + }$ , and dissimilar to the negative keys $r _ { k } ^ { - }$ . All queries and keys are sampled from the decoder representation head: rq, r+,k $r _ { q } , r _ { k } ^ { + , - } \in R$ . In ReCo, we use a pixel-level contrastive loss across all available semantic classes in each mini-batch, with the distance between keys and queries measured by their normalised dot product. The general formation of the ReCo loss $L _ { \tt r e c o }$ is then defined as:
|
| 47 |
+
|
| 48 |
+
$$
|
| 49 |
+
L _ { \mathbf { r e c o } } = \sum _ { c \in \mathcal { C } } \sum _ { r _ { q } \sim \mathcal { R } _ { q } ^ { c } } - \log \frac { \exp ( r _ { q } \cdot r _ { k } ^ { c , + } / \tau ) } { \exp ( r _ { q } \cdot r _ { k } ^ { c , + } / \tau ) + \sum _ { r _ { k } ^ { - } \sim \mathcal { R } _ { k } ^ { c } } \exp ( r _ { q } \cdot r _ { k } ^ { - } / \tau ) } ,
|
| 50 |
+
$$
|
| 51 |
+
|
| 52 |
+
for which $\mathcal { C }$ is a set containing all available classes in the current mini-batch, $\tau$ is the temperature control of the softness of the distribution, $\mathcal { R } _ { q } ^ { c }$ represents a query set containing all representations whose labels belong to class $c$ , $\mathcal { R } _ { k } ^ { c }$ represents a negative key set containing all representations whose labels do not belong to class $c$ , and $r _ { k } ^ { c , + }$ represents the positive key which is the mean representation of class $c$ . Suppose is a set containing all pixel coordinates with the same resolution as , these queries and keys are then defined as:
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
\mathcal { R } _ { q } ^ { c } = \bigcup _ { [ u , v ] \in \mathcal { P } } \mathbb { 1 } ( y _ { [ u , v ] } = c ) r _ { [ u , v ] } , \ \mathcal { R } _ { k } ^ { c } = \bigcup _ { [ u , v ] \in \mathcal { P } } \mathbb { 1 } ( y _ { [ u , v ] } \neq c ) r _ { [ u , v ] } , \ r _ { k } ^ { c , + } = \frac { 1 } { | \mathcal { R } _ { q } ^ { c } | } \sum _ { r _ { q } \in \mathcal { R } _ { q } ^ { c } } r _ { q } .
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
# 3.2 ACTIVE HARD SAMPLING ON QUERIES AND KEYS
|
| 59 |
+
|
| 60 |
+
Contrastive learning on all pixels in high-resolution images would be computationally expensive.
|
| 61 |
+
Here, we introduce active hard sampling strategies to optimise only a sparse set of queries and keys.
|
| 62 |
+
|
| 63 |
+
Active Key Sampling When classifying a pixel, a semantic network might be uncertain only over a very small number of candidates, among all available classes. The uncertainty from these candidates typically comes from a close spatial (e.g. rider and bicycle) or semantic (e.g. horse and cow) relationship. To reduce this uncertainty, we propose to sample negative keys non-uniformly, based on the relative distance between each negative key class and the query class. This involves building a pair-wise class relationship graph $G$ , with $G \in \mathbb { R } ^ { | \mathcal { C } | \times | \mathcal { C } | }$ , computed and dynamically updated for each mini-batch. This pair-wise relationship is measured by the normalised dot product between the mean representation from a pair of two classes and is defined as:
|
| 64 |
+
|
| 65 |
+
$$
|
| 66 |
+
G [ p , q ] = \left( r _ { k } ^ { p , + } \cdot r _ { k } ^ { q , + } \right) , \quad \forall p , q \in \mathcal { C } , \ \mathrm { a n d } \ p \neq q .
|
| 67 |
+
$$
|
| 68 |
+
|
| 69 |
+
We further apply SoftMax to normalise these pair-wise relationships among all negative classes $j$ for each query class $c$ , which produces a probabilistic distribution:
|
| 70 |
+
|
| 71 |
+
$\textstyle \exp ( G [ c , i ] ) / \sum _ { j \in { \mathcal { C } } , j \neq c } \exp ( G [ c , j ] )$ . We sample negative keys for each class $i$ based on this distribution, to learn the corresponding query class $c$ . This procedure allocates more samples to hard, confusing classes chosen specifically for each query class, helping the segmentation network to learn a more accurate decision boundary.
|
| 72 |
+
|
| 73 |
+
Active Query Sampling Due to the natural class imbalance in semantic segmentation, it is easy to over-fit on common classes, such as the road and building classes in the CityScapes dataset, or the background class in the Pascal VOC dataset. These common classes contribute to the majority of pixel space in training images, and so randomly sampling queries will under-sample rare classes and provide minimal supervision to these classes.
|
| 74 |
+
|
| 75 |
+
Therefore, we instead sample hard queries — for those whose corresponding pixel prediction confidence is below a defined threshold. Accordingly, ReCo’s loss would then guide the segmentation network by providing appropriate supervision on these less certain pixels. The easy and hard queries are defined as follows, and visualised in Fig. 2,
|
| 76 |
+
|
| 77 |
+
$$
|
| 78 |
+
\mathcal { R } _ { q } ^ { c , e a s y } = \bigcup _ { r _ { q } \in \mathcal { R } _ { q } ^ { c } } \mathbb { 1 } ( \hat { y } _ { q } > \delta _ { s } ) r _ { q } , \quad \mathcal { R } _ { q } ^ { c , h a r d } = \bigcup _ { r _ { q } \in \mathcal { R } _ { q } ^ { c } } \mathbb { 1 } ( \hat { y } _ { q } \leq \delta _ { s } ) r _ { q } ,
|
| 79 |
+
$$
|
| 80 |
+
|
| 81 |
+
where $\hat { y } _ { q }$ is the predicted confidence of label $c$ after the SoftMax operation corresponding to the same pixel location as $r _ { q }$ , and $\delta _ { s }$ is the user-defined confidence threshold.
|
| 82 |
+
|
| 83 |
+

|
| 84 |
+
Figure 2: Easy and hard queries (shown in white) determined from the predicted confidence map in the Cityscapes dataset. Here we set the confidence threshold $\delta _ { s } = 0 . 9 7$ .
|
| 85 |
+
|
| 86 |
+
# 3.3 SEMI-SUPERVISED SEMANTIC SEGMENTATION WITH RECO
|
| 87 |
+
|
| 88 |
+
ReCo can easily be added to modern semi-supervised segmentation methods without changing the training pipeline, with no additional cost at inference time. To incorporate ReCo, we simply add an additional representation head $\psi _ { r }$ as described in Section 3.1, and apply the ReCo loss (in Eq. 1) to this representation using the sampling strategy introduced in Section 3.2.
|
| 89 |
+
|
| 90 |
+
We apply the Mean Teacher framework (Tarvainen & Valpola, 2017) following prior state-of-the-art semi-supervised segmentation methods (Olsson et al., 2021; Mittal et al., 2019). Instead of using the original segmentation network $f _ { \theta }$ (which we call the student model), we instead use $f _ { \theta ^ { \prime } }$ (which we call the teacher model) to generate pseudo-labels from unlabelled images, where $\theta ^ { \prime }$ is a moving average of the previous state of $\theta$ during training optimisation: $\theta _ { t } ^ { \prime } = \lambda \theta _ { t - 1 } ^ { \prime } \bar { + } ( 1 - \lambda ) \theta _ { t }$ , with a decay parameter $\lambda = 0 . 9 9$ . This teacher model can be treated as a temporal ensemble of student models across training time $t$ , resulting in more stable predictions for unlabelled images. The student model $f _ { \theta }$ is then used to train on the augmented unlabelled images, with pseudo-labels as the ground-truths.
|
| 91 |
+
|
| 92 |
+
For all pixels with defined ground-truth labels, we apply the ReCo loss on dense representations corresponding to all valid pixels. For all pixels without such labels, we only sample pixels whose predicted pseudo-label confidence is greater than a threshold $\delta _ { w }$ . This avoids sampling pixels which are likely to have incorrect pseudo-labels.
|
| 93 |
+
|
| 94 |
+
We apply the ReCo loss to a combined set of labelled and unlabelled pixels. The overall training loss for semi-supervised segmentation is then the linear combination of supervised cross-entropy loss (on ground-truth labels), unsupervised cross-entropy loss (on pseudo-labels) and ReCo loss:
|
| 95 |
+
|
| 96 |
+
$$
|
| 97 |
+
L _ { t o t a l } = L _ { s u p e r v i s e d } + \eta \cdot L _ { u n s u p e r v i s e d } + L _ { r e c o }
|
| 98 |
+
$$
|
| 99 |
+
|
| 100 |
+
where $\eta$ is defined as the percentage of pixels whose predicted confidence are greater than $\delta _ { s }$ , a scalar re-weighting the contribution for unsupervised loss, following prior methods (Olsson et al., 2021;
|
| 101 |
+
|
| 102 |
+

|
| 103 |
+
Figure 3: Visualisation of the ReCo framework applied to semi-supervised segmentation and trained with three losses. A supervised loss is computed based on labelled data with ground-truth annotations. An unsupervised loss is computed for unlabelled data with generated pseudo-labels. And finally a ReCo loss is computed based on pixel-level dense representation predicted from both labelled and unlabelled images.
|
| 104 |
+
|
| 105 |
+
Mittal et al., 2019). This makes sure the segmentation network would not be dominated by gradients produced by uncertain pseudo-labels, which typically occur during the early stage of training. Fig. 3 shows a visualisation of the ReCo framework for semi-supervised segmentation.
|
| 106 |
+
|
| 107 |
+
# 4 EXPERIMENTS
|
| 108 |
+
|
| 109 |
+
Semi-Supervised Segmentation Benchmark Redesign We propose two modes of semisupervised segmentation tasks, aiming at two different applications.
|
| 110 |
+
|
| 111 |
+
i) Partial Dataset Full Labels: A small subset of the images is trained with complete ground-truth labels for each image, whilst the remaining training images are unlabelled. This is the de-facto standard of evaluating semi-supervised segmentation in prior works.
|
| 112 |
+
ii) Partial Labels Full Dataset: All images are trained with partial labels, but only a small percentage of labels are provided for each class in each training image. We create the dataset by first randomly sampling a pixel for each class, and then continuously apply a $[ 5 \times 5 ]$ square kernel for dilation until we meet the percentage criteria.
|
| 113 |
+
|
| 114 |
+
The Partial Dataset Full Label setting evaluates the ability to generalise semantic classes given a few examples with perfect boundary information. The Partial Label Full Dataset evaluates learning semantic class completion given many examples with no or minimal boundary information.
|
| 115 |
+
|
| 116 |
+

|
| 117 |
+
Figure 4: Example of training labels for Pascal VOC dataset in Partial Labels Full Dataset setting. (1 Pixel is zoomed 5 times for better visualisation.)
|
| 118 |
+
|
| 119 |
+
Datasets We experiment on segmentation datasets: Cityscapes (Cordts et al., 2016) and Pascal VOC 2012 (Everingham et al., 2015) in both partial and full label setting. We also
|
| 120 |
+
|
| 121 |
+
evaluate on a more difficult indoor scene dataset SUN RGB-D (Song et al., 2015) in the full label setting only, mainly due to the low quality annotations making it difficult for fair evaluation in the partial label setting. An example of the partially labelled Pascal VOC is shown in Fig. 4.
|
| 122 |
+
|
| 123 |
+
Strong Baselines Prior semi-supervised segmentation methods are typically designed with different backbone architectures, and trained with different strategies, which makes it difficult to compare them fairly. In this work, we standardise the baselines and implement four strong semi-supervised segmentation methods ourselves: S4GAN (Mittal et al., 2019): an adversarial learning based semisupervised method; CutOut (French et al., 2020), CutMix (French et al., 2020), ClassMix (Olsson et al., 2021): three image augmentation strategies designed specifically for semi-supervised segmentation. Our implementations for all baselines obtain performance on par with, and most of the time surpassing, the performance reported in each original publication, giving us a set of strong baselines. All baselines and our method were implemented on DeepLab ${ \mathrm { V } } 3 +$ (Chen et al., 2018) with ResNet-101 backbone (He et al., 2016), and all with the same optimisation strategies. Detailed hyper-parameters used for each dataset are provided in the Appendix A.
|
| 124 |
+
|
| 125 |
+
4.1 RESULTS ON PASCAL VOC, CITYSCAPES, SUN RGB-D (FULL LABELS)
|
| 126 |
+
|
| 127 |
+
First, we compared our results to semi-supervised baselines in a full label setting. We applied ReCo on top of ClassMix, which consistently outperformed other semi-supervised baselines.
|
| 128 |
+
|
| 129 |
+
Table 1 shows the mean IoU validation performance on three datasets over three individual runs (different labelled and unlabelled data splits). The number of labelled images shown in the three columns for each dataset, are chosen such that the least-appeared classes have appeared in 5, 15 and 50 images respectively. In the fewest-label setting for each dataset, applying ReCo with ClassMix can improve results by a significant margin, with up to $1 . 5 - 4 . 5 \%$ absolute improvement.
|
| 130 |
+
|
| 131 |
+
<table><tr><td></td><td colspan="3">Pascal VOC</td><td colspan="3">CityScapes</td><td colspan="3">SUN RGB-D</td></tr><tr><td>Method</td><td></td><td>60 labels 200 labels 600 labels</td><td></td><td>20 labels</td><td>50labels</td><td>150 labels</td><td>50labels</td><td>:150 labels 500 labels</td><td></td></tr><tr><td>Supervised</td><td>37.79</td><td>53.87</td><td>64.04</td><td>38.12</td><td>45.42</td><td>54.93</td><td>19.79</td><td>28.78</td><td>37.73</td></tr><tr><td>S4GAN (Mittal et al.,2019)</td><td>47.95</td><td>61.25</td><td>66.21</td><td>37.65</td><td>47.08</td><td>56.46</td><td>20.53</td><td>29.79</td><td>38.08</td></tr><tr><td>CutOut (French et al., 2020)</td><td>52.96</td><td>63.57</td><td>69.85</td><td>42.52</td><td>50.15</td><td>59.42</td><td>25.94</td><td>34.45</td><td>41.25</td></tr><tr><td>CutMix (French et al.,2020)</td><td>53.71</td><td>66.95</td><td>72.42</td><td>44.02</td><td>54.72</td><td>62.24</td><td>27.60</td><td>37.55</td><td>42.69</td></tr><tr><td>ClassMix (Olsson et al.,2021)</td><td>49.06</td><td>67.95</td><td>72.50</td><td>45.61</td><td>55.56</td><td>63.94</td><td>28.42</td><td>37.55</td><td>42.46</td></tr><tr><td>ReCo +ClassMix</td><td>53.31</td><td>69.81</td><td>72.75</td><td>49.86</td><td>57.69</td><td>65.04</td><td>29.65</td><td>39.14</td><td>44.55</td></tr></table>
|
| 132 |
+
|
| 133 |
+
Table 1: mean IoU validation performance for Pascal VOC, CityScapes and SUN RGB-D datasets.
|
| 134 |
+
We report the mean over three independent runs for all methods.
|
| 135 |
+
|
| 136 |
+
<table><tr><td>Pascal VOC</td><td>1/16 [92] 1/8 [183]1/4 [366] 1/2 [732]</td><td></td><td></td><td></td></tr><tr><td>AdvSemSeg (Hung et al.,2019)</td><td>39.69</td><td>47.58</td><td>59.97</td><td>65.27</td></tr><tr><td>Mean Teacher (Tarvainen & Valpola,2017)</td><td>48.70</td><td>55.81</td><td>63.01</td><td>69.16</td></tr><tr><td>CCT(Ouali et al.,2020)</td><td>33.10</td><td>47.60</td><td>58.80</td><td>62.10</td></tr><tr><td>GCT (Ke et al.,2020)</td><td>46.04</td><td>54.98</td><td>64.71</td><td>70.67</td></tr><tr><td>VAT (Miyato et al.,2018)</td><td>36.92</td><td>49.35</td><td>56.88</td><td>63.34</td></tr><tr><td>CutMix (French et al.,2020)</td><td>55.58</td><td>63.20</td><td>68.36</td><td>69.87</td></tr><tr><td>PseudoSeg (Zou et al.,2021)</td><td>57.60</td><td>65.50</td><td>69.14</td><td>72.41</td></tr><tr><td>ReCo + ClassMix</td><td>64.78</td><td>72.02</td><td>73.14</td><td>74.69</td></tr></table>
|
| 137 |
+
|
| 138 |
+
To further justify the effectiveness of ReCo, we also include results on existing benchmarks, to compare with other semi-supervised methods in Table 2. Here, all baselines were re-implemented and reported in the PseudoSeg setting (Zou et al., 2021), where the labelled images are sampled from the original PASCAL dataset, with a total of 1.4k images. In both benchmarks, ReCo shows state-of-the-art performance, and specifically is able to reach PseudoSeg’s performance, whilst requir
|
| 139 |
+
|
| 140 |
+
Table 2: mean IoU validation performance for Pascal VOC with data partition and training strategy proposed in PseudoSeg (Zou et al., 2021). The percentage and the number of labelled data used are listed in the first row.
|
| 141 |
+
|
| 142 |
+
ing only half the labelled data. Additional results are further shown in Appendix C.
|
| 143 |
+
|
| 144 |
+
In Fig. 5, we present qualitative results from the semi-supervised setup with the fewest labels: 20 labels for CityScapes and 50 labels SUN RGB-D datasets. The 60 labelled Pascal VOC is further shown in Appendix D. In Fig. 5, we can see the advantage of ReCo, where the edges and boundaries of small objects are clearly more pronounced such as in the person and bicycle classes in CityScapes, and the lamp and pillow classes in SUN RGB-D. Interestingly, we found that in SUN RGB-D, though all methods may confuse ambiguous class pairs such as table and desk or window and curtain, ReCo still produces consistently sharp and accurate object boundaries compared to the Supervised and ClassMix baselines where labels are noisy near object boundaries.
|
| 145 |
+
|
| 146 |
+
# 4.2 RESULTS ON PASCAL VOC AND CITYSCAPES (PARTIAL LABELS)
|
| 147 |
+
|
| 148 |
+
In the partial label setting, we evaluated on the CityScapes and Pascal VOC datasets. Table 3 compared ReCo to the two best semi-supervised baselines and a supervised baseline. Again, we see ReCo can improve performance in all cases when applied on top of ClassMix, with around $1 - 3 \%$
|
| 149 |
+
|
| 150 |
+

|
| 151 |
+
|
| 152 |
+
Figure 5: Visualisation of CityScapes and SUN RGB-D validation set trained on 20 and 50 labelled images respectively. Interesting regions are shown in white arrows.
|
| 153 |
+
|
| 154 |
+
<table><tr><td></td><td colspan="4">CityScapes (Partial)</td></tr><tr><td>Method</td><td>1 pixel</td><td>1% labels</td><td>5% labels</td><td>25% labels</td></tr><tr><td>Supervised</td><td>44.08</td><td>52.89</td><td>56.65</td><td>63.43</td></tr><tr><td>CutMix</td><td>46.91</td><td>54.90</td><td>59.69</td><td>65.61</td></tr><tr><td>ClassMix</td><td>47.42</td><td>56.68</td><td>60.96</td><td>66.46</td></tr><tr><td>ReCo + ClassMix</td><td>49.66</td><td>58.97</td><td>62.32</td><td>66.92</td></tr></table>
|
| 155 |
+
|
| 156 |
+
Table 3: mean IoU validation performance for Pascal VOC and Cityscapes datasets trained on $1 , 1 \%$ , $5 \%$ and $2 5 \%$ labelled pixels per class per image. We report the mean over three independent runs for all methods.
|
| 157 |
+
|
| 158 |
+
<table><tr><td></td><td colspan="4">Pascal VOC (Partial)</td></tr><tr><td>Method</td><td>1 pixel</td><td>1% labels</td><td>5% labels</td><td>25% labels</td></tr><tr><td>Supervised</td><td>60.33</td><td>66.17</td><td>69.16</td><td>73.75</td></tr><tr><td>CutMix</td><td>63.50</td><td>70.83</td><td>73.04</td><td>75.64</td></tr><tr><td>ClassMix</td><td>63.69</td><td>71.04</td><td>72.90</td><td>75.79</td></tr><tr><td>ReCo + ClassMix</td><td>66.11</td><td>72.67</td><td>74.09</td><td>75.96</td></tr></table>
|
| 159 |
+
|
| 160 |
+
absolute improvement. We observe less relative performance improvement than in the full label setting; very sparse ground-truth annotations could confuse ReCo, resulting in inaccurate supervision.
|
| 161 |
+
|
| 162 |
+
We show qualitative results on Pascal VOC dataset trained on 1 labelled pixel per class per image in Fig. 6. As in the full label setting, we see smoother and more accurate boundary predictions from ReCo. More visualisations from CityScapes are shown in Appendix E.
|
| 163 |
+
|
| 164 |
+
# 4.3 ABLATIVE ANALYSIS
|
| 165 |
+
|
| 166 |
+
Next we present an ablative analysis on 20 labelled CityScapes images to understand the behaviour of ReCo with respect to hyper-parameters. We use our default experimental setting from Section 4.1, using ReCo with ClassMix. Additional ablations are further shown in Appendix B.
|
| 167 |
+
|
| 168 |
+
Number of Queries and Keys We first evaluate the performance by varying the number of queries and keys used in ReCo framework, whilst fixing all other hyper-parameters. In Fig. 7a and 7b, we can observe that performance is better when sampling more queries and keys, but after a certain point, the improvements become marginal. Notably, even in our smallest option of having 32 queries per class in a mini-batch — consisting of less than $0 . 5 \%$ among all available pixel space — this can still improve performance by a non-trivial margin. Compared to a concurrent work (Zhang et al., 2021) which requires $1 0 \mathrm { k }$ queries and $4 0 \mathrm { k }$ keys in each training iteration, ReCo can be optimised with $\times 5 0$ more efficiency in terms of memory footprint.
|
| 169 |
+
|
| 170 |
+

|
| 171 |
+
Figure 6: Visualisation of Pascal VOC validation set with ClassMix (left) vs. with ReCo (right) trained on 1 labelled pixel per class per image. Interesting regions are shown in white arrows.
|
| 172 |
+
|
| 173 |
+
Ratio of Unlabelled Data We evaluate how ReCo can generalise across different levels of unlabelled data. In Fig. 7c, we show that by only training on $10 \%$ unlabelled data in the original setting, we can already surpass the ClassMix baseline. This shows that ReCo can achieve strong generalisation not only in label efficiency but also in data efficiency.
|
| 174 |
+
|
| 175 |
+
Choice of Semi-Supervised Method Finally, we show that ReCo is robust to the choice of different semi-supervised methods. In Fig. 7d, we can see that ReCo obtains a better performance from a variety choice of semi-supervised baselines.
|
| 176 |
+
|
| 177 |
+
Effect of Active Sampling In Fig. 7e, we see that randomly sampling queries and keys gives much less improvement compared to active sampling in our default setting. Particularly, hard query sampling has a dominant effect on generalisation: if we instead only sample from easy queries, ReCo only marginally improves on the baseline. This further verifies that most queries are redundant.
|
| 178 |
+
|
| 179 |
+

|
| 180 |
+
Figure 7: mean IoU validation performance on 20 labelled CityScapes dataset based on different choices of hyper-parameters. Grey: ClassMix (if not labelled otherwise) in our default setting. Light Blue: ReCo $^ +$ ClassMix (if not labelled otherwise) in a different hyper-parameter setting. Dark Blue: ReCo $^ +$ ClassMix in our default setting.
|
| 181 |
+
|
| 182 |
+
# 5 VISUALISATIONS AND INTERPRETABILITY OF CLASS RELATIONSHIPS
|
| 183 |
+
|
| 184 |
+
In this section, we visualise the pair-wise semantic class relation graph defined in Eq. 3, additionally supported by a semantic class dendrogram using the off-the-shelf hierarchical clustering algorithm in SciPy (Virtanen et al., 2020) for better visualisation. The features for each semantic class used in both visualisations are averaged across all available pixel embeddings in each class from the validation set. In all visualisations, we compared features learned with ReCo built on top of supervised learning compared to a standard supervised learning method trained on all data, representing the semantic class relationships of the full dataset.
|
| 185 |
+
|
| 186 |
+
Using the same definitions in Section 3.1, we first choose such pixel embedding to be the embedding $Z$ predicted from the encoder network $\phi$ in both supervised learning and with ReCo. We also show the visualisation for embedding $R$ which is the actual representation we used for ReCo loss and active sampling.
|
| 187 |
+
|
| 188 |
+

|
| 189 |
+
Figure 8: Visualisation of semantic class relation graph (top) and its corresponding semantic class dendrogram (bottom) on CityScapes dataset. Brighter colour represents closer (more confused) relationship. Best viewed in zoom.
|
| 190 |
+
|
| 191 |
+
In Fig. 8, we present the semantic class relationship and dendrogram for the CityScapes dataset by embedding $R$ and $Z$ with and without ReCo. We can clearly see that ReCo helps disentangle features compared to supervised learning where many pairs of semantic classes are similar. In addition, we find that the dendrogram generated by ReCo based on embedding $Z$ is more structured, showing a clear and interpretable semantic tree by grouping semantically similar classes together: for example, all large transportation classes car, truck, bus and train are under the same parent branch. In addition, we find that nearly all classes based on embedding $R$ are perfectly disentangled, except for bus and train, suggesting the CityScapes dataset might not have sufficient bus and train examples to learn a distinctive representation for these two classes.
|
| 192 |
+
|
| 193 |
+
The pair-wise relation graph helps us to understand the distribution of semantic classes in each dataset, and clarifies the pattern of incorrect predictions from the trained semantic network. We additionally provide a dendrogram based on embedding $R$ for the SUN RGBD dataset, clearly showing ambiguous class pairs, such as night stand and dresser; table and desk; floor
|
| 194 |
+
|
| 195 |
+

|
| 196 |
+
Figure 9: Visualisation of semantic class dendrogram based on embedding $R$ on SUN RGB-D dataset using ${ \mathrm { R e C o } } + { \mathrm { S } }$ upervised method. Best viewed in zoom.
|
| 197 |
+
|
| 198 |
+
and floormat, consistent with our results shown in Fig. 5. Complete visualisations of these semantic class relationships are shown in Appendix F.
|
| 199 |
+
|
| 200 |
+
# 6 CONCLUSION
|
| 201 |
+
|
| 202 |
+
In this work, we have presented ReCo, a new pixel-level contrastive framework with active sampling, designed specifically for semantic segmentation. ReCo can improve performance in semantic segmentation methods with minimal additional memory footprint. In particular, ReCo has shown its strongest effect in semi-supervised learning with very few labels, where we improved on the stateof-the-art by a large margin. In further work, we aim to design effective contrastive frameworks for video representation learning.
|
| 203 |
+
|
| 204 |
+
# REPRODUCIBILITY
|
| 205 |
+
|
| 206 |
+
All of the information for reproducibility is shown in Appendix A. Code is available at https: //github.com/lorenmt/reco.
|
| 207 |
+
|
| 208 |
+
# ACKNOWLEDGEMENT
|
| 209 |
+
|
| 210 |
+
This work has been supported by Dyson Technology Ltd. We thank Zhe Lin for the initial discussion and Zhengyang Feng for his help on the evaluation metric design.
|
| 211 |
+
|
| 212 |
+
# REFERENCES
|
| 213 |
+
|
| 214 |
+
Inigo Alonso, Alberto Sabater, David Ferstl, Luis Montesano, and Ana C Murillo. Semi-supervised ˜ semantic segmentation with pixel-level contrastive learning from a class-wise memory bank. In Proceedings of the International Conference on Computer Vision (ICCV), 2021.
|
| 215 |
+
|
| 216 |
+
David Berthelot, Nicholas Carlini, Ian Goodfellow, Nicolas Papernot, Avital Oliver, and Colin A Raffel. Mixmatch: A holistic approach to semi-supervised learning. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
|
| 217 |
+
|
| 218 |
+
Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs. IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI), 2017.
|
| 219 |
+
|
| 220 |
+
Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam. Encoderdecoder with atrous separable convolution for semantic image segmentation. In Proceedings of the European Conference on Computer Vision (ECCV), 2018.
|
| 221 |
+
|
| 222 |
+
Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In Proceedings of the International Conference on Machine Learning (ICML), 2020.
|
| 223 |
+
|
| 224 |
+
Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Rehfeld, Markus Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, and Bernt Schiele. The cityscapes dataset for semantic urban scene understanding. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
|
| 225 |
+
|
| 226 |
+
Mark Everingham, SM Ali Eslami, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman. The pascal visual object classes challenge: A retrospective. International Journal of Computer Vision (IJCV), 2015.
|
| 227 |
+
|
| 228 |
+
Zhengyang Feng, Qianyu Zhou, Qiqi Gu, Xin Tan, Guangliang Cheng, Xuequan Lu, Jianping Shi, and Lizhuang Ma. Dmt: Dynamic mutual training for semi-supervised learning. arXiv preprint arXiv:2004.08514, 2020.
|
| 229 |
+
|
| 230 |
+
Geoff French, Timo Aila, Samuli Laine, Michal Mackiewicz, and Graham Finlayson. Semisupervised semantic segmentation needs strong, high-dimensional perturbations. In Proceedings of the British Machine Vision Conference (BMVC), 2020.
|
| 231 |
+
|
| 232 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
|
| 233 |
+
|
| 234 |
+
Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
|
| 235 |
+
|
| 236 |
+
Wei Chih Hung, Yi Hsuan Tsai, Yan Ting Liou, Yen Yu Lin, and Ming Hsuan Yang. Adversarial learning for semi-supervised semantic segmentation. In Proceedings of the British Machine Vision Conference (BMVC), 2019.
|
| 237 |
+
|
| 238 |
+
Zhanghan Ke, Di Qiu, Kaican Li, Qiong Yan, and Rynson W.H. Lau. Guided collaborative training for pixel-wise semi-supervised learning. In Proceedings of the European Conference on Computer Vision (ECCV), 2020.
|
| 239 |
+
|
| 240 |
+
Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna, Yonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, and Dilip Krishnan. Supervised contrastive learning. Advances in Neural Information Processing Systems (NeurIPS), 2020.
|
| 241 |
+
|
| 242 |
+
Alexander Kirillov, Ross Girshick, Kaiming He, and Piotr Dollar. Panoptic feature pyramid net- ´ works. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
|
| 243 |
+
|
| 244 |
+
Alexander Kirillov, Yuxin Wu, Kaiming He, and Ross Girshick. Pointrend: Image segmentation as rendering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
|
| 245 |
+
|
| 246 |
+
Chia-Wen Kuo, Chih-Yao Ma, Jia-Bin Huang, and Zsolt Kira. Featmatch: Feature-based augmentation for semi-supervised learning. In Proceedings of the European Conference on Computer Vision (ECCV), 2020.
|
| 247 |
+
|
| 248 |
+
Xin Lai, Zhuotao Tian, Li Jiang, Shu Liu, Hengshuang Zhao, Liwei Wang, and Jiaya Jia. Semisupervised semantic segmentation with directional context-aware consistency. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
|
| 249 |
+
|
| 250 |
+
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense object ´ detection. In Proceedings of the International Conference on Computer Vision (ICCV), 2017.
|
| 251 |
+
|
| 252 |
+
Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2015.
|
| 253 |
+
|
| 254 |
+
Robert Mendel, Luis Antonio de Souza, David Rauber, Joao Paulo Papa, and Christoph Palm. Semi- ˜ supervised segmentation based on error-correcting supervision. In Proceedings of the European Conference on Computer Vision (ECCV), 2020.
|
| 255 |
+
|
| 256 |
+
Sudhanshu Mittal, Maxim Tatarchenko, and Thomas Brox. Semi-supervised semantic segmentation with high-and low-level consistency. IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI), 2019.
|
| 257 |
+
|
| 258 |
+
Takeru Miyato, Shin-ichi Maeda, Masanori Koyama, and Shin Ishii. Virtual adversarial training: a regularization method for supervised and semi-supervised learning. IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI), 2018.
|
| 259 |
+
|
| 260 |
+
Pedro O O. Pinheiro, Amjad Almahairi, Ryan Benmalek, Florian Golemo, and Aaron C Courville. Unsupervised learning of dense visual representations. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
|
| 261 |
+
|
| 262 |
+
Viktor Olsson, Wilhelm Tranheden, Juliano Pinto, and Lennart Svensson. Classmix: Segmentationbased data augmentation for semi-supervised learning. In IEEE Winter Conference on Applications of Computer Vision (WACV), 2021.
|
| 263 |
+
|
| 264 |
+
Yassine Ouali, Celine Hudelot, and Myriam Tami. Semi-supervised semantic segmentation with ´ cross-consistency training. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
|
| 265 |
+
|
| 266 |
+
Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In Proceedings of the International Conference on Medical Image Computing and Computer Assisted Intervention (MICCAI), 2015.
|
| 267 |
+
|
| 268 |
+
Kihyuk Sohn, David Berthelot, Nicholas Carlini, Zizhao Zhang, Han Zhang, Colin A Raffel, Ekin Dogus Cubuk, Alexey Kurakin, and Chun-Liang Li. Fixmatch: Simplifying semi-supervised learning with consistency and confidence. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
|
| 269 |
+
|
| 270 |
+
Shuran Song, Samuel P Lichtenberg, and Jianxiong Xiao. Sun rgb-d: A rgb-d scene understanding benchmark suite. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2015.
|
| 271 |
+
|
| 272 |
+
Antti Tarvainen and Harri Valpola. Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
|
| 273 |
+
|
| 274 |
+
Pauli Virtanen, Ralf Gommers, Travis E Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, et al. Scipy 1.0: fundamental algorithms for scientific computing in python. Nature methods, 2020.
|
| 275 |
+
|
| 276 |
+
Wenguan Wang, Tianfei Zhou, Fisher Yu, Jifeng Dai, Ender Konukoglu, and Luc Van Gool. Exploring cross-image pixel contrast for semantic segmentation. In Proceedings of the International Conference on Computer Vision (ICCV), 2021a.
|
| 277 |
+
|
| 278 |
+
Xinlong Wang, Rufeng Zhang, Chunhua Shen, Tao Kong, and Lei Li. Dense contrastive learning for self-supervised visual pre-training. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2021b.
|
| 279 |
+
|
| 280 |
+
Feihu Zhang, Philip Torr, Rene Ranftl, and Stephan R Richter. Looking beyond single images for contrastive semantic segmentation learning. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
|
| 281 |
+
|
| 282 |
+
Xiangyun Zhao, Raviteja Vemulapalli, Philip Andrew Mansfield, Boqing Gong, Bradley Green, Lior Shapira, and Ying Wu. Contrastive learning for label efficient semantic segmentation. In Proceedings of the International Conference on Computer Vision (ICCV), 2021.
|
| 283 |
+
|
| 284 |
+
Yi Zhu, Zhongyue Zhang, Chongruo Wu, Zhi Zhang, Tong He, Hang Zhang, R Manmatha, Mu Li, and Alexander Smola. Improving semantic segmentation via self-training. arXiv preprint arXiv:2004.14960, 2020.
|
| 285 |
+
|
| 286 |
+
Yang Zou, Zhiding Yu, BVK Kumar, and Jinsong Wang. Domain adaptation for semantic segmentation via class-balanced self-training. arXiv preprint arXiv:1810.07911, 2018.
|
| 287 |
+
|
| 288 |
+
Yang Zou, Zhiding Yu, Xiaofeng Liu, BVK Kumar, and Jinsong Wang. Confidence regularized self-training. In Proceedings of the International Conference on Computer Vision (ICCV), 2019.
|
| 289 |
+
|
| 290 |
+
Yuliang Zou, Zizhao Zhang, Han Zhang, Chun-Liang Li, Xiao Bian, Jia-Bin Huang, and Tomas Pfister. Pseudoseg: Designing pseudo labels for semantic segmentation. In Proceedings of the International Conference on Learning Representations (ICLR), 2021.
|
| 291 |
+
|
| 292 |
+
# APPENDIX
|
| 293 |
+
|
| 294 |
+
# A IMPLEMENTATION DETAILS
|
| 295 |
+
|
| 296 |
+
We trained all methods with SGD optimiser with learning rate $2 . 5 \times 1 0 ^ { - 3 }$ , momentum 0.9, and weight decay $5 \cdot 1 0 ^ { - 4 } $ . We adopted the polynomial annealing policy to schedule the learning rate, which is multiplied by $\begin{array} { r } { ( 1 - \frac { i \bar { t } e r } { t o t a l . i t e r } ) ^ { p o \bar { w } e r } } \end{array}$ with $p o w e r = 0 . 9$ , and trained for $4 0 \mathrm { k }$ iterations for all datasets. Code is attached in the supplementary material.
|
| 297 |
+
|
| 298 |
+
For CityScapes, we first downsampled all images in the dataset to half resolution $[ 5 1 2 \times 1 0 2 4 ]$ prior to use. We extracted $[ 5 1 2 \times 5 1 2 ]$ random crops and used a batch size of 2 during training.
|
| 299 |
+
|
| 300 |
+
For Pascal VOC, we extracted $[ 3 2 1 \times 3 2 1 ]$ random crops, applied a random scale between [0.5, 1.5], and used a batch size of 10 during training.
|
| 301 |
+
|
| 302 |
+
For SUN RGB-D, we first rescaled all images to $[ 3 8 4 \times 5 1 2 ]$ resolution, extracted $[ 3 2 1 \times 3 2 1 ]$ random crops, applied a random scale between [0.5, 1.5], and used a batch size of 5. We additionally re-organised the original training and validation split in SUN RGB-D dataset from 5285 and 5050 to 9860 and 475 samples respectively, to increase the amount of training data which we think is more appropriate for semi-supervised task.
|
| 303 |
+
|
| 304 |
+
All datasets were additionally augmented with Gaussian blur, colour jittering, and random horizontal flip. The pre-processing for CityScapes and Pascal VOC are consistent with the prior work (Olsson et al., 2021). In Table 2, we extracted $[ 5 1 3 \times 5 1 3 ]$ random crops and applied a random scale between [0.5, 2.0], following PseudoSeg’s training setup (Zou et al., 2021).
|
| 305 |
+
|
| 306 |
+
In our ReCo framework, we sampled 256 query samples and 512 key samples and used temperature $\tau = 0 . 5$ for each mini-batch, which we found to work well in all datasets. The dimensionality for pixel-level representation was set to $m = 2 5 6$ . The confidence thresholds were set to $\delta _ { w } = 0 . 7$ and $\delta _ { s } = 0 . 9 7$ .
|
| 307 |
+
|
| 308 |
+
# B ADDITIONAL ABLATIVE STUDIES
|
| 309 |
+
|
| 310 |
+
ReCo Only Results Table 4 shows ReCo designed with and without data augmentation, trained on 20 and 50 labelled CityScapes dataset. We observe that using pure semisupervised learning with additional unlabelled data will lead to worse performance compared to supervised learning without such labelled data. This shows data augmentation strategies designed for semi-supervised segmentation are the key component to make best use of the unlabelled data. Although the vanilla ReCo still performs better compared to standard semi-supervised learning, the active sam
|
| 311 |
+
|
| 312 |
+
<table><tr><td>CityScapes</td><td>20 Labels 50 Labels</td></tr><tr><td>Supervised</td><td>38.10 47.10</td></tr><tr><td>Semi-Supervised</td><td>28.59 43.74</td></tr><tr><td>Semi-Supervised +ReCo</td><td>29.16 46.96</td></tr><tr><td>ClassMix</td><td>45.61 55.56</td></tr><tr><td>ClassMix+Reco</td><td>49.86 57.69</td></tr></table>
|
| 313 |
+
|
| 314 |
+
Table 4: mean IoU validation performance for 20 and 50 labelled CityScapes data for supervised method (top) and semi-supervised methods (bottom).
|
| 315 |
+
|
| 316 |
+
pling of ReCo based on incorrect pseudo-labels leads to marginal improvement compared to a pure data augmentation method like ClassMix. Therefore, ReCo performs better as an auxiliary framework combined with a strong semi-supervised method.
|
| 317 |
+
|
| 318 |
+
Compared to Feature Bank Methods We have experimented with ReCo with a stored feature bank framework similar to the design in the concurrent works (Alonso et al., 2021; Wang et al., 2021a). We found that just by replacing our batch-wise sampling method with a feature bank sampling method will achieve a similar performance $4 9 . 3 4 ~ \mathrm { m I o U } )$ ) compared to our original design $( 4 9 . 8 6 ~ \mathrm { m I o U } )$ on 20 labelled CityScapes, but with a slower training speed. This verifies our assumption that batch-wise sampling is an accurate approximation of class distribution over the entire dataset.
|
| 319 |
+
|
| 320 |
+
# C RESULTS ON SEMI-SUPERVISED SEGMENTATION BENCHMARKS
|
| 321 |
+
|
| 322 |
+
Here, we present quantitative results for other semi-supervised semantic segmentation benchmarks in CityScapes and Pascal VOC datasets. Note that, this benchmark is much less challenging compared to our proposed benchmark in Section 4.1, evaluated with significantly less number of labelled images. Since some methods applied with different backbones and training strategies, we compared each result with respect to its performance gap compared to its corresponding fully supervised result, as shown in brackets, to ensure fairness following Feng et al. (2020).
|
| 323 |
+
|
| 324 |
+
In Table 5, we show results for ReCo applied on top of ClassMix, and trained with both DeepLabv2 (Chen et al., 2017) and DeepLabv $^ { 3 + }$ (Chen et al., 2018). We can observe that ReCo achieved the best performances in most cases in both datasets, showing its robustness to different backbone architectures and number of labelled training images.
|
| 325 |
+
|
| 326 |
+
<table><tr><td>Pascal VOC</td><td>Backbone</td><td>1/106 [100]</td><td>1/50 [212]</td><td>1/20 [529]</td><td>1/8 [1323]</td><td>Full [10582]</td></tr><tr><td>AdvSemSeg (Hung et al.,2019)</td><td>DeepLabv2</td><td></td><td>57.20(17.70)</td><td>64.70(10.20)</td><td>69.50(5.40)</td><td>74.90</td></tr><tr><td>S4GAN (Mittal et al.,2019)</td><td>DeepLabv2</td><td></td><td>63.30(12.30)</td><td>67.20(8.40)</td><td>71.40(4.20)</td><td>75.60</td></tr><tr><td>CutMix (French et al.,2020)</td><td>DeepLabv2</td><td>53.79(18.71)</td><td>64.81(7.73)</td><td>66.48(6.06)</td><td>67.60(4.94)</td><td>72.54</td></tr><tr><td>ClassMix (Olsson et al.,2021)</td><td>DeepLabv2</td><td>54.18(19.95)</td><td>66.15(7.98)</td><td>67.77(6.36)</td><td>71.00(3.13)</td><td>74.13</td></tr><tr><td>CCT (Ouali et al.,2020)</td><td>PSPNet</td><td></td><td></td><td>=</td><td>70.45(4.80)</td><td>75.25</td></tr><tr><td>CAC (Lai et al.,2021)</td><td>PSPNet</td><td></td><td></td><td></td><td>72.50(3.90)</td><td>76.40</td></tr><tr><td>GCT (Ke et al.,2020)</td><td>DeepLabv2</td><td></td><td></td><td></td><td>70.57(3.49)</td><td>74.06</td></tr><tr><td>DMT (Feng et al.,2020)</td><td>DeepLabv2</td><td>63.04(11.71)</td><td>67.15(7.60)</td><td>69.92(4.83)</td><td>72.70(2.05)</td><td>74.75</td></tr><tr><td>ReCo + ClassMix</td><td>DeepLabv2</td><td>63.16(11.20)</td><td>66.41(7.95)</td><td>68.85(5.51)</td><td>71.00(3.36)</td><td>74.36</td></tr><tr><td>ReCo+ClassMix</td><td>DeepLabv3+</td><td>63.60(14.15)</td><td>72.14(5.61)</td><td>73.66(4.09)</td><td>74.62( (3.13)</td><td>77.75</td></tr><tr><td>CityScapes</td><td>Backbone</td><td>1/30 [100]</td><td>1/8 [372]</td><td>1/4 [744]</td><td>1/2 [1488]</td><td>Full [2975]</td></tr><tr><td>AdvSemSeg (Hung et al.,2019)</td><td>DeepLabv2</td><td></td><td>58.80(7.60)</td><td>62.30(4.10)</td><td>65.70(0.70)</td><td>66.40</td></tr><tr><td>S4GAN (Mittal et al., 2019)</td><td>DeepLabv2</td><td></td><td>59.30(6.50)</td><td>61.90(3.90)</td><td></td><td>65.80</td></tr><tr><td>CutMix (French et al.,2020)</td><td>DeepLabv2</td><td>51.20(16.33)</td><td>60.34(7.19)</td><td>63.87(3.66)</td><td></td><td>67.53</td></tr><tr><td>ClassMix (Olsson et al.,2021)</td><td>DeepLabv2</td><td>54.07(12.12)</td><td>61.35(4.84)</td><td>63.63(2.56)</td><td>66.29(-0.10)</td><td>66.19</td></tr><tr><td>DMT (Feng et al.,2020)</td><td>DeepLabv2</td><td>54.81(13.36)</td><td>63.03(5.13)</td><td>=</td><td></td><td>68.16</td></tr><tr><td>ECS*(Mendel et al.,2020)</td><td>DeepLabv3+</td><td></td><td>67.38(7.38)</td><td>70.70(4.06)</td><td>72.89(1.87)</td><td>74.76</td></tr><tr><td>ReCo+ClassMix</td><td>DeepLabv2</td><td>56.53(12.07)</td><td>64.94(3.66)</td><td>67.53(1.07)</td><td>68.69(-0.09)</td><td>68.60</td></tr><tr><td>ReCo +ClassMix</td><td>DeepLabv3+</td><td>60.28(10.20)</td><td>66.44(4.04)</td><td>68.50(1.98)</td><td>70.63(-0.15)</td><td>70.48</td></tr></table>
|
| 327 |
+
|
| 328 |
+
Table 5: mean IoU validation performance in semi-supervsed Pascal VOC and CityScapes datasets. We list the percentage along with the number of labelled images at the top row. The first and second best performances in each data partition setting are coloured in red and orange respectively. $^ *$ trained images in doubled resolution. All results were taken from the corresponding publications.
|
| 329 |
+
|
| 330 |
+
# D VISUALISATION ON PASCAL VOC (TRAINED WITH 60 LABELLED IMAGES)
|
| 331 |
+
|
| 332 |
+
In the full label setting, the baselines Supervised and ClassMix are very prone to completely misclassifying rare objects such as boat, bottle and table, while our method can predict these rare classes accurately.
|
| 333 |
+
|
| 334 |
+

|
| 335 |
+
|
| 336 |
+
<table><tr><td rowspan=1 colspan=1>Background Aeroplane Bicycle</td><td rowspan=1 colspan=1>Bird</td><td rowspan=1 colspan=1>Boat</td><td rowspan=1 colspan=1>Bottle</td><td rowspan=1 colspan=1>Bus</td><td rowspan=1 colspan=1>Car</td><td rowspan=1 colspan=1>Cat</td><td rowspan=1 colspan=1>Chair</td><td rowspan=1 colspan=1>Cow</td></tr><tr><td rowspan=1 colspan=2>Table Dog Horse Motorbike</td><td rowspan=1 colspan=1>Motorbike</td><td rowspan=1 colspan=1>Person</td><td rowspan=1 colspan=1>Plant</td><td rowspan=1 colspan=1>Sheep</td><td rowspan=1 colspan=1>Sofa</td><td rowspan=1 colspan=1>Train</td><td rowspan=1 colspan=1>Monitor</td></tr></table>
|
| 337 |
+
|
| 338 |
+
# E VISUALISATION ON CITYSCAPES (TRAINED WITH $1 \%$ LABELLED PIXEL)
|
| 339 |
+
|
| 340 |
+
In the partial label setting, the performance improvements are less pronounced compared to the full label setting in CityScapes dataset. The improvements typically come from the more accurate predictions in small object boundaries such as in traffic light and traffic sign. Learning semantics with partial labels with minimal boundary information remains an open research question and still has huge scope for improvements.
|
| 341 |
+
|
| 342 |
+

|
| 343 |
+
|
| 344 |
+
<table><tr><td>Road</td><td>Sidewalk</td><td>Building</td><td>Wall</td><td></td><td>Pole</td><td>TrafficLight</td><td>Traffic Sign</td><td>Vegetation</td><td></td></tr><tr><td>Sky</td><td>Person</td><td>Rider</td><td>Car</td><td>ruck</td><td>Bus</td><td>Train</td><td>Motorcycle</td><td>Bicycle</td><td>Invalid</td></tr></table>
|
| 345 |
+
|
| 346 |
+
# F VISUALISATION ON SEMANTIC CLASS RELATIONSHIP FROM PASCAL VOC (TOP) AND SUN RGB-D (BOTTOM)
|
| 347 |
+
|
| 348 |
+
We show features learned by ReCo are more disentangled compared to the Supervised baseline in all datasets, which helps the segmentation model to learn a better decision boundary. Brighter colour represents closer (more confused) relationship. Best viewed in zoom.
|
| 349 |
+
|
| 350 |
+

|
| 351 |
+
(a) Embed. Z (Supervised) (b) Embed. Z (ReCo $^ +$ Supervised) (c) Embed. R (ReCo $^ +$ Supervised)
|
md/dev/8aHzds2uUyB/8aHzds2uUyB.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/9h3KsOVXhLZ/9h3KsOVXhLZ.md
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SwinTrack: A Simple and Strong Baseline for Transformer Tracking
|
| 2 |
+
|
| 3 |
+
Liting Lin1,2∗ Heng $\mathbf { F a n ^ { 3 * } }$ Zhipeng Zhang4 Yong $\mathbf { X } \mathbf { u } ^ { 1 , 2 }$ Haibin Ling5
|
| 4 |
+
|
| 5 |
+
1School of Computer Science & Engineering, South China Univ. of Tech., Guangzhou, China 2Peng Cheng Laboratory, Shenzhen, China
|
| 6 |
+
3Department of Computer Science and Engineering, University of North Texas, Denton, USA 4DiDi Chuxing, Beijing, China 5Department of Computer Science, Stony Brook University, Stony Brook, USA l.lt@mail.scut.edu.cn, heng.fan $@$ unt.edu, zhipeng.zhang.cv $@$ outlook.com yxu@scut.edu.cn, hling $@$ cs.stonybrook.edu
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
Recently Transformer has been largely explored in tracking and shown state-of-theart (SOTA) performance. However, existing efforts mainly focus on fusing and enhancing features generated by convolutional neural networks (CNNs). The potential of Transformer in representation learning remains under-explored. In this paper, we aim to further unleash the power of Transformer by proposing a simple yet efficient fully-attentional tracker, dubbed SwinTrack, within classic Siamese framework. In particular, both representation learning and feature fusion in SwinTrack leverage the Transformer architecture, enabling better feature interactions for tracking than pure CNN or hybrid CNN-Transformer frameworks. Besides, to further enhance robustness, we present a novel motion token that embeds historical target trajectory to improve tracking by providing temporal context. Our motion token is lightweight with negligible computation but brings clear gains. In our thorough experiments, SwinTrack exceeds existing approaches on multiple benchmarks. Particularly, on the challenging LaSOT, SwinTrack sets a new record with 0.713 SUC score. It also achieves SOTA results on other benchmarks. We expect SwinTrack to serve as a solid baseline for Transformer tracking and facilitate future research. Our codes and results are released at https://github.com/LitingLin/SwinTrack.
|
| 11 |
+
|
| 12 |
+
# 1 Introduction
|
| 13 |
+
|
| 14 |
+
Visual tracking has seen considerable progress since deep learning. In particular, the recent Transformer [30] has significantly pushed the state-of-the-art in tracking owing to its ability in modeling long-range dependencies. However, existing methods usually leverage Transformer for fusing and enhancing features generated from convolutional neural networks (CNNs), e.g., ResNet [14]. The potential of exploiting Transformer for feature representation learning is largely under-explored.
|
| 15 |
+
|
| 16 |
+
Recently, Vision Transformer (ViT) [7] has exhibited great potential in robust feature representation learning. Particularly, its extension Swin Transformer [23] has achieved state-of-the-art (SOTA) results on multiple tasks. Taking inspiration from this, we argue, besides the feature fusion, the representation learning in tracking can also benefit from Transformer via attention. Thus motivated, we propose to develop a fully attentional tracking framework based on Siamese architecture. Specifically, both the feature representation learning and the feature fusion of template and search region are realized by Transformer. More concretely, we borrow the architecture of the powerful
|
| 17 |
+
|
| 18 |
+

|
| 19 |
+
Figure 1: Comparison on LaSOT [9]. Our tracker (SwinTrack-B-384) sets a new record with 0.713 SUC score and still runs efficiently at around $4 5 f p s$ . A lighter version (SwinTrack-T-224) achieves 0.672 SUC score and runs at around $9 6 f p s$ , which is on par with existing SOTAs in accuracy but much faster.
|
| 20 |
+
|
| 21 |
+
Swin Transformer [23] and adapt it to Siamese tracking. Note that, other Transformer architectures can be used. For feature fusion, we introduce a simple homogeneous concatenation-based fusion architecture, without a query-based decoder.
|
| 22 |
+
|
| 23 |
+
Moreover, taking into consideration that tracking is a temporal task, we propose a novel motion token to improve robustness. Inspired by that the target usually moves smoothly in a short period, motion token is represented by the historical target trajectory within a local temporal window. We incorporate the (single) motion token in the decoder of feature fusion to leverage motion information during tracking. Despite being conceptually simple, our motion token can effectively boost tracking performance, with negligible computation.
|
| 24 |
+
|
| 25 |
+
We name our framework SwinTrack. As a pure Transformer framework, SwinTrack enables better interactions inside the feature learning of template and search region and their fusion compared to pure CNN-based [1, 20] and hybrid CNN-Transformer [5, 32, 36] frameworks, leading to more robust performance (see Fig. 1). Fig. 2 demonstrates the architecture of SwinTrack. We conduct extensive experiments on five large-scale benchmarks to verify the effectiveness of SwinTrack, including LaSOT [9], $\mathrm { L a S O T _ { \mathrm { e x t } } }$ [8], TrackingNet [26], GOT-10k [15] and TNL2k [34]. On all benchmarks, SwinTrack achieves promising results and meanwhile runs fast at $4 5 f p s$ . In particular, on the challenging LaSOT, SwinTrack sets a new record of 71.3 SUC score, surpassing the strongest prior tracker [36] (to date) by 3.1 absolute percentage points and crossing the 0.7 SUC threshold for the first time (see Fig. 1 again). It also achieves 49.1 SUC, 84.0 SUC, 72.4 AO and 55.9 SUC scores on $\mathrm { L a S O T _ { e x t } }$ , TrackingNet, GOT-10k and TNL2k respectively, which are better than or on par with state-of-the-arts (SoTAs). In addition, we provide a lighter version of SwinTrack that obtains comparable results to SoTAs but runs much faster at around 98 fps.
|
| 26 |
+
|
| 27 |
+
In summary, our contributions are as follows: (i) We propose SwinTrack, a simple and strong baseline for fully attentional tracking; (ii) We present a simple yet effective motion token, enabling the integration of rich motion context during tracking, further boosting the robustness of SwinTrack, with negligible computation; (iii) Our proposed SwinTrack achieves state-of-the-art performance on multiple benchmarks. We believe SwinTrack further shows the potential of Transformer and expect it to serve as a baseline for future research.
|
| 28 |
+
|
| 29 |
+
# 2 Related Work
|
| 30 |
+
|
| 31 |
+
Siamese Tracking. The Siamese tracking methods formulate tracking as a matching problem and aim to offline learn a generic matching function for this task. The seminal method of [1] introduces a fully convolutional Siamese network for tracking and shows a good balance between accuracy and speed. To improve Siamese tracking in handling scale variation, the work of [20] incorporates the region proposal network (RPN) [27] into the Siamese network and proposes the anchor-based tracker, showing higher accuracy with faster speed. Later, numerous extensions have been presented to improve Siamese tracking, including deeper backbone [19], multi-stage architecture [10, 11], anchor-free Siamese trackers [41], deformable attention [37], to name a few.
|
| 32 |
+
|
| 33 |
+

|
| 34 |
+
Figure 2: Architecture of SwinTrack, which contains three parts including Transformer-based feature representation extraction, Transformer-based feature fusion and prediction head. Our SwinTrack is a simple and neat tracking framework without complex designs such as multi-scale features or temporal template updating, yet demonstrating state-of-the-art performance. Best viewed in color.
|
| 35 |
+
|
| 36 |
+
Transformer in Vision. Transformer [30] originates from natural language processing (NLP) for machine translation and has been introduced to vision recently and shows great potential. The work of [3] first uses Transformer for object detection and achieved promising results. To explore the capability of Transformer in representation learning, the work of [7] applies Transformer to construct backbone network, and the resulting Vision Transformer (ViT) attains excellent performance compared to convolutional networks while requiring fewer training resources, which encourages many extensions upon ViT[29, 4, 38, 33, 23]. Among them, the Swin Transformer [23] has received extensive attention. It proposes a simple shifted window strategy to replace the fixed-patch method in ViT, which significantly improves efficiency and meanwhile demonstrates state-of-the-art results on multiple image tasks. Our work is inspired by Swin Transformer, but differently, we focus on the video task of visual tracking.
|
| 37 |
+
|
| 38 |
+
Transformer in Tracking. Inspired by the success in other fields, researchers have leveraged Transformer for tracking. The method of [5] applies Transformer to enhance and fuse features in the Siamese tracking for improvement. The approach of [32] uses Transformer to exploit temporal features to improve tracking robustness. The work of [36] introduces a new transformer architecture dedicated to visual tracking, explores the Spatio-temporal Transformer by integrating the model updating operations into a Transformer module.
|
| 39 |
+
|
| 40 |
+
Our SwinTrack is related to but significantly different from the above Transformer-based trackers. Specifically, the aforementioned methods mainly apply Transformer to fuse convolutional features and belong to the hybrid CNN-Transformer architecture. Unlike them, SwinTrack is a pure Transformerbased tracking architecture where both representation learning and feature fusion are realized with Transformer, enabling the exploration of better features for robust tracking.
|
| 41 |
+
|
| 42 |
+
# 3 Tracking via Vision-Motion Transformer
|
| 43 |
+
|
| 44 |
+
We present SwinTrack, a vision-motion integrated Transformer for object tracking, in Fig. 2. The proposed framework contains three main components, i.e., the Swin-Transformer backbone for feature extraction, the encoder-decoder network for mixing vision-motion cues, and the head network for localizing targets. In the following sections, we first shortly describe the Swin-Transformer backbone network, then elaborate on the proposed vision-motion encoder-decoder. Afterward, we give a discussion about our method and shortly describe the network head and training loss.
|
| 45 |
+
|
| 46 |
+
# 3.1 Swin-Transformer for Feature Extraction
|
| 47 |
+
|
| 48 |
+
The deep convolutional neural network has significantly improved the performance of trackers. Along with the advancement of trackers, the backbone network has evolved twice: AlexNet [17] and ResNet [14]. Swin-Transformer [23], in comparison to ResNet, can give a more compact feature representation and richer semantic information to assist succeeding networks in better localizing the target objects (demonstrate in the ablation study demonstrated in the ablation study), which is thus chosen for basic feature extraction in our model.
|
| 49 |
+
|
| 50 |
+
Our tracker, following Siamese tracking framework [1], requires a pair of image patches as inputs, i.e., template image $\mathbf { z } \in \overline { { \mathbb { R } } } ^ { H _ { z } \times W _ { z } \times 3 }$ and search region image $\mathbf { x } \in \mathbb { R } ^ { \mathbf { \hat { H } } _ { x } \times W _ { x } \times 3 }$ . As in the typical SwinTransformer procedure, template and search region images are divided to non-overlapped patches and sent to the network, which generates template tokens (dubbed T-tokens) φ(z) ∈ R Hzs Wzs ×C a nd search region tokens (dubbed S-tokens) $\varphi ( \mathbf { x } ) \in \mathbb { R } ^ { \frac { H _ { x } } { s } \frac { W _ { x } } { s } \times C }$ . $s$ is the stride of the backbone network. Since there is no dimension projection in our model, $C$ is the hidden dimension of the whole model.
|
| 51 |
+
|
| 52 |
+
# 3.2 Vision-Motion Representation Learning
|
| 53 |
+
|
| 54 |
+
The essential step for matching-based visual tracking is injecting the template information into the search region. In our framework, we adopt an encoder to fuse the features from the template and the search region, meanwhile, a decoder is arranged to achieve vision-motion representation learning, as illustrated in Fig. 2.
|
| 55 |
+
|
| 56 |
+
Encoder for fusing template and search tokens. The encoder contains a sequence of Transformer blocks where each consists of a multi-head self-attention (MSA) module and a feed-forward network (FFN). FFN contains a two-layers multi-layer perceptron (MLP), GELU activation layer is inserted after the first linear layer. Layer normalization (LN) is always conducted before every module (MSA and FFN). Residual connection is applied to MSA and FFN modules.
|
| 57 |
+
|
| 58 |
+
Before feeding the features into the encoder, the template and search region tokens are concatenated along spatial dimensions to generate a mixing representation $\mathbf { f } _ { m }$ . For each block, the MSA module computes self-attention over mixing union representation, which equals to separately conducting self-attention on T-tokens/S-tokens and meanwhile performing cross-attention between T-tokens and S-tokens, but more efficient. FFN refines the features generated by MSA. When the tokens get out of the encoder, a de-concatenation operation is arranged to decouple the template and search region tokens. The process of encoder can be expressed as:
|
| 59 |
+
|
| 60 |
+
$$
|
| 61 |
+
\begin{array} { r l } & { \mathbf { f } _ { m } ^ { 1 } = \mathrm { C o n c a t } ( \boldsymbol { \varphi } ( \mathbf { z } ) , \boldsymbol { \varphi } ( \mathbf { x } ) ) } \\ & { \qquad \cdots \cdot } \\ & { \mathbf { f } _ { m } ^ { l ^ { \prime } } = \mathbf { f } _ { m } ^ { l } + \mathrm { M S A } ( \mathrm { L N } ( \mathbf { f } _ { m } ^ { l } ) ) } \\ & { \mathbf { f } _ { m } ^ { l + 1 } = \mathbf { f } _ { m } ^ { l ^ { \prime } } + \mathrm { F F N } ( \mathrm { L N } ( \mathbf { f } _ { m } ^ { l ^ { \prime } } ) ) } \\ & { \qquad \cdots } \\ & { \mathbf { f } _ { z } ^ { L } , \mathbf { f } _ { x } ^ { L } = \mathrm { D e C o n c a t } ( \mathbf { f } ^ { L } ) , } \end{array}
|
| 62 |
+
$$
|
| 63 |
+
|
| 64 |
+
where $l$ denotes the $l$ -th layer and $L$ denotes the number of blocks.
|
| 65 |
+
|
| 66 |
+
Decoder for fusing vision and motion information. Before describing the architecture of decoder, we first detail how to generate a motion token (dubbed M-token). Motion token is the embedding of the historical trajectory of the target object. The past object trajectory is represented as a set of target object box coordinates, $T = \left\{ \Phi _ { 1 } , \Phi _ { 2 } , . . . , \Phi _ { t } \right\}$ , where $t$ represents the frame index, o is the bounding box of target object. o is defined by the top-left and bottom-right corners of the target object, denotes as $\Phi _ { t } ^ { - } = \bigl ( o _ { t } ^ { - x _ { 1 } } , o _ { t } ^ { y _ { 1 } } , o _ { t } ^ { x _ { 2 } } , o _ { t } ^ { y _ { 2 } } \bigr )$ . For flexible modeling, a sampling process is required to ensure the following properties: 1) fixed length, 2) focusing on the latest trajectories and 3) reducing redundancy. In our method, we sample object trajectory as:
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
\begin{array} { r } { \mathcal { T } = \big \{ \Phi _ { s ( 1 ) } , \Phi _ { s ( 2 ) } , . . . , \Phi _ { s ( n ) } \big \} , \mathrm { w h e r e } s ( i ) = m a x ( t - i \times \Delta , 1 ) , } \end{array}
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
$n$ is the number of sampled object trajectories, $\Delta$ is the fixed sampling interval. For Siamese tracker, the search region is cropped from the input image. In detail, a cropping with resizing operation can be used to describe the process. Giving the point in the input image as $\left( \mathbf { x } _ { i } , \mathbf { y } _ { i } \right)$ , the corresponding point in the search region as $\left( \mathbf { x } _ { o } , \mathbf { y } _ { o } \right)$ , we can formulate the cropping process employed in pre-processing of the Siamese Tracker as $\mathbf { x } _ { o } = ( \mathbf { x } _ { i } - i _ { x } ) s _ { x } + o _ { x }$ and ${ \bf y } _ { o } = ( { \bf y } _ { i } - i _ { y } ) s _ { y } + o _ { y }$ , where $( i _ { x } , i _ { y } )$ is the center of the cropping window in the input image, $( s _ { x } , s _ { y } )$ is the scaling factor, $( o _ { x } , o _ { y } )$ is the center of cropped and scaled window in the search region. We apply the same transformation on the sampled object trajectory to make the object trajectory invariant to the cropping, denoting $\bar { \mathcal { T } } = \{ \bar { \mathbb { D } } _ { s ( 1 ) } , \bar { \mathbb { D } } _ { s ( 2 ) } , . . . , \bar { \mathbb { D } } _ { s ( n ) } \}$ as the result.
|
| 73 |
+
|
| 74 |
+
Then, to embed the transformed object trajectory into the network, we adopt four embedding matrices to embed the elements in box coordinates separately. We denotes the embedding matrix as W ∈ R(g+1)×d, $\^ \mathrm { g }$ controls the embedding granularity of the object trajectory, $d$ is the size of each embedding vector. The last entry of the embedding matrix is used as the padding vector, indicating an invalid state, like object absence or out of the search region. Thus, we normalize the sampled target object box coordinates in the range $[ 1 , \mathbb { g } ]$ , and quantize to integers to get the index of embedding vector:
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
\begin{array} { r l } & { \hat { T } = \{ \hat { \mathbb { O } } _ { s ( 1 ) } , \hat { \mathbb { O } } _ { s ( 2 ) } , . . . , \hat { \mathbb { O } } _ { s ( n ) } \} , } \\ & { \mathrm { \it ~ \gamma ~ \mathrm { h e r e } ~ } \hat { \mathbb { O } } _ { s ( i ) } = [ \mathrm { n } ( \bar { \mathbb { O } } _ { s ( i ) } ^ { x _ { 1 } } , w ) , \mathrm { n } ( \bar { \mathbb { O } } _ { s ( i ) } ^ { y _ { 1 } } , h ) , \mathrm { n } ( \bar { \mathbb { O } } _ { s ( i ) } ^ { x _ { 2 } } , w ) , \mathrm { n } ( \bar { \mathbb { O } } _ { s ( i ) } ^ { y _ { 2 } } , h ) ] , } \\ & { \mathrm { \it ~ \mathrm { \it ~ \hat { \Omega } ~ } } \mathrm { \ n } ( o , l ) = \left\{ \begin{array} { l l } { \mathrm { \Delta } [ \frac { o } { l } \times \mathbb { g } ] } & { \mathrm { i f ~ } \mathrm { v a l i d } , } \\ { \mathbb { g } + 1 } & { \mathrm { e l s e } , } \end{array} \right. } \end{array}
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
$( w , h )$ is the size of search region feature map.
|
| 81 |
+
|
| 82 |
+
Finally, the motion token $\mathbf { E } _ { m o t i o n } ~ \in ~ \mathbb { R } ^ { 1 \times d }$ is given by a concatenation of all box coordinate embedding of the sampled object trajectory. FLOPs is negligible because the construction of motion token is just a composition of embedding lookups and token concatenation.
|
| 83 |
+
|
| 84 |
+
The decoder consists of a multi-head cross-attention(MCA) module and a feed-forward network(FFN). The decoder takes the outputsvision-motion representation $\mathbf { f } _ { v m } \in \mathbb { R } ^ { \frac { H _ { x } } { s } \times \frac { W _ { x } } { s } \times C }$ d the motion token as input, generating tof by computing cross-attention over $\mathbf { f } _ { x } ^ { L }$ finaland $\mathrm { C o n c a t } ( { \bf E } _ { m o t i o n } , { \bf f } _ { z } ^ { L } , { \bf f } _ { x } ^ { L } )$ . The decoder is akin to a layer in the encoder, except that the correlation between the template tokens and the search tokens is dropped since we do not need to update the features from the template image in the last layer. The process of the decoder is formulated as:
|
| 85 |
+
|
| 86 |
+
$$
|
| 87 |
+
\begin{array} { r l } & { \mathbf { f } _ { m } ^ { D } = \mathrm { C o n c a t } ( \mathbf { E } _ { m o t i o n } , \mathbf { f } _ { z } ^ { L } , \mathbf { f } _ { x } ^ { L } ) } \\ & { \mathbf { f } _ { v m } ^ { \prime } = \mathbf { f } _ { x } ^ { L } + \mathrm { M C A } ( \mathrm { L N } ( \mathbf { f } _ { x } ^ { L } ) , \mathrm { L N } ( \mathbf { f } _ { m } ^ { D } ) ) } \\ & { \mathbf { f } _ { v m } = \mathbf { f } _ { v m } ^ { \prime } + \mathrm { F F N } ( \mathrm { L N } ( \mathbf { f } _ { v m } ^ { \prime } ) ) . } \end{array}
|
| 88 |
+
$$
|
| 89 |
+
|
| 90 |
+
$\mathbf { f } _ { v m }$ will feed to the head network to generate a classification response map and a bounding box regression map.
|
| 91 |
+
|
| 92 |
+
Positional encoding. Transformer requires a positional encoding to identify the position of the current processing token[30] because the self-attention module is permutation-invariance. We adopt the untied positional encoding [16] as our positional encoding method. The untied positional encoding enhances the expressiveness of the model through untie the positional embeddings from token embeddings with an isolated positional embedding matrix. It also considers the case of special tokens, like the motion token in this paper. We generalize the untied positional encoding to multi-dimensions multi-sources data to comply with concatenated-based fusion in our tracker. See the appendix for the details.
|
| 93 |
+
|
| 94 |
+
# 3.3 Discussion
|
| 95 |
+
|
| 96 |
+
Why concatenated attention? To simplify the description, we call the method described above concatenation-based fusion. To fuse and process features from multiple sources, it is intuitive to perform self-attention on the feature from each source separately and then compute cross-attention across features from different sources. We call this method cross-attention-based fusion. Transformer makes fewer assumptions about the spatial structure of data, which provides great modeling flexibility.
|
| 97 |
+
|
| 98 |
+
In comparison to cross-attention-based fusion, concatenation-based fusion can save computation cost through operation sharing and reduce model parameters through weight sharing. From the perspective of metric learning, weight sharing is an essential design to ensure the metric between two branches of data is symmetric. Through concatenation-based fusion, we implement this property not only in the feature extraction stage but also in the feature fusion stage. In general, concatenation-based fusion improves both efficiency and performance.
|
| 99 |
+
|
| 100 |
+
Why not window-based self/cross-attention? Since we select stage 3 of the Swin-Transformer as the output, the number of tokens involved is significantly reduced, window-based attention cannot save too many FLOPs. Furthermore, considering the extra latency introduced by the window partition and window reverse operations, window-based attention may even be the slower one.
|
| 101 |
+
|
| 102 |
+
Why not a query-based decoder? Derivated from vanilla Transformer decoder, many transformerbased models in vision tasks leverage a learnable query to extract the desired objective features from the encoder, like object queries in [3], target query in [36]. However, in our experiment, a query-based decoder suffers from slow convergence and inferior performance. Most Siamese trackers [20, 35, 13] formulate tracking as a foreground-background classification problem, which can better exploit the background information. The vanilla Transformer decoder is a generative model, the generative approaches are considered not suitable for the classification tasks. In another aspect, learning a general target query for any kind of object might cause a bottleneck. In terms of vanilla Transformer encoder-decoder architecture, SwinTrack is an "encoder" only model. Furthermore, quite a little domain knowledge can be easily applied on a classic Siamese tracker to improve the performance, like introducing the smooth movement assumption by using Hanning penalty window on the response map.
|
| 103 |
+
|
| 104 |
+
Are other forms of motion token feasible? Other forms to construct motion token are possible, such as constructing motion token by summing up the past box coordinate embeddings or representing past object trajectories by one token per box. In our early experiments, we find that the proposed motion token is more effective with the best performance. Summing up the past box coordinate embeddings may result in over-parameterization on the coordinate embeddings. While adding temporal motion representation along with visual features to the single-layer decoder in a multi-token form is ineffective, precise temporal modeling may be required in this form.
|
| 105 |
+
|
| 106 |
+
# 3.4 Head and Loss
|
| 107 |
+
|
| 108 |
+
Head. The head network is split into two branches: classification and bounding box regression. Each of them is a three-layer perceptron. And both of them receives the feature map from the decoder as input to predict the classification response map $r _ { c l s } \in \mathbb { R } ^ { ( H _ { x } \times W _ { x } ) \times 1 }$ and bounding box regression map $\bar { r _ { r e g } } \in \mathbb { R } ^ { ( H _ { x } \times W _ { x } ) \times 4 }$ , respectively.
|
| 109 |
+
|
| 110 |
+
Classification loss. In classification branch, we employ the $I o U$ -aware classification score as the training target and the varifocal loss [39] as the training loss function. IoU-aware design has been very popular recently, but most works consider IoU prediction as an auxiliary branch to assist classification or bounding box regression [41, 2, 35]. To remove the gap between different prediction branches, [39] and [21] replace the hard classification target from the ground-truth value, (i.e., 1 for positive samples, 0 for negative samples), to the IoU between the predicted bounding box and the ground-truth one, which is named the $I o U .$ -aware classification score (IACS). IACS can help the model select a more accurate bounding box prediction candidate from the pool by trying to predict the quality of the bounding box prediction in another branch at the same position. Along with the IACS, the varifocal loss was proposed in [39] to help the IACS approach outperform other IoU-aware designs.
|
| 111 |
+
|
| 112 |
+
The classification loss can be formulated as:
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\mathbb { L } _ { c l s } = \mathbb { L } _ { \mathrm { V F L } } ( p , \mathrm { I o U } ( b , \hat { b } ) ) ,
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
where $p$ denotes the predicted IACS, $b$ denotes the predicted bounding box, and $\hat { b }$ denotes the ground-truth bounding box.
|
| 119 |
+
|
| 120 |
+
Regression loss. For bounding box regression, we employ the generalized IoU loss[28]. The regression loss function can be formulated as:
|
| 121 |
+
|
| 122 |
+
$$
|
| 123 |
+
\mathbb { L } _ { r e g } = \sum _ { j } \mathbb { 1 } _ { \left\{ \mathrm { I o U } ( b _ { j } , \hat { b } ) > 0 \right\} } [ p \mathbb { L } _ { \mathrm { G I o U } } ( b _ { j } , \hat { b } ) ] .
|
| 124 |
+
$$
|
| 125 |
+
|
| 126 |
+
The GIoU loss is weighted by $p$ to emphasize the high classification score samples. The training signals from the negative samples are ignored.
|
| 127 |
+
|
| 128 |
+
# 4 Experiments
|
| 129 |
+
|
| 130 |
+
# 4.1 Implementation
|
| 131 |
+
|
| 132 |
+
Model. We design two variants of SwinTrack with different configurations as follows:
|
| 133 |
+
|
| 134 |
+
• SwinTrack-T-224. Backbone: Swin Transformer-Tiny [23], pretrained with ImageNet-1k; Template size: $[ 1 1 2 \times 1 1 2 ]$ ; Search region size: $[ 2 2 4 \times 2 2 4 ]$ ; $C = 3 8 4$ ; $N = 4$ ;
|
| 135 |
+
• SwinTrack-B-384. Backbone: Swin Transformer-Base [23], pretrained with ImageNet-22k; Template size: $[ 1 9 2 \times 1 9 2 ]$ ; Search region size: $[ 3 8 4 \times 3 8 4 ]$ ; $C = 5 1 2$ ; $N = 8$ ;
|
| 136 |
+
|
| 137 |
+
where $C$ and $N$ are the channel number of the hidden layers in the first stage of Swin Transformer and the number of encoder blocks in feature fusion, respectively. In all variants, we use the output after the third stage of Swin Transformer for feature extraction. Thus, the backbone stride $s$ is 16.
|
| 138 |
+
|
| 139 |
+
For motion token, the number of sampled object trajectory $n$ is set to 16, the fixed sampling interval $\Delta$ is set to 15. If the frame rate of the video sequence is available, the sampling interval is adjusted according to the frame rate. Suppose the frame rate is $\mathbb { f }$ , the new sampling interval is getting by $\mathrm { { \frac { \Delta } { 3 0 } f } }$ , 30 fps is the standard frame rate we assumed. g, which controls the embedding granularity, is set to the same size as the search region feature map, like 14 for SwinTrack-T-224, and 24 for SwinTrack-B-384. For the model for GOT-10k sequences, $n$ is set to 8, $\Delta$ is set to 8, and no frame rate adjustment is applied.
|
| 140 |
+
|
| 141 |
+
Training. We train SwinTrack using the training splits of LaSOT [9], TrackingNet [26], GOT-10k [15] (1,000 videos are removed following [36] for fair comparison) and COCO 2017 [22]. In addition, we report the results of SwinTrack-T-224 and SwinTrack-B-384 with GOT-10k training split only to follow the protocol described in [15].
|
| 142 |
+
|
| 143 |
+
The model is optimized with AdamW [24], with a learning rate of 5e-4, and a weight decay of 1e-4. The learning rate of the backbone is set to 5e-5. We train the network on 8 NVIDIA V100 GPUs for 300 epochs with 131,072 samples per epoch. The learning rate is dropped by a factor of 10 after 210 epochs. A 3-epoch linear warmup is applied to stabilize the training process. DropPath [18] is applied on the backbone and the encoder with a rate of 0.1. For the models trained for the GOT-10k evaluation protocol, to prevent over-fitting, the training epoch is set to 150, and the learning rate is dropped after 120 epochs.
|
| 144 |
+
|
| 145 |
+
For the motion token, the object trajectory for the Siamese training pair is generated with the method described above. The frames that object annotated as absent or out of the video sequence are marked as invalid, the corresponding box coordinates set to $- \infty$ . Since the coarse granularity of the coordinate embedding in our setting is already can be seen as an augmentation of historical object trajectory, no additional data augmentation is applied.
|
| 146 |
+
|
| 147 |
+
Inference. We follow the common procedures for Siamese network-based tracking [1]. The template image is cropped from the first frame of the video sequence. The target object is in the center of the image with a background area factor of 2. The search region is cropped from the current tracking frame, and the image center is the target center position predicted in the previous frame. The background area factor for the search region is 4.
|
| 148 |
+
|
| 149 |
+
Our SwinTrack takes the template image and search region as inputs and output classification map $r _ { c l s }$ and regression map $r _ { r e g }$ . To utilize positional prior in tracking, we apply hanning window penalty on $r _ { c l s }$ , and the final classification map $r _ { c l s } ^ { \prime }$ is obtained via $\boldsymbol { r } _ { c l s } ^ { \prime } = ( 1 - \gamma ) \times \boldsymbol { r } _ { c l s } + \gamma \times \boldsymbol { h }$ , where $\gamma$ is the weight parameter and $h$ is the Hanning window with the same size as $r _ { c l s }$ . The target position is determined by the largest value in $r _ { c l s } ^ { \prime }$ and the scale is estimated based on the corresponding regression results in $r _ { r e g }$ .
|
| 150 |
+
|
| 151 |
+
For the motion token, the predicted confidence score and bounding box are collected on the fly. A confidence threshold $\theta _ { c o n f }$ is applied, if the confidence score given by the classification branch of the head is lower than the threshold, the target object in the current frame is marked as lost by setting the collected bounding box to $- \infty$ . $\theta _ { c o n f }$ is set to 0.4 for LaSOT, the rests are set to 0.3.
|
| 152 |
+
|
| 153 |
+
Table 1: Experiments and comparisons on five benchmarks: LaSOT, $\mathrm { L a S O T _ { e x t } }$ , TrackingNet, GOT10k and TNL2k.
|
| 154 |
+
|
| 155 |
+
<table><tr><td rowspan="2">Tracker</td><td colspan="2">LaSOT[9]</td><td colspan="2">LaSOText [8]</td><td colspan="2">TrackingNet [26]</td><td colspan="3">GOT-10k [15]</td><td colspan="2">TNL2k [34]</td></tr><tr><td>SUC</td><td>P</td><td>SUC</td><td>P</td><td>SUC</td><td>P</td><td>AO</td><td>SR0.5</td><td>SR0.75</td><td>SUC</td><td>P</td></tr><tr><td>C-RPN [10]</td><td>45.5</td><td>44.3</td><td>27.5</td><td>32.0</td><td>66.9</td><td>61.9</td><td>1</td><td>1</td><td>1</td><td>-</td><td>-</td></tr><tr><td>SiamPRN++ [19]</td><td>49.6</td><td>49.1</td><td>34.0</td><td>39.6</td><td>73.3</td><td>69.4</td><td>51.7</td><td>61.6</td><td>32.5</td><td>41.3</td><td>41.2</td></tr><tr><td>Ocean [41]</td><td>56.0</td><td>56.6</td><td>-</td><td>-</td><td>1</td><td>-</td><td>61.1</td><td>72.1</td><td>47.3</td><td>38.4</td><td>37.7</td></tr><tr><td>DiMP [2]</td><td>56.9</td><td>56.7</td><td>39.2</td><td>45.1</td><td>74.0</td><td>68.7</td><td>61.1</td><td>71.7</td><td>49.2</td><td>44.7</td><td>43.4</td></tr><tr><td>LTMU [6]</td><td>57.2</td><td>57.2</td><td>41.4</td><td>47.3</td><td>-</td><td>-</td><td>-</td><td>-</td><td>1</td><td>48.5</td><td>47.3</td></tr><tr><td>SiamR-CNN[31]</td><td>64.8</td><td>1</td><td>1</td><td>1</td><td>81.2</td><td>80.0</td><td>64.9</td><td>72.8</td><td>59.7</td><td>52.3</td><td>52.8</td></tr><tr><td>STMTrack [12]</td><td>60.6</td><td>63.3</td><td>-</td><td>-</td><td>80.3</td><td>76.7</td><td>64.2</td><td>73.7</td><td>57.5</td><td>-</td><td>-</td></tr><tr><td>AutoMatch [40]</td><td>58.3</td><td>59.9</td><td>37.6</td><td>43.0</td><td>76.0</td><td>72.6</td><td>65.2</td><td>76.6</td><td>54.3</td><td>-</td><td>-</td></tr><tr><td>TrDiMP [32]</td><td>63.9</td><td>61.4</td><td>1</td><td>1</td><td>78.4</td><td>73.1</td><td>67.1</td><td>77.7</td><td>58.3</td><td>-</td><td>-</td></tr><tr><td>TransT[5]</td><td>64.9</td><td>69.0</td><td>-</td><td>1</td><td>81.4</td><td>80.3</td><td>67.1</td><td>76.8</td><td>60.9</td><td>51.0</td><td>-</td></tr><tr><td>STARK [36]</td><td>67.1</td><td></td><td></td><td>=</td><td>82.0</td><td>-</td><td>68.8</td><td>78.1</td><td>64.1</td><td>-</td><td>-</td></tr><tr><td>KeepTrack [25]</td><td>67.1</td><td>70.2</td><td>48.2</td><td>-</td><td>-</td><td>-</td><td>1</td><td>-</td><td>1</td><td>-</td><td>-</td></tr><tr><td>SwinTrack-T-224</td><td>67.2</td><td>70.8</td><td>47.6</td><td>53.9</td><td>81.1</td><td>78.4</td><td>71.3</td><td>81.9</td><td>64.5</td><td>53.0</td><td>53.2</td></tr><tr><td>SwinTrack-B-384</td><td>71.3</td><td>76.5</td><td>49.1</td><td>55.6</td><td>84.0</td><td>82.8</td><td>72.4</td><td>80.5</td><td>67.8</td><td>55.9</td><td>57.1</td></tr></table>
|
| 156 |
+
|
| 157 |
+
# 4.2 Comparisons to State-of-the-arts
|
| 158 |
+
|
| 159 |
+
We conduct experiments and compare SwinTrack with SoTA trackers on five benchmarks.
|
| 160 |
+
|
| 161 |
+
LaSOT. LaSOT [9] consists of 280 videos for test. Tab. 1 shows the results and comparisons with SoTAs. From Tab. 1, we can observe that SwinTrack-T-224 with light architecture reaches SoTA performance with 0.672 SUC and 0.708 PRE scores, which is competitive compared with other Transformer-based trackers, including STARK-ST101 (0.671 SUC score) and TransT (0.649 SUC), and other trackers using complicated designs such as KeepTrack (0.671 SUC) and SiamR-CNN (0.648 SUC score). With a larger backbone and input size, our strongest variant SwinTrack-B-384 sets a new record with 0.713 SUC score, surpassing START-ST101 and KeepTrack by 4.2 absolute percentage points.
|
| 162 |
+
|
| 163 |
+
$\mathbf { L a S O T } _ { \mathrm { e x t } }$ . The recent $\mathrm { L a S O T _ { \mathrm { e x t } } }$ [8] is an extension of LaSOT by adding 150 extra videos. These new sequences are challenging as many similar distractors cause difficulties for tracking. The results of our tracker related to this dataset are an average of three times. KeepTrack uses a complex association technique to handle distractors and achieves a promising 0.482 SUC score as in Tab. 1. Compared with complicated KeepTrack, SwinTrack-T-224 is simple and neat, yet shows comparable performance with 0.476 SUC score. In addition, due to complicated design, KeepTrack runs at less than $2 0 f p s$ , while SwinTrack-T-224 runs in 98 fps, $5 \times$ faster than KeepTrack. When using a larger model, SwinTrack-B-384 shows the best performance with 0.491 SUC score.
|
| 164 |
+
|
| 165 |
+
TrackingNet. We evaluate different trackers on the test set of TrackingNet [26]. From Tab. 1, we observe that our SwinTrack-T-224 achieves a comparable result with 0.811 SUC score. Using a larger model and input size, SwinTrack-B-384 obtains the best performance with 0.840 SUC score, better than STARK-ST101 with 0.820 SUC score and TransT with 0.814 SUC score.
|
| 166 |
+
|
| 167 |
+
GOT-10k. GOT-10k [15] offers 180 videos for test and it requires trackers to be trained using GOT-10k train split only. From Tab. 1, we see that SwinTrack-B-384 achieves the best mAO of 0.724, and SwinTrack-T-224 obtains a mAO of 0.713. Both models outperform other Transformer-based counterparts significantly, including START-ST101 (0.688 mAO), TransT (0.671 mAO) and TrDiMP (0.671 mAO).
|
| 168 |
+
|
| 169 |
+
TNL2k. TNL2k [34] is a newly released tracking dataset with 700 videos for test. As reported in Tab. 1, both models surpass the others. SwinTrack-B-384 set a new state-of-the-art with 0.559 SUC score.
|
| 170 |
+
|
| 171 |
+
Table 2: Comparison on running speed and # parameters with other Transformer-based trackers.
|
| 172 |
+
|
| 173 |
+
<table><tr><td>Tracker</td><td>Speed (fps)</td><td>MACs² (G)</td><td>Params (M)</td></tr><tr><td>TrDiMP [32]</td><td>26</td><td>=</td><td>1</td></tr><tr><td>TransT[5]</td><td>50</td><td>=</td><td>23</td></tr><tr><td>STARK-ST50 [36]</td><td>42</td><td>10.9</td><td>24</td></tr><tr><td>STARK-ST101 [36]</td><td>32</td><td>18.5</td><td>42</td></tr><tr><td>SwinTrack-T-224</td><td>98</td><td>6.4</td><td>23</td></tr><tr><td>SwinTrack-B-384</td><td>45</td><td>69.7</td><td>91</td></tr></table>
|
| 174 |
+
|
| 175 |
+
Table 3: Ablation experiments of SwinTrack on four benchmarks. The experiments are conducted on SwinTrack-T-224 without the motion token. ❶: baseline method, i.e., SwinTrack-T-224 without motion token; $\otimes$ : replacing Transformer backbone in the baseline method with ResNet-50; ❸: replacing our feature fusion with cross attention-based fusion in the baseline method; $\bullet$ : replacing the decoder in baseline with a target query-based; $\pmb { \ 6 }$ : replacing united positional encoding with absolute sine position encoding in the baseline method; $\pmb { \circledcirc }$ : replacing the IoU-aware classification loss with the plain binary cross entropy loss; $\pmb { \ 6 }$ : removing the Hanning penalty window in the baseline method inference.
|
| 176 |
+
|
| 177 |
+
<table><tr><td></td><td>LaSOT SUC (%)</td><td>LaSOText SUC (%)</td><td>TrackingNet SUC (%)</td><td>GOT-10k3 mA0 (%)</td><td>Speed fps</td><td>Params M</td></tr><tr><td>1</td><td>66.7</td><td>46.9</td><td>80.8</td><td>70.9</td><td>98</td><td>22.7</td></tr><tr><td>②</td><td>64.2</td><td>41.8</td><td>79.5</td><td>68.2</td><td>121</td><td>20.0</td></tr><tr><td>③</td><td>66.6</td><td>45.4</td><td>80.2</td><td>69.3</td><td>72</td><td>34.6</td></tr><tr><td>4</td><td>66.6</td><td>43.2</td><td>79.6</td><td>69.0</td><td>91</td><td>25.3</td></tr><tr><td>5</td><td>65.7</td><td>45.0</td><td>80.0</td><td>70.0</td><td>103</td><td>21.6</td></tr><tr><td>6</td><td>66.2</td><td>46.7</td><td>79.4</td><td>68.2</td><td>98</td><td>22.7</td></tr><tr><td>0</td><td>65.7</td><td>46.0</td><td>80.0</td><td>69.6</td><td>98</td><td>22.7</td></tr></table>
|
| 178 |
+
|
| 179 |
+
Efficiency comparison. We report the comparisons of SwinTrack with other Transformer-based trackers in terms of efficiency and complexity. As displayed in Tab. 2, SwinTrack-T-224 with a small model runs the fastest with a speed of 98 fps. Especially, compared with STARK-ST101 and STARK-ST50 with $3 2 f p s$ and $4 2 f p s$ , SwinTrack-T-224 is $3 \times$ and $2 \times$ faster. Despite using a larger model, our SwinTrack-B-384 is still faster than STARK-ST101 and STARK-ST50.
|
| 180 |
+
|
| 181 |
+
# 4.3 Ablation Experiment
|
| 182 |
+
|
| 183 |
+
Comparison with ResNet backbone. We compare the Swin-Transformer backbone with popular ResNet-50 [14]. As shown in Tab. 3 ( $\pmb { \theta }$ vs. $\pmb { \varrho }$ ). The Swin Transformer backbone significantly boosts the performance by $2 . 5 \%$ SUC score in LaSOT, $5 . 1 \%$ SUC score in $\mathrm { L a S O T _ { e x t } }$ . The result shows that the strong appearance modeling capability provided by the Swin Transformer plays a crucial role.
|
| 184 |
+
|
| 185 |
+
Feature fusion. As displayed in Tab. 3 $\pmb { \theta }$ vs. $\pmb { \Theta }$ ), compared with the concatenation-based fusion, the cross attention-based fusion runs at a slower speed, occupies much more memory, and also has an inferior performance on all datasets. Slower speed can be due to the latency brought by the extra operations. The parameter-sharing strategy not only just reduces the number of parameters but also benefits metric learning.
|
| 186 |
+
|
| 187 |
+
Comparison with the query-based decoder. Queries is commonly adopted in the decoder of Transformer network in vision tasks, e.g. object query [3] and target query [36]. Nevertheless, our empirical results in Tab. 3 $\pmb { \ 0 }$ vs. $\pmb { \varrho }$ ) show that a target query-based decoder degrades the tracking performance on all benchmarks, even with $2 \times$ training pairs. As discussed, one possible reason is the generative model is not suitable for classification. Besides, learning a general target query for any kind of object may also be difficult.
|
| 188 |
+
|
| 189 |
+
Position encoding. We compare the united positional encoding used in SwinTrack and the original absolute position encoding in Transformer [30]. Notice, We make a little modification to the original absolute position encoding: Except for the 2D embedding, the index of token source (e.g. 1 for the tokens from the template patch, 2 for the tokens from the search region patch) is also embedded. As shown in Tab. 3 (❶ vs. $\bullet$ ), our method with united positional encoding obtains improvements with 0.8-1.9 absolute percentage points on the benchmarks with negligible loss in speed (98 vs. 103).
|
| 190 |
+
|
| 191 |
+
Table 4: Ablation experiments on our proposed motion token on the tracking performance on four benchmarks. The experiments are conducted on SwinTrack-T-224. ❶: SwinTrack-T-224; ❷: SwinTrack-B-384; $\otimes$ : SwinTrack-T-224 without motion token; ❹: SwinTrack-B-384 without motion token; $\pmb { \ 6 }$ : replacing the motion token in SwinTrack-T-224 with a learnable embedding token.
|
| 192 |
+
|
| 193 |
+
<table><tr><td>SUC (%)</td><td>LaSOT</td><td>LaSOText SUC (%)</td><td>TrackingNet SUC (%)</td><td>GOT-10k mA0 (%)</td><td>Speed fps</td></tr><tr><td>1</td><td>67.2</td><td>47.6</td><td>81.1</td><td>71.3</td><td>96</td></tr><tr><td>②</td><td>71.3</td><td>49.1</td><td>84.0</td><td>72.4</td><td>45</td></tr><tr><td>③</td><td>66.7</td><td>47.0</td><td>80.8</td><td>70.0</td><td>98</td></tr><tr><td>4</td><td>70.2</td><td>48.5</td><td>84.0</td><td>70.7</td><td>45</td></tr><tr><td>6</td><td>66.3</td><td>45.2</td><td>81.2</td><td>70.0</td><td>96</td></tr></table>
|
| 194 |
+
|
| 195 |
+
Loss function. From Tab. 3 $( \bullet \nu . \bullet )$ , we observe that the model trained with varifocal loss significantly outperforms the one with binary cross entropy (BCE) loss without loss of efficiency. This result indicates that the varifocal loss can assist the classification branch of the head to generate an IoU-aware response map, and thus help the tracker to improve the tracking performance.
|
| 196 |
+
|
| 197 |
+
Post processing. One may wonder with highly discriminative Transformer architecture and IoUaware classification loss does the hanning penalty window is still functional, which introduces a strong smooth movement assumption. In the experiments, we remove the hanning penalty window in post-processing, as shown in Tab. 3 $( \pmb { \mathbb { 0 } } \nu s . \pmb { \mathbb { \otimes } } )$ , the performance is dropped by 1.0 SUC for LaSOT, $1 . 3 \mathrm { \ A O }$ for GOT-10k in absolute percentage, and less than $1 \%$ in the SUC metric of other datasets. This suggests that the strong smooth movement assumption is still applicable for our tracker. But compared with the former Transformer-based tracker [5], the performance gap between with and without penalty window post-processing is narrowing.
|
| 198 |
+
|
| 199 |
+
Effectiveness of motion token. We study the effectiveness of the motion token by conducting comparison experiments. As shown in Tab. 4 $\pmb { \mathbb { \otimes } }$ vs. $\pmb { \otimes }$ and $\pmb { \varrho }$ vs. $\pmb { \varrho }$ ), the models with motion token outperforms the models without motion token on all datasets, especially on $\mathrm { L a S O T _ { e x t } }$ and GOT-10k. The results indicate that the motion token can assist the tracker to handle hard similar distractors in $\mathrm { L a S O T _ { e x t } }$ and stabilize the short-term tracking like the sequences in GOT-10k test set. We also study whether the effectiveness of the motion token is simply from the extra embedding vector. We set up an experiment as in Tab. 4 $( \pmb { \Theta } )$ , which replaces the motion token with a learnable embedding token. The result shows that the extra embedding vector has negative impacts indicating the effectiveness of the embedding of object trajectory.
|
| 200 |
+
|
| 201 |
+
# 5 Conclusion
|
| 202 |
+
|
| 203 |
+
In this work, we present SwinTrack, a simple and strong baseline for Transformer tracking. In SwinTrack, both representation learning and feature fusion are implemented with the attention mechanism. Extensive experiments demonstrate the effectiveness of such architecture. Besides, we propose the motion token to enhance the robustness of the tracker by providing the historical object trajectory, showing the flexibility of the Transformer model in architectural design. With the power of sequence-to-sequence model architecture, a context-rich tracker is possible, and more contextual cues can be incorporated. Finally, We hope this work can inspire and facilitate future research.
|
| 204 |
+
|
| 205 |
+
# Acknowledgments and Disclosure of Funding
|
| 206 |
+
|
| 207 |
+
This work is supported by Peng Cheng Laboratory Research Project No. PCL2021A07. Heng Fan and his employer receive no financial support for the research, authorship, and/or publication of this article.
|
| 208 |
+
|
| 209 |
+
# References
|
| 210 |
+
|
| 211 |
+
[1] Bertinetto, L., Valmadre, J., Henriques, J.F., Vedaldi, A., Torr, P.H., 2016. Fully-convolutional siamese networks for object tracking, in: ECCVW. [2] Bhat, G., Danelljan, M., Gool, L.V., Timofte, R., 2019. Learning discriminative model prediction for tracking, in: ICCV. [3] Carion, N., Massa, F., Synnaeve, G., Usunier, N., Kirillov, A., Zagoruyko, S., 2020. End-to-end object detection with transformers, in: ECCV. [4] Chen, C.F.R., Fan, Q., Panda, R., 2021a. Crossvit: Cross-attention multi-scale vision transformer for image classification, in: ICCV. [5] Chen, X., Yan, B., Zhu, J., Wang, D., Yang, X., Lu, H., 2021b. Transformer tracking, in: CVPR. [6] Dai, K., Zhang, Y., Wang, D., Li, J., Lu, H., Yang, X., 2020. High-performance long-term tracking with meta-updater, in: CVPR. [7] Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., et al., 2021. An image is worth 16x16 words: Transformers for image recognition at scale, in: ICLR. [8] Fan, H., Bai, H., Lin, L., Yang, F., Chu, P., Deng, G., Yu, S., Huang, M., Liu, J., Xu, Y., et al., 2021. Lasot: A high-quality large-scale single object tracking benchmark. International Journal of Computer Vision 129, 439–461. [9] Fan, H., Lin, L., Yang, F., Chu, P., Deng, G., Yu, S., Bai, H., Xu, Y., Liao, C., Ling, H., 2019. Lasot: A high-quality benchmark for large-scale single object tracking, in: CVPR.
|
| 212 |
+
[10] Fan, H., Ling, H., 2019. Siamese cascaded region proposal networks for real-time visual tracking, in: CVPR.
|
| 213 |
+
[11] Fan, H., Ling, H., 2021. Cract: Cascaded regression-align-classification for robust visual tracking, in: IROS.
|
| 214 |
+
[12] Fu, Z., Liu, Q., Fu, Z., Wang, Y., 2021. Stmtrack: Template-free visual tracking with space-time memory networks, in: CVPR.
|
| 215 |
+
[13] Han, W., Dong, X., Khan, F.S., Shao, L., Shen, J., 2021. Learning to fuse asymmetric feature maps in siamese trackers, in: CVPR.
|
| 216 |
+
[14] He, K., Zhang, X., Ren, S., Sun, J., 2016. Deep residual learning for image recognition, in: CVPR.
|
| 217 |
+
[15] Huang, L., Zhao, X., Huang, K., 2019. Got-10k: A large high-diversity benchmark for generic object tracking in the wild. IEEE Transactions on Pattern Analysis and Machine Intelligence 43, 1562–1577.
|
| 218 |
+
[16] Ke, G., He, D., Liu, T.Y., 2021. Rethinking positional encoding in language pre-training, in: ICLR.
|
| 219 |
+
[17] Krizhevsky, A., Sutskever, I., Hinton, G.E., 2012. Imagenet classification with deep convolutional neural networks. NIPS .
|
| 220 |
+
[18] Larsson, G., Maire, M., Shakhnarovich, G., 2016. Fractalnet: Ultra-deep neural networks without residuals, in: ICLR.
|
| 221 |
+
[19] Li, B., Wu, W., Wang, Q., Zhang, F., Xing, J., Yan, J.S., 2019. Evolution of siamese visual tracking with very deep networks, in: CVPR.
|
| 222 |
+
[20] Li, B., Yan, J., Wu, W., Zhu, Z., Hu, X., 2018. High performance visual tracking with siamese region proposal network, in: CVPR.
|
| 223 |
+
[21] Li, X., Wang, W., Wu, L., Chen, S., Hu, X., Li, J., Tang, J., Yang, J., 2020. Generalized focal loss: Learning qualified and distributed bounding boxes for dense object detection, in: NeurIPS.
|
| 224 |
+
[22] Lin, T.Y., Maire, M., Belongie, S., Hays, J., Perona, P., Ramanan, D., Dollár, P., Zitnick, C.L., 2014. Microsoft coco: Common objects in context, in: ECCV.
|
| 225 |
+
[23] Liu, Z., Lin, Y., Cao, Y., Hu, H., Wei, Y., Zhang, Z., Lin, S., Guo, B., 2021. Swin transformer: Hierarchical vision transformer using shifted windows. ICCV .
|
| 226 |
+
[24] Loshchilov, I., Hutter, F., 2019. Decoupled weight decay regularization, in: ICLR.
|
| 227 |
+
[25] Mayer, C., Danelljan, M., Paudel, D.P., Van Gool, L., 2021. Learning target candidate association to keep track of what not to track, in: ICCV.
|
| 228 |
+
[26] Muller, M., Bibi, A., Giancola, S., Alsubaihi, S., Ghanem, B., 2018. Trackingnet: A large-scale dataset and benchmark for object tracking in the wild, in: ECCV.
|
| 229 |
+
[27] Ren, S., He, K., Girshick, R., Sun, J., 2015. Faster r-cnn: Towards real-time object detection with region proposal networks, in: NIPS.
|
| 230 |
+
[28] Rezatofighi, H., Tsoi, N., Gwak, J., Sadeghian, A., Reid, I., Savarese, S., 2019. Generalized intersection over union .
|
| 231 |
+
[29] Touvron, H., Cord, M., Douze, M., Massa, F., Sablayrolles, A., Jégou, H., 2021. Training data-efficient image transformers & distillation through attention, in: ICML.
|
| 232 |
+
[30] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, Ł., Polosukhin, I., 2017. Attention is all you need, in: NeurIPS.
|
| 233 |
+
[31] Voigtlaender, P., Luiten, J., Torr, P.H., Leibe, B., 2020. Siam r-cnn: Visual tracking by re-detection, in: CVPR.
|
| 234 |
+
[32] Wang, N., Zhou, W., Wang, J., Li, H., 2021a. Transformer meets tracker: Exploiting temporal context for robust visual tracking, in: CVPR.
|
| 235 |
+
[33] Wang, W., Xie, E., Li, X., Fan, D.P., Song, K., Liang, D., Lu, T., Luo, P., Shao, L., 2021b. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions, in: ICCV.
|
| 236 |
+
[34] Wang, X., Shu, X., Zhang, Z., Jiang, B., Wang, Y., Tian, Y., Wu, F., 2021c. Towards more flexible and accurate object tracking with natural language: Algorithms and benchmark, in: CVPR.
|
| 237 |
+
[35] Xu, Y., Wang, Z., Li, Z., Yuan, Y., Yu, G., 2020. Siamfc++: Towards robust and accurate visual tracking with target estimation guidelines, in: AAAI.
|
| 238 |
+
[36] Yan, B., Peng, H., Fu, J., Wang, D., Lu, H., 2021. Learning spatio-temporal transformer for visual tracking, in: ICCV.
|
| 239 |
+
[37] Yu, Y., Xiong, Y., Huang, W., Scott, M.R., 2020. Deformable siamese attention networks for visual object tracking, in: CVPR.
|
| 240 |
+
[38] Yuan, L., Chen, Y., Wang, T., Yu, W., Shi, Y., Jiang, Z.H., Tay, F.E., Feng, J., Yan, S., 2021. Tokens-to-token vit: Training vision transformers from scratch on imagenet, in: ICCV.
|
| 241 |
+
[39] Zhang, H., Wang, Y., Dayoub, F., Sünderhauf, N., 2021a. Varifocalnet: An iou-aware dense object detector, in: CVPR.
|
| 242 |
+
[40] Zhang, Z., Liu, Y., Wang, X., Li, B., Hu, W., 2021b. Learn to match: Automatic matching network design for visual tracking, in: ICCV.
|
| 243 |
+
[41] Zhang, Z., Peng, H., Fu, J., Li, B., Hu, W., 2020. Ocean: Object-aware anchor-free tracking, in: ECCV.
|
md/dev/A4fSkNAs6E1/A4fSkNAs6E1.md
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HIERARCHICAL GAUSSIAN MIXTURE BASED TASK GENERATIVE MODEL FOR ROBUST META-LEARNING
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Meta-learning enables quick adaptation of machine learning models to new tasks with limited data. While tasks could come from varying distributions in reality, most of the existing meta-learning methods consider both training and testing tasks as from the same uni-component distribution, overlooking two critical needs of a practical solution: (1) the various sources of tasks may compose a multicomponent mixture distribution, and (2) novel tasks may come from a distribution that is unseen during meta-training. In this paper, we demonstrate these two challenges can be solved jointly by modeling the density of task instances. We develop a meta-training framework underlain by a novel Hierarchical Gaussian Mixture based Task Generative Model (HTGM). HTGM extends the widely used empirical process of sampling tasks to a theoretical model, which learns task embeddings, fits the mixture distribution of tasks, and enables density-based scoring of novel tasks. The framework is agnostic to the encoder and scales well with large backbone networks. The model parameters are learned end-to-end by maximum likelihood estimation via an Expectation-Maximization algorithm. Extensive experiments on benchmark datasets indicate the effectiveness of our method for both sample classification and novel task detection.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Training models in small data regimes is of fundamental importance. It demands a model’s ability to quickly adapt to new environments and tasks. To compensate for the lack of training data for each task, meta-learning (a.k.a. learning to learn) has become an essential paradigm for model training by generalizing meta-knowledge across tasks (Snell et al., 2017; Finn et al., 2017). While most existing meta-learning approaches were built upon an assumption that all training/testing tasks are sampled from the same distribution, a more realistic scenario should accommodate training tasks that lie in a mixture of distributions, and testing tasks that may belong to or deviate from the learned distributions. For example, in recent medical research, a global model is typically trained on the historical medical records of a certain set of patients in the database (Shukla & Marlin, 2019; Wu et al., 2021). However, due to the uniqueness of individuals (e.g., gender, age, genetics), patients’ data have a substantial discrepancy, and the pre-trained model may demonstrate significant demographic or geographical biases when testing on a new patient (Purushotham et al., 2017). This issue can be mitigated by personalized medicine approaches (Chan & Ginsburg, 2011; Ni et al., 2022) where each patient is regarded as a task, and the pre-trained model is fine-tuned (i.e., personalized) on a support set of a few records collected in a short period (e.g., a few weeks) from every patient for adaptation. In this case, the training tasks (i.e., patients) could be sampled from a mixture of distributions (e.g., different age groups), and a testing task may or may not belong to any of the observed groups. As such, a meta-training strategy that is able to fit a mixture of task distributions and identify novel tasks is desirable for making meta-learning a practical solution.
|
| 12 |
+
|
| 13 |
+
One way to tackle the mixture distributions of tasks is to tailor the transferable knowledge to each task by learning a task-specific representation (Oreshkin et al., 2018; Vuorio et al., 2018; Lee & Choi, 2018), but as discussed in (Yao et al., 2019a), the over-customized knowledge prevents its generalization among closely related tasks (e.g., tasks from the same distribution). The more recent methods try to balance the generalization and customization of the meta-knowledge by promoting local generalization either among a cluster of related tasks (Yao et al., 2019a), or within a neighborhood of a meta-knowledge graph of tasks (Yao et al., 2019b). Neither of them explicitly learns the underlying distribution from which the tasks are generated, rendering them infeasible for detecting novel tasks that are out-of-distribution. However, detecting novel tasks is crucial in high-stake domains, such as medicine and finance, which provides users (e.g., physicians) confidence on whether to trust the results of a testing task or not, and facilitates the downstream decision-making.
|
| 14 |
+
|
| 15 |
+
In (Lee et al., 2019a), a task-specific tuning variable was introduced to modulate the initial parameters learned by MAML (Finn et al., 2017), so that the impacts of the meta-knowledge on different tasks are adjusted differently, e.g., novel tasks receive less impact than known tasks do. Whereas, this method focuses on improving model performance on different tasks (either known or novel), but neglects the critical mission of detecting which tasks are novel. In practice, providing an unreliable accuracy on a novel task, without differentiating it from other tasks may be meaningless and risky.
|
| 16 |
+
|
| 17 |
+
Since the aforementioned methods cannot simultaneously handle the mixture distribution of tasks and novel tasks, a practical solution is in demand. In this work, we consider tasks as instances, and demonstrate the dual problem of modeling the mixture of task distributions and detecting novel tasks are two sides of the same coin, i.e., density estimation on task instances. To this end, we propose a new Hierarchical Gaussian Mixture based Task Generative Model (HTGM) to explicitly model the generative process of task instances. Our contributions are summarized as follows.
|
| 18 |
+
|
| 19 |
+
• For the first time, the widely used empirical process of generating a task is theoretically extended to and specified by a hierarchy of Gaussian mixture (GM) distributions. HTGM generates a task embedding from a task-level GM, and uses it to define the task-conditioned mixture probabilities for a class-level GM, from which samples are drawn, for instantiating the generated task. To allow realistic classes per task, a new Gibbs distribution is proposed to underlie the class-level GM. • HTGM is an encoder-agnostic framework, thus is flexible to different domains. It inherits metricbased meta-learning methods, and only introduces a small overhead to an encoder for parameterizing its distributions, thus is efficient, and enables large-scale backbone networks. The model parameters are learned end-to-end by maximum likelihood estimation via a principled ExpectationMaximization (EM) algorithm. The bounds of our likelihood function is theoretically analyzed. • In the experiments, we evaluated HTGM on benchmark image datasets for validating its ability to take advantage of large backbone networks, its effectiveness in modeling the mixture distribution of tasks, and its usefulness in identifying novel tasks. The results demonstrate HTGM outperforms the state-of-the-art (SOTA) baselines with significant improvements in most cases.
|
| 20 |
+
|
| 21 |
+
# 2 RELATED WORK
|
| 22 |
+
|
| 23 |
+
To the best of our knowledge, this is the first work to explicitly model the generative process of task instances from a mixture of distributions for meta-learning with novel task detection. Meta-learning aims to handle the few-shot learning problem, which derives memory-based (Mishra et al., 2018), optimization-based (Finn et al., 2017; Li et al., 2017), and metric-based methods (Vinyals et al., 2016; Snell et al., 2017), which often consider an artificial scenario where training/test tasks are sampled from the same distribution. To enable more varying tasks, task-adaptive methods facilitates the customization of meta-knowledge by learning task-specific parameters (Rusu et al., 2018; Lee & Choi, 2018), temperature scaling parameters (Oreshkin et al., 2018), and task-specific modulation on model initialization (Vuorio et al., 2018; Yao et al., 2019a;b; Lee et al., 2019a). Among them, there are methods tackling the mixture distribution of tasks by clustering tasks (Yao et al., 2019a) or learning task graphs (Yao et al., 2019b), and method relocating the initial parameters for different tasks so that they use the meta-knowledge differently (Lee et al., 2019a). As discussed before, none of these methods jointly handle the mixture of task distributions and the detection of novel tasks.
|
| 24 |
+
|
| 25 |
+
Our model is built upon metric-based methods, and learns task embeddings for modeling task distributions. Achille et al. (2019) also proposed to learn embeddings for tasks and introduced a metalearning method, but not for few-shot learning. Its embeddings are from a pre-specified set of tasks (rather than episode-wise sampling), and the meta-learning framework is for model selection. The model in (Yao et al., 2019a) has an augmented encoder for task embedding, but it does not explicitly model task generation, and is not designed for novel task detection (empirical comparison in 4.1).
|
| 26 |
+
|
| 27 |
+
Conventional novelty detection aims to identify and reject samples from unseen classes (Cheng & Vasconcelos, 2021). It relates to open-set recognition (Vaze et al., 2022), which aims to simultaneously identify unknown samples and classify samples from known classes. Out-of-distribution (OOD) detection (Liang et al., 2018; Liu et al., 2020) can be seen as a special case of novelty detection where novel samples are from other problem domains or datasets, thus are considered to be easier to detect than novelties (Cheng & Vasconcelos, 2021). These methods are for large-scale training. In contrast, we want to detect novel tasks, which is a new problem in the small data regime.
|
| 28 |
+
|
| 29 |
+
Hierarchical Gaussian Mixture (HGM) model has appeared in some traditional works (Goldberger & Roweis, 2005; Olech & Paradowski, 2016; Athey et al., 2019) for hierarchical clustering by applying GM agglomeratively or divisively, which do not pre-train models for meta-learning, and is remarkably different from the topic in this paper. The differences are elaborated in Appendix B.1. Moreover, we discuss the relevant multi-task learning methods with task grouping in Appendix B.2.
|
| 30 |
+
|
| 31 |
+
# 3 HIERARCHICAL GAUSSIAN MIXTURE BASED TASK GENERATIVE MODEL
|
| 32 |
+
|
| 33 |
+
Meta-learning methods typically use an episodic learning strategy, where the meta-training set ${ \mathcal { D } } ^ { \mathrm { t r } }$ consists of a batch of episodes. Each episode samples a task $\tau$ from a distribution $p ( \tau )$ . Task $\tau$ has a support set $\mathcal { D } _ { \tau } ^ { \mathfrak { s } } = \{ ( \mathbf { x } _ { i } ^ { \mathfrak { s } } , y _ { i } ^ { \mathfrak { s } } ) \} _ { i = 1 } ^ { n _ { \mathfrak { s } } }$ for training, and a query set $\mathcal { D } _ { \tau } ^ { \mathfrak { q } } = \{ ( \mathbf { x } _ { i } ^ { \mathfrak { q } } , y _ { i } ^ { \mathfrak { q } } ) \} _ { i = 1 } ^ { n _ { \mathfrak { q } } }$ for testing, where $n _ { \mathsf { s } }$ is a small number to denote a few training samples. In particular, in a commonly used $N$ -way $K$ -shot $Q$ -query task (Vinyals et al., 2016), $\mathcal { D } _ { \tau } ^ { \mathsf { s } }$ and $\mathcal { D } _ { \tau } ^ { \mathfrak { q } }$ contain $N$ classes, with $K$ and $Q$ samples per class respectively, i.e., $n _ { \mathrm { s } } = N K$ and $n _ { \mathfrak { q } } = N Q$ .
|
| 34 |
+
|
| 35 |
+
Let $f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { * } ) \ y _ { i } ^ { * }$ be a base model $^ *$ denotes s or q), and $f _ { \pmb { \theta } } ( \cdot ; \mathcal { D } _ { \tau } ^ { \tt s } )$ be the adapted model on $\mathcal { D } _ { \tau } ^ { \mathsf { s } }$ . The training objective on $\tau$ is to minimize the average test error of the adapted model, i.e., $\mathbb { E } _ { ( \mathbf { x } _ { i } ^ { \mathfrak { q } } , y _ { i } ^ { \mathfrak { q } } ) \in \mathcal { D } _ { \tau } ^ { \mathfrak { q } } } \ell ( y _ { i } ^ { \mathfrak { q } } , f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { \mathfrak { q } } ; \mathcal { D } _ { \tau } ^ { \mathfrak { s } } ) )$ , where $\ell ( \cdot , \cdot )$ is a loss function (e.g., cross-entropy loss), and the metatraining process aims to find the parameter $\pmb \theta$ that minimizes this error over all episodes in ${ \mathcal { D } } ^ { \mathrm { t r } }$ . Then, $f _ { \theta }$ is evaluated on every episode of a meta-test set $\mathcal { D } ^ { \mathrm { t e } }$ that samples a task from the same distribution $p ( \tau )$ . Usually, $p ( \tau )$ is a simple distribution (Finn et al., 2017; Lee et al., 2019a). In this work, $p ( \tau )$ is generalized to a mixture distribution consisting of multiple components $p _ { 1 } ( \tau )$ , ..., $p _ { r } ( \tau )$ , and a test episode may sample a task either in or out of any component of $p ( \tau )$ . As such, given the training tasks in ${ \mathcal { D } } ^ { \mathrm { t r } }$ , our goal is to estimate the underlying density of $p ( \tau )$ , so that once a test task is given, we can (1) identify if it is a novel task, and (2) adapt $f _ { \theta }$ to it with optimal accuracy.
|
| 36 |
+
|
| 37 |
+
Specifically, the base model $f _ { \theta }$ can be written as a combination of an encoder $g _ { \pmb { \theta } _ { e } }$ and a predictor $h _ { \pmb { \theta } _ { p } }$ , i.e., $f _ { \pmb \theta } ( \mathbf { x } _ { i } ^ { * } ) = h _ { \pmb \theta _ { p } } ( g _ { \pmb \theta _ { e } } ( \mathbf { x } _ { i } ^ { * } ) )$ (Tian et al., 2020). In this work, we focus on a metric-based nonparametric learner, i.e., $\theta _ { p } = \mathcal { D }$ (e.g., prototypical networks (Snell et al., 2017)), not only because metric-based classifiers were confirmed as more effective than probabilistic classifiers for novelty detection (Jeong et al., 2021), but also for its better training efficiency that fits large-scale backbone networks than the costly nested-loop training of optimization-based methods (Tian et al., 2020).
|
| 38 |
+
|
| 39 |
+
Formally, our goal is to find the model parameter $\pmb { \theta }$ that maximizes the likelihood of observing a task $\tau$ . In other words, let $f _ { \pmb \theta } ( \mathbf { x } _ { i } ^ { * } ) = \mathbf { e } _ { i } ^ { * } \bar { \in } \mathbb { R } ^ { d }$ be the sample embedding, we want to maximize the likelihood of the joint distribution $p _ { \pmb { \theta } } ( \mathbf { e } _ { i } ^ { * } , y _ { i } ^ { * } )$ on the observed data in $\mathcal { D } _ { \tau } = \{ \mathcal { D } _ { \tau } ^ { \mathsf { s } } , \mathcal { D } _ { \tau } ^ { \mathsf { q } } \}$ . We consider each task $\tau$ as an instance, with a representation $\mathbf { v } _ { \tau } \in \mathbb { R } ^ { d }$ in the embedding space (the method to infer $\mathbf { v } _ { \tau }$ is described in Sec. 3.2). To model the unobserved mixture component, we associate every task with a latent variable $z _ { \tau }$ to indicate to which component it belongs. Suppose there are $r$ possible components, and let $n = n _ { \mathsf { s } } + n _ { \mathsf { q } }$ be the total number of samples in $\mathcal { D } _ { \tau }$ , the log-likelihood to maximize can be written by hierarchically factorizing it on $y _ { i } ^ { * }$ and marginalizing out $\mathbf { v } _ { \tau }$ and $z _ { \tau }$ .
|
| 40 |
+
|
| 41 |
+
$$
|
| 42 |
+
\begin{array} { l } { \displaystyle \ell ( \mathcal { D } _ { \tau } ; \pmb { \theta } ) = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log \left[ p _ { \pmb { \theta } } ( \mathbf { e } _ { i } ^ { * } , y _ { i } ^ { * } ) \right] = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log \left[ p _ { \pmb { \theta } } ( \mathbf { e } _ { i } ^ { * } | y _ { i } ^ { * } ) p ( y _ { i } ^ { * } ) \right] } \\ { \displaystyle ~ = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log \left[ p _ { \pmb { \theta } } ( \mathbf { e } _ { i } ^ { * } | y _ { i } ^ { * } ) [ \int _ { \mathbf { v } _ { \tau } } p ( y _ { i } ^ { * } | \mathbf { v } _ { \tau } ) p ( \mathbf { v } _ { \tau } ) d \mathbf { v } _ { \tau } ] \right] } \\ { \displaystyle ~ = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log \left[ p _ { \pmb { \theta } } ( \mathbf { e } _ { i } ^ { * } | y _ { i } ^ { * } ) \left[ \int _ { \mathbf { v } _ { \tau } } p ( y _ { i } ^ { * } | \mathbf { v } _ { \tau } ) \big [ \sum _ { z = 1 } ^ { r } p ( \mathbf { v } _ { \tau } | z _ { \tau } ) p ( z _ { \tau } ) \big ] d \mathbf { v } _ { \tau } \right] \right] } \end{array}
|
| 43 |
+
$$
|
| 44 |
+
|
| 45 |
+
where $p _ { \pmb { \theta } } ( \mathbf { e } _ { i } ^ { \ast } | y _ { i } ^ { \ast } )$ specifies the probability of sampling $\mathbf { e } _ { i } ^ { * }$ from the $y _ { i } ^ { * }$ -th class, $p ( y _ { i } ^ { * } | \mathbf { v } _ { \tau } )$ is the probability of sampling the $y _ { i } ^ { * }$ -th class for task $\tau$ , and $p ( \mathbf { v } _ { \tau } | z _ { \tau } )$ indicates the probability of generating a task $\tau$ from the $z _ { \tau }$ -th mixture component. $p ( z _ { \tau } )$ is a prior on the $z _ { \tau }$ -th component. Hence, Eq. (1) implies a generative process of task $\tau$ : $z _ { \tau } { \mathbf v } _ { \tau } y _ { i } ^ { * } { \mathbf e } _ { i } ^ { * }$ . Next, we define each of the aforementioned distributions and propose our HTGM method.
|
| 46 |
+
|
| 47 |
+
# 3.1 MODEL SPECIFICATION AND PARAMETERIZATION
|
| 48 |
+
|
| 49 |
+
In Eq. (1), the class-conditional distribution $p _ { \pmb { \theta } } ( \mathbf { e } _ { i } ^ { \ast } | y _ { i } ^ { \ast } )$ , the task-conditional distribution $p ( y _ { i } ^ { * } | \mathbf { v } _ { \tau } )$ , and the mixture distribution of tasks defined by $\{ p ( \mathbf { v } _ { \tau } | \boldsymbol { z } _ { \tau } ) , p ( \boldsymbol { z } _ { \tau } ) \}$ are not specified. To make Eq. (1) optimizable, we introduce our HTGM that models the generative process of tasks. Because $\mathcal { D } _ { \tau } ^ { \mathsf { s } }$ and $\mathcal { D } _ { \tau } ^ { \mathfrak { q } }$ follow the same distribution, in the following, we ignore the superscript $^ *$ for simplicity.
|
| 50 |
+
|
| 51 |
+
Class-Conditional Distribution.bution to model the embeddings $\mathbf { e } _ { i }$ irst, similar to (Lee et’s in every class. Let $\pmb { \mu } _ { y _ { i } } ^ { \mathsf { c } }$ 201and $\Sigma _ { y _ { i } } ^ { \mathsf { c } }$ 19b), we use Gaussian distri-be the mean and variance of the distribution of the $y _ { i }$ -th class, then $p _ { \pmb { \theta } } ( \mathbf { e } _ { i } | y _ { i } ) = \mathcal { N } ( \mathbf { e } _ { i } | \pmb { \mu } _ { y _ { i } } ^ { \mathrm { c } } , \pmb { \Sigma } _ { y _ { i } } ^ { \mathrm { c } } )$ yi. In fact, the samples in all of the classes of task comprise a Gaussian mixture distribution, where $p ( y _ { i } )$ is the mixture probability of the $y _ { i }$ -th class. In Eq. (1), $p ( y _ { i } )$ is factorized to be task-specific, i.e., $p ( y _ { i } | \mathbf { v } _ { \tau } )$ , which resorts to another mixture distribution $p ( \mathbf { v } _ { \tau } )$ of tasks, and establishes a structure of hierarchical mixture.
|
| 52 |
+
|
| 53 |
+
Task-Conditional Distribution. A straightforward definition of $p ( y _ { i } | \mathbf { v } _ { \tau } )$ is the density at $\mu _ { y _ { i } } ^ { \mathsf { c } }$ in a Gaussian distribution with $\mathbf { v } _ { \tau }$ as the mean, where $\mu _ { y _ { i } } ^ { \mathsf { c } }$ is the mean (or prototype) of the $y _ { i }$ -th class. However, doing so exposes two problems: (1) the density function of Gaussian distribution is logconcave with one global maximum. Given the mean and variance, maximizing its log-likelihood tends to collapse the prototypes $\mu _ { y _ { i } } ^ { \mathsf { c } }$ ’s of all classes in $\tau$ , making them indistinguishable and impairing classification; (2) given $\mathbf { v } _ { \tau }$ , this method tends to sample classes with small $D _ { \mathbf { v } _ { \tau } } ( \mu _ { y _ { i } } ^ { \mathsf { c } } )$ , where $D _ { \mathbf { v } _ { \tau } } ( \cdot )$ measures the Mahalanobis distance between a data point and the Gaussian distribution centered at $\mathbf { v } _ { \tau }$ . However, in most of the existing works, classes are often uniformly sampled from a domain without any prior on distances (Finn et al., 2017). Fitting the distance function with such “uniform” classes naively leads to an ill-posed learning problem with degenerated solutions. In light of these issues, we seek to define $p ( y _ { i } | \mathbf { \bar { v } } _ { \tau } )$ as a (parameterized) density function with at least $N$ global optimums so that it can distinguish the $N$ different class prototypes of $N$ -way tasks. The $N$ equal (global) optimums also allow it to fit $N$ classes uniformly sampled from a domain. To this end, let $\pmb { \mu } _ { k } ^ { \mathsf { c } }$ be the surrogate embedding of the $k$ -th class, we propose a Gibbs distribution $\pi ( \mu _ { k } ^ { \mathrm { c } } | \mathbf { v } _ { \tau } , \omega )$ defined by $\mathbf { v } _ { \tau }$ and trainable parameters $\omega$ with an energy function. Then we write $p ( y _ { i } = \dot { k } | \mathbf { v } _ { \tau } )$ as
|
| 54 |
+
|
| 55 |
+
$$
|
| 56 |
+
p _ { \omega } ( y _ { i } = k | \mathbf { v } _ { \tau } ) = \pi ( \mu _ { k } ^ { \mathrm { c } } | \mathbf { v } _ { \tau } , \omega ) = \frac { \exp \left[ - E _ { \omega } ( \mu _ { k } ^ { \mathrm { c } } ; \mathbf { v } _ { \tau } ) \right] } { \int _ { \mu _ { k } ^ { \mathrm { c } } } \exp \left[ - E _ { \omega } ( \mu _ { k } ^ { \mathrm { c } } ; \mathbf { v } _ { \tau } ) \right] }
|
| 57 |
+
$$
|
| 58 |
+
|
| 59 |
+
where $E _ { \omega } ( \pmb { \mu } _ { k } ^ { \mathsf { c } } ; \mathbf { v } _ { \tau } ) = \operatorname* { m i n } \left( \{ | | \pmb { \mu } _ { k } ^ { \mathsf { c } } - \mathbf { W } _ { j } \mathbf { v } _ { \tau } | | _ { 2 } ^ { 2 } \} _ { j = 1 } ^ { N } \right)$ is our energy function, and the denominator in Eq (2) is a normalizing constant (with respect to $\mu _ { k } ^ { \mathrm { c } } )$ , a.k.a. the partition function in an energybased model (EBM) (LeCun et al., 2006). $\boldsymbol { \omega } = \{ \mathbf { \tilde { W } } _ { 1 } , . . . , \mathbf { W } _ { N } \}$ are trainable parameters, with $\mathbf { W } _ { i } \in \mathbb { R } ^ { d \times d }$ . Given $\omega$ and $\mathbf { v } _ { \tau }$ , Eq. (2) has $N$ global maximums at $\pmb { \mu } _ { k } ^ { \mathrm { c } } = \mathbf { W } _ { 1 } \mathbf { v } _ { \tau } , . . . , \pmb { \mu } _ { k } ^ { \mathrm { c } } = \mathbf { W } _ { N } \mathbf { v } _ { \tau }$ . More interpretations of the proposed task-conditional distribution can be found in Appendix B.3.
|
| 60 |
+
|
| 61 |
+
Mixture Distribution of Tasks. In Eq. (1), the task distribution $p ( \mathbf { v } _ { \tau } )$ is factorized as a mixture of $p ( \mathbf { v } _ { \tau } | z _ { \tau } = 1 )$ , ..., $p ( \mathbf { v } _ { \tau } | z _ { \tau } = r )$ , weighted by their respective mixture probability $p ( z _ { \tau } )$ . Thus we specify $p ( \mathbf { v } _ { \tau } )$ as a Gaussian mixture distribution, and introduce $\mu _ { z _ { \tau } } ^ { \mathrm { t } }$ and $\Sigma _ { z _ { \tau } } ^ { \mathrm { t } }$ as the mean and variance for each component, i.e., $p ( \mathbf { v } _ { \tau } | z _ { \tau } ) = \mathcal { N } ( \mathbf { v } _ { \tau } | \pmb { \mu } _ { z _ { \tau } } ^ { \mathrm { t } } , \pmb { \Sigma } _ { z _ { \tau } } ^ { \mathrm { t } } )$ . Then the generation of $\mathbf { v } _ { \tau }$ involves two steps: (1) draw a latent variable $z _ { \tau }$ from a categorical distribution on $[ p ( z _ { \tau } = 1 ) , . . . , p ( z _ { \tau } = r ) ]$ , which can be Uniform $( r )$ , and (2) draw $\mathbf { v } _ { \tau }$ from $\bar { \mathcal { N } } ( \mu _ { z _ { \tau } } ^ { \mathrm { t } } , \Sigma _ { z _ { \tau } } ^ { \mathrm { t } } )$ (Bishop, 2006).
|
| 62 |
+
|
| 63 |
+
As such, our HTGM generative process of an $N$ -way $K$ -shot $Q$ -query task $\tau$ can be summarized as
|
| 64 |
+
|
| 65 |
+
1. Draw a latent task variable $z _ { T } \sim$ Categorical $( [ p ( z _ { \tau } = 1 ) , . . . , p ( z _ { \tau } = r ) ] )$ 0
|
| 66 |
+
2. Draw a task embedding $\mathbf { v } _ { \tau } \sim \mathcal { N } ( \pmb { \mu } _ { z _ { \tau } } ^ { \mathrm { t } } , \pmb { \Sigma } _ { z _ { \tau } } ^ { \mathrm { t } } )$ )
|
| 67 |
+
|
| 68 |
+
3. For $k = 1 , . . . , N$ :
|
| 69 |
+
|
| 70 |
+
(a) Draw a class prototype $\pmb { \mu } _ { k } ^ { \mathrm { c } } \sim \pi ( \pmb { \mu } _ { k } ^ { \mathrm { c } } | \mathbf { v } _ { \tau } , \omega )$ from the proposed Gibbs distribution in Eq. (2)
|
| 71 |
+
(b) For $i = 1 , . . . , K + Q$ : i. Set $y _ { i } = k$ , draw a sample embedding $\mathbf { e } _ { i } \sim \mathcal { N } ( \mathbf { e } _ { i } | \boldsymbol { \mu } _ { y _ { i } } ^ { \mathrm { c } } , \boldsymbol { \Sigma } _ { y _ { i } } ^ { \mathrm { c } } )$ ii. Allocate $( \mathbf { e } _ { i } , y _ { i } )$ to the support set $\mathcal { D } _ { \tau } ^ { \mathsf { s } }$ if $i \leq K$ ; else allocate $( \mathbf { e } _ { i } , y _ { i } )$ to the query set $\mathcal { D } _ { \tau } ^ { \sf q }$
|
| 72 |
+
|
| 73 |
+
To reduce complexity, we investigate the feasibility of using isotropic Gaussian with tied variance, i.e., $\pmb { \Sigma } _ { 1 } ^ { \mathrm { c } } = \ldots \bar { = } \pmb { \Sigma } _ { N } ^ { \mathrm { c } } = \sigma ^ { 2 } \mathbf { I }$ , for class distributions, which turned out to be efficient in our experiments. Here, I is the identity matrix, $\sigma$ is a hyperparameter. Tied variance is also a commonly used trick in Gaussian discriminate analysis (GDA) for generative classifiers (Lee et al., 2018). For task distributions, the variances $\Sigma _ { 1 } ^ { \mathrm { t } } , . . . , \dot { \Sigma } _ { r } ^ { \mathrm { t } }$ can be automatically inferred by our algorithm in Sec. 3.2.
|
| 74 |
+
|
| 75 |
+

|
| 76 |
+
Figure 1: An illustration of HTGM on its (a) the training process, and (b) the testing process. In (a), $\textcircled{1} \textcircled{2} \textcircled { 3 }$ are the three parts of the training loss in Eq. (3). In (b), the training task embeddings contain the embeddings of all training tasks, i.e. the outputs of the task-pooling in (a).
|
| 77 |
+
|
| 78 |
+
Finally, substituting $\mathbf { \nabla } _ { \theta } ( \mathbf { e } _ { i } | y _ { i } ) = \mathcal { N } ( \mathbf { e } _ { i } | \mu _ { y _ { i } } ^ { \circ } , \sigma ^ { 2 } \mathbf { I } ) , p _ { \omega } ( y _ { i } | \mathbf { v } _ { \tau } ) = \pi ( \mu _ { y _ { i } } ^ { \circ } | \mathbf { v } _ { \tau } , \omega ) ( y _ { i } = k ) , p ( \mathbf { v } _ { \tau } | z _ { \tau } ) = \delta ( \mathbf { v } _ { \tau } | y _ { \tau } ) = \delta ( \mathbf { v } _ { \tau } | y _ { \tau } ) .$ $\mathcal { N } ( { \bf v } _ { \tau } | \mu _ { z _ { \tau } } ^ { \mathrm { t } } , \Sigma _ { z _ { \tau } } ^ { \mathrm { t } } )$ and $p ( z _ { \tau } ) = \mathrm { U n i f o r m } ( r )$ in Eq. (1), whose probabilities are specified and parameterized, we get our HTGM induced loss $\ell _ { \mathrm { H T G M } } ( \mathcal { D } _ { \tau } ; \pmb \theta , \omega )$ . The class means $\mu _ { y _ { i } } ^ { \mathrm { c } }$ , task means $\mu _ { z _ { \tau } } ^ { \mathrm { t } }$ and variances $\Sigma _ { z _ { \tau } } ^ { \mathrm { t } }$ are inferred in the E-step of our EM algorithm (details are in Sec. 3.2 and A.4).
|
| 79 |
+
|
| 80 |
+
# 3.2 MODEL OPTIMIZATION
|
| 81 |
+
|
| 82 |
+
It is hard to directly optimize $\ell _ { \mathrm { H T G M } } ( \mathcal { D } _ { \tau } ; \pmb \theta , \omega )$ , because the exact posterior inference is intractable (due to the integration over $\mathbf { v } _ { \tau }$ ). To solve it, we resort to variational methods, and introduce an approximated posterior $q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathsf { s } } )$ , which is defined by an inference network $\phi$ , and implies we want to infer $\mathbf { v } _ { \tau }$ from its observed support set $\mathcal { D } _ { \tau } ^ { \mathsf { s } }$ . The query set $\mathcal { D } _ { \tau } ^ { \mathfrak { q } }$ is not included because it is unavailable during model testing. Then we propose to maximize a lower-bound of Eq. (1), which is derived as (the details are in Appendix A.1)
|
| 83 |
+
|
| 84 |
+
$$
|
| 85 |
+
\begin{array} { l } { \displaystyle \ell _ { \mathrm { H T G M } } ( \mathcal { D } _ { \tau } ; \theta , \omega ) \geq \ell _ { \mathrm { H T G M - E L B O } } ( \mathcal { D } _ { \tau } ; \theta , \omega ) = \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log p _ { \theta , \omega } ( \mathbf { e } _ { i } | y _ { i } ) } \\ { \displaystyle + \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \mathbb { E } _ { \mathbf { v } _ { \tau } \sim q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathbb { S } } ) } \Big [ \log p _ { \omega } ( y _ { i } | \mathbf { v } _ { \tau } ) + \log \big ( \sum _ { z _ { \tau } = 1 } ^ { r } p ( \mathbf { v } _ { \tau } | z _ { \tau } ) p ( z _ { \tau } ) \big ) \Big ] + H \big ( q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathbb { S } } ) \big ) } \end{array}
|
| 86 |
+
$$
|
| 87 |
+
|
| 88 |
+
where $\begin{array} { r } { H ( q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathsf { s } } ) ) = - \int _ { \mathbf { v } _ { \tau } } q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathsf { s } } ) \log q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathsf { s } } ) d \mathbf { v } _ { \tau } } \end{array}$ is the entropy function. Similar to VAE (Kingma & Welling, 2013), Eq. (3) estimates the expectation (in the second term) by sampling ${ \bf v } _ { \tau }$ from $q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathsf { s } } )$ , instead of the integration in Eq. (1), hence facilitates computation. Next, we elaborate on the inference network, the challenges of maximizing Eq. (3), and our workarounds.
|
| 89 |
+
|
| 90 |
+
Inference Network. Similar to VAE, $q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathfrak { s } } )$ is defined as a Gaussian distribution $\mathcal { N } ( \mu _ { z _ { \tau } } ^ { \mathrm { a } } , \bar { \sigma } ^ { \mathrm { 2 } } \mathbf { I } )$ , where $\mu _ { z _ { \tau } } ^ { \mathsf { a } }$ is the output of the inference network, which approximates $\mu _ { z _ { \tau } } ^ { \mathrm { t } }$ in Step 2 of the generative process, and $\bar { \sigma }$ is a hyperparameter for the corresponding variance. As illustrated by Fig. 1(a), the inference network is built upon the base model $f _ { \pmb { \theta } } ( \cdot )$ with two non-parametric aggregation (i.e., mean pooling) functions, thus $\phi = \pmb \theta$ . The first function aggregates class-wise embeddings to prototypes $\mu _ { y _ { i } } ^ { \mathsf { c } }$ ’s, similar to prototypical networks (Snell et al., 2017). Differently, the second aggregates all prototypes to $\mu _ { z _ { \tau } } ^ { \mathsf { a } }$ . During model training, we use the reparameterization trick (Kingma & Welling, 2013) to sample $\mathbf { v } _ { \tau }$ from $\mathcal { N } ( \mu _ { z _ { \tau } } ^ { \mathrm { a } } , \bar { \sigma } ^ { \mathrm { 2 } } \mathbf { I } )$ . It is noteworthy that $H ( q _ { \phi } ( \mathbf { v } _ { \tau } \vert \mathcal { D } _ { \tau } ^ { \mathsf { s } } ) )$ in Eq. (3) becomes a constant now because $\bar { \sigma } ^ { 2 }$ is a constant.
|
| 91 |
+
|
| 92 |
+
Challenge 1: Trivial Solution. In Eq. (3), since the first term (constants are ignored) only penalizes the distance between a(i.e., intra-class distances) without considering inter-class re $\begin{array} { r } { \log p _ { \theta , \omega } ( \mathbf { e } _ { i } | y _ { i } ) = - \frac { 1 } { 2 \sigma ^ { 2 d } } \| \mathbf { e } _ { i } - \boldsymbol { \mu } _ { y _ { i } } ^ { \mathrm { c } } \| _ { 2 } ^ { 2 } } \end{array}$ $\mathbf { e } _ { i }$ $\mu _ { y _ { i } } ^ { \mathsf { c } }$ $\pmb { \mu } _ { 1 } ^ { \mathsf { c } }$
|
| 93 |
+
..., $\mu _ { N } ^ { \tt c }$ in task $\tau$ could collide, drawing all sample embeddings to the same spot. To avoid such
|
| 94 |
+
a trivial solution and improve the stability of optimization, we apply negative sampling (Mikolov
|
| 95 |
+
et al., 2013)
|
| 96 |
+
|
| 97 |
+
$$
|
| 98 |
+
\ell _ { \mathrm { n e g } } ( \mathcal { D } _ { \tau } ; y _ { i } , \pmb { \theta } , \omega ) = - \log \mathbb { E } _ { \mathbf { e } _ { j } \sim \mathcal { D } _ { \tau } } \big [ \exp { ( - \frac { 1 } { 2 \sigma ^ { 2 d } } \| \mathbf { e } _ { j } - \pmb { \mu } _ { y _ { i } } ^ { \mathrm { c } } \| _ { 2 } ^ { 2 } ) } \big ]
|
| 99 |
+
$$
|
| 100 |
+
|
| 101 |
+
where $\mathbf { e } _ { j }$ is a negative sample embedding from any class in the support set, and $\mu _ { y _ { i } } ^ { \mathrm { c } }$ is the mean of the positive class. In practice, we found it is beneficial to integrate $\ell _ { \mathrm { n { e g } } }$ with our likelihood $\ell _ { \mathrm { H T G M } }$ in Eq. (1) during training, i.e. $\begin{array} { r } { \ell _ { \mathrm { H T G M } } + \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \ell _ { \mathrm { n e g } } } \end{array}$ . Correspondingly, from Eq. (3) we have
|
| 102 |
+
|
| 103 |
+
$$
|
| 104 |
+
\ell ( \mathcal { D } _ { \tau } ; \pmb { \theta } , \omega ) = \ell _ { \mathrm { H T G M - E L B O } } ( \mathcal { D } _ { \tau } ; \pmb { \theta } , \omega ) + \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \ell _ { \mathrm { n e g } } ( \mathcal { D } _ { \tau } ; y _ { i } , \pmb { \theta } , \omega )
|
| 105 |
+
$$
|
| 106 |
+
|
| 107 |
+
which does not only serve as a robust training loss, but also helps solve the next challenge.
|
| 108 |
+
|
| 109 |
+
Challenge 2: The Partition Function in Eq. (2). The second term $p _ { \omega } ( y _ { i } | \mathbf { v } _ { \tau } )$ in Eq. (3) involves computing the partition function in Eq. (2) (i.e., the denominator), which is intractable because of the integration over all possible $\pmb { \mu } _ { k } ^ { \mathsf { c } }$ ’s. To solve it, we propose an upper bound of the partition function $\begin{array} { r } { \int _ { \pmb { \mu } _ { k } } \exp \big [ - E _ { \omega } ( \pmb { \mu } _ { k } ^ { \mathrm { c } } ; \mathbf { v } _ { \tau } ) \big ] d \pmb { \mu } _ { k } ^ { \mathrm { c } } \leq N \sqrt { 2 ^ { d - 1 } \pi ^ { d } } } \end{array}$ (the derivation is in Appendix A.2), which is a constant with a specific $N$ . By replacing the partition function in Eq. (2) with $N { \sqrt { 2 ^ { d - 1 } \pi ^ { d } } }$ , we got a lower bound of $p _ { \omega } ( y _ { i } | \mathbf { v } _ { \tau } )$ , which in turn relaxes the lower bound in Eq. (3). The following theorem (the proof is in Appendix A.3) states the tightness of the relaxed bound is controllable.
|
| 110 |
+
|
| 111 |
+
Theorem 1. Among the $N$ global maximums $\mathbf { W } _ { 1 } \mathbf { v } _ { \tau }$ , ..., ${ \bf W } _ { T } { \bf v } _ { \tau }$ of Eq. (2), let $\mathbf { W } _ { h } \mathbf { v } _ { \tau }$ and $\mathbf { W } _ { l } \mathbf { v } _ { \tau }$ $( 1 \leq h , l \leq N )$ be the pair with the smallest Euclidean distance $D ( \mathbf { W } _ { h } \mathbf { v } _ { \tau } , \mathbf { W } _ { l } \mathbf { v } _ { \tau } )$ , we have
|
| 112 |
+
|
| 113 |
+
$$
|
| 114 |
+
\operatorname * { l i m } _ { \substack { D ( \mathbf { W } _ { h } \mathbf { v } _ { \tau } , \mathbf { W } _ { l } \mathbf { v } _ { \tau } ) \infty } } \int _ { \mu _ { k } } \exp \Big [ - E _ { \omega } \big ( \pmb { \mu } _ { k } ^ { c } ; \mathbf { v } _ { \tau } \big ) \Big ] d \pmb { \mu } _ { k } ^ { c } = N \sqrt { 2 ^ { d - 1 } \pi ^ { d } }
|
| 115 |
+
$$
|
| 116 |
+
|
| 117 |
+
This theorem indicates the partition function approximates $N { \sqrt { 2 ^ { d - 1 } \pi ^ { d } } }$ when all pairs of the global maximums are far apart. It is noteworthy that during training (i.e., maximizing the likelihood) we fit ${ \bf W } _ { 1 } { \bf v } _ { \tau } , . . . , { \bf W } _ { N } \bar { \bf v _ { \tau } }$ to the different class prototypes $\pmb { \mu } _ { 1 } ^ { \mathsf { c } } , . . . , \pmb { \mu } _ { N } ^ { \mathsf { c } }$ in $N$ -way tasks. Because $\ell _ { \mathrm { n e g } }$ in Eq. (4) tends to maximize the distances between different prototypes through the negative samples, maximizing the joint loss $\ell$ in Eq. (5) tends to separate $\mathbf { W } _ { 1 } \mathbf { v } _ { \tau } , . . . , \mathbf { W } _ { N } \mathbf { v } _ { \tau }$ , thus tighten the relaxed bound after using $N { \sqrt { 2 ^ { d - 1 } \pi ^ { d } } }$ according to Theorem 1. This is another benefit of negative sampling.
|
| 118 |
+
|
| 119 |
+
Optimization via Expectation-Maximization. In the third term of $\ell _ { \mathrm { H T G M } }$ -ELBO in Eq. (3), we need to estimate the mixture distribution $p ( z _ { \tau } )$ . Similar to optimizing Gaussian mixture models, we alternately infer $p ( z _ { \tau } )$ and solve the model parameters $\{ \theta , \omega \}$ through an Expectation-Maximization algorithm. In E-step, we infer $p ( z _ { \tau } )$ when fixing model parameters. In M-step, when fixing $p ( z _ { \tau } )$ , $\{ \theta , \omega \}$ can be efficiently solved by optimizing Eq. (5) with stochastic gradient descent (SGD). The formula to infer $p ( z _ { \tau } )$ and the detailed training algorithm of HTGM can be found in Appendix A.4.
|
| 120 |
+
|
| 121 |
+
# 3.3 MODEL ADAPTATION
|
| 122 |
+
|
| 123 |
+
Fig. 1(b) illustrates the adaptation process of HTGM. Given a new $N$ -way task $\tau ^ { \prime }$ from the metatest set $\mathcal { D } ^ { \mathrm { t e } }$ , its support set $\mathcal { D } _ { \tau ^ { \prime } } ^ { \mathsf { s } }$ is fed to the inference network to generate (1) class prototypes $\pmb { \mu } _ { 1 } ^ { \mathsf { c } }$ , ..., $\mu _ { N } ^ { \mathrm { c } }$ (similar to prototypical networks), and (2) distribution $q _ { \phi } ( \mathbf { v } _ { \tau ^ { \prime } } | \mathcal { D } _ { \tau ^ { \prime } } ^ { \mathsf { s } } )$ , from which we draw the average task embedding $\mathbf { v } _ { \tau ^ { \prime } } = \mu _ { z _ { \tau ^ { \prime } } } ^ { \mathsf { a } }$ . Recall that the inference network is the base model $f _ { \theta } ( \cdot )$ with class-pooling and task-pooling layers, as illustrated in Fig. 1(b), and $\phi = \theta$ . Then $\mathbf { v } _ { \tau ^ { \prime } }$ is projected to $\mathbf { W } _ { 1 } \mathbf { v } _ { \tau ^ { \prime } } , . . . , \mathbf { W } _ { N } \mathbf { v } _ { \tau ^ { \prime } }$ which represent the $N$ optimal choices of class prototypes for task $\tau ^ { \prime }$ as learned by the Gibbs distribution in Eq. (2) from the training tasks. They are used to adapt $\mu _ { 1 } ^ { \mathsf { c } } , . . . , \mu _ { N } ^ { \mathsf { c } }$ so that the adapted prototypes are drawn towards the closest classes from the mixture component that task $\tau ^ { \prime }$ belongs to. The adaptation is performed by selecting the closest optimum for each prototype, i.e., $\bar { \pmb { \mu } } _ { j } ^ { \mathrm { c } } = \alpha \pmb { \mu } _ { j } ^ { \mathrm { c } } + ( 1 - \alpha ) \mathbf { W } _ { l ^ { \ast } } \mathbf { v } _ { \tau ^ { \prime } }$ where $l ^ { * } = \arg \operatorname* { m i n } _ { 1 \leq l \leq N } D ( \pmb { \mu } _ { j } ^ { \mathrm { c } } , \mathbf { W } _ { l } \mathbf { v } _ { \tau ^ { \prime } } )$ using Euclidean distance $D ( \cdot , \cdot )$ and $\alpha$ is a hyperparameter. Finally, we (1) assess if $\tau ^ { \prime }$ is a novelty by computing the likelihood of $\mathbf { v } _ { \tau ^ { \prime } }$ in a pre-fitted GMM on the embeddings $\mathbf { v } _ { \tau }$ ’s of the training tasks in ${ \mathcal { D } } ^ { \mathrm { t r } }$ , and (2) perform classification on each sample $\mathbf { x } _ { i } ^ { \prime }$ in the query set $\mathcal { D } _ { \tau ^ { \prime } } ^ { \mathfrak { q } }$ using the adapted prototypes by $\begin{array} { r } { p ( y _ { i } ^ { \prime } = j ^ { \prime } | \mathbf { x } _ { i } ^ { \prime } ) = \frac { \exp { ( - D ( f _ { \theta } ( \mathbf { x } _ { i } ^ { \prime } ) , \bar { \mu } _ { j ^ { \prime } } ^ { \mathrm { c } } ) ) } } { \sum _ { j = 1 } ^ { N } \exp { ( - D ( f _ { \theta } ( \mathbf { x } _ { i } ^ { \prime } ) , \bar { \mu } _ { j } ^ { \mathrm { c } } ) ) } } } \end{array}$ .
|
| 124 |
+
|
| 125 |
+
<table><tr><td rowspan=1 colspan=1>Setting</td><td rowspan=1 colspan=6>Model</td><td rowspan=1 colspan=1>Bird</td><td rowspan=1 colspan=6>Texture</td><td rowspan=1 colspan=1>Aircraft</td><td rowspan=1 colspan=2>Fungi</td><td rowspan=1 colspan=1>Average</td></tr><tr><td rowspan=5 colspan=1>5-way</td><td rowspan=3 colspan=6>TAMLMAMLMeta-SGD</td><td rowspan=1 colspan=1>55.77±1.43</td><td rowspan=1 colspan=6>31.78±1.30</td><td rowspan=1 colspan=1>48.56±1.37</td><td rowspan=1 colspan=2>41.00±1.50</td><td rowspan=1 colspan=1>44.28</td></tr><tr><td rowspan=1 colspan=1>53.94±1.45</td><td rowspan=1 colspan=6>31.66±1.31</td><td rowspan=1 colspan=1>51.37±1.38</td><td rowspan=1 colspan=2>42.12±1.36</td><td rowspan=1 colspan=1>44.77</td></tr><tr><td rowspan=1 colspan=6>Meta-SGD</td><td rowspan=1 colspan=1>55.58±1.43</td><td rowspan=1 colspan=4>32.38±1.32</td><td rowspan=1 colspan=2>32</td><td rowspan=1 colspan=1>32</td><td rowspan=1 colspan=1>52.99±1.36</td><td rowspan=1 colspan=1>41.74±1.34</td><td rowspan=1 colspan=1>34</td><td rowspan=1 colspan=1>45.67</td></tr><tr><td rowspan=2 colspan=3>HSML</td><td rowspan=3 colspan=4>MUMOMAMLHSMLARML</td><td rowspan=2 colspan=1>56.82±1.4960.98±1.50</td><td></td><td></td><td rowspan=1 colspan=2>31+1</td><td rowspan=1 colspan=2>1.36</td><td rowspan=1 colspan=1>6</td><td></td><td rowspan=1 colspan=1>53.14±1.39</td><td rowspan=2 colspan=2>42.22±1.4044.02±1.39</td><td rowspan=2 colspan=1>46.5049.35</td></tr><tr><td rowspan=1 colspan=4>35.01±1.36</td><td rowspan=1 colspan=2>36</td><td rowspan=1 colspan=1>57.38±1.40</td></tr><tr><td rowspan=1 colspan=1>1-shot</td><td rowspan=1 colspan=2>ARML</td><td rowspan=1 colspan=1>62.33±1.47</td><td rowspan=1 colspan=3>35.65±1.40</td><td rowspan=1 colspan=2>35.65±1.40</td><td rowspan=1 colspan=1>0</td><td></td><td rowspan=1 colspan=1>58.56±1.41</td><td rowspan=1 colspan=2>44.82±1.38</td><td rowspan=1 colspan=1>50.34</td></tr><tr><td rowspan=5 colspan=1></td><td rowspan=5 colspan=6>ProtoNetMetaOptNetProtoNet-AugNCAFEATS</td><td rowspan=1 colspan=1>Net</td><td rowspan=5 colspan=6>61.54±1.2762.80±1.2965.04±1.2962.58±1.2562.60±1.31</td><td rowspan=1 colspan=1>38.84±1.42</td><td rowspan=2 colspan=2>38.84±1.4244.30±1.45</td><td rowspan=1 colspan=1>42</td></tr><tr><td></td><td rowspan=1 colspan=1>68.64±1.29</td><td rowspan=1 colspan=2>47.04±1.38</td><td rowspan=1 colspan=1>55.70</td></tr><tr><td></td><td rowspan=3 colspan=6>44.68±1.4340.98±1.4444.12±1.49</td><td rowspan=1 colspan=1>70.44±1.32</td><td rowspan=1 colspan=2>49.30±1.40</td><td rowspan=1 colspan=1>57.37</td></tr><tr><td></td><td rowspan=1 colspan=1>68.70±1.26</td><td rowspan=2 colspan=2>46.36±1.3447.92±1.34</td><td rowspan=1 colspan=1>54.66</td></tr><tr><td></td><td rowspan=1 colspan=1>68.86±1.28</td><td rowspan=1 colspan=1>55.88</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=6>HTGM (ours)</td><td rowspan=1 colspan=1>70.12±1.28</td><td rowspan=1 colspan=6>47.76±1.49</td><td rowspan=1 colspan=1>75.52±1.24</td><td rowspan=1 colspan=2>52.06±1.41</td><td rowspan=1 colspan=1>61.37</td></tr><tr><td rowspan=6 colspan=1>5-way5-shot</td><td rowspan=11 colspan=6>TAMLMAMLMeta-SGDMUMOMAMLHSMLARMLProtoNetMetaOptNetProtoNet-AugNCAFEATS</td><td rowspan=3 colspan=1>69.50±0.7568.52±0.7967.87±0.74</td><td rowspan=1 colspan=6>45.11±0.69</td><td rowspan=1 colspan=1>65.92±0.74</td><td rowspan=1 colspan=2>50.99±0.87</td><td rowspan=1 colspan=1>57.88</td></tr><tr><td rowspan=2 colspan=6>44.56±0.6845.49±0.68</td><td rowspan=1 colspan=1>66.18±0.71</td><td rowspan=1 colspan=2>51.85±0.85</td><td rowspan=1 colspan=1>57.78</td></tr><tr><td rowspan=1 colspan=1>66.84±0.70</td><td rowspan=1 colspan=2>52.51±0.81</td><td rowspan=1 colspan=1>58.18</td></tr><tr><td rowspan=4 colspan=1>70.49±0.7671.68±0.7373.34±0.7078.88±0.72</td><td rowspan=1 colspan=6>45.89±0.69</td><td rowspan=1 colspan=1>67.31±0.68</td><td rowspan=1 colspan=2>53.96±0.82</td><td rowspan=1 colspan=1>59.41</td></tr><tr><td rowspan=3 colspan=6>48.08±0.6949.67±0.6757.93±0.75</td><td rowspan=1 colspan=1>73.49±0.68</td><td rowspan=1 colspan=2>56.32±0.80</td><td rowspan=1 colspan=1>62.39</td></tr><tr><td rowspan=1 colspan=1>74.88±0.64</td><td rowspan=1 colspan=2>57.55±0.82</td><td rowspan=1 colspan=1>63.86</td></tr><tr><td rowspan=5 colspan=1></td><td rowspan=1 colspan=1>86.42±0.57</td><td rowspan=1 colspan=2>62.52±0.79</td><td rowspan=1 colspan=1>71.44</td></tr><tr><td rowspan=3 colspan=1></td><td rowspan=3 colspan=1>81.66±0.7180.62±0.7179.16±0.75</td><td rowspan=1 colspan=6>61.97±0.78</td><td rowspan=1 colspan=1>84.03±0.56</td><td rowspan=1 colspan=2>63.80±0.81</td><td rowspan=1 colspan=1>72.87</td></tr><tr><td rowspan=1 colspan=6>58.30±0.77</td><td rowspan=1 colspan=1>87.05±0.53</td><td rowspan=1 colspan=2>63.62±0.81</td><td rowspan=1 colspan=1>72.39</td></tr><tr><td rowspan=1 colspan=6>58.69±0.76</td><td rowspan=1 colspan=1>85.27±0.53</td><td rowspan=1 colspan=2>61.68±0.80</td><td rowspan=1 colspan=1>71.20</td></tr><tr><td rowspan=1 colspan=1>78.37±0.72</td><td rowspan=1 colspan=6>57.02±0.73</td><td rowspan=1 colspan=1>85.55±0.54</td><td rowspan=1 colspan=2>61.56±0.80</td><td rowspan=1 colspan=1>70.63</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=6>HTGM (ours)</td><td rowspan=1 colspan=1>82.27±0.74</td><td rowspan=1 colspan=6>60.67±0.78</td><td rowspan=1 colspan=1>88.48±0.52</td><td rowspan=1 colspan=2>65.70±0.79</td><td rowspan=1 colspan=1>74.28</td></tr></table>
|
| 126 |
+
|
| 127 |
+
Table 1: Results (accuracy $\pm 9 5 \%$ confidence) of the compared methods on Plain-Multi dataset.
|
| 128 |
+
|
| 129 |
+
# 4 EXPERIMENTS
|
| 130 |
+
|
| 131 |
+
In this section, we evaluate HTGM’s effectiveness on few-shot classification and novel task detection on benchmark datasets, and compare it with SOTA methods.
|
| 132 |
+
|
| 133 |
+
Datasets. The first is the Plain-Multi benchmark proposed in (Yao et al., 2019a). It includes four fine-grained image classification datasets, i.e., CUB-200-2011 (Bird), Describable Textures Dataset (Texture), FGVC of Aircraft (Aircraft), and FGVCx-Fungi (Fungi). In each episode, a task samples classes from one of the four datasets, so that different tasks are from a mixture of the four domains. The second is the Art-Multi benchmark from (Yao et al., 2019b), whose distribution is more complex than Plain-Multi. Similar to (Jerfel et al., 2019), each image in Plain-Multi was applied with two filters, i.e., blur filter and pencil filter, respectively, to simulate a changing distribution of few-shot tasks. Afterward, together with the original four datasets, a total of 12 datasets comprise Art-Multi, and each task is sampled from one of them. Both benchmarks were divided into the meta-training, meta-validation, and meta-test sets by following their corresponding papers.
|
| 134 |
+
|
| 135 |
+
Baselines. We compare HTGM with the most relevant SOTA methods on meta-learning, including (1) optimization-based methods: MAML (Finn et al., 2017) and Meta-SGD (Li et al., 2017) learn globally shared initialization among tasks. MUMOMAML (Vuorio et al., 2018) is a task-specific method. TAML (Lee et al., 2019a) handles imbalanced tasks. HSML (Yao et al., 2019a) and ARML (Yao et al., 2019b) learn locally shared initial parameters in clusters of tasks and neighborhoods of a meta-graph of tasks, respectively; and (2) Metric-based methods: ProtoNet (Snell et al., 2017) learns prototypes with distance-based classifier. MetaOptNet (Lee et al., 2019c) uses an SVM classifier with kernel metrics. ProtoNet-Aug (Su et al., 2020), FEATS (Ye et al., 2020) and NCA (Laenen & Bertinetto, 2021) were built upon ProtoNet by augmenting images (e.g., rotation, jigsaw), adding prototype aggregator (e.g., Transformer), and using contrastive training loss, (instead of prototypebased loss), respectively. The detailed setup of these methods is deferred to Appendix C.1.
|
| 136 |
+
|
| 137 |
+
Implementation. Following (Tian et al., 2020), optimization-based baselines use the standard fourblock convolutional layers as the base learner, and metric-based methods use ResNet-12 as the base learner. The output dimension of these networks is 640 (MetaOptNet uses 16000 as in its paper). In our experiments, we observed the optimization-based methods have out-of-memory issues when using ResNet-12, indicating their limitation in using large backbone networks. To test them on ResNet-12, we followed the ANIL method (Raghu et al., 2020) by pre-training ResNet-12 via ProtoNet, freezing the encoder, and fine-tuning the last fully-connected layer. In this case, HSML and ARML cannot work properly as they require joint training of the encoder and other layers. The details are in Appendix D.5. For training, Adam optimizer was used. Each batch contains 4 tasks. Each model was trained with 20000 episodes. The learning rate of metric-based methods is $1 e ^ { - 3 }$ . The learning rates for inner- and outer-loops for optimization-based methods are $1 e ^ { - 3 }$ and $1 e ^ { - 4 }$ . The weight decay was $1 e ^ { - 4 }$ . For HTGM, we set $\sigma = 1 . 0$ , $\bar { \sigma } = 0 . 1$ , $\alpha = 0 . 5$ (0.9) for 1-shot (5-shot) tasks. The number of mixture components $r$ varies w.r.t. different datasets, and was grid-searched within [2, 4, 8, 16, 32]. All hyperparameters were set according to the meta-validation sets.
|
| 138 |
+
|
| 139 |
+
<table><tr><td rowspan=1 colspan=1>Setting</td><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>Original</td><td rowspan=1 colspan=2>Blur</td><td rowspan=1 colspan=2>Pencil</td><td rowspan=1 colspan=1>Average</td></tr><tr><td rowspan=7 colspan=1>5-way,1-shot</td><td rowspan=7 colspan=1>TAMLMAMLMeta-SGDMUMOMAMLHSMLARMLProtoNetMetaOptNetProtoNet-AugNCAFEATS</td><td rowspan=7 colspan=1>42.22±1.3942.70±1.3544.21±1.3845.63±1.3947.92±1.3445.68±1.3455.23±1.3156.10±1.3557.63±1.3456.12±1.3554.33±1.33</td><td rowspan=6 colspan=2>40.02±1.4140.53±1.3842.36±1.3941.59±1.3844.43±1.3442.62±1.3451.70±1.4252.33±1.4355.00±1.4050.80±1.49</td><td rowspan=1 colspan=2>35.11±1.34</td><td rowspan=1 colspan=1>39.11</td></tr><tr><td rowspan=1 colspan=2>36.71±1.37</td><td rowspan=1 colspan=1>39.98</td></tr><tr><td rowspan=1 colspan=2>37.21±1.3939.24±1.3641.44±1.34</td><td rowspan=1 colspan=1>41.2642.1544.60</td></tr><tr><td rowspan=1 colspan=2>39.78±1.3449.22±1.4449.08±1.45</td><td rowspan=1 colspan=1>42.6952.0552.50</td></tr><tr><td rowspan=1 colspan=2>49.73±1.53</td><td rowspan=1 colspan=1>54.12</td></tr><tr><td rowspan=1 colspan=2>47.99±1.45</td><td rowspan=1 colspan=1>51.64</td></tr><tr><td rowspan=1 colspan=2>50.90±1.48</td><td rowspan=1 colspan=2>47.96±1.48</td><td rowspan=1 colspan=1>51.07</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>HTGM (ours)</td><td rowspan=1 colspan=1>61.18±1.34</td><td rowspan=1 colspan=2>58.80±1.42</td><td rowspan=1 colspan=2>53.23±1.48</td><td rowspan=1 colspan=1>57.74</td></tr><tr><td rowspan=8 colspan=1>5-way,1-shot</td><td rowspan=4 colspan=1>TAMLMAMLMeta-SGDMUMOMAML</td><td rowspan=4 colspan=1>58.54±0.7358.30±0.7457.82±0.7258.60±0.75</td><td rowspan=1 colspan=2>55.23±0.75</td><td rowspan=1 colspan=2>49.23±0.75</td><td rowspan=1 colspan=1>54.33</td></tr><tr><td rowspan=1 colspan=1>55</td><td rowspan=1 colspan=1>55.71±0.74</td><td rowspan=1 colspan=2>49.59±0.73</td><td rowspan=1 colspan=1>54.50</td></tr><tr><td rowspan=1 colspan=2>55.54±0.73</td><td rowspan=1 colspan=2>50.24±0.72</td><td rowspan=1 colspan=1>54.53</td></tr><tr><td rowspan=1 colspan=2>51.15±0.73</td><td rowspan=2 colspan=1>55.3557.4958.5967.6568.37</td></tr><tr><td rowspan=4 colspan=1>HSMLARMLProtoNetMetaOptNetProtoNet-AugNCAFEATS</td><td rowspan=4 colspan=1>60.63±0.7361.78±0.7471.34±0.7372.33±0.7272.87±0.7172.44±0.7271.99±0.71</td><td rowspan=2 colspan=2>57.91±0.7258.73±0.7567.28±0.7568.90±0.7870.50±0.72</td><td rowspan=1 colspan=2>53.93±0.7255.27±0.7364.32±0.7663.89±0.71</td></tr><tr><td rowspan=1 colspan=2>63.98±0.73</td><td rowspan=1 colspan=1>68.78</td></tr><tr><td rowspan=2 colspan=2>67.33±0.7167.54±0.72</td><td rowspan=1 colspan=2>62.98±0.78</td><td rowspan=2 colspan=1>67.5867.54</td></tr><tr><td rowspan=1 colspan=2>63.09±0.76</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>HTGM (ours)</td><td rowspan=1 colspan=1>74.67±0.70</td><td rowspan=1 colspan=2>71.24±0.73</td><td rowspan=1 colspan=2>65.22±0.77</td><td rowspan=1 colspan=1>70.37</td></tr></table>
|
| 140 |
+
|
| 141 |
+
Table 2: Results (accuracy $\pm 9 5 \%$ confidence) of the compared methods on Art-Multi dataset.
|
| 142 |
+
|
| 143 |
+
# 4.1 EXPERIMENTAL RESULTS
|
| 144 |
+
|
| 145 |
+
Few-shot classification. Following (Tian et al., 2020), we report the mean accuracy and $9 5 \%$ confidence interval of 1000 random tasks with 5-way 1-shot/5-shot, 5/25-query tests. Following (Yao et al., 2019b), we report the accuracy of each domain (Bird, Texture, Aircraft and Fungi) and the overall average accuracy for Plain-Multi, and report the accuracy of each image filtering strategy and the overall average accuracy for Art-Multi.
|
| 146 |
+
|
| 147 |
+
Table 1 and 2 summarize the results. From the tables, we have several observations. First, metricbased methods generally outperform optimization-based methods. This is because of the efficiency of metric-based methods, enabling them to fit a larger backbone network, which is consistent with the results in (Tian et al., 2020). Built upon the metric-based method, HTGM only introduces a few distribution-related parameters and thus has the flexibility to scale with the encoder size. Second, baselines designed for dealing with mixture distributions of tasks, i.e., HSML and ARML, outperform their counterparts without such design, demonstrating the importance to consider mixture task distribution in practice. Finally, HTGM outperforms the SOTA baselines in most cases by large margins, suggesting its effectiveness in modeling the generative process of task instances.
|
| 148 |
+
|
| 149 |
+
Novel task detection. We also evaluate HTGM on the task of detecting novel $N$ -way- $K$ -shot tasks $N = 5$ , $K = 1$ ) that are drawn out of the training task distributions. To this end, we train each comapred model in the Original domain in Art-Multi dataset, and test the model on tasks drawn from either Original domain (i.e., known tasks), or {Blur, Pencil} domains (i.e., novel tasks), and evaluate if the model can tell whether a testing task is known or novel.
|
| 150 |
+
|
| 151 |
+

|
| 152 |
+
Figure 2: The frequency of tasks w.r.t. the normalized likelihood for (a) HSML (b) MetaOptNet (c) ProtoNet-Aug (d) HTGM. The $\mathbf { X } ^ { } -$ -axis ranges vary as only $9 5 \%$ tasks with top scores were preserved.
|
| 153 |
+
|
| 154 |
+
For comparison, since none of the baselines detects novel tasks, we adapt them as follows. For metric-based methods, since they use a fixed encoder for all training/testing tasks, we averaged the sample embeddings in each task to represent the task. Then a separate GMM model was built upon the training task embeddings, and its likelihood was adapted to score the novelty of testing tasks (some details of setup are in Appendix C.2. However, optimization-based models perform gradient descent on the support set of each task, leading to varying encoders per task. As such, sample embeddings of different tasks are not comparable, and we cannot obtain task embeddings in the same way as before. Among them, only HSML has an augmented task-level encoder for task embedding, allowing us to include it for comparison. For a fair comparison, our HTGM also trains a GMM on its task embeddings for detecting novel tasks. Moreover, two HTGM variants were included for ablation analysis to understand some design choices: (1) HTGM-Gaussian replaces the Gibbs distribution in Eq. (2) with a Gaussian distribution; (2) HTGM w/o GMM removes the task-level GM, i.e., the third term in Eq. (3). The classification results of the ablation variants are in Appendix D.4. Following (Cheng & Vasconcelos, 2021; Vaze et al., 2022; Sharma et al., 2021), we report Area Under ROC (AUROC), Average Precision (AP), and Max-F1 for performance evaluation.
|
| 155 |
+
|
| 156 |
+
Table 3 summarize the results, from which we observe HTGM outperforms all baselines over all evaluation metrics, indicating the superior quality of task embeddings learned by our model. The embeddings follow the specified mixture distribution of tasks $p ( \mathbf { v } _ { \tau } )$ as described in Sec. 3.1, which fits the mixture data well hence allowing to detect novel tasks that are close to the boundary. Since the baselines learn embeddings without explicit constraint, they even don’t fit the post-hoc GMM very well. Moreover, HTGM outperforms HTGM w/o GMM, which is even worse than some other baselines. This further validates the neces
|
| 157 |
+
|
| 158 |
+
Table 3: Comparison between HTGM and its variants and the applicable baselines on novel task detection.
|
| 159 |
+
|
| 160 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>AUROC</td><td rowspan=1 colspan=1>AP</td><td rowspan=1 colspan=1>Max-F1</td></tr><tr><td rowspan=2 colspan=1>HSMLProtoNetMetaOptNetNCAProtoNet-AugFEATS</td><td rowspan=1 colspan=1>55.96</td><td rowspan=1 colspan=1>37.94</td><td rowspan=1 colspan=1>50.17</td></tr><tr><td rowspan=1 colspan=1>65.1772.7166.2872.6759.35</td><td rowspan=1 colspan=1>41.5163.7751.4557.9342.57</td><td rowspan=1 colspan=1>56.0758.3352.7459.0749.31</td></tr><tr><td rowspan=1 colspan=1>HTGMw/oGMMHTGM-GaussianHTGM</td><td rowspan=1 colspan=1>70.2474.0675.66</td><td rowspan=1 colspan=1>62.4566.1868.03</td><td rowspan=1 colspan=1>57.7560.6260.51</td></tr></table>
|
| 161 |
+
|
| 162 |
+
sity to introduce the regularization of task-level mixture distribution $p ( \mathbf { v } _ { \tau } )$ . Also, the drops of AUROC and AP of HTGM-Gaussian demonstrate the importance of our unique design of the Gibbs distribution for the task-conditional distribution in Eq. (2). Similar to (Vaze et al., 2022), in Fig. 2, we visualized the normalized likelihood histogram of known and novel tasks for HSML, MetaOptNet (the best baseline), ProtoNet-Aug (the near-best baseline), and HTGM. The figures indicate the likelihoods (i.e., novelty scores) of HTGM are more distinguishable for known and novel tasks than the baselines. We also analyzed the hyperparameters of HTGM, which are in D.1, D.2, D.3.
|
| 163 |
+
|
| 164 |
+
# 5 CONCLUSION
|
| 165 |
+
|
| 166 |
+
In this paper, we propose a novel Hierarchical Gaussian Mixture based Task Generative Model (HTGM). HTGM models the generative process of task instances, and performs maximum likelihood estimation to learn task embeddings, which can help adjust prototypes acquired by the feature extractor and thus achieve better performance. Moreover, by explicitly modeling the mixture distribution of tasks in the embedding space, HTGM can effectively detect the tasks that are drawn from distributions unseen in the meta-training stage. The extensive experimental results indicate the advantage of the proposed method on both few-shot classification and novel task detection.
|
| 167 |
+
|
| 168 |
+
# REFERENCES
|
| 169 |
+
|
| 170 |
+
Alessandro Achille, Michael Lam, Rahul Tewari, Avinash Ravichandran, Subhransu Maji, Charless C Fowlkes, Stefano Soatto, and Pietro Perona. Task2vec: Task embedding for meta-learning. In ICCV, pp. 6430–6439, 2019.
|
| 171 |
+
|
| 172 |
+
Brandon Amos and J. Zico Kolter. OptNet: Differentiable optimization as a layer in neural networks. In ICML, volume 70 of Proceedings of Machine Learning Research, pp. 136–145. PMLR, 2017.
|
| 173 |
+
|
| 174 |
+
Thomas L Athey, Benjamin D Pedigo, Tingshan Liu, and Joshua T Vogelstein. Autogmm: Automatic and hierarchical gaussian mixture modeling in python. arXiv preprint arXiv:1909.02688, 2019.
|
| 175 |
+
|
| 176 |
+
M. Christopher Bishop. Pattern recognition and machine learning. Springer, 2006.
|
| 177 |
+
|
| 178 |
+
Isaac S Chan and Geoffrey S Ginsburg. Personalized medicine: progress and promise. Annual review of genomics and human genetics, 12:217–244, 2011.
|
| 179 |
+
|
| 180 |
+
Jiacheng Cheng and Nuno Vasconcelos. Learning deep classifiers consistent with fine-grained novelty detection. In CVPR, pp. 1664–1673, 2021.
|
| 181 |
+
|
| 182 |
+
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In ICML, pp. 1126–1135. PMLR, 2017.
|
| 183 |
+
|
| 184 |
+
Jacob Goldberger and Sam T Roweis. Hierarchical clustering of a mixture model. In NeurIPS, pp. 505–512, 2005.
|
| 185 |
+
|
| 186 |
+
Laurent Jacob, Jean-philippe Vert, and Francis Bach. Clustered multi-task learning: A convex formulation. In NIPS, 2008.
|
| 187 |
+
|
| 188 |
+
Minki Jeong, Seokeon Choi, and Changick Kim. Few-shot open-set recognition by transformation consistency. In CVPR, pp. 12566–12575, 2021.
|
| 189 |
+
|
| 190 |
+
Ghassen Jerfel, Erin Grant, Tom Griffiths, and Katherine A Heller. Reconciling meta-learning and continual learning with online mixtures of tasks. NeurIPS, 32, 2019.
|
| 191 |
+
|
| 192 |
+
Zhuoliang Kang, Kristen Grauman, and Fei Sha. Learning with whom to share in multi-task feature learning. In ICML, 2011.
|
| 193 |
+
|
| 194 |
+
Diederik $\mathrm { \bf P }$ Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
|
| 195 |
+
|
| 196 |
+
Abhishek Kumar and Hal Daume III. Learning task grouping and overlap in multi-task learning. In ´ ICML, pp. 1723–1730, 2012.
|
| 197 |
+
|
| 198 |
+
Steinar Laenen and Luca Bertinetto. On episodes, prototypical networks, and few-shot learning. NeurIPS, 34:24581–24592, 2021.
|
| 199 |
+
|
| 200 |
+
Yann LeCun, Sumit Chopra, Raia Hadsell, M Ranzato, and F Huang. A tutorial on energy-based learning. Predicting structured data, 1(0), 2006.
|
| 201 |
+
|
| 202 |
+
Hae Beom Lee, Hayeon Lee, Donghyun Na, Saehoon Kim, Minseop Park, Eunho Yang, and Sung Ju Hwang. Learning to balance: Bayesian meta-learning for imbalanced and out-of-distribution tasks. arXiv preprint arXiv:1905.12917, 2019a.
|
| 203 |
+
|
| 204 |
+
Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. NeurIPS, 31, 2018.
|
| 205 |
+
|
| 206 |
+
Kimin Lee, Sukmin Yun, Kibok Lee, Honglak Lee, Bo Li, and Jinwoo Shin. Robust inference via generative classifiers for handling noisy labels. In ICML, pp. 3763–3772. PMLR, 2019b.
|
| 207 |
+
|
| 208 |
+
Kwonjoon Lee, Subhransu Maji, Avinash Ravichandran, and Stefano Soatto. Meta-learning with differentiable convex optimization. In CVPR, pp. 10657–10665, 2019c.
|
| 209 |
+
|
| 210 |
+
Yoonho Lee and Seungjin Choi. Gradient-based meta-learning with learned layerwise metric and subspace. In ICML, pp. 2927–2936. PMLR, 2018.
|
| 211 |
+
|
| 212 |
+
Zhenguo Li, Fengwei Zhou, Fei Chen, and Hang Li. Meta-sgd: Learning to learn quickly for fewshot learning. arXiv preprint arXiv:1707.09835, 2017.
|
| 213 |
+
|
| 214 |
+
Shiyu Liang, Yixuan Li, and R Srikant. Enhancing the reliability of out-of-distribution image detection in neural networks. In ICLR, 2018.
|
| 215 |
+
|
| 216 |
+
Weitang Liu, Xiaoyun Wang, John Owens, and Yixuan Li. Energy-based out-of-distribution detection. pp. 21464–21475, 2020.
|
| 217 |
+
|
| 218 |
+
Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. Distributed representations of words and phrases and their compositionality. In NeurIPS, 2013.
|
| 219 |
+
|
| 220 |
+
Nikhil Mishra, Mostafa Rohaninejad, Xi Chen, and Pieter Abbeel. A simple neural attentive metalearner. In ICLR, 2018.
|
| 221 |
+
|
| 222 |
+
Jingchao Ni, Wei Cheng, Zhengzhang Chen, Takayoshi Asakura, Tomoya Soma, Sho Kato, and Haifeng Chen. Superclass-conditional gaussian mixture model for learning fine-grained embeddings. In ICLR, 2022.
|
| 223 |
+
|
| 224 |
+
Łukasz P Olech and Mariusz Paradowski. Hierarchical gaussian mixture model with objects attached to terminal and non-terminal dendrogram nodes. In Proceedings of the 9th International Conference on Computer Recognition Systems CORES 2015, pp. 191–201. Springer, 2016.
|
| 225 |
+
|
| 226 |
+
Boris Oreshkin, Pau Rodr´ıguez Lopez, and Alexandre Lacoste. Tadam: Task dependent adaptive ´ metric for improved few-shot learning. Advances in neural information processing systems, 31, 2018.
|
| 227 |
+
|
| 228 |
+
Alexandre Passos, Piyush Rai, Jacques Wainer, and Hal Daume III. Flexible modeling of latent task ´ structures in multitask learning. In ICMl, pp. 1283–1290, 2012.
|
| 229 |
+
|
| 230 |
+
Sanjay Purushotham, Wilka Carvalho, Tanachat Nilanon, and Yan Liu. Variational recurrent adversarial deep domain adaptation. In ICLR, 2017.
|
| 231 |
+
|
| 232 |
+
Aniruddh Raghu, Maithra Raghu, Samy Bengio, and Oriol Vinyals. Rapid learning or feature reuse? towards understanding the effectiveness of maml. In ICLR, 2020.
|
| 233 |
+
|
| 234 |
+
Andrei A Rusu, Dushyant Rao, Jakub Sygnowski, Oriol Vinyals, Razvan Pascanu, Simon Osindero, and Raia Hadsell. Meta-learning with latent embedding optimization. In ICLR, 2018.
|
| 235 |
+
|
| 236 |
+
Ketan Rajshekhar Shahapure and Charles Nicholas. Cluster quality analysis using silhouette score. In 2020 IEEE 7th International Conference on Data Science and Advanced Analytics (DSAA), pp. 747–748. IEEE, 2020.
|
| 237 |
+
|
| 238 |
+
Karishma Sharma, Yizhou Zhang, Emilio Ferrara, and Yan Liu. Identifying coordinated accounts on social media through hidden influence and group behaviours. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining, pp. 1441–1451, 2021.
|
| 239 |
+
|
| 240 |
+
Satya Narayan Shukla and Benjamin Marlin. Interpolation-prediction networks for irregularly sampled time series. In ICLR, 2019.
|
| 241 |
+
|
| 242 |
+
Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. In NeurIPS, 2017.
|
| 243 |
+
|
| 244 |
+
Jong-Chyi Su, Subhransu Maji, and Bharath Hariharan. When does self-supervision improve fewshot learning? In ECCV, pp. 645–666. Springer, 2020.
|
| 245 |
+
|
| 246 |
+
Yonglong Tian, Yue Wang, Dilip Krishnan, Joshua B Tenenbaum, and Phillip Isola. Rethinking fewshot image classification: a good embedding is all you need? In ECCV, pp. 266–282. Springer, 2020.
|
| 247 |
+
|
| 248 |
+
Sagar Vaze, Kai Han, Andrea Vedaldi, and Andrew Zisserman. Open-set recognition: A good closed-set classifier is all you need. In ICLR, 2022.
|
| 249 |
+
|
| 250 |
+
Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Daan Wierstra, et al. Matching networks for one shot learning. NIPS, 29, 2016.
|
| 251 |
+
|
| 252 |
+
Risto Vuorio, Shao-Hua Sun, Hexiang Hu, and Joseph J Lim. Toward multimodal model-agnostic meta-learning. arXiv preprint arXiv:1812.07172, 2018.
|
| 253 |
+
|
| 254 |
+
Yinjun Wu, Jingchao Ni, Wei Cheng, Bo Zong, Dongjin Song, Zhengzhang Chen, Yanchi Liu, Xuchao Zhang, Haifeng Chen, and Susan B Davidson. Dynamic gaussian mixture based deep generative model for robust forecasting on sparse multivariate time series. In AAAI, volume 35, pp. 651–659, 2021.
|
| 255 |
+
|
| 256 |
+
Ya Xue, Xuejun Liao, Lawrence Carin, and Balaji Krishnapuram. Multi-task learning for classification with dirichlet process priors. Journal of Machine Learning Research, 8(1), 2007.
|
| 257 |
+
|
| 258 |
+
Huaxiu Yao, Ying Wei, Junzhou Huang, and Zhenhui Li. Hierarchically structured meta-learning. In ICML, pp. 7045–7054. PMLR, 2019a.
|
| 259 |
+
|
| 260 |
+
Huaxiu Yao, Xian Wu, Zhiqiang Tao, Yaliang Li, Bolin Ding, Ruirui Li, and Zhenhui Li. Automated relational meta-learning. In ICLR, 2019b.
|
| 261 |
+
|
| 262 |
+
Han-Jia Ye, Hexiang Hu, De-Chuan Zhan, and Fei Sha. Few-shot learning via embedding adaptation with set-to-set functions. In CVPR, pp. 8808–8817, 2020.
|
| 263 |
+
|
| 264 |
+
# A APPENDIX FOR DETAILS OF DERIVING HTGM
|
| 265 |
+
|
| 266 |
+
# A.1 THE LOWER-BOUND OF THE LIKELIHOOD FUNCTION
|
| 267 |
+
|
| 268 |
+
In this section, we provide the details of the lower-bound in Eq. (3). By introducing the approximated posterior $q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathsf { s } } )$ , the likelihood in Eq. (1) becomes (the superscript $^ *$ is neglected for clarity)
|
| 269 |
+
|
| 270 |
+
$$
|
| 271 |
+
\begin{array} { r l } { \langle \mathcal { D } _ { r } , \theta \rangle = \frac { 1 } { w _ { 2 } } \displaystyle \sum _ { t = 1 } ^ { n } \log ( w _ { t } | \theta ) | \theta \rangle + \frac { 1 } { n } \displaystyle \sum _ { t = 1 } ^ { n } \log \Big ( \displaystyle \int _ { w _ { 1 } } w _ { t } \log ( w _ { t } | \theta ) | w _ { t } \Big ) } & { } \\ { = \frac { 1 } { n } \displaystyle \sum _ { t = 1 } ^ { n } \log ( w _ { 1 } | \theta ) + \frac { 1 } { w _ { 2 } } \displaystyle \sum _ { t = 1 } ^ { n } \log \Big ( \displaystyle \int _ { w _ { 1 } } w _ { t } \log ( w _ { 1 } | w _ { t } ) \displaystyle \frac { w _ { t } ( w _ { 1 } | w _ { t } ) } { \mu _ { 1 } ( w _ { 1 } ) } \Big ) \Big ( w _ { 1 } \log ( w _ { 1 } | w _ { t } ) \Big ) } & { } \\ { = \frac { 1 } { n } \displaystyle \sum _ { t = 1 } ^ { n } \log ( w _ { 1 } | \theta ) + \frac { 1 } { n } \displaystyle \sum _ { t = 1 } ^ { n } \log \Big ( \displaystyle \int _ { w _ { 1 } } w _ { t } \log ( w _ { 1 } | w _ { t } ) \displaystyle \frac { w _ { t } ( w _ { 1 } | w _ { t } ) } { \mu _ { 1 } ( w _ { 1 } ) } \Big ) \Big ( w _ { 1 } \log ( w _ { 1 } | w _ { t } ) \Big ) } & { } \\ { \geq \frac { 1 } { n } \displaystyle \sum _ { t = 1 } ^ { n } \log ( w _ { 1 } | w _ { 1 } ) + \frac { 1 } { n } \displaystyle \sum _ { t = 1 } ^ { n } \log ( w _ { 1 } | w _ { 1 } ) \displaystyle \frac { w _ { t } ( w _ { 1 } | w _ { 1 } ) } { \mu _ { 1 } ( w _ { 1 } ) } \Big [ \log ( w _ { 1 } | w _ { 1 } ) + \log ( w _ { 1 } | w _ { 1 } ) \displaystyle \sum _ { t = 1 } ^ { n } \log ( w _ { 1 } | w _ { t } ) \Big ] \Big ( w _ { 1 } \log ( w _ { 1 } | w _ { t } ) \Big ) } & { } \\ = \displaystyle \frac { 1 } { n } \displaystyle \sum _ { t = 1 } ^ { n } \log ( w _ { 1 } | w _ { 1 } ) + \displaystyle \frac { 1 } { n } \displaystyle \sum _ { t = 1 } ^ { n } \int _ w _ 1 \end{array}
|
| 272 |
+
$$
|
| 273 |
+
|
| 274 |
+
where the fourth step uses Jensen’s inequality. This completes the derivation of Eq. (3).
|
| 275 |
+
|
| 276 |
+
# A.2 THE UPPER-BOUND OF THE PARTITION FUNCTION
|
| 277 |
+
|
| 278 |
+
In Sec. 3.2, we apply an upper bound on the partition function in Eq. (2) for solving the challenging 2. The derivation of the upper bound is as follows.
|
| 279 |
+
|
| 280 |
+
$$
|
| 281 |
+
\begin{array} { r l } & { \displaystyle \int _ { \mu _ { y _ { i } } ^ { \mathrm { c } } } \exp \big [ - E _ { \omega } \big ( \mu _ { y _ { i } } ^ { \mathrm { c } } ; \mathbf { v } _ { \tau } \big ) \big ] d \mu _ { y _ { i } } ^ { \mathrm { c } } = \int _ { \mu _ { y _ { i } } ^ { \mathrm { c } } } \exp \big [ - \operatorname* { m i n } \big ( \xi \big | \big | \mu _ { y _ { i } } ^ { \mathrm { c } } - \mathbf { W } _ { j } \mathbf { v } _ { \tau } \big | \big | _ { 2 } ^ { 2 } \big ) _ { j = 1 } ^ { N } \big ) \Big ] d \mu _ { y _ { i } } ^ { \mathrm { c } } } \\ & { = \displaystyle \int _ { \mu _ { y _ { i } } ^ { \mathrm { c } } } \operatorname* { m a x } \Big ( \big \{ \exp \big [ - \big | \big | \mu _ { y _ { i } } ^ { \mathrm { c } } - \mathbf { W } _ { j } \mathbf { v } _ { \tau } \big | \big | _ { 2 } ^ { 2 } \big ] \big \} _ { j = 1 } ^ { N } \Big ) d \mu _ { y _ { i } } ^ { \mathrm { c } } < \int _ { \mu _ { y _ { i } } ^ { \mathrm { c } } } \displaystyle \sum _ { j = 1 } ^ { N } \exp \big [ - \big | \big | \mu _ { y _ { i } } ^ { \mathrm { c } } - \mathbf { W } _ { j } \mathbf { v } _ { \tau } \big | \big | _ { 2 } ^ { 2 } \big ] d \mu _ { y _ { i } } ^ { \mathrm { c } } } \\ & { = \displaystyle \sum _ { j = 1 } ^ { N } \int _ { \mu _ { y _ { i } } ^ { \mathrm { c } } } \exp \big [ - \big | \big | \mu _ { y _ { i } } ^ { \mathrm { c } } - \mathbf { W } _ { j } \mathbf { v } _ { \tau } \big | \big | _ { 2 } ^ { 2 } \big ] d \mu _ { y _ { i } } ^ { \mathrm { c } } = \sqrt { 2 ^ { d - 1 } \pi ^ { d } } } \end{array}
|
| 282 |
+
$$
|
| 283 |
+
|
| 284 |
+
where the last equation is from the multidimensional Gaussian integral. This completes the derivation of the upper bound of the partition function.
|
| 285 |
+
|
| 286 |
+
# A.3 THE PROOF OF THEOREM 1
|
| 287 |
+
|
| 288 |
+
Proof. Let $B _ { j }$ denote a ball in $\mathbb { R } ^ { d }$ . Its center is at ${ \bf W } _ { j } { \bf v } _ { \tau }$ and its radius is $D ( \mathbf { W } _ { h } \mathbf { v } _ { \tau } , \mathbf { W } _ { l } \mathbf { v } _ { \tau } ) / 3$ . Because $\mathbf { W } _ { h } \mathbf { v } _ { \tau }$ and $\mathbf { W } _ { l } \mathbf { v } _ { \tau }$ $( 1 ~ \le ~ h , l ~ \le ~ N )$ is the pair with the smallest Euclidean distance $D ( \mathbf { W } _ { h } \mathbf { v } _ { \tau } , \mathbf { W } _ { l } \mathbf { v } _ { \tau } )$ , for any pair of balls $B _ { j }$ and $B _ { m }$ we have $B _ { j } \cup B _ { m } = \varnothing$ .
|
| 289 |
+
|
| 290 |
+
In other words, there is no overlap between any pair of balls. Therefore, if we compute the integral over the joint of all balls, we have
|
| 291 |
+
|
| 292 |
+
$$
|
| 293 |
+
\int _ { \mu _ { k } ^ { \mathbb { C } } \in \bigcup _ { m = 1 } ^ { N } B _ { m } } \exp \big [ - E _ { \omega } ( \mu _ { k } ^ { \mathbb { C } } ; { \mathbf { v } } _ { \tau } ) \big ] d \mu _ { k } ^ { \mathbb { c } } = \sum _ { m = 1 } ^ { N } \int _ { \mu _ { k } ^ { \mathbb { C } } \in B _ { m } } \exp \big [ - E _ { \omega } ( \mu _ { k } ^ { \mathbb { C } } ; { \mathbf { v } } _ { \tau } ) \big ] d \mu _ { k } ^ { \mathbb { c } }
|
| 294 |
+
$$
|
| 295 |
+
|
| 296 |
+
Also, because there is no overlap between any pair of balls, for each point $\pmb { \mu } _ { k } ^ { \mathsf { c } } \in B _ { m }$ , we have
|
| 297 |
+
|
| 298 |
+
$$
|
| 299 |
+
- \operatorname* { m i n } \left( \{ | | \pmb { \mu } _ { k } ^ { \mathrm { c } } - \mathbf { W } _ { j } \mathbf { v } _ { \tau } | | _ { 2 } ^ { 2 } \} _ { j = 1 } ^ { N } \right) = - | | \pmb { \mu } _ { k } ^ { \mathrm { c } } - \mathbf { W } _ { m } \mathbf { v } _ { \tau } | | _ { 2 } ^ { 2 }
|
| 300 |
+
$$
|
| 301 |
+
|
| 302 |
+
Therefore, we have the following derivation from Eq. (9).
|
| 303 |
+
|
| 304 |
+
$$
|
| 305 |
+
\begin{array} { l l } { \displaystyle \int _ { \mu _ { k } ^ { \mathbb { c } } \in \bigcup _ { m = 1 } ^ { N } B _ { m } } \exp \big [ - E _ { \omega } ( \mu _ { k } ^ { \mathbb { c } } ; \mathbf { v } _ { \tau } ) \big ] d \mu _ { k } ^ { \mathbb { c } } = \displaystyle \sum _ { m = 1 } ^ { N } \int _ { \mu _ { k } ^ { \mathbb { c } } \in B _ { m } } \exp \big [ - E _ { \omega } ( \mu _ { k } ^ { \mathbb { c } } ; \mathbf { v } _ { \tau } ) \big ] d \mu _ { k } ^ { \mathbb { c } } } \\ { \displaystyle = \displaystyle \sum _ { m = 1 } ^ { N } \int _ { \mu _ { k } ^ { \mathbb { c } } \in B _ { m } } \exp \big [ - | | \mu _ { k } ^ { \mathbb { c } } - \mathbf { W } _ { m } \mathbf { v } _ { \tau } | | _ { 2 } ^ { 2 } \big ] d \mu _ { k } ^ { \mathbb { c } } = N \int _ { \mu _ { k } \in B _ { m } } \exp \big [ - | | \mu _ { k } ^ { \mathbb { c } } - \mathbf { W } _ { m } \mathbf { v } _ { \tau } | | _ { 2 } ^ { 2 } \big ] d \mu _ { k } ^ { \mathbb { c } } } \end{array}
|
| 306 |
+
$$
|
| 307 |
+
|
| 308 |
+
Meanwhile, since $\textstyle \bigcup _ { m = 1 } ^ { N } B _ { m }$ is a sub-area of the entire $\mathbb { R } ^ { d }$ space, we have
|
| 309 |
+
|
| 310 |
+
$$
|
| 311 |
+
\int _ { \mu _ { k } ^ { \mathbb { C } } \in \bigcup _ { m = 1 } ^ { N } B _ { m } } \exp \big [ - E _ { \omega } \big ( \mu _ { k } ^ { \mathbb { C } } ; { \mathbf { v } } _ { \tau } \big ) \big ] d \mu _ { k } ^ { \mathbb { C } } \leq \int _ { \mu _ { k } ^ { \mathbb { C } } } \exp \big [ - E _ { \omega } \big ( \mu _ { k } ^ { \mathbb { C } } ; { \mathbf { v } } _ { \tau } \big ) \big ] d \mu _ { k } ^ { \mathbb { C } }
|
| 312 |
+
$$
|
| 313 |
+
|
| 314 |
+
According to the multidimensional Gaussian integral, we have
|
| 315 |
+
|
| 316 |
+
$$
|
| 317 |
+
\operatorname* { l i m } _ { \substack { D ( \mathbf { W } _ { h } \mathbf { v } _ { \tau } , \mathbf { W } _ { l } \mathbf { v } _ { \tau } ) \infty } } \int _ { \pmb { \mu } _ { k } ^ { \mathbb { c } } \in B _ { m } } \exp \big [ - E _ { \omega } ( \pmb { \mu } _ { k } ^ { \mathbb { c } } ; \mathbf { v } _ { \tau } ) \big ] d \pmb { \mu } _ { k } ^ { \mathbb { c } } = \sqrt { 2 ^ { d - 1 } \pi ^ { d } }
|
| 318 |
+
$$
|
| 319 |
+
|
| 320 |
+
Therefore,
|
| 321 |
+
|
| 322 |
+
$$
|
| 323 |
+
\operatorname* { l i m } _ { \substack { D ( \mathbf { W } _ { h } \mathbf { v } _ { \tau } , \mathbf { W } _ { l } \mathbf { v } _ { \tau } ) \infty } } \int _ { \mu _ { k } ^ { \mathrm { c } } } \exp \Big [ - E _ { \omega } \big ( \mu _ { k } ^ { \mathrm { c } } ; \mathbf { v } _ { \tau } \big ) \Big ] d \mu _ { k } ^ { \mathrm { c } } \geq N \sqrt { 2 ^ { d - 1 } \pi ^ { d } }
|
| 324 |
+
$$
|
| 325 |
+
|
| 326 |
+
Since $N { \sqrt { 2 ^ { d - 1 } \pi ^ { d } } }$ is its upper bound, based on the squeeze theorem, we have
|
| 327 |
+
|
| 328 |
+
$$
|
| 329 |
+
\operatorname* { l i m } _ { \substack { D ( \mathbf { W } _ { h } \mathbf { v } _ { \tau } , \mathbf { W } _ { l } \mathbf { v } _ { \tau } ) \infty } } \int _ { \mu _ { k } ^ { \mathbb { C } } } \exp \big [ - E _ { \omega } ( \mu _ { k } ^ { \mathbb { C } } ; \mathbf { v } _ { \tau } ) \big ] d \mu _ { k } ^ { \mathbb { C } } = N \sqrt { 2 ^ { d - 1 } \pi ^ { d } }
|
| 330 |
+
$$
|
| 331 |
+
|
| 332 |
+
which completes the proof of Theorem 1.
|
| 333 |
+
|
| 334 |
+
A.4 THE TRAINING ALGORITHM OF HTGM
|
| 335 |
+
|
| 336 |
+
The training algorithm of HTGM is summarized in Algorithm 1.
|
| 337 |
+
|
| 338 |
+
B APPENDIX FOR FURTHER DISCUSSION
|
| 339 |
+
|
| 340 |
+
# B.1 DISCUSSION ABOUT THE RELATIONSHIP BETWEEN HTGM AND HGM MODEL
|
| 341 |
+
|
| 342 |
+
To the best of our knowledge, the Hierarchical Gaussian Mixture (HGM) model has appeared in the traditional works (Goldberger & Roweis, 2005; Olech & Paradowski, 2016; Athey et al., 2019) for hierarchical clustering by applying Gaussian Mixture model agglomeratively or divisively on the input samples. They are unsupervised methods that infer clusters of samples, but do not pretrain embedding models (or parameter initializations) that could be fine-tuned for the adaptation to new tasks in meta-learning. Therefore, these methods are remarkably different from meta-learning methods, and we think it is a non-trivial problem to adapt the concept of HGM to solve the metalearning problem. To this end, we need to (1) identify the motivation; and (2) solve the new technical challenges. For (1), we found the hierarchical structure of mixture distributions naturally appears when we want to model the generative process of tasks from a mixture of distributions, where each task contains another mixture distribution of classes (as suggested by Eq. (1)). In other words, the motivating point of our method is more on meta-learning than HGM. However, we think drawing such a connection between meta-learning and HGM is a novel contribution. For (2), our method is different from traditional HGM in (a) its generative process of tasks (Sec. 3.1), which is a theoretical extension of the widely used empirical process of generating tasks in meta-learning; (b) its Gibbsstyle task-conditional distribution (Eq. (2)) for fitting uniformly sampled classes; (c) the metricbased end-to-end meta-learning framework (Fig. 1) (note the traditional HGM is not for learning embeddings); (d) the non-trivial derivation of the optimization algorithm in Sect. 3.2 and Alg. 1; and (e) the novel model adaptation process in Sec. 3.3. Solving the technical challenges in the new generative model is another novel contribution of the proposed method.
|
| 343 |
+
|
| 344 |
+
Input: encoder $f _ { \theta }$ , training dataset ${ \mathcal { D } } ^ { \mathrm { t r } }$ , hyperparameters $r$ , $\sigma$ , $\bar { \sigma }$ Output: model parameters $\{ \theta , \omega \}$
|
| 345 |
+
|
| 346 |
+
1 Pre-train the encoder $f _ { \theta }$ via ProtoNet with augmentations.
|
| 347 |
+
2 Pre-train the energy function in Eq. (2) by maximizing $\begin{array} { r } { \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \log p _ { \theta , \omega } ( \mathbf { e } _ { i } | y _ { i } ) + \log p _ { \omega } ( y _ { i } | \mathbf { v } _ { \tau } ) } \end{array}$
|
| 348 |
+
3 for $i \gets 1$ to MaxEpoch do
|
| 349 |
+
|
| 350 |
+
/ $\star$ E-step $\star /$ 4 $\nu = \emptyset$ 5 for $\{ \mathcal { D } _ { \tau } ^ { s } = \{ ( \mathbf { x } _ { i } ^ { s } , y _ { i } ^ { s } ) \} _ { i = 1 } ^ { n _ { s } } , \mathcal { D } _ { \tau } ^ { q } = \{ ( \mathbf { x } _ { i } ^ { q } , y _ { i } ^ { q } ) \} _ { i = 1 } ^ { n _ { q } } \}$ in Dataloader $\mathcal { D } ^ { t r } .$ ) do / $\star$ load a task episode $\star /$ 6 $\{ { \bf e } _ { i } ^ { \mathfrak { s } } \} _ { i = 1 } ^ { n _ { \mathfrak { s } } } = \{ f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { \mathfrak { s } } ) \} _ { i = 1 } ^ { n _ { \mathfrak { s } } }$ // embeddings of the support set 7 $\pmb { \mu } _ { z _ { \tau } } ^ { \mathrm { a } } = \mathrm { T a s k - P o o l i n g } ( \mathrm { C l a s s - P o o l i n g } ( \{ ( \mathbf { e } _ { i } ^ { \mathrm { s } } , y _ { i } ^ { \mathrm { s } } ) \} _ { i = 1 } ^ { n _ { \mathrm { s } } } ) )$ // the mean of $q _ { \phi } \big ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathfrak { s } } \big )$ 8 Sample a task embedding $\mathbf { v } _ { \tau }$ from $q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathsf { s } } ) = \mathcal { N } ( \pmb { \mu } _ { z _ { \tau } } ^ { \mathsf { a } } , \bar { \sigma } ^ { 2 } \mathbf { I } )$ 9 $\mathcal { V } = \mathcal { V } \cup \{ \mathbf { v } _ { \tau } \}$ 10 end 11 $\left\{ z _ { \tau } \right\} _ { \tau = 1 } ^ { | \mathcal { V } | } , \left\{ \mu _ { 1 } ^ { \mathrm { t } } , . . . , \mu _ { r } ^ { \mathrm { t } } , \Sigma _ { 1 } ^ { \mathrm { t } } , . . . , \Sigma _ { r } ^ { \mathrm { t } } \right\} = \mathbf { G } \mathbf { M } \mathbf { M } ( \mathcal { V } ) .$ . // fit a GMM to $\nu$ , where $\{ z _ { \tau } \} _ { \tau = 1 } ^ { | \nu | }$ represents the labeling of the ${ \bf { v } } _ { \tau } \prime _ { \mathrm { ~ S ~ } }$ in $\nu$ /\* M-step \*/ 12 for $\{ \mathcal { D } _ { \tau } ^ { s } = \{ ( \mathbf { x } _ { i } ^ { s } , y _ { i } ^ { s } ) \} _ { i = 1 } ^ { n _ { s } } , \mathcal { D } _ { \tau } ^ { q } = \{ ( \mathbf { x } _ { i } ^ { q } , y _ { i } ^ { q } ) \} _ { i = 1 } ^ { n _ { q } } \}$ in Dataloader $\mathcal { D } ^ { t r } )$ do / $\star$ load a task episode $\star /$ 13 14 $\{ { \bf e } _ { i } ^ { \mathfrak { s } } \} _ { i = 1 } ^ { n _ { \mathfrak { s } } } = \{ f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { \mathfrak { s } } ) \} _ { i = 1 } ^ { n _ { \mathfrak { s } } }$ $\{ \mathbf { e } _ { i } ^ { \mathfrak { q } } \} _ { i = 1 } ^ { n _ { \mathfrak { q } } } = \{ f _ { \theta } ( \mathbf { x } _ { i } ^ { \mathfrak { q } } ) \} _ { i = 1 } ^ { n _ { \mathfrak { q } } }$ // forward pass// forward pass 15 $\{ \mu _ { 1 } ^ { \mathfrak { c } } , . . . , \mu _ { N } ^ { \mathfrak { c } } \} ^ { \mathfrak { s } } = \mathbf { C l a s s - P o o l i n g } ( \{ ( \mathbf { e } _ { i } ^ { \mathfrak { s } } , y _ { i } ^ { \mathfrak { s } } ) \} _ { i = 1 } ^ { n _ { \mathfrak { s } } } )$ 16 $\pmb { \mu } _ { z _ { \tau } } ^ { \mathrm { a } } = \mathrm { T a s k - P o o l i n g } ( \{ \pmb { \mu } _ { 1 } ^ { \mathrm { c } } , . . . , \pmb { \mu } _ { N } ^ { \mathrm { c } } \} ^ { \mathrm { s } } )$ // the mean of $q _ { \phi } \big ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathtt { S } } \big )$ 17 Sample a task embedding $\mathbf { v } _ { \tau }$ from $q _ { \phi } ( \mathbf { v } _ { \tau } | \mathcal { D } _ { \tau } ^ { \mathsf { s } } ) = \mathcal { N } ( \pmb { \mu } _ { z _ { \tau } } ^ { \mathsf { a } } , \bar { \sigma } ^ { 2 } \mathbf { I } )$ 18 for $j = I , . . . , N$ do 19 $\begin{array} { r l } { \lvert } & { { } \bar { \pmb { \mu } } _ { j } ^ { \mathrm { c } } = \alpha { \pmb { \mu } } _ { j } ^ { \mathrm { c } } + ( 1 - \alpha ) { \bf W } _ { l ^ { * } } { \bf v } _ { \tau ^ { \prime } } } \end{array}$ where $l ^ { * } = \arg \operatorname* { m i n } _ { 1 \leq l \leq N } D ( \pmb { \mu } _ { j } ^ { \mathrm { c } } , \mathbf { W } _ { l } \mathbf { v } _ { \tau ^ { \prime } } )$ 20 end 21 Calculate $\ell ( \{ \mathbf { e } _ { i } ^ { \mathfrak { q } } \} _ { i = 1 } ^ { n _ { \mathfrak { q } } } , \boldsymbol { \mathcal { V } } , \{ \bar { \mu } _ { j } ^ { \mathfrak { c } } \} _ { j = 1 } ^ { N } , \{ \mu _ { 1 } ^ { \mathfrak { t } } , . . . , \mu _ { r } ^ { \mathfrak { t } } , \Sigma _ { 1 } ^ { \mathfrak { t } } , . . . , \Sigma _ { r } ^ { \mathfrak { t } } \} , \sigma , \omega )$ // calculate the loss in Eq. (5) using Eq. (3) and Eq. (4) 22 $\pmb { \theta } , \omega = \mathrm { S G D } ( \ell , \pmb { \theta } , \omega )$ // update model parameters 23 end 24 end
|
| 351 |
+
|
| 352 |
+
# B.2 DISCUSSION ABOUT THE RELATED MULTI-TASK LEARNING METHODS
|
| 353 |
+
|
| 354 |
+
The modeling of the clustering/grouping structure of tasks or the mixture of distributions of tasks has been studied in multi-tasking learning (MTL). In (Xue et al., 2007; Jacob et al., 2008), tasks are assumed to have a clustering structure, and the model parameters of the tasks in the same cluster are drawn to each other via optimization on their L2 distances. In (Kang et al., 2011), a subspace based regularization framework was proposed for grouping task-specific model parameters, where the tasks in the same group are assumed to lie in the same low dimensional subspace for parameter sharing. The method in (Kumar & Daume III ´ , 2012) also uses the subspace based sharing of task parameters, but allows two tasks from different groups to overlap by having one or more bases in common. The method in (Passos et al., 2012) introduces a generative model for task-specific model parameters that encourages parameter sharing by modeling the latent mixture distribution of the parameters via the Dirichlet process and Beta process.
|
| 355 |
+
|
| 356 |
+
The key difference between these methods and our method HTGM lies in the difference between MTL and meta-learning. In an MTL method, all tasks are known a priori, i.e., the testing tasks are from the set of training tasks, and the model is non-inductive at the task-level (but it is inductive at the sample-level). In HTGM, testing tasks can be disjoint from the set of training tasks, thus the model is inductive at the task-level. In particular, we aim to allow testing tasks that are not from the distribution of the training tasks by enabling the detection of novel tasks, which is an extension of the task-level inductive model. The second difference lies in the generative process. The method in (Passos et al., 2012) models the generative process of the task-specific model parameters (e.g., the weights in a regressor). In contrast, HTGM models the generative process of each task by generating the classes in it, and the samples in the classes hierarchically, i.e., the $\left( \mathbf { x } , y \right)$ ’s (in Eq. (1) and Sec. 3.1). In this process, we allow our model to fit uniformly sampled classes given a task (without specifying a prior on the distance function on classes) by the proposed Gibbs distribution in Eq. (2). Other remarkable differences to the aforementioned MTL methods include the inference network (Fig. 1(b)), which allows the inductive inference on task embeddings and class prototypes; the optimization algorithm (Sec. 3.2) to our specific loss function in Eq. (3), which is from the likelihood in Eq. (1); and the model adaptation algorithm (Sec. 3.3) for performing predictions in a testing task, and detecting novel tasks. As such, the MTL methods can not be trivially applied to solve our problem.
|
| 357 |
+
|
| 358 |
+
# B.3 FURTHER INTERPRETATION OF THE TASK-CONDITIONAL DISTRIBUTION
|
| 359 |
+
|
| 360 |
+
The task-conditional class distribution $p _ { \omega } ( y _ { i } = k | \mathbf { v } _ { \tau } )$ in Eq. (2) is defined through an energy function $E _ { \omega } ( \pmb { \mu } _ { k } ^ { \mathsf { c } } ; \mathbf { v } _ { \tau } ) = \operatorname* { m i n } \left( \{ | | \pmb { \mu } _ { k } ^ { \mathsf { c } } - \mathbf { W } _ { j } \mathbf { v } _ { \tau } | | _ { 2 } ^ { 2 } \} _ { j = 1 } ^ { N } \right)$ with trainable parameters $\boldsymbol { \omega } = \{ \mathbf { W } _ { 1 } , . . . , \mathbf { W } _ { N } \}$ for allowing uniformly sampled classes per task. The conditional distribution $p ( y _ { i } | \mathbf { v } _ { \tau } )$ represents how classes distribute for a given task $\tau$ . The reason for its definition in Eq. (2) is as follows. If it is a Gaussian distribution with $\mathbf { v } _ { \tau }$ (i.e., task embedding) as the mean, $p ( y _ { i } = k | \mathbf { v } _ { \tau } )$ can be interpreted as the density at the representation of the $k$ -th class in this Gaussian distribution, i.e., the density at $\pmb { \mu } _ { k }$ , which is the mean/surrogate embedding of the $k$ -th class. One problem of this Gaussian $p ( y _ { i } | \mathbf { v } _ { \tau } )$ is that different classes, i.e., different $\pmb { \mu } _ { y _ { i } }$ ’s, are not uniformly distributed, contradicting the practice that given a dataset (e.g., images), classes are often uniformly sampled for constituting a task in the empirical studies. Using a uniformly sampled set of classes to fit the Gaussian distribution $p ( y _ { i } | v _ { \tau } )$ will lead to an ill-posed learning problem, as described in Sec. 3.1. To solve it, we introduced $\omega = \{ \mathbf { W } _ { 1 } , . . . , \mathbf { W } _ { N } \}$ in the energy function $E _ { \omega } ( \mu _ { k } ^ { \circ } ; \mathbf { v } _ { \tau } )$ in Eq. (2). $\mathbf { W } _ { j } \in \mathbb { R } ^ { d \times d }$ $( 1 \leq j \leq N )$ ) can be interpreted as projecting $\mathbf { v } _ { \tau }$ to the $j$ -th space spanned by the basis (i.e., columns) of $\mathbf { W } _ { j }$ . There are $N$ different spaces for $j = 1 , . . . , N$ . Thus, the $N$ projected task means $\mathbf { W } _ { 1 } \mathbf { v } _ { \tau } , . . . , \mathbf { W } _ { N } \bar { \mathbf { v } _ { \tau } }$ are in $N$ different spaces. Fitting the energy function $E _ { \omega } ( \mu _ { k } ^ { \circ } ; \mathbf { v } _ { \tau } )$ to $N$ uniformly sampled classes $\mu _ { 1 } ^ { \mathsf { c } } , . . . , \mu _ { N } ^ { \mathsf { c } }$ , which tend to be far from each other because they are uniformly random, tends to learn $\mathbf { W } _ { 1 } , . . . , \mathbf { W } _ { N }$ that project $\mathbf { v } _ { \tau }$ to $N$ far apart spaces that fit each of the $\mu _ { 1 } ^ { \mathsf { c } } , . . . , \mu _ { N } ^ { \mathsf { c } }$ by closeness, due to the min-pooling operation. This mitigates the aforementioned ill-posed learning problem.
|
| 361 |
+
|
| 362 |
+
# C APPENDIX FOR IMPLEMENTATION DETAILS
|
| 363 |
+
|
| 364 |
+
# C.1 THE SETUP OF THE COMPARED MODELS
|
| 365 |
+
|
| 366 |
+
Encoder of Metric-based Meta-Learning. For fairness, for all metric-based methods, including ProtoNet (Snell et al., 2017), MetaOptNet (Lee et al., 2019c), ProtoNet-Aug (Su et al., 2020), FEATS (Ye et al., 2020) and NCA (Laenen & Bertinetto, 2021), following (Tian et al., 2020; Lee et al., 2019c), we apply ResNet-12 as the encoder. ResNet-12 has 4 residual blocks, each has 3 convolutional layers with a kernel size of $3 \times 3$ . ResNet-12 uses dropblock as a regularizer, and its number of filters is (60, 160, 320, 640). For MetaOptNet, following its paper (Lee et al., 2019c), we flattened the output of the last convolutional layer to acquire a 16000-dimensional feature as the image embedding. For other baselines, following (Tian et al., 2020), we used a global averagepooling layer on the top of the last residual block to acquire a 640-dimensional feature as the image embedding.
|
| 367 |
+
|
| 368 |
+
Further Details. Following (Snell et al., 2017), ProtoNet, ProtoNet-Aug, and NCA use Adam optimizer with $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 9$ . We did grid-search for the initial learning rate of the Adam within $\{ 1 e ^ { - 2 } , 1 e ^ { - 3 } , 1 e ^ { - 4 } \}$ , where $1 e ^ { - 3 }$ was selected, which is the same as the official implementation provided by the authors. For FEATS, we chose transformer as the set-to-set function based on the results reported by (Ye et al., 2020). When pre-training the encoder in FEATS, following its paper (Ye et al., 2020), we applied the same setting as ProtoNet, which is to use Adam optimizer with an initial learning rate of $\bar { 1 { e } } ^ { - 3 }$ , $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 9$ . When training its aggregation function, we grid-searched the initial learning rate in $\{ 1 e ^ { - 4 } , 5 e ^ { - 4 } , 1 e ^ { - 5 } \}$ since a larger learning rate leads to invalid results on our datasets. The optimal choice is $1 e ^ { - 4 }$ . For MetaOptNet, following its paper (Lee et al., 2019c), we used SGD with Nesterov momentum of 0.9, an initial learning rate of 0.1 and a scheduler to optimize it, and applied the quadratic programming solver OptNet (Amos & Kolter, 2017) for the SVM solution in it.
|
| 369 |
+
|
| 370 |
+
# C.2 THE DETAILS OF THE SETUP FOR NOVEL TASK DETECTION
|
| 371 |
+
|
| 372 |
+
In the experiments on novel task detection in Sec. 4.1, the number of in-distribution tasks (from the Original domain) in the test set is 4000 (1000 per task cluster) and the number of novel tasks (from the Blur and Pencil domains) in the test set is 8000 (4000 for the Blur and 4000 for the Pencil).
|
| 373 |
+
|
| 374 |
+
# D APPENDIX FOR EXPERIMENTAL RESULTS
|
| 375 |
+
|
| 376 |
+
# D.1 ANALYSIS OF $\sigma$
|
| 377 |
+
|
| 378 |
+
Table 4: Analysis of different $\sigma$
|
| 379 |
+
|
| 380 |
+
<table><tr><td>Setting of σ</td><td>Bird</td><td>Texture</td><td>Aircraft</td><td>Fungi</td></tr><tr><td>0.1</td><td>69.33</td><td>46.92</td><td>75.20</td><td>50.78</td></tr><tr><td>0.5</td><td>70.00</td><td>47.98</td><td>75.38</td><td>52.38</td></tr><tr><td>1.0 (Ours)</td><td>70.12</td><td>47.76</td><td>75.52</td><td>52.06</td></tr><tr><td>10.0</td><td>69.4</td><td>47.28</td><td>75.32</td><td>51.5</td></tr></table>
|
| 381 |
+
|
| 382 |
+
Tabel 4 report the effect of different $\sigma$ on the classification performance (5-way-1-shot classification on Multi-Plain dataset). As shown in the table, although the too low or too high setting of this hyper-parameter will hurt the performance, in general the model is robust toward the setting of $\sigma$ .
|
| 383 |
+
|
| 384 |
+
# D.2 ANALYSIS OF $\bar { \sigma }$
|
| 385 |
+
|
| 386 |
+
Table 5: Analysis of different $\bar { \sigma }$
|
| 387 |
+
|
| 388 |
+
<table><tr><td>Setting of π</td><td>Bird</td><td>Texture</td><td>Aircraft</td><td>Fungi</td></tr><tr><td>0.05</td><td>69.78</td><td>48.36</td><td>74.36</td><td>51.34</td></tr><tr><td>0.1(Ours)</td><td>70.12</td><td>47.76</td><td>75.52</td><td>52.06</td></tr><tr><td>0.2</td><td>70.02</td><td>47.50</td><td>75.30</td><td>51.74</td></tr><tr><td>0.5</td><td>69.02</td><td>46.66</td><td>74.46</td><td>51.00</td></tr></table>
|
| 389 |
+
|
| 390 |
+
Tabel 5 summarize how different $\bar { \sigma }$ influence classification performance (5-way-1-shot classification on Multi-Plain dataset). In general, different settings of $\bar { \sigma }$ will influence the model performance at a marginal level, indicating our model’s robustness toward this hyper-parameter.
|
| 391 |
+
|
| 392 |
+
# D.3 IMPACT OF GMM COMPONENT NUMBER
|
| 393 |
+
|
| 394 |
+
Table 6: Analysis on the number of mixture components
|
| 395 |
+
|
| 396 |
+
<table><tr><td rowspan=1 colspan=1>Number of components r</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>16</td><td rowspan=1 colspan=1>32</td></tr><tr><td rowspan=1 colspan=1>Silhouette score</td><td rowspan=1 colspan=1>47.70</td><td rowspan=1 colspan=1>57.61</td><td rowspan=1 colspan=1>12.76</td><td rowspan=1 colspan=1>7.81</td><td rowspan=1 colspan=1>6.19</td></tr></table>
|
| 397 |
+
|
| 398 |
+
Different choices of the number of mixture components does not significantly influence the model classification performance. However, the clustering quality may vary due to the different numbers of components. Here, we report the Silhouette score (Shahapure & Nicholas, 2020; Sharma et al., 2021) w.r.t. the number in Table 6. From Table 6, we can see that selecting a component number close to the ground-truth component number of the distribution can benefit the clustering quality.
|
| 399 |
+
|
| 400 |
+
# D.4 CLASSIFICATION PERFORMANCE OF THE ABLATION VARIANTS
|
| 401 |
+
|
| 402 |
+
We summarize the classification performance of the two Ablation Variants HTGM w/o GMM and HTGM-Gaussian in Table 7. As we can see, our unique designs improve the novel task detection performance without significantly decreasing the classification performance.
|
| 403 |
+
|
| 404 |
+
Table 7: Ablation study of different variants of our proposed method.
|
| 405 |
+
|
| 406 |
+
<table><tr><td>Ablation Variants</td><td>Bird</td><td>Texture</td><td>Aircraft</td><td>Fungi</td></tr><tr><td>HTGMw/oGMM</td><td>68.86</td><td>48.00</td><td>75.74</td><td>52.28</td></tr><tr><td>HTGM-Gaussian</td><td>69.52</td><td>47.3</td><td>75.38</td><td>51.34</td></tr><tr><td>HTGM</td><td>70.12</td><td>47.76</td><td>75.52</td><td>52.06</td></tr></table>
|
| 407 |
+
|
| 408 |
+
<table><tr><td>Setting</td><td>Model</td><td>Bird</td><td>Texture</td><td>Aircraft</td><td>Fungi</td><td>Average</td></tr><tr><td rowspan="4">5-way-1-shot</td><td>ANIL-MAML ANIL-HSML</td><td>62.64±0.90</td><td>43.86±0.78</td><td>70.03±0.85</td><td>48.34±0.89</td><td>56.22</td></tr><tr><td></td><td>64.33±0.87</td><td>43.77±0.79</td><td>69.71±0.84</td><td>47.75±0.89</td><td>56.39</td></tr><tr><td>ANIL-ARML</td><td>65.98±0.87</td><td>43.57±0.78</td><td>70.28±0.84</td><td>48.48±0.92</td><td>57.08</td></tr><tr><td>HTGM (ours)</td><td>70.12±1.28</td><td>47.76±1.49</td><td>75.52±1.24</td><td>52.06±1.41</td><td>61.37</td></tr><tr><td rowspan="4">5-way-5-shot</td><td>ANIL-MAML</td><td>74.38±0.73</td><td>55.36±0.74</td><td>79.78±0.63</td><td>59.57±0.79</td><td>67.27</td></tr><tr><td>ANIL-HSML</td><td>78.18±0.71</td><td>57.70±0.75</td><td>81.32±0.62</td><td>59.83±0.81</td><td>69.26</td></tr><tr><td>ANIL-ARML</td><td>78.79±0.71</td><td>57.61±0.73</td><td>81.86±0.59</td><td>60.19±0.81</td><td>69.61</td></tr><tr><td>HTGM (ours)</td><td>82.27±0.74</td><td>60.67±0.78</td><td>88.48±0.52</td><td>65.70±0.79</td><td>74.28</td></tr></table>
|
| 409 |
+
|
| 410 |
+
Table 8: More results (accuracy $\pm 9 5 \%$ confidence) of the optimization-based methods.
|
| 411 |
+
|
| 412 |
+
# D.5 ABLATION ANALYSIS OF OPTIMIZATION-BASED METHODS
|
| 413 |
+
|
| 414 |
+
Table 8 summarizes the performance of MAML, HSML and ARML trained in ANIL method (Raghu et al., 2020), i.e., we pre-trained the ResNet-12 by ProtoNet, froze the encoder, and fine-tuned the last fully-connected layers using MAML, HSML and ARML on Plain-Multi dataset. From Table 8, the performance of ANIL-MAML is better than MAML in Table 1, similar to the observation in (Raghu et al., 2020), indicating the effectiveness of ANIL method. However, ANIL-HSML and ANIL-ARML perform similarly to ANIL-MAML, losing their superiority of modeling the mixture distribution of tasks achieved when implemented without ANIL as in Table 1 (up to $5 . 6 \%$ average improvement). This is because the cluster layer in HSML and the graph layer in ARML both affect the embeddings learned through backpropagation, i.e., they were designed for joint training with the encoder. When the encoder is frozen, they cannot work properly. For this reason, to be consistent with the existing researches (Yao et al., 2019a;b) that demonstrated the difference between HSML/ARML and MAML, we used their original designs in Sec. 4. Meanwhile, we observe the proposed HTGM outperforms MAML, HSML, and ARML trained in ANIL method, this is because MAML cannot model the mixture distribution of tasks, while HSML and ARML cannot work properly when trained in ANIL method.
|
| 415 |
+
|
| 416 |
+
D.6 LIMITATIONS OF THE PROPOSED METHOD
|
| 417 |
+
|
| 418 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>5-way-1-shot</td><td rowspan=1 colspan=1>5-way-5-shot</td></tr><tr><td rowspan=1 colspan=1>ProtoNet-AugHTGM</td><td rowspan=1 colspan=1>59.40±0.9361.80±0.95</td><td rowspan=1 colspan=1>74.68±0.4574.55±0.45</td></tr></table>
|
| 419 |
+
|
| 420 |
+
Table 9: Comparison of our proposed method with other models on mini-imagenet dataset.
|
| 421 |
+
|
| 422 |
+
In the case when the task distribution is not a mixture, our model would degenerate to and perform similarly to the general metric-based meta-learning methods, e.g., ProtoNet, which only considers a uni-component distribution. To confirm this, we added an experiment that compares our model with ProtoNet-Aug on Mini-Imagenet (Vinyals et al., 2016), which does not have the same explicit mixture distributions as in the Plain-Multi and Art-Multi datasets in Section 4. The results are summarized in Table 9. From the table, we observe our method performs comparably to ProtoNet, which validates the aforementioned guess. Meanwhile, together with the results in Table 1 and Table 2, the proposed method could be considered as a generalization of the metric-based methods to the mixture of task distributions.
|
md/dev/CQsmMYmlP5T/CQsmMYmlP5T.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/DhmYYrH_M3m/DhmYYrH_M3m.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Trajectory-guided Control Prediction for End-to-end Autonomous Driving: A Simple yet Strong Baseline
|
| 2 |
+
|
| 3 |
+
Penghao Wu∗† Shanghai AI Laboratory
|
| 4 |
+
Shanghai Jiao Tong University
|
| 5 |
+
wupenghaocraig@sjtu.edu.cn
|
| 6 |
+
|
| 7 |
+
Li Chen∗ Shanghai AI Laboratory lichen@pjlab.org.cn
|
| 8 |
+
|
| 9 |
+
Xiaosong Jia∗ Shanghai Jiao Tong University Shanghai AI Laboratory jiaxiaosong@sjtu.edu.cn
|
| 10 |
+
|
| 11 |
+
# Hongyang Li
|
| 12 |
+
|
| 13 |
+
Junchi Yan† Shanghai Jiao Tong University Shanghai AI Laboratory yanjunchi@sjtu.edu.cn
|
| 14 |
+
|
| 15 |
+
Yu Qiao Shanghai AI Laboratory qiaoyu@pjlab.org.cn
|
| 16 |
+
|
| 17 |
+
Shanghai AI Laboratory Shanghai Jiao Tong University lihongyang@pjlab.org.cn
|
| 18 |
+
|
| 19 |
+
# Abstract
|
| 20 |
+
|
| 21 |
+
Current end-to-end autonomous driving methods either run a controller based on a planned trajectory or perform control prediction directly, which have spanned two separately studied lines of research. Seeing their potential mutual benefits to each other, this paper takes the initiative to explore the combination of these two well-developed worlds. Specifically, our integrated approach has two branches for trajectory planning and direct control, respectively. The trajectory branch predicts the future trajectory, while the control branch involves a novel multi-step prediction scheme such that the relationship between current actions and future states can be reasoned. The two branches are connected so that the control branch receives corresponding guidance from the trajectory branch at each time step. The outputs from two branches are then fused to achieve complementary advantages. Our results are evaluated in the closed-loop urban driving setting with challenging scenarios using the CARLA simulator. Even with a monocular camera input, the proposed approach ranks first on the official CARLA Leaderboard, outperforming other complex candidates with multiple sensors or fusion mechanisms by a large margin. The source code is publicly available at https://github.com/OpenPerceptionX/TCP.
|
| 22 |
+
|
| 23 |
+
# 1 Introduction
|
| 24 |
+
|
| 25 |
+
End-to-end autonomous driving methods, which directly map raw sensor data to a planned trajectory or low-level control actions, show the virtue of simplicity, conceptually avoiding the cascading error of complex modular design and heavy hand-crafted rules. The output prediction of the model for end-toend autonomous driving generally falls into two forms: trajectory/waypoints [48, 4, 11, 46, 15, 29, 10] and direct control actions [17, 39, 18, 42, 12, 60, 9]. However, there is still no clear conclusion as to which of these two forms is better for all circumstances or certain scenarios.
|
| 26 |
+
|
| 27 |
+
Different from control predictions that could be directly applied to the vehicle, for methods that plan trajectory, additional controllers such as PID controllers are usually needed as a subsequent step to convert the planned trajectory into control signals. One attractive and potential supremacy of trajectory-based prediction is that it actually considers a relatively longer time horizon into the future and could be further combined with other modules (e.g., multi-agent trajectory prediction [59, 10], semantic or occupancy prediction modules [15, 8, 25]) to reduce possible collisions. However, turning the trajectory into control actions so that the vehicle could follow the planned trajectory is not trivial [57]. The industry usually adopts sophisticated control algorithms such as model predictive control to achieve reliable trajectory-following performance [5, 21]. Simple PID controllers may perform worse in situations such as taking a big turn or starting at the red light due to the inertial problem of end-to-end models [29]. For control-based methods, the control signals are directly optimized. Nevertheless, their focus on the current step may cause deferred reactions to avoid potential collisions with other moving agents. The independence between the control predictions of different steps also makes the actions of the vehicle more unstable or discontinuous. Fig. 1 shows two typical cases where two paradigms fail respectively. How to combine these two forms of prediction model as well as their outputs is an interesting yet relatively rarely studied area, which motivates this work.
|
| 28 |
+
|
| 29 |
+

|
| 30 |
+
Figure 1: Typical failure cases of two prediction paradigms. Red dots indicate the trajectory prediction, blue dots are the actual path following the red trajectory with PID controllers, and green dots denote the actual path from control-based method. (a) trajectory-based methods may struggle for big turns. (b) control-based methods may have a reaction latency and suffer from abrupt obstacles due to focusing on current time step only. These observations motivate us to propose a unified framework to combine these two worlds for mutual benefits.
|
| 31 |
+
|
| 32 |
+
One straightforward (but in fact rarely studied in literature) idea is to train a control prediction model and a trajectory planning model separately, and combine their ultimate outputs directly. It can be viewed as an ensemble of two different models. However, such a naive approach not only doubles the size of the model, but also ignores possible useful correlations between these two forms. To this end, we introduce the TCP (Trajectory-guided Control Prediction) framework, packing these two branches into a unified framework. It can be viewed as a multi-task learning (MTL) [7, 2] framework where a shared backbone extracts common features with decreased computational complexity as well as the increased ability of generalization due to the close relationship between the two tasks [38, 34, 13]. Furthermore, to address the drawbacks of current control prediction methods, we delicately devise a novel multi-step control branch and a trajectory-guided control prediction scheme.
|
| 33 |
+
|
| 34 |
+
While trajectory planning considers several steps into the future, directly learning the control in a behavior cloning fashion [44, 41, 17, 18, 11] often focuses on the current time step only, given prior on each state-action pair as independent and identical distributed (IID). This assumption is not accurate and may hamper the long-term performance since the driving task is a sequential decisionmaking problem. To alleviate the problem, we propose to predict multi-step control actions into the future. However, the multi-step control process needs interactions with the environment. Thus we formulate a temporal module to learn the forward process and interactions between the ego agent and the environment. A temporal module implemented with GRU [16] progressively deals with the feature representation for each time step, implicitly taking into account the dynamic motion of agents, interaction among them and dynamic environment information such as the changing of traffic lights.
|
| 35 |
+
|
| 36 |
+
Additionally, to generate accurate control signals in the multi-step prediction scheme, the model should retrieve proper location information from current sensor input for different future time steps. For example, an agent may pay more attention to nearby regions for a few early future time steps and far away regions for the remote ones. Considering that the knowledge has already been partly encoded in the trajectory branch, we adopt the attention mechanism to locate those critical and helpful areas in the long-term trajectory prediction branch, and guide the control prediction branch to pay attention to them at each future step in a corresponding way. As a result, our model is capable of reasoning about how to optimize current control prediction so that the future states are similar to those from the expert when the predicted control actions are applied.
|
| 37 |
+
|
| 38 |
+
With the predicted trajectory and control signals from two branches, we propose a situation based fusion scheme to adaptively combine these two forms in a self-ensemble way to form the ultimate output according to the experiments results and prior knowledge. It combines the best of these two forms, which further boosts the performance under different scenarios.
|
| 39 |
+
|
| 40 |
+
TCP has shown superior performance when being validated in the CARLA driving simulator [20]. Our method, which only uses a monocular camera, achieves a 75.137 driving score and ranks 1st on the public CARLA Leaderboard [1], even surpassing prior state-of-the-art methods using multiple cameras and a LiDAR by 13.291 points. The main contributions of this paper include:
|
| 41 |
+
|
| 42 |
+
• We examine two dominant paradigms for end-to-end autonomous driving: trajectory planning and direct control, and propose to combine them in an integrated learning pipeline. To our knowledge, this is the first time that such two branches are jointly learned and fused for prediction.
|
| 43 |
+
• A multi-step control prediction branch with a temporal module and trajectory-guided attention is devised to enable temporal reasoning. To combine the best of two branches, we design a situation based scheme to fuse the two outputs.
|
| 44 |
+
• As a simple yet strong baseline, our method with only a monocular camera as input achieves new state-of-the-art on the CARLA Leaderboard with many competitors using multiple sensors. We conduct thorough ablation studies to verify the effectiveness of our approach.
|
| 45 |
+
|
| 46 |
+
# 2 Related Work
|
| 47 |
+
|
| 48 |
+
# 2.1 End-to-end Autonomous Driving
|
| 49 |
+
|
| 50 |
+
Learning-based end-to-end autonomous driving has emerged as an active research topic in recent years. Studies usually fall into two categories: reinforcement learning (RL) and imitation learning. RL is a promising way to address the problem of being more robust to the distribution shifts of datasets. Liang et al. [39] use DDPG to train a policy which is pre-trained in a supervised way. Kendall et al. [30] train their deep RL algorithm onboard to efficiently learn to drive a real-world vehicle. The perception task is decoupled out of the online RL process in [50, 9, 62]. The model-based method WoR [12] assumes world on rails and uses policy distillation to realize powerful performance.
|
| 51 |
+
|
| 52 |
+
Imitation learning (IL), especially behavior cloning, collects recorded data for models to mimic with high data efficiency. The expert data typically has two forms, trajectories and control actions. Zeng et al. [58] train a cost volume to generate the planning route, while [49, 8, 25] explicitly design safety and comfort costs based on semantic occupancy maps to select the best one in the expert trajectory sets. Zhang et al. [59] predict trajectories of surrounding vehicles with labeled BEV map. LBC [11] and NEAT [15] decode waypoints from a dense heatmap or offset map. These approaches aforementioned all utilize a relatively dense representation to obtain results which increases model complexity. Transfuser and its variants [46, 29] adopt a simple GRU to auto-regress waypoints. LAV [10] adopts a temporal GRU module to further refine the trajectory. They unanimously achieve impressive performance on the CARLA leaderboard, motivating us to adapt the auto-regression scheme as well in our design. On the other hand, all trajectory-based methods use PID controllers to get the ultimate actions, which may cause inferior effects in complicated scenarios.
|
| 53 |
+
|
| 54 |
+
Another genre to predict control actions directly is proposed in [44, 40, 3, 54]. CIL [17] adds a measurement encoder and multiple branches for different high level commands with the image encoder. CILRS [18] is proposed afterwards and further introduces a speed prediction head. They stand as classic baselines for IL in the CARLA driving simulator. Diverse optimized approaches are presented based on them, such as multi-modal inputs [22, 53], multi-task learning [56, 37, 24, 27, 31, 26, 63], dataset aggregation [45] and knowledge distillation [61, 60]. However, the compact control-based methods often have higher vehicles collision rates, remaining an interesting domain to explore. Similar work exists in other related domains such as robotic navigation as well. [43] learns a controller after a local trajectory planner to improve the overall navigation behavior.
|
| 55 |
+
|
| 56 |
+
# 2.2 Multi-task and Ensemble Learning for Autonomous Driving
|
| 57 |
+
|
| 58 |
+
Multi-task learning is a popular approach to train several related tasks simultaneously to help each other and improve generalization [7, 2]. Combinations of various autonomous driving tasks such as object detection, lane detection, semantic segmentation, depth estimation, etc. have been proved to be capable of achieving incredible performance [38, 14, 47, 34, 52, 13]. MTL is also suitable in the end-to-end problem since it is observed the performance of a direct mapping from an image to control signals is limited. [56] adds a speed prediction task similar to CIL [17] and [63] separates the lateral and longitudinal controls as two tasks. LAV [10] trains an extra scene mapping network, and [24, 27, 29] additionally predict optical flow or dense depth. Our idea of training trajectory and control simultaneously is closely related to FASNet [31]. FASNet predicts future positions of the ego agent as an auxiliary task and adds a kinematic loss considering the relation between control and locations. However, the constrain is based on a constant velocity model which neglects the important throttle and brake, and it does not work at the inference time. On the other hand, our TCP framework has feature interactions at an earlier stage to fully explore their potential mutual benefits.
|
| 59 |
+
|
| 60 |
+
Ensembles of models have long been utilized to improve the performance in computer vision [19, 33, 35, 51, 55, 45]. Besides the normal combination of models, two classic ensemble learning methods are particularly preferred in the autonomous driving regime. One is the Test-Time Augmentation (TTA), which is of great help to the 3D object detection task with LiDAR [6, 36]. Another one is the fusion of experts [28] where experts are trained on a subset of the input space and a gating network is trained to provide the fusion weights. LSD [42] and MoDE [32] divide a dataset into sub-scenarios to get different sub-policies for end-to-end autonomous driving. These traditional ensemble approaches combine models of the same structure while our approach tries to combine two different representations. Also, the multiple experts design increases the complexity of the training strategy and we seek to have a simpler situation based fusion scheme to boost the performance.
|
| 61 |
+
|
| 62 |
+
# 3 Trajectory-guided Control Prediction
|
| 63 |
+
|
| 64 |
+
# 3.1 Problem Setting
|
| 65 |
+
|
| 66 |
+
Problem formulation. Given the state x comprised of the sensor signal i, the speed of the vehicle $v$ , and the high level navigation information $\mathbf { g }$ including a discrete navigation command and the coordinates of navigation target provided by the global planner, the end-to-end model needs to output control signals a comprised of longitudinal control signals throttle $\in [ 0 , 1 ]$ and brake $\in [ 0 , 1 ]$ , and the lateral control signal steer $\in [ - 1 , 1 ]$ .
|
| 67 |
+
|
| 68 |
+
Conventional methods tackle this problem with either a trajectory-output or a control-output only model. However, TCP combines both of them as two branches: a trajectory branch which predicts the planned trajectory and a control branch which is guided by the trajectory one and outputs both current and multi-step control signals into the future. Both branches are trained in a supervised manner. Consider an expert which directly outputs the control signals at each step, supervising the predicted trajectory with the ground truth trajectory makes it not strictly satisfy the setting of behavior cloning in imitation learning. The ground truth trajectory indeed involves future expert actions and future states about the environment, so we formulate it as a trajectory planning task with ground truth trajectory as supervision for our trajectory branch. As for the control branch, training a control model which makes current control prediction supervised by the expert control is just behavior cloning in imitation learning, and it can be formulated as:
|
| 69 |
+
|
| 70 |
+
$$
|
| 71 |
+
\arg \operatorname* { m i n } _ { \theta } \mathbb { E } _ { ( \mathbf { x } , \mathbf { a } ^ { * } ) \sim \mathrm { D } } [ \mathcal { L } ( \mathbf { a } ^ { * } , \pi _ { \theta } ( \mathbf { x } ) ) ] ,
|
| 72 |
+
$$
|
| 73 |
+
|
| 74 |
+
where $D = \{ ( { \bf x } , { \bf a } ^ { * } ) \}$ is a dataset comprised of state-action pairs collected from the expert. $\pi _ { \theta }$ denotes the policy of the control branch, and $\mathcal { L }$ is the loss measuring how close the action from the expert and the action from our model is. The expert collects the dataset by controlling the vehicle and interacting with the world. Each collected route is a trajectory $\xi = ( { \bf x } _ { 0 } , { \bf a } _ { 0 } ^ { * } , { \bf x } _ { 1 } , { \bf a } _ { 1 } ^ { * } , \cdot \cdot \ , { \bf x } _ { \mathrm { T } } )$ as a sequence of state action pairs $\{ ( \mathbf { x } _ { \mathrm { i } } , \mathbf { a } _ { \mathrm { i } } ^ { * } ) \} _ { \mathrm { i = 0 } } ^ { \mathrm { T } }$ , which is then added into the whole dataset $D$ .
|
| 75 |
+
|
| 76 |
+
Expert demonstration. Here we choose Roach [60] as the expert. Roach is a simple model trained by RL with privileged information, including roads, lanes, routes, vehicles, pedestrians, traffic lights, and stops, all being rendered into a 2D BEV image. Such a learning-based expert can transfer more information besides the direct supervision signals compared with an expert made by hand-crafted rules. Specifically, we have a feature loss which forces the latent features before the final output head from the student model to be similar to that of the expert. A value loss is also added as an auxiliary task for the student model to predict an expected return.
|
| 77 |
+
|
| 78 |
+

|
| 79 |
+
Figure 2: Overview of Trajectory-guided Control Prediction (TCP). The encoded features are shared by the trajectory and multi-step control branch. The trajectory branch provides per-step guidance for multi-step control prediction. Outputs from two branches are combined according to our situation based fusion scheme to generate the ultimate control actions.
|
| 80 |
+
|
| 81 |
+
# 3.2 Architecture Design
|
| 82 |
+
|
| 83 |
+
Overview. As illustrated in Fig. 2, the whole architecture is comprised of an input encoding stage and two subsequent branches. The input image i goes through a CNN based image encoder, such as ResNet [23], to generate a feature map $\mathbf { F }$ . In the meantime, the navigation information $\mathbf { g }$ is concatenated with the current speed $v$ to form the measurement input m, then an MLP based measurement encoder takes m as its input and outputs the measurement feature $\mathbf { j } _ { \mathrm { { m } } }$ . The encoded features are then shared by two branches for subsequent trajectory and control predictions. Specifically, the control branch is a novel multi-step prediction design with guidance from the trajectory one, which will be illustrated in detail in the following sections. Finally, a situation based fusion scheme is adopted to combine the best of the two output paradigms. We will go over each part in detail below.
|
| 84 |
+
|
| 85 |
+
# 3.2.1 Trajectory planning branch
|
| 86 |
+
|
| 87 |
+
Different from control prediction which directly predicts control actions, the trajectory planning branch first generates a planned trajectory comprised of waypoints at $K$ steps for the agent to follow, and then the trajectory is processed by low-level controllers to get the final control actions. With the shared feature from the input encoder, the image feature map $\mathbf { F }$ is average pooled and concatenated with the measurement feature $\mathbf { j } _ { \mathrm { { m } } }$ to form $\mathbf { j } ^ { \mathrm { t r a j } }$ . Inspired by [46], we feed $\mathbf { \hat { j } } ^ { \mathrm { t r a j } }$ into a GRU [16] to auto-regressively obtain future waypoints one by one to form the planned trajectory altogether.
|
| 88 |
+
|
| 89 |
+
We have two PID controllers for longitudinal and lateral control respectively. With the planned trajectory, we first calculate the vectors between consecutive waypoints. The magnitudes of these vectors represent the desired speed and are sent to the longitudinal controller to generate throttle and brake control actions, and the orientations are sent to the lateral controller to get the steer action.
|
| 90 |
+
|
| 91 |
+
# 3.2.2 Multi-step control prediction branch
|
| 92 |
+
|
| 93 |
+
As discussed in Sec. 3.1, for a control model predicting current control actions based on current input only, the supervised training is just behavior cloning, which relies on the independent and identically distributed (IID) assumption. This assumption apparently does not hold because of the distribution shifts in test cases, since the closed-loop tests require sequential decision making where the historical actions will affect the future states and actions. Instead of modeling it as a Markov Decision Process (MDP) and resorting to reinforcement learning, here we devise a simple way to mitigate the problem by predicting multi-step control into the future.
|
| 94 |
+
|
| 95 |
+
Given the current state $\mathbf { x } _ { \mathrm { t } }$ , now our multi-step control prediction branch outputs multiple actions: $\pi _ { \theta _ { m u l t i } } = ( \mathbf { a } _ { \mathrm { t } } , \mathbf { a } _ { \mathrm { t + 1 } } , \cdot \cdot \cdot , \mathbf { a } _ { \mathrm { t + K } } )$ . However, it is difficult to predict future control actions since we only have sensor inputs at the current time step. Towards this problem, we devise a temporal module to implicitly carry out the changing and interaction process of the environment and our agent. It is supposed to provide mainly dynamic information about the environment and the status of the agent itself, such as the motion of other objects, the changing of traffic lights, and the status of the ego agent. Meanwhile, to improve the ability of incorporating critical static information (e.g., curbs and lanes) and boost the spatial consistency of two branches, we propose to use the trajectory branch to guide the control counterpart to attend to proper regions of the input image at each future time step.
|
| 96 |
+
|
| 97 |
+
Temporal module. Our temporal module is implemented with a GRU for better consistency with the trajectory branch. At step $t$ $( 0 \leq t \leq K - 1 )$ , the input for the temporal module is the concatenation of the current feature $\mathbf { j } _ { \mathrm { t } } ^ { \mathrm { c t l } }$ (more construction details in the next section) and current predicted action $\mathbf { a } _ { \mathrm { t } }$ , which is a compact representation about the current states of the environment and the agent itself. The temporal module is supposed to reason about the dynamic changing process based on current feature vector and the predicted action. Then the updated hidden state $\bar { \mathbf { h } } _ { \mathrm { t + 1 } } ^ { \mathrm { c t l } }$ will contain dynamic information about the environment and the updated status of the agent at time step $t + 1$ . To some extent, the temporal module acts as a coarse simulator with the whole environment and the agent being abstracted as a feature vector. It then simulates the interaction between the environment and the agent based on current prediction of actions.
|
| 98 |
+
|
| 99 |
+
Trajectory-guided attention. With the sensor input at current step only, it is hard to pick out desirable regions where the model should focus on at future steps. However, the location of the ego agent contains important cues about how to find those regions containing critical static information for control prediction at each step.
|
| 100 |
+
|
| 101 |
+
Therefore, we seek help from the trajectory planning branch to get information about the possible location of our agent at that corresponding step. As shown in Fig. 3, TCP implements this by learning an attention map to extract important information from the encoded feature map. The interaction between two branches enhances the consistency of these two strongly related output paradigms and further elaborates the multi-task spirit. Specifically, with the 2D feature map extracted by the image encoder $\mathbf { F }$ at time step $t \left( 1 \leq t \leq K \right)$ , we calculate an attention map $\mathbf { w } _ { \mathrm { t } } \in \mathbb { R } ^ { 1 \times \mathrm { H } \times \mathrm { W } }$ using the corresponding hidden states from the control branch and the trajectory branch:
|
| 102 |
+
|
| 103 |
+

|
| 104 |
+
Figure 3: Detailed trajectory guiding process. For predictions at time step $t$ , the hidden states from the waypoint GRU and the temporal module are combined to learn an attention weight map to re-aggregate the 2D image feature map for control prediction.
|
| 105 |
+
|
| 106 |
+
$$
|
| 107 |
+
\mathbf { w } _ { \mathrm { t } } = \mathrm { M L P } ( \mathrm { C o n c a t } [ \mathbf { h } _ { \mathrm { t } } ^ { \mathrm { t r a j } } , \mathbf { h } _ { \mathrm { t } } ^ { \mathrm { c t l } } ] ) .
|
| 108 |
+
$$
|
| 109 |
+
|
| 110 |
+
The attention map $\mathbf { w } _ { \mathrm { t } } \in \mathbb { R } ^ { 1 \times \mathrm { H } \times \mathrm { W } }$ is adopted to aggregate the feature map $\mathbf { F }$ for this step. We then combine the attended feature map with $\mathbf { h } _ { \mathrm { t } } ^ { \mathrm { c t l } }$ to form the informative representation feature $\mathbf { j } _ { \mathrm { t } } ^ { \mathrm { c t l } }$ containing both static and dynamic information about the environment and the ego agent. The process can be described as follows:
|
| 111 |
+
|
| 112 |
+
$$
|
| 113 |
+
\mathbf { j } _ { \mathrm { t } } ^ { \mathrm { c t l } } = \mathrm { M L P } ( \mathrm { C o n c a t } [ \mathrm { S u m } ( \mathrm { S o f t m a x } ( \mathbf { w } _ { \mathrm { t } } ) \odot \mathbf { F } ) , \mathbf { h } _ { \mathrm { t } } ^ { \mathrm { c t l } } ] ) .
|
| 114 |
+
$$
|
| 115 |
+
|
| 116 |
+
The informative representation feature $\mathbf { j } _ { \mathrm { t } } ^ { \mathrm { c t l } }$ is fed into a policy head which is shared among all time steps to predict the corresponding control action $\mathbf { a } _ { \mathrm { t } }$ . Note that for the initial step, we only use the measurement feature to calculate the initial attention map and combine the attended image feature with the measurement feature to form the initial feature vector $\mathbf { j } _ { 0 } ^ { \mathrm { c t l } }$ . To guarantee the feature $\mathbf { j } _ { \mathrm { t } } ^ { \mathrm { c t l } }$ does describe the state at that step and contain the important information for control prediction, we add a feature loss at each step to make $\mathbf { j } _ { \mathrm { t } } ^ { \mathrm { c t l } }$ close to the feature of the expert as well.
|
| 117 |
+
|
| 118 |
+
To this end, our TCP framework endows the model with the reasoning ability along a short time horizon. It emphasizes how to make current control prediction close to the one from the expert. Furthermore, it takes into account what current control prediction can make the environment states and status of ego agent in future time steps similar to the ones from the expert.
|
| 119 |
+
|
| 120 |
+
# 3.3 Loss Design
|
| 121 |
+
|
| 122 |
+
Our loss contains trajectory planning loss $\mathcal { L } _ { t r a j }$ , control prediction $\mathcal { L } _ { c t l }$ , and auxiliary loss $\mathcal { L } _ { a u x }$
|
| 123 |
+
|
| 124 |
+
For the trajectory planning branch, the loss $\mathcal { L } _ { t r a j }$ can be expressed as:
|
| 125 |
+
|
| 126 |
+
$$
|
| 127 |
+
\mathcal { L } _ { t r a j } = \sum _ { t = 1 } ^ { K } \| \mathbf { w p } _ { \mathrm { t } } - \mathbf { w } \mathbf { \hat { p } } _ { \mathrm { t } } \| _ { 1 } + \lambda _ { \mathrm { F } } \cdot \mathcal { L } _ { \mathrm { F } } \left( \mathbf { j } _ { 0 } ^ { \mathrm { t r a j } } , \mathbf { j } _ { 0 } ^ { \mathrm { E x p e r t } } \right) ,
|
| 128 |
+
$$
|
| 129 |
+
|
| 130 |
+
where $\mathbf { w p } _ { \mathrm { t } } , \mathbf { w } \mathbf { \hat { p } _ { \mathrm { t } } }$ are the predicted and ground truth waypoint at the $t ^ { t h }$ step respectively. $\mathcal { L } _ { F }$ indicates the feature loss measuring the $L _ { 2 }$ distance between $\mathbf { j } _ { 0 } ^ { \mathrm { t r a j } }$ j and the feature jEx0 pert from the expert at the current step as an additional supervision signal [60]. $\lambda _ { F }$ is a tunable loss weight.
|
| 131 |
+
|
| 132 |
+
For the control prediction branch, we model the action as a beta distribution. The loss $\mathcal { L } _ { c t l }$ is:
|
| 133 |
+
|
| 134 |
+
$$
|
| 135 |
+
\begin{array} { r l r } { { \mathcal { L } _ { c t l } = \mathbf { K } \mathbf { L } ( \mathrm { B e t a } ( \mathbf { a } _ { 0 } ) | | \mathrm { B e t a } ( \hat { \mathbf { a } } _ { 0 } ) ) + \frac { 1 } { K } \sum _ { t = 1 } ^ { K } \mathbf { K } \mathbf { L } ( \mathrm { B e t a } ( \mathbf { a } _ { \mathrm { t } } ) | | \mathrm { B e t a } ( \hat { \mathbf { a } } _ { \mathrm { t } } ) ) } } \\ & { } & { + \lambda _ { F } \cdot \mathcal { L } _ { F } ( \mathbf { j } _ { 0 } ^ { \mathrm { c t l } } , \mathbf { j } _ { 0 } ^ { \mathrm { E x p e r t } } ) + \frac { 1 } { K } \sum _ { t = 1 } ^ { K } \mathcal { L } _ { F } ( \mathbf { j } _ { \mathrm { t } } ^ { \mathrm { c t l } } , \mathbf { j } _ { \mathrm { t } } ^ { \mathrm { E x p e r t } } ) , } \end{array}
|
| 136 |
+
$$
|
| 137 |
+
|
| 138 |
+
where $\mathrm { B e t a } ( \mathbf { a } )$ denotes the beta distribution represented by the corresponding predicted distribution parameters and KL-divergence is used to measure the similarity between the predicted control distribution and the one from expert, i.e., Beta(aˆ). Feature loss is applied here as well. Note that all losses for future time steps $( t \geq 1 )$ ) are averaged and then added to the loss for the current time step $( t = 0$ ), since the action executed immediately should be our key target to optimize.
|
| 139 |
+
|
| 140 |
+
To help the agent better estimate its current state, we add a speed prediction head to predict current speed $s$ from the image feature and a value prediction head to predict the expected return estimated by the expert, similarly as in [60]. We take the $L _ { 1 }$ loss for the speed prediction and $L _ { 2 }$ loss for the value prediction, denoting their weighted sum as $\mathcal { L } _ { a u x }$ .
|
| 141 |
+
|
| 142 |
+
The overall loss is as follows, as weighted by $\lambda _ { t r a j } , \lambda _ { c t l } , \lambda _ { a u x }$ :
|
| 143 |
+
|
| 144 |
+
$$
|
| 145 |
+
\mathcal { L } = \lambda _ { t r a j } \cdot \mathcal { L } _ { t r a j } + \lambda _ { c t l } \cdot \mathcal { L } _ { c t l } + \lambda _ { a u x } \cdot \mathcal { L } _ { a u x } .
|
| 146 |
+
$$
|
| 147 |
+
|
| 148 |
+
# 3.4 Output Fusion
|
| 149 |
+
|
| 150 |
+
We have two forms of output representations from our TCP framework: the planned trajectory and the predicted control. To further combine their advantages, we devise a situation-based fusion strategy as depicted in Algorithm 1. Specifically, denote $\alpha$ as a combination weight whose value is between 0 to 0.5, in a certain situation where one representation is more suitable according to our prior belief, we combine the results from trajectory and control predictions by taking average with weight $\alpha$ so that the more suitable one takes up more weight $( 1 - \alpha )$ . Note that the combination weight $\alpha$ indeed does not need to be
|
| 151 |
+
|
| 152 |
+
<table><tr><td>Algorithm1:Situation based fusion scheme to com- bine the two output paradigms</td></tr><tr><td>Input: sensory input i, speed of the ego vehicle v, high level navigation information g.</td></tr><tr><td>Hyper parameters:combination weight α E [0,0.5] Output: final control signals a</td></tr><tr><td>{wpt}=o,actl ← TCP(i,u, g) atraj ←Low-level Controller ({wpt}ε=0) a</td></tr><tr><td>Getcurrent situation if situationis trajectory specialized then</td></tr><tr><td>a←α×act1+(1-α)×atraj</td></tr><tr><td></td></tr><tr><td>else a←α×atraj+(1-α) ×actl</td></tr></table>
|
| 153 |
+
|
| 154 |
+
a constant or symmetric, which means we can set it to different values under different situations or different for specific control signals. In our experiment, we choose the situation according to whether the ego vehicle is turning, implying that if it is turning, the situation is control specialized otherwise trajectory specialized.
|
| 155 |
+
|
| 156 |
+
# 4 Experiments
|
| 157 |
+
|
| 158 |
+
# 4.1 Experimental Setup
|
| 159 |
+
|
| 160 |
+
Task & Evaluation metrics. Our method is validated and tested in the CARLA driving simulator [20]. Given a route defined by a sequence of sparse navigation points together with high level commands (straight, turn left/right, lane changing, and lane following), the closed-loop driving task requires the autonomous agent to drive towards the destination point. It is designed to simulate realistic traffic situations and includes different challenging scenarios such as obstacle avoidance, crossing an unsignalized intersection, and sudden control loss. There are three major metrics: Driving Score, Route Completion, and Infraction Score. Route Completion is the percentage of the route completed by the autonomous agent. Infraction Score measures the number of infractions made along the route, with pedestrians, vehicles, road layouts, red lights, and etc. Driving Score is the main metric which is the product of Route Completion and Infraction Score.
|
| 161 |
+
|
| 162 |
+
Table 1: Evaluation on the public CARLA Leaderboard [1] (accessed in May 2022). Our method TCP and TCP-Ens achieve a driving score of 69.714 and 75.137 respectively with only a monocular camera. More detailed infraction statistics can be found in the Supplementary.
|
| 163 |
+
|
| 164 |
+
<table><tr><td rowspan="2">Rank</td><td rowspan="2">Method</td><td colspan="2">Sensor Inputs</td><td colspan="3">Key Metrics ↑</td></tr><tr><td>#Cameras</td><td>LiDAR</td><td>Driving Score</td><td>Route Completion</td><td>Infraction Score</td></tr><tr><td>1</td><td>TCP-Ens (ours)</td><td>1</td><td>X</td><td>75.137</td><td>85.629</td><td>0.873</td></tr><tr><td>1</td><td>TCP (ours)</td><td>1</td><td>X</td><td>69.714</td><td>82.962</td><td>0.851</td></tr><tr><td>1</td><td>TCP-SB (ours)</td><td>1</td><td>X</td><td>68.695</td><td>82.957</td><td>0.833</td></tr><tr><td>2</td><td>LAV [10]</td><td>4</td><td>√</td><td>61.846</td><td>94.459</td><td>0.640</td></tr><tr><td>3</td><td>Transfuser</td><td>3</td><td>√</td><td>61.181</td><td>86.694</td><td>0.714</td></tr><tr><td>4</td><td>Latent Transfuser</td><td>3</td><td></td><td>45.029</td><td>75.366</td><td>0.618</td></tr><tr><td>5</td><td>GRIAD [9]</td><td>3</td><td>xx/</td><td>36.787</td><td>61.855</td><td>0.597</td></tr><tr><td>6</td><td>Transfuser+ [29]</td><td>4</td><td></td><td>34.577</td><td>69.841</td><td>0.562</td></tr><tr><td>7</td><td>WoR[12]</td><td>4</td><td>X</td><td>31.370</td><td>57.647</td><td>0.557</td></tr><tr><td>8</td><td>MaRLn [50]</td><td>1</td><td>X</td><td>24.980</td><td>46.968</td><td>0.518</td></tr><tr><td>9</td><td>NEAT[15]</td><td>3</td><td>X</td><td>21.832</td><td>41.707</td><td>0.650</td></tr></table>
|
| 165 |
+
|
| 166 |
+
Table 2: Comparison between the control and trajectory only model in terms of infractions frequency. TurnRatio means the corresponding ratio of happening during turning.
|
| 167 |
+
|
| 168 |
+
<table><tr><td rowspan="2">Model</td><td rowspan="2">Driving Score</td><td colspan="2">Collisions vehicles</td><td colspan="2">Collisions layout</td><td colspan="2">Off-road infractions</td><td colspan="2">Agent blocked</td></tr><tr><td>#/km↓</td><td>TurnRatio</td><td>#/km↓</td><td>TurnRatio</td><td>#/km↓</td><td>TurnRatio</td><td>#/km↓</td><td>TurnRatio</td></tr><tr><td>Control-Only</td><td>32.45±2.23</td><td>1.25</td><td>50.90%</td><td>0.23</td><td>10.00%</td><td>0.59</td><td>46.15%</td><td>0.41</td><td>50.00%</td></tr><tr><td>Trajectory-Only</td><td>28.29±3.03</td><td>0.85</td><td>38.70%</td><td>0.77</td><td>64.20%</td><td>0.74</td><td>62.90%</td><td>0.77</td><td>64.20%</td></tr></table>
|
| 169 |
+
|
| 170 |
+
Dataset. We use randomly generated routes under random weather conditions to collect 420K data in the 8 public towns offered by the CARLA simulator. Similar to [10], we train TCP on 189K of data in 4 out of 8 towns (Town01, Town03, Town04, and Town06) for ablations and train with all 420K data for our online leaderboard submission.
|
| 171 |
+
|
| 172 |
+
# 4.2 State-of-the-art Comparison
|
| 173 |
+
|
| 174 |
+
Table 1 shows the result of the comparison between our method and the top 8 entries on the public CARLA Leaderboard [1]. We report the results of TCP and two variants. TCP-SB replaces shared encoders of TCP with two separate ones for two branches, and TCP-Ens is the ensemble of TCP and TCP-SB. Our method TCP-Ens ranks first on the leaderboard with a 75.137 driving score and highest infraction score, and TCP alone also surpasses prior methods. Note that our method only uses a monocular camera while the top 2-4 methods all use multiple cameras and a LiDAR. Our driving score is 50.157 higher than the second-best monocular camera method, MaRLn [50]. Our route completion is slightly inferior to the LiDAR candidates - one reason is that methods using LiDAR may have a better object detection ability. Based on the detection results, they usually adopt a crawling strategy, indicating that the vehicle would move slowly when it has stopped for a long time and there are no obstacles ahead. As described in [29], this could alleviate ego vehicle’s blocking problems to boost the route completion performance.
|
| 175 |
+
|
| 176 |
+

|
| 177 |
+
Figure 4: The trajectory-guided attention maps in two cases. In each case (row), from the left to right we show that the input image with the predicted trajectory (the first waypoint is projected out of the image), the predicted trajectory in the top-down view, the attention map $\mathbf { w } _ { 1 }$ , the attention map $\mathbf { w } _ { 3 }$ .
|
| 178 |
+
|
| 179 |
+
Table 3: Ablative study on the effectiveness of different components design of our model.
|
| 180 |
+
|
| 181 |
+
<table><tr><td>Exp.</td><td>Driving Score</td><td>Route Completion</td><td>Infraction Score</td></tr><tr><td>Control</td><td>32.45±2.23</td><td>76.54±3.22</td><td>0.45±0.03</td></tr><tr><td>+ traj-task</td><td>34.98±1.96</td><td>81.32±5.50</td><td>0.49±0.05</td></tr><tr><td>+ temporal</td><td>42.87±4.77</td><td>87.51±3.63</td><td>0.49±0.07</td></tr><tr><td>+ traj-attn</td><td>46.08±3.47</td><td>84.95±1.84</td><td>0.56±0.03</td></tr><tr><td>+ fusion</td><td>57.01±1.88</td><td>85.27±1.20</td><td>0.67±0.01</td></tr></table>
|
| 182 |
+
|
| 183 |
+
Table 4: Comparison between MTL and ensemble methods ( $\alpha$ is 0.3 for all experiments).
|
| 184 |
+
|
| 185 |
+
<table><tr><td>Exp.</td><td>Driving Score</td><td>#Param.</td><td>FLOPs</td><td>FPS</td></tr><tr><td>Ensemble</td><td>45.03±1.28</td><td>46.81M</td><td>17.07G</td><td>69.47</td></tr><tr><td>MTL</td><td>48.27±0.58</td><td>23.58M</td><td>8.54G</td><td>133.30</td></tr><tr><td>TCP-SB</td><td>52.46±4.66</td><td>47.26M</td><td>17.07G</td><td>69.35</td></tr><tr><td>TCP</td><td>57.01±1.88</td><td>25.77M</td><td>8.54G</td><td>125.71</td></tr><tr><td>TCP-Ens</td><td>59.09±3.66</td><td>73.03M</td><td>25.61G</td><td>44.70</td></tr></table>
|
| 186 |
+
|
| 187 |
+
# 4.3 Control vs. Trajectory
|
| 188 |
+
|
| 189 |
+
In this section, we conduct quantitative experiments to compare the Control-Only model and the Trajectory-Only model to demonstrate their advantages and disadvantages. For both models, we use the same setting except for the output head and its corresponding loss. We use a ResNet-34 to encode visual inputs and a measurement module to encode the navigation information. Similar to [60], we add speed and value heads as auxiliary tasks to help the model better encode the environment. For Control-Only, we predict the control distribution based on the concatenated latent feature from the two encoders. As for Trajectory-Only, we feed the feature to a GRU decoder to generate waypoints. As shown in Table 2, though Trajectory-Only collides with vehicles less frequently than Control-Only, it has more layout collisions, off-road infractions, and agent blocks. We also count the ratio of each kind of infraction that occurs during turning. It can be observed that for Trajectory-Only, a large portion of such infractions happen when the ego agent is turning compared to Control-Only. This has verified that Trajectory-Only performs worse when the agent is turning, which is probably caused by the unsatisfactory trajectory following performance of simple PID controllers as discussed in Sec. 1. As for the fact that Control-Only has a higher vehicle-collision rate, it is because the model focuses on the current time step and the reaction to potential collisions tends to be late, as depicted in Sec. 1 as well. The results above further validate the necessity of combining the two output paradigms.
|
| 190 |
+
|
| 191 |
+
# 4.4 Ablative Study and Visualization
|
| 192 |
+
|
| 193 |
+
Component analysis. We first validate the effectiveness of the trajectory-guided multi-step control prediction design, as shown in Table 3. We only employ the control branch output except for the last complete one when fusion is applied for these ablations. Adding a trajectory branch as an auxiliary task improves the performance by 2.5 points. The multi-step predictions with our temporal module greatly help with 7.9 points gain, and adding the trajectory-guided attention further acquires an improvement of 3.2 points. Finally, applying our situation based fusion scheme $\alpha$ is set to 0.3) significantly boosts the infraction score, leading the overall driving score to 57.
|
| 194 |
+
|
| 195 |
+
Multi-task vs. Ensemble. The comparison regarding their performances and computational complexity is given in Table 4. Ensemble denotes directly combining the outputs of Control-Only and Trajectory-Only with our situation based fusion scheme. MTL represents the model with a shared CNN backbone and measurement encoders followed by a trajectory branch and a control branch, but the control branch predicts current step prediction only and there are no interactions between the two branches. We conclude that directly combining two models with our fusion scheme greatly improves the performance, and using an MTL approach works better than ensemble but with a much smaller model size and GFLOPs. A conventional ensemble approach to combine results from TCP and TCP-SB as TCP-Ens brings further performance gain at the cost of computational complexity.
|
| 196 |
+
|
| 197 |
+
Situation based fusion weight. We investigate the choice of the combination weight $\alpha$ in the situation based fusion scheme and show the box plot of the driving scores in the figure to the right. Besides $\alpha \in [ 0 , 0 . 5 ]$ , we additionally test 0.7 and 1, meaning that two results are conversely mixed with our specialization definition. We see that only using the control from the specialized branch $\alpha = 0$ performs poorly while directly taking the average or fusing conversely still has comparable results. One reason is that the situation criterion used here is whether the vehicle is turning, making most cases trajectory specialized, and the stronger control branch is not utilized enough if $\alpha$ is small. Note that the situation based fusion scheme is general and flexible, and the criterion or $\alpha$ value used here is relatively coarse.
|
| 198 |
+
|
| 199 |
+

|
| 200 |
+
Figure 5: Box plot of the driving score with different $\alpha$ values (3 trials for each $\alpha$ ).
|
| 201 |
+
|
| 202 |
+
Visualization. Fig. 4 visualizes the trajectory-guided attention maps. The trajectory branch provides location-related information to guide the control branch to focus on important regions which are useful for future control prediction. See more qualitative results in the Supplementary.
|
| 203 |
+
|
| 204 |
+
# 5 Conclusion
|
| 205 |
+
|
| 206 |
+
In this work, we study two learning and prediction paradigms based on trajectory and direct control, respectively, for end-to-end autonomous driving. We propose a unified framework comprised of a trajectory branch and a novel multi-step control branch with interactions in between. We design a situation based fusion scheme to combine the results from two branches. Our method with only a monocular camera has achieved state-of-the-art performance on the CARLA Leaderboard.
|
| 207 |
+
|
| 208 |
+
# Acknowledgments
|
| 209 |
+
|
| 210 |
+
This work was partly supported by National Key Research and Development Program of China (2020AAA0107600), NSFC (62206172, 61972250), Shanghai Municipal Science and Technology Major Project (2021SHZDZX0102), and Shanghai Committee of Science and Technology (21DZ1100100, 22511105100).
|
| 211 |
+
|
| 212 |
+
# References
|
| 213 |
+
|
| 214 |
+
[1] CARLA autonomous driving leaderboard. https://leaderboard.carla.org/, 2022. 3, 8
|
| 215 |
+
|
| 216 |
+
[2] Andreas Argyriou, Theodoros Evgeniou, and Massimiliano Pontil. Multi-task feature learning. In NeurIPS, 2006. 2, 3
|
| 217 |
+
[3] Mariusz Bojarski, Davide Del Testa, Daniel Dworakowski, Bernhard Firner, Beat Flepp, Prasoon Goyal, Lawrence D Jackel, Mathew Monfort, Urs Muller, Jiakai Zhang, et al. End to end learning for self-driving cars. arXiv preprint arXiv:1604.07316, 2016. 3
|
| 218 |
+
[4] Mariusz Bojarski, Chenyi Chen, Joyjit Daw, Alperen Degirmenci, Joya Deri, Bernhard Firner, Beat Flepp, ˘ Sachin Gogri, Jesse Hong, Lawrence Jackel, et al. The nvidia pilotnet experiments. arXiv preprint arXiv:2010.08776, 2020. 1
|
| 219 |
+
[5] Eduardo F Camacho and Carlos Bordons Alba. Model predictive control. Springer science & business media, 2013. 2
|
| 220 |
+
[6] Manuel Carranza-García, Pedro Lara-Benítez, Jorge García-Gutiérrez, and José C Riquelme. Enhancing object detection for autonomous driving by optimizing anchor generation and addressing class imbalance. Neurocomputing, 2021. 4
|
| 221 |
+
[7] Rich Caruana. Multitask learning. Machine learning, 1997. 2, 3
|
| 222 |
+
[8] Sergio Casas, Abbas Sadat, and Raquel Urtasun. Mp3: A unified model to map, perceive, predict and plan. In CVPR, 2021. 2, 3
|
| 223 |
+
[9] Raphael Chekroun, Marin Toromanoff, Sascha Hornauer, and Fabien Moutarde. Gri: General reinforced imitation and its application to vision-based autonomous driving. arXiv preprint arXiv:2111.08575, 2021. 1, 3, 8
|
| 224 |
+
[10] Dian Chen and Philipp Krähenbühl. Learning from all vehicles. In CVPR, 2022. 1, 3, 4, 8
|
| 225 |
+
[11] Dian Chen, Brady Zhou, Vladlen Koltun, and Philipp Krähenbühl. Learning by cheating. In CoRL, 2020. 1, 2, 3
|
| 226 |
+
[12] Dian Chen, Vladlen Koltun, and Philipp Krähenbühl. Learning to drive from a world on rails. In ICCV, 2021. 1, 3, 8
|
| 227 |
+
[13] Li Chen, Chonghao Sima, Yang Li, Zehan Zheng, Jiajie Xu, Xiangwei Geng, Hongyang Li, Conghui He, Jianping Shi, Yu Qiao, et al. Persformer: 3d lane detection via perspective transformer and the openlane benchmark. arXiv preprint arXiv:2203.11089, 2022. 2, 4
|
| 228 |
+
[14] Sumanth Chennupati, Ganesh Sistu, Senthil Yogamani, and Samir A Rawashdeh. Multinet++: Multi-stream feature aggregation and geometric loss strategy for multi-task learning. In CVPRW, 2019. 4
|
| 229 |
+
[15] Kashyap Chitta, Aditya Prakash, and Andreas Geiger. Neat: Neural attention fields for end-to-end autonomous driving. In ICCV, 2021. 1, 2, 3, 8
|
| 230 |
+
[16] Kyunghyun Cho, Bart van Merrienboer, Çaglar Gülçehre, Dzmitry Bahdanau, Fethi Bougares, Holger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder–decoder for statistical machine translation. In EMNLP, 2014. 2, 5
|
| 231 |
+
[17] Felipe Codevilla, Matthias Müller, Antonio López, Vladlen Koltun, and Alexey Dosovitskiy. End-to-end driving via conditional imitation learning. In ICRA, 2018. 1, 2, 3, 4
|
| 232 |
+
[18] Felipe Codevilla, Eder Santana, Antonio M López, and Adrien Gaidon. Exploring the limitations of behavior cloning for autonomous driving. In ICCV, 2019. 1, 2, 3
|
| 233 |
+
[19] Thomas G Dietterich. Ensemble methods in machine learning. In MCS, 2000. 4
|
| 234 |
+
[20] Alexey Dosovitskiy, German Ros, Felipe Codevilla, Antonio Lopez, and Vladlen Koltun. CARLA: An open urban driving simulator. In CoRL, 2017. 3, 7
|
| 235 |
+
[21] Hongyan Guo, Dongpu Cao, Hong Chen, Zhenping Sun, and Yunfeng Hu. Model predictive path following control for autonomous cars considering a measurable disturbance: Implementation, testing, and verification. MSSP, 2019. 2
|
| 236 |
+
[22] Jeffrey Hawke, Richard Shen, Corina Gurau, Siddharth Sharma, Daniele Reda, Nikolay Nikolov, Przemysław Mazur, Sean Micklethwaite, Nicolas Griffiths, Amar Shah, et al. Urban driving with conditional imitation learning. In ICRA, 2020. 3
|
| 237 |
+
[23] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016. 5
|
| 238 |
+
[24] Yuenan Hou, Zheng Ma, Chunxiao Liu, and Chen Change Loy. Learning to steer by mimicking features from heterogeneous auxiliary networks. In AAAI, 2019. 3, 4
|
| 239 |
+
[25] Shengchao Hu, Li Chen, Penghao Wu, Hongyang Li, Junchi Yan, and Dacheng Tao. St-p3: End-to-end vision-based autonomous driving via spatial-temporal feature learning. In ECCV, 2022. 2, 3
|
| 240 |
+
[26] Sebastian Huch, Aybike Ongel, Johannes Betz, and Markus Lienkamp. Multi-task end-to-end self-driving architecture for cav platoons. Sensors, 2021. 3
|
| 241 |
+
[27] Keishi Ishihara, Anssi Kanervisto, Jun Miura, and Ville Hautamaki. Multi-task learning with attention for end-to-end autonomous driving. In CVPR, 2021. 3, 4
|
| 242 |
+
[28] Robert A Jacobs, Michael I Jordan, Steven J Nowlan, and Geoffrey E Hinton. Adaptive mixtures of local experts. Neural computation, 1991. 4
|
| 243 |
+
[29] Bernhard Jaeger. Expert drivers for autonomous driving. Master’s thesis, University of Tübingen, 2021. 1, 2, 3, 4, 8
|
| 244 |
+
[30] Alex Kendall, Jeffrey Hawke, David Janz, Przemyslaw Mazur, Daniele Reda, John-Mark Allen, Vinh-Dieu Lam, Alex Bewley, and Amar Shah. Learning to drive in a day. In ICRA, 2019. 3
|
| 245 |
+
[31] Inhan Kim, Hyemin Lee, Joonyeong Lee, Eunseop Lee, and Daijin Kim. Multi-task learning with future states for vision-based autonomous driving. In ACCV, 2020. 3, 4
|
| 246 |
+
[32] Inhan Kim, Joonyeong Lee, and Daijin Kim. Learning mixture of domain-specific experts via disentangled factors for autonomous driving. In AAAI, 2022. 4
|
| 247 |
+
[33] Philipp Krähenbühl and Vladlen Koltun. Learning to propose objects. In CVPR, 2015. 4
|
| 248 |
+
[34] Varun Ravi Kumar, Senthil Yogamani, Hazem Rashed, Ganesh Sitsu, Christian Witt, Isabelle Leang, Stefan Milz, and Patrick Mäder. Omnidet: Surround view cameras based multi-task visual perception network for autonomous driving. RA-L, 2021. 2, 4
|
| 249 |
+
[35] Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and scalable predictive uncertainty estimation using deep ensembles. In NeurIPS, 2017. 4
|
| 250 |
+
[36] Yingwei Li, Adams Wei Yu, Tianjian Meng, Ben Caine, Jiquan Ngiam, Daiyi Peng, Junyang Shen, Bo Wu, Yifeng Lu, Denny Zhou, et al. Deepfusion: Lidar-camera deep fusion for multi-modal 3d object detection. In CVPR, 2022. 4
|
| 251 |
+
[37] Zhihao Li, Toshiyuki Motoyoshi, Kazuma Sasaki, Tetsuya Ogata, and Shigeki Sugano. Rethinking selfdriving: Multi-task knowledge for better generalization and accident explanation ability. arXiv preprint arXiv:1809.11100, 2018. 3
|
| 252 |
+
[38] Ming Liang, Bin Yang, Yun Chen, Rui Hu, and Raquel Urtasun. Multi-task multi-sensor fusion for 3d object detection. In CVPR, 2019. 2, 4
|
| 253 |
+
[39] Xiaodan Liang, Tairui Wang, Luona Yang, and Eric Xing. Cirl: Controllable imitative reinforcement learning for vision-based self-driving. In ECCV, 2018. 1, 3
|
| 254 |
+
[40] Urs Muller, Jan Ben, Eric Cosatto, Beat Flepp, and Yann Cun. Off-road obstacle avoidance through end-to-end learning. In NeurIPS, 2005. 3
|
| 255 |
+
[41] Urs Muller, Jan Ben, Eric Cosatto, Beat Flepp, and Yann Cun. Off-road obstacle avoidance through end-to-end learning. In NeurIPS, 2005. 2
|
| 256 |
+
[42] Eshed Ohn-Bar, Aditya Prakash, Aseem Behl, Kashyap Chitta, and Andreas Geiger. Learning situational driving. In CVPR, 2020. 1, 4
|
| 257 |
+
[43] Ashwini Pokle, Roberto Martín-Martín, Patrick Goebel, Vincent Chow, Hans M Ewald, Junwei Yang, Zhenkai Wang, Amir Sadeghian, Dorsa Sadigh, Silvio Savarese, et al. Deep local trajectory replanning and control for robot navigation. In ICRA, 2019. 3
|
| 258 |
+
[44] Dean A Pomerleau. Alvinn: An autonomous land vehicle in a neural network. In NeurIPS, 1988. 2, 3
|
| 259 |
+
[45] Aditya Prakash, Aseem Behl, Eshed Ohn-Bar, Kashyap Chitta, and Andreas Geiger. Exploring data aggregation in policy learning for vision-based urban autonomous driving. In CVPR, 2020. 3, 4
|
| 260 |
+
[46] Aditya Prakash, Kashyap Chitta, and Andreas Geiger. Multi-modal fusion transformer for end-to-end autonomous driving. In CVPR, 2021. 1, 3, 5
|
| 261 |
+
[47] Georgia Rajamanoharan, Aytaç Kanacı, Minxian Li, Shaogang Gong, et al. Multi-task mutual learning for vehicle re-identification. In CVPR, 2019. 4
|
| 262 |
+
[48] Nicholas Rhinehart, Rowan McAllister, and Sergey Levine. Deep imitative models for flexible inference, planning, and control. In ICLR, 2019. 1
|
| 263 |
+
[49] Abbas Sadat, Sergio Casas, Mengye Ren, Xinyu Wu, Pranaab Dhawan, and Raquel Urtasun. Perceive, predict, and plan: Safe motion planning through interpretable semantic representations. In ECCV, 2020. 3
|
| 264 |
+
[50] Marin Toromanoff, Emilie Wirbel, and Fabien Moutarde. End-to-end model-free reinforcement learning for urban driving using implicit affordances. In CVPR, 2020. 3, 8
|
| 265 |
+
[51] Apoorv Vyas, Nataraj Jammalamadaka, Xia Zhu, Dipankar Das, Bharat Kaul, and Theodore L Willke. Out-of-distribution detection using an ensemble of self supervised leave-out classifiers. In ECCV, pages 550–564, 2018. 4
|
| 266 |
+
[52] Dong Wu, Manwen Liao, Weitian Zhang, and Xinggang Wang. Yolop: You only look once for panoptic driving perception. arXiv preprint arXiv:2108.11250, 2021. 4
|
| 267 |
+
[53] Yi Xiao, Felipe Codevilla, Akhil Gurram, Onay Urfalioglu, and Antonio M López. Multimodal end-to-end autonomous driving. T-ITS, 2020. 3
|
| 268 |
+
[54] Huazhe Xu, Yang Gao, Fisher Yu, and Trevor Darrell. End-to-end learning of driving models from large-scale video datasets. In CVPR, 2017. 3
|
| 269 |
+
[55] Jie Xu, Wei Wang, Hanyuan Wang, and Jinhong Guo. Multi-model ensemble with rich spatial information for object detection. Pattern Recognition, 2020. 4
|
| 270 |
+
[56] Zhengyuan Yang, Yixuan Zhang, Jerry Yu, Junjie Cai, and Jiebo Luo. End-to-end multi-modal multi-task vehicle control for self-driving cars with visual perceptions. In ICPR, 2018. 3, 4
|
| 271 |
+
[57] Éloi Zablocki, Hédi Ben-Younes, Patrick Pérez, and Matthieu Cord. Explainability of vision-based autonomous driving systems: Review and challenges. arXiv preprint arXiv:2101.05307, 2021. 2
|
| 272 |
+
[58] Wenyuan Zeng, Wenjie Luo, Simon Suo, Abbas Sadat, Bin Yang, Sergio Casas, and Raquel Urtasun. End-to-end interpretable neural motion planner. In CVPR, 2019. 3
|
| 273 |
+
[59] Jimuyang Zhang and Eshed Ohn-Bar. Learning by watching. In CVPR, 2021. 1, 3
|
| 274 |
+
[60] Zhejun Zhang, Alexander Liniger, Dengxin Dai, Fisher Yu, and Luc Van Gool. End-to-end urban driving by imitating a reinforcement learning coach. In ICCV, 2021. 1, 3, 4, 7, 9
|
| 275 |
+
[61] Albert Zhao, Tong He, Yitao Liang, Haibin Huang, Guy Van den Broeck, and Stefano Soatto. Sam: Squeeze-and-mimic networks for conditional visual driving policy learning. In CoRL, 2021. 3
|
| 276 |
+
[62] Yinuo Zhao, Kun Wu, Zhiyuan Xu, Zhengping Che, Qi Lu, Jian Tang, and Chi Harold Liu. Cadre: A cascade deep reinforcement learning framework for vision-based autonomous urban driving. In AAAI, 2022. 3
|
| 277 |
+
[63] Zeyu Zhu and Huijing Zhao. Multi-task conditional imitation learning for autonomous navigation at crowded intersections. arXiv preprint arXiv:2202.10124, 2022. 3, 4
|
| 278 |
+
|
| 279 |
+
# Checklist
|
| 280 |
+
|
| 281 |
+
The checklist follows the references. Please read the checklist guidelines carefully for information on how to answer these questions. For each question, change the default [TODO] to [Yes] , [No] , or [N/A] . You are strongly encouraged to include a justification to your answer, either by referencing the appropriate section of your paper or providing a brief inline description. For example:
|
| 282 |
+
|
| 283 |
+
• Did you include the license to the code and datasets? [Yes] See Section XX.
|
| 284 |
+
• Did you include the license to the code and datasets? [No] The code and the data are proprietary.
|
| 285 |
+
• Did you include the license to the code and datasets? [N/A]
|
| 286 |
+
|
| 287 |
+
Please do not modify the questions and only use the provided macros for your answers. Note that the Checklist section does not count towards the page limit. In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
|
| 288 |
+
|
| 289 |
+
1. For all authors...
|
| 290 |
+
|
| 291 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 292 |
+
(b) Did you describe the limitations of your work? [Yes] See the Supplementary.
|
| 293 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] See the Supplementary.
|
| 294 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 295 |
+
|
| 296 |
+
2. If you are including theoretical results...
|
| 297 |
+
|
| 298 |
+
(a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
|
| 299 |
+
|
| 300 |
+
3. If you ran experiments...
|
| 301 |
+
|
| 302 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] The zip file of source code and the URL of data are in the Supplementary.
|
| 303 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Sec. 4.1 and the Supplementary.
|
| 304 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Sec. 4.
|
| 305 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See the Supplementary.
|
| 306 |
+
|
| 307 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 308 |
+
|
| 309 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes] We use the CARLA simulator and pretrained ResNet model.
|
| 310 |
+
(b) Did you mention the license of the assets? [Yes] See the Supplementary.
|
| 311 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] The zip file of source code and the URL of data are in the Supplementary.
|
| 312 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] CARLA is a public simulator.
|
| 313 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] Data in the public simulator does not have these issues.
|
| 314 |
+
|
| 315 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 316 |
+
|
| 317 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 318 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 319 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/E01k9048soZ/E01k9048soZ.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/ECvgmYVyeUz/ECvgmYVyeUz.md
ADDED
|
@@ -0,0 +1,559 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CHAOS IS A LADDER: A NEW THEORETICAL UNDERSTANDING OF CONTRASTIVE LEARNING VIA AUGMENTATION OVERLAP
|
| 2 |
+
|
| 3 |
+
Yifei Wang1∗ Qi Zhang2∗ Yisen Wang3,4† Jiansheng Yang1 Zhouchen Lin3,4,5
|
| 4 |
+
|
| 5 |
+
1 School of Mathematical Sciences, Peking University
|
| 6 |
+
2 School of Computer Science and Engineering, Sun Yat-sen University
|
| 7 |
+
3 Key Lab. of Machine Perception (MoE), School of Artificial Intelligence, Peking University
|
| 8 |
+
4 Institute for Artificial Intelligence, Peking University
|
| 9 |
+
5 Pazhou Lab, Guangzhou, 510330, China
|
| 10 |
+
|
| 11 |
+
# ABSTRACT
|
| 12 |
+
|
| 13 |
+
Recently, contrastive learning has risen to be a promising approach for large-scale self-supervised learning. However, theoretical understanding of how it works is still unclear. In this paper, we propose a new guarantee on the downstream performance without resorting to the conditional independence assumption that is widely adopted in previous work but hardly holds in practice. Our new theory hinges on the insight that the support of different intra-class samples will become more overlapped under aggressive data augmentations, thus simply aligning the positive samples (augmented views of the same sample) could make contrastive learning cluster intra-class samples together. Based on this augmentation overlap perspective, theoretically, we obtain asymptotically closed bounds for downstream performance under weaker assumptions, and empirically, we propose an unsupervised model selection metric ARC that aligns well with downstream accuracy. Our theory suggests an alternative understanding of contrastive learning: the role of aligning positive samples is more like a surrogate task than an ultimate goal, and the overlapped augmented views (i.e., the chaos) create a ladder for contrastive learning to gradually learn class-separated representations. The code for computing ARC is available at https://github.com/zhangq327/ARC.
|
| 14 |
+
|
| 15 |
+
# 1 INTRODUCTION
|
| 16 |
+
|
| 17 |
+
Contrastive Learning (CL) emerges to be a promising paradigm for learning data representations without labeled data (Oord et al., 2018; Hjelm et al., 2019). Recently, it has achieved impressive results and gradually closed the gap between supervised and unsupervised learning, hopefully leading to a new era that resolves the hunger for labeled data in the deep learning field (He et al., 2020; Chen et al., 2020b; Wang et al., 2021). However, despite its intriguing empirical success, a theoretical understanding of how contrastive learning actually works in practice is still under-explored.
|
| 18 |
+
|
| 19 |
+
The general methodology of contrastive learning is quite simple, that is to maximize the similarity between augmented views of the same image (a.k.a. positive samples), and minimize the similarity between that of two random images (a.k.a. negative samples). Intuitively, it is an instance discrimination task (differing each image from others) instead of a classification task (clustering images from the same class together and differing with other classes). Nevertheless, as shown in Figure 1(a), CL representations are also class-separated. Therefore, understanding how the pretraining task (CL) and the downstream task (classification) interact plays a central role in both theoretical understandings and practical designings of contrastive methods.
|
| 20 |
+
|
| 21 |
+
Previously, Saunshi et al. (2019) and Lee et al. (2020) have tried to establish guarantees on the classification performance for self-supervised representations. However, their analysis relies heavily on the assumption that the two positive samples, as augmented views of the same image, are (nearly) conditionally independent on the class $y$ . However, this is hardly practical as the augmented views are still strongly input-dependent (see Figure 1(b)). In fact, if the conditional independence is satisfied, the unsupervised task will become as informative as the supervised task, making this discussion
|
| 22 |
+
|
| 23 |
+
(a) Contrastive learning learns clustered features.
|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
Figure 1: (a) t-SNE visualization of representations before and after contrastive learning. Each point denotes a sample and its color denotes its class. (b) Applying aggressive data augmentations (Chen et al., 2020a) to four images from ImageNet (two are cars and two are pens). The 1st column shows the raw (center-cropped) images and the 2-5th colums show the augmented ones.
|
| 27 |
+
|
| 28 |
+

|
| 29 |
+
(b) Intra-class samples are more alike via augmented views.
|
| 30 |
+
|
| 31 |
+
almost unnecessary. This motivates us to find more practical and weaker assumptions to understand how contrastive learning actually works (even without conditional independence). To achieve this, we need to re-examine the contrastive learning process. Previously, Wang & Isola (2020) show that CL objective involves two goals: alignment (for positive samples) and uniformity (for negative samples). Nevertheless, we show that there exist bad cases where the features could still have poor performance even with perfect alignment and uniformity. Thus, contradictory to the common belief of contrastive learning as learning invariance, we note that invariance alone is inadequate to learning useful representations for downstream tasks.
|
| 32 |
+
|
| 33 |
+
In this paper, we provide a novel understanding of contrastive learning that requires only practical and minimal assumptions, while also guarantee class-separated representations. Our core insight hinges on the observation that contrastive learning usually adopts much more aggressive data augmentations than that in supervised learning (He et al., 2020; Chen et al., 2020a). As shown in Figure 1(b), we notice that aggressive random cropping of two images can generate views that are very much alike that we could even hardly tell them apart, e.g., the wheels of two different cars. In other words, there will be support overlap between different intra-class images through aggressively augmented views of them, a phenomenon we call augmentation overlap. Thus, the alignment of positive samples will also cluster all the intra-class samples together, and lead to class-separated representations. From our perspective, the role of data augmentation is to create a certain degree of “chaos” between intra-class samples, and the role of contrastive loss is to “climb the ladder of chaos”, i.e., the process that we gradually cluster intra-class samples by aligning positive samples.
|
| 34 |
+
|
| 35 |
+
Following this intuition, we develop a new theory for understanding the effectiveness of contrastive learning from the perspective of augmentation overlap. Specifically, we derive the upper and lower bounds for its downstream performance and show how the two bounds will asymptotically converge with our assumptions on augmentation overlap. Driven by this analysis, we further discuss how varying augmentation will affect the performance of contrastive learning from both synthetic and real-world datasets, and show that the results align well with our theory. In summary,
|
| 36 |
+
|
| 37 |
+
• We characterize the failure of the previous analysis of contrastive learning, and develop a new understanding through the augmentation overlap effect. Compared to existing theories on contrastive learning, ours can provide guidance to the practical designing of contrastive methods and evaluation metrics. • We establish general guarantees (both upper and lower bounds) for the downstream performance without assumptions on conditional independence. And we further show how the two bounds could asymptotically converge under our less restrictive assumptions. • We provide a quantitative discussion on the effect of augmentation strength, which verifies our theory from both theoretical and empirical aspects. Motivated by our theory, we further propose a new unsupervised evaluation metric for contrastive learning named ARC and show that it aligns well with downstream performance on real-world datasets.
|
| 38 |
+
|
| 39 |
+
# 2 RELATED WORK
|
| 40 |
+
|
| 41 |
+
Contrastive Learning in Practice. Contrastive self-supervised learning originates from a mutual information perspective of representation learning (Oord et al., 2018; Hjelm et al., 2019), and soon becomes a general learning paradigm that contrasts between positive and negative pairs (He et al., 2020; Chen et al., 2020a). It is rapidly closing the performance gap between unsupervised and supervised learning on large-scale dataset like ImageNet (Chen et al., 2021), and outperforms supervised learning when combined with a few (e.g., $10 \%$ ) labels (Chen et al., 2020b). Several recent works show that similar performance could be achieved without negative samples by adopting certain training techniques (Grill et al., 2020; Chen & He, 2020).
|
| 42 |
+
|
| 43 |
+
Understanding Contrastive Learning Objectives. Both the original InfoNCE loss (Oord et al., 2018) and its InfoMax variants (Hjelm et al., 2019; Poole et al., 2019) are designed as variational estimates of the mutual information between inputs and representations, but these estimators are shown to have poor bias-variance trade-offs (Song & Ermon, 2020). Instead, Wang & Isola (2020) simply understand contrastive learning through the two terms in the InfoNCE loss: alignment of positive samples and uniformity of negative samples. However, as we show later, this perspective is also insufficient to explain the effectiveness of contrastive learning, and we should take the interplay between augmentation and alignment into consideration.
|
| 44 |
+
|
| 45 |
+
Understanding Downstream Generalization. Saunshi et al. (2019) propose the first theoretical guarantees by bridging the contrastive and classification objectives. Lee et al. (2020) further link the reconstruction-based objective to the downstream objective. However, both Saunshi et al. (2019) and Lee et al. (2020) rely on the unrealistic assumption that the positive samples are (nearly) conditionally independent. Huang et al. (2021) establish bounds by assuming a very small intra-class support diameter, which is also not practical. Besides, some also explore the information-theoretical perspectives for analyzing contrastive learning (Tian et al., 2020; Tsai et al., 2021; Tosh et al., 2020; 2021), though their mutual information assumptions are hard to verify. Recently, similar to our analysis, HaoChen et al. (2021) also study the augmentation graph and establish guarantees in terms of graph connectivity. Our work differs to theirs mainly in three aspects: 1) our analysis is applicable for the widely adopted InfoNCE and CE losses, while theirs is developed for their own spectral loss; 2) ours starts from the alignment and uniformity perspective while theirs starts from the matrix decomposition perspective; 3) our theory is empirically verified and inspires a useful evaluation metric for data augmentation, while their analysis focusing on minimizing the decomposition error is farther from the practical designing of positive and negative samples. In a nutshell, compared to previous discussions, our theory has a closer connection to the actual contrastive learning process, and we verify the feasibility of each assumption with empirical evidence.
|
| 46 |
+
|
| 47 |
+
# 3 LIMITATIONS OF PREVIOUS UNDERSTANDINGS
|
| 48 |
+
|
| 49 |
+
We begin by introducing the basic notations and common practice of contrastive learning in the image classification task. In general, it has two stages, unsupervised pretraining, and supervised finetuning. In the first stage, with $N$ unlabeled samples $\mathcal { D } _ { u } \dot { = } \{ x _ { i } \} _ { i = 1 } ^ { \hat { N } }$ , we pretrain an encoder mapping from the $d$ -dimensonal input space to a unit hypersphere $f \in \bar { \mathcal { F } } : \mathbb { R } ^ { d } \to \mathbb { S } ^ { m - 1 }$ in the $m$ - dimensional space. In the second stage, we evaluate the learned representations $z$ with the labeled data $\mathcal { D } _ { l } = \{ ( \dot { x } _ { i } , y _ { i } ) \}$ where labels $\check { y _ { i } } \in \{ 1 , \ldots , K \}$ . Specifically, we fix the encoder and learn a linear classification head $g : \mathcal { R } ^ { m } \to \mathcal { R } ^ { K }$ on top from $\tilde { \mathcal { D } } _ { l } = \{ ( z , y ) | z = f ( x ) \in \mathcal { R } ^ { m } \}$ .
|
| 50 |
+
|
| 51 |
+
Contrastive Pretraining. Taking a training example $x \in \mathcal { D } _ { u }$ , we draw its positive sample $x ^ { + } =$ $t ( x )$ by applying a random data augmentation $t \sim \tau$ , and draw $M$ randomly augmented samples $\{ x _ { i } ^ { - } \} _ { i = 1 } ^ { M }$ from $\mathcal { D } _ { u }$ as its negative samples. Then, we can learn the encoder $f$ with the widely used InfoNCE loss (Oord et al., 2018)
|
| 52 |
+
|
| 53 |
+
$$
|
| 54 |
+
{ \mathcal { L } } _ { \mathrm { N C E } } ( f ) = \mathbb { E } _ { p ( x , x ^ { + } ) } \mathbb { E } _ { \{ p ( x _ { i } ^ { - } ) \} } \left[ - \log \frac { \exp ( f ( x ) ^ { \top } f ( x ^ { + } ) ) } { \sum _ { i = 1 } ^ { M } \exp ( f ( x ) ^ { \top } f ( x _ { i } ^ { - } ) ) } \right] .
|
| 55 |
+
$$
|
| 56 |
+
|
| 57 |
+
Let $p ( x )$ be the data distribution, $p ( x , x ^ { + } )$ be the joint distribution of positive pairs, and we simply assume $p ( x , x ^ { + } ) = p ( x ^ { + } , x )$ and $\begin{array} { r } { p ( x ) = \int p ( x , x ^ { + } ) d x ^ { + } , \forall x \in \mathbb { R } ^ { d } } \end{array}$ following Wang $\&$ Isola (2020).
|
| 58 |
+
|
| 59 |
+
Linear Evaluation. To evaluate the learned representations by contrastive learning, we usually adopt the Cross Entropy (CE) loss (Chen et al., 2020a) for a labeled pair $( x , y ) \in \mathcal { D } _ { l }$
|
| 60 |
+
|
| 61 |
+
$$
|
| 62 |
+
\mathcal { L } _ { \mathrm { C E } } ( \boldsymbol { f } , \boldsymbol { g } ) = \mathbb { E } _ { p ( \boldsymbol { x } , \boldsymbol { y } ) } \left[ - \log \frac { \exp \left( \boldsymbol { f } ( \boldsymbol { x } ) ^ { \top } \boldsymbol { w } _ { \boldsymbol { y } } \right) } { \sum _ { i = 1 } ^ { K } \exp \left( \boldsymbol { f } ( \boldsymbol { x } ) ^ { \top } \boldsymbol { w } _ { i } \right) } \right] ,
|
| 63 |
+
$$
|
| 64 |
+
|
| 65 |
+
with a linear classifier $\begin{array} { r } { g ( z ) = W z } \end{array}$ where $W = [ w _ { 1 } , w _ { 2 } , \dots , w _ { K } ]$
|
| 66 |
+
|
| 67 |
+
As discussed above, there are some previous understandings on how contrastive learning yields good performance, and they mainly differ by their theoretical assumptions.
|
| 68 |
+
|
| 69 |
+
First, Wang & Isola (2020) interpret the first and second terms of the InfoNCE loss (Eq. 1) as they are aiming at the following two properties: 1) alignment (the nominator): positive samples $x , x ^ { \mp }$ has similar features, i.e., $f ( x ) \approx f ( x ^ { + } ) ; 2 )$ uniformity (the denominator): features are roughly uniformly distributed in the unit hypersphere $\mathbb { S } ^ { m - 1 }$ . In particular, they show that InfoNCE can be minimized with 1) perfect alignment and 2) perfect uniformity. However, as we illustrate in Figure 2, the features could still have very poor downstream performance in the finite sample scenario. This issue can be described rigorously by the following proposition.
|
| 70 |
+
|
| 71 |
+
Proposition 3.1 (Class-uniform Features Also Minimize the InfoNCE Loss). For $N$ training examples of $K$ classes, consider the case when features $\{ f ( x _ { i } ) \} _ { i = 1 } ^ { N }$ are randomly distributed in $\mathbb { S } ^ { m - 1 }$ with maximal uniformity (i.e., , minimizing the 2nd term of Eq. 1) while also satisfying $\forall x _ { i } , x _ { i } ^ { + } \sim$ $p ( x , x ^ { + } ) , f ( x _ { i } ) = f ( x _ { i } ^ { + } )$ . Because we have these two properties, the InfoNCE loss achieves its minimum. However, the downstream classification accuracy is at most $1 / K + \varepsilon$ and $\varepsilon$ is nearly zero when $N$ is large enough.
|
| 72 |
+
|
| 73 |
+

|
| 74 |
+
Figure 2: Contrastive learning may learn class inseparable features even with perfect aligned postive samples and uniform negative samples. Colors denote classes.
|
| 75 |
+
|
| 76 |
+
Proofs can be found in Appendix A. This proposition indicates that the instance discrimination task (alignment $^ +$ uniformity) alone cannot guarantee the learning of class-discriminative features as desired in the downsteam classification. Instead, Saunshi et al. (2019) and Lee et al. (2020) both establish the relationship between pretraining and classification objectives and provide guarantees for the downstream performance. In fact, the two works both assume the conditional independence of the two positive samples, i.e., $p ( x , x ^ { + } | y ) \stackrel { } { = } p ( x | y ) p ( x ^ { + } | y )$ . However, this assumption is too strong as it is hardly practical. As shown in Figure 1(b), augmented views from the same class are not actually independent as views from the same sample are more alike than that from other samples.
|
| 77 |
+
|
| 78 |
+
# 4 NEW AUGMENTATION OVERLAP THEORY FOR CONTRASTIVE LEARNING
|
| 79 |
+
|
| 80 |
+
The analysis above motivates us to find a minimal and practical assumption: 1) it is enough to guarantee good performance on downstream tasks; 2) it is less restrictive than the i.i.d. assumptions as in Saunshi et al. (2019) and Lee et al. (2020).
|
| 81 |
+
|
| 82 |
+
# 4.1 GAP BETWEEN CONTRASTIVE LEARNING AND DOWNSTREAM CLASSIFICATION
|
| 83 |
+
|
| 84 |
+
We start with an assumption on the label consistency between positive samples, that is, any pair of positive samples $( x , x ^ { + } )$ should belong to the same class.
|
| 85 |
+
|
| 86 |
+
Assumption 4.1 (Label Consistency). $\forall x , x ^ { + } \sim p ( x , x ^ { + } )$ , we assume the labels are deterministic (one-hot) and consistent: $p ( y | x ) = p ( y | x ^ { + } )$ .
|
| 87 |
+
|
| 88 |
+
This is a natural and minimal assumption that is likely to hold in practice. As shown in Figure 1(b), the widely adopted augmentations in contrastive learning (Chen et al., 2020a) like images cropping, color distortion, and horizontal flipping will hardly alter the belonging image classes.
|
| 89 |
+
|
| 90 |
+
With this minimal assumption, we can characterize the generalization gap between unsupervised and supervised learning risks. We first introduce the mean CE loss, $L _ { \mathrm { C E } } ^ { \mu } ( f ) \ ^ { \bullet } =$ $\begin{array} { r } { \mathbb { E } _ { p ( x , y ) } \left[ - \log \frac { \exp \bigl ( f ( x ) ^ { \top } \mu _ { y } \bigr ) } { \sum _ { i = 1 } ^ { K } \exp ( f ( x ) ^ { \top } \mu _ { i } ) } \right] } \end{array}$ where we use the classwise mean representation $\mu _ { k } \quad = $ $\mathbb { E } _ { p ( x | y = k ) } [ f ( x ) ]$ as the weight $w _ { k }$ of the classifier $g$ . It is easy to see that the mean CE loss upper bounds the CE loss, i.e., $L _ { \mathrm { C E } } ^ { \mu } ( f ) \ge \operatorname* { m i n } _ { g } \mathcal { L } _ { \mathrm { C E } } ( f , g )$ and Saunshi et al. (2019) showed that the mean classifier could achieve comparable performance to learned weights. Then, we have the following upper and lower bounds on the downstream risk (measured by mean CE loss).
|
| 91 |
+
|
| 92 |
+

|
| 93 |
+
(b) Augmentation graph under increasing augmentation strengthes (left to right).
|
| 94 |
+
|
| 95 |
+
(a) Contrastive learning with an augmentation graph satisfying intra-class connectivity.
|
| 96 |
+
|
| 97 |
+
Figure 3: Illustrative examples of augmentation graphs, where each dot denotes a sample $x \in \mathcal { D } _ { u }$ and its color denotes its class. The lighter disks denote the support of the positive samples $p ( x ^ { + } | x )$ . We draw a solid edge for each $\tau$ -connected pair.
|
| 98 |
+
|
| 99 |
+
Theorem 4.2 (Guarantees for General Encoders). If Assumption 4.1 holds, then, for any $f \in { \mathcal { F } }$ , its downstream classification risk $\mathcal { L } _ { \mathrm { C E } } ^ { \mu } ( f )$ can be bounded by the contrastive learning risk $\mathcal { L } _ { \mathrm { N C E } } ( f )$
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
\begin{array} { r l } & { \quad \mathcal { L } _ { \mathrm { N C E } } ( f ) - \sqrt { \mathrm { V a r } ( f ( x ) \mid y ) } - \frac { 1 } { 2 } \mathrm { V a r } ( f ( x ) \mid y ) - \mathcal { O } \left( M ^ { - 1 / 2 } \right) } \\ & { \leq \mathcal { L } _ { \mathrm { C E } } ^ { \mu } ( f ) + \log ( M / K ) \leq \mathcal { L } _ { \mathrm { N C E } } ( f ) + \sqrt { \mathrm { V a r } ( f ( x ) \mid y ) } + \mathcal { O } \left( M ^ { - 1 / 2 } \right) , } \end{array}
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
where $\log ( M / K )$ is a constant\*, $\operatorname { V a r } ( f ( x ) | y ) = \mathbb { E } _ { p ( y ) } \left[ \mathbb { E } _ { p ( x | y ) } | | f ( x ) - \mathbb { E } _ { p ( x | y ) } f ( x ) | | ^ { 2 } \right]$ denotes the conditional (intra-class) feature variance, and $\mathcal { O } \left( M ^ { - 1 / 2 } \right)$ denotes the order of the approximation error by using $M$ negative samples.
|
| 106 |
+
|
| 107 |
+
Notably, our generalization bounds above improve over previous ones in the following aspects:
|
| 108 |
+
|
| 109 |
+
1) we do not require the conditional independence assumption as in Saunshi et al. (2019); 2) we directly analyze the widely adopted InfoNCE loss (for contrastive learning) and CE loss (for supervised finetuning), while Saunshi et al. (2019) are restricted to hinge and logistic objectives that have worse performance in practice (Chen et al., 2020a); 3) the class collision error terms introduced in Saunshi et al. (2019) (due to the existence of same-class samples in the negative samples) now disappear in our bounds by adopting the InfoNCE loss, which also helps understand why InfoNCE performs better in practice; and 4) the bounds in Saunshi et al. (2019) will become looser with more negative samples, which is contradictory to the common practice (Chen et al., 2020a). While in our bounds, a larger $M$ indeed has a lower approximation error and helps close the generalization gap.
|
| 110 |
+
|
| 111 |
+
In fact, several recent works have also been devoted to resolve the last “large- $M ^ { \prime }$ ” problem (Ash et al., 2021; Merad et al., 2020). Nevertheless, their analysis also requires the conditional independence assumption as in Saunshi et al. (2019), while we show this problem can be resolved even without conditional independence. Nozawa & Sato (2021) also establish bounds for the InfoNCE loss, but their bounds have incompressible class collision terms while ours do not.
|
| 112 |
+
|
| 113 |
+
Nevertheless, an important message of the theorem above is that Assumption 4.1 alone is still insufficient to guarantee good downstream performance. As there are intra-class variance terms in the upper and lower bounds, when they are large enough, contrastive learning might still have inferior performance as shown in Proposition 3.1. Although the variance terms can be easily eliminated with the canonical conditional independence assumption, discussions in Section 1 have already demonstrated its impracticality. In the next part, we will present a new understanding of how contrastive learning could control this variance term in practice.
|
| 114 |
+
|
| 115 |
+
# 4.2 CLOSING THE GAP WITH INTRA-CLASS CONNECTIVITY
|
| 116 |
+
|
| 117 |
+
The theorem above motivates us to study how contrastive learning could effectively control its intraclass variance and learn class-separated features. Here, we propose a new understanding of this clustering ability through a dissection of the augmented views. In particular, we notice that although samples are different from each other, applying aggressive augmentations like that in SimCLR (Chen et al., 2020a) can largely make them more alike. For example, in Figure 1(b), two different cars become very similar when they are both cropped to the wheels. Then, with contrastive learning, the two cars will have closer representations as they share a common view of the wheels. In other words, two different intra-class samples could be aligned together if they have overlapped augmented views. If all intra-class samples could be bridged by data augmentations, we can successfully cluster the whole class together. Below, we formalize the intuition above with the language of graphs.
|
| 118 |
+
|
| 119 |
+
Notations. A graph $\mathcal { G }$ is represented by a tuple $\mathcal { G } = ( \nu , \mathcal { E } )$ where $\mathcal { V } = ( v _ { 1 } , v _ { 2 } , \ldots , v _ { N } )$ is a set of vertices and $\mathcal { E } \subseteq \mathcal { V } \times \mathcal { V }$ is a set of edges. A path is a sequence of edges that joins a sequence of vertices, e.g., $v _ { i _ { 1 } } - v _ { i _ { 2 } } - \cdot \cdot \cdot - v _ { i _ { k } }$ . We say that two vertices $v$ and $u$ are connected if $\mathcal { G }$ contains a path from $v$ to $u$ . A graph is said to be connected if every pair of vertices in the graph is connected. Two graphs are said to be disjoint if any pair of inter-graph vertices are not connected.
|
| 120 |
+
|
| 121 |
+
To begin with, we define the concept of $\tau$ -connectivity of sample pairs, which describes whether two samples could be connected via the augmentation overlap of their augmented views.
|
| 122 |
+
|
| 123 |
+
Definition 4.3 ( $\tau$ -connectivity). Given a collection of augmentations $\mathcal { T } = \{ t \ | \ t : \mathbb { R } ^ { d } \to \mathbb { R } ^ { d } \}$ , we say that two different images $x _ { i } , x _ { j } \ \in \ \mathbb { R } ^ { d }$ are $\tau$ -connected if they have overlapped views: $\mathrm { s u p p } ( p ( x _ { i } ^ { + } | x _ { i } ) ) \bigcap \mathrm { s u p p } ( p ( x _ { j } ^ { + } | x _ { j } ) ) \neq \partial$ , or equivalently, $\exists t _ { i } , t _ { j } \in \mathcal { T }$ such that $t _ { i } ( x _ { i } ) = t _ { j } ( x _ { j } )$ .
|
| 124 |
+
|
| 125 |
+
Then, we can define an augmentation graph of all training samples in terms of their $\tau$ -connectivity. Definition 4.4 (Augmentation Graph). Given a set of $N$ samples $\mathcal { D } = \{ x _ { i } \} _ { i = 1 } ^ { N }$ and an augmentation set $\mathcal { T } = \{ t \mid t : \mathbb { R } ^ { d } \mathbb { R } ^ { d } \}$ , we can define an augmentation graph $\mathcal { G } ( \mathcal { D } , \mathcal { T } ) = ( \nu , \mathcal { E } )$ as
|
| 126 |
+
|
| 127 |
+
• we take the $N$ natural samples as the vertices of the graph, i.e., $ { \gamma } = \{ x _ { i } \} _ { i = 1 } ^ { N }$ ;
|
| 128 |
+
• there exists an edge $e _ { i j }$ between two vertices $x _ { i }$ and $x _ { j }$ if they are $\tau$ -connected.
|
| 129 |
+
|
| 130 |
+
Based on these concepts, we introduce the following assumption that with a proper choice of data augmentations, all intra-class samples could form a connected graph, as depicted in Figure 3(a).
|
| 131 |
+
|
| 132 |
+
Assumption 4.5 (Intra-class Connectivity). Given a training set $\mathcal { D } _ { u }$ , there exists an appropriate augmentation set $\tau$ such that the augmentation graph $\mathcal { G } ( \mathcal { D } _ { u } , \bar { \mathcal { T } } )$ is class-wise connected, i.e., $\forall k \in$ $\{ 1 , \ldots , K \}$ , the subgraph $\mathcal { G } _ { k }$ (graph $\mathcal { G }$ restricted to vertices in class $k$ ) is connected.
|
| 133 |
+
|
| 134 |
+
Comparing to Saunshi et al. (2019) and Lee et al. (2020) that require (nearly) conditional independence $p ( \tilde { x , x ^ { + } } | y ) = p ( x | y ) p ( x ^ { + } | y )$ , ours only requires the connectivity of intra-class samples as in Figure 1(b), and does not need them to be conditionally independent.
|
| 135 |
+
|
| 136 |
+
To make this analysis technically simpler, we make another assumption that we can align positive samples perfectly by minimizing the InfoNCE loss. In practice, the alignment loss can typically be minimized up to a small error $\varepsilon$ , and we have appended a more involved discussion of this weak alignment scenario in Appendix B. For now, we focus on the simplified perfect alignment scenario.
|
| 137 |
+
|
| 138 |
+
Assumption 4.6 (Perfect Alignment). At the minimizer $f ^ { \star }$ of the InfoNCE loss, we can achieve perfect alignment, i.e., $\forall x , x ^ { \bar { + } } \sim p ( x , x ^ { + } ) , f ^ { \star } ( x ) = f ^ { \star } ( x ^ { + } )$ .
|
| 139 |
+
|
| 140 |
+
Proposition 4.7. Under Assumptions 4.5 & 4.6, by minimizing the InfoNCE loss we can conclude that the conditional variance terms vanish at the minimizer $f ^ { \star }$ , i.e.,
|
| 141 |
+
|
| 142 |
+
$$
|
| 143 |
+
\operatorname { V a r } ( f ^ { \star } ( x ) \mid y ) = 0 .
|
| 144 |
+
$$
|
| 145 |
+
|
| 146 |
+
Intuitively, for samples in each class $k$ , if the corresponding subgraph $\mathcal { G } _ { k }$ is connected, there exists a path connecting every intra-class pairs $( x _ { i } , x _ { j } )$ , as shown in Figure 3(a). Consequently, aligning the positive pairs will also align all samples on the path, and eventually align $x _ { i }$ and $x _ { j }$ . In this way, all intra-class samples can be clustered together and the intra-class variance shrinks to zero (under Assumption 4.6). Besides, because proper data augmentation will not cause inter-class augmentation overlap (Assumption 4.1), inter-class samples can be well separated with the uniformity term. As a result, we can attain alignment of intra-class samples while maximizing the uniformity of inter-class samples. According to Theorem 4.2, we will have an asymptotically closed generalization gap (with more negative samples $M \to \infty$ ) for the encoder that minimizes the contrastive loss.
|
| 147 |
+
|
| 148 |
+
Theorem 4.8 (Guarantees for the Optimal Encoder). If Assumption 4.1, 4.5 & 4.6 hold and $f$ is $L$ -smooth, then, for the minimizer $f ^ { \star } = \arg \operatorname* { m i n } \mathcal { L } _ { \mathrm { N C E } } ( f )$ , its classification risk can be upper and lower bounded by its contrastive risk as
|
| 149 |
+
|
| 150 |
+
$$
|
| 151 |
+
\begin{array} { r l } { { \mathcal { L } } _ { \mathrm { N C E } } ( f ^ { \star } ) - { \mathcal { O } } \left( M ^ { - 1 / 2 } \right) \leq } & { { \mathcal { L } } _ { \mathrm { C E } } ^ { \mu } ( f ^ { \star } ) + \log ( M / K ) \leq { \mathcal { L } } _ { \mathrm { N C E } } ( f ^ { \star } ) + { \mathcal { O } } \left( M ^ { - 1 / 2 } \right) . } \end{array}
|
| 152 |
+
$$
|
| 153 |
+
|
| 154 |
+

|
| 155 |
+
Figure 4: t-SNE visualization of features learned with different augmentation strength $r$ on the random augmentation graph experiment. Each dot denotes a sample and its color denotes its class.
|
| 156 |
+
|
| 157 |
+
We note that different to previous bounds that hold for any $f \in { \mathcal { F } }$ as in Theorem 4.2, our results here only stand for the minimizer of the contrastive loss $\bar { f } ^ { \star }$ . This indicates that the InfoNCE loss alone cannot simply guarantee good downstream performance, and the learning dynamics matters for the contrastive learning to learn useful features.
|
| 158 |
+
|
| 159 |
+
# 4.3 RETHINKING THE ROLE OF DATA AUGMENTATIONS
|
| 160 |
+
|
| 161 |
+
Our analysis above suggests a new understanding of the role of data augmentations in contrastive learning. Conventionally, the success of contrastive learning is usually attributed to learning invariance w.r.t. various data augmentations by matching positive examples. However, as shown in Proposition 3.1, matching positive pairs alone is theoretically inadequate to learn useful features. Indeed, assuming that an ideal encoder that possesses invariance a priori does exist, like invariance to translation (CNNs), rotation (Cheng et al., 2016), and scaling (Xu et al., 2014), do we obtain class-discriminative features simply by random initialization? Still NO, since these low-level properties are independent of high-level class information that we want to learn. Thus, the reason why contrastive learning works cannot simply be attributed to the invariance learning principle.
|
| 162 |
+
|
| 163 |
+
We instead believe that the role of data augmentation is to create a certain degree of “chaos” between different intra-class samples (Figure 1(b)) such that they become more alike (or formally, $\tau$ -connected). In this way, the chaos serves as a “ladder” for bridging intra-class samples together when labels are absent, and the mission of the contrastive loss is to “climb this ladder”, that is, aligning intra-class samples by aligning the overlapped positive samples, as shown in Figure 3(a). Therefore, from our perspective, instance discrimination by contrastive learning is actually a surrogate for the classification task, and the surrogate can complete its misson when the ladder of chaos is complete (or formally, when intra-class connectivity holds).
|
| 164 |
+
|
| 165 |
+
# 5 QUANTIFYING THE INFLUENCE OF AUGMENTATION STRENGTH
|
| 166 |
+
|
| 167 |
+
We have shown that with appropriate augmentations, we can derive guarantees on downstream performance. However, in practice, as illustrated in Figure 3(b), there could be cases where augmentations are either too weak (intra-class features cannot be clustered together as in Figure 2) or too strong (inter-class features will also collapse to the same point) and lead to sub-optimal results. In this section, we further provide a quantitative analysis of how different strength of data augmentation will affect the final performance, both theoretically and empirically.
|
| 168 |
+
|
| 169 |
+
# 5.1 CHARACTERIZATION ON RANDOM AUGMENTATION GRAPH
|
| 170 |
+
|
| 171 |
+
In practice, there are various data augmentation types that are hard to be described precisely. For the ease of analysis, we consider a simple case where for each class $k$ , there are $N$ samples uniformly distributed around the cluster center $c _ { k }$ on a hypersphere $\mathbb { S } ^ { d }$ . We then augment each sample $x _ { i }$ with random samples in a hyper-disk of radius $r$ on the hypersphere.
|
| 172 |
+
|
| 173 |
+
In Appendix D, we provide theoretical analysis on how different augmentation strength (measured by $r$ ) will affect the connectivity of the augmentation as a function of the number of samples $N$ , the position of the cluster centers $c _ { k }$ and input dimensions $d$ . In particular, the minimal $r$ for the graph to be connected decreases as $N$ increases, so large-scale datasets can bring better connectivity. Meanwhile, the required $r$ also increases as $d$ increases, so we need more samples or stronger augmentations for large-size inputs. Here, we show our simulation results by applying contrastive learning to the problem above. From Figure 4, we can see that when $r = 0$ (no augmentation), the features are mixed together and hardly (linearly) separable, which corresponds to the under-overlap case in Figure 3(b). As we increase $r$ from 0 to 0.1, the features become more and more discriminative. And when $r$ is too large $( r = 1 . 5 )$ ), the inter-class features become mixed and inseparable again (over-overlap). In Appendix C.2, we provide visualization results of the augmentation graphs, which also align well with our analysis. Overall, our theoretical and empirical discussions verify our theory that intra-class augmentation overlap with a proper amount of data augmentation is crucial for contrastive learning to work well.
|
| 174 |
+
|
| 175 |
+

|
| 176 |
+
Figure 5: (a) Average Confusion Rate (ACR) and downstream accuracy v.s. different augmentation strength (before training). (b,c): ACR and downstream accuracy while training.
|
| 177 |
+
|
| 178 |
+
# 5.2 NEW SURROGATE METRICS FOR AUGMENTATION OVERLAP
|
| 179 |
+
|
| 180 |
+
From our theory and analysis above, we see that the augmentation overlap between intra-class samples indeed matters from contrastive learning to generalize better. Inspired by this, we propose the Confusion Ratio metric as a measure of the degree of augmentation overlap. Specifically, for an unlabeled dataset $\mathcal { D } _ { u }$ with $N$ samples, we randomly augment each raw sample $x _ { i } \ \in \ \bar { D _ { u } }$ for $C$ times, and get an augmented set $\tilde { \mathcal { D } _ { u } } = \{ x _ { i j } , i \in [ \dot { N } ] , j \in [ C ] \}$ . Then, for each $x _ { i p } \in \widetilde { D } _ { u }$ that is an augmented view of $x _ { i } \in \mathcal { D } _ { u }$ , denoting its $k$ -nearest neighbors in $ { \widetilde { \mathcal { D } } } _ { u }$ in the feature space of $f$ as $\mathcal { N } _ { k } \overline { { ( x _ { i p } , f ) } }$ and other augmented views from the same image as $\mathcal { C } ( x _ { i p } ) = \{ x _ { i j } , j \neq p \}$ , we can define its Confusion Ratio (CR) as the ratio of augmented views from different raw samples in its $k$ -nearest neighbors,
|
| 181 |
+
|
| 182 |
+
$$
|
| 183 |
+
\mathrm { C R } ( x _ { i j } , f ) = \frac { \# [ \mathcal { N } _ { k } ( x _ { i p } , f ) \setminus \mathcal { C } ( x _ { i p } ) ] } { \# \mathcal { N } _ { k } ( x _ { i p } , f ) } \in [ 0 , 1 ] .
|
| 184 |
+
$$
|
| 185 |
+
|
| 186 |
+
We also define its average as Average Confusion Ratio (ACR):
|
| 187 |
+
|
| 188 |
+
$$
|
| 189 |
+
\begin{array} { r } { \mathrm { A C R } ( f ) = \mathbb { E } _ { x _ { i j } \sim \widetilde { \mathcal { D } } _ { u } } \mathrm { C R } ( x _ { i j , f } ) . } \end{array}
|
| 190 |
+
$$
|
| 191 |
+
|
| 192 |
+
When augmentation overlap happens, the nearest neighbors could be augmented views from a different sample, leading to a higher ACR. Thus, ACR measures the degree of augmentation overlap, and a higher ACR indicates a higher degree of augmentation overlap. Here we take $k = 1$ by default.
|
| 193 |
+
|
| 194 |
+
Here, to measure the augmentation strength in real-world datasets, following the common practice (Chen et al., 2020a), we adopt the RandomResizedCrop operator with scale range $[ a , b ]$ for data augmentation, and we define its strength of augmentation as $r = ( 1 - b ) + ( 1 - \bar { a } )$ (a comparison with other kinds of augmentations, e.g., color jittering, can be found in Appendix C.1). As shown in Figure 5(a), ACR (augmentation overlap) indeed increases with the strength of data augmentations, and only a moderate ACR achieves the best accuracy, which is consistent with our theory discussed above. Besides, we also plot the change of ACR along the training process in Figure 5(b) & 5(c). We can notice that for weak augmentations, the initial ACR is low, and it rapidly decreases to zero and seldom changes while training, which leads to poor test accuracy. Instead, with proper augmentations, the initial ACR is higher, and it gradually decreases to zero and obtains good accuracy. This is also consistent with our theory that we need a certain amount of augmentation overlap for contrastive learning to work well. At the beginning, this will lead to a higher ACR, but as training continues, better alignment (lower ACR) will help bring up the test accuracy.
|
| 195 |
+
|
| 196 |
+
Average Relative Confusion (ARC). In the discussion above, we notice that ACR itself does not indicate the test accuracy, but the relative change of ACR before and after training can be used as such an indicator. A large change of ACR means a large change of augmentation overlap, which indicates that the contrastive loss can actually cluster intra-class samples together through overlapped views. Based on this observation, we propose Average Relative Confusion (ARC) as
|
| 197 |
+
|
| 198 |
+

|
| 199 |
+
Figure 6: Average Relative Confusion (ARC) and downstream accuracy v.s. different augmentation strength on different datasets (CIFAR-10, CIFAR-100, and STL-10) with different contrastive learning methods: SimCLR (Chen et al., 2020a) and BYOL (Grill et al., 2020).
|
| 200 |
+
|
| 201 |
+

|
| 202 |
+
Figure 7: Average Relative Confusion (ARC) and downstream accuracy v.s. different augmentation strength on CIFAR-10 (SimCLR) with different number of nearest neighbors $k$ .
|
| 203 |
+
|
| 204 |
+
$$
|
| 205 |
+
\mathrm { A R C } = \frac { 1 - \mathrm { A C R } ( f _ { \mathrm { f i n a l } } ) } { 1 - \mathrm { A C R } ( f _ { \mathrm { i n i t } } ) } ,
|
| 206 |
+
$$
|
| 207 |
+
|
| 208 |
+
a ratio calculated with the initial ACR of the initialized model $f _ { \mathrm { i n i t } }$ and the final ACR of the pretrained model $f _ { \mathrm { f i n a l } }$ . A higher ARC indicates that the contrastive learning process faces a hard task (augmentation overlap) at the beginning (high initial ACR), while successfully clustering intra-class samples with good alignment of positive samples at the end (lo final ACR). Therefore, a higher ARC score should correspond to higher downstream accuracy.
|
| 209 |
+
|
| 210 |
+
As shown in Figure 6 & 7, as augmentations become stronger, ARC scores indeed align well with the change of downstream accuracy across 1) different datasets, 2) different contrastive methods, and 3) different choices of $k$ . This justifies our understanding of contrastive learning through augmentation overlap. Meanwhile, as the calculation of ARC only involves unsupervised data, it could serve as a good surrogate metric for evaluating contrastive learning without using labeled data. Compared to previous evaluation methods like linear classification (Eq. 2), our ARC metric is more preferable as 1) it is theoretically motivated; 2) it does not need labeled data; 3) it does not need to learn additional modules like linear classifiers or rotation tasks (Reed et al., 2021). More experimental details can be found in Appendix E.
|
| 211 |
+
|
| 212 |
+
# 6 CONCLUSION
|
| 213 |
+
|
| 214 |
+
In this paper, we have proposed a new understanding of contrastive learning through a revisiting of the role of data augmentations. In particular, we notice the aggressive data augmentation applied in contrastive learning can significantly increase the augmentation overlap between intra-class samples, and as a result, by aligning positive samples, we can also cluster inter-class samples together. Based on this insight, we develop a new augmentation overlap theory that could guarantee good downstream performance without relying on conditional independence and obtain asymptotically closed gaps. With this perspective, we also characterize how different augmentation strength affects downstream performance with both random graphs and real-world datasets. Last but not least, we also develop a new surrogate metric for evaluating contrastive learning without labels and show that it aligns well with downstream performance. Overall, we believe that we pave a new way for understanding contrastive learning with insights on the designing of contrastive methods and evaluation metrics.
|
| 215 |
+
|
| 216 |
+
# ACKNOWLEDGEMENT
|
| 217 |
+
|
| 218 |
+
Yisen Wang is partially supported by the National Natural Science Foundation of China under Grant 62006153, Project 2020BD006 supported by PKU-Baidu Fund, and Huawei Technologies Inc. Jiansheng Yang is supported by the National Science Foundation of China under Grant No. 11961141007. Zhouchen Lin is supported by the NSF China (No. 61731018), NSFC Tianyuan Fund for Mathematics (No. 12026606), Project 2020BD006 supported by PKU-Baidu Fund, and Qualcomm.
|
| 219 |
+
|
| 220 |
+
# REFERENCES
|
| 221 |
+
|
| 222 |
+
Jordan T Ash, Surbhi Goel, Akshay Krishnamurthy, and Dipendra Misra. Investigating the role of negatives in contrastive representation learning. arXiv preprint arXiv:2106.09943, 2021.
|
| 223 |
+
|
| 224 |
+
Ivan Budimir, Sever S Dragomir, and Josep Pecaric. Further reverse results for jensen’s discrete inequality and applications in information theory. RGMIA research report collection, 3(1), 2000.
|
| 225 |
+
|
| 226 |
+
Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. ICML, 2020a.
|
| 227 |
+
|
| 228 |
+
Ting Chen, Simon Kornblith, Kevin Swersky, Mohammad Norouzi, and Geoffrey Hinton. Big selfsupervised models are strong semi-supervised learners. arXiv preprint arXiv:2006.10029, 2020b.
|
| 229 |
+
|
| 230 |
+
Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. arXiv preprint arXiv:2011.10566, 2020.
|
| 231 |
+
|
| 232 |
+
Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised vision transformers. arXiv preprint arXiv:2104.02057, 2021.
|
| 233 |
+
|
| 234 |
+
Gong Cheng, Peicheng Zhou, and Junwei Han. RIFD-CNN: Rotation-invariant and fisher discriminative convolutional neural networks for object detection. In CVPR, 2016.
|
| 235 |
+
|
| 236 |
+
Jean-Bastien Grill, Florian Strub, Florent Altche, C. Tallec, Pierre H. Richemond, Elena ´ Buchatskaya, C. Doersch, Bernardo Avila Pires, Zhaohan Daniel Guo, Mohammad Gheshlaghi Azar, B. Piot, K. Kavukcuoglu, Remi Munos, and Michal Valko. Bootstrap your own latent: A´ new approach to self-supervised learning. NeurIPS, 2020.
|
| 237 |
+
|
| 238 |
+
Jeff Z HaoChen, Colin Wei, Adrien Gaidon, and Tengyu Ma. Provable guarantees for self-supervised deep learning with spectral contrastive loss. NeurIPS, 2021.
|
| 239 |
+
|
| 240 |
+
Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. CVPR, 2020.
|
| 241 |
+
|
| 242 |
+
Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. NeurIPS, 2017.
|
| 243 |
+
|
| 244 |
+
R Devon Hjelm, Alex Fedorov, Samuel Lavoie-Marchildon, Karan Grewal, Phil Bachman, Adam Trischler, and Yoshua Bengio. Learning deep representations by mutual information estimation and maximization. ICLR, 2019.
|
| 245 |
+
|
| 246 |
+
Weiran Huang, Mingyang Yi, and Xuyang Zhao. Towards the generalization of contrastive selfsupervised learning. arXiv preprint arXiv:2111.00743, 2021.
|
| 247 |
+
|
| 248 |
+
Jason D Lee, Qi Lei, Nikunj Saunshi, and Jiacheng Zhuo. Predicting what you already know helps: Provable self-supervised learning. arXiv preprint arXiv:2008.01064, 2020.
|
| 249 |
+
|
| 250 |
+
Ibrahim Merad, Yiyang Yu, Emmanuel Bacry, and Stephane Ga ´ ¨ıffas. About contrastive unsupervised representation learning for classification and its convergence. arXiv preprint arXiv:2012.01064, 2020.
|
| 251 |
+
|
| 252 |
+
Kento Nozawa and Issei Sato. Understanding negative samples in instance discriminative selfsupervised representation learning. NeurIPS, 2021.
|
| 253 |
+
|
| 254 |
+
Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
|
| 255 |
+
|
| 256 |
+
Mathew D. Penrose. A Strong Law for the Longest Edge of the Minimal Spanning Tree. The Annals of Probability, 27(1):246 – 260, 1999.
|
| 257 |
+
Allon G Percus and Olivier C Martin. Scaling universalities of kth-nearest neighbor distances on closed manifolds. Advances in Applied Mathematics, 21(3):424–436, 1998. ISSN 0196-8858.
|
| 258 |
+
Ben Poole, Sherjil Ozair, Aaron Van Den Oord, Alex Alemi, and George Tucker. On variational bounds of mutual information. In ICML, 2019.
|
| 259 |
+
Colorado J Reed, Sean Metzger, Aravind Srinivas, Trevor Darrell, and Kurt Keutzer. Selfaugment: Automatic augmentation policies for self-supervised learning. In CVPR, 2021.
|
| 260 |
+
Nikunj Saunshi, Orestis Plevrakis, Sanjeev Arora, Mikhail Khodak, and Hrishikesh Khandeparkar. A theoretical analysis of contrastive unsupervised representation learning. In ICML, 2019.
|
| 261 |
+
Jiaming Song and Stefano Ermon. Understanding the limitations of variational mutual information estimators. In ICLR, 2020.
|
| 262 |
+
Yonglong Tian, Chen Sun, Ben Poole, Dilip Krishnan, Cordelia Schmid, and Phillip Isola. What makes for good views for contrastive learning. NeurIPS, 2020.
|
| 263 |
+
Christopher Tosh, Akshay Krishnamurthy, and Daniel Hsu. Contrastive estimation reveals topic posterior information to linear models. arXiv preprint arXiv:2003.02234, 2020.
|
| 264 |
+
Christopher Tosh, Akshay Krishnamurthy, and Daniel Hsu. Contrastive learning, multi-view redundancy, and linear models. In ALT, 2021.
|
| 265 |
+
Yao-Hung Hubert Tsai, Yue Wu, Ruslan Salakhutdinov, and Louis-Philippe Morency. Selfsupervised learning from a multi-view perspective. In ICLR, 2021.
|
| 266 |
+
Tongzhou Wang and Phillip Isola. Understanding contrastive representation learning through alignment and uniformity on the hypersphere, 2020.
|
| 267 |
+
Yifei Wang, Zhengyang Geng, Feng Jiang, Chuming Li, Yisen Wang, Jiansheng Yang, and Zhouchen Lin. Residual relaxation for multi-view representation learning. In NeurIPS, 2021.
|
| 268 |
+
Yichong Xu, Tianjun Xiao, Jiaxing Zhang, Kuiyuan Yang, and Zheng Zhang. Scale-invariant convolutional neural networks. arXiv preprint arXiv:1411.6369, 2014.
|
| 269 |
+
|
| 270 |
+
# A OMITTED PROOFS
|
| 271 |
+
|
| 272 |
+
# A.1 PROOF OF PROPOSITION 3.1
|
| 273 |
+
|
| 274 |
+
Proposition A.1 (Class-uniform features also minimize the InfoNCE loss). For $N$ training examples of $K$ classes, consider the case when features $\{ f ( x _ { i } ) \} _ { i = 1 } ^ { N }$ are randomly distributed in $\mathbb { S } ^ { m - 1 }$ with maximal uniformity while also satisfying $\forall x _ { i } , x _ { i } ^ { + } \sim p ( x , x ^ { + } ) , f ( x _ { i } ) = f ( x _ { i } ^ { + } )$ . Because we have perfect alignment and perfect uniformity, the InfoNCE loss achieves its minimum. However, the downstream classification accuracy is at most $1 / \check { K } + \varepsilon$ and $\varepsilon$ is nearly zero when $N$ is large enough.
|
| 275 |
+
|
| 276 |
+
Proof. We only need to give a counterexample that satisfy the desired classification accuracy. We consider the case when there is no $\tau$ -connectivity between any pair of samples from $\{ x _ { i } \} _ { i = 1 } ^ { N }$ , which is easily achieved if we adopt a small enough data augmentation. In this scenario, the perfect alignment of positive samples $( x _ { i } , x _ { i } ^ { + } )$ could have no effect on the other samples. Therefore, when the features $\{ f ( x _ { i } ) \} _ { i = 1 } ^ { N }$ are uniformly distributed in $\mathbb { S } ^ { m - 1 }$ , according to the law of large number, for any measurable set $\bar { \boldsymbol { u } } \in \mathbb { S } ^ { m - 1 }$ , when $N$ is large enough, there will be almost equal size of features from each class in $\mathcal { U }$ . Consequently, any classifier $g$ that classifies $\mathcal { U }$ to class $k$ will only have $1 / K$ accuracy asymptotically. □
|
| 277 |
+
|
| 278 |
+
# A.2 PROOF OF THEOREM 4.2
|
| 279 |
+
|
| 280 |
+
We will prove the upper and lower bounds separately as follows.
|
| 281 |
+
|
| 282 |
+
# A.2.1 THE UPPER BOUND
|
| 283 |
+
|
| 284 |
+
We first provide the upper bound of the approximation error of the following Monte Carlo estimate.
|
| 285 |
+
|
| 286 |
+
Lemma A.2. For $\mathrm { L S E } : = \log \mathbb { E } _ { p ( z ) } \exp ( f ( x ) ^ { \top } g ( z ) )$ , we denote its (biased) Monte Carlo estimate with $M$ random samples $z _ { i } \sim p ( z ) , i = 1 , . . . , M$ as $\begin{array} { r } { \widehat { \mathrm { L S E } } _ { M } = \log \frac { 1 } { M } \sum _ { i = 1 } ^ { M } \exp ( f ( x ) ^ { \top } g ( z _ { i } ) ) } \end{array}$ . Then the approximation error $A ( M )$ can be upper bounded in expectation as
|
| 287 |
+
|
| 288 |
+
$$
|
| 289 |
+
A ( M ) : = \mathbb { E } _ { p ( x , z _ { i } ) } | \widehat { \mathrm { L S E } } ( M ) - \mathrm { L S E } | \leq \mathcal { O } ( M ^ { - 1 / 2 } ) .
|
| 290 |
+
$$
|
| 291 |
+
|
| 292 |
+
We can see that the approximation error converges to zero in the order of $1 / M ^ { - 1 / 2 }$ .
|
| 293 |
+
|
| 294 |
+
Proof. First, we have
|
| 295 |
+
|
| 296 |
+
$$
|
| 297 |
+
\begin{array} { r l } & { \mathbb { E } _ { p ( x , z _ { i } ) } \left[ \log \displaystyle \frac { 1 } { M } \sum _ { i = 1 } ^ { M } \exp ( f ( x ) ^ { \top } g ( z _ { i } ) ) - \log \mathbb { E } _ { p ( z _ { i } ) } \exp ( f ( x ) ^ { \top } g ( z _ { i } ) ) \right] } \\ & { { \le } e \mathbb { E } _ { p ( x , z _ { i } ) } \left[ \displaystyle \frac { 1 } { M } \sum _ { i = 1 } ^ { M } \exp ( f ( x ) ^ { \top } g ( z _ { i } ) ) - \mathbb { E } _ { p ( z _ { i } ) } \exp ( f ( x ) ^ { \top } g ( z _ { i } ) ) \right] = \mathcal { O } ( M ^ { - 1 / 2 } ) , } \end{array}
|
| 298 |
+
$$
|
| 299 |
+
|
| 300 |
+
where the first inequality follows the Intermediate Value Theorem and $e$ (the natural number) is the upper bound of the absolute derivative of log between two points when $| f ( x ) ^ { \top } g ( z _ { i } ) | \leq 1$ . And the second inequality follows the Berry-Esseen Theorem given the bounded support of $\exp ( { f ( x ) } ^ { \top } g ( z _ { i } ) )$ as following: for i.i.d random variables $Y _ { i }$ with bounded support $\operatorname { s u p p } ( Y ) ~ \subset$ $[ - \alpha , \alpha ]$ , zero mean and bounded variance $\sigma _ { Y } ^ { 2 } < \alpha ^ { 2 }$ , we have:
|
| 301 |
+
|
| 302 |
+
$$
|
| 303 |
+
\begin{array} { r l } & { \mathbb { E } \left[ \left| \displaystyle \frac { 1 } { M } \displaystyle \sum _ { i = 1 } ^ { M ^ { d } } Y _ { i } \right| \right] = \frac { \sigma _ { y } } { \sqrt { M } } \mathbb { E } \left[ \left| \displaystyle \frac { 1 } { \sqrt { M } \sigma _ { y } } \displaystyle \sum _ { i = 1 } ^ { M } Y _ { i } \right| \right] } \\ & { = \frac { \sigma _ { Y } } { \sqrt { M } } \int _ { 0 } ^ { \infty \infty \pi } \mathbb { P } \left[ \left| \displaystyle \frac { 1 } { \sqrt { M } \sigma _ { Y } } \displaystyle \sum _ { i = 1 } ^ { M } Y _ { i } \right| > x \right] \mathrm { d } x } \\ & { \le \frac { \sigma _ { Y } } { \sqrt { M } } \int _ { 0 } ^ { \infty \pi } \mathbb { P } [ | N ( 0 , 1 ) | > x ] + \frac { C _ { \alpha } } { \sqrt { M } } \mathrm { d } x } \\ & { \le \frac { \sigma _ { Y } } { \sqrt { M } } \left( \frac { \alpha C _ { \alpha } } { \sigma _ { Y } } + \displaystyle \int _ { 0 } ^ { \infty } \mathbb { P } [ | N ( 0 , 1 ) | > x ] \mathrm { d } x \right) } \\ & { \le \frac { C _ { \alpha } } { \sqrt { M } } + \frac { \alpha } { \sqrt { M } } \mathbb { E } [ | N ( 0 , 1 ) | ] = \mathcal { O } ( M ^ { - 1 / 2 } ) } \end{array}
|
| 304 |
+
$$
|
| 305 |
+
|
| 306 |
+
where the constant $C _ { \alpha }$ only depends on $\alpha$ . Here, we set $\begin{array} { r l r } { Y _ { i } } & { { } = } & { \exp ( f ( x ) ^ { \top } g ( z _ { i } ) ) ~ - } \end{array}$ $\mathbb { E } _ { p ( z _ { i } ) } \exp ( f ( x ) ^ { \top } g ( z _ { i } ) )$ . As $| \mathbf { \bar { \Psi } } f ( x ) ^ { \dagger } g ( z _ { i } ) | \leq 1$ , $| Y _ { i } | \le 2 e$ . $Y _ { i }$ has zero mean and bounded variance $( 2 e ) ^ { 2 }$ . □
|
| 307 |
+
|
| 308 |
+
Theorem A.3. For each $f \in { \mathcal { F } }$ , the mean $C E$ loss can be upper bounded by the InfoNCE loss:
|
| 309 |
+
|
| 310 |
+
$$
|
| 311 |
+
\begin{array} { r } { \mathcal { L } _ { \mathrm { C E } } ^ { \mu } ( x , y ; f ) \leq \mathcal { L } _ { \mathrm { N C E } } ( x ; f ) - \log ( M / K ) + \sqrt { \mathrm { V a r } ( f ( x ) \mid y ) } + A ( M ) , } \end{array}
|
| 312 |
+
$$
|
| 313 |
+
|
| 314 |
+
where $\operatorname { V a r } ( f ( x ) | y ) = \mathbb { E } _ { p ( y ) } \left[ \mathbb { E } _ { p ( x | y ) } | | f ( x ) - \mathbb { E } _ { p ( x | y ) } f ( x ) | | ^ { 2 } \right]$ denotes the conditional variance.
|
| 315 |
+
|
| 316 |
+
Proof. Denote $p ( x , x ^ { + } , y )$ as the joint distribution of the positive pairs $x , x ^ { + }$ and the label $y$ . Denote the $M$ independently negative smaples as $\{ x _ { i } ^ { - } \} _ { i = 1 } ^ { M }$ . According to Assumption 4.1, $x ^ { + }$ and $x$ here has the same label $y$ . Denote $\mu _ { y }$ as the center of features of class y, $y = \mathsf { \bar { 1 } } , \ldots , K$ . Then we have the following lower bounds of the InfoNCE loss,
|
| 317 |
+
|
| 318 |
+
$$
|
| 319 |
+
\begin{array} { r l } & { \quad - \nu _ { 6 , 0 , e } / \nu _ { 1 , 0 } ^ { 2 } \nu _ { 2 , 0 } ^ { 3 } \nu _ { 1 , 0 } ^ { 4 } + 6 \nu _ { 1 , 1 } \nu _ { 2 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } } \\ & { \stackrel { ( a , b ) } { \geq } \nu _ { 6 , 0 , e } / \nu _ { 2 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } + 6 \nu _ { 1 , 1 } \nu _ { 2 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 2 , 0 } ^ { 4 } \nu _ { 2 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } + 6 \nu _ { 1 , 1 } \nu _ { 1 , 0 } ^ { 4 } } \\ & { \stackrel { ( b , c ) } { \geq } \nu _ { 6 , 0 , e } / \nu _ { 1 , 0 } ^ { 2 } \nu _ { 2 , 1 } ^ { 4 } + 6 \nu _ { 1 , 1 } ^ { 2 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } + 6 \nu _ { 1 , 1 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } } \\ & { \quad - \nu _ { 6 , 0 , e } / \nu _ { 1 , 0 } ^ { 4 } \nu _ { 2 , 1 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } \nu _ { 1 , 0 } ^ { 4 } } \\ & \stackrel { ( c , d ) } { = } - \nu _ { 6 , e } - \nu _ { 9 , e } / \nu _ { 2 , e } ^ { 2 } \nu _ { 1 , e } ^ { 2 } \nu _ { 2 , e } ^ { 3 } \nu _ { 1 , e } ^ { 4 } \nu _ { 1 , e } ^ { 4 } \nu _ { 1 , e } ^ { 4 } \nu _ { 1 , e } ^ { 4 } \nu _ { 1 , e } ^ { 4 } \nu _ { 1 , e } ^ { 4 } \nu _ { 1 , e } ^ \end{array}
|
| 320 |
+
$$
|
| 321 |
+
|
| 322 |
+
which is equivalent to our desired results. In the proof above, (1) follows Lemma A.2; (2) follows the Jensen’s inequality for the convex function $\exp ( \cdot )$ ; (3) follows from the fact that because $f ( x ) \in$ $\mathbb { S } ^ { m - 1 }$ , we have
|
| 323 |
+
|
| 324 |
+
$$
|
| 325 |
+
f ( x ) ^ { \top } ( f ( x ^ { + } ) - \mu _ { y } ) \leq \left( { \frac { f ( x ^ { + } ) - \mu _ { y } } { \| f ( x ^ { + } ) - \mu _ { y } \| } } \right) ^ { \top } ( f ( x ^ { + } ) - \mu _ { y } ) = \| f ( x ^ { + } ) - \mu _ { y } \| ;
|
| 326 |
+
$$
|
| 327 |
+
|
| 328 |
+
and (4) follows the Cauchy–Schwarz inequality and the fact that because $p ( x , x ^ { + } ) \ : = \ : p ( x ^ { + } , x )$ holds, $x , x ^ { + }$ have the same marginal distribution. □
|
| 329 |
+
|
| 330 |
+
# A.2.2 THE LOWER BOUND
|
| 331 |
+
|
| 332 |
+
In this part, we further show a lower bound on the downstream performance.
|
| 333 |
+
|
| 334 |
+
Lemma A.4 (Budimir et al. (2000) Corollary 3.5 (restated)). Let $g : \mathbb { R } ^ { m } \mathbb { R }$ be a differentiable convex mapping and $z \in \mathbb { R } ^ { n }$ . Suppose that $g$ is $L$ - smooth with the constant $L > 0$ , i.e., $\forall x , y \in$ $\mathbb { R } ^ { m } , \| \nabla g ( \dot { x } ) - \nabla g ( y ) \| \le L \| x - \dot { y } \|$ . Then we have
|
| 335 |
+
|
| 336 |
+
$$
|
| 337 |
+
0 \leq \mathbb { E } _ { p ( z ) } g ( z ) - g \left( \mathbb { E } _ { p ( z ) } z \right) \leq L \left[ \mathbb { E } _ { p ( z ) } \| z \| ^ { 2 } - \| \mathbb { E } _ { p ( z ) } z \| ^ { 2 } \right] = L \sum _ { j = 1 } ^ { n } \mathrm { V a r } ( z ^ { ( j ) } ) ,
|
| 338 |
+
$$
|
| 339 |
+
|
| 340 |
+
where $x ^ { ( j ) }$ denotes the $j$ -th dimension of $x$
|
| 341 |
+
|
| 342 |
+
With the lemma above, we can derive the lower bound of the downstream performance.
|
| 343 |
+
|
| 344 |
+
Theorem A.5. For any $f \in { \mathcal { F } }$ , we have
|
| 345 |
+
|
| 346 |
+
$$
|
| 347 |
+
L _ { \mathrm { C E } } ^ { \mu } ( f ) \geq \mathcal { L } _ { \mathrm { N C E } } ( x ; f ) - \sqrt { \mathrm { V a r } ( f ( x ) \mid y ) } - \frac { 1 } { 2 } \mathrm { V a r } ( f ( x ) \mid y ) - A ( M ) - \log \frac { M } { K } ,
|
| 348 |
+
$$
|
| 349 |
+
|
| 350 |
+
where $\mathrm { V a r } ( u ( x ) | y ) = \mathbb { E } _ { p ( y ) } \left[ \mathbb { E } _ { p ( x | y ) } | | u ( x ) - \mathbb { E } _ { p ( x | y ) } u ( x ) | | ^ { 2 } \right]$ denotes the conditional variance.
|
| 351 |
+
|
| 352 |
+
Proof. Similar to the proof of Theorem A.3, we have
|
| 353 |
+
|
| 354 |
+
$$
|
| 355 |
+
\begin{array} { r l } & { \begin{array} { r l } & { \quad \lambda ^ { 2 } \lambda ^ { 3 } \mu _ { 3 } - \lambda ^ { 3 } \mu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } + \lambda ^ { 3 } \mu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) } \\ & { = \quad \mathrm { E } _ { \mu \nu \mu \nu \lambda } ( \dot { \mathcal { R } } ^ { 2 } ) \ \dot { \mathcal { R } } \ \mu \mu \dot { \mathcal { R } } \mu \dot { \mathcal { R } } \mu \dot { \mathcal { R } } \mu \dot { \mathcal { R } } \dot { \mathcal { R } } \dot { \mathcal { R } } } \\ & { \quad - \mathrm { E } _ { \mu \nu \nu \lambda } ( \dot { \mathcal { R } } ^ { 2 } ) \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) \dot { \mathcal { R } } \mu \mu \dot { \mathcal { R } } \mu \dot { \mathcal { R } } \dot { \mathcal { R } } ) \dot { \mathcal { R } } \mu \dot { \mathcal { R } } \dot { \mathcal { R } } } \end{ 1 } } \\ & \begin{array} { r l } & \quad - \mu _ { 5 } - \lambda ^ { 2 } \mu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } + \lambda ^ { 2 } \mu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot { \mathcal { R } } ^ { 2 } ) ^ { 2 } \nu _ { 5 } ( \dot \mathcal R \end{array} \end{array} \end{array}
|
| 356 |
+
$$
|
| 357 |
+
|
| 358 |
+
which is our desired result. In the proof, (1) we adopt a Monte Carlo estimate with $M$ samples from $p ( y )$ and bound the approximation error with Lemma A.2; (2) follows the same deduction in Theorem A.3; (3) the first term is derived following the Cauchy–Schwarz inequality for the alignment term. As for the second term, we first show that the convex function logsumexp is $L$ -smooth as a function of $f ( x _ { j } ^ { - } )$ in our scenario. Because $\| f ( X ) \| \leq 1$ , we have $\forall f ( x _ { j _ { 1 } } ) , f ( x _ { j _ { 2 } } ) \in \mathbb { R } ^ { m }$ , the following bound on the difference of their gradients holds
|
| 359 |
+
|
| 360 |
+
$$
|
| 361 |
+
\begin{array} { r l } & { \Big \| \frac { \partial \log \left[ \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 1 } } ^ { - } ) + \sum _ { i \neq j } \exp ( f ( x ) ^ { \top } f ( x _ { i } ^ { - } ) ) ) \right] } { \partial f ( x _ { j _ { 1 } } ^ { - } ) } - \frac { \partial \log \left[ \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 2 } } ^ { - } ) + \sum _ { i \neq j } \exp ( f ( x ) ^ { \top } f ( x _ { i } ^ { - } ) ) ) \right] } { \partial f ( x _ { j _ { 2 } } ^ { - } ) } } \\ & { = \Big \| \left( \frac { \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 1 } } ^ { - } ) ) } { \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 1 } } ^ { - } ) + \sum _ { i \neq j } \exp ( f ( x _ { i } ^ { - } ) ) ) } - \frac { \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 2 } } ^ { - } ) ) } { \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 2 } } ^ { - } ) + \sum _ { i \neq j } \exp ( f ( x ) ^ { \top } f ( x _ { i } ^ { - } ) ) ) } \right) f \ } \\ & \leq \Big | \frac { ( \sum _ { i \neq j } \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 1 } } ^ { - } ) ) \exp ( f ( x _ { j _ { 1 } } ^ { - } ) ) - \sum _ { i \neq j } \exp ( f ( x ) ^ { \top } f ( x _ { i } ^ { - } ) ) \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 2 } } ^ { - } ) ) } { \big \{ \exp ( f ( x ) ^ { \top } f ( x _ { j _ { 1 } } ^ { - } ) ) + \sum _ { i \neq j } \exp ( f ( x ) ^ { \top } f ( x _ { i } ^ { - } ) ) \big \} ( \exp ( f ( x ) ^ { \top } f ( x _ { i } ^ { - } ) ) } \\ & { \leq \big \| f ( x ) \big \| \leq \frac { 1 } { 2 } \big \| f ( x _ { j _ { 1 } } ^ { - } ) - f ( x _ { j } ^ { - } ) \big \| } \end{array}
|
| 362 |
+
$$
|
| 363 |
+
|
| 364 |
+
So here the logsumexp is $L$ -smooth for $\begin{array} { r } { L = \frac { 1 } { 2 } } \end{array}$ . Then, we can apply the reversed Jensen’s inequality in Lemma A.4; (4) holds because
|
| 365 |
+
|
| 366 |
+
$$
|
| 367 |
+
\begin{array} { l } { { \displaystyle \sum _ { j = 1 } ^ { m } \mathrm { V a r } ( f _ { j } ( x ) | y ) } \ ~ } \\ { { \displaystyle = \sum _ { j = 1 } ^ { m } \mathbb { E } _ { p ( y ) } \mathbb { E } _ { p ( x | y ) } ( f _ { j } ( x ) - \mathbb { E } _ { p ( x ^ { \prime } | y ) } f _ { j } ( x ^ { \prime } ) ) ^ { 2 } } } \\ { { \displaystyle = \mathbb { E } _ { p ( y ) } \mathbb { E } _ { p ( x | y ) } \sum _ { j = 1 } ^ { m } ( f _ { j } ( x ) - \mathbb { E } _ { x ^ { \prime } } f _ { j } ( x ^ { \prime } ) ) ^ { 2 } } } \\ { { \displaystyle = \mathbb { E } _ { p ( y ) } \mathbb { E } _ { p ( x | y ) } \| f ( x ) - \mathbb { E } _ { x ^ { \prime } } f ( x ^ { \prime } ) \| ^ { 2 } } } \\ { { \displaystyle = \mathrm { V a r } ( f ( x ) | y ) . } } \end{array}
|
| 368 |
+
$$
|
| 369 |
+
|
| 370 |
+
# A.3 PROOF OF PROPOSITION 4.7
|
| 371 |
+
|
| 372 |
+
Proposition A.6. Under Assumptions 4.5, & 4.6, by minimizing the InfoNCE loss, we can conclude that the conditional variance term vanishes, i.e.,
|
| 373 |
+
|
| 374 |
+
$$
|
| 375 |
+
\operatorname { V a r } ( f ( x ) \mid y ) = 0 .
|
| 376 |
+
$$
|
| 377 |
+
|
| 378 |
+
Proof. Consider any $\tau$ -connected sample $x _ { i } , x _ { j }$ . Accoding to the definition of $\tau$ -connectivity, there exist $t _ { i } , t _ { j } \in \mathcal { T }$ such that $t _ { i } ( x ) = t _ { j } ( x )$ . When perfect alignment holds as in Assumption 4.6, we will have $f ( x _ { i } ) = f ( t _ { i } ( x _ { i } ) )$ and ${ \bf { \bar { f } } } ( x _ { j } ) = f ( t _ { j } ( x _ { j } ) )$ . Combining with $t _ { i } ( x _ { i } ) = t _ { j } ( x _ { j } )$ , we have $f ( x _ { i } ) = f ( x _ { j } )$ . That is, any $\tau$ -connected pair has the same representation. Then, in the augmentation subgraph $\mathcal { G } _ { k }$ that is connected according to Assumption 4.5, there exists a path for any pair of samples $\bar { \hat { x } } _ { i } , \hat { x } _ { j } \in \mathcal G _ { k }$ where any two adjacent samples are $\tau$ -connected. As a result, ${ \hat { x } } _ { i }$ and $\bar { \hat { x } } _ { j }$ will also have the same representation by applying $\bar { \tau }$ -connectivity recursively. At last, all samples in $\mathcal { G } _ { k }$ will have the same representation and the intra-class variance vanishes. □
|
| 379 |
+
|
| 380 |
+
# A.4 PROOF OF THEOREM 4.8
|
| 381 |
+
|
| 382 |
+
Theorem A.7 (Guarantees for the optimal encoder). If Assumption 4.1, 4.5 & 4.6 hold and $f$ is $L$ -smooth, then, for the minimizer $f ^ { \star } = \arg \operatorname* { m i n } \mathcal { L } _ { \mathrm { N C E } } ( f )$ , its classification risk can be upper and lower bounded by its contrastive risk as
|
| 383 |
+
|
| 384 |
+
$$
|
| 385 |
+
\begin{array} { r l } { { \mathcal { L } } _ { \mathrm { N C E } } ( f ^ { \star } ) - { \mathcal { O } } \left( M ^ { - 1 / 2 } \right) \leq } & { { \mathcal { L } } _ { \mathrm { C E } } ^ { \mu } ( f ^ { \star } ) + \log ( M / K ) \leq { \mathcal { L } } _ { \mathrm { N C E } } ( f ^ { \star } ) + { \mathcal { O } } \left( M ^ { - 1 / 2 } \right) . } \end{array}
|
| 386 |
+
$$
|
| 387 |
+
|
| 388 |
+
Proof. A direct combination of Theorem 4.2 and 4.7 will give us the above two-sided bounds.
|
| 389 |
+
|
| 390 |
+
# B GENERALIZED GUARANTEES UNDER WEAK ALIGNMENT
|
| 391 |
+
|
| 392 |
+
In Section 4.2, we have shown that with perfect alignment (Assumption 4.6), the variance terms in the bounds of Theorem 4.2 can be minimized to zero, and consequently, the upper and lower bounds can be asymptotically closed. Nevertheless, in practice, due to the constraint of hypothesis class $\mathcal { F }$ and optimization algorithms, we typically cannot achieve the exact minimizer, i.e., a perfect degree of alignment. This motivates us to consider a less restrictive setting, namely the $\varepsilon$ -weak alignment assumption, where the alignment error could be as large as $\varepsilon$ .
|
| 393 |
+
|
| 394 |
+
Definition B.1 (Weak Alignment). $A$ mapping $f$ satisfies $\varepsilon$ -weak alignment $i f \ \forall \ x , x ^ { + } \sim$ $p ( x , x ^ { + } ) , \| f ( x ) - f ( x ^ { + } ) \| \bar { \leq } \varepsilon$ .
|
| 395 |
+
|
| 396 |
+
For any $\varepsilon$ -weak alignment $f \in { \mathcal { F } }$ , we have the following bounds on its downstream risk.
|
| 397 |
+
|
| 398 |
+
Theorem B.2 (Guarantees under weak alignment). If Assumption 4.1, 4.5 hold, then $\forall f \in { \mathcal { F } }$ satisfying $\varepsilon$ -weak alignment, its classification risk can be upper and lower bounded by its contrastive risk as
|
| 399 |
+
|
| 400 |
+
$$
|
| 401 |
+
\begin{array} { r l } & { \quad \mathcal { L } _ { \mathrm { N C E } } ( f ) - D \varepsilon - \cfrac { 1 } { 2 } D ^ { 2 } \varepsilon ^ { 2 } - \mathcal { O } \left( M ^ { - 1 / 2 } \right) } \\ & { \leq \mathcal { L } _ { \mathrm { C E } } ^ { \mu } ( f ) + \log ( M / K ) \leq \mathcal { L } _ { \mathrm { N C E } } ( f ) + D \varepsilon + \mathcal { O } \left( M ^ { - 1 / 2 } \right) , } \end{array}
|
| 402 |
+
$$
|
| 403 |
+
|
| 404 |
+
where $D$ denotes the maximal diameter of the intra-class augmentation graphs $\{ \mathcal { G } _ { k } , k = 1 , \ldots , K \}$ and m denotes the output dimension of the encoder $f$ .
|
| 405 |
+
|
| 406 |
+
In this way, we extend the guarantees developed for optimal encoders (Theorem 4.8) to even nonminimizers $f \in { \mathcal { F } }$ as long as it could align the positive samples within error $\varepsilon$ .
|
| 407 |
+
|
| 408 |
+

|
| 409 |
+
Figure 8: Evaluation of the maximal diameter $D$ as a function of different augmentation strength (a) and different number of samples (b) on the synthetic data in Section 5.1.
|
| 410 |
+
|
| 411 |
+
Empirical Verification. Besides the alignment error, we could notice this relaxation also introduces the dependence on an additional parameter $D$ , the maximal diameter of the intra-class augmentation graphs. As shown in Figure 8, when the augmentation is very weak, the intra-class graph is not connected and the diameter is $\infty$ . Then, by applying stronger augmentations, $D$ will become smaller and smaller, and finally converge to 1 (fully connected). Besides, increasing the number of samples, ranging from 50 to $1 \dot { 0 } , 0 0 0$ , does not have a large impact on $D$ in practice. Given these facts, we could reasonably assume that $D$ is bounded and has a relatively small value with properly chosen augmentations. As a result, with a bounded diameter $D$ , a small alignment error $\varepsilon$ will guarantee a small generalization gap between the upstream and downstream tasks. This generalizes Theorem 4.8 by quantifying the generalization gap under weak alignment.
|
| 412 |
+
|
| 413 |
+
Proof. Consider any pair of samples $( x , x ^ { \prime } )$ from the same class $y$ , and the positive sample of $x$ as $x ^ { + }$ . As intra-class connectivity holds, $x$ and $x ^ { \prime }$ are connected, and the maximal length of the path from $x$ to $x ^ { \prime }$ is $D$ . Therefore, under the $\varepsilon$ -weak alignment that
|
| 414 |
+
|
| 415 |
+
$$
|
| 416 |
+
\forall x , x ^ { + } \sim p ( x , x ^ { + } ) , \| f ( x ) - f ( x ^ { + } ) \| \leq \varepsilon ,
|
| 417 |
+
$$
|
| 418 |
+
|
| 419 |
+
we can bound the representation distance between $x$ and $x ^ { \prime }$ by the triangular inequality
|
| 420 |
+
|
| 421 |
+
$$
|
| 422 |
+
\| f ( x ) - f ( x ^ { \prime } ) \| { \leq } D \operatorname* { s u p } _ { p ( x , x ^ { + } | y \sim p ( x , x ^ { + } ) } \| f ( x ) - f ( x _ { + } ) \| { \leq } D \varepsilon .
|
| 423 |
+
$$
|
| 424 |
+
|
| 425 |
+
With the inequality above, we can bound the variance terms in Theorem 4.2. In particular, the conditional variance can be bounded as
|
| 426 |
+
|
| 427 |
+
$$
|
| 428 |
+
\begin{array} { r l } & { \quad \mathrm { V a r } ( f ( x ) \ | \ y ) } \\ & { = \mathbb { E } _ { p ( y ) } \mathbb { E } _ { p ( x \mid y ) } \| f ( x ) - \mathbb { E } _ { x ^ { \prime } } f ( x ^ { \prime } ) \| ^ { 2 } } \\ & { = \mathbb { E } _ { p ( y ) } \mathbb { E } _ { p ( x \mid y ) } \| \mathbb { E } _ { x ^ { \prime } } f ( x ) - f ( x ^ { \prime } ) \| ^ { 2 } } \\ & { \le \mathbb { E } _ { p ( y ) } \mathbb { E } _ { p ( x \mid y ) } \mathbb { E } _ { p ( x ^ { \prime } \mid y ) } \| f ( x ) - f ( x ^ { \prime } ) \| ^ { 2 } } \\ & { \le \mathbb { E } _ { p ( y ) } \underset { x , x ^ { \prime } \sim p ( x \mid y ) } { \mathrm { m a x } } \ \| f ( x ) - f ( x ^ { \prime } ) \| ^ { 2 } } \\ & { \overset { ( 1 ) } { \le } \mathbb { E } _ { p ( y ) } D ^ { 2 } \varepsilon ^ { 2 } = D ^ { 2 } \varepsilon ^ { 2 } } \end{array}
|
| 429 |
+
$$
|
| 430 |
+
|
| 431 |
+
where (1) follows Eq. 19. At last, we can bound the variance items in Theorem 4.2 with Eq. 20, arrive at the desired bounds
|
| 432 |
+
|
| 433 |
+
$$
|
| 434 |
+
\begin{array} { r l } & { \quad \mathcal { L } _ { \mathrm { N C E } } ( f ) - D \varepsilon - \cfrac { 1 } { 2 } D ^ { 2 } \varepsilon ^ { 2 } - \mathcal { O } \left( M ^ { - 1 / 2 } \right) } \\ & { \leq \mathcal { L } _ { \mathrm { C E } } ^ { \mu } ( f ) + \log ( M / K ) \leq \mathcal { L } _ { \mathrm { N C E } } ( f ) + D \varepsilon + \mathcal { O } \left( M ^ { - 1 / 2 } \right) , } \end{array}
|
| 435 |
+
$$
|
| 436 |
+
|
| 437 |
+
which conclude our proof.
|
| 438 |
+
|
| 439 |
+
# C ADDITIONAL EMPIRICAL EVIDENCE
|
| 440 |
+
|
| 441 |
+
# C.1 FURTHER EVALUATION OF ARC METRIC
|
| 442 |
+
|
| 443 |
+
In the main text, we study the effect of different strength of RandomResizedCrop on the downstream accuracy as our proposed metrics (ACR and ARC), which help verify our theory. Nevertheless, in practice, the augmentations adopted in contrastive learning is composed of a list of different kinds of augmentations. Therefore, in this part, we further study the effect of other types of data augmentations, and we show that our ARC metric is also effective for evaluating not only other kinds of data augmentations, but also their composed ones.
|
| 444 |
+
|
| 445 |
+

|
| 446 |
+
Figure 9: Downstream accuracy (ACC) v.s. Average Relative Confusion (ARC) for different types of augmentations in SimCLR on CIFAR-10.
|
| 447 |
+
|
| 448 |
+
Comparing different kinds of augmentations. We begin by comparing the four kinds of data augmentations adopted in SimCLR (Chen et al., 2020a): RandomResizedCrop, ColorJitter, Grayscale, etc. For a fair comparison, we apply each one alone for contrastive learning, and evaluate both the downstream accuracy and ARC. From Figure 11, we can conclude that among the six kinds of augmentations, RandomResizedCrop is the most important augmentation, and ColorJitter is the second. The rest of them are less powerful, as they cannot even learn useful features by themselves. We can also see that our ARC metric aligns well with the downstream accuracy for different kinds of augmentations.
|
| 449 |
+
|
| 450 |
+
Comparing ColorJitter with different strength. Based on the observation above, as we have discussed RandomResizedCrop in Section 5.2, we now choose ColorJitter, the second important augmentation, as another kind of augmentation for the study of different augmentation strength. Specifically, we study the four parameters of brightness, contrast, saturation, and hue, where a large value corresponds a large degree of augmentation. Note that we also adopt the default augmentations in SimCLR while only changing the parameters of ColorJitter (different to the setup in Figure 9). As shown in Figure 10, there is also a reverse-U curve like that in RandomResizedCrop, and the sweet spot is usually achieved with 0.8, which corresponds to the default of choice in SimCLR (which is selected with exhausted hyperparameter search). Meanwhile, our ARC metric still aligns well with the downstream accuracy for different strength of different kinds of color jittering, which demonstrates its wide applicability.
|
| 451 |
+
|
| 452 |
+

|
| 453 |
+
Figure 10: Average Relative Confusion (ARC) v.s. downstream accuracy with different augmentation strength on four different kinds of color jittering operations.
|
| 454 |
+
|
| 455 |
+

|
| 456 |
+
Figure 11: Downstream accuracy (ACC) v.s. the logarithm of Average Relative Confusion (ARC) on a composition of RandomResizedCrop and ColorJitter with different strength. Experiments are conducted on CIFAR-10 with SimCLR.
|
| 457 |
+
|
| 458 |
+
Comparing composed augmentations. In the above discussion, we focus on the effect of a single kind of augmentations. Here, we show that our ARC metric is still effective for evaluating the composition of different augmentations. Notably, it is hard to define a metric of augmentation strength in this case, as the effect of different augmentations could be nested. Nevertheless, we can still draw a “ACC - log(ARC)” plot to show the correlation between the downstream accuracy (ACC) and our ARC metric, where each point denotes a model trained with randomly selected parameters of RandomResizedCrop and ColorJitter. As shown in Figure 11, we can see there is indeed a strong correlation between the two metrics, with a Pearson correlation coefficient $\rho = 0 . 8 0$ . Therefore, our metric can be used for selecting different kinds of augmentations as well as their compositions in an unsupervised fashion.
|
| 459 |
+
|
| 460 |
+
For a more intuitive and practical understanding of our augmentation overlap theory developed in Section 4, we visualize of the augmentation graphs on both synthetic data (Section 5.1) and realworld data (Section 5.2).
|
| 461 |
+
|
| 462 |
+

|
| 463 |
+
Figure 12: Visualization of the augmentation graph with different augmentation strength $r$ on the synthetic data described in Section 5.1. Each color denotes a connected component. The corresponding t-SNE visualization and test accuracy (of contrastive learning) can be found in Figure 4.
|
| 464 |
+
|
| 465 |
+
Synthetic data. Following the setting of experiments in Section 5.1, we construct the adjacent matrix of different samples, calculate its connected components, and visualize it in Figure 12 with different colors. It shows that when there is no augmentation, i.e., $r = 0$ , each sample is a connected component alone, and the number of connected components is the same as the number of samples $N$ . As we increase the augmentation strength, samples will be connected together through the augmented views. In particular, when $r = 0 . { \overset { } { 1 } }$ , the whole intra-class samples are connected while inter-class samples are separated, which exactly satisfy our assumptions on intra-class connectivity and label consistency, respectively. Therefore, this is the perfect overlap as desired, and indeed, as shown in Figure 5.1, contrastive learning on it obtains $\hat { 1 } 0 0 \%$ test accuracy. When we keep increasing the augmentation strength to be as large as 1.5, inter-class samples also become connected and inseparable, leading to a random guess in test accuracy $( 5 0 \% )$ . This shows that the relationship between the augmentation graph and the downstream performance aligns well with our augmentation overlap theory.
|
| 466 |
+
|
| 467 |
+

|
| 468 |
+
(a) Under-overlap augmentation (b) Proper overlap augmentation (c) Over-overlap augmentation graph $( \mathrm { r } { = } 0 . 0 \dot { 1 }$ , $\operatorname { a c c } { = } 0 . { \overset { - } { 2 } } 5 )$ ). graph $_ { ( \mathrm { r = } 0 . 9 2 }$ , ac ${ : = } 0 . 7 5$ ). graph $( \mathrm { r } { = } 1 . \hat { 9 } 6 $ , ac ${ \tt : = } 0 . \bar { 2 } 9 $ ).
|
| 469 |
+
Figure 13: The augmentation graph of CIFAR-10 with different strength $r$ of RandomResizedCrop as in Section 5.2. We choose a random subset of test images, randomly augment each one for 20 times. Then, we calculate the sample distance in the representation space as in prior work like FID (Heusel et al., 2017), and draw edges for image pairs whose smallest view distance is below a small threshold. Afterwards, we visualize the samples with t-SNE and color intra-class edges in black and inter-class edges in red and report their frequencies.
|
| 470 |
+
|
| 471 |
+
Real-world data. For the ease of analysis, our augmentation overlap theory adopts a simplified scenario by assuming label consistency (Assumption 4.1) and intra-class connectivity (Assumption 4.5), and we have verified their feasibility on the synthetic data. In comparison, these assumptions cannot hold exactly on real-world data as the chosen augmentations could be sub-optimal. Nevertheless, as shown in the augmentation graphs of CIFAR-10 (Figure 13), our assumptions could still approximately hold: with a properly chosen augmentation strength, the inter-class connections will be much less frequent than intra-class connections: $9 6 . 4 \%$ edges are intra-class edges. Further considering the continuity property and extrapolation ability of deep neural networks, these approximate conditions could still achieve close performance to the optimal performance guaranteed under the exact conditions. Besides, we also have similar conclusions for the under-overlap and over-overlap scenarios: 1) the lack of enough augmentations produces only a few edges in the augmentation graph, as a result, even though all edges are intra-class edges, the downstream performance is still poor ( $25 \%$ test accuracy); 2) too strong augmentations instead produce too many inter-class edges $\bar { ( } 8 7 . 6 \% )$ , which laso leads to poor downstream accuracy $( 2 9 \% )$ . This highlights that our assumptions on label consistency and intra-class connectivity are indeed effective guidelines for the designing of contrastive methods.
|
| 472 |
+
|
| 473 |
+
# D THEORETICAL CHARACTERIZATION OF AUGMENTATION STRENGTH
|
| 474 |
+
|
| 475 |
+
Following the setting in Section 5.1, we can take the radius $r$ as a notation of augmentation strength, and analyze its effect on the connectivity of the corresponding augmentation graph.
|
| 476 |
+
|
| 477 |
+
Theorem D.1. For $N$ random samples taken from a class, while gradually increasing the augmentation strength $r$ , we have the following results.
|
| 478 |
+
|
| 479 |
+
(a) Under-overlap. When $\begin{array} { r } { 0 \leq r \leq r _ { 1 } = \frac { [ ( d / 2 ) ! ] ^ { \frac { 1 } { d } } } { \sqrt { \pi } } \big ( \frac { 1 } { d } \big ) ! \big ( \frac { S } { N - 1 } \big ) ^ { \frac { 1 } { d } } \big [ 1 - \frac { 1 / d + 1 / d ^ { 2 } } { 2 ( N - 1 ) } + O \big ( \frac { 1 } { ( N - 1 ) ^ { 2 } } \big ) \big ] , } \end{array}$ where $r _ { 1 }$ is the minimal distance between $N$ samples, all samples (vertices) in the augmentation graph will be isolated. As a result, the learned features could be totally random as in Proposition 3.1. Instead, if $r \geq r _ { 1 }$ , there are at least two intra-class samples are $\tau$ -connected and enjoy the same representation.
|
| 480 |
+
|
| 481 |
+
(b) Perfect overlap. When r ≥ r2 = [(d/2)!] 1d √ (N−2+1/d)! ( $\begin{array} { r } { r \ge r _ { 2 } = \frac { [ ( d / 2 ) ! ] ^ { \frac { 1 } { d } } } { \sqrt { \pi } } \frac { ( N - 2 + 1 / d ) ! } { ( N - 2 ) ! } ( \frac { S } { N - 1 } ) ^ { \frac { 1 } { d } } [ 1 - \frac { 1 / d + 1 / d ^ { 2 } } { 2 ( N - 1 ) } + O ( \frac { 1 } { ( N - 1 ) ^ { 2 } } ) ] , } \end{array}$ where $r _ { 2 }$ is the maximal distance between $N$ samples, all samples in the augmentation graph will be $\tau$ -connected. As a result, the classwise connectivity in Assumption $4 . 5 ~ w i l l$ be guaranteed.
|
| 482 |
+
|
| 483 |
+
(c) Over-overlap. When $\begin{array} { r } { 0 \leq r < r _ { 3 } = \frac { 1 } { 2 } \operatorname* { m i n } _ { i , j } { \| c _ { i } - c _ { j } \| - 1 } } \end{array}$ , where $r _ { 3 }$ is the (asymptotic) minimal distance between samples from different classes, the label consistency is guaranteed. Otherwise, when the augmentation is too large, e.g., $r > r _ { 3 }$ , there will be inter-class augmentation overlap and Assumption 4.1 not longer holds.
|
| 484 |
+
|
| 485 |
+
In the theorem above, we show that the proper augmentation strength is a function of the number of samples $N$ and the input dimensions $d$ . In particular, for each $x$ , as $N$ increases, there will be more natural examples and we only need a smaller $r$ to obtain an overlap sample. Instead, as $d$ increases, due to the curse of dimensionality, there will be less samples within the same distance, thus it requires a larger $r$ .
|
| 486 |
+
|
| 487 |
+
Nevertheless, we actually only need the augmentation sub-graph $G _ { k }$ to be connected, instead of being fully connected as in Theorem D.1 (b). While the connectivity is hard to analyze in the finite sample scenario $N < \infty$ ), we have the following asymptotic property as $N \to \infty$ .
|
| 488 |
+
|
| 489 |
+
Theorem D.2. For $N$ uniformly distributed samples defined in $\mathbb { R } ^ { d }$ as above, we denote the min$G _ { k } ^ { ( r ) }$ augmentation strength needed for connectivity as a function of is connected}, and the minimal augmentation strength needed for $N$ : oi $c _ { N } ~ = ~ \operatorname* { i n f } \{ r ~ > ~ 0 ~ :$ $a$ function of $N$ : $d _ { N } = \operatorname* { i n f } \{ r > 0$ : every vertex at least has a neighbour}. $V _ { u }$ is the volume of unit hyperball. Then we have the following asymptotic result:
|
| 490 |
+
|
| 491 |
+
$$
|
| 492 |
+
\forall d \geq 2 , \operatorname* { l i m } _ { N \infty } ( c _ { N } ^ { d } \frac { N ^ { 2 } } { \log N } ) = \operatorname* { l i m } _ { N \infty } ( d _ { N } ^ { d } \frac { N ^ { 2 } } { \log N } ) = 2 \frac { ( 1 - 1 / d ) S } { V _ { u } } .
|
| 493 |
+
$$
|
| 494 |
+
|
| 495 |
+
From the theorem we can see that $c _ { N } ^ { d }$ decreases in the order of $\Theta \left( \sqrt [ d ] { \frac { \log N } { N ^ { 2 } } } \right)$ as $N \infty$ . First, this result is aligned with the empirical finding that self-supervised learning can benefit more from large scale dataset (Chen et al., 2020b). Second, it also indicate a curse of dimensionality that the required augmentation strength is exponentially large.
|
| 496 |
+
|
| 497 |
+
# D.1 PROOF OF THEOREM D.1
|
| 498 |
+
|
| 499 |
+
Proof. From definition and notation in section 4. We can construct an augmentation Graph $\mathcal { G } ( \mathcal { D } , \tau )$ given N random samples. We define $D _ { k }$ as the distance from a random point to its $\mathbf { k }$ -th nearest
|
| 500 |
+
|
| 501 |
+
neighbour. Percus & Martin (1998) discuss $D _ { k }$ in random grpah and give the estimation of that:
|
| 502 |
+
|
| 503 |
+
$$
|
| 504 |
+
D _ { k } \approx { \frac { [ ( d / 2 ) ! ] ^ { \frac { 1 } { d } } } { \sqrt { \pi } } } { \frac { ( k - 1 + 1 / d ) ! } { ( k - 1 ) ! } } ( { \frac { S } { N - 1 } } ) ^ { \frac { 1 } { d } } [ 1 - { \frac { 1 / d + 1 / d ^ { 2 } } { 2 ( N - 1 ) } } + O ( { \frac { 1 } { ( N - 1 ) ^ { 2 } } } ) ]
|
| 505 |
+
$$
|
| 506 |
+
|
| 507 |
+
where d is the dimension of hypersphere and $\mathbf { N }$ is the number of random points. When $r < D _ { 1 }$ there is no edge in the graph. So the class is separated. When $r > D _ { N - 1 }$ , any pair of vertexes have an edge between them,so the graph is full connected. □
|
| 508 |
+
|
| 509 |
+
# D.2 PROOF OF THEOREM D.2
|
| 510 |
+
|
| 511 |
+
Proof. Denote
|
| 512 |
+
|
| 513 |
+
$$
|
| 514 |
+
c _ { N } = \operatorname* { i n f } \{ r _ { i } > 0 : G _ { N } ( V , E , r _ { i } ) { \mathrm { i s ~ c o n n e c t e d } } \} .
|
| 515 |
+
$$
|
| 516 |
+
|
| 517 |
+
With Theorem 1.1 from Penrose (1999) and features are uniformly distributed in the surface of unit hypersphere, $V _ { u }$ denotes to the volume of unit hypershpere
|
| 518 |
+
|
| 519 |
+
$$
|
| 520 |
+
\operatorname* { l i m } _ { N \to \infty } ( c _ { N } ^ { d } \frac { N ^ { 2 } } { \log N } ) = 2 \frac { ( 1 - \frac { 1 } { d } ) S } { V _ { u } } , d \geq 2
|
| 521 |
+
$$
|
| 522 |
+
|
| 523 |
+
$\exists N _ { 0 }$ when $N > N _ { 0 }$ , and augmentation strength is larger than ( 2(d−1)S log N2 ) 1d + 1, the graph is connected,i.e the class is overlapped.
|
| 524 |
+
|
| 525 |
+
Then we want specify the case the class will be depart begin with some concepts in graph theory. The largest nearest-neighbor link: For a give edge distance $\mathbf { X }$ and for each $\mathrm { i } = 1$ ,...,n,let
|
| 526 |
+
|
| 527 |
+
$$
|
| 528 |
+
\deg { U _ { N , j } } = \sum _ { 1 \leq j \neq k \leq N } 1 _ { \{ \| U _ { j } - U _ { k } \| \leq r _ { i } \} }
|
| 529 |
+
$$
|
| 530 |
+
|
| 531 |
+
to be the degree of the vertex $U _ { j }$ in the random graph $G _ { N } ( V , E , r _ { i } )$ , and let
|
| 532 |
+
|
| 533 |
+
$$
|
| 534 |
+
\delta _ { N } ( r _ { i } ) = \operatorname* { m i n } \{ \deg \ U _ { m , 1 } ( x ) , . . . , \deg \ U _ { N , N } ( x ) \}
|
| 535 |
+
$$
|
| 536 |
+
|
| 537 |
+
be the minimum vertex degree.Define the largest nearest-neighbor link, the smallest edge distance for which each vertex has at least one neighbor
|
| 538 |
+
|
| 539 |
+
$$
|
| 540 |
+
d _ { N } = \operatorname* { i n f } \{ r _ { i } : \delta _ { N } ( r _ { i } ) \geq 1 \}
|
| 541 |
+
$$
|
| 542 |
+
|
| 543 |
+
With Theorem 1.2 from Penrose (1999),
|
| 544 |
+
|
| 545 |
+
$$
|
| 546 |
+
\operatorname* { l i m } _ { N \to \infty } ( d _ { N } ^ { d } \frac { N ^ { 2 } } { \log N } ) = 2 \frac { ( 1 - \frac { 1 } { d } ) S } { V _ { u } } , d \geq 2
|
| 547 |
+
$$
|
| 548 |
+
|
| 549 |
+
$\exists N _ { 0 } ^ { \prime }$ when $N > N _ { 0 } ^ { \prime }$ , and augmentation strength is less than $\big ( { \frac { 2 ( d - 1 ) S \log N } { 2 N ^ { 2 } V _ { u } d } } \big ) ^ { \frac { 1 } { d } } - \epsilon _ { 2 }$ , there will be at least 1 isolated point which is not connected to any other point,i.e the class is departed. Thus $\begin{array} { r l r } { \exists N _ { 1 } } & { { } = } & { \operatorname* { m a x } ( N _ { 0 } , N _ { 0 } ^ { \prime } ) } \end{array}$ ,when $\begin{array} { r l r } { N } & { { } > } & { \mathsf { \bar { N } } _ { 1 } } \end{array}$ , if augmentation strength is larger than $\Bigl ( { \frac { 2 ( d - 1 ) S \log N } { 2 N ^ { 2 } V _ { u } d } } \Bigr ) ^ { \frac { 1 } { d } } \ + \ \epsilon _ { 1 }$ , the graph is connected, if augmentation strength is less than $\big ( { \frac { 2 ( d - 1 ) S \log N } { 2 N ^ { 2 } V _ { u } d } } \big ) ^ { \frac { 1 } { d } } - \epsilon _ { 2 }$ , there will be at least 1 isolated point.
|
| 550 |
+
|
| 551 |
+
# E ADDITIONAL EXPERIMENTAL DETAILS
|
| 552 |
+
|
| 553 |
+
# E.1 SIMULATION ON RANDOM AUGMENTATION GRAPH
|
| 554 |
+
|
| 555 |
+
Following our setting in Section 5.1, we consider a binary classification task with InfoNCE loss. We generate data from two uniform distribution on a unit ball $\mathbb { S } ^ { 2 }$ in the 3-dimensional space. One center is $( 0 , 0 , 1 )$ and another is $( 0 , 0 , - 1 )$ . The area of both parts are 1. We take 5000 samples as train set and 1000 samples as test set. For the encoder class $\mathcal { F }$ , we use a single-hidden-layer neural network with softmax activation, and we use InfoNCE loss to optimize it.
|
| 556 |
+
|
| 557 |
+
# E.2 EXPERIMENTS ON REAL-WORLD DATASETS
|
| 558 |
+
|
| 559 |
+
To better understand and verify our theorem, we conduct experiments on real-world datasets, including CIFAR-10, CIFAR-100 and STL-10. We use SimCLR (Chen et al., 2020a) and BYOL Grill et al. (2020) as our training framework and use ResNet18 as our network. For CIFAR-10 and CIFAR-100, we adopt $C = 1 0$ augmentations for each image, and search neural neighbors in the entire augmented dataset. For STL-10, we adopt $C = 6$ due to its relatively large size.
|
md/dev/FWMQYjFso-a/FWMQYjFso-a.md
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Pre-Trained Language Models for Interactive Decision-Making
|
| 2 |
+
|
| 3 |
+
Shuang Li 1⇤ , Xavier $\mathbf { P u i g ^ { 1 } }$ , Chris Paxton2, Yilun $\mathbf { D } \mathbf { u } ^ { 1 }$ , Clinton Wang1, Linxi Fan2, Tao Chen1, De-An Huang2, Ekin Akyürek1, Anima Anandkumar2,3,†, Jacob Andreas1,†, Igor Mordatch4,†, Antonio Torralba1,†, Yuke Zhu2,5,†
|
| 4 |
+
|
| 5 |
+
1MIT, 2Nvidia, 3Caltech, 4Google Brain, 5UT Austin Junior authors are ordered based on contributions and senior authors† are ordered alphabetically.
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Language model (LM) pre-training is useful in many language processing tasks. But can pre-trained LMs be further leveraged for more general machine learning problems? We propose an approach for using LMs to scaffold learning and generalization in general sequential decision-making problems. In this approach, goals and observations are represented as a sequence of embeddings, and a policy network initialized with a pre-trained LM predicts the next action. We demonstrate that this framework enables effective combinatorial generalization across different environments and supervisory modalities. We begin by assuming access to a set of expert demonstrations, and show that initializing policies with LMs and fine-tuning them via behavior cloning improves task completion rates by $4 3 . 6 \%$ in the VirtualHome environment. Next, we integrate an active data gathering procedure in which agents iteratively interact with the environment, relabel past “failed” experiences with new goals, and update their policies in a self-supervised loop. Active data gathering further improves combinatorial generalization, outperforming the best baseline by $2 5 . 1 \%$ . Finally, we explain these results by investigating three possible factors underlying the effectiveness of the LM-based policy. We find that sequential input representations (vs. fixed-dimensional feature vectors) and LM-based weight initialization are both important for generalization. Surprisingly, however, the format of the policy inputs encoding (e.g. as a natural language string vs. an arbitrary sequential encoding) has little influence. Together, these results suggest that language modeling induces representations that are useful for modeling not just language, but also goals and plans; these representations can aid learning and generalization even outside of language processing. 2
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Language models (LMs) play a key role in machine learning approaches to natural language processing tasks $\mathbb { P }$ . This includes tasks that are not purely linguistic, and require nontrivial planning and reasoning capabilities [24, 13]: for example, instruction following, vision-language navigation, and visual question answering. Indeed, some of these tasks are so distant from language modeling that one can ask whether pre-trained LMs can be used as a general framework even for tasks that involve no language at all. If so, how might these capabilities be accessed in a model trained only to process and generate natural language strings?
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: Environments (left): Different environments have different types of observations and goals. Our approach (right): We use pre-trained LMs as a general framework for interactive decision-making by converting policy inputs into sequential data. Such a method enables effective combinatorial generalization to novel tasks.
|
| 17 |
+
|
| 18 |
+
In this paper, we study these questions through the lens of embodied decision-making, investigating the effectiveness of LM pre-training as a general framework for learning policies across a variety of environments. We propose LID, a framework that uses Pre-Trained Language Models for Interactive Decision-Making. As shown in Figure $\boxed { 1 }$ (right), we encode the inputs to a policy—including observations, goals, and history—as a sequence of embeddings. These embeddings are passed to a policy network initialized with the parameters of a pre-trained LM, which is fine-tuned to predict actions. This framework is broadly applicable, accommodating goals and environment states represented as natural language strings, image patches, or scene graphs.
|
| 19 |
+
|
| 20 |
+
We find that imitation learning using pre-trained LMs as policy initializers improves in-domain performance and enables strong generalization over novel tasks. For i.i.d. training and evaluation tasks, this approach yields $20 \%$ more successful policies than other baseline methods in VirtualHome $\textcircled { \scriptsize { 1 3 1 } }$ . For combinatorial generalization to out-of-distribution tasks, i.e. tasks involving new combinations of goals, states or objects, LM pre-training confers even more benefits: it improves task completion rates by $4 3 . 6 \%$ for novel tasks (see Figure $3 )$ . These results hold for a variety of environment representations: encoding states as natural language strings, when possible, improves the data-efficiency of training, but even LMs fine-tuned on random environment encodings generalize combinatorially to new goals and states when trained on large enough datasets.
|
| 21 |
+
|
| 22 |
+
We further examine how our method may be used in environments where expert data is not available, and agents must instead actively gather data. To do this, we integrate an Active Data Gathering (ADG) procedure into pre-trained LMs as shown in Figure 2. Our proposed approach to ADG consists of three parts. First, exploration collects trajectories using a mix of random actions and actions generated by the current policy. Exploration is insufficient in this high dimensional problem and most of the trajectories will likely fail to achieve the end goal. A key insight is that even the failed trajectories contain useful sub-trajectories that solve certain sub-goals, and we relabel these goals in a hindsight relabeling stage. The relabeled goal describes what was achieved in the extracted sub-trajectory. The policy update stage samples relabeled trajectories to update the policy. The active data gathering procedure allows us to train the LM-policy without pre-collected expert data. It also outperforms reinforcement learning (RL) methods on embodied decision-making tasks and enables more effective generalization to novel tasks.
|
| 23 |
+
|
| 24 |
+
Finally, we investigate why LID contributes to generalization. We hypothesize three possible causes for the effectiveness of LM-based policy initialization: (1) the use of language-based input encodings, and more generally LMs’ ability to reason about natural language strings; (2) the sequential structure of transformer inputs, in contrast to the fixed-sized observations used by most policy architectures, and (3) task-general inductive bias conferred by weight initialization with LM pretraining. We investigate (1) by encoding the policy inputs as different types of sequences. Different input encoding schemes have only a negligible impact on the performance: the effectiveness of language modeling is not limited to utilizing natural strings, but in fact extends to arbitrary sequential encodings. We study (2) by encoding observations with a single vector embedding, thereby removing its sequential structure. This operation significantly degrades the model’s performance on novel tasks. Finally, we investigate (3) by learning the parameters of the policy from scratch. The success rate after removing the pre-trained LM weights drops by $1 1 . 2 \%$ , indicating that LM pretraining provides useful inductive bias for sequence processing even when sequences are not natural language strings.
|
| 25 |
+
|
| 26 |
+
To summarize, our work has four main contributions:
|
| 27 |
+
|
| 28 |
+
• First, we propose to use pre-trained LMs as a general scaffold for interactive decision-making across a variety of environments by converting all policy inputs into sequential data.
|
| 29 |
+
• Second, we demonstrate that language modeling improves combinatorial generalization in policy learning: initializing a policy with a pre-trained LM substantially improves out-of-distribution performance on novel tasks.
|
| 30 |
+
• Third, we integrate an active data gathering procedure into the proposed approach to further enable policy learning on environments without using pre-collected expert data.
|
| 31 |
+
• Finally, we perform several analyses to explain the generalization capabilities of pre-trained LMs, finding that natural strings are not needed to benefit from LM pre-training, but the sequential input encoding and weight pre-training are important.
|
| 32 |
+
|
| 33 |
+
These results point to the effectiveness of the proposed framework with pre-trained LMs as a generalpurpose framework to promote structured generalization in interactive decision-making.
|
| 34 |
+
|
| 35 |
+
# 2 Related Work
|
| 36 |
+
|
| 37 |
+
In recent years, word and sentence representations from pre-trained LMs [29, 9, 33] have become ubiquitous in natural language processing [49, 30]. Some of the most successful applications of pre-training lie at the boundary of natural language processing and other domains, as in instruction following $\bar { \mathbb { L } } 3 \mathbb { I }$ and language-guided image retrieval $\bar { \lVert \boldsymbol { 2 2 } \rVert }$ .
|
| 38 |
+
|
| 39 |
+
Learning representations of language. From nearly the earliest days of the field, natural language processing researchers observed that representations of words derived from distributional statistics in large text corpora serve as useful features for downstream tasks $\mathbb { B } \mathbb { B }$ . The earliest versions of these representation learning schemes focused on isolated word forms [25, 28]. However, recent years have seen a number of techniques for training (masked or autoregressive) language models to produce contextualized word representations (which incorporate information neighboring words in sentences and paragraphs) via a variety of masked-word prediction objectives [9, 47].
|
| 40 |
+
|
| 41 |
+
Applications of pre-trained LMs. LMs can be fine-tuned to perform language processing tasks other than language modeling by casting those tasks as word-prediction problems. Successful uses of representations from pre-trained models include syntactic parsing $\pmb { \mathbb { I } }$ and language-to-code translation $\lVert \boldsymbol { \mathsf { E } } \boldsymbol { \mathsf { 5 } } \rVert$ ; successful adaptations of LM prediction heads include machine translation [49], sentiment classification $\textcircled { 6 }$ and style transfer $[ \overline { { 1 8 } } ]$ . A number of tasks integrate language and other modalities, including visual question answering and image captioning $\lVert \rVert$ . Recent works find that image representations can be injected directly into LMs’ embedding layers [42].
|
| 42 |
+
|
| 43 |
+
Policy learning and LM. Traditional policy learning methods, such as PPO [37], DQN [27], DDPG [21], A3C [26], perform well on playing tasks on Atari, OpenAI gym [5], and MuJoCo [41]. Some of them might fail to solve more challenging tasks on embodied environments [31, 39]. Several recent papers [36, 17, 15] propose to use LM for policy learning. Frozen Pretrained Transformer (FPT) $\bar { \mathbb { Z } 3 } \mathbb { I }$ demonstrates that pre-trained LMs require very little fine-tuning to match the performance of task-specific models on several image classification and numerical sequence processing tasks. Semi-Supervised Skill Learning with Latent Language (SL)3 [38] shows that LMs can serve as an effective backbone for hierarchical policies that express plans as natural language strings [2, 4]. In this paper, we focus on building a general framework for decision-making tasks using pre-trained LMs, even when language is not provided as an input or output.
|
| 44 |
+
|
| 45 |
+
# 3 Decision-Making and Language Modeling
|
| 46 |
+
|
| 47 |
+
# 3.1 POMDPs and Policy Learning
|
| 48 |
+
|
| 49 |
+
We explore the application of LMs to general sequential decision-making tasks in partially observed environments. These tasks may be formalized as partially observable Markov decision processes (POMDPs). A POMDP is defined by a set of states, a set of observations, a set of actions, and a transition model $\mathscr { T } ( s _ { t + 1 } | s _ { t } , a _ { t } )$ that maps the current state and action to the next state. Importantly, in a POMDP setting, the observation $o _ { t }$ only captures a portion of the underlying state $s _ { t }$ , and an optimal decision-making strategy (a policy) must incorporate both the current observation and the history of previous observations and actions. In our experiments, policies are parametric models $\pi _ { \phi } ( a _ { t } | g , h _ { t } , o _ { t } )$ that output the probability of an action given the goals $g$ , history information $h _ { t } =$ $\{ o _ { 1 } , a _ { 1 } , \cdot \cdot \cdot , o _ { t - 1 } , a _ { t - 1 } \}$ , and partial observations $o _ { t }$ of the current state $s _ { t }$ .
|
| 50 |
+
|
| 51 |
+
In Figure $\overline { { \vert 1 \vert } } ( \mathrm { r i g h t } )$ , we show a high-level overview of the proposed method. We first convert all policy inputs into a sequence and provide them as input to a transformer encoder. Representations from this encoder model are then passed to a task-specific decoder that predicts actions. We collect a dataset of $N$ training trajectories $\mathcal { D } = \{ d ^ { i } \} _ { i = 1 } ^ { N }$ , where each trajectory consists of a goal and a sequence of observations and actions: $d ^ { i } = \{ \tilde { g } ^ { i } , \tilde { o } _ { 1 } ^ { i } , \tilde { a } _ { 1 } ^ { i } , \tilde { \cdot } \cdot \cdot , o _ { T _ { i } } ^ { i } , a _ { T _ { i } } ^ { i } \}$ , where $T _ { i }$ is the length of the trajectory. We then train the policy to maximize the probability of actions we want to achieve $\pmb { a } ^ { i } = \{ a _ { 1 } ^ { i } , \dots , a _ { T _ { i } } ^ { i } \}$ across trajectories using the cross-entropy loss:
|
| 52 |
+
|
| 53 |
+
$$
|
| 54 |
+
\boldsymbol { \phi } ^ { * } = \underset { \boldsymbol { \phi } } { \arg \operatorname* { m i n } } \left( - \sum _ { i = 1 } ^ { N } \sum _ { t = 1 } ^ { T _ { i } } \ln \pi _ { \phi } ( a _ { t } ^ { i } | \boldsymbol { g } ^ { i } , \boldsymbol { h } _ { t } ^ { i } , \boldsymbol { o } _ { t } ^ { i } ) \right) .
|
| 55 |
+
$$
|
| 56 |
+
|
| 57 |
+
# 3.2 Language models as policy initializers
|
| 58 |
+
|
| 59 |
+
Our experiments focus on autoregressive, transformer-based LMs $\mathbb { \lVert \overline { { 4 3 } } \rVert }$ . These models are trained to fit a distribution over a text sequence $\pmb { y } = \{ y _ { i } \} _ { i = 1 } ^ { n }$ via the chain rule $\begin{array} { r } { p ( \pmb { y } ) = p ( y _ { 1 } ) \prod _ { i = 2 } ^ { n } p ( y _ { i } \ | } \end{array}$ $y _ { 1 } , \dotsc , y _ { i - 1 } )$ . Each term on the right hand side is parameterized by a transformer network, which accepts the conditioned tokens as input. Each token passes through a learned embedding layer $F _ { \theta }$ , then the full conditioned sequence is fed into the LM. In our work, we use a standard LM, GPT-2, to process the input sequence rather than to predict future tokens.
|
| 60 |
+
|
| 61 |
+
Both POMDP decision-making and language modeling are naturally framed as sequence prediction tasks, where successive words or actions/observations are predicted based on a sequence of previous words or actions/observations. This suggests that pre-trained LMs can be used to initialize POMDP policies by fine-tuning them to model high-reward or expert trajectories, as described below.
|
| 62 |
+
|
| 63 |
+
# 4 Approach
|
| 64 |
+
|
| 65 |
+
We evaluate the effectiveness of pre-trained LMs in solving decision-making tasks across environments. We use BabyAI $\mathbb { I H }$ and VirtualHome $\textcircled { \scriptsize { 1 3 1 } }$ to evaluate the proposed method. While both environments feature complex goals, the nature of these goals, as well as the state and action sequences that accomplish them, differ substantially across environments (Figure 1 (left)).
|
| 66 |
+
|
| 67 |
+
# 4.1 Policy Network
|
| 68 |
+
|
| 69 |
+
We first examine whether pre-trained LMs provide effective initializers when states and action histories are represented as natural language strings. We encode the inputs to the policy—including observations, goals, and action histories—as sequences of words. These word sequences are passed to the LM (using its pre-trained word embedding layer $F _ { \theta }$ ) and used to obtain contextualized token representations. Token representations are averaged and used to predict actions. We design a policy network following the general policy framework proposed in Figure 1.
|
| 70 |
+
|
| 71 |
+
Environment encodings in VirtualHome. In VirtualHome, each goal consists of a sequence of predicates and multiplicities, and is translated into a templated English sentence (e.g. “Inside(apple, fridge):2” becomes “put two apples inside the fridge”). To encode the agent’s partial observation, we extract a list of currently visible objects, their states (e.g. “open, clean”), and 3D world coordinates. We use a fully-connected layer to encode the 3D information and generate a feature representation of each object in the observation. To encode history, we store information about all previous actions and convert them into templated English sentences (e.g. “I have put the plate on the kitchen table and the apple inside the fridge”).
|
| 72 |
+
|
| 73 |
+
Environment encodings in BabyAI. The observation by default is a $7 \times 7$ grid. We convert the observation into $7 \times 7$ text descriptions, e.g. “purple ball”, “grey wall”, “open door”, and combine them into a long sentence. We then convert the history actions into text descriptions, e.g. “turn left” and “go forward”. We combine the language instruction (without modification) with the observation and history text descriptions, and feed them to the pre-trained LM.
|
| 74 |
+
|
| 75 |
+
We note that the policy network described above does not strictly require that these encodings take the form of natural language strings—other encodings of the environment as a sequence also work (see Section $^ { 7 ) }$ . This framework could be also generalized to support pixel-based observations using discretization schemes like the one employed in the Vision Transformer [10].
|
| 76 |
+
|
| 77 |
+
Action prediction. We pool LM outputs into a “context representation” that is used to predict the next action. In training, we maximize the probabilities of demonstrated actions. In inference, we select the valid action with the highest probability. See Appendix C.1 for details.
|
| 78 |
+
|
| 79 |
+
VirtualHome and BabyAI have quite different observation spaces, action spaces, and goal spaces; however, we show that embedding policy inputs as sequences and utilizing the pre-trained LM as a policy initializer, enables effective generalization to novel tasks on both environments. We note that LID is not limited to VirtualHome and BabyAI, but is straightforwardly applicable to other embodied environments, such as ALFRED $\mathbb { \left| \mathrm { \overline { { 4 0 } } } }\right|$ and iGibson $\mathbb { \lVert 3 9 \rVert }$ .
|
| 80 |
+
|
| 81 |
+
# 4.2 Training
|
| 82 |
+
|
| 83 |
+
We first examine LID through imitation learning on data collected by experts in Section $4 . 2 . 1 .$ We then show that integrating an active data gathering procedure into LID enables policy learning without using expert data in Section $4 . 2 . 2 .$ We use VirtualHome as an example to explain the data gathering.
|
| 84 |
+
|
| 85 |
+
# 4.2.1 Policy Learning with Expert Data
|
| 86 |
+
|
| 87 |
+
The policy model is first initialized from a pre-trained LM and then fine-tuned on data collected by experts. We build on the VirtualHome environment to collect a set of expert trajectories using regression planning $\pmb { \mathbb { Z } } 0 \|$ and create a VirtualHome-Imitation Learning dataset. Given a task described by goal predicates, the planner generates an action sequence to accomplish this task (See Appendix E.1). The planner has access to privileged information, such as information about the pre-conditions and effects of each action, allowing an agent to robustly perform tasks in partially observable environments and generate expert trajectories for training and evaluation.
|
| 88 |
+
|
| 89 |
+
# 4.2.2 Policy Learning with Active Data Gathering
|
| 90 |
+
|
| 91 |
+
Collecting expert data is sometimes challenging. It may require privileged information of the environment or human annotations, which can be timeconsuming and difficult to scale. A promising way to scale up supervision is Hindsight Experience Replay (HER) [3], which allows agents to learn from orders of magnitude more data without supervision. However, existing HER methods [12] focus on simple tasks with small state/action space and full observability. They cannot tackle more complicated embodied decision-making tasks, requiring nontrivial planning and reasoning or natural language understanding. LID with the active data gathering (LIDADG) can be used in solving tasks in such environments.
|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
Figure 2: LID with the active data gathering procedure. By iteratively repeating the exploration, hindsight relabeling, and policy update, LID with active data gathering can learn an effective policy without using pre-collected expert data.
|
| 95 |
+
|
| 96 |
+
As shown in Figure 2, LID-ADG consists of three stages, i.e. exploration, hindsight relabeling, and policy update. The key idea is to gradually improve the task success rate by asking the agent to iteratively explore the environment, relabel failure samples, and update its policy using imitation learning. In the exploration stage, we first randomly sample a goal and an initial state. We then use a mix of random actions and actions generated by the current policy $\pi _ { \phi } ( a _ { t } | g , h _ { t } , o _ { t } )$ to obtain the next action. We repeat this process until this episode ends. We collect $M$ trajectories and store them in the replay buffers. The generated actions in the early stages rarely complete the given task.
|
| 97 |
+
|
| 98 |
+
However, even the failed trajectories contain useful sub-trajectories that solve certain sub-goals. In the hindsight relabeling stage, we extract useful sub-trajectories and relabel a goal $g ^ { \prime }$ for each of them. We design a goal relabel function $f _ { l }$ that generates a goal based on the sequence of observations and actions using hand-designed templates. In practice, we implement the goal relabel function as a program (see Appendix E.2). The hindsight relabeling stage allows sample-efficient learning by reusing the failure cases. During policy update, the agent samples the data from the replay buffers and updates its policy network $\pi _ { \phi }$ .
|
| 99 |
+
|
| 100 |
+
By interleaving the exploration, hindsight relabeling, and policy update, LID-ADG can gradually improve the policy without requiring pre-collected expert data. In embodied environments with large action spaces, sparse rewards, and long-horizon planning, RL methods often struggle to obtain stable policy gradients during training. Our method enables sample-efficient learning from the sparse rewards by relabeling new goals for the bad samples that the agent fails to achieve. In addition, LID-ADG leverages the stability of supervised learning in the policy update stage, enabling it to outperform RL approaches on a wide range of decision-making tasks.
|
| 101 |
+
|
| 102 |
+
# 5 Experiment Setup
|
| 103 |
+
|
| 104 |
+
We evaluate the proposed method and baselines on VirtualHome and BabyAI.
|
| 105 |
+
|
| 106 |
+
# 5.1 VirtualHome
|
| 107 |
+
|
| 108 |
+
VirtualHome is a 3D embodied environment featuring partial observability, large action spaces, and long time horizons. We evaluate policies’ performance from three aspects: (1) performance on in-distribution tasks; (2) generalization to novel scenes; and (3) generalization to novel tasks.
|
| 109 |
+
|
| 110 |
+
In-Distribution. The predicate types and their counts in the goal are randomly sampled from the same distribution as the training data. The objects are initially placed in the environment according to common-sense layouts (e.g. plates appear inside the kitchen cabinets rather than the bathtub).
|
| 111 |
+
|
| 112 |
+
Novel Scenes. The objects are placed in random positions in the initial environment without commonsense constraints (e.g. apples may appear inside the dishwasher).
|
| 113 |
+
|
| 114 |
+
Novel Tasks. The components of all goal predicates are never seen together during training (e.g. both plates and fridges appear in training goals, but Inside(plate, fridge) only appears in the test set. (See Appendix $\bar { \underline { { \mathbf { F } } } }$ for more details.)
|
| 115 |
+
|
| 116 |
+
We evaluate the success rates of different methods on each test set. A given episode is scored as successful if the policy completes its entire goal within the maximum allowed steps of the environment. On each of the 3 test subsets, we use 5 different random seeds and test 100 tasks under each seed. Thus there are 1500 examples used to evaluate each model.
|
| 117 |
+
|
| 118 |
+
# 5.2 BabyAI
|
| 119 |
+
|
| 120 |
+
BabyAI is a 2D grid world environment for instruction following. Observations in BabyAI are $7 \times 7 \times 3$ grids describing a partial and local egocentric view of the state of the environment. We evaluate the methods on four representative tasks: GoToRedBall, GoToLocal, PickupLoc, and PutNextLocal. Performing well on the test set requires the models to generalize to new environment layouts and goals, resulting in new combinations of tasks not seen in training. For each method, we compute success rates over 500 episodes on each task.
|
| 121 |
+
|
| 122 |
+
# 6 Experiments
|
| 123 |
+
|
| 124 |
+
We first show results of the proposed method and baselines for embodied decision-making tasks using expert data in Section $\boxed { 6 . 1 }$ We then show our results when using actively gathered data in Section $6 . { \overset { \vartriangle } { 6 } }$
|
| 125 |
+
|
| 126 |
+
# 6.1 Embodied Decision Making with Pre-trained Language Model (LID)
|
| 127 |
+
|
| 128 |
+
# 6.1.1 Results on VirtualHome
|
| 129 |
+
|
| 130 |
+
We evaluate the following methods:
|
| 131 |
+
|
| 132 |
+

|
| 133 |
+
Figure 3: Comparisons of the proposed method and baselines on VirtualHome. All the methods are trained on expert data using imitation learning. MLP-1, MLP, and LSTM are baselines without using the pre-trained LM. The proposed method, LID-Text (Ours), outperforms all baselines.
|
| 134 |
+
|
| 135 |
+
Table 1: Success rates on BabyAI tasks. All the methods are trained on offline expert data using imitation learning. LID-Text (Ours) outperforms BabyAIOri, the method used in the original paper [16].
|
| 136 |
+
|
| 137 |
+
<table><tr><td>Tasks</td><td>Methods</td><td colspan="3">Number of Demos</td></tr><tr><td></td><td></td><td>100 500 1K</td><td>5K</td><td>10K</td></tr><tr><td>GoToRedBall</td><td>BabyAI-Ori 国 LID-Text (Ours)</td><td>81.0 96.0 99.0 93.999.4 99.7</td><td>99.5 100.0</td><td>99.9 100.0</td></tr><tr><td>GoToLocal</td><td>BabyAI-Ori 国 LID-Text (Ours) </td><td>55.9 84.3 98.6 64.6 97.9 99.0</td><td>99.9 99.5</td><td>99.8 99.5</td></tr><tr><td>PickupLoc</td><td>BabyAI-Ori[16 LID-Text (0urs) 28.7 73.4 99.0</td><td>28.0 58.0 93.3</td><td>97.9 99.6</td><td>99.8 99.8</td></tr><tr><td>PutNextLocal</td><td>BabyAI-Ori 国 LID-Text (Ours)</td><td>14.3 16.8 43.4 11.1 93.0 93.2</td><td>81.2 98.9</td><td>97.7 99.9</td></tr></table>
|
| 138 |
+
|
| 139 |
+
LID-Text (Ours) is the proposed method that converts all environments inputs into text descriptions. The pre-trained LM is fine-tuned for decision-making (conditioned on goals, observations, and histories) as described in Section 4.1.
|
| 140 |
+
|
| 141 |
+
Recurrent Network. We compare our method with a recurrent baseline using an LSTM $\mathbb { \lVert \underline { { 4 } } \rVert }$ to encode the history information. The hidden representation from the last timestep, together with the goal and current observation, are used to predict the next action.
|
| 142 |
+
|
| 143 |
+
MLP and MLP-1. We perform additional comparisons with baselines that do not use recurrent networks or pre-trained LMs. MLP and MLP-1 take the goal, histories, and the current observation as input and send them to the multilayer perceptron neural network (MLP) to predict actions. MLP-1 has three more average-pooling layers than $M L P$ that average the features of tokens in the goal, history actions, and the current observation, respectively, before sending them to the MLP layer.
|
| 144 |
+
|
| 145 |
+
Quantitative results. Each method is trained on $2 0 K$ demos from the VirtualHome-Imitation Learning dataset, and then evaluated on the three test subsets: In-Distribution, Novel Scenes, and Novel Tasks. In Figure $\textcircled{3}$ LID-Text (Ours), which initializes the policy with a pre-trained LM, has higher success rates than other methods. This difference is most pronounced in the Novel Tasks setting, where test tasks require combinatorial generalization across goals that are never seen during training. Here, LID-Text (Ours) dramatically $( 4 3 . 6 \% )$ improves upon all baselines. Such combinatorial generalization is necessary to construct general purpose agents, but is often difficult for existing approaches. Our results suggest that pre-trained LMs can serve as a computational backbone for combinatorial generalization.
|
| 146 |
+
|
| 147 |
+
# 6.1.2 Results on BabyAI
|
| 148 |
+
|
| 149 |
+
We use the standard training and test data provided by [16]. In BabyAI, performing well on unseen test tasks with new environment layouts and goals requires combinatorial reasoning. In Table $\bigstar$ we report the success rate of models trained on different number of demos. BabyAI-Ori [16] is the method used in the original paper. LID-Text (Ours) is the proposed method that converts policy inputs into a text sequence. Given enough training data, i.e. 10K demos, both methods achieve high success rates, but LID-Text (Ours) outperforms BabyAI-Ori with less training data, indicating the proposed method improves sample efficiency when generalizing to novel tasks.
|
| 150 |
+
|
| 151 |
+
# 6.2 Pre-trained Language Model with Active Data Gathering (LID-ADG)
|
| 152 |
+
|
| 153 |
+
We compare LID-ADG, the proposed LM framework for decision-making using actively gathered data (Section $\boxed { 4 . 2 . 2 }$ , to a variety of baselines that do not use pre-collected expert data on VirtualHome.
|
| 154 |
+
|
| 155 |
+
Random. The agent selects the next action randomly from the valid action space at that state. Goal-Object. The agent randomly selects an object that in the goal and in the valid action space to interact with. For example, given a goal of “Inside(apple, fridge):1”, this baseline might choose “grab apple”, “open fridge”, or other actions containing “apple” or “fridge”. Online RL. We compare with PPO $\pmb { \mathbb { B 7 } }$ , one of the most commonly used online RL methods. For fair comparison, we equip PPO with the same main policy network as the proposed method. Our implementation is
|
| 156 |
+
|
| 157 |
+
Table 2: Comparisons of methods without using expert data on VirtualHome. LID-ADG (Ours) is the only successful approach.
|
| 158 |
+
|
| 159 |
+
<table><tr><td>In-Distribution Novel Scenes Novel Tasks</td></tr><tr><td>Random</td><td>0.0±0.0 0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>Goal-Object</td><td>0.8±0.5 0.0±0.0</td><td>0.4±0.4</td></tr><tr><td>PPO</td><td>0.0±0.0 0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>DQN+HER</td><td>0.0±0.0 0.0±0.0</td><td>0.0±0.0</td></tr><tr><td>LID-ADG (Ours)</td><td>46.7 ± 2.7 32.2 ± 3.3</td><td>25.5± 4.1</td></tr></table>
|
| 160 |
+
|
| 161 |
+
<table><tr><td></td><td>In-Distribution Novel Scenes Novel Tasks</td><td></td></tr><tr><td>LID-ADG (Ours)</td><td>46.7 ± 2.7</td><td>32.2 ± 3.3 25.5 ± 4.1</td></tr><tr><td>PPO (LID-ADG Init)</td><td>53.7± 3.5 30.2±3.4</td><td>27.8± 2.7</td></tr><tr><td>DT (LID-ADG Data)</td><td>42.4 ± 1.5</td><td>21.6 ± 2.48 16.8 ± 1.0</td></tr></table>
|
| 162 |
+
|
| 163 |
+
Table 3: The proposed method with active data gathering, LID-ADG (Ours), can be used as an policy initializer for online RL or a data provider for offline RL.
|
| 164 |
+
|
| 165 |
+
based on Stable Baselines3 [35]. Hindsight Experience Replay. We compare with DQN+HER used in [3] and modify its main policy network to be the same as the proposed method.
|
| 166 |
+
|
| 167 |
+
Quantitative results. We compare LID-ADG with baselines on VirtualHome in Table 2. Each experiment is performed 5 times with different random seeds. The Random baseline is always 0, indicating the tasks in VirtualHome cannot be easily solved by a random policy. Goal-Object is better than Random because Goal-Object has access to objects in the goal and it samples actions from a much smaller action space. The online RL baseline, PPO, fails to solve tasks in VirtualHome featured by partially observation, large state/action space, and long-term horizon. $\mathbf { D Q N + H E R }$ works well on simple tasks on 2D environments, but they cannot tackle VirtualHome tasks neither, requiring nontrivial planning and reasoning. LID-ADG does not require expert data and can solve the complicated tasks in 3D embodied environments which cannot be easily achieved using RL.
|
| 168 |
+
|
| 169 |
+
Policy initializer and data provider. LID-ADG can further be used to initialize the weights for finetuning RL policies and to gather data for offline learning. As shown in Table 2, directly training RL, e.g. PPO, fails to solve tasks in VirtualHome. However, after using the policy trained by LID-ADG to initialize the PPO policy, we may effectively learn an interactive policy with good performance. In Table 3, PPO (LID-ADG Init) is initialized from LID-ADG and further fine-tuned to solve the tasks in VirtualHome. After initialization, PPO improves its success rate by $5 3 . 7 \%$ on the In-Distribution setting (See PPO results in Table $2$ and Table $\mathsf { \bar { \rho } } _ { 3 ) }$ . In addition, LID-ADG can provide data for offline learning. LID-ADG saves the relabeled data in replay buffers. We train Decision Transformer (DT) [7] using the data collected by LID-ADG. See DT (LID-ADG Data) in Table 3.
|
| 170 |
+
|
| 171 |
+
# 7 Analysis: Understanding the Sources of Generalization
|
| 172 |
+
|
| 173 |
+
The pre-trained LM policy, fine-tuned on either expert data or actively gathered data, exhibits effective combinatorial generalization. Is this simply because LMs are effective models of relations between natural language descriptions of states and actions $\mathbb { M }$ , or because they provide a more general framework for combinatorial generalization in decision-making? We hypothesize and investigate three possible factors to understand the sources of such combinatorial generalization. We use policies trained on the expert data as an example to explain the experiments.
|
| 174 |
+
|
| 175 |
+
# 7.1 Input Encoding Scheme
|
| 176 |
+
|
| 177 |
+
We first hypothesize that converting environment inputs into natural language contributes to the combinatorial generalization as the LMs are trained on language data. We explore the role of natural language by investigating three alternative ways of encoding policy inputs to our model without using natural language strings: two in VirtualHome, and one in BabyAI. BabyAI results are in Appendix A.
|
| 178 |
+
|
| 179 |
+
Index encoding in VirtualHome. Rather than natural language strings, LID-Index (Ours) converts policy inputs into integer indices. LID-Index (Ours) retains the discrete, serial format of the goal, history, and observation, but replaces each word with an integer, and replaces the embedding layer from the pre-trained LM with a new embedding layer trained from scratch. For example, grab apple is mapped to (5,3) based on the positions of grab and apple in the vocabulary set.
|
| 180 |
+
|
| 181 |
+
Unnatural string encoding in VirtualHome. LID-Unnatural (Ours) replaces the natural language tokens (e.g. converting the goal “On(fork, table):1” to put one fork on the table) with random ones (e.g. converting On(fork, table) to brought wise character trees fine yet). This is done by randomly permuting the entire vocabulary, mapping each token to a new token. Such a permutation breaks the semantic information in natural strings.
|
| 182 |
+
|
| 183 |
+
Table 4: Success rates of policies trained with different input encodings in the Novel Tasks setting on VirtualHome. The text encoding is the most sample-efficient, but all models converge to similar performance given sufficient training data.
|
| 184 |
+
|
| 185 |
+
<table><tr><td>Methods</td><td colspan="6">Number of Demos</td></tr><tr><td></td><td>100</td><td>500</td><td>1K</td><td>5K</td><td>10K</td><td>20K</td></tr><tr><td>LID-Text (Ours)</td><td>8.8 ± 1.4</td><td>22.2 ±1.7</td><td>26.8 ±1.0</td><td>46.0 ± 1.0</td><td>58.2 ±1.2</td><td>58.2 ±1.6</td></tr><tr><td>LID-Index (Ours)</td><td>6.4 ± 0.6</td><td>18.0±3.8</td><td>18.8 ±1.0</td><td>45.5± 2.1</td><td>54.6 ± 0.8</td><td>57.8 ± 0.9</td></tr><tr><td>LID-Unnatural (Ours)</td><td>6.8 ±1.3</td><td>18.6 ± 2.1</td><td>27.0 ± 1.1</td><td>47.2 ± 1.7</td><td>55.8 ± 0.8</td><td>58.8 ± 0.9</td></tr></table>
|
| 186 |
+
|
| 187 |
+
LID-Index (Ours) and LID-Unnatural (Ours) have the same policy network as LID-Text (Ours). All are fine-tuned on the expert data. The averaged results using 5 different random seeds on the Novel Tasks setting are reported in Table $\textcircled { 4 }$ Given few training data, e.g. 100 demos, all the models perform poorly, with success rates lower than $1 0 \%$ . LID-Text (Ours) achieves higher success rates than LID-Index (Ours) and LID-Unnatural (Ours) when dataset size increases, e.g. LID-Text (Ours) is around $4 \%$ higher than LID-Index (Ours) and LID-Unnatural (Ours) with 500 training demos. When the training dataset is further enlarged, e.g. 20K demos, success rates of all approaches reach similar performance. This result indicates that the effectiveness of pre-trained LMs in compositional generalization is not unique to natural language strings, but can be leveraged from arbitrary encodings, although adapting the model to arbitrary encodings may require more training data.
|
| 188 |
+
|
| 189 |
+
# 7.2 Sequential Input Representation
|
| 190 |
+
|
| 191 |
+
Next, we explore whether generalization requires the sequential processing mechanisms in transformer-based LMs. We investigate whether the LM pre-trained policy will still be effective when the input encoding is not sequential. No-Seq encodes the goal as a single vector by averaging all goal embeddings. History and observation features are obtained in the same way. All features are then sent to the pre-trained LM to predict actions. As shown in Table $5 ,$ removing sequential structure significantly hurts performance on Novel Tasks. No
|
| 192 |
+
|
| 193 |
+
Table 5: Experiments on sequential inputs and weight initialization. Fine-tuning the pre-trained weights and the usage of sequential encoding are important for combinatorial generalization.
|
| 194 |
+
|
| 195 |
+
<table><tr><td colspan="2">In-Distribution</td><td>Novel Tasks</td></tr><tr><td>LID-Text (Ours)</td><td>87.6 ± 1.9</td><td>58.2 ± 2.3</td></tr><tr><td>No-Seq</td><td>74.0 ± 2.3</td><td>2.0± 0.6</td></tr><tr><td>No-Pretrain</td><td>90.8 ± 2.0</td><td>47.0 ±2.8</td></tr><tr><td>No-FT</td><td>51.2 ± 4.5</td><td>17.0 ± 2.9</td></tr></table>
|
| 196 |
+
|
| 197 |
+
Seq achieves good performance on test tasks that are closer to training tasks, but cannot generalize well to more challenging unseen tasks. Thus, combinatorial generalization in pre-trained LMs may be attributed in part to transformers’ ability to process sequential input representations effectively.
|
| 198 |
+
|
| 199 |
+
# 7.3 Favorable Weight Initialization
|
| 200 |
+
|
| 201 |
+
Finally, we investigate if the favorable weight initialization from LM pre-training enables effective generalization of the proposed model. No-Pretrain does not initialize the policy using the pre-trained LM, but instead training the policy on the expert data from scratch. In Table $5 ,$ we find that removing the pre-trained weights can fit the in-domain data and thus performs well on the In-Distribution setting. However, its success rate is $1 1 . 2 \%$ lower than the proposed model on the Novel Tasks setting, indicating the pre-trained weights are important for effective generalization, but not necessary for effective data fitting. We further test a baseline, No-FT, that keeps the pre-trained weights of the language model but freezes them while training the rest model on our expert data. Freezing the pretrained weights without fine-tuning significantly hurts the performance on both settings, suggesting that fine-tuning of the transformer weights is essential for effective combinatorial generalization.
|
| 202 |
+
|
| 203 |
+
Together, these results suggest that sequential input representations (vs. fixed-dimensional feature vectors) and favorable weight initialization are both important for generalization, however, the input encoding schemes (e.g. as a natural language string vs. an arbitrary encoding scheme) has little influence. These results point to the potential broader applicability of pre-trained LMs as a computational backbone for compositional embodied decision making, where arbitrary inputs, such as language, images, or grids, may be converted to sequential encodings.
|
| 204 |
+
|
| 205 |
+

|
| 206 |
+
Figure 4: Qualitative results of our model on VirtualHome and BabyAI. We only show a sub-trajectory in each example to save space. The interacted objects are labelled by green bounding boxes.
|
| 207 |
+
|
| 208 |
+

|
| 209 |
+
Figure 5: Failure cases. We show failure cases caused by the grounding error and policy error. The interacted objects are labelled by green bounding boxes.
|
| 210 |
+
|
| 211 |
+
# 8 Qualitative Results
|
| 212 |
+
|
| 213 |
+
In Figure $^ { 4 , }$ we show examples of LID-Text (Ours) completing tasks in VirtualHome and BabyAI. We show two successful examples from VirtualHome on the In-Distribution and Novel Tasks settings, and two successful examples from BabyAI on solving the GoToLocal and PickupLoc tasks. We only show short trajectories or extract a sub-trajectory for saving space.
|
| 214 |
+
|
| 215 |
+
Failure case analysis. In Figure 5, we show some failure cases of the proposed method. We observed two main types of failure cases: grounding error and policy error. For failures caused by the grounding error, the agent interacts with a wrong object that is not related to the given goal, e.g. the agent puts cutlets instead of the salmon inside the fridge. For failures caused by the policy error, the agent cannot find the target objects or does not interact with them. The proposed method that converts policy inputs into sequential encodings and feeds them to the general LM framework can accomplish decision-making tasks efficiently, however, there are still challenging tasks that the policy fails to accomplish. Larger LMs, e.g. GPT-3 [6], may improve the success rate of those challenging tasks.
|
| 216 |
+
|
| 217 |
+
# 9 Conclusion and Broader Impact
|
| 218 |
+
|
| 219 |
+
In this paper, we introduced LID, a general approach to sequential decision-making that converts goals, histories, and observations into sequences and processes them using a policy initialized with a pre-trained LM. We integrated an active data gathering procedure into the proposed method to enable policy learning without using expert data. Our analysis showed that input representation and favorable weight initialization both contribute to the generalization while the input encoding scheme has little influence. One drawback of the active data gathering is that it relies on hand-designed rules for task relabeling. More generally, a potential disadvantage of the proposed approach is that biases of the pre-trained LMs may influence its behavior, and further study of LID-based models’ bias is required before they may be deployed in sensitive downstream applications. Nevertheless, our results demonstrate that LID enables effective combinatorial generalization across different environments, and highlight the promise of LM pre-training for more general decision-making problems.
|
| 220 |
+
|
| 221 |
+
# References
|
| 222 |
+
|
| 223 |
+
[1] P. Ammanabrolu and M. O. Riedl. Playing text-adventure games with graph-based deep reinforcement learning. arXiv preprint arXiv:1812.01628, 2018.
|
| 224 |
+
[2] J. Andreas and D. Klein. Learning with latent language. In North American Association for Computational Linguistics, 2022.
|
| 225 |
+
[3] M. Andrychowicz, F. Wolski, A. Ray, J. Schneider, R. Fong, P. Welinder, B. McGrew, J. Tobin, P. Abbeel, and W. Zaremba. Hindsight experience replay. arXiv preprint arXiv:1707.01495, 2017.
|
| 226 |
+
[4] M. L. Athul Paul Jacob and J. Andreas. Multitasking inhibits semantic drift. In North American Association for Computational Linguistics, 2021.
|
| 227 |
+
[5] G. Brockman, V. Cheung, L. Pettersson, J. Schneider, J. Schulman, J. Tang, and W. Zaremba. Openai gym, 2016.
|
| 228 |
+
[6] T. B. Brown, B. Mann, N. Ryder, M. Subbiah, J. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al. Language models are few-shot learners. arXiv preprint arXiv:2005.14165, 2020.
|
| 229 |
+
[7] L. Chen, K. Lu, A. Rajeswaran, K. Lee, A. Grover, M. Laskin, P. Abbeel, A. Srinivas, and I. Mordatch. Decision transformer: Reinforcement learning via sequence modeling. arXiv preprint arXiv:2106.01345, 2021.
|
| 230 |
+
[8] S. Deerwester, S. T. Dumais, G. W. Furnas, T. K. Landauer, and R. Harshman. Indexing by latent semantic analysis. Journal of the American society for information science, 41(6):391–407, 1990.
|
| 231 |
+
[9] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
|
| 232 |
+
[10] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
|
| 233 |
+
[11] S. T. Dumais. Latent semantic analysis. Annual review of information science and technology, 38(1):188–230, 2004.
|
| 234 |
+
[12] D. Ghosh, A. Gupta, A. Reddy, J. Fu, C. Devin, B. Eysenbach, and S. Levine. Learning to reach goals via iterated supervised learning. arXiv preprint arXiv:1912.06088, 2019.
|
| 235 |
+
[13] F. Hill, S. Mokra, N. Wong, and T. Harley. Human instruction-following with deep reinforcement learning via transfer-learning from text. arXiv preprint arXiv:2005.09382, 2020.
|
| 236 |
+
[14] S. Hochreiter and J. Schmidhuber. Long short-term memory. Neural computation, 9(8):1735– 1780, 1997.
|
| 237 |
+
[15] W. Huang, P. Abbeel, D. Pathak, and I. Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents. arXiv preprint arXiv:2201.07207, 2022.
|
| 238 |
+
[16] D. Y.-T. Hui, M. Chevalier-Boisvert, D. Bahdanau, and Y. Bengio. Babyai 1.1, 2020.
|
| 239 |
+
[17] E. Jang, A. Irpan, M. Khansari, D. Kappler, F. Ebert, C. Lynch, S. Levine, and C. Finn. Bc-z: Zero-shot task generalization with robotic imitation learning. In Conference on Robot Learning, pages 991–1002. PMLR, 2022.
|
| 240 |
+
[18] N. S. Keskar, B. McCann, L. R. Varshney, C. Xiong, and R. Socher. Ctrl: A conditional transformer language model for controllable generation. arXiv preprint arXiv:1909.05858, 2019.
|
| 241 |
+
[19] N. Kitaev, S. Cao, and D. Klein. Multilingual constituency parsing with self-attention and pre-training. arXiv preprint arXiv:1812.11760, 2018.
|
| 242 |
+
[20] R. E. Korf. Planning as search: A quantitative approach. Artificial intelligence, 33(1):65–88, 1987.
|
| 243 |
+
[21] T. P. Lillicrap, J. J. Hunt, A. Pritzel, N. Heess, T. Erez, Y. Tassa, D. Silver, and D. Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
|
| 244 |
+
[22] J. Lu, D. Batra, D. Parikh, and S. Lee. Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. arXiv preprint arXiv:1908.02265, 2019.
|
| 245 |
+
[23] K. Lu, A. Grover, P. Abbeel, and I. Mordatch. Pretrained transformers as universal computation engines. arXiv preprint arXiv:2103.05247, 2021.
|
| 246 |
+
[24] A. Majumdar, A. Shrivastava, S. Lee, P. Anderson, D. Parikh, and D. Batra. Improving visionand-language navigation with image-text pairs from the web. In European Conference on Computer Vision, pages 259–274. Springer, 2020.
|
| 247 |
+
[25] T. Mikolov, I. Sutskever, K. Chen, G. S. Corrado, and J. Dean. Distributed representations of words and phrases and their compositionality. In Advances in neural information processing systems, pages 3111–3119, 2013.
|
| 248 |
+
[26] V. Mnih, A. P. Badia, M. Mirza, A. Graves, T. Lillicrap, T. Harley, D. Silver, and K. Kavukcuoglu. Asynchronous methods for deep reinforcement learning. In International conference on machine learning, pages 1928–1937. PMLR, 2016.
|
| 249 |
+
[27] V. Mnih, K. Kavukcuoglu, D. Silver, A. Graves, I. Antonoglou, D. Wierstra, and M. Riedmiller. Playing atari with deep reinforcement learning. arXiv preprint arXiv:1312.5602, 2013.
|
| 250 |
+
[28] J. Pennington, R. Socher, and C. D. Manning. Glove: Global vectors for word representation. In Proceedings of the 2014 conference on empirical methods in natural language processing (EMNLP), pages 1532–1543, 2014.
|
| 251 |
+
[29] M. E. Peters, M. Neumann, M. Iyyer, M. Gardner, C. Clark, K. Lee, and L. Zettlemoyer. Deep contextualized word representations. arXiv preprint arXiv:1802.05365, 2018.
|
| 252 |
+
[30] E. A. Platanios, A. Pauls, S. Roy, Y. Zhang, A. Kyte, A. Guo, S. Thomson, J. Krishnamurthy, J. Wolfe, J. Andreas, et al. Value-agnostic conversational semantic parsing. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 3666–3681, 2021.
|
| 253 |
+
[31] X. Puig, K. Ra, M. Boben, J. Li, T. Wang, S. Fidler, and A. Torralba. Virtualhome: Simulating household activities via programs. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 8494–8502, 2018.
|
| 254 |
+
[32] X. Puig, T. Shu, S. Li, Z. Wang, J. B. Tenenbaum, S. Fidler, and A. Torralba. Watch-and-help: A challenge for social perception and human-ai collaboration. arXiv preprint arXiv:2010.09890, 2020.
|
| 255 |
+
[33] A. Radford, K. Narasimhan, T. Salimans, and I. Sutskever. Improving language understanding by generative pre-training. 2018.
|
| 256 |
+
[34] A. Radford, J. Wu, R. Child, D. Luan, D. Amodei, I. Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
|
| 257 |
+
[35] A. Raffin, A. Hill, A. Gleave, A. Kanervisto, M. Ernestus, and N. Dormann. Stable-baselines3: Reliable reinforcement learning implementations. Journal of Machine Learning Research, 22(268):1–8, 2021.
|
| 258 |
+
[36] M. Reid, Y. Yamada, and S. S. Gu. Can wikipedia help offline reinforcement learning? arXiv preprint arXiv:2201.12122, 2022.
|
| 259 |
+
[37] J. Schulman, F. Wolski, P. Dhariwal, A. Radford, and O. Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
|
| 260 |
+
[38] P. Sharma, A. Torralba, and J. Andreas. Skill induction and planning with latent language. In Association for Computational Linguistics, 2022.
|
| 261 |
+
[39] B. Shen, F. Xia, C. Li, R. Martín-Martín, L. Fan, G. Wang, S. Buch, C. D’Arpino, S. Srivastava, L. P. Tchapmi, et al. igibson, a simulation environment for interactive tasks in large realisticscenes. arXiv preprint arXiv:2012.02924, 2020.
|
| 262 |
+
[40] M. Shridhar, J. Thomason, D. Gordon, Y. Bisk, W. Han, R. Mottaghi, L. Zettlemoyer, and D. Fox. Alfred: A benchmark for interpreting grounded instructions for everyday tasks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 10740–10749, 2020.
|
| 263 |
+
[41] E. Todorov, T. Erez, and Y. Tassa. Mujoco: A physics engine for model-based control. In 2012 IEEE/RSJ International Conference on Intelligent Robots and Systems, pages 5026–5033. IEEE, 2012.
|
| 264 |
+
[42] M. Tsimpoukelli, J. Menick, S. Cabi, S. Eslami, O. Vinyals, and F. Hill. Multimodal few-shot learning with frozen language models. arXiv preprint arXiv:2106.13884, 2021.
|
| 265 |
+
[43] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762, 2017.
|
| 266 |
+
[44] J. Vig. A multiscale visualization of attention in the transformer model. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pages 37–42, Florence, Italy, July 2019. Association for Computational Linguistics.
|
| 267 |
+
[45] B. Wang, R. Shin, X. Liu, O. Polozov, and M. Richardson. Rat-sql: Relation-aware schema encoding and linking for text-to-sql parsers. arXiv preprint arXiv:1911.04942, 2019.
|
| 268 |
+
[46] T. Wolf, L. Debut, V. Sanh, J. Chaumond, C. Delangue, A. Moi, P. Cistac, T. Rault, R. Louf, M. Funtowicz, et al. Huggingface’s transformers: State-of-the-art natural language processing. arXiv preprint arXiv:1910.03771, 2019.
|
| 269 |
+
[47] Z. Yang, Z. Dai, Y. Yang, J. Carbonell, R. R. Salakhutdinov, and Q. V. Le. Xlnet: Generalized autoregressive pretraining for language understanding. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019.
|
| 270 |
+
[48] Z. Yang, N. Garcia, C. Chu, M. Otani, Y. Nakashima, and H. Takemura. Bert representations for video question answering. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 1556–1565, 2020.
|
| 271 |
+
[49] J. Zhu, Y. Xia, L. Wu, D. He, T. Qin, W. Zhou, H. Li, and T.-Y. Liu. Incorporating bert into neural machine translation. arXiv preprint arXiv:2002.06823, 2020.
|
| 272 |
+
|
| 273 |
+
# Checklist
|
| 274 |
+
|
| 275 |
+
1. For all authors...
|
| 276 |
+
|
| 277 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 278 |
+
(b) Did you describe the limitations of your work? [Yes] See Section 9.
|
| 279 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] See Section 9.
|
| 280 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 281 |
+
|
| 282 |
+
2. If you are including theoretical results...
|
| 283 |
+
|
| 284 |
+
(a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
|
| 285 |
+
|
| 286 |
+
3. If you ran experiments...
|
| 287 |
+
|
| 288 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] In the supplemental material.
|
| 289 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 6 and Appendix C.2.
|
| 290 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Section 6.
|
| 291 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Appendix C.2.
|
| 292 |
+
|
| 293 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 294 |
+
|
| 295 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 296 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 297 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 298 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 299 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] See Section 9.
|
| 300 |
+
|
| 301 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 302 |
+
|
| 303 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 304 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 305 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/IajGRJuM7D3/IajGRJuM7D3.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/KmtVD97J43e/KmtVD97J43e.md
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SYNCHROMESH: RELIABLE CODE GENERATION FROM PRE-TRAINED LANGUAGE MODELS
|
| 2 |
+
|
| 3 |
+
Gabriel Poesia∗† Stanford University poesia@stanford.edu
|
| 4 |
+
|
| 5 |
+
Oleksandr Polozov∗‡ X, the moonshot factory polozov@google.com
|
| 6 |
+
|
| 7 |
+
Vu Le, Ashish Tiwari, Gustavo Soares, Christopher Meek, Sumit Gulwani Microsoft Research, Redmond {levu,astiwar,gustavo.soares,meek,sumitg}@microsoft.com
|
| 8 |
+
|
| 9 |
+
# ABSTRACT
|
| 10 |
+
|
| 11 |
+
Large pre-trained language models have been used to generate code, providing a flexible interface for synthesizing programs from natural language specifications. However, they often violate syntactic and semantic rules of their output language, limiting their practical usability. In this paper, we propose SYNCHROMESH: a framework for substantially improving the reliability of pre-trained models for code generation. SYNCHROMESH comprises two components. First, it retrieves few-shot examples from a training bank using Target Similarity Tuning (TST), a novel method for semantic example selection. TST learns to recognize utterances that describe similar target programs despite differences in surface natural language features. Then, SYNCHROMESH feeds the examples to a pre-trained language model and samples programs using Constrained Semantic Decoding (CSD): a general framework for constraining the output to a set of valid programs in the target language. CSD leverages constraints on partial outputs to sample complete correct programs, and needs neither re-training nor fine-tuning of the language model. We evaluate our methods by synthesizing code from natural language descriptions using GPT-3 and Codex in three real-world languages: SQL queries, Vega-Lite visualizations and SMCalFlow programs. These domains showcase rich constraints that CSD is able to enforce, including syntax, scope, typing rules, and contextual logic. We observe substantial complementary gains from CSD and TST in prediction accuracy and in effectively preventing run-time errors.
|
| 12 |
+
|
| 13 |
+
# 1 INTRODUCTION
|
| 14 |
+
|
| 15 |
+
Large language models (LLMs) trained on massive corpora of unsupervised data have been shown to perform a wide range of tasks, including natural language generation, semantic parsing and sentiment analysis (Brown et al., 2020; Devlin et al., 2019; Raffel et al., 2020). This can be achieved without task-specific training, but rather by adapting the model to each task at test-time using textual prompts, which can contain examples and natural language descriptions. In many cases, this methodology was shown to provide good performance, reducing the need to annotate large datasets for each task of interest (Brown et al., 2020; Shin et al., 2021).
|
| 16 |
+
|
| 17 |
+
An important application of LLMs is in synthesizing programs from natural language descriptions (Austin et al., 2021; Chen et al., 2021). But this task is still challenging for LLMs. First, they can commit conceptual errors, generating code that misses the intent behind the given description. For example, when asked to reverse an array, the model might generate code that simply swaps the first and last elements. Indeed, users of current natural language-to-code systems report that models often produce code that is unrelated to their query (Xu et al., 2021).
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Overview of the SYNCHROMESH framework. Given the user’s query, high-relevance examples are first retrieved with Target Similarity Tuning (TST). Then, a program is incrementally sampled via Constrained Semantic Decoding (CSD), which queries a completion engine (CE) to enforce constraints during code generation without re-training or fine-tuning the language model.
|
| 21 |
+
|
| 22 |
+
Even when they capture the right intent, LLMs can still make implementation errors: the generated code can fail to execute. For reversing an array, a model might generate a loop with the correct structure but with an off-by-one error, causing a runtime exception. These errors are common even with very large models. For example, Austin et al. (2021) tested models with up to 137B parameters on generating short Python programs from natural language. Still, $47 \%$ of the failures were due to syntax, typing or run-time errors (as opposed to running but producing incorrect output). This is in line with theoretical results in Merrill et al. (2021) showing that programming language semantics cannot be fully inferred from ungrounded data. Together, both observations suggest that simply scaling up LLMs might be ineffective to obtain reliable performance, especially for longer programs.
|
| 23 |
+
|
| 24 |
+
In this paper, we address both conceptual and implementation errors with SYNCHROMESH, a framework for reliable code generation from pre-trained models. Since LLMs are highly sensitive to which few-shot examples are given in their prompt, we propose Target Similarity Tuning (TST): a method for dynamically selecting semantically relevant examples for a given description. TST mitigates conceptual errors by learning to select examples with similar intent, even when their natural language descriptions seem unrelated in form. Given relevant examples, we then generate programs with Constrained Semantic Decoding (CSD), a novel method for enforcing rich syntactic and semantic constraints during code generation on top of a frozen language model. Rich language-specific constraints, ranging from syntax validity to scoping and type-checking, can be implemented under the simple abstraction of completion engines $( C E )$ . CSD aligns these constraints with the language model’s token vocabulary by leveraging Brzozowski language derivatives (Brzozowski, 1964). This guarantees that all sampled programs satisfies the implemented constraints, preventing whole classes of implementation errors by construction. The pipeline is illustrated in Figure 1.
|
| 25 |
+
|
| 26 |
+
We demonstrate the generality of SYNCHROMESH in three real-world languages: SQL (database queries), Vega-Lite (data visualization) and SMCalFlow (calendar applications). In experiments with GPT-3 and Codex, we observe that SYNCHROMESH can eliminate whole classes of errors that make outputs from unconstrained models either fail to execute or produce trivial results (e.g., empty charts). Furthermore, eliminating invalid programs consistently improves prediction accuracy. In summary, we make the following contributions:
|
| 27 |
+
|
| 28 |
+
• We propose Target Similarity Tuning for selecting few-shot examples based on the similarity of the programs they describe, improving relevance and downstream performance. • We introduce completion engines as an abstraction that can implement rich classes of semantic program constraints, as we demonstrate in SQL, Vega-Lite and SMCalFlow. • We introduce a general, constraint-observing decoding algorithm, which aligns programming language constraints with the language model’s token vocabulary. • We evaluate our method in three natural language-to-code tasks. CSD and TST both show strong complementary gains in output validity and prediction accuracy across domains.
|
| 29 |
+
|
| 30 |
+
# 2 TARGET SIMILARITY TUNING
|
| 31 |
+
|
| 32 |
+
In this section, we first overview the challenge posed by conceptual errors in programs synthesized by LLMs. We then introduce TST, which improves performance through more relevant example selection. Throughout, we will use a real example of synthesizing a SQL database query to answer a question posed in natural language.
|
| 33 |
+
|
| 34 |
+

|
| 35 |
+
Figure 2: Example of Target Similarity Tuning improving example selection for synthesizing a SQL query. In (a), the prompt example missed the key query structure (grouping and counting). With this example, GPT-3 generates an invalid query (b). With TST, we retrieve a relevant example which GPT-3 successfully adapts to answer the user’s question (c).
|
| 36 |
+
|
| 37 |
+
Suppose a data analyst has a relational database of airports and wants to answer the following question: “Which city has the highest number of airports?” One procedure for turning this description into a SQL query is to use an LLM such as GPT-3 (Brown et al., 2020) or Codex (Chen et al., 2021). To prompt the model for the task at hand, we would feed it with a natural language description of the task and a selection of input-output examples.
|
| 38 |
+
|
| 39 |
+
Given the analyst’s question, how do we select the most relevant examples from a training pool? Liu et al. (2021a) proposed to retrieve examples with similar natural language descriptions using a pre-trained paraphrase detection model. Figure 2a shows the most similar example from the Spider natural language-to-SQL dataset (Yu et al., 2018) according to Sentence-BERT (Reimers & Gurevych, 2019). The query “Which city has the highest elevation?” is similar on a surface level: it also asks “Which city has the highest ?”. This training query asks about “elevation”, a property that is readily available as a column in the Airports table. Figure 2b shows GPT-3’s output when given this and a few other examples. The model attempts to mimic the top example, referring to a nonexistent column “NumberOfAirports”. The issue is that we picked the example in the prompt based on description similarity and not SQL query similarity. In fact, the SQL query in the chosen example had a simplistic structure that was significantly different from the structure of the desired SQL query, and this contributed to the failure at Point (b) in Figure 2.
|
| 40 |
+
|
| 41 |
+
We want to retrieve examples that have relevant program structures for the test query. We do so using our fine-tuning scheme called Target Similarity Tuning (TST). Formally, suppose $\mathcal { D }$ is a dataset of programs and associated utterances, with $\mathcal { D } _ { i } = ( p _ { i } , u _ { i } )$ . Let $S ( p _ { a } , p _ { b } ) \bar { \in } [ 0 , \bar { 1 } ]$ denote a normalized similarity metric between programs. If $f _ { \theta }$ is a pre-trained similarity model for natural language sentences, TST consists in fine-tuning $f$ to predict the similarity between target programs given by $S$ from their descriptions. Precisely, we minimize the mean-squared error loss:
|
| 42 |
+
|
| 43 |
+
$$
|
| 44 |
+
\mathcal { L } _ { T S T } ( \theta ) : = \mathbb { E } _ { i , j \sim \mathcal { D } } \left[ f _ { \theta } ( u _ { i } , u _ { j } ) - S ( p _ { i } , p _ { j } ) \right] ^ { 2 } \ .
|
| 45 |
+
$$
|
| 46 |
+
|
| 47 |
+
We define $S$ using the classical tree edit distance algorithm from Zhang & Shasha (1989) to compare Abstract Syntax Trees (ASTs). Figure $2 \mathrm { c }$ shows GPT-3’s output when given examples selected with TST. Now, the output query is correct: it performs a “group by” on the “City” column, and sorts by the count of records in each group. This structure was already present in the top example selected by TST, corresponding to “Return the team with the most technicians”. Even if the analyst’s question and this utterance are drastically different in natural language, they share similarity in the SQL query that they describe. The TST objective is able to properly capture this fact. As our experiments show in Section 4, TST significantly boosts the performance of both GPT-3 and Codex.
|
| 48 |
+
|
| 49 |
+
# 3 CONSTRAINED SEMANTIC DECODING
|
| 50 |
+
|
| 51 |
+
We now present Constrained Semantic Decoding (CSD) as an approach to eliminate implementation errors from code generated by LLMs. We first illustrate CSD with an example, and then formalize it using the abstraction of CEs.
|
| 52 |
+
|
| 53 |
+

|
| 54 |
+
Figure 3: Example on CSD generating a SQL query. Given the prompt, GPT-3 makes a mistake (a) when generating the JOIN condition. CSD is able to prevent this error by (b) keeping track of table aliases and constraining the model to respect the database schema.
|
| 55 |
+
|
| 56 |
+
The example in Figure 2 showed that TST can help LLMs generate the correct program. In general, however, TST only helps LLMs by guiding toward the correct structure, but the model still needs to fill all the specific implementation details correctly. Figure 3 shows a case where the model cannot simply adapt one example from the prompt. Here, the user’s query is “Which city has the highest number of departing flights?” This query is similar to the previous one – in fact, TST retrieves the same top-1 example as before. But now the correct SQL query needs to join the “Airports” and “Flights” tables. GPT-3 generates the join condition Flights.AirportCode $=$ Airports.SourceAirport, but this condition has a subtle error: the column names of the two tables are swapped. Thus, this query fails to execute. In general, unconstrained language models often make such implementation errors: using undeclared variables, losing track of nesting levels when producing complex expressions, or calling functions using arguments of the wrong type. Even the smallest of such errors prevents generated code from executing.
|
| 57 |
+
|
| 58 |
+
CSD prevents implementation errors by construction (as opposed to repairing after-the-fact). Imagine we have access to an oracle, which we call a $C E$ , that can take a partial program and return all tokens that can extend that partial program toward a complete correct program. When the LLM is generating the program token by token, CSD ensures that the next token is sampled from the set returned by the CE.
|
| 59 |
+
|
| 60 |
+
In Figure 3, after generating “T1.” inside the “on” clause, our SQL CE resolves the alias and constrains the model to output one of the columns from the “Flights” table. This fixes the error seen previously during generation and produces the correct SQL query.
|
| 61 |
+
|
| 62 |
+
# 3.1 COMPLETION ENGINES
|
| 63 |
+
|
| 64 |
+
We now formally define CEs. Let $\Sigma$ be a base alphabet, and $\Sigma _ { L } \subseteq \Sigma ^ { * }$ be the (potentially infinite) set of tokens of the target language. Our goal is to sample programs from a language $L \subseteq \Sigma _ { L } ^ { * } -$ the set of valid programs. A CE $C _ { L }$ is a partial function from $\Sigma _ { L } ^ { * }$ to a set of tokens. We use a regular expression over $\Sigma$ to represent a set of tokens. The strings in the domain of $C _ { L }$ are called completion points, and a CE satisfies the following axioms: (A1) The empty string and every $p \in L$ must be completion points. For every $p \in L$ , $\bar { C _ { L } } ( p ) = r ^ { \prime } \ S ^ { \prime }$ , where $r ^ { \prime } \bar { \mathfrak { F ^ { \prime } } }$ is the regular expression that matches the stop token. (A2) If $s \in \Sigma _ { L } ^ { * }$ is a completion point and $t$ fully matches $C _ { L } ( s )$ , then their concatenation $^ { s t }$ must also be a completion point. (A3) The CE is exhaustive; that is, if $s$ is a completion point and $s = t t _ { 0 }$ , where $t _ { 0 }$ is a token, then $t$ should be a completion point and $C _ { L } ( t )$ should match $t _ { 0 }$ . Furthermore, we assume that CEs are only called after maximal matches. For example, if a partial program ends in an identifier, the CE can assume that the identifier is complete.
|
| 65 |
+
|
| 66 |
+
Our CEs are implemented in two layers: a context-free layer, which enforces syntactic validity, and a context-sensitive layer, which encodes semantic constraints that depend on language semantics and the user’s context (e.g., the database). Below, we describe an automatic method for constructing context-free CEs directly from the target language’s grammar. The context-sensitive layer of an engine is specific to the target language. Table 1 provides an overview of several constraints implemented by our CEs for SQL, Vega-Lite and SMCalFlow, three rich languages with different syntactic and semantic structures. A detailed description of the three CEs can be found in Appendix C.
|
| 67 |
+
|
| 68 |
+
Table 1: Examples of constraints implemented in our CEs for SQL, Vega-Lite and SMCalFlow. Given a partial program, CEs return a regular expression that matches the valid tokens that can follow. Here, we show positive and negative token examples for each such regular expression. This abstraction allows domain experts to encode a wide range of expressive code generation constraints.
|
| 69 |
+
|
| 70 |
+
<table><tr><td>Language</td><td>Constraint</td><td>Example of partial program</td><td>Valid/Invalid Examples</td></tr><tr><td>SQL</td><td>A valid identifier must follow after AS.</td><td>SELECT Name, Role FROM User AS^</td><td>U √ T1 √ 2×</td></tr><tr><td></td><td>Column names must come from schema,even behind aliases.</td><td>SELECT U.Name FROM User AS U WHERE U. ^</td><td>Name√ DoB√ Birthday X</td></tr><tr><td>Vega-Lite</td><td>Data fields must be used with compatible types. Do not facet on field with too many distinct values (breaks</td><td>{"x": {"field": "Category", "type":^ {"column":{"field": ^</td><td>"nominal" "temporal" X "Category" "ZipCode" </td></tr><tr><td>SMCalFlow</td><td>rendering). Type-check parameters of all</td><td>(Yield</td><td>Takeout√</td></tr><tr><td></td><td>API functions. Track declared variables and</td><td>(PlaceHasFeature(> (let (x 85)</td><td>IsWindy X List.Apply X x√</td></tr></table>
|
| 71 |
+
|
| 72 |
+
Deriving completions from grammars Computer language parsers are often automatically generated from a grammar. The grammar contains enough information to derive the context-free layer of CEs. To facilitate this process, we created a library that extends any parser generated by ANTLR (Parr & Fisher, 2011), a popular $\operatorname { L L } ( ^ { * } )$ top-down parser generator, to provide token-level completions. Namely, we (i) let the ANTLR-generated parser process the given program prefix $p$ , (ii) retrieve its state in the Augmented Transition Network (ATN) at the last program token, (iii) traverse the ATN from that state to enumerate all possible next token productions. This process yields (a) a list of productions and token types $\{ \tau _ { j } \} _ { j = 1 } ^ { K }$ that are allowed to follow $p$ and $\mathbf { ( b ) }$ a partial AST $T _ { p }$ . Each CE takes $\{ \tau _ { j } \}$ and $T _ { p }$ as input to generate semantic context-sensitive constraints.
|
| 73 |
+
|
| 74 |
+
# 3.2 FROM COMPLETION ENGINES TO A DECISION PROCEDURE
|
| 75 |
+
|
| 76 |
+
We use CEs to guide sampling from an LLM. A key component of our algorithm for constrained sampling is a decision procedure for membership in prefix-closure of the set $L$ of all valid programs. The prefix-closure $L ^ { c }$ of a language $L$ contains all programs in $L$ as well as all of their prefixes. Intuitively, $L ^ { c }$ contains all partial programs that can be completed to a valid program. Given a CE $C _ { L }$ , our first goal is to build a decision procedure for $L ^ { c }$ : given a string $s$ , does it belong to $L ^ { c } ?$
|
| 77 |
+
|
| 78 |
+
We answer if $s \in L ^ { c }$ by repeatedly calling $C _ { L }$ on certain prefixes $p$ of $s$ and matching the regular expression $C _ { L } ( \boldsymbol { p } )$ with suffixes of $s$ . We start with $p$ being the empty string. We find the maximal prefix of $s$ that matches the regular expression $C _ { L } ( \boldsymbol { p } )$ and remove it from $s$ and add it to $p$ , and repeat until the match fails. There are two cases: either $s$ is empty now, which means the input string was a completion point and hence it is in $L ^ { c }$ , or $s$ now is the remainder left after removing the largest prefix that was a completion point. For the second case, we must check: does there exist a completion string $c$ such that $s c$ fully matches the regular expression $C _ { L } ( \boldsymbol { p } )$ ?
|
| 79 |
+
|
| 80 |
+
This question can be efficiently answered by Brzozowski derivatives (Brzozowski, 1964). Formally, the derivative of a formal language $S$ with respect to a string $u$ is another formal language $u ^ { - 1 } S \stackrel { . } { = }$ $\{ v : u v \in S \}$ . In other words, it is precisely the set of strings that can complete $u$ to some string in $S$ . If $u ^ { - 1 } S \stackrel { . } { = } \varnothing$ , then no string in $S$ starts with $u$ . Brzozowski derivatives are efficient to compute for our regular languages (or regular expressions defining them) – we describe a simple linear-time algorithm in the Appendix. Given the derivative of $C _ { L } ( \boldsymbol { p } )$ , answering whether $s$ can be completed to belong to $C _ { L } ( \boldsymbol { p } )$ reduces to performing a simple regular expression match. This operation answers the case when the remainder is non-empty and completes our decision procedure for $L ^ { c }$ .
|
| 81 |
+
|
| 82 |
+
# 3.3 THE CONSTRAINED SEMANTIC DECODING ALGORITHM
|
| 83 |
+
|
| 84 |
+
Using the decision procedure for $L ^ { c }$ , we can now describe the Constrained Semantic Decoding algorithm. Suppose $s \in L ^ { c }$ is the language model’s output so far (we start with $\epsilon$ ). If $\Sigma _ { M }$ is the model’s vocabulary, we can compute the set of valid next tokens $V _ { M } ( s ) = \{ t \in \Sigma _ { M } : s t \in L ^ { c } \}$ by using our decision procedure for each token in the vocabulary $\Sigma _ { M }$ . In other words, we maintain the invariant that the model’s current partial output $s$ is in $L ^ { c }$ , and make progress by using the model to sample from $V _ { M } ( s )$ , instead of the unconstrained $\Sigma _ { M }$ . Once we have a complete program, we are guaranteed that it will satisfy all constraints enforced by the CE.
|
| 85 |
+
|
| 86 |
+
One subtlety to note is that language models and programming languages have drastically different tokenizations; i.e., $C _ { L }$ and LLM work with different tokens. For instance, a long string literal is a single SQL token, but might span multiple tokens for the language model. Similarly, a single token from the language model’s vocabulary might close multiple parentheses at once. In general, token boundaries between the two can be arbitrarily misaligned. Each decision of whether $^ { s t }$ belongs to $L ^ { c }$ can potentially cross multiple completion points, or might not even finish a maximal match to the previous completion point (see the Appendix for an example prediction in Vega-Lite where this happens multiple times). Nevertheless, our CSD algorithm described here naturally handles this alignment problem. Hence, in SYNCHROMESH, CEs do not need to be aware of this issue – they can be fully implemented in terms of the target language’s tokens.1
|
| 87 |
+
|
| 88 |
+
Our implementation applies substantial optimizations that leverage the structure of Byte-Pair Encoding vocabularies (namely, that many tokens are prefixes of longer tokens) and reuse computation. We detail these optimizations in Appendix E. In our experiments with GPT-3, CSD adds an average of $8 \%$ overhead to the sampling procedure – a relatively small impact to trade for output correctness.
|
| 89 |
+
|
| 90 |
+
# 4 EXPERIMENTS
|
| 91 |
+
|
| 92 |
+
We evaluate SYNCHROMESH in three tasks of synthesizing code from natural language descriptions. For SQL, we use the Spider dataset (Yu et al., 2018). For Vega-Lite, we use the NLV Corpus (Srinivasan et al., 2021). For SMCalFlow, we use the dataset that introduced the language (Andreas et al., 2020). In NLV, which has visualizations over 3 different datasets, we alternate using each dataset as a test-set by only using training examples from the other two datasets. In Spider and SMCalFlow, we use the training/validation set split given in each dataset.
|
| 93 |
+
|
| 94 |
+
Example selection model To select examples, we use Sentence-BERT (Reimers & Gurevych, 2019) to fetch the 5 closest examples by cosine similarity. When using TST, we fine-tuned the model with the TST objective in both the Spider and SMCalFlow training sets. The NLV corpus is smaller and does not provide a clear train-test split to fairly evaluate TST. Holding out one dataset and fine-tuning on the remaining two yields SYNCHROMESH accuracies of over $90 \%$ . However, we attribute that performance to the fact that NLV has only 10 distinct visualizations and the same participants labeled all three datasets. For that reason, we omit Vega-Lite from the TST experiments.
|
| 95 |
+
|
| 96 |
+
Language models We used the two largest models from the GPT-3 family (Brown et al., 2020, with 13B and 175B parameters), as well as the largest Codex model (Chen et al., 2021). Codex shares the same architecture with 175B GPT-3, but its training set contained a larger portion of source code in a variety of languages. Our only access to the models was through the public OpenAI HTTP API, which allowed us to apply constraints by adding a bias to logits. We describe the necessary adaptations of CSD to this setting in Appendix F.
|
| 97 |
+
|
| 98 |
+
Metrics For Vega-Lite and SMCalFlow, we report the exact-match accuracy between predictions and ground-truth (field order is disregarded in Vega-Lite). In SQL, we instead measure execution accuracy, comparing query results instead. For a more fine-grained signal, we additionally measure the edit distance between the predicted and ground-truth ASTs using the normalized tree edit distance (Zhang & Shasha, 1989).
|
| 99 |
+
|
| 100 |
+
Table 2: Results of each language model on all domains with and without CSD and TST. For SQL, we run the resulting query and report Execution Match accuracy (Exec.). For Vega-Lite and SMCalFlow, we instead report Exact Match accuracy (Acc.). Edit Distance (Dist.) measures average relative edit distance between the prediction and the ground truth. We also report the fraction of Valid model outputs (those that parse, type-check and execute). For context only, we show recent results from supervised models (trained on the datasets we use) marked with (S).
|
| 101 |
+
|
| 102 |
+
<table><tr><td rowspan="2">Model</td><td rowspan="2">Exec.</td><td colspan="3">SQL</td><td colspan="2">Vega-Lite</td><td colspan="3">SMCalFlow</td></tr><tr><td>Valid</td><td>Dist.</td><td>Acc.</td><td>Valid</td><td>Dist.</td><td>Acc.</td><td>Valid</td><td>Dist.</td></tr><tr><td>Andreas et al. (2020)</td><td></td><td>=</td><td></td><td></td><td>=</td><td>=</td><td>72%(s)</td><td>=</td><td></td></tr><tr><td>Srinivasan et al. (2021)</td><td>=</td><td>=</td><td>=</td><td>64%(s)</td><td>=</td><td>=</td><td>=</td><td>=</td><td>=</td></tr><tr><td>Rubin & Berant (2021)</td><td>71%(s)</td><td>-</td><td>=</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Scholak et al. (2021)</td><td>79%(s)</td><td>98%</td><td>1</td><td></td><td>1</td><td>=</td><td></td><td></td><td></td></tr><tr><td>GPT-3 13B</td><td>16%</td><td>43%</td><td>0.42</td><td>14%</td><td>55%</td><td>0.51</td><td>38%</td><td>76%</td><td>0.43</td></tr><tr><td>”+ CSD</td><td>20%</td><td>66%</td><td>0.44</td><td>17%</td><td>100%</td><td>0.48</td><td>40%</td><td>95%</td><td>0.40</td></tr><tr><td>"+TST</td><td>14%</td><td>48%</td><td>0.42</td><td>1</td><td>-</td><td>-</td><td>60%</td><td>88%</td><td>0.22</td></tr><tr><td>”+ CSD + TST</td><td>19%</td><td>72%</td><td>0.43</td><td>-</td><td>-</td><td>-</td><td>63%</td><td>98%</td><td>0.17</td></tr><tr><td>GPT-3175B</td><td>28%</td><td>49%</td><td>0.36</td><td>20%</td><td>67%</td><td>0.36</td><td>44%</td><td>77%</td><td>0.41</td></tr><tr><td>”+ CSD</td><td>35%</td><td>73%</td><td>0.36</td><td>25%</td><td>100%</td><td>0.32</td><td>45%</td><td>97%</td><td>0.37</td></tr><tr><td>”+ TST</td><td>31%</td><td>56%</td><td>0.35</td><td>1</td><td>-</td><td>-</td><td>60%</td><td>88%</td><td>0.24</td></tr><tr><td>"+ CSD + TST</td><td>37%</td><td>76%</td><td>0.34</td><td>-</td><td>-</td><td>-</td><td>66%</td><td>97%</td><td>0.18</td></tr><tr><td>Codex 175B</td><td>56%</td><td>73%</td><td>0.25</td><td>39%</td><td>87%</td><td>0.24</td><td>45%</td><td>79%</td><td>0.37</td></tr><tr><td>”+ CSD</td><td>61%</td><td>85%</td><td>0.23</td><td>40%</td><td>99%</td><td>0.23</td><td>46%</td><td>97%</td><td>0.33</td></tr><tr><td>”+TST</td><td>60%</td><td>81%</td><td>0.23</td><td>1</td><td>1</td><td>-</td><td>63%</td><td>90%</td><td>0.21</td></tr><tr><td>"+ CSD + TST</td><td>64%</td><td>85%</td><td>0.23</td><td>-</td><td>1</td><td>-</td><td>63%</td><td>99%</td><td>0.19</td></tr></table>
|
| 103 |
+
|
| 104 |
+
# 4.1 RESULTS
|
| 105 |
+
|
| 106 |
+
Table 2 and Figure 4 summarize our main results evaluating SYNCHROMESH. Key observations are:
|
| 107 |
+
|
| 108 |
+
SYNCHROMESH improves reliability on top of all pre-trained LLMs. First, it improves top-1 accuracy (exact or execution-measured) over any pre-trained LLM in all domains. SMCalFlow benefits the most, likely because this domain-specific language is absent in the LLM pre-training corpus. For SQL and SMCalFlow, the absolute gain is almost the same for equally-sized GPT-3 and Codex.
|
| 109 |
+
|
| 110 |
+
Second, SYNCHROMESH dramatically improves validity. In SQL, it eliminates execution errors from $2 9 \%$ of the queries generated by GPT-3 13B (as validity improves from $43 \%$ to $72 \%$ ). Even Codex benefits, with $12 \%$ more queries executing successfully after SYNCHROMESH augmentation. In Vega-Lite and SMCalFlow, SYNCHROMESH improves reliability even more substantially. GPT-3 13B only produces valid charts for $55 \%$ of the queries in NLV; all errors are eliminated with SYNCHROMESH. This is nearly paralleled in SMCalFlow, in which all models produce well-typed programs $9 7 \%$ of the time or more with SYNCHROMESH.
|
| 111 |
+
|
| 112 |
+
SYNCHROMESH brings the output closer to ground truth. Error prevention alone is trivial (e.g., with a constant error-free prediction), but not while simultaneously improving accuracy or edit distance to the ground-truth, as SYNCHROMESH does. Again, we observe improvements in all domains and the most in SMCalFlow. For GPT-3 175B, the average edit distance is reduced from 0.41 to 0.18.
|
| 113 |
+
|
| 114 |
+
TST and CSD bring complementary benefits. Our ablation studies reported in Table 2 show that their combination performs better than either one separately. TST helps LLMs generate programs in the “vicinity” of the correct one, and CSD helps by “guiding” the models toward the correct one.
|
| 115 |
+
|
| 116 |
+
SYNCHROMESH adds more value for longer programs. Program synthesis is hardest when the target program is complex. Does SYNCHROMESH improve synthesis of longer programs, or are its benefits coming from fixes to small programs? Figure 4(a) shows accuracies and (b) validity for SMCalFlow broken down by the length of the ground truth program (we show results for SQL in the Appendix). Here, program lengths are shown as their percentile. With SYNCHROMESH, we see that accuracy decays at a slower pace, and validity remains high throughout, when compared to Codex alone. This indicates that SYNCHROMESH improves the ability of base models to generate longer programs.
|
| 117 |
+
|
| 118 |
+

|
| 119 |
+
Figure 4: (a) Accuracy and (b) validity of Codex predictions with and without SYNCHROMESH on SMCalFlow as a function of the ground-truth program length. We map program lengths to percentiles, and round to the closest multiple of $10 \%$ . Error bands correspond to standard error. (c) Evaluation of the “generate-then-test” approach with Codex, showing the probability of at least one prediction being a valid program (Valid $( \varpi \mathrm { K } )$ ) for up to 5 samples.
|
| 120 |
+
|
| 121 |
+

|
| 122 |
+
Figure 5: Illustration of implementation and conceptual errors in Vega-Lite. CSD can avoid generating the invalid Vega-Lite mark type “scatterplot”, though conceptual errors can still remain.
|
| 123 |
+
|
| 124 |
+
LLMs augmented with SYNCHROMESH approach but underperform supervised models. For context, we include state-of-the-art results at the time of writing for each task in Table 2. We note that these methods fine-tune or train the underlying language-to-code model on each task, thus are not directly comparable to LLMs with SYNCHROMESH. That said, we observe that base LLMs—even Codex— substantially underperform supervised models ( $19 \%$ worse for SQL; $27 \%$ worse for SMCalFlow), and SYNCHROMESH helps narrow that gap (now $11 \%$ worse for SQL; $9 \%$ worse for SMCalFlow).
|
| 125 |
+
|
| 126 |
+
SYNCHROMESH outperforms “generate-then-test”. CSD enforces program constraints during generation. Instead, prior work has leveraged a “generate-then-test” approach: take multiple samples and filter out those that produce errors or violate constraints (Chen et al., 2021). Figure 4(b) evaluates this approach with Codex, the highest performing base LLM. We sample from Codex with a temperature $\tau = 0 . 7$ to obtain diverse but high-quality samples. We then compute the “Valid $@ \mathrm { K } '$ metric by using the “Pass $@ \mathrm { K } '$ estimator from Chen et al. (2021) to calculate the probability of at least one valid sample among $K$ , with $K \leq 5$ . In SQL, Codex needs 3 samples to match SYNCHROMESH (Va $\mathrm { l i d } @ \mathrm { K } = 8 5 \%$ ). In SMCalFlow and Vega-Lite, SYNCHROMESH is able to virtually eliminate errors with 1 sample, while “Valid $@ 5 '$ for Codex is still below $93 \%$ . This provides evidence that even the best LLMs benefit from incremental validation, especially in less popular languages.
|
| 127 |
+
|
| 128 |
+
# 4.2 DISCUSSION
|
| 129 |
+
|
| 130 |
+
In our experiments, SYNCHROMESH was able to improve accuracies and program validity across all languages due to better examples to use as a reference (TST) and preventing errors during generation (CSD). Yet, this approach has an important limitation. While TST can reduce conceptual errors, and CSD can guarantee that certain implementation errors never occur (e.g., type errors in SMCalFlow, or undefined column references in Vega-Lite or SQL), TST cannot guarantee elimination of conceptual errors. When those occur, CSD is usually insufficient to correct the prediction. Figure 5 shows an example in Vega-Lite from the “Cars” dataset in NLV. Here, the user asks for one scatter plot for each origin, indicating faceting (multiple charts). GPT-3 alone produces an invalid Vega-Lite chart type, “scatterplot”. CSD can eliminate this error, guiding GPT-3 to generate “point” instead. However, a conceptual error remains: instead of faceting, the model colors points by their origin. Codex produces the correct Vega-Lite mark type, but still makes the same conceptual mistake.
|
| 131 |
+
|
| 132 |
+
Nonetheless, we argue that improving validity is especially important for user-facing applications. Users of language-to-code systems might need to rephrase their request or to edit the system’s output. But outputs that fail to even execute undermine user experience: fixing an automatically generated program can be more cumbersome than writing it in the first place. In LLM-driven systems like Github Copilot, implementation errors can remain unnoticed and introduce bugs or vulnerabilities.
|
| 133 |
+
|
| 134 |
+
# 5 RELATED WORK
|
| 135 |
+
|
| 136 |
+
Program synthesis is a long-standing AI challenge with the goal of generating computer programs from higher-level specification (Gulwani et al., 2017). In particular, synthesis from natural language descriptions has gained recent attention (Liu et al., 2016; Yaghmazadeh et al., 2017), thanks to advances in natural language processing models such as Transformers (Vaswani et al., 2017). Typically, LLMs such as GPT-3 (Brown et al., 2020) and Codex (Chen et al., 2021) output an unconstrained sequence of tokens, and still often make conceptual or implementation errors in generated programs (Austin et al., 2021). Specialized training, e.g. to output an AST (Wang et al., 2020; Yin & Neubig, 2017), can mitigate syntactic errors, but still does not guarantee accuracy or conformance to domain-specific semantic constraints. Moreover, it requires a specialized architecture and a decoding procedure for each target language. Instead, SYNCHROMESH applies such constraints at inference, neither using specialized architectures nor fine-tuning the LLM.
|
| 137 |
+
|
| 138 |
+
The general idea of constraining LLMs when generating programs has been explored in recent work. Shin et al. (2021) applied syntactic constraints for semantic parsing. However, their method requires enumerating all valid programs for determining valid next tokens for the LLM, and does not enforce semantic constraints. In concurrent work, Scholak et al. (2021) applied similar semantic constraints to synthesizing SQL queries. The authors substantially improve the performance of an already finetuned model by leveraging an incremental parser. We see CSD as a generalization of these efforts, as our completion engines can apply context-sensitive constraints by dynamically constructing regular expressions. Aligning these constraints with the underlying model vocabulary does not require finetuning: SYNCHROMESH only trains the much smaller target similarity model (Section 2).
|
| 139 |
+
|
| 140 |
+
Since the emergence of LLMs, researchers have developed numerous techniques to adapt them to new domains (Liu et al., 2021b). Many focus on prompting, i.e. generating a domain- and instancespecific input to an LLM to increase the likelihood of correctness. In few-shot prompt augmentation, Gao et al. (2020) use pre-trained sentence embeddings to select the closest prompt examples to the given input instance. Liu et al. (2021a) further fine-tune sentence embeddings on the available training set of input utterances. TST in SYNCHROMESH takes this approach a step further, and finetunes the embedding models based on output similarity. It optimizes the amount of relevant output bits in the prompt, thereby reinforcing the necessary hints for the LLM.
|
| 141 |
+
|
| 142 |
+
# 6 CONCLUSION
|
| 143 |
+
|
| 144 |
+
SYNCHROMESH augments program synthesis with pre-trained LLMs to prevent conceptual and implementation errors during generation. We designed SYNCHROMESH to be easily usable with minimal NLP or LLM knowledge expected from a domain expert. As such, it (a) automatically generates the completion engine API from the language grammar, (b) does not require fine-tuning the LLM, drastically reducing the data/compute budget, and (c) integrates into the decoding loop or inference API with minimal overhead. Our method significantly improves performance of both GPT-3 and Codex in three languages, both by boosting accuracy and consistently improving output validity.
|
| 145 |
+
|
| 146 |
+
While real-world and well-established, the domains we study are still not Turing-complete. We envision extending SYNCHROMESH to a Turing-complete language like Python can vastly increase reliability of LLM-based systems like Github Copilot. This requires further extension of CSD to integrate with the parser/interpreter of the target language, and to study applicable classes of constraints. The TST technique, however, can be used in any LLM-based language-to-code system.
|
| 147 |
+
|
| 148 |
+
# REFERENCES
|
| 149 |
+
|
| 150 |
+
Jacob Andreas, John Bufe, David Burkett, Charles Chen, Josh Clausman, Jean Crawford, Kate Crim, Jordan DeLoach, Leah Dorner, Jason Eisner, et al. Task-oriented dialogue as dataflow synthesis. Transactions of the Association for Computational Linguistics, 8:556–571, 2020.
|
| 151 |
+
|
| 152 |
+
Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, and Charles Sutton. Program synthesis with large language models, 2021.
|
| 153 |
+
|
| 154 |
+
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.
|
| 155 |
+
|
| 156 |
+
Janusz A Brzozowski. Derivatives of regular expressions. Journal of the ACM (JACM), 11(4): 481–494, 1964.
|
| 157 |
+
|
| 158 |
+
Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harri Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
|
| 159 |
+
|
| 160 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, 2019.
|
| 161 |
+
|
| 162 |
+
Tianyu Gao, Adam Fisch, and Danqi Chen. Making pre-trained language models better few-shot learners. arXiv preprint arXiv:2012.15723, 2020.
|
| 163 |
+
|
| 164 |
+
Sumit Gulwani, Oleksandr Polozov, Rishabh Singh, et al. Program synthesis. Foundations and Trends® in Programming Languages, 4(1-2):1–119, 2017.
|
| 165 |
+
|
| 166 |
+
John Jewkes, David Sawers, and Richard Stillerman. Automatic Transmissions, pp. 231– 233. Palgrave Macmillan UK, London, 1969. ISBN 978-1-349-00015-9. doi: 10.1007/ 978-1-349-00015-9 11.
|
| 167 |
+
|
| 168 |
+
Chang Liu, Xinyun Chen, Eui Chul Shin, Mingcheng Chen, and Dawn Song. Latent attention for if-then program synthesis. Advances in Neural Information Processing Systems, 29:4574–4582, 2016.
|
| 169 |
+
|
| 170 |
+
Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. What makes good in-context examples for gpt-3? arXiv preprint arXiv:2101.06804, 2021a.
|
| 171 |
+
|
| 172 |
+
Pengfei Liu, Weizhe Yuan, Jinlan Fu, Zhengbao Jiang, Hiroaki Hayashi, and Graham Neubig. Pretrain, prompt, and predict: A systematic survey of prompting methods in natural language processing, 2021b.
|
| 173 |
+
|
| 174 |
+
William Merrill, Yoav Goldberg, Roy Schwartz, and Noah A. Smith. Provable limitations of acquiring meaning from ungrounded form: What will future language models understand?, 2021.
|
| 175 |
+
|
| 176 |
+
Terence Parr and Kathleen Fisher. Ll (\*) the foundation of the antlr parser generator. ACM Sigplan Notices, 46(6):425–436, 2011.
|
| 177 |
+
|
| 178 |
+
Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21:1–67, 2020.
|
| 179 |
+
|
| 180 |
+
Nils Reimers and Iryna Gurevych. Sentence-bert: Sentence embeddings using siamese bertnetworks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing. Association for Computational Linguistics, 11 2019. URL https://arxiv. org/abs/1908.10084.
|
| 181 |
+
|
| 182 |
+
Ohad Rubin and Jonathan Berant. Smbop: Semi-autoregressive bottom-up semantic parsing. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 311–324, 2021.
|
| 183 |
+
|
| 184 |
+
Torsten Scholak, Nathan Schucher, and Dzmitry Bahdanau. Picard: Parsing incrementally for constrained auto-regressive decoding from language models. arXiv preprint arXiv:2109.05093, 2021.
|
| 185 |
+
|
| 186 |
+
Richard Shin, Christopher H Lin, Sam Thomson, Charles Chen, Subhro Roy, Emmanouil Antonios Platanios, Adam Pauls, Dan Klein, Jason Eisner, and Benjamin Van Durme. Constrained language models yield few-shot semantic parsers. arXiv preprint arXiv:2104.08768, 2021.
|
| 187 |
+
|
| 188 |
+
Arjun Srinivasan, Nikhila Nyapathy, Bongshin Lee, Steven M Drucker, and John Stasko. Collecting and characterizing natural language utterances for specifying data visualizations. In Proceedings of the 2021 CHI Conference on Human Factors in Computing Systems, pp. 1–10, 2021.
|
| 189 |
+
|
| 190 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998–6008, 2017.
|
| 191 |
+
|
| 192 |
+
Bailin Wang, Richard Shin, Xiaodong Liu, Oleksandr Polozov, and Matthew Richardson. RATSQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parsers. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 7567–7578, 2020.
|
| 193 |
+
|
| 194 |
+
Frank F Xu, Bogdan Vasilescu, and Graham Neubig. In-ide code generation from natural language: Promise and challenges. arXiv preprint arXiv:2101.11149, 2021.
|
| 195 |
+
|
| 196 |
+
Navid Yaghmazadeh, Yuepeng Wang, Isil Dillig, and Thomas Dillig. Sqlizer: query synthesis from natural language. Proceedings of the ACM on Programming Languages, 1(OOPSLA):1–26, 2017.
|
| 197 |
+
|
| 198 |
+
Pengcheng Yin and Graham Neubig. A syntactic neural model for general-purpose code generation. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 440–450, 2017.
|
| 199 |
+
|
| 200 |
+
Tao Yu, Rui Zhang, Kai Yang, Michihiro Yasunaga, Dongxu Wang, Zifan Li, James Ma, Irene Li, Qingning Yao, Shanelle Roman, et al. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 3911–3921, 2018.
|
| 201 |
+
|
| 202 |
+
# Algorithm 1: $\mathtt { C S D } ( M , \Sigma _ { M } )$
|
| 203 |
+
|
| 204 |
+
Input : A LLM-based token generator, $M$
|
| 205 |
+
Input : Its token set $\Sigma _ { M }$
|
| 206 |
+
Output: String generated by $M$ , constrained by $C _ { L }$
|
| 207 |
+
s ← next token ← ””;
|
| 208 |
+
while next token $\neq " \mathbb { S } "$ do valid tokens $\textstyle \overleftarrow \} \left\{ t \in \Sigma _ { M } \right.$ | ValidPrefix $( s t ) \}$ ; next token Sample( $M ( s )$ , valid tokens); $s \gets s \cdot n$ ext token;
|
| 209 |
+
end
|
| 210 |
+
return $s$ ;
|
| 211 |
+
|
| 212 |
+
# Algorithm 2: ValidPrefix(s)
|
| 213 |
+
|
| 214 |
+
Input : A string s
|
| 215 |
+
Output: True iff $s \in L ^ { c }$
|
| 216 |
+
p ← next prefix ← ””;
|
| 217 |
+
while next prefix $\neq \bot$ do p ← p · next prefix ; s ← next prefix −1 · s; regex ← CL(p); next prefix startswith(s, regex );
|
| 218 |
+
end
|
| 219 |
+
return (s−1 · regex 6= {});
|
| 220 |
+
|
| 221 |
+
# A CONSTRAINED SEMANTIC DECODING ALGORITHM
|
| 222 |
+
|
| 223 |
+
In Section 3.3, we described the Constrained Semantic Decoding algorithm in the text. We provide the same algorithm in pseudo-code in Algorithms 1 and 2 in Figure 6 below. ValidPrefix is our decision procedure for $L ^ { c }$ , while CSD samples a complete program from the model $M$ by making calls to ValidPrefix. We use $s \cdot t$ to denote concatenation of $s$ and $t$ , and $s ^ { - 1 } \cdot t$ to denote the string obtained by removing the prefix $s$ from $t$ . The utility function startswith $( s , r )$ returns the maximal prefix of $s$ that matches the regular expression $r$ , and returns $\perp$ if there is no such match. The function $\mathtt { S a m p l e } ( D i s t , S )$ returns a token from the set $S$ of tokens sampled from the distribution Dist restricted to $S$ . The CSD procedure uses the model $M$ on the partial program to generate a distribution on the next token, but constrains it to belong to the set of valid tokens determined by the completion engine $C _ { L }$ .
|
| 224 |
+
|
| 225 |
+
# B COMPUTING BRZOZOWSKI DERIVATIVES
|
| 226 |
+
|
| 227 |
+
Regular expression derivatives can be expensive to compute in general. The main challenge is that Klenee stars fork the decision procedure: the algorithm must decide to repeat or skip the pattern inside a star. However, in this work, all our regular expressions come from grammars of programming languages. These languages have one important feature in common: tokens are defined by greedy matching rules. This means that Klenee stars consume as many characters as possible, and do not backtrack if a tokenization error occurs (the error simply propagates). Under the assumption that Klenee stars have greedy semantics, derivatives can be computed in linear time. The algorithm for computing derivatives of a regular expression can be worked out by looking at all constructors of regular expressions. Table 3 details this computation for regular expressions of a base alphabet $\Sigma$ .
|
| 228 |
+
|
| 229 |
+
# C COMPLETION ENGINES
|
| 230 |
+
|
| 231 |
+
Here, we describe our completion engines for SQL, Vega-Lite and SMCalFlow in more detail.
|
| 232 |
+
|
| 233 |
+
# C.1 SQL
|
| 234 |
+
|
| 235 |
+
SQL database queries are executed in the context of a particular database containing a set of tables. Each table has a schema, which specifies named columns, their data types and constraints such as foreign keys. We refer to Yu et al. (2018) for a more detailed description of the SQL language.
|
| 236 |
+
|
| 237 |
+
Our CE for SQL enforces that only columns that exist in the tables in the database are used. The main challenge is that queries often specify aliases. Thus, during parsing, we construct a symbol table mapping aliases to the tables they refer to. We enforce that tables that already have an alias should only be referred to by their alias, not in their unqualified form. Since aliases can be referred to in the SELECT clause before being defined in the FROM clause, we also keep track of undefined aliases to enforce that they will be assigned a table later. Moreover, a condition in the WHERE clause might involve a nested query, which in its turn might redefine or create new aliases. As a result, our symbol table keeps a stack of scopes to properly resolve aliases in nested contexts.
|
| 238 |
+
|
| 239 |
+
Table 3: Computing Brzozowski derivatives for each constructor of regular expressions under the assumption that Klenee stars are greedy. The resulting algorithm runs in linear-time on the size of the regular expression.
|
| 240 |
+
|
| 241 |
+
<table><tr><td>Constructor</td><td>Description</td><td>Derivative w.r.t c' ∈∑</td></tr><tr><td>Q</td><td>Empty regular expression (matches no string).</td><td>Q</td></tr><tr><td>E</td><td>Matches only the empty string.</td><td>Q</td></tr><tr><td>C</td><td>Matches a single character c</td><td>∈ if c= c',or & otherwise. If the derivative of R1 w.r.t. c' is not ,</td></tr><tr><td>R1R2</td><td>Concatenation of two regular ex- pressions R1 and R2</td><td>then it's the concatenation of that with R2. Otherwise,if Rl matches ∈, then it is sim- ply the derivative of R2 w.r.t. c'. If not,</td></tr><tr><td>R1R2</td><td>Union of two regular expressions R1 and R2</td><td>then the result is &. Union of the derivatives of R1 and R2 W.r.t. c'(if one becomes &,simply return the other).</td></tr><tr><td>R*</td><td>Klenee star - any number of repeti- tions of R</td><td>If the derivative of R w.r.t. c is not Q, then return the concatenation of that derivative with R*. Otherwise,return @.</td></tr></table>
|
| 242 |
+
|
| 243 |
+
We constrain numeric literals to either come from a set of common numbers (including 0 and 1) or from the user’s natural language question. This prevents the model from copying arbitrary numbers from the few-shot examples in the prompt. Finally, since SQL is case-insensitive, our CE returns case-insensitive regular expressions for keywords, table and column names.
|
| 244 |
+
|
| 245 |
+
# C.2 VEGA-LITE
|
| 246 |
+
|
| 247 |
+
Vega-Lite is a declarative language for specifying data visualizations given a data frame – a table where rows represent data points and columns represent attributes of various data types. Its syntax is a subset of JSON. Therefore, our Vega-Lite grammar accepts JSON objects that follow a subset of the Vega-Lite schema.
|
| 248 |
+
|
| 249 |
+
As in SQL, we use the user’s data frame to constrain valid field names. Additionally, in Vega-Lite, one must also specify a Vega-Lite type that is used to interpret the field values. We inspect the runtime values in the data frame to determine compatible Vega-Lite types. For example, a string column is typically used as a categorical value (nominal, in Vega-Lite). However, if its entries have ISOformatted timestamps, it can be used as temporal, or quantitative if its values can be parsed as numbers. Since JSON objects are unordered, it must handle two valid output orders: the model might output the field name first (we thus later constrain the type) or the data type first (we then constrain the field name to compatible columns). Because Vega-Lite’s behavior is to silently ignore invalid data points, associating a column with an incompatible type simply produces an empty chart. Our constraint completely prevents this class of errors.
|
| 250 |
+
|
| 251 |
+
We forbid repeated fields and limit the length of free-form string literals to 30 characters, which prevents the common failure mode of language models to enter repetition loops. Similarly, we only allow an aggregation in one of the X-Y axes, but not both, since that collapses the chart to a single data point and is another common failure case. Finally, we prevent the model from faceting (i.e., splitting into multiple charts) based on a column with too many $( > 5 0 )$ ) distinct values: that typically crashes the Vega-Lite rendering engine since it allocates an overly large output image. In summary, our constraints guarantee conformance to the Vega-Lite specification and additionally avoid common mistakes that cause crashes or degenerate outputs.
|
| 252 |
+
|
| 253 |
+

|
| 254 |
+
Figure 7: Illustration of the token misalignment problem in Vega-Lite. Colors denote Vega-Lite tokens, which match how the completion engine works (and what are its completion points). Vertical lines denote how GPT-3 tokenizes this program.
|
| 255 |
+
|
| 256 |
+
# C.3 SMCALFLOW
|
| 257 |
+
|
| 258 |
+
SMCalFlow programs express responses to user queries about calendar events, weather, places, and people (Andreas et al., 2020). It is a rich language with scoped variable declarations, generic types, polymorphic operators and a large API of over 400 functions, which can be composed to express complex actions like “cancel any meetings on the same day of my next doctor’s appointment”, or answer queries such as ”will it be raining during my next walking meeting with Frank?”
|
| 259 |
+
|
| 260 |
+
Our CE enforces that programs type-check2 by construction. An example3 is given in Figure 1. At the current point in inference, the model is producing an argument to size. Since this function takes a list, its argument must be the return value of a function with return type List $< \mathrm { T } >$ . Among all functions and methods in the SMCalFlow API, only 14 return lists, which severely limits the valid options for the callee. Similarly, we keep track of declared variables inside let expressions, together with their types (inferred from their initialization expression), and use that data structure to limit options whenever a token of type identifier is syntactically allowed to follow.
|
| 261 |
+
|
| 262 |
+
Finally, we implemented heuristics based on user utterance patterns that avoid common failure cases we observed in GPT-3. These tend to happen when the model blindly copies portions of the examples in the prompt without adaptation. For instance, whenever the utterance contains exactly one of “a.m.” or “p.m”, this is usually represented in SMCalFlow by a call to a corresponding SMCalFlow function that constructs a Time object (e.g., NumberAM(5)). However, if the examples retrieved for the prompt tend to only have times in the opposite half of the day, GPT-3 might call the wrong function, and translate the time sub-expression in “Schedule it for $5 \mathrm { p m } ^ { \mathrm { , , } \mathrm { , } }$ into NumberAM(5). To avoid this, if we detect exactly one of “a.m.” or “p.m.” in the utterance, we remove the time construction functions associated with the opposite pattern from the candidates. We do the same filtering with days of the week and months, which are also constructed by specific functions.
|
| 263 |
+
|
| 264 |
+
In all domains, the CE abstraction allows us to easily encode domain knowledge in a modular fashion. Besides constraints coming from the language’s semantics, it further allows domain experts to analyze failure modes of the language model and to implement fixes them in a modular and predictable manner.
|
| 265 |
+
|
| 266 |
+
# D THE TOKEN MISALIGNMENT CHALLENGE
|
| 267 |
+
|
| 268 |
+
The main challenge of CSD is in aligning constraints expressed in terms of programming language tokens with the model’s output, which happens in another token vocabulary (typically constructed with Byte-Pair Encoding). Figure 7 shows an illustration of this challenge in Vega-Lite. Arbitrary mismatches can occur: the first BPE token includes the first Vega-Lite token and the first character of the second. In the middle of the example, the "encoding" token in Vega-Lite spans 4 BPE tokens, with misaligned boundaries at the beginning and end. Nonetheless, this issue is seamlessly handled by the CSD algorithm.
|
| 269 |
+
|
| 270 |
+

|
| 271 |
+
Figure 8: (a) Accuracy and (b) validity of Codex predictions with and without SYNCHROMESH on SQL as a function of the ground-truth program length. We map program lengths to percentiles, and round to the closest multiple of $10 \%$ . Error bands correspond to standard error.
|
| 272 |
+
|
| 273 |
+
# E OPTIMIZATIONS TO CSD
|
| 274 |
+
|
| 275 |
+
The algorithm described in Section 3.3 tests each token from the language model’s vocabulary individually. However, many BPE tokens are prefixes of oen another, which lets us apply a significant optimization. If $t _ { 1 }$ is a prefix of $t _ { 2 }$ and $t _ { 1 }$ is inadmissible after a partial program $p$ , then $t _ { 2 }$ is also inadmissible. Thus, we test tokens by order of length, and keep rejected tokens in a Trie structure. Before we test a token against the completion engine, we check whether one of its prefixes was already rejected. If so, we can safely skip that token.
|
| 276 |
+
|
| 277 |
+
Another optimization consists in memoizing the enumerated completion points. When testing a new partial program $p$ , instead of starting from the empty string, we can start from the longest known completion point that is a prefix of $p$ . This, again, can be efficiently done by keeping completion points in a Trie.
|
| 278 |
+
|
| 279 |
+
# F CSD WITHOUT DIRECT ACCESS TO THE LANGUAGE MODEL
|
| 280 |
+
|
| 281 |
+
We used the public OpenAI API to access GPT-3 and Codex. Therefore, we did not have direct access to the underlying language models. Even so, CSD can still be applied provided we can pass a bias to be added to the logits, which is available in the OpenAI API.
|
| 282 |
+
|
| 283 |
+
However, making one request at each token is too slow. Instead, we apply a “rejection”-based sampling, as follows. First, we request a complete program from the model. Then, we iterate tokenby-token, validating it with the CSD algorithm against the completion engine. If we find a violation, we (a) use CSD to determine all valid next tokens, (b) make a request asking from just a single token, applying a logit bias to constrain it to the valid tokens, and then (c) continue generation after appending the new token. Most $( 9 0 \% + )$ trajectories end after at most 3 corrections to the model. In degenerate cases, we might need to correct the model after almost every token. In our experiments, we capped CSD to apply at most 15 corrections, to control the time a request with CSD takes. This only happened in less than . $5 \%$ of the cases, and could be completely avoided if we had direct access to the model (in which case CSD is efficient enough to be applied at every token).
|
| 284 |
+
|
| 285 |
+
# G ANALYSIS OF ACCURACY AND VALIDITY BY LENGTH IN SQL
|
| 286 |
+
|
| 287 |
+
Figure 8 shows the equivalent of Figure 4 for the SQL domain. We notice that the largest gaps in validity happen for the longest queries, and the benefits in accuracy are highest for queries around the $60 \%$ length percentile.
|
| 288 |
+
|
| 289 |
+
# H TST FINE-TUNING DETAILS
|
| 290 |
+
|
| 291 |
+
In Section 2, we described TST, which fine-tunes a sentence embedding model to attempt to capture program similarity. Here, we give more details on our training procedure.
|
| 292 |
+
|
| 293 |
+
First, for both SQL and SMCalFlow, we selected a random set of 2000 examples, and computed the normalized tree edit distance between all pairs of examples. We then fine-tuned S-BERT for one epoch using the cosine similarity loss. We used the AdamW optimizer with a learning rate of $2 \times 1 \mathrm { { 0 } ^ { - } 5 }$ – the default parameters in the S-BERT library4. We did not perform any hyperparameter tuning. Training took around 3 hours on a single GPU.
|
| 294 |
+
|
| 295 |
+
# I COMMENTED EXAMPLES OF TST AND CSD
|
| 296 |
+
|
| 297 |
+
Here, we provide three more detailed examples. The first examples shows the benefit of using TST on top of Codex. The remaining two show value of CSD on top of Codex. Since the examples in Sections 2 and 3 used SQL, we now give examples in SMCalFlow and Vega-Lite for diversity.
|
| 298 |
+
|
| 299 |
+
# I.1 TST EXAMPLE IN SMCALFLOW
|
| 300 |
+
|
| 301 |
+
Query: “Hi, I need to meet with Alex on this Sunday at 6pm at the CVS shopping center for an hour.” This query asks the system to create an event. Without TST, the top example (similar to the query) returned by vanilla S-BERT from the training set is:
|
| 302 |
+
|
| 303 |
+
User utterance: Hi, I need to meet with Alex tomorrow afternoon for an hour.
|
| 304 |
+
SMCalFlow: (Yield (CreateCommitEventWrapper (CreatePreflightEventWrapper (& (& (Event.start_? (DateTimeConstraint (Afternoon) (Tomorrow))) (Event.duration_? ( $? =$ (toHours 1)))) (Event.attendees_? (AttendeeListHasRecipient (Execute (refer (extensionConstraint (RecipientWithNameLike (EmptyStructConstraint) (PersonName.apply "Alex")))))))))))
|
| 305 |
+
|
| 306 |
+
This example also involves creating an event, and also with a person named “Alex”. However, the time structure of this example, “Tomorrow afternoon”, is not trivial to translate to “this Sunday at 6pm”, because these two specifications require different APIs from SMCalFlow. Given this and 4 more examples, Codex generates:
|
| 307 |
+
|
| 308 |
+
(Yield (CreateCommitEventWrapper (CreatePreflightEventWrapper (& (& (Event.start_? (DateTimeConstraint (Afternoon) (ThisSunday))) (Event.duration_? ( $? =$ (toHours 1)))) (Event.location_? ( $? =$ (LocationWithNameLike (EmptyStructConstraint) (LocationName.apply "CVS shopping center")))) (Event.attendees_? (AttendeeListHasRecipient (Execute (refer (extensionConstraint (RecipientWithNameLike (EmptyStructConstraint) (PersonName.apply "Alex")))))))))))
|
| 309 |
+
|
| 310 |
+
This prediction, while seeming reasonable at a surface level, violates the SMCalFlow APIs in multiple places. First, the function “ThisSunday” does not exist. The parameter 6pm was lost in this prediction, since the examples had no explicit time in it and Codex could not identify where to put it. Besides that, the model is trying to specify four attributes of the created event: start time, duration, location and attendees, but it would need one more conjunction (call to “&”) to do so. This error likely came from the fact that the top example only specified three attributes. The calls to the location APIs are also incorrect – “LocationWithNameLike” exists (and is present in other examples in the prompt), but is not really needed or appropriate in this context.
|
| 311 |
+
|
| 312 |
+
However, if we use TST to pick the examples for the prompt, Codex is able to solve the problem. With TST, the top retrieved example is:
|
| 313 |
+
|
| 314 |
+
User utterance: Schedule 2 hours on Friday at 7:00 am for a Meeting with Kayla at the Sear’s Tower.
|
| 315 |
+
SMCalFlow: (Yield (CreateCommitEventWrapper (CreatePreflightEventWrapper (& (& (& (Event.start_? ( $? =$ (DateAtTimeWithDefaults (NextDOW (Friday)) (NumberAM 7L)))) (Event.duration_? ( $? =$ (toHours 2)))) (Event.location_? ( $? =$ (LocationKeyphrase.apply "Sear\’s Tower")))) (Event.attendees_? (AttendeeListHasRecipient (Execute (refer (extensionConstraint (RecipientWithNameLike (EmptyStructConstraint) (PersonName.apply "Kayla")))))))))))
|
| 316 |
+
|
| 317 |
+
Note that the utterance, from the perspective of its natural language structure, is less similar to the user’s request than the previous example. However, it describes a query with the exact necessary structure: it schedules something for the next Friday (trivial to modify to Sunday) at a certain time of the day (“NumberAM” can be simply rewritten to “NumberPM”, which Codex does correctly). The location attribute, which Codex had previously tried to adapt from a less related example, is now also specified here. With this example, Codex is able to make a correct adaptation. It predicts:
|
| 318 |
+
|
| 319 |
+
(Yield (CreateCommitEventWrapper (CreatePreflightEventWrapper (& (& (& (Event.start_? ( $? =$ (DateAtTimeWithDefaults (NextDOW (Sunday)) (NumberPM 6L)))) (Event.duration_? ( $? =$ (toHours 1)))) (Event.location_? ( $? =$ (LocationKeyphrase.apply "CVS shopping center")))) (Event.attendees_? (AttendeeListHasRecipient (Execute (refer (extensionConstraint (RecipientWithNameLike (EmptyStructConstraint) (PersonName.apply "Alex")))))))))))
|
| 320 |
+
|
| 321 |
+
This matches the reference program from the dataset.
|
| 322 |
+
|
| 323 |
+
# I.2 CSD EXAMPLES IN VEGA-LITE
|
| 324 |
+
|
| 325 |
+
Query: “average horsepower over years, colored by origin” This query does not specify a chart type, but one could infer that a line chart is likely more appropriate since it is showing a quantity over time. The dataset under consideration contains car models with their year of manufacture, horsepower, number of cylinders and many other attribute. Thus, to obtain the “average horsepower” in a given year, we need an aggregation in Vega-Lite. Codex alone predicts:
|
| 326 |
+
|
| 327 |
+
{"mark": {"type": "line" },
|
| 328 |
+
"encoding": {"x": {"field": "Year", "type": "temporal", "timeUnit": "yearmonth" }, "y": {"field": "Horsepower", "type": "quantitative", "aggregate": "average" }, "color": {"field": "Origin", "type": "nominal" } } }
|
| 329 |
+
|
| 330 |
+
All the right components of the query are there. However, even though the query asks for the “average horsepower”, the aggregation function in Vega-Lite is called “mean”. Specifying an invalid aggregation function makes Vega-Lite raise an exception. Thus, an actual user wouldn’t see any plot from this response.
|
| 331 |
+
|
| 332 |
+
CSD prevents Codex from generating “average” after it outputs the field name “aggregate”, forcing it to choose one of the existing aggregation functions (max, min, mean, etc). Constrained by CSD, Codex generates:
|
| 333 |
+
|
| 334 |
+
{"mark": {"type": "line" },
|
| 335 |
+
"encoding": {"x": {"field": "Year", "type": "temporal", "timeUnit": "yearmonth" }, "y": {"field": "Horsepower", "type": "quantitative", "aggregate": "mean" }, "color": {"field": "Origin", "type": "nominal" } } }
|
| 336 |
+
|
| 337 |
+
This is not only valid but also matches the ground-truth from the dataset.
|
| 338 |
+
|
| 339 |
+
“Create a scatterplot of acceleration vs horsepower by model” This utterance asks for a chart that relates each car’s acceleration and horsepower. Codex generates:
|
| 340 |
+
|
| 341 |
+
{"mark": {"type": "point" },
|
| 342 |
+
"encoding": {"x": {"field": "Horsepower", "type": "quantitative" }, "y": {"field": "Acceleration", "type": "quantitative" }, "color": {"field": "Model", "type": "nominal" } } }
|
| 343 |
+
|
| 344 |
+
The produced plot, shown in Figure 9 (left) is in principle correct, and answers the user’s question. The “by model” in the query might sound as if the user wants specialized plots by model. Codex realizes this interpretation by coloring each point differently by the car’s model. But in this dataset, each row represents a different car with a distinct model. Thus, there are 303 unique values of the “Model” column, and Vega-Lite raises a run-time warning saying that the legend has overflowed for having too many values, so some values (the majority, in this case) were omitted. When the model decides to facet on a column with too many values, the Vega-Lite run-time often runs out of memory for allocating an overly large image.
|
| 345 |
+
|
| 346 |
+
CSD avoids these errors by looking at the user’s dataset and determining which columns can be used for coloring or faceting, based on how many distinct values they have. If none are available, then CSD doesn’t let the model use these features. In this example, CSD forces Codex to choose one of the columns with less than 30 distinct values. Between those, Codex generates “Year”. The resulting plot is shown in Figure 9 (right). While in this example the “Year” column was not mentioned in the user’s request, the application of this constraint here steers Codex to avoid a run-time warning or error. The ground-truth visualization for this description does not have any color specification, so neither prediction counts as an exact match. Nevertheless, from the point of view of the user’s experience, CSD can be helpful even when it cannot completely fix the prediction.
|
| 347 |
+
|
| 348 |
+

|
| 349 |
+
Figure 9: Benefit of CSD: The left plot is generated by Codex without CSD, but it has an overflowing legend and it also raises a warning about missing values. Using CSD, we generate the plot on right that generates no runtime warning or error.
|
md/dev/LPB2BFZvncQ/LPB2BFZvncQ.md
ADDED
|
@@ -0,0 +1,827 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# An Information-theoretic Perspective of Hierarchical Clustering
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 A combinatorial cost function for hierarchical clustering was introduced by Das
|
| 11 |
+
2 gupta [10]. It has received great attention and several new cost functions from sim
|
| 12 |
+
3 ilar combinatorial perspective have been proposed. In this paper, we investigate
|
| 13 |
+
4 hierarchical clustering from the information-theoretic perspective and formulate
|
| 14 |
+
5 a new objective function. We also establish the relationship between these two
|
| 15 |
+
6 perspectives. In algorithmic aspect, we present two algorithms for expander-like
|
| 16 |
+
7 and well-clustered cardinality weighted graphs, respectively, and show that both
|
| 17 |
+
8 of them achieve $O ( 1 )$ -approximation for our new objective function. For practi
|
| 18 |
+
9 cal use, we consider non-binary hierarchical clustering problem. We get rid of
|
| 19 |
+
10 the traditional top-down and bottom-up frameworks, and present a new one. Our
|
| 20 |
+
11 new framework stratifies the sparsest level of a cluster tree recursively in guide
|
| 21 |
+
12 with our objective function. Our algorithm called HCSE outputs a $k$ -level cluster
|
| 22 |
+
13 tree by an interpretable mechanism to choose $k$ automatically without any hyper
|
| 23 |
+
14 parameter. Our experimental results on synthetic datasets show that HCSE has
|
| 24 |
+
15 its own superiority in finding the intrinsic number of hierarchies, and the results
|
| 25 |
+
16 on real datasets show that HCSE also achieves competitive costs over the popular
|
| 26 |
+
17 non-binary hierarchical clustering algorithms LOUVAIN and HLP.
|
| 27 |
+
|
| 28 |
+
# 18 1 Introduction
|
| 29 |
+
|
| 30 |
+
19 Hierarchical clustering for graphs plays an important role in the structural analysis of a given data
|
| 31 |
+
20 set. Understanding hierarchical structures on the levels of multiple granularities is fundamental in
|
| 32 |
+
21 various disciplines including artificial intelligence, physics, biology, sociology, etc [4, 11, 13, 9].
|
| 33 |
+
22 Hierarchical clustering requires a cluster tree that represents a recursive partitioning of a graph into
|
| 34 |
+
23 smaller clusters as the tree nodes get deeper. A leaf represents a graph node while a non-leaf node
|
| 35 |
+
24 represents a cluster containing its descendant leaves. The root is the largest one containing all leaves.
|
| 36 |
+
25 Clustering is usually formulated as an optimization problem with some objective function. For hier
|
| 37 |
+
26 archical clustering, no cost function with a clear and reasonable combinatorial explanation was de
|
| 38 |
+
27 veloped until Dasgupta [10] introduced a cost function for cluster trees. In this definition, similarity
|
| 39 |
+
28 or dissimilarity between data points is represented by weighted edges. Taking the similarity-based
|
| 40 |
+
29 metrics as an example, a cluster is a set of nodes with relatively denser intra-links compared with its
|
| 41 |
+
30 inter-links, and in a good cluster tree, heavier edges tend to connect leaves whose lowest common
|
| 42 |
+
31 ancestor (LCA) is as deep as possible. This intuition leads to Dasgupta’s cost function that is a
|
| 43 |
+
32 bilinear combination of edge weights and the sizes of corresponding LCAs.
|
| 44 |
+
33 Motivated by Dasgupta’s cost function, Cohen-Addad et al. [8] proposed admissible cost functions.
|
| 45 |
+
34 In their definition, the size of each LCA in Dasgupta’s objective is generalized to be a function of
|
| 46 |
+
35 the sizes of its left and right children. For all similarity-based graphs generated from a minimal
|
| 47 |
+
36 ultrametric, a cluster tree achieves the minimum cost if and only if it is a generating tree that is a
|
| 48 |
+
37 “natural” ground truth tree in an axiomatic sense therein. A necessary condition of admissibility of
|
| 49 |
+
38 an objective function is that it achieves the same value for every cluster tree for a uniformly weighted
|
| 50 |
+
39 clique that has no structure in common sense. However, any slight deviation of edge weights would
|
| 51 |
+
40 generally separate the two end-points of a light edge on a high level of its optimal (similarity-based)
|
| 52 |
+
41 cluster tree. Thus, it seems that admissible objective functions, which take Dasgupta’s cost function
|
| 53 |
+
42 as a specific form, ought to be an unchallenged criterion in evaluating cluster trees since they are
|
| 54 |
+
43 formulated by an axiomatic approach.
|
| 55 |
+
44 However, an admissible cost function seems imperfect in practice. The arbitrariness of optima of
|
| 56 |
+
45 cluster trees for cliques indicates that the division of each internal node on an optimal cluster tree
|
| 57 |
+
46 totally neglects the balance of its two children. Edge weight is the unique factor that decides the
|
| 58 |
+
47 structure of optimal trees. But a balanced tree is commonly considered as an ideal candidate in
|
| 59 |
+
48 hierarchical clustering compared to an unbalanced one. Even clustering for cliques, a balanced
|
| 60 |
+
49 partition should be preferable for each internal node. At least, an optimal cluster tree whose height
|
| 61 |
+
50 is logarithm of graph size $n$ is intuitively more reasonable than a caterpillar shaped cluster tree
|
| 62 |
+
51 whose height is $n - 1$ . Moreover, a simple proof would imply that the optimal cluster tree for any
|
| 63 |
+
52 connected graphs is binary. This property is not always useful in practice since a real system usually
|
| 64 |
+
53 has its inherent number of hierarchies and a natural partition for each internal cluster. For instance,
|
| 65 |
+
54 the natural levels of administrative division in a country is usually intrinsic, and it is not suitable to
|
| 66 |
+
55 differentiate hierarchies for parallel cities in the same state. This structure cannot be obtained by
|
| 67 |
+
56 simply minimizing admissible cost functions.
|
| 68 |
+
57 In this paper, we investigate the hierarchical clustering from the perspective of information theory.
|
| 69 |
+
58 Our study is based on Li and Pan’s structural information theory [14] whose core concept named
|
| 70 |
+
59 structural entropy measures the complexity of hierarchical networks. We summarize our contribu
|
| 71 |
+
60 tions as follows.
|
| 72 |
+
61 (1) We formulate a new objective function from the information-theoretic perspective, which
|
| 73 |
+
62 builds the bridge for combinatorial and information-theoretic perspectives for hierarchical cluster
|
| 74 |
+
63 ing. For this cost function, the balance of cluster trees will be involved naturally as a factor just
|
| 75 |
+
64 like we design optimal codes, for which the balance of probability over objects is fundamental in
|
| 76 |
+
65 constructing an efficient coding tree. We also define cluster trees with a specific height, which is
|
| 77 |
+
66 coincident with our cognition of natural clustering.
|
| 78 |
+
67 (2) For our new objective function, we present two polynomial-time approximation algorithms
|
| 79 |
+
68 respectively for two cases of the conductance $\Phi ( G )$ of a cardinality weighted graph $G$ . Our first
|
| 80 |
+
69 result shows that any cluster tree of $G$ has a approximation factor $\bar { O } ( \Phi ( \bar { G } ) ^ { - 1 } )$ (Theorem 3.1). So
|
| 81 |
+
70 a "Huffman-merge" heuristic that solely depends on the degrees of vertices achieves this guaran
|
| 82 |
+
71 tee, and it achieves $O ( 1 )$ -approximation when $\Phi ( G )$ is a constant. The second result is a $O ( 1 )$ -
|
| 83 |
+
72 approximation algorithm for $G$ that can be well clustered into a constant number of expanders (The
|
| 84 |
+
73 orem 3.2). The main idea of this algorithm is inspired by very recent Manghiuc and Sun’s work [15],
|
| 85 |
+
74 and our approximation factors for our new objective also match their results in these two cases.
|
| 86 |
+
75 (3) For practical use, we develop a new interpretable framework for natural hierarchical clus
|
| 87 |
+
76 tering that outputs a non-binary cluster tree. The idea of our framework is essentially different from
|
| 88 |
+
77 the traditional recursive division or agglomeration ones. In our framework, the sparsest level of the
|
| 89 |
+
78 cluster tree is stratified recursively. This coincide with the intuition that when we differentiate the
|
| 90 |
+
79 hierarchies of a complex system, the clearest level should be stratified first, rather than in a rigid
|
| 91 |
+
80 divisive or agglomerative fashion. Therefore, this framework has much better interpretability than
|
| 92 |
+
81 the traditional ones.
|
| 93 |
+
82 (4) We develop a new non-binary clustering algorithm (HCSE) under the new clustering frame
|
| 94 |
+
83 work. To find the sparsest level in each iteration, we formulate two basic operations called stretch
|
| 95 |
+
84 and compress, respectively. HCSE terminates when a specific criterion that intuitively coincides
|
| 96 |
+
85 with the natural hierarchies is met, and no hyperparameter is needed. Our extensive experiments on
|
| 97 |
+
86 both synthetic and real datasets demonstrate that HCSE outperforms the present popular heuristic
|
| 98 |
+
87 algorithms LOUVAIN [3] and HLP [19]. These two algorithms proceed simply by recursively in
|
| 99 |
+
88 voking flat clustering algorithms based on modularity and label propagation, respectively, and the
|
| 100 |
+
89 hierarchy number is solely determined by the number of rounds when the algorithm terminates. So
|
| 101 |
+
90 their interpretability is quite poor. Our experimental results on synthetic datasets show that HCSE
|
| 102 |
+
91 has a great advantage in finding the intrinsic number of hierarchies, and the results on real datasets
|
| 103 |
+
92 show that HCSE achieves much better costs than HLP and competitive costs to LOUVAIN.
|
| 104 |
+
93 Related work. The first combinatorial objective function was proposed by Dasgupta [10]. Along
|
| 105 |
+
94 with this line of study, several alternative objectives have been presented. All of them are bilinear
|
| 106 |
+
95 functions of edge weights and some function of the corresponding LCAs. For Dasgupta’s cost func
|
| 107 |
+
96 tion and for the worst case study, Dasgupta showed that a recursively bipartition applying Arora’s
|
| 108 |
+
97 seminal algorithm for sparsest cut problem [2] yields √ $O ( \log ^ { 1 . 5 } n )$ -approximation, and it was im
|
| 109 |
+
98 proved by [20] and [5, 8] to $O ( \log n )$ and $\sqrt { \log n }$ , respectively. It is NP-hard to optimize the cluster
|
| 110 |
+
99 tree [10] and even a $O ( 1 )$ -approximation is impossible under the Small Set Expansion hypothesis
|
| 111 |
+
100 [20, 5]. Beyond the worst case, Cohen-Addad et al. [8] showed that a SVD-based algorithm achieves
|
| 112 |
+
101 a $O ( 1 + o ( 1 ) )$ -approximation for the stochastic block model with high probability. Manghiuc and
|
| 113 |
+
102 Sun [15] presented a $O ( 1 )$ -appromation algorithm for more generalized well-clustered graphs. The
|
| 114 |
+
103 outline of their method is to utilize a flat clustering algorithm [12] to obtain the underlying clusters
|
| 115 |
+
104 first, and then some relatively easy heuristics for clustering in and out of these clusters are enough
|
| 116 |
+
105 for the guarantee. Our proof follows this route also.
|
| 117 |
+
106 For other lines of this study, Moseley and Wang [16] studied the dual of Dasgupta’s cost function
|
| 118 |
+
107 and showed that the average-linkage algorithm achieves a $( 1 / 3 )$ -approximation. This factor has
|
| 119 |
+
108 been improved by a series of works to 0.336 [6], 0.4246 [7] and 0.585 [1], respectively. Cohen
|
| 120 |
+
109 Addad et al. [8] considered maximization of Dasgupta’s cost function for the dissimilarity-based
|
| 121 |
+
110 metrics. They proved that the average-link and random partitioning algorithms achieve a $( 2 / 3 )$ -
|
| 122 |
+
111 approximation, which has been improved to 0.667 [6], 0.716 [18] and 0.74 [17], respectively.
|
| 123 |
+
112 For non-binary cluster tree construction, the most popular algorithm for practical use is LOUVAIN
|
| 124 |
+
113 [3]. More recently, a hierarchical label propagation based algorithm HLP has been presented [19].
|
| 125 |
+
114 Both of these two algorithms construct a non-binary cluster tree with the same framework, that is,
|
| 126 |
+
115 the hierarchies are formed from bottom to top one by one. In each round, they invoke different flat
|
| 127 |
+
116 clustering algorithms, Modularity and Label Propagation, respectively.
|
| 128 |
+
|
| 129 |
+
# 117 2 A cost function from information-theoretic perspective
|
| 130 |
+
|
| 131 |
+
118 In this section, we introduce Li and Pan’s structural information theory [14] and the combinatorial
|
| 132 |
+
119 cost functions of Dasgupta [10] and Cohen-Addad et al. [8]. Then we propose a new cost func
|
| 133 |
+
120 tion that is developed from structural information theory and establish the relationship between the
|
| 134 |
+
121 information-theoretic and combinatorial perspectives.
|
| 135 |
+
122 Notations. Let $G = ( V , E , w )$ be an undirected weighted graph with a set of vertices $V$ , a set of
|
| 136 |
+
123 edges $E$ and a weight function $w : E \to \mathbb { R } ^ { + }$ , where $\bar { \mathbb { R } ^ { + } }$ denotes the set of all positive real numbers.
|
| 137 |
+
124 An unweighted multigraph can be viewed as a cardinality weighted one whose edge weight is the
|
| 138 |
+
125 number of parallel edges. For each vertex $u \in V$ , denote by $\begin{array} { r } { \bar { d _ { u } } = \sum _ { ( u , v ) \in E } w ( u , \bar { v } ) } \end{array}$ the weighted
|
| 139 |
+
126 degree of $u$ . For a subset of vertices $S \subseteq V$ , define the volume of $S$ to be the sum of degrees of
|
| 140 |
+
127 vertices. We denote it by $\begin{array} { r } { \mathrm { v o l } ( S ) = \sum _ { u \in S } d _ { u } } \end{array}$ . We denote by $G [ S ]$ the subgraph induced by $S$ . A
|
| 141 |
+
128 cluster tree $T$ for graph $G$ is a rooted tree with $| V |$ leaves, each of which is labeled by a distinct
|
| 142 |
+
129 vertex $v \in V$ . Each non-leaf node on $T$ is labeled by a subset $S$ of $V$ that consists of all the leaves
|
| 143 |
+
130 treating $S$ as an ancestor. For each node $\alpha$ on $T$ , denote by $\alpha ^ { - }$ the parent of $\alpha$ , and by $| \alpha |$ its size.
|
| 144 |
+
131 For each pair of leaves $u$ and $v$ , denote by $u \vee v$ the LCA of them on $T$ .
|
| 145 |
+
|
| 146 |
+
Structural entropy of graphs. Because of the tense space limit, we just give the definition of the core concept structural entropy in structural information theory. The idea of this definition is briefly introduced in Appendix A. Readers could also refer to [14] for more information on this theory.
|
| 147 |
+
|
| 148 |
+
35 Given a weighted graph $G = ( V , E , w )$ and a cluster tree $T$ for $G$ , the structural entropy of $G$ on $T$
|
| 149 |
+
36 is defined as
|
| 150 |
+
|
| 151 |
+
$$
|
| 152 |
+
{ \mathcal { H } } ^ { T } ( G ) = - \sum _ { \alpha \in T } { \frac { g _ { \alpha } } { \operatorname { v o l } ( V ) } } \log { \frac { \operatorname { v o l } ( \alpha ) } { \operatorname { v o l } ( \alpha ^ { - } ) } } , ^ { 1 }
|
| 153 |
+
$$
|
| 154 |
+
|
| 155 |
+
137 where $\alpha ^ { - }$ denotes the parent of tree node $\alpha$ , and $g _ { \alpha }$ denotes the sum of weights of edges in $G$
|
| 156 |
+
138 with exactly one end-point in the set of vertices corresponding to $\alpha$ . The structural entropy of $G$ is
|
| 157 |
+
139 defined as the minimum one among all cluster trees, denoted by $\begin{array} { r } { \mathcal { H } ( G ) = \operatorname* { m i n } _ { T } \big \{ \mathcal { H } ^ { T } ( G ) \big \} } \end{array}$ .
|
| 158 |
+
140 Combinatorial explanation of structural entropy. The cost function of a cluster tree $T$ for graph
|
| 159 |
+
141 $G = ( V , E )$ introduced by Dasgupta [10] is defined to be $\begin{array} { r } { c ^ { T } ( G ) = \sum _ { ( u , v ) \in E } w ( u , v ) | u \vee v | } \end{array}$ . The
|
| 160 |
+
142 admissible cost function introduced by Cohen-Addad et al. [8] generalizes the term $\vert u \vee v \vert$ in the
|
| 161 |
+
143 definition of $c ^ { T } ( G )$ to be a general function $g ( | L | , | R | )$ , where $L$ and $R$ are the two children of
|
| 162 |
+
144 $u \vee v$ , respectively. Dasgupta defined $g ( x , y ) = x + y$ . For both definitions, the optimal hierarchical
|
| 163 |
+
145 clustering of $G$ is in correspondence with a cluster tree of minimum cost in the combinatorial sense
|
| 164 |
+
146 that heavy edges are cut as far down the tree as possible. The following proposition establishes the
|
| 165 |
+
147 relationship between structural entropy and this kind of combinatorial form of cost functions.
|
| 166 |
+
148 Proposition 2.1. For a weighted graph $G = ( V , E , w )$ , minimizing ${ \mathcal { H } } ^ { T } ( G )$ (over $T$ ) is equivalent
|
| 167 |
+
149 to minimizing the cost function
|
| 168 |
+
|
| 169 |
+
$$
|
| 170 |
+
c o s t ^ { T } ( G ) = \sum _ { ( u , v ) \in E } w ( u , v ) \log { \nu o l ( u \vee v ) } .
|
| 171 |
+
$$
|
| 172 |
+
|
| 173 |
+
150 We defer the proof of Proposition 2.1 to Appendix B. We call cost(SE) the cost function in Propo
|
| 174 |
+
151 sition 2.1 from now on. Proposition 2.1 indicates that when we view $g$ as a function of the LCA
|
| 175 |
+
152 rather than that of its size and define $g ( u , v ) = \log { \mathrm { v o l } } ( u \vee v )$ , the “admissible” function becomes
|
| 176 |
+
153 equivalent to structural entropy in evaluating cluster trees, although it is not admissible any more.
|
| 177 |
+
154 So what is the difference between these two cost functions? As stated by Cohen-Addad et al. [8],
|
| 178 |
+
155 an important axiomatic hypothesis for admissible function, thus also for Dasgupta’s cost function,
|
| 179 |
+
156 is that the cost for every binary cluster tree of an unweighted clique is identical. So any binary tree
|
| 180 |
+
157 for clustering on cliques is reasonable, which coincides with the common sense that structureless
|
| 181 |
+
158 datasets can be organized hierarchically free. However, for structural entropy, the following theorem
|
| 182 |
+
159 indicates that balanced organization is of importance even though for structureless dataset.
|
| 183 |
+
160 Proposition 2.2. For any positive integer $n$ , let $K _ { n }$ be the clique of n vertices with identical weight
|
| 184 |
+
161 on every edge. Then a cluster tree $T$ of $K _ { n }$ achieves minimum structural entropy if and only if $T$ is
|
| 185 |
+
162 a balanced binary tree, that is, the two children clusters of each sub-tree of T have difference in size
|
| 186 |
+
163 at most 1.
|
| 187 |
+
164 The proof of Proposition 2.2 is a bit technical, and we defer it to Appendix C. The intuition behind
|
| 188 |
+
165 Proposition 2.2 is that balanced codes are the most efficient encoding scheme for unrelated data. So
|
| 189 |
+
166 the codewords of the random walk that jumps freely among clusters on each level of a cluster tree
|
| 190 |
+
167 have the minimum average length if all the clusters on this level are in balance.
|
| 191 |
+
168 It is worth noting that the admissible function introduced by Cohen-Addad et al. [8] is defined
|
| 192 |
+
169 from the viewpoint that a generating tree $T$ of a similarity-based graph $G$ that is generated from a
|
| 193 |
+
170 minimal ultrametric achieves the minimum cost. In this definition, the monotonicity of edge weights
|
| 194 |
+
171 between clusters on each level from bottom to top on $T$ , which is given by Cohen-Addad et al. [8] as
|
| 195 |
+
172 a property of a “natural” ground-truth hierarchical clustering, is the unique factor when evaluating $T$
|
| 196 |
+
173 However, Proposition 2.2 implies that for cost(SE), besides cluster weights, the balance of cluster
|
| 197 |
+
174 trees is implicitly involved as another factor. Moreover, for cliques, the minimum cost should be
|
| 198 |
+
175 achieved on every subtree, which makes an optimal cluster tree balanced everywhere. This optimal
|
| 199 |
+
176 clustering for cliques is also robust in the sense that a slight perturbation to the minimal ultrametric,
|
| 200 |
+
177 which can be considered as slight variations to the weights of a batch of edges, will not change the
|
| 201 |
+
178 optimal cluster tree structure wildly due to the holdback force of balance.
|
| 202 |
+
|
| 203 |
+
# 179 3 Approximation algorithms for SE-based cost function
|
| 204 |
+
|
| 205 |
+
In this section, we present approximation algorithms for expander-like and well-clustered graphs, respectively. These algorithms work for cardinality edge weights (e.g. the multiplicity of edges).
|
| 206 |
+
|
| 207 |
+
Why cardinality weights? In general, the term $\log { \mathrm { v o l } } ( u \vee v )$ in Eq. 1 and thus cost(SE) may be negative when the volume of $u \vee v$ varies, which may lead to pathosis in approximation analysis. The cardinality weight function $w$ is at least one, which makes cost(SE) non-negative. The dependence of cost(SE) on the scale of edge weights violates the scale-invariance principle. However, we emphasize that ${ \dot { \mathcal { H } } } ^ { T } ( G )$ is scale-invariant and Proposition 2.1 holds for any scale variation. In this paper, we present approximation algorithms for cost(SE) in well-defined settings.
|
| 208 |
+
|
| 209 |
+
188 Theorem 3.1. For any cardinality weighted graph $G = ( V , E , w )$ with conductance $\Phi ( G )$ , it holds that any cluster tree has a cost 189 $O ( \Phi ( G ) ^ { - 1 } ) \cdot O P T$ , where $O P T$ is the minimum cost $S E )$ of $G$ .
|
| 210 |
+
|
| 211 |
+
190 We defer the proof of Theorem 3.1 to Appendix D. When $\Phi ( G )$ is a constant, Theorem 3.1 implies
|
| 212 |
+
191 that any cluster tree achieves $O ( 1 )$ -approximation for expanders. Thus, the balance of a cluster
|
| 213 |
+
192 tree has a significant impact on its cost. Considering balance as an important factor, we present a
|
| 214 |
+
193 Huffman-merging heuristic (Algorithm 1). It will serve as a subroutine for the algorithm for well
|
| 215 |
+
194 clustered graphs.
|
| 216 |
+
|
| 217 |
+
# Algorithm 1: HuffmanMerge
|
| 218 |
+
|
| 219 |
+
Input: a graph $G = ( V , E , w )$
|
| 220 |
+
|
| 221 |
+
Output: A cluster tree $T$ of $G$
|
| 222 |
+
|
| 223 |
+
1 Create $n$ singleton trees;
|
| 224 |
+
|
| 225 |
+
2 while there are at least two trees do
|
| 226 |
+
|
| 227 |
+
3 Select the two trees $T _ { 1 }$ and $T _ { 2 }$ with the least volumes;
|
| 228 |
+
4 Construct a new tree $T _ { 0 }$ with $T _ { 1 }$ and $T _ { 2 }$ as two subtrees of the root;
|
| 229 |
+
|
| 230 |
+
5 Return the resulting binary tree $T _ { 0 }$
|
| 231 |
+
|
| 232 |
+
195 Next, we consider well-clustered graphs that are composed by a collection of densely-connected
|
| 233 |
+
196 components with high inner conductance and weakly interconnections. Our settings for well
|
| 234 |
+
197 clustered graphs is the same as those in [15]. We start from the following $( \Phi _ { i n } , \Phi _ { o u t } )$ -decomposition
|
| 235 |
+
198 presented by Gharan and Trevisan [12]. Let $\lambda _ { k }$ be the $k$ -th smallest eigenvalue of the normalized
|
| 236 |
+
199 Laplacian matrix of $G$ and $\Phi _ { G } ( S )$ be the conductance of a vertex set $S$ in $G$ .
|
| 237 |
+
|
| 238 |
+
200 Lemma 3.1. ([12], Theorem 1.5) Let $G = ( V , E , w )$ be a graph such that $\lambda _ { k } > 0$ , for some $k \geq 1$ . 201 Then, there is a local search algorithm that finds a $l$ -partition $\{ P _ { i } \} _ { i = 1 } ^ { l }$ of $V ,$ for some $l < k$ , such that for every 202 $1 \leq i \leq l$ , $\Phi _ { G } ( P _ { i } ) = \mathcal { O } ( k ^ { 6 } \sqrt { \lambda _ { k - 1 } } )$ and $\Phi ( G [ P _ { i } ] ) = \Omega ( \lambda _ { k } ^ { 2 } / k ^ { 4 } )$ .
|
| 239 |
+
|
| 240 |
+
Lemma 3.1 implies that, when graph $G$ exhibits a clear clustering structure, there is a partition $\{ P _ { i } \} _ { i = 1 } ^ { l }$ of $\mathrm { v }$ such that for each $P _ { i }$ both the outer and inner conductance can be bounded. This is one of the most crucial insights that we can use $\{ P _ { i } \} _ { i = 1 } ^ { l }$ directly to construct a cluster tree.
|
| 241 |
+
|
| 242 |
+
206 For a high-level description, our algorithm consists of two phases: Partition and Merge. In the
|
| 243 |
+
207 Partition phase, it invokes the algorithm in Lemma 3.1 to partion $V$ into sets $\{ P _ { i } \} _ { i = 1 } ^ { l }$ . In the Merge
|
| 244 |
+
208 phase it combines the trees in a "caterpillar style" according to an increasing order of their volumes.
|
| 245 |
+
209 This algorithm is described as Algorithm 2.
|
| 246 |
+
|
| 247 |
+
# Algorithm 2: CaterpillarMerge
|
| 248 |
+
|
| 249 |
+
Input: A graph $G = ( V , E , w )$ , an integer $k \geq 2$ such that $\lambda _ { k } > 0$ Output: A cluster tree $T$ of $G$
|
| 250 |
+
|
| 251 |
+
1 Apply the partitioning algorithm in Lemma 3.1 on input $( G , k )$ to obtain $\{ P _ { i } \} _ { i = 1 } ^ { l }$ for some $l < k$ ;
|
| 252 |
+
|
| 253 |
+
2 Sort $P _ { 1 } , . . . , P _ { l }$ be such that ${ \mathrm { v o l } } _ { G } ( P _ { i } ) \leq { \mathrm { v o l } } _ { G } ( P _ { i + 1 } )$ , for all $1 \leq i < l$ ;
|
| 254 |
+
|
| 255 |
+
3 Let $T _ { i } =$ HuffmanMerge $( G [ P _ { i } ] )$ ;
|
| 256 |
+
4 Initialize $T = T _ { 1 }$ ;
|
| 257 |
+
5 for $i = 2 , . . . , l$ do
|
| 258 |
+
6 Let $T$ be the tree with $T$ and $T _ { i }$ as its two children;
|
| 259 |
+
|
| 260 |
+
7 Return $T$
|
| 261 |
+
|
| 262 |
+
210 Note that Algorithm 2 degenerates to Algorithm 1 when $k = 2$ . For the approximation guarantee,
|
| 263 |
+
211 we have the following theorem.
|
| 264 |
+
212 Theorem 3.2. Let $G = ( V , E , w )$ be a cardinality weighted graph such that $\lambda _ { k } \ > \ 0$ for some
|
| 265 |
+
213 $k \geq 1$ . Then Algorithm 2 constructs in polynomial time a cluster tree $T$ of $G$ that achieves
|
| 266 |
+
214 $\begin{array} { r } { O \left( \frac { 1 } { ( 1 - \alpha ) \beta } \log \frac { k } { 1 - \alpha } \right) } \end{array}$ -approximation for $c o s t ^ { T } ( G )$ , where $\alpha = O ( k ^ { 6 } \sqrt { \lambda _ { k - 1 } } )$ , $\beta = \Omega ( \lambda _ { k } ^ { 2 } / k ^ { 4 } )$ . Con
|
| 267 |
+
215 sequently, when $\lambda _ { k } = \Omega ( 1 / p o l y ( k ) )$ and $\lambda _ { k - 1 } = { \cal O } ( 1 / k ^ { 1 2 } )$ such that $\alpha < 1 - \rho$ for some constant
|
| 268 |
+
216 $\rho \in \mathsf { \Gamma } ( 0 , 1 )$ , Algorithm 2 achieves $O ( p o l y ( k ) )$ -approximation. In addition, when $k$ is a constant,
|
| 269 |
+
217 Algorithm 2 achieves $O ( 1 )$ -approximation.
|
| 270 |
+
|
| 271 |
+
218 The proof of Theorem 3.2 is given in Appendix E.
|
| 272 |
+
|
| 273 |
+
In this section, we develop a non-binary hierarchical clustering algorithm based on cost(SE) optimization. At present, all existing algorithms for hierarchical clustering can be categorized into two frameworks: top-down division and bottom-up agglomeration [8]. The top-down division approach usually yields a binary tree by recursively dividing a cluster into two parts with a cut-related criterion. But a binary clustering tree is far from a practical one as we introduced in Section 1. For practical use, bottom-up agglomeration that is also known as hierarchical agglomerative clustering (HAC) is commonly preferable. It constructs a cluster tree from leaves to the root recursively, during each round of which the newly generated clusters shrink into single vertices.
|
| 274 |
+
|
| 275 |
+
Our algorithm jumps out of these two frameworks. We establish a new one that stratifies the sparsest level of a cluster tree recursively rather than in a sequential order. In general, in guide with cost(SE), we construct a $k + 1$ -level cluster tree from the previous $k$ -level one, during which we find the level whose stratification makes the average cost in a local reduced subgraph decrease most, and then differentiate it into two levels. The process of stratification consists of two basic operations: stretch and compression. Generally speaking, in stretch steps, given an internal node of a cluster tree, a local binary subtree is constructed, while in compression steps, the paths that are overlength from the root to leaves on the binary tree is compressed by shrinking tree edges that make the cost reduce most. The intuition behind the “stretch-and-compress” scheme is as follows. First, we run a fast and simple, but probably rough clustering algorithm to obtain a binary cluster subtree. So intuitively, after stretch, we unfold all the potential hierarchies such that the sparsest level is possibly to be seen. Second, we compress every overlength path that is supposed to get through each level of this subtree, during which, the edge on the sparsest level whose compression makes too many graph edges amplify the sizes of their LCAs to a large extent will be retained.
|
| 276 |
+
|
| 277 |
+
We remark that this framework can be collocated with any cost function and any binary cluster tree algorithm. For computational efficiency, especially for real networks of large scale more than $1 0 ^ { 4 }$ we will adopt in our experiments an HAC construction of binary cluster trees in stretch steps.
|
| 278 |
+
|
| 279 |
+
Stretch and compress. Given a cluster tree $T$ for graph $G = ( V , E )$ , let $u$ be an internal node on $T$ and $v _ { 1 } , v _ { 2 } , \ldots , v _ { \ell }$ be its children. We call this local parent-children structure rooted at $u$ to be a $u$ -triangle of $T$ , denoted by $T _ { u }$ . These two operations are defined on $u$ -triangles. Note that each child $v _ { i }$ of $u$ is a cluster in $G$ . We reduce $G$ by shrinking each $v _ { i }$ to be a single vertex $\boldsymbol { v } _ { i } ^ { \prime }$ while maintaining each inter-link and ignoring each internal edge of $v _ { i }$ . This reduction captures the connections of clusters at this level in the parent cluster $u$ . The stretch operation constructs a binary tree for $u$ -triangle. We adopt a common HAC construction in this $u$ -triangle. That is, initially, view each $\boldsymbol { v } _ { i } ^ { \prime }$ as a cluster and recursively combine two clusters into a new one for which cost(SE) drops most. The sequence of combinations yields a binary subtree $T _ { u } ^ { \prime }$ rooted at $u$ which has $v _ { 1 } , v _ { 2 } , \ldots , v _ { \ell }$ as leaves. Then the compression operation is proposed to reduce the height of $T _ { u } ^ { \prime }$ to be 2. Let $\hat { E } ( T ^ { \prime } )$ be the set of edges on $T ^ { \prime }$ , each of which appears on a path of length more than 2 from the root of $T ^ { \prime }$ to some leaf. Denote by $\Delta ( e )$ for edge $e$ be the amount of structural entropy enhanced by the shrink of $e$ . We pick from $\hat { E } ( T _ { u } ^ { \prime } )$ the edge $e$ with least $\Delta ( e )$ . Note that the compression of a tree edge makes the grandchildren of some internal node to be children, which must amplify the cost. The compression operation picks the least amplification. The processes of stretch and compress are illustrated in Figure 3 and stated in Algorithms 5 and 6, respectively (see Appendix G).
|
| 280 |
+
|
| 281 |
+
Sparsest level. Let $U _ { j }$ be the set of $j$ -level nodes on cluster tree $T$ , that is, $U _ { j }$ is the set of nodes each of which has distance $j$ from $T$ ’s root. Suppose that the height of $T$ is $k$ , then $U _ { 0 } , U _ { 1 } , \dots , U _ { k - 1 }$ is a partition for all internal nodes of $T$ . For each internal node $u$ , define $\begin{array} { r } { \mathcal { H } ( u ) = - \sum _ { v : v ^ { - } = u } \frac { g _ { u } } { \mathrm { v o l } ( V ) } \log \frac { \mathrm { v o l } ( v ) } { \mathrm { v o l } ( u ) } } \end{array}$ . Note that $\mathcal { H } ( u )$ is the partial sum contributed by $u$ in ${ \mathcal { H } } ^ { T } ( G )$ . After a “stretch-and-compress” round on $u$ -triangle, denote by $\Delta \mathcal { H } ( u )$ the structural entropy by which the new cluster tree reduces. Since the reconstruction of $u$ -triangle stratifies cluster $u$ , $\Delta \mathcal { H } ( u )$ is always non-negative. Define the sparsity of $u$ to be $\begin{array} { r } { \mathrm { S p a r } ( u ) = \frac { \Delta \mathcal { H } ( u ) } { \mathcal { H } ( u ) } } \end{array}$ , which is the relative variation of structural entropy in cluster $u$ . From the information-theoretic perspective, this means that the uncertainty of random walk can be measured locally in any internal cluster, which reflects the quality of clustering in this local area. At last, we define the sparsest level of $T$ to be the $j$ -th level such that the average sparsity of triangles rooted at nodes in $U _ { j }$ is maximum, that is arg $\operatorname* { m a x } _ { j } \{ { \overline { { \operatorname { S p a r } } } } _ { j } ( T ) \}$ where 272 $\begin{array} { r } { \overline { { \mathrm { S p a r } } } _ { j } ( T ) = \sum _ { u \in U _ { j } } { \mathrm { S p a r } } ( \mathbf { u } ) / | U _ { j } | } \end{array}$ . Then stratification works for the sparsest level of $T$ . This 73 process is illustrated in Figure 4 (see Appendix G).
|
| 282 |
+
|
| 283 |
+
274 For a given positive integer $k$ , to construct a cluster tree of height $k$ , we start from the trivial 1-level
|
| 284 |
+
275 cluster tree that involves all vertices of $G$ as leaves. Then we do not stop stratifying at the sparsest
|
| 285 |
+
276 level recursively until a $k$ -level cluster tree is obtained. This process is described in Algorithm 3.
|
| 286 |
+
|
| 287 |
+
# Algorithm 3: $k$ -Hierarchical clustering based on structural entropy ( $k$ -HCSE)
|
| 288 |
+
|
| 289 |
+
Input: a graph $G = ( V , E )$ , $k \in \mathbb { Z } ^ { + }$
|
| 290 |
+
Output: a $k$ -level cluster tree $T$
|
| 291 |
+
1 Initialize $T$ to be the 1-level cluster tree;
|
| 292 |
+
2 $h = \mathrm { h e i g h t ( T ) }$ ;
|
| 293 |
+
3 while $h < k$ do
|
| 294 |
+
4 $j ^ { \prime } \gets \arg \operatorname* { m a x } _ { j } \{ \overline { { \mathrm { S p a r } } } _ { j } ( T ) \}$ ; // Find the sparsest level of $T$ (breaking ties arbitraily);
|
| 295 |
+
5 if $\overline { { S p a r } } _ { j ^ { \prime } } ( T ) = 0$ then
|
| 296 |
+
6 break; // No cost will be saved by any further clustering;
|
| 297 |
+
7 for $u \in U _ { j ^ { \prime } }$ do
|
| 298 |
+
8 $T _ { u } \gets \mathrm { S t r e t c h } ( u \mathrm { - t r i a n g l e } T _ { u } )$ ;
|
| 299 |
+
9 Compress $( T _ { u } )$ ;
|
| 300 |
+
10 $h \gets h + 1$ ;
|
| 301 |
+
11 for $j \in [ j ^ { \prime } + 1 , h ]$ do
|
| 302 |
+
12 Update $U _ { j }$ ;
|
| 303 |
+
13 return T
|
| 304 |
+
277 To determine the height of the cluster tree automatically, we derive the natural clustering from the
|
| 305 |
+
278 variation of sparsity on each level. Intuitively, a natural hierarchical cluster tree $T$ should have
|
| 306 |
+
279 not only sparse boundary on clusters, but also low sparsity for triangles of $T$ , which means that
|
| 307 |
+
280 stratification within the reduced subgraphs corresponding to the triangles on the sparsest level makes
|
| 308 |
+
281 little sense. For this reason, we consider the inflection points of the sequence $\{ \delta _ { t } ( \mathcal { H } ) \} _ { t = 1 , 2 , . . . }$ ,
|
| 309 |
+
282 where $\delta _ { t } ( \mathcal { H } )$ is the structural entropy by which the $t$ -th round of stratification reduces. Formally,
|
| 310 |
+
283 denote $\Delta _ { t } \mathcal { H } = \delta _ { t - 1 } ( \mathcal { H } ) - \delta _ { t } ( \mathcal { H } )$ for each $t \geq 2$ . We say that $\Delta _ { t } \mathcal { H }$ is an inflection point if both
|
| 311 |
+
284 $\Delta _ { t } \mathcal { H } \ \geq \ \Delta _ { t - 1 } \mathcal { H }$ and $\Delta _ { t } \mathcal { H } \ \geq \ \Delta _ { t + 1 } \mathcal { H }$ hold. Our algorithm finds the least $t$ such that $\Delta _ { t } \mathcal { H }$ is
|
| 312 |
+
285 an inflection point and fix the height of the cluster tree to be $t$ (Note that after $t - 1$ rounds of
|
| 313 |
+
286 stratification, the number of levels is $t$ ). This process is described as Algorithm 4.
|
| 314 |
+
|
| 315 |
+
# Algorithm 4: Hierarchical clustering based on structural entropy (HCSE)
|
| 316 |
+
|
| 317 |
+
Input: a graph $G = ( V , E )$ Output: a cluster tree $T$ 1 $t \gets 2$ ; 2 while $\Delta _ { t } \mathcal { H } < \Delta _ { t - 1 } \mathcal { H }$ or $\Delta _ { t } \mathcal { H } < \Delta _ { t + 1 } \mathcal { H }$ do 3 $\scriptstyle \mathbf { f } \operatorname* { m a x } _ { j } \{ { \overline { { S p a r } } } _ { j } ( T ) \} = O$ then 4 break; 5 $t \gets t + 1$ ; 6 return $\scriptstyle t - \mathrm { H C S E } ( T )$
|
| 318 |
+
|
| 319 |
+
287 Time complexity. The running time of HCSE on graph $G = ( V , E )$ for which $| V | = n$ and $| E | = m$
|
| 320 |
+
288 depends mainly on the iterations of stratification for the sparsest level. For each round of $t$ -HCSE in
|
| 321 |
+
289 Algorithm 4, since the change of structure entropy can be calculated incrementally and locally when
|
| 322 |
+
290 merge siblings, the time complexity for the Stretch process is $O ( m h \log n )$ , where $h$ is the height
|
| 323 |
+
291 of the binary tree that Stretch yields. Since at most $n$ times of shrinking operations on tree edges
|
| 324 |
+
292 will happen, the time complexity for the Compress process is $O ( h n )$ . Let $h _ { \mathrm { m a x } }$ be the maximum
|
| 325 |
+
293 height among the binary trees that appear during all iterations. The time complexity of HCSE (and
|
| 326 |
+
294 also $k$ -HCSE) is $O ( k m h _ { \operatorname* { m a x } } \log n + k h _ { \operatorname* { m a x } } n )$ . In practice, $k$ is usually very small (we can even
|
| 327 |
+
295 set $k = O ( 1 )$ in $k$ -HCSE). Moreover, the balance property of structural entropy tends to produce a
|
| 328 |
+
|
| 329 |
+
<table><tr><td></td><td>p</td><td>HCSE</td><td>HLP</td><td>LOU</td></tr><tr><td>P2 P1 P0</td><td>4.5E(-2) 1.5E(-3) 6E(-6)</td><td>0.89 0.93 0.62</td><td>0.79 0.75 0.58</td><td>0.92 0.92 11</td></tr><tr><td>P2 P1 P0</td><td>5.5E(-2) 1.5E(-3) 4E(-6)</td><td>0.87 0.95 0.72</td><td>0.89 0.87 11</td><td>0.89 0.87 11</td></tr><tr><td>P2 P1 P0</td><td>6.5E(-2) 4.5E(-3) 2.5E(-6)</td><td>0.96 0.94 0.80</td><td>0.95 0.81 11</td><td>0.99 0.99</td></tr></table>
|
| 330 |
+
|
| 331 |
+
Table 1: NMI for three algorithms. Each dataset has 2, 500 vertices, and the cluster numbers at three levels are 5, 25 and 250, respectively, for which the size of each cluster is accordingly generated at random. $p _ { 3 } = 0 . 9$ for each graph. “ ” means the algorithm does not find this level.
|
| 332 |
+
|
| 333 |
+

|
| 334 |
+
Figure 1: $\delta _ { t } ( \mathcal { H } )$ variations for HCSE. It can be observed easily that the inflection points for all the three datasets appear on $t = 4$ , which is also the ground-truth number of hierarchies.
|
| 335 |
+
|
| 336 |
+
296 balanced binary tree after stretch, which makes $h _ { \mathrm { m a x } } = { \cal { O } } ( \log n )$ . Therefore, in this case, the time complexity is merely 297 $O ( m \log ^ { 2 } n )$ .
|
| 337 |
+
|
| 338 |
+
# 298 5 Experiments
|
| 339 |
+
|
| 340 |
+
We evaluate experimentally our practically used non-binary clustering algorithm both on synthetic networks generated from the Hierarchical Stochastic Block Model (HSBM) and on real datasets, respectively. We compare HCSE with the popular practical algorithms LOUVAIN [3] and HLP [19]. To avoid over-fitting to higher levels, which possibly results in under-fitting to lower levels, LOUVAIN admits a sequential input of vertices. Usually, to avert the worst-case trap, the vertices come randomly, and the resulting cluster tree depends on their order. HLP invokes the common LP algorithm recursively, and so it cannot be guaranteed to avoid under-fitting in each round. This can be seen in our experiments on synthetic datasets, for which these two algorithms usually miss ground-truth levels. For real datasets, as far as we know, no public real datasets have clear ground truth for hierarchical clustering. We do the comparative experiments on real networks. Some of them have (overlapping, possibly hierarchical) ground truth, e.g., Amazon, while others do not have. We evaluate the resulting cluster trees for the Amazon network by Jaccard index, and show the results in Appendix F, For other networks without ground truth, we evaluate results by both cost(SE) and Dasgupta’s cost function cost(Das). All the source code can be downloaded from https://github.com/samwu-learn/HCSE.
|
| 341 |
+
|
| 342 |
+
314 Synthetic datasets generated from HSBM. Our experiments on synthetic datasets utilize 4-level
|
| 343 |
+
315 HSBM. For simplicity, let $\vec { p } = \left( p _ { 0 } , p _ { 1 } , p _ { 2 } , p _ { 3 } \right)$ be the probability vector for which $p _ { i }$ is the proba
|
| 344 |
+
316 bility of generating edges for vertex pairs whose LCA on the ground-truth cluster tree has depth $i$
|
| 345 |
+
317 Note that the 0-depth node is the root. We compare the Normalized Mutual Information (NMI) at
|
| 346 |
+
318 each level of the ground-truth cluster tree to those of three algorithms. Note that the randomness in
|
| 347 |
+
319 LOUVAIN, and breaking-ties rule as well as convergence of HLP make different results, we choose
|
| 348 |
+
320 the most effective strategy and pick the best results in five runs for both of them. Compared to their
|
| 349 |
+
321 uncertainty, our algorithm HCSE yields stable results.
|
| 350 |
+
|
| 351 |
+
Table 1 demonstrates the results in three groups of probabilities, for which the hierarchical structures get clearer one by one. Each dataset has 2, 500 vertices, and the cluster numbers at three levels are 5, 25 and 250, respectively, for which the size of each cluster is accordingly generated at random. $p _ { 3 } = 0 . 9$ for each graph. Our algorithm HCSE is always able to find the right number of levels, while LOUVAIN always misses the top level, and HLP misses the top level in two groups. The inflection points for choosing the intrinsic hierarchy number $t = 4$ of hierarchies are demonstrated in Figure 1.
|
| 352 |
+
|
| 353 |
+
<table><tr><td>Networks</td><td>HCSE</td><td>HLP</td><td>LOUVAIN</td></tr><tr><td>CSphd</td><td>1.30E4 / 5.19E4 / 5</td><td>1.54E4 / 5.58E4 /4</td><td>1.28E4 / 7.61E4 / 5</td></tr><tr><td>fb-pages-government</td><td>2.48E6 /1.18E8 / 4</td><td>2.53E6 / 1.76E8 / 3</td><td>2.43E6 / 1.33E8 / 4</td></tr><tr><td>email-univ</td><td>1.16E5 /2.20E6 / 3</td><td>1.46E5 / 6.14E6 / 3</td><td>1.14E5 / 2.20E6 /4</td></tr><tr><td>fb-messages</td><td>1.58E5 / 4.50E6 / 4</td><td>1.76E5 /8.12E6 / 3</td><td>1.52E5 / 4.96E6 / 4</td></tr><tr><td>G22</td><td>5.56E5 / 2.68E7 /4</td><td>6.11E5 /4.00E7 /3</td><td>5.63E5 /2.80E7 /5</td></tr><tr><td>As20000102</td><td>2.64E5 / 2.36E7 /4</td><td>3.62E5 / 7.63E7 /3</td><td>2.42E5 /2.42E7 / 5</td></tr><tr><td>bibd-13-6</td><td>7.41E5 / 2.56E7 / 3</td><td>8.05E5 /4.41E7 /2</td><td>7.50E5 / 2.75E7 /4</td></tr><tr><td>delaunay-n10</td><td>4.65E4 / 3.39E5 / 4</td><td>4.87E4 / 3.55E5 /4</td><td>4.24E4 / 4.25E5 / 5</td></tr><tr><td>p2p-Gnutella05</td><td>9.00E5 /1.48E8 / 3</td><td>1.01E6 / 2.78E8 / 3</td><td>8.05E5 / 1.49E8 / 5</td></tr><tr><td>p2p-Gnutella08</td><td>5.59E5 / 5.51E7 / 4</td><td>6.36E5 / 1.28E8 /4</td><td>4.88E5 / 6.03E7 / 5</td></tr></table>
|
| 354 |
+
|
| 355 |
+
Table 2: “cost(SE) / cost(Das) / k” for three algorithms, where $k$ is the hierarchy number that the algorithm finds.
|
| 356 |
+
|
| 357 |
+
Real datasets. We do our experiments on a series of real networks 2 without ground truth. We compare cost(SE) and cost(Das), respectively. Since the different level numbers given by the three algorithms influence the costs seriously, that is, lower costs are obtained just due to greater heights, we only list in Table 2 the networks for which the three algorithms yield similar level numbers that differ by at most 1 or 2. It can be observed that HLP does not achieve optima for any network, while HCSE performs best w.r.t. cost(Das) for all networks, but does not outperform LOUVAIN for most networks. This is mainly due to the fact that LOUVAIN always finds no less number of hierarchies than HCSE, and the better cost benefits from its depth. Moreover, we emphasize that there is no evidence to indicate that the lower cost(SE) or cost(Das) is, the better a non-binary cluster tree is. Our experiments on these real datasets are just demonstrations of the effectiveness for our interpretable mechanism in hierarchical clustering.
|
| 358 |
+
|
| 359 |
+
# 340 6 Conclusions and future discussions
|
| 360 |
+
|
| 361 |
+
In this paper, we investigate the hierarchical clustering problem from an information-theoretic perspective and propose a new objective function that relates to the combinatorial cost functions raised by Dasgupta [10]. For optimization of this function, we present two $O ( 1 )$ -approximation algorithms for expander-like and well-clustered cardinality weighted graphs, respectively. For practical use, we propose a new interpretable non-binary hierarchical clustering framework that stratifies the sparsest level of the cluster tree recursively, which can be collocated with any cost function. We also present an interpretable strategy to find the intrinsic number of levels without any hyper-parameter. The experimental results on $k$ -level HSBM demonstrate that our algorithm HCSE has a great advantage in finding $k$ compared to the popular but strongly heuristic algorithms LOUVAIN and HLP. Our results on real datasets show that HCSE also achieves competitive costs compared to these two algorithms.
|
| 362 |
+
|
| 363 |
+
There are several directions that are worth further study. The first problem is about the relationship between the concavity of $g$ of the cost function and the balance of the optimal cluster tree. It can be checked that for cliques, being concave is not a sufficient condition for total balance. Whether is it a necessary condition? Moreover, is there any explicit necessary and sufficient condition for total balance of the optimal cluster tree for cliques? The second problem is about approximation algorithms for both structural entropy and cost(SE) in the worst case. Due to the non-linear and volume-related function $g$ , many previous proof techniques for approximation algorithms seems unavailable. The third one is about more precise characterizations for “natural” hierarchical clustering whose depth is limited. Since any reasonable choice of $g$ makes the cost function achieve optimum on some binary tree, a blind pursuit of minimization of cost functions seems not to be a rational approach. More criteria in this scenario need to be studied.
|
| 364 |
+
|
| 365 |
+
# References
|
| 366 |
+
|
| 367 |
+
[1] Noga Alon, Yossi Azar, and Danny Vainstein. Hierarchical clustering: A 0.585 revenue approximation. In Jacob D. Abernethy and Shivani Agarwal, editors, Conference on Learning Theory, COLT 2020, 9-12 July 2020, Virtual Event [Graz, Austria], volume 125 of Proceedings of Machine Learning Research, pages 153–162. PMLR, 2020. [2] Sanjeev Arora, Satish Rao, and Umesh V. Vazirani. Expander flows, geometric embeddings and graph partitioning. J. ACM, 56(2):5:1–5:37, 2009. [3] Vincent D. Blondel, Jean-Loup Guillaume, Renaud Lambiotte, and Etienne Lefebvre. Fast unfolding of communities in large networks. Journal of statistical mechanics: theory and experiment, 2008(10):P10008, 2008. [4] Peter F Brown, Vincent J Della Pietra, Peter V Desouza, Jennifer C Lai, and Robert L Mercer. Class-based n-gram models of natural language. Computational linguistics, 18(4):467–480, 1992. [5] Moses Charikar and Vaggos Chatziafratis. Approximate hierarchical clustering via sparsest cut and spreading metrics. In Philip N. Klein, editor, Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 841–854. SIAM, 2017. [6] Moses Charikar, Vaggos Chatziafratis, and Rad Niazadeh. Hierarchical clustering better than average-linkage. In Timothy M. Chan, editor, Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2019, San Diego, California, USA, January 6-9, 2019, pages 2291–2304. SIAM, 2019. [7] Vaggos Chatziafratis, Grigory Yaroslavtsev, Euiwoong Lee, Konstantin Makarychev, Sara Ahmadian, Alessandro Epasto, and Mohammad Mahdian. Bisect and conquer: Hierarchical clustering via max-uncut bisection. In Silvia Chiappa and Roberto Calandra, editors, The $2 3 r d$ International Conference on Artificial Intelligence and Statistics, AISTATS 2020, 26-28 August 2020, Online [Palermo, Sicily, Italy], volume 108 of Proceedings of Machine Learning Research, pages 3121–3132. PMLR, 2020. [8] Vincent Cohen-Addad, Varun Kanade, Frederik Mallmann-Trenn, and Claire Mathieu. Hierarchical clustering: Objective functions and algorithms. Journal of the ACM (JACM), 66(4):1–42, 2019. [9] Aron Culotta, Pallika Kanani, Robert Hall, Michael Wick, and Andrew McCallum. Author disambiguation using error-driven machine learning with a ranking loss function. In Sixth International Workshop on Information Integration on the Web (IIWeb-07), Vancouver, Canada, 2007. [10] Sanjoy Dasgupta. A cost function for similarity-based hierarchical clustering. In Daniel Wichs and Yishay Mansour, editors, Proceedings of the 48th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2016, Cambridge, MA, USA, June 18-21, 2016, pages 118–127. ACM, 2016. [11] Michael B Eisen, Paul T Spellman, Patrick O Brown, and David Botstein. Cluster analysis and display of genome-wide expression patterns. Proceedings of the National Academy of Sciences, 95(25):14863–14868, 1998. [12] Shayan Oveis Gharan and Luca Trevisan. Partitioning into expanders. In Chandra Chekuri, editor, Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 1256–1266. SIAM, 2014. 06 [13] Alexander N Gorban, Balázs Kégl, Donald C Wunsch, Andrei Y Zinovyev, et al. Principal manifolds for data visualization and dimension reduction, volume 58. Springer, 2008. [14] Angsheng Li and Yicheng Pan. Structural information and dynamical complexity of networks. IEEE Trans. Inf. Theory, 62(6):3290–3339, 2016.
|
| 368 |
+
|
| 369 |
+
[15] Bogdan-Adrian Manghiuc and He Sun. Hierarchical clustering: O(1)-approximation for wellclustered graphs. In Marc’Aurelio Ranzato, Alina Beygelzimer, Yann N. Dauphin, Percy Liang, and Jennifer Wortman Vaughan, editors, Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, pages 9278–9289, 2021.
|
| 370 |
+
[16] Benjamin Moseley and Joshua R. Wang. Approximation bounds for hierarchical clustering: Average linkage, bisecting $\mathbf { k }$ -means, and local search. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett, editors, Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pages 3094–3103, 2017.
|
| 371 |
+
[17] Stanislav Naumov, Grigory Yaroslavtsev, and Dmitrii Avdiukhin. Objective-based hierarchical clustering of deep embedding vectors. In Thirty-Fifth AAAI Conference on Artificial Intelligence, AAAI 2021, Thirty-Third Conference on Innovative Applications of Artificial Intelligence, IAAI 2021, The Eleventh Symposium on Educational Advances in Artificial Intelligence, EAAI 2021, Virtual Event, February 2-9, 2021, pages 9055–9063. AAAI Press, 2021.
|
| 372 |
+
[18] Mirmahdi Rahgoshay and Mohammad R. Salavatipour. Hierarchical clustering: New bounds and objective. CoRR, abs/2111.06863, 2021.
|
| 373 |
+
[19] Ryan A Rossi, Nesreen K Ahmed, Eunyee Koh, and Sungchul Kim. Fast hierarchical graph clustering in linear-time. In Companion Proceedings of the Web Conference 2020, pages 10– 12, 2020.
|
| 374 |
+
[20] Aurko Roy and Sebastian Pokutta. Hierarchical clustering via spreading metrics. J. Mach. Learn. Res., 18:88:1–88:35, 2017.
|
| 375 |
+
|
| 376 |
+
# Checklist
|
| 377 |
+
|
| 378 |
+
1. For all authors...
|
| 379 |
+
|
| 380 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Abstract and Section 1
|
| 381 |
+
(b) Did you describe the limitations of your work? [Yes] See Section 3 and 6
|
| 382 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A]
|
| 383 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 384 |
+
|
| 385 |
+
2. If you are including theoretical results...
|
| 386 |
+
|
| 387 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 3 (b) Did you include complete proofs of all theoretical results? [Yes] See Appendices
|
| 388 |
+
|
| 389 |
+
3. If you ran experiments...
|
| 390 |
+
|
| 391 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See Section 5
|
| 392 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [N/A]
|
| 393 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
|
| 394 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [No] We do not compare the speed of computing, and so due to the space limit we have omitted resource introduction.
|
| 395 |
+
|
| 396 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 397 |
+
|
| 398 |
+
(a) If your work uses existing assets, did you cite the creators? [N/A] All codes are written by the authors, and all datasets we use is public. We have provided the URLs that link to the datasets we use.
|
| 399 |
+
|
| 400 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 401 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 402 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] All datasets we used are public.
|
| 403 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] No such content is included.
|
| 404 |
+
|
| 405 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 406 |
+
|
| 407 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 408 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 409 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
| 410 |
+
|
| 411 |
+
# 473 A A brief introduction to structural information
|
| 412 |
+
|
| 413 |
+
The idea of structural information is to encode a random walk with a certain rule by using a highdimensional encoding system for a graph $G$ . It is well known that a random walk, for which a neighbor is randomly chosen with probability proportional to edge weights, has a stationary distribution on vertices that is proportional to vertex degree.3 So to position a random walk under its stationary distribution, the amount of information needed is typically the Shannon’s entropy, denoted by
|
| 414 |
+
|
| 415 |
+
$$
|
| 416 |
+
{ \mathcal { H } } ^ { ( 1 ) } ( G ) = - \sum _ { v \in V } { \frac { d _ { v } } { { \mathrm { v o l } } ( V ) } } \log { \frac { d _ { v } } { { \mathrm { v o l } } ( V ) } } .
|
| 417 |
+
$$
|
| 418 |
+
|
| 419 |
+
474 By Shannon’s noiseless coding theorem, $\mathcal { H } ^ { ( 1 ) } ( G )$ is the limit of average code length generated from
|
| 420 |
+
475 the memoryless source for one step of the random walk. However, dependence of locations may
|
| 421 |
+
476 shorten the code length. For each level on cluster trees, the uncertainty of locations is measured by
|
| 422 |
+
477 the entropy of the stationary distribution on the clusters of this level. Consider an encoding for every
|
| 423 |
+
478 cluster, including the leaves. Each non-root node $\alpha$ is labeled by its order among the children of
|
| 424 |
+
479 its parent $\alpha ^ { - }$ . So the amount of self-information of $\alpha$ within this local parent-children substructure
|
| 425 |
+
480 is $\bar { - } \log ( \mathrm { v o l } ( \alpha ) / \mathrm { v o l } ( \alpha ^ { - } ) )$ , which is also roughly the length of Shannon code for $\alpha$ and its siblings.
|
| 426 |
+
481 The codeword of $\alpha$ consists of the sequential labels of nodes along the unique path from the root
|
| 427 |
+
482 (excluded) to itself (included). The key idea is as follows. For one step of the random walk from $u$ to
|
| 428 |
+
483 $v$ in $G$ , to indicate $v$ , we omit from $v$ ’s codeword the longest common prefix of $u$ and $v$ that is exactly
|
| 429 |
+
484 the codeword of $u \vee v$ . This means that the random walk takes this step in the cluster $u \vee v$ (and
|
| 430 |
+
485 also in $u \vee v$ ’s ancestors) and the uncertainty at this level may not be involved. Therefore, intuitively,
|
| 431 |
+
486 a quality similarity-based cluster tree would trap the random walk with high frequency in the deep
|
| 432 |
+
487 clusters that are far from the root, and long codeword of $u \vee v$ would be omitted. This shortens the
|
| 433 |
+
488 average code length of the random walk. Note that we ignore the uniqueness of decoding since a
|
| 434 |
+
489 practical design of codewords is not our purpose. We utilize this scheme to evaluate and differentiate
|
| 435 |
+
490 hierarchical structures.
|
| 436 |
+
491 Then we formulate the above scheme and measure the average code length as follows. Given a
|
| 437 |
+
492 weighted graph $G = ( V , E , w )$ and a cluster tree $T$ for $G$ , note that under the stationary distribution,
|
| 438 |
+
493 the random walk takes one step out of a cluster $\alpha$ on $T$ with probability $g _ { \alpha } / { \mathrm { v o l } } ( V )$ . Therefore, the
|
| 439 |
+
494 aforementioned uncertainty measured by the average code length is
|
| 440 |
+
|
| 441 |
+
$$
|
| 442 |
+
\mathcal { H } ^ { T } ( G ) = - \sum _ { \alpha \in T } \frac { g _ { \alpha } } { \mathrm { v o l } ( V ) } \log \frac { \mathrm { v o l } ( \alpha ) } { \mathrm { v o l } ( \alpha ^ { - } ) } ,
|
| 443 |
+
$$
|
| 444 |
+
|
| 445 |
+
495 which is defined as the structural entropy of $G$ on $T$ . To minimize this uncertainty, the structural
|
| 446 |
+
496 entropy $\mathcal { H } ( G )$ of $G$ is defined as the minimum one among all cluster trees. Note that the structural
|
| 447 |
+
497 entropy of $G$ on the trivial 1-level cluster tree is consistent with the previously defined $\mathcal { H } ^ { ( 1 ) } ( G )$ . It
|
| 448 |
+
498 doesn’t have any non-trivial cluster.
|
| 449 |
+
|
| 450 |
+
# 499 B Proof of Proposition 2.1
|
| 451 |
+
|
| 452 |
+
500 Proof. For each internal node $\alpha$ on $T$ , denote by $\partial ( \alpha )$ the sets of edges in $G$ with exactly one
|
| 453 |
+
501 end-point in the set of vertices corresponding to $\alpha$ $\begin{array} { r } { \chi _ { * } \operatorname { S o } g _ { \alpha } = \sum _ { e \in \partial ( \alpha ) } w \bar { ( } e ) } \end{array}$ . Note that
|
| 454 |
+
|
| 455 |
+
$$
|
| 456 |
+
\begin{array} { r c l } { \mathcal { H } ^ { T } ( G ) } & { = } & { \displaystyle - \sum _ { \alpha \in T } \frac { g _ { \alpha } } { \mathrm { v o l } ( V ) } \log \frac { \mathrm { v o l } ( \alpha ) } { \mathrm { v o l } ( \alpha ^ { - } ) } } \\ & { = } & { \displaystyle - \sum _ { \alpha \in T } \displaystyle \sum _ { ( u , v ) \in \partial ( \alpha ) } \frac { w ( u , v ) } { \mathrm { v o l } ( V ) } \log \frac { \mathrm { v o l } ( \alpha ) } { \mathrm { v o l } ( \alpha ^ { - } ) } } \\ & { = } & { \displaystyle - \sum _ { ( u , v ) \in E } \left( \frac { w ( u , v ) } { \mathrm { v o l } ( V ) } \sum _ { \alpha : ( u , v ) \in g _ { \alpha } } \log \frac { \mathrm { v o l } ( \alpha ) } { \mathrm { v o l } ( \alpha ^ { - } ) } \right) . } \end{array}
|
| 457 |
+
$$
|
| 458 |
+
|
| 459 |
+
502 For a single edge $( u , v ) \in E$ , all the terms $\log ( \mathrm { v o l } ( \alpha ) / \mathrm { v o l } ( \alpha ^ { - } ) )$ for leaf $u$ satisfying $( u , v ) \in g _ { \alpha }$
|
| 460 |
+
503 sum (over $\alpha$ ) up to $\log ( d _ { u } / \mathrm { v o l } ( u \vee v ) )$ along the unique path from $u$ to $u \vee v$ . It is symmetric for $v$
|
| 461 |
+
504 Therefore, considering ordered pair $( u , v ) \in E$ ,
|
| 462 |
+
|
| 463 |
+
$$
|
| 464 |
+
\begin{array} { r c l } { \mathcal { H } ^ { T } ( G ) } & { = } & { - \displaystyle \sum _ { \mathrm { \tiny ~ o r d e r e d ~ } ( u , v ) \in E } \frac { w ( u , v ) } { \mathrm { v o l } ( V ) } \log \frac { d _ { u } } { \mathrm { v o l } ( u \vee v ) } } \\ & { = } & { \displaystyle \frac { 1 } { \mathrm { v o l } ( V ) } \left( - \sum _ { u \in V } d _ { u } \log d _ { u } + \sum _ { \mathrm { \tiny ~ o r d e r d ~ } ( u , v ) \in E } w ( u , v ) \log \mathrm { v o l } ( u \vee v ) \right) } \\ & { = } & { \displaystyle \frac { 1 } { \mathrm { v o l } ( V ) } \left( - \sum _ { u \in V } d _ { u } \log d _ { u } + 2 \cdot \sum _ { ( u , v ) \in E } w ( u , v ) \log \mathrm { v o l } ( u \vee v ) \right) . } \end{array}
|
| 465 |
+
$$
|
| 466 |
+
|
| 467 |
+
505 The second equality follows from the fact $\begin{array} { r } { \sum _ { u \in V } d _ { u } = \sum _ { \mathrm { o r d e r e d } ( u , v ) \in E } w ( u , v ) = \mathrm { v o l } ( V ) } \end{array}$ and the
|
| 468 |
+
506 last equality from the symmetry of $( u , v )$ . Since the first summation is independent of $T$ , Proposition
|
| 469 |
+
507 2.1 follows. □
|
| 470 |
+
|
| 471 |
+
# C Proof of Proposition 2.2
|
| 472 |
+
|
| 473 |
+
We restate Proposition 2.2 as follows.
|
| 474 |
+
|
| 475 |
+
Theorem 2.2. For any positive integer n, let $K _ { n }$ be the clique of n vertices with identical weight on every edge. Then a cluster tree $T$ of $K _ { n }$ achieves minimum structural entropy if and only if $T$ is $a$ balanced binary tree, that is, the two children clusters of each sub-tree of $T$ have difference in size at most 1.
|
| 476 |
+
|
| 477 |
+
Note that a balanced binary tree (BBT for abbreviation) means the tree is balanced on every internal node. Formally, for an internal node of cluster size $k$ , its two sub-trees are of cluster sizes $\lfloor \dot { k } / 2 \rfloor$ and $\lceil k / 2 \rceil$ , respectively.
|
| 478 |
+
|
| 479 |
+
517 For cliques, since the weights of each edge are identical, we assume it safely to be 1. By Theorem
|
| 480 |
+
518 2.1, minimizing the structural entropy is equivalent to minimizing the cost function (over $T$ )
|
| 481 |
+
|
| 482 |
+
$$
|
| 483 |
+
\begin{array} { l c l } { \displaystyle \cos t ^ { T } ( G ) } & { = } & { \displaystyle \sum _ { ( u , v ) \in E } \log \mathrm { v o l } ( u \vee v ) } \\ { \displaystyle } & { = } & { \displaystyle \sum _ { ( u , v ) \in E } \log \left( ( n - 1 ) | u \vee v | \right) } \\ { \displaystyle } & { = } & { \displaystyle \sum _ { ( u , v ) \in E } \log ( n - 1 ) + \sum _ { ( u , v ) \in E } \log | u \vee v | } \end{array}
|
| 484 |
+
$$
|
| 485 |
+
|
| 486 |
+
519 Since the first term in the last equation is independent of $T$ , the optimization turns to minimizing
|
| 487 |
+
520 the last term, which we denote by $\Gamma ( T )$ . Grouping all edges in $E$ by LCA of two end-points, the
|
| 488 |
+
521 cost $\Gamma ( T )$ can be written as the sum of the cost $\gamma$ at every internal node $N$ of $T$ . Formally, for every
|
| 489 |
+
522 internal node $N$ , let $A , B \subseteq V$ be the leaves of the sub-trees rooted at the left and right child of $N$ ,
|
| 490 |
+
523 respectively. We have
|
| 491 |
+
|
| 492 |
+
$$
|
| 493 |
+
\begin{array} { r c l } { { \Gamma ( T ) } } & { { = } } & { { \displaystyle \sum _ { N } \gamma ( N ) } } \\ { { } } & { { } } & { { } } \\ { { \gamma ( N ) } } & { { = } } & { { \displaystyle \left( \sum _ { x \in A , y \in B } 1 \right) \cdot \log \left( | A | + | B | \right) } } \\ { { } } & { { } } & { { } } \\ { { } } & { { = } } & { { | A | \cdot | B | \cdot \log ( | A | + | B | ) } } \end{array}
|
| 494 |
+
$$
|
| 495 |
+
|
| 496 |
+
524 Now we only have to show the following lemma.
|
| 497 |
+
|
| 498 |
+
25 Lemma C.1. For any positive integer $n$ , a cluster tree $T$ of $K _ { n }$ achieves minimum cost $\Gamma ( T )$ if and
|
| 499 |
+
26 only if T is a BBT.
|
| 500 |
+
527 Proof. Lemma C.1 is proved by induction on $| V |$ . The key technique of tree swapping we use here
|
| 501 |
+
28 is inspired by Cohen-Addad et al [4]. The basis step holds since for $| V | = 2$ or 3, the cluster tree is
|
| 502 |
+
29 balanced and unique. It certainly achieves the minimum cost exclusively.
|
| 503 |
+
|
| 504 |
+
Now, consider a clique $G = ( V , E )$ with $n = | V | \geq 4$ . Let $T _ { 1 }$ be an arbitrary unbalanced cluster tree and $\lambda$ be its root. We need to prove that the cost $\Gamma ( T _ { 1 } )$ does not achieve the minimum. Without loss of generality, we can safely assume the root node is unbalanced, since otherwise, we set $T _ { 1 }$ to be the sub-tree that is rooted at an unbalanced node. Let $T _ { 2 }$ be a tree with root $\lambda$ whose left and right sub-trees are BBTs such that they have the same sizes with the left and right sub-trees of $T _ { 1 }$ , respectively. Let $V _ { l l }$ , $V _ { l r }$ , $V _ { r l }$ and $V _ { r r }$ be the sets of nodes on the four sub-trees at the second level of $T _ { 2 }$ and $n _ { l l }$ , $n _ { l r }$ , $n _ { r l }$ and $n _ { r r }$ denote their sizes, respectively. Our proof is also available when some of them are empty. We always assume $n _ { l l } \le n _ { l r }$ and $n _ { r l } \geq n _ { r r }$ . Next, we construct $T _ { 3 }$ by swapping (transplanting) $V _ { l r }$ and $V _ { r l }$ with each other. Finally, let $T _ { 4 }$ be a tree with root $\lambda$ whose left and right sub-trees are BBTs after balancing the left and right sub-trees of $T _ { 3 }$ . So $T _ { 4 }$ is a BBT. Then we only have to prove that $\Gamma ( T _ { 1 } ) > \Gamma ( T _ { 4 } ) \quad$ . Note that the strict $\mathit { \Theta } ^ { \bullet } > \mathit { \Theta } ^ { \bullet }$ is necessary since we need to negate all unbalanced cluster trees.
|
| 505 |
+
|
| 506 |
+
Then we show that the transformation process that consists of the above three steps makes the cost decrease step by step. Formally,
|
| 507 |
+
|
| 508 |
+
(a) $T _ { 1 }$ to $T _ { 2 }$ . The sub-trees of $T _ { 1 }$ become BBTs in $T _ { 2 }$ . Since the number of edges whose end-points treat the root as LCA is the same, by induction we have $\Gamma ( T _ { 1 } ) \geq \Gamma ( \bar { T } _ { 2 } )$ .
|
| 509 |
+
(b) $T _ { 2 }$ to $T _ { 3 }$ . We will show that $\Gamma ( T _ { 2 } ) > \Gamma ( T _ { 3 } )$ in Lemma C.2.
|
| 510 |
+
(c) $T _ { 3 }$ to $T _ { 4 }$ . The sub-trees of $T _ { 3 }$ become BBTs in $T _ { 4 }$ . For the same reason as (a), we have $\Gamma ( T _ { 3 } ) \geq \Gamma ( T _ { 4 } )$ .
|
| 511 |
+
|
| 512 |
+
Putting them together, we get $\Gamma ( T _ { 1 } ) > \Gamma ( T _ { 4 } )$ and Lemma C.1 follows.
|
| 513 |
+
|
| 514 |
+
Lemma C.2. After swapping $V _ { l r }$ and $V _ { r l }$ , we obtain $T _ { 3 }$ from $T _ { 2 }$ , for which $\Gamma ( T _ { 2 } ) > \Gamma ( T _ { 3 } )$ .
|
| 515 |
+
|
| 516 |
+
552 Proof. We only need to consider the changes in cost of three nodes: root and its left and right
|
| 517 |
+
553 children, since the cost contributed by each of the remaining nodes does not change after swapping.
|
| 518 |
+
554 Ignoring the unchanged costs, define
|
| 519 |
+
|
| 520 |
+
$$
|
| 521 |
+
\begin{array} { l l l } { { \displaystyle \mathrm { c o s t } ( T _ { 2 } ) } } & { { = } } & { { { n _ { l } } { n _ { r } } \log { n } + { n _ { l l } } { n _ { l r } } \log { n _ { l } } + { n _ { r l } } { n _ { r r } } \log { n _ { r } } } } \\ { { \displaystyle } } & { { = } } & { { { n _ { l } } { n _ { r } } \log { n } + \left\lfloor \displaystyle \frac { { n _ { l } } } { 2 } \right\rfloor \left\lceil \displaystyle \frac { { n _ { l } } } { 2 } \right\rceil \log { n _ { l } } + \left\lceil \displaystyle \frac { { n _ { r } } } { 2 } \right\rceil \left\lfloor \displaystyle \frac { { n _ { r } } } { 2 } \right\rfloor \log { n _ { r } } , } } \end{array}
|
| 522 |
+
$$
|
| 523 |
+
|
| 524 |
+
555 where $n _ { l } = n _ { l l } + n _ { l r }$ , $n _ { r } = n _ { r l } + n _ { r r }$ . Both of them are at least 1. Similarly, define
|
| 525 |
+
|
| 526 |
+
$$
|
| 527 |
+
{ \begin{array} { r c l } { \operatorname { o s t } ( T _ { 3 } ) } & { = } & { ( n _ { l l } + n _ { r l } ) ( n _ { l r } + n _ { r r } ) \log n + n _ { l l } n _ { r l } \log \left( n _ { l l } + n _ { r l } \right) + n _ { l r } n _ { r r } \log \left( n _ { l r } + n _ { r r } \right) } \\ & { = } & { \left\lfloor { \frac { n } { 2 } } \right\rfloor \left\lceil { \frac { n } { 2 } } \right\rceil \log n + \left\lfloor { \frac { n _ { l } } { 2 } } \right\rfloor \left\lceil { \frac { n _ { r } } { 2 } } \right\rceil \log \left( \left\lfloor { \frac { n _ { l } } { 2 } } \right\rfloor + \left\lceil { \frac { n _ { r } } { 2 } } \right\rceil \right) + \left\lceil { \frac { n _ { l } } { 2 } } \right\rceil \left\lfloor { \frac { n _ { r } } { 2 } } \right\rfloor \log \left( \left\lceil { \frac { n _ { l } } { 2 } } \right\rceil + \left\lfloor { \frac { n _ { r } } { 2 } } \right\rfloor \right) } \end{array} }
|
| 528 |
+
$$
|
| 529 |
+
|
| 530 |
+
556 Denote
|
| 531 |
+
|
| 532 |
+
$$
|
| 533 |
+
\begin{array} { r c l } { { \Delta } } & { { = } } & { { \Gamma ( T _ { 2 } ) - \Gamma ( T _ { 3 } ) } } \\ { { } } & { { = } } & { { \displaystyle \mathrm { c o s t } ( T _ { 2 } ) - \mathrm { c o s t } ( T _ { 3 } ) } } \\ { { } } & { { = } } & { { \displaystyle \left\lfloor \frac { n _ { l } } { 2 } \right\rfloor \left\lceil \frac { n _ { l } } { 2 } \right\rceil \log \left( \frac { n _ { l } } { n } \right) + \left\lceil \frac { n _ { r } } { 2 } \right\rceil \left\lfloor \frac { n _ { r } } { 2 } \right\rfloor \log \left( \frac { n _ { r } } { n } \right) } } \\ { { } } & { { } } & { { - \left\lfloor \frac { n _ { l } } { 2 } \right\rfloor \left\lceil \frac { n _ { r } } { 2 } \right\rceil \log \left( \frac { \left\lfloor \frac { n _ { l } } { 2 } \right\rfloor + \left\lceil \frac { n _ { r } } { 2 } \right\rceil } { n } \right) - \left\lceil \frac { n _ { l } } { 2 } \right\rceil \left\lfloor \frac { n _ { r } } { 2 } \right\rfloor \log \left( \frac { \left\lceil \frac { n _ { l } } { 2 } \right\rceil + \left\lfloor \frac { n _ { r } } { 2 } \right\rfloor } { n } \right) } } \end{array}
|
| 534 |
+
$$
|
| 535 |
+
|
| 536 |
+
557 So we only have to show that $\Delta > 0$ . We consider the following three cases according to the odevity
|
| 537 |
+
558 of $n _ { l }$ and $n _ { r }$ .
|
| 538 |
+
|
| 539 |
+
Case 1: $n _ { l }$ and $n _ { r }$ are even.
|
| 540 |
+
|
| 541 |
+
Case 2: $n _ { l }$ and $n _ { r }$ are odd.
|
| 542 |
+
|
| 543 |
+
Case 3: $n _ { l }$ is odd while $n _ { r }$ is even.
|
| 544 |
+
|
| 545 |
+
The case that $n _ { l }$ is even while $n _ { r }$ is odd is symmetric to Case 3.
|
| 546 |
+
|
| 547 |
+
63 For Case 1, if both $n _ { l }$ and $n _ { r }$ are even, then notations of rounding in Eq. (2) can be removed and $\Delta$
|
| 548 |
+
64 can be simplified as
|
| 549 |
+
|
| 550 |
+
$$
|
| 551 |
+
\Delta = \frac { n _ { l } ^ { 2 } } { 4 } \log \left( \frac { n _ { l } } { n } \right) + \frac { n _ { r } ^ { 2 } } { 4 } \log \left( \frac { n _ { r } } { n } \right) + \frac { n _ { l } n _ { r } } { 2 } .
|
| 552 |
+
$$
|
| 553 |
+
|
| 554 |
+
565 Let $p = n _ { l } / n , q = n _ { r } / n$ , and so $p + q = 1$ . Recall that $T _ { 1 }$ is unbalanced on the root $\lambda$ , so is $T _ { 2 }$ Thus 566 $p \neq q$ . Multiplying by $\textstyle { \frac { 4 } { n ^ { 2 } } }$ on both sides, we only have to prove that
|
| 555 |
+
|
| 556 |
+
$$
|
| 557 |
+
p ^ { 2 } \log p + q ^ { 2 } \log q + 2 p q > 0 .
|
| 558 |
+
$$
|
| 559 |
+
|
| 560 |
+
That is,
|
| 561 |
+
|
| 562 |
+
$$
|
| 563 |
+
\frac { p } { q } \log p + \frac { q } { p } \log q + 2 > 0 .
|
| 564 |
+
$$
|
| 565 |
+
|
| 566 |
+
Let 567 $\begin{array} { r } { g ( x ) = \frac { x } { 1 - x } \log x } \end{array}$ . Then we only need to show that $g ( p ) + g ( q ) + 2 > 0$ when $p \neq q$ . Since
|
| 567 |
+
|
| 568 |
+
$$
|
| 569 |
+
\begin{array} { r c l } { { g ^ { \prime } ( x ) } } & { { = } } & { { \displaystyle \frac { ( 1 - x ) + \ln x } { \ln 2 \cdot ( 1 - x ) ^ { 2 } } , } } \\ { { } } & { { } } & { { } } \\ { { g ^ { \prime \prime } ( x ) } } & { { = } } & { { \displaystyle - \frac { x ^ { 2 } - 2 x \ln x - 1 } { \ln 2 \cdot x ( 1 - x ) ^ { 3 } } . } } \end{array}
|
| 570 |
+
$$
|
| 571 |
+
|
| 572 |
+
It is easy to check that $g ^ { \prime \prime } ( x ) > 0$ when $0 < x < 1$ . So $g ( x )$ is strictly convex in the interval $( 0 , 1 )$ . Since $p \neq q$ ,
|
| 573 |
+
|
| 574 |
+
$$
|
| 575 |
+
g ( p ) + g ( q ) > 2 g \left( \frac { p + q } { 2 } \right) = - 2 .
|
| 576 |
+
$$
|
| 577 |
+
|
| 578 |
+
568 Thus $\Delta > 0$ holds.
|
| 579 |
+
|
| 580 |
+
569 For Case 2, if both $n _ { l }$ and $n _ { r }$ are odd, then $\Delta$ can be split into two parts $\Delta = \Delta _ { 1 } + \Delta _ { 2 }$ , in which
|
| 581 |
+
|
| 582 |
+
$$
|
| 583 |
+
\begin{array} { l c l } { \Delta _ { 1 } } & { = } & { \displaystyle \frac { n _ { l } ^ { 2 } } { 4 } \log \left( \frac { n _ { l } } { n } \right) + \frac { n _ { r } ^ { 2 } } { 4 } \log \left( \frac { n _ { r } } { n } \right) + \frac { n _ { l } n _ { r } } { 2 } } \\ { \Delta _ { 2 } } & { = } & { \displaystyle - \frac { 1 } { 4 } \log \left( \frac { n _ { l } } { n } \right) - \frac { 1 } { 4 } \log \left( \frac { n _ { r } } { n } \right) - \frac { 1 } { 2 } } \end{array}
|
| 584 |
+
$$
|
| 585 |
+
|
| 586 |
+
570 Since we have shown that $\Delta _ { 1 } > 0$ , if we can prove $\Delta _ { 2 } \geq 0$ , then the lemma will hold for Case 2.
|
| 587 |
+
571 Due to the convexity of logarithmic function, this holds clearly since
|
| 588 |
+
|
| 589 |
+
$$
|
| 590 |
+
2 \log \left( \frac { n } { 2 } \right) \geq \log n _ { l } + \log n _ { r } .
|
| 591 |
+
$$
|
| 592 |
+
|
| 593 |
+
For Case 3, if 572 $n _ { l }$ is odd while $n _ { r }$ is even,
|
| 594 |
+
|
| 595 |
+
$$
|
| 596 |
+
\Delta = \frac { n _ { l } ^ { 2 } - 1 } { 4 } \log { \left( \frac { n _ { l } } { n } \right) } + \frac { n _ { r } ^ { 2 } } { 4 } \log { \left( \frac { n _ { r } } { n } \right) } - \left[ \frac { ( n _ { l } - 1 ) n _ { r } } { 4 } \log { \left( \frac { n - 1 } { 2 n } \right) } + \frac { ( n _ { l } + 1 ) n _ { r } } { 4 } \log { \left( \frac { n + 1 } { 2 n } \right) } \right] .
|
| 597 |
+
$$
|
| 598 |
+
|
| 599 |
+
$$
|
| 600 |
+
4 \ln 2 ) \Delta = ( n _ { l } ^ { 2 } - 1 ) \ln \left( \frac { n _ { l } } { n } \right) + n _ { r } ^ { 2 } \ln \left( \frac { n _ { r } } { n } \right) - \left[ ( n _ { l } - 1 ) n _ { r } \ln \left( \frac { n - 1 } { 2 n } \right) + ( n _ { l } + 1 ) n _ { r } \ln \left( \frac { n + 1 } { 2 n } \right) \right] .
|
| 601 |
+
$$
|
| 602 |
+
|
| 603 |
+
574 Splitting the right hand side into two parts,
|
| 604 |
+
|
| 605 |
+
$$
|
| 606 |
+
\begin{array} { l c l } { { A } } & { { = } } & { { \displaystyle n _ { l } ^ { 2 } \ln \left( \frac { n _ { l } } { n } \right) + n _ { r } ^ { 2 } \ln \left( \frac { n _ { r } } { n } \right) + 2 n _ { l } n _ { r } \ln 2 } } \\ { { } } & { { } } & { { } } \\ { { B } } & { { = } } & { { \displaystyle - \ln \left( \frac { n _ { l } } { n } \right) - ( n _ { l } + 1 ) n _ { r } \ln \left( 1 + \frac { 1 } { n } \right) - ( n _ { l } - 1 ) n _ { r } \ln \left( 1 - \frac { 1 } { n } \right) } } \end{array}
|
| 607 |
+
$$
|
| 608 |
+
|
| 609 |
+
575 Since $n$ is odd and the root $\lambda$ of $T _ { 2 }$ is unbalanced, we only need to consider the case that $n _ { l } =$
|
| 610 |
+
576 $( n - i ) / 2$ , $n _ { r } = ( n + i ) / 2$ (Note that $n _ { l }$ and $n _ { r }$ are symmetric. So if $( n - i ) / 2$ is even, exchange
|
| 611 |
+
577 $n _ { l }$ and $n _ { r }$ ), where both $n$ and $i$ are odd satisfying $n > i \geq 3$ . Next we show that in this case,
|
| 612 |
+
578 $A \geq \ln ( 1 / 5 ) + 4 ^ { 2 } \ln ( 4 / 5 ) + 2 \cdot 4 \ln 2$ and $\dot { B } > \ln 2 - 3 / 4 - ( 2 / 3 ) \cdot ( 1 / 5 ^ { 2 } )$ . By calculation,
|
| 613 |
+
579 $\Delta = A + B > 0$ for Case 3.
|
| 614 |
+
|
| 615 |
+
Claim C.1. 580 $A \geq \ln ( 1 / 5 ) + 4 ^ { 2 } \ln ( 4 / 5 ) + 2 \cdot 4 \ln 2$ for odd integers $n > i \geq 3$ .
|
| 616 |
+
|
| 617 |
+
581 Proof. Substituting $n _ { l } = ( n - i ) / 2$ , $n _ { r } = ( n + i ) / 2$ into the $A$ yields
|
| 618 |
+
|
| 619 |
+
$$
|
| 620 |
+
A = C ( n , i ) \triangleq \left( { \frac { n - i } { 2 } } \right) ^ { 2 } \ln \left( { \frac { n - i } { 2 n } } \right) + \left( { \frac { n + i } { 2 } } \right) ^ { 2 } \ln \left( { \frac { n + i } { 2 n } } \right) + 2 \cdot { \frac { n - i } { 2 } } \cdot { \frac { n + i } { 2 } } \ln 2 .
|
| 621 |
+
$$
|
| 622 |
+
|
| 623 |
+
582 Treat $n$ as a continuous variable, we have
|
| 624 |
+
|
| 625 |
+
$$
|
| 626 |
+
\frac { \partial C ( n , i ) } { \partial n } = \frac { 1 } { 2 } \left[ ( n + i ) \ln \left( 1 + \frac { i } { n } \right) + ( n - i ) \ln \left( 1 - \frac { i } { n } \right) - \frac { i ^ { 2 } } { n } \right]
|
| 627 |
+
$$
|
| 628 |
+
|
| 629 |
+
583 Multiplying the above equation by $2 / n$ and setting $x = i / n$ yields
|
| 630 |
+
|
| 631 |
+
$$
|
| 632 |
+
\begin{array} { r c l } { { f ( x ) } } & { { \triangleq } } & { { \displaystyle \left( 1 + x \right) \ln ( 1 + x ) + ( 1 - x ) \ln ( 1 - x ) - x ^ { 2 } , } } \\ { { f ^ { \prime } ( x ) } } & { { = } } & { { \ln ( 1 + x ) - \ln ( 1 - x ) - 2 x , } } \\ { { f ^ { \prime \prime } ( x ) } } & { { = } } & { { \displaystyle \frac { 2 x ^ { 2 } } { 1 - x ^ { 2 } } . } } \end{array}
|
| 633 |
+
$$
|
| 634 |
+
|
| 635 |
+
584 It is easy to check that $f ( 0 ) = 0$ and $f ^ { \prime } ( 0 ) = 0$ . When $0 < x < 1$ , $f ^ { \prime \prime } ( x ) > 0$ . Thus $f ^ { \prime } ( x ) > 0$ and
|
| 636 |
+
585 $f ( x ) > 0$ . This means that $\partial C ( n , i ) / \partial n > 0$ for all $n > 0$ . So $C ( n , i ) \geq C ( i + 2 , i )$ for $n \geq i + 2$
|
| 637 |
+
586 (When $i$ is fixed, the minimum value of $n$ can be taken to $i + 2$ , which makes $n _ { l } = ( n - i ) / 2$ and
|
| 638 |
+
587 $n _ { r } = ( n + i ) / 2$ integral). The curves of $C ( n , i )$ for varying $i$ are plotted in Figure 2.
|
| 639 |
+
588 When $n = i + 2$ , we get $n _ { l } = ( n - i ) / 2 = 1$ and $n _ { r } = ( n + i ) / 2 = n - 1$ . Substituting them into
|
| 640 |
+
589 $A$ yields
|
| 641 |
+
|
| 642 |
+

|
| 643 |
+
Figure 2: Functions $C ( n , i )$
|
| 644 |
+
|
| 645 |
+
$$
|
| 646 |
+
\begin{array} { r c l } { { { \cal D } ( n ) } } & { { \triangleq } } & { { \displaystyle \ln \left( \frac { 1 } { n } \right) + ( n - 1 ) ^ { 2 } \ln \left( 1 - \frac { 1 } { n } \right) + 2 ( n - 1 ) \ln 2 , } } \\ { { \displaystyle \frac { d { \cal D } } { d n } } } & { { = } } & { { \displaystyle 1 - \frac { 2 } { n } + 2 \ln 2 + 2 ( n - 1 ) \ln \left( 1 - \frac { 1 } { n } \right) . } } \end{array}
|
| 647 |
+
$$
|
| 648 |
+
|
| 649 |
+
590 When $n > 2$ , it is easy to check that $d D / d n > 0$ . So the minimum value of $d ( n )$ , which is also the
|
| 650 |
+
591 minimum value of $\dot { C ( i + 2 , i ) }$ , is achieved at $n = i + 2 = 5$ . So $A = C ( n , i ) \geq C ( i + 2 , i ) \geq$
|
| 651 |
+
592 $C ( 5 , 3 ) = \ln ( 1 / 5 ) + 4 ^ { 2 } \ln ( 4 / 5 ) + 2 \cdot 4 \ln 2$ . □
|
| 652 |
+
|
| 653 |
+
Claim C.2. 593 $B > \ln 2 - 3 / 4 - ( 2 / 3 ) \cdot ( 1 / 5 ^ { 2 } ) .$ .
|
| 654 |
+
|
| 655 |
+
594 Proof. Due to the facts that
|
| 656 |
+
|
| 657 |
+
$$
|
| 658 |
+
{ \begin{array} { r c c c } { \ln \left( 1 + { \cfrac { 1 } { n } } \right) } & { < } & { { \cfrac { 1 } { n } } - { \cfrac { 1 } { 2 n ^ { 2 } } } + { \cfrac { 1 } { 3 n ^ { 3 } } } , } \\ { \ln \left( 1 - { \cfrac { 1 } { n } } \right) } & { < } & { - { \cfrac { 1 } { n } } - { \cfrac { 1 } { 2 n ^ { 2 } } } - { \cfrac { 1 } { 3 n ^ { 3 } } } , } \end{array} }
|
| 659 |
+
$$
|
| 660 |
+
|
| 661 |
+
595 we have
|
| 662 |
+
|
| 663 |
+
$$
|
| 664 |
+
\begin{array} { r c l } { B } & { = } & { \displaystyle - \ln \left( \frac { n _ { l } } { n } \right) - ( n _ { l } + 1 ) n _ { r } \ln \left( 1 + \frac { 1 } { n } \right) - ( n _ { l } - 1 ) n _ { r } \ln \left( 1 - \frac { 1 } { n } \right) } \\ & { > } & { \displaystyle - \ln \left( \frac { n _ { l } } { n } \right) + \frac { n _ { l } n _ { r } } { n ^ { 2 } } - \frac { 2 n _ { r } } { n } - \frac { 2 n _ { r } } { 3 n ^ { 3 } } } \\ & { > } & { \displaystyle - \ln \left( \frac { n _ { l } } { n } \right) + \frac { n _ { l } n _ { r } } { n ^ { 2 } } - \frac { 2 n _ { r } } { n } - \frac { 2 } { 3 n ^ { 2 } } . } \end{array}
|
| 665 |
+
$$
|
| 666 |
+
|
| 667 |
+
596 Let $\alpha = n _ { l } / n$ , then
|
| 668 |
+
|
| 669 |
+
$$
|
| 670 |
+
\begin{array} { l l l } { { B } } & { { > } } & { { \displaystyle - \ln \alpha + \alpha ( 1 - \alpha ) - 2 ( 1 - \alpha ) - \frac { 2 } { 3 n ^ { 2 } } } } \\ { { } } & { { \geq } } & { { \ln 2 - \displaystyle \frac { 3 } { 4 } - \frac { 2 } { 3 n ^ { 2 } } . } } \end{array}
|
| 671 |
+
$$
|
| 672 |
+
|
| 673 |
+
When 597 $n \geq 5$ $5 , B > \ln 2 - 3 / 4 - ( 2 / 3 ) \cdot ( 1 / 5 ^ { 2 } )$ .
|
| 674 |
+
|
| 675 |
+
8 Combining Claims C.1 and C.2, Lemma C.2 follows.
|
| 676 |
+
|
| 677 |
+
99 This completes the proof of Proposition 2.2.
|
| 678 |
+
|
| 679 |
+
# 600 D Proof of Theorem 3.1
|
| 680 |
+
|
| 681 |
+
Proof. Note that $\operatorname { c o s t } ^ { T } ( G )$ for any cluster tree $T$ has a trivial upper bound. That is,
|
| 682 |
+
|
| 683 |
+
$$
|
| 684 |
+
\cos \mathsf { t } ^ { T } ( G ) = \sum _ { e \in E } \mathsf { c o s t } ^ { T } ( e ) \leq \sum _ { e \in E } w _ { e } \cdot \log ( \mathsf { v o l } ( G ) ) \leq \frac { \mathsf { v o l } ( G ) \cdot \log ( \mathsf { v o l } ( G ) ) } { 2 } ,
|
| 685 |
+
$$
|
| 686 |
+
|
| 687 |
+
601 where $\mathrm { c o s t } ^ { T } ( e ) = w _ { e } \log \mathrm { v o l } ( \mathrm { L C A } _ { T } ( e ) )$ . Let $T ^ { * }$ be the optimal cluster tree that achieves the mini
|
| 688 |
+
602 mum cost, we present here a lower bound for $\mathrm { c o s t } ^ { T ^ { * } } ( G )$ . Referring to the dense branch technique
|
| 689 |
+
603 [10, 15], we start with the root node $A _ { 0 }$ and walk along $T ^ { * }$ recursively as follows: at every internal
|
| 690 |
+
604 node $A _ { i }$ , walk down to the node $A _ { i + 1 }$ of higher volume between its two children. This process stops
|
| 691 |
+
605 when we reach node $A _ { k }$ such that $\begin{array} { r } { \mathrm { v o l } _ { G } ( A _ { k } ) \le \frac { 2 \mathrm { v o l } ( G ) } { 3 } } \end{array}$ 2vol(G)3 . Denote A ≜ Ak as well as B ≜ V \Ak. By
|
| 692 |
+
606 construction, it holds that $\begin{array} { r } { \mathrm { v o l } _ { G } ( A ) > \frac { \mathrm { v o l } ( G ) } { 3 } } \end{array}$ and $\begin{array} { r } { \mathrm { v o l } _ { G } ( B ) \geq \frac { \mathrm { v o l } ( G ) } { 3 } } \end{array}$ . Moreover, $\begin{array} { r } { \mathrm { v o l } _ { G } ( A _ { i } ) > \frac { 2 \mathrm { v o l } ( G ) } { 3 } } \end{array}$
|
| 693 |
+
|
| 694 |
+
607 for every $0 \leq i < k$ . The basic idea behind the dense branch is that the $c u t ( A , B )$ has a significant contribution to 608 $c o s t ^ { T ^ { * } } ( G )$ .
|
| 695 |
+
|
| 696 |
+
$$
|
| 697 |
+
\begin{array} { r l } { c o s t ^ { T ^ { * } } ( G ) = \displaystyle \sum _ { e = \{ u , v \} } w _ { e } \cdot \log ( \mathsf { v o l } _ { G } ( u \vee v ) ) } & { } \\ { \ge \displaystyle \sum _ { e = \{ u , v \} } w _ { e } \cdot \log ( \mathsf { v o l } _ { G } ( u \vee v ) ) } & { } \\ { ~ } & { \displaystyle \sum _ { e \in E \{ A , B \} } \log \left( \frac { 2 \mathsf { v o l } ( G ) } { 3 } \right) . } \\ { ~ } & { \ge w ( A , B ) \cdot \log \left( \frac { 2 \mathsf { v o l } ( G ) } { 3 } \right) . } \\ { ~ } & { \ge \Phi ( G ) \cdot \displaystyle \frac { \mathsf { v o l } ( G ) } { 3 } \cdot \log \left( \frac { 2 \mathsf { v o l } ( G ) } { 3 } \right) . } \end{array}
|
| 698 |
+
$$
|
| 699 |
+
|
| 700 |
+
Let $T$ be an arbitrary cluster tree, and $T ^ { * }$ be an optimal tree. We have
|
| 701 |
+
|
| 702 |
+
$$
|
| 703 |
+
\frac { c o s t ^ { T } ( G ) } { c o s t ^ { T * } ( G ) } \leq \frac { 3 } { 2 \Phi ( G ) } \cdot \frac { \log ( \mathrm { v o l } ( G ) ) } { \log \left( \frac { 2 \mathrm { v o l } ( G ) } { 3 } \right) } = O ( \Phi ( G ) ^ { - 1 } ) .
|
| 704 |
+
$$
|
| 705 |
+
|
| 706 |
+
609
|
| 707 |
+
|
| 708 |
+
# 610 E Proof of Theorem 3.2
|
| 709 |
+
|
| 710 |
+
Proof. To prove Theorem 3.2, we only have to prove the following lemma. Then the theorem follows from a simplification of the approximation factor.
|
| 711 |
+
|
| 712 |
+
Lemma E.1. Let $\alpha ~ = ~ \operatorname* { m a x } _ { i } \{ \Phi _ { G } ( P _ { i } ) \}$ and $\beta ~ = ~ \mathrm { \ m i n } _ { i } \{ \Phi ( G [ P _ { i } ] ) \}$ . Algorithm 2 achieves $\begin{array} { r } { \bigg ( \Big ( \Big ( \log \Big ( \frac { 1 } { 1 - \alpha } \Big ) + 1 \Big ) + \frac { 2 \alpha } { 1 - \alpha } \left( 1 + \log \frac { k } { 1 - \alpha } \right) \Big ) \cdot \frac { 3 } { 2 \beta \log \left( \frac { 4 } { 3 } \right) } \bigg ) } \end{array}$ -approximation.
|
| 713 |
+
|
| 714 |
+
Proof. We group the edges of $\mathbf { G }$ into two categories: let $E _ { 1 }$ be the set of edges in the induced subgraphs $G [ P _ { i } ]$ for all $1 \leq i \leq l$ , i.e.,
|
| 715 |
+
|
| 716 |
+
$$
|
| 717 |
+
E _ { 1 } \triangleq \cup _ { i = 1 } ^ { l } E [ G [ P _ { i } ] ] ,
|
| 718 |
+
$$
|
| 719 |
+
|
| 720 |
+
and $E _ { 2 }$ be the remaining crossing edges. Then we have
|
| 721 |
+
|
| 722 |
+
$$
|
| 723 |
+
\mathrm { c o s t } ^ { T } ( G ) = \sum _ { e \in E _ { 1 } } \mathrm { c o s t } ^ { T } ( e ) + \sum _ { e \in E _ { 2 } } \mathrm { c o s t } ^ { T } ( e ) .
|
| 724 |
+
$$
|
| 725 |
+
|
| 726 |
+
We denote by ${ \mathrm { v o l } } ( G [ P _ { i } ] )$ the volume of the induced graph $G [ P _ { i } ]$ , by ${ \mathrm { v o l } } _ { G } ( P _ { i } )$ the volume of $P _ { i }$ in $G$ , and by parent $^ T ( \dot { P _ { i } } )$ the parent of $P _ { i }$ on $T$ . Then it holds for every $P _ { i }$ that
|
| 727 |
+
|
| 728 |
+
$$
|
| 729 |
+
\operatorname { v o l } _ { G } ( { \mathrm { p a r e n t } } ^ { T } ( P _ { i } ) ) \leq k \cdot \operatorname { v o l } _ { G } ( P _ { i } ) .
|
| 730 |
+
$$
|
| 731 |
+
|
| 732 |
+
By the construction of $T$ we have that
|
| 733 |
+
|
| 734 |
+
$$
|
| 735 |
+
\operatorname { v o l } _ { G } ( { \mathrm { p a r e n t } } ^ { T } ( P _ { i } ) ) = \sum _ { j = 1 } ^ { i } \operatorname { v o l } _ { G } ( P _ { j } ) \leq i \cdot \operatorname { v o l } _ { G } ( P _ { i } ) \leq k \cdot \operatorname { v o l } _ { G } ( P _ { i } ) .
|
| 736 |
+
$$
|
| 737 |
+
|
| 738 |
+
Note that
|
| 739 |
+
|
| 740 |
+
$$
|
| 741 |
+
\begin{array} { r l } & { w ( P _ { i } , V \backslash P _ { i } ) = \mathsf { v o l } _ { G } ( P _ { i } ) - \mathsf { v o l } ( G [ P _ { i } ] ) \leq \alpha \cdot \mathsf { v o l } _ { G } ( P _ { i } ) , } \\ & { \qquad ( 1 - \alpha ) \cdot \mathsf { v o l } _ { G } ( P _ { i } ) \leq \mathsf { v o l } ( G [ P _ { i } ] ) , } \end{array}
|
| 742 |
+
$$
|
| 743 |
+
|
| 744 |
+
and thus
|
| 745 |
+
|
| 746 |
+
$$
|
| 747 |
+
\operatorname { v o l } _ { G } ( { \mathrm { p a r e n t } } ^ { T } ( P _ { i } ) ) \leq k \cdot \operatorname { v o l } _ { G } ( P _ { i } ) \leq { \frac { k } { 1 - \alpha } } { \mathrm { v o l } } ( G [ P _ { i } ] ) .
|
| 748 |
+
$$
|
| 749 |
+
|
| 750 |
+
615 Combining the above, we have that
|
| 751 |
+
|
| 752 |
+
$$
|
| 753 |
+
\begin{array} { r c l } { \displaystyle \sum _ { \boldsymbol { \alpha } \in E _ { 1 } } \cos ^ { T } ( \boldsymbol { \epsilon } ) } & { \le } & { \displaystyle \sum _ { \boldsymbol { \epsilon } \in E _ { 1 } } w _ { \boldsymbol { \epsilon } } \cdot \log ( \mathsf { v o l } _ { G } ( P _ { i } ) ) } \\ & { \le } & { \displaystyle \sum _ { \boldsymbol { \epsilon } \in E _ { 1 } } w _ { \boldsymbol { \epsilon } } \cdot \log \left( \frac { 1 } { 1 - \boldsymbol { \alpha } } \operatorname { v o l } ( G [ P _ { i } ] ) \right) } \\ & { = } & { \displaystyle \sum _ { \boldsymbol { \epsilon } \in E _ { 1 } } \left( w _ { \boldsymbol { \epsilon } } \cdot \log \frac { 1 } { 1 - \boldsymbol { \alpha } } + w _ { \boldsymbol { \epsilon } } \cdot \log ( \operatorname { v o l } ( G [ P _ { i } ] ) ) \right) } \\ & { \le } & { \displaystyle \left( \log \frac { 1 } { 1 - \boldsymbol { \alpha } } + 1 \right) \cdot \sum _ { j = 1 } ^ { k } \frac { \operatorname { v o l } ( G [ P _ { i } ] ) \cdot \log ( \operatorname { v o l } ( G [ P _ { i } ] ) ) } { 2 } , } \end{array}
|
| 754 |
+
$$
|
| 755 |
+
|
| 756 |
+
616 and
|
| 757 |
+
|
| 758 |
+
$$
|
| 759 |
+
\begin{array} { r c l } { \displaystyle \sum _ { e \in E _ { 2 } } \cos \mathrm { t r } ^ { T } ( e ) } & { \le } & { \displaystyle \sum _ { j = 1 } ^ { k } w ( P _ { 1 } , V \backslash P _ { k } ) \cdot \log ( \mathsf { w d } _ { G } ( \mathsf { p a r e n t } ^ { T } ( P _ { i } ) ) ) } \\ & { \le } & { \displaystyle \sum _ { j = 1 } ^ { k } \frac { \alpha } { 1 - \alpha } \mathrm { v o l } ( G [ P _ { i } ] ) \log \left( \frac { k } { 1 - \alpha } \mathrm { v o l } ( G [ P _ { i } ] ) \right) } \\ & { \le } & { \displaystyle \sum _ { j = 1 } ^ { k } \frac { \alpha } { 1 - \alpha } \left( 1 + \log \frac { k } { 1 - \alpha } \right) \mathrm { v o l } ( G [ P _ { i } ] ) \log ( \mathsf { w l } ( G [ P _ { i } ] ) ) } \\ & { = } & { \displaystyle \frac { 2 \alpha } { 1 - \alpha } \left( 1 + \log \frac { k } { 1 - \alpha } \right) \cdot \displaystyle \sum _ { j = 1 } ^ { k } \frac { \mathrm { v o l } ( G [ P _ { i } ] ) \cdot \log ( \mathrm { w d } ( G [ P _ { i } ] ) ) } { 2 } . } \end{array}
|
| 760 |
+
$$
|
| 761 |
+
|
| 762 |
+
Let $T ^ { * }$ be the optimal cluster tree of $G$ , and $O P T _ { G }$ be the optimal value. We have
|
| 763 |
+
|
| 764 |
+
$$
|
| 765 |
+
O P T _ { G } = \mathsf { c o s t } _ { G } ( T ^ { * } ) \geq \sum _ { i = 1 } ^ { l } \sum _ { e \in E ( G [ P _ { i } ] ) } \mathsf { c o s t } _ { T ^ { * } } ( e ) \geq \sum _ { i = 1 } ^ { l } O P T _ { G [ P _ { i } ] } .
|
| 766 |
+
$$
|
| 767 |
+
|
| 768 |
+
Denote by
|
| 769 |
+
|
| 770 |
+
$$
|
| 771 |
+
h ( \alpha , k ) = \left( \left( \log \left( \frac { 1 } { 1 - \alpha } \right) + 1 \right) + \frac { 2 \alpha } { 1 - \alpha } \left( 1 + \log \frac { k } { 1 - \alpha } \right) \right) .
|
| 772 |
+
$$
|
| 773 |
+
|
| 774 |
+
617 We have
|
| 775 |
+
|
| 776 |
+
$$
|
| 777 |
+
\begin{array} { l l l } { \displaystyle \mathrm { c o s s } ^ { T } ( G ) } & { = } & { \displaystyle \sum _ { s \in { \bar { \mathbb { E } } } _ { k } } \mathrm { c o s s } ^ { T } ( e ) + \sum _ { s \in { \bar { \mathbb { E } } } _ { k } } \mathrm { c o s s } ^ { T } ( e ) } \\ { \ } & { \le } & { \displaystyle \hbar ( \alpha , k ) \cdot \sum _ { j = 1 } ^ { k } \frac { \sum _ { w \in [ 0 , 1 ] } \cdot 1 - \log ( \mathrm { c } ( P _ { k } | ) ) } { 2 } } \\ { \ } & { \le } & { \displaystyle \hbar ( \alpha , k ) \cdot \sum _ { j = 1 } ^ { k } \frac { \log ( | G | P _ { k , j } | ) \cdot 1 - \log ( \mathrm { c } ( P _ { k } | ) | ) } { 2 } } \\ { \ } & { \displaystyle \le } & { \displaystyle \hbar ( \alpha , k ) \cdot \sum _ { j = 1 } ^ { k } \frac { \log ( | G | P _ { k , j } | ) \cdot 1 - \log ( \mathrm { c } ( P _ { k } | ) | ) } { 2 \sqrt { 6 } ( P _ { k } | ) \cdot 1 - | G | ( G | P _ { k , j } | ) \cdot 1 - \log ( \mathrm { c } ( P _ { k } | ) | ) } { 2 \sqrt { 6 } ( P _ { k } | ) \cdot 1 - | G | ( P _ { k , j } | ) } { 2 \sqrt { 6 } ( P _ { k } | ) \cdot 1 - | G | ( P _ { k , j } | ) } { 2 \sqrt { 6 } ( P _ { k } | ) \cdot 1 - | G | ( P _ { k , j } | ) } } \\ { \ } & { \displaystyle \le } & { \displaystyle \hbar ( \alpha , k ) \cdot \operatorname* { m a x } _ { i } \frac { \log ( | G | P _ { k , j } | ) ) } { 2 \sqrt { 6 } ( P _ { k } | ) \cdot 1 - | G | ( P _ { k , j } | ) \cdot 1 - | G | ( P _ { k , j } | ) } \sum _ { j = 1 } ^ { k } { \cal P } { \cal T } _ { [ 0 , k ] } } \\ { \ } & { \displaystyle \le } & \displaystyle \hbar ( \alpha , k ) \cdot \operatorname* { m a x } _ { i } \frac { \sum _ { w \in [ 0 , 1 ] } \cdot | \log ( \mathrm { c } ( P _ { k } | ) | ) } { 2 \sqrt { 6 } ( P _ { k , j } | ) \cdot 1 - | G | ( P _ { k , j } | ) \cdot 1 - | G | ( P _ { k , j } | ) } \\ { \ } & { \displaystyle \le } & \end{array}
|
| 778 |
+
$$
|
| 779 |
+
|
| 780 |
+
618 Lemma E.1 follows.
|
| 781 |
+
|
| 782 |
+
Note that 619 $\begin{array} { r } { h ( \alpha , k ) = O \left( \frac { 1 } { ( 1 - \alpha ) } \log \frac { k } { 1 - \alpha } \right) } \end{array}$ , Theorem 3.2 follows.
|
| 783 |
+
|
| 784 |
+
621 We do our experiments on Amazon network 4 for which the set of ground-truth clusters has been
|
| 785 |
+
622 given. For two sets $A , B$ , the Jaccard Index of them is defined as $J ( \bar { A } , B ) = | A \cap B | / | A \cup B |$ . We
|
| 786 |
+
623 pick the largest cluster which is a subgraph with 58283 vertices and 133178 edges. We run HCSE
|
| 787 |
+
624 algorithm on it. For each ground-truth cluster $c$ that appears in this subgraph, we find from the
|
| 788 |
+
625 resulting cluster tree an internal node that has maximum Jaccard index with $c$ . Then we calculate
|
| 789 |
+
626 the average Jaccard index $\overline { J }$ over all such $c$ . We also calculate cost(SE) and cost(Das). The results
|
| 790 |
+
627 are demonstrated in Table 3. HCSE performs better for $\overline { J }$ and cost(SE), while LOUVAIN performs
|
| 791 |
+
628 better for cost(Das). Because of unbalance in over-fitting and under-fitting traps, HLP outperforms
|
| 792 |
+
629 none of the other two algorithms for all criteria.
|
| 793 |
+
|
| 794 |
+
<table><tr><td>index</td><td>HCSE</td><td>HLP</td><td>LOUVAIN</td></tr><tr><td>J</td><td>0.20</td><td>0.16</td><td>0.17</td></tr><tr><td>cost(SE)</td><td>1.85E6</td><td>2.05E6</td><td>1.89E6</td></tr><tr><td>cost(Das)</td><td>5.57E8</td><td>3.99E8</td><td>3.08E8</td></tr></table>
|
| 795 |
+
|
| 796 |
+
# 630 G Some figures and pseudocodes
|
| 797 |
+
|
| 798 |
+

|
| 799 |
+
Table 3: Comparisons of the average Jaccard index $( { \overline { { J } } } )$ , cost function based on structural entropy (cost(SE)) and Dasgupta’s cost function (cost(Das)).
|
| 800 |
+
Figure 3: Illustrations of stretch and compress for a $u$ -triangle. A binary cluster tree is constructed first by stretch, and then edge $e$ is compressed, which yields a non-binary tree.
|
| 801 |
+
|
| 802 |
+

|
| 803 |
+
Figure 4: Illustration of stratification for a 2-level cluster tree. The preference of (a) and (b) depends on the average sparsity of triangles at each level.
|
| 804 |
+
|
| 805 |
+
# Algorithm 5: Stretch
|
| 806 |
+
|
| 807 |
+
Input: a $u$ -triangle $T _ { u }$
|
| 808 |
+
Output: a binary tree rooted at $u$
|
| 809 |
+
1 Let $\{ v _ { 1 } , v _ { 2 } , \ldots , v _ { \ell } \}$ be the set of leaves of $T _ { u }$ ;
|
| 810 |
+
2 Compute $\eta ( a , b )$ which is the cost reduced by merging siblings $a , b$ into a single cluster;
|
| 811 |
+
3 for $t \in [ \ell - 1 ]$ do
|
| 812 |
+
4 $( \alpha , \beta ) \gets \mathrm { a r g m a x } _ { ( a , b ) }$ are siblings $\{ \eta ( a , b ) \}$ ;
|
| 813 |
+
5 Add a new node $\gamma$ ;
|
| 814 |
+
6 $\gamma . p a r e n t \alpha$ .parent;
|
| 815 |
+
7 $\alpha . p a r e n t = \gamma$ ;
|
| 816 |
+
8 $\beta . p a r e n t = \gamma$ ;
|
| 817 |
+
9 return $T _ { u }$
|
| 818 |
+
|
| 819 |
+
# Algorithm 6: Compress
|
| 820 |
+
|
| 821 |
+
Input: a binary tree $T$
|
| 822 |
+
1 while $T$ ’s height is more than 2 do
|
| 823 |
+
2 $e \gets \arg \operatorname* { m i n } _ { e ^ { \prime } \in \hat { E } ( T ) } \{ \Delta ( e ^ { \prime } ) \}$ ;
|
| 824 |
+
3 Denote $\boldsymbol { e } = ( u , v )$ where $u$ is the parent of $v$ ;
|
| 825 |
+
4 for $w \in v$ .children do
|
| 826 |
+
5 ${ \_ } \psi . p a r e n t u .$ ;
|
| 827 |
+
6 Delete $v$ from $T$ ;
|
md/dev/MR7XubKUFB/MR7XubKUFB.md
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ADVERSARIAL RETRIEVER-RANKER FOR DENSE TEXT RETRIEVAL
|
| 2 |
+
|
| 3 |
+
Hang Zhang1∗, Yeyun Gong2†, Yelong Shen3, Jiancheng $\mathbf { L } \mathbf { v } ^ { 1 }$ , Nan Duan2, Weizhu Chen3
|
| 4 |
+
|
| 5 |
+
1College of Computer Science, Sichuan University,
|
| 6 |
+
2Microsoft Research Asia, 3Microsoft Azure AI
|
| 7 |
+
hangzhang scu@foxmail.com,{yegong,yelong.shen}@microsoft.com,
|
| 8 |
+
lvjiancheng@scu.edu.cn, {nanduan,wzchen}@microsoft.com
|
| 9 |
+
|
| 10 |
+
# ABSTRACT
|
| 11 |
+
|
| 12 |
+
Current dense text retrieval models face two typical challenges. First, they adopt a siamese dual-encoder architecture to encode queries and documents independently for fast indexing and searching, while neglecting the finer-grained termwise interactions. This results in a sub-optimal recall performance. Second, their model training highly relies on a negative sampling technique to build up the negative documents in their contrastive losses. To address these challenges, we present Adversarial Retriever-Ranker (AR2), which consists of a dual-encoder retriever plus a cross-encoder ranker. The two models are jointly optimized according to a minimax adversarial objective: the retriever learns to retrieve negative documents to cheat the ranker, while the ranker learns to rank a collection of candidates including both the ground-truth and the retrieved ones, as well as providing progressive direct feedback to the dual-encoder retriever. Through this adversarial game, the retriever gradually produces harder negative documents to train a better ranker, whereas the cross-encoder ranker provides progressive feedback to improve retriever. We evaluate AR2 on three benchmarks. Experimental results show that AR2 consistently and significantly outperforms existing dense retriever methods and achieves new state-of-the-art results on all of them. This includes the improvements on Natural Questions $\mathbf { R } @ 5$ to $7 7 . 9 \%$ $( + 2 . 1 \% )$ , TriviaQA $\mathbf { R } @ 5$ to $7 8 . { \bar { 2 } } \%$ $( + 1 . 4 \% )$ , and MS-MARCO MRR $@ 1 0$ to $3 9 . 5 \%$ $( + 1 . 3 \% )$ . Code and models are available at https://github.com/microsoft/AR2.
|
| 13 |
+
|
| 14 |
+
# 1 INTRODUCTION
|
| 15 |
+
|
| 16 |
+
Dense text retrieval (Lee et al., 2019; Karpukhin et al., 2020) has achieved great successes in a wide variety of both research and industrial areas, such as search engines (Brickley et al., 2019; Shen et al., 2014), recommendation system (Hu et al., 2020), open-domain question answering (Guo et al., 2018; Liu et al., 2020), etc. A typical dense retrieval model adopts a dual-encoder (Huang et al., 2013) architecture to encode queries and documents into low-dimensional embedding vectors, with the relevance between query and document being measured by the similarity between embeddings. In real-world dense text retrieval applications, it pre-computes all the embedding vectors of documents in the corpus, and leverages the approximate nearest neighbor (ANN) (Johnson et al., 2019) technique for efficiency. To train a dense retriever, contrastive loss with negative samples is widely applied in the literature (Xiong et al., 2021; Karpukhin et al., 2020). During training, the model utilizes a negative sampling method to obtain negative documents for a given querydocument pair, and then minimizes the contrastive loss which relies on both the positive document and the sampled negative ones (Shen et al., 2014; Chen et al., 2017; Radford et al., 2021).
|
| 17 |
+
|
| 18 |
+
Recent studies on contrastive learning (Xiong et al., 2021; Karpukhin et al., 2020) show that the iterative “hard-negative” sampling technique can significantly improve the performance compared with “random-negative” sampling approach, as it can pick more representative negative samples to … …learn a more discriminative retriever. In the work (Qu et al., 2021), it suggests leveraging crossquery documentencoder model to heuristically filter “hard-negative” samples to further improve performance and shows the importance of sampling technique in the contrastive learning.
|
| 19 |
+
|
| 20 |
+

|
| 21 |
+
Figure 1: Illustration of two modules in AR2. (a) Retriever: query and document are encoded independently by a dual-encoder. (b) Ranker: concatenated, jointly encoded by a cross-encoder.
|
| 22 |
+
|
| 23 |
+
On the other hand, the model architecture of dual-encoders enables the encoding of queries and documents independently which is essential for document indexing and fast retrieval. However, this ignores the modeling of finer-grained interactions between queries and documents which could be a sub-optimal solution in terms of retrieval accuracy.
|
| 24 |
+
|
| 25 |
+
Motivated by these phenomena, we propose an Adversarial Retriever-Ranker (AR2) framework. The intuitive idea of AR2 is inspired by the “retriever-ranker” architecture in the classical information retrieval systems. AR2 consists of two modules: a dual-encoder model served as the retrieval module in Figure 1a and a cross-encoder model served as the ranker module in Figure 1b. The crossencoder model takes the concatenation of a query and document as input text, and can generate more accurate relevance scores compared with the dual-encoder model, since it can fully explore the interactions between the query and document through a self-attention mechanism using a conventional transformer model (Vaswani et al., 2017; Guo et al., 2020). Instead of training “retriever-ranker” modules independently in some IR systems (Manning et al., 2008; Mitra & Craswell, 2017), AR2 constructs a unified minimax game for training the retriever and ranker models interactively, as shown in Figure 2.
|
| 26 |
+
|
| 27 |
+
In particular, AR2 adopts a minimax objective from the adversarial game (Goodfellow et al., 2014) where the retrieval model is optimized to produce relevant documents to fool the ranker model, whereas the ranker model learns to distinguish the ground-truth relevant document and retrieved ones by its opponent retrieval model. Within the adversarial “retriever-ranker” training framework, the retrieval model receives the smooth training signals from the ranker model which helps alleviate the harmful effects of “false-negative” issues. For example, a “false-negative” example which is rated as high-relevance by the ranker model, will also be granted with high probability by retrieval model in order to fool the ranker, meanwhile the ranker model with better generalization capability is more resistant to label noises compared to the retrieval model.
|
| 28 |
+
|
| 29 |
+
In the empirical studies of AR2, we further introduce a distillation regularization approach to help stabilize/improve the training of the retriever. Intuitively, the retriever would converge to sharp conditionalprobabilities over documents given a query within the adversarial training framework, i.e., high retrieval probabilities for the top relevant documents and near-zero retrieval ones for the rest. However, it is not a desirable property as it might impede exploring different documents during training. Thus, we incorporate the distillation loss between the retriever and ranker models as a smooth term for further improvement.
|
| 30 |
+
|
| 31 |
+

|
| 32 |
+
Figure 2: Illustration of the AR2 training pipeline. $q , d ,$ , and $\mathbb { D } _ { q } ^ { - }$ represent the query, positive document, and retrieved documents, respectively.
|
| 33 |
+
|
| 34 |
+
In experiments, we evaluate AR2 on three widely used benchmarks for dense text retrieval: Natural Questions, Trivia QA and MS-MARCO. Experimental results show that AR2 achieves state-of-theart performance on all these datasets. Meanwhile, we provide a comprehensive ablation study to demonstrate the advantage of different AR2 components.
|
| 35 |
+
|
| 36 |
+
# 2 PRELIMINARIES
|
| 37 |
+
|
| 38 |
+
Dense Text Retrieval: We mainly consider a contrastive-learning paradigm for dense text retrieval in this work, where the training set consists of a collection of text pairs. $C = \{ ( q _ { 1 } , d _ { 1 } ) , . . . , ( q _ { n } , d _ { n } ) \}$ . In the scenario of open-domain question answering, a text pair $( q , d )$ refers to a question and a corresponding document which contains the answer. A typical dense retrieval model adopts a dual encoder architecture, where questions and documents are represented as dense vectors separately and the relevance score $s _ { \theta } ( q , d )$ between them is measured by the similarity between their embeddings:
|
| 39 |
+
|
| 40 |
+
$$
|
| 41 |
+
s _ { \theta } ( q , d ) = \langle E ( q ; \theta ) , E ( d ; \theta ) ) \rangle
|
| 42 |
+
$$
|
| 43 |
+
|
| 44 |
+
where $E ( \cdot ; \theta )$ denotes the encoder module parameterized with $\theta$ , and $\langle \cdot \rangle$ is the similarity function, e.g., inner-product, Euclidean distance. Based on the embeddings, existing solutions generally leverage on-the-shelf fast ANN-search (Johnson et al., 2019) for efficiency.
|
| 45 |
+
|
| 46 |
+
A conventional contrastive-learning algorithm could be applied for training the dual encoders (Shen et al., 2014; Chen et al., 2017; Liu et al., 2020). For example, given a training instance $( q , d )$ , we select $n$ negative irrelevant documents $( d _ { 1 } ^ { - } , . . . , d _ { n } ^ { - } )$ (denoted as $\mathbb { D } _ { q } ^ { - }$ ) to optimize the loss function of the negative log likelihood of the positive document:
|
| 47 |
+
|
| 48 |
+
$$
|
| 49 |
+
L _ { \theta } ( q , d , \mathbb { D } _ { q } ^ { - } ) = - \mathrm { l o g } \frac { e ^ { \tau s _ { \theta } ( q , d ) } } { e ^ { \tau s _ { \theta } ( q , d ) } + \sum _ { i = 1 } ^ { n } e ^ { \tau s _ { \theta } ( q , d _ { i } ^ { - } ) } }
|
| 50 |
+
$$
|
| 51 |
+
|
| 52 |
+
where $\tau$ is a hyper-parameter to control the temperature. Previous works (Shen et al., 2014; Chen et al., 2017; Liu et al., 2020) present an effective strategy on negative document sampling, called “InBatch Negatives” where negative documents are randomly sampled from a collection of documents which are within the same mini-batch as question-document training pairs.
|
| 53 |
+
|
| 54 |
+
Recently, some studies e.g., ANCE (Xiong et al., 2021) and Condenser (Gao & Callan, 2021b), have shown that selecting “hard-negatives” in the training can significantly improve the retrieval performance in open-domain question answering. For example, instead of sampling negative document randomly, “hard-negatives” are iteratively retrieved through previous checkpoints of the dual encoder model. However, a more recent work RocketQA (Qu et al., 2021) continues to point out that the retrieved “hard-negatives” could potential be “false-negatives” in some cases, which might limit the performance.
|
| 55 |
+
|
| 56 |
+
Generative Adversarial Network: GANs have been widely studied for generating the realisticlooking images in computation vision (Goodfellow et al., 2014; Brock et al., 2018). In the past few years, the idea of GANs has been applied in information retrieval (Wang et al., 2017). For example, IRGAN (Wang et al., 2017), proposes a minimax retrieval framework which constructs two types of IR models: a generative retrieval model and a discriminative retrieval model. The two IR models are optimized through a minimax game: the generative retrieval model generates relevant documents that look like ground-truth relevant documents to fool the discriminative retrieval model, whereas the discriminative retrieval model learns to draw a clear distinction between the groundtruth relevant documents and the generated ones made by its opponent generative retrieval model. The minimax objective is formulated as:
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
\begin{array} { r } { J ^ { G ^ { * } , D ^ { * } } = \operatorname* { m i n } _ { \theta } \operatorname* { m a x } _ { \phi } \mathrm { E } _ { d \sim p _ { \mathrm { t w e } } ( \cdot \vert q ) } \left[ \log D _ { \phi } ( d , q ) \right] + \mathrm { E } _ { d ^ { - } \sim G _ { \theta } ( \cdot \vert q ) } \left[ \log \left( 1 - D _ { \phi } ( d ^ { - } , q ) \right) \right] } \end{array}
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
where $G _ { \theta } ( \cdot | q )$ and $D _ { \phi } ( d ^ { - } , q )$ denote the generative retrieval model and discriminative retrieval model in IRGAN, respectively. It is worth noting the original IRGAN model doesn’t work for dense retrieval tasks as it doesn’t contain the dual-encoder model for document indexing or fast retrieval.
|
| 63 |
+
|
| 64 |
+
# 3 METHOD
|
| 65 |
+
|
| 66 |
+
In this section, we introduce the proposed adversarial retriever-ranker (AR2) approach. It consists of two modules: the dual-encoder retriever module $G _ { \theta }$ as in Figure 1a, and the cross-encoder ranker module $D _ { \phi }$ as in Figure 1b. $G _ { \theta }$ and $D _ { \phi }$ computes the relevance score between question and document as follows:
|
| 67 |
+
|
| 68 |
+
$$
|
| 69 |
+
\begin{array} { r l } & { G _ { \theta } ( q , d ) = E _ { \theta } ( q ) ^ { T } E _ { \theta } ( d ) } \\ & { D _ { \phi } ( q , d ) = \mathbf { w _ { \phi } } ^ { T } E _ { \phi } \left( [ q , d ] \right) } \end{array}
|
| 70 |
+
$$
|
| 71 |
+
|
| 72 |
+
where $E _ { \theta } ( \cdot )$ and $E _ { \phi } ( \cdot )$ are language model encoders which can be initialized with any pre-trained language model, $\mathbf { w } _ { \phi }$ is the linear projector in $D _ { \phi }$ , and $[ q , d ]$ is the concatenation of question and document.
|
| 73 |
+
|
| 74 |
+
In AR2, the retriever and ranker modules are optimized jointly through a contrastive minimax objective:
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
J ^ { G ^ { * } , D ^ { * } } = \operatorname* { m i n } _ { \theta } \mathrm { m a x } _ { \phi } { \bf E } _ { \mathbb { D } _ { q } ^ { - } \sim G _ { \theta } ( q , \cdot ) } \left[ \log p _ { \phi } ( d | q ; \mathbb { D } _ { q } ) \right]
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
where $\mathbb { D } _ { q } ^ { - } \colon \{ d _ { i } ^ { - } \} _ { i = 1 } ^ { n }$ is the set of $n$ negative documents sampled by $G _ { \theta } ( \boldsymbol { q } , \cdot )$ given $q$ , and $p _ { \phi } ( d | q ; \mathbb { D } _ { q } )$ denotes the probability of selecting the ground-truth document $d$ from the document set $\mathbb { D } _ { q }$ $\mathbb { D } _ { q } =$ $\{ d \} \cup \mathbb { D } _ { q } ^ { - } )$ by the ranker module $D _ { \phi }$ ;
|
| 81 |
+
|
| 82 |
+
$$
|
| 83 |
+
p _ { \phi } ( d | q ; \mathbb { D } _ { q } ) = \frac { e ^ { \tau D _ { \phi } ( q , d ) } } { \sum _ { d ^ { \prime } \in \mathbb { D } _ { q } } e ^ { \tau D _ { \phi } ( q , d ^ { \prime } ) } }
|
| 84 |
+
$$
|
| 85 |
+
|
| 86 |
+
According to the objective function (Eqn. 5), the dual-encoder retrieval model $G _ { \theta } ( \boldsymbol { q } , \cdot )$ would try to sample the high-relevant documents to fool the ranker model, whereas the ranker model $D _ { \phi } ( q , \cdot )$ is optimized to draw distinctions between ground-truth passage and the ones sampled by $G _ { \theta } ( q , \cdot )$ . We present the illustration of the AR2 framework in Figure 2. In order to optimize the minimax objective function, we adopt a conventional iterative-learning mechanism to optimize the retriever and ranker modules coordinately.
|
| 87 |
+
|
| 88 |
+
# 3.1 TRAINING THE RANKER $D _ { \phi }$
|
| 89 |
+
|
| 90 |
+
Given the fixed retriever $G _ { \theta }$ , the ranker model $D _ { \phi }$ is updated by maximizing the log likelihood of selecting ground-truth $d$ from set $\mathbb { D } _ { q }$ given a query $q$ :
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
\begin{array} { r } { \phi ^ { * } = \mathrm { a r g m a x } _ { \phi } \log p _ { \phi } ( d | q ; \mathbb { D } _ { q } ) } \end{array}
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
where $\mathbb { D } _ { q }$ consists of ground-truth document $d$ and negative document set $\mathbb { D } _ { q } ^ { - }$ . $\mathbb { D } _ { q } ^ { - }$ is sampled by $G _ { \theta }$ according to Eqn. 5. In experiments, we first retrieve top-100 negative documents, and then randomly sample $n$ examples from them to obtain $\mathbb { D } _ { q } ^ { - }$ .
|
| 97 |
+
|
| 98 |
+
# 3.2 TRAINING RETRIEVER $G _ { \theta }$
|
| 99 |
+
|
| 100 |
+
With fixing the ranker $D _ { \phi }$ , the model parameters $\theta ^ { * }$ for the retriever $G _ { \theta }$ is optimized by minimizing the expectation of log likelihood of function. In particular, by isolating $\theta$ from the minimax function (Eqn. 5), the objective for the retriever can be written as:
|
| 101 |
+
|
| 102 |
+
$$
|
| 103 |
+
\theta ^ { * } = \operatorname * { a r g m i n } _ { \theta } J ^ { \theta } = \mathbf { E } _ { \mathbb { D } _ { q } ^ { - } \sim G _ { \theta } ( q , \cdot ) } \left[ \log p _ { \phi } ( d | q ; \mathbb { D } _ { q } ) \right]
|
| 104 |
+
$$
|
| 105 |
+
|
| 106 |
+
However, it is intractable to optimize $\theta$ directly through Eqn. 8, as the computation of probability $\mathbb { D } _ { q } ^ { - } \sim G _ { \theta } ( q , \cdot )$ does not follow a close form. Thus, we seek to minimize an alternative upper-bound of the loss criteria:
|
| 107 |
+
|
| 108 |
+
$$
|
| 109 |
+
J ^ { \theta } \leq \hat { J } ^ { \theta } = \mathbf { E } _ { d ^ { - } \sim p _ { \theta } ( \cdot | q ; \mathbb { D } _ { q } ^ { - } ) } \left[ \log p _ { \phi } ( d | q ; \{ d , d ^ { - } \} ) \right]
|
| 110 |
+
$$
|
| 111 |
+
|
| 112 |
+
The detailed deviation of Eqn. 9 is provided in the Appendix A.1. Therefore, the gradient of parameter $\theta$ can be computed as the derivative of ${ \hat { J } } ^ { \theta }$ with respect to $\theta$ :
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\nabla _ { \theta } \hat { J } ^ { \theta } = \mathbf { E } _ { d ^ { - } \sim p _ { \theta } ( \cdot | q ; \mathbb { D } _ { q } ^ { - } ) } \nabla _ { \theta } \log p _ { \theta } ( d ^ { - } | q ; \mathbb { D } _ { q } ^ { - } ) \left[ \log p _ { \phi } ( d | q ; \{ d , d ^ { - } \} ) \right]
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
Require: Retriever $G _ { \theta }$ ; Ranker $D _ { \phi }$ ; Document pool $\mathbb { D }$ ; Training dataset $C$ .
|
| 119 |
+
1: Initialize the retriever $G _ { \theta }$ and the ranker $D _ { \phi }$ with pre-trained language models.
|
| 120 |
+
2: Train the warm-up retriever $G _ { \theta } ^ { 0 }$ on training dataset $C$ .
|
| 121 |
+
3: Build ANN index on $\mathbb { D }$
|
| 122 |
+
4: Retrieve negative samples on $\mathbb { D }$ .
|
| 123 |
+
5: Train the warm-up ranker $D _ { \theta } ^ { 0 }$
|
| 124 |
+
6: while AR2 has not converged do
|
| 125 |
+
7: for Retriever training step do
|
| 126 |
+
8: Sample $n$ documents $\{ d _ { i } ^ { - } \} _ { n }$ from ANN index.
|
| 127 |
+
9: Update parameters of the retriever $G _ { \theta }$ .
|
| 128 |
+
10: end for
|
| 129 |
+
11: Refresh ANN Index.
|
| 130 |
+
12: for Ranker training step do
|
| 131 |
+
13: Sample $n$ hard negatives $\{ d _ { i } ^ { - } \} _ { n }$ from ANN index.
|
| 132 |
+
14: Update parameters of the ranker $D _ { \phi }$ .
|
| 133 |
+
15: end for
|
| 134 |
+
16: end while
|
| 135 |
+
|
| 136 |
+
Here, the same approach is applied to obtain set $\mathbb { D } _ { q } ^ { - }$ as in Eqn. 7.
|
| 137 |
+
|
| 138 |
+
Regularization: we further introduce a distillation regularization term in $G _ { \theta }$ ’s training, which encourages the retriever model to distill from the ranker model.
|
| 139 |
+
|
| 140 |
+
$$
|
| 141 |
+
J _ { \mathcal { R } } ^ { \theta } = H ( p _ { \phi } ( \cdot | q ; \mathbb { D } ) , p _ { \theta } ( \cdot | q ; \mathbb { D } ) )
|
| 142 |
+
$$
|
| 143 |
+
|
| 144 |
+
$H ( \cdot )$ is the cross entropy function. $p _ { \phi } ( \cdot | q ; \mathbb { D } )$ and $p _ { \theta } ( \cdot | q ; \mathbb { D } )$ denote the conditional probabilities of document in the whole corpus $\mathbb { D }$ by the ranker and the retriever model, respectively. In practice, we also limit the sampling space over documents to a fixed set, i.e., $\mathbb { D } _ { q } = { \bar { \{ d \} } } \cup { \bar { \mathbb { D } } } _ { q } ^ { - }$ . Thus the regularization loss for the retriever model can be rewritten as:
|
| 145 |
+
|
| 146 |
+
$$
|
| 147 |
+
J _ { \mathcal { R } } ^ { \theta } = H \left( p _ { \phi } ( \cdot | q ; \mathbb { D } _ { q } ) , p _ { \theta } ( \cdot | q ; \mathbb { D } _ { q } ) \right)
|
| 148 |
+
$$
|
| 149 |
+
|
| 150 |
+
# 3.3 INDEX REFRESH
|
| 151 |
+
|
| 152 |
+
During each training iteration of retriever and ranker models in AR2, we refresh the document index to keep the retrieved document set updated. To build the document index, we take the document encoder from the retrieval model to compute the embeddings $E ( d ; \theta )$ for every document $d$ from the corpus: $d \in C$ , and then build the inner-product based ANN search index with FAISS tool.
|
| 153 |
+
|
| 154 |
+
In summary, Algorithm 1 shows the full implementation details of the proposed AR2.
|
| 155 |
+
|
| 156 |
+
# 4 EXPERIMENTS
|
| 157 |
+
|
| 158 |
+
# 4.1 DATASETS
|
| 159 |
+
|
| 160 |
+
We conduct experiments on three popular benchmarks: Natural Questions (Kwiatkowski et al., 2019), Trivia QA (Joshi et al., 2017), and MS-MARCO Passage Ranking (Nguyen et al., 2016).
|
| 161 |
+
|
| 162 |
+
Natural Questions (NQ) collects real questions from the Google search engine and each question is paired with an answer span and golden passages from the Wikipedia pages. In NQ, the goal of the retrieval stage is to find positive passages from a large passage pool. We report Recall of top- $k$ $( \mathbb { R } ^ { \circledcirc \mathrm { k } ) }$ , which represents the proportion of top k retrieved passages that contain the answers.
|
| 163 |
+
|
| 164 |
+
Trivia QA is a reading comprehension corpus authored by trivia enthusiasts. Each sample is a hquestion, answer, evidencei triple. In the retrieval stage, the goal is to find passages that contain the answer. We also use Recall of top- $k$ as the evaluation metric for Trivia QA.
|
| 165 |
+
|
| 166 |
+
MS-MARCO Passage Ranking is widely used in information retrieval. It collects real questions from the Bing search engine. Each question is paired with several web documents. Following previous works (Ren et al., 2021; Qu et al., 2021), we report MRR $@ 1 0$ , $\mathrm { R @ 5 0 }$ , ${ \textrm { R @ 1 k } }$ on the dev set. Mean Reciprocal Rank (MRR) is the mean of Reciprocal Rank(RR) across questions, calculated as the reciprocal of the rank where the first relevant document was retrieved.
|
| 167 |
+
|
| 168 |
+
Table 1: The comparison of the first-stage retrieval performance on Natural Questions test set, Trivia QA test set, and MS-MARCO dev set. The results of the first two blocks are from published papers. If the results are not provided, we mark them as “-”.
|
| 169 |
+
|
| 170 |
+
<table><tr><td></td><td colspan="3">Natural Questions</td><td colspan="3">Trivia QA</td><td colspan="3">MS-MARCO</td></tr><tr><td></td><td>R@5</td><td>R@20</td><td>R@100</td><td>R@5</td><td>R@20</td><td>R@100</td><td>MRR@10</td><td>R@50</td><td>R@1k</td></tr><tr><td>BM25 (Yang et al.,2017)</td><td>-</td><td>59.1</td><td>73.7</td><td>-</td><td>66.9</td><td>76.7</td><td>18.7</td><td>59.2</td><td>85.7</td></tr><tr><td>GAR (Mao et al., 2021a)</td><td>60.9</td><td>74.4</td><td>85.3</td><td>73.1</td><td>80.4</td><td>85.7</td><td>-</td><td>=</td><td></td></tr><tr><td>doc2query (Nogueira et al.,2019b)</td><td></td><td>=</td><td>=</td><td></td><td></td><td>1</td><td>21.5</td><td>64.4</td><td>89.1</td></tr><tr><td>DeepCT (Dai& Callan,2019)</td><td>=</td><td>=</td><td>-</td><td>=</td><td></td><td>-</td><td>24.3</td><td>69.0</td><td>91.0</td></tr><tr><td>docTTTTTquery (Nogueira et al.,2019a)</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>27.7</td><td>75.6</td><td>94.7</td></tr><tr><td>DPR (Karpukhin et al.,2020)</td><td>-</td><td>78.4</td><td>85.3</td><td>-</td><td>79.3</td><td>84.9</td><td>-</td><td>-</td><td></td></tr><tr><td>ANCE (Xiong et al.,2021)</td><td>-</td><td>81.9</td><td>87.5</td><td></td><td>80.3</td><td>85.3</td><td>33.0</td><td>-</td><td>95.9</td></tr><tr><td>RDR(Yang& Seo,2020)</td><td>=</td><td>82.8</td><td>88.2</td><td>=</td><td>82.5</td><td>87.3</td><td></td><td>-</td><td></td></tr><tr><td>ColBERT(Khattab & Zaharia,2020)</td><td>=</td><td>-</td><td>1</td><td>=</td><td>-</td><td>-</td><td>36.0</td><td>82.9</td><td>96.8</td></tr><tr><td>RocketQA (Qu et al.,2021)</td><td>74.0</td><td>82.7</td><td>88.5</td><td>=</td><td></td><td>-</td><td>37.0</td><td>85.5</td><td>97.9</td></tr><tr><td>COIL (Gao et al.,2021)</td><td>-</td><td>1</td><td>-</td><td>=</td><td></td><td></td><td>35.5</td><td>-</td><td>96.3</td></tr><tr><td>ME-BERT(Luan et al.,2021)</td><td>=</td><td>-</td><td>=</td><td>-</td><td>-</td><td>-</td><td>33.8</td><td>1</td><td>-</td></tr><tr><td>Joint Top-k(Sachan et al.,2021a)</td><td>72.1</td><td>81.8</td><td>87.8</td><td>74.1</td><td>81.3</td><td>86.3</td><td>-</td><td></td><td>=</td></tr><tr><td>Individual Top-k (Sachan et al.,2021a)</td><td>75.0</td><td>84.0</td><td>89.2</td><td>76.8</td><td>83.1</td><td>87.0</td><td></td><td>-</td><td>-</td></tr><tr><td>PAIR (Ren et al., 2021) DPR-PAQ (Oguz et al., 2021)</td><td>74.9</td><td>83.5</td><td>89.1</td><td>-</td><td></td><td>1</td><td>37.9</td><td>86.4</td><td>98.2</td></tr><tr><td>-BERTbase</td><td>74.5</td><td>83.7</td><td>88.6</td><td>=</td><td>=</td><td>=</td><td>31.4</td><td>=</td><td>=</td></tr><tr><td>-RoBERTabase</td><td>74.2</td><td>84.0</td><td>89.2</td><td></td><td></td><td>=</td><td>31.1</td><td>=</td><td>=</td></tr><tr><td>Condenser(Gao & Callan,2021b)</td><td>-</td><td>83.2</td><td>88.4</td><td>-</td><td>81.9</td><td>86.2</td><td>36.6</td><td></td><td>97.4</td></tr><tr><td>coCondenser (Gao & Callan,2021a)</td><td>75.8</td><td>84.3</td><td>89.0</td><td>76.8</td><td>83.2</td><td>87.3</td><td>38.2</td><td>-</td><td>98.4</td></tr><tr><td>AR2-G0</td><td>69.7</td><td>80.8</td><td>87.1</td><td>74.4</td><td>81.7</td><td>86.6</td><td>34.8</td><td>84.2</td><td>98.0</td></tr><tr><td>AR2-G</td><td>77.9</td><td>86.0</td><td>90.1</td><td>78.2</td><td>84.4</td><td>87.9</td><td>39.5</td><td>87.8</td><td>98.6</td></tr></table>
|
| 171 |
+
|
| 172 |
+
# 4.2 IMPLEMENTATION DETAILS
|
| 173 |
+
|
| 174 |
+
First step, we follow the experiments in Sachan et al. (2021b) and Gao & Callan (2021a) to continuous pre-training the ERNIE-2.0-base model (Sun et al., 2020) with Inverse Cloze Task (ICT) training (Lee et al., 2019) for NQ and TriviaQA datasets, and coCondenser training (Gao & Callan, 2021a) for MS-MARCO dataset.
|
| 175 |
+
|
| 176 |
+
Second step, we follow the experiment settings of DPR (Karpukhin et al., 2020) to train a warm-up dual-encoder retrieval model $\mathbf { \dot { G } ^ { 0 } }$ . It is initialized with the continuous pretrained ERNIE-2.0-based model we obtained in step one. Then we train a warm-up cross-encoder model $\mathbf { D ^ { 0 } }$ initialized with the ERNIE-2.0-Large. $\hat { \mathbf { D } } ^ { \mathbf { 0 } }$ learns to rank the Top- $\mathbf { \nabla \cdot k }$ documents selected by $\mathbf { G } ^ { 0 }$ with contrastive learning. The detailed hyper-parameters in training are listed in Appendix A.3.
|
| 177 |
+
|
| 178 |
+
Third step, we iteratively train the ranker (AR2-D) model initialized with ERNIE-2.0-large and the retriever (AR2-G) initialized with $\mathbf { G } ^ { 0 }$ according to Algorithm 1. The number of training iterations is set to 10. During each iteration of training, the retriever model is scheduled to train with $1 5 0 0 \mathrm { { m i n i } }$ batches, while the ranker model is scheduled to train with 500 mini-batches. The document index is refreshed after each iteration of training. The other hyper-parameters are shown in Appendix A.3.
|
| 179 |
+
|
| 180 |
+
All the experiments in this work run on 8 NVIDIA Tesla A100 GPUs. The implementation code of AR2 is based on Huggingface Transformers (Wolf et al., 2020) utilizing gradient checkpointing (Chen et al., 2016), Apex1, and gradient accumulation to reduce GPU memory consumption.
|
| 181 |
+
|
| 182 |
+
# 4.3 RESULTS
|
| 183 |
+
|
| 184 |
+
Performance of Retriever AR2-G: The comparison of retrieval performance on NQ, Trivia QA, and MS-MARCO are presented in Table 1.
|
| 185 |
+
|
| 186 |
+
We compare AR2-G with previous state-of-the-art methods, including sparse and dense retrieval models. The top block shows the performance of sparse retrieval methods. BM25 (Yang et al., 2017) is a traditional sparse retriever based on the exact term matching. DeepCT (Dai & Callan, 2019) uses
|
| 187 |
+
|
| 188 |
+
Table 2: Performance of rankers before and after AR2 training on NQ test set.
|
| 189 |
+
|
| 190 |
+
<table><tr><td>Retriever</td><td>Ranker</td><td>R@1</td><td>R@5</td><td>R@10</td></tr><tr><td>AR2-G0</td><td>- AR2-D0 AR2-D</td><td>48.3 60.6 64.2</td><td>69.7 78.7 79.0</td><td>76.2 82.6</td></tr><tr><td>AR2-G</td><td>- AR2-D0 AR2-D</td><td>58.7 61.1 65.6</td><td>77.9 80.1 81.5</td><td>82.6 82.5 84.3 84.9</td></tr></table>
|
| 191 |
+
|
| 192 |
+
Table 3: Performance of AR2-G on NQ test set with different negative sample size $n$ .
|
| 193 |
+
|
| 194 |
+
<table><tr><td></td><td>R@1</td><td>R@5</td><td>R@20</td><td>R@100</td><td>Latency</td></tr><tr><td>n=1</td><td>56.3</td><td>76.4</td><td>85.3</td><td>89.7</td><td>210ms</td></tr><tr><td>n=5</td><td>57.8</td><td>76.9</td><td>85.3</td><td>89.7</td><td>330ms</td></tr><tr><td>n=7</td><td>58.0</td><td>77.2</td><td>85.2</td><td>89.7</td><td>396ms</td></tr><tr><td>n=11</td><td>58.0</td><td>77.1</td><td>85.4</td><td>89.8</td><td>510ms</td></tr><tr><td>n=15</td><td>57.8</td><td>77.3</td><td>85.6</td><td>90.1</td><td>630ms</td></tr></table>
|
| 195 |
+
|
| 196 |
+
Table 4: Comparison of AR2 and IRGAN.
|
| 197 |
+
|
| 198 |
+
<table><tr><td></td><td>R@1</td><td>R@5</td><td>R@20</td><td>R@100</td></tr><tr><td>AR2</td><td>58.7</td><td>77.9</td><td>86.0</td><td>90.1</td></tr><tr><td>IRGAN</td><td>55.2</td><td>75.2</td><td>84.5</td><td>89.2</td></tr></table>
|
| 199 |
+
|
| 200 |
+
Table 5: Effect of regularization in AR2.
|
| 201 |
+
|
| 202 |
+
<table><tr><td></td><td>R@1</td><td>R@5</td><td>R@20</td><td>R@100</td><td>Entropy</td></tr><tr><td>AR2-G</td><td>58.7</td><td>77.9</td><td>86.0</td><td>90.1</td><td>2.10</td></tr><tr><td>-w/oR</td><td>57.8</td><td>77.3</td><td>85.6</td><td>90.1</td><td>1.70</td></tr></table>
|
| 203 |
+
|
| 204 |
+
BERT to dynamically generate lexical weights to augment BM25 Systems. doc2Query (Nogueira et al., 2019b), docTTTTTQuery (Nogueira et al., 2019a), and GAR (Mao et al., 2021a) use text generation to expand queries or documents to make better use of BM25. The middle block lists the results of strong dense retrieval methods, including DPR (Karpukhin et al., 2020), ANCE (Xiong et al., 2021), RDR (Yang & Seo, 2020), RocketQA (Qu et al., 2021), Joint and Individual Top- $\mathbf { \nabla } \cdot \mathbf { k }$ (Sachan et al., 2021a), PAIR (Ren et al., 2021), DPR-PAQ (Oguz et al., 2021), Condenser (Gao & Callan, ˘ 2021b). coCondenser (Gao & Callan, 2021a), ME-BERT (Luan et al., 2021), CoIL (Gao et al., 2021). These methods improve the performance of dense retrieval by constructing hard negative samples, jointly training the retriever and downstream tasks, pre-training, knowledge distillation, and multi-vector representations.
|
| 205 |
+
|
| 206 |
+
The bottom block in Table 1 shows the results of proposed AR2 models. AR2- $\mathbf { G } ^ { 0 }$ refers to the warm-up retrieval model in AR2 (details can be found in section 4.2) which leverages the existing continuous pre-training technique for dense text retrieval tasks. i.e., it shows a better performance compared with DPR (Karpukhin et al., 2020) and ANCE (Xiong et al., 2021), etc approaches that do not adopt the continuous pre-training procedure. We also observed that AR2-G: the retrieval model trained with the adversary framework, significantly outperforms the warm-up AR2- $\mathbf { G } ^ { 0 }$ model, and achieves new state-of-the-art performance on all three datasets.
|
| 207 |
+
|
| 208 |
+
# 4.4 ANALYSIS
|
| 209 |
+
|
| 210 |
+
In this section, we conduct a set of detailed experiments on analyzing the proposed AR2 training framework to help understand its pros and cons.
|
| 211 |
+
|
| 212 |
+
Performance of Ranker AR2-D: To evaluate the performance of ranker AR2-D on NQ, we first retrieve the top-100 documents for each query in the test set with the help of dual-encoder AR2- $\mathbf { G }$ model, and then re-rank them with the scores produced by the AR2-D model. The results are shown in Table 2. “-” represents without ranker. ${ \bf A } { \bf R } { \bf \Lambda } ^ { 2 - { \bf D } ^ { 0 } }$ refers to the warm-up ranker model in AR2. The results show that the ranker obtains better performance compared with only using retriever. It suggests that we could use a two-stage ranking strategy to further boost the retrieval performance. Comparing the results of AR2-D and $\mathbf { \Delta } \mathbf { A } \mathbf { R } \mathbf { \hat { \mathbf { \xi } } } \mathbf { - } \mathbf { \bar { D } } ^ { 0 }$ , we further find that the ranker AR2- $\mathbf { D }$ gets a significant gain with adversarial training.
|
| 213 |
+
|
| 214 |
+
Impact of Negative Sample Size: In the training of AR2, the number of negative documents $n$ would affect both the model performance and training time. In Table 3, we show the performance and the training latency per batch with different negative sample size $n$ . In this setting, we evaluate AR2 without the regularization term. We observe the improvement over $\mathbb { R } \ @ 1$ and $\mathbf { R } @ 5$ by increasing $n$ from 1 to 7, and marginal improvement when keep increasing $n$ from 7 to 15. The latency of training per batch is almost linear increased by improving $n$ .
|
| 215 |
+
|
| 216 |
+
Comparison with IRGAN: The original IRGAN (Wang et al., 2017) doesn’t work for dense text retrieval tasks as it does not contain the dual-encoder retrieval model for fast document indexing and search. However, it provides an conventional GAN framework for training the generative and discriminative models jointly for IR tasks. To compare the proposed AR2 with IRGAN, we replaced the generative and discriminative models in IRGAN with the retriever and ranker models in AR2, respectively. Therefore, with the configuration of the same model architectures for generator (retriever) and discriminator (ranker), The performance of the retriever is shown in Table 4. We see that AR2 outperforms IRGAN significantly.
|
| 217 |
+
|
| 218 |
+

|
| 219 |
+
Figure 3: NQ $\mathbf { R } @ 5$ on the number of iteration for both the AR2-retriever and the AR2-ranker.
|
| 220 |
+
|
| 221 |
+

|
| 222 |
+
Figure 4: The comparison of ANCE and AR2 on NQ test set.
|
| 223 |
+
|
| 224 |
+
Table 6: The results of the second-stage ranking on Natural Questions test set. Note that we copy the numbers of the first block from the RIDER paper (Mao et al., 2021b).
|
| 225 |
+
|
| 226 |
+
<table><tr><td>Retriever</td><td>Ranker</td><td>R@1</td><td>R@5</td><td>R@10</td><td>R@20</td><td>R@50</td><td>R@100</td></tr><tr><td>GAR+ (Mao et al., 2021a)</td><td>1</td><td>46.8</td><td>70.7</td><td>77.0</td><td>81.5</td><td>1</td><td>88.9</td></tr><tr><td>GAR+ (Mao et al., 2021a)</td><td>BERT</td><td>51.4</td><td>67.6</td><td>75.7</td><td>82.4</td><td>1</td><td>88.9</td></tr><tr><td>GAR+ (Mao et al., 2021a)</td><td>BART</td><td>55.2</td><td>73.5</td><td>78.5</td><td>82.2</td><td>1</td><td>88.9</td></tr><tr><td>GAR+ (Mao et al., 2021a)</td><td>RIDER</td><td>53.5</td><td>75.2</td><td>80.0</td><td>83.2</td><td>1</td><td>88.9</td></tr><tr><td>AR2-G</td><td>-</td><td>58.7</td><td>77.9</td><td>82.5</td><td>86.0</td><td>88.5</td><td>90.1</td></tr><tr><td>AR2-G</td><td>AR2-D</td><td>65.6</td><td>81.5</td><td>84.9</td><td>87.2</td><td>89.5</td><td>90.1</td></tr></table>
|
| 227 |
+
|
| 228 |
+
Effect of Regularization: To study the effectiveness of regularization, we conducted ablation studies by removing the regularization term in the training of retrieval model. In Table 5, $" R "$ refers to the regularization item, it shows that the regularization approach helps to improve the $\mathbf { R } \ @ 1$ and $\mathbf { R } @ 5$ evaluation metrics. In additional, we compute the average entropy of distribution $p _ { \theta } ( \cdot | q , d , \mathbb { D } _ { q } )$ on the NQ test set, where $\mathbb { D } _ { q }$ is the retrieved top-15 documents. The average entropy measures the sharpness of distribution $p _ { \theta } \dot { ( \cdot | } q , d , \mathbb { D } _ { q } )$ . In experiments, the average entropies for with $R$ and w/o $R$ in AR2-G are 2.10 and 1.70 respectively. This indicates that the regularization term could help smooth the prediction of probabilities in the retriever.
|
| 229 |
+
|
| 230 |
+
Visualization of the Training Procedure: We visualize the changes of $\mathbf { R } @ 5$ during the AR2- $\mathbf { G }$ training. The result is shown in Figure 3. We see that as adversarial iteration increases, the $\mathbf { R } @ 5$ of both AR2-retriever and AR2-ranker also gradually increases. AR2-retriever has the most significant improvement (about $4 . 5 \%$ ) after the first iteration. While the training advances closer to the convergence, the improvement of $\mathbf { R } @ 5$ also gradually slows down. In the end, AR2-retriever is improved by approximately $8 \%$ and AR2-ranker is improved by approximately $3 \%$ .
|
| 231 |
+
|
| 232 |
+
Adversarial Training versus Iterative Hard-Negative Sampling: To give a fair comparison of AR2 and ANCE (Xiong et al., 2021), we retrain the ANCE model by initializing it with the same warm-up ${ \bf A } { \bf R } 2 – { \bf G } ^ { \bf 0 }$ which leverages the advantage of the continuous pre-training technique. In experiments, ANCE trains the retriever with an iterative hard-negative sampling approach instead of adversarial training in AR2. In Figure 4, we observe that AR2 steadily outperforms ANCE during training in terms of $\mathbf { R } @ 5$ and $\mathrm { R @ 1 0 }$ evaluation metrics with the same model-initialization. It shows that AR2 is a superior training framework compared with ANCE.
|
| 233 |
+
|
| 234 |
+
Performance of the Pipeline: We evaluate the performance of the retrieve-then-rank pipeline on NQ dataset. The results are shown in Table 6. $\mathrm { G A R ^ { + } }$ is a sparse retriever which ensembles GAR (Mao et al., 2021a) and DPR (Karpukhin et al., 2020). BERT (Nogueira & Cho, 2019), BART (Nogueira et al., 2020), and RIDER (Mao et al., 2021b) are three ranking methods. BERT ranker is a cross-encoder, which makes a binary relevance decision for each query-passage pair.
|
| 235 |
+
|
| 236 |
+
BART ranker generates relevance labels as target tokens in a seq2seq manner. RIDER re-ranks the retrieved passages based on the lexical overlap with the top predicted answers from the reader. The results show that AR2 pipeline significantly outperforms existing public pipelines.
|
| 237 |
+
|
| 238 |
+
# 5 RELATED WORK
|
| 239 |
+
|
| 240 |
+
Text Retrieval: Text retrieval aims to find related documents from a large corpus given a query.
|
| 241 |
+
Retrieval-then-rank is the widely used pipeline (Huang et al., 2020; Zou et al., 2021).
|
| 242 |
+
|
| 243 |
+
For the first stage retrieval, early researchers used sparse vector space models, e.g., BM25 (Yang et al., 2017). Recently, some works improve the traditional sparse retriever with neural network, e.g., Dai & Callan (2019) use BERT to dynamically generate term weights, doc2Query (Nogueira et al., 2019b), docTTTTTQuery (Nogueira et al., 2019a), and GAR (Mao et al., 2021a) use text generation to expand queries or documents to make better use of BM25.
|
| 244 |
+
|
| 245 |
+
Recently, dense retrieval methods have become a new paradigm for the first stage of retrieval. Various methods have been proposed to enhance dense retrieval, e.g., DPR (Karpukhin et al., 2020) and ME-BERT (Luan et al., 2021) use in-batch negatives and construct hard negatives by BM25; ANCE (Xiong et al., 2021), RocketQA (Qu et al., 2021), and ADORE (Zhan et al., 2021) improve the hard negative sampling by iterative replacement, denoising, and dynamic sampling, respectively; PAIR (Ren et al., 2021) leverages passage-centric similarity relation into training object; FID-KD (Izacard & Grave, 2020) and RDR (Yang & Seo, 2020) distill knowledge from reader to retriever; Guu et al. (2020) and Sachan et al. (2021b) enhance retriever by jointly training with downstream tasks. Some researchers focus on the pre-training of dense retrieval, such as ICT (Lee et al., 2019), Condenser (Gao & Callan, 2021b) and Cocondenser (Gao & Callan, 2021a).
|
| 246 |
+
|
| 247 |
+
For the second stage ranking, previous works typically use cross-encoder based methods. The crossencoder models which capture the token-level interactions between the query and the document (Guo et al., 2016; Xiong et al., 2017), have shown to be more effective. Various methods are proposed to enhance ranker, e.g., Nogueira & Cho (2019) use BERT to make a binary relevance decision for each query-passage pair; Nogueira et al. (2020) adopt BART to generate relevance labels as target tokens in a seq2seq manner; Khattab & Zaharia (2020) and Gao et al. (2020) adopt the lightweight interaction based on the representations of dense retrievers to reduce computation. However, negative samples are statically sampled in these works. In AR2, negative samples for training the ranker will be dynamically adjusted with the progressive retriever.
|
| 248 |
+
|
| 249 |
+
Generative Adversarial Nets: Generative Adversarial Nets (Goodfellow et al., 2014) have been widely studied in the generation field, i.e., image generation (Brock et al., 2018) and text generation (Yu et al., 2017). With a minimax game, GAN aims to train a generative model to fit the real data distribution under the guidance of a discriminative model. Few works study GAN to text retrieval. A related work is IRGAN (Wang et al., 2017). It proposes a minimax retrieval framework that aims to unify the generative and discriminative retrieval models.
|
| 250 |
+
|
| 251 |
+
# 6 CONCLUSION
|
| 252 |
+
|
| 253 |
+
In this paper, we introduce AR2, an adversarial retriever-ranker framework to jointly train the end-toend retrieve-then-rank pipeline. In AR2, the retriever retrieves hard negatives to cheat the ranker, and the ranker learns to rank the collection of positives and hard negatives while providing progressive rewards to the retriever. AR2 can iteratively improve the performance of both the retriever and the ranker because (1) the retriever is guided by the progressive ranker; (2) the ranker learns better through the harder negatives sampled by the progressive retriever. AR2 achieves new state-of-the-art performance on all three competitive benchmarks.
|
| 254 |
+
|
| 255 |
+
# Acknowledgement
|
| 256 |
+
|
| 257 |
+
This work is supported by the National Natural Science Fund for Distinguished Young Scholar (Grant No. 61625204), and partially supported by the Key Program of National Science Foundation of China (Grant No. 61836006).
|
| 258 |
+
|
| 259 |
+
# REFERENCES
|
| 260 |
+
|
| 261 |
+
Dan Brickley, Matthew Burgess, and Natasha Noy. Google dataset search: Building a search engine for datasets in an open web ecosystem. In WWW, 2019.
|
| 262 |
+
|
| 263 |
+
Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. In ICLR, 2018.
|
| 264 |
+
|
| 265 |
+
Danqi Chen, Adam Fisch, Jason Weston, and Antoine Bordes. Reading wikipedia to answer opendomain questions. In ACL, 2017.
|
| 266 |
+
|
| 267 |
+
Tianqi Chen, Bing Xu, Chiyuan Zhang, and Carlos Guestrin. Training deep nets with sublinear memory cost. arXiv preprint arXiv:1604.06174, 2016.
|
| 268 |
+
|
| 269 |
+
Zhuyun Dai and Jamie Callan. Deeper text understanding for ir with contextual neural language modeling. In SIGIR, 2019.
|
| 270 |
+
|
| 271 |
+
Luyu Gao and Jamie Callan. Unsupervised corpus aware language model pre-training for dense passage retrieval. arXiv preprint arXiv:2108.05540, 2021a.
|
| 272 |
+
|
| 273 |
+
Luyu Gao and Jamie Callan. Is your language model ready for dense representation fine-tuning? arXiv preprint arXiv:2104.08253, 2021b.
|
| 274 |
+
|
| 275 |
+
Luyu Gao, Zhuyun Dai, and Jamie Callan. Modularized transfomer-based ranking framework. In EMNLP, 2020.
|
| 276 |
+
|
| 277 |
+
Luyu Gao, Zhuyun Dai, and Jamie Callan. COIL: revisit exact lexical match in information retrieval with contextualized inverted list. In NAACL-HLT, 2021.
|
| 278 |
+
|
| 279 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. NIPS, 2014.
|
| 280 |
+
|
| 281 |
+
Daya Guo, Duyu Tang, Nan Duan, Ming Zhou, and Jian Yin. Dialog-to-action: Conversational question answering over a large-scale knowledge base. 2018.
|
| 282 |
+
|
| 283 |
+
Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, Shujie Liu, Long Zhou, Nan Duan, Alexey Svyatkovskiy, Shengyu Fu, et al. Graphcodebert: Pre-training code representations with data flow. arXiv preprint arXiv:2009.08366, 2020.
|
| 284 |
+
|
| 285 |
+
Jiafeng Guo, Yixing Fan, Qingyao Ai, and W Bruce Croft. A deep relevance matching model for ad-hoc retrieval. In CIKM, 2016.
|
| 286 |
+
|
| 287 |
+
Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Mingwei Chang. Retrieval augmented language model pre-training. In ICML, 2020.
|
| 288 |
+
|
| 289 |
+
Shuguang Han, Xuanhui Wang, Mike Bendersky, and Marc Najork. Learning-to-rank with bert in tf-ranking. arXiv preprint arXiv:2004.08476, 2020.
|
| 290 |
+
|
| 291 |
+
Linmei Hu, Siyong Xu, Chen Li, Cheng Yang, Chuan Shi, Nan Duan, Xing Xie, and Ming Zhou. Graph neural news recommendation with unsupervised preference disentanglement. In ACL, 2020.
|
| 292 |
+
|
| 293 |
+
Jui-Ting Huang, Ashish Sharma, Shuying Sun, Li Xia, David Zhang, Philip Pronin, Janani Padmanabhan, Giuseppe Ottaviano, and Linjun Yang. Embedding-based retrieval in facebook search. In KDD, 2020.
|
| 294 |
+
|
| 295 |
+
Po-Sen Huang, Xiaodong He, Jianfeng Gao, Li Deng, Alex Acero, and Larry Heck. Learning deep structured semantic models for web search using clickthrough data. In CIKM, 2013.
|
| 296 |
+
|
| 297 |
+
Gautier Izacard and Edouard Grave. Distilling knowledge from reader to retriever for question answering. arXiv preprint arXiv:2012.04584, 2020.
|
| 298 |
+
|
| 299 |
+
Jeff Johnson, Matthijs Douze, and Herve J ´ egou. Billion-scale similarity search with gpus. ´ IEEE Transactions on Big Data, 2019.
|
| 300 |
+
|
| 301 |
+
Mandar Joshi, Eunsol Choi, Daniel S. Weld, and Luke Zettlemoyer. Triviaqa: A large scale distantly supervised challenge dataset for reading comprehension. In ACL, 2017.
|
| 302 |
+
|
| 303 |
+
Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick S. H. Lewis, Ledell Wu, Sergey Edunov, Danqi Chen, and Wen-tau Yih. Dense passage retrieval for open-domain question answering. In EMNLP, 2020.
|
| 304 |
+
|
| 305 |
+
Omar Khattab and Matei Zaharia. Colbert: Efficient and effective passage search via contextualized late interaction over bert. In SIGIR, 2020.
|
| 306 |
+
|
| 307 |
+
Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur P. Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, Kristina Toutanova, Llion Jones, Matthew Kelcey, Ming-Wei Chang, Andrew M. Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. Natural questions: a benchmark for question answering research. Trans. Assoc. Comput. Linguistics, 7:452–466, 2019.
|
| 308 |
+
|
| 309 |
+
Kenton Lee, Ming-Wei Chang, and Kristina Toutanova. Latent retrieval for weakly supervised open domain question answering. In ACL, 2019.
|
| 310 |
+
|
| 311 |
+
Dayiheng Liu, Yeyun Gong, Jie Fu, Yu Yan, Jiusheng Chen, Daxin Jiang, Jiancheng Lv, and Nan Duan. Rikinet: Reading wikipedia pages for natural question answering. In ACL, 2020.
|
| 312 |
+
|
| 313 |
+
Yi Luan, Jacob Eisenstein, Kristina Toutanova, and Michael Collins. Sparse, dense, and attentional representations for text retrieval. Transactions of the Association for Computational Linguistics, 9:329–345, 2021.
|
| 314 |
+
|
| 315 |
+
Christopher D. Manning, Prabhakar Raghavan, and Hinrich Schutze. ¨ Introduction to Information Retrieval. Cambridge University Press, Cambridge, UK, 2008. ISBN 978-0-521-86571-5.
|
| 316 |
+
|
| 317 |
+
Yuning Mao, Pengcheng He, Xiaodong Liu, Yelong Shen, Jianfeng Gao, Jiawei Han, and Weizhu Chen. Generation-augmented retrieval for open-domain question answering. In ACL, 2021a.
|
| 318 |
+
|
| 319 |
+
Yuning Mao, Pengcheng He, Xiaodong Liu, Yelong Shen, Jianfeng Gao, Jiawei Han, and Weizhu Chen. Reader-guided passage reranking for open-domain question answering. In Findings of ACL/IJCNLP, 2021b.
|
| 320 |
+
|
| 321 |
+
Bhaskar Mitra and Nick Craswell. Neural models for information retrieval. CoRR, abs/1705.01509, 2017. URL http://arxiv.org/abs/1705.01509.
|
| 322 |
+
|
| 323 |
+
Tri Nguyen, Mir Rosenberg, Xia Song, Jianfeng Gao, Saurabh Tiwary, Rangan Majumder, and Li Deng. Ms marco: A human generated machine reading comprehension dataset. In CoCo@ NIPS, 2016.
|
| 324 |
+
|
| 325 |
+
Rodrigo Nogueira and Kyunghyun Cho. Passage re-ranking with bert. arXiv preprint arXiv:1901.04085, 2019.
|
| 326 |
+
|
| 327 |
+
Rodrigo Nogueira, Jimmy Lin, and AI Epistemic. From doc2query to doctttttquery. Online preprint, 2019a.
|
| 328 |
+
|
| 329 |
+
Rodrigo Nogueira, Wei Yang, Jimmy Lin, and Kyunghyun Cho. Document expansion by query prediction. arXiv preprint arXiv:1904.08375, 2019b.
|
| 330 |
+
|
| 331 |
+
Rodrigo Nogueira, Zhiying Jiang, and Jimmy Lin. Document ranking with a pretrained sequenceto-sequence model. arXiv preprint arXiv:2003.06713, 2020.
|
| 332 |
+
|
| 333 |
+
Barlas Oguz, Kushal Lakhotia, Anchit Gupta, Patrick Lewis, Vladimir Karpukhin, Aleksandra Pik- ˘ tus, Xilun Chen, Sebastian Riedel, Wen-tau Yih, Sonal Gupta, et al. Domain-matched pre-training tasks for dense retrieval. arXiv preprint arXiv:2107.13602, 2021.
|
| 334 |
+
|
| 335 |
+
Yingqi Qu, Yuchen Ding, Jing Liu, Kai Liu, Ruiyang Ren, Wayne Xin Zhao, Daxiang Dong, Hua Wu, and Haifeng Wang. Rocketqa: An optimized training approach to dense passage retrieval for open-domain question answering. In NAACL-HLT, 2021.
|
| 336 |
+
|
| 337 |
+
Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. CoRR, abs/2103.00020, 2021.
|
| 338 |
+
|
| 339 |
+
Ruiyang Ren, Shangwen Lv, Yingqi Qu, Jing Liu, Wayne Xin Zhao, Qiaoqiao She, Hua Wu, Haifeng Wang, and Ji-Rong Wen. PAIR: leveraging passage-centric similarity relation for improving dense passage retrieval. In Findings of ACL/IJCNLP, 2021.
|
| 340 |
+
|
| 341 |
+
Devendra Singh Sachan, Mostofa Patwary, Mohammad Shoeybi, Neel Kant, Wei Ping, William L. Hamilton, and Bryan Catanzaro. End-to-end training of neural retrievers for open-domain question answering. In ACL/IJCNLP, 2021a.
|
| 342 |
+
|
| 343 |
+
Devendra Singh Sachan, Siva Reddy, William Hamilton, Chris Dyer, and Dani Yogatama. End-toend training of multi-document reader and retriever for open-domain question answering. arXiv preprint arXiv:2106.05346, 2021b.
|
| 344 |
+
|
| 345 |
+
Yelong Shen, Xiaodong He, Jianfeng Gao, Li Deng, and Gregoire Mesnil. Learning semantic rep- ´ resentations using convolutional neural networks for web search. In WWW, 2014.
|
| 346 |
+
|
| 347 |
+
Yu Sun, Shuohuan Wang, Yukun Li, Shikun Feng, Hao Tian, Hua Wu, and Haifeng Wang. Ernie 2.0: A continual pre-training framework for language understanding. In AAAI, 2020.
|
| 348 |
+
|
| 349 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NIPS, 2017.
|
| 350 |
+
|
| 351 |
+
Jun Wang, Lantao Yu, Weinan Zhang, Yu Gong, Yinghui Xu, Benyou Wang, Peng Zhang, and Dell Zhang. Irgan: A minimax game for unifying generative and discriminative information retrieval models. In SIGIR, 2017.
|
| 352 |
+
|
| 353 |
+
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick ´ von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In EMNLP, 2020.
|
| 354 |
+
|
| 355 |
+
Chenyan Xiong, Zhuyun Dai, Jamie Callan, Zhiyuan Liu, and Russell Power. End-to-end neural ad-hoc ranking with kernel pooling. In SIGIR, 2017.
|
| 356 |
+
|
| 357 |
+
Lee Xiong, Chenyan Xiong, Ye Li, Kwok-Fung Tang, Jialin Liu, Paul N. Bennett, Junaid Ahmed, and Arnold Overwijk. Approximate nearest neighbor negative contrastive learning for dense text retrieval. In ICLR, 2021.
|
| 358 |
+
|
| 359 |
+
Peilin Yang, Hui Fang, and Jimmy Lin. Anserini: Enabling the use of lucene for information retrieval research. In SIGIR, 2017.
|
| 360 |
+
|
| 361 |
+
Sohee Yang and Minjoon Seo. Is retriever merely an approximator of reader? arXiv preprint arXiv:2010.10999, 2020.
|
| 362 |
+
|
| 363 |
+
Lantao Yu, Weinan Zhang, Jun Wang, and Yong Yu. Seqgan: Sequence generative adversarial nets with policy gradient. In AAAI, 2017.
|
| 364 |
+
|
| 365 |
+
Jingtao Zhan, Jiaxin Mao, Yiqun Liu, Min Zhang, and Shaoping Ma. Repbert: Contextualized text embeddings for first-stage retrieval. arXiv preprint arXiv:2006.15498, 2020.
|
| 366 |
+
|
| 367 |
+
Jingtao Zhan, Jiaxin Mao, Yiqun Liu, Jiafeng Guo, Min Zhang, and Shaoping Ma. Optimizing dense retrieval model training with hard negatives. In SIGIR, 2021.
|
| 368 |
+
|
| 369 |
+
Lixin Zou, Shengqiang Zhang, Hengyi Cai, Dehong Ma, Suqi Cheng, Shuaiqiang Wang, Daiting Shi, Zhicong Cheng, and Dawei Yin. Pre-trained language model based ranking in baidu search. In KDD, 2021.
|
| 370 |
+
|
| 371 |
+
# A APPENDIX
|
| 372 |
+
|
| 373 |
+
A.1 PROOF
|
| 374 |
+
|
| 375 |
+
Proof of Eqn. 9: Suppose $d _ { i } ^ { - } \in { \mathbb { D } } _ { q } ^ { - }$ is sampled by $p _ { \theta } ( \cdot | q ; \mathbb { D } _ { q } ^ { - } )$ , thus
|
| 376 |
+
|
| 377 |
+
$$
|
| 378 |
+
\begin{array} { r l } & { J ^ { \theta } = \mathbf { E } _ { \mathbb { D } _ { q } ^ { - } \sim G _ { \theta } ( q , \cdot ) } \left[ \log p _ { \phi } ( d | q ; \{ d \} \cup \mathbb { D } _ { q } ^ { - } ) \right] } \\ & { \qquad \le \mathbf { E } _ { \mathbb { D } _ { q } ^ { - } \sim G _ { \theta } ( q , \cdot ) } \left( \mathbf { E } _ { d _ { i } ^ { - } \sim p _ { \phi } ( \cdot | q ; \mathbb { D } _ { q } ^ { - } ) } \left[ \log p _ { \phi } ( d | q ; \{ d , d _ { i } ^ { - } \} ) \right] \right) } \end{array}
|
| 379 |
+
$$
|
| 380 |
+
|
| 381 |
+
where $\mathbb { D } _ { q } ^ { - }$ indicates the set of negative documents sampled by $G _ { \theta } ( q , \cdot )$ . In practice, we approximate $\mathbb { D } _ { q } ^ { - }$ by sampling $n$ documents from the top- $K$ retrieved negative set. Therefore, we could further obtain the following approximately equation in implementation.
|
| 382 |
+
|
| 383 |
+
$$
|
| 384 |
+
\approx \mathbf { E } _ { d _ { i } ^ { - } \sim p _ { \theta } ( \cdot \vert q ; \mathbb { D } _ { q } ^ { - } ) } \left[ \log p _ { \phi } ( d \vert q ; \{ d , d _ { i } ^ { - } \} ) \right] = \hat { J } ^ { \theta }
|
| 385 |
+
$$
|
| 386 |
+
|
| 387 |
+
Proof of Eqn. 10:
|
| 388 |
+
|
| 389 |
+
$$
|
| 390 |
+
\begin{array} { l } { { \nabla _ { \theta } \hat { J } ^ { \theta } = \nabla _ { \theta } \mathbf { E } _ { d _ { i } ^ { - } \sim p _ { \theta } ( \cdot \vert q ; \mathbb { D } _ { q } ^ { - } ) } \left[ \log p _ { \phi } ( d \vert q ; \{ d , d _ { i } ^ { - } \} ) \right] } } \\ { { { { } } } = \displaystyle \sum _ { i } \nabla _ { \theta } p _ { \theta } ( d _ { i } ^ { - } \vert q ; \mathbb { D } _ { q } ^ { - } ) \left[ \log p _ { \phi } ( d \vert q ; \{ d , d _ { i } ^ { - } \} ) \right] } \\ { { { } } } \\ { { { } } = \displaystyle \sum _ { i } p _ { \theta } ( d _ { i } ^ { - } \vert q ; \mathbb { D } _ { q } ^ { - } ) \nabla _ { \theta } \log p _ { \theta } ( d _ { i } ^ { - } \vert q ; \mathbb { D } _ { q } ^ { - } ) \left[ \log p _ { \phi } ( d \vert q ; \{ d , d _ { i } ^ { - } \} ) \right] } \\ { { { } } } \\ { { { } } = \displaystyle \mathbf { E } _ { d _ { i } ^ { - } \sim p _ { \theta } ( \cdot \vert q ; \mathbb { D } _ { q } ^ { - } ) } \nabla _ { \theta } \log p _ { \theta } ( d _ { i } ^ { - } \vert q ; \mathbb { D } _ { q } ^ { - } ) \left[ \log p _ { \phi } ( d \vert q ; \{ d , d _ { i } ^ { - } \} ) \right] } \end{array}
|
| 391 |
+
$$
|
| 392 |
+
|
| 393 |
+
# A.2 EFFICIENCY REPORT
|
| 394 |
+
|
| 395 |
+
We list the time cost of training and inference in Table 7. The evaluation is made with 8 NVIDIA A100 GPUs. The max step of ANCE training is from the ANCE’s open-source website 2.We estimate the overall training time without taking account of the time of continuous pre-training step and warming-up step.
|
| 396 |
+
|
| 397 |
+
Table 7: Comparison of Efficiency
|
| 398 |
+
|
| 399 |
+
<table><tr><td></td><td>DPR</td><td>ANCE</td><td>AR2(n=15)</td><td>AR2(n=1)</td></tr><tr><td>Training Batch Size Max Step</td><td>128 20k 1.8h</td><td>128 136k</td><td>64 20k</td><td>64 20k</td></tr><tr><td>BPfor Retriever BP for Ranker Iteration Number Index Refresh</td><td>1 0 0.5</td><td>11h 1 10</td><td>2.3h 0.75h 10</td><td>1h 0.35h 10</td></tr><tr><td>Overall</td><td>1.85h</td><td>0.5h 16h</td><td>0.5h</td><td>0.5h</td></tr><tr><td>Inference</td><td></td><td></td><td>9.1h</td><td>6.4h</td></tr><tr><td></td><td>20min</td><td></td><td></td><td></td></tr><tr><td>Encoding of Corpus</td><td></td><td>20min</td><td>20min</td><td>20min</td></tr><tr><td>Query Encoding</td><td>40ns</td><td>40ns</td><td>40ns</td><td>40ns</td></tr><tr><td>ANNIndexBuild</td><td>2min</td><td>2min</td><td>2min</td><td></td></tr><tr><td></td><td>2ms</td><td></td><td></td><td>2min</td></tr><tr><td>ANN Retrieval(Top-100)</td><td></td><td>2ms</td><td>2ms</td><td>2ms</td></tr></table>
|
| 400 |
+
|
| 401 |
+
# A.3 HYPERPARAMETERS
|
| 402 |
+
|
| 403 |
+
Table 8: Hyperparameters for AR2 training.
|
| 404 |
+
|
| 405 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=9>Parameter</td><td rowspan=1 colspan=1>NQ TriviaQA MS-MARCO</td></tr><tr><td rowspan=1 colspan=1>Default</td><td rowspan=1 colspan=9>Max query lengthMax passage length</td><td rowspan=1 colspan=1>32 32 32128 128 128</td></tr><tr><td rowspan=5 colspan=1>AR2-G0</td><td rowspan=5 colspan=9>Learning rateNegative sizeBatch sizeTemperature TOptimizerSchedulerWarmup proportionTraining epoch</td><td rowspan=1 colspan=1>1e-5 1e-5 1e-4</td></tr><tr><td rowspan=1 colspan=3></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>255 255 127</td></tr><tr><td rowspan=1 colspan=2></td><td rowspan=1 colspan=1></td><td rowspan=3 colspan=1>128 128 641 1 1AdamW AdamW AdamWLinear Linear Linear0.1 0.1 0.140 40 3</td></tr><tr><td rowspan=1 colspan=2></td></tr><tr><td rowspan=1 colspan=2>Scheduler</td><td rowspan=1 colspan=3>r</td></tr><tr><td rowspan=9 colspan=1>AR2-D0</td><td rowspan=3 colspan=9>Learning rateNegative sizeBatch size</td><td rowspan=1 colspan=1>1e-5 1e-5 1e-5</td></tr><tr><td rowspan=1 colspan=1>15 15 15</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>64 64 256</td></tr><tr><td rowspan=2 colspan=9>Temperature TOptimizer</td><td rowspan=2 colspan=1>1 1 1AdamW AdamW AdamW</td></tr><tr><td rowspan=3 colspan=1>AdamW AdamW AdamWLinear Linear Linear0.1 0.1 0.1</td></tr><tr><td rowspan=1 colspan=9>Scheduler</td><td rowspan=1 colspan=1>Linear Linear</td></tr><tr><td rowspan=3 colspan=9>Warmup proportionTraining step per iterationMax step</td></tr><tr><td rowspan=1 colspan=1>1500 1500 1500</td></tr><tr><td rowspan=1 colspan=5></td><td rowspan=1 colspan=1>2000 2000 4000</td></tr><tr><td rowspan=8 colspan=1>AR2-G</td><td rowspan=8 colspan=9>Learning rateNegative sizeBatch sizeTemperature TOptimizerSchedulerWarmup proportionTraining step per iterationMax step</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>15 15 15</td></tr><tr><td rowspan=1 colspan=1>64 64 64</td></tr><tr><td rowspan=1 colspan=1>1 1 1AdamW AdamW AdamW</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Linear Linear Linear</td></tr><tr><td rowspan=1 colspan=1>0.1 0.1 0.1</td></tr><tr><td rowspan=1 colspan=1>1500 1500 1500</td></tr><tr><td rowspan=1 colspan=5></td><td rowspan=1 colspan=1>15000 15000 15000</td></tr><tr><td rowspan=8 colspan=1>AR2-D</td><td rowspan=5 colspan=9>Negative sizeLearning rateBatch sizeTemperature TOptimizerScheduler</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1></td><td></td></tr><tr><td rowspan=1 colspan=1>64 64 64</td></tr><tr><td rowspan=1 colspan=1>1 1 1AdamW AdamW AdamW</td></tr><tr><td rowspan=1 colspan=1>Linear Linear Linear</td></tr><tr><td rowspan=2 colspan=9>Warmup proportionTraining step per iteration</td><td rowspan=1 colspan=1>0.1 0.1 0.1</td></tr><tr><td rowspan=1 colspan=1>500 500 500</td></tr><tr><td rowspan=1 colspan=9>Max step</td><td rowspan=1 colspan=1>5000 5000 5000</td></tr></table>
|
| 406 |
+
|
| 407 |
+
# A.4 MODEL CONFIGURATION AND EXPERIMENT SETTINGS
|
| 408 |
+
|
| 409 |
+
We list the detailed configuration of AR2 and baseline models in Table 9.
|
| 410 |
+
|
| 411 |
+
Table 9: Model configuration and experiment settings.
|
| 412 |
+
|
| 413 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>InitialModel</td><td rowspan=1 colspan=1>Parameters</td><td rowspan=1 colspan=1>FurtherPretrain</td><td rowspan=1 colspan=1>AdditionalData</td></tr><tr><td rowspan=1 colspan=1>DPR (Karpukhin et al., 2020)</td><td rowspan=1 colspan=1>BERT-Base</td><td rowspan=1 colspan=1>110M</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=1 colspan=1>ANCE (Xiong et al., 2021)</td><td rowspan=1 colspan=1>BERT/RoBERTa-Base</td><td rowspan=1 colspan=1>110M/125M</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=1 colspan=1>RocketQA (Qu et al., 2021)</td><td rowspan=1 colspan=1>ERNIE-2.0-BaseERNIE-2.0-Large</td><td rowspan=1 colspan=1>110M330M</td><td rowspan=1 colspan=1>--</td><td rowspan=1 colspan=1>1.7 M</td></tr><tr><td rowspan=1 colspan=1>PAIR (Ren et al., 2021)</td><td rowspan=1 colspan=1>ERNIE-2.0-BaseERNIE-2.0-Large</td><td rowspan=1 colspan=1>110M330M</td><td rowspan=1 colspan=1>--</td><td rowspan=1 colspan=1>1.7 M</td></tr><tr><td rowspan=1 colspan=1>Individual Top-k (Sachan et al., 2021a)</td><td rowspan=1 colspan=1>ERNIE-2.0-BaseT5-Large</td><td rowspan=1 colspan=1>110M739M</td><td rowspan=1 colspan=1>Yes1</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>coCondenser (Gao & Callan,2021a)</td><td rowspan=1 colspan=1>BERT-Base</td><td rowspan=1 colspan=1>110M</td><td rowspan=1 colspan=1>Yes</td><td rowspan=1 colspan=1>=</td></tr><tr><td rowspan=1 colspan=1>Our (AR2-G) (Retriever)Our (AR2-D) (Ranker)</td><td rowspan=1 colspan=1>ERNIE-2.0-BaseERNIE-2.0-Large</td><td rowspan=1 colspan=1>110M330M</td><td rowspan=1 colspan=1>Yes-</td><td rowspan=1 colspan=1>==</td></tr></table>
|
| 414 |
+
|
| 415 |
+
# A.5 ABLATION STUDY ON DIFFERENT INITIAL MODELS
|
| 416 |
+
|
| 417 |
+
Table 10 shows the results of our method with different initial models. We see that ERNIE-Base as the initial model achieves a little better performance than BERT-Base. And AR2-G using BERTBase as the initial model still achieves better performance than other methods under the same initial model. Meanwhile, ICT pre-training improves the performance of AR2-G.
|
| 418 |
+
|
| 419 |
+
Table 10: Performance of AR2-G on NQ test set with different initial model
|
| 420 |
+
|
| 421 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Initial Model</td><td rowspan=1 colspan=1>R@1</td><td rowspan=1 colspan=1>R@5</td><td rowspan=1 colspan=2>R@20</td><td rowspan=1 colspan=1>R@100</td></tr><tr><td rowspan=4 colspan=1>DPR (Karpukhin et al., 2020)ANCE (Xiong et al., 2021)RocketQA (Qu et al., 2021)PAIR (Ren et al.,2021)</td><td rowspan=4 colspan=1>BERT-BaseBERT-BaseERNIE-BaseERNIE-Base</td><td rowspan=4 colspan=1>1111</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=2>78.4</td><td rowspan=1 colspan=1>85.3</td></tr><tr><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=2>81.9</td><td rowspan=1 colspan=1>87.5</td></tr><tr><td rowspan=1 colspan=1>74.0</td><td rowspan=2 colspan=2>82.783.5</td><td rowspan=2 colspan=1>88.589.1</td></tr><tr><td rowspan=1 colspan=1>74.9</td></tr><tr><td rowspan=3 colspan=1>AR2-GAR2-GAR2-G</td><td rowspan=3 colspan=1>BERT-BaseERNIE-BaseERNIE-Base w/ ICT</td><td rowspan=3 colspan=1>56.757.258.7</td><td rowspan=1 colspan=1>76.1</td><td rowspan=1 colspan=2>85.0</td><td rowspan=1 colspan=1>89.3</td></tr><tr><td rowspan=2 colspan=1>76.677.9</td><td rowspan=1 colspan=1>85.3</td><td></td><td rowspan=1 colspan=1>89.8</td></tr><tr><td rowspan=1 colspan=2>86.0</td><td rowspan=1 colspan=1>90.1</td></tr></table>
|
| 422 |
+
|
| 423 |
+
# A.6 COMPARISON WITH SEVERAL EXISTING APPROACHES
|
| 424 |
+
|
| 425 |
+
Table 11 shows the comparison of AR2 and several existing retrieval approaches. “Extra Label” refers to whether the answer label is used. AR2 jointly optimizes both the retriever and the ranker according to a principle adversarial objective, which is the key difference with previous works.
|
| 426 |
+
|
| 427 |
+
Table 11: Comparison with existing approaches
|
| 428 |
+
|
| 429 |
+
<table><tr><td>Model</td><td>Extra Label</td><td>Retriever-Ranker/ Retriever-Reader</td><td>Adversarial Objective</td><td>Update Hard Negatives</td></tr><tr><td>FID-KD (Izacard & Grave,2020)</td><td>Yes</td><td>Yes</td><td>No</td><td>No</td></tr><tr><td>RDR(Yang& Seo,2020)</td><td>Yes</td><td>Yes</td><td>No</td><td>No</td></tr><tr><td>RocketQA (Qu et al.,2021)</td><td>No</td><td>Yes</td><td>No</td><td>Yes</td></tr><tr><td>ANCE (Xiong et al.,2021)</td><td>No</td><td>No</td><td>No</td><td>Yes</td></tr><tr><td>RIDER (Mao et al., 2021b)</td><td>Yes</td><td>Yes</td><td>No</td><td>No</td></tr><tr><td>AR2</td><td>No</td><td>Yes</td><td>Yes</td><td>Yes</td></tr></table>
|
| 430 |
+
|
| 431 |
+
# A.7 PERFORMANCE OF THE PIPELINE
|
| 432 |
+
|
| 433 |
+
Table 12 shows the performance of the retrieve-then-rank pipeline on Trivia QA and MS-MARCO. From the results of Table 6 and Table 12, we find that the ranker AR2-D improves the performance on all three benchmarks including NQ, Trivia QA, and MS-MARCO. Meanwhile, the pipeline based on AR2 achieves state-of-the-art performances on all benchmarks.
|
| 434 |
+
|
| 435 |
+
Table 12: The results of the second-stage ranking on Trivia QA and MS-MARCO.
|
| 436 |
+
|
| 437 |
+
<table><tr><td rowspan="2">Retriever</td><td rowspan="2">Ranker</td><td colspan="3">Trivia QA</td><td rowspan="2">MS-MARCO MRR@10</td></tr><tr><td>R@1</td><td>R@5</td><td>R@10</td><td>R@20</td></tr><tr><td>RepBERT (Zhan et al., 2020)</td><td>RepBERT (Zhan et al.,2020)</td><td>-</td><td>-</td><td>-</td><td>-</td><td>37.7</td></tr><tr><td>ME-HYBIRD (Luan et al., 2021)</td><td>ME-HYBIRD (Luan et al., 2021)</td><td>-</td><td>-</td><td>:</td><td>■</td><td>39.4</td></tr><tr><td>ME-BERT(Luan et al.,2021)</td><td>ME-BERT (Luan et al.,2021)</td><td>-</td><td>-</td><td>■</td><td>■</td><td>39.5</td></tr><tr><td>BM25 (Yang et al.,2017)</td><td>TFR-BERT (Han et al.,2020)</td><td>-</td><td>-</td><td>=</td><td>-</td><td>40.5</td></tr><tr><td>GAR+ (Mao et al.,2021a)</td><td>RIDER (Mao et al.,2021b)</td><td>71.9</td><td>77.5</td><td>79.8</td><td>81.8</td><td>-</td></tr><tr><td>AR2-G</td><td>■</td><td>64.2</td><td>78.2</td><td>81.8</td><td>84.4</td><td>39.5</td></tr><tr><td>AR2-G</td><td>AR2-D</td><td>73.0</td><td>82.1</td><td>84.1</td><td>85.8</td><td>43.2</td></tr></table>
|
| 438 |
+
|
| 439 |
+
# A.8 PERFORMANCE OF THE LARGE-SIZE MODEL
|
| 440 |
+
|
| 441 |
+
Table 13 shows the results of AR2-G (Retriever) initialized with ERNIE-2.0-Large (without continuous pre-training (ICT)). All baselines are initialized by large-size model, and DPR-PAQ (Oguz ˘ et al., 2021) utilizes a large external corpus $6 5 \mathrm { m }$ question-answer pairs) to continue pre-training the model; Individual Top-K (Sachan et al., 2021a) utilizes T5-Large model (739M parameters vs 330M parameters ERNIE-2.0-Large) as reader to guide the retriever. Compared with these baseline methods, AR2-G achieves a significant performance improvement, which further demonstrates the effectiveness of AR2-G (Retriever).
|
| 442 |
+
|
| 443 |
+
Table 13: The performance of large-size models on Natural Questions test set,
|
| 444 |
+
|
| 445 |
+
<table><tr><td></td><td>Size</td><td>R@1</td><td>R@5</td><td>R@20</td><td>R@100</td></tr><tr><td>DPR-PAQBERT (Oguz et al., 2021) DPR-PAQRoBERTa (Oguz et al., 2021)</td><td>Large Large</td><td>1 1</td><td>75.3 76.9</td><td>84.4 84.7</td><td>88.9 89.2</td></tr><tr><td>Individual Top-K (Sachan et al., 2021a) AR2-G AR2-G</td><td>Large Base Large</td><td>57.5 58.7 61.1</td><td>76.2 77.9 78.8</td><td>84.8 86.0 86.5</td><td>89.8 90.1 90.4</td></tr></table>
|
md/dev/NudBMY-tzDr/NudBMY-tzDr.md
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NATURAL LANGUAGE DESCRIPTIONS OF DEEP VISUAL FEATURES
|
| 2 |
+
|
| 3 |
+
Evan Hernandez1 Sarah Schwettmann1 David $\mathbf { B a u } ^ { 1 , 2 }$ Teona Bagashvili3 Antonio Torralba1 Jacob Andreas1 1MIT CSAIL 2Northeastern University 3Allegheny College {dez,schwett,teona,torralba,jda}@mit.edu d.bau@northeastern.edu
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Some neurons in deep networks specialize in recognizing highly specific perceptual, structural, or semantic features of inputs. In computer vision, techniques exist for identifying neurons that respond to individual concept categories like colors, textures, and object classes. But these techniques are limited in scope, labeling only a small subset of neurons and behaviors in any network. Is a richer characterization of neuron-level computation possible? We introduce a procedure (called MILAN, for mutual-information-guided linguistic annotation of neurons) that automatically labels neurons with open-ended, compositional, natural language descriptions. Given a neuron, MILAN generates a description by searching for a natural language string that maximizes pointwise mutual information with the image regions in which the neuron is active. MILAN produces fine-grained descriptions that capture categorical, relational, and logical structure in learned features. These descriptions obtain high agreement with human-generated feature descriptions across a diverse set of model architectures and tasks, and can aid in understanding and controlling learned models. We highlight three applications of natural language neuron descriptions. First, we use MILAN for analysis, characterizing the distribution and importance of neurons selective for attribute, category, and relational information in vision models. Second, we use MILAN for auditing, surfacing neurons sensitive to human faces in datasets designed to obscure them. Finally, we use MILAN for editing, improving robustness in an image classifier by deleting neurons sensitive to text features spuriously correlated with class labels.1
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
A surprising amount can be learned about the behavior of a deep network by understanding the individual neurons that make it up. Previous studies aimed at visualizing or automatically categorizing neurons have identified a range of interpretable functions across models and application domains: low-level convolutional units in image classifiers implement color detectors and Gabor filters (Erhan et al., 2009), while some later units activate for specific parts and object categories (Zeiler & Fergus, 2014; Bau et al., 2017). Single neurons have also been found to encode sentiment in language data (Radford et al., 2017) and biological function in computational chemistry (Preuer et al., 2019). Given a new model trained to perform a new task, can we automatically catalog these behaviors?
|
| 12 |
+
|
| 13 |
+
Techniques for characterizing the behavior of individual neurons are still quite limited. Approaches based on visualization (Zeiler & Fergus, 2014; Girshick et al., 2014; Karpathy et al., 2015; Mahendran & Vedaldi, 2015; Olah et al., 2017) leave much of the work of interpretation up to human users, and cannot be used for large-scale analysis. Existing automated labeling techniques (Bau et al., 2017; 2019; Mu & Andreas, 2020) require researchers to pre-define a fixed space of candidate neuron labels; they label only a subset of neurons in a given network and cannot be used to surface novel or unexpected behaviors.
|
| 14 |
+
|
| 15 |
+
This paper develops an alternative paradigm for labeling neurons with expressive, compositional, and open-ended annotations in the form of natural language descriptions. We focus on the visual domain: building on past work on information-theoretic approaches to model interpretability, we formulate neuron labeling as a problem of finding informative descriptions of a neuron’s pattern of activation on input images. We describe a procedure (called MILAN, for mutual-informationguided linguistic annotation of neurons) that labels individual neurons with fine-grained natural language descriptions by searching for descriptions that maximize pointwise mutual information with the image regions in which neurons are active. To do so, we first collect a new dataset of fine-grained image annotations (MILANNOTATIONS, Figure 1c), then use these to construct learned approximations to the distributions over image regions (Figure 1b) and descriptions. In some cases, MILAN surfaces neuron descriptions that more specific than the underlying training data (Figure 1d).
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: (a) We aim to generate natural language descriptions of individual neurons in deep networks. (b) We first represent each neuron via an exemplar set of input regions that activate it. (c) In parallel, we collect a dataset of fine-grained human descriptions of image regions, and use these to train a model of $p$ (description | exemplars) and $p$ (description). (d) Using these models, we search for a description that has high pointwise mutual information with the exemplars, ultimately generating highly specific neuron annotations.
|
| 19 |
+
|
| 20 |
+
MILAN is largely model-agnostic and can surface descriptions for different classes of neurons, ranging from convolutional units in CNNs to fully connected units in vision transformers, even when the target network is trained on data that differs systematically from MILANNOTATIONS’ images. These descriptions can in turn serve a diverse set of practical goals in model interpretability and dataset design. Our experiments highlight three: using MILAN-generated descriptions to (1) analyze the role and importance of different neuron classes in convolutional image classifiers, (2) audit models for demographically sensitive feature by comparing their features when trained on anonymized (blurred) and non-anonymized datasets, and (3) identify and mitigate the effects of spurious correlations with text features, improving classifier performance on adversarially distributed test sets. Taken together, these results show that fine-grained, automatic annotation of deep network models is both possible and practical: rich descriptions produced by automated annotation procedures can surface meaningful and actionable information about model behavior.
|
| 21 |
+
|
| 22 |
+
# 2 RELATED WORK
|
| 23 |
+
|
| 24 |
+
Interpreting deep networks MILAN builds on a long line of recent approaches aimed at explaining the behavior of deep networks by characterizing the function of individual neurons, either by visualizing the inputs they select for (Zeiler & Fergus, 2014; Girshick et al., 2014; Karpathy et al., 2015; Mahendran & Vedaldi, 2015; Olah et al., 2017) or by automatically categorizing them according to the concepts they recognize (Bau et al., 2017; 2018; Mu & Andreas, 2020; Morcos et al., 2018; Dalvi et al., 2019). Past approaches to automatic neuron labeling require fixed, pre-defined label sets; in computer vision, this has limited exploration to pre-selected object classes, parts, materials, and simple logical combinations of these concepts. While manual inspection of neurons has revealed that a wider range of features play an important role in visual recognition (e.g. orientation, illumination, and spatial relations; Cammarata et al. 2021) MILAN is the first automated approach that can identify such features at scale. Discrete categorization is also possible for directions in representation space (Kim et al., 2018; Andreas et al., 2017; Schwettmann et al., 2021) and for clusters of images induced by visual representations (Laina et al., 2020); in the latter, an off-the-shelf image captioning model is used to obtain language descriptions of the unifying visual concept for the cluster, although the descriptions miss low-level visual commonalities. As MILAN requires only a primitive procedure for generating model inputs maximally associated with the feature or direction of interest, future work might extend it to these settings as well.
|
| 25 |
+
|
| 26 |
+
Natural language explanations of decisions Previous work aimed at explaining computer vision classifiers using natural language has focused on generating explanations for individual classification decisions (e.g., Hendricks et al., 2016; Park et al., 2018; Hendricks et al., 2018; Zellers et al., 2019). Outside of computer vision, several recent papers have proposed procedures for generating natural language explanations of decisions in text classification models (Zaidan & Eisner, 2008; Camburu et al., 2018; Rajani et al., 2019; Narang et al., 2020) and of representations in more general sequence modeling problems (Andreas & Klein, 2017). These approaches require task-specific datasets and often specialized training procedures, and do not assist with interpretability at the model level. To the best of our knowledge, MILAN is the first approach for generating compositional natural language descriptions for interpretability at the level of individual features rather than input-conditional decisions or representations. More fundamentally, MILAN can do so independently of the model being described, making it (as shown in Section 4) modular, portable, and to a limited extent task-agnostic.
|
| 27 |
+
|
| 28 |
+
# 3 APPROACH
|
| 29 |
+
|
| 30 |
+
Neurons and exemplars Consider the neuron depicted in Figure 1b, located in a convlutional network trained to classify scenes (Zhou et al., 2017). When the images in Figure 1 are provided as input to the network, the neuron activates in patches of grass near animals, but not in grass without animals nearby. How might we automate the process of automatically generating such a description?
|
| 31 |
+
|
| 32 |
+
While the image regions depicted in Fig. 1b do not completely characterize the neuron’s function in the broader network, past work has found that actionable information can be gleaned from such regions alone. Bau et al. (2020; 2019) use them to identify neurons that can trigger class predictions or generative synthesis of specific objects; Andreas & Klein (2017) use them to predict sequence outputs on novel inputs; Olah et al. (2018) and Mu & Andreas (2020) use them to identify adversarial vulnerabilities. Thus, building on this past work, our approach to neuron labeling also begins by representing each neuron via the set of input regions on which its activity exceeds a fixed threshold.
|
| 33 |
+
|
| 34 |
+
Definition 1. Let $f : X \to Y$ be a neural network, and let $f _ { i } ( x )$ denote the activation value of the ith neuron in $f$ given an input $x$ .2 Then, an exemplar representation of the neuron $f _ { i }$ is given by:
|
| 35 |
+
|
| 36 |
+
$$
|
| 37 |
+
E _ { i } = \{ x \in X : f _ { i } ( x ) > \eta _ { i } \} .
|
| 38 |
+
$$
|
| 39 |
+
|
| 40 |
+
for some threshold parameter $\eta _ { i }$ (discussed in more detail below).
|
| 41 |
+
|
| 42 |
+
Exemplars and descriptions Given this explicit representation of $f _ { i }$ ’s behavior, it remains to construct a description $d _ { i }$ of the neuron. Past work (Bau et al., 2017; Andreas et al., 2017) begins with a fixed inventory of candidate descriptions (e.g. object categories), defines an exemplar set $E _ { d } ^ { \prime }$ for each such category (e.g. via the output of a semantic segmentation procedure) then labels neurons by optimizing $d _ { i } : = \arg \operatorname* { m i n } _ { d } \ \delta ( E _ { i } , E _ { d } ^ { \prime } )$ for some measure of set distance (e.g. Jaccard, 1912).
|
| 43 |
+
|
| 44 |
+
In this work, we instead adopt a probabilistic approach to neuron labeling. In computer vision applications, each $E _ { i }$ is a set of image patches. Humans are adept at describing such patches (Rashtchian et al., 2010) and one straightforward possibility might be to directly optimize $d _ { i } : = \arg \operatorname* { m a x } _ { d } p ( d \mid$ $E _ { i }$ ). In practice, however, the distribution of human descriptions given images may not be wellaligned with the needs of model users. Fig. 2 includes examples of human-generated descriptions for exemplar sets. Many of them (e.g. text for AlexNet conv3-252) are accurate, but generic; in reality, the neuron responds specifically to text on screens. The generated description of a neuron should capture the specificity of its function—especially relative to other neurons in the same model.
|
| 45 |
+
|
| 46 |
+
We thus adopt an information-theoretic criterion for selecting descriptions: our final neuron description procedure optimizes pointwise mutual information between descriptions and exemplar sets:
|
| 47 |
+
|
| 48 |
+
# Definition 2. The max-mutual-information description of the neuron $f _ { i }$ is given by:
|
| 49 |
+
|
| 50 |
+
$$
|
| 51 |
+
\operatorname { M I L A N } ( f _ { i } ) : = \arg \operatorname* { m a x } _ { d } \ \operatorname { p m i } ( d ; E _ { i } ) = \arg \operatorname* { m a x } _ { d } \ \log p ( d \mid E _ { i } ) - \log p ( d ) ~ .
|
| 52 |
+
$$
|
| 53 |
+
|
| 54 |
+
To turn Eq. (2) into a practical procedure for annotating neurons, three additional steps are required: constructing a tractable approximation to the exemplar set $E _ { i }$ (Section 3.1), using human-generated image descriptions to model $p ( d \mid E )$ and $p ( d )$ (Section 3.2 and Section 3.3), and finding a highquality description $d$ in the infinite space of natural language strings (Section 3.4).
|
| 55 |
+
|
| 56 |
+

|
| 57 |
+
Figure 2: Examples of MILAN descriptions on the generalization tasks described in Section 4. Even highly specific labels (like the top boundaries of horizontal objects) can be predicted for neurons in new networks. Failure modes include semantic errors, e.g. MILAN misses the cupcakes in the dog faces and cupcakes neuron.
|
| 58 |
+
|
| 59 |
+
# 3.1 APPROXIMATING THE EXEMPLAR SET
|
| 60 |
+
|
| 61 |
+
As written, the exemplar set in Equation (1) captures a neuron’s behavior on all image patches. This set is large (limited only by the precision used to represent individual pixel values), so we follow past work (Bau et al., 2017) by restricting each $E _ { i }$ to the set of images that cause the greatest activation in the neuron $f _ { i }$ . For convolutional neurons in image processing tasks, sets $E _ { i }$ ultimately comprise $k$ images with activation masks indicating the regions of those images in which $f _ { i }$ fired (Fig. 1a; see Bau et al. 2017 for details). Throughout this paper, we use exemplar sets with $k = 1 5$ images and choose $\eta _ { i }$ equal to the 0.99 percentile of activations for the neuron $f _ { i }$ .
|
| 62 |
+
|
| 63 |
+
# 3.2 MODELING $p ( d \mid E )$ AND $p ( d )$
|
| 64 |
+
|
| 65 |
+
The term $\mathrm { p m i } ( d ; E _ { i } )$ in Equation (2) can be expressed in terms of two distributions: the probability $p ( d \mid E _ { i } )$ that a human would describe an image region with $d$ , and the probability $p ( d )$ that a human would use the description $d$ for any neuron. $\bar { p ( d \mid E _ { i } ) }$ is, roughly speaking, a distribution over image captions (Donahue et al., 2015). Here, however, the input to the model is not a single image but a set of image regions (the masks in Fig. 1a); we seek natural language descriptions of the common features of those regions. We approximate $p ( d \mid E _ { i } )$ with learned model—specifically the Show-Attend-Tell image description model of $\mathrm { X u }$ et al. (2015) trained on the MILANNOTATIONS dataset described below, and with several modifications tailored to our use case. We approximate $p ( d )$ with a two-layer LSTM language model (Hochreiter & Schmidhuber, 1997) trained on the text of MILANNOTATIONS. Details about both models are provided in Appendix B.
|
| 66 |
+
|
| 67 |
+
# 3.3 COLLECTING HUMAN ANNOTATIONS
|
| 68 |
+
|
| 69 |
+
As $p ( d \mid E _ { i } )$ and $p ( d )$ are both estimated using learned models, they require training data. In particular, modeling $p ( d \mid E _ { i } )$ requires a dataset of captions that describe regions from multiple different images, such as the ones shown in Fig. 1. These descriptions must describe not only objects and actions, but all other details that individual neurons select for. Existing image captioning datasets, like MSCOCO (Lin et al., 2014) and Conceptual Captions (Sharma et al., 2018), only focus on scene-level details about a single image and do not provide suitable annotations for this task. We therefore collect a novel dataset of captions for image regions to train the models underlying MILAN.
|
| 70 |
+
|
| 71 |
+
First, we must obtain a set of image regions to annotate. To ensure that these regions have a similar distribution to the target neurons themselves, we derive them directly from the exemplar sets of neurons in a set of seed models. We obtain the exemplar sets for a subset of the units in each seed model in Table 1 using the method from Section 3.1. We then present each set to a human annotator and ask them to describe what is common to the image regions.
|
| 72 |
+
|
| 73 |
+
<table><tr><td>Network</td><td>Arch.</td><td>Task</td><td>Datasets</td><td>Annotated</td><td>#Units</td></tr><tr><td>AlexNet</td><td>CNN</td><td>Class.</td><td>ImageNet Places365</td><td>conv. 1-5</td><td>1152 1376</td></tr><tr><td>ResNet152</td><td>CNN</td><td>Class.</td><td>ImageNet Places365</td><td>conv. 1 res. 1-4</td><td>3904 3904</td></tr><tr><td>BigGAN</td><td>CNN</td><td>Gen.</td><td>ImageNet Places365</td><td>res.0-5</td><td>3744 4992</td></tr><tr><td>DINO</td><td>ViT</td><td>BYOL</td><td>ImageNet</td><td>MLP 1-12 (first 100)</td><td>1200</td></tr></table>
|
| 74 |
+
|
| 75 |
+
Table 1: Summary of MILANNOTATIONS, which labels 20k units across 7 models with different network architectures, datsasets, and tasks. Each unit is annotated by three human participants.
|
| 76 |
+
|
| 77 |
+
Table 1 summarizes the dataset, which we call MILANNOTATIONS. In total, we construct exemplar sets using neurons from seven vision models, totaling 20k neurons. These models include two architectures for supervised image classification, AlexNet (Krizhevsky et al., 2012) and ResNet152 (He et al., 2015); one architecture for image generation, BigGAN (Brock et al., 2018); and one for unsupervised representation learning trained with a “Bootsrap Your Own Latent” (BYOL) objective (Chen & He, 2020; Grill et al., 2020), DINO (Caron et al., 2021). These models cover two datasets, specifically ImageNet (Deng et al., 2009) and Places365 (Zhou et al., 2017), as well as two completely different families of models, CNNs and Vision Transformers (ViT) (Dosovitskiy et al., 2021). Each exemplar set is shown to three distinct human participants, resulting 60k total annotations. Examples are provided in Appendix A (Fig. 10). We recruit participants from Amazon Mechanical Turk. This data collection effort was approved by MIT’s Committee on the Use of Humans as Experimental Subjects. To control for quality, workers were required to have a HIT acceptance rate of at least $9 5 \%$ , have at least 100 approved HITs, and pass a short qualification test. Full details about our data collection process and the collected data can be found in Appendix A.
|
| 78 |
+
|
| 79 |
+
# 3.4 SEARCHING IN THE SPACE OF DESCRIPTIONS
|
| 80 |
+
|
| 81 |
+
Directly decoding descriptions from $\operatorname { p m i } ( d ; E _ { i } )$ tends to generate disfluent descriptions. This is because the $p ( d )$ term inherently discourages common function words like the from appearing in descriptions. Past work language generation (Wang et al., 2020) has found that this can be remedied by first introducing a hyperparameter $\lambda$ to modulate the importance of $p ( d )$ when computing PMI, giving a new weighted PMI objective:
|
| 82 |
+
|
| 83 |
+
$$
|
| 84 |
+
\operatorname { w p m i } ( d ) = \log p ( d \mid E _ { i } ) - \lambda \log p ( d ) .
|
| 85 |
+
$$
|
| 86 |
+
|
| 87 |
+
Next, search is restricted to a set of captions that are high probability under $p ( d \mid E _ { i } )$ , which are reranked according to Eq. (3). Specifically, we run beam search on $p ( \boldsymbol { d } \mid E _ { i } )$ , and use the full beam after the final search step as a set of candidate descriptions. For all experiments, we set $\lambda = . 2$ and beam size to 50.
|
| 88 |
+
|
| 89 |
+
# 4 DOES MILAN GENERALIZE?
|
| 90 |
+
|
| 91 |
+
Because it is trained on a set of human-annotated exemplar sets obtained from a set of seed networks, MILAN is useful as an automated procedure only if it generalizes and correctly describes neurons in trained models with new architectures, new datasets, and new training objectives. Thus, before describing applications of MILAN to specific interpretability problems, we perform crossvalidation experiments within the MILANNOTATIONS data to validate that MILAN can reliably label new neurons. We additionally verify that MILAN provides benefits over other neuron annotation techniques by comparing its descriptions to three baselines: NetDissect (Bau et al., 2017), which assigns a single concept label to each neuron by comparing the neuron’s exemplars to semantic segmentations of the same images; Compositional Explanations (Mu & Andreas, 2020), which follows a similar procedure to generate logical concept labels; and ordinary image captioning (selecting descriptions using $p ( d \mid E )$ instead of $\operatorname { p m i } ( d ; E ) )$ .
|
| 92 |
+
|
| 93 |
+
Method In each experiment, we train MILAN on a subset of MILANNOTATIONS and evaluate its performance on a held-out subset. To compare MILAN to the baselines, we train on all data except a single held-out network; we obtain the baseline labels by running the publicly available code with the default settings on the held-out network. To test generalization within a network, we train on $90 \%$ of neurons from each network and test on the remaining $10 \%$ . To test generalization across architectures, we train on all AlexNet (ResNet) neurons and test on all ResNet (AlexNet) neurons; we also train on all CNN neurons and test on ViT neurons. To test generalization across datasets, we train on all neurons from models trained on ImageNet (Places) and test on neurons from models for the other datasets. To test generalization across tasks, we train on all classifier neurons (GAN neurons) and test on all GAN neurons (classifier neurons). We measure performance via BERTScore (Zhang et al., 2020) relative to the human annotations. Hyperparameters for each of these experiments are in Appendix C.
|
| 94 |
+
|
| 95 |
+
Table 2: BERTScores for neuron labeling methods relative to human annotations. MILAN obtains higher agreement than Compositional Explanations (CE) or NetDissect (ND).
|
| 96 |
+
|
| 97 |
+
<table><tr><td>Model</td><td>CE</td><td>ND</td><td>p(d|E)</td><td>pmi(d; E)</td></tr><tr><td>AlexNet-ImageNet</td><td>.01</td><td>.24</td><td>.34</td><td>.38</td></tr><tr><td>AlexNet-Places</td><td>.02</td><td>.21</td><td>.31</td><td>.37</td></tr><tr><td>ResNet-ImageNet</td><td>.01</td><td>.25</td><td>.27</td><td>.35</td></tr><tr><td>ResNet-Places</td><td>.03</td><td>.22</td><td>.30</td><td>.31</td></tr></table>
|
| 98 |
+
|
| 99 |
+
Table 3: BERTScores on held out neurons relative to the human annotations. Each train/test split evaluates a different kind of generalization, ultimately evaluating how well MILAN generalizes to networks with architectures, datasets, and tasks unseen in the training annotations.
|
| 100 |
+
|
| 101 |
+
<table><tr><td>Generalization</td><td>Train + Test</td><td>BERTScore (f)</td></tr><tr><td>within network</td><td>AlexNet-ImageNet</td><td>.39</td></tr><tr><td></td><td>AlexNet-Places</td><td>.47</td></tr><tr><td></td><td>ResNet152-ImageNet</td><td>.35</td></tr><tr><td></td><td>ResNet152-Places</td><td>.28</td></tr><tr><td></td><td>BigGAN-ImageNet</td><td>.49</td></tr><tr><td></td><td>BigGAN-Places</td><td>.52</td></tr><tr><td></td><td>Train Test</td><td></td></tr><tr><td rowspan="3">across arch.</td><td>AlexNet</td><td>ResNet152</td><td>.28</td></tr><tr><td>ResNet152</td><td>AlexNet</td><td>.35</td></tr><tr><td>CNNs</td><td>ViT</td><td>.34</td></tr><tr><td>across datasets</td><td>ImageNet</td><td>Places</td><td>.30</td></tr><tr><td rowspan="2"></td><td>Places</td><td>ImageNet</td><td>.33</td></tr><tr><td>Classifiers</td><td>BigGAN</td><td>.34</td></tr><tr><td>across tasks</td><td>BigGAN</td><td>Classifiers</td><td>.27</td></tr></table>
|
| 102 |
+
|
| 103 |
+
Results Table 2 shows results for MILAN and all three baselines applied to four different networks. MILAN obtains higher agreement with human annotations on held-out networks than baselines. It is able to surface highly specific behaviors in its descriptions, like the splashes of water neuron shown in Figure 2 (splashes has no clear equivalent in the concept sets used by NetDissect (ND) or Compositional Explanations (CE)). MILAN also outperforms the ablated $p ( d \mid E )$ decoder, justifying the choice of pmi as an objective for obtaining specific and high-quality descriptions.3
|
| 104 |
+
|
| 105 |
+
Table 3 shows that MILAN exhibits different degrees of generalization across models, with generalization to new GAN neurons in the same network easiest and GAN-to-classifier generalization hardest. MILAN can generalize to novel architectures. It correctly labels ViT neurons (in fully connected layers) as often as it correctly labels other convolutional units (e.g., in AlexNet). We observe that transferability across tasks is asymmetric: agreement scores are higher when transferring from classifier neurons to GAN neurons than the reverse. Finally, Figure 3 presents some of MILAN’s failure cases: when faced with new visual concepts, MILAN sometimes mislabels the concept (e.g., by calling brass instruments noodle dishes), prefers a vague description (e.g., similar color patterns), or ignores the highlighted regions and describes the context instead.
|
| 106 |
+
|
| 107 |
+
We emphasize that this section is primarily intended as a sanity check of the learned models underlying MILAN, and not as direct evidence of its usefulness or reliability as a tool for interpretability. We follow Vaughan & Wallach (2020) in arguing that the final test of any such tool must be its ability to produce actionable insights for human users, as in the three applications described below.
|
| 108 |
+
|
| 109 |
+
# 5 ANALYZING FEATURE IMPORTANCE
|
| 110 |
+
|
| 111 |
+
# MILAN failures
|
| 112 |
+
|
| 113 |
+

|
| 114 |
+
AlexNet conv5-239
|
| 115 |
+
|
| 116 |
+
Human:yellow and green animals, food,
|
| 117 |
+
instruments,and objects
|
| 118 |
+
MILAN: Noodle dishes
|
| 119 |
+
|
| 120 |
+
The previous section shows that MILAN can generalize to new architectures, datasets, and tasks. The remainder of this paper focuses on applications that use generated labels to understand how neurons influence model behavior. As a first example: descriptions in Figure 2 reveal that neurons have different degrees of specificity. Some neurons detect objects with spatial constraints (the area on top of the line), while others fire for low-level but highly specific perceptual qualities (long, thin objects). Still others detect perceptually similar but fundamentally different objects (dog faces and cupcakes). How important are these different classes of neurons to model behavior?
|
| 121 |
+
|
| 122 |
+
BigGAN layerl-486
|
| 123 |
+
|
| 124 |
+

|
| 125 |
+
Human:sea life MILAN: Similar color patterns
|
| 126 |
+
|
| 127 |
+
DINO layer8-72
|
| 128 |
+
|
| 129 |
+
Human: the crowd MILAN: Athletes
|
| 130 |
+
|
| 131 |
+
Method We use MILAN trained on all convolutional units in MILANNOTATIONS to annotate every neuron in ResNet18- ImageNet. We then score each neuron according to one of seven criteria that capture different syntactic or structural properties of the caption. Four syntactic criteria each count the number of times that a specific part of speech appears in a caption: nouns, verbs, prepositions, and adjectives. Three structural criteria measure properties of the entire caption: its length, the depth of its parse tree (a rough measure of its compositional complexity, obtained from the spaCy parser of Honnibal et al. 2020), and its maximum word difference (a measure of the semantic coherence of the description, measured as the maximum Euclidean distance between any two caption words, again obtained via spaCy). Finally, neurons are incrementally ablated in order of their score. The network is tested on the ImageNet validation set and its accuracy recorded. This procedure is then repeated, deleting $2 \%$ of neurons at each step. We also include five trials in which neurons are ordered randomly. Further details and examples of ablated neurons are provided in Appendix D.
|
| 132 |
+
|
| 133 |
+

|
| 134 |
+
Figure 3: Examples of MILAN failures. Failure modes include incorrect generalization (top), vague descriptions for concepts not seen in the training set (middle), and mistaking the context for the highlighted regions (bottom).
|
| 135 |
+
|
| 136 |
+
Results Figure 4 plots accuracy on the ImageNet validation set as a function of the number of ablated neurons. Linguistic features of neuron descriptions highlight several important differences between neurons. First, neurons captioned with many adjectives or prepositions (that is, neurons that capture attributes and relational features) are relatively important to model behavior. Ablating these neurons causes a rapid decline in performance compared to ablating random neurons or nouns. Second, neurons that detect dissimilar concepts appear to be less important. When the caption contains highly dissimilar words (max word diff.), ablation hurts performance substantially less than ablating random neurons. Such neurons sometimes detect non-semantic compositions of concepts like the dog faces and cupcakes neuron shown in Fig. 2; Mu & Andreas (2020) find that these units contribute to non-robust model behavior. We reproduce their robustness experiments using these neurons in Section 5 (Figure 14) and reach similar conclusions. Finally, Figure 4 highlights that neurons satisfying each criterion are not evenly distributed across layers—for example, middle layers contain the largest fraction of relation-selective neurons measured via prepositions.
|
| 137 |
+
|
| 138 |
+

|
| 139 |
+
Figure 4: ResNet18 accuracy on the ImageNet validation set as units are ablated (left, middle), and distribution of neurons matching syntactic and structural criteria in each layer (right). In each configuration, neurons are scored according to a property of their generated description (e.g., number of nouns/words in description, etc.), sorted based on their score, and ablated in that order. Neurons described with adjectives appear crucial for good performance, while neurons described with very different words (measured by word embedding difference; max word diff.) appear less important for good performance. Adjective-selective neurons are most prevalent in early layers, while neurons with large semantic differences are more prevalent in late ones.
|
| 140 |
+
|
| 141 |
+
# 6 AUDITING ANONYMIZED MODELS
|
| 142 |
+
|
| 143 |
+
One recent line of work in computer vision aims to construct privacy-aware datasets, e.g. by detecting and blurring all faces to avoid leakage of information about specific individuals into trained models (Yang et al., 2021). But to what extent does this form of anonymization actually reduce models’ reliance on images of humans? We wish to understand if models trained on blurred data still construct features that can human faces, or even specific categories of faces. A core function of tools for interpretable machine learning is to enable auditing of trained models for such behavior; here, we apply MILAN to investigate the effect of blurringbased dataset privacy.
|
| 144 |
+
|
| 145 |
+
Method We use MILAN to caption a subset of convolutional units in 12 different models pretrained for image classification on the blurred ImageNet images (blurred models). These models are distributed by the original authors of the blurred ImageNet dataset (Yang et al., 2021). We caption the same units in models pretrained on regular ImageNet (unblurred models) obtained from torchvision (Paszke et al., 2019). We then manually inspect all neurons in the blurred and unblurred models for which MILAN descriptions contain the words face, head, nose, eyes, and mouth (using exemplar sets containing only unblurred images).
|
| 146 |
+
|
| 147 |
+

|
| 148 |
+
Figure 5: Change in $\#$ o f face neurons found by MILAN (each pair of points is one model architecture). Blurring reduces, but does not eliminate, units selective for unblurred faces.
|
| 149 |
+
|
| 150 |
+
Results Across models trained on ordinary ImageNet, MILAN identified 213 neurons selective for human faces. Across models trained on blurred ImageNet, MILAN identified 142 neurons selective for human faces. MILAN can distinguish between models trained on blurred and unblurred data (Fig. 5). However, it also reveals that models trained on blurred data acquire neurons selective for unblurred faces. Indeed, it is possible to use MILAN’s labels to extract these face-selective neurons directly. Doing so reveals that several of them are not simply face detectors, but appear to selectively identify female faces (Fig. 6b) and Asian faces (Fig. 6c). Blurring does not prevent models from extracting highly specific features for these attributes. Our results in this section highlight the use of MILAN for both quantitative and qualitative, human-in-the loop auditing of model behavior.
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
images, we report insights about the effects of face blurring. ContributionsFigure 6: (a) The blurred ImageNet dataset. The validation accuracy drops only slightly (0.13%–0.68%) itates subsequ(b–c) Exemplar sets and labels for two neuhardly surprising since face blurring could remove informa- our knowledgrons in a blurred model that activate on unassures us that we can train privacy-aware visual classifiers privacy-awarenition. Througblurred faces—and appear to preferentially on ILSVRC with less than 1% accuracy drop. training on facaccuracy on bo(but not exclusively) respond to faces in speILSVRC, we observe that they are impacted by cific demographic categories.
|
| 154 |
+
|
| 155 |
+
# 7 EDITING SPURIOUS FEATURES
|
| 156 |
+
|
| 157 |
+
Our results demonstrate the utility of face-blurred ILSVRCfor benchmarking. It enhances privacy with only a marginal chine learningSpurious correlations between features and labels are a persistent problem in machine learning accuracy drop. Models trained on it perform competitivelywith models trained on the original ILSVRC dataset. trying to inferapplications, especially in the presence of mismatches between training and testing data (Storkey, Effects on feature transferability. Besides a classifi- tive attributes (2009). In object recognition, one frequent example is correlation between backgrounds and objects cation benchmark, ILSVRC also serves as pretrainingdata for transferring to domains where labeled images are the model’s ou2017; Li et al., (e.g. cows are more likely to appear with green grass in the background, while fish are more likely tion is: Does face obfuscation hurt the transferability of training (Shokto appear with a blue background; Xiao et al. 2020). In a more recent example, models trained on visual features learned from ILSVRC? et al., 2020). Ttim training dajoint text and image data are subject to “text-based adversarial attacks”, in which e.g. an apple with original/blurred images and finetuning on 4 downstream For defending ageneral framewthe word iPod written on it is classified as an iPod (Goh et al., 2021). Our final experiment shows 2009), scene recognition on SUN (Xithat MILAN can be used to reduce models’ sensitivity to these spurious features.
|
| 158 |
+
|
| 159 |
+
Data We create a controlled dataset imitating Goh et al. (2021)’s spurious text features. The dataset consists of 10 ImageNet classes. In the training split, there are 1000 images per class; 500 are annotated with (correct) text labels in the top-left corner. The test set contains 100 images per class (from the ImageNet validation set); in all these images, a random (usually incorrect) text label is included. We train and evaluate a fresh ResNet18 model on this dataset, holding out $10 \%$ of the training data as a validation dataset for early stopping. Training details can be found in Appendix E.
|
| 160 |
+
|
| 161 |
+
Method We use MILAN to obtain descriptions of every residual neuron in the model as well as the first convolutional layer. We identify all neurons whose description contains text, word, or letter. To identify spurious neurons, we first assign each text neuron an independent importance score by removing it from the network and measuring the resulting drop in validation accuracy (with non-adversarial images). We then sort neurons by importance score (with the least important first), and successively ablate them from the model.
|
| 162 |
+
|
| 163 |
+

|
| 164 |
+
|
| 165 |
+

|
| 166 |
+
layer3-134, “words and letters”
|
| 167 |
+
Figure 7: Network editing. (a) We train an image classifier on a synthetic dataset in which half the images include the class label written in text in the corner. (b) We evaluate the classifier on an adversarial test set, in which every image has a random textual label. (c) Nearly a third of neurons in the trained model model detect text, hurting its performance on the test set.
|
| 168 |
+
|
| 169 |
+
Results The result of this procedure on adversarial test accuracy is shown in Fig. 8. Training on the spurious data substantially reduces ResNet18’s performance on the adversarial test set: the model achieves $5 8 . 8 \%$ accuracy, as opposed to $6 9 . 9 \%$ when tested on non-spurious data. MILAN identifies 300 text-related convolutional units (out of 1024 examined) in the model, confirming that the model has indeed devoted substantial capacity to identifying text labels in the image. Figure 7c shows an example neurons specifically selective for airline and truck text. By deleting only 13 such neurons, test accuracy is improved by $4 . 9 \%$ (a $12 \%$ reduction in overall error rate).4 This increase cannot be explained by the sorting procedure described above: if instead we sort all neurons according to validation accuracy (orange line), accuracy improves by less than $1 \%$ . Thus, while this experiment does not completely eliminate the model’s reliance on text features, it shows that MILAN’s predictions enable direct editing of networks to partially mitigate sensitivity to spurious feature correlations.
|
| 170 |
+
|
| 171 |
+

|
| 172 |
+
Figure 8: ResNet18 accuracy on the adversarial test set as neurons are incrementally ablated. Neurons are sorted by the model’s validation accuracy when that single neuron is ablated, then ablated in that order. When ablating neurons that select for the spurious text, the accuracy improves by 4.9 points. When zeroing arbitrary neurons, accuracy still improves, but by much less.
|
| 173 |
+
|
| 174 |
+
# 8 CONCLUSIONS
|
| 175 |
+
|
| 176 |
+
We have presented MILAN, an approach for automatically labeling neurons with natural language descriptions of their behavior. MILAN selects these descriptions by maximizing pointwise mutual information with image regions in which each neuron is active. These mutual information estimates are in turn produced by a pair of learned models trained on MILANNOTATIONS, a dataset of fine-grained image annotations released with this paper. Descriptions generated by MILAN surface diverse aspects of model behavior, and can serve as a foundation for numerous analysis, auditing, and editing techniques workflows for users of deep network models.
|
| 177 |
+
|
| 178 |
+
# IMPACT STATEMENT
|
| 179 |
+
|
| 180 |
+
In contrast to most past work on neuron labeling, MILAN generates neuron labels using another black-box learned model trained on human annotations of visual concepts. With this increase in expressive power come a number of potential limitations: exemplar-based explanations have known shortcomings (Bolukbasi et al., 2021), human annotations of exemplar sets may be noisy, and the captioning model may itself behave in unexpected ways far outside the training domain. The MILANNOTATIONS dataset was collected with annotator tests to address potential data quality issues, and our evaluation in Section 4 characterizes prediction quality on new networks; we nevertheless emphasize that these descriptions are partial and potentially noisy characterizations of neuron function via their behavior on a fixed-sized set of representative inputs. MILAN complements, rather than replaces, both formal verification (Dathathri et al., 2020) and careful review of predictions and datasets by expert humans (Gebru et al., 2018; Mitchell et al., 2019).
|
| 181 |
+
|
| 182 |
+
# ACKNOWLEDGMENTS
|
| 183 |
+
|
| 184 |
+
We thank Ekin Akyurek and Tianxing He for helpful feedback on early drafts of the paper. We ¨ also thank IBM for the donation of the Satori supercomputer that enabled training BigGAN on MIT Places. This work was partially supported by the MIT-IBM Watson AI lab, the SystemsThatLearn initiative at MIT, a Sony Faculty Innovation Award, DARPA SAIL-ON HR0011-20-C-0022, and a hardware gift from NVIDIA under the NVAIL grant program.
|
| 185 |
+
|
| 186 |
+
# REFERENCES
|
| 187 |
+
|
| 188 |
+
Jacob Andreas and Dan Klein. Analogs of linguistic structure in deep representations. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pp. 2893– 2897, Copenhagen, Denmark, September 2017. Association for Computational Linguistics. doi: 10.18653/v1/D17-1311. URL https://www.aclweb.org/anthology/D17-1311.
|
| 189 |
+
|
| 190 |
+
Jacob Andreas, Anca D Dragan, and Dan Klein. Translating neuralese. In ACL (1), 2017.
|
| 191 |
+
|
| 192 |
+
Dzmitry Bahdanau, Kyung Hyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In ICLR, January 2015.
|
| 193 |
+
|
| 194 |
+
Anthony Bau, Yonatan Belinkov, Hassan Sajjad, Nadir Durrani, Fahim Dalvi, and James Glass. Identifying and controlling important neurons in neural machine translation. In International Conference on Learning Representations, 2018.
|
| 195 |
+
|
| 196 |
+
David Bau, Bolei Zhou, Aditya Khosla, Aude Oliva, and Antonio Torralba. Network dissection: Quantifying interpretability of deep visual representations. In Computer Vision and Pattern Recognition (CVPR), 2017.
|
| 197 |
+
|
| 198 |
+
David Bau, Jun-Yan Zhu, Hendrik Strobelt, Bolei Zhou, Joshua B Tenenbaum, William T Freeman, and Antonio Torralba. Gan dissection: Visualizing and understanding generative adversarial networks. In International Conference on Learning Representations (ICLR), 2019.
|
| 199 |
+
|
| 200 |
+
David Bau, Jun-Yan Zhu, Hendrik Strobelt, Agata Lapedriza, Bolei Zhou, and Antonio Torralba. Understanding the role of individual units in a deep neural network. Proceedings of the National Academy of Sciences (PNAS), 2020.
|
| 201 |
+
|
| 202 |
+
Tolga Bolukbasi, Adam Pearce, Ann Yuan, Andy Coenen, Emily Reif, Fernanda Viegas, and Martin ´ Wattenberg. An interpretability illusion for bert. arXiv preprint arXiv:2104.07143, 2021.
|
| 203 |
+
|
| 204 |
+
Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. In International Conference on Learning Representations, 2018.
|
| 205 |
+
|
| 206 |
+
Oana-Maria Camburu, Tim Rocktaschel, Thomas Lukasiewicz, and Phil Blunsom. e-snli: Natural ¨ language inference with natural language explanations. arXiv preprint arXiv:1812.01193, 2018.
|
| 207 |
+
|
| 208 |
+
Nick Cammarata, Gabriel Goh, Shan Carter, Chelsea Voss, Ludwig Schubert, and Chris Olah. Curve circuits. Distill, 6(1):e00024–006, 2021.
|
| 209 |
+
|
| 210 |
+
Mathilde Caron, Hugo Touvron, Ishan Misra, Herve J ´ egou, Julien Mairal, Piotr Bojanowski, and ´ Armand Joulin. Emerging properties in self-supervised vision transformers. In Proceedings of the International Conference on Computer Vision (ICCV), 2021.
|
| 211 |
+
|
| 212 |
+
Xinlei Chen and Kaiming He. Exploring simple siamese representation learning, 2020.
|
| 213 |
+
|
| 214 |
+
Fahim Dalvi, Nadir Durrani, Hassan Sajjad, Yonatan Belinkov, Anthony Bau, and James Glass. What is one grain of sand in the desert? analyzing individual neurons in deep nlp models. In Proceedings of AAAI, 2019.
|
| 215 |
+
|
| 216 |
+
Sumanth Dathathri, Krishnamurthy Dvijotham, Alexey Kurakin, Aditi Raghunathan, Jonathan Uesato, Rudy Bunel, Shreya Shankar, Jacob Steinhardt, Ian Goodfellow, Percy Liang, et al. Enabling certification of verification-agnostic networks via memory-efficient semidefinite programming. In Neural Information Processing Systems (NeurIPS), 2020.
|
| 217 |
+
|
| 218 |
+
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Computer Vision and Pattern Recognition (CVPR), 2009.
|
| 219 |
+
|
| 220 |
+
Jeffrey Donahue, Lisa Anne Hendricks, Sergio Guadarrama, Marcus Rohrbach, Subhashini Venugopalan, Kate Saenko, and Trevor Darrell. Long-term recurrent convolutional networks for visual recognition and description. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2625–2634, 2015.
|
| 221 |
+
|
| 222 |
+
Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021.
|
| 223 |
+
|
| 224 |
+
Dumitru Erhan, Yoshua Bengio, Aaron Courville, and Pascal Vincent. Visualizing higher-layer features of a deep network. 2009.
|
| 225 |
+
|
| 226 |
+
Timnit Gebru, Jamie Morgenstern, Briana Vecchione, Jennifer Wortman Vaughan, Hanna Wallach, Hal Daume III, and Kate Crawford. Datasheets for datasets. ´ arXiv preprint arXiv:1803.09010, 2018.
|
| 227 |
+
|
| 228 |
+
Ross Girshick, Jeff Donahue, Trevor Darrell, and Jitendra Malik. Rich feature hierarchies for accurate object detection and semantic segmentation. In computer vision and pattern recognition (CVPR), pp. 580–587, 2014.
|
| 229 |
+
|
| 230 |
+
Gabriel Goh, Nick Cammarata, Chelsea Voss, Shan Carter, Michael Petrov, Ludwig Schubert, Alec Radford, and Chris Olah. Multimodal neurons in artificial neural networks. Distill, 2021.
|
| 231 |
+
|
| 232 |
+
Jean-Bastien Grill, Florian Strub, Florent Altche, Corentin Tallec, Pierre H. Richemond, Elena ´ Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Daniel Guo, Mohammad Gheshlaghi Azar, Bilal Piot, Koray Kavukcuoglu, Remi Munos, and Michal Valko. Bootstrap your own ´ latent: A new approach to self-supervised learning, 2020.
|
| 233 |
+
|
| 234 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition, 2015.
|
| 235 |
+
|
| 236 |
+
Lisa Anne Hendricks, Zeynep Akata, Marcus Rohrbach, Jeff Donahue, Bernt Schiele, and Trevor Darrell. Generating visual explanations. In European conference on computer vision, pp. 3–19. Springer, 2016.
|
| 237 |
+
|
| 238 |
+
Lisa Anne Hendricks, Ronghang Hu, Trevor Darrell, and Zeynep Akata. Grounding visual explanations. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 264–279, 2018.
|
| 239 |
+
|
| 240 |
+
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. In ¨ Neural computation, 1997.
|
| 241 |
+
|
| 242 |
+
Matthew Honnibal, Ines Montani, Sofie Van Landeghem, and Adriane Boyd. spaCy: Industrialstrength Natural Language Processing in Python, 2020. URL https://doi.org/10.5281/ zenodo.1212303.
|
| 243 |
+
|
| 244 |
+
Paul Jaccard. The distribution of the flora in the alpine zone. New Phytologist, 11(2):37–50, 1912.
|
| 245 |
+
|
| 246 |
+
Andrej Karpathy, Justin Johnson, and Li Fei-Fei. Visualizing and understanding recurrent networks. arXiv preprint arXiv:1506.02078, 2015.
|
| 247 |
+
|
| 248 |
+
Been Kim, Martin Wattenberg, Justin Gilmer, Carrie Cai, James Wexler, Fernanda Viegas, et al. Interpretability beyond feature attribution: Quantitative testing with concept activation vectors (tcav). In International conference on machine learning (ICML), 2018.
|
| 249 |
+
|
| 250 |
+
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems (NeurIPS), 2012.
|
| 251 |
+
|
| 252 |
+
Iro Laina, Ruth C. Fong, and Andrea Vedaldi. Quantifying learnability and describability of visual concepts emerging in representation learning. Advances in Neural Information Processing Systems, 2020-December, 2020. ISSN 1049-5258. Funding Information: We would like to thank Yuki Asano and Christian Rupprecht for helpful discussions and for their feedback on this work. We are also grateful for the EPSRC programme grant Seebibyte EP/M013774/1 (I.L.), ERC starting grant IDIU 638009 (I.L), and Open Philanthropy Project (R.F.). Publisher Copyright: $©$ 2020 Neural information processing systems foundation. All rights reserved.; 34th Conference on Neural Information Processing Systems, NeurIPS 2020 ; Conference date: 06-12-2020 Through 12- 12-2020.
|
| 253 |
+
|
| 254 |
+
Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C. Lawrence Zitnick. Microsoft coco: Common objects in context. In David Fleet, ´ Tomas Pajdla, Bernt Schiele, and Tinne Tuytelaars (eds.), Computer Vision – ECCV 2014, pp. 740–755, Cham, 2014. Springer International Publishing. ISBN 978-3-319-10602-1.
|
| 255 |
+
|
| 256 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR, 2019.
|
| 257 |
+
|
| 258 |
+
Aravindh Mahendran and Andrea Vedaldi. Understanding deep image representations by inverting them. In computer vision and pattern recognition (CVPR), 2015.
|
| 259 |
+
|
| 260 |
+
Margaret Mitchell, Simone Wu, Andrew Zaldivar, Parker Barnes, Lucy Vasserman, Ben Hutchinson, Elena Spitzer, Inioluwa Deborah Raji, and Timnit Gebru. Model cards for model reporting. In Proceedings of the conference on fairness, accountability, and transparency, pp. 220–229, 2019.
|
| 261 |
+
|
| 262 |
+
Ari S Morcos, David GT Barrett, Neil C Rabinowitz, and Matthew Botvinick. On the importance of single directions for generalization. In International Conference on Learning Representations (ICLR), 2018.
|
| 263 |
+
|
| 264 |
+
Jesse Mu and Jacob Andreas. Compositional explanations of neurons. In Advances in Neural Information Processing Systems, 2020.
|
| 265 |
+
|
| 266 |
+
Sharan Narang, Colin Raffel, Katherine Lee, Adam Roberts, Noah Fiedel, and Karishma Malkan. WT5?! Training text-to-text models to explain their predictions. arXiv preprint arXiv:2004.14546, 2020.
|
| 267 |
+
|
| 268 |
+
Chris Olah, Alexander Mordvintsev, and Ludwig Schubert. Feature visualization. In Distill, 2017.
|
| 269 |
+
|
| 270 |
+
Chris Olah, Arvind Satyanarayan, Ian Johnson, Shan Carter, Ludwig Schubert, Katherine Ye, and Alexander Mordvintsev. The building blocks of interpretability. In Distill, 2018.
|
| 271 |
+
|
| 272 |
+
Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting of the Association for Computational Linguistics, pp. 311–318, 2002.
|
| 273 |
+
|
| 274 |
+
Dong Huk Park, Lisa Anne Hendricks, Zeynep Akata, Anna Rohrbach, Bernt Schiele, Trevor Darrell, and Marcus Rohrbach. Multimodal explanations: Justifying decisions and pointing to the evidence. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 8779–8788, 2018.
|
| 275 |
+
|
| 276 |
+
Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, highperformance deep learning library. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alche-´ Buc, E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems 32, pp. 8024–8035. Curran Associates, Inc., 2019. URL http://papers.neurips.cc/paper/ 9015-pytorch-an-imperative-style-high-performance-deep-learning-library.pdf.
|
| 277 |
+
|
| 278 |
+
Kristina Preuer, Gunter Klambauer, Friedrich Rippmann, Sepp Hochreiter, and Thomas Unterthiner. ¨ Interpretable deep learning in drug discovery. In Explainable AI: Interpreting, Explaining and Visualizing Deep Learning, pp. 331–345. Springer, 2019.
|
| 279 |
+
|
| 280 |
+
Alec Radford, Rafal Jozefowicz, and Ilya Sutskever. Learning to generate reviews and discovering sentiment. arXiv preprint arXiv:1704.01444, 2017.
|
| 281 |
+
|
| 282 |
+
Nazneen Fatema Rajani, Bryan McCann, Caiming Xiong, and Richard Socher. Explain yourself! leveraging language models for commonsense reasoning. arXiv preprint arXiv:1906.02361, 2019.
|
| 283 |
+
|
| 284 |
+
Cyrus Rashtchian, Peter Young, Micah Hodosh, and Julia Hockenmaier. Collecting image annotations using amazon’s mechanical turk. In Proceedings of the NAACL HLT 2010 Workshop on Creating Speech and Language Data with Amazon’s Mechanical Turk, pp. 139–147, 2010.
|
| 285 |
+
|
| 286 |
+
Sarah Schwettmann, Evan Hernandez, David Bau, Samuel Klein, Jacob Andreas, and Antonio Torralba. Toward a visual concept vocabulary for gan latent space. International Conference on Computer Vision, 2021.
|
| 287 |
+
|
| 288 |
+
Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Proceedings of ACL, 2018.
|
| 289 |
+
|
| 290 |
+
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In International Conference on Learning Representations (ICLR), 2015.
|
| 291 |
+
|
| 292 |
+
Amos Storkey. When training and test sets are different: characterizing learning transfer. Dataset shift in machine learning, 30:3–28, 2009.
|
| 293 |
+
|
| 294 |
+
Jennifer Wortman Vaughan and Hanna Wallach. A human-centered agenda for intelligible machine learning. Machines We Trust: Getting Along with Artificial Intelligence, 2020.
|
| 295 |
+
|
| 296 |
+
Zeyu Wang, Berthy Feng, Karthik Narasimhan, and Olga Russakovsky. Towards unique and informative captioning of images. In European Conference on Computer Vision (ECCV), 2020.
|
| 297 |
+
|
| 298 |
+
Kai Xiao, Logan Engstrom, Andrew Ilyas, and Aleksander Madry. Noise or signal: The role of image backgrounds in object recognition. arXiv preprint arXiv:2006.09994, 2020.
|
| 299 |
+
|
| 300 |
+
Kelvin Xu, Jimmy Lei Ba, Ryan Kiros, Kyunghyun Cho, Aaron Courville, Ruslan Salakhutdinov, Richard S. Zemel, and Yoshua Bengio. Show, attend and tell: Neural image caption generation with visual attention. In Proceedings of the 32nd International Conference on International Conference on Machine Learning - Volume 37, ICML’15, pp. 2048–2057. JMLR.org, 2015.
|
| 301 |
+
|
| 302 |
+
Kaiyu Yang, Jacqueline Yau, Li Fei-Fei, Jia Deng, and Olga Russakovsky. A study of face obfuscation in imagenet. arXiv preprint arXiv:2103.06191, 2021.
|
| 303 |
+
|
| 304 |
+
Omar Zaidan and Jason Eisner. Modeling annotators: A generative approach to learning from annotator rationales. In Proceedings of the 2008 conference on Empirical methods in natural language processing, pp. 31–40, 2008.
|
| 305 |
+
|
| 306 |
+
Matthew D Zeiler and Rob Fergus. Visualizing and understanding convolutional networks. ECCV, 2014.
|
| 307 |
+
|
| 308 |
+
Rowan Zellers, Yonatan Bisk, Ali Farhadi, and Yejin Choi. From recognition to cognition: Visual commonsense reasoning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 6720–6731, 2019.
|
| 309 |
+
|
| 310 |
+

|
| 311 |
+
Figure 9: Screenshots of the Amazon Mechanical Turk forms we used to collect the CaNCAn dataset. (a) The qualification test. Workers are asked to pick the best description for two hand-chosen neurons from a model not included in our corpus. (b) The annotation form. Workers are shown the top-15 highest-activating images for a neuron and asked to describe what is common to them in one sentence.
|
| 312 |
+
|
| 313 |
+
Tianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q. Weinberger, and Yoav Artzi. Bertscore: Evaluating text generation with bert. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=SkeHuCVFDr.
|
| 314 |
+
|
| 315 |
+
Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 million image database for scene recognition. IEEE transactions on pattern analysis and machine intelligence, 2017.
|
| 316 |
+
|
| 317 |
+
Bolei Zhou, Hang Zhao, Xavier Puig, Tete Xiao, Sanja Fidler, Adela Barriuso, and Antonio Torralba. Semantic understanding of scenes through the ade20k dataset. International Journal of Computer Vision, 127(3):302–321, 2019.
|
| 318 |
+
|
| 319 |
+
# A MILANNOTATIONS
|
| 320 |
+
|
| 321 |
+
We recruited annotators from Amazon Mechanical Turk to describe one neuron at a time given its top-activating images. A screenshot of the template is shown in Figure 9b. Participants were given the instructions:
|
| 322 |
+
|
| 323 |
+
Instructions: In one sentence, summarize everything shown inside the highlighted regions in the images. They might all show the same thing, or they might show several different things.
|
| 324 |
+
In your answer, DO NOT mention that you are describing highlighted regions in images.
|
| 325 |
+
|
| 326 |
+
Workers were given up to an hour to complete each annotation, but early trials revealed they required about 30 seconds per HIT. We paid workers $\$ 0.08$ per annotation, which at $\$ 9.60$ per hour exceeds the United States federal minimum wage.
|
| 327 |
+
|
| 328 |
+

|
| 329 |
+
Figure 10: Example human annotations for neuron exemplars in MILANNOTATIONS, which contains annotations for neurons in seven networks. Each set of images is annotated by three distinct human participants.
|
| 330 |
+
|
| 331 |
+
To control for quality, we required workers to pass a short qualification test in which they had to choose the most descriptive caption for two manually chosen neurons from VGG-16 (Simonyan & Zisserman, 2015) trained on ImageNet (not included as part of MILANNOTATIONS). A screenshot of this test is shown in Figure 9a.
|
| 332 |
+
|
| 333 |
+
Table 4 shows the inter-annotator agreement of neuron annotations for each model, and Table 5 shows some corpus statistics broken down by model and layer. Layers closest to the image (early layers in CNNs and later layers in GANs) are generally described with more adjectives than other layers, while annotations for layers farther from the image include more nouns, perhaps highlighting the low-level perceptual role of the former and the scene- and objectcentric behavior of the latter. Layers farther from the image tend to have longer descriptions (e.g. in BigGAN-ImageNet, AlexNet
|
| 334 |
+
|
| 335 |
+
<table><tr><td>Model</td><td>Dataset</td><td>IAA</td></tr><tr><td>AlexNet</td><td>ImageNet</td><td>.25</td></tr><tr><td></td><td>Places365</td><td>.27</td></tr><tr><td>ResNet152</td><td>ImageNet</td><td>.21</td></tr><tr><td></td><td>Places365</td><td>.17</td></tr><tr><td>BigGAN</td><td>ImageNet</td><td>.26</td></tr><tr><td></td><td>Places365</td><td>.24</td></tr><tr><td>DINO</td><td>ImageNet</td><td>.23</td></tr></table>
|
| 336 |
+
|
| 337 |
+
Table 4: Average inter-annotator agreement among human annotations, measured in BERTScore. Some models have clearer neuron exemplars than others.
|
| 338 |
+
|
| 339 |
+
ImageNet), but this trend is not consistent across all models (e.g. in models trained on Places365, the middle layers have the longest average caption length).
|
| 340 |
+
|
| 341 |
+
# B MILAN IMPLEMENTATION DETAILS
|
| 342 |
+
|
| 343 |
+
# B.1 IMPLEMENTING $p ( d \mid E )$
|
| 344 |
+
|
| 345 |
+
We build on the Show, Attend, and Tell (SAT) model for describing images (Xu et al., 2015). SAT is designed for describing the high-level content of a single images, so we must make several modifications to support our use case, where our goal is to describe sets of regions in images.
|
| 346 |
+
|
| 347 |
+
Table 5: Corpus statistics for MILANNOTATIONS descriptions broken down by model and layer. The # Words column reports the number of unique words used across all layer annotations, the Len. column reports the average number of words in each caption for that layer, and the $\%$ columns report the percentage of all words across all captions for that layer that are a specific part of speech.
|
| 348 |
+
|
| 349 |
+
<table><tr><td>Model</td><td>Layer</td><td>#Units</td><td>#Words</td><td>Len.</td><td>% Noun</td><td>% Adj</td><td>% Prep</td></tr><tr><td>AlexNet-ImageNet</td><td>conv1</td><td>64</td><td>185</td><td>4.8</td><td>37.5</td><td>24.3</td><td>12.2</td></tr><tr><td></td><td>conv2</td><td>192</td><td>384</td><td>5.5</td><td>37.8</td><td>19.4</td><td>13.2</td></tr><tr><td></td><td>conv3</td><td>384</td><td>661</td><td>5.3</td><td>41.0</td><td>16.4</td><td>13.0</td></tr><tr><td></td><td>conv4</td><td>256</td><td>608</td><td>5.5</td><td>43.1</td><td>11.9</td><td>12.5</td></tr><tr><td></td><td>conv5</td><td>256</td><td>693</td><td>5.5</td><td>46.0</td><td>10.2</td><td>10.4</td></tr><tr><td>AlexNet-Places365</td><td>conv1</td><td>96</td><td>153</td><td>4.3</td><td>38.4</td><td>26.8</td><td>12.7</td></tr><tr><td></td><td>conv2</td><td>256</td><td>297</td><td>4.8</td><td>37.8</td><td>26.0</td><td>12.7</td></tr><tr><td></td><td>conv3</td><td>384</td><td>412</td><td>4.7</td><td>40.2</td><td>24.8</td><td>10.5</td></tr><tr><td></td><td>conv4</td><td>384</td><td>483</td><td>4.4</td><td>43.7</td><td>19.9</td><td>10.3</td></tr><tr><td></td><td>conv5</td><td>256</td><td>486</td><td>4.1</td><td>45.8</td><td>17.6</td><td>10.6</td></tr><tr><td>ResNet152-ImageNet</td><td>conv1</td><td>64</td><td>285</td><td>4.7</td><td>43.8</td><td>11.8</td><td>10.3</td></tr><tr><td></td><td>layer1</td><td>256</td><td>653</td><td>5.5</td><td>43.1</td><td>10.5</td><td>12.5</td></tr><tr><td></td><td>layer2</td><td>512</td><td>936</td><td>5.1</td><td>44.0</td><td>12.7</td><td>12.6</td></tr><tr><td></td><td>layer3</td><td>1024</td><td>1222</td><td>4.2</td><td>49.6</td><td>10.9</td><td>11.3</td></tr><tr><td></td><td>layer4</td><td>2048</td><td>1728</td><td>4.6</td><td>47.8</td><td>8.6</td><td>7.8</td></tr><tr><td>ResNet152-Places365</td><td>conv1</td><td>64</td><td>283</td><td>5.2</td><td>47.3</td><td>11.1</td><td>14.6</td></tr><tr><td></td><td>layer1</td><td>256</td><td>633</td><td>5.3</td><td>46.3</td><td>9.4</td><td>13.3</td></tr><tr><td></td><td>layer2</td><td>512</td><td>986</td><td>5.8</td><td>46.0</td><td>8.3</td><td>13.8</td></tr><tr><td></td><td>layer3</td><td>1024</td><td>1389</td><td>4.8</td><td>48.2</td><td>6.7</td><td>12.7</td></tr><tr><td></td><td>layer4</td><td>2048</td><td>1970</td><td>5.3</td><td>46.3</td><td>5.5</td><td>11.9</td></tr><tr><td>BigGAN-ImageNet</td><td>layer0</td><td>1536</td><td>1147</td><td>3.9</td><td>52.4</td><td>7.8</td><td>8.2</td></tr><tr><td></td><td>layer1</td><td>768</td><td>853</td><td>3.5</td><td>53.0</td><td>9.4</td><td>8.9</td></tr><tr><td></td><td>layer2</td><td>768</td><td>618</td><td>3.2</td><td>52.6</td><td>12.3</td><td>9.5</td></tr><tr><td></td><td>layer3</td><td>384</td><td>495</td><td>3.7</td><td>49.9</td><td>14.3</td><td>10.9</td></tr><tr><td></td><td>layer4</td><td>192</td><td>269</td><td>3.3</td><td>47.9</td><td>18.0</td><td>13.4</td></tr><tr><td></td><td>layer5</td><td>96</td><td>69</td><td>2.6</td><td>53.6</td><td>22.8</td><td>14.6</td></tr><tr><td>BigGAN-Places365</td><td>layer0</td><td>2048</td><td>1062</td><td>4.2</td><td>53.3</td><td>5.4</td><td>8.3</td></tr><tr><td></td><td>layer1</td><td>1024</td><td>708</td><td>3.9</td><td>55.0</td><td>6.1</td><td>11.5</td></tr><tr><td></td><td>layer2</td><td>1024</td><td>410</td><td>4.6</td><td>52.7</td><td>8.1</td><td>16.3</td></tr><tr><td></td><td>layer3</td><td>512</td><td>273</td><td>5.2</td><td>50.4</td><td>7.6</td><td>15.0</td></tr><tr><td></td><td>layer4</td><td>256</td><td>192</td><td>4.6</td><td>47.5</td><td>9.3</td><td>14.9</td></tr><tr><td></td><td>layer5</td><td>128</td><td>123</td><td>4.2</td><td>46.7</td><td>13.5</td><td>13.0</td></tr><tr><td>DINO-ImageNet</td><td>layer0</td><td>100</td><td>320</td><td>4.4</td><td>45.7</td><td>12.7</td><td>4.8</td></tr><tr><td></td><td>layer1</td><td>100</td><td>321</td><td>4.2</td><td>49.8</td><td>9.1</td><td>6.8</td></tr><tr><td></td><td>layer2</td><td>100</td><td>285</td><td>3.9</td><td>53.3</td><td>6.2</td><td>7.5</td></tr><tr><td></td><td>layer3</td><td>100</td><td>312</td><td>3.9</td><td>54.4</td><td>6.2</td><td>7.1</td></tr><tr><td></td><td>layer4</td><td>100</td><td>304</td><td>3.9</td><td>53.5</td><td>4.4</td><td>7.0</td></tr><tr><td></td><td>layer5</td><td>100</td><td>287</td><td>3.5</td><td>55.1</td><td>5.5</td><td>5.2</td></tr><tr><td></td><td>layer6</td><td>100</td><td>377</td><td>3.9</td><td>51.3</td><td>8.2</td><td>5.4</td></tr><tr><td></td><td>layer7</td><td>100</td><td>374</td><td>3.8</td><td>52.0</td><td>6.4</td><td>6.2</td></tr><tr><td></td><td>layer8</td><td>100</td><td>330</td><td>3.4</td><td>53.0</td><td>7.0</td><td>8.8</td></tr><tr><td></td><td>layer9</td><td>100</td><td>350</td><td>3.1</td><td>56.1</td><td>6.3</td><td>9.6</td></tr><tr><td></td><td>layer10</td><td>100</td><td>369</td><td>3.9</td><td>50.3</td><td>9.3</td><td>8.2</td></tr><tr><td></td><td>layer11</td><td>100</td><td>294</td><td>3.3</td><td>52.4</td><td>7.5</td><td>9.4</td></tr><tr><td>Total</td><td></td><td>20272</td><td>4597</td><td>4.5</td><td>48.7</td><td>9.4</td><td>10.9</td></tr></table>
|
| 350 |
+
|
| 351 |
+

|
| 352 |
+
Figure 11: Neuron captioning model. Given the set of top-activating images for a neuron and masks for the regions of greatest activation, we extract features maps from each convolutional layer of a pretrained image classifier. We then downsample the masks and use them to pool the features before concatenating them into a single feature vector per image. These feature vectors are used as input to the decoder attention mechanism.
|
| 353 |
+
|
| 354 |
+
In the original SAT architecture, a single input image $x$ is first converted to visual features by passing it through an encoder network $g$ , typically an image classifier pretrained on a large dataset. The output of the last convolutional layer is extracted as a matrix of visual features:
|
| 355 |
+
|
| 356 |
+
$$
|
| 357 |
+
v = [ v _ { 1 } ; v _ { 2 } ; \ldots ; v _ { k } ]
|
| 358 |
+
$$
|
| 359 |
+
|
| 360 |
+
These visual features are passed to a decoder LSTM whose hidden state is initialized as a function of the mean of the visual features $\overline { { v } } = 1 / k \textstyle \sum _ { i } v _ { i }$ . At each time step, the decoder attends over the features using an additive attention mechanism (Bahdanau et al., 2015), then consumes the attenuated visual features and previous token as input to predict the next token.
|
| 361 |
+
|
| 362 |
+
The SAT architecture makes few assumptions about the structure of the visual features. We will take advantage of this generality and modify how $v$ is constructed to support our task, leaving the decoder architecture intact.
|
| 363 |
+
|
| 364 |
+
Now, instead of a single image $x$ , the model inputs are the $k$ top-activating images $x _ { j }$ for a neuron as well as a mask $m _ { j }$ for each image that highlights the regions of greatest activation. Our task is to describe what the neuron is detecting, based strictly on the highlighted regions of the $x _ { j }$ . In support of this, the visual features must (1) include information about all $k$ images, (2) encode multiple resolutions of the images to capture both low-level perceptual and high-level scene details about the image, and (3) pay most (but not exclusive) attention to the regions of greatest activation in the image.
|
| 365 |
+
|
| 366 |
+
Describing sets of images The $k$ features in SAT correspond to different spatial localities of a single image. In our architecture, each feature $v _ { j }$ corresponds to one input image $x _ { j }$ .
|
| 367 |
+
|
| 368 |
+
Encoding multiple resolutions Instead of encoding the image with just the last convolutional layer of $g$ , we use pooled convolutional features from every layer. Formally, let $g _ { \ell } ( x )$ denote the output of layer $\ell$ in the pretrained image encoder with $L$ layers, and let pool denote a pooling function that uses the mask to pool the features (described further below). The feature vector for the $j$ th image $x _ { j }$ is:
|
| 369 |
+
|
| 370 |
+
$$
|
| 371 |
+
v _ { j } = \left[ \mathsf { p o o l } ( m _ { j } , g _ { 1 } ( x _ { j } ) ) ; \ldots ; \mathsf { p o o l } ( m _ { i } , g _ { L } ( x _ { j } ) ) \right]
|
| 372 |
+
$$
|
| 373 |
+
|
| 374 |
+
Highlighting regions of greatest activation Each of the top-activating images $x _ { j }$ that we hand to our model comes with a mask $m _ { j }$ highlighting the image regions of greatest activation. We incorporate these masks into the pooling function pool from above. Specifically, we first downsample the mask $m _ { j }$ to the same spatial shape as $g _ { \ell } ( x _ { j } )$ using bilinear interpolation, which we denote upsample $( m _ { j } )$ . We then apply the mask to each channel $c$ at layer $\ell$ , written $g _ { \ell , c } ( x _ { j } )$ , via elementwise multiplication $( \odot )$ with upsample $( m _ { j } )$ . Finally, we sum spatially along each channel, resulting in a length $c$ vector. Formally:
|
| 375 |
+
|
| 376 |
+
$$
|
| 377 |
+
\mathsf { p o o l } _ { c } ( g _ { \ell } ( x _ { j } ) ) = \mathbb { 1 } ^ { \top } \mathsf { v e c } ( \mathsf { u p s a m p l e } ( m _ { j } ) \odot g _ { \ell , c } ( x _ { j } ) )
|
| 378 |
+
$$
|
| 379 |
+
|
| 380 |
+
Each $v _ { i }$ is thus a length $\textstyle \sum _ { \ell } C _ { \ell }$ vector, where $C _ { \ell }$ is the number of channels at layer $\ell$ of $g$
|
| 381 |
+
|
| 382 |
+
Table 6: Statistics for MILAN-generated descriptions on the held-out neurons from the generalization experiments of Section 4. Columns are the same as in Table 5.
|
| 383 |
+
|
| 384 |
+
<table><tr><td>Gen.</td><td colspan="2">Train + Test</td><td># Units</td><td>#Words</td><td>Len.</td><td>% Noun</td><td>% Adj</td><td>%Prep</td></tr><tr><td>within netwok</td><td colspan="2">AlexNet-ImageNet</td><td>115</td><td>100</td><td>3.5</td><td>45.7</td><td>16.4</td><td>11.9</td></tr><tr><td></td><td colspan="2">AlexNet-Places</td><td>137</td><td>46</td><td>2.5</td><td>49.3</td><td>28.7</td><td>9.6</td></tr><tr><td></td><td colspan="2">ResNet-ImageNet</td><td>390</td><td>121</td><td>2.8</td><td>52.2</td><td>23.8</td><td>11.7</td></tr><tr><td></td><td colspan="2">ResNet-Places</td><td>390</td><td>376</td><td>4.3</td><td>46.5</td><td>8.7</td><td>10.9</td></tr><tr><td></td><td colspan="2">BigGAN-ImageNet</td><td>374</td><td>112</td><td>2.2</td><td>59.8</td><td>17.5</td><td>10.4</td></tr><tr><td></td><td colspan="2">BigGAN-Places</td><td>499</td><td>245</td><td>3.8</td><td>54.2</td><td>6.0</td><td>9.0</td></tr><tr><td></td><td>Train</td><td>Test</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>across arch.</td><td>AlexNet</td><td>ResNet</td><td>7808</td><td>326</td><td>3.0</td><td>46.1</td><td>21.0</td><td>8.9</td></tr><tr><td></td><td>ResNet</td><td>AlexNet</td><td>2528</td><td>275</td><td>2.7</td><td>48.0</td><td>27.1</td><td>6.4</td></tr><tr><td></td><td>CNNs</td><td>ViT</td><td>1200</td><td>200</td><td>2.6</td><td>55.0</td><td>18.2</td><td>13.0</td></tr><tr><td>across dataset</td><td>ImageNet</td><td>Places</td><td>10272</td><td>271</td><td>2.2</td><td>58.8</td><td>14.0</td><td>13.8</td></tr><tr><td></td><td>Places</td><td>ImageNet</td><td>8800</td><td>309</td><td>3.1</td><td>47.8</td><td>26.9</td><td>7.8</td></tr><tr><td>across task</td><td>Classifiers</td><td>BigGAN</td><td>8736</td><td>202</td><td>2.1</td><td>53.0</td><td>25.3</td><td>6.1</td></tr><tr><td></td><td>BigGAN</td><td>Classifiers</td><td>10336</td><td>336</td><td>3.2</td><td>54.3</td><td>14.2</td><td>16.8</td></tr><tr><td>Total</td><td></td><td></td><td>51585</td><td>1002</td><td>2.7</td><td>51.9</td><td>19.8</td><td>11.1</td></tr></table>
|
| 385 |
+
|
| 386 |
+
Throughout our experiments, $g$ is a ResNet101 pretrained for image classification on ImageNet, provided by PyTorch Paszke et al. (2019). We extract visual features from the first convolutional layer and all four residual layers. We do not fine tune any parameters in the encoder. The decoder is a single LSTM cell with an input embedding size of 128 and a hidden size of 512. The attention mechanism linearly maps the current hidden state and all visual feature vectors to size 512 vectors before computing attention weights. We always decode for a maximum of 15 steps. The rest of the decoder is exactly the same as in $\mathrm { X u }$ et al. (2015).
|
| 387 |
+
|
| 388 |
+
The model is trained to minimize cross entropy on the training set using the AdamW optimizer Loshchilov & Hutter (2019) with a learning rate of 1e-3 and minibatches of size 64. We include the double stochasticity regularization term used by Xu et al. (2015) with $\lambda = 1$ . We also apply dropout $\left( p = . 5 \right)$ to the hidden state before predicting the next word. Across configurations, $10 \%$ of the training data is held out and used as a validation set, and training stops when the model’s BLEU score (Papineni et al., 2002) does not improve on this set for 4 epochs, up to a maximum of 100 epochs.
|
| 389 |
+
|
| 390 |
+
# B.2 IMPLEMENTING $p ( d )$
|
| 391 |
+
|
| 392 |
+
We implement $p ( d )$ using a two-layer LSTM language model (Hochreiter & Schmidhuber, 1997). We use an input embedding size of 128 with a hidden state size and cell size of 512. We apply dropout to non-recurrent connections $( p = . 5 )$ during training and hold out $10 \%$ of the training dataset as a validation set and following the same early stopping procedure as in Appendix B.1, except we stop on validation loss instead of BLEU.
|
| 393 |
+
|
| 394 |
+
# C GENERALIZATION EXPERIMENT DETAILS
|
| 395 |
+
|
| 396 |
+
In each experiment, MILAN is trained with the hyperparameters described in Appendix B and Section 3.4, with the sole exception being the within-network splits—for these, we increase the early stopping criterion to require 10 epochs of no improvement to account for the training instability caused by the small training set size.
|
| 397 |
+
|
| 398 |
+
To obtain NetDissect labels, we obtain image exemplars with the same settings as we do for MILAN, and we obtain segmentations using the full segmentation vocabulary minus the textures.
|
| 399 |
+
|
| 400 |
+
To obtain Compositional Explanations labels, we search for up to length 3 formulas (comprised of not, and, and or operators) with a beam size of 5 and no length penalty. Image region exemplars and corresponding segmentations come from the ADE20k dataset (Zhou et al., 2019).
|
| 401 |
+
|
| 402 |
+
Finally, Table 6 shows statistics for MILAN descriptions generated on the held out sets from each generalization experiment. Compared to human annotators (Table 5), MILAN descriptions are on
|
| 403 |
+
|
| 404 |
+
# MILAN examples
|
| 405 |
+
|
| 406 |
+
ResNet-ImageNet layer3-982
|
| 407 |
+
|
| 408 |
+
AlexNet-Places conv5-144
|
| 409 |
+
|
| 410 |
+
BigGAN-ImageNet layer2-100
|
| 411 |
+
|
| 412 |
+

|
| 413 |
+
|
| 414 |
+
Human: curvatures of different objects MILAN: The edges of objects
|
| 415 |
+
|
| 416 |
+

|
| 417 |
+
|
| 418 |
+
Human: horizontal lines MILAN: Diagonal lines
|
| 419 |
+
|
| 420 |
+

|
| 421 |
+
|
| 422 |
+
Human: noses MILAN: Dog noses
|
| 423 |
+
|
| 424 |
+
ResNet-ImageNet layer3-298
|
| 425 |
+
|
| 426 |
+

|
| 427 |
+
|
| 428 |
+
Human: areas that look like keys on a keyboard MILAN: Number pads
|
| 429 |
+
|
| 430 |
+
# AlexNet-Places conv3-196
|
| 431 |
+
|
| 432 |
+

|
| 433 |
+
|
| 434 |
+
Human: surfaces that show a pattern
|
| 435 |
+
composed of lines
|
| 436 |
+
MILAN: Grates
|
| 437 |
+
|
| 438 |
+

|
| 439 |
+
BigGAN-Places layer0-1415
|
| 440 |
+
|
| 441 |
+
Human: surfaces MILAN: The ground
|
| 442 |
+
|
| 443 |
+
ResNet-ImageNet conv1-27
|
| 444 |
+
|
| 445 |
+

|
| 446 |
+
|
| 447 |
+
Human: blue areas in pictures MILAN: Blue lines
|
| 448 |
+
|
| 449 |
+
AlexNet-Places conv4-207
|
| 450 |
+
|
| 451 |
+

|
| 452 |
+
|
| 453 |
+
Human: heads and balloons MILAN: Faces of things
|
| 454 |
+
|
| 455 |
+
BigGAN-ImageNet layer0-1411
|
| 456 |
+
|
| 457 |
+

|
| 458 |
+
|
| 459 |
+
Human: fruit, insects,food MILAN: Food
|
| 460 |
+
|
| 461 |
+
AlexNet ImageNet conv2-91
|
| 462 |
+
|
| 463 |
+

|
| 464 |
+
|
| 465 |
+
Human: red colored objects MILAN: Orange and red objects
|
| 466 |
+
|
| 467 |
+

|
| 468 |
+
AlexNet-ImageNet conv5-119
|
| 469 |
+
|
| 470 |
+
Human: green animals and plants MILAN: Grass
|
| 471 |
+
|
| 472 |
+
DINO-ImageNet layer9-52
|
| 473 |
+
|
| 474 |
+

|
| 475 |
+
|
| 476 |
+
Human: hands of a person MILAN: Human hands
|
| 477 |
+
|
| 478 |
+
AlexNet-Places conv4-188
|
| 479 |
+
|
| 480 |
+

|
| 481 |
+
|
| 482 |
+
Human: windows and screens MILAN: Signs and screens
|
| 483 |
+
|
| 484 |
+

|
| 485 |
+
AlexNet-ImageNet conv2-126
|
| 486 |
+
|
| 487 |
+
Human: red-orange text and objects MILAN: Red colored object with text
|
| 488 |
+
|
| 489 |
+

|
| 490 |
+
DINO-ImageNet layer8-18
|
| 491 |
+
|
| 492 |
+
Human: sign or monument,keyboard MILAN: Sewer cover, text on a sign, text on a sign, text on
|
| 493 |
+
|
| 494 |
+
AlexNet-Places conv2-77
|
| 495 |
+
|
| 496 |
+

|
| 497 |
+
|
| 498 |
+
Human: picture of white fence beams MILAN: Fencing
|
| 499 |
+
|
| 500 |
+
# AlexNet-ImageNet conv4-5
|
| 501 |
+
|
| 502 |
+

|
| 503 |
+
|
| 504 |
+
Human: circles and rounded edges of many things and people MILAN: Wheels of an object
|
| 505 |
+
|
| 506 |
+
DINO-ImageNet layerl-25
|
| 507 |
+
|
| 508 |
+

|
| 509 |
+
Human: vertical white and blue lines MILAN: Brighter areas in objects
|
| 510 |
+
|
| 511 |
+
Figure 12: Randomly chosen examples of MILAN-generated descriptions from the generalization experiments of Section 4.
|
| 512 |
+
|
| 513 |
+
average shorter (2.7 vs. 4.5 tokens), use fewer unique words (1k vs. 4.6k), and contain adjectives twice as often $9 . 4 \%$ vs. $1 9 . 8 \%$ ). Figure 12 contains additional examples, chosen at random.
|
| 514 |
+
|
| 515 |
+
# D ANALYSIS EXPERIMENT DETAILS
|
| 516 |
+
|
| 517 |
+
We obtain the ResNet18 model pretrained on ImageNet from torchvision (Paszke et al., 2019). We obtain neuron descriptions for the same layers that we annotate in ResNet152 (Section 3.3) using the MILAN hyperparameters described in Section 3.2 and Section 3.4. We obtain part of speech tags, parse trees, and word vectors for each description from spaCy (Honnibal et al., 2020).
|
| 518 |
+
|
| 519 |
+
Figure 13 shows examples of neurons that scored high under each criterion (and consequently were among the first ablated in Fig. 5). Note that these examples include some failure cases of MILAN: for example, in the # verbs example, MILAN incorrectly categorizes all brass instruments as flutes; and in the # adjectives example, the description is disfluent. Nevertheless, these examples confirm our intuitions about the kinds of neurons selected for by each scoring criterion, as described in Section 5.
|
| 520 |
+
|
| 521 |
+

|
| 522 |
+
Figure 13: Examples of ablated neurons for each condition Section 5, chosen from among the first 10 ablated.
|
| 523 |
+
|
| 524 |
+

|
| 525 |
+
Figure 14: Cut-and-paste adversarial attacks highlighting non-robust behavior by a neuron that scored high on the max-word-diff criterion of Section 5. (a) MILAN finds this neuron automatically because the generated description mentions two or more dissimilar concepts: animals and vehicles. The neuron is directly connected to the final fully-connected output layer, and strongly influences amphibian, hermit crab, and jeep predictions according to the connection weights. (b) To construct adversarial inputs, we pick three images from the ImageNet validation set that do not include concepts detected by the neuron. (c) We then select a different set of images to act as distractors that do include the concepts detected by the neuron. (d) By cutting and pasting the central object from the distractor to the original image, the model is fooled into predicting a class label that is completely unrelated to the pasted object: e.g., it predicts amphibian when the military vehicle is pasted.
|
| 526 |
+
|
| 527 |
+
We hypothesized in Section 5 that neurons scoring high on the max-word-diff criterion correspond to non-robust behavior by the model. Figure 14 provides some evidence for this hypothesis: we construct cut-and-paste adversarial inputs in the style of Mu & Andreas (2020). Specifically, we look at the example max-word-diff neuron shown in Figure 13, crudely copy and paste one of the objects mentioned in its description (e.g., a vehicle-related object like a half track), and show that this can cause the model to predict one of the other concepts in the description (e.g., an animal-related class like amphibian).
|
| 528 |
+
|
| 529 |
+
# E EDITING EXPERIMENT DETAILS
|
| 530 |
+
|
| 531 |
+
Hyperparameters We train a randomly initialized ResNet18 on the spurious training dataset for a maximum of 100 epochs with a learning rate of 1e-4 and a minibatch size of 128. We annotate the same convolutional and residual units we did for ResNet152 in Section 3.3. We stop training when validation loss does not improve for 4 epochs.
|
| 532 |
+
|
| 533 |
+
How many neurons should we remove? In practice, we cannot incrementally test our model on an adversarial set. So how do we decide on the number of neurons to zero? One option is to look solely at validation accuracy. Figure 15 recreates Figure 8 with accuracy on the held out validation set (which is distributed like the training dataset) instead of accuracy on the adversarial test set. The accuracy starts peaks and starts decreasing earlier than in Fig. 8, but if we were to choose the number to be the largest before validation accuracy permanently decreases, we would choose 8 neurons, which would still result in a $3 . 1 \%$ increase in adversarial accuracy.
|
| 534 |
+
|
| 535 |
+

|
| 536 |
+
Figure 15: Same as Fig. 8, but shows accuracy on the validation dataset, which is distributed identically to the training dataset. Dotted line denotes initial accuracy.
|
md/dev/RKiWwhocuiU/RKiWwhocuiU.md
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DOMAIN GENERALIZATION WITH SMALL DATA
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
In this work, we propose to tackle the problem of domain generalization in the context of insufficient samples. Instead of extracting latent feature embeddings based on deterministic models, we propose to learn a domain-invariant representation based on the probabilistic framework by mapping each data point into probabilistic embeddings. Specifically, we first extend empirical maximum mean discrepancy (MMD) to a novel probabilistic MMD that can measure the discrepancy between mixture distributions (i.e., source domains) consisted of a serial of latent distributions rather than latent points. Moreover, instead of imposing the contrastive semantic alignment (CSA) loss based on pairs of latent points, a novel probabilistic CSA loss encourages positive probabilistic embedding pairs to be closer while pulling other negative ones apart. Benefiting from the learned representation captured by probabilistic models, our proposed method can marriage the measurement on the distribution over distributions (i.e., the global perspective alignment) and the distribution-based contrastive semantic alignment (i.e., the local perspective alignment). Extensive experimental results on three challenging medical datasets show the effectiveness of our proposed method in the context of insufficient data compared with state-of-the-art baseline methods.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Nowadays, we have witnessed a lot of successes via imposing machine learning techniques in a variety of tasks related to computer vision and natural language processing, such as face recognition Li et al. (2022b), object detection Zaidi et al. (2022), and speech recognition Mridha et al. (2022). Despite many achievements so far, the widely-adopted assumption for most existing methods, i.e., it is identically and independently distributed between training and testing data, may not always hold in actual applications Zhou et al. (2022); Liu et al. (2022). In the real-world scenario, it is quite common that the distribution between training and testing data may be different, owing to sophisticated environments. For example, resulting from the differences of device vendor and staining method, acquired histopathological images of breast cancer from different healthcare centers exist significant domain gaps (a.k.a., domain shift, see Figure 1 for more details), which may lead to the catastrophic deterioration of the performance Qi et al. (2020). To address this issue, domain generalization (DG) is developed to learn a model from multiple related yet different domains (a.k.a., source domains) that is able to generalize well on unseen testing domain (a.k.a., target domain).
|
| 12 |
+
|
| 13 |
+
Recently, researchers proposed quite a few domain generalization approaches, such as data augmentation with randomization Yue et al. (2019), data generalization with stylization Verma et al. (2019); Zhou et al. (2021), meta learning Li et al. (2018a); Kim et al. (2021)-based training schemes, among which representation learning-based methods are one of the most popular ones. These representation learning-based methods Balaji et al. (2019) aim to learn domain-invariant feature representation. To be specific, if the discrepancy between source domains in feature space can be minimized, the model is expected to be better generalize well on unseen target domain, owning to learned domaininvariant and transferable feature representation Ben-David et al. (2006). For instance, an classical contrastive semantic alignment (CSA) loss proposed by (Motiian et al., 2017) was to encourage positive sample pairs (with same label) from different domains closer while pulling other negative pairs (with different labels) apart. (Dou et al., 2019) introduced the CSA loss which jointly considers local class alignment loss (for point-wise domain alignment) and global class alignment loss (for distribution-wise alignment).
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
Figure 1: Histopathological image examples of breast cancer tissue from three different healthcare institutes, including NKI with 626 images, IHC with 645 images, and VGH with 1324 images. There are two different tissue types, including epithelium and stroma. Obvious domain gaps (e.g., the density of tissue and the staining color) can be observed.
|
| 17 |
+
|
| 18 |
+
Despite the progress being achieved so far, it should be noted that a reliable contrastive semantic loss with point-wise (or local) perspective usually requires sufficient samples on source domains such that diverse sample-to-sample pairs can be constructed Sohn (2016); Khosla et al. (2020). For example, (Khosla et al., 2020) proposed a supervised contrastive semantic loss with a considerable volume of batch size on large-scale datasets such that decent performance can be guaranteed. (Yao et al., 2022) also emphasized the importance of the number of sample-to-sample pairs influenced by data sizes for contrastive-based loss on DG problem. Meanwhile, in the eye of distribution-wise (or global) alignment between domains Dou et al. (2019), a consistent distribution measurement (e.g., Kullback–Leibler (KL) divergence) theoretically relies on sufficient samples for the distribution estimation as discussed by (Bu et al., 2018). However, these sufficient samples from multiple source domains may not always be available and accessible, especially for the medical imaging data, due to potential ethic, privacy and proprietorship risks. It is therefore necessary to develop reliable and effective contrastive semantic alignments with local and global perspectives in the context of insufficient samples (a.k.a., small-data scenario) from source domains, in order to achieve better domain-invariant representations.
|
| 19 |
+
|
| 20 |
+
In this paper, we propose to learn domain-invariant representation from multiple source domains to tackle the domain generalization problem in the context of insufficient samples. Instead of extracting latent embeddings (i.e., latent points) based on deterministic models (e.g., convolutional neural networks, CNNs), we propose to leverage a probabilistic framework endowed by variational Bayesian inference to map each data point into probabilistic embeddings (i.e., the latent distribution) for domain generalization. Specifically, by following the domain-invariant learning from global (distribution-wise) perspective, we propose to extend empirical maximum mean discrepancy (MMD) to a novel probabilistic MMD (P-MMD) that can empirically measure the discrepancy between mixture distributions (a.k.a., distributions over distributions), consisted of a serial of latent distributions rather than latent points. From a local perspective, instead of imposing the CSA loss based on pairs of latent points, a novel probabilistic contrastive semantic alignment (P-CSA) loss with kernel mean embedding is proposed to encourage positive probabilistic embedding pairs closer while pulling other negative ones apart. Extensive experimental results on three challenging medical imaging classification tasks, including epithelium stroma classification on insufficient histopathological images, imbalanced-class based skin lesion classification, and spinal cord gray matter segmentation, show that our proposed method can achieve better cross-domain performance in the context of insufficient data compared with state-of-the-art baseline methods.
|
| 21 |
+
|
| 22 |
+
# 2 RELATED WORKS
|
| 23 |
+
|
| 24 |
+
# 2.1 DOMAIN GENERALIZATION AND ITS APPLICATION IN MEDICAL IMAGE CLASSIFICATION
|
| 25 |
+
|
| 26 |
+
Existing DG methods can be generally categorized into three different streams, namely data augmentation/generation Yue et al. (2019); Graves (2011); Zhou et al. (2021), meta-learning Li et al. (2018a); Kim et al. (2021) and feature representation learning Li et al. (2018b); Gong et al. (2019); Xiao et al. (2021). Among these methods, feature representation learning, which aims to explore invariant feature information that can be shared across domains, demonstrates to be a widely adopted method for the problem of DG. For feature representation learning-based DG method, Li et al.
|
| 27 |
+
|
| 28 |
+
(2018b) proposed to conduct multi-domain alignment in latent space via a multi-domain MMD distance. Gong et al. (2019) leveraged adversarial training to eliminate the domain discrepancy such that domain-invariant representation can be learned in a manifold space. Due to the varieties of imaging protocol (e.g., the choice of image solution for MRI image), device vendors (e.g., Philips or Siemens CT scanners), and patient populations (the race and age group), the acquired imaging data from different medical sites may exist significant domain shift problem Liu et al. (2021). Dou et al. (2019) proposed a meta-learning framework to perform local and global semantic alignment for medical image classification. Similar design is also adopted by Li et al. (2022a) for tissue image classification. Qi et al. (2020) utilized the curriculum learning scheme to transfer the knowledge for histopathological images classification. Li et al. (2020a) combined the data augmentation and domain alignment to achieve decent performance on multiple medical data classification tasks. However, these methods may not focus on learning domain-invariant representation on insufficient samples from source domains. This scenario may widely encounter in clinical environments because 1) The cost of annotated data by experienced professionals are typically prohibitive, leading to the lack of samples in size and diversity Yoon et al. (2019). 2) For rare diseases (e.g., glioblastoma and lymphoma), the size of data is usually small Lee et al. (2022). 3) medical imaging data are strictly insufficient in most cases due to potential ethic and privacy-preserving concerns Li et al. (2020b).
|
| 29 |
+
|
| 30 |
+
# 2.2 PROBABILISTIC NEURAL NETWORKS
|
| 31 |
+
|
| 32 |
+
Compared with deterministic models, probabilistic neural networks turns to learn a distribution over model parameters, which can integrate the uncertainty in predictive modeling Kingma et al. (2015); Gal & Ghahramani (2016). When the data is insufficient, probabilistic models usually can achieve better generalized performance due to its probabilistic property (as an implicit regularization) Blundell et al. (2015). In the context of insufficient samples, Bayesian neural network Neal (2012) (BNN) with variational inference, a representative probabilistic model, not only can improve predictive accuracy as a classifier Wilson & Izmailov (2020), but also can build up the quality of low-dimensional embeddings of insufficient data Mallick et al. (2021), which is a crucial motivation for this paper. Meanwhile, modern analytical approximation techniques (e.g., Variational inference Blei et al. (2017), empirical Bayes Krishnan et al. (2020)) can efficiently infer the posterior distribution of model parameters with stochastic gradient descent method, which can integrate BNN with deterministic DNN conveniently.
|
| 33 |
+
|
| 34 |
+
In Xiao et al. (2021), the authors proposed to consider the uncertainty of a generalizable model based on BNN, where the distances of positive probabilistic embedding pairs and class distribution are minimized via KL measure. Despite the effectiveness, the dissimilar pairs (i.e., negative pairs) are ignored, which may not benefit feature representation learning. Moreover, they only focused on sample similarity while the distribution information is ignored. Instead, our proposed method comprehensively considers both positive and negative probabilistic embedding pairs via a novel distribution-based contrastive semantic loss.
|
| 35 |
+
|
| 36 |
+
# 3 METHOD
|
| 37 |
+
|
| 38 |
+
# 3.1 PRELIMINARY
|
| 39 |
+
|
| 40 |
+
Assume that there are $K$ domains from different collected environments. The samples in each domain can be represented as $\mathbf { X } _ { l } = \{ \mathbf { x } _ { l _ { 1 } } , \cdot \cdot \cdot , \mathbf { x } _ { l _ { n _ { l } } } \}$ , where $l \in \mathbb { N } ^ { + } : \{ 1 , \cdots , K \}$ , $\mathbf { \bar { x } } _ { l _ { i } } \in \mathbb { R } ^ { d \times 1 }$ denotes a sample with the $d$ dimension vector in the $l$ -th domain. $n _ { l }$ is the total number of samples in the $l$ -th domain. The corresponding labels of samples in each domain can be denoted as ${ \bf Y } _ { l } = { \bf \Phi }$ $\{ \mathbf { y } _ { l _ { 1 } } , \cdots , \mathbf { y } _ { l _ { n _ { l } } } \}$ , where $\mathbf { y } _ { l _ { i } } \in \mathbb { R } ^ { m \times 1 }$ is the form of one-hot encoding with $m$ classes in total. For lthe setting of domain generalization, the source domain data represented as $\{ \mathbf { X } _ { l } ^ { S } , \mathbf { Y } _ { l } ^ { S } \} _ { l = 1 } ^ { K }$ , can be available in the training phase only, whereas the target domain data, denoted by $\mathbf { X } ^ { T }$ , are only seen in test phase.
|
| 41 |
+
|
| 42 |
+
Here, we provide a framework that can learn better domain-invariant representation when there is insufficient source domain data. The probabilistic neural network is imposed to enable high-quality and powerful feature representation in the context of insufficient samples. To effectively perform global perspective alignment, a novel probabilistic MMD is proposed to empirically measure the discrepancy between distributions over distributions based on reproducing kernel Hilbert space. We also propose a probabilistic contrastive semantic alignment to adapt probabilistic embeddings with local perspective. The details of our proposed method are discussed as below.
|
| 43 |
+
|
| 44 |
+
# 3.2 PROBABILISTIC EMBEDDING OF INSUFFICIENT DATA
|
| 45 |
+
|
| 46 |
+
Compared with deterministic models, the probabilistic models can learn a distribution over model weights, which has shown a better capacity to represent latent embeddings Mallick et al. (2021) under insufficient sample scenario, which is a key motivation for this work. Here, Bayesian neural network (BNN) Blei et al. (2017) is utilized to extract the low-dimensional embeddings from highdimensional inputs. By feeding the inputs into BNN with parameter $\mathbf { W } \sim p ( \mathbf { W } )$ , the samples $\mathbf { X } _ { l } = \{ \mathbf { x } _ { l _ { 1 } } , \cdot \cdot \cdot , \mathbf { x } _ { l _ { n _ { l } } } \}$ of each domain can be represented by a set of probabilistic embeddings (i.e., latent distributions), i.e., $p ( \mathbf { Z } | \mathbf { X } _ { l } ) = \{ p ( \mathbf { z } | \mathbf { x } _ { l _ { 1 } } , \mathbf { W } ) , \cdot \cdot \cdot , p ( \mathbf { z } | \mathbf { x } _ { l _ { n _ { l } } } , \mathbf { W } ) \}$ where $\mathbf { W } \sim p ( \mathbf { W } )$ is sampled stochastically. The variational inference is used to approximate the posterior distribution of W with the evidence lower bound (ELBO) (more details can be found in appendix). By using Monte Carlo (MC) estimators with $T$ stochastic sampling operations from the W, the predictive distribution of each $p ( \mathbf { z } | \mathbf { x } )$ can be unbiased approximation. The number of MC samples and the corresponding issue of computational efficiency is discussed in A.6.
|
| 47 |
+
|
| 48 |
+
# 3.3 DISTRIBUTION ALIGNMENT VIA PROBABILISTIC MAXIMUM MEAN DISCREPANCY
|
| 49 |
+
|
| 50 |
+
In this section, we introduce an approach to learning domain-invariant representation from a global perspective by minimizing the discrepancy among domains. Among various distribution distance metrics, Maximum Mean Discrepancy (MMD) is widely adopted Long et al. (2017); Li et al. (2018b) which aims to measure the distance between two probability distributions in a non-parametric manner. Specifically, assume that latent embeddings $\mathbf { Z } _ { l } = \{ \mathbf { z } _ { l _ { 1 } } , \cdots , \mathbf { z } _ { l _ { n _ { l } } } \}$ and $\mathbf { Z } _ { t } = \{ \mathbf { z } _ { t _ { 1 } } , \cdots , \mathbf { z } _ { t _ { n _ { t } } } \}$ are drawn from two unknown distributions $\mathbb { P } _ { l }$ and $\mathbb { P } _ { t }$ . The probability measure $\mathbb { P }$ can be mapped into a reproducing kernel Hilbert space (RKHS) $\mathcal { H }$ as a element by setting,
|
| 51 |
+
|
| 52 |
+
$$
|
| 53 |
+
\mu _ { \mathbb { P } } : = \mathbb { E } _ { \mathbf { z } \sim \mathbb { P } } [ \phi ( \mathbf { z } ) ] = \int _ { \mathcal { Z } } k ( \mathbf { z } , \cdot ) d \mathbb { P } = \mathbb { E } _ { \mathbf { z } \sim \mathbb { P } } [ k ( \mathbf { z } , \cdot ) ] ,
|
| 54 |
+
$$
|
| 55 |
+
|
| 56 |
+
where a reproducing kernel $k : \mathcal { X } \times \mathcal { X } \to \mathbb { R }$ and corresponding feature map $\phi : \mathcal { X } \to \mathcal { H }$ are defined. Let the kernel $k$ is characteristic such that the map $\mu : \mathbb { P } \to \mu _ { \mathbb { P } }$ is injective. In this case the MMD can be defined as the distance $\| \mu _ { \mathbb { P } _ { l } } - \mu _ { \mathbb { P } _ { k } } \| _ { \mathcal { H } }$ in $\mathcal { H }$ between mean embeddings and it can be used as a measure of distance between the distributions $\mathbb { P } _ { l }$ and $\mathbb { P } _ { t }$ Borgwardt et al. (2006); Gretton et al. (2012). The explicit computation of MMD can be derived by unbiased empirical estimation of mean map Gretton et al. (2012), i.e.,
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
\mathrm { M M D } \left( \mathbb { P } _ { l } , \mathbb { P } _ { t } \right) ^ { 2 } = \left. \mu _ { \mathbb { P } _ { l } } - \mu _ { \mathbb { P } _ { t } } \right. _ { \mathcal { H } } ^ { 2 } = \left. \frac { 1 } { n _ { l } } \sum _ { i = 1 } ^ { n _ { l } } \phi \left( \mathbf { z } _ { l _ { i } } \right) - \frac { 1 } { n _ { t } } \sum _ { j = 1 } ^ { n _ { t } } \phi \left( \mathbf { z } _ { t _ { j } } \right) \right. _ { \mathcal { H } } ^ { 2 } .
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
The idea of using MMD for domain generalization has been explored in several works (e.g., Li et al.
|
| 63 |
+
(2018b); Hu et al. (2020)).
|
| 64 |
+
|
| 65 |
+
In the probabilistic framework, instead of the individual latent embeddings $\mathbf { z } _ { l _ { 1 } , \ldots }$ , we have latent probabilistic embeddings $\Pi _ { l _ { 1 } } : = p ( \mathbf { z } | \mathbf { x } _ { l _ { 1 } } , \mathbf { W } ) , . . . .$ For a source domain $D _ { l }$ , we have the associated distribution over distributions $\mathbb { P } _ { l } = \{ \Pi _ { l _ { 1 } } , \cdot \cdot \cdot , \Pi _ { l _ { n _ { l } } } \}$ . For this scenario, we propose to extend the existing point-based empirical MMD estimate to a distribution-based empirical probability MMD (P-MMD) estimate. P-MMD utilizes empirical estimation by kernels on distributions to measure the discrepancy between mixture distributions $\mathbb { P } _ { l }$ and $\mathbb { P } _ { t }$ under the probabilistic framework.
|
| 66 |
+
|
| 67 |
+
Specifically, we first represent latent probabilistic embeddings as elements in RKHS $\mathcal { H } _ { k }$ using the kernel $k$ , that we call a level-1 kernel in the sequel, e.g., $\mu _ { \Pi l _ { 1 } } : = \mathbb { E } _ { \mathbf { z } \sim \Pi _ { l _ { 1 } } } [ \phi ( \mathbf { z } ) ] = \mathbb { E } _ { \mathbf { z } \sim \Pi _ { l _ { 1 } } } [ k ( \mathbf { z } , \cdot ) ]$ , which is an analogous way to the Eq. (1). The kernel mean embedding $\mu _ { \Pi _ { l _ { 1 } } }$ can be regarded as a new feature map for a variety of tasks Yoshikawa et al. (2014). Here, to enable non-linear learning on distributions, we introduce level-2 kernel $K$ Muandet et al. (2012). Consider a level-1 kernel $\kappa$ on $\mathcal { H }$ and its reproducing kernel Hilbert space (RKHS) $\mathcal { H } _ { \kappa }$ . Define $K$ as
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\begin{array} { r } { K ( \Pi _ { l _ { i } } , \Pi _ { t _ { j } } ) = \kappa ( \mu _ { \Pi _ { l _ { i } } } , \mu _ { \Pi _ { t _ { j } } } ) = \langle \psi ( \mu _ { \Pi _ { l _ { i } } } ) , \psi ( \mu _ { \Pi _ { t _ { j } } } ) \rangle _ { \mathcal { H } _ { \kappa } } , } \end{array}
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
where $K$ and its explicit form on kernel mean embeddings $\kappa$ are p.d. kernels Berlinet $\&$ ThomasAgnan (2011). We define the probabilistic MMD (P-MMD) empirical estimation method using the level-2 kernel $K$ :
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\begin{array} { r c l } { { \mathrm { P - M M D } ( \mathbb { P } _ { l } , \mathbb { P } _ { t } ) ^ { 2 } } } & { { = } } & { { \displaystyle \| \frac { 1 } { n _ { l } } \sum _ { i = 1 } ^ { n _ { l } } \psi ( \mu _ { \Pi _ { i } } ) - \frac { 1 } { n _ { t } } \sum _ { j = 1 } ^ { n _ { t } } \psi ( \mu _ { \Pi _ { t _ { j } } } ) \| _ { \mathcal { H } _ { \kappa } } ^ { 2 } } } \\ { { } } & { { = } } & { { \displaystyle \frac { 1 } { n _ { l } ^ { 2 } } \sum _ { i = 1 } ^ { n _ { l } } \sum _ { i ^ { \prime } = 1 } ^ { n _ { l } } K ( \Pi _ { l _ { i } } , \Pi _ { l _ { i } ^ { \prime } } ) + \frac { 1 } { n _ { t } ^ { 2 } } \sum _ { j = 1 } ^ { n _ { t } } \sum _ { j ^ { \prime } = 1 } ^ { n _ { t } } K ( \Pi _ { t _ { j } } , \Pi _ { t _ { j } ^ { \prime } } ) } } \\ { { } } & { { - } } & { { \displaystyle \frac { 2 } { n _ { l } n _ { t } } \sum _ { i = 1 } ^ { n _ { l } } \sum _ { j = 1 } ^ { n _ { t } } K ( \Pi _ { l _ { i } } , \Pi _ { t _ { j } } ) . } } \end{array}
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
In this work the level-1 and level-2 kernels, $k$ and $K$ , are both Gaussian RBF kernel due to its impressive performance on a limited amount of distribution data Muandet et al. (2012). Namely, K can be represented as
|
| 80 |
+
|
| 81 |
+
$$
|
| 82 |
+
\begin{array} { r c l } { \displaystyle \mathcal { K } _ { G a u } ( \Pi _ { l _ { i } } , \Pi _ { t _ { j } } ) = \kappa ( \mu _ { \Pi _ { l _ { i } } } , \mu _ { \Pi _ { i _ { j } } } ) } & { = } & { \displaystyle ( - \frac { \lambda } { 2 } \| \mu _ { \Pi _ { l _ { i } } } - \mu _ { \Pi _ { t _ { j } } } \| _ { \mathcal { H } _ { \kappa } } ^ { 2 } \Big ) } \\ & { = } & { \displaystyle \exp \bigg ( - \frac { \lambda } { 2 } ( \langle \mu _ { \Pi _ { i _ { i } } } , \mu _ { \Pi _ { i _ { i } } } \rangle _ { \mathcal { H } _ { \kappa } } ) - 2 \langle \mu _ { \Pi _ { l _ { i } } } , \mu _ { \Pi _ { t _ { j } } } \rangle _ { \mathcal { H } _ { \kappa } } + \langle \mu \Pi _ { t _ { j } } , \mu _ { \Pi _ { t _ { j } } } \rangle _ { \mathcal { H } _ { \kappa } } \bigg ) } \\ & { = } & { \displaystyle \exp ( - \frac { \lambda } { 2 } ( \frac { 1 } { m _ { l _ { i } } ^ { 2 } } \sum _ { i = 1 } ^ { m _ { l } } \sum _ { i = 1 } ^ { m _ { l } } k ( \mathbf { z } _ { i _ { i } } , \mathbf { z } _ { l _ { i } ^ { \prime } } ) - \frac { 2 } { m _ { l } m _ { l } } \sum _ { i = 1 } ^ { m _ { l } } \sum _ { j = 1 } ^ { m _ { l } } k ( \mathbf { z } _ { l _ { i } } , \mathbf { z } _ { t _ { j } } ) ) } \\ & { + } & { \displaystyle \frac { 1 } { m _ { l } ^ { 2 } } \sum _ { j = 1 } ^ { m _ { l } } \sum _ { j = 1 } ^ { m _ { l } } k ( \mathbf { z } _ { i _ { j } } , \mathbf { z } _ { t _ { j } ^ { \prime } } ) , } \end{array}
|
| 83 |
+
$$
|
| 84 |
+
|
| 85 |
+
where $m _ { l }$ and $m _ { t }$ are determined by sampling times $T$ . The kernel mean embedding using the level-1 kernel $k$ creates distributions $\mu ( \mathbb { P } _ { 1 } ) , \ldots , \mu ( \mathbb { P } _ { N } )$ represented by the samples $\{ \mu _ { \Pi _ { l _ { 1 } } } , \ldots , \mu _ { \Pi _ { l _ { n } } } \}$ for $l = 1 , \ldots , N$ respectively in the RKHS $\mathcal { H } _ { k }$ . The underlying strategy of P-MMD is to apply the classic MMD to these distributions (with respect to the kernel $\kappa$ ) . To access the effect that the minimization of P-MMD has on the original latent probability distributions across different domains we recall the following:
|
| 86 |
+
|
| 87 |
+
1 (Muandet et al. (2012)). Let . Then the distributional variance $\mathbb { P } _ { 1 } , \dots , \mathbb { P } _ { N }$ ityis di if $\begin{array} { l l } { \hat { \mathbb { P } } } & { : = } \end{array}$ $\textstyle { \frac { 1 } { N } } \sum _ { i = 1 } ^ { N } \mathbb { P } _ { i }$ $\textstyle { \frac { 1 } { N } } \sum \lVert \mu _ { \mathbb { P } i } - \mu _ { \hat { \mathbb { P } } } \rVert$ $O$ $\mathcal { f } \mathbb { P } _ { 1 } = \mathbb { P } _ { 2 } = . . . = \mathbb { P } _ { N }$ Corollary 1 (Li et al. (2018b)). The upper bound of the distributional variance can be written as
|
| 88 |
+
|
| 89 |
+
$$
|
| 90 |
+
\frac { 1 } { K ^ { 2 } } \sum _ { 1 \le i , j \le K } \mathrm { M M D } ( \mathbb { P } _ { i } , \mathbb { P } _ { j } ) ^ { 2 } .
|
| 91 |
+
$$
|
| 92 |
+
|
| 93 |
+
In our setting Theorem 1 and Corollary 1 along with the fact that $k$ is a characteristic kernel imply the following
|
| 94 |
+
|
| 95 |
+
Corollary 2. $\begin{array} { r } { \frac { 1 } { K ^ { 2 } } \sum _ { 1 < i , j < K } \mathrm { P - M M D } ( \mathbb { P } _ { i } , \mathbb { P } _ { j } ) ^ { 2 } = 0 } \end{array}$ iff all moments of latent distributions $\Pi _ { l }$ associated to points of domain $\bar { D } _ { l }$ for $l = 1 , \ldots , N$ are distributed identically across domains.
|
| 96 |
+
|
| 97 |
+
Following Corollary 2 we define the following loss function:
|
| 98 |
+
|
| 99 |
+
$$
|
| 100 |
+
\mathcal { L } _ { g l o b a l } = \frac { 1 } { K ^ { 2 } } \sum _ { 1 \le i , j \le K } \mathrm { P - M M D } ( \mathbb { P } _ { i } , \mathbb { P } _ { j } ) ^ { 2 } .
|
| 101 |
+
$$
|
| 102 |
+
|
| 103 |
+
Corollary 2 implies that as 6 tends to 0 so does the distance between the distributions of means, variances and higher moments of the distributions $\Pi _ { l }$ associated to points of different domains. Remark. In the ablation study (see Appendix), we compare the P-MMD approach to simply taking the mean (i.e., first moment) of latent probabilistic embeddings $\Pi _ { l }$ i.e. taking $\Pi _ { l } \mathbf { m } _ { \Pi _ { l } } = \mathbb { E } _ { \mathbf { x } \sim \Pi _ { l } [ \mathbf { x } ] }$ , and then minimizing the associated ”vanilla” MMD. Although this scheme is more computationalefficient over our proposed method, it throws away most information about high-level statistics as discussed by (Muandet et al., 2017). We verify empirically that our approach leads to better performance across the domains. The visualized computation of P-MMD is shown in Figure 2.
|
| 104 |
+
|
| 105 |
+
Although we focus on the scenario of insufficient samples, the computational consumption from Eq. (4) and Eq. (5) may be still prohibitive as the calculation of MMD distance between distributions can scale at least quadratically with the increasing of sample size (especially for image segmentation task), i.e., $O ( n ^ { 2 } )$ in a domain. Here, by following the linear statistic theory of MMD, the unbiased estimate can be derived by drawing pairs from two domains with replacement, i.e., $\mathrm { P - M M D } ( \mathbb { P } _ { l } , \mathbb { P } _ { t } ) ^ { 2 } \approx$ $\begin{array} { r } { \frac { 2 } { n _ { l } } \sum _ { i = 1 } ^ { \frac { 2 } { n _ { l } } } \left[ K ( \Pi _ { l _ { 2 i } } , \Pi _ { l _ { 2 i + 1 } ^ { \prime } } ) + K ( \Pi _ { t _ { 2 i } } , \Pi _ { t _ { 2 i + 1 } ^ { \prime } } ) - K ( \Pi _ { l _ { 2 i } } , \Pi _ { t _ { 2 i + 1 } } ) - K ( \Pi _ { l _ { 2 i + 1 } } , \Pi _ { t _ { 2 i } } ) \right] } \end{array}$ , where assuming $n _ { l } = n _ { t }$ for simplicity. (Borgwardt et al., 2006) gives proofs about the unbiased property of the linear statistic of MMD and shows that statistic power does not be sacrificed too much.
|
| 106 |
+
|
| 107 |
+

|
| 108 |
+
Figure 2: A visualized computational process for probabilistic MMD (P-MMD) on two source domains. The same color for each sample in different domains denotes the same label.
|
| 109 |
+
|
| 110 |
+
# 3.4 PROBABILISTIC CONTRASTIVE SEMANTIC ALIGNMENT
|
| 111 |
+
|
| 112 |
+
To learn domain-invariant representation from local perspective, a popular idea is to encourage positive pairs with same label closer while pulling other negative ones with different labels apart Motiian et al. (2017); Dou et al. (2019). These methods usually measure the Euclidean distance between samples in the embedding space. However, this scheme may not satisfy our probabilistic framework due to its probabilistic embeddings. To this end, we propose a probabilistic contrastive semantic alignment (P-CSA) loss that can utilize the empirical MMD to measure the discrepancy between probabilistic embeddings. The proposed P-CAS loss $\mathcal { L } _ { l o c a l }$ consists of two components, including the positive probabilistic contrastive loss and negative probabilistic contrastive loss. The former aims to minimize the distance between intra-class distributions from different domains, i.e.,
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\mathcal { L } _ { l o c a l } ^ { p o s } = \frac { 1 } { 2 } \mathrm { M M D } ( \Pi _ { n } , \Pi _ { q } ) ^ { 2 } = \frac { 1 } { 2 } \left. \frac { 1 } { T } \sum _ { i = 1 } ^ { T } \phi \left( M _ { \Theta } ( \mathbf { z } _ { n _ { i } } ) \right) - \frac { 1 } { T } \sum _ { j = 1 } ^ { T } \phi \left( M _ { \Theta } ( \mathbf { z } _ { q _ { j } } ) \right) \right. _ { \mathcal { H } } ^ { 2 } , s . t . \mathbf { y } _ { n } = \mathbf { y } _ { q } ,
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
where $M _ { \Theta } ( \cdot )$ denotes the embedding network of metric learning, which will contribute to learn the distance between features better Dou et al. (2019). Then, by introducing a distance margin $\xi$ (can guarantee a appropriate repulsion range), the negative probabilistic contrastive loss is denoted by
|
| 119 |
+
|
| 120 |
+
$$
|
| 121 |
+
\begin{array} { r c l } { \mathcal { L } _ { l o c a l } ^ { n e g } } & { = } & { \displaystyle \frac { 1 } { 2 } \operatorname* { m a x } [ 0 , \xi - \mathrm { M M D } ( \Pi _ { n } , \Pi _ { q } ) ^ { 2 } ] } \\ & & { = } & { \displaystyle \frac { 1 } { 2 } \operatorname* { m a x } [ 0 , \xi - \left\| \frac { 1 } { T } \sum _ { i = 1 } ^ { T } \phi \left( M \Theta ( \mathbf { z } _ { n _ { i } } ) \right) - \frac { 1 } { T } \sum _ { j = 1 } ^ { T } \phi \left( M \Theta ( \mathbf { z } _ { q _ { j } } ) \right) \right\| _ { \mathcal { H } } ^ { 2 } ] , s . t . \mathbf { y } _ { n } \neq \mathbf { y } _ { q } . } \end{array}
|
| 122 |
+
$$
|
| 123 |
+
|
| 124 |
+
Model Training. Our proposed framework consists of three modules, a BNN-based probabilistic extractor $Q _ { \phi }$ , a BNN-based classifier $C _ { \omega }$ , and a metric network $M _ { \Theta } ( \cdot )$ . For the $Q _ { \phi }$ , we only add a Bayesian layer with ReLU layer on the bottom of a pretrained deterministic model (e.g., ResNet18 by removing fully-connected layers) by following (Xiao et al., 2021). For the $C _ { \omega }$ , a Bayesian layer is also introduced to adapt the classification on insufficient sample better. The structure of $M _ { \Theta }$ is the same as (Dou et al., 2019). The images ${ \mathcal X } = \{ \mathbf x _ { l _ { i } } \}$ conduct $T$ stochastic forward passes on the $Q _ { \phi }$ and $C _ { \omega }$ by MC sampling to obtain probabilistic predicts $\{ \hat { y } _ { l _ { i } } ^ { j } \} _ { j = 1 } ^ { T }$ , where the outputs (i.e., probabilistic embeddings) of $Q _ { \phi }$ serve as the inputs for the calculations of $\mathcal { L } _ { g l o b a l }$ and $\mathcal { L } _ { l o c a l }$ . The final predicts $\{ \hat { y } _ { l _ { i } } ^ { j } \}$ are the expectation of $\{ \hat { y } _ { l _ { i } } ^ { j } \} _ { j = 1 } ^ { T }$ . The total objectives can be summarized as below,
|
| 125 |
+
|
| 126 |
+
$$
|
| 127 |
+
\mathcal { L } _ { t o t a l } = \sum _ { l , i } \mathcal { L } _ { c } ( \hat { y } _ { l _ { i } } , y _ { l _ { i } } ) + \mathrm { K L } [ q _ { \theta } ( Q _ { \phi } ) | | p ( Q _ { \phi } ) ] + \mathrm { K L } [ q _ { \theta } ( C _ { \omega } ) | | p ( C _ { \omega } ) ] + \beta _ { 1 } \mathcal { L } _ { l o c a l } + \beta _ { 2 } \mathcal { L } _ { g l o b a l } ,
|
| 128 |
+
$$
|
| 129 |
+
|
| 130 |
+
where $\mathcal { L } _ { c } ( \hat { y } _ { l _ { i } } , y _ { l _ { i } } )$ is the cross-entropy loss with ground-truth $y _ { l _ { i } }$ and its estimation $\hat { y } _ { l _ { i } }$ . The second and third terms aim to learn a variational distribution $q _ { \theta } ( \cdot )$ to approximate the Bayesian posterior distribution on the weights, while minimizing the KL divergence with its prior distribution $p ( \cdot )$ . The first three terms refer to variational Bayesian inference with ELBO Blei et al. (2017).
|
| 131 |
+
|
| 132 |
+
Table 1: Domain generalization results on the skin lesion classification task. The average value and standard deviation are reported by running each method with five times. Each column denotes a cross-domain task. For example, in the second column, we use DMF dataset denotes as the target domain and the remaining datasets as the source domains.
|
| 133 |
+
|
| 134 |
+
<table><tr><td>Method</td><td>DMF</td><td>D7P</td><td>MSK</td><td>PH2</td><td>SON</td><td>UDA</td><td>AVG</td></tr><tr><td>DeepAll</td><td>0.2492 ±0.0127</td><td>0.5680±0.0181</td><td>0.6674±0.0083</td><td>0.8000±0.0167</td><td>0.8613±0.0296</td><td>0.6264±0.0312</td><td>0.6287</td></tr><tr><td>MASF Dou et al. (2019)</td><td>0.2692±0.0146</td><td>0.5678±0.0361</td><td>0.6815±0.0122</td><td>0.7833±0.0101</td><td>0.9204±0.0227</td><td>0.6538±0.0196</td><td>0.6460</td></tr><tr><td>LDDG Li et al. (2020a)</td><td>0.2793±0.0244</td><td>0.6007±0.0187</td><td>0.6967±0.0211</td><td>0.8167±0.0209</td><td>0.9272±0.0117</td><td>0.6978±0.0182</td><td>0.6697</td></tr><tr><td>SWAD Cha et al.(2021)</td><td>0.3582 ±0.0234</td><td>0.5491 ±0.0231</td><td>0.6842 ±0.0156</td><td>0.9167 ±0.0121</td><td>0.9824 ±0.0012</td><td>0.7240 ±0.0251</td><td>0.7024</td></tr><tr><td>BDIL Xiao et al. (2021)</td><td>0.2985±0.0452</td><td>0.6204±0.0212</td><td>0.7059±0.0145</td><td>0.8967±0.0096</td><td>0.9860±0.0198</td><td>0.7219±0.0284</td><td>0.7049</td></tr><tr><td>DNA Chu et al. (2022)</td><td>0.3532 ±0.0133</td><td>0.5581 ±0.0178</td><td>0.7120 ±0.0194</td><td>0.9333 ±0.0045</td><td>0.9851 ±0.0032</td><td>0.7314 ±0.0141</td><td>0.7122</td></tr><tr><td>DSU Li et al. (2022c)</td><td>0.3830 ±0.0267</td><td>0.5739 ±0.0147</td><td>0.6935 ±0.0165</td><td>0.8833 ±0.0231</td><td>0.9841 ±0.0098</td><td>0.7201 ±0.0121</td><td>0.7063</td></tr><tr><td>Ours</td><td>0.3781±0.0136</td><td>0.6120±0.0115</td><td>0.7276 ±0.0201</td><td>0.9416±0.0103</td><td>0.9889±0.0041</td><td>0.7486 ±0.0123</td><td>0.7328</td></tr></table>
|
| 135 |
+
|
| 136 |
+
Table 2: Experiment results of Epithelium Stroma Classification in Histopathological Images. Each column denotes a cross-domain task. For example, in the second column, we use IHC dataset denotes as the target domain and the remaining datasets as the source domains.
|
| 137 |
+
|
| 138 |
+
<table><tr><td>Method</td><td>IHC</td><td>NKI</td><td>VGH</td><td>Average (%)</td></tr><tr><td>DeepAll</td><td>73.29 ±0.13</td><td>70.60 ±0.15</td><td>79.56±0.11</td><td>74.48</td></tr><tr><td>MASF Dou et al. (2019)</td><td>80.45±0.10</td><td>76.10±0.11</td><td>84.44±0.12</td><td>80.33</td></tr><tr><td>SWAD Cha et al. (2021)</td><td>79.74±0.15</td><td>74.84±0.13</td><td>84.29±0.12</td><td>79.62</td></tr><tr><td>BDIL Xiao et al. (2021)</td><td>85.56±0.12</td><td>71.89±0.14</td><td>85.90±0.18</td><td>81.05</td></tr><tr><td>DNA Chu et al. (2022)</td><td>83.93±0.18</td><td>73.94±0.15</td><td>85.57±0.17</td><td>81.14</td></tr><tr><td>DSULi et al. (2022c)</td><td>81.56±0.14</td><td>72.47±0.12</td><td>83.94±0.16</td><td>79.32</td></tr><tr><td>Ours (in this paper)</td><td>88.82±0.09</td><td>76.71±0.10</td><td>86.92±0.14</td><td>84.06</td></tr></table>
|
| 139 |
+
|
| 140 |
+
# 4 EXPERIMENTS AND ANALYSES
|
| 141 |
+
|
| 142 |
+
# 4.1 SKIN LESION CLASSIFICATION
|
| 143 |
+
|
| 144 |
+
Here, we first perform the skin lesion classification task to explore the generalization performance of our proposed method. 7 public skin lesion datasets 1 are utilized, including HAM10000, UDA, SON, DMF, MSK, D7P, and PH2. There are seven classes of skin lesions. The challenges of this task refer to two aspects. 1) The diversity of samples: The lesion locations (e.g., on the leg and the thigh), patients’ characteristics (e.g., the skin age and complexion) and the imaging vendors are different among domains, significant domain shifts thus can not be ignored. 2) Insufficient samples: The acquired data not only are restricted by the total number of samples in some domains (e.g., UDA and PH2 have only 601 and 200 samples, respectively) but also suffer from the limitation of inter-class imbalance (e.g., SON dataset only has a class of lesion). We follow experimental settings in (Li et al., 2020a), where each dataset is randomly split into $50 \%$ training set, $30 \%$ test set, and $20 \%$ validate set, respectively. The pretrained ResNet18 network is used as the backbone for all methods.
|
| 145 |
+
|
| 146 |
+
Results. Some competitive domain generalization approaches are introduced for comparison, including MASF Dou et al. (2019), BDIL Xiao et al. (2021), LDDG Li et al. (2020a) SWAD Cha et al. (2021), DNA Chu et al. (2022), and DSU Li et al. (2022c). ”DeepAll” denotes the model that is trained directly without any domain generalization strategy in all subsequent tasks. We turn their hyperparameters in a wide range. Note that our proposed method, DSU, DNA and BDIL are based on SWAD framework. The accuracy results of each cross-domain task are shown in Table 1. One has some observations as following. First, all methods achieve consistent improvements compared over DeepAll model. Second, we observe that MASF and LDDG with deterministic models may not explicitly adapt to the scenario of insufficient samples. In contrast, our proposed method and other baseline methods impose respective schemes to relieve the impact of insufficient samples, which leads to obvious improvements. Benefiting from probabilistic framework as an implicit regularization, our proposed method and BDIL can learn a distribution over weights, which can handle insufficient samples flexibly. However, it can be observed that additional invariant classifier learning on BDIL may cause negative effects (see the results on DMF) on challenging data, which may be reasonable as the explicit alignment on the classifier with high error probability can lead to negative transfer (take more uncertainty). The lack of explicit domain-invariant representations for DNA and DSU may be difficult to address significant domain shifts compared with our proposed method.
|
| 147 |
+
|
| 148 |
+
Table 3: The average results of spinal cord GM segmentation on 4 domain generalization tasks.
|
| 149 |
+
|
| 150 |
+
<table><tr><td rowspan="2">Method</td><td rowspan="2">DeepAll</td><td rowspan="2">MASF Dou et al. (2019)</td><td rowspan="2">LDGG Li et al. (2020a)</td><td rowspan="2">KDGG</td><td rowspan="2">DSU Li et al. (2022c)</td><td rowspan="2">Ours</td></tr><tr><td>Wang et al. (2021)</td></tr><tr><td>DSC↑</td><td>0.7425</td><td>0.7710</td><td>0.7881</td><td>0.7886</td><td>0.7921</td><td>0.7957</td></tr><tr><td>CC个</td><td>-11.4</td><td>23.52</td><td>34.86</td><td>33.43</td><td>34.65</td><td>35.76</td></tr><tr><td>JI个</td><td>0.6160</td><td>0.6502</td><td>0.6667</td><td>0.6667</td><td>0.6775</td><td>0.6828</td></tr><tr><td>TPR↑</td><td>0.7667</td><td>0.7803</td><td>0.8058</td><td>0.8075</td><td>0.8225</td><td>0.8260</td></tr><tr><td>ASD</td><td>0.5265</td><td>0.5505</td><td>0.4076</td><td>0.3553</td><td>0.4362</td><td>0.3356</td></tr></table>
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
Figure 3: The loss curve of iteration on skin lesion and epothelial-stromal classficaiton tasks. (a) Global alignment loss (b) Local alignment loss.
|
| 154 |
+
|
| 155 |
+
Table 4: Ablation study on each component of our proposed method for spinal cord gray matter segmentation task (where ”site2” is as the target domain). The model on the first row denotes the basic Unet model.
|
| 156 |
+
|
| 157 |
+
<table><tr><td>Backbone (Unet)</td><td>Bayesian Layers</td><td>Local Alignment Alignment</td><td>Global</td><td>Bayesian Classifier</td><td>DSC</td><td>CC</td><td>JI</td><td>TPR</td><td>ASD</td></tr><tr><td>√</td><td>X</td><td>=</td><td>=</td><td>X</td><td>0.7223</td><td>26.21</td><td>0.5789</td><td>0.8109</td><td>0.0992</td></tr><tr><td></td><td></td><td>=</td><td></td><td></td><td>0.7934 47.19 0.6595</td><td></td><td></td><td>0.8133</td><td>30.0692</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>0.8268 57.52</td><td></td><td>0.7067</td><td>0.8156</td><td>50.0501</td></tr><tr><td></td><td></td><td>?</td><td>X</td><td></td><td>0.8364</td><td>60.72</td><td>0.7195</td><td>0.8267</td><td>0.0486</td></tr><tr><td>ss></td><td></td><td>×</td><td></td><td></td><td>0.837160.57 0.7217</td><td></td><td></td><td>0.8152</td><td>20.0510</td></tr><tr><td></td><td></td><td>?</td><td></td><td>Xxs>>></td><td>0.848563.78 0.7389 0.8401</td><td></td><td></td><td></td><td>10.0401</td></tr></table>
|
| 158 |
+
|
| 159 |
+
# 4.2 EPITHELIUM STROMA CLASSIFICATION
|
| 160 |
+
|
| 161 |
+
The epithelium-stroma ratio can reflect the prognostic status of the tumor, especially for the breast cancer. A key step, therefore, is to recognize which tissues are epithelial or stromal in histopathological images. The obvious domain gaps can be observed from Figure 1. Meanwhile, it is much difficult to collect massive number of histopathological images from different sites due to the privacy. Here, three histopathological image datasets 2 collected from different medical institutes are used for comparison, where the NKI and VGH datasets only have 671 and 615 images, respectively. We follow the research in Qi et al. (2020) to extract epithelial or stromal patches from histopathological images, in order to balance the number of images among datasets. Then, IHC, NKI, and VGH datasets have 1342, 1230, and 1376 patches, respectively, which is still insufficient for training. We utilize the DomainBed benchmark Gulrajani & Lopez-Paz (2020) for fair comparison, where each dataset in source domain is randomly split into $80 \%$ training set, $20 \%$ validate set. The testing is on overall target domain. The pretrained ResNet18 is adopted by all methods as backbone.
|
| 162 |
+
|
| 163 |
+
Results. We compare our proposed method with recent DG models, including MASF, SWAD, BDIL, DNA, and DUS. By turning the hyperparameter of baseline methods in a wide range, the classification accuracy on each target domain (the remaining is as the source domain) is reported in Table 2. Some observations can be summarized as following. First, we observe that the type of weight averaging method (e.g., SWAD and DNA) is effective for this challenging out-of-domain task. However, due to the lack of explicit domain alignment, the obvious domain shifts may not be fully addressed via weighted ensemble learning, leading to the limitation of the performance. Second, BDIL not only adopts two-level alignments on feature extractor and classifier, but also obtains further improvements by probabilistic framework. However, one can observe that BDIL has a similar performance drop (in the skin lesion classification) on the challenging task (i.e., the NKI task). The best performance achieved by our proposed method thus shows the effectiveness of our proposed method. DSU has the poorest performance among all baseline methods, which may be reasonable as the straightforward domain randomization in feature space may not be powerful for eliminating obvious domain shifts.
|
| 164 |
+
|
| 165 |
+
# 4.3 SPINAL CORD GRAY MATTER SEGMENTATION
|
| 166 |
+
|
| 167 |
+
The spinal cord Gray Matter (GM) segmentation Challenge Dataset 3 is used here, where the acquired magnetic resonance imaging (MRI) data are collected from four healthcare centers, and acquisition manufactures and imaging protocols are variable. The challenges of insufficient sample are from two aspects. 1) The number of slices in some sites is relatively small (e.g., site1 and site2 have only 30 and 113 slices). 2) The number of target pixels is small, as GM area is only a very small area in overall slice. We follow the training protocols used in Li et al. (2020a) for all methods.
|
| 168 |
+
|
| 169 |
+
Table 5: Experiment results of PACS multi-domain classification task based on ResNet50. Each column denotes a cross-domain task. For example, in the third column, we use Art dataset denotes as the target domain and the remaining datasets as the source domains.
|
| 170 |
+
|
| 171 |
+
<table><tr><td>Method</td><td>Reference</td><td>Art</td><td>Cartoon</td><td>Photo</td><td>Sketch</td><td>Average (%)</td></tr><tr><td>RSCHuang et al. (2020) L2A-OT Zhou et al. (2020)</td><td>ECCV2020 ECCV2020</td><td>78.9 83.3</td><td>76.9 78.2</td><td>94.1 96.2</td><td>76.8 73.6</td><td>81 .7 82.8</td></tr><tr><td>MatchDG Mahajan et al. (2021) pAdaIN Nuriel et al. (2021)</td><td>ICML2020 CVPR 2021</td><td>81.2 81.7</td><td>80.4 76.6</td><td>96.8</td><td>77.2</td><td>83.9</td></tr><tr><td>MixStyle Zhou et al. (2021)</td><td></td><td></td><td></td><td>96.3</td><td>75.1</td><td>82.5</td></tr><tr><td></td><td>ICLR2021</td><td>86.8</td><td>79.0</td><td>96.6</td><td>78.5</td><td>85.2</td></tr><tr><td>SagNet Nam et al. (2021)</td><td>CVPR2021</td><td>87.4</td><td>80.7</td><td>97.1</td><td>80.0</td><td>86.3</td></tr><tr><td>SWAD Cha et al. (2021)</td><td>NeurIPS2021</td><td>89.3</td><td>83.4</td><td>97.3</td><td>82.5</td><td>88.1</td></tr><tr><td>DNA Chu et al. (2022)</td><td>ICML2022</td><td>89.8</td><td>83.4</td><td>97.7</td><td>82.6</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>88.4</td></tr><tr><td>Bayesian</td><td>=</td><td>89.4</td><td>83.5</td><td>97.3</td><td>82.3</td><td>88.1</td></tr><tr><td>Ours</td><td></td><td>90.2</td><td>85.2</td><td>98.7</td><td>83.6</td><td>89.4</td></tr></table>
|
| 172 |
+
|
| 173 |
+
Results. Here, four domain generalization approaches are utilized for comparison, including MASF, LDDG Li et al. (2020a), KDDG Wang et al. (2021), and DSU. To qualitatively evaluate the segmentation results, 5 complementary metrics are introduced from statistical and distance-based perspectives, respectively. The average results on four domain generalization tasks are illustrated in Table 3. The detailed evaluation results for each domain can be found in Appendix. First, the performance of segmentation results among all methods achieve improvements with an obvious margin compared with DeepAll. Second, suffering from insufficient samples in some domains, LDDG and KDDG with deterministic models may not model these uncertainties explicitly. In contrast, our proposed method and DSU can generally obtained the best and second best results.
|
| 174 |
+
|
| 175 |
+
# 4.4 ADDITIONAL RESULTS
|
| 176 |
+
|
| 177 |
+
Ablation study on each component of our proposed method. We are interested in the effectiveness of each component of our proposed method. The results can be shown in Table 4. First, we observe that better performance can be achieved by introducing probabilistic layer compared with the results that using Unet, which reflects the superiority of probabilistic models. Secondly, we observe that by either introducing local or global alignment for domain-invariant information learning, better performance can be achieved compared with the results of only using probabilistic layer, which shows the effectiveness of introduced probabilistic feature regularization term. Last but not the least, by imposing the domain-invariant learning with both local and global views, the performances are further improved, which justifies the effectiveness of our proposed method by jointly considering local and global alignment.
|
| 178 |
+
|
| 179 |
+
Effectiveness of domain-invariant loss. We are also interested in impacts of domain-invariant losses on different tasks. The results can be shown in Figure 3. As we can observe, for the skin lesion (on DMF) and epithelium-stroma (on IHC) classification tasks, the loss curves with iterations reflect the global discrepancy converges faster than local discrepancy, while the more challenging cross-domain task converges more slowly on global alignment.
|
| 180 |
+
|
| 181 |
+
Results on DG Benchmark. While our proposed method is designed for the context of insufficient data, it can also be applied to the setting of conventional DG problem generalization. Here, we introduce three DG benchmarks, namely PACS, OfficeHome and VLCS, for further comparison. Compared with some large-scale benchmarks (e.g., DomainNet and Wilds), these two datasets are more appropriate to explore the effectiveness of different DG models under the scenario of insufficient samples. We report the results on PACS in Table 5. We compare our proposed method with some stateof-the-art DG methods. To be fair, all methods adopt a same backbone, i.e., the pretrained ResNet50. ”Bayesian” model does not have any alignment compared with our model. As we can see, our proposed method outperforms recent methods, such as DNA and SWAD. Specifically, our proposed method surpasses the gradient operation-based method (e.g., RSC). Although data generation methods (e.g., MixStyle) can effectively tackle the insufficient sample problem via additional generative samples, the lack of effective domain-invariant learning may hamper the improvement of the performance.
|
| 182 |
+
|
| 183 |
+
# 5 CONCLUSION
|
| 184 |
+
|
| 185 |
+
In this work, we address the domain generalization problem in the context of insufficient data from source domains. Benefiting from the learned representation captured by probabilistic models, our proposed method can marriage the measurement on the distribution over distributions by level-2 kernel and probabilistic contrastive semantic alignment. Extensive experiments on challenging medical image tasks indicate the effectiveness of our proposed method.
|
| 186 |
+
|
| 187 |
+
# ETHICS STATEMENT
|
| 188 |
+
|
| 189 |
+
We believe that there is no ethics issue in our work. The reasons are provided as follow. First, no personal or private information exists in our adopted medical imaging data. Second, access to these medical imaging data is feasible by signing an agreement form with the provider or download datasets directly from our given website link in the main content. Third, in our submission, we focus on the problem of domain generalization instead of long-tail/imbalance data classification. We therefore follow the previous work on these medical imaging datasets.
|
| 190 |
+
|
| 191 |
+
# REFERENCES
|
| 192 |
+
|
| 193 |
+
Yogesh Balaji, Swami Sankaranarayanan, and Rama Chellappa. Metareg: Towards domain generalization using meta-regularization. Advances in neural information processing systems, 31, 2018.
|
| 194 |
+
|
| 195 |
+
Yogesh Balaji, Rama Chellappa, and Soheil Feizi. Normalized wasserstein for mixture distributions with applications in adversarial learning and domain adaptation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 6500–6508, 2019.
|
| 196 |
+
|
| 197 |
+
Shai Ben-David, John Blitzer, Koby Crammer, and Fernando Pereira. Analysis of representations for domain adaptation. Advances in neural information processing systems, 19, 2006.
|
| 198 |
+
|
| 199 |
+
Alain Berlinet and Christine Thomas-Agnan. Reproducing kernel Hilbert spaces in probability and statistics. Springer Science & Business Media, 2011.
|
| 200 |
+
|
| 201 |
+
Gilles Blanchard, Aniket Anand Deshmukh, Urun Dogan, Gyemin Lee, and Clayton Scott. Domain ¨ generalization by marginal transfer learning. The Journal of Machine Learning Research, 22(1): 46–100, 2021.
|
| 202 |
+
|
| 203 |
+
David M Blei, Alp Kucukelbir, and Jon D McAuliffe. Variational inference: A review for statisticians. Journal of the American statistical Association, 112(518):859–877, 2017.
|
| 204 |
+
|
| 205 |
+
Charles Blundell, Julien Cornebise, Koray Kavukcuoglu, and Daan Wierstra. Weight uncertainty in neural network. In International conference on machine learning, pp. 1613–1622. PMLR, 2015.
|
| 206 |
+
|
| 207 |
+
Karsten M Borgwardt, Arthur Gretton, Malte J Rasch, Hans-Peter Kriegel, Bernhard Scholkopf, ¨ and Alex J Smola. Integrating structured biological data by kernel maximum mean discrepancy. Bioinformatics, 22(14):e49–e57, 2006.
|
| 208 |
+
|
| 209 |
+
Yuheng Bu, Shaofeng Zou, Yingbin Liang, and Venugopal V Veeravalli. Estimation of kl divergence: Optimal minimax rate. IEEE Transactions on Information Theory, 64(4):2648–2674, 2018.
|
| 210 |
+
|
| 211 |
+
Junbum Cha, Sanghyuk Chun, Kyungjae Lee, Han-Cheol Cho, Seunghyun Park, Yunsung Lee, and Sungrae Park. Swad: Domain generalization by seeking flat minima. Advances in Neural Information Processing Systems, 34:22405–22418, 2021.
|
| 212 |
+
|
| 213 |
+
Xu Chu, Yujie Jin, Wenwu Zhu, Yasha Wang, Xin Wang, Shanghang Zhang, and Hong Mei. Dna: Domain generalization with diversified neural averaging. In International Conference on Machine Learning, pp. 4010–4034. PMLR, 2022.
|
| 214 |
+
|
| 215 |
+
Qi Dou, Daniel Coelho de Castro, Konstantinos Kamnitsas, and Ben Glocker. Domain generalization via model-agnostic learning of semantic features. Advances in Neural Information Processing Systems, 32, 2019.
|
| 216 |
+
|
| 217 |
+
Yarin Gal and Zoubin Ghahramani. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conference on machine learning, pp. 1050–1059. PMLR, 2016.
|
| 218 |
+
|
| 219 |
+
Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, Franc¸ois Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. The journal of machine learning research, 17(1):2096–2030, 2016.
|
| 220 |
+
|
| 221 |
+
Rui Gong, Wen Li, Yuhua Chen, and Luc Van Gool. Dlow: Domain flow for adaptation and generalization. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 2477–2486, 2019.
|
| 222 |
+
|
| 223 |
+
Alex Graves. Practical variational inference for neural networks. Advances in neural information processing systems, 24, 2011.
|
| 224 |
+
|
| 225 |
+
Arthur Gretton, Karsten M Borgwardt, Malte J Rasch, Bernhard Scholkopf, and Alexander Smola. A ¨ kernel two-sample test. The Journal of Machine Learning Research, 13(1):723–773, 2012.
|
| 226 |
+
|
| 227 |
+
Ishaan Gulrajani and David Lopez-Paz. In search of lost domain generalization. arXiv preprint arXiv:2007.01434, 2020.
|
| 228 |
+
|
| 229 |
+
Shoubo Hu, Kun Zhang, Zhitang Chen, and Laiwan Chan. Domain generalization via multidomain discriminant analysis. In Uncertainty in Artificial Intelligence, pp. 292–302. PMLR, 2020.
|
| 230 |
+
|
| 231 |
+
Zeyi Huang, Haohan Wang, Eric P Xing, and Dong Huang. Self-challenging improves cross-domain generalization. In European Conference on Computer Vision, pp. 124–140. Springer, 2020.
|
| 232 |
+
|
| 233 |
+
Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna, Yonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, and Dilip Krishnan. Supervised contrastive learning. Advances in Neural Information Processing Systems, 33:18661–18673, 2020.
|
| 234 |
+
|
| 235 |
+
Jin Kim, Jiyoung Lee, Jungin Park, Dongbo Min, and Kwanghoon Sohn. Self-balanced learning for domain generalization. In 2021 IEEE International Conference on Image Processing (ICIP), pp. 779–783. IEEE, 2021.
|
| 236 |
+
|
| 237 |
+
Durk P Kingma, Tim Salimans, and Max Welling. Variational dropout and the local reparameterization trick. Advances in neural information processing systems, 28, 2015.
|
| 238 |
+
|
| 239 |
+
Ranganath Krishnan, Mahesh Subedar, and Omesh Tickoo. Specifying weight priors in bayesian deep neural networks with empirical bayes. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 4477–4484, 2020.
|
| 240 |
+
|
| 241 |
+
Ranganath Krishnan, Pi Esposito, and Mahesh Subedar. Bayesian-torch: Bayesian neural network layers for uncertainty estimation, January 2022. URL https://doi.org/10.5281/zenodo. 5908307.
|
| 242 |
+
|
| 243 |
+
David Krueger, Ethan Caballero, Joern-Henrik Jacobsen, Amy Zhang, Jonathan Binas, Dinghuai Zhang, Remi Le Priol, and Aaron Courville. Out-of-distribution generalization via risk extrapolation (rex). In International Conference on Machine Learning, pp. 5815–5826. PMLR, 2021.
|
| 244 |
+
|
| 245 |
+
Junghwan Lee, Cong Liu, Junyoung Kim, Zhehuan Chen, Yingcheng Sun, James R Rogers, Wendy K Chung, and Chunhua Weng. Deep learning for rare disease: A scoping review. medRxiv, 2022.
|
| 246 |
+
|
| 247 |
+
Chenxin Li, Xin Lin, Yijin Mao, Wei Lin, Qi Qi, Xinghao Ding, Yue Huang, Dong Liang, and Yizhou Yu. Domain generalization on medical imaging classification using episodic training with task augmentation. Computers in Biology and Medicine, 141:105144, 2022a.
|
| 248 |
+
|
| 249 |
+
Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy Hospedales. Learning to generalize: Meta-learning for domain generalization. In Proceedings of the AAAI conference on artificial intelligence, volume 32, 2018a.
|
| 250 |
+
|
| 251 |
+
Haoliang Li, Sinno Jialin Pan, Shiqi Wang, and Alex C Kot. Domain generalization with adversarial feature learning. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 5400–5409, 2018b.
|
| 252 |
+
|
| 253 |
+
Haoliang Li, YuFei Wang, Renjie Wan, Shiqi Wang, Tie-Qiang Li, and Alex Kot. Domain generalization for medical imaging classification with linear-dependency regularization. Advances in Neural Information Processing Systems, 33:3118–3129, 2020a.
|
| 254 |
+
|
| 255 |
+
Menghan Li, Bin Huang, and Guohui Tian. A comprehensive survey on 3d face recognition methods. Engineering Applications of Artificial Intelligence, 110:104669, 2022b.
|
| 256 |
+
|
| 257 |
+
Xiaotong Li, Yongxing Dai, Yixiao Ge, Jun Liu, Ying Shan, and LINGYU DUAN. Uncertainty modeling for out-of-distribution generalization. In International Conference on Learning Representations, 2022c. URL https://openreview.net/forum?id $= 6 .$ HN7LHyzGgC.
|
| 258 |
+
|
| 259 |
+
Xiaoxiao Li, Yufeng Gu, Nicha Dvornek, Lawrence H Staib, Pamela Ventola, and James S Duncan. Multi-site fmri analysis using privacy-preserving federated learning and domain adaptation: Abide results. Medical Image Analysis, 65:101765, 2020b.
|
| 260 |
+
|
| 261 |
+
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense object ´ detection. In Proceedings of the IEEE international conference on computer vision, pp. 2980–2988, 2017.
|
| 262 |
+
|
| 263 |
+
Quande Liu, Cheng Chen, Jing Qin, Qi Dou, and Pheng-Ann Heng. Feddg: Federated domain generalization on medical image segmentation via episodic learning in continuous frequency space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1013–1023, 2021.
|
| 264 |
+
|
| 265 |
+
Xiaofeng Liu, Chaehwa Yoo, Fangxu Xing, Hyejin Oh, Georges El Fakhri, Je-Won Kang, Jonghye Woo, et al. Deep unsupervised domain adaptation: A review of recent advances and perspectives. APSIPA Transactions on Signal and Information Processing, 11(1), 2022.
|
| 266 |
+
|
| 267 |
+
Mingsheng Long, Han Zhu, Jianmin Wang, and Michael I Jordan. Deep transfer learning with joint adaptation networks. In International conference on machine learning, pp. 2208–2217. PMLR, 2017.
|
| 268 |
+
|
| 269 |
+
Divyat Mahajan, Shruti Tople, and Amit Sharma. Domain generalization using causal matching. In International Conference on Machine Learning, pp. 7313–7324. PMLR, 2021.
|
| 270 |
+
|
| 271 |
+
Ankur Mallick, Chaitanya Dwivedi, Bhavya Kailkhura, Gauri Joshi, and T Yong-Jin Han. Deep kernels with probabilistic embeddings for small-data learning. In Uncertainty in Artificial Intelligence, pp. 918–928. PMLR, 2021.
|
| 272 |
+
|
| 273 |
+
Saeid Motiian, Marco Piccirilli, Donald A Adjeroh, and Gianfranco Doretto. Unified deep supervised domain adaptation and generalization. In Proceedings of the IEEE international conference on computer vision, pp. 5715–5725, 2017.
|
| 274 |
+
|
| 275 |
+
Muhammad F Mridha, Abu Quwsar Ohi, Md Abdul Hamid, and Muhammad Mostafa Monowar. A study on the challenges and opportunities of speech recognition for bengali language. Artificial Intelligence Review, 55(4):3431–3455, 2022.
|
| 276 |
+
|
| 277 |
+
Krikamol Muandet, Kenji Fukumizu, Francesco Dinuzzo, and Bernhard Scholkopf. Learning from ¨ distributions via support measure machines. Advances in neural information processing systems, 25, 2012.
|
| 278 |
+
|
| 279 |
+
Krikamol Muandet, Kenji Fukumizu, Bharath Sriperumbudur, Bernhard Scholkopf, et al. Kernel ¨ mean embedding of distributions: A review and beyond. Foundations and Trends® in Machine Learning, 10(1-2):1–141, 2017.
|
| 280 |
+
|
| 281 |
+
Hyeonseob Nam, HyunJae Lee, Jongchan Park, Wonjun Yoon, and Donggeun Yoo. Reducing domain gap by reducing style bias. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 8690–8699, 2021.
|
| 282 |
+
|
| 283 |
+
Radford M Neal. Bayesian learning for neural networks, volume 118. Springer Science & Business Media, 2012.
|
| 284 |
+
|
| 285 |
+
Oren Nuriel, Sagie Benaim, and Lior Wolf. Permuted adain: Reducing the bias towards global statistics in image classification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9482–9491, 2021.
|
| 286 |
+
|
| 287 |
+
Qi Qi, Xin Lin, Chaoqi Chen, Weiping Xie, Yue Huang, Xinghao Ding, Xiaoqing Liu, and Yizhou Yu. Curriculum feature alignment domain adaptation for epithelium-stroma classification in histopathological images. IEEE Journal of Biomedical and Health Informatics, 25(4):1163–1172, 2020.
|
| 288 |
+
|
| 289 |
+
Hangwei Qian, Sinno Jialin Pan, and Chunyan Miao. Latent independent excitation for generalizable sensor-based cross-person activity recognition. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 11921–11929, 2021.
|
| 290 |
+
|
| 291 |
+
Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical image computing and computerassisted intervention, pp. 234–241. Springer, 2015.
|
| 292 |
+
|
| 293 |
+
Shiori Sagawa, Pang Wei Koh, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. arXiv preprint arXiv:1911.08731, 2019.
|
| 294 |
+
|
| 295 |
+
Kihyuk Sohn. Improved deep metric learning with multi-class n-pair loss objective. Advances in neural information processing systems, 29, 2016.
|
| 296 |
+
|
| 297 |
+
Baochen Sun and Kate Saenko. Deep coral: Correlation alignment for deep domain adaptation. In European conference on computer vision, pp. 443–450. Springer, 2016.
|
| 298 |
+
|
| 299 |
+
Vikas Verma, Alex Lamb, Christopher Beckham, Amir Najafi, Ioannis Mitliagkas, David Lopez-Paz, and Yoshua Bengio. Manifold mixup: Better representations by interpolating hidden states. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 6438–6447. PMLR, 09–15 Jun 2019. URL https://proceedings.mlr.press/v97/ verma19a.html.
|
| 300 |
+
|
| 301 |
+
Yufei Wang, Haoliang Li, Lap-pui Chau, and Alex C Kot. Embracing the dark knowledge: Domain generalization using regularized knowledge distillation. In Proceedings of the 29th ACM International Conference on Multimedia, pp. 2595–2604, 2021.
|
| 302 |
+
|
| 303 |
+
Andrew G Wilson and Pavel Izmailov. Bayesian deep learning and a probabilistic perspective of generalization. Advances in neural information processing systems, 33:4697–4708, 2020.
|
| 304 |
+
|
| 305 |
+
Zehao Xiao, Jiayi Shen, Xiantong Zhen, Ling Shao, and Cees Snoek. A bit more bayesian: Domaininvariant learning with uncertainty. In International Conference on Machine Learning, pp. 11351– 11361. PMLR, 2021.
|
| 306 |
+
|
| 307 |
+
Xufeng Yao, Yang Bai, Xinyun Zhang, Yuechen Zhang, Qi Sun, Ran Chen, Ruiyu Li, and Bei Yu. Pcl: Proxy-based contrastive learning for domain generalization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7097–7107, 2022.
|
| 308 |
+
|
| 309 |
+
Chris Yoon, Ghassan Hamarneh, and Rafeef Garbi. Generalizable feature learning in the presence of data bias and domain class imbalance with application to skin lesion classification. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 365–373. Springer, 2019.
|
| 310 |
+
|
| 311 |
+
Yuya Yoshikawa, Tomoharu Iwata, and Hiroshi Sawada. Latent support measure machines for bag-of-words data classification. Advances in neural information processing systems, 27, 2014.
|
| 312 |
+
|
| 313 |
+
Xiangyu Yue, Yang Zhang, Sicheng Zhao, Alberto Sangiovanni-Vincentelli, Kurt Keutzer, and Boqing Gong. Domain randomization and pyramid consistency: Simulation-to-real generalization without accessing target domain data. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 2100–2110, 2019.
|
| 314 |
+
|
| 315 |
+
Syed Sahil Abbas Zaidi, Mohammad Samar Ansari, Asra Aslam, Nadia Kanwal, Mamoona Asghar, and Brian Lee. A survey of modern deep learning based object detection models. Digital Signal Processing, pp. 103514, 2022.
|
| 316 |
+
|
| 317 |
+
Kaiyang Zhou, Yongxin Yang, Timothy Hospedales, and Tao Xiang. Learning to generate novel domains for domain generalization. In European conference on computer vision, pp. 561–578. Springer, 2020.
|
| 318 |
+
|
| 319 |
+
Kaiyang Zhou, Yongxin Yang, Yu Qiao, and Tao Xiang. Domain generalization with mixstyle. arXiv preprint arXiv:2104.02008, 2021.
|
| 320 |
+
|
| 321 |
+
Kaiyang Zhou, Ziwei Liu, Yu Qiao, Tao Xiang, and Chen Change Loy. Domain generalization: A survey. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
|
| 322 |
+
|
| 323 |
+
# A APPENDIX
|
| 324 |
+
|
| 325 |
+
# A.1 DETAILS OF BAYESIAN NEURAL NETWORK
|
| 326 |
+
|
| 327 |
+
For our proposed method, the Bayesian layer refers to the probabilistic extractor $Q _ { \phi }$ and the probabilistic classifier $C _ { \omega }$ . Here, a simple and convenient PyTorch library, namely BayesianTorch Krishnan et al. (2022), is utilized to construct the Bayesian neural network. The log evidence lower bound (ELBO) cost function, i.e.,
|
| 328 |
+
|
| 329 |
+
$$
|
| 330 |
+
\mathcal { L } : = \int q _ { \theta } l o g ( y | x , w ) d w - \mathrm { K L } [ q _ { \theta } ( w ) | p ( w ) ] ,
|
| 331 |
+
$$
|
| 332 |
+
|
| 333 |
+
can be calculated automatically. By using BayesianTorch, arbitrary deterministic models can be converted into the Bayesian layers easily. In this paper, mean-field variational inference (MFVI) Graves (2011) is adopted, where the parameters of the model are characterized by fully factorized Gaussian distribution endowed by variational parameters $\mu$ and $\sigma$ , i.e.,
|
| 334 |
+
|
| 335 |
+
$$
|
| 336 |
+
q _ { \theta } ( w ) : = \mathcal { N } ( w | \mu , \sigma ) .
|
| 337 |
+
$$
|
| 338 |
+
|
| 339 |
+
By using stochastic gradient descent method with ELBO cost, the variational distribution $q _ { \theta } ( w )$ as the approximation of the posterior distribution, and corresponding parameters ( $\mu$ and $\sigma$ ) and can be learned conveniently.
|
| 340 |
+
|
| 341 |
+
For the settings of Bayesian layer, we follow the model priors with empirical Bayes using DNN (MOPED) method for the parameter settings of weights prior, each weight is sampled from the Gaussian distribution independently Krishnan et al. (2020),
|
| 342 |
+
|
| 343 |
+
$$
|
| 344 |
+
w \sim \mathcal { N } ( w _ { \mathrm { D N N } } , \delta | w _ { \mathrm { D N N } } | ) ,
|
| 345 |
+
$$
|
| 346 |
+
|
| 347 |
+
where $w _ { \mathrm { D N N } }$ denotes the mean of prior distribution from the maximum likelihood estimates of weights from deterministic deep neural network. $\delta$ , a hyperparameter, is set to the initial perturbation factor for the percentage of the pretrained deterministic weight values. The variational layer is modeled using reparameterization trick. The MOPED can realize better training convergence for complex models Krishnan et al. (2020), which is beneficial to our proposed method. In this paper, we follow the setting in (Krishnan et al., 2020) to set the initial perturbation factor $\delta$ for the weight to 0.1.
|
| 348 |
+
|
| 349 |
+
# A.2 EXPERIMENTAL DETAILS OF SKIN LESION CLASSIFICATION
|
| 350 |
+
|
| 351 |
+
Dataset Details. There are seven classes of skin lesions, including melanoma $( m e l )$ , melanocytic nevus $( n \nu )$ , dermato broma $( d f )$ , basal cell carcinoma $( b c c )$ benign keratosis $( b k l )$ , vascular lesion (vasc), and actinic keratosis (akiec). The 7 public skin lesion datasets suffer from an insufficient data problem from some (certain) source domains. For example, the PH2 and UDA datasets only have 200 and 601 skin lesion images, respectively. The number of images for each domain can be found in Table 9. More details of datasets can be found in Yoon et al. (2019). For inputs, all images are resized into $2 2 4 \times 2 2 4$ for all methods.
|
| 352 |
+
|
| 353 |
+
Implementation Details. The pretrained ResNet18 is introduced as the backbone for all methods. For our proposed method, the structure of Bayesian layer in probabilistic extractor $Q _ { \phi }$ is a fullyconnected based Bayesian neural network with $5 1 2 \times 5 1 2$ . Note that the DSU, BDIL, DNA, and our proposed method are constructed based on SWAD framework. The hyperparameters of SWAD follow default settings Cha et al. (2021). The DSU can be regarded as the uncertainty version of SWAD with ResNet18. The structure of Bayesian layer in probabilistic classifier $C _ { \omega }$ is also a fully-connected based Bayesian neural network with $5 1 2 \times 7$ . The construction of $C _ { \omega }$ is the same as that of $T _ { \phi }$ . Due to the class imbalance problem, the focal loss Lin et al. (2017) as the classification objective is introduced for all methods.
|
| 354 |
+
|
| 355 |
+
During training, our proposed method is optimized by Adam optimizer with $5 \times 1 0 ^ { - 5 }$ learning rate. The training steps are 2000. For each step, we randomly sample from each training source domain with 32 samples to construct the mini-batch. To evaluate the testing set, the training process is stopped according to the validation loss computed by SWAD on the validation set. The hyperparameters are also selected in a wide range on the validation set. For the probabilistic MMD, level-1 and leve-2 kernels are the Gaussian RBF kernels by following (Muandet et al., 2012). The kernel bandwidth is empirically set to 1 for all kernels. For the probabilistic CSA loss, the distance margin $\xi$ is set to 1. For the $\mathcal { L } _ { l o c a l }$ and the $\mathcal { L } _ { g l o b a l }$ , the $\beta _ { 1 }$ and $\beta _ { 2 }$ are 0.1 and 0.7, respectively. By balancing the performance and computational efficiency, $T$ , the number of Monte Carlo sampling in each Bayesian layer, is 10.
|
| 356 |
+
|
| 357 |
+
Table 6: Domain generalization results on gray matter segmentation task. For the DSC, CC, TPR, and JI, the higher the better. For the ASD, the lower the better.
|
| 358 |
+
|
| 359 |
+
<table><tr><td colspan="8">(a) DeepAll</td><td colspan="8">(b) KDDG</td></tr><tr><td>source</td><td>target</td><td>DSC</td><td>CC</td><td>JI</td><td>TPR</td><td>ASD</td><td>source</td><td>target</td><td></td><td>DSC</td><td>CC</td><td>JI</td><td>TPR</td><td>ASD</td></tr><tr><td>2,3,4</td><td>1</td><td>0.8560</td><td>65.34</td><td>0.7520</td><td>0.8746</td><td>0.0809</td><td>2,3,4</td><td>1</td><td>0.8745</td><td>70.75</td><td></td><td>0.7795</td><td>0.8949</td><td>0.0539</td></tr><tr><td>1,3,4</td><td>2</td><td>0.7323</td><td>26.21</td><td>0.5789</td><td>0.8109</td><td>0.0992</td><td>1,3,4</td><td>2</td><td></td><td>0.8229</td><td>56.71</td><td>0.6997</td><td>0.8226</td><td>0.0490</td></tr><tr><td>1,2,4</td><td>3</td><td>0.5041</td><td>-209</td><td>0.3504</td><td>0.4926</td><td>1.8661</td><td>1,2.4</td><td>3</td><td>0.5676</td><td></td><td>-63.1</td><td>0.3866</td><td>0.5904</td><td>1.2805</td></tr><tr><td>1,2.3</td><td>4</td><td>0.8775</td><td>71.92</td><td>0.7827</td><td>0.8888</td><td>0.0599</td><td>1,2,3</td><td>4</td><td>0.8894</td><td></td><td>75.06</td><td>0.8011</td><td>0.9222</td><td>0.0377</td></tr><tr><td>Average</td><td></td><td>0.7425</td><td>-11.4</td><td>0.6160</td><td>0.7667</td><td>0.5265</td><td colspan="2">Average</td><td>0.7886</td><td>34.86</td><td></td><td>0.6667</td><td>0.8075</td><td>0.3553</td></tr><tr><td colspan="10">(c) MASF</td><td colspan="7">(d) LDDG</td></tr><tr><td>source</td><td>target</td><td>DSC</td><td>CC</td><td>JI</td><td>TPR</td><td>ASD</td><td>source</td><td>target</td><td></td><td>DSC</td><td>CC</td><td>JI</td><td>TPR</td><td>ASD</td></tr><tr><td>2.3,4</td><td>1</td><td>0.8502</td><td>64.22</td><td>0.7415</td><td>0.8903</td><td>0.2274</td><td>2.3,4</td><td>1</td><td>0.8708</td><td>69.29</td><td></td><td>0.7753</td><td>0.8978</td><td>0.0411</td></tr><tr><td>1,3,4</td><td>2</td><td>0.8115</td><td>53.04</td><td>0.6844</td><td>0.8161</td><td>0.0826</td><td>1,3,4</td><td>2</td><td>0.8364</td><td>60.58</td><td></td><td>0.7199</td><td>0.8485</td><td>0.0416</td></tr><tr><td>1,2,4</td><td>3</td><td>0.5285</td><td>-99.3</td><td>0.3665</td><td>0.5155</td><td>1.8554</td><td>1,2,4</td><td>3</td><td>0.5543</td><td></td><td>-71.6</td><td>0.3889</td><td>0.5923</td><td>1.5187</td></tr><tr><td>1,2,3</td><td>4</td><td>0.8938</td><td>76.14</td><td>0.8083</td><td>0.8991</td><td>0.0366</td><td>1,2.3</td><td>4</td><td>0.8910</td><td></td><td>75.46</td><td>0.8039</td><td>0.8844</td><td>0.0289</td></tr><tr><td>Average</td><td></td><td>0.7710</td><td>23.52</td><td>0.6502</td><td>0.7803</td><td>0.5505</td><td colspan="2">Average</td><td>0.7881</td><td>33.43</td><td></td><td>0.6720</td><td>0.8058</td><td>0.4076</td></tr><tr><td colspan="10">(e)DSU</td><td colspan="7">(f) Ours</td></tr><tr><td>source</td><td>target</td><td>DSC</td><td>CC</td><td>JI</td><td>TPR</td><td>ASD</td><td>source</td><td>target</td><td>DSC</td><td>CC</td><td></td><td>JI</td><td>TPR</td><td>ASD</td></tr><tr><td>2,3,4</td><td>1</td><td>0.8739</td><td>70.32</td><td>0.7794</td><td>0.9210</td><td>0.0793</td><td>2,3,4</td><td>1</td><td>0.8786</td><td>71.57</td><td></td><td>0.7873</td><td>0.9293</td><td>0.0422</td></tr><tr><td>1,3,4</td><td>2</td><td>0.8474</td><td>63.58</td><td>0.7367</td><td>0.8502</td><td>0.0494</td><td>1,3,4</td><td>2</td><td>0.8485</td><td>63.78</td><td></td><td>0.7389</td><td>0.8401</td><td>0.0401</td></tr><tr><td>1,2,4</td><td>3</td><td>0.5574</td><td>-70.4</td><td>0.3923</td><td>0.6097</td><td>1.5049</td><td>1,2,4</td><td>3</td><td>0.5634</td><td></td><td>-68.0</td><td>0.3992</td><td>0.6103</td><td>1.2239</td></tr><tr><td>1,2,3</td><td>4</td><td>0.8897</td><td>75.10</td><td>0.8018</td><td>0.9225</td><td>0.0415</td><td>1,2.3</td><td>4</td><td>0.8921</td><td></td><td>75.69</td><td>0.8058</td><td>0.9245</td><td>0.0362</td></tr><tr><td>Average</td><td></td><td>0.7921</td><td>34.65</td><td>0.6775</td><td>0.8225</td><td>0.4362</td><td></td><td>Average</td><td></td><td>0.7957</td><td>35.76</td><td>0.6828</td><td>0.8260</td><td>0.3356</td></tr></table>
|
| 360 |
+
|
| 361 |
+
# A.3 EXPERIMENTAL DETAILS OF EPITHELIUM STROMA CLASSIFICATION
|
| 362 |
+
|
| 363 |
+
Dataset Details. There are two types of basic tissues, i.e., the epithelium and the stroma. Due to the differences of the scanner, the staining type, and the population, the color of the background and the morphological structure among different histopathological image datasets are diverse. The number of images for each domain can be found in Table 9. The extract epithelial or stromal patches are resized into $2 2 4 \times 2 2 4$ .
|
| 364 |
+
|
| 365 |
+
Implementation Details. The pretrained ResNet18 is utilized as the backbone for all methods. The basic model framework and corresponding parameters for our proposed method are similar with the settings mentioned in A.2. The DSU, BDIL, DNA, and our proposed method are constructed based on SWAD framework with DomainBed benchmark. The classification objective is the cross-entropy loss with softmax function.
|
| 366 |
+
|
| 367 |
+
During training, our proposed method is optimized by Adam optimizer with $5 \times 1 0 ^ { - 5 }$ learning rate. The training steps are 4000. The holdout fraction rate for DomainBed is set to 0.2 for all methods such that the hyperparameters can be selected in a wide range on the validation set. The $\beta _ { 1 }$ and $\beta _ { 2 }$ are 0.1 and 0.7 for the $\mathcal { L } _ { l o c a l }$ and the $\mathcal { L } _ { g l o b a l }$ , respectively. Other hyperparameters are the same as the settings mentioned in A.2.
|
| 368 |
+
|
| 369 |
+
# A.4 EXPERIMENTAL DETAILS OF SPINAL CORD GRAY MATTER SEGMENTATION
|
| 370 |
+
|
| 371 |
+
Dataset Details. The spinal cord gray matter (GM) segmentation is an emergent task that can be utilized to predict disability (as a biomarker) via evaluating the atrophy of GM area. The acquired magnetic resonance imaging (MRI) data are collected from four healthcare centers (including ”site1”, ”site2”,”site3”, and ”site4”), where acquisition manufacturers (including Philips Achieva, Siemens Trio, and Siemens Skyra) and imaging protocols (lead to the difference in the resolution of the voxel) are variable. The number of images for each domain can be found in Table 9. By following (Li et al.,
|
| 372 |
+
|
| 373 |
+
Table 7: Out-of-domain accuracies $( \% )$ on OfficeHome based on ResNet50.
|
| 374 |
+
|
| 375 |
+
<table><tr><td>Algorithm</td><td>Art</td><td>Clipart</td><td>Product</td><td>Real</td><td>Avg</td></tr><tr><td>Mixstyle Zhou et al. (2021)</td><td>51.1</td><td>53.2</td><td>68.2</td><td>69.2</td><td>60.4</td></tr><tr><td>RSC Huang et al. (2020)</td><td>60.7</td><td>51.4</td><td>74.8</td><td>75.1</td><td>65.5</td></tr><tr><td>DANN Ganin et al. (2016)</td><td>59.9</td><td>53.0</td><td>73.6</td><td>76.9</td><td>65.9</td></tr><tr><td>GroupDRO Sagawa et al. (2019)</td><td>60.4</td><td>52.7</td><td>75.0</td><td>76.0</td><td>66.0</td></tr><tr><td>MTL Blanchard et al. (2021)</td><td>61.5</td><td>52.4</td><td>74.9</td><td>76.8</td><td>66.4</td></tr><tr><td>VREx Krueger et al. (2021)</td><td>60.7</td><td>53.0</td><td>75.3</td><td>76.6</td><td>66.4</td></tr><tr><td>MLDG Balaji et al. (2018)</td><td>61.5</td><td>53.2</td><td>75.0</td><td>77.5</td><td>66.8</td></tr><tr><td>SagNet Qian et al. (2021)</td><td>63.4</td><td>54.8</td><td>75.8</td><td>78.3</td><td>68.1</td></tr><tr><td>CORAL Sun & Saenko (2016)</td><td>65.3</td><td>54.4</td><td>76.5</td><td>78.4</td><td>68.7</td></tr><tr><td>SWAD Cha et al. (2021)</td><td>66.1</td><td>57.7</td><td>78.4</td><td>80.2</td><td>70.6</td></tr><tr><td>DNA Chu et al. (2022)</td><td>67.7</td><td>57.7</td><td>78.9</td><td>80.5</td><td>71.2</td></tr><tr><td>Bayesian</td><td>67.0</td><td>58.0</td><td>79.3</td><td>80.4</td><td>71.2</td></tr><tr><td>Ours</td><td>68.2</td><td>58.9</td><td>80.2</td><td>80.7</td><td>72.0</td></tr></table>
|
| 376 |
+
|
| 377 |
+
Table 8: Out-of-domain accuracies (%) on VLCS based on ResNet50.
|
| 378 |
+
|
| 379 |
+
<table><tr><td>Algorithm</td><td>C</td><td>L ?</td><td>S</td><td>V</td><td>Ayg</td></tr><tr><td>Mixstyle Zhou et al. (2021) RSC Huang et al. (2020) DANN Ganin et al. (2016) GroupDRO Sagawa et al. (2019)</td><td>98.3 97.9 99.0 97.3 97.8</td><td>64.8 62.5 65.1 63.4 64.3 64.4</td><td>72.1 72.3 73.1 69.5 71.5 74.1</td><td>74.3 75.6 77.2 76.7 75.3 76.2</td><td>77.4 77.1 78.6 76.7 77.2 78.3</td></tr></table>
|
| 380 |
+
|
| 381 |
+
2018b), the 3D MRI data are split into 2D slices in axial view. Then, these obtained 2D slices are centered cropped to $1 6 0 \times 1 6 0$ and randomly cropped to $1 4 4 \times 1 4 4$ for training.
|
| 382 |
+
|
| 383 |
+
Implementation Details. The 2D-Unet Ronneberger et al. (2015) is leveraged as the backbone for all methods. For our proposed method, probabilistic extractor $Q _ { \phi }$ is constructed by two Bayesian-based $1 \times 1$ convolutional layers. The input and output channels in the first convolutional layer are both 64. After a ReLU layer, the input and output channels in the second convolutional laye are 64 and 1, respectively. The BayesianTorch can enable to convert ordinary convolutional layer into Bayesian convolutional neural network easily. The Bayesian neural network adopts MFVI to approximate the posterior distribution of weights. The parameters of Bayesian layer are the same as aforementioned settings. The structure of Bayesian layer in probabilistic classifier $C _ { \omega }$ is a Bayesian-based $1 \times 1$ convolutional layers. The input and output channels are 64 and 1, respectively. The construction of $C _ { \omega }$ is the same as that of $T _ { \phi }$ . Here, all methods adopt a two-stage scheme for coarse-to-fine segmentation, as used in (Li et al., 2020a). Specifically, we first conduct preliminary segmentation to obtain the spinal cord area from the original 2D slice. Then, we perform elaborative segmentation on obtained spinal cord results to derive gray matter results.
|
| 384 |
+
|
| 385 |
+
Here, the settings of most hyperparameters follow (Li et al., 2020a), where the Adam optimizer is utilized with learning rate as $1 \times 1 0 ^ { - 4 }$ , weight decay as $1 \times 1 0 ^ { - 8 }$ . We randomly select 8 slices from each source domain to construct the mini-batch. All models are trained with 200 epochs, where the learning rate will be decreased each 80 epochs with a factor of 10. Other hyperparameters such as kernel function, kernel bandwidth and distance margin are similar with the settings in skin lesion classification and epithelium-stroma classification. The segmentation can be regarded as the pixel-level classification. For the $\mathcal { L } _ { l o c a l }$ and $\mathcal { L } _ { g l o b a l }$ , we follow (Motiian et al., 2017) to randomly sample some positive and negative pairs from two domains such that the computational efficiency can be improved significantly. Here, we randomly sample 400 positive and negative pixel pairs from two domains in a mini-batch for the computation of $\mathcal { L } _ { l o c a l }$ , respective. By leveraging selected pixels of a domain in $\mathcal { L } _ { l o c a l }$ , we further utilize these pixels to calculate the $\mathcal { L } _ { g l o b a l }$ , which may induce a more accurate measurement owing to the balanced class distribution, as well as reducing computational cost. For the $\mathcal { L } _ { l o c a l }$ and $\mathcal { L } _ { g l o b a l }$ , the $\beta _ { 1 }$ and the $\beta _ { 2 }$ are set to 0.01 and 0.001.
|
| 386 |
+
|
| 387 |
+
Table 9: The details of adopted datasets
|
| 388 |
+
|
| 389 |
+
<table><tr><td rowspan=1 colspan=1>Task</td><td rowspan=1 colspan=1>Datasets Domains) and Corresponding Size</td><td rowspan=1 colspan=1>Number of Class</td></tr><tr><td rowspan=1 colspan=1> Skin Lesion Classification</td><td rowspan=1 colspan=1>HAM:10015: DMF:1212: D7P:1926:MSK:3551;UDA:601: PH2:200: SON:9251</td><td rowspan=1 colspan=1>7</td></tr><tr><td rowspan=1 colspan=1>Epithelium Stroma Classification</td><td rowspan=1 colspan=1>NKI: 671: IHC:1376: VGH: 615</td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=1 colspan=1>Spnal Cord GM Segementation</td><td rowspan=1 colspan=1>site1: 30; site2: 113: site3: 246: site4: 122</td><td rowspan=1 colspan=1>2 (pixel-level)</td></tr><tr><td rowspan=1 colspan=1>PACS</td><td rowspan=1 colspan=1>Art:2048: Cartoon:2344: Photo:1670: Sketch:3929</td><td rowspan=1 colspan=1>7</td></tr><tr><td rowspan=1 colspan=1>OfficeHome</td><td rowspan=1 colspan=1>A total of around 15500 images for 4 domains(Art,Clipart,Product,and Real with around 3897 per domain)</td><td rowspan=1 colspan=1>6</td></tr><tr><td rowspan=1 colspan=1>VLCS</td><td rowspan=1 colspan=1>VOC2007 (V): 3376: LabelMe (L):2656;SUN09(S):3282: Caltech101 (C): 1415</td><td rowspan=1 colspan=1>5</td></tr></table>
|
| 390 |
+
|
| 391 |
+
Result Analysis. Dice Similarity Coefficient (DSC), Jaccard Index (JI), and Conformity Coefficient (CC) are used to measure the accuracy of obtained segmentation results. Besides, True Positive Rate (TPR) and Average Surface Distance (ASD) are introduced as complementary evaluations from statistical and distance-based perspectives. The experimental results are shown in Table 6 in details. As we can see, our proposed method can achieve best or second-best performance in all task. For average results, our proposed method and DSU roughly achieve the best and second-best performance, especially in the DSC, JI, and TPR, which may be reasonable. Specifically, DSU introduce the multivariate Gaussian distribution of feature statistics for the uncertainty of the feature. Our proposed method not only can model the uncertainty by the introduction of Bayesian neural network, but also can learn distribution-based domain-invariant representations in latent feature space.
|
| 392 |
+
|
| 393 |
+
# A.5 EXPERIMENTAL SETTINGS AND ADDITIONAL RESULTS ON BENCHMARK
|
| 394 |
+
|
| 395 |
+
Besides PACS benchmark dataset, we further validate the effectiveness of our proposed method on two popular benchmark datasets, including OfficeHome (has 15588 samples with 65 classes from four domains) and VLCS (has 10729 samples with 5 classes from four domains). The number of images for each domain can be found in Table 9. We adopt pretrained ResNet50 as the backbone for all benchmarks. The structure of the overall framework is similar with the model mentioned in lesion skin classification. Our proposed method as well as baseline methods are all based on DomainBed, where the holdout fraction (the proportion of validation set) rate for DomainBed is set to 0.2 for all methods. A domain is the target domain and the remaining domains are the source domain for training. The testing is on the overall data of a target domain.
|
| 396 |
+
|
| 397 |
+
Here, our proposed method is optimized by Adam optimizer with learning rate as $5 \times 1 0 ^ { - 5 }$ . The batch size for each source domain is 32. The training steps are set to 20000 for PACS and OfficeHome, and 2000 for VLCS. By following the SWAD framework, the training process will be stopped for our proposed method when the validation loss increases significantly. The hyperparameters are selected in a wide range on the validation set. For the $\mathcal { L } _ { l o c a l }$ and $\mathcal { L } _ { g l o b a l }$ , the $\beta _ { 1 }$ and the $\beta _ { 2 }$ are set to 0.1 and 1 for all benchmark datasets. Other hyperparameters such as kernel function, kernel bandwidth and distance margin are similar with the settings mentioned before.
|
| 398 |
+
|
| 399 |
+
The experimental results on OfficeHome and VLCS can be shown in Table 7 and Table 8. As we can see, our proposed method achieves better performance compared with state-of-the-art methods, such as SWAD and DNA. Compared with domain-invariant based approaches (e.g., DANN), our proposed method has a significant improvement due to the introduction of probabilistic framework. Meanwhile, the model, namely ”Bayesian” on Table 7 can be regarded as a probabilistic version of
|
| 400 |
+
|
| 401 |
+

|
| 402 |
+
Figure 4: The performance of our proposed model on the NKI task of Epithelium Stroma classification with different Monte Carlo samples $T$ .
|
| 403 |
+
|
| 404 |
+

|
| 405 |
+
Figure 5: The performance comparison between mean embedding method and kernel mean embedding method with different Monte Carlo samples $T$ . For each sub-figure, we use only one alignment operation. (a) Local alignment. Mean Embedding: The mean embedding operation with Euclidean distance is utilized between probabilistic embedding pairs. Kernel Mean Embedding: The kernel mean embedding with MMD distance is utilized between probabilistic embedding pairs. (b) Global alignment. Mean Embedding: The mean embedding operation with MMD distance is utilized between domains (as distributions). Kernel Mean Embedding: The kernel mean embedding with P-MMD distance is utilized between domains (as distributions over distributions).
|
| 406 |
+
|
| 407 |
+
SWAD via replacing deterministic layers with Bayesian layers. Interestingly, compared with SWAD, a significant improvement can be obtained by Bayesian model (which does not have any alignment compared with our model), which shows the effectiveness of probabilistic framework on insufficient data. Our proposed method also outperforms the data augmentation-based approach (e.g., Mixstyle).
|
| 408 |
+
|
| 409 |
+
# A.6 ADDITIONAL ANALYSIS
|
| 410 |
+
|
| 411 |
+
First, it is much important to balance the number of Monte Carlos samples and the computational efficiency. On the one hand, the property of probabilistic embeddings can be affected by the Monte Carlos sampling. On the other hand, too many Monte Carlos samples may suffer from the heavy computational cost. (Xiao et al., 2021) suggested that the distributional property and computational cost are both acceptable for the computation of the KL divergence when the number of Monte Carlos samples is chosen appropriately, the practical performance for our proposed method need to be explored. We conduct the experiments on the NKI task of Epithelium-Stromal classification with different Monte Carlo samples $T$ .
|
| 412 |
+
|
| 413 |
+
The results are shown in Figure 4. As we can see, if the number of Monte Carlo samples is too small, it is difficult to capture the property of distribution for probabilistic embeddings. As the increase of $T$ , there is an obvious improvement for our proposed method. Interestingly, the performance is gradually saturated. As a result, by balancing the number of Monte Carlos samples and the computational efficiency, the number of Monte Carlos samples $T$ in each Bayesian layer is set to 10.
|
| 414 |
+
|
| 415 |
+
Kernel Mean Embedding (level-2 kernel) v.s. Mean Embedding. Second, we explore the effect of different schemes for probabilistic embeddings. A straightforward method is first to represent probabilistic embeddings with the expectation (i.e., first moment), which is called as the Mean Embedding. Then, a probabilistic embedding can be regarded as a latent point, and the MMD can be leveraged to measure the discrepancy between distributions consisted of latent points.
|
| 416 |
+
|
| 417 |
+
For the mean embedding-based $\mathcal { L } _ { g l o b a l }$ , the computational process of this scheme for MMD distance can be formulated as
|
| 418 |
+
|
| 419 |
+
$$
|
| 420 |
+
\mathrm { M M D } ( \mathbb { P } _ { l } , \mathbb { P } _ { t } ) ^ { 2 } = \| \frac { 1 } { n _ { l } } \sum _ { i = 1 } ^ { n _ { l } } \varphi ( \mathbb { E } [ \Pi _ { l _ { i } } ] ) - \frac { 1 } { n _ { t } } \sum _ { j = 1 } ^ { n _ { t } } \varphi ( \mathbb { E } [ \Pi _ { t _ { j } } ] ) \| _ { \mathcal { H } } ^ { 2 } .
|
| 421 |
+
$$
|
| 422 |
+
|
| 423 |
+
The Eq. (13) can be further constructed a global alignment loss $\mathcal { L } _ { g l o b a l }$ . For the local alignment loss $\mathcal { L } _ { l o c a l }$ , the Euclidean distance can be used to compute the distance between latent points, which is similar with original CAS loss in (Motiian et al., 20the mean embedding-based positive contrastive loss $\mathcal { L } _ { l o c a l } ^ { p o s }$ or the positive pairs with the same label,can be represented as
|
| 424 |
+
|
| 425 |
+
$$
|
| 426 |
+
\mathcal { L } _ { l o c a l } ^ { p o s } = \frac { 1 } { 2 } \left\| \frac { 1 } { T } \sum _ { i = 1 } ^ { T } \mathbb { E } \left[ M _ { \Theta } ( \mathbf { z } _ { n _ { i } } ) \right] ) - \frac { 1 } { T } \sum _ { j = 1 } ^ { T } \mathbb { E } \left[ M _ { \Theta } ( \mathbf { z } _ { q _ { j } } ) \right] ) \right\| _ { 2 } ^ { 2 } , s . t . \mathbf { y } _ { n } = \mathbf { y } _ { q } ,
|
| 427 |
+
$$
|
| 428 |
+
|
| 429 |
+
where $M _ { \Theta } ( \cdot )$ denotes the embedding network of metric learning. For the negative pairs with the different labels, the negative contrastive loss is denoted by
|
| 430 |
+
|
| 431 |
+
$$
|
| 432 |
+
\mathcal { L } _ { l o c a l } ^ { n e g } = \frac { 1 } { 2 } \operatorname* { m a x } [ 0 , \boldsymbol { \xi } - \left\| \frac { 1 } { T } \sum _ { i = 1 } ^ { T } \mathbb { E } \left[ M _ { \Theta } ( \mathbf { z } _ { n _ { i } } ) \right] ) - \frac { 1 } { T } \sum _ { j = 1 } ^ { T } \mathbb { E } \left[ M _ { \Theta } ( \mathbf { z } _ { q _ { j } } ) \right] ) \right\| _ { 2 } ^ { 2 } ] , s . t . \mathbf { y } _ { n } \neq \mathbf { y } _ { q } .
|
| 433 |
+
$$
|
| 434 |
+
|
| 435 |
+
As a result, a mean embedding-based contrastive loss with the view of local alignment can be calculated as
|
| 436 |
+
|
| 437 |
+
$$
|
| 438 |
+
\mathcal { L } _ { l o c a l } = \mathcal { L } _ { l o c a l } ^ { p o s } + \mathcal { L } _ { l o c a l } ^ { n e g } .
|
| 439 |
+
$$
|
| 440 |
+
|
| 441 |
+
Instead, we can observe from Figure 2 that our proposed method induces a level-2 kernel-based MMD with empirical estimation for probabilistic embeddings. Specifically, our proposed scheme can preserve higher moments of a probabilistic embedding via nonlinear level-1 kernel (see the fourth component in Figure 2). Moreover, by introducing a level-2 kernel, the similarities between probabilistic embeddings also can be measured based on their own moment information (see the last component in Figure 2). Benefiting from these virtues, the proposed probabilistic MMD can accurately capture the discrepancy between mixture distributions via an extended empirical MMD fashion.
|
| 442 |
+
|
| 443 |
+
Here, we validate the effectiveness of different schemes on the NKI task of Epithelium Stroma classification in each aligned view. The experimental settings are similar for different methods. The experimental results can be found in Figure 5. As we can see, our proposed method achieves consistent improvements in each alignment method with different Monte Carlo samples, which may be reasonable as the kernel mean representation can preserve many statistical components due to the injective property. Second, when the number of MC samples is 10, we can observe an obvious margin in global alignment, which refers to the computation between mixture distributions. ✿
|
| 444 |
+
|
| 445 |
+
Finally, we are also interested in the performance of the proposed method under challenging small data scenarios compared with baseline methods. As a result, we conduct two kinds of experiments with different conditions on skin lesion classification, including a fixed number of samples per class in each source domain and a fixed fraction of samples in each source domain. We choose MSK dataset as the target domain and the remaining domains as the source domains.
|
| 446 |
+
|
| 447 |
+
Table 10: Fixed number of samples per class in each source domain.
|
| 448 |
+
|
| 449 |
+
<table><tr><td>Number of sample per class for each source domain</td><td>DeepAll</td><td>DSU</td><td>BDIL</td><td>DNA?</td><td>Qurs</td></tr><tr><td>40</td><td>0.5399 ±0.0156</td><td>0.6145 ±0.0175</td><td></td><td>0.5897±0.0029 0.5412 ±0.0143 0.6368±0.0074</td><td></td></tr><tr><td>30</td><td></td><td></td><td></td><td>0.5309±0.02010.5458±0.01840.5762_±0.01010.5132±0.02290.6138±0.0291</td><td></td></tr><tr><td>20</td><td>0.5044 ±0.0129</td><td>0.5243 ±0.0143</td><td>0.5573 ±0.0011</td><td>0.5048 ±0.00870.6037±0.0121</td><td></td></tr></table>
|
| 450 |
+
|
| 451 |
+
Table 11: Fixed fraction of samples in each source domain.
|
| 452 |
+
|
| 453 |
+
<table><tr><td>Fraction of sample for each source domain</td><td>DeepAll</td><td>DSU</td><td>BDIL</td><td>DNA</td><td>Qurs</td></tr><tr><td>100%</td><td>0.6674 ±0.0312</td><td>0.6935 ±0.0121</td><td>0.7059 ±0.0284</td><td>0.7121_±0.0141</td><td>0.7276 ±0.0123</td></tr><tr><td>80%</td><td>0.6614 ±0.0123</td><td>0.6717 ±0.0029</td><td>0.6625 ±0.092</td><td>0.6591 ±0.0022</td><td>0.6975 ±0.0036</td></tr><tr><td>60%</td><td>0.6249 ±0.0122</td><td>0.6299 ±0.0114</td><td>0.6468 ±0.0106</td><td>0.6149 ±0.0112</td><td>0.6641 ±0.0114</td></tr><tr><td>40%</td><td>0.5911 ±0.0215</td><td>0.6188 ±0.0541</td><td>0.6491±0.0171</td><td>0.6065 ±0.0111</td><td>0.6579 ±0.0057</td></tr></table>
|
| 454 |
+
|
| 455 |
+
Fixed number of samples per class in each source domain. Specifically, we randomly draw T samples from each class in a source domain to represent this domain for training. Here, we set T to 20,30, and 40, respectively, in different experiments. The experimental settings are the same as the descriptions in A.2, except for the training steps as 600.
|
| 456 |
+
|
| 457 |
+
The results can be found in Table 10. As we can see, our proposed method achieved the best performance among all settings compared with all baseline methods. Meanwhile, it seems that the Bayesian-based DG approaches (e.g., our proposed method and BIDL) have better performance compared with other methods, which is reasonable as the BNN can be adaptive to the small data scenario well. Especially, our proposed method has around $5 \%$ improvements compared with the second-best method when $T$ is set to smaller, i.e., 20.
|
| 458 |
+
|
| 459 |
+
Fixed fraction of samples in each source domain. Specifically, we randomly draw $C \%$ samples from the training samples of each source domain to represent this domain for training. For example, D7P dataset has 963 training samples originally. The total number of samples for this domain is $-$ for training when $\cdot$ is set to $40 \%$ . Here, we set $C$ to $\cdot$ , $\cdot$ , and $\cdot$ , respectively, as separately different experiments. Note that $\cdot$ can not be set too small (as the number of samples in some classes of some domains is very limited.), otherwise the batch size can not be uniform. We can observe this kind of setting is challenging as the total number of samples for each domain is gradually small. The results can be found in Table 11. We can observe from Table 11 that our proposed method also achieves a relatively stable and better performance compared with baseline methods, as the decrease of fraction of samples in each source domain.
|
| 460 |
+
|
| 461 |
+
# A.7 DISCUSSIONS
|
| 462 |
+
|
| 463 |
+
In this paper, the definition of small data is based on a specific task, including the difficulty of prediction, the quality of on-hand images, the number of source domains, and so on. Small data scenarios may be a relative concept. Specifically, a small data scenario not only can represent the number of training examples is small among all source domains compared with some large volumes of datasets but also can reflect the number of training examples is relatively smaller in some (certain) domains. On the abovementioned conditions, it may be difficult to ensure reliable contrastive semantic loss with point-wise (or local) alignment and distribution-wise (or global) alignment because both of them require sufficient samples among source domains. Our proposed method aims to improve performance over the abovementioned small data scenarios, which is a significant motivation for this work.
|
md/dev/RecZ9nB9Q4/RecZ9nB9Q4.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/S9GpoS2TmN/S9GpoS2TmN.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/SMa9EAovKMC/SMa9EAovKMC.md
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DRAFT, SKETCH, AND PROVE: GUIDING FORMAL THEOREM PROVERS WITH INFORMAL PROOFS
|
| 2 |
+
|
| 3 |
+
Albert Q. Jiang1,2,† Sean Welleck3,4,† Jin Peng Zhou5,6,†
|
| 4 |
+
|
| 5 |
+
Wenda Li2 Jiacheng Liu3 Mateja Jamnik2
|
| 6 |
+
|
| 7 |
+
Timothee Lacroix ´ 1 Guillaume Lample1,‡ Yuhuai Wu5,7,‡
|
| 8 |
+
|
| 9 |
+
1Meta AI 2University of Cambridge 3University of Washington 4Allen Institute for AI
|
| 10 |
+
5Google Research 6Cornell University 7Stanford University
|
| 11 |
+
|
| 12 |
+
# ABSTRACT
|
| 13 |
+
|
| 14 |
+
The formalization of existing mathematical proofs is a notoriously difficult process. Despite decades of research on automation and proof assistants, writing formal proofs remains arduous and only accessible to a few experts. While previous studies to automate formalization focused on powerful search algorithms, no attempts were made to take advantage of available informal proofs. In this work, we introduce Draft, Sketch, and Prove (DSP), a method that maps informal proofs to formal proof sketches, and uses the sketches to guide an automated prover by directing its search to easier sub-problems. We investigate two relevant setups where informal proofs are either written by humans or generated by a language model. Our experiments and ablation studies show that large language models are able to produce wellstructured formal sketches that follow the same reasoning steps as the informal proofs. Guiding an automated prover with these sketches enhances its performance from $2 0 . 9 \%$ to ${ \mathrm { 3 9 . 3 \% } }$ on a collection of mathematical competition problems.
|
| 15 |
+
|
| 16 |
+

|
| 17 |
+
Figure 1: Draft, Sketch, and Prove. Starting with an informal statement, our framework yields a formal proof through a three-stage process: drafting informal proofs, mapping them into formal sketches, and proving the remaining conjectures. Concretely, an informal statement is a mathematical problem described in a mixture of natural and mathematical languages (e.g., formulae in $\mathrm { I A I R } X ,$ ). Then, we use a large language model to autoformalize each informal proof into a formal sketch, which is a skeleton of the formal proof with open conjectures left unproven (indicated by the <proof $>$ blocks). The formal sketch mirrors the structure of the informal proof. Finally, the open conjectures/gaps inside each formal sketch are proved by an off-the-shelf prover.
|
| 18 |
+
|
| 19 |
+
# 1 INTRODUCTION
|
| 20 |
+
|
| 21 |
+
Formal proof automation is a challenging task that has been the focus of increased attention in recent years (Bansal et al., 2019b; Polu & Sutskever, 2020; Lample et al., 2022; Jiang et al., 2022; Wu et al., 2022). However, deep learning approaches have not been as successful as in other domains, mainly because of the scarcity of formal data. Indeed, formalizing proofs is notoriously difficult and only accessible to a handful of experts, which makes large annotation endeavors unrealistic (Wiedijk, 2008). The largest formal proof corpus is written in Isabelle (Paulson, 1994), and amounts to less than 0.6 GB in size, orders of magnitude smaller than datasets commonly used in vision (Deng et al., 2009) or natural language processing (Brown et al., 2020). To address the scarcity of formal proofs, previous studies have proposed to use synthetic data (Wu et al., 2021b), self-supervision (Polu & Sutskever, 2020; Han et al., 2022), or reinforcement learning (Bansal et al., 2019a; Polu et al., 2022) to synthesize additional formal training data. Although these methods alleviate the data insufficiency to some degree, none are able to capitalize on the bulk of human-written mathematical proofs.
|
| 22 |
+
|
| 23 |
+
Unlike formal mathematics, informal mathematical data is abundant and widely available. Recently, large language models trained on informal mathematical data showcased impressive quantitative reasoning abilities (Lewkowycz et al., 2022; Welleck et al., 2022). However, they often generate erroneous proofs and it is challenging to detect the faulty reasoning in these proofs automatically. Our work devises a novel approach called Draft, Sketch, and Prove (DSP) to translate informal mathematical proofs into formal ones and thus enjoy both the logical rigor provided by formal systems and the wealth of informal data. We give a schematic diagram of the $D S P$ method in Figure 1 and describe it in Section 3. Recent work (Wu et al., 2022) demonstrates the feasibility of automatically translating informal statements into formal ones with large language models. $D S P$ goes beyond and leverages large language models to generate formal proof sketches (Wiedijk, 2003) from informal proofs. Proof sketches consist of high-level reasoning steps that can be interpreted by formal systems such as interactive theorem provers. They differ from complete formal proofs in that they contain sequences of intermediate conjectures without justification. An example of informal proof with its corresponding formal proof sketch is provided in Figure 2. In the last step of $D S P$ , we elaborate the formal proof sketch into a full formal proof using an automated prover to prove all intermediate conjectures.
|
| 24 |
+
|
| 25 |
+
We perform experiments to generate formal proofs of problems from the miniF2F dataset (Zheng et al., 2022) and show that a large portion of theorems can be proved automatically with this method. We investigate two settings where the informal proofs are either written by humans or drafted by a large language model trained on mathematical text. These two settings correspond to situations frequently occurring during the formalization of existing theories, where informal proofs are usually available, but sometimes left as exercises to the reader or missing due to space limits in the margin.
|
| 26 |
+
|
| 27 |
+
# Contributions:
|
| 28 |
+
|
| 29 |
+
• We introduce a novel approach to leverage informal proofs to guide automated provers with formal proof sketches.
|
| 30 |
+
• To evaluate our approach, we build a dataset of manually curated informal statements and informal proofs aligned with formal statements in the miniF2F dataset (Zheng et al., 2022).
|
| 31 |
+
• We increase the proportion of problems solved by an automated prover on miniF2F from $2 0 . 9 \%$ to $3 8 . 9 \%$ given language-model-generated informal proofs, and up to $3 9 . 3 \%$ when proofs are written by humans.
|
| 32 |
+
• Through three ablation studies, we demonstrate the performance benefit of drafting informal proofs, annotating sketches with informal segments, and using automated provers to close open conjectures for the autoformalization of proofs.
|
| 33 |
+
|
| 34 |
+
# 2 BACKGROUND AND RELATED WORK
|
| 35 |
+
|
| 36 |
+
Interactive theorem proving Modern verification systems for mathematics are centered around interactive theorem provers $( I T P s )$ , such as Isabelle (Paulson, 1994), Lean (Moura et al., 2015), Coq (Barras et al., 1997), or Metamath (Megill & Wheeler, 2019). ITPs embed the mathematical definitions and theorems onto a solid logical foundation (e.g., Higher-Order Logic, Dependent Type Theory) implemented by their kernels. Every theorem must be checked by the kernel to be recognized by the ITP. To be proved formally, a theorem is first stated in the ITP’s programming language, and iteratively simplified into simpler objectives (or subgoals), until it can be reduced to already proven facts. In this paper, we will refer to proofs verified by a formal theorem prover as formal proofs, and proofs written in “standard” mathematics (e.g. in LATEX) as informal proofs.
|
| 37 |
+
|
| 38 |
+
Machine learning for formal proof synthesis Several approaches propose to combine machine learning with modern interactive theorem provers (Yang & Deng, 2019; Gauthier et al., 2021), and build upon the recent success of language models (Polu & Sutskever, 2020; Han et al., 2022; Polu et al., 2022; Jiang et al., 2022; Lample et al., 2022). These methods typically rely on sequence-to-sequence models (Sutskever et al., 2014) to generate the next step of a proof given the current proof state and perform search over the generated subgoals using powerful search methods such as MCTS (Silver et al., 2018; Wu et al., 2021a; Laurent & Platzer, 2022). Because search is computationally expensive, these language models are relatively small (with fewer than 1 billion parameters). Our method contrasts with these approaches in that we use a significantly reduced number of calls to the models, but also much larger language models (with up to 175 billion parameters) that showcase outstanding few-shot learning abilities (Brown et al., 2020).
|
| 39 |
+
|
| 40 |
+
Machine learning for informal reasoning Language models have also been used in the context of purely informal mathematics (Lample & Charton, 2020; Hendrycks et al., 2021; Welleck et al., 2021; Drori et al., 2022; Welleck et al., 2022). Nevertheless, Lewkowycz et al. (2022) note that for quantitative question answering, models are prone to generate false positives: the model guesses the right answer while providing an incorrect proof. These errors are hard to spot without human inspection. Worryingly, the frequency of false positives increases with the difficulty of the problem. Our method builds on these findings and translates informal proofs into formal proofs. Since ITPs are logically grounded, once a formal proof is checked by them, we are guaranteed its correctness.
|
| 41 |
+
|
| 42 |
+
Autoformalization In a position paper, Szegedy (2020) argued for attaining formal mathematical data from informal sources with neural networks. Wang et al. (2020) performed preliminary experiments where the evaluation was limited to text-level similarities on synthetic datasets. Recently, Wu et al. (2022) found that large language models (Chen et al., 2021; Chowdhery et al., 2022) are capable of few-shot statement autoformalization. Namely, a small number of examples are enough for them to learn to perform informal-to-formal translation of statements. In this paper, we investigate whether these findings can generalize to proof autoformalization, i.e., whether large language models can be used to translate informal proofs into formal ones.
|
| 43 |
+
|
| 44 |
+
# 3 METHOD
|
| 45 |
+
|
| 46 |
+
In this section, we describe our Draft, Sketch, and Prove (DSP) method for formal proof automation, which leverages informal proofs to guide automated formal theorem provers with proof sketches. We assume that each problem comes with an informal statement and a formal statement describing the problem. Our pipeline consists of three stages (depicted in Figure 1), which we present below.
|
| 47 |
+
|
| 48 |
+
# 3.1 DRAFTING INFORMAL PROOFS
|
| 49 |
+
|
| 50 |
+
The initial phase of the DSP method consists in finding informal proofs for a problem according to its description in natural mathematical language (possibly with LATEX). The resulting informal proof is seen as a draft for the subsequent phases. In mathematical textbooks, proofs of theorems are in general provided, but are sometimes missing or incomplete. Therefore, we consider two settings corresponding to the presence or absence of the informal proofs. In the first, we assume that a “ground-truth” informal proof (i.e., one written by a human) is available, which is the typical scenario in the practice of formalizing existing mathematical theories. In the second setting, we make a more general assumption that the ground-truth informal proof is not given, and draft proof candidates with a large language model trained on informal mathematical data. The language model removes the dependence on human proofs and can produce multiple alternative solutions for every problem. Although there is no easy way to automatically verify the correctness of these proofs, the informal proof only needs to be useful for producing a sketch in the next stage.
|
| 51 |
+
|
| 52 |
+
# 3.2 MAPPING INFORMAL PROOFS INTO FORMAL SKETCHES
|
| 53 |
+
|
| 54 |
+
A formal proof sketch encodes the structure of a solution and leaves out low-level details (Wiedijk, 2003). Intuitively, it is a partial proof that outlines high-level conjecture statements. A concrete example of a proof sketch is shown in Figure 2. Although informal proofs often leave aside low-level details, (e.g., by stating their triviality), these details cannot be discharged in a formal proof, making
|
| 55 |
+
|
| 56 |
+
Informal Statement: Show that for any real number $a$ , $1 0 a \leq 2 8 a ^ { 2 } + 1$
|
| 57 |
+
|
| 58 |
+
# Informal Proof:
|
| 59 |
+
|
| 60 |
+
It suffices to show $0 \leq 2 8 a ^ { 2 } - 1 0 a + 1$ . First, consider completing the square for $2 8 a ^ { 2 } - 1 0 a$ and observe that $\textstyle \left( a - { \frac { 5 } { 2 8 } } \right) ^ { 2 } = a ^ { 2 } - { \frac { 1 0 } { 2 8 } } a + ( 5 / 2 8 ) ^ { 2 }$ . Since $\begin{array} { r } { 0 \leq \left( a - \frac { 5 } { 2 8 } \right) ^ { 2 } } \end{array}$ , we get $0 \leq a ^ { 2 } - { \textstyle { \frac { 1 0 } { 2 8 } } } a + ( 5 / 2 8 ) ^ { 2 }$ . Multiplying by 28 and simplifying gives $0 \leq 2 8 a ^ { 2 } - 1 0 a + ( 2 5 / 2 8 )$ . Since $2 5 / 2 8 < 1$ , the result follows.
|
| 61 |
+
|
| 62 |
+
# Formal Proof Sketch:
|
| 63 |
+
|
| 64 |
+

|
| 65 |
+
Figure 2: A proof sketch in Isabelle. The problem “Show that for any real number $a$ , $1 0 a \leq 2 8 a ^ { 2 } + 1 ^ { \prime }$ is given with an informal proof and an associated formal proof sketch. The sketch first rewrites the original statement $( \mathtt { C } 0 )$ , which is proved through 5 intermediary conjectures (c1..c5). We use a special token $( < \cdots > )$ to indicate that the conjecture is “open” and should be tackled by an automated prover later. To facilitate the alignment between the informal and formal languages, we annotate the formal proof sketch examples with informal proof segments (shown in red), which are immediately followed by their formal counterparts.
|
| 66 |
+
|
| 67 |
+
straightforward informal-to-formal proof translation difficult. Instead, we propose to map informal proofs to formal proof sketches that share the same high-level structures. The low-level details missing from a proof sketch can later be filled by an automated prover. Since large informal-formal parallel corpora do not exist, standard machine translation methods are unsuitable for this task. Rather, we use the few-shot learning abilities of a large language model. Specifically, we prompt the model with a few example pairs containing informal proofs and their corresponding formal sketches, followed by an informal proof yet to be translated. We then let the model generate the subsequent tokens to obtain the desired formal sketch. We refer to this model as an autoformalizer.
|
| 68 |
+
|
| 69 |
+
# 3.3 PROVING OPEN CONJECTURES IN THE SKETCHES
|
| 70 |
+
|
| 71 |
+
As the last part of the process, we execute off-the-shelf automated provers to fill in the missing details in proof sketches, where “automated provers” refers to systems capable of producing formally verifiable proofs. Our framework is agnostic to the specific choice of the automated prover: it can be symbolic provers such as heuristic proof automation tools, neural-network-based provers, or hybrid approaches. If the automated prover successfully closes all the gaps in the proof sketch, it returns the final formal proof which can be checked against the problem’s specification. If the automated prover fails (e.g., it exceeds the allocated time limit), we consider the evaluation to be unsuccessful.
|
| 72 |
+
|
| 73 |
+
# 4 EXPERIMENTS
|
| 74 |
+
|
| 75 |
+
# 4.1 DATASET AND EVALUATION
|
| 76 |
+
|
| 77 |
+
We evaluate our method on the miniF2F dataset (Zheng et al., 2022). The dataset contains the formal statements of 488 problems from high-school mathematical competitions, written in three formal languages: Lean, HOL-Light, and Isabelle. They are split into a valid set and a test set, composed of 244 problems each. In this work, we choose to experiment with Isabelle for three reasons: (1) Isabelle’s proof corpus is one of the largest among interactive theorem provers, conducive to the language models’ mastery of its syntax; (2) Isabelle supports the declarative proof style (detailed discussion in Appendix A), enabling formal proof sketches (Wiedijk, 2003) which are central to our method; (3) although automated proving tools are available in other interactive theorem provers, none are as developed and effective as Sledgehammer (Paulson, 2010) in Isabelle for proving conjectures.
|
| 78 |
+
|
| 79 |
+
The miniF2F dataset is comprised of problems from three source categories: (1) 260 problems sampled from the MATH dataset (Hendrycks et al., 2021); (2) 160 problems from actual high-school mathematical competitions (AMC, AIME, and IMO); (3) 68 crafted problems at the same difficulty level as (2). We employ three methods to obtain informal statements and proofs from these sources. For source (1), we access the informal statements and proofs from the MATH dataset; for (2), we retrieve their informal statements and proofs from the AOPS website 1; and for (3), we manually write down their informal statements and proofs. Thus we gather a parallel set of 488 informal statements, informal proofs, and formal statements. This dataset provides the informal statements and proofs for our experiment in the human-as-informal-proof-writer setting and will be released upon publication.
|
| 80 |
+
|
| 81 |
+
Our task is to generate formal proofs for problems as they are formally stated in miniF2F. We consider a proof valid if and only if it (a) does not contain “cheating” keywords (sorry and oops) that exit a proof without completing it, and (b) Isabelle is able to verify the corresponding formal statement with the proof. We use the Portal-to-ISAbelle API by Jiang et al. (2021) to interact with Isabelle.
|
| 82 |
+
|
| 83 |
+
# 4.2 BASELINES
|
| 84 |
+
|
| 85 |
+
Sledgehammer As a baseline, we attempt to prove the formal statement directly with Sledgehammer, a popular proof automation tool in Isabelle. We use the default Sledgehammer configuration in Isabelle2021, including a 120-second timeout and the five automated theorem provers (Z3, CVC4, SPASS, Vampire, E). Appendix B gives a more thorough introduction to Sledgehammer.
|
| 86 |
+
|
| 87 |
+
Sledgehammer $^ +$ heuristics Occasionally, Sledgehammer may fail without trying simple yet effective tactics. As a second, stronger baseline, we create an automated prover that tries 11 common tactics (auto, simp, blast, fastforce, force, eval, presburger, sos, arith, linarith, auto simp: field simps) for high-school level algebra and number theory problems. If every attempted tactic fails, or times out after 10 seconds, it falls back to Sledgehammer.
|
| 88 |
+
|
| 89 |
+
Language models for proof search Finally, we include baselines which are representative of state-of-the-art neural theorem proving in Isabelle, specifically Thor (Jiang et al., 2022) and Thor with expert iteration on autoformalized data (Wu et al., 2022). The methods GPT-f with expert iteration (Polu et al., 2022), and HyperTree Proof Search (HTPS) (Lample et al., 2022) can solve $3 6 . 6 \%$ and $4 1 . 0 \%$ of the problems on miniF2F-test. However, they rely on the Lean theorem prover instead of Isabelle, which greatly influences the performance due to the different tactics and automation, and are not directly comparable to our method.
|
| 90 |
+
|
| 91 |
+
# 4.3 EXPERIMENTAL SETUP
|
| 92 |
+
|
| 93 |
+
The experimental code is at github.com/albertqjiang/draft sketch prove.
|
| 94 |
+
|
| 95 |
+
Drafting When informal proofs are generated, we condition a large language model on informal statements to sample 100 informal proofs per problem. Specifically, we use the Codex code-davinci002 model (Chen et al., 2021) through the OpenAI API, and the 8B, 62B, and 540B versions of the Minerva model from Lewkowycz et al. (2022). We use greedy decoding for Codex and nucleus sampling (Holtzman et al., 2019) with temperature $T = 0 . 6$ and top $\mathbf { p } = 0 . 9 5$ for Minerva models.
|
| 96 |
+
|
| 97 |
+
Sketching For sketching, we manually prepare 20 autoformalization examples of the format (informal statement, informal proof, formal statement, formal sketch), to form a pool of high-quality demonstrations. Of these 20 examples, 10 are of the algebra type and 10 are of the number theory type. All examples are from the validation set of the miniF2F dataset and can be found in the supplementary materials. The sketches contain in-line comments as in Figure 2. If the name of the problem gives away its type (algebra or number theory), we only use examples of the corresponding type. We also ensure that the sampled few-shot examples do not contain the problem being solved. The prompt is 3 uniformly randomly sampled example from the pool concatenated with the current problem’s (informal statement, informal proof, formal statement). We use this prompt to query the same Codex model to get the desired proof sketches. We use deterministic greedy decoding and a maximum of 2048 tokens in the generated sequence. For all the experiments, unless stated otherwise, we control the total number of queries made to Codex per problem to be 100. This means 100 queries per human informal solution and one query per language-model-generated solution.
|
| 98 |
+
|
| 99 |
+
Table 1: Proving success rates on the miniF2F dataset with Isabelle In the table are the success rates of four baselines, the DSP method with human and language model informal proofs, as well as three ablation studies, on the validation and the test sets of miniF2F. The highest success rates on each set are highlighted in bold. The performance difference between ablation studies and DSP with human informal proofs are enclosed in brackets.
|
| 100 |
+
|
| 101 |
+
<table><tr><td>Success rate</td><td>miniF2F-valid</td><td>miniF2F-test</td></tr><tr><td colspan="3">Baselines</td></tr><tr><td>Sledgehammer</td><td>9.9%</td><td>10.4%</td></tr><tr><td>Sledgehammer + heuristics</td><td>18.0%</td><td>20.9%</td></tr><tr><td>Thor (Jiang et al., 2022)</td><td>28.3%</td><td>29.9%</td></tr><tr><td>Thor+ expert iteration (Wu et al.,2022)</td><td>37.3%</td><td>35.2%</td></tr><tr><td colspan="3">Draft,Sketch,and Prove</td></tr><tr><td>Human informal proof</td><td>42.6%</td><td>39.3%</td></tr><tr><td>Codex informal proof</td><td>40.6%</td><td>35.3%</td></tr><tr><td>8B Minerva informal proof</td><td>40.6%</td><td>35.3%</td></tr><tr><td>62BMinerva informal proof</td><td>43.9%</td><td>37.7%</td></tr><tr><td>540BMinerva informal proof</td><td>42.6%</td><td>38.9%</td></tr><tr><td colspan="3">Ablations (with human informal statements and proofs)</td></tr><tr><td>-In-line comments</td><td>37.7% (-4.9%)</td><td>36.5% (-2.8%)</td></tr><tr><td>- Informal proofs</td><td>38.9%(-3.7%)</td><td>34.0% (-5.3%)</td></tr><tr><td>- Automated provers</td><td>32.8% (-9.8%)</td><td>30.3% (-9.0%)</td></tr></table>
|
| 102 |
+
|
| 103 |
+
Proving To prove the conjectures left open by the formal sketch, we use the Sledgehammer $^ +$ heuristics automated prover described in Subsection 4.2. We execute the automated prover on every open conjecture in the sketch to synthesize a formal proof that can be verified by Isabelle.
|
| 104 |
+
|
| 105 |
+
# 4.4 RESULTS
|
| 106 |
+
|
| 107 |
+
In Table 1, we display the proportion of successful formal proofs found on the miniF2F dataset with the interactive theorem prover Isabelle. The results include the four baselines described in Subsection 4.2 and the $D S P$ method with human-written proofs and model-generated proofs. From the table, we can see that the automated prover with 11 additional heuristic tactics significantly increases the performance of Sledgehammer, boosting its success rate from $9 . 9 \%$ to $1 8 . { \bar { 0 } } \%$ on the validation set of miniF2F and from $1 0 . 4 \%$ to $2 0 . 9 \%$ on the test set. The two baselines using language models and proof search (Thor and Thor $^ +$ expert iteration) achieve success rates of $2 9 . 9 \%$ and ${ \bar { 3 } } 5 . 2 { \bar { \% } }$ on the test set of miniF2F, respectively.
|
| 108 |
+
|
| 109 |
+
With informal proofs written by humans, the $D S P$ method achieves success rates of $4 2 . 6 \%$ and $3 9 . 3 \%$ on the validation and test sets of miniF2F. A total of 200 out of 488 problems can be proved in this way. The Codex model and the Minerva (8B) model give very similar results in solving problems on miniF2F: they both guide the automated prover to solve $4 0 . { \dot { 6 } } \%$ and $3 5 . 3 \%$ of problems on the validation and the test sets respectively. This is corroborated by Lewkowycz et al. (2022)’s observation that these two models have comparable performances in solving mathematical problems.
|
| 110 |
+
|
| 111 |
+
When we switch to the Minerva (62B) model, the success rates rise up to $4 3 . 9 \%$ and $3 7 . 7 \%$ respectively. Compared to human-written informal proofs, its success rates are $1 . 3 \%$ higher on the validation set and $1 . 6 \%$ lower on the test set. In total, the Minerva (62B) model is able to solve 199 problems on miniF2F, one fewer than with human proofs. The $D S P$ method is effective in guiding the automated prover under both settings that we study: using either human informal proofs or language-model-generated informal proofs. $D S P$ almost doubles the prover’s success rate and results in a new state-of-the-art performance on miniF2F with Isabelle. Moreover, the larger Minerva model is almost as helpful as a human in guiding the automated prover in solving problems.
|
| 112 |
+
|
| 113 |
+
# 5 ANALYSIS
|
| 114 |
+
|
| 115 |
+
# 5.1 ABLATION STUDIES
|
| 116 |
+
|
| 117 |
+
Ablation of in-line comments To facilitate the alignment between the informal proofs and the formal proof sketches, we copy relevant segments of the informal proofs as in-line comments in the sketches. In the manually constructed prompt examples, these comments are prefixed to the corresponding Isabelle code blocks, as shown in Figure 2 (the text in red). We hypothesize that this technique is beneficial for large language models to synthesize formal sketches. To validate this hypothesis, we perform an ablation study by removing the in-line comments in the prompt examples before running the experiment. The results are displayed in Table 1. We find that without in-line comments, the success rates drop by $4 . 9 \%$ and $2 . 8 \%$ on the validation and test sets respectively. We conclude that having in-line comments is helpful for generating formal proof sketches.
|
| 118 |
+
|
| 119 |
+

|
| 120 |
+
Figure 3: Number of problems solved on miniF2F against the number of autoformalization attempts per problem. Left: The figure displays the experiments carried out with the $D S P$ method and three ablations on it. The curves represent the $D S P$ method (blue), formal proof sketches without the in-line comments (orange), without informal proofs altogether (green), and without the automated provers (red). Right: The figure compares the experimental results with informal proof drafts written by humans (blue), the 540B Minerva model (orange), the 62B Minerva model (green), the 8B Minerva model (red), and the Codex model (purple).
|
| 121 |
+
|
| 122 |
+
Ablation of informal proof drafts Drafting informal proofs is the first step of the $D S P$ method. To investigate the necessity of this step, we perform an experiment of formal sketching and proving without informal proofs at all. Because formal proof sketches are written in the declarative proof style, they are fairly similar to the informal proof drafts already. Concretely, we remove the informal proofs and the in-line comments (because they are copied segments of the informal proofs) in the prompt examples. This removes the need for the informal proof writer, whether a human or a neural network. The results of this setup are shown in Table 1. It can be seen that the success rates on the validation and the test sets of miniF2F drop by $3 . 7 \%$ and $5 . 3 \%$ respectively compared to with human-written proofs. They are also inferior to success rates obtained with language-model-generated informal proofs. This demonstrates the importance of drafting informal proofs before sketching and proving.
|
| 123 |
+
|
| 124 |
+
Ablation of automated provers Using an autoformalizer to generate proof sketches which are then completed by an automated prover is central to our method. The effect of utilizing an automated prover to close open conjectures in proof sketches is worth studying, so we conduct an ablation experiment for it. Namely, we replace the proof sketches in the prompt examples with complete formal proofs. The complete formal proofs still follow the declarative proof style, but do not contain any open conjectures. As a result, the large language model will also generate full proofs instead of sketches, and we directly check whether these generated proofs are valid. The results in this setup are presented in Table 1. The results reveal that without an automated prover to close open conjectures, the success rate on miniF2F decreases by $9 . 8 \%$ and $9 . 0 \%$ on the validation and test sets respectively. The drastic performance difference indicates the essential role of automated provers in our approach.
|
| 125 |
+
|
| 126 |
+
Scaling properties of ablation studies To understand the effect of the ablations on the $D S P$ method’s scaling properties, we vary the number of autoformalization attempts per problem and plot the number of successful proofs found on the miniF2F dataset in Figure 3 (left). Three methods are contrasted: the original $D S P$ method with human informal proofs, the $D S P$ method without in-line comments, and the $D S P$ method without sketching. It can be seen from the figure that with the original $D S P$ method, the performance reaches a plateau (no new proofs are found) after 70 autoformalization attempts are made for each problem. For the ablation study with no in-line comments, the plateau is reached much faster, after around 50 autoformalization attempts. This method solves 181 problems in total. The ablation study without sketching can solve 154 problems on miniF2F. In comparison, with human informal proofs, only 7 autoformalization attempts are required to reach this performance.
|
| 127 |
+
|
| 128 |
+

|
| 129 |
+
Figure 4: IMO proof guided by a Minerva informal proof An informal proof of the International Math Olympiad problem $\mathrm { i m o \_ 1 9 5 9 \mathrm { _ - p 1 } }$ generated by Minerva that leads to a successful formal proof. The steps enclosed by the $A T P$ delimiters are generated by an automated prover and all other steps are generated by the DSP autoformalizer.
|
| 130 |
+
|
| 131 |
+
# 5.2 LANGUAGE-MODEL-GENERATED PROOFS
|
| 132 |
+
|
| 133 |
+
Our experiments demonstrated that model-generated informal proofs from Minerva and Codex can help guide a formal theorem prover. In this section, we analyze the properties of these proofs further. Since the Minerva (62B and 540B) models give the best overall performance on miniF2F, we focus on the informal proofs they produce in this section.
|
| 134 |
+
|
| 135 |
+
Minerva helps solve one IMO problem Interestingly, our approach manages to solve one problem from the International Mathematical Olympiad (imo 1959 1) with a Minerva-generated solution, but not with the human proof. For this problem, we present the successful Minerva-generated informal proof draft and the formal proof in Figure 4. We hypothesize that the reason behind this phenomenon is that human proofs might leave gaps between conjectures that are too difficult for automated provers to solve. On the other hand, the diversity in language model informal proofs makes some of them more amenable to automated provers. In Appendix C, we analyze the human and the Minerva informal proofs for this problem in greater detail. In Appendix D, we present a manual evaluation of Minerva proofs, and 3 more case studies comparing the human and Minerva informal proofs.
|
| 136 |
+
|
| 137 |
+
Is there a way to detect which Minerva proofs are correct, without human evaluation? For a preliminary investigation, we filter out all the problems that can be solved directly with the automated prover from the 50 and are left with 27 informal proofs. Of these 27, 21 are completely correct, 6 still contain small errors, but none are nonsensical. With this simple filter, we achieve a precision of $7 7 . 8 \%$ and a recall of $7 2 . 4 \%$ in identifying correct Minerva informal proofs.
|
| 138 |
+
|
| 139 |
+
Scaling properties of human and Minerva proofs To understand the influence of different informal proof sources on the scaling properties of $D S P$ , we plot the number of successful proofs found on miniF2F against the number of autoformalization attempts per problem in Figure 3 (right). Note that for each problem, we have 1 informal proof by a human and 100 informal proof drafts by each language model. The one human proof is used 100 times for formal proof sketch generation, while each language model proof draft is used only once. The 62B and the 540B models result in more successful proofs than the smaller (8B) Minerva model and the Codex model, consistently for any number of attempts. The 8B Minerva model and the Codex model behave similarly, both finding 185 proofs in the end. Informal proofs written by humans help solve more problems than those by Minerva models for $1 - 1 0 0$ autoformalization attempts. However, the difference is small (1 problem) when 100 are made.
|
| 140 |
+
|
| 141 |
+
Noticing that the number of successful proofs does not plateau for the Minerva-generated proofs, we investigate how further increasing the number of autoformalization attempts changes the number of problems solved for human-written and language-model-generated proofs. For each problem, we use 1 human informal proof and sample 200 sketches for it; we also use the same 100 informal proof drafts by the Minerva (540B) language model and sample 2 sketches for each draft. The total number of sketches per problem is 200 in both settings. We find that with human informal proofs, 203 theorems ${ \mathrm { ~ ( 1 0 6 / 9 7 } }$ on valid/test) have successful formal proofs, while with language-model-generated informal proofs, 209 (111/98 on valid/test) theorems have successful formal proofs after the same number of attempts. This suggests that the diversity in language-model-generated informal proofs can benefit the automated formalization process more than the “ground-truth” human proofs.
|
| 142 |
+
|
| 143 |
+
# 5.3 MEMORIZATION
|
| 144 |
+
|
| 145 |
+
This work utilizes two language models that have been trained on a large amount of internet data. Several prior works (Trinh & Le, 2018; Carlini et al., 2022) pointed out that such models can memorize some fraction of the data they encounter during training. For drafting informal proofs, we mainly experimented with Minerva. Lewkowycz et al. (2022, Section 5) discussed the memorization effects within Minerva and concluded that they could not find evidence that its abilities are due to memorization. For the autoformalization of proof sketches, the Codex (code-davinci-002) model was used. Its training data was collected before June $2 0 2 1 ^ { 2 }$ , at which time the miniF2F dataset had not been made public. So the model cannot benefit from memorizing the exact problems and proofs. Therefore, it is inappropriate to attribute the abilities of models used in this paper to memorization.
|
| 146 |
+
|
| 147 |
+
# 6 CONCLUSION
|
| 148 |
+
|
| 149 |
+
In this paper, we introduced Draft, Sketch, and Prove $( D S P )$ , a novel approach that takes advantage of informal proofs to synthesize formal proofs. We demonstrated its feasibility and effectiveness by reaching state-of-the-art performance on the miniF2F dataset with the Isabelle theorem prover. Central to our method are formal proof sketches that mirror the high-level reasoning structures of informal proofs. Our ablations showed that the ability to automatically convert informal proofs to proof sketches is critical to the success of $D S P$ .
|
| 150 |
+
|
| 151 |
+
Our $D S P$ method differs fundamentally from previous applications of machine learning to formal proof synthesis in two aspects. Firstly, while most approaches in the field focus on improving proof search, our method seeks to construct the entire formal proof structure from the informal proof in one decoding operation. The task of the automated prover is then simplified to filling the gaps between intermediate conjectures. Secondly, while existing approaches operate exclusively on formal data, $D S P$ by design benefits from informal proofs.
|
| 152 |
+
|
| 153 |
+
In this work, we utilized a purely symbolic automated prover to close the gaps in proof sketches. In the future, we aim to equip $D S P$ with more powerful mechanisms, such as HyperTree Proof Search (Lample et al., 2022), to broaden the scope of provable theorems. Similar to AlphaCode (Li et al., 2022), we found that the number of generations is crucial for performance. The computational cost of the autoformalizer being a bottleneck in our method, we seek to develop approaches able to generate high-quality proof sketches more efficiently.
|
| 154 |
+
|
| 155 |
+
# ACKNOWLEDGEMENTS
|
| 156 |
+
|
| 157 |
+
We thank Rui Yuan and Kunhao Zheng for helping with the informal solutions used in our dataset.
|
| 158 |
+
We thank Christian Szegedy for his feedback on the early draft.
|
| 159 |
+
|
| 160 |
+
FUNDING DISCLOSURE
|
| 161 |
+
|
| 162 |
+
AQJ and WL are supported by the ERC Advanced Grant ALEXANDRIA (Project GA 742178).
|
| 163 |
+
|
| 164 |
+
REFERENCES
|
| 165 |
+
|
| 166 |
+
Kshitij Bansal, Sarah M. Loos, Markus N. Rabe, and Christian Szegedy. Learning to reason in large theories without imitation. CoRR, abs/1905.10501, 2019a. URL http://arxiv.org/abs/ 1905.10501.
|
| 167 |
+
|
| 168 |
+
Kshitij Bansal, Sarah M. Loos, Markus N. Rabe, Christian Szegedy, and Stewart Wilcox. Holist: An environment for machine learning of higher order logic theorem proving. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, ICML 2019, 9-15 June 2019, Long Beach, California, USA, volume 97 of Proceedings of Machine Learning Research, pp. 454–463. PMLR, 2019b. URL http://proceedings. mlr.press/v97/bansal19a.html.
|
| 169 |
+
|
| 170 |
+
Bruno Barras, Samuel Boutin, Cristina Cornes, Judicael Courant, Jean-Christophe Filliatre, Eduardo ¨ Gimenez, Hugo Herbelin, Gerard Huet, Cesar Munoz, Chetan Murthy, et al. The Coq proof assistant reference manual: Version 6.1. PhD thesis, Inria, 1997.
|
| 171 |
+
|
| 172 |
+
Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In Hugo Larochelle, Marc’Aurelio Ranzato, Raia Hadsell, Maria-Florina Balcan, and Hsuan-Tien Lin (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020. URL https://proceedings.neurips.cc/paper/2020/hash/ 1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html.
|
| 173 |
+
|
| 174 |
+
Nicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee, Florian Tramer, and Chiyuan \` Zhang. Quantifying memorization across neural language models. CoRR, abs/2202.07646, 2022. URL https://arxiv.org/abs/2202.07646.
|
| 175 |
+
|
| 176 |
+
Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harrison Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin, Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mohammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, David W. Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William H. Guss, Alex Nichol, Igor Babuschkin, S. Arun Balaji, Shantanu Jain, Andrew Carr, Jan Leike, Joshua Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew M. Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. Evaluating large language models trained on code. ArXiv, abs/2107.03374, 2021.
|
| 177 |
+
|
| 178 |
+
Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret
|
| 179 |
+
|
| 180 |
+
Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. Palm: Scaling language modeling with pathways. CoRR, abs/2204.02311, 2022. doi: 10.48550/arXiv.2204.02311. URL https://doi.org/10.48550/arXiv.2204.02311.
|
| 181 |
+
|
| 182 |
+
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248–255. Ieee, 2009.
|
| 183 |
+
|
| 184 |
+
Iddo Drori, Sarah Zhang, Reece Shuttleworth, Leonard Tang, Albert Lu, Elizabeth Ke, Kevin Liu, Linda Chen, Sunny Tran, Newman Cheng, et al. A neural network solves, explains, and generates university math problems by program synthesis and few-shot learning at human level. Proceedings of the National Academy of Sciences, 119(32):e2123433119, 2022.
|
| 185 |
+
|
| 186 |
+
Thibault Gauthier, Cezary Kaliszyk, Josef Urban, Ramana Kumar, and Michael Norrish. Tactictoe: learning to prove with tactics. Journal of Automated Reasoning, 65(2):257–286, 2021.
|
| 187 |
+
|
| 188 |
+
Jesse Michael Han, Jason Rute, Yuhuai Wu, Edward W. Ayers, and Stanislas Polu. Proof artifact co-training for theorem proving with language models. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022. OpenReview.net, 2022. URL https://openreview.net/forum?id $=$ rpxJc9j04U.
|
| 189 |
+
|
| 190 |
+
Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. Measuring mathematical problem solving with the math dataset. NeurIPS, 2021.
|
| 191 |
+
|
| 192 |
+
Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751, 2019.
|
| 193 |
+
|
| 194 |
+
Albert Q. Jiang, Wenda Li, Jesse Michael Han, and Yuhuai Wu. LISA: Language models of Isabelle proofs. In 6th Conference on Artificial Intelligence and Theorem Proving, 2021.
|
| 195 |
+
|
| 196 |
+
Albert Q. Jiang, Wenda Li, Szymon Tworkowski, Konrad Czechowski, Tomasz Odrzygozdz, Piotr ´ Milos, Yuhuai Wu, and Mateja Jamnik. Thor: Wielding hammers to integrate language models and automated theorem provers. CoRR, abs/2205.10893, 2022. doi: 10.48550/arXiv.2205.10893. URL https://doi.org/10.48550/arXiv.2205.10893.
|
| 197 |
+
|
| 198 |
+
Guillaume Lample and Franc¸ois Charton. Deep learning for symbolic mathematics. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum? id=S1eZYeHFDS.
|
| 199 |
+
|
| 200 |
+
Guillaume Lample, Marie-Anne Lachaux, Thibaut Lavril, Xavier Martinet, Amaury Hayat, Gabriel Ebner, Aurelien Rodriguez, and Timoth ´ ee Lacroix. Hypertree proof search for neural theorem ´ proving. CoRR, abs/2205.11491, 2022. doi: 10.48550/arXiv.2205.11491. URL https://doi. org/10.48550/arXiv.2205.11491.
|
| 201 |
+
|
| 202 |
+
Jonathan Laurent and Andre Platzer. Learning to find proofs and theorems by learning to refine ´ search strategies. CoRR, abs/2205.14229, 2022. doi: 10.48550/arXiv.2205.14229. URL https: //doi.org/10.48550/arXiv.2205.14229.
|
| 203 |
+
|
| 204 |
+
Aitor Lewkowycz, Anders Andreassen, David Dohan, Ethan Dyer, Henryk Michalewski, Vinay V. Ramasesh, Ambrose Slone, Cem Anil, Imanol Schlag, Theo Gutman-Solo, Yuhuai Wu, Behnam Neyshabur, Guy Gur-Ari, and Vedant Misra. Solving quantitative reasoning problems with language models. CoRR, abs/2206.14858, 2022. doi: 10.48550/arXiv.2206.14858. URL https: //doi.org/10.48550/arXiv.2206.14858.
|
| 205 |
+
|
| 206 |
+
Yujia Li, David H. Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Remi Leblond, ´ Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d’Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson,
|
| 207 |
+
|
| 208 |
+
Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, and Oriol Vinyals. Competition-level code generation with alphacode. CoRR, abs/2203.07814, 2022. doi: 10.48550/arXiv.2203.07814. URL https://doi.org/10.48550/arXiv.2203.07814.
|
| 209 |
+
|
| 210 |
+
Norman D. Megill and David A. Wheeler. Metamath: A Computer Language for Mathematical Proofs. Lulu Press, Morrisville, North Carolina, 2019. http://us.metamath.org/downloads/metamath.pdf.
|
| 211 |
+
|
| 212 |
+
Leonardo de Moura, Soonho Kong, Jeremy Avigad, Floris van Doorn, and Jakob von Raumer. The lean theorem prover (system description). In International Conference on Automated Deduction, pp. 378–388. Springer, 2015.
|
| 213 |
+
|
| 214 |
+
Lawrence C. Paulson. Isabelle - A Generic Theorem Prover (with a contribution by T. Nipkow), volume 828 of Lecture Notes in Computer Science. Springer, 1994. ISBN 3-540-58244-4. doi: 10.1007/BFb0030541. URL https://doi.org/10.1007/BFb0030541.
|
| 215 |
+
|
| 216 |
+
Lawrence C. Paulson. Three years of experience with sledgehammer, a practical link between automatic and interactive theorem provers. In Renate A. Schmidt, Stephan Schulz, and Boris Konev (eds.), Proceedings of the 2nd Workshop on Practical Aspects of Automated Reasoning, PAAR-2010, Edinburgh, Scotland, UK, July 14, 2010, volume 9 of EPiC Series in Computing, pp. 1–10. EasyChair, 2010. doi: 10.29007/tnfd. URL https://doi.org/10.29007/tnfd.
|
| 217 |
+
|
| 218 |
+
Stanislas Polu and Ilya Sutskever. Generative language modeling for automated theorem proving. CoRR, abs/2009.03393, 2020. URL https://arxiv.org/abs/2009.03393.
|
| 219 |
+
|
| 220 |
+
Stanislas Polu, Jesse Michael Han, Kunhao Zheng, Mantas Baksys, Igor Babuschkin, and Ilya Sutskever. Formal mathematics statement curriculum learning. CoRR, abs/2202.01344, 2022. URL https://arxiv.org/abs/2202.01344.
|
| 221 |
+
|
| 222 |
+
David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, et al. A general reinforcement learning algorithm that masters chess, shogi, and go through self-play. Science, 362(6419): 1140–1144, 2018.
|
| 223 |
+
|
| 224 |
+
Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. Advances in neural information processing systems, 27, 2014.
|
| 225 |
+
|
| 226 |
+
Donald Syme. DECLARE: A prototype declarative proof system for higher order logic. Citeseer, 1997.
|
| 227 |
+
|
| 228 |
+
Christian Szegedy. A promising path towards autoformalization and general artificial intelligence. In Christoph Benzmuller and Bruce R. Miller (eds.), ¨ Intelligent Computer Mathematics - 13th International Conference, CICM 2020, Bertinoro, Italy, July 26-31, 2020, Proceedings, volume 12236 of Lecture Notes in Computer Science, pp. 3–20. Springer, 2020. doi: 10.1007/978-3-030-53518-6\ 1. URL https://doi.org/10.1007/978-3-030-53518-6_1.
|
| 229 |
+
|
| 230 |
+
Trieu H. Trinh and Quoc V. Le. A simple method for commonsense reasoning. CoRR, abs/1806.02847, 2018. URL http://arxiv.org/abs/1806.02847.
|
| 231 |
+
|
| 232 |
+
Qingxiang Wang, Chad E. Brown, Cezary Kaliszyk, and Josef Urban. Exploration of neural machine translation in autoformalization of mathematics in mizar. In Jasmin Blanchette and Catalin Hritcu (eds.), Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2020, New Orleans, LA, USA, January 20-21, 2020, pp. 85–98. ACM, 2020. doi: 10.1145/3372885.3373827. URL https://doi.org/10.1145/3372885.3373827.
|
| 233 |
+
|
| 234 |
+
Sean Welleck, Jiacheng Liu, Ronan Le Bras, Hannaneh Hajishirzi, Yejin Choi, and Kyunghyun Cho. Naturalproofs: Mathematical theorem proving in natural language. In Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 1), 2021. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ Jvxa8adr3iY.
|
| 235 |
+
|
| 236 |
+
Sean Welleck, Jiacheng Liu, Ximing Lu, Hannaneh Hajishirzi, and Yejin Choi. Naturalprover: Grounded mathematical proof generation with language models. CoRR, abs/2205.12910, 2022. doi: 10.48550/arXiv.2205.12910. URL https://doi.org/10.48550/arXiv.2205.12910.
|
| 237 |
+
|
| 238 |
+
Freek Wiedijk. Formal proof sketches. In Stefano Berardi, Mario Coppo, and Ferruccio Damiani (eds.), Types for Proofs and Programs, International Workshop, TYPES 2003, Torino, Italy, April 30 - May 4, 2003, Revised Selected Papers, volume 3085 of Lecture Notes in Computer Science, pp. 378–393. Springer, 2003. doi: 10.1007/978-3-540-24849-1\ 24. URL https: //doi.org/10.1007/978-3-540-24849-1_24.
|
| 239 |
+
|
| 240 |
+
Freek Wiedijk. Formal proof – getting started. Notices of the American Mathematical Society, 55: 1408–1414, 2008.
|
| 241 |
+
|
| 242 |
+
Minchao Wu, Michael Norrish, Christian Walder, and Amir Dezfouli. Tacticzero: Learning to prove theorems from scratch with deep reinforcement learning. Advances in Neural Information Processing Systems, 34:9330–9342, 2021a.
|
| 243 |
+
|
| 244 |
+
Yuhuai Wu, Albert Jiang, Jimmy Ba, and Roger Baker Grosse. INT: An inequality benchmark for evaluating generalization in theorem proving. In International Conference on Learning Representations, 2021b. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ O6LPudowNQm.
|
| 245 |
+
|
| 246 |
+
Yuhuai Wu, Albert Q. Jiang, Wenda Li, Markus N. Rabe, Charles Staats, Mateja Jamnik, and Christian Szegedy. Autoformalization with large language models. CoRR, abs/2205.12615, 2022. doi: 10.48550/arXiv.2205.12615. URL https://doi.org/10.48550/arXiv.2205.12615.
|
| 247 |
+
|
| 248 |
+
Kaiyu Yang and Jia Deng. Learning to prove theorems via interacting with proof assistants. In International Conference on Machine Learning (ICML), 2019.
|
| 249 |
+
|
| 250 |
+
Kunhao Zheng, Jesse Michael Han, and Stanislas Polu. miniF2F: a cross-system benchmark for formal olympiad-level mathematics. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022. OpenReview.net, 2022. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ 9ZPegFuFTFv.
|
| 251 |
+
|
| 252 |
+
# APPENDIX
|
| 253 |
+
|
| 254 |
+
# A CONJECTURES AND THE DECLARATIVE PROOF STYLE
|
| 255 |
+
|
| 256 |
+
Interactive theorem provers such as Isabelle and Mizar use a declarative proof style (Syme, 1997), in which a proof is interleaved with conjectures and their corresponding proofs. Syme (1997) stated that the list of conjectures in a declarative proof should be analogous to a proof sketch found in a mathematical textbook and sufficiently convincing for the reader. In practice, ITP users often prove a theorem by writing down a list of conjectures (a “formal sketch”), then attempt to find a proof of each conjecture (fill a “gap”) with an automated system.
|
| 257 |
+
|
| 258 |
+
# B SLEDGEHAMMER
|
| 259 |
+
|
| 260 |
+
Sledgehammer (Paulson, 2010) is a powerful system that automates reasoning with the interactive theorem prover Isabelle. It works by flattening the goals encoded in the higher-order logic used by Isabelle/HOL into other logics (e.g., first-order logic) which can then be fed into automated theorem provers such as E 3, CVC4 4, $\bar { Z 3 ^ { 5 } }$ , Vampire 6, and SPASS 7. If any of these automated theorem provers succeeds in finding the proof in their own corresponding format, Sledgehammer reconstructs the proof in Isabelle/HOL with certified provers (metis, meson, and smt), which is relatively more interpretable by humans.
|
| 261 |
+
|
| 262 |
+
As a practical example of using Sledgehammer, one can declare a conjecture in Isabelle/HOL: have "4 dvd (a::nat) $\Longrightarrow ~ 2$ dvd $\mathtt { a } "$ and call Sledgehammer immediately afterwards. If Sledgehammer succeeds, it will return a proof step that proves the conjecture. In this example, the step is by (meson dvd trans even numeral), which uses the meson resolution prover and two facts: that the division relation is transitive and that 4 is an even number. If Sledgehammer does not find the proof or timeouts, it will report failure.
|
| 263 |
+
|
| 264 |
+
# C A PROOF TO AN INTERNATIONAL MATHEMATICAL OLYMPIAD PROBLEM
|
| 265 |
+
|
| 266 |
+
With the Minerva-generated solutions, a proof to the problem imo 1959 p1 is discovered. This is the first problem of the first ever International Mathematical Olympiad (IMO). The informal problem statement, Minerva-generated informal solution, and DSP’s formal proof are shown in Figure 4.
|
| 267 |
+
|
| 268 |
+
In Figure 4, we can see that the autoformalizer in DSP (a large language model), copies over parts of the informal proof generated by Minerva as in-line comments to precede their corresponding formal proof blocks. The formal proof does not use the first sentence of the informal proof solution as it is already identical to the formal statement. We also notice that the large language model selects relevant premises after writing down the conjectures (the steps starting with using) despite not every premise is strictly needed.
|
| 269 |
+
|
| 270 |
+
The formal proof creates 5 conjectures (4 have statements and 1 show statement) which are all subsequently proved by our automated theorem prover. The step to prove the statement have "gcd $( 2 1 \star \Pi + 4 )$ ) $( { { \mathchoice { \mathrm { ~ 1 ~ 4 ~ } } { \mathrm { ~ ~ 1 ~ } } { \mathrm { ~ 1 ~ 4 ~ } } { \mathrm { ~ ~ 1 ~ } } { \mathrm { ~ ~ 1 ~ } } } } + { { \mathchoice { \mathrm { ~ 3 ~ ) ~ } } { \mathrm { ~ ~ 3 ~ } } { \mathrm { ~ ~ 3 ~ } } { \mathrm { ~ ~ 3 ~ } } } } = { { \mathchoice { \mathrm { ~ 1 ~ } } { \mathrm { ~ ~ 1 ~ } } { \mathrm { ~ ~ 1 ~ } } { \mathrm { ~ ~ 1 ~ } } { \mathrm { ~ ~ 1 ~ } } } }$ involves 2 verified low-level provers smt and $^ { z 3 }$ and 10 lemmas/facts from outside the scope of the language model. It is highly unlikely that either the large language model or the automated theorem prover can finish this proof on its own.
|
| 271 |
+
|
| 272 |
+
Unsuccessful human-written proof. In contrast, the human-written informal proof of this IMO problem did not lead to a successful formal proof. The human-written proof is:
|
| 273 |
+
|
| 274 |
+
Denoting the greatest common divisor of $a , b$ as $( a , b )$ , we use the Euclidean algorithm:
|
| 275 |
+
|
| 276 |
+
$$
|
| 277 |
+
( 2 1 n + 4 , 1 4 n + 3 ) = ( 7 n + 1 , 1 4 n + 3 ) = ( 7 n + 1 , 1 ) = 1
|
| 278 |
+
$$
|
| 279 |
+
|
| 280 |
+
It follows that $\frac { 2 1 n + 4 } { 1 4 n + 3 }$ is irreducible. Q.E.D.
|
| 281 |
+
|
| 282 |
+
A key difference between the Minerva proof and the human proof is the way that invoking the Euclidean algorithm is described. The Minerva proof explicitly writes out the results of the Euclidean algorithm (e.g. $2 1 n + 4 = 1 \cdot ( 1 4 n + 3 ) + { \bar { 7 } } n + 1 )$ , which are translated into the sketch ( $_ { c l }$ in Figure 4). The human proof introduces new notation to express the results indirectly in terms of greatest common divisors, which ends up being less suitable for sketching. For example, below is a sketch generated with the human proof, which has a conjecture that is semantically incorrect and hence cannot be closed by the automated prover:
|
| 283 |
+
|
| 284 |
+
# theorem
|
| 285 |
+
|
| 286 |
+
fixes n :: nat shows "gcd $( 2 1 { \star } \Pi + 4 )$ ) $( 1 4 \star \Pi + 3 ) = 1 "$ proof - have " $( 2 1 \star \mathsf { n } + 4 , ~ 1 4 \star \mathsf { n } + 3 ) \ = \ ( 7 \star \mathsf { n } + 1 , ~ 1 4 \star \mathsf { n } + 3 ) \mathsf { n }$ 1 ATP (\* <--- UNSUCCESSFUL $^ { \star }$ ) also have " $" \ldots = ( 7 \star \Omega + 1 , \mathrm { ~ 1 ~ } ) "$ ATP finally show ?thesis ATP qed
|
| 287 |
+
|
| 288 |
+
# D MORE ANALYSIS ON HUMAN AND MINERVA INFORMAL PROOFS
|
| 289 |
+
|
| 290 |
+
We analyze the relationship between the validity of the formal proofs and the correctness of the informal proofs. For our analysis, we randomly sample 50 Minerva proofs of different problems, which are then successfully converted to formal proofs. We then manually evaluate the correctness of these 50 informal proofs. Among them, 29 proofs $( 5 8 \% )$ are entirely correct, 16 are incorrect with a clearly identifiable incorrect step, and 5 “proofs” are nonsensical and simply rephrase the final conclusions of the problems.
|
| 291 |
+
|
| 292 |
+
Seeing that a total of $1 6 + 5 = 2 1$ incorrect informal proofs can lead to successful formal proofs, we study how they guide the automated formal prover despite having flaws themselves. The 21 proofs divide into 2 cases: In the first case, we find 13 problems for which the informal proofs are mostly ignored, and the automated prover can find proofs by itself; In the other 8 problems, although the informal proofs are wrong, the autoformalizer manages to correct them, either by ignoring the erroneous steps or by stating their correct versions in the formal proof sketches. This suggests that the autoformalizer has some understanding of the mathematical statements and is not merely translating them from an informal language to a formal language. It is robust to slight noises in its input.
|
| 293 |
+
|
| 294 |
+
We present 3 case studies comparing the human and Minerva informal proofs. Particularly, Figure 7 shows a completely correct example and one example of each pathological case.
|
| 295 |
+
|
| 296 |
+

|
| 297 |
+
Figure 5: Algebra example with Minerva informal proof. An informal proof generated by Minerva that led to a successful formal proof. The autoformalizer generated a proof sketch containing all lines of the formal proof except for those with $I A T P J$ . The sketch is structured according to the informal proof, containing five intermediate conjectures based on the informal proof. The autoformalizer generated in-line comments in the proof sketch (shown in red), which correctly identified an alignment between the formal and informal proofs.
|
| 298 |
+
|
| 299 |
+
Statement: For any integer $a$ , show that $a ^ { 2 } \equiv$ 0 (mod 4) or ${ a ^ { 2 } \equiv 1 }$ (mod 4).
|
| 300 |
+
|
| 301 |
+
# Informal Proof (Minerva 62B):
|
| 302 |
+
|
| 303 |
+
Let $a = 2 k$ for some integer $k$ .
|
| 304 |
+
Then $a ^ { 2 } = 4 k ^ { 2 }$ .
|
| 305 |
+
Since $4 k ^ { 2 }$ is divisible by 4, we have $\boldsymbol { a } ^ { 2 } \equiv 0$ (mod 4).
|
| 306 |
+
Now, let $a = 2 k + 1$ for some integer $k$ .
|
| 307 |
+
Then $a ^ { 2 } = 4 k ^ { 2 } + 4 k + 1 = 4 ( k ^ { 2 } + k ) + 1$ . Since $\boldsymbol { k } ^ { 2 } + \boldsymbol { k }$ is an integer, $4 ( k ^ { 2 } + k ) { \dot { + } } 1$ is not divisible by 4.
|
| 308 |
+
Thus, ${ a ^ { 2 } \equiv 1 }$ (mod 4).
|
| 309 |
+
|
| 310 |
+
Statement: For any integer $a$ , show that ${ a } ^ { 2 } \equiv$ 0 (mod 4) or ${ a ^ { 2 } \equiv 1 }$ (mod 4).
|
| 311 |
+
|
| 312 |
+
# Informal Proof (Minerva 62B):
|
| 313 |
+
|
| 314 |
+
$a \ ( \mathrm { m o d } \ 4 ) \in \{ 0 , 1 , 2 , 3 \}$ .
|
| 315 |
+
Using that for any natural number $k$ , $a \equiv b$ (mod 4) implies $\dot { a } ^ { k } \equiv b ^ { k }$ (mod 4), we have $\dot { a } ^ { 2 }$ $\overset { \cdot } { \left( \mathrm { m o d } \ 4 \right) } \in \left\{ 0 , 1 , 4 , 9 \right\}$ .
|
| 316 |
+
Since $4 \equiv 0$ (mod 4) and $9 \equiv 1 { \pmod { 4 } }$ , the result follows.
|
| 317 |
+
|
| 318 |
+
# Formal Proof:
|
| 319 |
+
|
| 320 |
+
theorem numbertheory_sqmod4in01d: fixes a :: int shows "( $\ a \hat { \textmd a } _ { 2 }$ mod $4 \ = \ 0$ ) $\scriptstyle \backslash < _ { \mathrm { { O L } } } >$ (aˆ2 mod $4 \ = \ 1$ )"
|
| 321 |
+
proof (cases "even a")
|
| 322 |
+
case True ( $\star$ Let a=2k for some integer k. Then $\hat { \mathbf { a } } \hat { \mathbf { \Lambda } } 2 \mathbf { = } 4 \mathbf { k } \hat { \mathbf { \Lambda } } 2$ . Since $4 1 - 2$ is divisible by 4, we have aˆ2 \equiv 0 \pmod{4}.\*) then obtain k where $" \mathrm { a } \mathrm { = } 2 \star \mathrm { k } "$ using evenE by auto [ATP]
|
| 323 |
+
then have $" a \widehat { } 2 = 4 \star \widehat { } 2 "$ unfolding power2_eq_square by auto [ATP] then have "aˆ2 mod $4 \ = \ 0$ " by auto [ATP]
|
| 324 |
+
then show ?thesis by auto [ATP]
|
| 325 |
+
next
|
| 326 |
+
case False $( \star \ \aleph \circ \aleph ,$ let $a = 2 k + 1$ for some integer k. Then $a \cdot 2 = 4 k \cdot 2 + 4 k + 1 = 4 ( k \cdot 2 + k ) + 1$ . Since $k ^ { \mathord { \sim } } 2 { + } k$ is an integer, 4 $( \mathbf { k } ^ { \sim } 2 + \mathbf { k } ) + \mathbf { 1 }$ is not divisible by 4. Thus, $\widehat { \mathbf { a } } \widehat { \mathbf { \Lambda } } ^ { 2 }$ \equiv $\texttt { 1 } \backslash \mathtt { p m o d } \{ 4 \} \ldots \star \}$ then obtain k where $\ " { a } { = } 2 { \star } \mathrm { k } { + } 1$ " using oddE by auto [ATP] then have $" a \widehat { } 2 = 4 { \star } \widehat { } 2 { + } 4 { \star } \mathrm { k } { + } 1 "$ " unfolding power2_eq_square by (auto simp: field_simps) [ATP] then have $\ " \mathtt { a } \hat { } 2$ mod $4 \ = \ 1$ " by presburger [ATP] then show ?thesis by auto [ATP]
|
| 327 |
+
qed
|
| 328 |
+
|
| 329 |
+
# Formal Proof:
|
| 330 |
+
|
| 331 |
+
theorem numbertheory_sqmod4in01d: fixes a :: int shows " $\hat { a } ^ { \star } 2$ mod $4 \ = \ 0$ ) $\scriptstyle \backslash < \supset \pm \gamma$ ( $\hat { \mathbf { a } } ^ { \hat { } } 2$ mod $4 ~ = ~ 1$ )"
|
| 332 |
+
proof -
|
| 333 |
+
(\* a \pmod 4 \in {0, 1, 2, 3}. \*)
|
| 334 |
+
have c0: "a mod 4 \<in> {0, 1, 2, 3}" by auto [ATP]
|
| 335 |
+
( $\star$ Using that for any natural number $\mathbf { k } ,$ a \equiv b \pmod 4 implies aˆk \equiv bˆk \pmod $^ { 4 , \star }$ )
|
| 336 |
+
have $\ " \mathtt { a } \hat { } 2$ mod $4 \ =$ (a mod 4)\<ˆsup> 2 mod 4" by (smt (z3) numeral_eq_Suc power_mod) [ATP]
|
| 337 |
+
( $\star$ we have aˆ2 \pmod 4 \in {0, 1, 4, 9}. \*)
|
| 338 |
+
also have "... \<in> {0, 1, 4, 9}" using c0 by auto [ATP]
|
| 339 |
+
( $^ { \star }$ Since 4 \equiv 0 \pmod 4 and 9 \equiv 1 \pmod 4, the result follows. \*)
|
| 340 |
+
finally show ?thesis by auto [ATP]
|
| 341 |
+
qed
|
| 342 |
+
|
| 343 |
+
Statement: For each plumbing repair job, Mr. Wrench charges $N$ dollars for coming out to the house plus $_ x$ dollars per hour that he works at the house. He charged $\$ 97$ for a one-hour repair job and $\$ 265$ for a five-hour repair job. What is his charge for a two-hour repair job? Show that it is $\$ 139$ .
|
| 344 |
+
|
| 345 |
+
# Informal Proof (Minerva 62B):
|
| 346 |
+
|
| 347 |
+
Let $N$ be the number of dollars charged for coming out to the house and let $x$ be the number of dollars per hour that Mr. Wrench works. For the one-hour repair job, we have that the total cost is $N + x = 9 7$ .
|
| 348 |
+
For the five-hour repair job, we have that the total cost is $N + 5 x = 2 6 5$ .
|
| 349 |
+
We subtract the first equation from the second equation to obtain $4 x = 1 6 8 \Rightarrow x = 4 2$ .
|
| 350 |
+
Plugging this back into the first equation, we obtain that $N = 5 5$ .
|
| 351 |
+
Therefore, for a two-hour repair job, the total cost is $5 5 + 2 x = 5 5 + 2 ( 4 2 ) = { \Big [ } \ S 1 3 9 { \Big ] } .$
|
| 352 |
+
|
| 353 |
+
# Formal Proof:
|
| 354 |
+
|
| 355 |
+
theorem mathd_algebra_160: fixes n x ::real assumes $" \mathrm { n } + \mathrm { x } = 9 7 "$ and $" \mathrm { n } ~ + ~ 5 ~ \star ~ \mathrm { x } = 2 6 5 "$ shows $" { \mathrm { ~ n ~ } } + ~ 2 ~ \star ~ { \mathrm { ~ x ~ } } = ~ 1 3 9 "$
|
| 356 |
+
proof - ( $\star$ We subtract the first equation from the second equation to obtain $4 \mathbf { x } = 1 6 8 \Rightarrow \mathbf { x } = 4 2 . \ \star )$ ) have $" 4 ~ * ~ \mathrm { \bf { x } } ~ = ~ 1 6 8 "$ using assms by auto [ATP] then have $" \mathrm { z } = 4 2 "$ by auto [ATP] ( $^ { * }$ Plugging this back into the first equation, we obtain that $\mathbf { N } = 5 5$ . \*) then have $" \mathrm { n } = 5 5 "$ using assms by auto $[ A T P ]$ ( $\left[ \star \right]$ Therefore, for a two-hour repair job, the total cost is $\mathbf { 5 5 } + \mathbf { 2 x } = \mathbf { 5 5 } + \mathbf { 2 } ( \mathbf { 4 2 } ) = \mathbb { 8 1 3 9 } . ~ \star )$ then show ?thesis by (smt (z3) $\langle \mathbf { x } \ : = \ : 4 2 \rangle$ ) [ATP]
|
| 357 |
+
qed
|
| 358 |
+
|
| 359 |
+
Statement: Show that for any real number $_ x$ and any natural number $n$ , if $x > - 1$ , then $( 1 + n x ) \leq ( 1 + x ) ^ { n }$ .
|
| 360 |
+
|
| 361 |
+
# Informal Proof (Minerva 62B):
|
| 362 |
+
|
| 363 |
+
This is true for $n = 1$ . Now, suppose that this is true for $n$ .
|
| 364 |
+
Then we have that
|
| 365 |
+
|
| 366 |
+
$$
|
| 367 |
+
( 1 + n x ) ^ { n } = 1 + n ^ { 2 } x + n ^ { 3 } x ^ { 2 } + \cdot \cdot \cdot + n x ^ { n }
|
| 368 |
+
$$
|
| 369 |
+
|
| 370 |
+
$$
|
| 371 |
+
\leq 1 + n x + n ^ { 2 } x ^ { 2 } + \cdot \cdot \cdot + n x ^ { n } = ( 1 + x ) ^ { n }
|
| 372 |
+
$$
|
| 373 |
+
|
| 374 |
+
and
|
| 375 |
+
|
| 376 |
+
$$
|
| 377 |
+
\begin{array} { c } { { ( 1 + n x ) ^ { n + 1 } = ( 1 + n x ) ^ { n } ( 1 + n x ) } } \\ { { \leq ( 1 + x ) ^ { n } ( 1 + x ) = ( 1 + x ) ^ { n + 1 } . } } \end{array}
|
| 378 |
+
$$
|
| 379 |
+
|
| 380 |
+
Therefore, this is true for $n + 1$
|
| 381 |
+
|
| 382 |
+
# Formal Proof:
|
| 383 |
+
|
| 384 |
+
theorem induction_1pxpownlt1pnx: fixes x :: real and n :: nat assumes $" - 1 < x "$ shows " $( \underline { { { 1 } } } ~ + ~ \boldsymbol { \mathrm { n } } { \star } \boldsymbol { \mathrm { x } } )$ ) (1 + x)ˆn"
|
| 385 |
+
proof (induct n)
|
| 386 |
+
case 0
|
| 387 |
+
then show ?case
|
| 388 |
+
by auto [ATP]
|
| 389 |
+
next case (Suc n)
|
| 390 |
+
then show ?case
|
| 391 |
+
by (smt (z3) Bernoulli_inequality assms)
|
| 392 |
+
[ATP]
|
| 393 |
+
qed
|
| 394 |
+
|
| 395 |
+
Statement: Determine the remainder of 1529 (mod 6). Show that it is 5.
|
| 396 |
+
|
| 397 |
+
Informal Proof (Minerva 62B): By definition, $1 5 2 9 \equiv 5$ (mod 6).
|
| 398 |
+
|
| 399 |
+
# Formal Proof:
|
| 400 |
+
|
| 401 |
+
theorem mathd_numbertheory_551 : "1529 mod $6 =$ (5::nat)" by auto [ATP]
|
md/dev/SVBR6xBaMl/SVBR6xBaMl.md
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Language Models Meet World Models: Embodied Experiences Enhance Language Models
|
| 2 |
+
|
| 3 |
+
Jiannan Xiang∗♠, Tianhua $\mathbf { T a o ^ { * } } ^ { \mathbf { A } }$ , Yi $\mathbf { G u } ^ { \pmb { \alpha } }$ , Tianmin $\mathbf { S h u } ^ { \bigcirc \bigtriangleup }$ , Zirui Wang♠, Zichao $\mathbf { Y a n g } ^ { \bigcirc }$ , Zhiting $\mathbf { H } \mathbf { u } ^ { \pmb { \alpha } }$ ♠UC San Diego, ♣UIUC, ${ \ \diamond \bf { \hat { \mu } } } _ { \mathrm { { M I T } } }$ , $\Delta _ { \mathrm { J H U } }$ , $^ { \heartsuit } { \mathbf { C M U } }$
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
While large language models (LMs) have shown remarkable capabilities across numerous tasks, they often struggle with simple reasoning and planning in physical environments, such as understanding object permanence or planning household activities. The limitation arises from the fact that LMs are trained only on written text and miss essential embodied knowledge and skills. In this paper, we propose a new paradigm of enhancing LMs by finetuning them with world models, to gain diverse embodied knowledge while retaining their general language capabilities. Our approach deploys an embodied agent in a world model, particularly a simulator of the physical world (VirtualHome), and acquires a diverse set of embodied experiences through both goal-oriented planning and random exploration. These experiences are then used to finetune LMs to teach diverse abilities of reasoning and acting in the physical world, e.g., planning and completing goals, object permanence and tracking, etc. Moreover, it is desirable to preserve the generality of LMs during finetuning, which facilitates generalizing the embodied knowledge across tasks rather than being tied to specific simulations. We thus further introduce the classical elastic weight consolidation (EWC) for selective weight updates, combined with low-rank adapters (LoRA) for training efficiency. Extensive experiments show our approach substantially improves base LMs on 18 downstream tasks by $6 4 . 2 8 \%$ on average. In particular, the small LMs (1.3B, 6B, and 13B) enhanced by our approach match or even outperform much larger LMs (e.g., ChatGPT). 1
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Language Models (LMs) have demonstrated impressive performance on a wide range of natural language processing tasks [34, 48, 4, 7, 54]. In particular, recent studies show that LMs can assist decision-making for embodied tasks [1, 18, 25, 45, 19], demonstrating a certain level of understanding of the physical world. However, such understanding is not robust enough for many reasoning and planning tasks in physical environments. As shown in Figure 1, even the latest large LMs like ChatGPT2 can still make mistakes in seemingly simple inquiries, such as counting objects in a location. We hypothesize that this is because current LMs trained merely with large-scale text corpora are devoid of embodied experiences such as navigating in an environment, interacting with objects, and sensing as well as tracking the world state. Consequently, they lack robust and comprehensive embodied knowledge necessary for reasoning and planning associated with physical environments. A related line of research finetunes LMs in order to improve specific embodied tasks, resulting in task-specialized models [6, 58, 21, 57].
|
| 12 |
+
|
| 13 |
+

|
| 14 |
+
Figure 1: Examples of tasks requiring embodied knowledge (upper), and an overview of our approach (bottom). In the task examples, blue text indicates the useful information for answering the question.
|
| 15 |
+
|
| 16 |
+
In this paper, we aim to inject diverse fundamental embodied knowledge and skills into pretrained LMs, while retaining the models’ generality. We introduce a novel training paradigm for LMs – finetuning with Embodied Experiences from World Models (E2WM). Here, world models are embodied simulators that emulate physical interactions in real-world environments (e.g., VirtualHome [36]). They provide LMs with the opportunity to comprehend object interactions within the environment and to execute actions, thus enabling a level of active engagement previously unattainable. These world models serve as a simplified and cost-effective replica of our real world that can significantly augment the conventional pretraining paradigm. We anticipate that finetuning LMs on embodied experiences gathered from world models can enhance their embodied knowledge—and, with the preserved model generality—consequently strengthen their abilities to solve a broad range of embodied tasks.
|
| 17 |
+
|
| 18 |
+
In this work, we consider a diverse range of fundamental knowledge and skills for embodied tasks, including tracking objects, planning to complete given goals, recognizing other agents’ behaviors, etc. To this end, we introduce two ways to collect embodied experiences from world models that give rise to the desired knowledge and skills: goal-oriented planning and random exploration (Figure 1). Specifically, goal-oriented planning aims to gather experiences associated with planning and goal-oriented agent behaviors, while random exploration focuses on accumulating experiences that involve object and world state tracking. In goal-oriented planning, models are given the goal (e.g., IN(dust, trash can)) for a specific activity (e.g., Clean Floor), and is supposed to generate a plan to complete it. To find the plan, we devise Monte Carlo Tree Search (MCTS) [5, 44] to explore the world model. Then the process will be stored as an embodied experience. In random exploration, one or more agents are deployed in the world model to execute random actions, while the locations and the movements of all the objects are tracked simultaneously.
|
| 19 |
+
|
| 20 |
+
After collecting the embodied experiences, we use them to construct a set of fine-tuning tasks (e.g., plan generation, activity recognition, and tracking). Crucially, to finetune LMs on the collected embodied experiences while retaining their original general knowledge and capabilities, we propose to incorporate the classical Elastic Weight Consolidation (EWC) [22] into our training paradigm. By regularizing the finetuning loss, EWC aims to preserve the important LM parameters from pretraining. We show that EWC is substantially more effective than the popular KL regularization [35, 28, 31]. We further introduce efficient low-rank updates by harmonizing the recent Low-Rank Adaptation (LoRA) [16] with the EWC regularizer. This results in the new EWC-LoRA update rule that greatly reduces training costs and makes our E2WM paradigm accessible to cheap hardware (GPUs).
|
| 21 |
+
|
| 22 |
+
We instantiate a world model using a virtual household simulator, VirtualHome [36, 37], and apply our method to GPT-Neo-1.3B [3], GPT-J-6B [49], OPT-13B [59], and LLaMA-13B [48] models. To test the generalizability of the finetuned LMs, we evaluate them on a variety of unseen tasks which demand similar embodied knowledge required to solve the training tasks. Additionally, we assess the models’ performance on the original pretraining data to determine the extent to which their core language modeling abilities are retained. Experiments show that our method significantly improves the baselines on both seen and unseen tasks (e.g., $3 4 . 3 1 5 1 . 2 3 $ Rouge-L on plan generation task, $3 0 . 4 1 \% 6 7 . 0 1 \%$ accuracy on counting task), without suffering performance degradation on the pretraining dataset $3 . 4 4 3 3 . 5 3 7$ perplexity on Pile test subset [12]). Moreover, the small GPTJ-6B, OPT-13B, and LLaMA-13B models finetuned with our E2WM paradigm even outperforms ChatGPT on many of the tasks. The experimental results demonstrate the effectiveness of E2WM as a promising fine-tuning mechanism to enhance pretrained LMs with generalizable embodied knowledge and skills.
|
| 23 |
+
|
| 24 |
+
# 2 Related Work
|
| 25 |
+
|
| 26 |
+
World Model. The term “world model” generally refer to a computational representation of the physical world, capable of simulating changes in the world’s state in response to various actions. For instance, humans possess an internal world model that aids in predicting the outcomes of specific actions during the planning process. Recent research induces world models from large LMs for robust human-like reasoning [15]. In this work, we employ a simulator equipped with a physics engine to serve as our world model, effectively emulating real-world conditions. In the field of embodied AI, various world models are built to replicate the real world and serve as virtual test environments for assessing robotic agents before real-world deployment. For example, VirtualHome [36, 37] is a simulated 3D household environment implemented by Unity3D game engine. AI2-THOR [23] consists of near photo-realistic 3D indoor scenes and has richer object attributes and interaction types. Other indoor household World Models include VRKitchen [13], CHALET [56], MINOS [41], House3D [53], etc. Besides, MineCraft is a more challenging and open-ended world model, which has a large number of objectives and a large-scale task hierarchy [14, 27, 20]. In this paper, we use VirtualHome as our world model.
|
| 27 |
+
|
| 28 |
+
Language Model Grounding. A significant number of recent works focused on grounding language models to world models [1, 24, 38, 47, 55]. Some of them freeze LMs and leverage certain prompting strategies or specifically-designed modules. For example, Zero-Shot Planner [18] prompts LMs to generate activity plans and translate them into admissible actions. Mind’s eye [29] prompts LMs to do simulations with physical engines to answer physical reasoning questions. SayCan [1] uses a learned affordance function to assist LMs in selecting valid actions. DEPS [50] prompts LMs to describe, explain and generate action plans, incorporated with a learned selector module to choose the most efficient path. There are also other works finetuning LMs towards better downstream task performance. For example, Li et al. [25] finetune LMs with supervised learning for interactive decision making, and Carta et al. [6] ground LMs with online reinforcement learning. Different from these works aiming to optimize LMs for specific tasks in the target environments, our work instead focuses on improving the language model itself by acquiring knowledge from world models.
|
| 29 |
+
|
| 30 |
+
Language Model Regularization. To facilitate the acquisition of new knowledge and skills without losing LMs’ language modeling abilities , regularization is often introduced during finetuning. One popular method is adding KL penalty [35, 28, 46, 52, 33, 60], which leverages KL divergence between the output probability of the currently trained model and the original model to regularize the LM in an RL manner, i.e., by computing policy gradients. For example, InstructGPT uses KL penalty to mitigate over-optimization of the reward model [35], and Liu et al. [28] add KL regularization for training a commonsense knowledge generator. In this work, we instead use elastic weight consolidation (EWC) for regularization. Our empirical results demonstrate that EWC is more effective than applying KL penalty for retaining language modeling abilities and generality of LMs.
|
| 31 |
+
|
| 32 |
+
# 3 Approach
|
| 33 |
+
|
| 34 |
+
In this work, we propose a new training paradigm, namely finetuning with Embodied Experiences from World Models (E2WM), to inject embodied knowledge into LMs without sacrificing its generality and language modeling abilities. The world model we use is VirtualHome [36, 37], a multi-agent simulator for househould activities. In VirtualHome, an executable action step can be simplified as the format of [action] <arg>, e.g., [Grab] <apple> . The world state of VirtualHome consists of objects and their relations (e.g., apple on table). Details about VirtualHome can be found in Appendix
|
| 35 |
+
|
| 36 |
+

|
| 37 |
+
Figure 2: The illustration of goal-oriented planning (left) and random exploration (right) in our training paradigm. In MCTS, the path in orange represents the final plan generated by the planner.
|
| 38 |
+
|
| 39 |
+
A.1. We first describe how to gather embodied experiences in the world model in Section 3.1. Then in Section 3.2 we demonstrate how to finetune LMs by utilizing collected experiences, as well as our proposed method EWC-LoRA for efficient knowledge generalization.
|
| 40 |
+
|
| 41 |
+
# 3.1 Collecting Embodied Experiences from World Model
|
| 42 |
+
|
| 43 |
+
LMs pretrained on large scale human-written text corpus often have difficulties in solving basic reasoning and planning in physical environments. This is because that LMs lack necessary embodied knowledge and experiential understanding of the physical world. To address the problem, we propose to leverage world models to collect diverse embodied experiences for enhancing LMs. Specifically, to inject different types of embodied knowledge into LMs, we introduce two ways to gather experiences: goal-oriented planning and random exploration. Figure 2 illustrates the two methods.
|
| 44 |
+
|
| 45 |
+
Goal-oriented Planning. One important embodied skill is to plan and complete a specific goal, e.g., placing tableware properly to set up the table. To endow LMs with this ability, we propose goal-oriented planning. The approach aims to generate experiences that are goal-oriented, thus are useful to facilitate the acquisition of skills and task planning abilities for executing a range of activities in the world model. To do that, we collect various activities and their corresponding goals. Formally, the goal for an activity in the world model is defined as a set of predicates describing the target world state. For instance, an activity can be set up table, and its goal can be ON(fork, table);ON(plate, table), which means that fork and plate should be put on the table to fulfill the activity. More details about predicates and goal definitions can be found in Appendix A.2. As shown in Figure 2, in goal-oriented planning, we devise a Monte Carlo Tree Search (MCTS) planner to search through the action space and find a plan, i.e., a sequence of actions, to achieve the goal. The key to successful MCTS is the reward design. At each time step, if at least one goal predicate is satisfied, the MCTS planner will get a reward of $+ 2$ , and the achieved goal predicates will be removed from the goal. This ensures that the planner does not repeatedly execute the same action to receive rewards, but rather focuses on achieving the remaining unfulfilled goals. Besides, it will get a -0.1 penalty after each time step to discourage the planner from doing actions irrelevant to fulfilling the goals. Finally, we store the planning process as an embodied experience.
|
| 46 |
+
|
| 47 |
+
Random Exploration. In real-world scenarios, humans not only acquire new knowledge by finishing tasks, but also learn by just randomly exploring the surroundings, e.g., randomly observing/tracking objects and knowing their properties. To mimic this learning process, we propose another approach, namely random exploration. By simply exploring in the world model, embodied experiences emerge that involve advanced cognitive abilities including object permanence and tracking, as agents observe and track the consistent existence of objects even when they are out of sight. Then the experiences are gathered for finetuning LMs later. Specifically, the approach deploys one or multiple agents in the world model wandering aimlessly and randomly executing actions. As illustrated in Figure 2, multiple agents are in the same environment, interacting with each other or executing different actions on the same objects, which simulates complex situations. During the exploration, the moving paths and the final locations of all the objects in the world model are recorded. Then the whole process is captured as an embodied experience.
|
| 48 |
+
|
| 49 |
+
# 3.2 Finetuning LMs with Embodied Experiences
|
| 50 |
+
|
| 51 |
+
There are multiple ways to utilize collected embodied experiences for LMs finetuning, such as supervised learning and reinforcement learning. In this work, we use them with supervised learning for simplicity and efficiency. Specifically, goal-oriented planning experiences are compiled into data examples in two formats: plan generation and activity recognition. As shown in Figure 2, in plan generation, the model is required to generate a stepwise action sequence to fulfill an activity, given the state of some relevant objects as the initial condition. In activity recognition, the model needs to recognize the activity name given its plan. Experiences obtained from random exploration are also transformed into two self-supervision tasks: counting and object path tracking. Examples of the two tasks can be seen in Figure 2. Specifically, for counting, the LM is tasked with identifying the number and name of the objects at a specific location after the agents performed relevant and irrelevant actions and arranged objects randomly. In object path tracking, the model is tasked to output the moving path of an object that is picked up by different agents and moved to different rooms at different times. All the tasks are trained with cross-entropy loss. Suppose that $\mathbf { x }$ is the input (e.g., the initial condition in plan generation) and $\mathbf { y } = \{ y _ { 1 } , . . . , \bar { y _ { M } } \}$ is the label (e.g., the stepwise action sequence), we finetune LMs by assigning different weights to different tasks:
|
| 52 |
+
|
| 53 |
+
$$
|
| 54 |
+
\mathcal { L } _ { V } = \sum _ { v \in V } \alpha _ { v } \sum _ { m = 1 } ^ { M } \log P ( y _ { m } | \mathbf { y } _ { < m } , \mathbf { x } ) ,
|
| 55 |
+
$$
|
| 56 |
+
|
| 57 |
+
where $\mathcal { L }$ is the loss function; $V$ is the task set; and $\alpha _ { v }$ is the weight for task $v$ . Following Flan-T5 [8], $\mathbf { x }$ is a prompt formatted to contain a task instruction and sampled in-context demonstrations. We provide all prompts in Appendix A.3.
|
| 58 |
+
|
| 59 |
+
Efficient Finetuning with Preserved Generality. However, there are two key problems for simply finetuning LMs. The first one is that LMs will easily overfit to the downstream tasks, leading to performance degradation on other tasks. This deviates from our goal that the model should generalize acquired knowledge across various tasks. Another problem is that finetuning the entire LM is resource-intensive and time-consuming, especially when the LM is extremely large. To overcome the problem and facilitate continual and efficient knowledge acquisition with world models, we propose to finetune only a small number of weights using low-rank adaptors (LoRA) [16] with elastic weight consolidation (EWC) [22], which we refer to as EWC-LoRA.
|
| 60 |
+
|
| 61 |
+
EWC is a regularization-based method typically used in the area of continual learning [9]. It calculates a fisher matrix [11] to estimate the importance of each parameter for a task and then uses it to regularize the training on a new task. The regularization term helps to constrain the parameter updates for the new task to avoid forgetting the previous knowledge. Let $U$ be the pretraining task set, and $V$ be the finetuning task set. Following [2], we have:
|
| 62 |
+
|
| 63 |
+
$$
|
| 64 |
+
\begin{array} { c } { { \displaystyle F _ { i , i } = \frac { 1 } { N } \sum _ { j = 1 } ^ { N } \left( \frac { \partial \mathcal { L } _ { U } ^ { ( j ) } } { \partial \theta _ { U , i } ^ { * } } \right) ^ { 2 } , } } \\ { { \mathcal { L } ( \theta ) = \mathcal { L } _ { V } ( \theta ) + \lambda \sum _ { i } F _ { i , i } ( \theta _ { i } - \theta _ { U , i } ^ { * } ) ^ { 2 } , } } \end{array}
|
| 65 |
+
$$
|
| 66 |
+
|
| 67 |
+
where $\mathcal { L }$ is the loss function, $F$ is the fisher matrix, $\lambda$ is the hyperparameter, $i$ and $j$ are the indices for parameters and data samples, respectively, and $\theta$ and $\theta _ { U } ^ { * }$ are currently trained parameters and frozen task $U$ parameters, respectively. Notice that the first term ${ \mathcal { L } } _ { V } ( \theta )$ in Equation 3 is calculated in Equation 1, and the second term is the EWC regularizer. In Equation 2, the fisher matrix is calculated by averaging the sum of squares of the gradients from the task $U$ , which indicates the significance of each parameter to the task $U$ . Then the matrix is used in Equation 3 to weigh the shift of model parameters when training on $V$ . By using EWC, the LM learns to adapt to new tasks without catastrophic forgetting on the pretraining task, which forces it to understand and digest new knowledge from the finetuning tasks instead of overfitting to them.
|
| 68 |
+
|
| 69 |
+
However, EWC is both time- and memory-inefficient. First, it requires finetuning the entire set of large LM’s parameters. Moreover, the approach involves creating a frozen original model and a fisher matrix that is the same size as the LM, leading to a memory overhead of three times the original size.
|
| 70 |
+
|
| 71 |
+
This makes it particularly challenging to apply to larger models. To alleviate the problem, we propose to combine EWC with low-rank adaptors (LoRA), a parameter-efficient tuning method. LoRA freezes the pretrained model weights and injects two trainable low-rank matrices into each layer of the model. Suppose that $W$ , $W ^ { \ast } \in \bar { \mathbb { R } } ^ { r \times d }$ are the trained weight matrix and frozen weight matrix, respectively; and $B \in \mathbb { R } ^ { r \times k } , A \in \mathbb { R } ^ { k \times d }$ are two low-rank matrices with $k \ll \operatorname* { m i n } ( r , d )$ . Then the formula for LoRA can be written as $W = W ^ { * } + B A$ . Suppose that $H$ is flattened $B A$ . Notably, we found that $\theta _ { i }$ in Equation 3 is the element of $W$ , and $\theta _ { U , i } ^ { * }$ is that of $W ^ { * }$ . Therefore, $\theta _ { i } - \theta _ { U , i } ^ { * }$ is the element of $H$ . We can thus transform Equation 3 into the final formula of EWC-LoRA method:
|
| 72 |
+
|
| 73 |
+
$$
|
| 74 |
+
\mathcal { L } ( \boldsymbol { \theta } ) = \mathcal { L } _ { V } ( \boldsymbol { \theta } ) + \lambda \sum _ { i } F _ { i , i } h _ { i } ^ { 2 } ,
|
| 75 |
+
$$
|
| 76 |
+
|
| 77 |
+
where $h _ { i } = \theta _ { i } - \theta _ { U , i } ^ { * }$ is the $i$ -th element of $H$ . One of the benefits of this rewriting is that we no longer need to store the trained LM weight matrixes as what vanilla EWC does, which saves plenty of memory space. Besides, we only need to update $B$ and $A$ during the finetuning, which also lowers memory requirements and leads to much faster training speed. Surprisingly, as shown later, we empirically found that adding LoRA into EWC can further mitigate the issue of catastrophic forgetting and overfitting. This aligns with the previous conclusion that limiting the dimension of the optimization problem can alleviate catastrophic forgetting [32].
|
| 78 |
+
|
| 79 |
+
# 4 Experiments
|
| 80 |
+
|
| 81 |
+
Training Details. For goal-oriented planning, we collected activities and their corresponding target goals with data from RobotHow [36], a housework activity knowledge base created in VirtualHome. We applied our method to GPT-Neo-1.3B [3], GPT-J-6B [49], OPT-13B [59], and LLaMA-13B [48]. To save computing resources, we use Int8 technique [10]. Both of the models were trained with the AdamW optimizer [30]. All the hyperparameters are chosen according to the performance on a held out set. We used one NVIDIA GeForce RTX 3090 for training. More details can be found in Appendix A.4.
|
| 82 |
+
|
| 83 |
+
# 4.1 Downstream Evaluation Tasks
|
| 84 |
+
|
| 85 |
+
We developed various downstream evaluation tasks for each type of embodied knowledge, including both the training tasks as well as novel tasks unseen during training used for generalization evaluation. Additionally, we evaluate our models on bAbI [51], a dataset for testing multiple types of knowledge and abilities including embodied knowledge, logic reasoning, linguistic knowledge, etc. We select the bAbI tasks related to embodied knowledge for our evaluation. We evaluate all the unseen tasks including bAbI under few-shot settings, specifically 2-10 shots, by providing a few in-context exemplars in the prompts. We discuss more details of the tasks below.
|
| 86 |
+
|
| 87 |
+
Plan Generation. To evaluate planning ability, we construct downstream tasks using human-written plans from RobotHow. Specifically, we have three tasks:
|
| 88 |
+
|
| 89 |
+
• Plan Generation Evaluation. In this task, the model needs to generate a plan for a housework activity. It is similar to the training task but uses human-written plans as the ground truth instead of the collected experiences. We include activities unseen during training to test the generalizability of the model. Inspired by the previous study showing that LMs can easily be distracted by irrelevant context [43], we also created samples having states of unrelated objects in the context (e.g., TV is on for activity Make Coffee) to confuse LMs. In summary, this results in four settings: Vanilla Seen, Vanilla Unseen, Confusing Seen, and Confusing Unseen. We have 175/54/135/43 examples for four settings, respectively. We use Rouge-L [26] as the metric.
|
| 90 |
+
|
| 91 |
+
• Housework QA. This is a multi-choice QA task, which is unseen during training. It asks which choice is the relevant object to finish a household activity, e.g., which object is relevant to making coffee? It has 261 examples in total, and we use accuracy as the metric. When evaluating, we provide 10 in-context exemplars in the prompts, so this task is evaluated as a 10-shot learning task.
|
| 92 |
+
|
| 93 |
+
• Negation Housework QA. This is similar to Housework QA but inquires about the irrelevant object, e.g., which object is irrelevant to making coffee? It is more challenging than the vanilla QA because LMs that simply memorize the word co-occurrence in the training data may succeed in the vanilla QA but will fail in the negation QA. This task has 162 examples and uses accuracy as the metric. We provide 10 in-context exemplars in the prompts.
|
| 94 |
+
|
| 95 |
+
Activity Recognition. We developed two multi-choice QA tasks with the human-written plans and the state changes from RobotHow to test the knowledge gained from activity recognition:
|
| 96 |
+
|
| 97 |
+
• Activity Recognition QA. In this task, a human-written plan is given and the model needs to choose the correct activity name. An example of the question is “Given a plan: Walk to living room. Sit on sofa. Turn on TV. What is the name of this activity?”. And the answer should be Watch TV. The task has 549 examples. We use accuracy as the metric.
|
| 98 |
+
• Activity Inference QA. In this task, we use the final state of the world model as input for the model to infer the activity name. For example, the input can be “Tom is sitting on the sofa and facing the TV. The TV is on. What is a possible activity he is doing?”, and the answer is “Watch TV”. We have 262 examples for this task and use accuracy to measure the performance. We provide 10 in-context exemplars in the prompts.
|
| 99 |
+
|
| 100 |
+
Counting. We gathered random exploration experiences to construct Counting QA for evaluating skills learned from the counting task. The model is required to answer the number of objects in a specific location. For example, a query can be “Tom put an apple on the table. Tom turned on the TV. Tom put a cup on the table. How many objects are there on the table?”. We can see that there will be irrelevant actions like turn on TV to confuse the model and make the question more challenging. We collected 194 samples for the task and used accuracy as the evaluation metric. We provide 5 in-context exemplars in the input prompts.
|
| 101 |
+
|
| 102 |
+
Object Path Tracking. We developed two downstream tasks for the object path tracking training task, namely Object Path Tracking Evaluation and Object Location QA.
|
| 103 |
+
|
| 104 |
+
• Object Path Tacking Evaluation. This evaluation task is the same as the training task, where the model is required to generate the full moving path of an object. An example is “Tom walked to the kitchen. Tom grabbed the apple. Mary walked to the bedroom. Tom walked to the living room. What is the order of the rooms where the apple appears?”. This question typically includes multiple agents and many irrelevant actions, which makes it difficult to track the object. This task contains 200 examples. Following Huang et al. [18], we evaluate the performance by calculating the length of the longest common subsequence (LCS) between the ground truth and the generated path, normalized by the maximum length of the two.
|
| 105 |
+
|
| 106 |
+
• Object Location QA. In this task, the model is asked about the location of an object before/after it moves to another location, e.g., where is the apple before/after the kitchen? This task has 200 examples with accuracy as the metric. We provide 2 in-context exemplars in the prompts.
|
| 107 |
+
|
| 108 |
+
A previous study on prompting multiple QA questions [39] introduces two prompting methods, multiple choice prompt and cloze prompt, and two normalization methods, length, and unconditioned normalization. For all the multi-choice QA tasks, we choose the combination of prompting and normalization methods which yields the best performance on a held out set.
|
| 109 |
+
|
| 110 |
+
To further verify the effectiveness of our method, we evaluate our finetuned GPT-Neo and GPT-J on the bAbI dataset. Specifically. we select 8 test sets from bAbI that align with the abilities covered in our collected embodied experiences. We include the description of each test set in Appendix A.5. For all the bAbI tasks, we do 2-shot learning by providing 2 in-context exemplars in the input prompts.
|
| 111 |
+
|
| 112 |
+
Besides downstream tasks, we also want to ensure that our approach does not hurt language modeling performance of the models. Therefore, following previous work [42], we evaluate the perplexity on a subset of Pile [12] test set, which is the pretraining dataset for GPT-Neo and GPT-J. We sampled 5000 examples from Pile test set for evaluation.
|
| 113 |
+
|
| 114 |
+
# 4.2 Results
|
| 115 |
+
|
| 116 |
+
Constructed Evaluation Tasks. Results for all the downstream evaluation tasks are shown in Figure 3 and Figure 4. For all the models, we compare the results obtained after finetuning with world model against those of the original base models. For GPT-J, we also include a finetuned model without EWC-LoRA as a baseline. Detailed numbers of the results can be found in Appendix A.6. We also conduct human evaluations for GPT-J on the plan generation task, which can be found in Appendix A.7. In general, the models trained with the world model significantly outperform the baselines on various downstream tasks. Our method is not only effective for small 1.3B model, but can also scale to larger 6B and 13B models. Specifically, our finetuned GPT-J and LLaMA-13B with world model even achieve better performance than ChatGPT as a much larger LM on most of the 11 tasks. Besides, we can see the world model improves LMs on both seen and unseen tasks. This demonstrates that our model absorbs the knowledge for goal-oriented planning and random exploration instead of memorizing the seen experiences. Specifically, the better plan generation performance under the "Confusing" setting indicates that the world model improves the ability of LMs to avoid being interfered with by irrelevant contexts. On both Housework QA and Negation Housework QA, our models surpass the baselines, showing that our models also acquire knowledge about the necessary objects for completing a housework activity. Results on other downstream tasks also prove the effectiveness of our method. For example, on both Activity Recognition Evaluation and Activity Inference, our approach improves over the baselines significantly. Moreover, improvements can be observed in the downstream tasks regarding random exploration. On Counting and Object Location QA tasks, our LLaMA-13B trained with the world model even surpasses ChatGPT.
|
| 117 |
+
|
| 118 |
+

|
| 119 |
+
Figure 3: Experimental results of GPT-Neo and GPT-J on our constructed downstream tasks. GPT-J (FT) refers to the finetuned GPT-J without EWC-LoRA. Our approach surpasses baselines on all of the 11 tasks, and outperforms ChatGPT on 7 of them. For example, our GPT-J model achieves 98.67 LCS on object path tracking, which is significantly better than 33.86 of base GPT-J and 59.53 of ChatGPT.
|
| 120 |
+
|
| 121 |
+

|
| 122 |
+
Figure 4: Experimental results of OPT-13B and LLaMA-13B on our constructed downstream tasks. Our approach applied on LLaMA-13B outperforms ChatGPT on 8 of them.
|
| 123 |
+
|
| 124 |
+

|
| 125 |
+
Figure 5: Experimental results on bAbI. Our approach outperforms base LMs on all the tasks except for the Two Supporting Fact task.
|
| 126 |
+
|
| 127 |
+
Table 1: Perplexity on Pile test subset, showing the proposed finetuning with world model manages to preserve the LMs’ language modeling capability.
|
| 128 |
+
|
| 129 |
+
<table><tr><td colspan="2">GPT-Neo</td><td colspan="2">GPT-J</td><td colspan="2">OPT-13B</td><td colspan="2">LLaMA-13B</td></tr><tr><td>Base</td><td>Ours</td><td>Base</td><td>Ours</td><td>Base</td><td>Ours</td><td>Base</td><td>Ours</td></tr><tr><td>4.120</td><td>4.193</td><td>3.443</td><td>3.537</td><td>4.077</td><td>4.358</td><td>3.036</td><td>3.069</td></tr></table>
|
| 130 |
+
|
| 131 |
+
Table 2: Results of different regularization methods. The abbreviations in the Task column stand for the corresponding evaluation tasks for four training tasks. We use asterisk∗ to mark the perplexity of base models.
|
| 132 |
+
|
| 133 |
+
<table><tr><td rowspan="2">Task</td><td colspan="5">GPT-Neo</td><td colspan="3">GPT-J</td></tr><tr><td>Base</td><td>EWC</td><td>LoRA</td><td>LoRA&KL</td><td>EWC-LoRA</td><td>Base</td><td>LoRA</td><td>EWC-LoRA</td></tr><tr><td>Plan Gen</td><td>21.25</td><td>48.56</td><td>51.24</td><td>45.99</td><td>49.70</td><td>34.31</td><td>51.23</td><td>51.23</td></tr><tr><td>Act Recog</td><td>69.22</td><td>89.98</td><td>87.98</td><td>81.42</td><td>85.43</td><td>87.98</td><td>90.16</td><td>88.52</td></tr><tr><td>Count</td><td>22.68</td><td>55.67</td><td>27.84</td><td>49.48</td><td>28.87</td><td>30.41</td><td>63.92</td><td>67.01</td></tr><tr><td>Obj PT</td><td>30.80</td><td>95.96</td><td>87.28</td><td>63.59</td><td>85.91</td><td>33.86</td><td>97.22</td><td>98.67</td></tr><tr><td>Perplexity</td><td>4.120*</td><td>4.995</td><td>4.360</td><td>5.029</td><td>4.193</td><td>3.443*</td><td>3.675</td><td>3.537</td></tr></table>
|
| 134 |
+
|
| 135 |
+
bAbI Tasks. To further verify the effectiveness of our method, we evaluate our finetuned models on the bAbI dataset. The results are shown in Figure 5. We can see that our approach significantly outperforms the base LMs. Notably, after finetuned with VirtualHome experiences, GPT-J surpasses the much stronger ChatGPT on the most challenging tasks. Specifically, it outperforms ChatGPT on the Three Supporting Fact task, where the model is required to use three supporting facts from the context to answer a question like “where was the apple before the kitchen?”, and Lists/Sets task, which asks the model to give the answers in the form of a list, e.g., the answer for “What is Daniel holding?” is “apple, milk”. These results prove that our approach enables LMs to acquire the knowledge and skills inherent in embodied experiences, rather than simply overfitting to the training environment.
|
| 136 |
+
|
| 137 |
+
Language Modeling. In addition to verifying improved performance on the downstream tasks, we also report results on Pile test subset to ensure the preservation of the generality and language modeling abilities of LMs. From the experimental results shown in Table 1, we can see that our approach only causes a negligible increase in perplexity over the base models. This demonstrates the effectiveness of EWC-LoRA to preserve the generality and linguistic competence of LMs. To verify the generality on other NLP tasks, we also include the results on SuperGLUE [40] in Appendix A.8.
|
| 138 |
+
|
| 139 |
+
# 4.3 Comparison of Different Regularization Methods
|
| 140 |
+
|
| 141 |
+
We compare our proposed EWC-LoRA with EWC and LoRA. Besides, we also include the baseline using KL penalty as regularization.The experimental results are shown in Table 2. We also include the results of four evaluation tasks. Notice that we do not include the results of GPT-J with pure EWC and KL, since they are overly memory-intensive or time-consuming. EWC requires an original model and a fisher matrix other than the trained model, which triples the memory usage, making it hard to be applied to large models like GPT-J-6B. Besides, KL penalty term is computed by $\mathcal { L } _ { K L } = E _ { ( \mathbf { x } , \mathbf { y } ) \sim P _ { \theta ^ { * } } } \bigl [ - \log \left( P _ { \theta ^ { * } } ( \mathbf { y } | \mathbf { x } ) / P _ { \theta } ( \mathbf { y } | \mathbf { x } ) \right) \bigr ]$ , thus it requires sampling from the model output probability, which is time-consuming. On the contrary, EWC-LoRA is both memory- and timeefficient. In Table 2, we can see that EWC-LoRA achieves the lowest perplexity compared to other methods, while still significantly outperforming the base LMs. Compared with pure EWC, applying pure LoRA greatly decreases perplexity, which is consistent with the previous conclusion that limiting the dimension of the optimization problem can mitigate catastrophic forgetting [32]. EWC-LoRA further decreases perplexity, making it extremely close to the original perplexity, while achieving comparable performance with LoRA on downstream tasks. This demonstrates the effectiveness of EWC-LoRA. Besides, We can find that combing LoRA with KL will greatly increase perplexity while not achieving better downstream performance. Overall, our proposed EWC-LoRA achieves the best trade-off between the perplexity and the downstream performance, which outperforms baselines significantly while almost not increasing the perplexity on the pretraining dataset.
|
| 142 |
+
|
| 143 |
+
<table><tr><td></td><td colspan="6">GPT-Neo</td></tr><tr><td></td><td>Base</td><td>Ours</td><td> -w/o Plan Gen</td><td> -W/o Act Recog</td><td> -w/o Count</td><td> - w/o Obj PT</td></tr><tr><td>Plan Gen</td><td>21.25</td><td>49.70</td><td>14.48</td><td>49.38</td><td>49.85</td><td>50.06</td></tr><tr><td>Act Recog</td><td>69.22</td><td>85.43</td><td>85.97</td><td>48.63</td><td>85.25</td><td>84.34</td></tr><tr><td>Count</td><td>22.68</td><td>28.87</td><td>18.56</td><td>25.26</td><td>35.05</td><td>32.99</td></tr><tr><td>Obj PT</td><td>30.80</td><td>85.91</td><td>92.13</td><td>84.17</td><td>86.46</td><td>29.90</td></tr><tr><td>Perplexity</td><td>4.120*</td><td>4.193</td><td>4.171</td><td>4.151</td><td>4.162</td><td>4.164</td></tr></table>
|
| 144 |
+
|
| 145 |
+
Table 3: Ablation experimental results on training tasks. We use the same abbreviations as Table 2.
|
| 146 |
+
|
| 147 |
+
# 4.4 Ablation Studies
|
| 148 |
+
|
| 149 |
+
To study the contribution of each training task, we conducted an ablation study by removing one training task every time. We use GPT-Neo-1.3B as the base model. We include the results on tasks seen during training in Table 3. Results on all the tasks can be found in Appendix A. We can see that the removal of a training task with similar ability leads to a notable decrease in the model’s performance on downstream tasks. For example, the performance of plan generation drops significantly when plan generation is removed from the training tasks. Similarly, the removal of activity recognition or object path tracking from the training tasks leads to a decline in performance in their respective downstream tasks. We conclude that our gathered embodied experience has a tremendous contribution to teaching the corresponding reasoning ability by finetuning. Interestingly, Counting QA performance shows an increase when counting is omitted from the training tasks, possibly because the ability of counting can be inferred from other training tasks.
|
| 150 |
+
|
| 151 |
+
# 5 Conclusion & Future Work
|
| 152 |
+
|
| 153 |
+
We proposed a new training framework that uses world models to enhance language models. It first collects embodied experiences from world models through both goal-oriented planning and random exploration. The experiences are then compiled into appropriate formats for LMs finetuning. We further introduce EWC-LoRA, which not only facilitates parameter-efficient tuning but also alleviates catastrophic forgetting and enables knowledge generalization. We show the strong performance of our method on a large number of downstream evaluation tasks.
|
| 154 |
+
|
| 155 |
+
This work demonstrates the advantage of panoramic learning with all forms of experience [17]. On the other hand, the present work is limited to a single household environment as the world model. In the future, we intend to study how to integrate embodied experiences from different world models and generalize knowledge learned from each world model to different domains.
|
| 156 |
+
|
| 157 |
+
Acknowledgements. This project is partially supported by DARPA ECOLE HR00112390063.
|
| 158 |
+
|
| 159 |
+
# References
|
| 160 |
+
|
| 161 |
+
[1] Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, et al. Do as i can, not as i say: Grounding language in robotic affordances. arXiv preprint arXiv:2204.01691, 2022.
|
| 162 |
+
|
| 163 |
+
[2] Kristjan Arumae, Qing Sun, and Parminder Bhatia. An empirical investigation towards efficient multi-domain language model pre-training. arXiv preprint arXiv:2010.00784, 2020.
|
| 164 |
+
|
| 165 |
+
[3] Sid Black, Leo Gao, Phil Wang, Connor Leahy, and Stella Biderman. GPT-Neo: Large Scale Autoregressive Language Modeling with Mesh-Tensorflow, March 2021.
|
| 166 |
+
|
| 167 |
+
[4] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
|
| 168 |
+
|
| 169 |
+
[5] Cameron B Browne, Edward Powley, Daniel Whitehouse, Simon M Lucas, Peter I Cowling, Philipp Rohlfshagen, Stephen Tavener, Diego Perez, Spyridon Samothrakis, and Simon Colton. A survey of monte carlo tree search methods. IEEE Transactions on Computational Intelligence and AI in games, 4(1):1–43, 2012.
|
| 170 |
+
|
| 171 |
+
[6] Thomas Carta, Clément Romac, Thomas Wolf, Sylvain Lamprier, Olivier Sigaud, and PierreYves Oudeyer. Grounding large language models in interactive environments with online reinforcement learning. arXiv preprint arXiv:2302.02662, 2023.
|
| 172 |
+
|
| 173 |
+
[7] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
|
| 174 |
+
|
| 175 |
+
[8] Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph, Yi Tay, William Fedus, Eric Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, et al. Scaling instruction-finetuned language models. arXiv preprint arXiv:2210.11416, 2022.
|
| 176 |
+
|
| 177 |
+
[9] Matthias De Lange, Rahaf Aljundi, Marc Masana, Sarah Parisot, Xu Jia, Aleš Leonardis, Gregory Slabaugh, and Tinne Tuytelaars. A continual learning survey: Defying forgetting in classification tasks. IEEE transactions on pattern analysis and machine intelligence, 44(7):3366– 3385, 2021.
|
| 178 |
+
|
| 179 |
+
[10] Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. Llm.int8(): 8-bit matrix multiplication for transformers at scale. arXiv preprint arXiv:2208.07339, 2022.
|
| 180 |
+
|
| 181 |
+
[11] B Roy Frieden. Science from Fisher information, volume 974. Citeseer, 2004.
|
| 182 |
+
|
| 183 |
+
[12] Leo Gao, Stella Biderman, Sid Black, Laurence Golding, Travis Hoppe, Charles Foster, Jason Phang, Horace He, Anish Thite, Noa Nabeshima, Shawn Presser, and Connor Leahy. The Pile: An 800gb dataset of diverse text for language modeling. arXiv preprint arXiv:2101.00027, 2020.
|
| 184 |
+
|
| 185 |
+
[13] Xiaofeng Gao, Ran Gong, Tianmin Shu, Xu Xie, Shu Wang, and Song-Chun Zhu. Vrkitchen: an interactive 3d virtual environment for task-oriented learning. arXiv, abs/1903.05757, 2019.
|
| 186 |
+
|
| 187 |
+
[14] William H Guss, Brandon Houghton, Nicholay Topin, Phillip Wang, Cayden Codel, Manuela Veloso, and Ruslan Salakhutdinov. Minerl: a large-scale dataset of minecraft demonstrations. In Proceedings of the 28th International Joint Conference on Artificial Intelligence, pages 2442–2448, 2019.
|
| 188 |
+
|
| 189 |
+
[15] Shibo Hao, Yi Gu, Haodi Ma, Joshua Jiahua Hong, Zhen Wang, Daisy Zhe Wang, and Zhiting Hu. Reasoning with Language Model is Planning with World Model. NeurIPS, 2023.
|
| 190 |
+
|
| 191 |
+
[16] Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.
|
| 192 |
+
|
| 193 |
+
[17] Zhiting Hu and Eric P. Xing. Toward a ’Standard Model’ of Machine Learning. Harvard Data Science Review, 4(4), oct 27 2022. https://hdsr.mitpress.mit.edu/pub/zkib7xth.
|
| 194 |
+
|
| 195 |
+
[18] Wenlong Huang, Pieter Abbeel, Deepak Pathak, and Igor Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents. In International Conference on Machine Learning, pages 9118–9147. PMLR, 2022.
|
| 196 |
+
|
| 197 |
+
[19] Wenlong Huang, Fei Xia, Ted Xiao, Harris Chan, Jacky Liang, Pete Florence, Andy Zeng, Jonathan Tompson, Igor Mordatch, Yevgen Chebotar, Pierre Sermanet, Tomas Jackson, Noah Brown, Linda Luu, Sergey Levine, Karol Hausman, and brian ichter. Inner monologue: Embodied reasoning through planning with language models. In Karen Liu, Dana Kulic, and Jeff Ichnowski, editors, Proceedings of The 6th Conference on Robot Learning, volume 205 of Proceedings of Machine Learning Research, pages 1769–1782. PMLR, 14–18 Dec 2023.
|
| 198 |
+
|
| 199 |
+
[20] Anssi Kanervisto, Stephanie Milani, Karolis Ramanauskas, Nicholay Topin, Zichuan Lin, Junyou Li, Jianing Shi, Deheng Ye, Qiang Fu, Wei Yang, et al. Minerl diamond 2021 competition: Overview, results, and lessons learned. NeurIPS 2021 Competitions and Demonstrations Track, pages 13–28, 2022.
|
| 200 |
+
|
| 201 |
+
[21] Yash Kant, Arun Ramachandran, Sriram Yenamandra, Igor Gilitschenski, Dhruv Batra, Andrew Szot, and Harsh Agrawal. Housekeep: Tidying virtual households using commonsense reasoning. In Computer Vision – ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XXXIX, page 355–373, Berlin, Heidelberg, 2022. Springer-Verlag.
|
| 202 |
+
|
| 203 |
+
[22] James Kirkpatrick, Razvan Pascanu, Neil Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka Grabska-Barwinska, et al. Overcoming catastrophic forgetting in neural networks. Proceedings of the national academy of sciences, 114(13):3521–3526, 2017.
|
| 204 |
+
|
| 205 |
+
[23] Eric Kolve, Roozbeh Mottaghi, Winson Han, Eli VanderBilt, Luca Weihs, Alvaro Herrasti, Matt Deitke, Kiana Ehsani, Daniel Gordon, Yuke Zhu, et al. Ai2-thor: An interactive 3d environment for visual ai. arXiv preprint arXiv:1712.05474, 2017.
|
| 206 |
+
|
| 207 |
+
[24] Liunian Harold Li, Mark Yatskar, Da Yin, Cho-Jui Hsieh, and Kai-Wei Chang. Visualbert: A simple and performant baseline for vision and language. arXiv preprint arXiv:1908.03557, 2019.
|
| 208 |
+
|
| 209 |
+
[25] Shuang Li, Xavier Puig, Chris Paxton, Yilun Du, Clinton Wang, Linxi Fan, Tao Chen, De-An Huang, Ekin Akyürek, Anima Anandkumar, et al. Pre-trained language models for interactive decision-making. Advances in Neural Information Processing Systems, 35:31199–31212, 2022.
|
| 210 |
+
|
| 211 |
+
[26] Chin-Yew Lin. Rouge: A package for automatic evaluation of summaries. In Text summarization branches out, pages 74–81, 2004.
|
| 212 |
+
|
| 213 |
+
[27] Zichuan Lin, Junyou Li, Jianing Shi, Deheng Ye, Qiang Fu, and Wei Yang. Juewu-mc: Playing minecraft with sample-efficient hierarchical reinforcement learning. arXiv preprint arXiv:2112.04907, 2021.
|
| 214 |
+
|
| 215 |
+
[28] Jiacheng Liu, Skyler Hallinan, Ximing Lu, Pengfei He, Sean Welleck, Hannaneh Hajishirzi, and Yejin Choi. Rainier: Reinforced knowledge introspector for commonsense question answering. arXiv preprint arXiv:2210.03078, 2022.
|
| 216 |
+
|
| 217 |
+
[29] Ruibo Liu, Jason Wei, Shixiang Shane Gu, Te-Yen Wu, Soroush Vosoughi, Claire Cui, Denny Zhou, and Andrew M Dai. Mind’s eye: Grounded language model reasoning through simulation. arXiv preprint arXiv:2210.05359, 2022.
|
| 218 |
+
|
| 219 |
+
[30] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
|
| 220 |
+
|
| 221 |
+
[31] Ximing Lu, Sean Welleck, Jack Hessel, Liwei Jiang, Lianhui Qin, Peter West, Prithviraj Ammanabrolu, and Yejin Choi. Quark: Controllable text generation with reinforced unlearning. Advances in neural information processing systems, 35:27591–27609, 2022.
|
| 222 |
+
|
| 223 |
+
[32] Michael McCloskey and Neal J Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. In Psychology of learning and motivation, volume 24, pages 109–165. Elsevier, 1989.
|
| 224 |
+
|
| 225 |
+
[33] Reiichiro Nakano, Jacob Hilton, Suchir Balaji, Jeff Wu, Long Ouyang, Christina Kim, Christopher Hesse, Shantanu Jain, Vineet Kosaraju, William Saunders, et al. Webgpt: Browser-assisted question-answering with human feedback. arXiv preprint arXiv:2112.09332, 2021.
|
| 226 |
+
|
| 227 |
+
[34] OpenAI. Gpt-4 technical report. ArXiv, abs/2303.08774, 2023.
|
| 228 |
+
|
| 229 |
+
[35] Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35:27730–27744, 2022.
|
| 230 |
+
|
| 231 |
+
[36] Xavier Puig, Kevin Ra, Marko Boben, Jiaman Li, Tingwu Wang, Sanja Fidler, and Antonio Torralba. Virtualhome: Simulating household activities via programs. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 8494–8502, 2018.
|
| 232 |
+
|
| 233 |
+
[37] Xavier Puig, Tianmin Shu, Shuang Li, Zilin Wang, Yuan-Hong Liao, Joshua B. Tenenbaum, Sanja Fidler, and Antonio Torralba. Watch-and-help: A challenge for social perception and human-{ai} collaboration. In International Conference on Learning Representations, 2021.
|
| 234 |
+
|
| 235 |
+
[38] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International conference on machine learning, pages 8748–8763. PMLR, 2021.
|
| 236 |
+
|
| 237 |
+
[39] Joshua Robinson, Christopher Michael Rytting, and David Wingate. Leveraging large language models for multiple choice question answering. arXiv preprint arXiv:2210.12353, 2022.
|
| 238 |
+
|
| 239 |
+
[40] Paul-Edouard Sarlin, Daniel DeTone, Tomasz Malisiewicz, and Andrew Rabinovich. Superglue: Learning feature matching with graph neural networks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 4938–4947, 2020.
|
| 240 |
+
|
| 241 |
+
[41] Manolis Savva, Angel X Chang, Alexey Dosovitskiy, Thomas Funkhouser, and Vladlen Koltun. Minos: Multimodal indoor simulator for navigation in complex environments. arXiv preprint arXiv:1712.03931, 2017.
|
| 242 |
+
|
| 243 |
+
[42] Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language models can teach themselves to use tools. arXiv preprint arXiv:2302.04761, 2023.
|
| 244 |
+
|
| 245 |
+
[43] Freda Shi, Xinyun Chen, Kanishka Misra, Nathan Scales, David Dohan, Ed Chi, Nathanael Schärli, and Denny Zhou. Large language models can be easily distracted by irrelevant context. arXiv preprint arXiv:2302.00093, 2023.
|
| 246 |
+
|
| 247 |
+
[44] David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484–489, 2016.
|
| 248 |
+
|
| 249 |
+
[45] Ishika Singh, Valts Blukis, Arsalan Mousavian, Ankit Goyal, Danfei Xu, Jonathan Tremblay, Dieter Fox, Jesse Thomason, and Animesh Garg. Progprompt: Generating situated robot task plans using large language models. In Workshop on Language and Robotics at CoRL 2022, 2022.
|
| 250 |
+
|
| 251 |
+
[46] Nisan Stiennon, Long Ouyang, Jeffrey Wu, Daniel Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul F Christiano. Learning to summarize with human feedback. Advances in Neural Information Processing Systems, 33:3008–3021, 2020.
|
| 252 |
+
|
| 253 |
+
[47] Alessandro Suglia, Qiaozi Gao, Jesse Thomason, Govind Thattai, and Gaurav Sukhatme. Embodied bert: A transformer model for embodied, language-guided visual task completion. arXiv preprint arXiv:2108.04927, 2021.
|
| 254 |
+
|
| 255 |
+
[48] Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
|
| 256 |
+
[49] Ben Wang and Aran Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
|
| 257 |
+
[50] Zihao Wang, Shaofei Cai, Anji Liu, Xiaojian Ma, and Yitao Liang. Describe, explain, plan and select: Interactive planning with large language models enables open-world multi-task agents. arXiv preprint arXiv:2302.01560, 2023.
|
| 258 |
+
[51] Jason Weston, Antoine Bordes, Sumit Chopra, Alexander M Rush, Bart Van Merriënboer, Armand Joulin, and Tomas Mikolov. Towards ai-complete question answering: A set of prerequisite toy tasks. In 4th International Conference on Learning Representations, ICLR 2016, 2016.
|
| 259 |
+
[52] Jeff Wu, Long Ouyang, Daniel M Ziegler, Nisan Stiennon, Ryan Lowe, Jan Leike, and Paul Christiano. Recursively summarizing books with human feedback. arXiv preprint arXiv:2109.10862, 2021.
|
| 260 |
+
[53] Yi Wu, Yuxin Wu, Georgia Gkioxari, and Yuandong Tian. Building generalizable agents with a realistic and rich 3d environment. arXiv preprint arXiv:1801.02209, 2018.
|
| 261 |
+
[54] Jiannan Xiang, Zhengzhong Liu, Yucheng Zhou, Eric Xing, and Zhiting Hu. ASDOT: Any-shot data-to-text generation with pretrained language models. In Findings of the Association for Computational Linguistics: EMNLP 2022, pages 1886–1899, Abu Dhabi, United Arab Emirates, December 2022. Association for Computational Linguistics.
|
| 262 |
+
[55] Jiannan Xiang, Xin Wang, and William Yang Wang. Learning to stop: A simple yet effective approach to urban vision-language navigation. In Findings of the Association for Computational Linguistics: EMNLP 2020, pages 699–707, 2020.
|
| 263 |
+
[56] Claudia Yan, Dipendra Misra, Andrew Bennnett, Aaron Walsman, Yonatan Bisk, and Yoav Artzi. Chalet: Cornell house agent learning environment. arXiv preprint arXiv:1801.07357, 2018.
|
| 264 |
+
[57] Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. ReAct: Synergizing reasoning and acting in language models. In International Conference on Learning Representations (ICLR), 2023.
|
| 265 |
+
[58] Rowan Zellers, Ari Holtzman, Matthew E Peters, Roozbeh Mottaghi, Aniruddha Kembhavi, Ali Farhadi, and Yejin Choi. PIGLeT: Language grounding through neuro-symbolic interaction in a 3d world. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 2040–2050, 2021.
|
| 266 |
+
[59] Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, et al. Opt: Open pre-trained transformer language models. arXiv preprint arXiv:2205.01068, 2022.
|
| 267 |
+
[60] Daniel M Ziegler, Nisan Stiennon, Jeffrey Wu, Tom B Brown, Alec Radford, Dario Amodei, Paul Christiano, and Geoffrey Irving. Fine-tuning language models from human preferences. arXiv preprint arXiv:1909.08593, 2019.
|
| 268 |
+
|
| 269 |
+
<table><tr><td>Action</td><td>Template</td></tr><tr><td>[Find] <Object></td><td>Find Object</td></tr><tr><td>[Walk] <0bject></td><td>Walk to Object</td></tr><tr><td>[Run] <Object></td><td>Run to Object</td></tr><tr><td>[Sit] <Object></td><td>Sit on Object</td></tr><tr><td>[StandUp]</td><td> Stand up</td></tr><tr><td>[Grab] <0bject></td><td>Grab Object</td></tr><tr><td>[Open] <Object></td><td></td></tr><tr><td>[Ciose] <Object></td><td>Open Object</td></tr><tr><td>[Put] <0bject_1> <0bject_2></td><td>Close Object</td></tr><tr><td></td><td>Put Object_1 on Object_2</td></tr><tr><td>[PutIn] <Object_1> <0bject_2></td><td>Put Ojbect_1 in Object_2</td></tr><tr><td>[SwitchOn] <Object></td><td>Switch/Turn on Object</td></tr><tr><td>[SwitchOff] <Object></td><td>Switch/Turn off Ojbect</td></tr><tr><td>[Drink] <Object></td><td>Drink Object</td></tr><tr><td>[TurnTo] <Object></td><td>Turn to Object</td></tr><tr><td>[LookAt] <Object></td><td>Look at Object</td></tr><tr><td>[Wipe] <Object></td><td>Wipe Object</td></tr><tr><td>[PutOn] <0bject></td><td>Put on Object</td></tr><tr><td>[PutOff] <Object></td><td>Put off Object</td></tr><tr><td>[Greet] <Object></td><td>Greet Object</td></tr><tr><td>[Drop] <Object></td><td>Drop Object</td></tr><tr><td>[Touch] <Object></td><td></td></tr><tr><td>[Lie] <0bject></td><td>Touch Object</td></tr><tr><td>[Pour] <0bject_1> <0bject_2></td><td>Lie on Object</td></tr><tr><td></td><td>Pour Object_1 into Object_2</td></tr><tr><td>[Type] <Object></td><td>Type Object</td></tr><tr><td>[Watch] <Object></td><td>Watch Object</td></tr><tr><td>[Move] <Object></td><td>Move Object</td></tr><tr><td>[Wash] <Object></td><td>Wash Object</td></tr><tr><td>[Rinse] <Object></td><td>Rinse Object</td></tr><tr><td>[Scrub] <Object></td><td>Scrub Object</td></tr><tr><td>[Squeeze] <0bject></td><td>Squeeze Object</td></tr><tr><td>[PlugIn] <Object></td><td>Plug in Object</td></tr><tr><td>[PlugOut] <Object></td><td>Plug out Object</td></tr><tr><td>[Cut] <0bject></td><td>Cut Object</td></tr><tr><td>[Eat] <Object></td><td>Eat Object</td></tr><tr><td>[Sleep]</td><td>Sleep</td></tr><tr><td>[WakeUp]</td><td>Wake up</td></tr></table>
|
| 270 |
+
|
| 271 |
+
Table 4: Supported actions in VirtualHome and their corresponding text templates.
|
| 272 |
+
|
| 273 |
+
# A Appendix
|
| 274 |
+
|
| 275 |
+
# A.1 VirtualHome
|
| 276 |
+
|
| 277 |
+
The complete format of an executable action step in VirtualHome is <char{char_id}> [Action] <Object> (Object_id). Specifically, char_id specifies which agent to execute the action when multiple agents are in the world model at the same time. Action should be a supported atomic action in VirtualHome. Object is the object with which the agent interacts. Each object in the environment is assigned an Object_id to distinguish it from others of the same object class. We designed a template for each action to transform them into natural text for LMs finetuing. The full list of executable actions can be found in Table 4. Note that in the list, we omit <char{char_id}> and (Object_id) for simplicity.
|
| 278 |
+
|
| 279 |
+
# A.2 Acitivity Goal And Predicate
|
| 280 |
+
|
| 281 |
+
The goal of an household activity in VirtualHome consists of several predicates. Each predicate represents a condition of one object or a relation between two objects. For example, OPEN(coffe
|
| 282 |
+
|
| 283 |
+
maker) means the coffee maker is open, and ON(apple, table) means an apple is on the table. The goal is only achieved when all the predicates are achieved. We collected activities and goals from RobotHow.
|
| 284 |
+
|
| 285 |
+
# A.3 Data Format and Prompts
|
| 286 |
+
|
| 287 |
+
Following Chung et al. [8], we use instructions with in-context exemplars as prompts. Specifically, the instruction, the question context, and the answer will be provided in each exemplar, and the full prompt will contain multiple such exemplars for in-context learning. The format of the data and the exemplar for each task is provided below.
|
| 288 |
+
|
| 289 |
+
# A.3.1 Plan Generation
|
| 290 |
+
|
| 291 |
+
# Data Example
|
| 292 |
+
|
| 293 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>activity</td><td>watch TV</td></tr><tr><td>condition plan</td><td>living room,sofa,TV.The sofa and TV are in the living room. Walk to living room.Sit on sofa. Watch TV.</td></tr></table>
|
| 294 |
+
|
| 295 |
+
# In-context Exemplar
|
| 296 |
+
|
| 297 |
+
Q: How to {{ activity }}? Given items include {{ condition }} A: {{ plan }}
|
| 298 |
+
|
| 299 |
+
# A.3.2 Housework QA
|
| 300 |
+
|
| 301 |
+
# Data Example
|
| 302 |
+
|
| 303 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>activity</td><td>watch TV</td></tr><tr><td>choices</td><td>[TV,coffee,bed,toothbrush]</td></tr><tr><td>answer</td><td>TV</td></tr></table>
|
| 304 |
+
|
| 305 |
+
# In-context Exemplar
|
| 306 |
+
|
| 307 |
+
Question: To {{ activity }}, a possibly related item could be Answer: {{ answer }}
|
| 308 |
+
|
| 309 |
+
# A.3.3 Negation Housework QA
|
| 310 |
+
|
| 311 |
+
# Data Example
|
| 312 |
+
|
| 313 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>activity</td><td>watch TV</td></tr><tr><td>choices</td><td>[TV,sofa,living room,toothbrush]</td></tr><tr><td>answer</td><td>toothbrush</td></tr></table>
|
| 314 |
+
|
| 315 |
+
# In-context Exemplar
|
| 316 |
+
|
| 317 |
+
Question: To {{ activity }}, an unrelated item could be Answer: {{ answer }}
|
| 318 |
+
|
| 319 |
+
# A.3.4 Activity Recognition
|
| 320 |
+
|
| 321 |
+
# Data Example
|
| 322 |
+
|
| 323 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>plan choices activity</td><td>Walk to living room.Sit on sofa. Watch TV. [watch TV,make coffee,sleep,brush teeth] watch TV</td></tr></table>
|
| 324 |
+
|
| 325 |
+
# In-context Exemplar
|
| 326 |
+
|
| 327 |
+
Given a task plan: {{ plan }} Question: what is the name of this task? Answer: {{ answer }}
|
| 328 |
+
|
| 329 |
+
# A.3.5 Activity Inference
|
| 330 |
+
|
| 331 |
+
# Data Example
|
| 332 |
+
|
| 333 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>state</td><td>Tom is sitting on the sofa. Tom is facing the TV.</td></tr><tr><td>choices</td><td>[watch TV,make coffee,sleep,brush teeth]</td></tr><tr><td>activity</td><td>watch TV</td></tr></table>
|
| 334 |
+
|
| 335 |
+
# In-context Exemplar
|
| 336 |
+
|
| 337 |
+
{{ state }}
|
| 338 |
+
Question: given the above state, a possible activity could be
|
| 339 |
+
Answer: {{ answer }}
|
| 340 |
+
|
| 341 |
+
# A.3.6 Counting
|
| 342 |
+
|
| 343 |
+
Data Example
|
| 344 |
+
|
| 345 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>movement</td><td>Tom was at home. He grabbed an apple and put it on the bookshelf. He then walked to the kitchen and srcub a plate. He went back to bookshelf and put the plate on it.</td></tr><tr><td>location number</td><td>bookshelf</td></tr><tr><td>items</td><td>2 apple,plate</td></tr></table>
|
| 346 |
+
|
| 347 |
+
# In-context Exemplar
|
| 348 |
+
|
| 349 |
+
Given a sequence of actions in a house, and a question about what items are located in a specific place. Answer the number of items and list the items.
|
| 350 |
+
|
| 351 |
+
Q: {{ movement }} How many items are there on the {{ location }}? A: Ther are {{ number }} itmes on the {{ location }}. They are {{ items }}
|
| 352 |
+
|
| 353 |
+
A.3.7 Counting QA Data Example
|
| 354 |
+
|
| 355 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>movement</td><td>Tom was at home. He grabbed an apple and put it on the bookshelf. He then walked to the kitchen and srcub a plate. He went back to bookshelf and put the plate on it.</td></tr><tr><td>location number</td><td>bookshelf 2</td></tr></table>
|
| 356 |
+
|
| 357 |
+
# In-context Exemplar
|
| 358 |
+
|
| 359 |
+
Q: {{ movement }} How many items are there on the {{ location }}? A: {{ number }}
|
| 360 |
+
|
| 361 |
+
# A.3.8 Object Path Tracking
|
| 362 |
+
|
| 363 |
+
# Data Example
|
| 364 |
+
|
| 365 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>movement</td><td>Tom went to the kitchen. Mary walked into the dining room. Tom grabbed a plate. Tom travelled to the living room. Mary moved to the living room. Tom put the plate on the table. Mary grabbed the</td></tr><tr><td></td><td>plate. Mary journeyed to the bedroom.</td></tr><tr><td>object</td><td>plate</td></tr><tr><td>path</td><td>kitchen,living room,bedroom</td></tr><tr><td></td><td></td></tr></table>
|
| 366 |
+
|
| 367 |
+
# In-context Exemplar
|
| 368 |
+
|
| 369 |
+
{{ movement }}
|
| 370 |
+
Question: What is the order of the rooms where the {{ object }} appeared?
|
| 371 |
+
Answer: {{ path }}
|
| 372 |
+
|
| 373 |
+
# A.3.9 Object Location QA
|
| 374 |
+
|
| 375 |
+
Data Example
|
| 376 |
+
|
| 377 |
+
<table><tr><td>Key</td><td>Value</td></tr><tr><td>movement</td><td>Tom went to the kitchen. Mary walked into the dining room. Tom grabbed a plate. Tom travelled to the living room. Mary moved to the living room. Tom put the plate on the table. Mary grabbed the</td></tr><tr><td>object</td><td>plate. Mary journeyed to the bedroom. plate</td></tr><tr><td>reference_room</td><td>iiving room before</td></tr><tr><td>preposition answer</td><td></td></tr></table>
|
| 378 |
+
|
| 379 |
+
# In-context Exemplar
|
| 380 |
+
|
| 381 |
+
{{ movement }}
|
| 382 |
+
Question: Where is the {{ object }} {{ preposition }} the {{ reference_room }}?
|
| 383 |
+
Answer: {{ answer }}
|
| 384 |
+
|
| 385 |
+
# A.4 Hyperparameters
|
| 386 |
+
|
| 387 |
+
For both GPT-Neo-1.3B and GPT-J-6B, we use a learning rate of $8 \times 1 0 ^ { - 5 }$ and a batch size of 20. The weights for plan generation, activity recognition, counting, and object path tracking are 1.0, 0.7, 1.0, and 1.0, respectively. We trained GPT-Neo-1.3B for 3 epochs with the EWC coefficient $\lambda = 0 . 5$ in Equation 4. For GPT-J-6B, we trained it for 5 epochs with $\lambda = 2$ . With our approach, it takes 40 minutes to train a GPT-Neo and 220 minutes to train a GPT-J. We used a rank of 8 and coefficient of 32 for LoRA’s hyperparameters.
|
| 388 |
+
|
| 389 |
+
# A.5 bAbI Dataset
|
| 390 |
+
|
| 391 |
+
We include 8 tasks from bAbI that test embodied knowledge. They are: One Supporting Fact, Two Supporting Fact, Three Supporting Fact, Counting, Lists/Sets, Simple Negation, Time Reasoning, Positional Reasoning. Examples for each task are shown in Table 5.
|
| 392 |
+
|
| 393 |
+
# Task 1: Single Supporting Fact
|
| 394 |
+
|
| 395 |
+
Mary went to the bathroom. John moved to the hallway. Mary travelled to the office. Where is Mary? A:office
|
| 396 |
+
|
| 397 |
+
# Task 2: Two Supporting Facts
|
| 398 |
+
|
| 399 |
+
John is in the playground. John picked up the football. Bob went to the kitchen. Where is the football? A:playground
|
| 400 |
+
|
| 401 |
+
# Task 3: Three Supporting Facts
|
| 402 |
+
|
| 403 |
+
John picked up the apple.
|
| 404 |
+
John went to the office.
|
| 405 |
+
John went to the kitchen.
|
| 406 |
+
John dropped the apple.
|
| 407 |
+
Where was the apple before the kitchen? A:office
|
| 408 |
+
|
| 409 |
+
# Task 4: Counting
|
| 410 |
+
|
| 411 |
+
Daniel picked up the football.
|
| 412 |
+
Daniel dropped the football.
|
| 413 |
+
Daniel got the milk.
|
| 414 |
+
Daniel took the apple. A: office
|
| 415 |
+
How many objects is Daniel holding? A: two
|
| 416 |
+
|
| 417 |
+
# Task 5: Lists/Sets
|
| 418 |
+
|
| 419 |
+
Daniel picks up the football. Daniel drops the newspaper. Daniel picks up the milk. What is Daniel holding? milk, football
|
| 420 |
+
|
| 421 |
+
# Task 6: Simple Negation
|
| 422 |
+
|
| 423 |
+
Sandra travelled to the office. Fred is no longer in the office. Is Fred in the office? A:no Is Sandra in the office? A:yes
|
| 424 |
+
|
| 425 |
+
# Task 7: Time Reasoning
|
| 426 |
+
|
| 427 |
+
In the afternoon Julie went to the park. Yesterday Julie was at school. Julie went to the cinema this evening. Where did Julie go after the park? A:cinema Where was Julie before the park? A:school
|
| 428 |
+
|
| 429 |
+
# Task 8: Positional Reasoning
|
| 430 |
+
|
| 431 |
+
The triangle is to the right of the blue square. The red square is on top of the blue square. The red sphere is to the right of the blue square. Is the red sphere to the right of the blue square? A:yes Is the red square to the left of the triangle? A:yes
|
| 432 |
+
|
| 433 |
+
Table 5: Examples for bAbI tasks.
|
| 434 |
+
|
| 435 |
+
# A.6 Results of Main Experiments and Ablation Studies
|
| 436 |
+
|
| 437 |
+
Experimental results on our constructed downstream tasks are shown in Table 6, and the results on bAbI are shown in Table 7. We also show the results of ablation studies in Table 8.
|
| 438 |
+
|
| 439 |
+
# A.7 Human Evaluations
|
| 440 |
+
|
| 441 |
+
We conduct human evaluations on plan generation for GPT-J model. Following Huang et al. [18] we asked 3 people to annotate whether each task can be completed using a generated plan. We randomly sampled 150 tasks and asked each person to annotate 50 of them. The Results show that the base GPT-J model can only achieve $2 4 . 0 \%$ accuracy, while the finetuned model can achieve $6 2 . 4 \%$ . The higher planning accuracy demonstrates the superior task planning ability of our model.
|
| 442 |
+
|
| 443 |
+
# A.8 SuperGLUE Results
|
| 444 |
+
|
| 445 |
+
We evaluate the base GPT-J model and our finetuned model on appropriate SuperGLUE tasks, e.g., that can be formulated as a multi-choice QA task without prompt engineering. Our model’s performance matches and even outperforms the baseline, showing our model retains the general language capability.
|
| 446 |
+
|
| 447 |
+
Table 6: Experimental results on various downstream evaluation tasks. The best result among baselines and our method is shown in bold, and the best result among all the models is underlined.
|
| 448 |
+
|
| 449 |
+
<table><tr><td rowspan="2">Task</td><td rowspan="2">Metric</td><td colspan="2">GPT-Neo</td><td colspan="3">GPT-J</td><td colspan="2">OPT-13B</td><td colspan="2">LLaMA-13B</td><td>ChatGPT</td></tr><tr><td>Base</td><td>Ours</td><td>Base</td><td>FT</td><td>Ours</td><td>Base</td><td>Ours</td><td>Base</td><td>Ours</td><td>(GPT3.5-turbo)</td></tr><tr><td>Plan Generation</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>-Vanilla Seen</td><td>Rouge-L</td><td>21.25</td><td>49.70</td><td>34.31</td><td>47.98</td><td>51.23</td><td>36.00</td><td>50.15</td><td>41.77</td><td>52.05</td><td>40.57</td></tr><tr><td>-Vanilla UnSeen</td><td>Rouge-L</td><td>17.64</td><td>49.27</td><td>34.22</td><td>47.86</td><td>49.58</td><td>29.34</td><td>45.11</td><td>38.78</td><td>47.44</td><td>41.01</td></tr><tr><td>-Confusing Seen</td><td>Rouge-L</td><td>16.86</td><td>46.88</td><td>34.81</td><td>47.59</td><td>48.94</td><td>31.92</td><td>49.87</td><td>40.33</td><td>51.00</td><td>40.41</td></tr><tr><td>-Confusing Unseen</td><td>Rouge-L</td><td>17.05</td><td>42.34</td><td>32.98</td><td>44.43</td><td>45.60</td><td>36.98</td><td>47.93</td><td>41.73</td><td>50.49</td><td>40.97</td></tr><tr><td>Housework QA</td><td>Accuracy</td><td>70.11</td><td>72.41</td><td>77.78</td><td>51.34</td><td>85.44</td><td>81.61</td><td>84.29</td><td>81.99</td><td>86.59</td><td>83.91</td></tr><tr><td>Negation Housework QA</td><td>Accuracy</td><td>38.27</td><td>41.98</td><td>35.19</td><td>33.33</td><td>39.51</td><td>43.21</td><td>40.21</td><td>43.21</td><td>30.25</td><td>87.65</td></tr><tr><td>Activity Recognition</td><td>Accuracy</td><td>69.22</td><td>85.43</td><td>87.98</td><td>71.41</td><td>88.52</td><td>89.07</td><td>91.44</td><td>90.53</td><td>91.80</td><td>95.05</td></tr><tr><td>Activity Inference</td><td>Accuracy</td><td>56.49</td><td>66.03</td><td>69.08</td><td>70.99</td><td>74.43</td><td>67.94</td><td>70.61</td><td>74.05</td><td>68.32</td><td>83.59</td></tr><tr><td>Counting</td><td>Accuracy</td><td>22.68</td><td>28.87</td><td>30.41</td><td>16.49</td><td>67.01</td><td>20.01</td><td>62.37</td><td>29.38</td><td>79.38</td><td>66.49</td></tr><tr><td>Object Path Tracking</td><td>LCS</td><td>30.80</td><td>85.91</td><td>33.86</td><td>46.25</td><td>98.67</td><td>33.49</td><td>96.28</td><td>38.82</td><td>96.99</td><td>59.53</td></tr><tr><td>Object Location QA</td><td>Accuracy</td><td>22.50</td><td>33.50</td><td>30.00</td><td>22.50</td><td>34.50</td><td>37.00</td><td>33.00</td><td>28.50</td><td>79.00</td><td>67.50</td></tr></table>
|
| 450 |
+
|
| 451 |
+
<table><tr><td rowspan="2">Task</td><td colspan="2">GPT-Neo</td><td colspan="2">GPT-J</td><td rowspan="2">ChatGPT</td></tr><tr><td>Base</td><td>Ours</td><td>Base</td><td>Ours</td></tr><tr><td>Single Supporting Fact</td><td>51.86</td><td>56.29</td><td>65.16</td><td>68.98</td><td>96.27</td></tr><tr><td>Two Supporting Fact</td><td>33.43</td><td>30.82</td><td>40.48</td><td>26.08</td><td>47.33</td></tr><tr><td>Three Supporting Fact</td><td>7.85</td><td>13.49</td><td>22.46</td><td>30.41</td><td>16.82</td></tr><tr><td>Counting</td><td>34.04</td><td>48.84</td><td>41.39</td><td>69.08</td><td>93.96</td></tr><tr><td>Lists/Sets</td><td>14.80</td><td>51.76</td><td>34.74</td><td>84.99</td><td>76.84</td></tr><tr><td>Simple Negation</td><td>36.05</td><td>65.56</td><td>42.80</td><td>63.95</td><td>93.66</td></tr><tr><td>Time Reasoning</td><td>21.45</td><td>23.46</td><td>36.96</td><td>59.42</td><td>61.63</td></tr><tr><td>Positional Reasoning</td><td>50.51</td><td>53.64</td><td>49.70</td><td>53.23</td><td>58.38</td></tr></table>
|
| 452 |
+
|
| 453 |
+
Table 7: Experimental results on bAbI test sets.
|
| 454 |
+
|
| 455 |
+
Table 8: Ablation experimental results on training tasks.
|
| 456 |
+
|
| 457 |
+
<table><tr><td></td><td colspan="6">GPT-Neo</td></tr><tr><td></td><td>Base</td><td>Ours</td><td>-w/o Plan Gen</td><td>-w/o Act Recog</td><td> -w/o Count</td><td>-w/o Obj PT</td></tr><tr><td>Plan Gen</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>-Vanilla/Seen</td><td>21.25</td><td>49.70</td><td>14.48</td><td>49.38</td><td>49.85</td><td>50.06</td></tr><tr><td>-Vanilla / Unseen</td><td>17.64</td><td>49.27</td><td>14.28</td><td>48.96</td><td>51.16</td><td>49.02</td></tr><tr><td>-Confusing /Seen</td><td>16.86</td><td>46.88</td><td>13.63</td><td>46.37</td><td>48.30</td><td>49.14</td></tr><tr><td>-Confusing / Unseen</td><td>17.05</td><td>42.34</td><td>9.86</td><td>43.79</td><td>46.28</td><td>44.64</td></tr><tr><td>QA</td><td>70.11</td><td>72.41</td><td>73.18</td><td>71.26</td><td>74.71</td><td>70.11</td></tr><tr><td>Neg QA</td><td>38.27</td><td>41.98</td><td>32.72</td><td>35.80</td><td>36.42</td><td>38.89</td></tr><tr><td>Act Recog</td><td>69.22</td><td>85.43</td><td>85.97</td><td>48.63</td><td>85.25</td><td>84.34</td></tr><tr><td>Act Infer</td><td>56.49</td><td>66.03</td><td>66.03</td><td>58.40</td><td>64.89</td><td>62.21</td></tr><tr><td>Count</td><td>22.68</td><td>28.87</td><td>18.56</td><td>25.26</td><td>35.05</td><td>32.99</td></tr><tr><td>Obj PT</td><td>30.80</td><td>85.91</td><td>92.13</td><td>84.17</td><td>86.46</td><td>29.90</td></tr><tr><td>Obj QA</td><td>22.50</td><td>33.50</td><td>35.00</td><td>49.00</td><td>43.50</td><td>22.00</td></tr><tr><td>Perplexity</td><td>4.120*</td><td>4.193</td><td>4.171</td><td>4.151</td><td>4.162</td><td>4.164</td></tr></table>
|
| 458 |
+
|
| 459 |
+
<table><tr><td>Model</td><td>BoolQ</td><td>CB</td><td>RTE</td><td>AX-g</td><td>AX-b</td><td>COPA</td></tr><tr><td>GPT-J</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>- Base</td><td>45.20</td><td>41.07</td><td>47.29</td><td>50.00</td><td>57.50</td><td>59.00</td></tr><tr><td>- Ours</td><td>66.00</td><td>41.07</td><td>58.84</td><td>53.37</td><td>54.00</td><td>62.00</td></tr></table>
|
| 460 |
+
|
| 461 |
+
Table 9: Results on SuperGLUE subset.
|
| 462 |
+
|
| 463 |
+
# A.9 Broader Impact
|
| 464 |
+
|
| 465 |
+
Like other generation systems, the language model trained by our approach is susceptible to producing unintended output when confronted with harmful input, such as unethical text or input intended for adversarial attacks. Therefore, we strongly advise against utilizing our approach outside of controlled research environments until these risks have been mitigated. It is important to note that a thoughtless deployment of our method could potentially enable malicious exploitation of the underlying language models. Thus, precautions, such as implementing a filtering mechanism, must be taken.
|
md/dev/T0GpzBQ1Fg6/T0GpzBQ1Fg6.md
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# STEP-UNROLLED DENOISING AUTOENCODERS FOR TEXT GENERATION
|
| 2 |
+
|
| 3 |
+
Nikolay Savinov\* Junyoung Chung\* Mikołaj Binkowski ´ \* Erich Elsen Aaron van den Oord ¨ DeepMind, London, UK
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
In this paper we propose a new generative model of text, Step-unrolled Denoising Autoencoder (SUNDAE), that does not rely on autoregressive models. Similarly to denoising diffusion techniques, SUNDAE is repeatedly applied on a sequence of tokens, starting from random inputs and improving them each time until convergence. We present a simple new improvement operator that converges in fewer iterations than diffusion methods, while qualitatively producing better samples on natural language datasets. SUNDAE achieves state-of-the-art results (among non-autoregressive methods) on the WMT’14 English-to-German translation task and good qualitative results on unconditional language modeling on the Colossal Cleaned Common Crawl dataset and a dataset of Python code from GitHub. The non-autoregressive nature of SUNDAE opens up possibilities beyond left-to-right prompted generation, by filling in arbitrary blank patterns in a template.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Autoregressive (AR) models have shown excellent results in generating text (e.g., GPT-3, Brown et al., 2020). However, while their training scales very well, sampling is prohibitively slow for many practical applications. Moreover, there are limitations to the kinds of conditioning AR models can seamlessly handle: the left-to-right restriction makes it hard to “fill in the gaps” in a partially written text draft. Even more importantly, this prohibits iterative refinement of complete text drafts to make them more self-consistent, which is a common task for human writers. Finally, AR models require network architectures to be causal, severely limiting the kinds of neural network architectures that can be used for text-modeling. All of these motivated the machine learning community to make extensive efforts to propose alternatives to AR models.
|
| 12 |
+
|
| 13 |
+
Machine translation (MT) was perhaps one of the first tasks where non-AR approaches were shown to seriously rival the AR-based state of the art: methods like CMLM (Ghazvininejad et al., 2019) and DisCo (Kasai et al., 2020) show promising results and their decoding speed is excellent compared to AR. However, while their performance is competitive, they are still behind the AR benchmark and actually require distillation of a larger AR model — without which, performance drops considerably.
|
| 14 |
+
|
| 15 |
+
Non-AR methods have proven hard to apply to the general unconditional language modeling (LM) task. When there is no conditioning, the multi-modality problem becomes paramount, as shown by Gu et al. (2017), which likely makes it problematic to use methods like CMLM and DisCo because their decoding mechanism is deterministic and does not model uncertainty. Yet, recently the community has seen promising results from non-AR models like Multinomial Diffusion (Hoogeboom et al., 2021) and D3PM (Austin et al., 2021). These methods optimize a lower bound (ELBO) on likelihoods and have shown negative log-likelihood (NLL) results approaching AR models on several benchmarks like text8 (Mahoney, 2011) and LM1B (Chelba et al., 2013). However, a major gap in NLL persists, and samples from those models lack coherence.
|
| 16 |
+
|
| 17 |
+
In this paper we propose a novel non-autoregressive method which shows state-of-the-art results in machine translation on WMT’14 EN→DE raw data (without distillation from AR) amongst non-AR methods and good qualitative results on unconditional language modeling on the Colossal Clean Common Crawl (C4) dataset (Raffel et al., 2019) and a dataset of Python code from GitHub. Our model operates as a time-homogeneous Markov Chain similar to that of Lee et al. (2018): conditioned on the corrupted data, it tries to approximate the original uncorrupted samples by a per-token factorised distribution. During generation, we unroll the chain by sampling from the transition distribution and feeding samples back into the input. We propose a new training mechanism called unrolled denoising, which uses unrolls of the chain during training as well, and which we empirically show to be crucial for practical performance of the algorithm in ablation studies. This feature motivates the name for the model, Step-unrolled Denoising Autoencoder (SUNDAE). The difference between usual denoising and unrolled denoising is illustrated in Figure 1.
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: The difference between denoising and unrolled denoising. Original text (top) is randomly corrupted, producing a text (middle) where some tokens are original (green) and others are corrupted (red). This text is denoised by sampling from the generative model to produce another noisy text (bottom). While standard denoising autoencoders only learn a mapping from the middle text to the top text, Step-unrolled Denoising Autoencoder learns a mapping from bottom to top (including middle as a special case of zero unroll steps). This has an intuitive meaning: during generation time, the network will mostly (right after the first step) encounter texts like the bottom one, not like the middle one — so unrolls prepare the model during training for inputs it will get at generation time.
|
| 21 |
+
|
| 22 |
+
To summarize our contributions:
|
| 23 |
+
|
| 24 |
+
• We present SUNDAE, a new generative model of text that unrolls the denoising process during training.
|
| 25 |
+
• SUNDAE achieves state-of-the-art results on WMT’14 English-to-German translation task among non-AR methods. We demonstrate good qualitative results for unconditional generation and inpainting on Colossal Clean Common Crawl dataset and a dataset of Python code from GitHub.
|
| 26 |
+
• We carefully ablate and analyze the properties of the proposed method, and show that unrolls during training are crucial for the model’s performance.
|
| 27 |
+
|
| 28 |
+
# 2 METHOD
|
| 29 |
+
|
| 30 |
+
We approach the problem of generative modelling of discrete sequences by bringing together the framework of denoising autoencoders and Markov chain models. In this section, we first discuss the definition of the generative model, and then describe the training process, which includes our main contribution, unrolled denoising.
|
| 31 |
+
|
| 32 |
+
For a fixed prior distribution $p _ { 0 }$ on some space $X$ consider a process $\mathbf { x } _ { t } \sim f _ { \theta } ( \cdot | \mathbf { x } _ { t - 1 } )$ , where $f _ { \theta }$ is a parametric transition function. Then $\{ { \bf { x } } _ { t } \} _ { t }$ is a time-homogeneous Markov chain, and transition $t$ -steps ahead has the following form1
|
| 33 |
+
|
| 34 |
+
$$
|
| 35 |
+
p _ { t } ( \pmb { x } _ { t } | \pmb { x } _ { 0 } ) = \sum _ { \substack { \pmb { x } _ { 1 } , \pmb { x } _ { 2 } , \ldots , \pmb { x } _ { t - 1 } \in X } } \ \prod _ { s = 1 } ^ { t } f _ { \theta } ( \pmb { x } _ { s } | \pmb { x } _ { s - 1 } ) .
|
| 36 |
+
$$
|
| 37 |
+
|
| 38 |
+
For a fixed number of steps $T$ , the prior $p _ { 0 }$ and decoder $p _ { T }$ together determine our model distribution $p _ { T } ( \mathbf { x } _ { T } ) = p _ { T } ( \mathbf { x } _ { T } \vert \mathbf { x } _ { 0 } ) p _ { 0 } ( \mathbf { x } _ { 0 } )$ .
|
| 39 |
+
|
| 40 |
+
We assume $X = \{ 1 , \ldots , v \} ^ { N }$ to be the space of sequences of length $N$ with values at all positions coming from a vocabulary of size $v$ , and the prior $p _ { 0 }$ to be uniform over $X$ . Let $p _ { \mathrm { d a t a } }$ be a distribution of the data and assume that $f _ { \theta }$ induces a conditional probability distribution $f _ { \boldsymbol { \theta } } ( \cdot | \boldsymbol { x } ^ { \prime } )$ that can be
|
| 41 |
+
|
| 42 |
+
factorised into a conditionally-indepedent product as follows:
|
| 43 |
+
|
| 44 |
+
$$
|
| 45 |
+
f _ { \theta } ( \pmb { x } | \pmb { x } ^ { \prime } ) = f _ { \theta } ^ { ( 1 ) } ( \pmb { x } ^ { ( 1 ) } | \pmb { x } ^ { \prime } ) f _ { \theta } ^ { ( 2 ) } ( \pmb { x } ^ { ( 2 ) } | \pmb { x } ^ { \prime } ) \cdot \cdot \cdot f _ { \theta } ^ { ( N ) } ( \pmb { x } ^ { ( N ) } | \pmb { x } ^ { \prime } ) , \qquad \mathrm { f o r } \ \pmb { x } , \pmb { x } ^ { \prime } \in X .
|
| 46 |
+
$$
|
| 47 |
+
|
| 48 |
+
Note that although for $t = 1$ the distribution $p _ { 1 } ( \cdot | \pmb { x } _ { 0 } )$ is limited by product structure (Eq. 2), the subsequent $p _ { t } \mathbf { s }$ are not restricted in the same way, and after each step they belong to potentially more and more expressive family.
|
| 49 |
+
|
| 50 |
+
# 2.1 TRAINING WITH UNROLLED DENOISING
|
| 51 |
+
|
| 52 |
+
Due to intractability of the likelihood of the model $p _ { T }$ as well as the computational requirements of optimising the whole chain $\{ p _ { t } \} _ { t }$ , we propose an efficient two-step training method which we term unrolled denosing and visualise in Figure 1. We consider a smaller number of steps than $T$ that we intend to use at sampling, but to compensate for that, we unroll the chain starting from corrupted data samples, rather than the prior $p _ { 0 }$ . This way, the model learns to denoise the samples it is likely to encounter during the full unroll used at sample time. While using a single step would resemble the training strategy of BERT (Devlin et al., 2018), using at least two steps is essential for the performance of our model.
|
| 53 |
+
|
| 54 |
+
Consider a corruption distribution $q ( \pmb { x } ^ { c } | \mathbf { x } )$ that replaces a random proportion of tokens in a sentence $\mathbf { x }$ with ones randomly sampled from a uniform distribution. Our objective is given by $L ^ { ( 1 : 2 ) } =$ $\begin{array} { r } { \frac { 1 } { 2 } \left( L ^ { ( 1 ) } + L ^ { ( 2 ) } \right) } \end{array}$ where
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
\begin{array} { r } { L ^ { ( t ) } ( \theta ) : = - \mathbb { E } \underset { \mathbf { x } _ { 0 } \sim q ( \cdot | \mathbf { x } ) } { \sim p _ { \mathrm { d a t a } } } ~ [ \log f _ { \theta } ( \mathbf { x } | \mathbf { x } _ { t - 1 } ) ] , } \\ { \quad \quad \quad \quad \quad \mathbf { x } _ { 1 } \sim f _ { \theta } ( \cdot | \mathbf { x } _ { 0 } ) } \\ { \quad \quad \quad \quad \mathbf { x } _ { t - 1 } \sim \dot { f } _ { \theta } ^ { \cdots } ( \cdot | \mathbf { x } _ { t - 2 } ) } \end{array}
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
i.e. the reconstruction loss of the chain after $t$ steps, starting from a corrupted sample $\mathbf { x } _ { \mathrm { 0 } }$ . In Appendix A.1 we show that $L ^ { ( t ) }$ is an upper bound on the actual negative log-likelihood from the model distribution $p _ { t }$ :
|
| 61 |
+
|
| 62 |
+
$$
|
| 63 |
+
\widetilde { L ^ { ( t ) } } ( \boldsymbol { \theta } ) : = - \mathbb { E } \underset { \mathbf { x } ^ { c } \sim q ( \cdot | \mathbf { x } ) } { \mathbf { x } \sim p _ { \mathrm { d a t a } } } [ \log p _ { t } ( \mathbf { x } | \mathbf { x } ^ { c } ) ] .
|
| 64 |
+
$$
|
| 65 |
+
|
| 66 |
+
Note that $\widetilde { L ^ { ( T ) } }$ is the actual term we would like to minimise if $p _ { T }$ were tractable, and in fact is closely related to evidence lower bound (ELBO) via a fixed encoder $q ( \mathbf { x } ^ { c } | \mathbf { x } )$ (Appendix A.2). However, due to the inherent non-differentiable nature of discrete Markov chain models, optimisation of $\widetilde { L ^ { ( T ) } }$ would not only be costly, but also limit the gradient flow to the last step of the chain. We found instead that optimising several steps together without propagating the gradient through sampling is sufficient for obtaining good results. Averaging more $L ^ { ( t ) }$ terms can lead to minor improvements in performance (see Figure 4d in Appendix C), but it considerably slows down the training speed. We discuss these and other loss variants further in Section 3.1.
|
| 67 |
+
|
| 68 |
+
Since function $f _ { \theta }$ is modelled as a neural network, the logarithm under expectation on the right hand side of Eq. 3 is obtained from predicted logits, thus we term $L ^ { ( 1 ) } ( \theta )$ and $L ^ { ( 2 ) } ( \theta )$ logits loss and unrolled logits loss, respectively.
|
| 69 |
+
|
| 70 |
+
Corruption function. To corrupt texts, we first sample a proportion of tokens uniformly from $[ 0 , 1 ]$ , randomly select positions according to this proportion and then change tokens at those positions to random tokens sampled uniformly from the vocabulary. This way, we want to ensure that samples seen at various steps during a generative unroll (including the first one, sampled from the uniform prior) are well-represented in corruptions applied during training. More details and relations to the forward diffusion process (Hoogeboom et al., 2021) are presented in Appendix A.3.
|
| 71 |
+
|
| 72 |
+
# 2.2 SAMPLING
|
| 73 |
+
|
| 74 |
+
At sampling time we follow the structure of the Markov process and sample sequentially $\mathbf { \mathcal { x } } _ { t } \sim$ $f _ { \theta } ( \pmb { x } _ { t } | \pmb { x } _ { t - 1 } )$ for some fixed number of steps $T$ , beginning from a random sequence $\scriptstyle { \mathbf { { \mathit { x } } } } _ { 0 }$ (potentially starting with a prompt or a template for conditional generation). To control the speed of convergence, we propose three improved strategies which allow the use of a much smaller number of steps:
|
| 75 |
+
|
| 76 |
+
• Low-temperature sampling. For temperature $\tau$ and trained network $f _ { \theta }$ we consider modified function $f _ { \theta } ^ { \tau }$ such that $\begin{array} { r } { \operatorname * { l o g } f _ { \theta } ^ { \tau } ( { \cdot } | x ) \propto \frac { 1 } { \tau } \log f _ { \theta } ( { \cdot } | x ) } \end{array}$ . We found that sampling with temperatures lower than 1 leads to much faster convergence than with the original logits, and allowed generation of high-quality samples in a matter of 10-16 steps.
|
| 77 |
+
|
| 78 |
+
Table 1: Test BLEU scores of AR and non-AR systems on the WMT’14 English-to-German $\mathrm { E N } { } \mathrm { D E } )$ ) and German-to-English $( \mathrm { D E } \to \mathrm { E N } )$ ) translation tasks. The number of reranked candidates is denoted $n$ . SUNDAE does not use an AR model for re-ranking. We highlight BLEU scores of the best non-AR systems in bold font. All the entries are ordered based on the $\mathrm { E N } { } \mathrm { D E }$ BLEU score. ∗indicates the results of the Transformer baselines implemented by the authors of DisCo. †DisCo has a dynamic inference mode for which we report the average number of steps.
|
| 79 |
+
|
| 80 |
+
<table><tr><td rowspan="2">Model</td><td colspan="2">Raw BLEU</td><td colspan="2">AR-distilled BLEU</td></tr><tr><td>Steps (T)</td><td>EN→DE</td><td>DE→EN</td><td>EN→DE DE→EN</td></tr><tr><td>ARModels</td><td></td><td></td><td></td><td></td></tr><tr><td>Transformer Base (65M) (Vaswani et al.,2017) (n=4)</td><td>27.3</td><td>31.78*</td><td></td><td></td></tr><tr><td>Non-AR Models</td><td></td><td></td><td></td><td></td></tr><tr><td>NAT (Gu et al., 2017) (n =100)</td><td>1</td><td></td><td>19.17</td><td>23.20</td></tr><tr><td>LVM-DAE (Lee et al.,2018)</td><td></td><td></td><td>21.54</td><td>25.43</td></tr><tr><td>NAT-REG (Wang et al.,2019) (n =9)</td><td>= 1</td><td></td><td>一</td><td>24.61 28.90</td></tr><tr><td>LV-NAR (Shu et al., 2020) (n = 50)</td><td>1</td><td>11.8</td><td>=</td><td>25.10</td></tr><tr><td>NART w/ hints (Li et al.,2019)(n =9)</td><td>1</td><td>=</td><td>-</td><td>25.20 29.52</td></tr><tr><td>FlowSeq (Ma et al.,2019) (n=30)</td><td>1</td><td>23.64</td><td>28.29</td><td>25.31 30.68</td></tr><tr><td>ReorderNAT (Ran et al., 2019)</td><td>1</td><td>=</td><td>=</td><td>26.49 31.13</td></tr><tr><td>NART (Sun et al.,2019) (n =19)</td><td>1</td><td>=</td><td></td><td>26.80 30.04</td></tr><tr><td>CMLM(Ghazvininejad et al.,2019) + Mask-Predict (n =5)</td><td>4</td><td>22.25</td><td>=</td><td>25.94 29.90</td></tr><tr><td>CMLM(Ghazvininejad et al.,2019)+ Mask-Predict (n=5)</td><td>10</td><td>24.61</td><td></td><td>27.03 30.53</td></tr><tr><td>DisCo (Kasai et al.,2020) + Mask-Predict (n=5)</td><td>4</td><td>-</td><td></td><td>25.83 30.15</td></tr><tr><td>DisCo (Kasai et al.,202O) + Mask-Predict (n=5)</td><td>10</td><td>=</td><td></td><td>27.06 30.89</td></tr><tr><td>DisCo (Kasai et al., 202O) + Easy-First (n=5)</td><td>4-5†</td><td>24.8</td><td></td><td>27.34 31.31</td></tr><tr><td>NARLVM (Lee et al.,2020) (n= 25)</td><td>4</td><td>-</td><td></td><td>27.40 ■</td></tr><tr><td>JM-NAT (Guo et al., 2020) (n =3)</td><td>4</td><td></td><td></td><td>27.05 31.51</td></tr><tr><td>JM-NAT (Guo et al., 2020) (n = 3)</td><td>10</td><td></td><td>27.69</td><td>32.54</td></tr><tr><td>SMART (Ghazvininejad et al., 2020) (n =5)</td><td>4</td><td></td><td></td><td>27.03 30.87</td></tr><tr><td>SMART (Ghazvininejad et al., 2020) (n =5)</td><td>10</td><td>■</td><td></td><td>27.65 31.27</td></tr><tr><td>Imputer (Saharia et al., 2020) (n =1)</td><td>4</td><td>24.7</td><td></td><td>28.0 31.0</td></tr><tr><td>Imputer (Saharia et al.,2020) (n = 1)</td><td>8</td><td>25.2</td><td>28.2</td><td>31.3</td></tr><tr><td>SUNDAE (ours 63M)</td><td></td><td></td><td></td><td></td></tr><tr><td>Deterministic (n=16)</td><td>4</td><td>25.01</td><td>29.53</td><td>28.33 32.25</td></tr><tr><td>Deterministic (n=16)</td><td>8</td><td>25.53</td><td>30.01</td><td>28.32 32.27</td></tr><tr><td>Deterministic (n =16)</td><td>10</td><td>25.54</td><td>30.11</td><td>28.32 32.27</td></tr><tr><td>Stochastic (n=16)</td><td>4</td><td>23.05</td><td>28.13</td><td>27.94 32.10</td></tr><tr><td>Stochastic (n=16)</td><td>8</td><td>26.08</td><td>30.48</td><td>28.23 32.33</td></tr><tr><td>Stochastic (n=16)</td><td>10</td><td>26.25</td><td>30.80</td><td>28.33 32.29</td></tr><tr><td>Stochastic (n=16)</td><td>16</td><td>26.24</td><td>30.76</td><td>28.46 32.30</td></tr></table>
|
| 81 |
+
|
| 82 |
+
• Argmax-unrolled decoding. At the limit $\tau 0$ sampling with temperature reduces to deterministic argmax decoding where the most probable token is chosen at each step. Relatedly to our unrolled logits loss, we modify this strategy by resampling the low-certainty tokens in accordance with unrolled logits. This heuristic allowed further improvements to sampling speed while maintaining the high quality of the samples. We discuss it in detail in Section 3.1.
|
| 83 |
+
|
| 84 |
+
• Updating fewer tokens. In tasks where diversity is paramount (like unconditional text generation), we found that updating a random subset of tokens at each decoding step leads to faster convergence. This likely happens because independent sampling of all tokens might create uncoordinated changes which could take some time to fix in the subsequent steps. We use this strategy in Section 3.2.
|
| 85 |
+
|
| 86 |
+
# 3 EXPERIMENTS
|
| 87 |
+
|
| 88 |
+
# 3.1 MACHINE TRANSLATION
|
| 89 |
+
|
| 90 |
+
We first evaluate SUNDAE on Machine Translation (MT) benchmarks. We compare SUNDAE against AR and non-AR models in terms of the translation quality using BLEU (Papineni et al., 2002) as the metric. We demonstrate that without using techniques like sequence-level knowledge distillation (Kim & Rush, 2016), SUNDAE performs almost as well as the AR model and outperforms all other methods that do not rely on AR models.
|
| 91 |
+
|
| 92 |
+
Target Length Prediction. Unlike their AR counterparts, non-AR models do not explicitly learn to predict an end of sequence, but instead have been shown to benefit from auxiliary target length prediction (Lee et al., 2018; Ghazvininejad et al., 2019; Kasai et al., 2020). A common approach is to treat it as a classification task, predicting either the exact length or the difference between the source and target lengths. The decoding process has to commit to the predicted length, and often multiple length beams are used to get the best translation results. In our models, we use a separate network that receives source encodings as input and predicts corresponding target length. Target length embedding vector is prepended to source embeddings so that decoder can attend to it. During training, we use the reference target length, while at sampling, a predicted one, although the model does not need to fully commit to the predicted length like some previous non-AR models (Saharia et al., 2020). Note that the length classification loss does not affect the encoder parameters. Our models are also trained to predict the padding tokens at the end of the text. For more details, see Appendix B.
|
| 93 |
+
|
| 94 |
+
Experiment Settings. We conduct experiments on WMT’14 parallel corpora using $\mathrm { E N } { } \mathrm { D E }$ (4.5M pairs) and $\operatorname { E N } { } \operatorname { F R }$ (36M pairs) translation tasks. The raw texts are encoded using BPE (Sennrich et al., 2015) as the subword units, and we use the same preprocessed data as in Vaswani et al. (2017) for fair comparisons. We evaluate the performance by measuring BLEU (Papineni et al., 2002; Post, 2018) on the test split of each translation $\mathrm { t a s k } ^ { 2 }$ . We use the encoder-decoder Transformer architecture for MT (Vaswani et al., 2017), but remove the causality masking in the decoder. There are 6 attention layers for both encoder and decoder, 8 attention heads, 512 model dimension and 2048 feedforward hidden dimension. The total number of parameters is 63M including the target length prediction module described in 3.1. We use dropout $( p = 0 . 1 )$ ) and label smoothing $\epsilon = 0 . 1 $ ) during training for all tasks, except for AR-distilled $\mathrm { E N } { } \mathrm { D E }$ , where we found lower dropout $\scriptstyle ( p = 0 . 0 5 )$ and no label smoothing produces better results on validation. The training batch size is 4096, and we use Adam (Kingma & Ba, 2014) with $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 9 9$ , $\epsilon = 1 0 ^ { - 6 }$ and weight decay of 0.1 (Loshchilov & Hutter, 2017). We warm up the learning rate from $1 0 ^ { - 7 }$ to $1 0 ^ { - 4 }$ in the first 5K steps and decay it to $1 0 ^ { - 5 }$ using cosine annealing (Loshchilov & Hutter, 2016). Our models were trained for $1 0 ^ { 6 }$ steps using 16 TPU accelerators using bfloat16 precision. We crop sequences that have more than 128 tokens (this occurs less than $0 . 2 \%$ in training data). Finally, we average the last 10 checkpoints to obtain a single model for the evaluation. All hyperparameter tuning is performed on a held-out validation set.
|
| 95 |
+
|
| 96 |
+
Decoding. We decode translations from SUNDAE using two different types of heuristic decoding methods in MT experiments. The decoding process always begins with an array of random integers sampled from the discrete uniform prior $y _ { 0 } \sim p _ { 0 }$ , while the encoder input - the source sentence - remains the same throughout the process. The first decoding method is low-temperature sampling, where we iteratively sample $\pmb { y } _ { t } \sim f _ { \theta } ^ { \tau } ( \cdot | \pmb { y } _ { t - 1 } )$ for $T$ iterations (with the decoder output logits divided by $\tau$ , see Section 2.2), with $T \leq 1 6$ and $\tau \in [ 0 . 1 , 0 . 6 ]$ determined based on the validation performance. The second method is argmax-unrolled decoding, which requires a smaller number of iterations compared to its stochastic counterpart. In argmax-unrolled decoding, we first compute the logits $\lambda _ { 1 } = f _ { \theta } ( \cdot | \pmb { y } _ { 0 } )$ of the initial sample array $\mathbf { { \boldsymbol { { y } } } _ { 0 } }$ and obtain the samples $\mathbf { \nabla } _ { \mathbf { \eta } _ { \mathbf { 3 } } } \mathbf { \eta } _ { \mathbf { 1 } }$ , pass a tuple $( \pmb { y } _ { 1 } , \lambda _ { 1 } )$ to the next iteration. At each step $t \geq 2$ , the method finds top- $\boldsymbol { \rho }$ share of the tokens that are sorted by the log-probability in descending order (i.e. uncertain tokens) from $\lambda _ { t - 1 }$ , where $\rho \in [ 0 . 1 , 0 . 6 ]$ is another hyperparameter searched for in the validation stage. We compute unrolled logits for those top- $\rho$ tokens and then apply arg max to obtain unrolled tokens. For the rest of the input tokens of $\mathbf { \nabla } _ { \mathbf { y } _ { t - 1 } }$ we compute logits once and obtain $\begin{array} { r } { \lambda _ { t } ~ = ~ f _ { \theta } ( \cdot | \pmb { y } _ { t - 1 } ) } \end{array}$ and then apply arg max to obtain predicted tokens. Finally, we combine unrolled tokens for uncertain input positions with predicted tokens for remaining positions to obtain ${ \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \mathbf { } } _ { \mathbf { } } \mathbf { \Xi } _ { \mathbf { } } \mathbf { \Lambda } _ { \mathbf { } } \mathbf { \Lambda } _ { \mathbf { } } \textbf { } _ { \mathbf { } } \textbf { } \textbf { } _ { \mathrm { } }$ , and the tuple $( \pmb { y } _ { t } , \lambda _ { t } )$ is provided as the input to the next iteration. This procedure is repeated over a fixed number of iterations $T$ . We always decode $n$ samples in parallel and rerank them based on the model score. We show the relative speed gain of SUNDAE in Table 2, the Transformer base is used as the AR baseline, for which we perform incremental sampling by caching the previous attention states.
|
| 97 |
+
|
| 98 |
+
Baselines. We compare SUNDAE with Transformer base (Vaswani et al., 2017) as the AR baseline and several non-AR models including CMLM (Ghazvininejad et al., 2019) and DisCo (Kasai et al., 2020). The last two are both iterative non-AR models that share a substantial amount of common ground with SUNDAE. However, their best results come from the variants distilled from Transformer large (Vaswani et al., 2017), with only few test results available without distillation. As we aim to remove any kinds of dependencies on AR approaches, we would like to make a distinction
|
| 99 |
+
|
| 100 |
+

|
| 101 |
+
Figure 2: BLEU scores on EMNLP2017 News. Left is better, lower is better. Quality/variation is controlled by changing the temperature.
|
| 102 |
+
|
| 103 |
+
<table><tr><td>Steps (T)</td><td>Relative Speed Improvement</td></tr><tr><td>4</td><td>4.7x</td></tr><tr><td>8</td><td>2.6x</td></tr><tr><td>10</td><td>2.2x</td></tr><tr><td>16</td><td>1.4x</td></tr></table>
|
| 104 |
+
|
| 105 |
+
Table 2: Relative speed gain of SUNDAE over AR Transformer base (greedy decoding) on WMT’14 EN DE validation set.
|
| 106 |
+
|
| 107 |
+
between raw, fully-non-AR models, and AR-distilled ones, i.e. those trained via distillation from large AR teachers (which typically perform better than the student models), or via AR reranking.
|
| 108 |
+
|
| 109 |
+
Results and Ablation Studies. In Table 1, we show test BLEU scores from SUNDAE and other baselines. On E $\mathrm { \Gamma } \to \mathrm { D E }$ , SUNDAE achieved 26.25 BLEU, and it performed the best among the raw non-AR models. To the best of our knowledge, SUNDAE achieved the closest result ( $\triangle = 1 . 0 5 )$ ) to the score of Transformer base (Vaswani et al., 2017) without the aid of AR models.3 In the raw setting, argmax-unrolled decoding outperforms mask-predict (Ghazvininejad et al., 2019) and easyfirst (Kasai et al., 2020) by 0.74 BLEU when using the same amount of the worst-case compute budget. At $T = 8$ , SUNDAE performs better than Imputer (Saharia et al., 2020), which is a strong baseline that can generate high-quality translation within few (4-8) iterations. We discovered that as $T$ increases, low-temperature sampling outperforms argmax-unrolled decoding, and at $T = 1 0$ , lowtemperature sampling outperforms Mask-Predict (Ghazvininejad et al., 2019) and Easy-First (Kasai et al., 2020) by 1.5 BLEU score. SUNDAE achieved 30.80 BLEU on $\mathrm { D E } { } \mathrm { E N }$ , where there are not that many raw baselines to compare with. The difference between SUNDAE and the AR baseline on $) \mathrm { E } { } \mathrm { E N }$ is 0.98. Finally, SUNDAE achieved 37.53 BLEU on $\operatorname { E N } { } \operatorname { F R }$ at $T = 1 0$ , while the Transformer base (Vaswani et al., 2017) reported 38.1 BLEU on this task. Thus, SUNDAE without distillation is only 0.57 BLEU behind the standard AR baseline on EN FR. We present more details on $\operatorname { E N } { } \operatorname { F R }$ scores in Table 7 in Appendix G.
|
| 110 |
+
|
| 111 |
+
While knowledge distillation was outside our main focus, we also report scores for AR-distilled SUNDAE.4 It again performed well, establishing new SotA on $\mathrm { E N } { } \mathrm { D E }$ translation among AR– distilled models, and being second only to JM-NAT (Guo et al., 2020) in DE EN task.
|
| 112 |
+
|
| 113 |
+
We ablate the number of steps of unrolled denoising on $\mathrm { E N } { } \mathrm { D E }$ test split. We observe that having at least one unrolled denoising step is crucial to obtain good performance in translation. With only the $L ^ { ( 1 ) }$ loss, SUNDAE achieves 11.19 BLEU, whereas using $L ^ { ( 1 : 2 ) }$ , the score improves to 26.57 BLEU. Using $L ^ { ( 1 : 3 ) }$ , i.e. averaging more unrolled denoising loss terms, did not improve the performance further, scoring 26.25 BLEU. The target length prediction also turned out to be an important component of our model: without it, the translation performance degrades on average by 2 BLEU score points on EN DE (see Appendix C). Finally, we qualitatively show how translation improves along the sampling steps by elimination of incoherent/repeated tokens in Table 5 in Appendix E.
|
| 114 |
+
|
| 115 |
+
# 3.2 TEXT GENERATION
|
| 116 |
+
|
| 117 |
+
Unconditional Text Generation (Qualitative). We train our method on a large high-quality publicly available Colossal Clean Common Crawl (C4) dataset (Raffel et al., 2019) to demonstrate samples. We tokenize the data using SentencePiece (Kudo & Richardson, 2018) 5 with vocabulary size 32K and train on randomly cropped sequences of length 32. The network is the same as the Transformer decoder part for MT in Section 3.1 but is much larger — 335M parameters: 24 layers,
|
| 118 |
+
|
| 119 |
+
Table 3: Inpainting from our model trained on C4 (cherry-picked).
|
| 120 |
+
|
| 121 |
+
<table><tr><td></td><td>IndexType</td><td>Text</td></tr><tr><td rowspan="2">1</td><td>Prompt</td><td>Seeing****** for any visitor toa national park.While it is an exciting moment,a bear can*******</td></tr><tr><td>Completion</td><td>Seingabigbearisamustforanyvisitortoaationalpark.Whileitisanexcitingmoment,abearcanbeintimidatingasitilome</td></tr><tr><td rowspan="2">2</td><td>Prompt</td><td>Seeing****** for any visitor toa national park.While it is an exciting moment,a moose can******</td></tr><tr><td>Completion</td><td>SeingmooseisqeeerecefoiottioalarkWileitieciigontooeaigateisaogot</td></tr></table>
|
| 122 |
+
|
| 123 |
+
1024 embedding size, 4096 hidden size, 16 attention heads. Same as in the MT setup, we remove the causal mask since our model is non-autoregressive. We train up to 400K steps with Adam optimizer with batch size 4096 and use cosine annealing for scheduling the learning rate with minimum $1 0 ^ { - 5 }$ , maximum $2 * 1 0 ^ { - 3 }$ and linear warm-up of 10K steps from starting value of $1 0 ^ { - 7 }$ .
|
| 124 |
+
|
| 125 |
+
The trained model is then used for unconditional sampling. Starting with 32 random tokens, we iteratively perform up to 1K steps from our model, stopping earlier if samples do not change anymore. To make convergence faster, we use temperature 0.8 and update only $3 0 \%$ of all tokens at each step, chosen randomly — as explained in Section 2.2. We show 10 non-cherry-picked samples from our model in Table 8 of Appendix H. Of those samples, all but one resemble reasonable internet texts.
|
| 126 |
+
|
| 127 |
+
Unconditional Text Generation (Quantitative). While C4 is one of the largest high-quality datasets publicly available, it does not have an established benchmark among non-AR methods. To quantitatively evaluate our algorithm, we train it on the EMNLP2017 News6 dataset, which has numerous text GAN baselines, including a strong ScratchGAN method (d’Autume et al., 2019). We also compare to several other baselines reported in (d’Autume et al., 2019; Caccia et al., 2020): SeqGAN (Yu et al., 2017), LeakGAN (Guo et al., 2017), RankGAN (Lin et al., 2017), MaliGAN (Che et al., 2017) and autoregressive (AR) language models.
|
| 128 |
+
|
| 129 |
+
We use the same architecture and optimizer as in qualitative experiments and train with batch size 1024 for 8K steps (chosen to achieve the lowest validation loss). We follow the same tokenization strategy as d’Autume et al. (2019), with vocabulary size of 5.7K and maximum length 52 tokens, padding shorter sequences to this maximum length. During sampling, we perform 1K steps and update all the tokens at each step (which we found beneficial for the chosen metrics). The quality/- variation trade-off is controlled by changing the sampling temperature in the range [0.1, 2.0], using 60 values overall. For every temperature, we sample 10K texts for evaluating quality and another 10K texts for evaluating diversity, as done by d’Autume et al. (2019).
|
| 130 |
+
|
| 131 |
+
The results are shown in Figure 2. SUNDAE demonstrates good quality/variation trade-off, as measured by BLEU/self-BLEU metrics, outperforming 4 out of 5 GAN baselines, and competing with ScratchGAN and AR model. In the higher quality region, SUNDAE outperforms ScratchGAN, while in higher diversity region it slightly underperforms. The advantage of ScratchGAN in higher diversity region could be explained by its autoregressive decoding (it is a hybrid between AR and GAN). Interestingly, the curve for SUNDAE has a more complicated shape than the baselines — possibly because of its Markov Chain sampling, which can empirically exhibit something akin to “phase transitions”. We show samples from SUNDAE in Table 9 of Appendix I.
|
| 132 |
+
|
| 133 |
+
Text In-painting. The non-autoregressive nature of our model opens up possibilities beyond leftto-right prompted generation, such as filling in arbitrary blank patterns in a template. In this section, we qualitatively investigate this new capability, using the C4-trained model described in previous sections, and another one, trained on a dataset of Python code from GitHub. All the architecture/training settings remain the same, except we train twice longer: up to 800K steps. Sampling settings are also the same, except we update all the tokens at each step as diversity is less of an issue with stronger conditioning. We construct the code dataset by extracting files ending in .py from open source GitHub repositories with licenses that are one of apache-2.0, mit, bsd-3-clause, bsd-2-clause, unlicense, $\mathtt { C C } 0 - 1 . 0 ,$ , isc, artistic-2.0. We perform document level de-duplication checking for exact matches.
|
| 134 |
+
|
| 135 |
+
For the C4 dataset, we present a model with a particular type of prompt [CTX1][MSK1][CTX2][MSK2], where [CTX] stands for “context” and [MSK] for “masked”, in Table 3, which shows how information can be “teleported” from arbitrary location to another arbitrary location, while taking into account bidirectional context. We change a species of the animal in [CTX2] and observe that the model actually uses the right word while in-painting [MSK1] and plausibly continues [MSK2] according to the species. This kind of task would be impossible to perform for an AR model: with left-to-right causality it would be unable to correctly guess the name of the animal, while with a right-to-left one it would have to start filling [MSK2] tokens first, so it would just ignore the conditioning. By contrast, our model succeeds in this task.
|
| 136 |
+
|
| 137 |
+
Table 4: Inpainting from our model trained on GitHub (cherry-picked).
|
| 138 |
+
|
| 139 |
+
<table><tr><td>Index</td><td>Type</td><td>Text</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>1</td><td>Prompt</td><td></td><td></td><td>def trunc_len(x,t):</td><td></td><td></td><td>★★*★★*★*★******</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>return min(n,t)</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>Completion</td><td></td><td></td><td>n = len(x)</td><td>def trunc_len(x,t):</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td>return min(n,t)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>2</td><td>Prompt</td><td></td><td></td><td></td><td>is_even = lambda x:</td><td></td><td></td><td></td><td>**★**★</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>is_odd = lambda x:</td><td></td><td></td><td></td><td></td><td>not******</td><td></td><td></td><td></td><td>#</td><td>reuse</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>Completion</td><td>is_odd = lambda x:</td><td></td><td></td><td>is_even = lambda x:</td><td></td><td></td><td></td><td>x%2==0 not is_even(x)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
|
| 140 |
+
|
| 141 |
+
For GitHub Python data, we use two different kinds of prompts for our model in Table 4: [CTX1][MSK1][CTX2] and [CTX1][MSK1][CTX2][MSK2][CTX3]. In the first example, our model guesses that n should be the length of the input sequence and correctly in-paints [MSK1] region. This would again be impossible to do for AR models. Looking from left-to-right, it is impossible to guess that n will be the name of the length variable and t is meant to be a threshold. Looking from right-to-left, it is unclear what variables n and t represent and what is the function being computed. Only a bidirectional model can perform well in this task. In the second example, our model correctly follows the suggestion to reuse the function which it also has to in-paint.
|
| 142 |
+
|
| 143 |
+
# 4 RELATED WORK
|
| 144 |
+
|
| 145 |
+
In this section we provide an overview of generative models, focusing on applications in text domain.
|
| 146 |
+
|
| 147 |
+
# 4.1 AUTOREGRESSIVE MODELS
|
| 148 |
+
|
| 149 |
+
Early attempts to perform autoregressive modelling of text using neural networks began with Bengio et al. (2003); later Sutskever et al. (2011) extended this approach with RNNs. Since then, improvements in neural network architecture, such as the Transformer (Vaswani et al., 2017), and scaling up as with GPT-3 (Brown et al., 2020) dramatically improved the performance of AR models. While the architectures evolved, the loss function remained the same with minor modifications.
|
| 150 |
+
|
| 151 |
+
Insertion (Stern et al., 2019) and Levenshtein (Gu et al., 2019) Transformers are deviations from the standard paradigm of training and could potentially overcome some of AR problems. However, in the parallel decoding regime, they have to rely on AR distillation for obtaining competitive results.
|
| 152 |
+
|
| 153 |
+
# 4.2 NON-AUTOREGRESSIVE MODELS IN GENERAL
|
| 154 |
+
|
| 155 |
+
Non-autoregressive models evolved in parallel with autoregressive ones but have so far struggled to address the same spectrum of tasks with the same quality as AR models.
|
| 156 |
+
|
| 157 |
+
Diffusion for generative models was originally introduced by Sohl-Dickstein et al. (2015). Recently Ho et al. (2020) proposed a different parametrization: instead of modeling one-step transitions, one could instead model $p ( x _ { 0 } | x _ { t } )$ and later convert those to $p ( x _ { t - 1 } | x _ { t } )$ by probabilistic reasoning. This was recently up-scaled for image modeling by Nichol & Dhariwal (2021) and extended to continuous time by Song et al. (2020). In terms of applications to text generation, two recent works addressed this: Hoogeboom et al. (2021) and Austin et al. (2021). Likelihoods obtained in those works are promising, but still behind AR and lacking sample quality as well.
|
| 158 |
+
|
| 159 |
+
Some diffusion works like Mittal et al. (2021) also approached modeling discrete sequences in another way: first encode sequences with a VAE into a continuous space and then apply continuous diffusion approaches commonly used for image generation.
|
| 160 |
+
|
| 161 |
+
Variational Autoencoders (VAEs) were proposed by Rezende et al. (2014) and Kingma & Welling (2013) as a likelihood-based extension of autoencoders. Application of such methods to text has been problematic empirically: as it was first noted in Bowman et al. (2015), good results come from using a strong AR decoder instead of a simple factorised one, but the latents are often ignored — which was named “posterior collapse problem”. This problem was later tackled by Delta-VAEs (Razavi et al., 2019), with limited success in the text domain (Bosc & Vincent, 2020).
|
| 162 |
+
|
| 163 |
+
Normalising Flows (Dinh et al., 2014; Rezende & Mohamed, 2015; Dinh et al., 2016) are another prominent family of generative models, originally proposed for real-valued data and recently revisited for text generation by Hoogeboom et al. (2021). While conceptually interesting, the text samples of such methods lack in fidelity.
|
| 164 |
+
|
| 165 |
+
Generative Adversarial Networks (GANs) were originally introduced by Goodfellow et al. (2014) and remain one of the dominant methods for image generation. They were later adapted to text generation in Yu et al. (2017); Guo et al. (2017); Lin et al. (2017); Che et al. (2017). However, text generation with such methods is still a challenge, with a more recent ScratchGAN (d’Autume et al., 2019) showing relatively low-quality samples. At least part of the problem with applying GANs to text generation comes from non-differentiability of discrete text samples, which requires usage of zeroth order optimization methods.
|
| 166 |
+
|
| 167 |
+
Energy-Based models have a long history dating back to Hopfield (1982); Hinton (2002); LeCun et al. (2006); Ranzato et al. (2007). Recently, Deng et al. (2020) shows promising results for text.
|
| 168 |
+
|
| 169 |
+
# 4.3 NON-AUTOREGRESSIVE MODELS FOR MACHINE TRANSLATION
|
| 170 |
+
|
| 171 |
+
There have been many attempts to apply non-autoregressive methods to machine translation. Latent transformer (Kaiser et al., 2018) generated latent variables autoregressively and then decoded feedforwardly. NAT (Gu et al., 2017) was the first to characterize a problem with non-autoregressive generation — “multi-modality”. FlowSeq (Ma et al., 2019) applied Normalising Flows to machine translation. LVM-DAEs (Lee et al., 2018) are perhaps most related to our method, but these models do not have unrolled denoising and their decoding method is deterministic. The leading methods in this area are CMLM (Ghazvininejad et al., 2019) and DisCo (Kasai et al., 2020). While conceptually similar to LVM-DAEs (Lee et al., 2018), these works have introduced significant improvements to the training and decoding procedure, and, as a result, shown strong competition to AR methods. Both of them also do not have unrolled denoising and sampling like we do, but they are still powerful baselines. Later, there were attempts to combine CMLM with local AR (Kong et al., 2020). Perhaps the most related to our work is the SMART (Ghazvininejad et al., 2020) follow-up of the CMLM. However, this method is not probabilistic and it does not show unconditional generation capabilities. Finally, a recent line of work called Imputer (Chan et al., 2020; Saharia et al., 2020) achieves strong results in machine translation by aligning target to source via dynamic programming.
|
| 172 |
+
|
| 173 |
+
# 4.4 DENOISING OBJECTIVE IN GENERAL
|
| 174 |
+
|
| 175 |
+
With the advent of BERT (Devlin et al., 2018), the denoising objective became very popular for text representation learning. The original idea was later simplified in RoBERTa (Liu et al., 2019) by removing the unnecessary next-sentence-prediction task and only retaining the denoising task (the cloze task). This is similar to our work, however, we do not apply masking to corrupt the input tokens, and instead only switch them to random ones. More importantly, RoBERTa does not use unrolled denoising. Another work, Electra (Clark et al., 2020a), deals with the same kind of corruption that we use, but instead of predicting the original token before the corruption, Electra predicts whether it was corrupted or not. Electric (Clark et al., 2020b) does not perform masking, but instead uses noise-contrastive loss to learn a representation of text. BART (Lewis et al., 2019) uses both BERT-style denoising and autoregressive modeling for learning representations. All of these methods were originally motivated by improving representation learning of text. There were a few attempts to heuristically decode models like BERT and turn them into text generative models such as in Wang & Cho (2019), however, samples from these models lack coherence.
|
| 176 |
+
|
| 177 |
+
# 5 CONCLUSION
|
| 178 |
+
|
| 179 |
+
In this paper we have proposed a novel non-autoregressive method that operates within the framework of denoising autoencoders and, crucially, unrolls the denoising process during training. Unrolled denoising allows us to achieve state-of-the art results in WMT’14 English-to-German translation task amongst non-AR methods (without distillation from large AR models) and good qualitative results in unconditional text modeling on C4 dataset. We have also qualitatively demonstrated new inpainting capabilities on C4 and GitHub Python data, which opens up new avenues for creative text editing where a human could more naturally collaborate with a machine on writing and even programming.
|
| 180 |
+
|
| 181 |
+
# AUTHOR CONTRIBUTIONS
|
| 182 |
+
|
| 183 |
+
Nikolay Savinov came up with the idea of unrolled denoising, wrote the first prototype of unconditional generation, contributed to the machine translation codebase and co-led the project. Junyoung Chung wrote most of the machine translation codebase, came up with the length prediction conditioning, suggested argmax-unrolled decoding and co-led the project. Mikołaj Binkowski came ´ up with theoretical insights about our model, wrote most of the evaluation codebase, implemented model improvements and co-led the project. All three first authors contributed equally to writing the paper. Erich Elsen gave high-level scientific guidance, suggested text in-painting experiments and made substantial edits to the paper draft. Aaron van den Oord originally suggested to look into de- ¨ noising generative models for text, gave high-level scientific guidance, proposed machine translation experiments and made substantial edits to the paper draft.
|
| 184 |
+
|
| 185 |
+
# ACKNOWLEDGMENTS
|
| 186 |
+
|
| 187 |
+
We would like to thank Jean-Baptiste Alayrac and Miruna Pˆıslar for valuable discussions on the machine translation experiments, William Chan and Chitwan Saharia for sharing distilled translation datasets, Mihaela Rosca and Cyprien de Masson d’Autume for sharing text GAN evaluation code, Yujia Li and Jack Rae for sharing a dataset of Python code from GitHub, Sander Dieleman and Oriol Vinyals for in-depth feedback about our work, Jungo Kasai for responses to our questions about DisCo, Dani Yogatama for sharing knowledge on machine translation evaluation, and Jeff Donahue for feedback and discussions.
|
| 188 |
+
|
| 189 |
+
# REFERENCES
|
| 190 |
+
|
| 191 |
+
Jacob Austin, Daniel Johnson, Jonathan Ho, Danny Tarlow, and Rianne van den Berg. Structured denoising diffusion models in discrete state-spaces. arXiv preprint arXiv:2107.03006, 2021.
|
| 192 |
+
|
| 193 |
+
Yoshua Bengio, Rejean Ducharme, Pascal Vincent, and Christian Janvin. A neural probabilistic ´ language model. The journal of machine learning research, 3:1137–1155, 2003.
|
| 194 |
+
|
| 195 |
+
Tom Bosc and Pascal Vincent. Do sequence-to-sequence vaes learn global features of sentences? arXiv preprint arXiv:2004.07683, 2020.
|
| 196 |
+
|
| 197 |
+
Samuel R Bowman, Luke Vilnis, Oriol Vinyals, Andrew M Dai, Rafal Jozefowicz, and Samy Bengio. Generating sentences from a continuous space. arXiv preprint arXiv:1511.06349, 2015.
|
| 198 |
+
|
| 199 |
+
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.
|
| 200 |
+
|
| 201 |
+
Massimo Caccia, Lucas Caccia, William Fedus, Hugo Larochelle, Joelle Pineau, and Laurent Charlin. Language gans falling short. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ BJgza6VtPB.
|
| 202 |
+
|
| 203 |
+
William Chan, Chitwan Saharia, Geoffrey Hinton, Mohammad Norouzi, and Navdeep Jaitly. Imputer: Sequence modelling via imputation and dynamic programming. In International Conference on Machine Learning, pp. 1403–1413. PMLR, 2020.
|
| 204 |
+
|
| 205 |
+
Tong Che, Yanran Li, Ruixiang Zhang, R Devon Hjelm, Wenjie Li, Yangqiu Song, and Yoshua Bengio. Maximum-likelihood augmented discrete generative adversarial networks. arXiv preprint arXiv:1702.07983, 2017.
|
| 206 |
+
|
| 207 |
+
Ciprian Chelba, Tomas Mikolov, Mike Schuster, Qi Ge, Thorsten Brants, and Phillipp Koehn. One billion word benchmark for measuring progress in statistical language modeling. CoRR, abs/1312.3005, 2013. URL http://arxiv.org/abs/1312.3005.
|
| 208 |
+
|
| 209 |
+
Kevin Clark, Minh-Thang Luong, Quoc V Le, and Christopher D Manning. Electra: Pre-training text encoders as discriminators rather than generators. arXiv preprint arXiv:2003.10555, 2020a.
|
| 210 |
+
|
| 211 |
+
Kevin Clark, Minh-Thang Luong, Quoc V Le, and Christopher D Manning. Pre-training transformers as energy-based cloze models. arXiv preprint arXiv:2012.08561, 2020b.
|
| 212 |
+
|
| 213 |
+
Cyprien de Masson d’Autume, Mihaela Rosca, Jack Rae, and Shakir Mohamed. Training language gans from scratch. arXiv preprint arXiv:1905.09922, 2019.
|
| 214 |
+
|
| 215 |
+
Yuntian Deng, Anton Bakhtin, Myle Ott, Arthur Szlam, and Marc’Aurelio Ranzato. Residual energy-based models for text generation. arXiv preprint arXiv:2004.11714, 2020.
|
| 216 |
+
|
| 217 |
+
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.
|
| 218 |
+
|
| 219 |
+
Laurent Dinh, David Krueger, and Yoshua Bengio. Nice: Non-linear independent components estimation. arXiv preprint arXiv:1410.8516, 2014.
|
| 220 |
+
|
| 221 |
+
Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real nvp. arXiv preprint arXiv:1605.08803, 2016.
|
| 222 |
+
|
| 223 |
+
Marjan Ghazvininejad, Omer Levy, Yinhan Liu, and Luke Zettlemoyer. Mask-predict: Parallel decoding of conditional masked language models. arXiv preprint arXiv:1904.09324, 2019.
|
| 224 |
+
|
| 225 |
+
Marjan Ghazvininejad, Omer Levy, and Luke Zettlemoyer. Semi-autoregressive training improves mask-predict decoding. arXiv preprint arXiv:2001.08785, 2020.
|
| 226 |
+
|
| 227 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
|
| 228 |
+
|
| 229 |
+
Jiatao Gu, James Bradbury, Caiming Xiong, Victor OK Li, and Richard Socher. Non-autoregressive neural machine translation. arXiv preprint arXiv:1711.02281, 2017.
|
| 230 |
+
|
| 231 |
+
Jiatao Gu, Changhan Wang, and Jake Zhao. Levenshtein transformer. arXiv preprint arXiv:1905.11006, 2019.
|
| 232 |
+
|
| 233 |
+
Jiaxian Guo, Sidi Lu, Han Cai, Weinan Zhang, Yong Yu, and Jun Wang. Long text generation via adversarial training with leaked information. arxiv e-prints, art. arXiv preprint arXiv:1709.08624, 2017.
|
| 234 |
+
|
| 235 |
+
Junliang Guo, Linli Xu, and Enhong Chen. Jointly masked sequence-to-sequence model for nonautoregressive neural machine translation. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 376–385, 2020.
|
| 236 |
+
|
| 237 |
+
Geoffrey E Hinton. Training products of experts by minimizing contrastive divergence. Neural computation, 14(8):1771–1800, 2002.
|
| 238 |
+
|
| 239 |
+
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. arXiv preprint arXiv:2006.11239, 2020.
|
| 240 |
+
|
| 241 |
+
Emiel Hoogeboom, Didrik Nielsen, Priyank Jaini, Patrick Forre, and Max Welling. Argmax ´ flows and multinomial diffusion: Towards non-autoregressive language models. arXiv preprint arXiv:2102.05379, 2021.
|
| 242 |
+
|
| 243 |
+
John J Hopfield. Neural networks and physical systems with emergent collective computational abilities. Proceedings of the national academy of sciences, 79(8):2554–2558, 1982.
|
| 244 |
+
|
| 245 |
+
Lukasz Kaiser, Samy Bengio, Aurko Roy, Ashish Vaswani, Niki Parmar, Jakob Uszkoreit, and Noam Shazeer. Fast decoding in sequence models using discrete latent variables. In International Conference on Machine Learning, pp. 2390–2399. PMLR, 2018.
|
| 246 |
+
|
| 247 |
+
Jungo Kasai, James Cross, Marjan Ghazvininejad, and Jiatao Gu. Non-autoregressive machine translation with disentangled context transformer. In International Conference on Machine Learning, pp. 5144–5155. PMLR, 2020.
|
| 248 |
+
|
| 249 |
+
Yoon Kim and Alexander M Rush. Sequence-level knowledge distillation. arXiv preprint arXiv:1606.07947, 2016.
|
| 250 |
+
|
| 251 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 252 |
+
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
|
| 253 |
+
Xiang Kong, Zhisong Zhang, and Eduard Hovy. Incorporating a local translation mechanism into non-autoregressive translation. arXiv preprint arXiv:2011.06132, 2020.
|
| 254 |
+
Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. arXiv preprint arXiv:1808.06226, 2018.
|
| 255 |
+
Yann LeCun, Sumit Chopra, Raia Hadsell, M Ranzato, and F Huang. A tutorial on energy-based learning. Predicting structured data, 1(0), 2006.
|
| 256 |
+
Jason Lee, Elman Mansimov, and Kyunghyun Cho. Deterministic non-autoregressive neural sequence modeling by iterative refinement. arXiv preprint arXiv:1802.06901, 2018.
|
| 257 |
+
Jason Lee, Raphael Shu, and Kyunghyun Cho. Iterative refinement in the continuous space for non-autoregressive neural machine translation. arXiv preprint arXiv:2009.07177, 2020.
|
| 258 |
+
Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. Bart: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019.
|
| 259 |
+
Zhuohan Li, Zi Lin, Di He, Fei Tian, Tao Qin, Liwei Wang, and Tie-Yan Liu. Hint-based training for non-autoregressive machine translation. arXiv preprint arXiv:1909.06708, 2019.
|
| 260 |
+
Kevin Lin, Dianqi Li, Xiaodong He, Zhengyou Zhang, and Ming-Ting Sun. Adversarial ranking for language generation. arXiv preprint arXiv:1705.11001, 2017.
|
| 261 |
+
Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
|
| 262 |
+
Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983, 2016.
|
| 263 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
|
| 264 |
+
Xuezhe Ma, Chunting Zhou, Xian Li, Graham Neubig, and Eduard Hovy. Flowseq: Non-autoregressive conditional sequence generation with generative flow. arXiv preprint arXiv:1909.02480, 2019.
|
| 265 |
+
Matt Mahoney. Text 8 dataset. http://mattmahoney.net/dc/textdata, 2011. Accessed: 2021-09-29.
|
| 266 |
+
Gautam Mittal, Jesse Engel, Curtis Hawthorne, and Ian Simon. Symbolic music generation with diffusion models. arXiv preprint arXiv:2103.16091, 2021.
|
| 267 |
+
Alex Nichol and Prafulla Dhariwal. Improved denoising diffusion probabilistic models. arXiv preprint arXiv:2102.09672, 2021.
|
| 268 |
+
Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting of the Association for Computational Linguistics, pp. 311–318, 2002.
|
| 269 |
+
Matt Post. A call for clarity in reporting bleu scores. arXiv preprint arXiv:1804.08771, 2018.
|
| 270 |
+
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 e-prints, 2019.
|
| 271 |
+
|
| 272 |
+
Qiu Ran, Yankai Lin, Peng Li, and Jie Zhou. Guiding non-autoregressive neural machine translation decoding with reordering information. arXiv preprint arXiv:1911.02215, 2019.
|
| 273 |
+
|
| 274 |
+
Marc’Aurelio Ranzato, Y-Lan Boureau, Sumit Chopra, and Yann LeCun. A unified energy-based framework for unsupervised learning. In Artificial Intelligence and Statistics, pp. 371–379. PMLR, 2007.
|
| 275 |
+
|
| 276 |
+
Ali Razavi, Aaron van den Oord, Ben Poole, and Oriol Vinyals. Preventing posterior collapse with ¨ delta-vaes. arXiv preprint arXiv:1901.03416, 2019.
|
| 277 |
+
|
| 278 |
+
Danilo Rezende and Shakir Mohamed. Variational inference with normalizing flows. In International conference on machine learning, pp. 1530–1538. PMLR, 2015.
|
| 279 |
+
|
| 280 |
+
Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In International conference on machine learning, pp. 1278–1286. PMLR, 2014.
|
| 281 |
+
|
| 282 |
+
Chitwan Saharia, William Chan, Saurabh Saxena, and Mohammad Norouzi. Non-autoregressive machine translation with latent alignments. arXiv preprint arXiv:2004.07437, 2020.
|
| 283 |
+
|
| 284 |
+
Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. arXiv preprint arXiv:1508.07909, 2015.
|
| 285 |
+
|
| 286 |
+
Raphael Shu, Jason Lee, Hideki Nakayama, and Kyunghyun Cho. Latent-variable nonautoregressive neural machine translation with deterministic inference using a delta posterior. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 8846–8853, 2020.
|
| 287 |
+
|
| 288 |
+
Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning, pp. 2256–2265. PMLR, 2015.
|
| 289 |
+
|
| 290 |
+
Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020.
|
| 291 |
+
|
| 292 |
+
Mitchell Stern, William Chan, Jamie Kiros, and Jakob Uszkoreit. Insertion transformer: Flexible sequence generation via insertion operations. In International Conference on Machine Learning, pp. 5976–5985. PMLR, 2019.
|
| 293 |
+
|
| 294 |
+
Zhiqing Sun, Zhuohan Li, Haoqing Wang, Zi Lin, Di He, and Zhi-Hong Deng. Fast structured decoding for sequence models. arXiv preprint arXiv:1910.11555, 2019.
|
| 295 |
+
|
| 296 |
+
Ilya Sutskever, James Martens, and Geoffrey E Hinton. Generating text with recurrent neural networks. In ICML, 2011.
|
| 297 |
+
|
| 298 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998–6008, 2017.
|
| 299 |
+
|
| 300 |
+
Alex Wang and Kyunghyun Cho. Bert has a mouth, and it must speak: Bert as a markov random field language model. arXiv preprint arXiv:1902.04094, 2019.
|
| 301 |
+
|
| 302 |
+
Yiren Wang, Fei Tian, Di He, Tao Qin, ChengXiang Zhai, and Tie-Yan Liu. Non-autoregressive machine translation with auxiliary regularization. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 5377–5384, 2019.
|
| 303 |
+
|
| 304 |
+
Lantao Yu, Weinan Zhang, Jun Wang, and Yong Yu. Seqgan: Sequence generative adversarial nets with policy gradient. In Proceedings of the AAAI conference on artificial intelligence, volume 31, 2017.
|
| 305 |
+
|
| 306 |
+
# A METHOD DETAILS
|
| 307 |
+
|
| 308 |
+
Using Markov property and the form of $p _ { t } = f _ { \theta } ( \cdot | \mathbf { x } _ { t - 1 } )$ , for any $t > 0$ we obtain
|
| 309 |
+
|
| 310 |
+
$$
|
| 311 |
+
\begin{array} { l } { { \displaystyle p _ { t } \big ( { \bf x } _ { t } | { \bf x } _ { 0 } \big ) = \sum _ { { \bf x } _ { t - 1 } \in X } p _ { t - 1 } \big ( { \bf x } _ { t - 1 } | { \bf x } _ { 0 } \big ) f _ { \theta } \big ( { \bf x } _ { t } | { \bf x } _ { t - 1 } \big ) } \ ~ } \\ { ~ = \mathbb { E } _ { { \bf x } _ { t - 1 } \sim p _ { t - 1 } \cdot ( \cdot | { \bf x } _ { 0 } ) } f _ { \theta } \big ( { \bf x } _ { t } | { \bf x } _ { t - 1 } \big ) . } \end{array}
|
| 312 |
+
$$
|
| 313 |
+
|
| 314 |
+
By induction, we can keep unrolling the chain for all steps $s = t - 1 , t - 2 , \dots , 1$ , eventually obtaining
|
| 315 |
+
|
| 316 |
+
$$
|
| 317 |
+
\begin{array} { r l } { { p _ { t } ( { \pmb x } _ { t } | { \pmb x } _ { 0 } ) = \sum _ { { \pmb x } _ { 1 } , \dots , { \pmb x } _ { t - 1 } } \prod _ { s = 1 } ^ { t } f _ { \theta } ( { \pmb x } _ { s } | { \pmb x } _ { s - 1 } ) } \ ~ } & { } \\ & { = \mathbb { E } _ { { \pmb x } _ { 1 } \sim p _ { 1 } ( \cdot | { \pmb x } _ { 0 } ) } \ [ f _ { \theta } ( { \pmb x } _ { t } | { \pmb x } _ { t - 1 } ) ] , } \\ & { ~ { \pmb x } _ { t - 1 } \sim p _ { t - 1 } ( \cdot | { \pmb x } _ { t - 2 } ) } \end{array}
|
| 318 |
+
$$
|
| 319 |
+
|
| 320 |
+
which proves the from of the model distribution (Eq. 1).
|
| 321 |
+
|
| 322 |
+
A.1 UPPER BOUND ON THE LOSS.
|
| 323 |
+
|
| 324 |
+
Using Jensen’s inequality we can swap log and expectation in Eq. 7 to obtain
|
| 325 |
+
|
| 326 |
+
$$
|
| 327 |
+
\begin{array} { r } { - \log p _ { t } ( \mathbf { x } | \mathbf { x } _ { 0 } ) \leq - \mathbb { E } _ { \mathbf { \lambda } _ { \mathbf { x } _ { 1 } \sim p _ { 1 } ( \cdot | \mathbf { x } _ { 0 } ) } } \left[ \log f _ { \theta } ( \mathbf { x } | \mathbf { x } _ { t - 1 } ) \right] , } \\ { \mathbf { x } _ { t - 1 } { \sim } p ( \cdot | \mathbf { x } _ { t - 2 } ) \qquad } \end{array}
|
| 328 |
+
$$
|
| 329 |
+
|
| 330 |
+
hence
|
| 331 |
+
|
| 332 |
+
$$
|
| 333 |
+
\begin{array} { r } { \widetilde { L ^ { ( t ) } } ( \boldsymbol { \theta } ) = - \mathbb { E } \underset { \mathbf { x } _ { 0 } \sim q ( \cdot | \mathbf { x } ) } { \mathbf { x } } \left[ \log p _ { t } ( \mathbf { x } | \mathbf { x } _ { 0 } ) \right] \leq - \mathbb { E } \underset { \mathbf { x } _ { 0 } \sim q ( \cdot | \mathbf { x } ) } { \mathbf { x } } \quad [ \log f _ { \boldsymbol { \theta } } ( \mathbf { x } | \mathbf { x } _ { t - 1 } ) ] = L ^ { ( t ) } ( \boldsymbol { \theta } ) . } \\ { \mathbf { x } _ { 1 } \sim f _ { \boldsymbol { \theta } } ( \cdot | \mathbf { x } _ { 0 } ) } \\ { \mathbf { x } _ { t - 1 } \sim f _ { \boldsymbol { \theta } } ( \cdot | \mathbf { x } _ { t - 2 } ) } \end{array}
|
| 334 |
+
$$
|
| 335 |
+
|
| 336 |
+
# A.2 RELATION TO VAE
|
| 337 |
+
|
| 338 |
+
Variational Autoencoders (Kingma & Welling, 2013; Rezende et al., 2014) optimise the expected evidence lower bound (ELBO) on the marginal likelihood
|
| 339 |
+
|
| 340 |
+
$$
|
| 341 |
+
\begin{array} { r } { \log p ( \mathbf { x } ) \geq - D _ { \mathrm { K L } } ( q ( \mathbf { z } | \mathbf { x } ) \Vert p _ { 0 } ( \mathbf { z } ) ) + \mathbb { E } _ { \mathbf { z } \sim q ( \cdot | \mathbf { x } ) } \left[ \log p ( \mathbf { x } | \mathbf { z } ) \right] , } \end{array}
|
| 342 |
+
$$
|
| 343 |
+
|
| 344 |
+
with respect to parameters of both the variational distribution $q$ and generative distribution $p$ , where $p _ { 0 }$ remains the prior for for the latent variables. Denosing autoencoders limit the optimisation to the second term, assuming a fixed encoder $q$ , which is also the case with SUNDAE: identifying encoder with our corruption distribution and generative distribution $p$ with the distribution of our chain at the last step $p _ { T }$ , expected ELBO becomes
|
| 345 |
+
|
| 346 |
+
$$
|
| 347 |
+
\begin{array} { r l } & { \mathbb { E } _ { \mathbf { x } \sim p _ { \mathrm { d a t a } } } [ \log p _ { T } ( \mathbf { x } ) ] \geq - \mathbb { E } _ { \mathbf { x } \sim p _ { \mathrm { d a t a } } } \left[ D _ { \mathrm { K L } } ( q ( \mathbf { z } | \mathbf { x } ) \| p _ { 0 } ( \mathbf { z } ) ) \right] + \mathbb { E } _ { \mathbf { \phi } \sim p _ { \mathrm { d a t a } } } \left[ \log p _ { t } ( \mathbf { x } | \mathbf { x } ^ { c } ) \right] } \\ & { \qquad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ & { \qquad \geq - \mathbb { E } _ { \mathbf { x } \sim p _ { \mathrm { d a t a } } } \left[ D _ { \mathrm { K L } } ( q ( \mathbf { z } | \mathbf { x } ) \| p _ { 0 } ( \mathbf { z } ) ) \right] - L ^ { ( T ) } ( \theta ) . } \end{array}
|
| 348 |
+
$$
|
| 349 |
+
|
| 350 |
+
where the second inequality is a consequence of the upper bound 3. Hence, minimizing $L ^ { ( T ) }$ would lead to maximisation of the lower bound on the model likelihood.
|
| 351 |
+
|
| 352 |
+
# A.3 CORRUPTION FUNCTION
|
| 353 |
+
|
| 354 |
+
Our corruption function is obtained in stages:
|
| 355 |
+
|
| 356 |
+
• sample uniform expected corruption proportion $\alpha \sim \mathcal { U } ( [ 0 , 1 ] )$ , • sample Bernoulli mask, independently for each token $m \sim ( { \mathrm { B e r n o u l l i } } ( \alpha ) ) ^ { N }$ , • sample noise $\boldsymbol \eta \sim ( \mathcal { U } ( \{ 1 , 2 , \dots , v \} ) ^ { N }$ ,
|
| 357 |
+
|
| 358 |
+

|
| 359 |
+
Figure 3: Overview of target length prediction. During SUNDAE training, we simultaneously train the length predictor with cross-entropy loss and give ground-truth target length as input to the decoder (green dashed arrow), thus teacher-forcing it. During sampling, we give the most likely target length prediction from the network to the decoder (red dashed arrow).
|
| 360 |
+
|
| 361 |
+
• compute corruption $\pmb { x } ^ { c } = c _ { \alpha , \pmb { m } , \eta } ( \pmb { x } ) = ( 1 - \pmb { m } ) \cdot \pmb { x } + \pmb { m } \cdot \eta$ (with multiplications taken element-wise).
|
| 362 |
+
|
| 363 |
+
The distribution $p ^ { c } ( \cdot | \pmb { x } ) p _ { \mathrm { d a t a } } ( \pmb { x } )$ obtained in this process covers the entire input space $X$ , with probability skewed towards samples whose parts come from $p _ { \mathrm { d a t a } }$ . Note that except for corruption proportion, all steps are independent for all individual tokens. Given $\alpha$ $, p ^ { c _ { \alpha } } ( \pmb { y } | \pmb { x } )$ can be factorised as
|
| 364 |
+
|
| 365 |
+
$$
|
| 366 |
+
\prod _ { n } p ^ { c _ { \alpha } } ( \pmb { y } ^ { ( n ) } | \pmb { x } ^ { ( n ) } ) = \prod _ { n } h ( \pmb { y } ^ { ( n ) } ) ^ { T } \pmb { Q } _ { \alpha } h ( \pmb { x } ^ { ( n ) } ) ,
|
| 367 |
+
$$
|
| 368 |
+
|
| 369 |
+
where $Q _ { \alpha } = \alpha I + ( 1 - \alpha ) V$ is a transition matrix, $V$ is a $v \times v$ matrix with all entries equal to $\textstyle { \frac { 1 } { v } }$ , and ith ra $h ( a )$ denotes one-hot vector representation of corresponds to a multinomial-diffusion for $a \in \{ 1 , 2 , \ldots , v \}$ . In this con probability xt, corruptionof remaining $\alpha$ $\alpha$ in the same state, as proposed by (Hoogeboom et al., 2021).
|
| 370 |
+
|
| 371 |
+
# B DETAILS OF TARGET LENGTH PREDICTION
|
| 372 |
+
|
| 373 |
+
We provide a simplified high-level overview of the target length predictor in Figure 3. In the rest of this section we focus on implementation details.
|
| 374 |
+
|
| 375 |
+
The target length prediction module consists of 6 residual blocks. The length prediction module takes the source encodings $h _ { \pmb { x } } = e n c o d e r ( \pmb { x } )$ as the input, where $_ { \textbf { \em x } }$ is a sequence of source tokens. We first project $h _ { x }$ into a vector $\pmb { v _ { x } } \in \mathbb { R } ^ { d _ { L P } }$ , where $d _ { L P } = 1 2 8$ is the hidden size of the target length prediction module. We add a source length embedding vector $v _ { l e n } = S _ { ( N _ { s o u r c e } \times d _ { L P } ) } ( l _ { \pmb { x } } )$ to ${ \pmb v } _ { { \pmb x } }$ and obtain the final encoder state representation ${ \pmb v _ { \pmb x } ^ { \prime } } = { \pmb v _ { \pmb x } } + { \pmb v _ { l e n } }$ , where $l _ { x }$ is the number of the source tokens, and $N _ { s o u r c e } = 1 2 8$ is the maximum number of the source tokens. The target length prediction module then takes ${ \pmb v } _ { { \pmb x } }$ as the input and predicts the (downsampled) target length $\tilde { l } _ { d }$ . We found beneficial downsampling the target lengths for the length prediction by a factor of 2, i.e. $l _ { d } = \lceil { l } / 2 \rceil$ as compared to exact prediction of $l$ ; since the maximum number of target tokens is $N = 1 2 8$ , the maximum size of the outcome of length prediction is $N _ { d } = 6 4$ .
|
| 376 |
+
|
| 377 |
+
We prepend an embedding $\pmb { h } _ { l e n } \in \mathbb { R } ^ { d _ { e n c } }$ of target length to the source encodings $\begin{array} { r l } { h _ { x } } & { { } \in \ } \end{array}$ $\mathbb { R } ^ { N _ { s o u r c e } ^ { \bullet } \times d _ { e n c } }$ for each source example $_ { \textbf { \em x } }$ and allow the decoder to attend to it $\boldsymbol { \mathrm { \Delta } d _ { e n c } }$ here denotes the dimensionality of the encoder). $\boldsymbol { h } _ { l e n }$ is obtained by applying an embedding matrix $V _ { ( N _ { d } \times d _ { e n c } ) }$ to ground truth (downsampled) length $l _ { d }$ at training time, or to predicted one $\tilde { l } _ { d }$ during sampling. Note that optimisation of the length classification loss does not affect the encoder parameters.
|
| 378 |
+
|
| 379 |
+
# C EFFECTS OF TARGET LENGTH PREDICTION
|
| 380 |
+
|
| 381 |
+
It is shown empirically that the length of the translated results can affect BLEU score. Approximate search methods such as beam search usually incorporate a length normalization term in order to prevent the search algorithm to prefer shorter sentences. This is due to the fact that the scoring function is usually chosen as the likelihood modelled by the translation system, and beams containing shorter sequences tend to score higher likelihoods. In non-AR models, the end of sequence is not explicitly learned by the models, thus they can benefit by knowing the target sequence length in advance to generating the translation. However, the length of the target sequence cannot be known at inference time, therefore, a model should predict it instead. We show how BLEU scores can differ in WMT’14 translation tasks with and without the target length prediction in Figure 4a-4c.
|
| 382 |
+
|
| 383 |
+

|
| 384 |
+
Figure 4: Validation BLEU curves during training with and without target length prediction on WMT’ $1 4 ~ \mathrm { E N } { } \mathrm { D E }$ , D $\mathrm { E } { } \mathrm { E N }$ and $\operatorname { E N } { } \operatorname { F R }$ tasks shown in Figure 4a, 4b and 4c, respectively. Figure 4d shows the effect of unrolled denoising terms on translation quality, here $L ( k ) = L ^ { ( 1 : k ) }$ . All models are trained with a batch size of 256 using 20 different random seeds to display uncertainty.
|
| 385 |
+
|
| 386 |
+
Table 5: German-to-English translation process. Since initialization is quite long, we substitute the trailing tokens with [...]. Tokens changed from previous step are highlighted in gray. The process converges after 3 steps, while AR would take 10 steps (one for each token in the translation).
|
| 387 |
+
|
| 388 |
+
<table><tr><td>Source</td><td>Ich habe dort Dinge gesehen, aus denen ich gestarkt hervorgegangen bin.</td></tr><tr><td>Initialization</td><td> ThirVerschlMarta moderatopposed frameworks solidierweitert [..]</td></tr><tr><td>Step 1</td><td>I saw things there that which I I stronger..</td></tr><tr><td>Step 2</td><td>I saw things there from which I me stronger..</td></tr><tr><td>Step 3</td><td>I saw things there from which I emerged stronger.</td></tr><tr><td>Step 4</td><td>I saw things there from which I emerged stronger.</td></tr><tr><td>Reference</td><td>I saw some things there and came out stronger.</td></tr></table>
|
| 389 |
+
|
| 390 |
+
# D EFFECTS OF UNROLLED LOGITS LOSSES
|
| 391 |
+
|
| 392 |
+
We show how varying the number of unrolled logits can affect the MT performance in Figure 4d.
|
| 393 |
+
|
| 394 |
+

|
| 395 |
+
Figure 5: Model score (left) and BLEU (right) evolution throughout sampling for various temperatures. The reference score on the left hand side denotes the model score obtained for ground truth inputs. Overall, medium-low temperatures give the best results.
|
| 396 |
+
|
| 397 |
+
# E TRANSLATION ANALYSIS
|
| 398 |
+
|
| 399 |
+
We show how our algorithm works step-by-step for translation in Table 5. It is interesting to observe how the multimodality problem (Gu et al., 2017) gets resolved with more steps. Multimodality usually manifests in repeated tokens in translation, which intrinsically comes from inability to coordinate decisions when independently sampling multiple tokens at once. However, after a few steps all repetitions are corrected, because the model conditions on the previous step and hence can better coordinate further changes.
|
| 400 |
+
|
| 401 |
+
Figure 5 shows how the model and the BLEU scores evolve during sampling for various temperatures. The model score here refers to the cross-entropy between translation and model logits produced by giving this translation as the input. While for very low temperatures the scores initially improve faster, they are eventually outperformed by scores for higher temperatures, possibly due to low diversity induced by near-deterministic sampling. For very high temperatures, on the other hand, the scores improve slowly, and hence using such temperatures is rather impractical.
|
| 402 |
+
|
| 403 |
+
# F DISTILLATION SCORES OBTAINED WITH TRANSFORMER–BASE
|
| 404 |
+
|
| 405 |
+
In Table 6 we also present results for SUNDAE trained on data distilled from autoregressive Transformer-Base model, which allows direct comparison with similarly obtained Imputer scores (Saharia et al., 2020). The results show that SUNDAE noticeably outperforms Imputer at 8 steps for both $\Im \mathrm { N } \substack { \mathrm { D E } }$ and DE EN language pairs.
|
| 406 |
+
|
| 407 |
+
Table 6: Test BLEU scores of SUNDAE and Imputer (Saharia et al., 2020) distilled from AR Transformer–Base model on English-to-German $\mathrm { E N } { } \mathrm { D E } )$ ) and German-to-English $( \mathrm { D E \mathrm { \to E N } } )$ translation tasks.
|
| 408 |
+
|
| 409 |
+
<table><tr><td colspan="2"></td><td colspan="2">AR-distilled BLEU</td></tr><tr><td>Model</td><td>Steps (T)</td><td>EN→DE</td><td>DE→EN</td></tr><tr><td>Imputer (Saharia et al., 2020) (n =1)</td><td>4</td><td>27.9</td><td>30.9</td></tr><tr><td>Imputer (Saharia et al., 2020) (n=1)</td><td>8</td><td>27.9</td><td>31.1</td></tr><tr><td>SUNDAE (63M)</td><td></td><td></td><td></td></tr><tr><td>Deterministic (n=16)</td><td>4</td><td>28.00</td><td>31.82</td></tr><tr><td>Deterministic (n=16)</td><td>8</td><td>28.01</td><td>31.84</td></tr><tr><td>Deterministic (n = 16)</td><td>10</td><td>28.01</td><td>31.84</td></tr><tr><td>Stochastic (n= 16)</td><td>4</td><td>27.78</td><td>31.42</td></tr><tr><td>Stochastic (n = 16)</td><td>8</td><td>28.14</td><td>31.78</td></tr><tr><td>Stochastic (n=16)</td><td>10</td><td>28.11</td><td>31.87</td></tr><tr><td>Stochastic (n=16)</td><td>16</td><td>28.11</td><td>31.87</td></tr><tr><td>Stochastic (n=16)</td><td>32</td><td>28.02</td><td>31.92</td></tr></table>
|
| 410 |
+
|
| 411 |
+
# G SACREBLEU SCORES FOR WMT’14 EXPERIMENTS
|
| 412 |
+
|
| 413 |
+
SacreBLEU (Post, 2018) is a library for computing BLEU score7 that does not require the user to manually tokenize the reference and candidate translations. We report BLEU scores measured with SacreBLEU library in order to provide a reference for future studies. We show all the BLEU scores in Table 7.
|
| 414 |
+
|
| 415 |
+
<table><tr><td></td><td></td><td colspan="2">EN→DE</td><td colspan="2">DE→EN</td><td colspan="2">EN→FR</td></tr><tr><td>Model</td><td>Steps (T)</td><td>BLEU</td><td>BLEU*</td><td>BLEU</td><td>BLEU*</td><td>BLEU</td><td>BLEU*</td></tr><tr><td>Deterministic (n = 16)</td><td>2</td><td>20.29</td><td>20.13</td><td>25.28</td><td>24.83</td><td>31.60</td><td>30.51</td></tr><tr><td>Deterministic (n =16)</td><td>3</td><td>24.07</td><td>23.84</td><td>28.64</td><td>28.12</td><td>35.88</td><td>34.68</td></tr><tr><td>Deterministic (n =16)</td><td>4</td><td>25.01</td><td>24.75</td><td>29.53</td><td>28.99</td><td>36.85</td><td>35.61</td></tr><tr><td>Deterministic (n=16)</td><td>10</td><td>25.54</td><td>25.25</td><td>30.11</td><td>29.54</td><td>37.15</td><td>35.92</td></tr><tr><td>Stochastic (n = 16)</td><td>4</td><td>23.05</td><td>22.75</td><td>28.13</td><td>27.62</td><td>35.27</td><td>34.03</td></tr><tr><td>Stochastic (n = 16)</td><td>8</td><td>26.22</td><td>26.08</td><td>30.48</td><td>30.00</td><td>37.45</td><td>36.16</td></tr><tr><td>Stochastic (n=16)</td><td>10</td><td>26.25</td><td>25.99</td><td>30.80</td><td>30.24</td><td>27.53</td><td>36.23</td></tr><tr><td>Stochastic (n=16)</td><td>32</td><td>26.57</td><td>26.31</td><td>30.74</td><td>30.11</td><td>37.60</td><td>36.20</td></tr></table>
|
| 416 |
+
|
| 417 |
+
Table 7: Test BLEU without AR distillation (raw). Scores computed with SacreBLEU library are denoted as BLEU?.
|
| 418 |
+
|
| 419 |
+
# H UNCONDITIONAL SAMPLES FOR C4
|
| 420 |
+
|
| 421 |
+
We provide samples for our model trained on C4 dataset as described in the main text (Section 3.2).
|
| 422 |
+
All of them resemble reasonable-quality internet texts, except perhaps sample $\# 4$ .
|
| 423 |
+
|
| 424 |
+
Table 8: Unconditional samples from our model trained on C4 (without cherry-picking). Since C4 was crawled from the web, newline symbols are abundant both in the training data and the samples.
|
| 425 |
+
|
| 426 |
+
<table><tr><td>Index</td><td>Sample from our model</td></tr><tr><td>1</td><td>Ihadto gobackandforthandstartovertoseewhathadhappened,what was working,andallthepeces wereintherightplaces.</td></tr><tr><td>2</td><td>tossed in a delicious sauce.</td></tr><tr><td></td><td>Beef brisket is a hearty cut of meat -thick and tender. When you make a lot of meat</td></tr><tr><td>3</td><td>canexpect to see more of the same in 'Wild Herring',although not very often enough to achieve the same effect.</td></tr><tr><td></td><td>In 'Herring',</td></tr><tr><td>4</td><td>,she was considered to be a fake.</td></tr><tr><td></td><td>Dr. Deborah Chienna has 93 in the last 365 days., headaches,stomach pain, sore</td></tr><tr><td></td><td>as an artist.</td></tr><tr><td>5</td><td>printing photo cards,artwork,and posters.</td></tr><tr><td></td><td>email me for some ideas.</td></tr><tr><td></td><td>"Rebecca's studio</td></tr><tr><td>6</td><td>Jesee</td></tr><tr><td>7</td><td>'s location.</td></tr><tr><td></td><td>ThisresearchwassuportedbyagrantfomtheNationalAsociatioforteAdvancementofSciencetroughtheU.SDeparmentofEnergy</td></tr><tr><td>8</td><td>different artists,we would love to show you the piece we have in our shop!</td></tr><tr><td></td><td>Keep an eye on our Gallery-all you have to do is</td></tr><tr><td>9</td><td>6.3 million from $8.8 million reported by Zacks.com back in February.</td></tr><tr><td></td><td>Brad Brickley, general manager of Irvine, Calif.-based</td></tr><tr><td>10</td><td>towritingwitteusgetomeofhsswillspendimeinheasroomtadomfromthialook.Fomewe</td></tr></table>
|
| 427 |
+
|
| 428 |
+
# I UNCONDITIONAL SAMPLES FOR EMNLP2017 NEWS
|
| 429 |
+
|
| 430 |
+
We provide samples from our model trained on EMNLP2017 News dataset in Table 9, accompanying the quantitative results in the main text (Section 3.2). These samples are obtained at temperature 0.8. None of them appear in the training set, so the model does not merely memorize the data it is given. To provide a point of reference, we also include samples from ScratchGAN (d’Autume et al., 2019).
|
| 431 |
+
|
| 432 |
+
<table><tr><td>Index</td><td>Sample</td></tr><tr><td colspan="2">ScratchGAN</td></tr><tr><td>1</td><td>We are pleased for the trust and it was incredible,our job quickly learn the shape and get on that way.</td></tr><tr><td>2</td><td>ButIobviously have him with the guys,maybe in Melbourne,the players that weren 'tquite clear there .</td></tr><tr><td>3</td><td>Thereistask nowthatthe UKwillmakeforthe societyto seek secureenough governmentbudget fundreduce theeconomy</td></tr><tr><td>4</td><td>KeithisalsoeldidTed’sucessfulcapaspoesoanforsudentsdyougrotrshastodatafato</td></tr><tr><td>5</td><td>Police aid howaDemocratic police oficer,would choose the honorof alcoholand reduce his defenseand foundation.</td></tr><tr><td>6</td><td>We do not go the Blues because that Ispent in ten months and soIdidn'thave a great job in a big revolution.</td></tr><tr><td>7</td><td>The28-year-old-son Dr Pricesaid she would havebeen invitedto Britain forher”friend”inalovely family.</td></tr><tr><td>8</td><td>And as long as it is lower about,our families are coming from a friend of a family</td></tr><tr><td colspan="2">SUNDAE</td></tr><tr><td>1</td><td>Ms Sturgeon was quoted as saying that she is prepared to quit the EU by the end of March next year .</td></tr><tr><td>2</td><td>They’ve been around a long time,but it’s too natural to ignore what has happened .</td></tr><tr><td>3</td><td>” It’sa busy road,and we’ve got to get through it,”he said.</td></tr><tr><td>4</td><td>That means some voters will decide if they'll change their minds before the first day of the debate .</td></tr><tr><td>5</td><td>”We don’t learn very much from my point of view because we live here,”he said.</td></tr><tr><td>6</td><td>”I spent my whole life at the stage and nowI’ma normal father,”hecontinued.</td></tr><tr><td>7</td><td>Whether your phone is near or online,you can check if your phone is tied to your Instagram account .</td></tr><tr><td>8</td><td>”Itis onlytoo earlyto know why the incidentoccurred shortlyafter it happened,”he toldthe Associated Press.</td></tr><tr><td>9</td><td>The website will be updated on a day -to -day basis,as well as other special services</td></tr><tr><td>10</td><td>So it’stoo early to know exactly what each candidate has to say in terms of the American election .</td></tr></table>
|
| 433 |
+
|
| 434 |
+
Table 9: Unconditional samples from our model SUNDAE trained on EMNLP2017 News (without cherry-picking). We also provide samples from ScratchGAN (d’Autume et al., 2019) for comparison.
|
| 435 |
+
|
| 436 |
+
# J PSEUDOCODE OF SUNDAE
|
| 437 |
+
|
| 438 |
+
We provide Python-like pseudocode for our method in Listing 1. The main functions are build loss fn, which should be used for training, and sampling fn which should be used for sampling. For simplicity, we consider the decoder-only setup as in unconditional generation experiments (Section 3.2).
|
| 439 |
+
|
| 440 |
+
def get_random_text(shape, vocab_size): 2 random_text $=$ rand_int(shape, minva $\beth = 0$ , maxval $=$ vocab_size) return random_text 5 6 def corrupt_text(batched_text, vocab_size): corruption_prob_per_sequence $=$ rand_uniform([batched_text.shape[0], 1]) 8 rand $=$ rand_uniform(batched_text.shape) 9 mask $=$ rand $<$ corruption_prob_per_sequence 10 random_text $=$ get_random_text(batched_text.shape, vocab_size) 11 corrupted $=$ mask $\star$ random_text $^ +$ (1 - mask) $\star$ batched_text 12 return corrupted 13 14 15 def build_logits_fn(vocab_size, n_unrolled_steps, enable_sampling): 16 17 def logits_fn(batched_text): 18 model $=$ Transformer(vocab_size, use_causal_mask ${ \bf \Phi } . = { \bf { \Phi } }$ False) 19 20 def fn(input_batched_text): 21 logits $=$ model(input_batched_text) 22 return logits 23 24 def unrolled_fn(input_batched_text): 25 samples $=$ corrupt_text(input_batched_text, vocab_size) 26 all_logits $=$ [] 27 for _ in range(n_unrolled_steps):
|
| 441 |
+
|
| 442 |
+
28 logits $=$ fn(samples)
|
| 443 |
+
29 samples $=$ stop_grad(rand_categorical(logits))
|
| 444 |
+
30 all_logits $+ =$ [logits]
|
| 445 |
+
31 final_logits $=$ concatenate(all_logits, axi $\mathtt { S } = 0$ )
|
| 446 |
+
32 return final_logits
|
| 447 |
+
33
|
| 448 |
+
34 if enable_sampling:
|
| 449 |
+
35 return fn(batched_text)
|
| 450 |
+
36 else:
|
| 451 |
+
37 return unrolled_fn(batched_text)
|
| 452 |
+
38
|
| 453 |
+
39 return logits_fn
|
| 454 |
+
40
|
| 455 |
+
41
|
| 456 |
+
42 def build_loss_fn(vocab_size, n_unrolled_step ${ \sf S } = 2$ ):
|
| 457 |
+
43 logits_fn $=$ build_logits_fn(
|
| 458 |
+
44 vocab_size, n_unrolled_steps, enable_sampling $=$ False)
|
| 459 |
+
45
|
| 460 |
+
46 def loss_fn(batched_text):
|
| 461 |
+
47 logits $=$ logits_fn(batched_text)
|
| 462 |
+
48 # repeat batched_text to fit unrolled logits
|
| 463 |
+
49 targets $=$ concatenate([batched_text] $\star$ n_unrolled_steps, axi $\scriptstyle \vdots = 0$ )
|
| 464 |
+
50 one_hot_targets $=$ one_hot(targets, vocab_size)
|
| 465 |
+
51 loss_per_token $=$ -sum(
|
| 466 |
+
52 one_hot_targets $\star$ log_softmax(logits), axi $\hphantom { 0 } \mathsf { S } = - 1$ )
|
| 467 |
+
53 loss $=$ mean(loss_per_token)
|
| 468 |
+
54 return loss
|
| 469 |
+
55
|
| 470 |
+
56 return loss_fn
|
| 471 |
+
57
|
| 472 |
+
58
|
| 473 |
+
59 def sampling_fn(logits_fn, steps, temperature, batch_size,
|
| 474 |
+
60 sequence_length, vocab_size):
|
| 475 |
+
61 batched_text $=$ get_random_text(
|
| 476 |
+
62 shape $=$ [batch_size, sequence_length], vocab_size)
|
| 477 |
+
63 for _ in range(steps):
|
| 478 |
+
64 logits $=$ logits_fn(batched_text)
|
| 479 |
+
65 samples $=$ rand_categorical(logits / temperature)
|
| 480 |
+
66 batched_text $=$ samples
|
| 481 |
+
67 return batched_text
|
md/dev/UaXD4Al3mdb/UaXD4Al3mdb.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Masked Autoencoders As Spatiotemporal Learners
|
| 2 |
+
|
| 3 |
+
Christoph Feichtenhofer∗
|
| 4 |
+
|
| 5 |
+
Haoqi Fan∗ Yanghao Li Kaiming He
|
| 6 |
+
|
| 7 |
+
Meta AI, FAIR
|
| 8 |
+
|
| 9 |
+
https://github.com/facebookresearch/mae_st
|
| 10 |
+
|
| 11 |
+
# Abstract
|
| 12 |
+
|
| 13 |
+
This paper studies a conceptually simple extension of Masked Autoencoders (MAE) [31] to spatiotemporal representation learning from videos. We randomly mask out spacetime patches in videos and learn an autoencoder to reconstruct them in pixels. Interestingly, we show that our MAE method can learn strong representations with almost no inductive bias on spacetime (only except for patch and positional embeddings), and spacetime-agnostic random masking performs the best. We observe that the optimal masking ratio is as high as $90 \%$ (vs. $7 5 \%$ on images [31]), supporting the hypothesis that this ratio is related to information redundancy of the data. A high masking ratio leads to a large speedup, e.g., $> 4 \times$ in wall-clock time or even more. We report competitive results on several challenging video datasets using vanilla Vision Transformers [18]. We observe that MAE can outperform supervised pre-training by large margins. We further report encouraging results of training on real-world, uncurated Instagram data. Our study suggests that the general framework of masked autoencoding (BERT [15], MAE [31], etc.) can be a unified methodology for representation learning with minimal domain knowledge.
|
| 14 |
+
|
| 15 |
+
# 1 Introduction
|
| 16 |
+
|
| 17 |
+
The deep learning community is experiencing a trend of unifying methodologies for solving problems in different areas, such as language, vision, speech, and more. For architectures, Transformers [67] have been successfully introduced into computer vision [18] and established as a general building block in both language and vision. For self-supervised representation learning, the denoising/masked autoencoding methodology [68] in BERT [15] has been shown effective on learning visual representations from images [31]. Towards unifying methodologies, less domain knowledge (“fewer inductive biases” [18]) is introduced for a specific problem, which urges the models to learn useful knowledge almost purely from data.
|
| 18 |
+
|
| 19 |
+
Following this philosophy, we study extending Masked Autoencoders (MAE) [31] to the problem of spatiotemporal representation learning. Our method is simple: we randomly mask out spacetime patches in videos and learn an autoencoder to reconstruct them (Fig. 1). Our method has minimal domain knowledge: the only spacetime-specific inductive bias is on embedding the patches and their positions; all other components are agnostic to the spacetime nature of the problem. In particular, our encoder and decoder are both vanilla Vision Transformers [18] with no factorization or hierarchy, and our random mask sampling is agnostic to the spacetime structures. Our method predicts pixel values and uses no extra problem-specific tokenizer. In a nutshell, our method is simply MAE applied to the set of spacetime patches. Despite minimal inductive biases, our method achieves strong empirical results, suggesting that useful knowledge can be learned from data.
|
| 20 |
+
|
| 21 |
+
It is hypothesized in [31] that the masking ratio (i.e., percentage of removed tokens) in masked autoencoding methods is related to the information redundancy of the problems. For example, natural images are more information-redundant than languages and thus the optimal masking ratio is higher (e.g., than BERT [15]). Our observations on video data support this hypothesis. We find that the optimal masking ratio of MAE is $90 \%$ for videos (Fig. 2), higher than the masking ratio of $7 5 \%$ for its image counterpart [31]. This can be understood as a consequence of natural video being correlated.
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
Figure 1: Masked Autoencoders as spatiotemporal learners. We mask a large subset (e.g., $90 \%$ ) of random patches in spacetime. An encoder operates on the set of visible patches. A small decoder then processes the full set of encoded patches and mask tokens to reconstruct the input. Except for patch and positional embeddings, neither the encoder, the decoder, nor the masking strategy, has any spatiotemporal inductive bias.
|
| 25 |
+
|
| 26 |
+
To the extreme, if a video has $T$ identical static frames, randomly sampling $1 / T$ of all spacetime patches would reveal most of the static frame. Because slow motion is more likely than fast motion in natural videos, the masking ratio can be very high as we observe empirically.
|
| 27 |
+
|
| 28 |
+
The higher masking ratio leads to a more efficient solution in practice. Following the MAE in [31] that applies the encoder only on visible tokens, a masking ratio of $90 \%$ reduces the encoder time and memory complexity to ${ < } 1 / 1 0$ . Put together with a small decoder [31], the MAE pre-training can achieve a theoretically $7 . 7 \times$ reduction in computation vs. encoding all tokens. In fact, the computation reduction is so large that the data loading time becomes a new bottleneck; even so, we record a $4 . 1 \times$ wall-clock speedup. Such a significant speedup is of great importance for video research that is large-scale and time-consuming.
|
| 29 |
+
|
| 30 |
+
We report strong results on a variety of video recognition datasets. Our MAE pre-training greatly improves generalization performance: on Kinetics-400 [35], it increases the accuracy of ViT-Large [18] by absolute $13 \%$ vs. training from scratch, while it takes less wall-clock training time overall (pre-training plus fine-tuning). Our MAE pre-training can outperform its supervised pre-training counterpart by big margins. Using vanilla ViT [18], our method achieves competitive results with previous state-of-the-art methods that incorporate more domain knowledge. We also report encouraging results using MAE pre-trained on 1 million random, uncurated Instagram videos. These results suggest that self-supervised learning on videos can be tackled in a way similar to its counterparts on language [15] and images [31], under a unified framework.
|
| 31 |
+
|
| 32 |
+
# 2 Related Work
|
| 33 |
+
|
| 34 |
+
Denoising autoencoders. Denoising autoencoders (DAE) [68, 69] present a general methodology for learning representations by reconstructing clean signals from corrupted inputs. Masking as a type of noise dates back to at least a decade ago [69]. One of its most successful developments is BERT [15], which is conceptually masked autoencoding on language tokens.
|
| 35 |
+
|
| 36 |
+
Denoising/masked autoencoding methods for computer vision have been making continuous progress [50, 9, 18, 31]. A series of recent methods are based on Transformer architectures [67] and are towards a unified solution between vision and language. iGPT [9] pioneers this direction by training Transformers on pixels as tokens. The ViT paper [18] makes a revolutionary step forward by using patches as tokens. It not only establishes strong Transformer architectures for vision tasks, but also explores masked prediction with patches. MAE [31] returns to the basics of the autoencoding concept [68] and draws attention to the decoding aspect. The presence of a meaningful decoder provides more flexibility, e.g., enabling the encoder to operate only on visible patches and leading to a more efficient solution. It empirically shows that a high masking ratio is essential for image tasks [31]. Our study follows this line of research.
|
| 37 |
+
|
| 38 |
+

|
| 39 |
+
Figure 2: Visualizations on the Kinetics-400 [35] validation set (masking ratio $90 \%$ ). We show the original video (top), masked video (middle), and MAE output (bottom) for each sample. This model reconstructs the original pixels. The video size is $1 6 { \times } 2 2 4 { \times } 2 2 4$ and the spacetime patch size is $2 \times 1 6 \times 1 6$ (the temporal patch size of 2 is not visualized here). Each sample has $8 \times 1 4 \times 1 4 = 1 5 6 8$ tokens with 156 being visible. For better visualizations, the known patches in the output are from the original input. Fig. 7 shows more examples.
|
| 40 |
+
|
| 41 |
+

|
| 42 |
+
Figure 3: Visualizations of the same pre-trained model in Fig. 2 but with a masking ratio of $95 \%$ .
|
| 43 |
+
|
| 44 |
+
Instead of predicting pixels [9, 18, 31, 80], another line of research focuses on the tokenization of the prediction targets [3, 17, 77]. BEiT [3] proposes to use pre-trained dVAE [47, 55] as the reconstruction target. The dVAE tokenizer can be improved by perceptual or adversarial losses [17]. MaskFeat [77] shows that HoG [13] as prediction targets performs strongly.
|
| 45 |
+
|
| 46 |
+
Self-supervised learning on videos. The presence of the temporal dimension is a focus of selfsupervised learning on video data. Related topics include temporal coherence (‘slowness’) [79, 25], future prediction [61, 72, 70, 45, 44, 71, 16], object motion [1, 75, 49, 76], temporal ordering [46, 23, 38, 78, 81], spatiotemporal contrast [58, 62, 30, 22, 51, 56], etc.
|
| 47 |
+
|
| 48 |
+
Our method also relies on the temporal coherence of videos, but it approaches this goal implicitly. In fact, as our method is largely agnostic to spacetime, the main opportunity for it to make use of the temporal coherence is a higher masking ratio (e.g., $90 \%$ ), which assumes that videos are more information-redundant than images.
|
| 49 |
+
|
| 50 |
+

|
| 51 |
+
Figure 4: Mask sampling. (a): Random sampling that is spacetime-agnostic. (b): Space-only random sampling, broadcasted to all time steps (“tube” masking [77]). (c): Time-only random sampling, broadcasted to all spatial locations (“frame” masking [77]). (d): Block-wise sampling [3] in spacetime, removing large regions (“cube” masking [77]). In this illustration, $T \times H \times W$ is $8 \times 1 4 \times 1 4$ ; green tokens are kept and others are masked out.
|
| 52 |
+
|
| 53 |
+
There has been growing interest in masking-based methods for self-supervised learning on videos. Previous works focus on tokenizing the prediction targets for the use of videos [65, 73, 77]. Our autoencoding method operates on pixels, which is simpler and requires no extra data or domain knowledge on the tokenizer. Importantly, our method greatly improves the efficiency of learning. The practical speedup is of central importance for video-related research, which is in general larger-scale and more time-consuming.
|
| 54 |
+
|
| 55 |
+
Our work is done independently and concurrently with [66] on a related method.
|
| 56 |
+
|
| 57 |
+
# 3 Method
|
| 58 |
+
|
| 59 |
+
Our method is a simple extension of MAE [31] to spacetime data (Fig. 1). Our goal is to develop the method under a general and unified framework, with as little domain knowledge as possible.
|
| 60 |
+
|
| 61 |
+
Patch embedding. Following the original ViT [18], given a video clip, we divide it into a regular grid of non-overlapping patches in spacetime [4, 2, 19, 77]. The patches are flattened and embedded by linear projection [18]. Positional embeddings [67] are added to the embedded patches. The patch and positional embedding process is the only process that is spacetime-aware.
|
| 62 |
+
|
| 63 |
+
Masking. We sample random patches without replacement from the set of embedded patches. This random sampling is agnostic to the spacetime structure (Fig. 4 (a)). This structure-agnostic sampling strategy is analogous to that of BERT in 1D [15] and MAE in 2D [31].
|
| 64 |
+
|
| 65 |
+
It is hypothesized in [31] that the optimal masking ratio is related to the information redundancy of the data. With unstructured random masking, BERT [15] uses a masking ratio of $15 \%$ for language and MAE [31] uses a ratio of $7 5 \%$ for images, suggesting that images are more information-redundant than language. Our empirical results on videos support this hypothesis. The optimal masking ratio we observe is $90 \%$ . This is in line with the common assumption that natural videos are more informationredundant than images because of temporal coherence. Fig. 2 and 3 present our MAE reconstruction results on unseen validation data with a masking ratio of $90 \%$ and $9 5 \%$ .
|
| 66 |
+
|
| 67 |
+
The spacetime-agnostic sampling can be more effective than structure-aware sampling strategies, e.g., space-only, time-only, or block-wise sampling (Fig. 4 (b-d)). As neighboring patches in space or in time (Fig. 4(b, c)) are coherent, with a very high masking ratio, space-only or time-only sampling may retain less information and yield an overly difficult pre-training task. For example, time-only sampling from 8 frames with a masking ratio of $8 7 . 5 \%$ means keeping only a single frame, which presents an overly challenging task of predicting the future and past given only one frame. We observe that optimal masking ratios for structure-aware sampling are in general lower. In contrast, the spacetime-agnostic sampling better utilizes the limited number of visible patches and thus allows to use a higher masking ratio.
|
| 68 |
+
|
| 69 |
+
Autoencoding. Our encoder is a vanilla ViT [18] applied only on the visible set of embedded patches, following [31]. This design greatly reduces time and memory complexity and leads to a more practical solution. A masking ratio of $90 \%$ reduces the encoder complexity to ${ < } 1 / 1 0$ (noting that self-attention is quadratically-complex w.r.t. the token set size).
|
| 70 |
+
|
| 71 |
+
Our decoder is another vanilla ViT on the union of the encoded patch set and a set of mask tokens [31]. Decoder-specific positional embeddings are added to this set [31]. The decoder is designed to be smaller than the encoder [31]. Although the decoder processes the full set, its complexity is smaller than the encoder (e.g., ${ \sim } 1 / 2 0$ per token). In our default setting, the overall autoencoder has a complexity reduction of $7 . 7 \times \nu s .$ . full encoding (more discussions are in Sec. 5.1 and Table 1).
|
| 72 |
+
|
| 73 |
+
The decoder predicts the patches in the pixel space. In principle we can simply predict a full spacetime patch (e.g., $t \times 1 6 \times 1 6 )$ ); in practice, we find it sufficient to predict a single time slice of the patch $( 1 6 \times 1 6 )$ , which keeps the prediction layer’s size manageable. We predict the original pixels or their per-patch normalized values [31] (compared in Table 2b). The training loss function is the mean squared error (MSE) between the prediction and its target, averaged over unknown patches [15].
|
| 74 |
+
|
| 75 |
+
The encoder and decoder are agnostic to the spacetime structure of the problem. There is no hierarchy or spacetime factorization, in contrast to the leading architectures [4, 2, 19]. Our method relies on the global self-attention to learn useful knowledge from data, following the spirit of [18].
|
| 76 |
+
|
| 77 |
+
# 4 Implementation
|
| 78 |
+
|
| 79 |
+
Data pre-processing. For MAE pre-training, our default input size is 16 frames each with $2 2 4 \times 2 2 4$ pixels (i.e., $1 6 { \times } 2 2 4 { \times } 2 2 4 ,$ . The 16 frames are sampled from the raw video with a temporal stride of 4 (i.e., $1 6 \times 4$ sampling in the literature [21]), and the starting frame is randomly sampled. In the spatial domain, we perform random resized cropping [63] with a scale range of [0.5, 1], and random horizontal flipping. We do not apply other data augmentations unless noted.
|
| 80 |
+
|
| 81 |
+
Our MAE pre-training is so fast in computation that data loading becomes a new bottleneck that dominates running time in our setup. We adopt repeated sampling [33]1 to alleviate this problem. Each time a raw video is loaded and decompressed, we take multiple (4 by default) samples from it. This reduces the data loading and decompressing time per sample. We note that repeated sampling does not change the number of samples seen; it only influences the orders of the samples seen during training. We always count epochs as “effective epochs”, i.e., how many times each raw video is sampled throughout training.
|
| 82 |
+
|
| 83 |
+
Architecture. Our encoder and decoder are the vanilla ViT architectures [18]. We use a temporal patch size of 2 [2, 19, 77] and a spatial patch size of $1 6 \times 1 6$ [18], denoted as $2 \times 1 6 \times 1 6$ . We use the same patch size for ViT-B/L/H [18] for simplicity. For a $1 6 \times 2 2 4 \times 2 2 4$ input, this patch size produces $8 \times 1 4 \times 1 4$ tokens.
|
| 84 |
+
|
| 85 |
+
We adopt separable positional embeddings for the encoder. We have two positional embeddings, one for space and the other for time. The spacetime positional embeddings are the sum of them. This separable implementation prevents the size of positional embeddings growing too large in 3D. We use learnable positional embeddings; the sin-cos variant [67] works similarly.
|
| 86 |
+
|
| 87 |
+
Settings. Our MAE pre-training configuration mostly follows [31]. We use the AdamW optimizer [43] with a batch size of 512. We evaluate the pre-training quality by end-to-end fine-tuning. The choice of evaluating by fine-tuning (instead of linear probing) follows [3, 31]. Our inference process follows the common practice of multi-view testing [74, 21]: it takes $K$ temporal clips (by default $K { = } 7$ on Kinetics) to cover the video length, and for each clip it takes 3 spatial views to cover the longer spatial axis (denoted as $K { \times } 3 )$ ). The final prediction is the average of all views. The implementation details and hyper-parameters are in the appendix.
|
| 88 |
+
|
| 89 |
+
# 5 Experiments
|
| 90 |
+
|
| 91 |
+
In Sec. 5.1 and Sec. 5.2 we perform ablation experiments on Kinetics-400 (K400) [35]. We do MAE self-supervised pre-training and then fine-tune the encoder with supervision for evaluation. We report top-1 classification accuracy $( \% )$ on the K400 validation set. In Sec. 5.3 we study more pre-training datasets and downstream tasks.
|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
Figure 5: MAE pre-training plus fine-tuning is much more accurate and faster than training from scratch. Here the $\mathbf { X }$ -axis is the wall-clock training time (128 A100 GPUs), and the y-axis is the 1-view accuracy on Kinetics-400 validation. The table shows the final accuracy. The model is ViT-L.
|
| 95 |
+
|
| 96 |
+
<table><tr><td>MAE w/</td><td>acc.</td><td>FLOPs</td><td>compute</td><td>load+compute</td></tr><tr><td>encoder w/ [M]</td><td>84.3</td><td>627.5 G</td><td>141.1 hr</td><td>147.5 hr</td></tr><tr><td>encoder w/o [M]</td><td>84.4</td><td>81.0G</td><td>24.5 hr</td><td>35.8 hr</td></tr><tr><td>gain</td><td></td><td>7.7×</td><td>5.8×</td><td>4.1×</td></tr></table>
|
| 97 |
+
|
| 98 |
+
Table 1: Training time comparison between a dense encoder (w/ [M]) and a sparse encoder (w/o [M]) in MAE. The encoder is ViT-L (1024-d, 24-block); the decoder is our default (512-d, 4-block). With a masking ratio of $90 \%$ , the sparse variant reduces FLOPs by $7 . 7 \times$ . This reduces computation time by $5 . 8 \times$ . In our infra, computation is so fast that data loading becomes a bottleneck, which leads to an actual speedup of $4 . 1 \times$ . Profiling is with synchronized SGD over 16 nodes, each with 8 A100 GPUs and 80 CPU cores. The training length is 800 epochs.
|
| 99 |
+
|
| 100 |
+
# 5.1 Performance
|
| 101 |
+
|
| 102 |
+
Fig. 5 compares MAE pre-training vs. no pre-training (i.e., training from scratch), using vanilla ViT-L [18]. The from-scratch recipe follows [77] and has $7 1 . 4 \%$ accuracy.2 As a comparison, using MAE pre-training for 800 epochs, the same vanilla ViT-L achieves $8 4 . 4 \%$ accuracy, which has a large increase of $1 3 . 0 \%$ absolute vs. training from scratch. This gap is much larger than that on image recognition tasks ${ \sim } 3 \%$ [31]), suggesting that MAE pre-training is more helpful for video recognition.
|
| 103 |
+
|
| 104 |
+
In addition to the accuracy gain, MAE pre-training can reduce the overall training cost, as plotted in Fig. 5. The 800-epoch MAE pre-training only takes 35.8 hours. A short fine-tuning (100 epochs here), which takes 16.3 hours, achieves good accuracy thanks to pre-training. The overall training time can be shorter than training from scratch (e.g., 400 epochs, 65.2 hours), which converges more slowly without pre-training. This shows that MAE is a practical solution to video recognition.
|
| 105 |
+
|
| 106 |
+
MAE pre-training is fast because its encoder is only applied on the sparse set of visible patches, without the mask token [M]. We profile the pre-training performance in Table 1. With a masking ratio of $90 \%$ , the sparse encoder reduces the FLOPs (floating-point operations) by $> 1 0 \times$ . After counting the decoder, the sparse design of MAE reduces FLOPs by $7 . 7 \times$ . In our implementation, this reduction should produce a $5 . 8 \times$ computational speedup, if the video data were already pre-processed and loaded in memory. Our speedup ratio is so high that the video pre-processing and loading time becomes a new bottleneck. In our system, the data loading step increases the wall-clock training time from 24.5 hours to 35.8 hours. Nevertheless, this still leads to a significant speedup of $4 . 1 \times$ . 3
|
| 107 |
+
|
| 108 |
+
# 5.2 Ablation experiments
|
| 109 |
+
|
| 110 |
+
Masking ratio. Fig. 6 shows the influence of the masking ratio jointly with the pre-training length. The ratio of $90 \%$ works the best. The ratio of $9 5 \%$ performs surprisingly well, which can catch up if trained long enough (Fig. 6 left). A higher masking ratio leads to fewer tokens encoded by the encoder; to have a more comprehensive look, we plot the results w.r.t. the total number of encoded tokens (Fig. 6 right). Under this measure, the ratios of $90 \%$ and $9 5 \%$ perform closely.
|
| 111 |
+
|
| 112 |
+
The lower masking ratios of $7 5 \%$ and $50 \%$ perform worse, even though the encoder sees more tokens and has higher computation cost. The ratio of $7 5 \%$ is optimal for its image counterpart [31], but not for videos. This observation can be explained by the assumption that video data is more information-redundant.
|
| 113 |
+
|
| 114 |
+

|
| 115 |
+
Figure 6: Masking ratio. Every point represents a single pre-training and fine-tuning experiment. Left: $\mathbf { X }$ -axis is the epochs (proportional to the number of decoded tokens). Right: $\mathbf { X }$ -axis is the number of encoded tokens.
|
| 116 |
+
|
| 117 |
+
<table><tr><td>case</td><td>ratio</td><td>acc.</td></tr><tr><td>agnostic</td><td>90</td><td>84.4</td></tr><tr><td>space-only</td><td>90</td><td>83.5</td></tr><tr><td>time-only</td><td>75</td><td>79.1</td></tr><tr><td>block</td><td>75</td><td>83.2</td></tr></table>
|
| 118 |
+
|
| 119 |
+
<table><tr><td>case</td><td>acc.</td></tr><tr><td>pixel (w/o norm)</td><td>83.8</td></tr><tr><td>pixel (w/ norm)</td><td>84.4</td></tr><tr><td>HOG</td><td>84.0</td></tr><tr><td>dVAE token</td><td>83.8</td></tr></table>
|
| 120 |
+
|
| 121 |
+
<table><tr><td>case</td><td>acc.</td></tr><tr><td>center crop</td><td>83.9</td></tr><tr><td>rand crop</td><td>84.4</td></tr><tr><td>rand crop (stronger)</td><td>83.4</td></tr><tr><td>rand crop + color jit</td><td>83.8</td></tr></table>
|
| 122 |
+
|
| 123 |
+
(a) Mask sampling. See also Fig. 4. Random sampling that is spacetimeagnostic works the best.
|
| 124 |
+
|
| 125 |
+
(b) Reconstruction target. Pixels as reconstruction targets work well with no domain knowledge.
|
| 126 |
+
|
| 127 |
+
(c) Data augmentation. Strong augmentation is unnecessary.
|
| 128 |
+
|
| 129 |
+
<table><tr><td>rep.</td><td>acc.</td><td>speed</td></tr><tr><td>1</td><td>83.7</td><td>1.0×</td></tr><tr><td>2</td><td>84.3</td><td>1.8×</td></tr><tr><td>4</td><td>84.4</td><td>3.0×</td></tr></table>
|
| 130 |
+
|
| 131 |
+
<table><tr><td>dim</td><td>acc.</td></tr><tr><td>128</td><td>80.8</td></tr><tr><td>256</td><td>83.1</td></tr><tr><td>512</td><td>84.4</td></tr><tr><td>1024</td><td>83.7</td></tr></table>
|
| 132 |
+
|
| 133 |
+
<table><tr><td>blocks</td><td>acc.</td></tr><tr><td>1</td><td>83.2</td></tr><tr><td>2</td><td>83.6</td></tr><tr><td>4</td><td>84.4</td></tr><tr><td>8</td><td>84.3</td></tr></table>
|
| 134 |
+
|
| 135 |
+
(d) Repeated sampling. All entries see the same # samples. Data loading overhead is reduced.
|
| 136 |
+
|
| 137 |
+
(e) Decoder width. Unlike the image counterpart [31], an overly narrow decoder degrades accuracy noticeably.
|
| 138 |
+
|
| 139 |
+
(f) Decoder depth. Unlike the image counterpart [31], an overly shallow decoder degrades accuracy.
|
| 140 |
+
|
| 141 |
+
Table 2: Ablation experiments on Kinetics-400. The model is ViT-L, with an input size of $1 6 \times 2 2 4 \times 2 2 4$ and a spacetime patch size of $2 \times 1 6 \times 1 6$ . The pre-training length is 800 epochs. The entries marked in gray are the same, which specify the default settings. This table format follows [31].
|
| 142 |
+
|
| 143 |
+
Mask sampling strategy. Our method follows the structure-agnostic random sampling methodology in BERT [15] and MAE [31]. Table 2a reports that this simple solution works the best in our method.
|
| 144 |
+
|
| 145 |
+
We compare with other strategies as illustrated in Fig. 4. Space-only sampling, which samples on the 2D spatial axes and broadcasts along the temporal axis, works reasonably well $( 8 3 . 5 \% )$ . Time-only sampling, with a masking ratio of $7 5 \%$ (i.e., keep 2 time steps out of 8), performs poorly $( 7 9 . 1 \% )$ ; if we increase its masking ratio to $8 7 . 5 \%$ (keep 1 out of 8), the accuracy drops further to $7 5 . 4 \%$ . Time-only sampling is related to future/past frame prediction, which can be an overly difficult task in our scenario. Block-wise sampling [3], in its spacetime variant [77], has $8 3 . 2 \%$ accuracy with $7 5 \%$ masking ratio (a higher ratio is worse).
|
| 146 |
+
|
| 147 |
+
Reconstruction target. Our method performs decently by reconstructing the original, unmodified pixels $( 8 3 . 8 \%$ , Table 2b). Using per-patch normalized pixels [31] improves by $0 . 6 \%$ . This observation is similar to that of its image counterpart [31]. Using HOG [13] as the target [77] works strongly too.
|
| 148 |
+
|
| 149 |
+
The autoencoding nature of our method (i.e., predicting pixels) provides a self-contained solution. In contrast, an extra tokenizer (e.g., dVAE [47, 9]), as is used in [3, 73], may require external data to train and additional domain knowledge to design (e.g., the dVAE used is a ConvNet [37]). Applying the extra dVAE tokenizer to each frame is computationally heavy, which slows down training by $1 . 6 \times$ in our implementation. Our pixel-based method is simpler and performs better (Table 2b).
|
| 150 |
+
|
| 151 |
+
Data augmentation. Temporal data can provide natural augmentation, e.g., on view points, motion, deformation, occlusion. These forms of natural augmentation have been incorporated by random temporal sampling. Table 2c compares additional augmentation on the spatial domain. Even using no spatial augmentation (center crop only) works competitively, similar to the observation on images [31]. Random cropping with a mild scale range of [0.5, 1] works well, while stronger cropping (range [0.08, 1], [63]) reduces accuracy; adding color jittering reduces accuracy too, similar to [31].
|
| 152 |
+
|
| 153 |
+
Table 3: Influence of pre-training data, evaluated on K400, AVA, and SSv2 as the downstream tasks. The MAE pre-training length is 1600 epochs on K400/600/700 and IG-uncurated. No intermediate fine-tuning is used. The model is ViT-L. †: The K700 training set has $I 3 . 9 k$ duplicated videos with the K400 validation set $( I 9 . 9 k )$ , so it is not legitimate to train on K700 to get K400 results.
|
| 154 |
+
|
| 155 |
+
<table><tr><td>pre-train set</td><td># pre-train data</td><td>pre-train method</td><td>K400</td><td>AVA</td><td>SSv2</td></tr><tr><td>-</td><td>1</td><td>none (from scratch)</td><td>71.4</td><td>-</td><td>-</td></tr><tr><td>IN1K</td><td>1.28M</td><td>supervised</td><td>78.6</td><td>17.8</td><td>50.2</td></tr><tr><td>IN1K</td><td>1.28M</td><td>MAE</td><td>82.3</td><td>27.2</td><td>65.6</td></tr><tr><td>K400</td><td>240k</td><td>supervised</td><td>-</td><td>22.2</td><td>55.7</td></tr><tr><td>K400</td><td>240k</td><td>MAE</td><td>84.8</td><td>32.3</td><td>72.1</td></tr><tr><td>K600</td><td>387k</td><td>MAE</td><td>84.9</td><td>33.7</td><td>73.0</td></tr><tr><td>K700</td><td>537k</td><td>MAE</td><td>n/at</td><td>34.2</td><td>73.6</td></tr><tr><td>IG-uncurated</td><td>1M</td><td>MAE</td><td>84.4</td><td>35.1</td><td>73.6</td></tr></table>
|
| 156 |
+
|
| 157 |
+
It is practically valuable for self-supervised learning methods to be less dependent on data augmentation. There are a variety of applications in which augmentation is not valid or is hard to induce, e.g., medical imaging, hyper-spectral imaging, remote sensing, geometric data (point cloud, key points, etc.), and their temporal extensions. Our method could be generalized to these cases.
|
| 158 |
+
|
| 159 |
+
Repeated sampling. As our method is fast in computation, we adopt repeated sampling [33] to reduce the data loading overhead. Table 2d reports its influence. Using 2 or 4 repetitions increases wall-clock speed by $1 . 8 \times$ or $3 . 0 \times$ , as a loaded and decompressed file is reused multiple times.
|
| 160 |
+
|
| 161 |
+
Decoder capacity. Table 2e and 2f report the influence of the decoder width and depth. Using an overly small decoder degrades accuracy by large margins. This is unlike its image counterpart [31], in which a 128-d or 1-block decoder has no degradation if fine-tuning is applied. We hypothesize that the higher-dimensional video data are more complex and thus require higher decoding capacity. On the other hand, our optimal decoder (512-d, 4-block) is still substantially smaller than the encoder (1024-d, 24-block). This is similar to the observation on its image counterpart [31].
|
| 162 |
+
|
| 163 |
+
# 5.3 Influence of Data
|
| 164 |
+
|
| 165 |
+
Transfer learning ablation. Table 3 studies pre-training on different datasets and transferring to various downstream tasks. The pre-training datasets include ImageNet-1K (IN1K) [14] and Kinetics-400, 600, and 700 [35, 6, 7]. The downstream tasks include K400, AVA [29], and SomethingSomething v2 (SSv2) [27]. We do not perform any intermediate fine-tuning (see appendix), so the comparison here is influenced by the data scale/distribution but not by the number of their labels.
|
| 166 |
+
|
| 167 |
+
First we compare with pre-training on the IN1K images. MAE pre-training on $\mathrm { I N } 1 \mathrm { K } ^ { 4 }$ is $3 . 7 \%$ better than IN1K supervised pre-training $7 8 . 6 \%$ to $8 2 . 3 \%$ ); this image-based MAE is even better than K400 supervised pre-training, on both AVA ( $2 1 . 6 \%$ to $2 6 . 3 \%$ ) and SSv2 $5 5 . 7 \%$ to $6 5 . 6 \%$ ).
|
| 168 |
+
|
| 169 |
+
MAE pre-training on K400 has massive gains over supervised pre-training on K400: it improves by $1 0 . 1 \%$ on AVA $2 2 . 2 \%$ to $3 2 . 3 \%$ ) and $1 6 . 4 \%$ on SSv2 $5 5 . 7 \%$ to $7 2 . 1 \%$ ). MAE pre-training on K400 videos also substantially outperforms MAE pre-training on IN1K images: it increases by $2 . 5 \%$ on K400 $8 2 . 3 \%$ to $8 4 . 8 \%$ ), $5 . 1 \%$ on AVA $2 7 . 2 \%$ to $3 2 . 3 \%$ ), and $6 . 5 \%$ on SSv2 $6 5 . 6 \%$ to $7 2 . 1 \%$ ), suggesting that MAE pre-training on videos is highly beneficial for these video tasks.
|
| 170 |
+
|
| 171 |
+
With more pre-training data (K600/K700) without labels, we observe noticeable improvements on AVA and SSv2: comparing with K400 pre-training, MAE with K700 has an extra gain of $1 . 9 \%$ gain on AVA ( $3 2 . 3 \%$ to $3 4 . 2 \%$ ) and $1 . 5 \%$ on SSv2 ( $7 2 . 1 \%$ to $7 3 . 6 \%$ ).
|
| 172 |
+
|
| 173 |
+
Real-world data. We further study MAE pre-training on real-world Instagram videos. We study two sets: (i) Instagram videos curated (IG-curated) [24] with hashtags similar to K400 classes, and (ii) random, uncrated Instagram videos (IG-uncurated). Both sets have 1 million videos.
|
| 174 |
+
|
| 175 |
+
Table 3 (last row) reports transfer learning results on AVA and SSv2 using IG-uncurated pre-training. Notably, on AVA, MAE with IG-uncurated is better than MAE with curated Kinetics pre-training (e.g., by $3 . 1 / 1 . 7 / 1 . 1 \%$ over K400/600/700 pre-training); on SSv2, MAE with IG-uncurated is among the best, on par with the K700 counterpart.
|
| 176 |
+
|
| 177 |
+
Table 4: Real-world Instagram data for MAE pre-training. We pre-train MAE on each individual set for 200, 400, and 800 epochs. We compare fine-tuning accuracy on K400. The model is ViT-L.
|
| 178 |
+
|
| 179 |
+
<table><tr><td>data</td><td>#videos</td><td>200-ep.</td><td>400-ep.</td><td>800-ep.</td></tr><tr><td>K400</td><td>240k</td><td>81.5</td><td>83.3</td><td>84.4</td></tr><tr><td>IG-curated</td><td>240k</td><td>79.0</td><td>81.6</td><td>83.2</td></tr><tr><td>IG-curated</td><td>512k</td><td>81.9</td><td>83.5</td><td>83.9</td></tr><tr><td>IG-curated</td><td>1M</td><td>83.5</td><td>84.1</td><td>84.2</td></tr><tr><td>IG-uncurated</td><td>1M</td><td>83.2</td><td>84.5</td><td>84.4</td></tr></table>
|
| 180 |
+
|
| 181 |
+
Table 4 presents more results on the dataset size and training epochs. Pre-training on a 240k subset of IG-curated (the same size as K400) performs worse on K400 classification, which can be caused by the domain shift of data. However, increasing the dataset size of IG-curated to $5 1 2 \mathrm { k }$ and 1M shows good gains: under the same number of pre-training epochs (200 and 400), it can outperform K400 pre-training even when evaluating on K400. IG-uncurated performs similarly well as IG-curated, although the videos are randomly sampled and unrelated to K400 classes. This behavior is not observed on contrastive learning methods for videos: e.g., in [22] it is empirically shown that data curation has a major impact on contrastive learning [32, 10, 28] performance.
|
| 182 |
+
|
| 183 |
+
We believe that our exploration with real-world data has encouraging results. It is a more realistic use case of unsupervised learning at scale. We hope this exploration will shed light on future study.
|
| 184 |
+
|
| 185 |
+
# 5.4 System-level Comparisons
|
| 186 |
+
|
| 187 |
+
We provide system-level comparisons with the leading results on K400, AVA, and SSv2. The detailed tables are in the appendix (Table 7, 8, 9). These results are multifaceted, involving architecture designs, computational complexity, model sizes, input resolution, pre-training data and methods, etc., as we summarize in the tables. Our results are competitive and are close to the leading entries. In particular, our results are based only on vanilla ViT architectures, while the leading methods are hierarchical or specialized for videos. Our results demonstrate the potential of using fewer inductive biases and learning more from data, which is a pursuit of self-supervised learning.
|
| 188 |
+
|
| 189 |
+
# 5.5 Video Pre-training for Image Recognition
|
| 190 |
+
|
| 191 |
+
Finally, we report preliminary results on video pre-training for image recognition. The usage of vanilla ViT allows to convert to 2D easily: we only “deflate” patch embeddings by summing in time. Using ViT-L pre-trained by MAE on K400 / IG-uncurated, we obtain $8 3 . 7 \bar { \% } / \bar { 8 } 4 . 1 \%$ accuracy on IN1K image classification. This is better than training ViT-L from scratch on IN1K $( 8 2 . 6 \%$ [31]), though lower than MAE pre-training on IN1K $8 5 . 9 \%$ [31]). Considering the large domain gap, we believe this result is decent and its improvement over training from scratch is encouraging. We hope it will motivate the community to explore video pre-training for general visual representation learning.
|
| 192 |
+
|
| 193 |
+
# 6 Conclusion
|
| 194 |
+
|
| 195 |
+
We have explored a simple extension of MAE [31] to video data. We have drawn several interesting observations. (i) We find that it is possible to learn strong representations with minimal domain knowledge or inductive biases. This follows the spirit of the ViT paper [18]. Similar to BERT [15] and MAE [31], we show that self-supervised learning on videos can be tackled in a conceptually unified framework. (ii) We empirically show that the masking ratio is an important factor for general masked autoencoding methods [69], and its optimal values may depend on the nature of the data (language, images, videos, etc.). (iii) We report encouraging results of pre-training on real-world, uncurated data. It achieves strong performance, close to pre-training on controlled, curated data (e.g., Kinetics). To the best of our knowledge, promising results on uncurated data are rare in the literature.
|
| 196 |
+
|
| 197 |
+
In spite of these observations, open problems remain. The scale of data we have explored is orders of magnitudes smaller than the language counterparts [52, 15, 53, 5]. While our method has largely improved the efficiency of self-supervised learning, the high-dimensional video data still present a major challenge for scaling up. We hope our study will provide initial signals for future research.
|
| 198 |
+
|
| 199 |
+
# References
|
| 200 |
+
|
| 201 |
+
[2] Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Luciˇ c, and Cordelia ´ Schmid. ViViT: A video vision transformer. In ICCV, 2021.
|
| 202 |
+
[3] Hangbo Bao, Li Dong, and Furu Wei. BEiT: BERT pre-training of image Transformers. arXiv:2106.08254, 2021.
|
| 203 |
+
[4] Gedas Bertasius, Heng Wang, and Lorenzo Torresani. Is space-time attention all you need for video understanding? In ICML, 2021.
|
| 204 |
+
[5] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. In NeurIPS, 2020.
|
| 205 |
+
[6] João Carreira, Eric Noland, Andras Banki-Horvath, Chloe Hillier, and Andrew Zisserman. A short note about Kinetics-600. arXiv:1808.01340, 2018.
|
| 206 |
+
[7] João Carreira, Eric Noland, Chloe Hillier, and Andrew Zisserman. A short note on the Kinetics700 human action dataset. arXiv:1907.06987, 2019.
|
| 207 |
+
[8] João Carreira and Andrew Zisserman. Quo vadis, action recognition? a new model and the kinetics dataset. In CVPR, 2017.
|
| 208 |
+
[9] Mark Chen, Alec Radford, Rewon Child, Jeffrey Wu, Heewoo Jun, David Luan, and Ilya Sutskever. Generative pretraining from pixels. In ICML, 2020.
|
| 209 |
+
[10] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In ICML, 2020.
|
| 210 |
+
[11] Kevin Clark, Minh-Thang Luong, Quoc V Le, and Christopher D Manning. ELECTRA: Pre-training text encoders as discriminators rather than generators. In ICLR, 2020.
|
| 211 |
+
[12] Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. RandAugment: Practical automated data augmentation with a reduced search space. In CVPR Workshops, 2020.
|
| 212 |
+
[13] Navneet Dalal and Bill Triggs. Histograms of oriented gradients for human detection. In CVPR, 2005.
|
| 213 |
+
[14] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. ImageNet: A large-scale hierarchical image database. In CVPR, 2009.
|
| 214 |
+
[15] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional Transformers for language understanding. In NAACL, 2019.
|
| 215 |
+
[16] Ali Diba, Vivek Sharma, Luc Van Gool, and Rainer Stiefelhagen. DynamoNet: Dynamic Action and Motion Network. In ICCV, 2019.
|
| 216 |
+
[17] Xiaoyi Dong, Jianmin Bao, Ting Zhang, Dongdong Chen, Weiming Zhang, Lu Yuan, Dong Chen, Fang Wen, and Nenghai Yu. PeCo: Perceptual codebook for BERT pre-training of Vision Transformers. arXiv:2111.12710, 2021.
|
| 217 |
+
[18] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021.
|
| 218 |
+
[19] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale Vision Transformers. In ICCV, 2021.
|
| 219 |
+
[20] Christoph Feichtenhofer. X3D: Expanding architectures for efficient video recognition. In CVPR, 2020.
|
| 220 |
+
[21] Christoph Feichtenhofer, Haoqi Fan, Jitendra Malik, and Kaiming He. SlowFast networks for video recognition. In ICCV, 2019.
|
| 221 |
+
[22] Christoph Feichtenhofer, Haoqi Fan, Bo Xiong, Ross Girshick, and Kaiming He. A large-scale study on unsupervised spatiotemporal representation learning. In CVPR, 2021.
|
| 222 |
+
[23] Basura Fernando, Hakan Bilen, Efstratios Gavves, and Stephen Gould. Self-supervised video representation learning with odd-one-out networks. In ICCV, 2017.
|
| 223 |
+
[24] Deepti Ghadiyaram, Matt Feiszli, Du Tran, Xueting Yan, Heng Wang, and Dhruv Mahajan. Large-scale weakly-supervised pre-training for video action recognition. In CVPR, 2019.
|
| 224 |
+
[25] Ross Goroshin, Joan Bruna, Jonathan Tompson, David Eigen, and Yann LeCun. Unsupervised learning of spatiotemporally coherent metrics. In ICCV, 2015. Andrew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch SGD: Training ImageNet in 1 hour. arXiv:1706.02677, 2017.
|
| 225 |
+
[27] Raghav Goyal, Samira Ebrahimi Kahou, Vincent Michalski, Joanna Materzynska, Susanne Westphal, Heuna Kim, Valentin Haenel, Ingo Fruend, Peter Yianilos, Moritz Mueller-Freitag, et al. The “something something” video database for learning and evaluating visual common sense. In ICCV, 2017.
|
| 226 |
+
[28] Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, Bilal Piot, Koray Kavukcuoglu, Remi Munos, and Michal Valko. Bootstrap your own latent - a new approach to self-supervised learning. In NeurIPS, 2020.
|
| 227 |
+
[29] Chunhui Gu, Chen Sun, Sudheendra Vijayanarasimhan, Caroline Pantofaru, David A. Ross, George Toderici, Yeqing Li, Susanna Ricco, Rahul Sukthankar, Cordelia Schmid, and Jitendra Malik. AVA: A video dataset of spatio-temporally localized atomic visual actions. In CVPR, 2018.
|
| 228 |
+
[30] Tengda Han, Weidi Xie, and Andrew Zisserman. Video representation learning by dense predictive coding. In Workshop on Large Scale Holistic Video Understanding, ICCV, 2019.
|
| 229 |
+
[31] Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. arXiv:2111.06377, 2021.
|
| 230 |
+
[32] Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In CVPR, 2020.
|
| 231 |
+
[33] Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In CVPR, 2020.
|
| 232 |
+
[34] Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In ECCV, 2016.
|
| 233 |
+
[35] Will Kay, João Carreira, Karen Simonyan, Brian Zhang, Chloe Hillier, Sudheendra Vijayanarasimhan, Fabio Viola, Tim Green, Trevor Back, Paul Natsev, et al. The Kinetics human action video dataset. arXiv:1705.06950, 2017.
|
| 234 |
+
[36] Dan Kondratyuk, Liangzhe Yuan, Yandong Li, Li Zhang, Mingxing Tan, Matthew Brown, and Boqing Gong. MoviNets: Mobile video networks for efficient video recognition. In CVPR, 2021.
|
| 235 |
+
[37] Yann LeCun, Bernhard Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne Hubbard, and Lawrence D Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1989.
|
| 236 |
+
[38] Hsin-Ying Lee, Jia-Bin Huang, Maneesh Singh, and Ming-Hsuan Yang. Unsupervised representation learning by sorting sequence. In ICCV, 2017.
|
| 237 |
+
[39] Yanghao Li, Chao-Yuan Wu, Haoqi Fan, Karttikeya Mangalam, Bo Xiong, Jitendra Malik, and Christoph Feichtenhofer. Improved multiscale vision transformers for classification and detection. arXiv:2112.01526, 2021.
|
| 238 |
+
[40] Ze Liu, Han Hu, Yutong Lin, Zhuliang Yao, Zhenda Xie, Yixuan Wei, Jia Ning, Yue Cao, Zheng Zhang, Li Dong, Furu Wei, and Baining Guo. Swin Transformer v2: Scaling up capacity and resolution. arXiv:2111.09883, 2021.
|
| 239 |
+
[41] Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video Swin Transformer. arXiv:2106.13230, 2021.
|
| 240 |
+
[42] Ilya Loshchilov and Frank Hutter. SGDR: Stochastic gradient descent with warm restarts. In ICLR, 2017.
|
| 241 |
+
[43] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR, 2019.
|
| 242 |
+
[44] William Lotter, Gabriel Kreiman, and David Cox. Deep predictive coding networks for video prediction and unsupervised learning. In ICLR, 2017.
|
| 243 |
+
[45] Michael Mathieu, Camille Couprie, and Yann LeCun. Deep multi-scale video prediction beyond mean square error. In ICLR, 2016.
|
| 244 |
+
[46] Ishan Misra, C. Lawrence Zitnick, and Martial Hebert. Shuffle and learn: Unsupervised learning using temporal order verification. In ECCV, 2016.
|
| 245 |
+
[47] Aaron van den Oord, Oriol Vinyals, and Koray Kavukcuoglu. Neural discrete representation learning. In NeurIPS, 2017.
|
| 246 |
+
[48] Junting Pan, Siyu Chen, Mike Zheng Shou, Yu Liu, Jing Shao, and Hongsheng Li. Actorcontext-actor relation network for spatio-temporal action localization. In CVPR, 2021.
|
| 247 |
+
[49] Deepak Pathak, Ross Girshick, Piotr Dollár, Trevor Darrell, and Bharath Hariharan. Learning features by watching objects move. In CVPR, 2017.
|
| 248 |
+
[50] Deepak Pathak, Philipp Krahenbuhl, Jeff Donahue, Trevor Darrell, and Alexei A Efros. Context encoders: Feature learning by inpainting. In CVPR, 2016.
|
| 249 |
+
[51] Rui Qian, Tianjian Meng, Boqing Gong, Ming-Hsuan Yang, Huisheng Wang, Serge Belongie, and Yin Cui. Spatiotemporal contrastive video representation learning. In CVPR, 2021.
|
| 250 |
+
[52] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018.
|
| 251 |
+
[53] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.
|
| 252 |
+
[54] 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. JMLR, 2020.
|
| 253 |
+
[55] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In ICML, 2021.
|
| 254 |
+
[56] Adria Recasens, Pauline Luc, Jean-Baptiste Alayrac, Luyu Wang, Florian Strub, Corentin Tallec, Mateusz Malinowski, Viorica Patr ˘ aucean, Florent Altché, Michal Valko, et al. Broaden your ˘ views for self-supervised video learning. In ICCV, 2021.
|
| 255 |
+
[57] Shaoqing Ren, Kaiming He, Ross Girshick, and Jian Sun. Faster R-CNN: Towards real-time object detection with region proposal networks. In NeurIPS, 2015.
|
| 256 |
+
[58] Pierre Sermanet et al. Time-contrastive networks: Self-supervised learning from video. In ICRA, 2018.
|
| 257 |
+
[59] Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. arXiv:1803.02155, 2018.
|
| 258 |
+
[60] Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: A simple way to prevent neural networks from overfitting. The Journal of Machine Learning Research, 2014.
|
| 259 |
+
[61] N. Srivastava, E. Mansimov, and R. Salakhudinov. Unsupervised learning of video representations using LSTMs. In ICML, 2015.
|
| 260 |
+
[62] Chen Sun, Fabien Baradel, Kevin Murphy, and Cordelia Schmid. Contrastive bidirectional transformer for temporal representation learning. arXiv:1906.05743, 2019.
|
| 261 |
+
[63] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In CVPR, 2015.
|
| 262 |
+
[64] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In CVPR, 2016.
|
| 263 |
+
[65] Hao Tan, Jie Lei, Thomas Wolf, and Mohit Bansal. VIMPAC: Video pre-training via masked token prediction and contrastive learning. arXiv:2106.11250, 2021.
|
| 264 |
+
[66] Zhan Tong, Yibing Song, Jue Wang, and Limin Wang. VideoMAE: Masked autoencoders are data-efficient learners for self-supervised video pre-training. arXiv:2203.12602, 2022.
|
| 265 |
+
[67] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
|
| 266 |
+
[68] Pascal Vincent, Hugo Larochelle, Yoshua Bengio, and Pierre-Antoine Manzagol. Extracting and composing robust features with denoising autoencoders. In ICML, 2008.
|
| 267 |
+
[69] Pascal Vincent, Hugo Larochelle, Isabelle Lajoie, Yoshua Bengio, Pierre-Antoine Manzagol, and Léon Bottou. Stacked denoising autoencoders: Learning useful representations in a deep network with a local denoising criterion. JMLR, 2010.
|
| 268 |
+
[70] Carl Vondrick, Hamed Pirsiavash, and Antonio Torralba. Anticipating visual representations from unlabelled video. In CVPR, 2016.
|
| 269 |
+
[71] Carl Vondrick, Abhinav Shrivastava, Alireza Fathi, Sergio Guadarrama, and Kevin Murphy. Tracking emerges by colorizing videos. In ECCV, 2018.
|
| 270 |
+
[72] Jacob Walker, Carl Doersch, Abhinav Gupta, and Martial Hebert. An uncertain future: Forecasting from static images using variational autoencoders. In ECCV, 2016.
|
| 271 |
+
[73] Rui Wang, Dongdong Chen, Zuxuan Wu, Yinpeng Chen, Xiyang Dai, Mengchen Liu, Yu-Gang Jiang, Luowei Zhou, and Lu Yuan. BEVT: BERT pretraining of video transformers. In CVPR,
|
| 272 |
+
[74] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In CVPR, 2018.
|
| 273 |
+
[75] Xiaolong Wang and Abhinav Gupta. Unsupervised learning of visual representations using videos. In ICCV, 2015.
|
| 274 |
+
[76] Xiaolong Wang, Allan Jabri, and Alexei A. Efros. Learning correspondence from the cycleconsistency of time. In CVPR, 2019.
|
| 275 |
+
[77] Chen Wei, Haoqi Fan, Saining Xie, Chao-Yuan Wu, Alan Yuille, and Christoph Feichtenhofer. Masked feature prediction for self-supervised visual pre-training. arXiv:2112.09133, 2021.
|
| 276 |
+
[78] Donglai Wei, Joseph J. Lim, Andrew Zisserman, and William T. Freeman. Learning and using the arrow of time. In CVPR, 2018.
|
| 277 |
+
[79] Laurenz Wiskott and Terrence Sejnowski. Slow feature analysis: Unsupervised learning of invariances. In Neural Computation, 2002.
|
| 278 |
+
[80] Zhenda Xie, Zheng Zhang, Yue Cao, Yutong Lin, Jianmin Bao, Zhuliang Yao, Qi Dai, and Han Hu. SimMIM: A simple framework for masked image modeling. arXiv:2111.09886, 2021.
|
| 279 |
+
[81] Dejing Xu, Jun Xiao, Zhou Zhao, Jian Shao, Di Xie, and Yueting Zhuang. Self-supervised spatiotemporal learning via video clip order prediction. In CVPR, 2019.
|
| 280 |
+
[82] Shen Yan, Xuehan Xiong, Anurag Arnab, Zhichao Lu, Mi Zhang, Chen Sun, and Cordelia Schmid. Multiview transformers for video recognition. arXiv:2201.04288, 2022.
|
| 281 |
+
[83] Lu Yuan, Dongdong Chen, Yi-Ling Chen, Noel Codella, Xiyang Dai, Jianfeng Gao, Houdong Hu, Xuedong Huang, Boxin Li, Chunyuan Li, Ce Liu, Mengchen Liu, Zicheng Liu, Yumao Lu, Yu Shi, Lijuan Wang, Jianfeng Wang, Bin Xiao, Zhen Xiao, Jianwei Yang, Michael Zeng, Luowei Zhou, and Pengchuan Zhang. Florence: A new foundation model for computer vision. arXiv:2111.11432, 2021.
|
| 282 |
+
[84] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. Cutmix: Regularization strategy to train strong classifiers with localizable features. In ICCV, 2019.
|
| 283 |
+
[85] Bowen Zhang, Jiahui Yu, Christopher Fifty, Wei Han, Andrew M Dai, Ruoming Pang, and Fei Sha. Co-training Transformer with videos and images improves action recognition. arXiv:2112.07175, 2021.
|
| 284 |
+
[86] Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In ICLR, 2018.
|
md/dev/Uynr3iPhksa/Uynr3iPhksa.md
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Recurrent Memory Transformer
|
| 2 |
+
|
| 3 |
+
Aydar Bulatov1 bulatov.as@phystech.edu
|
| 4 |
+
|
| 5 |
+
Yuri Kuratov1,2 yurii.kuratov@phystech.edu
|
| 6 |
+
|
| 7 |
+
Mikhail S. Burtsev1,2 burtcev.ms@mipt.ru
|
| 8 |
+
|
| 9 |
+
1Neural Networks and Deep Learning Lab, Moscow Institute of Physics and Technology, Dolgoprudny, Russia 2AIRI, Moscow, Russia
|
| 10 |
+
|
| 11 |
+
# Abstract
|
| 12 |
+
|
| 13 |
+
Transformer-based models show their effectiveness across multiple domains and tasks. The self-attention allows to combine information from all sequence elements into context-aware representations. However, global and local information has to be stored mostly in the same element-wise representations. Moreover, the length of an input sequence is limited by quadratic computational complexity of selfattention. In this work, we propose and study a memory-augmented segment-level recurrent Transformer (RMT). Memory allows to store and process local and global information as well as to pass information between segments of the long sequence with the help of recurrence. We implement a memory mechanism with no changes to Transformer model by adding special memory tokens to the input or output sequence. Then the model is trained to control both memory operations and sequence representations processing. Results of experiments show that RMT performs on par with the Transformer-XL on language modeling for smaller memory sizes and outperforms it for tasks that require longer sequence processing. We show that adding memory tokens to $\mathrm { T r } \mathrm { X L }$ is able to improve its performance. This makes Recurrent Memory Transformer a promising architecture for applications that require learning of long-term dependencies and general purpose in memory processing, such as algorithmic tasks and reasoning.
|
| 14 |
+
|
| 15 |
+
# 1 Introduction
|
| 16 |
+
|
| 17 |
+
Transformers (Vaswani et al., 2017) have been widely adopted across multiple domains and tasks (Radford et al., 2018; Dong et al., 2018; Devlin et al., 2019; Dosovitskiy et al., 2021; Ramesh et al., 2021; Jaegle et al., 2021). The key component of Transformer layer is a self-attention. Self-attention allows to update each sequence element representation with information from all other elements in the sequence. As a result, rich contextual representation for every element is generated at the end of encoding. This way, global sequence-level and local information are stored in a single representation. However, this mixing of two types of information in a single representation has limitations. Distributed storage of global features across all sequence elements results in global features "blurring" and makes it harder to access them. Another well-known deficiency of Transformers is poor scaling of self-attention with
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Recurrent Memory Transformer. Memory is added as tokens to the input sequence and memory output is passed to the next segment. During training gradients flow from the current segment through memory to the previous segment.
|
| 21 |
+
|
| 22 |
+
input sequence length that hurts its applications to long inputs (Child et al., 2019; Guo et al., 2019;
|
| 23 |
+
Dai et al., 2019; Beltagy et al., 2020; Ainslie et al., 2020; Zaheer et al., 2020; Wang et al., 2020;
|
| 24 |
+
Choromanski et al., 2020).
|
| 25 |
+
|
| 26 |
+
Our work introduces a memory-augmented segment-level recurrent Transformer named Recurrent Memory Transformer (RMT). RMT uses a memory mechanism based on special memory tokens (Burtsev et al., 2020) added to the input sequence. Memory tokens provide additional reserved capacity to the model that could be used to process information which is not directly representing any element in the input sequence. To process long sequences, we split them into segments and pass memory states from a previous to a current segment. This memory passing makes the model recurrent and removes the input sequence length limitations. RMT model can theoretically work with infinite lengths but, in practice, it is limited by memory capacity and the efficiency of memory access/update operations. Our implementation of both memory and recurrence in RMT requires no changes to the Transformer model because modifications are made only to the input and output sequences of the model.
|
| 27 |
+
|
| 28 |
+
We tested RMT on the tasks that require global information about the whole input sequence to be solved. We use copy, reverse, and associative retrieval tasks in the setting where the input sequence is split into segments. RMT and Transformer-XL perfectly solve these tasks, but exceeding some value of sequence length, RMT starts to outperform Transformer-XL. Also, we experimentally show that the proposed Recurrent Memory Transformer requires less memory size to perform closely to Transformer-XL on language modeling tasks. RMT code and experiments are available1.
|
| 29 |
+
|
| 30 |
+
# Contributions
|
| 31 |
+
|
| 32 |
+
1. In this study we augment Transformer with token based memory storage and segment-level recurrence.
|
| 33 |
+
|
| 34 |
+
2. We experimentally evaluate proposed architecture as well as vanilla Transformer and TransformerXL on memory-intensive tasks such as copy, reverse, associative retrieval, and language modeling. We show that RMT outperforms Transformer-XL for sequence processing tasks and on par with Transformer-XL on language modeling but requires less memory.
|
| 35 |
+
|
| 36 |
+
3. We show that Tr-XL cache could be combined with RMT leading to better performance on language modeling.
|
| 37 |
+
|
| 38 |
+
4. We analysed how the Transformer model learns to use memory. Specific interpretable memory read-write patterns of attention are shown.
|
| 39 |
+
|
| 40 |
+
# 2 Related work
|
| 41 |
+
|
| 42 |
+
In our study we add a memory to general purpose attention based neural architecture. Memory is a recurrent topic in neural networks research. It had started from the early works (McCulloch and Pitts, 1943; Stephen, 1956) and significantly progressed in 90’s with introduction of Backpropagation Through Time learning algorithm (Werbos, 1990) and Long-Short Term Memory (LSTM) (Hochreiter and Schmidhuber, 1997) neural architecture. Today memory-augmented neural networks (MANNs) usually rely on some kind of recurrent external-memory which is separate from the model’s parameters. Neural Turing Machines (NTMs) (Graves et al., 2014) and Memory Networks (Weston et al., 2014) are equipped with a storage for vector representations that can be accessed with an attention mechanism. Memory Networks (Weston et al., 2014; Sukhbaatar et al., 2015) were designed to enable reasoning by sequential attention over to the content of a memory. NTMs followed by Differentiable Neural Computer (DNC) (Graves et al., 2016) and Sparse DNC (Rae et al., 2016) are implemented as recurrent neural networks able to write to memory storage over time. All these models are differentiable and can be trained via backpropagation through time (BPTT). Parallel line of research extends recurrent neural networks such as LSTM with data structures like stacks, lists, or queues (Joulin and Mikolov, 2015; Grefenstette et al., 2015). MANN architectures with a more advanced addressing mechanisms such as address-content separation and multi-step addressing were proposed in (Gulcehre et al., 2016, 2017; Meng and Rumshisky, 2018). The Global Context Layer model (Meng and Rumshisky, 2018) uses the idea of address-content separation to solve the difficulty of training content-based addressing in the canonical NTM.
|
| 43 |
+
|
| 44 |
+
The recent rise of Transformer models also resulted in introduction of a number of new memory architectures. Transformer-XL (Dai et al., 2019) introduces a segment-level recurrence at the level of hidden representations. These representations of a sequence are computed and stored in the cache to be reused as an extended context for the next segment. Compressive Transformer (Rae et al., 2019) adds the second layer of memory to Transformer-XL. This memory compresses and stores information from the cache. $\infty$ -former (Martins et al., 2021) utilizes continuous-space attention and represents input sequence as a continuous signal to make long-term memory unbounded. Memory Layers (Lample et al., 2019) model has a product key memory layer instead of a feed-forward layer within Transformer block to increase model capacity.
|
| 45 |
+
|
| 46 |
+
In many variations of Transformer different sorts of global representations are added. Among them are Star-Transformer (Guo et al., 2019), Longformer (Beltagy et al., 2020), GMAT (Gupta and Berant, 2020), Extended Transformer Construction (ETC) (Ainslie et al., 2020) and Big Bird (Zaheer et al., 2020). All these architectures re-design self-attention mechanism to reduce it computational complexity with and ensure input coverage with the help of global representations. Memory Transformer (Burtsev et al., 2020) keeps Transformer model intact and adds memory by extending input sequence with special memory tokens. Perceiver IO (Jaegle et al., 2021) maps an entire arbitrary input to the fixed number of latent representations. Transformer layers do further processing over latent memory representations only.
|
| 47 |
+
|
| 48 |
+
Segment-level recurrence in Transformers is actively explored in a number of studies. TransformerXL, Compressive Transformer keep previous states and re-use them in subsequent segments. ErnieDoc (Ding et al., 2021) improves processing by using same-layer recurrence instead of attending to previous layer outputs of a precedent segment. Memformer (Wu et al., 2020) introduces a dedicated memory module to keep previous hidden states in summarized representations. Memformer uses two special layers added to the Transformer model. Memory cross-attention layer reads from memory and memory slot attention layer updates it. MART (Lei et al., 2020) has a similar approach as Memformer but uses memory update rules analogous to LSTM (Hochreiter and Schmidhuber, 1997) and GRU (Cho et al., 2014). FeedBack Transformer (Fan et al., 2020) goes further with full, and not segment-level, recurrence. FeedBack Memory merges past hidden representations from all layers into a single vector and makes it accessible to the computations at any layer. The disadvantage of full recurrence is that it is less parallelizable. FeedBack Memory requires every sequence element to be processed sequentially. In segment-level recurrent models, all elements of a segment are processed by Transformer layers in parallel. Only segments are processed sequentially. Staircase Transformer (Ju et al., 2021) combines segment-level recurrence and depth recurrence. Staircase models use the output for previous segments and pass them as input for the next segment. Our Recurrent Memory Transformer is based on special memory tokens similar to Memory Transformer, segment-level recurrence as in Transformer-XL, and depth-recurrent mechanism for memory processing similar to Staircase.
|
| 49 |
+
|
| 50 |
+
# 3 Recurrent Memory Transformer
|
| 51 |
+
|
| 52 |
+
Transformer-XL (Dai et al., 2019) extends Transformer model with state re-use cache mechanism for segment-level recurrence and relative position encoding. Input sequence is split on segments processed sequentially. Hidden states computed for the previous segment $M ^ { n }$ are cached for each transformer layer $n$ . The input of the layer $n$ consists of the last $m$ states from the cached memory and output of previous Transformer layer for the current segment $\tau$ :
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
{ \tilde { H } } _ { \tau } ^ { n - 1 } = [ S G ( M _ { - m : } ^ { n - 1 } ) \circ H _ { \tau } ^ { n - 1 } ] ,
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
here, SG stands for stop-gradient, $\circ$ denotes concatenation. Cached states allow to increase effective context size of Transformer model and save on compute operations.
|
| 59 |
+
|
| 60 |
+
Then, $\tilde { H } _ { \tau } ^ { n - 1 }$ goes to Transformer layer $T L$ to produce layer $n$ outputs for segment $\tau$
|
| 61 |
+
|
| 62 |
+
$$
|
| 63 |
+
H _ { \tau } ^ { n } = T L ( Q _ { \tau } ^ { n } , K _ { \tau } ^ { n } , V _ { \tau } ^ { n } ) , Q _ { \tau } ^ { n } = W _ { q } ^ { n } H _ { \tau } ^ { n - 1 } ; K _ { \tau } ^ { n } = W _ { k } ^ { n } \tilde { H } _ { \tau } ^ { n - 1 } , V _ { \tau } ^ { n } = W _ { v } ^ { n } \tilde { H } _ { \tau } ^ { n - 1 } .
|
| 64 |
+
$$
|
| 65 |
+
|
| 66 |
+
In Transformer-XL, self-attention layers are modified to use relative position encodings to improve generalization to longer attention lengths. The overall architecture is shown in the Figure 2.
|
| 67 |
+
|
| 68 |
+
Memory augmented Transformers such as GMAT, ETC, Memory Transformer (Gupta and Berant, 2020; Ainslie et al., 2020; Burtsev et al., 2020) proposed to use special global tokens as storage for representations. Usually, memory tokens are added to the beginning of the input sequence. However, in decoder-only architectures the causal attention mask makes impossible for memory tokens at the start of the sequence to collect information from the subsequent tokens. On the other hand, if memory tokens are placed at the end of the sequence then preceding tokens unable to access their representations. To solve this problem we add a recurrence to the sequence processing. Representations of memory tokens placed at the end of the segment are used as an input memory representations at the start as well as at the end of the next segment.
|
| 69 |
+
|
| 70 |
+

|
| 71 |
+
Figure 2: Comparison of Recurrent Memory Transformer (RMT) and Transformer-XL architectures. Recurrent Memory Transformer augments Transformer with global memory tokens and passes them to allow a segment-level recurrence. Special read/write memory tokens are added to the input sequence. Multiple memory tokens can be used in each read/write block. Updated representations of write memory are passed to the next segment. During training, RMT uses BPTT to propagate gradient to previous segments through memory tokens representation. Effective context length for recurrence with memory is not limited by the depth of a network which is the case for the cache of Transformer-XL.
|
| 72 |
+
|
| 73 |
+
In the Recurrent Memory Transformer input is augmented with special [mem] tokens, processed in a standard way along with the sequence of tokens. Each memory token is a real-valued vector. $m$ memory tokens are added at the beginning of the segment tokens representations $H _ { \tau } ^ { 0 }$ and the same $m$ tokens are added at the end:
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\tilde { H } _ { \tau } ^ { 0 } = [ H _ { \tau } ^ { m e m } \circ H _ { \tau } ^ { 0 } \circ H _ { \tau } ^ { m e m } ] , \bar { H } _ { \tau } ^ { N } = \mathrm { T r a n s f o r m e r } ( \tilde { H } _ { \tau } ^ { 0 } ) , [ H _ { \tau } ^ { r e a d } \circ H _ { \tau } ^ { N } \circ H _ { \tau } ^ { w r i t e } ] : = \bar { H } _ { \tau } ^ { N } ,
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
here $N$ is a number of Transformer layers.
|
| 80 |
+
|
| 81 |
+
The starting group of memory tokens functions as a read memory that allows sequence tokens to attend to memory states produced at the previous segment. The ending group works as a write memory that can attend to all current segment tokens and update representation stored in the memory. As a result, $H _ { \tau } ^ { w r i t e }$ contains updated memory tokens for the segment $\tau$ .
|
| 82 |
+
|
| 83 |
+
Segments of the input sequence are processed sequentially. To enable recurrent connection between segments, we pass outputs of the memory tokens from the current segment to the input of the next segment:
|
| 84 |
+
|
| 85 |
+
$$
|
| 86 |
+
H _ { \tau + 1 } ^ { m e m } : = H _ { \tau } ^ { w r i t e } , \tilde { H } _ { \tau + 1 } ^ { 0 } = [ H _ { \tau + 1 } ^ { m e m } \circ H _ { \tau + 1 } ^ { 0 } \circ H _ { \tau + 1 } ^ { m e m } ] .
|
| 87 |
+
$$
|
| 88 |
+
|
| 89 |
+
Both memory and recurrence in the RMT are based only on global memory tokens. It allows to keep the backbone Transformer unchanged and make RMT memory augmentation compatible with any model from the Transformer family. Memory tokens operate only on the input and output of the model. In this study we implement RMT on top of the original Transformer-XL code. Both architectures are shown in Figure 2.
|
| 90 |
+
|
| 91 |
+
Recurrence in the RMT is different compared to the Transformer-XL because the former stores only $m$ memory vectors per segment. On the other hand, the Transformer-XL stores $m \times N$ vectors per segment. Also, in the RMT model memory representations from the previous segment are processed by Transformer layers together with the current segment tokens. This makes memory part of RMT effectively deeper in a number of applied Transformer layers $\tau \times N$ . Additionally, we allow all memory tokens in the read/write block to access all other tokens in the same block. The causal attention mask is applied only to tokens of the input sequence (Figure 6(d)).
|
| 92 |
+
|
| 93 |
+
We train the RMT with Backpropagation Through Time (BPTT). During backward pass, unlike in Transformer-XL, memory gradients are not stopped between segments. The number of previous segments to backpropagate is a hyperparameter of a training procedure. We vary BPTT unroll in our experiments from 0 to 4 previous segments. Increasing this parameter is computationally expensive and requires a lot of GPU RAM. However, techniques such as gradient checkpointing could be used to alleviate this problem.
|
| 94 |
+
|
| 95 |
+
# 4 Experiments
|
| 96 |
+
|
| 97 |
+
We designed our experiments to evaluate the ability of Recurrent Memory Transformers to preserve long-term dependencies across multiple input segments. The first set of experiments includes copy, reverse, associative retrieval, and quadratic equations tasks. The second one addresses language modeling task for word-level on WikiText-103 (Merity et al., 2017) and for character-level on enwik8 (Mahoney, 2006). We compare Recurrent Memory Transformer with Transformer and Transformer-XL models.
|
| 98 |
+
|
| 99 |
+
Our RMT implementation is based on Transformer-XL repository2. The full set of hyperparameters is available in our repository as well as in supplementary materials. Language modeling experiments follow the same model and training hyperparameters as Transformer-XL. WikiText-103 experiments use 16-layer Transformers (10 heads, 410 hidden size, 2100 intermediate FF), enwik8 – 12 layer Transformers (8 heads, 512 hidden size, 2048 intermediate FF). We used Adam optimizer Kingma and Ba (2015) with linear schedule learning rate starting from 0.00025 for 200,000 steps for WikiText-103 and 400,000 steps for enwik8. We refer to Transformer-XL with memory size equal to zero as a Baseline. With this experimental setup we were able to reproduce results for the Transformer-XL model close to the original paper.
|
| 100 |
+
|
| 101 |
+
Algorithmic Tasks. We evaluate RMT on algorithmic tasks that require information about the whole input sequence to be solved successfully. In a recurrent setting, the model has to keep information about all previous segments to make predictions.
|
| 102 |
+
|
| 103 |
+
In the Copy task, an input sequence should be replicated twice after a special start-to-generate token. In the Reverse task, an input sequence should be generated in a reverse order. Input for the Associative Retrieval task consists of $N$ key-value pairs. Then one key is randomly selected, and the task is to produce an appropriate value for the selected key. Another task is to solve quadratic equations. One example consists of an equation, its solution with discriminant, and an answer. The task is to generate a solution and answer, while only answer quality is evaluated.
|
| 104 |
+
|
| 105 |
+
For all tasks, input and output sequences are split into segments and processed by models sequentially. Datasets for algorithmic tasks were randomly pre-generated, the same data was used in all experiments, and character-level tokenization was used. Because Transformer-XL and RMT are decoder-only Transformer models, we don’t compute loss over the input sequence before the start-to-generate token. The loss is computed over target sequence segments only (see Appendix A.1 for details).
|
| 106 |
+
|
| 107 |
+
Language Modeling and NLP. We use two standard benchmarks for language modeling: WikiText103 and enwik8. WikiText-103 (Merity et al., 2017) is used for word-level language modeling and contains 103M words from English Wikipedia articles. Enwik8 (Mahoney, 2006) is used for character-level and consists of $1 0 ^ { 8 }$ first bytes of XML text dump of the English Wikipedia. Vocabulary contains 267735 words and 204 characters for Wikitext-103 and enwik8 tokenizers accordingly.
|
| 108 |
+
|
| 109 |
+
We compare Recurrent Memory Transformer with decoder-only Transformer and Transformer-XL as baselines. Model size and training parameters are selected to match Transformer-XL paper. For Wikitext-103 an input context length was set to 150 tokens, and for enwik8 it was set to 512 characters. Another set of experiments inspected how RMT handles long-term dependencies and recurrence. We increased the number of segments and recurrent steps by making segments smaller (50 tokens for WikiText-103, 128 characters for enwik8). The increased number of recurrent steps makes language modeling tasks harder for RMT because information has to be stored in the same amount of memory for more steps.
|
| 110 |
+
|
| 111 |
+
As a testbed for the real-life application scenario we select popular long-text classification benchmark Hyperpartisan news (Kiesel et al., 2019). Instead of pre-training RMT from scratch we add recurrent memory mechanism to the most widely adopted models from HuggingFace Transformers (Wolf et al., 2020). Specifically, we augment 500 input tokens of already pretrained BERT-base, RoBERTa-base, DeBERTa-base and T5-base with the recurrent memory of size 10 and fine-tune on the target task.
|
| 112 |
+
|
| 113 |
+
# 5 Results
|
| 114 |
+
|
| 115 |
+
Baseline, Transformer-XL (Tr-XL) and RMT perform perfectly in the single segment setting on copy and reverse tasks (Figure 3). In this case, the models do not need recurrence because the whole sequence is available. When the number of segments is larger than one, non-recurrent baseline struggles to solve tasks, but both memory models demonstrate ability to retain required information from the previous segments in memory.
|
| 116 |
+
|
| 117 |
+

|
| 118 |
+
Figure 3: RMT outperforms Transformer-XL on Copy and Reverse tasks as a number of segments increases. Panels show test set per-character accuracy on copy, reverse, and associative retrieval tasks (from left to right). Memory/cache size equals to the length of a segment for both models. RMT does not pass gradients between segments in this experiment. MT results are the same as for the Baseline. Source/target sequence lengths for copy, reverse, and associative retrieval tasks: 24/48, 24/24, 10/1.
|
| 119 |
+
|
| 120 |
+
On Copy and Reverse tasks as a number of segments increases, RMT starts to outperform TransformerXL with memory sizes less than the number of all previous tokens. With the number of segments up to 6 mean accuracy of Transformer-XL drops by up to 0.2 points, and with 9 segments plunges close to the baseline without memory. Associative Retrieval results are similar with the number of segments up to 4. RMT manages to solve the task with Transformer-XL closely behind. However, in the setting with 5 segments, RMT performance slightly decreases and Transformer-XL average accuracy rises higher.
|
| 121 |
+
|
| 122 |
+
We analyze how a number of segments, sequence length, a length of training context, and memory size affect models’ performance on Copy task (Figure 4). As we split a sequence into more segments it becomes more crucial to be able to pass information between segments. We split 360 tokens of source $^ +$ target sequence into multiple segments. In Figure 4a we observe that Transformer-XL performance starts to degrade and eventually falls to the baseline model performance as the number of segments increases. In contrast, RMT continues to solve the task perfectly. In a more extreme setting, when we keep memory size fixed, but increase the total length of a sequence to copy Transformer-XL fails shortly, while RMT starts to gradually degrade only after the length of 720 tokens (Figure 4b).
|
| 123 |
+
|
| 124 |
+
On the Quadratic Equations task (Table 1) we have checked that it is possible to solve the task with the Transformer baseline and no segmentation used. The baseline in this case defines upper bound for this task. With multiple segments recurrency RMT solves the task perfectly, while Transformer-XL finds the task challenging.
|
| 125 |
+
|
| 126 |
+
The results of experiments on word-level language modeling on WikiText-103 are shown in Table 2. In the first section with a segment length of 150, Tr-XL and RMT outperform the baseline and Memory Transformer (MemTr) by a large margin. It shows the significance of increased effective context length by Tr-XL cache or RMT memory for language modeling. RMT improves over MemTr memory mechanism with read/write blocks. The best RMT models with
|
| 127 |
+
|
| 128 |
+
Table 1: Quadratic equations task. Sequence of 180 tokens consists of quadratic equation, a solution, and an answer. It is split into a number of segments with an answer in the last segment. Accuracy equals 1.0 if the full answer is predicted correctly.
|
| 129 |
+
|
| 130 |
+
<table><tr><td>MODEL</td><td>MEMORY</td><td>SEGMENTS</td><td>ACC±STD</td></tr><tr><td>BASELINE</td><td>0</td><td>1</td><td>0.99 ±0.01</td></tr><tr><td>TRANSFORMER-XL</td><td>30</td><td>6</td><td>0.93 ±0.02</td></tr><tr><td>RMT</td><td>30</td><td>6</td><td>0.99 ±0.002</td></tr></table>
|
| 131 |
+
|
| 132 |
+
memory size 10 and 25 show similar performance as Transformer-XL with a memory size equal to 75. RMT learns to use smaller memory more effectively than Transformer-XL. Additionally, the smaller memory size of RMT leads to reducing required GPU memory for running the model.
|
| 133 |
+
|
| 134 |
+
To force models to process longer recurrent dependencies the size of a segment is set to 50, so the number of recurrent steps increases. RMT with memory size 1 shows similar results to Transformer
|
| 135 |
+
|
| 136 |
+

|
| 137 |
+
Figure 4: RMT scales better with a number of segments and sequence size. (a) RMT is able to solve copy task perfectly up to 9 segments for a fixed sequence length of 360, while Tr-XL fails. (b) RMT learns to use memory of the same fixed size (60 tokens) more effectively than TR-XL as a sequence length to copy increases (a segment size is 120 for the both models).
|
| 138 |
+
|
| 139 |
+
XL with memory size 10. It is worth noting that Transformer-XL memory consists of hidden representations from all layers (in this case, it is $1 0 \times 1 6$ vectors) when RMT memory is only memory_size vectors. Transformer-XL with memory size 50 and RMT with memory size 5 show similar perplexity values (see Appendix A.5).
|
| 140 |
+
|
| 141 |
+
RMT could be combined with Tr-XL cache. In this case Tr-XL cache could be seen as short-term memory keeping the nearest context and RMT memory as long-term memory. Such combination leads to the best results on WikiText-103 improving over Tr-XL.
|
| 142 |
+
|
| 143 |
+
Table 2: Language modeling on WikiText-103. Average perplexity for the best performed variations of RMT models reported (see full results in Appendix A.5). Underlined values show Tr-XL and RMT models with close results. RMT models with smaller memory sizes achieve similar scores to $\mathrm { T r } \mathrm { X L }$ models with larger memory. Combination of cache with recurrent memory (Tr$\mathbf { X L + R M T }$ ) shows the best performance.
|
| 144 |
+
|
| 145 |
+
<table><tr><td>MODEL</td><td>MEMORY</td><td>SEGMENT LEN</td><td>PPL±STD</td></tr><tr><td>TR-XL (PAPER)</td><td>150</td><td>150</td><td>24.0</td></tr><tr><td>BASELINE</td><td>0</td><td>150</td><td>29.95 ± 0.15</td></tr><tr><td>MEMTR</td><td>10</td><td>150</td><td>29.63 ±0.06</td></tr><tr><td>TR-XL (OURS)</td><td>150</td><td>150</td><td>24.12 ±0.05</td></tr><tr><td>TR-XL</td><td>25</td><td>150</td><td>25.57 ±0.02</td></tr><tr><td>TR-XL</td><td>75</td><td>150</td><td>24.68 ±0.01</td></tr><tr><td>RMTBPTT-3</td><td>10</td><td>150</td><td>25.04 ± 0.07</td></tr><tr><td>RMTBPTT-2</td><td>25</td><td>150</td><td>24.85 ±0.31</td></tr><tr><td>TR-XL+RMT</td><td>75+5</td><td>150</td><td>24.47 ± 0.05</td></tr><tr><td>TR-XL+RMT</td><td>150+10</td><td>150</td><td>23.99 ± 0.09</td></tr><tr><td>BASELINE</td><td>0</td><td>50</td><td>39.05 ± 0.01</td></tr><tr><td>TR-XL</td><td>100</td><td>50</td><td>25.66 ± 0.01</td></tr><tr><td>TR-XL</td><td>50</td><td>50</td><td>26.54 ± 0.01</td></tr><tr><td>TR-XL</td><td>25</td><td>50</td><td>27.57 ± 0.09</td></tr><tr><td>TR-XL</td><td>10</td><td>50</td><td>28.98 ±0.11</td></tr><tr><td>RMTBPTT-1</td><td>1</td><td>50</td><td>28.71 ±0.03</td></tr><tr><td>RMTBPTT-3</td><td>10</td><td>50</td><td>26.37 ± 0.01</td></tr></table>
|
| 146 |
+
|
| 147 |
+
On enwik8 RMT models with memory size 5 and Transformer-XL with memory size 40 show similar results. Confirming that RMT learns to use smaller amounts of memory representation more effectively. All results for enwik8 dataset are shown in Appendix A.4.
|
| 148 |
+
|
| 149 |
+
Recurrent Memory Transformer learns to make predictions depending on #BPTT_unrolls over previous segments $+ 1$ current segment. Transformer-XL does not use BPTT and relies only on memory_size cached states and current segment making in total: memory_size + segment_length tokens. In Figure 5a, we compare RMT and Tr-XL according to the described value of visible context at training time.
|
| 150 |
+
|
| 151 |
+
RMT with a single memory vector could be trained to achieve lower perplexity as Transformer-XL with memory size 10. This means that RMT can learn to compress information from the previous observations better. Another observation is that RMT with memory sizes 10 and 25 performs only a bit weaker compared to Transformer-XL even when Transformer-XL has access to more non
|
| 152 |
+
|
| 153 |
+
compressed states (50, 100, 200) from previous segments. In general, training RMT with unrolling gradients in earlier segments drastically improves scores thus showing the importance of BPTT training but, we observe instabilities and out-of-memory issues during RMT training for a larger memory sizes with deeper BPTT unrolls.
|
| 154 |
+
|
| 155 |
+
RMT wins a lot when only one memory token is added but then the effect from increasing memory size from 5 to 50 fades (Figure 5b). Still, RMT with memory size 5 have performance on par with Transformer-XL with cache 50, confirming that RMT learns to store more compact representations. The results suggest that there is some optimal memory size for RMT to solve the task, and further increase does not add much.
|
| 156 |
+
|
| 157 |
+
Proposed recurrent memory mechanism affects only input and gradient flows of the augmented core model. This might be an important advantage because the memory can be added to already pretrained model. Evaluation results for four memory augmented language models fine tuned for long text classification are presented in the Table 3. Incorporation of 10 memory tokens in the input sequence of 512 allows to encode longer stretches of a text up to 2000 tokens and significantly improve metrics for the majority of models. Moreover, a combination of recurrent memory with RoBERTa-base results in state of the art performance for the Hyperpartisan news classification task (Kiesel et al., 2019). Interestingly, many competing models have input size of 4096 that is at least twice longer compared to RMT extended counterparts but still lag behind.
|
| 158 |
+
|
| 159 |
+

|
| 160 |
+
Figure 5: Deeper BPPT unrolling improves RMT scores on WikiText-103 (a) Visible context at training time can be increased by deeper BPTT unrolls for RMT or enlarging cache for $\mathrm { T r } \mathrm { X L }$ . Larger visible context leads to lower perplexity for both models (marker size corresponds to memory size). (b) Recurrence improves performance of RMT compared to $\mathrm { T r } \mathrm { X L }$ for the same memory sizes.
|
| 161 |
+
|
| 162 |
+
Table 3: Hyperpartisan news detection. Models starting with RMT are taken from HuggingFace Transformers and augmented with 10 memory tokens and recurrence before fine-tuning. Train/valid/test split as in (Beltagy et al., 2020) and metric is F1.
|
| 163 |
+
|
| 164 |
+
<table><tr><td>MODEL [INPUT SIZE]</td><td colspan="4">NUMBER OF SEGMENTS 2 3</td></tr><tr><td></td><td>1</td><td></td><td></td><td></td></tr><tr><td>BIG BIRD [4096] (ZAHEER ET AL.,2020) LONGFORMER [4096] (BELTAGY ET AL.,2020)</td><td>92.20 94.80</td><td></td><td></td><td></td></tr><tr><td>GRAPH-ROBERTA [512X100](XU ET AL.,2021)</td><td>96.15</td><td></td><td></td><td></td></tr><tr><td>ERNIE-DOC-LARGE [640] (DING ET AL.,2021)</td><td>96.60</td><td></td><td></td><td></td></tr><tr><td>ERNIE-SPARSE [4096] (LIU ET AL.,2022)</td><td>92.81</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>RMT BERT-BASE-CASE [512]</td><td>91.60</td><td>94.12 97.20</td><td>93.06 96.72</td><td>94.34</td></tr><tr><td>RMT ROBERTA-BASE [512] RMT DEBERTA-V3-BASE[512]</td><td>94.87 94.17</td><td>96.78</td><td>94.80</td><td>98.11 94.80</td></tr><tr><td>RMTT5-BASE[512]</td><td>94.99</td><td>95.32</td><td>96.12</td><td>97.20</td></tr></table>
|
| 165 |
+
|
| 166 |
+
To get an understanding of memory operations, learned by RMT for algorithmic tasks we visualise attention maps for copy and reverse tasks (Figure 6). In each RMT attention map sequence tokens are preceded by read memory, located at the top left corner, and followed by write memory at the bottom right. Diagonal at the central part of the fig.6(a) (top) shows classic attention of token sequence
|
| 167 |
+
|
| 168 |
+
to itself, but the bottom diagonal represents the operation of writing of sequence tokens to memory in straight order. When completing reverse (fig.6(a) bottom) the model learns to write the sequence to the memory in the reversed order, which is in line with common sense.
|
| 169 |
+
|
| 170 |
+
When it comes to reproducing the target sequence, the model accesses memory (fig.6(b)) and writes to the output sequence. Another operation (fig.6(c)) is rewriting from read memory to write memory. It is commonly used by RMT in settings with larger number of segments to keep information about recent segments longer.
|
| 171 |
+
|
| 172 |
+
Transformer-XL mechanism of accessing memory (fig.6(d)) does not allow straightforward writing to memory without changing sequence token representations. Sequential reading from cache is represented by diagonals on Transformer-XL attention maps. Using token representations as storage harms model performance in tasks with larger number of segments. For reverse task with 4 segments Transformer-XL with limited memory size 6 (Appendix B Figure 9(b)) attempts to mix representations of tokens and read multiple symbols from one cached state in the next segments giving average accuracy of 0.8 on the target task. Despite having the same memory size, RMT manages to compress the whole segment in memory tokens (Appendix B Figure 9(a)) and achieve mean accuracy 1.
|
| 173 |
+
|
| 174 |
+
Visualizations from Figure 6 and Appendix B Figure 9 provide evidence to support our hypotheses that Tr-XL has to mix representations from previous and current segments in the same hidden states to pass information between segments. Also, visualizations show how memory tokens in RMT help mitigate such kind of mixing. RMT ability of sequence compression to memory is illustrated in Appendix A.1 Figure 8. For copy with 6 segments RMT compresses and then reads the sequence of 12 tokens with just 6 memory tokens. For Transformer-XL decreasing memory size harms the accuracy score significantly with number of segments larger than 2.
|
| 175 |
+
|
| 176 |
+

|
| 177 |
+
Figure 6: Selected attention map patterns of memory models. (color intensity corresponds to attention score) RMT with segment length $^ { 1 = 2 4 }$ , memory size $= 2 4$ (a) write to memory, (b) read from memory. (c) RMT, segment length $^ { = 8 }$ , memory size ${ : = } 8$ , rewrite from read memory to write memory. (d) Transformer-XL, segment length $^ { 1 = 2 4 }$ , memory siz ${ \romannumeral 2 4 }$ read from the previous hidden states.
|
| 178 |
+
|
| 179 |
+
# 6 Conclusions
|
| 180 |
+
|
| 181 |
+
In this paper we introduced Recurrent Memory Transformer a simple recurrent memory augmentation of Transformer model. RMT is implemented by extension of an input sequence with special global memory tokens and segment-level recurrence. Importantly, our method allows to learn more compact sequence representations and improve existing pretrained models without extensive additional compute, thus making practical machine learning applications more energy efficient and environmentally friendly.
|
| 182 |
+
|
| 183 |
+
In our experiments we compared RMT with Transformer baseline and Transformer-XL which is a well-known modification of Transformer for long sequences. RMT almost perfectly solves Copy, Reverse as well as quadratic equations tasks for sequences consisting of multiple segments outperforming Transformer-XL. It also demonstrates quality for associative retrieval task on par with Transformer-XL. As expected, baseline Transformer fails to solve these tasks for multi-segment settings.
|
| 184 |
+
|
| 185 |
+
RMT trained as a language model performs significantly ahead of Transformer baseline and shows quality metrics similar to Transformer-XL but for up to 10 times smaller memory size. Experimental results demonstrate that for fixed memory size backpropagating gradients for more segments improves performance of RMT. Proposed approach to memory augmentation is quite universal and might be easily applied to any pretrained transformer based model as demonstrated by achievement of state of the art results for long text classification task by fine tuning a combination of RoBERTa and RMT.
|
| 186 |
+
|
| 187 |
+
Analysis of attention maps suggests that better RMT performance can be related to more effective storage of input representations in dedicated memory tokens compared to mixing representations storage in Transformer-XL. RMT could be combined with Transformer-XL cache and improve the performance of both models.
|
| 188 |
+
|
| 189 |
+
Overall, results of the study show that dedicated memory storage and recurrence provided by Recurrent Memory Transformer make it a promising architecture for applications that require learning of long-term dependencies and general purpose in-memory processing, such as algorithmic tasks and reasoning. Furthermore, we believe that RMT could open the way for adding memory and recurrence to other models in the Transformer family.
|
| 190 |
+
|
| 191 |
+
# Acknowledgments and Disclosure of Funding
|
| 192 |
+
|
| 193 |
+
This work was supported by a grant for research centers in the field of artificial intelligence, provided by the Analytical Center for the Government of the Russian Federation in accordance with the subsidy agreement (agreement identifier 000000D730321P5Q0002) and the agreement with the Moscow Institute of Physics and Technology dated November 1, 2021 No. 70-2021-00138.
|
| 194 |
+
|
| 195 |
+
# References
|
| 196 |
+
|
| 197 |
+
Joshua Ainslie, Santiago Ontanon, Chris Alberti, Philip Pham, Anirudh Ravula, and Sumit Sanghai. Etc: Encoding long and structured data in transformers, 2020.
|
| 198 |
+
|
| 199 |
+
Jimmy Ba, Geoffrey E Hinton, Volodymyr Mnih, Joel Z Leibo, and Catalin Ionescu. Using fast weights to attend to the recent past. In D. Lee, M. Sugiyama, U. Luxburg, I. Guyon, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 29. Curran Associates, Inc., 2016. URL https://proceedings. neurips.cc/paper/2016/file/9f44e956e3a2b7b5598c625fcc802c36-Paper.pdf.
|
| 200 |
+
|
| 201 |
+
Iz Beltagy, Matthew E Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv preprint arXiv:2004.05150, 2020.
|
| 202 |
+
|
| 203 |
+
Mikhail S Burtsev, Yuri Kuratov, Anton Peganov, and Grigory V Sapunov. Memory transformer. arXiv preprint arXiv:2006.11527, 2020.
|
| 204 |
+
|
| 205 |
+
Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers, 2019.
|
| 206 |
+
|
| 207 |
+
Kyunghyun Cho, Bart van Merriënboer, Dzmitry Bahdanau, and Yoshua Bengio. On the properties of neural machine translation: Encoder–decoder approaches. In Proceedings of SSST-8, Eighth Workshop on Syntax, Semantics and Structure in Statistical Translation, pages 103–111, Doha, Qatar, October 2014. Association for Computational Linguistics. doi: 10.3115/v1/W14-4012. URL https://aclanthology.org/W14-4012.
|
| 208 |
+
|
| 209 |
+
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.
|
| 210 |
+
|
| 211 |
+
Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc V. Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context, 2019.
|
| 212 |
+
|
| 213 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, 2019. URL https://aclweb.org/anthology/papers/N/N19/ N19-1423/.
|
| 214 |
+
|
| 215 |
+
SiYu Ding, Junyuan Shang, Shuohuan Wang, Yu Sun, Hao Tian, Hua Wu, and Haifeng Wang. ERNIE-Doc: A retrospective long-document modeling transformer. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 2914–2927, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.227. URL https://aclanthology.org/2021.acl-long. 227.
|
| 216 |
+
|
| 217 |
+
Linhao Dong, Shuang Xu, and Bo Xu. Speech-transformer: A no-recurrence sequence-to-sequence model for speech recognition. In 2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 5884–5888, 2018. doi: 10.1109/ICASSP.2018.8462506.
|
| 218 |
+
|
| 219 |
+
Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=YicbFdNTTy.
|
| 220 |
+
|
| 221 |
+
Angela Fan, Thibaut Lavril, Edouard Grave, Armand Joulin, and Sainbayar Sukhbaatar. Addressing some limitations of transformers with feedback memory. arXiv preprint arXiv:2002.09402, 2020.
|
| 222 |
+
|
| 223 |
+
Alex Graves, Greg Wayne, and Ivo Danihelka. Neural turing machines, 2014.
|
| 224 |
+
|
| 225 |
+
Alex Graves, Greg Wayne, Malcolm Reynolds, Tim Harley, Ivo Danihelka, Agnieszka Grabska-Barwinska, ´ Sergio Gómez Colmenarejo, Edward Grefenstette, Tiago Ramalho, John Agapiou, Adrià Puigdomènech Badia, Karl Moritz Hermann, Yori Zwols, Georg Ostrovski, Adam Cain, Helen King, Christopher Summerfield, Phil Blunsom, Koray Kavukcuoglu, and Demis Hassabis. Hybrid computing using a neural network with dynamic external memory. Nature, 538(7626):471–476, October 2016. ISSN 00280836. URL http: //dx.doi.org/10.1038/nature20101.
|
| 226 |
+
|
| 227 |
+
Edward Grefenstette, Karl Moritz Hermann, Mustafa Suleyman, and Phil Blunsom. Learning to transduce with unbounded memory, 2015.
|
| 228 |
+
|
| 229 |
+
Caglar Gulcehre, Sarath Chandar, Kyunghyun Cho, and Yoshua Bengio. Dynamic neural turing machine with soft and hard addressing schemes. arXiv preprint arXiv:1607.00036, 2016.
|
| 230 |
+
|
| 231 |
+
Caglar Gulcehre, Sarath Chandar, and Yoshua Bengio. Memory augmented neural networks with wormhole connections. arXiv preprint arXiv:1701.08718, 2017.
|
| 232 |
+
|
| 233 |
+
Qipeng Guo, Xipeng Qiu, Pengfei Liu, Yunfan Shao, Xiangyang Xue, and Zheng Zhang. Star-transformer, 2019.
|
| 234 |
+
|
| 235 |
+
Ankit Gupta and Jonathan Berant. Gmat: Global memory augmentation for transformers. arXiv preprint arXiv:2006.03274, 2020.
|
| 236 |
+
|
| 237 |
+
Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Comput., 9(8):1735–1780, November 1997. ISSN 0899-7667. doi: 10.1162/neco.1997.9.8.1735. URL https://doi.org/10.1162/ neco.1997.9.8.1735.
|
| 238 |
+
|
| 239 |
+
Andrew Jaegle, Sebastian Borgeaud, Jean-Baptiste Alayrac, Carl Doersch, Catalin Ionescu, David Ding, Skanda Koppula, Daniel Zoran, Andrew Brock, Evan Shelhamer, et al. Perceiver io: A general architecture for structured inputs & outputs. arXiv preprint arXiv:2107.14795, 2021.
|
| 240 |
+
|
| 241 |
+
Armand Joulin and Tomas Mikolov. Inferring algorithmic patterns with stack-augmented recurrent nets, 2015.
|
| 242 |
+
|
| 243 |
+
Da Ju, Stephen Roller, Sainbayar Sukhbaatar, and Jason Weston. Staircase attention for recurrent processing of sequences. arXiv preprint arXiv:2106.04279, 2021.
|
| 244 |
+
|
| 245 |
+
Johannes Kiesel, Maria Mestre, Rishabh Shukla, Emmanuel Vincent, Payam Adineh, David Corney, Benno Stein, and Martin Potthast. Semeval-2019 task 4: Hyperpartisan news detection. In Proceedings of the 13th International Workshop on Semantic Evaluation, pages 829–839, 2019.
|
| 246 |
+
|
| 247 |
+
Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR (Poster), 2015. URL http://arxiv.org/abs/1412.6980.
|
| 248 |
+
|
| 249 |
+
Guillaume Lample, Alexandre Sablayrolles, Marc’Aurelio Ranzato, Ludovic Denoyer, and Hervé Jégou. Large memory layers with product keys, 2019.
|
| 250 |
+
|
| 251 |
+
Jie Lei, Liwei Wang, Yelong Shen, Dong Yu, Tamara L. Berg, and Mohit Bansal. Mart: Memory-augmented recurrent transformer for coherent video paragraph captioning, 2020.
|
| 252 |
+
|
| 253 |
+
Yang Liu, Jiaxiang Liu, Li Chen, Yuxiang Lu, Shikun Feng, Zhida Feng, Yu Sun, Hao Tian, Hua Wu, and Haifeng Wang. Ernie-sparse: Learning hierarchical efficient transformer through regularized self-attention. arXiv preprint arXiv:2203.12276, 2022.
|
| 254 |
+
|
| 255 |
+
Matt Mahoney. Large text compression benchmark, 2006. URL http://www.mattmahoney.net/dc/text. html.
|
| 256 |
+
|
| 257 |
+
Pedro Henrique Martins, Zita Marinho, and André FT Martins. $\infty$ -former: Infinite memory transformer. arXiv preprint arXiv:2109.00301, 2021.
|
| 258 |
+
|
| 259 |
+
Warren S McCulloch and Walter Pitts. A logical calculus of the ideas immanent in nervous activity. The bulletin of mathematical biophysics, 5(4):115–133, 1943.
|
| 260 |
+
|
| 261 |
+
Yuanliang Meng and Anna Rumshisky. Context-aware neural model for temporal information extraction. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 527–536, 2018.
|
| 262 |
+
|
| 263 |
+
Stephen Merity, Caiming Xiong, James Bradbury, and Richard Socher. Pointer sentinel mixture models. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL https://openreview.net/forum? id=Byj72udxe.
|
| 264 |
+
|
| 265 |
+
Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. 2018. URL https://www.cs.ubc.ca/\~amuham01/LING530/papers/ radford2018improving.pdf.
|
| 266 |
+
|
| 267 |
+
Jack W Rae, Jonathan J Hunt, Tim Harley, Ivo Danihelka, Andrew Senior, Greg Wayne, Alex Graves, and Timothy P Lillicrap. Scaling memory-augmented neural networks with sparse reads and writes, 2016.
|
| 268 |
+
|
| 269 |
+
Jack W. Rae, Anna Potapenko, Siddhant M. Jayakumar, and Timothy P. Lillicrap. Compressive transformers for long-range sequence modelling, 2019.
|
| 270 |
+
|
| 271 |
+
Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 8821–8831. PMLR, 18–24 Jul 2021. URL https://proceedings.mlr.press/v139/ ramesh21a.html.
|
| 272 |
+
|
| 273 |
+
C Stephen. Kleene. representation of events in nerve nets and finite automata. Automata studies, 1956.
|
| 274 |
+
|
| 275 |
+
Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory networks, 2015.
|
| 276 |
+
|
| 277 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is All you Need. In Advances in neural information processing systems, pages 5998–6008, 2017. URL http://papers.nips.cc/paper/7181-attention-is-all-you-need.
|
| 278 |
+
|
| 279 |
+
Sinong Wang, Belinda Z. Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with linear complexity, 2020.
|
| 280 |
+
|
| 281 |
+
Paul J Werbos. Backpropagation through time: what it does and how to do it. Proceedings of the IEEE, 78(10): 1550–1560, 1990.
|
| 282 |
+
|
| 283 |
+
Jason Weston, Sumit Chopra, and Antoine Bordes. Memory networks, 2014.
|
| 284 |
+
|
| 285 |
+
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, et al. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 conference on empirical methods in natural language processing: system demonstrations, pages 38–45, 2020.
|
| 286 |
+
|
| 287 |
+
Qingyang Wu, Zhenzhong Lan, Jing Gu, and Zhou Yu. Memformer: The memory-augmented transformer. arXiv preprint arXiv:2010.06891, 2020.
|
| 288 |
+
|
| 289 |
+
Peng Xu, Xinchi Chen, Xiaofei Ma, Zhiheng Huang, and Bing Xiang. Contrastive document representation learning with graph attention networks. arXiv preprint arXiv:2110.10778, 2021.
|
| 290 |
+
|
| 291 |
+
Manzil Zaheer, Guru Guruganesh, Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, et al. Big bird: Transformers for longer sequences. arXiv preprint arXiv:2007.14062, 2020.
|
| 292 |
+
|
| 293 |
+
# Checklist
|
| 294 |
+
|
| 295 |
+
1. For all authors...
|
| 296 |
+
|
| 297 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 298 |
+
(b) Did you describe the limitations of your work? [Yes] We mention training instabilities and GPU RAM issues in Section 5.
|
| 299 |
+
(c) Did you discuss any potential negative societal impacts of your work? [No] The proposed model and method do not have any specific impacts. All general negative societal impacts applicable to the field could be potentially relative.
|
| 300 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 301 |
+
|
| 302 |
+
2. If you are including theoretical results...
|
| 303 |
+
|
| 304 |
+
(a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
|
| 305 |
+
|
| 306 |
+
3. If you ran experiments...
|
| 307 |
+
|
| 308 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] We include code, training scripts, and raw experimental data in the supplementary material. The supplemental materials would be published on github with the final version of the paper. Instructions for language modeling data&experiments are taken from Tr-XL repo.
|
| 309 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 4, Appendix A, and provided supplementary material.
|
| 310 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] All the key experiments results are reported with std. Furthermore, we provide raw experimental data in the supplementary materials.
|
| 311 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] We used different GPUs depending on the task: 1080Ti, V100, A100. We provide this information in Appendix A for each task.
|
| 312 |
+
|
| 313 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 314 |
+
|
| 315 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes] We refer to the original Tr-XL code and Tr-XL paper. We use it for establishing baselines and setting our methods. See Section 4
|
| 316 |
+
(b) Did you mention the license of the assets? [No] Tr-XL license is Apache 2.0 and available at its github repo.
|
| 317 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] Our code is in the supplemental material and on GitHub: https://github.com/ booydar/LM-RMT
|
| 318 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] We used publicly available Tr-XL code (Apache 2.0) and datasets.
|
| 319 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] We use either synthetic data or datasets collected from the Wikipedia (Wikitext-103, enwik8).
|
| 320 |
+
|
| 321 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 322 |
+
|
| 323 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 324 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 325 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/XsZ5YebcCz/XsZ5YebcCz.md
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Mildly Constrained Evaluation Policy for Offline Reinforcement Learning
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 Offline reinforcement learning (RL) methodologies enforce constraints on the
|
| 11 |
+
2 policy to adhere closely to the behavior policy, thereby stabilizing value learning
|
| 12 |
+
3 and mitigating the selection of out-of-distribution (OOD) actions during test time.
|
| 13 |
+
4 Conventional approaches apply identical constraints for both value learning and test
|
| 14 |
+
5 time inference. However, our findings indicate that the constraints suitable for value
|
| 15 |
+
6 estimation may in fact be excessively restrictive for action selection during test time.
|
| 16 |
+
7 To address this issue, we propose a Mildly Constrained Evaluation Policy (MCEP)
|
| 17 |
+
8 for test time inference with a more constrained target policy for value estimation.
|
| 18 |
+
9 Since the target policy has been adopted in various prior approaches, MCEP can
|
| 19 |
+
10 be seamlessly integrated with them as a plug-in. We instantiate MCEP based on
|
| 20 |
+
11 TD3-BC [Fujimoto and Gu, 2021] and AWAC [Nair et al., 2020] algorithms. The
|
| 21 |
+
12 empirical results on MuJoCo locomotion tasks show that the MCEP significantly
|
| 22 |
+
13 outperforms the target policy and achieves competitive results to state-of-the-art
|
| 23 |
+
14 offline RL methods. The codes are open-sourced at link.
|
| 24 |
+
|
| 25 |
+
# 15 1 Introduction
|
| 26 |
+
|
| 27 |
+
16 Offline reinforcement learning (RL) extracts a policy from data that is pre-collected by unknown
|
| 28 |
+
17 policies. This setting does not require interactions with the environment thus it is well-suited for tasks
|
| 29 |
+
18 where the interaction is costly or risky. Recently, it has been applied to Natural Language Process
|
| 30 |
+
19 ing [Snell et al., 2022], e-commerce [Degirmenci and Jones] and real-world robotics [Kalashnikov
|
| 31 |
+
20 et al., 2021, Rafailov et al., 2021, Kumar et al., 2022, Shah et al., 2022] etc. Compared to the standard
|
| 32 |
+
21 online setting where the policy gets improved via trial and error, learning with a static offline dataset
|
| 33 |
+
22 raises novel challenges. One challenge is the distributional shift between the training data and the data
|
| 34 |
+
23 encountered during deployment. To attain stable evaluation performance under the distributional shift,
|
| 35 |
+
24 the policy is expected to stay close to the behavior policy. Another challenge is the "extrapolation
|
| 36 |
+
25 error" [Fujimoto et al., 2019, Kumar et al., 2019] that indicates value estimate error on unseen
|
| 37 |
+
26 state-action pairs or Out-Of-Distribution (OOD) actions. Worsely, this error can be amplified with
|
| 38 |
+
27 bootstrapping and cause instability of the training, which is also known as deadly-triad [Van Hasselt
|
| 39 |
+
28 et al., 2018]. Majorities of model-free approaches tackle these challenges by either constraining the
|
| 40 |
+
29 policy to adhere closely to the behavior policy [Wu et al., 2019, Kumar et al., 2019, Fujimoto and Gu,
|
| 41 |
+
30 2021] or regularising the Q to pessimistic estimation for OOD actions [Kumar et al., 2020, Lyu et al.,
|
| 42 |
+
31 2022]. In this work, we focus on policy constraints methods.
|
| 43 |
+
32 Policy constraints methods minimize the disparity between the policy distribution and the behavior
|
| 44 |
+
33 distribution. It is found that policy constraints introduce a tradeoff between stabilizing value estimates
|
| 45 |
+
34 and attaining better performance. While previous approaches focus on developing various constraints
|
| 46 |
+
35 for the learning policy to address this tradeoff, the tradeoff itself is not well understood. Current
|
| 47 |
+
36 solutions have confirmed that an excessively constrained policy enables stable values estimate
|
| 48 |
+
37 but degrades the evaluation performance [Kumar et al., 2019, Singh et al., 2022, Yu et al., 2023].
|
| 49 |
+
38 Nevertheless, it is not clear to what extent this constraint fails to stabilize value learning and to
|
| 50 |
+
39 what extent this constraint leads to a performant evaluation policy. It is essential to investigate these
|
| 51 |
+
40 questions as their answers indicate how well a solution can be found under the tradeoff. However,
|
| 52 |
+
41 the investigation into the latter question is impeded by the existing tradeoff, as it requires tuning the
|
| 53 |
+
42 constraint without influencing the value learning. We circumvent the tradeoff and seek solutions for
|
| 54 |
+
43 this investigation through the critic. For actor-critic methods, [Czarnecki et al., 2019] has shed light
|
| 55 |
+
44 on the potential of distilling a student policy that improves over the teacher using the teacher’s critic.
|
| 56 |
+
45 Inspired by this work, we propose to derive an extra evaluation policy from the critic to avoid solving
|
| 57 |
+
46 the above-mentioned tradeoff. The actor is now called target policy as it is used only to stabilize the
|
| 58 |
+
47 value estimation.
|
| 59 |
+
48 Based on the proposed framework, we empirically investigate the constraint strengths for 1) stabilizing
|
| 60 |
+
49 value learning and 2) better evaluation performance. The results find that a milder constraint improves
|
| 61 |
+
50 the evaluation performance but may fall beyond the constraint space of stable value estimation.
|
| 62 |
+
51 This finding indicates that the optimal evaluation performance may not be found under the tradeoff,
|
| 63 |
+
52 especially when stable value learning is the priority. Consequently, we propose a novel approach of
|
| 64 |
+
53 using a Mildly Constrained Evaluation Policy (MCEP) derived from the critic to avoid solving the
|
| 65 |
+
54 above-mentioned tradeoff and to achieve better evaluation performance.
|
| 66 |
+
55 As the target policy is commonly used in previous approaches, our MCEP can be integrated with
|
| 67 |
+
56 them seamlessly. In this paper, we first validate the finding of [Czarnecki et al., 2019] in the offline
|
| 68 |
+
57 setting by a toy maze experiment, where a constrained policy results in bad evaluation performance
|
| 69 |
+
58 but its off-policy Q estimation indicates an optimal policy. After that, our experiments on D4RL [Fu
|
| 70 |
+
59 et al., 2020] MoJoCo locomotion tasks showed that in most tasks milder constraint achieves better
|
| 71 |
+
60 evaluation performance while more restrictive constraint stabilizes the value estimate. Finally, we
|
| 72 |
+
61 instantiated MCEP on both TD3BC and AWAC algorithms. The empirical results find that the MCEP
|
| 73 |
+
62 significantly outperforms the target policy and achieves competitive results to state-of-the-art offline
|
| 74 |
+
63 RL methods.
|
| 75 |
+
|
| 76 |
+
# 64 2 Related Work
|
| 77 |
+
|
| 78 |
+
65 Policy constraints method (or behavior-regularized policy method) [Wu et al., 2019, Kumar et al.,
|
| 79 |
+
66 2019, Siegel et al., 2020, Fujimoto and Gu, 2021] forces the policy distribution to stay close to the
|
| 80 |
+
67 behavior distribution. Different discrepancy measurements such as KL divergence [Jaques et al., 2019,
|
| 81 |
+
68 Wu et al., 2019], reverse KL divergence Cai et al. [2022] and Maximum Mean Discrepancy [Kumar
|
| 82 |
+
69 et al., 2019] are applied in previous approaches. [Fujimoto and Gu, 2021] simply adds a behavior
|
| 83 |
+
70 cloning (BC) term to the online RL method Twin Delayed DDPG (TD3) [Fujimoto et al., 2018]
|
| 84 |
+
71 and obtains competitive performances in the offline setting. While the above-mentioned methods
|
| 85 |
+
72 calculate the divergence from the data, [Wu et al., 2022] estimates the density of the behavior
|
| 86 |
+
73 distribution using VAE, and thus the divergence can be directly calculated. Except for explicit policy
|
| 87 |
+
74 constraints, implicit constraints are achieved by different approaches. E.g. [Zhou et al., 2021] ensures
|
| 88 |
+
75 the output actions stay in support of the data distribution by using a pre-trained conditional VAE
|
| 89 |
+
76 (CVAE) decoder that maps latent actions to the behavior distribution. In all previous approaches, the
|
| 90 |
+
77 constraints are applied to the learning policy that is queried during policy evaluation and is evaluated
|
| 91 |
+
78 in the environment during deployment. Our approach does not count on this learning policy for the
|
| 92 |
+
79 deployment, instead, it is used as a target policy only for the policy evaluation.
|
| 93 |
+
80 While it is well-known that a policy constraint can be efficient to reduce extrapolation errors, its
|
| 94 |
+
81 drawback is not well-studied yet. [Kumar et al., 2019] reveals a tradeoff between reducing errors in
|
| 95 |
+
82 the Q estimate and reducing the suboptimality bias that degrades the evaluation policy. A constraint is
|
| 96 |
+
83 designed to create a policy space that ensures the resulting policy is under the support of the behavior
|
| 97 |
+
84 distribution for mitigating bootstrapping error. [Singh et al., 2022] discussed the inefficiency of policy
|
| 98 |
+
85 constraints on heteroskedastic dataset where the behavior varies across the state space in a highly
|
| 99 |
+
86 non-uniform manner, as the constraint is state-agnostic. A reweighting method is proposed to achieve
|
| 100 |
+
87 a state-aware distributional constraint to overcome this problem. Our work studies essential questions
|
| 101 |
+
88 about the tradeoff [Kumar et al., 2019] and overcomes this drawback [Singh et al., 2022] by using an
|
| 102 |
+
89 extra evaluation policy.
|
| 103 |
+
90 There are methods that extract an evaluation policy from a learned Q estimate. One-step RL [Brand
|
| 104 |
+
91 fonbrener et al., 2021] first estimates the behavior policy and its Q estimate, which is later used
|
| 105 |
+
92 for extracting the evaluation policy. Although its simplicity, one-step RL is found to perform badly
|
| 106 |
+
93 in long-horizon problems due to a lack of iterative dynamic programming [Kostrikov et al., 2022].
|
| 107 |
+
94 [Kostrikov et al., 2022] proposed Implicity Q learning (IQL) that avoids query of OOD actions
|
| 108 |
+
95 by learning an upper expectile of the state value distribution. No explicit target policy is mod
|
| 109 |
+
96 eled during their Q learning. With the learned Q estimate, an evaluation policy is extracted using
|
| 110 |
+
97 advantage-weighted regression [Wang et al., 2018, Peng et al., 2019]. Our approach has a similar
|
| 111 |
+
98 form of extracting an evaluation from a learned Q estimate. However, one-step RL aims to avoid
|
| 112 |
+
99 distribution shift and iterative error exploitation during iterative dynamic programming. IQL avoids
|
| 113 |
+
100 error exploitation by eliminating OOD action queries and abandoning policy improvement (i.e. the
|
| 114 |
+
101 policy is not trained against the Q estimate). Our work instead tries to address the error exploitation
|
| 115 |
+
102 problem and evaluation performance by using policies of different constraint strengths.
|
| 116 |
+
|
| 117 |
+
# 103 3 Background
|
| 118 |
+
|
| 119 |
+
104 We model the environment as a Markov Decision Process (MDP) $\langle S , A , R , T , p _ { 0 } ( s ) , \gamma , \rangle$ , where $S$ is
|
| 120 |
+
105 the state space, $A$ is the action space, $R$ is the reward function, $T ( s ^ { \prime } | s , a )$ is the transition probability,
|
| 121 |
+
106 $p _ { 0 } ( s )$ is initial state distribution and $\gamma$ is a discount factor. In the offline setting, a static dataset
|
| 122 |
+
107 $\mathcal { D } _ { \beta } = \{ ( s , a , r , s ^ { \prime } ) \}$ is pre-collected by a behavior policy $\pi _ { \beta }$ . The goal is to learn a policy $\pi _ { \phi } ( s )$ with
|
| 123 |
+
108 the dataset $\mathcal { D }$ that maximizes the discounted cumulated rewards in the MDP:
|
| 124 |
+
|
| 125 |
+
$$
|
| 126 |
+
\phi ^ { * } = \arg \operatorname* { m a x } _ { \phi } \mathbb { E } _ { s _ { 0 } \sim p _ { 0 } ( \cdot ) , a _ { t } \sim \pi _ { \phi } ( s _ { t } ) , s _ { t + 1 } \sim T ( \cdot | s _ { t } , a _ { t } ) } [ \sum _ { t = 0 } ^ { \infty } \gamma ^ { t } R ( s _ { t } , a _ { t } ) ]
|
| 127 |
+
$$
|
| 128 |
+
|
| 129 |
+
109 Next, we introduce the general policy constraint method, where the policy $\pi _ { \phi }$ and an off-policy Q
|
| 130 |
+
110 estimate $Q _ { \theta }$ are updated by iteratively taking policy improvement steps and policy evaluation steps,
|
| 131 |
+
111 respectively. The policy evaluation step minimizes the Bellman error:
|
| 132 |
+
|
| 133 |
+
$$
|
| 134 |
+
\mathcal { L } _ { Q } ( \theta ) = \mathbb { E } _ { s _ { t } , a _ { t } \sim \mathcal { D } , a _ { t + 1 } \sim \pi _ { \phi } ( s _ { t + 1 } ) } \left[ \left( Q _ { \theta } ( s _ { t } , a _ { t } ) - ( r + \gamma Q _ { \theta ^ { \prime } } ( s _ { t } , a _ { t + 1 } ) ) \right) ^ { 2 } \right] .
|
| 135 |
+
$$
|
| 136 |
+
|
| 137 |
+
where the 112 $\theta ^ { \prime }$ is the parameter for a delayed-updated target Q network. The Q value for the next state is 113 calculated with actions $a _ { t + 1 }$ from the learning policy that is updated through the policy improvement 114 step:
|
| 138 |
+
|
| 139 |
+
$$
|
| 140 |
+
\begin{array} { r } { \mathcal { L } _ { \pi } ( \phi ) = \mathbb { E } _ { s \sim \mathcal { D } , a \sim \pi _ { \phi } ( s ) } [ - Q _ { \theta } ( s , a ) + w C ( \pi _ { \beta } , \pi _ { \phi } ) ] , } \end{array}
|
| 141 |
+
$$
|
| 142 |
+
|
| 143 |
+
115 where $C$ is a constraint measuring the discrepancy between the policy distribution $\pi _ { \phi }$ and the behavior
|
| 144 |
+
116 distribution $\pi _ { \beta }$ . The $w \in ( 0 , \infty ]$ is a weighting factor. Different kinds of constraints were used such
|
| 145 |
+
117 as Maximum Mean Discrepancy (MMD), KL divergence, and reverse KL divergence.
|
| 146 |
+
|
| 147 |
+
# 118 4 Method
|
| 148 |
+
|
| 149 |
+
119 In this section, we first introduce the generic algorithm that can be integrated with any policy
|
| 150 |
+
120 constraints method. Next, we introduce two examples based on popular offline RL methods TD3BC
|
| 151 |
+
121 and AWAC. With a mildly constrained evaluation policy, we name these two instances as TD3BC
|
| 152 |
+
122 with MCEP (TD3BC-MCEP) and AWAC with MCEP (AWAC-MCEP).
|
| 153 |
+
|
| 154 |
+
# 123 4.1 Offline RL with mildly constrained evaluation policy
|
| 155 |
+
|
| 156 |
+
124 The proposed method is designed for overcoming the tradeoff between a stable policy evaluation and
|
| 157 |
+
125 a performant evaluation policy. In previous constrained policy methods, a restrictive policy constraint
|
| 158 |
+
126 is applied to obtain stable policy evaluation. We retain this benefit but use this policy (actor) $\tilde { \pi }$ as
|
| 159 |
+
127 a target policy only to obtain stable policy evaluation. To achieve better evaluation performance,
|
| 160 |
+
128 we introduce an MCEP $\pi ^ { e }$ that is updated by taking policy improvement steps with the critic $Q _ { \tilde { \pi } }$ .
|
| 161 |
+
129 Different from $\tilde { \pi }$ , $\pi ^ { e }$ does not participate in the policy evaluation procedure. Therefore, a mild policy
|
| 162 |
+
130 constraint can be applied, which helps $\pi ^ { e }$ go further away from the behavior distribution without
|
| 163 |
+
131 influencing the stability of policy evaluation. We demonstrate the policy spaces and policy trajectories
|
| 164 |
+
132 for $\tilde { \pi }$ and $\pi ^ { e }$ in the l.h.s. diagram of Figure 1, where $\pi ^ { e }$ is updated in the wider policy space using $Q _ { \tilde { \pi } }$ .
|
| 165 |
+
133 The overall algorithm is shown as pseudo-codes
|
| 166 |
+
134 (Alg. 1). At each step, the $Q _ { \tilde { \pi } }$ , $\tilde { \pi } _ { \psi }$ and $\pi _ { \phi } ^ { e }$ are
|
| 167 |
+
135 updated iteratively. A policy evaluation step up
|
| 168 |
+
136 dates $Q _ { \tilde { \pi } }$ by minimizing the TD error (line 7),
|
| 169 |
+
137 i.e. the deviation between the approximate $Q$
|
| 170 |
+
138 and its target value. Next, a policy improve
|
| 171 |
+
139 ment step updates $\tilde { \pi } _ { \psi }$ (line 6. These two steps
|
| 172 |
+
140 form the actor-critic algorithm. After that, $\pi _ { \phi } ^ { e }$
|
| 173 |
+
141 is extracted from the $Q _ { \tilde { \pi } }$ , by taking a policy im
|
| 174 |
+
142 provement step with a policy constraint that is
|
| 175 |
+
143 likely milder than the constraint for $\tilde { \pi } _ { \psi }$ (line 7).
|
| 176 |
+
144 Many approaches can be taken to obtain a milder
|
| 177 |
+
|
| 178 |
+

|
| 179 |
+
Figure 1: Left: diagram depicts policy trajectories for target policy $\tilde { \pi }$ and MCEP $\pi ^ { e }$ . Right: policy evaluation steps to update $Q _ { \tilde { \pi } }$ and policy improvement steps to update $\tilde { \pi }$ and $\pi ^ { e }$ .
|
| 180 |
+
|
| 181 |
+
# Algorithm 1 MCEP Training
|
| 182 |
+
|
| 183 |
+
1: Hyperparameters: LR $\alpha$ , EMA $\eta$ , $\tilde { w }$ and $w ^ { e }$
|
| 184 |
+
2: Initialize: $\theta , \theta ^ { \prime } , \psi$ , and $\phi$
|
| 185 |
+
3: for $\mathrm { i } { = } 1$ , 2, ..., N do
|
| 186 |
+
4: $\theta \theta - \alpha \mathcal { L } _ { Q } ( \theta )$ (Equation 2)
|
| 187 |
+
5: $\theta ^ { \prime } ( 1 - \eta ) \dot { \theta } ^ { \prime } + \eta \theta$
|
| 188 |
+
6: $\psi \psi - \alpha \mathcal { L } _ { \tilde { \pi } } ( \psi ; \tilde { w } )$ (Equation 3)
|
| 189 |
+
7: $\phi \phi - \alpha \mathcal { L } _ { \pi ^ { e } } ( \phi ; w ^ { e } )$ (Equation 3)
|
| 190 |
+
145 policy constraint. For example, tuning down the weight factor $w ^ { e }$ for the policy constraint term or
|
| 191 |
+
146 replacing the constraint measurement with a less restrictive one. Note that the constraint for $\pi _ { \phi } ^ { e }$ is
|
| 192 |
+
147 necessary (the constraint term should not be dropped) as the $Q _ { \tilde { \pi } }$ has large approximate errors for
|
| 193 |
+
148 state-action pairs that are far from the data distribution.
|
| 194 |
+
|
| 195 |
+
# 4.2 Two Examples: TD3BC-MCEP and AWAC-MCEP
|
| 196 |
+
|
| 197 |
+
150 TD3BC with MCEP TD3BC takes a minimalist modification on the online RL algorithm TD3. To
|
| 198 |
+
151 keep the learned policy to stay close to the behavior distribution, a behavior-cloning term is added to
|
| 199 |
+
152 the policy improvement objective. TD3 learns a deterministic policy therefore the behavior cloning is
|
| 200 |
+
153 achieved by directly regressing the data actions. For TD3BC-MCEP, the target policy $\tilde { \pi } _ { \psi }$ has the
|
| 201 |
+
154 same policy improvement objective as TD3BC:
|
| 202 |
+
|
| 203 |
+
$$
|
| 204 |
+
\mathcal { L } _ { \tilde { \pi } } ( \psi ) = \mathbb { E } _ { ( s , a ) \sim \mathcal { D } } [ - \tilde { \lambda } Q _ { \theta } ( s , \tilde { \pi } _ { \psi } ( s ) ) + \left( a - \tilde { \pi } _ { \psi } ( s ) \right) ^ { 2 } ] ,
|
| 205 |
+
$$
|
| 206 |
+
|
| 207 |
+
155 where the $\begin{array} { r } { \tilde { \lambda } = \frac { \tilde { \alpha } } { \frac { 1 } { N } \sum _ { s _ { i } , a _ { i } } | Q _ { \theta } ( s _ { i } , a _ { i } ) | } } \end{array}$ is a normalizer for $\mathrm { Q }$ values with a hyper-parameter $\tilde { \alpha }$ : The $Q _ { \theta }$
|
| 208 |
+
156 is updated with the policy evaluation step similar to Eq. 2 using $\tilde { \pi } _ { \psi }$ . The MCEP $\pi _ { \phi } ^ { e }$ is updated by
|
| 209 |
+
157 policy improvement steps with the $Q _ { \tilde { \pi } }$ taking part in. The policy improvement objective function for
|
| 210 |
+
158 $\pi _ { \phi } ^ { e }$ is similar to Eq. 4 but with a higher-value $\alpha ^ { e }$ for the Q-value normalizer $\lambda ^ { e }$ . The final objective
|
| 211 |
+
159 for $\pi _ { \phi } ^ { e }$ is
|
| 212 |
+
|
| 213 |
+
$$
|
| 214 |
+
\mathscr { L } _ { \pi ^ { e } } ( \phi ) = \mathbb { E } _ { ( s , a ) \sim \mathcal { D } } [ - \lambda ^ { e } Q ( s , \pi _ { \phi } ^ { e } ( s ) ) + \left( a - \pi _ { \phi } ^ { e } ( s ) \right) ^ { 2 } ] .
|
| 215 |
+
$$
|
| 216 |
+
|
| 217 |
+
160 AWAC with MCEP AWAC [Nair et al., 2020] is an advantage-weighted behavior cloning method.
|
| 218 |
+
161 As the target policy imitates the actions from the behavior distribution, it stays close to the behavior
|
| 219 |
+
162 distribution during learning. In AWAC-MCEP, the policy evaluation follows the Eq. 2 with the target
|
| 220 |
+
|
| 221 |
+

|
| 222 |
+
Figure 2: Evaluation of policy constraint method on a toy maze MDP 2a. In other figures, the color of a grid represents the state value and arrows indicate the actions from the corresponding policy. 2b shows the optimal value function and one optimal policy. 2c shows a constrained policy trained from the above-mentioned offline data, with its value function calculated by $V _ { \pi } = \mathbb { E } _ { a } Q ( s , \pi ( a | s ) )$ . The policy does not perform well in the low state-value area but its value function is close to the optimal value function. 2d indicates that an optimal policy is recovered by deriving the greedy policy from the off-policy Q estimate (the critic).
|
| 223 |
+
|
| 224 |
+
163 policy $\tilde { \pi } _ { \psi }$ that updates with the following objective:
|
| 225 |
+
|
| 226 |
+
$$
|
| 227 |
+
\mathcal { L } _ { \tilde { \pi } } ( \psi ) = \mathbb { E } _ { s , a \sim \mathcal { D } } \biggl [ - \exp \biggl ( \frac { 1 } { \tilde { \lambda } } A ( s , a ) \biggr ) \log \tilde { \pi } _ { \psi } ( a | s ) \biggr ] ,
|
| 228 |
+
$$
|
| 229 |
+
|
| 230 |
+
164 where the advantage $A ( s , a ) = Q _ { \theta } ( s , a ) - Q _ { \theta } ( s , \tilde { \pi } _ { \psi } ( s ) )$ . This objective function solves an advantage
|
| 231 |
+
165 weighted maximum likelihood. Note that the gradient will not be passed through the advantage term.
|
| 232 |
+
166 As this objective has no policy improvement term, we use the original policy improvement with KL
|
| 233 |
+
167 divergence as the policy constraint and construct the following policy improvement objective:
|
| 234 |
+
|
| 235 |
+
$$
|
| 236 |
+
\begin{array} { r l } & { \mathcal { L } _ { \pi ^ { e } } ( \phi ) = \mathbb { E } _ { s , a \sim \mathcal { D } , \hat { a } \sim \pi ^ { e } ( \cdot | s ) } [ - Q ( s , \hat { a } ) + \lambda ^ { e } D _ { K L } \left( \pi _ { \beta } ( \cdot | s ) | | \pi _ { \phi } ^ { e } ( \cdot | s ) \right) ] } \\ & { \quad \quad \quad = \mathbb { E } _ { s , a \sim \mathcal { D } , \hat { a } \sim \pi ^ { e } ( \cdot | s ) } [ - Q ( s , \hat { a } ) - \lambda ^ { e } \log \pi _ { \phi } ^ { e } ( a | s ) ] , } \end{array}
|
| 237 |
+
$$
|
| 238 |
+
|
| 239 |
+
168 where the weighting factor $\lambda ^ { e }$ is a hyper-parameter. Although the Eq. 6 is derived by solving Eq. 8
|
| 240 |
+
169 in a parametric-policy space, the original problem (Eq. 8) is less restrictive even with $\tilde { \lambda } = \lambda ^ { e }$ as it
|
| 241 |
+
170 includes a $- Q ( s , \pi ^ { e } ( s ) )$ term. This difference means that even with a $\lambda ^ { e } > \tilde { \lambda }$ , the policy constraint
|
| 242 |
+
171 for $\pi ^ { e }$ could still be more relaxed than the policy constraint for $\tilde { \pi }$ .
|
| 243 |
+
|
| 244 |
+
# 172 5 Experiments
|
| 245 |
+
|
| 246 |
+
173 In this section, we set up 4 groups of experiments to illustrate: 1) the policy constraint might degrade
|
| 247 |
+
174 the evaluation performance by forcing the policy to stay close to low-state-value transitions. 2) The
|
| 248 |
+
175 suitable constraint for the final inference could be milder than the ones for safe Q estimates. 3) Our
|
| 249 |
+
176 method shows significant performance improvement compared to the target policy and achieves
|
| 250 |
+
177 competitive results to state-of-the-art offline RL methods on MuJoCo locomotion tasks. 4) the MCEP
|
| 251 |
+
178 generally gains a higher estimate Q compared to the target policy. Additionally, we adopt 2 groups of
|
| 252 |
+
179 ablation studies to verify the benefit of an MCEP and to investigate the constraint strengths of MCEP.
|
| 253 |
+
180 Environments D4RL [Fu et al., 2020] is an offline RL benchmark consisting of many task sets.
|
| 254 |
+
181 Our experiments involve MuJoCo locomotion tasks $( - \nu 2 )$ and two tasks from Adroit $( - \nu O )$ . For
|
| 255 |
+
182 MuJoCo locomotion tasks, we select 4 versions of datasets: data collected by a uniformly-random
|
| 256 |
+
183 agent (random), collected by a medium-performance policy (medium), a $5 0 \% - 5 0 \%$ mixture of the
|
| 257 |
+
184 medium data and the replay buffer during training a medium-performance policy (medium-replay), a
|
| 258 |
+
185 $5 0 \% - 5 0 \%$ mixture of the medium data and expert demonstrations (medium-expert). For Adroit,
|
| 259 |
+
186 we select pen-human and pen-cloned, where the pen-human includes a small number of human
|
| 260 |
+
187 demonstrations, and pen-cloned is a $5 0 \% - 5 0 \%$ mixture of demonstrations and data collected by
|
| 261 |
+
188 rolling out an imitation policy on the demonstrations.
|
| 262 |
+
|
| 263 |
+
# 5.1 Target policy that enables safe Q estimate might be overly constrained
|
| 264 |
+
|
| 265 |
+
190 To investigate the policy constraint under a highly suboptimal dataset, we set up a toy maze MDP that
|
| 266 |
+
191 is similar to the one used in [Kostrikov et al., 2022]. The environment is depicted in Figure 2a, where
|
| 267 |
+
192 the lower left yellow grid is the starting point and the upper left green grid is the terminal state that
|
| 268 |
+
193 gives a reward of 10. Other grids give no reward. Dark blue indicates un-walkable areas. The action
|
| 269 |
+
194 space is defined as 4 direction movements (arrows) and staying where the agent is (filled circles).
|
| 270 |
+
195 There is a $2 5 \%$ probability that a random action is taken instead of the action from the agent. For the
|
| 271 |
+
196 dataset, 99 trajectories are collected by a uniformly random agent and 1 trajectory is collected by an
|
| 272 |
+
197 expert policy. Fig. 2b shows the optimal value function (colors) and one of the optimal policies.
|
| 273 |
+
198 We trained a constrained policy using Eq. 2 and Eq. 8 in an actor-critic manner, where the actor is
|
| 274 |
+
199 constrained by a KL divergence with a weight factor of 1. Figure 2c shows the value function and the
|
| 275 |
+
200 policy. We observe that the learned value function is close to the optimal one in Figure 2b. However,
|
| 276 |
+
201 the policy does not make optimal actions in the lower left areas where the state values are relatively
|
| 277 |
+
202 low. As the policy improvement objective shows a trade-off between the Q and the KL divergence,
|
| 278 |
+
203 when the Q value is low, the KL divergence term will obtain higher priority. i.e. in low-Q-value
|
| 279 |
+
204 areas, the KL divergence takes the majority for the learning objective, which makes the policy stays
|
| 280 |
+
205 closer to the transitions in low-value areas. However, we find that the corresponding value function
|
| 281 |
+
206 indicates an optimal policy. In Figure 2d, we recover a greedy policy underlying the learned critic
|
| 282 |
+
207 that shows an optimal policy. In conclusion, the constraint might degrade the evaluation performance
|
| 283 |
+
208 although the learned critic may indicate a better policy. Although such a trade-off between the Q
|
| 284 |
+
209 term and the KL divergence term can be alleviated in previous work [Fujimoto and Gu, 2021] by
|
| 285 |
+
210 normalizing the Q values, in the next section, we will illustrate that the constraint required to obtain
|
| 286 |
+
211 performant evaluation policy can still cause unstable value estimate.
|
| 287 |
+
|
| 288 |
+

|
| 289 |
+
Figure 4: The training process of TD3BC and AWAC. Left: TD3BC on hopper-medium- $\nu 2$ . Middle: TD3BC on walker2d-medium-replay$\nu 2$ . Right: AWAC on hopper-medium-replay- $\cdot \nu 2$ .
|
| 290 |
+
|
| 291 |
+

|
| 292 |
+
Figure 5: $\alpha$ values in TD3BC for value estimate and test time inference in MuJoCo locomotion tasks.
|
| 293 |
+
|
| 294 |
+
# 212 5.2 Test-time inference requires milder constraints
|
| 295 |
+
|
| 296 |
+
The previous experiment shows that a restrictive constraint might harm the test-time inference, which motivates us to investigate what constraints make better evaluation performance. Firstly, we relax the policy constraint on TD3BC and AWAC by setting up different hyper-parameter values that control the strengths of the policy constraints. For TD3BC, we set $\alpha = \{ 1 , 4 , 1 0 \}$ ([Fujimoto and Gu, 2021] recommends $\alpha = 2 . 5$ ). For AWAC, we set $\lambda = \{ 1 . 0 , 0 . 5 , 0 . 3 , 0 . 1 \}$ ([Nair et al., 2020] recommends $\lambda = 1$ ). Finally, We visualize the evaluation performance and the learned Q estimates.
|
| 297 |
+
|
| 298 |
+
In Figure 4, the left two columns show the training of TD3BC in the hopper-medium- $\nu 2$ and walker2dmedium-replay- $\nu 2$ . In both domains, we found that using a milder constraint by tuning the $\alpha$ from 1 to 4 improves the evaluation performance, which motivates us to expect better performance with $\alpha = 1 0$ . As shown in the lower row, we do observe higher performances in some training steps. However, unstable training is caused by the divergence in value estimate, which indicates the tradeoff between the stable Q estimate and the evaluation performance. The rightmost column shows the training of AWAC in hopper-medium-replay- $\nu 2$ , we observe higher evaluation performance by relaxing the constraint $\lambda > 1 \AA$ ). Although the Q estimate keeps stable during the training in all $\lambda$ values, higher $\lambda$ results in unstable policy performance and causes the performance crash with $\lambda = 0 . 1$ .
|
| 299 |
+
|
| 300 |
+
228 Concluding on all these examples, a milder constraint can potentially improve the performance
|
| 301 |
+
229 but may cause unstable Q estimates or unstable policy performances. As we find that relaxing the
|
| 302 |
+
230 constraint on current methods triggers unstable training, which hinders the investigation of constraints
|
| 303 |
+
231 for better evaluation performance. We instead systematically study the constraint strengths in TD3BC
|
| 304 |
+
232 and TD3BC with evaluation policy (TD3BC-EP).
|
| 305 |
+
|
| 306 |
+
<table><tr><td>TaskName</td><td>BC</td><td>CQL IQL</td><td></td><td>TD3BC (ours)</td><td>TD3BC-MCEP AWAC</td><td></td><td>AWAC-MCEP (ours)</td></tr><tr><td>halfcheetah-r</td><td>2.2±0.0</td><td>=</td><td>10±1.7</td><td>11.7±0.4</td><td>28.8±1.0</td><td>9.6±0.4</td><td>34.9±0.8</td></tr><tr><td>hopper-r</td><td>4.7±0.1</td><td></td><td>8.1±0.4</td><td>8.3±0.1</td><td>8.0±0.4</td><td>5.3±0.4</td><td>9.8±0.5</td></tr><tr><td>walker2d-r</td><td>1.6±0.0</td><td></td><td>5.6±0.1</td><td>1.2±0.0</td><td>-0.2±0.1</td><td>5.2±1.0</td><td>3.1±0.4</td></tr><tr><td>halfcheetah-m</td><td>42.4±0.1</td><td>44.0</td><td>47.4±0.1</td><td>48.7±0.2</td><td>55.5±0.4</td><td>45.1±0</td><td>46.6±0</td></tr><tr><td>hopper-m</td><td>54.1±1.1</td><td>58.5</td><td>65±3.6</td><td>56.1±1.2</td><td>91.8±0.9</td><td>58.9±1.9</td><td>91.1±1.5</td></tr><tr><td>walker2d-m</td><td>71±1.7</td><td>72.5</td><td>80.4±1.7</td><td>85.2±0.9</td><td>88.8±0.5</td><td>79.6±1.5</td><td>83.4±0.9</td></tr><tr><td>halfcheetah-m-r</td><td>37.8±1.1</td><td>45.5</td><td>43.2±0.8</td><td>44.8±0.3</td><td>50.6±0.2</td><td>43.3±0.1</td><td>44.9±0.1</td></tr><tr><td>hopper-m-r</td><td>22.5±3.0</td><td>95.0</td><td>74.2±5.3</td><td>55.2±10.8</td><td>100.9±0.4</td><td>64.8±6.2</td><td>101.4±0.2</td></tr><tr><td>walker2d-m-r</td><td>14.4±2.7</td><td>77.2</td><td>62.7±1.9</td><td>50.9±16.1</td><td>86.3±3.2</td><td>84.1±0.6</td><td>84.6±1.3</td></tr><tr><td>halfcheetah-m-e</td><td>62.3±1.5</td><td>91.6</td><td>91.2±1.0</td><td>87.1±1.4</td><td>71.5±3.7</td><td>77.6±2.6</td><td>76.2±5.5</td></tr><tr><td>hopper-m-e</td><td>52.5±1.4</td><td>105.4</td><td>110.2±0.3</td><td>91.7±10.5</td><td>80.1±12.7</td><td>52.4±8.7</td><td>92.5±8.3</td></tr><tr><td>walker2d-m-e</td><td>107±1.1</td><td>108.8</td><td>111.1±0.5</td><td>110.4±0.5</td><td>111.7±0.3</td><td>109.5±0.2</td><td>110.3±0.1</td></tr><tr><td>Average</td><td>39.3</td><td>=</td><td>59.0</td><td>54.2</td><td>64.5</td><td>52.9</td><td>64.9</td></tr><tr><td>pen-human</td><td>76.8±4.8</td><td>37.5</td><td>64.2±10.4</td><td>61.6±11</td><td>58.6±20.8</td><td>34.7±11.8</td><td>23.3 ±5.6</td></tr><tr><td>pen-cloned</td><td>28.5±6.7</td><td>39.2</td><td>32.1±7.5</td><td>49±9.5</td><td>43.4±20.3</td><td>20.8±7.3</td><td>19.0±7.5</td></tr><tr><td>Average</td><td>52.6</td><td>38.3</td><td>48.1</td><td>55.3</td><td>51.0</td><td>27.7</td><td>21.1</td></tr></table>
|
| 307 |
+
|
| 308 |
+
Table 1: Normalized episode returns on D4RL benchmark. The results (except for CQL) are means and standard errors from the last step of 5 runs using different random seeds. Performances that are higher than corresponding baselines are underlined and task-wise best performances are bolded.
|
| 309 |
+
|
| 310 |
+
We first tune the $\alpha$ for TD3BC to unveil the range for safe Q estimates. Then in TD3BC-EP, we tune the $\alpha ^ { e }$ for the evaluation policy with a fixed $\tilde { \alpha } = 2 . 5$ to approximate the constraint range of better test inference performance (i.e. where the evaluation policy outperforms the target policy). The $\tilde { \alpha } = 2 . 5$ is selected to ensure a stable Q estimate (also the paper-recommended value). The $\alpha \left( \alpha ^ { e } \right)$ is tuned within $\{ 2 . 5 , 5 , 1 0 , 2 0 , 3 0 , 4 0 , 5 0 , 6 0 , 7 0 , 8 0 , 9 0 , 1 0 0 \}$ . For each $\alpha \left( \alpha ^ { e } \right)$ , we observe the training of 5 runs with different random seeds. In Figure 5, we visualize these two ranges for each task from MuJoCo locomotion set. The blue area shows $\alpha$ values where the TD3BC Q estimate is stable for all seeds. The edge shows the lowest $\alpha$ value that causes $\mathrm { Q }$ value explosion. The orange area shows the range of $\alpha ^ { e }$ where the learned evaluation policy outperforms the target policy. Its edge (the orange line) shows the lowest $\alpha ^ { e }$ values where the evaluation policy performance is worse than the target policy. For each task, the orange area has a lower bound $\alpha ^ { e } = 2 . 5$ where the evaluation policy shows a similar performance to the target policy.
|
| 311 |
+
|
| 312 |
+
Note that $\alpha$ weighs the $\mathrm { Q }$ term and thus a larger $\alpha$ indicates a less restrictive constraint. Comparing the blue area and the orange area, we observe that in 6 out of the 9 tasks, the $\alpha$ for better inference performance is higher than the $\alpha$ that enables safe Q estimates, indicating that test-time inference requires milder constraints. In the next section, we show that with an MCEP, we can achieve much better inference performance without breaking the stable Q estimates.
|
| 313 |
+
|
| 314 |
+
# 5.3 Comparison on MuJoCo locomotion and Adroit
|
| 315 |
+
|
| 316 |
+
We compare the proposed method to state-of-the-art offline RL methods CQL and IQL, together with our baselines TD3BC and AWAC. Similar hyper-parameters are used for all tasks from the same domain. For our baseline methods (TD3BC and AWAC), we use the hyper-parameter recommended by their papers. TD3BC uses $\alpha = 2 . 5$ for its $\mathrm { Q }$ value normalizer and AWAC uses 1.0 for the advantage value normalizer. In TD3BC-MCEP, the target policy uses $\tilde { \alpha } = 2 . 5$ and the MCEP uses $\alpha ^ { e } = 1 0$ . In AWAC-MCEP, the target policy has $\tilde { \lambda } = \bar { 1 . 0 }$ and the MCEP has $\lambda ^ { e } = 0 . 6$ . The full list of hyper-parameters can be found in the Appendix.
|
| 317 |
+
|
| 318 |
+
As is shown in Table 1, we observe that the evaluation policies with a mild constraint significantly outperform their corresponding target policy. TD3BC-MCEP gains progress on all medium and medium-replay datasets. Although the progress is superior, we observe a performance degradation on the medium-expert datasets which indicates an overly relaxed constraint for the evaluation policy. To overcome this imbalance problem, we designed a behavior-cloning normalizer. The results are shown in the Appendix. Nevertheless, the TD3BC-MCEP achieves much better general performance than the
|
| 319 |
+
|
| 320 |
+
264 target policy. In the AWAC-MCEP, we observe a consistent performance improvement over the target
|
| 321 |
+
265 policy on most tasks. Additionally, evaluation policies from both TD3BC-MCEP and AWAC-MCEP outperform the CQL and IQL while the target policies have relatively low performances. On Adroit tasks, the best results are obtained by behavioral cloning agent and TD3BC with a high BC weighting factor. Other agents fail to outperform the BC agent. We observe that MCEP does not benefit these tasks where behavior cloning is essential for the evaluation performance.
|
| 322 |
+
|
| 323 |
+
# 5.4 Ablation Study
|
| 324 |
+
|
| 325 |
+
In this section, we design 2 groups of ablation studies to investigate the effect of the extra evaluation policy and its constraint strengths. Reported results are averaged on 5 runs of different random seeds.
|
| 326 |
+
|
| 327 |
+
Performance of the extra evaluation policy. Now, we investigate the performance of the introduced evaluation policy $\pi ^ { e }$ . For TD3BC, we set the parameter $\alpha ~ = ~ \{ 2 . 5 , 1 0 . 0 \}$ . A large $\alpha$ indicates a milder constraint. After that, we train TD3BC-MCEP with $\tilde { \alpha } = 2 . 5$ and $\alpha ^ { e } = 1 0 . 0$ . For AWAC, we trained AWAC with the $\lambda \ = \ \{ 1 . 0 , 0 . 5 \}$ and AWAC-MCEP with $\tilde { \lambda } = 1 . 0$ and $\lambda ^ { e } = 0 . 5$ .
|
| 328 |
+
|
| 329 |
+

|
| 330 |
+
Figure 6: Left: TD3BC with $\alpha = 2 . 5$ , $\alpha = 1 0$ and TD3BCMCEP with $\tilde { \alpha } = 2 . 5$ , $\alpha ^ { e } = 1 0 $ . Right: AWAC with $\lambda = 1 . 0$ $\lambda = 0 . 5$ and AWAC-MCEP with $\tilde { \lambda } = 1 . 0$ and $\lambda ^ { e } = 0 . 5$ .
|
| 331 |
+
|
| 332 |
+
The results are shown in Figure 6. By comparing TD3BC of different $\alpha$ values, we found a milder constraint $\langle \alpha = 1 0 . 0 \rangle$ ) brought performance improvement in hopper tasks but de
|
| 333 |
+
|
| 334 |
+
grades the performance in walker2d tasks. The degradation is potentially caused by unstable value estimates (see experiment at section 5.2). Finally, the evaluation policy trained from the critic learned with a target policy with $\alpha = 2 . 5$ achieves the best performance in all three tasks. In AWAC, a lower $\lambda$ value brought policy improvement in hopper tasks but degrades performances in half-cheetah and walker2d tasks. Finally, an evaluation policy obtains the best performances in all tasks.
|
| 335 |
+
|
| 336 |
+
94 In conclusion, we observe consistent performance improvement brought by an extra MCEP that
|
| 337 |
+
95 circumvents the tradeoff brought by the constraint.
|
| 338 |
+
|
| 339 |
+
Constraint strengths of the evaluation policy. We set up two groups of ablation experiments to investigate the performance of evaluation policy under different constraint strengths. For TD3BC-MCEP, we tune the constraint strength by setting the Q normalizer hyper-parameter. The target policy hyper-parameter is fixed to $\alpha = 2 . 5$ . We pick three strengths for evaluation policy $\alpha ^ { e } = \{ 1 . 0 , \hat { 2 . 5 } , 1 0 . 0 \}$ to create more restrictive, similar, and milder constraints, respectively. For AWACMCEP, the target policy uses $\lambda = 1 . 0$ . However, it is not straightforward to create a similar constraint for the eval
|
| 340 |
+
|
| 341 |
+

|
| 342 |
+
Figure 7: Left: TD3BC-EP with $\alpha = 1 . 0$ , $\alpha = 2 . 5$ and $\alpha = 1 0 . 0$ . Right: AWAC-EP with $\lambda = 1 . 4$ , $\lambda = 1 . 0$ and $\lambda = 0 . 6$ .
|
| 343 |
+
|
| 344 |
+
uation policy as it has a different policy improvement objective. We set 312 $\lambda ^ { e } = \{ 0 . 6 , 1 . 0 , 1 . 4 \}$ to show 313 how performance changes with different constraint strengths.
|
| 345 |
+
|
| 346 |
+
The performance improvements over the target policy are shown in Fig. 7. The left column shows a significant performance drop when the evaluation policy has a more restrictive constraint $( \alpha ^ { e } = 1 . 0 $ ) than the target policy. A very close performance is shown when the target policy and the evaluation policy have similar policy constraint strengths $\alpha ^ { e } = 2 . 5$ ). Significant policy improvements are obtained with the target policy having a milder constraint $( \alpha ^ { e } = 1 0 $ ). The right column presents the results of AWAC-MCEP. Generally, the performance in hopper tasks keeps increasing with milder constraints while the half-cheetah and walker2d tasks show performances that increase from $\lambda = 1 . 4$ to $\lambda = 1$ and similar performances between $\lambda = 1$ and $\lambda = 0 . 6$ . Compared to the target policy, the evaluation policy consistently outperforms in half-cheetah and hopper tasks. On the walker2d task, a strong constraint $\lambda = 1 . 4$ ) causes a performance worse than the target policy but milder constraints $( \lambda = \{ 1 , 0 . 6 \} )$ ) obtain similar performance to the target policy.
|
| 347 |
+
|
| 348 |
+
Table 2: Proportion of $Q ( s , \pi ( s ) ) \quad { \bar { > } } \quad Q ( s , a )$ for target policies and evalution policies in different tasks.
|
| 349 |
+
|
| 350 |
+
<table><tr><td rowspan=1 colspan=1>env</td><td rowspan=1 colspan=1>(%) π(%)</td></tr><tr><td rowspan=1 colspan=1>TD</td><td rowspan=1 colspan=1>TD3BC-MCEP</td></tr><tr><td rowspan=1 colspan=1>wa-me</td><td rowspan=2 colspan=1>69.8 87.266.2 82.771.8 88.789.6 99.0</td></tr><tr><td rowspan=1 colspan=1>wa-mwa-mrwa-r</td></tr><tr><td rowspan=1 colspan=1>AI</td><td rowspan=1 colspan=1>AWAC-MCEP</td></tr><tr><td rowspan=1 colspan=1>ha-me</td><td rowspan=2 colspan=1>63.4 70.864.7 68.3</td></tr><tr><td rowspan=1 colspan=1>ha-m</td></tr><tr><td rowspan=1 colspan=1>ha-mr</td><td rowspan=1 colspan=1>68.6 73.1</td></tr><tr><td rowspan=1 colspan=1>ha-r</td><td rowspan=1 colspan=1>75.3 95.6</td></tr></table>
|
| 351 |
+
|
| 352 |
+

|
| 353 |
+
Figure 9: The distributions of $Q ( s , \tilde { \pi } ( s ) ) - Q ( s , a )$ and $Q ( s , \pi ^ { e } ( s ) ) -$ $Q \bar { ( } s , a )$ on MuJoCo locomotion tasks. First row: policies of TD3BCMCEP learned in walker2d tasks. Second row: policies of AWAC-MCEP learned in half cheetah tasks. See the Appendix for full results.
|
| 354 |
+
|
| 355 |
+
In conclusion, for both algorithms, we observe that on evaluation policy, a milder constraint obtains higher performance than the target policy while a restrictive constraint may harm the performance.
|
| 356 |
+
|
| 357 |
+
# 5.5 Estimated Q values for the learned evaluation policies
|
| 358 |
+
|
| 359 |
+
To compare the performance of the policies learned in Section 5.3 on the learning objective (maximizing the $\mathrm { \bf Q }$ values), we counted $\mathrm { Q }$ differences between the policy action and the data action $Q ( s , \pi ( s ) ) - Q ( s , a )$ in the training data (visualized in Figure 9). Proportions of data points that show positive differences are listed in Table 2, where we find that on more than half of the data, both the target policy and the MCEP have larger Q estimation than the behavior actions. Additionally, the proportions for the MCEP are higher than the proportions for the target policy in all datasets, indicating that the MCEP is able to move further toward large Q values.
|
| 360 |
+
|
| 361 |
+
# 6 Conclusion
|
| 362 |
+
|
| 363 |
+
This work focuses on the policy constraints methods where the constraint addresses the tradeoff between stable value estimate and evaluation performance. While to what extent the constraint achieves the best results for each end of this tradeoff remains unknown, we first investigate the constraint strength range for a stable value estimate and for evaluation performance. Our findings indicate that test time inference requires milder constraints that can go beyond the range of stable value estimates. We propose to use an auxiliary mildly constrained evaluation policy to circumvent the above-mentioned tradeoff and derive a performant evaluation policy. The empirical results show that MCEP obtains significant performance improvement compared to target policy and achieves competitive results to state-of-the-art offline RL methods. Our ablation studies show that an auxiliary evaluation policy and a milder policy constraint are essential for the proposed method. Additional empirical analysis demonstrates higher estimated Q values are obtained by the MCEP.
|
| 364 |
+
|
| 365 |
+
Limitations. Although the MCEP is able to obtain a better performance, it depends on stable value estimation. Unstable value learning may crash both the target policy and the evaluation policy. While the target policy may recover its performance by iterative policy improvement and policy evaluation, we observe that the evaluation policy may fail to do so. Therefore, a restrictive constrained target policy that stabilizes the value learning is essential for the proposed method.
|
| 366 |
+
|
| 367 |
+
52 References
|
| 368 |
+
353 David Brandfonbrener, Will Whitney, Rajesh Ranganath, and Joan Bruna. Offline rl without off-policy evaluation. Advances in neural information processing systems, 34:4933–4946, 2021.
|
| 369 |
+
55 Y. Cai, C. Zhang, L. Zhao, W. Shen, X. Zhang, L. Song, J. Bian, T. Qin, and T. Liu. Td3 with reverse kl regularizer for offline reinforcement learning from mixed datasets. In 2022 IEEE International Conference on Data Mining (ICDM), pages 21–30, Los Alamitos, CA, USA, dec 2022. IEEE Computer Society. doi: 10.1109/ICDM54844.2022.00012. URL https://doi. ieeecomputersociety.org/10.1109/ICDM54844.2022.00012. Wojciech M Czarnecki, Razvan Pascanu, Simon Osindero, Siddhant Jayakumar, Grzegorz Swirszcz, and Max Jaderberg. Distilling policy distillation. In The 22nd international conference on artificial intelligence and statistics, pages 1331–1340. PMLR, 2019.
|
| 370 |
+
Soysal Degirmenci and Chris Jones. Benchmarking offline reinforcement learning algorithms for e-commerce order fraud evaluation. In 3rd Offline RL Workshop: Offline RL as a”Launchpad”.
|
| 371 |
+
365 Justin Fu, Aviral Kumar, Ofir Nachum, George Tucker, and Sergey Levine. D4rl: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020.
|
| 372 |
+
367 Scott Fujimoto and Shixiang Shane Gu. A minimalist approach to offline reinforcement learning. Advances in neural information processing systems, 34:20132–20145, 2021.
|
| 373 |
+
69 Scott Fujimoto, Herke Hoof, and David Meger. Addressing function approximation error in actorcritic methods. In International conference on machine learning, pages 1587–1596. PMLR, 2018.
|
| 374 |
+
72 Scott Fujimoto, David Meger, and Doina Precup. Off-policy deep reinforcement learning without exploration. In International conference on machine learning, pages 2052–2062. PMLR, 2019.
|
| 375 |
+
74 Natasha Jaques, Asma Ghandeharioun, Judy Hanwen Shen, Craig Ferguson, Agata Lapedriza, Noah Jones, Shixiang Gu, and Rosalind Picard. Way off-policy batch deep reinforcement learning of implicit human preferences in dialog. arXiv preprint arXiv:1907.00456, 2019. Dmitry Kalashnikov, Jacob Varley, Yevgen Chebotar, Benjamin Swanson, Rico Jonschkowski, Chelsea Finn, Sergey Levine, and Karol Hausman. Mt-opt: Continuous multi-task robotic reinforcement learning at scale. arXiv preprint arXiv:2104.08212, 2021. Ilya Kostrikov, Ashvin Nair, and Sergey Levine. Offline reinforcement learning with implicit q-learning. In International Conference on Learning Representations, 2022. URL https:// openreview.net/forum?id $\equiv$ 68n2s9ZJWF8.
|
| 376 |
+
383 Aviral Kumar, Justin Fu, Matthew Soh, George Tucker, and Sergey Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. Advances in Neural Information Processing Systems, 32, 2019.
|
| 377 |
+
86 Aviral Kumar, Aurick Zhou, George Tucker, and Sergey Levine. Conservative q-learning for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:1179–1191, 2020.
|
| 378 |
+
88 Aviral Kumar, Anikait Singh, Stephen Tian, Chelsea Finn, and Sergey Levine. A workflow for offline model-free robotic reinforcement learning. In Conference on Robot Learning, pages 417–428. PMLR, 2022. Jiafei Lyu, Xiaoteng Ma, Xiu Li, and Zongqing Lu. Mildly conservative q-learning for offline reinforcement learning. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave, and Kyunghyun Cho, editors, Advances in Neural Information Processing Systems, 2022. URL https://openreview. net/forum?id $\cdot ^ { = }$ VYYf6S67pQc.
|
| 379 |
+
95 Ashvin Nair, Abhishek Gupta, Murtaza Dalal, and Sergey Levine. Awac: Accelerating online reinforcement learning with offline datasets. arXiv preprint arXiv:2006.09359, 2020.
|
| 380 |
+
97 Xue Bin Peng, Aviral Kumar, Grace Zhang, and Sergey Levine. Advantage-weighted regression: Simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177, 2019.
|
| 381 |
+
|
| 382 |
+
399 Rafael Rafailov, Tianhe Yu, Aravind Rajeswaran, and Chelsea Finn. Offline reinforcement learning
|
| 383 |
+
400 from images with latent space models. In Learning for Dynamics and Control, pages 1154–1168.
|
| 384 |
+
401 PMLR, 2021.
|
| 385 |
+
402 Dhruv Shah, Arjun Bhorkar, Hrishit Leen, Ilya Kostrikov, Nicholas Rhinehart, and Sergey Levine.
|
| 386 |
+
403 Offline reinforcement learning for visual navigation. In 6th Annual Conference on Robot Learning,
|
| 387 |
+
404 2022. URL https://openreview.net/forum?id $\cdot ^ { = }$ uhIfIEIiWm_.
|
| 388 |
+
405 Noah Siegel, Jost Tobias Springenberg, Felix Berkenkamp, Abbas Abdolmaleki, Michael Neunert,
|
| 389 |
+
406 Thomas Lampe, Roland Hafner, Nicolas Heess, and Martin Riedmiller. Keep doing what worked:
|
| 390 |
+
407 Behavior modelling priors for offline reinforcement learning. In International Conference on
|
| 391 |
+
408 Learning Representations, 2020. URL https://openreview.net/forum?id $\underset { . } { = }$ rke7geHtwH.
|
| 392 |
+
409 Anikait Singh, Aviral Kumar, Quan Vuong, Yevgen Chebotar, and Sergey Levine. Offline rl with
|
| 393 |
+
410 realistic datasets: Heteroskedasticity and support constraints. arXiv preprint arXiv:2211.01052,
|
| 394 |
+
411 2022.
|
| 395 |
+
412 Charlie Snell, Ilya Kostrikov, Yi Su, Mengjiao Yang, and Sergey Levine. Offline rl for natural
|
| 396 |
+
413 language generation with implicit language q learning. arXiv preprint arXiv:2206.11871, 2022.
|
| 397 |
+
414 Hado Van Hasselt, Yotam Doron, Florian Strub, Matteo Hessel, Nicolas Sonnerat, and Joseph
|
| 398 |
+
415 Modayil. Deep reinforcement learning and the deadly triad. arXiv preprint arXiv:1812.02648,
|
| 399 |
+
416 2018.
|
| 400 |
+
417 Qing Wang, Jiechao Xiong, Lei Han, Peng Sun, Han Liu, and Tong Zhang. Exponentially weighted
|
| 401 |
+
418 imitation learning for batched historical data. In Proceedings of the 32nd International Conference
|
| 402 |
+
419 on Neural Information Processing Systems, pages 6291–6300, 2018.
|
| 403 |
+
420 Jialong Wu, Haixu Wu, Zihan Qiu, Jianmin Wang, and Mingsheng Long. Supported policy opti
|
| 404 |
+
421 mization for offline reinforcement learning. In Alice H. Oh, Alekh Agarwal, Danielle Belgrave,
|
| 405 |
+
422 and Kyunghyun Cho, editors, Advances in Neural Information Processing Systems, 2022. URL
|
| 406 |
+
423 https://openreview.net/forum?id $\equiv$ KCXQ5HoM-fy.
|
| 407 |
+
424 Yifan Wu, George Tucker, and Ofir Nachum. Behavior regularized offline reinforcement learning.
|
| 408 |
+
425 arXiv preprint arXiv:1911.11361, 2019.
|
| 409 |
+
426 Lantao Yu, Tianhe Yu, Jiaming Song, Willie Neiswanger, and Stefano Ermon. Offline imita
|
| 410 |
+
427 tion learning with suboptimal demonstrations via relaxed distribution matching. arXiv preprint
|
| 411 |
+
428 arXiv:2303.02569, 2023.
|
| 412 |
+
429 Wenxuan Zhou, Sujay Bajracharya, and David Held. Plas: Latent action space for offline reinforce
|
| 413 |
+
430 ment learning. In Conference on Robot Learning, pages 1719–1735. PMLR, 2021.
|
md/dev/ZBESeIUB5k/ZBESeIUB5k.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/a6NvoZ5DLoe/a6NvoZ5DLoe.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DYNAMIC ENSEMBLE FOR PROBABILISTIC TIMESERIES FORECASTING VIA DEEP REINFORCEMENT LEARNING
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
It is well known that ensemble improve the accuracy of forecasting tasks. However, most of ensembling strategies designed for probabilistic time series forecasting are static methods, in the sense that they either assume the time-invariant ensemble strategies over the prediction horizon, or are non-adaptive to the forecast start point. In addition, the static methods naively rely on the predictions of the base forecasters but fail to utilize base learners themselves efficiently. In this paper, we propose a novel dynamic ensemble policy to overcome three major limitations mentioned above via deep Reinforcement Learning (RL) framework. To learn such a policy, we design a Markov Decision Process (MDP), together with our environment (TS-GYM) that supports the interaction between the agent or ensembler, offline datasets and base learners. In doing so, we effectively leverage the power of the ensemble to improve each of the base learners by reducing the error accumulation of each base learner via consecutively feeding a better ensembled sample to each base learner. The proposed ensembling method has several desirable properties such as uncertainty quantification and the ability to generate sample path, on top of significant performance gain. The effectiveness of the proposed framework is demonstrated on multiple synthetic and real-world experiments.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Time series data occur naturally in countless domains including supply chain optimization (Larson, 2001; Wen et al., 2017), medical analysis (Keogh et al., 2001; Matsubara et al., 2014b), financial analysis (Zhu & Shasha, 2002; Hallac et al., 2017), sensor network monitoring (Papadimitriou & Yu, 2006; Letchner et al., 2009), cloud computing (Park et al., 2019; 2021), optimal control of vehecle (Kim et al., 2020) and social activity mining (Mathioudakis et al., 2010; Matsubara et al., 2012; 2014a). Among the applications of ML-based time series analysis, forecasting is arguably one of the most sought-after, due to its importance in industrial, social, and scientific applications. For example, forecasting plays a key role in automating and optimizing operational processes in most businesses and enables data driven decision making. Forecasts of product supply and demand are used for optimal inventory management, staff scheduling and topology planning, and are more generally a crucial technology for most aspects of supply chain optimization. In order to make optimal decisions, predictive uncertainties need to be taken into account, making probabilistic forecast a desirable property of time series models (Benidis et al., 2022).
|
| 12 |
+
|
| 13 |
+
In practice, one often encounters complex time series, making it difficult to find a single best model that excels at short-term, mid-term, and long-term forecasting scenarios. In such cases, different forecasting models usually perform well on different data regimes at different time steps. As a motivating example, Figure 1a shows the relative ranking of the performances of 5 popular forecasting models on the dataset Solar. In this example, Transformer excels at shorter and longer-term forecasts while DeepAR and TFT shine in the mid-term scenario. It is thus desirable to have an ensembling strategy that has different weights at each time step. Therefore, the traditional ensembling strategy in time series forecast, which assumes that ensemble weights do not vary along the forecasting horizon is not sufficient to capture the non-stationary patterns of base learners’ performance profile. Furthermore, popular auto-regression based models are known to have increasing prediction errors as the prediction horizon stretches further, and the performance degrades dramatically when the prediction horizon is sufficiently large (Salinas et al., 2020). As shown in the blue curve of Figure 1b, the prediction error increases for “DeepAR-G original”(“G” means using the Gaussian distribution as the output distribution and “original” means using the original implementation of DeepAR) over the prediction horizon on exchange rate dataset. On the other hand, if we can provide base learners such as DeepAR with more accurate estimations of the future as the auto-regressive input, the prediction error can be significantly decreased for the long horizon predictions (see the orange curve in Figure 1b). The huge difference in the prediction error between these two cases show the huge potential to improve the auto-regression based models if we can provide more accurate estimations during the prediction horizon. However, none of the traditional ensemble methods utilize the ensemble predictions as the feedback to boost the performance of the auto-regression based models. Motivated by the above examples, the natural question arises whether we can develop a general dynamic ensembling approach that overcomes all the major limitations of the traditional static ensemble methods and further improve the prediction accuracy for the probabilistic time-series forecasting?
|
| 14 |
+
|
| 15 |
+

|
| 16 |
+
|
| 17 |
+
(a) The ranks of 5 base learners along the prediction horizon on Solar dataset. The ranks are based on the mean weighted quantile loss over the quantiles [0.1, 0.5, 0.9] and averaged over all items in each dataset.
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
(b) The gap between the “DeepAR original" and “DeepAR w/ target” shows the potential improvement we can gain if the accuracy of the auto-regressive input to DeepAR can be improved.
|
| 21 |
+
|
| 22 |
+
Figure 1: Two motivations on the need of dynamic ensembles, beyond static ensembles.
|
| 23 |
+
|
| 24 |
+
To address the above mentioned challenges, in this work, we develop a general dynamic ensemble framework for probabilistic multi-horizon time series forecasting. Our contributions can be summarized as follows:
|
| 25 |
+
|
| 26 |
+
• This work is the first one that proposes a dynamic ensemble policy suitable for probabilistic time series forecasting with the properties of sequential weighting, being adaptive, and quantile ensemble. • We formulate this as a Markov Decision Process (MDP) with a careful design of the rewards, transition dynamics, and ensemble action policy. In particular, the state evolution in our formulation depends on the ensemble strategy through our novel transition dynamics design. • To solve this MDP problem, we design a time series gym (TS-GYM) environment which implements the interaction between the time series off-line dataset, base learners and ensemble agent. Through this interaction, actor-critic based deep RL method with our “random extreme point” exploration strategy can learn optimal ensemble policy. • The extensive experiments show the advantages of our ensemble dynamic framework. In particular, we demonstrate that our general dynamic ensemble framework can (1) learn the optimal time-varying ensemble weights along the multi-horizon prediction, (2) be adaptive to any forecast start time, (3) boost the performance of the auto-regressive base learners, and (4) result in better performance than other potential variants on real-world datasets.
|
| 27 |
+
|
| 28 |
+
# 2 RELATED WORK
|
| 29 |
+
|
| 30 |
+
Probabilistic time series forecasting In recent years there has been an increasing interest in “probabilistic forecasting”, namely forecasting models that account for the data’s uncertainty by modeling the distribution of target values, rather than predicting a single point estimate. Probablistic forecasting is useful for business purposes such as supply and demand, inventory management, staff scheduling and topology planning (Larson, 2001). Modern open source packages such as Kats (facebookresearch, 2021), Merlion (Bhatnagar et al., 2021) and GluonTS (Alexandrov et al., 2020a) offer probabilistic forecasting, and include some popular probabilistic forecasters such as Prophet (Taylor & Letham, 2018), and deep learning probabilistic forecasters such as DeepAR (Salinas et al., 2020), MQ-CNN (Wen et al., 2017; Park et al., 2022), MQF2 (Kan et al., 2022), NBEATS (Oreshkin et al., 2019), TFT (Lim et al., 2021) and Transformer (Vaswani et al., 2017). There are several advances in improving those models in adversarial robustness (Yoon et al., 2022; Liu et al., 2022) and few-shot learning (Jin et al., 2022).
|
| 31 |
+
|
| 32 |
+
Time series ensemble The literature on ensembling methods for time series predictions have focused solely on static ensembling strategies, namely ones that have access to the predictions of the base learners but not to the base learners themselves. In that situation, a debate on the theory of ensembling for time series was sparked by an empirical observation that a simple average of the base learners is often superior to more sophisticated ensemble methods (a problem called the “forecast combination puzzle”, see Stock & Watson (2004) and Bates & Granger (1969)). See Smith & Wallis (2009), Claeskens et al. (2016), and Elliott (2011)). While theory lags, however, sophisticated static ensembling methods have often been observed to work well. (See Donaldson & Kamstra (1996), Moon et al. (2020), and Massaoudi et al. (2021). Particularly interesting is Gastinger et al. (2021), with a large empirical study.)
|
| 33 |
+
|
| 34 |
+
Contrary to the situation considered in these papers, literature on ensembling methods that have direct access to the base learners, rather than only to their predictions, is limited. Recently, RL based approaches are proposed in Saadallah & Morik (2021) and $\mathrm { F u }$ et al. (2022). Saadallah & Morik (2021) consider action dependent state (window of ensemble predictions) transition. Their work focus on online policy learning with update timing determined by a concept-drift detection algorithm. In Fu et al. (2022) the state (time series for a given context window and base learners performance at the next window) transition is action independent with action taken for $H$ steps at a time. In addition, their methods are only designed for the point based forecasting problem and do not demonstrate the capability of capturing the non-stationary ensemble weights.
|
| 35 |
+
|
| 36 |
+
# 3 PRELIMINARIES
|
| 37 |
+
|
| 38 |
+
# 3.1 PROBABILISTIC TIME-SERIES FORECASTING
|
| 39 |
+
|
| 40 |
+
Suppose we have a panel of $n$ time series, where the $i$ -th time series consists of observations $z _ { i , t } \in \mathbb { R }$ with (optional) input covariates $x _ { i , t } \in \mathbb { R } ^ { d }$ , as $t$ varies over time at fixed discrete intervals. For an $i$ -th time series (often called $i$ -th item), we wish to make predictions for the next $H$ timestamps, namely of $z _ { i , T + 1 : T + H }$ from the forecast start time $T + 1$ , given the history of that item’s observations $z _ { i , 1 : T }$ and (optional) the associated historical and future covariates $x _ { i , 1 : T + H }$ . In this paper we will focus on global forecasters, namely a single univariate model trained on all of the items together, and accepting only a single item at inference. For notational simplicity we will drop the item index $i$ and covariates $x _ { i , t }$ unless explicitly stated. We now formally define a forecasting model as a set of random variable valued functions $\{ f _ { h } \} _ { h = 1 } ^ { H }$ such that, for $h = 1 , . . . , H$
|
| 41 |
+
|
| 42 |
+
$$
|
| 43 |
+
Z _ { T + h } = f _ { h } \big ( z _ { 1 : T } , \xi _ { T + h - 1 } \big ) ,
|
| 44 |
+
$$
|
| 45 |
+
|
| 46 |
+
where $\xi _ { T + h - 1 }$ is the hidden state variable passed from the previous (or older) step. The evolution of $f _ { h }$ and $\xi _ { T + h - 1 }$ depend on the type of the base model. For the auto-regressive model which uses the recursive prediction strategy, the hidden state $\cdot$ is generated by passing a sample $\_$ from previous time step to the forecaster decoder for the next prediction in a recursive manner. Often the decoder is homogeneous, i.e., $\cdot$ for $h = 1 , \ldots , H$ . On the other hand, Seq2Seq model which uses the direct prediction strategy, directly forecast the future time series without involving the evoluation of the hidden state, i.e., $\xi _ { T + h - 1 } = \xi _ { T }$ for all $h = 1 , \ldots , H$ . Refer to Alexandrov et al. (2020b) for the detailed modeling. In Section 4, we will explore a different choice for the auto-regressive step, using the entire ensemble.
|
| 47 |
+
|
| 48 |
+
Then, the associated $\tau$ -quantile predictions can be followed as $\hat { z } _ { T + h } ^ { \tau } = q _ { \tau } \left( Z _ { T + h } \right)$ where, for a random variable $Z \in \mathbb { R }$ with its culmulative distribution $F _ { Z }$ and a quantile level $\tau \in ( 0 , 1 )$ , $q _ { \tau }$ is denoted as the quantile function, i.e., $q _ { \tau } ( Z ) : = F _ { Z } ^ { - 1 } ( \tau ) = \operatorname* { i n f } \left\{ z \in \mathbb { R } : \tau \leq F _ { Z } ( z ) \right\}$ .
|
| 49 |
+
|
| 50 |
+
# 3.2 FORECASTING ENSEMBLE
|
| 51 |
+
|
| 52 |
+
For each m-th base learner, we denote zˆτk,mT+h as the $\tau _ { k }$ -quantile prediction at time step $T + h$ on a quantile level where $\tau _ { k } \in \{ \tau _ { k } \} _ { k = 1 } ^ { K }$ . Then, $\left\{ \hat { z } _ { T + h } ^ { \tau _ { k } , m } \right\} _ { k = 1 , m = 1 } ^ { K , M }$ is denoted as a pool of quantile predictions at time step $T + h$ over $M$ base learners and $K$ quantile levels. A general ensemble predictions can be formally expressed as a (linear) weighted combination of predictions of the individual base models, at each prediction step $h = 1 , \ldots , H$ ,
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
\hat { z } _ { T + h } ^ { \tau , \mathrm { e s } } = \sum _ { m = 1 } ^ { M } w _ { h } ^ { m } \hat { z } _ { T + h } ^ { \tau , m } ,
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
$w _ { h } ^ { m } \geq 0$ with $\textstyle \sum _ { m = 1 } ^ { M } w _ { h } ^ { m } = 1$ are the ensemble weights.
|
| 59 |
+
|
| 60 |
+
# 3.3 REINFORCEMENT LEARNING
|
| 61 |
+
|
| 62 |
+
Reinforcement learning (RL) is usually formulated as a Markov Decision Process (MDP), which can be defined as a tuple $( S , { \mathcal { A } } , { \mathcal { P } } , r , \gamma , H )$ where $s$ is the state space, $\mathcal { A }$ is the action space, $\mathcal { P } : \mathcal { S } \times \mathcal { A } \mathcal { S }$ is the transition function, $r : \mathcal { S } \times \mathcal { A } \to \mathbb { R }$ is the reward function, $\gamma \in ( 0 , 1 )$ is the discount factor and $H > 0$ is the horizon length of each episode. At each state $s \in \mathcal { S }$ , the RL agent takes an action $a \in { \mathcal { A } }$ , transits to the next state $s ^ { \prime } \in { \mathcal { S } }$ under the dynamics $\mathcal { P }$ and receives a reward $r ( s , a )$ . The goal of an MDP is to learn a policy $\pi : { \mathcal { S } } A$ that maximizes the total obtained rewards $\begin{array} { r } { \operatorname* { m a x } _ { \pi } J ( \pi ) = \mathbb { E } _ { \tau } \left[ \sum _ { h = 0 } ^ { H - 1 } \gamma ^ { h } r ( s _ { h } , a _ { h } ) \bigg | \pi \right] , } \end{array}$ where the expectation is over the trajectory $\tau = \{ \big ( s _ { 0 } , a _ { 0 } , r \big ( s _ { 0 } , a _ { 0 } \big ) \big ) . . . . , \big ( s _ { H } , a _ { H } , r \big ( s _ { H } , a _ { H } \big ) \big ) \}$ where $a _ { h } = \pi ( s _ { h } )$ .
|
| 63 |
+
|
| 64 |
+
# 4 DYNAMIC ENSEMBLE FRAMEWORK
|
| 65 |
+
|
| 66 |
+
In this section, we mainly focus on how to select a sequence of ensemble weights $( w _ { 1 } , w _ { 2 } , \dots , w _ { H } )$ with $w _ { h } \in \mathbb { R } ^ { M }$ over $M$ base learners by learning a ensemble policy $\pi$ . Especially in the presence of auto-regressive base learners, ensemble weights chosen at the step $\cdot$ may affect the forecasting of auto-regressive base learners and also ensemble weights chosen at the next step $h + 1$ (see Section 4.1.1 for more details). With this intuition, we will take a reinforcement learning approach to learn an optimal policy function $\pi$ that provides the optimal ensemble weights sequentially.
|
| 67 |
+
|
| 68 |
+
In Section 4.1, we give a high-level overview of the MDP formulation for the multi-horizon probabilistic time series forecasting problems. In particular, the classes of ensembled sampling strategies and predictions which determine the state transformation and state transition are discussed in Section 4.1.1 and the careful design of reward computation is explained in Section 4.1.2. Based on the formulated MDP, we then design our simulated environment, TS-GYM (in Section 4.2) which provides the interaction among the time series datasets, base learners and the dynamic ensemble agent. Finally, we describe how to employ deep reinforcement learning with our “random extreme point” exploration strategy to learn the optimal ensemble policy in Section 4.3.
|
| 69 |
+
|
| 70 |
+
# 4.1 MDP FORMULATION
|
| 71 |
+
|
| 72 |
+
We describe the high-level formulation of the MDP for our dynamic time-series ensemble framework. Once each episode starts with $h = 1$ , the environment fixes an arbitrary forecasting start point $T$ , and then starts to provide a time series pair of both historical input $z _ { 1 : T }$ and corresponding future (backtest) output $z _ { T + 1 }$ as well as corresponding quantile predictions $\big \{ \hat { z } _ { T + 1 } ^ { \tau , m } \big \}$ from alll $M$ base models for the next step $T + 1$ . (We defer the details implementation of the environment to Section 4.2). The agent will then decide the ensemble weights to compute the ensembled predictions, and update the ensemble policy based on the accuracy of the ensembled predictions. Depending on the type of ensemble dynamics, the ensembled predictions may also affect the base learners’ future predictions. Then, in the next step $h = 2$ , the environment provides next time series output $z _ { T + 2 }$ and associated predictions $\big \{ \hat { z } _ { T + 2 } ^ { \tau , m } \big \}$ and go on. See Figure 2a for a high level schema.
|
| 73 |
+
|
| 74 |
+
More formally, for each step $h = 1 , \ldots , H$ of an episode, given the information provided by the environment (e.g., historical observation $z _ { 1 : T }$ , and future (backtest) observation $z _ { T + h }$ , a pool of all quantile predictions $\{ \hat { z } _ { T + h } ^ { \tau _ { k } , m } \} _ { k = 1 , m = 1 } ^ { K , M }$ , and step $h$ ) , we define MDP as follows:
|
| 75 |
+
|
| 76 |
+
• the fixed-size state $s _ { h } = \Big \{ z _ { 1 : T } , \big \{ \hat { z } _ { T + h } ^ { \tau _ { k } , m } \big \} _ { k = 1 , m = 1 } ^ { K , M } , h \Big \} ,$ ,
|
| 77 |
+
• the action $a _ { h } = \{ w _ { h } ^ { m } \} _ { m = 1 } ^ { M } = \pi \big ( s _ { h } \big )$ , $M$ -ensemble weights $w _ { h } ^ { m }$ from a policy function $\pi$ , • the state transition $\mathcal { P } ( s _ { h + 1 } \mid s _ { h } , a _ { h } )$ governed by ensemble dynamics in Section 4.1.1, • the reward $R \left( { { s _ { h } } , { a _ { h } } ; { z _ { T + h } } } \right)$ 1 which evaluates ensemble prediction against ground-truth $z _ { T + h }$ in Section 4.1.2 .
|
| 78 |
+
|
| 79 |
+
# 4.1.1 ENSEMBLE DYNAMICS $\mathcal { P }$ AND ENSEMBLED QUANTILES
|
| 80 |
+
|
| 81 |
+
Defining state transition $\mathcal { P }$ , which we call ensemble dynamics, narrows down how to construct quantile predictions over M base learners {zˆτk,mT +h }K,Mk=1,m =1 ∈ sh. Here, we proposed three strategies: direct dynamic, auto-regressive dynamic and their composition. The idea of direct ensemble is similar to Seq2Seq models which employs the direct prediction strategy. The idea of auto-regressive dynamic is based on auto-regressive models where you recursively feed a new ensembled sample to each base learner for the next prediction. The ensemble dynamics appear at the step represented by the red arrow line in Figure 2a.
|
| 82 |
+
|
| 83 |
+
Direct dynamic. learner itself over $H$ s a direct ensembling ovehorizon, i.e., we compute $\hat { z } _ { T + h } ^ { \tau , m } = q _ { \tau } \left( Z _ { T + h } ^ { m } \right)$ first cofor all $h = 1 , \ldots , H$ es by base, based on Equation 1. Then the final quantile ensemble becomes $\begin{array} { r } { \hat { z } _ { T + h } ^ { \tau , e s } = \sum _ { m = 1 } ^ { M } w _ { h } ^ { m } \hat { z } _ { T + h } ^ { \tau , m } } \end{array}$ in Equation 2. Note that the base learner’s predictions are not affected by the ensembling. In other words, the transition dynamic $\mathcal { P } ( s _ { h + 1 } \mid s _ { h } , a _ { h } ) = \mathcal { P } ( s _ { h + 1 } \mid s _ { h } )$ is actually irrelevant to the ensembling weights.
|
| 84 |
+
|
| 85 |
+
Auto-regressive dynamic. In this dynamic, we generate an (intermediate) ensembled sample $p _ { T + h }$ , which is fed into each autoregressive base leaner in a recursive manner. This ends up forming a sample path through which we can compute the final ensembled (empirical) quantile prediction $\hat { z } _ { T + h } ^ { \tau , \mathrm { e s } }$
|
| 86 |
+
|
| 87 |
+
To begin with, we generate a sample path $( \hat { z } _ { T + 1 } ^ { m } , \dots , \hat { z } _ { T + H } ^ { m } )$ for each base learner as follows: First, for each step , we sample $p _ { T + h }$ from mixture of base learners’ distributions $\mathbb { P } ( Z _ { T + h } ^ { m } )$ proportional to ensemble weights $w _ { h } ^ { m }$ , i.e.,
|
| 88 |
+
|
| 89 |
+
$$
|
| 90 |
+
p _ { T + h } \sim \sum _ { m = 1 } ^ { M } w _ { h } ^ { m } \mathbb { P } ( Z _ { T + h } ^ { m } ) .
|
| 91 |
+
$$
|
| 92 |
+
|
| 93 |
+
Second, we feed $p _ { T + h }$ to each autoregressive base learner, i.e.,
|
| 94 |
+
|
| 95 |
+
$$
|
| 96 |
+
\begin{array} { c } { { Z _ { T + h + 1 } ^ { m } = f ^ { m } ( z _ { 1 : T } , \xi _ { T + h } ^ { m } ) , } } \\ { { \xi _ { T + h } ^ { m } = g ^ { m } ( p _ { T + h } , \xi _ { T + h - 1 } ^ { m } ) . } } \end{array}
|
| 97 |
+
$$
|
| 98 |
+
|
| 99 |
+
where get a sgenera $g ^ { m }$ represents thple for each sample path $m$ on dynamics for the hidden state , which can be operated in a recbase learners. $\xi _ { T + h } ^ { m }$ . Lastly, wee manner to $\hat { z } _ { T + h . } ^ { m } \sim Z _ { T + h . } ^ { m }$ $\_$ for all
|
| 100 |
+
|
| 101 |
+
After collecting a set of sample paths $\{ ( \hat { z } _ { T + 1 } ^ { m } , \dots , \hat { z } _ { T + H } ^ { m } ) _ { l } \} _ { l = 1 , m = 1 } ^ { L , M }$ where $( \hat { z } _ { T + 1 } ^ { m } , \dots , \hat { z } _ { T + H } ^ { m } ) _ { l }$ is $l$ -th sample path above for the $m$ -base learner, we construct the empirical marginal distribution $\cdot$ based on the samples $\cdot$ for all $\_$ . Then, the final (ensemble-dependent) quantile prediction of each base learner is obtained as $\hat { z } _ { T + h } ^ { \tau , m } ( w ) = q _ { \tau } \left( \hat { \mathbb { P } } ( \hat { Z } _ { T + h } ^ { m } ) \right)$ for all $m = 1 , \ldots , M$ with the final ensemble $\begin{array} { r } { \hat { z } _ { T + h } ^ { \tau , e s } = \sum _ { m = 1 } ^ { M } w _ { h } ^ { m } \hat { z } _ { T + h } ^ { \tau , m } } \end{array}$ . Note that, like $p _ { T + h }$ was sampled, the final ensemble model is ultimately a (single) auto-regressive one that supports sample path and quantiles.
|
| 102 |
+
|
| 103 |
+
Under auto-regressive dynamic strategy, the ensembled sample $p _ { T + h }$ based on ensemble weight from policy affects the performance of individual base learner consecutively and thus final quantile ensemble. In other words, action in the previous step affects state in the current step, meaning, unlike the direct dynamic, the transition dynamics $\mathcal { P } ( s _ { h + 1 } \mid s _ { h } , a _ { h } ) \neq \mathcal { P } ( s _ { h + 1 } \mid s _ { h } )$ .
|
| 104 |
+
|
| 105 |
+
Hybrid dynamic. Note that the auto-regressive dynamic strategy is not applicable for Seq2seq base learners. Still, under the hybrid dynamic strategy, Seq2seq base learners can contribute to generate ensembled samples together, i.e., ensembled sample Seq2seq and autoregressive ones, which would b $\begin{array} { r } { p _ { T + H } \sim \sum _ { m = 1 } ^ { M } w _ { h } ^ { m } \mathbb { P } ( Z _ { T + h } ^ { m } ) } \end{array}$ sampled from bothssive base learners. The behaviours of Seq2seq base learner is the exactly same in sampling and constructing quantile prediction without any feedback loop like ensembled sample, which means any auto-regressive base learners does not affect Seq2seq one’s prediction.The final ensemble under hybrid dynamic is capable of auto-regressive model, supporting desirable sample path through recursive feedings.
|
| 106 |
+
|
| 107 |
+
# 4.1.2 REWARD FUNCTION
|
| 108 |
+
|
| 109 |
+
To minimize the total quantile losses and encourage the agent to learn a uniform distribution over
|
| 110 |
+
the nearly-optimal base learners, we design the reward function as $R ( s , a ; z ) ~ = ~ R _ { 1 } ( s , a ; z ) ~ +$
|
| 111 |
+
$\lambda ( s ) R _ { 2 } ( \bar { s } , a )$ for some nsemble p $\lambda ( s ) \geq 0$ e, the first term compared with t $r _ { 1 }$ measures the performance of the cur-best quantile predictions among the base $\hat { z } _ { T + h } ^ { \tau _ { k } , e s }$
|
| 112 |
+
learners. and takes the form
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
R _ { 1 } \big ( s _ { h } , a _ { h } ; z _ { T + h } \big ) = \operatorname* { m i n } _ { m } \left\{ \sum _ { k = 1 } ^ { K } \left( \mathcal { L } \big ( \hat { z } _ { T + h } ^ { \tau _ { k } , m } , z _ { T + h } ; \tau _ { k } \big ) - \mathcal { L } \big ( \hat { z } _ { T + h } ^ { \tau _ { k } , \mathrm { e s } } , z _ { T + h } ; \tau _ { k } \big ) \right) \right\}
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
where $ { \mathcal Ḋ L Ḍ } ( \cdot , \cdot ; \tau )$ can be any measurement of the forecasting accuracy at the quantile level $\tau$ . By designing the $R _ { 1 }$ term as a regret w.r.t. the best base learner, we normalize the reward around zero: if the $R _ { 1 }$ term is less than 0, then it means that the ensemble prediction is worse than the single best base learner and the corresponding should be punished, and vise versa. Furthermore, $R _ { 2 }$ takes the form
|
| 119 |
+
|
| 120 |
+
$$
|
| 121 |
+
R _ { 2 } { \big ( } s _ { h } , a _ { h } { \big ) } = D _ { \mathrm { K L } } { \big ( } a _ { h } \ { \big | } \ \mathrm { U n i f } { \big ( } M ^ { * } { \big ( } s _ { h } { \big ) } { \big ) } { \big ) }
|
| 122 |
+
$$
|
| 123 |
+
|
| 124 |
+
where $D _ { \mathrm { K L } }$ denotes the Kullback–Leibler divergence, $-$ for a threshold $\cdot$ . denotes the set of nearly-optimal base learners at the state $s$ , and $\operatorname { J n i f } ( M ^ { * } ( s ) )$ denotes a distribution with probability mass $\frac { 1 } { \vert M ^ { \ast } ( s ) \vert }$ on the indices corresponding to the base learners in $M ^ { \ast } ( s )$ and 0 otherwise. We introduce the term $R _ { 2 }$ to encourage the ensemble policy to be uniformly distributed among the nearly optimal base learners which could potentially further reduce the estimation error and the variance. Finally, $\lambda ( s )$ is a state-dependent hyper-parameter controlling the weights between $R _ { 1 }$ and $R _ { 2 }$ . When there is only a single nearly-optimal base learner, i.e., $\vert M ^ { \ast } ( s ) \vert = 1$ , we set $\lambda ( s ) = 0$ which means that we only incorporate $R _ { 2 }$ when there are at least two nearly-optimal base learners.
|
| 125 |
+
|
| 126 |
+
# 4.2 SIMULATED ENVIRONMENT: TS-GYM
|
| 127 |
+
|
| 128 |
+
Before attempting to train the policy $\pi$ , we first design a novel simulated environment for the
|
| 129 |
+
time series ensemble, namely TS-GYM, that follows state transition (in Section 4.1.1) properly, by
|
| 130 |
+
extending the OpenAI’s gym interface. As illustrated in Figure 2a, it is composed of pre-trained base
|
| 131 |
+
learners in the ensemble, time series (off-line) dataset, time series samplers, ensemble dynamics and
|
| 132 |
+
dynamic ensemble agent. During the initialization stage of the environment $h = 1$ , it first decides
|
| 133 |
+
forecast start time $T$ which is uniformly sampled among time horizon in off-line datasets, and then
|
| 134 |
+
starts to provide followthe quantile predictions ground-truth (future) ob (1) sample a time seriefor the next timestamp The first three informa historical) observatio, (3) the step number used to construct th $z _ { 1 : T }$ , (2)d (4) and $\{ \hat { z } _ { T + h } ^ { \tau _ { k } , m } \} _ { k = 1 , m = 1 } ^ { K , M }$ $T + h$ $h$ $\cdot$
|
| 135 |
+
the last information is used to construct the reward defined in Section 4.1.
|
| 136 |
+
|
| 137 |
+
Note here that generating all quantile predictions $\{ \hat { z } _ { T + h } ^ { \tau _ { k } , m } \} _ { k = 1 , m = 1 } ^ { K , M }$ at each timestamp $T + h$ is governed by the choice of ensemble dynamics in Section 4.1.1 where the ensembled quantile predictions themselves may be used for the base learners’ prediction in the next timestamp. This will affect the optimal choice of ensemble actions in the end. This process is repeated until we reach the end of the prediction horizon $T + H$ , completing one episode. In practice, this whole of procedure can be done with batch sampling in parallel.
|
| 138 |
+
|
| 139 |
+

|
| 140 |
+
Figure 2: Dynamic ensemble framework.
|
| 141 |
+
|
| 142 |
+
# 4.3 LEARNING DYNAMIC ENSEMBLE POLICY WITH EXPLORATION
|
| 143 |
+
|
| 144 |
+
To learn an optimal ensemble policy $\pi$ , we employ the deep actor-critic approach DDPG (Lillicrap et al., 2015) in a continuous action space to maximize culmulative reward. To accelerate the exploration of the base learners’ performance, we deploy the “random extreme point” exploration.
|
| 145 |
+
|
| 146 |
+
Random extreme point exploration. For the exploration of actions, for each step $h$ , we assign the action $a _ { h } = e _ { m } \mathbf { \bar { \Pi } } \in \mathbb { R } ^ { M }$ where $e _ { m }$ is an one-hot vector2 with randomly chosen $m$ from $\mathcal { M }$ base learners. This exploration policy encourages the agent to take different individual base learners, efficiently collecting the observations on not only the sampled base learner performance but also various dynamic ensemble patterns. In addition this requires no prior knowledge on the base learners.
|
| 147 |
+
|
| 148 |
+
# 5 EXPERIMENTS
|
| 149 |
+
|
| 150 |
+
The extensive experiments are conducted to demonstrate the effectiveness of the proposed dynamic ensemble approach in adapting the ensemble strategy to the time series item and prediction timestamp in Section 5.1. Then, we spend to investigate properties of our ensemble methods from dynamic weights to the phenomena of boosting the performance of the auto-regressive base learner by feeding the better ensemble sample in Section 5.2.
|
| 151 |
+
|
| 152 |
+
# 5.1 BENCHMARK EXPERIMENTS ON DYNAMIC ENSEMBLE
|
| 153 |
+
|
| 154 |
+
# 5.1.1 EXPERIMENT SETUP
|
| 155 |
+
|
| 156 |
+
Datasets and base learners. We perform experiments on four real benchmark datasets that are widely used in forecasting literature: exchange rate, elec, traf and solar from (Salinas et al., 2019). For more dataset details, see appendix A.1. We consider the global deep learning based probabilistic forecasters from GluonTS (Alexandrov et al., 2020b): DeepAR (Salinas et al., 2020), MQ-CNN (Wen et al., 2017; Park et al., 2022), NBEATS(Oreshkin et al., 2019), TFT (Lim et al., 2021) and Transformer (Vaswani et al., 2017). Since the performance of DeepAR can be heavily dependent on the distribution outputs, we trained DeepAR with three different distribution outputs: Gaussian, Student’s t and Poisson distribution referred as DeepAR-G, DeepAR-T and DeepAR-P, respectively. All base learners are trained using the default configurations in GluonTS (Alexandrov et al., 2020b) .
|
| 157 |
+
|
| 158 |
+
MDP formulation and RL training To evaluate the performance of our general dynamic ensemble framework, we take the most general ensemble dynamics, which is the hybrid quantile ensemble dynamics. In particular, we will apply the auto-regressive ensemble dynamics to the DeepAR models with different distribution outputs and apply the direct ensemble dynamics to the rest of the base learners. The samples from the DeepAR models from the previous timestamps will then recursively feed as the input to DeepAR models at the next timestamps. In defining the reward function, we adopt the mean weighted quantile loss (see Equation 7 in Appendix) as the accuracy measurement of our predictions. RL algorithm (DDPG) is implemented in PyTorch (Paszke et al., 2019) and trained on AWS Sagemaker (Liberty et al., 2020) with ml.p3.2xlarge instances. Train and test are done with TS-GYM specific to the given dataset.
|
| 159 |
+
|
| 160 |
+
Ensemble baselines We compare our RL-based dynamic ensemble approach with the following static ensemble baselines:
|
| 161 |
+
|
| 162 |
+
• Mean/Median: for each item and timestamp, take a simple mean/median of all base learners. • Global optimal ensemble: of all of the possible weights of base learners which are shared across items and timestamps, choose the weight for which the associated convex combinations of base learners lead to the best performance in the backtest validation set. • Winner-takes-all(WTA): choose the single base learner which leads to the best performance in the backtest validation set.
|
| 163 |
+
|
| 164 |
+
# 5.1.2 BENCHMARK RESULTS
|
| 165 |
+
|
| 166 |
+
Message 1: Our hybrid dynamic ensembles is the best or at least on par against other 4 baselines. We evaluate the time series forecasting results by the mean weighted quantile loss defined in Equation Equation 7 in the appendix. The results of all dynamic ensemble approaches including our hybrid quantile ensemble dynamics are summarized in Table 1. From the results in Table 1, we can further report three metrics, winning rate, average ranking, and averaged stability score (amount of $\%$ degradation compared with winining method). For winning rate, our RL-hybrid ensemble is $50 \%$ (wins in two out of four datasets) against other 4 baselines whereas Median and Winner-takes-all ensemble won $25 \%$ respectively. In the average ranking, Median and our RL-hybrid method is 1.75 and 2 respectively whereas Mean and WTA method is 3.75 and 3.5 respectively. In terms of stability score, our RL-hybrid and Median ensemble is $- 1 0 \%$ and - $- 1 5 \%$ respectively whereas Mean and WTA method is at least $- 1 0 0 \%$ and $- 7 0 \%$ . Please see more detailed analysis dataset by dataset in Appendix B.
|
| 167 |
+
|
| 168 |
+
Message 2: Overfitting and distribution shift hinders coherent ensembles over all ensemble methods. We also observe the over-fitting of some base learners from the results of Winner-takes-all. In exchange rate, elec and solar datasets, the best base learner in the backtest validation set is not the best base learner in the prediction testing window. It would be challenging to learn a good ensemble strategy in this situation. However, our approach can overcome this over-fitting issue to some extend and still be able to learn good ensemble policy for exchange rate and solar datasets. This is partially because the ensemble policy is trained using the entire time series dataset instead of just the backtest window. In addition, although Winner-takes-all gives the best forecasting accuracy for traf, the severe over-fitting of $\mathtt { M Q \mathrm { - } C N N }$ (see accuracies inside parenthesis of Table 1) slightly degrades the performance of our approach since the uniform weights are encouraged for the nearly-optimal base learners in our ensemble framework.
|
| 169 |
+
|
| 170 |
+
<table><tr><td>Base learner/ Ensemble strategy</td><td>exchange rate</td><td>elec</td><td>traf</td><td>solar</td></tr><tr><td>DeepAR-T</td><td>0.0075</td><td>0.0548</td><td>0.0879 (0.113)</td><td>0.3252</td></tr><tr><td>DeepAR-G</td><td>0.0067</td><td>0.0618</td><td>0.1140</td><td>0.3117</td></tr><tr><td>DeepAR-P</td><td>0.2261</td><td>0.0910</td><td>0.9828</td><td>0.3137</td></tr><tr><td>Transformer</td><td>0.0298</td><td>0.0266</td><td>0.0908</td><td>0.3584</td></tr><tr><td>MQ-CNN</td><td>0.0133</td><td>0.0544</td><td>1.8793 (0.166)</td><td>0.7735</td></tr><tr><td>TFT</td><td>0.0060</td><td>0.0844</td><td>0.1144</td><td>0.3253</td></tr><tr><td>NBEATS</td><td>0.0106</td><td>0.0480</td><td>0.2270</td><td>0.9983</td></tr><tr><td>Mean</td><td>0.0359</td><td>0.0490</td><td>0.2029</td><td>0.3790</td></tr><tr><td>Median</td><td>0.0090</td><td>0.0489</td><td>0.0905</td><td>0.3256</td></tr><tr><td>Global optimal</td><td>0.0124</td><td>0.0790</td><td>0.1991</td><td>0.3913</td></tr><tr><td>Winner-takes-all</td><td>0.0133</td><td>0.0548</td><td>0.0879</td><td>0.7735</td></tr><tr><td>RL-hybrid(Ours)</td><td>0.0060</td><td>0.0544</td><td>0.1141</td><td>0.3058</td></tr></table>
|
| 171 |
+
|
| 172 |
+
Table 1: Performance comparison on real-world benchmark datasets. The winning method among ensemble methods are made bold. The retangular is the one selected in Winner-takes-all ensemble method. The values in the parenthesis are the accuracy evaluated in the backtesting window.
|
| 173 |
+
|
| 174 |
+
# 5.2 INVESTIGATING PROPERTIES OF DYNAMIC ENSEMBLES
|
| 175 |
+
|
| 176 |
+
Property 1: Capturing time-varying ensemble weights. We first demonstrate the capability of our dynamic ensemble framework to learn the time-varying ensemble weights when the optimal base learners vary along the prediction horizon. We examine policy trained on the motivating example on the dataset Solar in Section 1 more closely. Our dynamic ensemble approach is able to learn ensemble weights which are consistent with the time-varying pattern of the optimal base learners. In particular, we can see from Figure 3a that (1) only Transformer, TFT and DeepAR are given positive ensemble weights during the prediction, (2) the ensemble weights of transformer remain relatively high in prediction timestamps $[ 0 , 6 ] \cup [ 1 6 , 2 9 ]$ while dropping below 0.1 during prediction timestamps [7, 15], (3) the ensemble weights of TFT remain 0 in prediction timestamps $[ 0 , 5 ] \cup [ 1 6 , 2 9 ]$ but dominate the ensemble weights of transformer in prediction timestamps [7, 15], (4) the ensemble weights of DeepAR remain high during the entire prediction horizon because its relatively good performance during the entire prediction horizon.
|
| 177 |
+
|
| 178 |
+

|
| 179 |
+
Figure 3: The learned ensemble weights are consistent with the performances of the base learners. over the prediction horizon. QL and rank are averaged over all items in the dataset.
|
| 180 |
+
|
| 181 |
+
Property 2: Boosting the performance of auto-regressive (AR) forecasters. Improving the base learners’ performance is important for the improving the accuracy of the final ensembled predictions, and for allowing a broader set of admissible ensemble polices (in the extreme case, if all base learners perform equally well, then any ensemble strategy is optimal). We demonstrate the capability of auto-regressive ensemble (as shown in Figure 3b) on boosting the performance of AR forecasters. In particular, we focus on the DeepAR models with different distribution outputs: Gaussian , Student’s t and Poisson distribution and train the ensemble policy using our dynamic ensemble approach with auto-regressive ensemble dynamics on exchange rate dataset. Figure 3b shows the mean weighted quantile losses of the DeepAR-G over the prediction horizon for 3 different strategies:
|
| 182 |
+
|
| 183 |
+
• using DeepAR with Gaussian distribution (denoted as DeepAR-G original); • using DeepAR with Gaussian distribution, but feed the true target value as the autoregressive input in Equation 4b (denoted as DeepAR-G w/ target); using the DeepAR with Gaussian distribution, but feed the samples from the mixture of distributions in Equation 3 as the auto-regressive input in Equation $^ { 4 \mathrm { b } }$ (denoted as DeepAR-G w/ ensemble);
|
| 184 |
+
|
| 185 |
+
We can observe that by feeding a more accurate input to the auto-regressive forecaster, DeepAR-G w/ ensemble improves DeepAR-G original consistently over the entire prediction horizon. The mean weighted quantile loss for DeepAR-G original and DeepAR- $- G$ w/ ensemble are 0.01466 and 0.00988, respectively, which demonstrates a $3 2 . 6 \%$ performance boost.
|
| 186 |
+
|
| 187 |
+
Property 3: Auto-regressive dynamic ensemble is more powerful than direct dynamic through ablation study. We conduct the ablation on AR dynamics that is explicitly considered in our algorithm in comparison to the methods where the AR feedback is not explicit. We term these ablations as RL-auto and RL-naive. We consider the solar dataset with base learners DeepAR-T, DeepAR-G and DeepAR-P.
|
| 188 |
+
|
| 189 |
+
Table 2: Ablation study to compare auto-regressive vs direct dynamic.
|
| 190 |
+
|
| 191 |
+
<table><tr><td>Base learner /Ensemble strategy</td><td>DeepAR-T</td><td>DeepAR-G</td><td>DeepAR-P</td><td>Mean</td><td>Global Optimal</td><td>RL-naive</td><td>RL-auto</td></tr><tr><td>solar</td><td>0.3252</td><td>0.3117</td><td>0.3137</td><td>0.3088</td><td>0.3302</td><td>0.3148</td><td>0.2840</td></tr></table>
|
| 192 |
+
|
| 193 |
+
Table 2 highlights the significance of AR dynamics that is explicit in our MDP formulation. With same set of base learners the AR dynamics is able to achieve ${ \bf 1 1 \% }$ better result than the naive dynamics. Further, the RL-auto is better $( 8 \% )$ than all models/ensemble strategy considered, thus showing the significance of base learner boosting via AR feedback.
|
| 194 |
+
|
| 195 |
+
# REFERENCES
|
| 196 |
+
|
| 197 |
+
Alexander Alexandrov, Konstantinos Benidis, Michael Bohlke-Schneider, Valentin Flunkert, Jan Gasthaus, Tim Januschowski, Danielle C. Maddix, Syama Rangapuram, David Salinas, Jasper Schulz, Lorenzo Stella, Ali Caner Türkmen, and Yuyang Wang. GluonTS: Probabilistic and Neural Time Series Modeling in Python. Journal of Machine Learning Research, 21(116):1–6, 2020a. URL http://jmlr.org/papers/v21/19-820.html.
|
| 198 |
+
|
| 199 |
+
Alexander Alexandrov, Konstantinos Benidis, Michael Bohlke-Schneider, Valentin Flunkert, Jan Gasthaus, Tim Januschowski, Danielle C Maddix, Syama Sundar Rangapuram, David Salinas, Jasper Schulz, et al. GluonTS: Probabilistic and neural time series modeling in Python. Journal of Machine Learning Research, 21(116):1–6, 2020b.
|
| 200 |
+
|
| 201 |
+
John M Bates and Clive WJ Granger. The combination of forecasts. Journal of the Operational Research Society, 20(4):451–468, 1969.
|
| 202 |
+
|
| 203 |
+
Konstantinos Benidis, Syama Sundar Rangapuram, Valentin Flunkert, Yuyang Wang, Danielle Maddix, Caner Turkmen, Jan Gasthaus, Michael Bohlke-Schneider, David Salinas, Lorenzo Stella, et al. Deep learning for time series forecasting: Tutorial and literature survey. ACM Computing Surveys (CSUR), 2022.
|
| 204 |
+
|
| 205 |
+
Aadyot Bhatnagar, Paul Kassianik, Chenghao Liu, Tian Lan, Wenzhuo Yang, Rowan Cassius, Doyen Sahoo, Devansh Arpit, Sri Subramanian, Gerald Woo, Amrita Saha, Arun Kumar Jagota, Gokulakrishnan Gopalakrishnan, Manpreet Singh, K C Krithika, Sukumar Maddineni, Daeki Cho, Bo Zong, Yingbo Zhou, Caiming Xiong, Silvio Savarese, Steven Hoi, and Huan Wang. Merlion: A machine learning library for time series. 2021.
|
| 206 |
+
|
| 207 |
+
Gerda Claeskens, Jan R Magnus, Andrey L Vasnev, and Wendun Wang. The forecast combination puzzle: A simple theoretical explanation. International Journal of Forecasting, 32(3):754–762, 2016.
|
| 208 |
+
|
| 209 |
+
R Glen Donaldson and Mark Kamstra. Forecast combining with neural networks. Journal of Forecasting, 15(1):49–61, 1996.
|
| 210 |
+
|
| 211 |
+
Graham Elliott. Averaging and the optimal combination of forecasts. University of California, San Diego, 2011.
|
| 212 |
+
|
| 213 |
+
facebookresearch. Kats. https://github.com/facebookresearch/Kats, 2021.
|
| 214 |
+
|
| 215 |
+
Yuwei Fu, Di Wu, and Benoit Boulet. Reinforcement learning based dynamic model combination for time series forecasting. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 36, pp. 6639–6647, 2022.
|
| 216 |
+
|
| 217 |
+
Julia Gastinger, Sébastien Nicolas, Dušica Stepic, Mischa Schmidt, and Anett Schülke. A study on ´ ensemble learning for time series forecasting and the need for meta-learning. In 2021 International Joint Conference on Neural Networks (IJCNN), pp. 1–8. IEEE, 2021.
|
| 218 |
+
|
| 219 |
+
David Hallac, Youngsuk Park, Stephen Boyd, and Jure Leskovec. Network inference via the timevarying graphical lasso. In Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 205–213, 2017.
|
| 220 |
+
|
| 221 |
+
Xiaoyong Jin, Youngsuk Park, Danielle C. Maddix, Hao Wang, and Yuyang Wang. Domain adaptation for time series forecasting via attention sharing, 2022.
|
| 222 |
+
|
| 223 |
+
Kelvin Kan, François-Xavier Aubet, Tim Januschowski, Youngsuk Park, Konstantinos Benidis, Lars Ruthotto, and Jan Gasthaus. Multivariate quantile function forecaster. In International Conference on Artificial Intelligence and Statistics, pp. 10603–10621. PMLR, 2022.
|
| 224 |
+
|
| 225 |
+
Eamonn Keogh, Selina Chu, David Hart, and Michael Pazzani. An online algorithm for segmenting time series. In Proceedings 2001 IEEE international conference on data mining, pp. 289–296. IEEE, 2001.
|
| 226 |
+
|
| 227 |
+
Jongho Kim, Youngsuk Park, John D Fox, Stephen P Boyd, and William Dally. Optimal operation of a plug-in hybrid vehicle with battery thermal and degradation model. In 2020 American Control Conference (ACC), pp. 3083–3090. IEEE, 2020.
|
| 228 |
+
|
| 229 |
+
Paul D Larson. Designing and managing the supply chain: concepts, strategies, and case studies. Journal of Business Logistics, 22(1):259, 2001.
|
| 230 |
+
|
| 231 |
+
Julie Letchner, Christopher Ré, Magdalena Balazinska, and Matthai Philipose. Access methods for markovian streams. In 2009 IEEE 25th International Conference on Data Engineering, pp. 246–257. IEEE, 2009.
|
| 232 |
+
|
| 233 |
+
Edo Liberty, Zohar Karnin, Bing Xiang, Laurence Rouesnel, Baris Coskun, Ramesh Nallapati, Julio Delgado, Amir Sadoughi, Yury Astashonok, Piali Das, et al. Elastic machine learning algorithms in amazon sagemaker. In Proceedings of the 2020 ACM SIGMOD International Conference on Management of Data, pp. 731–737, 2020.
|
| 234 |
+
|
| 235 |
+
Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.
|
| 236 |
+
|
| 237 |
+
Bryan Lim, Sercan Ö Arık, Nicolas Loeff, and Tomas Pfister. Temporal fusion transformers for interpretable multi-horizon time series forecasting. International Journal of Forecasting, 37(4): 1748–1764, 2021.
|
| 238 |
+
|
| 239 |
+
Linbo Liu, Youngsuk Park, Trong Nghia Hoang, Hilaf Hasson, and Jun Huan. Towards robust multivariate time-series forecasting: Adversarial attacks and defense mechanisms. arXiv preprint arXiv:2207.09572, 2022.
|
| 240 |
+
|
| 241 |
+
Mohamed Massaoudi, Shady S Refaat, Ines Chihi, Mohamed Trabelsi, Fakhreddine S Oueslati, and Haitham Abu-Rub. A novel stacked generalization ensemble-based hybrid lgbm-xgb-mlp model for short-term load forecasting. Energy, 214:118874, 2021.
|
| 242 |
+
|
| 243 |
+
Michael Mathioudakis, Nick Koudas, and Peter Marbach. Early online identification of attention gathering items in social media. In Proceedings of the third ACM international conference on Web search and data mining, pp. 301–310, 2010.
|
| 244 |
+
|
| 245 |
+
Yasuko Matsubara, Yasushi Sakurai, B Aditya Prakash, Lei Li, and Christos Faloutsos. Rise and fall patterns of information diffusion: model and implications. In Proceedings of the 18th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 6–14, 2012.
|
| 246 |
+
|
| 247 |
+
Yasuko Matsubara, Yasushi Sakurai, Naonori Ueda, and Masatoshi Yoshikawa. Fast and exact monitoring of co-evolving data streams. In 2014 IEEE International Conference on Data Mining, pp. 390–399. IEEE, 2014a.
|
| 248 |
+
|
| 249 |
+
Yasuko Matsubara, Yasushi Sakurai, Willem G van Panhuis, and Christos Faloutsos. Funnel: automatic mining of spatially coevolving epidemics. In KDD, pp. 105–114. ACM, 2014b.
|
| 250 |
+
|
| 251 |
+
Jihoon Moon, Seungwon Jung, Jehyeok Rew, Seungmin Rho, and Eenjun Hwang. Combination of short-term load forecasting models based on a stacking ensemble approach. Energy and Buildings, 216:109921, 2020.
|
| 252 |
+
|
| 253 |
+
Boris N Oreshkin, Dmitri Carpov, Nicolas Chapados, and Yoshua Bengio. N-BEATS: Neural basis expansion analysis for interpretable time series forecasting. arXiv:1905.10437, 2019.
|
| 254 |
+
|
| 255 |
+
Spiros Papadimitriou and Philip Yu. Optimal multi-scale patterns in time series streams. In Proceedings of the 2006 ACM SIGMOD international conference on Management of data, pp. 647–658, 2006.
|
| 256 |
+
|
| 257 |
+
Youngsuk Park, Kanak Mahadik, Ryan A Rossi, Gang Wu, and Handong Zhao. Linear quadratic regulator for resource-efficient cloud services. In Proceedings of the ACM Symposium on Cloud Computing, pp. 488–489, 2019.
|
| 258 |
+
|
| 259 |
+
Youngsuk Park, Danielle Maddix, François-Xavier Aubet, Kelvin Kan, Jan Gasthaus, and Yuyang Wang. Learning quantile functions without quantile crossing for distribution-free time series forecasting. arXiv:2111.06581, 2021.
|
| 260 |
+
|
| 261 |
+
Youngsuk Park, Danielle Maddix, François-Xavier Aubet, Kelvin Kan, Jan Gasthaus, and Yuyang Wang. Learning quantile functions without quantile crossing for distribution-free time series forecasting. In International Conference on Artificial Intelligence and Statistics, pp. 8127–8150. PMLR, 2022.
|
| 262 |
+
|
| 263 |
+
Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. Advances in neural information processing systems, 32, 2019.
|
| 264 |
+
|
| 265 |
+
Amal Saadallah and Katharina Morik. Online ensemble aggregation using deep reinforcement learning for time series forecasting. In 2021 IEEE 8th International Conference on Data Science and Advanced Analytics (DSAA), pp. 1–8. IEEE, 2021.
|
| 266 |
+
|
| 267 |
+
David Salinas, Michael Bohlke-Schneider, Laurent Callot, Roberto Medico, and Jan Gasthaus. Highdimensional multivariate forecasting with low-rank gaussian copula processes. Advances in Neural Information Processing Systems, 32:6827–6837, 2019.
|
| 268 |
+
|
| 269 |
+
David Salinas, Valentin Flunkert, Jan Gasthaus, and Tim Januschowski. DeepAR: Probabilistic forecasting with autoregressive recurrent networks. International Journal of Forecasting, 36(3): 1181–1191, 2020.
|
| 270 |
+
|
| 271 |
+
Jeremy Smith and Kenneth F Wallis. A simple explanation of the forecast combination puzzle. Oxford Bulletin of Economics and Statistics, 71(3):331–355, 2009.
|
| 272 |
+
|
| 273 |
+
James H Stock and Mark W Watson. Combination forecasts of output growth in a seven-country data set. Journal of forecasting, 23(6):405–430, 2004.
|
| 274 |
+
|
| 275 |
+
Sean J Taylor and Benjamin Letham. Forecasting at scale. The American Statistician, 72(1):37–45, 2018.
|
| 276 |
+
|
| 277 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
|
| 278 |
+
|
| 279 |
+
Ruofeng Wen, Kari Torkkola, Balakrishnan Narayanaswamy, and Dhruv Madeka. A multi-horizon quantile recurrent forecaster. arXiv preprint arXiv:1711.11053, 2017.
|
| 280 |
+
|
| 281 |
+
TaeHo Yoon, Youngsuk Park, Ernest K Ryu, and Yuyang Wang. Robust probabilistic time series forecasting. In International Conference on Artificial Intelligence and Statistics, pp. 1336–1358. PMLR, 2022.
|
| 282 |
+
|
| 283 |
+
Yunyue Zhu and Dennis Shasha. Statstream: Statistical monitoring of thousands of data streams in real time. In VLDB’02: Proceedings of the 28th International Conference on Very Large Databases, pp. 358–369. Elsevier, 2002.
|
| 284 |
+
|
| 285 |
+
# A EXPERIMENT SETUP
|
| 286 |
+
|
| 287 |
+
# A.1 REAL-WORLD DATASET
|
| 288 |
+
|
| 289 |
+
Table 3 summarizes the four benchmark real-world datasets that we use to evaluate our dynamic ensemble approach.
|
| 290 |
+
Table 3: Benchmark dataset descriptions
|
| 291 |
+
|
| 292 |
+
<table><tr><td rowspan=1 colspan=1>Dataset</td><td rowspan=1 colspan=1>Freq</td><td rowspan=1 colspan=1>Domain</td><td rowspan=1 colspan=1>#Time series</td><td rowspan=1 colspan=1>Prediction length</td></tr><tr><td rowspan=1 colspan=1>exchangerate</td><td rowspan=1 colspan=1>daily</td><td rowspan=1 colspan=1>R+</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>30</td></tr><tr><td rowspan=1 colspan=1>elec</td><td rowspan=1 colspan=1>hourly</td><td rowspan=1 colspan=1>R+</td><td rowspan=1 colspan=1>2950</td><td rowspan=1 colspan=1>24</td></tr><tr><td rowspan=1 colspan=1>traf</td><td rowspan=1 colspan=1>hourly</td><td rowspan=1 colspan=1>[0,1]</td><td rowspan=1 colspan=1>6741</td><td rowspan=1 colspan=1>24</td></tr><tr><td rowspan=1 colspan=1>solar</td><td rowspan=1 colspan=1>hourly</td><td rowspan=1 colspan=1>R+</td><td rowspan=1 colspan=1>959</td><td rowspan=1 colspan=1>24</td></tr></table>
|
| 293 |
+
|
| 294 |
+
# A.2 IMPLEMENTATION OF DDPG
|
| 295 |
+
|
| 296 |
+
We use the DDPG implementation from OpenAI spinning up baselines. The last layer of policy network is a softmax layer with output dimensions as the number of base learners considered. For hyper-parameter tuning we consider the hyper-parameters in Lillicrap et al. (2015) and some specific to dynamic AR ensemble. The final hyper-parameters used for different datasets for the experiment in Section 5.1 is given in Tables 4 and 5. The default weights among AR model parameter is used to set the weights among the AR model if all the AR models in the hybrid dynamics gets zero weight at certain step in the RL; $\lambda$ controls the trade-off as explained in the reward function section. The reward scale is the scaling applied to mean-wQL to be comparable with the secondary reward $r _ { 2 }$ . Round threshold is the number of decimal digits for rounding the mean-wQL to get ranking for base learners.
|
| 297 |
+
|
| 298 |
+
A.2.1 EXPERIMENTS IN TABLE 1
|
| 299 |
+
Table 4: Hyperparameters of DDPG algorithm in various real-world datasets.
|
| 300 |
+
|
| 301 |
+
<table><tr><td rowspan=1 colspan=1>Hyperparamters</td><td rowspan=1 colspan=1>exchange rate</td><td rowspan=1 colspan=1>elec</td><td rowspan=1 colspan=1>traf</td><td rowspan=1 colspan=1>solar</td></tr><tr><td rowspan=1 colspan=1>episodes per epoch</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>5</td></tr><tr><td rowspan=1 colspan=1>start episodes</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>50</td><td rowspan=1 colspan=1>50</td><td rowspan=1 colspan=1>50</td></tr><tr><td rowspan=1 colspan=1>update after episodes</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>5</td><td rowspan=1 colspan=1>5</td></tr><tr><td rowspan=1 colspan=1> update steps per prediction length</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>4</td></tr><tr><td rowspan=1 colspan=1>update every episodes</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.25</td><td rowspan=1 colspan=1>0.25</td><td rowspan=1 colspan=1>0.5</td></tr><tr><td rowspan=1 colspan=1>discount factor</td><td rowspan=1 colspan=1>0.99</td><td rowspan=1 colspan=1>0.99</td><td rowspan=1 colspan=1>0.99</td><td rowspan=1 colspan=1>0.99</td></tr><tr><td rowspan=1 colspan=1>epochs</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>60</td><td rowspan=1 colspan=1>60</td><td rowspan=1 colspan=1>70</td></tr><tr><td rowspan=1 colspan=1>polyak</td><td rowspan=1 colspan=1>0.99</td><td rowspan=1 colspan=1>0.99</td><td rowspan=1 colspan=1>0.99</td><td rowspan=1 colspan=1>0.99</td></tr><tr><td rowspan=1 colspan=1>learning rate for policy</td><td rowspan=1 colspan=1>0.0005</td><td rowspan=1 colspan=1>0.0005</td><td rowspan=1 colspan=1>0.0005</td><td rowspan=1 colspan=1>0.0005</td></tr><tr><td rowspan=1 colspan=1>learning rate for Q value</td><td rowspan=1 colspan=1>0.0005</td><td rowspan=1 colspan=1>0.0005</td><td rowspan=1 colspan=1>0.0005</td><td rowspan=1 colspan=1>0.0005</td></tr><tr><td rowspan=1 colspan=1>noise level for action</td><td rowspan=1 colspan=1>0.05</td><td rowspan=1 colspan=1>0.05</td><td rowspan=1 colspan=1>0.05</td><td rowspan=1 colspan=1>0.1</td></tr></table>
|
| 302 |
+
|
| 303 |
+
# A.3 IMPLEMENTAIONS OF TS-GYM
|
| 304 |
+
|
| 305 |
+
Error metric We evaluate the forecasting error in terms of the mean weighted quantile loss. See the precise definition in the appendix.
|
| 306 |
+
|
| 307 |
+
$$
|
| 308 |
+
\frac { 1 } { q } \frac { \sum _ { i = 1 , j = T + 1 , k = 1 } ^ { N , T + h , q } \operatorname* { m a x } \left\{ \tau _ { k } ( z _ { i , j } - \widetilde { z } _ { i , j , k } ) , ( 1 - \tau _ { k } ) ( \widetilde { z } _ { i , j , k } - z _ { i , j } ) \right\} } { \sum _ { i = 1 , j = T + 1 } ^ { N , T + h } | z _ { i , j } | }
|
| 309 |
+
$$
|
| 310 |
+
|
| 311 |
+
where {zi,j}N,T hi=1,j=T +1 are the true values of future time series and $\{ \widetilde { z } _ { i , j , k } \} _ { i = 1 , j = T + 1 , k = 1 } ^ { N , T + h , q }$ are the estimated quantile predictions.
|
| 312 |
+
|
| 313 |
+
Table 5: Hyperparameters of TS-GYM in various real-world datasets.
|
| 314 |
+
|
| 315 |
+
<table><tr><td rowspan=1 colspan=1>Hyperparameters</td><td rowspan=1 colspan=1>exchange rate</td><td rowspan=1 colspan=1>elec</td><td rowspan=1 colspan=1>traf</td><td rowspan=1 colspan=1>solar</td></tr><tr><td rowspan=1 colspan=1>train batch size</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>200</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>200</td></tr><tr><td rowspan=1 colspan=1>reward scale</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>0.0001</td><td rowspan=1 colspan=1>10</td><td rowspan=1 colspan=1>0.01</td></tr><tr><td rowspan=1 colspan=1>round threshold</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>2</td></tr><tr><td rowspan=1 colspan=1>入</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.5</td><td rowspan=1 colspan=1>0.5</td></tr><tr><td rowspan=1 colspan=1>default weights amongauto-regressive models</td><td rowspan=1 colspan=1>[1,0,0]</td><td rowspan=1 colspan=1>[1,0,0]</td><td rowspan=1 colspan=1>[1,0,0]</td><td rowspan=1 colspan=1>[1,0,0]</td></tr></table>
|
| 316 |
+
|
| 317 |
+
# B BENCHMARK RESULT DISCUSSION
|
| 318 |
+
|
| 319 |
+
For the more detailed discussion, we can observe that the proposed RL-hybrid method outperforms all base models and baselines on all exchange rate and solar datasets. For exchange rate, which is a regular dataset with clear daily patterns, a single base learner usually performs very well. Our RL-hybrid method is able to identify the single best base learner (TFT). On the other hand, exchange rate is less regular and more challenging. Our RL-hybrid method is better $( 2 \% )$ than all base models and baselines considered. This is because our dynamic ensemble method are able to capture the time-varying patterns of the base learners’ performance profile and boost the performance of the auto-regressive base learners (see Section 5.2 for more discussions).
|
md/dev/aa8KsqfTPa/aa8KsqfTPa.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MarioGPT: Open-Ended Text2Level Generation through Large Language Models
|
| 2 |
+
|
| 3 |
+
Shyam Sudhakaran1, Miguel González-Duque∗1, Matthias Freiberger∗1, Claire Glanois1, Elias Najarro1, Sebastian Risi1,2 1IT University of Copenhagen, 2modl.ai, Copenhagen shyamsnair@protonmail.com, sebr@itu.dk
|
| 4 |
+
|
| 5 |
+

|
| 6 |
+
Figure 1: MarioGPT is able to successfully generate levels that follow the text prompt (a–e). Failure cases rarely happen: for example in (f) the model manages to generate many pipes and some blocks, but it still generates enemies even though it was prompted with "no enemies".
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
Procedural Content Generation (PCG) is a technique to generate complex and diverse environments in an automated way. However, while generating content with PCG methods is often straightforward, generating meaningful content that reflects specific intentions and constraints remains challenging. Furthermore, many PCG algorithms lack the ability to generate content in an open-ended manner. Recently, Large Language Models (LLMs) have shown to be incredibly effective in many diverse domains. These trained LLMs can be fine-tuned, re-using information and accelerating training for new tasks. Here, we introduce MarioGPT, a fine-tuned GPT2 model trained to generate tile-based game levels, in our case Super Mario Bros levels. MarioGPT can not only generate diverse levels, but can be text-prompted for controllable level generation, addressing one of the key challenges of current PCG techniques. As far as we know, MarioGPT is the first text-to-level model and combined with novelty search it enables the generation of diverse levels with varying play-style dynamics (i.e. player paths) and the openended discovery of an increasingly diverse range of content. Code available at https://github.com/shyamsn97/mario-gpt.
|
| 11 |
+
|
| 12 |
+
# 1 Introduction
|
| 13 |
+
|
| 14 |
+
Procedural Content Generation (PCG) refers to techniques that can automatically create game content, such as levels, maps, or characters [36]. Some of the benefits of PCG are an increase in the replayability of a game and reduced production costs.
|
| 15 |
+
|
| 16 |
+

|
| 17 |
+
Figure 2: MarioGPT prediction pipeline. Our MarioGPT model is a finetuned version of the distilled GPT2 language model. Like GPT2, MarioGPT is trained to predict next token sequences. Levels are represented as strings, which are tokenized by a Byte-Pair Encoding, similar to the original GPT2 model. The level is split by columns and flattened into a single vector (or batch of vectors for multiple levels). To incorporate prompt information, we utilize a frozen text encoder in the form of a pretrained bidirectional LLM (BART), and output the average hidden states of the model’s forward pass. This average hidden state is then used in the cross attention layers of the GPT2 architecture in combination with the actual level sequence being passed into the model.
|
| 18 |
+
|
| 19 |
+
Recently, developments in PCG and machine learning have started to influence each other in different ways [30]. PCG researchers are now incorporating machine learning-based approaches into their systems and models such as Generative Adversarial Networks (GANs) [13] can be trained to generate levels for games as diverse as Doom [10] or Super Mario Bros, training on levels from the Video Game Level Corpus [45]. However, current approaches in this field of Procedural Content Generation via Machine Learning (PCGML) [39] often rely on costly searching inside of the latent space of the underlying neural networks. It would be more desirable to being able to directly condition a generator to create levels with certain properties, ideally in natural language.
|
| 20 |
+
|
| 21 |
+
To address these challenges, we propose MarioGPT (Figure 2), a fine-tuned GPT-2 model trained to generate Mario levels. Our model demonstrates how LLMs can be combined with PCG techniques, enabling the effective creation of new and diverse levels through natural language prompts (Figure 1). Large language models (LLMs) trained on a diverse corpus such as the GPT-n family model [29], capture the statistical correlations of the human experience in the form of language correlations. Through this process, GPT acquires knowledge of how to represent and predict intricate sequences. We utilize this knowledge to provide our model with the ability to generate levels that incorporate simple artefacts as well as more complex relational properties. Surprisingly, a high percentage $( 8 8 \% )$ of MarioGPT generated levels are in fact playable.
|
| 22 |
+
|
| 23 |
+
Furthermore, we combine MarioGPT with novelty search [22], a diversity-seeking algorithm, to continually generate diverse levels in an open-ended manner. The combination of LLMs with algorithms such as novelty search opens up many interesting new directions for future research. We hope our work opens the door to more flexible and controllable PCG methods that can generate infinite content that is complex, diverse, and functional. To facilitate this, the code to run the experiments in this paper is publicly available at: https://github.com/shyamsn97/mario-gpt.
|
| 24 |
+
|
| 25 |
+
# 2 Background and Related Work
|
| 26 |
+
|
| 27 |
+
Procedural Content Generation. Procedural Content Generation (PCG) algorithms [36] deal with the automatic creation of game content (e.g. for level design, character generation, environment modeling, etc.). As reviewed in [36, 46], earlier works often focused on evolutionary computation [4], solver-based methods [37] or constructive generation methods (such as cellular automata, grammarbased methods, etc). More recently, deep learning for PCG [27, 39] has emerged as a promising approach to learning to generate high-quality game content in a data-driven manner, which is not only aesthetically pleasing but also functional and challenging. However, the diversity, originality and playability of the generated content in addition to the controllability of its generation, remain major challenges [39]. Our work aims to show how conditioned language models, paired with novelty-driven approaches to content generation [26, 2], could help tackle these shortcomings.
|
| 28 |
+
|
| 29 |
+
Neural Network-based Level Generation. Recent works in the space of video game level generation, particularly for Super Mario [2, 8, 45, 33, 35, 34], also leveraged neural network architectures to create levels. Beukman et al. [2] evolved neural networks in order to generate levels, while others [8, 45, 12, 34] performed evolution / search in the latent space of a trained generative model. These works showed that guided sampling of the latent space of the learned generative model could result in a diverse set of levels.
|
| 30 |
+
|
| 31 |
+
Previous works that utilize a trained generative model [8, 45, 34, 12] also explored the abilities to control characteristics in generated levels. However, to do so these methods relied on searching the latent space (e.g. through quality diversity algorithms [28, 9] or evolutionary strategies [14]) for levels with specific target characteristics (e.g. a level with many pipes). This is a significant limitation because even though the generative models may represent a rich set of content, one has to search through its latent space to try to find the content that actually satisfies specific characteristics. MarioGPT is able to improve upon this limitation by incorporating text prompts into the actual generative process, allowing for easily controllable level generation. In other words, instead of searching for a level with specific characteristics, MarioGPT allows us to just ask for it. Concurrently to our work, Todd et al. [42] showed that LLMs can also be used to generate levels for other games such as Sokoban but their model did not allow for any text-prompting.
|
| 32 |
+
|
| 33 |
+
Open-Endedness and Genetic Algorithms. The open-endedness paradigm focuses on algorithms that can produce infinite innovation [24]. These open-ended algorithms are popular in the field of PCG, where designers and players both can benefit from diverse and never-ending content. However, PCG must balance the hard task of generating content with diversity as well as playability. Genetic algorithms (GA), a family of optimization algorithms that are inspired by the principles of natural selection, are commonly used as the backbone for more open-ended search methods. Because GAs allow the integration of multiple objectives, they are particularly suitable for achieving a balance between fitness and diversity.
|
| 34 |
+
|
| 35 |
+
In that regard, novelty search approaches [23] aim at finding the most novel solutions at each generation, in comparison to what has been seen (i.e. an archive of previously discovered highlynovel individuals). What makes novelty-search powerful, and motivated its use in this paper, is that it guides the generation towards increasingly diverse solutions in an open-ended fashion. Novelty search keeps track of solutions in an archive and measures diversity by the distance between their behavior characteristics (BCs) compared to that of their $k$ closest neighbors. This makes novelty search very flexible, allowing for the use of many different behavior characteristic types.
|
| 36 |
+
|
| 37 |
+
Sequence Modelling and Transformers. Classic approaches to sequence modelling using recurrent neural networks (RNNs) [31] and Long Short Term Memory (LSTM) networks [15] have traditionally been constrained by the fading memory of the network’s state vector, as well as limited scalability due to the temporal interdependency of the operations. Transformers [44] address both challenges by applying associative attention [1] to learned reprojections of the windowed input sequence, which is commonly referred to as self-attention. These architectural innovations have enabled Large Language Models (LLMs) to learn from massive datasets. Additionally, such models have also shown to be effective in accelerated learning of down-stream tasks. Fine-tuning LLMs [7] involves using pre-trained model weights as a weight initialization for new tasks.
|
| 38 |
+
|
| 39 |
+
One particularly relevant use of pretrained / fine-tuned LLMs comes from the method Evolution through Large Models (ELM), proposed in Lehman et al. [21]. ELM utilizes an LLM diff model [3], which is trained on code diffs obtained by Github data, giving the model the ability to modify a code snippet based on a particular commit message. This diff model is used as a "mutation operator", for a GA that evolves a population of programs. The wide generative capabilities of the LLM produce diverse mutations, resulting in novel individuals that vary increasingly over the course of the GA.
|
| 40 |
+
|
| 41 |
+
# 3 Open-Ended Level Generation through LLMs
|
| 42 |
+
|
| 43 |
+
Here we present our complete approach to open-ended level generation through LLMs, which is composed of two parts. First, we introduce our prompt-conditioned model MarioGPT (Figure 2) in Section 3.1, which generates levels –encoded as text– given a natural-language prompt. Second, we detail how MarioGPT can be used in a novelty-search evolutionary loop (Figure 3) in Section 3.2, allowing the approach to produce a continual stream of diverse levels.
|
| 44 |
+
|
| 45 |
+
Level Representation. Mario levels are represented similarly to previous works [45, 8, 35, 33, 34, 12], using the levels provided in the Video Game Level Corpus (VGLC) [40]. We utilize a relatively small set of path-annotated levels, taken from Super Mario Bros. and Super Mario Bros.: The Lost Levels (in total 37 levels). For more details on specific tiles present, see Section 6.1 in the Appendix. These levels are stitched together, to essentially make one giant level, allowing us to sample freely without worrying about the ends of the levels. Each tile is represented as a string. The string representation and characters are tokenized into discrete values using a Byte Pair Encoding tokenizer used in the original GPT2 model [29]. The tokenizer learns a mapping that maps each tile to its own unique token. One limitation from the dataset is the simplified representation of enemies. Even though levels contain many different enemies, each with different behaviors and features, the dataset represents them all as the same token.
|
| 46 |
+
|
| 47 |
+

|
| 48 |
+
Figure 3: Novelty search setup and MarioGPT mutation operators. A level is sampled from a set of top elites in the archive, mutated, and, if novel enough, added to the archive. The mutation process involves two main steps: (1) Pick a random slice from the level and replace it with a new MarioGPT sample, using a random prompt. (2) Inpaint the border region with MarioBert to preserve path consistency.
|
| 49 |
+
|
| 50 |
+
# 3.1 MarioGPT Model
|
| 51 |
+
|
| 52 |
+
Our model, MarioGPT, is a prompt-conditioned unidirectional language model, optimized for long sequence level prediction. More precisely, MarioGPT’s architecture relies on a distilled, lightweight version of GPT2 [29] transformer architecture called DistilGPT2 [32] \*. Encoding slices of Mario levels as strings, similar to the approach taken in Summerville and Mateas [38], we can fine-tune this distilled version of GPT2 on predicting next tokens in Mario levels. To generate levels, we concatenate a window of previous 50 columns into a single vector and feed them into MarioGPT.
|
| 53 |
+
|
| 54 |
+
Architecture: MarioGPT’s architecture is the same as the DistilGPT2 architecture, except the cross attention weights are utilized for prompting. Even though DistilGPT2 supports context lengths up to size 1024, we limit our context lengths to 700, as we found increasing it did little to increase performance. In total, MarioGPT has 96 million parameters (86 million of the original DistilGPT2 parameters and 10 million from cross attention weights). We train MarioGPT for 50,000 steps, sampling 4 random slices of levels at each iteration and optimize the model using the Adam optimizer [20]. In total, MarioGPT sees 200,000 training samples. Because the model is relatively small, it can be trained using a single Nvidia GeForce RTX 2080 Ti GPU.
|
| 55 |
+
|
| 56 |
+
Prompting details: In order to incorporate prompt information, we fine-tune the attention layers’ cross attention weights, as illustrated in Figure 2. Prompts are encoded through BART [25], a frozen pre-trained language model. Prompts are passed through the frozen language model and the hidden states from the forward pass are averaged into a single vector. This average hidden state is then used in the cross attention layers of the GPT2 architecture in combination with the actual level sequence being passed into the model. We represent our prompts as combinations of specific features along with keywords that correspond to quantiles (e.g. none, little, some, many). This allows us to easily generate level/prompt pairs by counting corresponding tile values. For more details on the prompts, see Section 6.2 in the Appendix.
|
| 57 |
+
|
| 58 |
+
In addition, it is possible to use synonyms for words. For example, changing “many” to “a lot” or “a ton”, produces similar results because the BART encoder can generalize well.
|
| 59 |
+
|
| 60 |
+
# 3.2 Open-Ended Mario Level Generation with Novelty Search
|
| 61 |
+
|
| 62 |
+
In the realm of PCG, it is important to not only generate levels with diverse physical features, but also levels that elicit a wide range of player behavior. When it comes to creating Mario levels, the focus is on the different paths a player can take to complete the level. This is often a challenge for many algorithms (such as [45, 8]) and requires the use of an external agent for evaluation. However, with MarioGPT, it is possible to generate diverse and controllable levels that approximate a realistic player path, reducing the need for an external agent and producing levels that are directly playable. To encourage diversity in generated levels, we integrate MarioGPT within a novelty search augmented genetic algorithm (NS-MarioGPT), where language-models play the role of mutation operators. As illustrated in Figure 3, NS-MarioGPT iteratively samples and mutates elite levels from an archive of generated levels.
|
| 63 |
+
|
| 64 |
+
Novelty Search: Mutated levels are only stored in the archive if they achieve a higher novelty score compared to the previous elites. The novelty score is measured as the mean distance between the behavioral characteristic vector of the levels and the behavioral characteristic vector of the $K$ closest elements from the archive $K$ -means). Our goal in level generation is to create paths that result in diverse player behavior, so we use predicted player paths as our basis for these behavior characteristics. More specifically, we are interested in the relative patterns of predicted paths. For instance, if a player character moves in a straight line on high elevated blocks, we want the path’s representation to be close in behavior space to a path that moves straight in lower elevation. To achieve this, we represent the behavior characteristic as the normalized average of the predicted path’s coordinates, allowing a smooth representation of paths (Figure 4). Thus the significance of a single block difference is reduced, making it harder for mutated levels to be added to the archive. This is desired because we don’t want the archive to fill up with levels that only vary slightly from the existing levels in the archive. For all our novelty search experiments, we use a small neighborhood of size 4, which results in a behavioral characteristic of dimension 100. We initialize our archive with a small number of levels (30), as we found mutations are significant enough to generate a diverse set of levels without a big starting population.
|
| 65 |
+
|
| 66 |
+

|
| 67 |
+
Figure 4: Novelty search behavior characteristic. Left: level, Right: smoothed moving average of generated path.
|
| 68 |
+
|
| 69 |
+
Mutations: The LLM-based mutation operation introduced in this paper (Figure 3) transforms a randomly picked slice of a level (a slice between $4 0 - 8 0$ columns) with a new MarioGPT prediction, guided by a random prompt. By itself, MarioGPT is able, through mutations, to produce a variety of levels with varying agent paths. However, because MarioGPT is a unidirectional model, we cannot guarantee that the new generated path is consistent with the rest of the level. To further improve path consistency, we incorporate a fine-tuned mask prediction model (which we call MarioBert), based on the Bert architecture. The BERT language model [7] is a bidirectional LLM that shows impressive performance in the task of mask prediction, which is analogous to image in-painting. This ability is ideal for our use case, where MarioBert is used to inpaint its border region after the newly sampled slice, smoothly joining the mutated slice and the rest of level. This can be observed in the second step of the "Mutation process" part of Figure 3.
|
| 70 |
+
|
| 71 |
+
# 4 Experiments and Results
|
| 72 |
+
|
| 73 |
+
# 4.1 Tile Prediction Accuracy
|
| 74 |
+
|
| 75 |
+
To measure how proficient MarioGPT is in generating levels and because the majority of tiles in these levels are air tiles, we focus on comparing non-air tile prediction accuracy. We compare to baselines: LSTM, as proposed in Summerville and Mateas [38] and MarioGPT that is trained from scratch (without using pretrained GPT2 weights), with results reported in Table 1. For all our baselines, we train for the same amount (200,000 samples). The results show that MarioGPT (using a pretrained GPT2 model) outperforms all other baselines with regards to tile prediction. In addition, training MarioGPT from scratch and training an adapter layer (a small multi layer network on top of the original prediction layer) results in models that performs worse than even the LSTM baseline (given the 200,000 training samples). These models were trained with minimal hyperparameter search, so their performance can likely be improved. However, as a tangential point, this shows a major benefit of fine-tuning pretrained models, which seem to require much less effort in regards to hyperparameters.
|
| 76 |
+
|
| 77 |
+
Table 1: Training Reconstruction Accuracy – Validation Set
|
| 78 |
+
|
| 79 |
+
<table><tr><td>Model</td><td>Tile Acc.</td><td>Path Acc.</td><td>Promptable?</td></tr><tr><td>LSTM</td><td>46%</td><td>39%</td><td>NO</td></tr><tr><td>from-scratch-MarioGPT</td><td>31%</td><td>23%</td><td>YES</td></tr><tr><td>adapter-MarioGPT</td><td>21%</td><td>11%</td><td>YES</td></tr><tr><td>MarioGPT</td><td>93%</td><td>91%</td><td>YES</td></tr></table>
|
| 80 |
+
|
| 81 |
+
# 4.2 Measuring Playability of Levels
|
| 82 |
+
|
| 83 |
+
To test for playability, we deploy Robin Baumgarten’s $\mathbf { A } ^ { * }$ agent [43, 19] in 250 generated levels\*. The reason for choosing Robin Baumgarten’s $\mathbf { A } ^ { * }$ agent for measuring playability comes from its performance on the 2009 Mario AI competition, where it beat handcrafted controllers and even simple evolved neural networks on getting the furthest in an infinite-level setting, as well as solving a corpus of levels [43]. We find that $8 8 . 4 \%$ of all MarioGPT-generated levels can be completed by the agent, and are therefore considered playable (compared to the best baseline, the LSTM, which achieves around $31 \%$ solvable levels). Moreover, we find that only one of the successful levels needed a retry with the $\mathbf { A } ^ { * }$ agent. We further test whether the path generated by the model matches that of the $\mathbf { A } ^ { * }$ agent to assess their feasibility. Table 2 shows the mean absolute error (MAE) between suggested and actual agent path for playable and not playable levels respectively. We see that for playable levels, the MAE between the path generated by the model and the actually taken path by the agent is 1.15 tiles, i.e. paths are on average about 1 tile apart. For the non-playable levels, this average difference of taken paths is significantly higher with 4.56 tiles. Thus, we can conclude that in playable levels, the agent mostly takes a similar path as the one generated by the model. The significantly higher MAE of 4.56 in non-playable levels on the other hand indicates that the path generated by the models in these cases may not be feasible for the agent.
|
| 84 |
+
|
| 85 |
+
Table 2: Mean average error (MAE) between paths suggested by model and Baumgarten’s $\mathbf { A } ^ { * }$ agent. Results are averaged over 5 runs per level to account for minor stochastic variation in agent simulation. MAEs are computed between $y$ coordinates of path trajectories for every point on the $x$ axis (which goes across the level) both trajectories have visited.
|
| 86 |
+
|
| 87 |
+
<table><tr><td>Playable</td><td>Not Playable</td><td>All</td></tr><tr><td>1.15</td><td>4.56</td><td>1.56</td></tr></table>
|
| 88 |
+
|
| 89 |
+
Considering the MAE of 1.56 tiles for paths in all levels, we can conclude that in the majority of the cases, the path generated by the model is similar to the path taken by an actual agent, and having the model generate a path through the level jointly with the level is an effective approach to obtain high-quality levels in terms of playability.
|
| 90 |
+
|
| 91 |
+
To investigate the quality of the generated paths further, we visualize the paths with the most, least and median overlap (i.e. the levels corresponding to the maximum, minimum and median values for the mean absolute error in height) as well as two interesting handpicked examples in Figure 5.
|
| 92 |
+
|
| 93 |
+
Figures 5d and 5e show that paths generated by MarioGPT tend to have more airtime than Baumgarten’s agent in the sense that they only weakly take into account "gravity". This result may be attributed to the nature of the path annotations in the models training set. In Summerville et al. [40], the authors use an $\mathbf { A } ^ { * }$ path solver to find a path through the level, while an actual agent, such as the one we used for comparison here, is more strongly bound by game physics (especially "gravity") and has to avoid enemies in the level. A second reason for non-playable levels can be seen in Figure 5c: Baumgarten’s agent is spawned in a tight space from which it can not escape, while the model has generated a path that traverses beyond the actual level, again a path that would likely be suggested by a solver. We argue that these issues can in part be attributed to the paths in the training data stemming from a solver rather than an actual agent, and could be alleviated in future work by annotating the training data with the trajectories of actual agents.
|
| 94 |
+
|
| 95 |
+

|
| 96 |
+
Figure 5: $\mathbf { A } ^ { * }$ vs. MarioGPT generated paths. Levels with (a) minimum (0.02), (a) median (0.89) and (a) maximum (11.0) mean absolute error (MAE) between trajectory of actual $\mathbf { A } ^ { * }$ agent (denoted as A), and model suggestion (denoted as P), as well as interesting hand-picked examples. Positions where both trajectories overlap are marked with \*. Paths suggested by the model generally tend to have more airtime than the $\mathbf { A } ^ { * }$ agent (d, e), likely due to game physics not being accounted for in the original path annotations of the training data.
|
| 97 |
+
|
| 98 |
+
# 4.3 Is MarioGPT memorizing?
|
| 99 |
+
|
| 100 |
+

|
| 101 |
+
Figure 6: Generated levels vs closest in dataset. Temperature of 1.0 ends up spitting out almost exactly what is in the dataset, while increasing temperature improves sample diversity.
|
| 102 |
+
|
| 103 |
+
Memorization dynamics in LLMs remain an open problem when training transformer architectures [41, 5, 16]. While LLMs are incredibly powerful, they can sometimes overfit extremely and end up regurgitating training data. One popular way to alleviate this issue is to add some randomness in predictions in the form a tunable "temperature" parameter [17]. To evaluate whether MarioGPT is generating levels that are identical to the training set, we sample with different temperature parameters and compare them the closest level in the training dataset. From Figure 6, we can see that increasing temperature results in samples that are more diverse, but lack quality. In our case, when generating levels we use a temperature of 2.4-2.7, as it can generate diverse samples while still retaining some quality. There are many possible improvements to explore in the future. One common way is to simply increase the richness of the dataset. The more samples the model has access to, the less likely it is to overfit. We could also improve MarioGPT’s sampling abilities by introducing different search methods other than sampling with temperature, such as constrained beam search [6] and dataset augmented search [16], to increase diversity while preserving more quality.
|
| 104 |
+
|
| 105 |
+
# 4.4 Guided Level Generation via Prompting
|
| 106 |
+
|
| 107 |
+
Through simple prompting, we are able to guide MarioGPT towards controllable and diverse level generation. We empirically evaluate the prompting ability of MarioGPT by generating 1,000 samples with various combinations of prompts, and check how accurate the generated levels are to the prompt descriptions. The results suggest that MarioGPT can generate levels that match their given prompts most of the time (Table 3). MarioGPT is the most accurate with blocks and the least accurate with enemies. This is expected because there are fewer total tiles of enemies, while there are many more block tiles observed during training.
|
| 108 |
+
|
| 109 |
+
Table 3: Prompt vs actual description accuracy
|
| 110 |
+
|
| 111 |
+
<table><tr><td>pipes</td><td>enemies</td><td>blocks</td><td>elevation</td></tr><tr><td>81%</td><td>68%</td><td>92%</td><td>76%</td></tr></table>
|
| 112 |
+
|
| 113 |
+
We visually evaluated the system, displaying selected prompt-conditioned generations in Figure 1. In addition, we evaluate the importance of the keywords in the prompt by comparing the distribution of the number of pipes between levels generated with random prompts without pipes-related commands (e.g. "some enemies, some blocks, high elevation") versus random prompts with pipes-related commands (e.g. "little pipes, some enemies, some blocks, high elevation"). The distribution without pipe prompts is scattered, while the ones with pipe prompts result in distributions with peaks, indicating that the keywords actually have an effect on the level generated (see Figure 11 in the Appendix).
|
| 114 |
+
|
| 115 |
+
MarioGPT is also able to generate levels from text descriptions that are not represented in the dataset. For instance, Figure 1e shows a successful approximation of the prompt, "many pipes, no enemies, many blocks", with a slight inaccuracy in that it has 1 less pipe (5 pipes is considered "many", while 4 are present). However, this is not always the case, as can be seen in Figure 1f, where the model, prompted by "many pipes, no enemies, some blocks", generates a level with the correct number of pipes and blocks but generates too many enemies. In future work, we hope to explore more ways to incorporate prompt importance, such as editing levels with tiles to create more samples or prompt tuning [18].
|
| 116 |
+
|
| 117 |
+
# 4.5 Generating Diverse Levels with Novelty Search
|
| 118 |
+
|
| 119 |
+
Through the combination of an LLM (Section 3.1) and novelty search (Section 3.2), we are able to continuously generate diverse levels in an open-ended fashion. Specifically, NS-MarioGPT is able to generate a collection of levels with a diverse set of predicted agent paths. We project the archive as a set of 2D embeddings in Figure 7 and darken the embedding points that are added later in the process. We can see that the levels are increasingly filling up empty spots in the embedding space. We also compare the distribution of levels generated by novelty search to levels generated by random prompts in Figure 8a. Visually, we can see that the levels generated by novelty search are more spread out in t-SNE space and the sampled ones, indicating that they are more diverse. Finally, we have also evaluated the playability of levels generated by novelty search, and find that the majority are solvable and non-playable levels are not clustered but rather scattered across t-SNE space. This indicates that there is no trade-off between path diversity and the ability to generate solvable levels. Figure 8b shows the corresponding results.
|
| 120 |
+
|
| 121 |
+
Figure 9 displays all the overlayed predicted paths (in a level grid) as more and more levels get added to the archive during novelty search. Similar as in Figure 7, we can see that over time, the space of possible predicted agent paths gets filled, as increasingly diverse levels are mutated and added to the archive. As more levels are added to the archive, more and more of the tiles / empty space in the grid are being filled up, indicating that NS-MarioGPT is discovering a variety of levels that produce diverse paths. Concretely, we found that after 300 levels are added to the archive, around $78 \%$ of the possible coordinates are filled up. However, there are still many overlapping paths in the archive, meaning that similar paths are still being added to the archive. This is an issue that could be improved by using more related time series distance metrics that account for patterns in a path [11].
|
| 122 |
+
|
| 123 |
+

|
| 124 |
+
Figure 7: t-SNE of the levels in the archive. t-SNE embeddings are computed from the behavioral characteristic. Darker points indicate more recently added elements. Although novelty search is using the behavioral characteristics of the player paths, the levels also demonstrate visual novelty.
|
| 125 |
+
|
| 126 |
+

|
| 127 |
+
Figure 8: Comparing exploration for novelty search vs. random sampling and playable vs. nonplayable levels. (a) t-SNE of both the embeddings of novelty-search levels and levels generated with random prompts. The visualization suggests that novelty search enables a much wider exploration of the space of levels. (b) Unsolvable levels are not clustered together but instead scattered across the t-SNE space. This distribution indicates that there is no correlation between the diversity of levels and their solvability.
|
| 128 |
+
|
| 129 |
+
Levels with the highest and lowest novelty score from the archive are also shown in Figure 10. The level with the lowest novelty, shown in Figure 10a, has a path that is much more common in the archive, which can be seen by its almost identical look compared to the 2nd lowest in Figure 10c. The levels with higher novelty, Figure 10b and Figure 10d, have more unique patterns, but share a similar pattern towards the end. This indicates that one was created by mutating the other. We also found that the diversity starts to plateau after around 350-400 generations. However, this is very sensitive to the behavior characteristic (the smoothed predicted path of the level), so it may be different for other behavior characteristics.
|
| 130 |
+
|
| 131 |
+

|
| 132 |
+
Figure 9: Generated path populations during novelty search. Each line is a path through a level. Over time, NS-MarioGPT fills more and more of the space of all possible paths.
|
| 133 |
+
|
| 134 |
+

|
| 135 |
+
Figure 10: Comparison of most and least novel levels in the archive. The two least novel levels are very similar to each other, while the most novel levels have more distinct path patterns.
|
| 136 |
+
|
| 137 |
+
While NS-MarioGPT is still able to discover many diverse levels through its simple mutation process, more complex functions could also be explored. For instance, crossover, a common mutation utilized in many genetic algorithms, would increase mutation diversity which can lead to more diverse levels.
|
| 138 |
+
|
| 139 |
+
# 5 Conclusion
|
| 140 |
+
|
| 141 |
+
Here we introduced MarioGPT, a fine-tuned GPT2 LLM that can not only generate diverse levels, but can guide its generation via a language prompt. This ability is useful in the field of Procedural Content Generation, where balancing controllable and diverse generation is a difficult task. We showed that MarioGPT is also able to (1) predict player interaction in generated levels, (2) generate diverse and playable environments, and (3) reduce the need for expensive external agent interactions (MarioGPT can generate playable levels approximately $8 8 \%$ of the time). Additionally, when combined with a diversity-driven algorithm like novelty search, MarioGPT can generate open-ended and functional content. While MarioGPT can generate diverse content, it is still limited. It can sometimes not follow prompt instruction and it is also subject to memorizing the dataset. We hope to improve these limitations by introducing richer data to the system.
|
| 142 |
+
|
| 143 |
+
One major benefit of re-using an existing LLM is that we can take advantage of all the research and improvements that have gone into these architectures. We plan to leverage the scalability of LLMs and train MarioGPT on bigger, more detailed annotated levels. Also, we are particularly excited about incorporating human feedback into the level generation process through reinforcement learning from human feedback (RLHF) [47]. The ability to fine-tune these models on human feedback allows users to continually tune their generated levels towards desired characteristics. Ultimately, we hope that MarioGPT opens the door to more controllable and diverse PCG systems.
|
| 144 |
+
|
| 145 |
+
# Acknowledgements
|
| 146 |
+
|
| 147 |
+
This project was supported by a DFF-Research Project1 grant (9131- 00042B) and a European Research Council (ERC) grant (GA no. 101045094, project ”GROW-AI”).
|
| 148 |
+
|
| 149 |
+
References
|
| 150 |
+
[1] Dzmitry Bahdanau, KyungHyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473, 2014.
|
| 151 |
+
[2] Michael Beukman, Christopher W Cleghorn, and Steven James. Procedural content generation using neuroevolution and novelty search for diverse video game levels. In Proceedings of the Genetic and Evolutionary Computation Conference, GECCO ’22, page 1028–1037, New York, NY, USA, 2022. Association for Computing Machinery.
|
| 152 |
+
[3] Herbie Bradley, Honglu Fan, Harry Saini, Reshinth Adithyan, Shivanshu Purohit, and Joel Lehman. Diff models - a new way to edit code. CarperAI Blog, Jan 2023.
|
| 153 |
+
[4] Cameron Browne and Frederic Maire. Evolutionary game design. IEEE Transactions on Computational Intelligence and AI in Games, 2(1):1–16, 2010.
|
| 154 |
+
[5] Nicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee, Florian Tramer, and Chiyuan Zhang. Quantifying memorization across neural language models, 2022.
|
| 155 |
+
[6] Katsuki Chousa and Makoto Morishita. Input augmentation improves constrained beam search for neural machine translation: Ntt at wat 2021, 2021.
|
| 156 |
+
[7] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding, 2018.
|
| 157 |
+
[8] Matthew C. Fontaine, Ruilin Liu, Ahmed Khalifa, Jignesh Modi, Julian Togelius, Amy K. Hoover, and Stefanos Nikolaidis. Illuminating Mario scenes in the latent space of a generative adversarial network, 2020.
|
| 158 |
+
[9] Matthew C. Fontaine, Julian Togelius, Stefanos Nikolaidis, and Amy K. Hoover. Covariance matrix adaptation for the rapid illumination of behavior space. In Proceedings of the 2020 Genetic and Evolutionary Computation Conference. ACM, jun 2020.
|
| 159 |
+
[10] Edoardo Giacomello, Pier Luca Lanzi, and Daniele Loiacono. Doom level generation using generative adversarial networks. In 2018 IEEE Games, Entertainment, Media Conference (GEM), pages 316–323. IEEE, 2018.
|
| 160 |
+
[11] Omer Gold and Micha Sharir. Dynamic time warping and geometric edit distance: Breaking the quadratic barrier, 2016.
|
| 161 |
+
[12] Miguel González-Duque, Rasmus Berg Palm, Søren Hauberg, and Sebastian Risi. Mario plays on a manifold: Generating functional content in latent space through differential geometry, 2022.
|
| 162 |
+
[13] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial networks. Communications of the ACM, 63(11):139–144, 2020.
|
| 163 |
+
[14] Nikolaus Hansen. The CMA evolution strategy: A tutorial, 2016. hal-01297037v2f.
|
| 164 |
+
[15] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation, 9(8):1735–1780, 1997.
|
| 165 |
+
[16] Daphne Ippolito, Florian Tramèr, Milad Nasr, Chiyuan Zhang, Matthew Jagielski, Katherine Lee, Christopher A. Choquette-Choo, and Nicholas Carlini. Preventing verbatim memorization in language models gives a false sense of privacy, 2022.
|
| 166 |
+
[17] Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax, 2016.
|
| 167 |
+
[18] Zhengbao Jiang, Frank F. Xu, Jun Araki, and Graham Neubig. How can we know what language models know?, 2019.
|
| 168 |
+
[19] Ahmed. Khalifa. The mario AI framework. https://github.com/amidos2006/ Mario-AI-Framework, 2009.
|
| 169 |
+
|
| 170 |
+
[20] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization, 2014.
|
| 171 |
+
|
| 172 |
+
[21] Joel Lehman, Jonathan Gordon, Shawn Jain, Kamal Ndousse, Cathy Yeh, and Kenneth O. Stanley. Evolution through large models, 2022.
|
| 173 |
+
|
| 174 |
+
[22] Joel Lehman and Kenneth O. Stanley. Abandoning Objectives: Evolution Through the Search for Novelty Alone. Evolutionary Computation, 19(2):189–223, 06 2011.
|
| 175 |
+
|
| 176 |
+
[23] Joel Lehman, Kenneth O Stanley, et al. Exploiting open-endedness to solve problems through the search for novelty. In ALIFE, pages 329–336, 2008.
|
| 177 |
+
|
| 178 |
+
[24] Joel Lehman, Kenneth O. Stanley, and Lisa Soros. Open-endedness: The last grand challenge you’ve never heard of. https://www.oreilly.com/radar/ open-endedness-the-last-grand-challenge-youve-never-heard-of/. Accessed: 2017-12-19.
|
| 179 |
+
|
| 180 |
+
[25] Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. Bart: Denoising sequence-to-sequence pre-training for natural language generation, translation, and comprehension, 2019.
|
| 181 |
+
|
| 182 |
+
[26] Antonios Liapis, Georgios N Yannakakis, and Julian Togelius. Constrained novelty search: A study on game content generation. Evolutionary computation, 23(1):101–129, 2015.
|
| 183 |
+
|
| 184 |
+
[27] Jialin Liu, Sam Snodgrass, Ahmed Khalifa, Sebastian Risi, Georgios N Yannakakis, and Julian Togelius. Deep learning for procedural content generation. Neural Computing and Applications, 33(1):19–37, 2021.
|
| 185 |
+
|
| 186 |
+
[28] Jean-Baptiste Mouret and Jeff Clune. Illuminating search spaces by mapping elites, 2015.
|
| 187 |
+
|
| 188 |
+
[29] Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. Language models are unsupervised multitask learners. OpenAI blog, 1(8):9, 2019.
|
| 189 |
+
|
| 190 |
+
[30] Sebastian Risi and Julian Togelius. Increasing generality in machine learning through procedural content generation. Nature Machine Intelligence, 2(8):428–436, 2020.
|
| 191 |
+
|
| 192 |
+
[31] David E Rumelhart, Geoffrey E Hinton, and Ronald J Williams. Learning internal representations by error propagation. Technical report, California Univ San Diego La Jolla Inst for Cognitive Science, 1985.
|
| 193 |
+
|
| 194 |
+
[32] Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. Distilbert, a distilled version of BERT: smaller, faster, cheaper and lighter, 2019.
|
| 195 |
+
|
| 196 |
+
[33] Anurag Sarkar and Seth Cooper. Dungeon and platformer level blending and generation using conditional vaes. In Proceedings of the IEEE Conference on Games (CoG), 2021.
|
| 197 |
+
|
| 198 |
+
[34] Anurag Sarkar and Seth Cooper. Generating and blending game levels via quality-diversity in the latent space of a variational autoencoder. In Proceedings of the Foundations of Digital Games, 2021.
|
| 199 |
+
|
| 200 |
+
[35] Anurag Sarkar, Zhihan Yang, and Seth Cooper. Conditional level generation and game blending. In Proceedings of the Experimental AI in Games (EXAG) Workshop at AIIDE, 2020.
|
| 201 |
+
|
| 202 |
+
[36] Noor Shaker, Julian Togelius, and Mark J Nelson. Procedural content generation in games. Springer, 2016.
|
| 203 |
+
|
| 204 |
+
[37] Adam M Smith and Michael Mateas. Answer set programming for procedural content generation: A design space approach. IEEE Transactions on Computational Intelligence and AI in Games, 3(3):187–200, 2011.
|
| 205 |
+
|
| 206 |
+
[38] Adam Summerville and Michael Mateas. Super Mario as a string: Platformer level generation via lstms, 2016.
|
| 207 |
+
|
| 208 |
+
[39] Adam Summerville, Sam Snodgrass, Matthew Guzdial, Christoffer Holmgård, Amy K Hoover, Aaron Isaksen, Andy Nealen, and Julian Togelius. Procedural content generation via machine learning (PCGML). IEEE Transactions on Games, 10(3):257–270, 2018.
|
| 209 |
+
|
| 210 |
+
[40] Adam James Summerville, Sam Snodgrass, Michael Mateas, and Santiago Ontañón. The VGLC: The video game level corpus, 2016.
|
| 211 |
+
[41] Kushal Tirumala, Aram H. Markosyan, Luke Zettlemoyer, and Armen Aghajanyan. Memorization without overfitting: Analyzing the training dynamics of large language models, 2022.
|
| 212 |
+
[42] Graham Todd, Sam Earle, Muhammad Umair Nasir, Michael Cerny Green, and Julian Togelius. Level generation through large language models. In Proceedings of the 18th International Conference on the Foundations of Digital Games, pages 1–8, 2023.
|
| 213 |
+
[43] Julian Togelius, Sergey Karakovskiy, and Robin Baumgarten. The 2009 Mario AI competition. In IEEE Congress on Evolutionary Computation, pages 1–8, 2010.
|
| 214 |
+
[44] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
|
| 215 |
+
[45] Vanessa Volz, Jacob Schrum, Jialin Liu, Simon M. Lucas, Adam Smith, and Sebastian Risi. Evolving Mario levels in the latent space of a deep convolutional generative adversarial network, 2018.
|
| 216 |
+
[46] Georgios N Yannakakis and Julian Togelius. Artificial intelligence and games, volume 2. Springer, 2018.
|
| 217 |
+
[47] Daniel M. Ziegler, Nisan Stiennon, Jeffrey Wu, Tom B. Brown, Alec Radford, Dario Amodei, Paul Christiano, and Geoffrey Irving. Fine-tuning language models from human preferences, 2019.
|
| 218 |
+
|
| 219 |
+
# 6 Appendix
|
| 220 |
+
|
| 221 |
+
# 6.1 Dataset Details
|
| 222 |
+
|
| 223 |
+
Table 4: Unique Mario tiles
|
| 224 |
+
|
| 225 |
+
<table><tr><td>Tile Type</td><td>Symbol</td><td>Visualization</td></tr><tr><td>Empty</td><td>1</td><td>?</td></tr><tr><td>Unbreakable</td><td>X</td><td>口</td></tr><tr><td>Breakable</td><td>S</td><td>喜</td></tr><tr><td>Question Block</td><td>?/Q</td><td>?</td></tr><tr><td>Coin</td><td>0</td><td>0</td></tr><tr><td>Enemy</td><td>E</td><td>□</td></tr><tr><td>Left pipe top</td><td><</td><td>T</td></tr><tr><td>Right pipe top</td><td>V</td><td>T</td></tr><tr><td>Left pipe lower</td><td>[</td><td></td></tr><tr><td>Right pipe lower</td><td>1</td><td>■</td></tr><tr><td>Cannon Top</td><td>B</td><td>同</td></tr><tr><td>Cannon Body</td><td>b</td><td>□</td></tr><tr><td>Path</td><td>X</td><td>P</td></tr></table>
|
| 226 |
+
|
| 227 |
+
# 6.2 Constructing Prompts
|
| 228 |
+
|
| 229 |
+
Prompts are represented as combinations of specific features (e.g. pipes, enemies, blocks, elevation) alongside quantitative keywords:
|
| 230 |
+
|
| 231 |
+
• { no, little, some, many, [0-1000]} pipes • { no, little, some, many, [0-1000] } enemies • { little, some, many, [0-1000]} blocks • { low, high} elevation
|
| 232 |
+
|
| 233 |
+
As an example, "no pipes, many enemies, low elevation" or "many pipes, many enemies, many blocks" are both possible prompts. The keywords "no", "little", "some", "many" are calculated from quantiles of the corresponding count within a 50 column window (Table 5). The "low" and "high" elevation are determined from the height of the highest unbreakable blocks in a segment of the level.
|
| 234 |
+
|
| 235 |
+
Table 5: Prompt Quantiles and corresponding counts within a 50 column window
|
| 236 |
+
|
| 237 |
+
<table><tr><td>tile</td><td>no</td><td>little</td><td>some</td><td>many</td></tr><tr><td>pipes</td><td>0</td><td>1</td><td>2</td><td>5</td></tr><tr><td>enemies</td><td>0</td><td>1</td><td>3</td><td>7</td></tr><tr><td>blocks</td><td>0</td><td>50</td><td>75</td><td>176</td></tr></table>
|
| 238 |
+
|
| 239 |
+

|
| 240 |
+
Figure 11: Effect of prompt conditioning. Comparison of the distribution of the number of pipes between levels generated with random prompts without pipes-related commands (e.g. "some enemies, some blocks, high elevation") versus random prompts with pipes-related commands (e.g. "little pipes, some enemies, some blocks, high elevation"). The distribution without pipe prompts is scattered, while the ones with pipe prompts result in distributions with peaks.
|
md/dev/bdHkMjBJG_w/bdHkMjBJG_w.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/c5Inzw6giM/c5Inzw6giM.md
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Privacy-Preserving CNN Training with Transfer Learning
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
Privacy-preserving nerual network inference has been well studied while homomorphic CNN training still remains an open challenging task. In this paper, we present a practical solution to implement privacy-preserving CNN training based on mere Homomorphic Encryption (HE) technique. To our best knowledge, this is the first attempt successfully to crack this nut and no work ever before has achieved this goal. Several techniques combine to accomplish the task:: (1) with transfer learning, privacy-preserving CNN training can be reduced to homomorphic neural network training, or even multiclass logistic regression (MLR) training; (2) via a faster gradient variant called Quadratic Gradient, an enhanced gradient method for MLR with a state-of-the-art performance in convergence speed is applied in this work to achieve high performance; (3) we employ the thought of transformation in mathematics to transform approximating Softmax function in the encryption domain to the approximation of the Sigmoid function. A new type of loss function termed Squared Likelihood Error has been developed alongside to align with this change.; and (4) we use a simple but flexible matrix-encoding method named Volley Revolver to manage the data flow in the ciphertexts, which is the key factor to complete the whole homomorphic CNN training. The complete, runnable $\mathrm { C } { + } { + }$ code to implement our work can be found at: https://anonymous.4open.science/r/HE-CNNtraining-B355/.
|
| 11 |
+
|
| 12 |
+
We select REGNET_X_400MF as our pre-trained model for transfer learning. We use the first 128 MNIST training images as training data and the whole MNIST testing dataset as the testing data. The client only needs to upload 6 ciphertexts to the cloud and it takes $\sim 2 1$ mins to perform 2 iterations on a cloud with 64 vCPUs, resulting in a precision of $2 1 . 4 9 \%$ .
|
| 13 |
+
|
| 14 |
+
# 25 1 Introduction
|
| 15 |
+
|
| 16 |
+
# 1.1 Background
|
| 17 |
+
|
| 18 |
+
27 Applying machine learning to problems involving sensitive data requires not only accurate predictions
|
| 19 |
+
28 but also careful attention to model training. Legal and ethical requirements might limit the use of
|
| 20 |
+
29 machine learning solutions based on a cloud service for such tasks. As a particular encryption scheme,
|
| 21 |
+
30 homomorphic encryption provides the ultimate security for these machine learning applications and
|
| 22 |
+
31 ensures that the data remains confidential since the cloud does not need private keys to decrypt it.
|
| 23 |
+
32 However, it is a big challenge to train the machine learning model, such as neural networks or even
|
| 24 |
+
33 convolution neural networks, in such encrypted domains. Nonetheless, we will demonstrate that
|
| 25 |
+
34 cloud services are capable of applying neural networks over the encrypted data to make encrypted
|
| 26 |
+
35 training, and also return them in encrypted form.
|
| 27 |
+
|
| 28 |
+
Several studies on machine learning solutions are based on homomorphic encryption in the cloud environment. Since Gilad-Bachrach et al. [1] firstly considered privacy-preserving deep learning prediction models and proposed the private evaluation protocol CryptoNets for CNN, many other approaches [2, 3, 4, 5] for privacy-preserving deep learning prediction based on HE or its combination with other techniques have been developed. Also, there are several studies [6, 7, 8, 9] working on logistic regression models based on homomorphic encryption.
|
| 29 |
+
|
| 30 |
+
However, to our best knowledge, no work ever before based on mere HE techique has presented an solution to successfully perform homomorphic CNN training.
|
| 31 |
+
|
| 32 |
+
# 1.3 Contributions
|
| 33 |
+
|
| 34 |
+
46 Our specific contributions in this paper are as follows:
|
| 35 |
+
|
| 36 |
+
1. with various techniques, we initiate to propose a practical solution for privacy-preserving CNN training, demonstrating the feasibility of homomorphic CNN training.
|
| 37 |
+
2. We suggest a new type of loss function, Squared Likelihood Error (SLE), which is friendly to pervacy-perserving manner. As a result, we can use the Sigmoid function to replace the Softmax function which is too diffuclt to calculate in the encryption domain due to its uncertainty.
|
| 38 |
+
3. We develop a new algorithm with SLE loss function for MLR using quadratic gradient. Experiments show that this HE-friendly algorithm has a state-of-the-art performance in convergence speed.
|
| 39 |
+
|
| 40 |
+
# 2 Preliminaries
|
| 41 |
+
|
| 42 |
+
We adopt “ $\otimes$ ” to denote the kronecker product and “ $\odot ^ { \bullet }$ ” to denote the component-wise multiplication between matrices.
|
| 43 |
+
|
| 44 |
+
# 2.1 Fully Homomorphic Encryption
|
| 45 |
+
|
| 46 |
+
60 Homomorphic Encryption (HE) is one type of encryption scheme with a special characteristic called
|
| 47 |
+
61 Homomorphic, which allows to compute on encrypted data without having access to the secret key.
|
| 48 |
+
62 Fully HE means that the scheme is fully homomorphic, namely, homomorphic with regards to both
|
| 49 |
+
63 addition and multiplication, and that it allows arbitrary computation on encrypted data. Since Gentry
|
| 50 |
+
64 proposed the first fully HE scheme [10] in 2009, some technological progress on HE has been made.
|
| 51 |
+
65 For example, Brakerski, Gentry and Vaikuntanathan [11] present a novel way of constructing leveled
|
| 52 |
+
66 fully homomorphic encryption schemes (BGV) and Smart and Vercauteren [12] introduced one of the
|
| 53 |
+
67 most important features of HE systems, a packing technique based on polynomial-CRT called Single
|
| 54 |
+
68 Instruction Multiple Data (aka SIMD) to encrypt multiple values into a single ciphertext. Another
|
| 55 |
+
69 great progress in terms of machine learning applications is the rescaling procedure [13], which can
|
| 56 |
+
70 manage the magnitude of plaintext effectively.
|
| 57 |
+
71 Modern fully HE schemes, such as HEAAN, usually support seveal common homomorphic opera
|
| 58 |
+
72 tions: the encryption algorithm Enc encrypting a vector, the decryption algorithm Dec decrypting
|
| 59 |
+
73 a ciphertext, the homomorphic addition Add and multiplication Mult between two ciphertexts, the
|
| 60 |
+
74 multiplication cMult of a contant vector with a ciphertext, the rescaling operation ReScale to reduce
|
| 61 |
+
75 the magnitude of a plaintext to an appropriate level, the rotation operation Rot generating a new
|
| 62 |
+
76 ciphertext encrypting the shifted plaintext vector, and the bootstrapping operation bootstrap to
|
| 63 |
+
77 refresh a ciphertext usually with a small ciphertext modulus.
|
| 64 |
+
|
| 65 |
+
# 8 2.2 Database Encoding Method
|
| 66 |
+
|
| 67 |
+
79 For a given database $Z$ , Kim et al. [6] first developed an efficient database encoding method, in order
|
| 68 |
+
80 to make full use of the HE computation and storage resources. They first expand the matrix database
|
| 69 |
+
81 to a vector form $V$ in a row-by-row manner and then encrypt this vector $V$ to obtain a ciphertext
|
| 70 |
+
82 $Z = E n c ( V )$ . Also, based on this database encoding, they mentioned two simple operations via
|
| 71 |
+
|
| 72 |
+
83 shifting the encrypted vector by two different positions, respectively: the complete row shifting 84 and the incomplete column shifting. These two operations performing on the matrix $Z$ output the matrices 85 $Z ^ { ' }$ and $Z ^ { ' \prime }$ , as follows:
|
| 73 |
+
|
| 74 |
+
$$
|
| 75 |
+
\begin{array} { c c } { { Z = \left[ \begin{array} { c c c c } { { x _ { 1 0 } } } & { { x _ { 1 1 } } } & { { \ldots } } & { { x _ { 1 d } } } \\ { { x _ { 2 0 } } } & { { x _ { 2 1 } } } & { { \ldots } } & { { x _ { 2 d } } } \\ { { \vdots } } & { { \vdots } } & { { \ddots } } & { { \vdots } } \\ { { x _ { n 0 } } } & { { x _ { n 1 } } } & { { \ldots } } & { { x _ { n d } } } \end{array} \right] , } } & { { Z ^ { ' } = E n c \left[ \begin{array} { c c c c } { { x _ { 2 0 } } } & { { x _ { 2 1 } } } & { { \ldots } } & { { x _ { 2 d } } } \\ { { \vdots } } & { { \vdots } } & { { \ddots } } & { { \vdots } } \\ { { x _ { n 0 } } } & { { x _ { n 1 } } } & { { \ldots } } & { { x _ { n d } } } \\ { { x _ { 1 0 } } } & { { x _ { 1 1 } } } & { { \ldots } } & { { x _ { 1 d } } } \end{array} \right] , } } \\ { { Z ^ { ' } = E n c \left[ \begin{array} { c c c c } { { x _ { 1 1 } } } & { { \ldots } } & { { x _ { 1 d } } } & { { x _ { 2 0 } } } \\ { { x _ { 2 1 } } } & { { \ldots } } & { { x _ { 2 d } } } & { { x _ { 3 0 } } } \\ { { \vdots } } & { { \vdots } } & { { \ddots } } & { { \vdots } } \\ { { x _ { n 1 } } } & { { \ldots } } & { { x _ { n d } } } & { { x _ { 1 0 } } } \end{array} \right] , } } & { { Z ^ { ' \prime \prime } = E n c \left[ \begin{array} { c c c c } { { x _ { 1 1 } } } & { { \ldots } } & { { x _ { 1 d } } } & { { x _ { 1 0 } } } \\ { { x _ { 2 1 } } } & { { \ldots } } & { { x _ { 2 d } } } & { { x _ { 2 0 } } } \\ { { \vdots } } & { { \vdots } } & { { \ddots } } & { { \vdots } } \\ { { x _ { n 1 } } } & { { x _ { n 1 } } } & { { x _ { n 0 } } } \end{array} \right] . } } \end{array}
|
| 76 |
+
$$
|
| 77 |
+
|
| 78 |
+
The complete column shifting to obtain the matrix 86 $Z ^ { ^ { \prime \prime \prime } }$ can also be achieved by two Rot, two cMult, 87 and an Add.
|
| 79 |
+
|
| 80 |
+
88 Other works [14, 4] using the same encoding method also developed some other procedures, such
|
| 81 |
+
89 as SumRowVec and SumColVec to calculate the summation of each row and column, respectively.
|
| 82 |
+
90 Such basic common and simple operations consisting of a series of HE operations are significantly
|
| 83 |
+
91 important for more complex calculations such as the homomorphic evaluation of gradient.
|
| 84 |
+
|
| 85 |
+
# 2.3 Convolutional Neural Network
|
| 86 |
+
|
| 87 |
+
Inspired by biological processes, Convolutional Neural Networks (CNN) are a type of artificial neural network most commonly used to analyze visual images. CNNs play a significant role in image recognition due to their powerful performance. It is also worth mentioning that the CNN model is one of a few deep learning models built with reference to the visual organization of the human brain.
|
| 88 |
+
|
| 89 |
+
# 2.3.1 Transfer Learning
|
| 90 |
+
|
| 91 |
+
98 Transfer learning in machine learning is a class of methods in which a pretrained model can be used
|
| 92 |
+
99 as an optimization for a new model on a related task, allowing rapid progress in modeling the new
|
| 93 |
+
00 task. In real-world applications, very few researchers train entire convolutional neural networks
|
| 94 |
+
01 from scratch for image processing-related tasks. Instead, it is common to use a well-trained CNN
|
| 95 |
+
02 as a fixed feature extractor for the task of interest. In our case, we freeze all the weights of the
|
| 96 |
+
03 selected pre-trained CNN except that of the final fully-connected layer. We then replace the last
|
| 97 |
+
04 fully-connected layer with a new layer with random weights (such as zeros) and only train this layer.
|
| 98 |
+
105 REGNET_X_400MF To use transfer learning in our privacy-preserving CNN training, we adopt
|
| 99 |
+
106 a new network design paradigm called RegNet, recently introduced by Facebook AI researchers,
|
| 100 |
+
107 as our pre-trained model. RegNet is a low-dimensional design space consisting of simple, regular
|
| 101 |
+
108 networks. In particular, we apply REGNET_X_400MF as a fixed feature extractor and replaced the final
|
| 102 |
+
109 fully connected layer with a new one of zero weights. CNN training in this case can be simplified
|
| 103 |
+
110 to multiclass logistic regression training. Since REGNET_X_400MF only receive color images of size
|
| 104 |
+
111 $2 2 4 \times 2 2 4$ , the grayscale images will be stacked threefold and images of different sizes will be resized
|
| 105 |
+
112 to the same size in advance. These two transformations can be done by using PyTorch.
|
| 106 |
+
|
| 107 |
+
# 2.3.2 Datasets
|
| 108 |
+
|
| 109 |
+
We adopt three common datasets in our experiments: MNIST, USPS, and CIFAR10. Table 1 describes the three datasets.
|
| 110 |
+
|
| 111 |
+
# 3 Technical details
|
| 112 |
+
|
| 113 |
+
# 3.1 Multiclass Logistic Regression
|
| 114 |
+
|
| 115 |
+
118 Multiclass Logistic Regression, or Multinomial Logistic Regression, can be seen as an extension of logistic regression for multi-class classification problems. Supposing that the matrix 119 $X \in \mathbb { R } ^ { n \times ( 1 + d ) }$ ,
|
| 116 |
+
|
| 117 |
+
Table 1: Characteristics of the several datasets used in our experiments
|
| 118 |
+
|
| 119 |
+
<table><tr><td rowspan=1 colspan=1>Dataset</td><td rowspan=1 colspan=1>No. Samples(training)</td><td rowspan=1 colspan=1>No. Samples(testing)</td><td rowspan=1 colspan=1>No. Features</td><td rowspan=1 colspan=1>No. Classes</td></tr><tr><td rowspan=1 colspan=1>USPS</td><td rowspan=1 colspan=1>7,291</td><td rowspan=1 colspan=1>2,007</td><td rowspan=1 colspan=1>16×16</td><td rowspan=1 colspan=1>10</td></tr><tr><td rowspan=1 colspan=1>MNIST</td><td rowspan=1 colspan=1>60,000</td><td rowspan=1 colspan=1>10,000</td><td rowspan=1 colspan=1>28×28</td><td rowspan=1 colspan=1>10</td></tr><tr><td rowspan=1 colspan=1>CIFAR-10</td><td rowspan=1 colspan=1>50,000</td><td rowspan=1 colspan=1>10,000</td><td rowspan=1 colspan=1>3×32×32</td><td rowspan=1 colspan=1>10</td></tr></table>
|
| 120 |
+
|
| 121 |
+
the column vector 120 $Y \in \mathbb { N } ^ { n \times 1 }$ , the matrix $\bar { Y } \in \mathbb { R } ^ { n \times c }$ , and the matrix $W \in \mathbb { R } ^ { c \times ( 1 + d ) }$ represent 121 the dataset, class labels, the one-hot encoding of the class labels, and the MLR model parameter, 122 respectively:
|
| 122 |
+
|
| 123 |
+
$$
|
| 124 |
+
\begin{array} { c } { { X = \left[ \begin{array} { c } { { \alpha ^ { 2 } } } \\ { { \vdots } } \\ { { \vdots } } \\ { { \vdots } } \\ { { \vdots } } \\ { { \zeta _ { n } } } \end{array} \right] = \left[ \begin{array} { c c c c c } { { \boxed { { 2 1 } [ 0 ] } } } & { { \alpha ^ { [ 2 } [ 1 ] } } & { { \cdots } } & { { \cdots } } & { { \boxed { { 2 1 } [ 2 ] } } } \\ { { \vdots } } & { { \vdots } } & { { \ddots } } & { { \vdots } } \\ { { \vdots } } & { { \vdots } } & { { \ddots } } & { { \vdots } } \\ { { \alpha ^ { [ } n ] ( 0 ] } } & { { \alpha ^ { [ } n ] [ 1 ] } } & { { \cdots } } & { { \cdots } } & { { \alpha [ n ] [ d ] } } \end{array} \right] , } } \\ { { Y = \left[ \begin{array} { c } { { \beta _ { 1 } } } \\ { { y _ { 2 } } } \\ { { \vdots } } \\ { { \vdots } } \\ { { \xi _ { n } } } \end{array} \right] , \overset { \mathrm { o u c h o t s o d i n g ~ } } { \longrightarrow } \bar { Y } = \left[ \begin{array} { c } { { \boxed { { \bar { Y } } _ { 1 } } } } \\ { { \bar { Y } _ { 2 } } } \\ { { \bar { Y } _ { n } } } \\ { { \bar { Y } _ { n } } } \end{array} \right] = \left[ \begin{array} { c c c c c } { { \beta _ { 1 } [ 1 ] } } & { { \beta _ { 1 } [ 1 ] } } & { { \cdots } } & { { \beta _ { 1 } [ 1 ] [ c - 1 ] } } \\ { { \beta _ { 2 } [ 2 ] } } & { { \beta _ { 2 } [ 1 ] } } & { { \cdots } } & { { \beta _ { 2 } [ 2 ] [ c - 1 ] } } \\ { { \vdots } } & { { \vdots } } & { { \ddots } } & { { \vdots } } \\ { { \beta _ { [ n ] } ( 1 ) } } & { { \beta _ { [ n ] [ 2 ] } } } & { { \cdots } } & { { \beta _ { [ n ] [ - 1 ] } } } \end{array} \right] , } } \\ W = \left[ \begin{array} { c } { { w _ { [ 0 ] } } } \\ { { w _ { [ 1 ] } } } \\ { { \vdots } } \\ { { w _ { [ - 1 ] } } } \\ { { w _ { [ - 1 ] } } } \end{array} \right] = \end{array}
|
| 125 |
+
$$
|
| 126 |
+
|
| 127 |
+
MLR aims to maxsize $L$ or $\ln { \cal L }$ :
|
| 128 |
+
|
| 129 |
+
$$
|
| 130 |
+
{ \cal L } = \prod _ { i = 1 } ^ { n } \frac { \exp ( x _ { i } \cdot w _ { [ y _ { i } ] } ^ { \top } ) } { \sum _ { k = 0 } ^ { c - 1 } \exp ( x _ { i } \cdot w _ { [ k ] } ^ { \top } ) } \longmapsto \ln { \cal L } = \sum _ { i = 1 } ^ { n } [ x _ { i } \cdot w _ { [ y _ { i } ] } ^ { \top } - \ln \sum _ { k = 0 } ^ { c - 1 } \exp ( x _ { i } \cdot w _ { [ k ] } ^ { \top } ) ] .
|
| 131 |
+
$$
|
| 132 |
+
|
| 133 |
+
123 The loss function $\ln { \cal L }$ is a multivariate function of $[ ( 1 + c ) ( 1 + d ) ]$ variables, which has its column
|
| 134 |
+
124 vector gradient $\nabla$ of size $[ ( 1 + c ) ( 1 + d ) ]$ and Hessian square matrix $\nabla ^ { 2 }$ of order $[ ( 1 + c ) ( 1 + d ) ]$ as
|
| 135 |
+
125 follows:
|
| 136 |
+
|
| 137 |
+
$$
|
| 138 |
+
\begin{array} { r l } & { \nabla = \frac { \partial \ln L } { \partial \pi } = \left[ \frac { \partial \ln L } { \partial w _ { [ 0 ] } } , \frac { \partial \ln L } { \partial w _ { [ 1 ] } } , \ldots , \frac { \partial \ln L } { \partial w _ { [ c - 1 ] } } \right] ^ { \top } , } \\ & { \nabla ^ { 2 } = \left[ \begin{array} { c c c c } { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ 0 ] } \partial w _ { [ 0 ] } } } & { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ 0 ] } \partial w _ { [ 1 ] } } } & { \cdots } & { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ 0 ] } \partial w _ { [ c - 1 ] } } } \\ { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ 1 ] } \partial w _ { [ 0 ] } } } & { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ 1 ] } \partial w _ { [ 1 ] } } } & { \cdots } & { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ 1 ] } \partial w _ { [ - 1 ] } } } \\ { \vdots } & { \vdots } & { \ddots } & { \vdots } \\ { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ c - 1 ] } \partial w _ { [ 0 ] } } } & { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ c - 1 ] } \partial w _ { [ 1 ] } } } & { \cdots } & { \frac { \partial ^ { 2 } \ln L } { \partial w _ { [ c - 1 ] } \partial w _ { [ c - 1 ] } } } \end{array} \right] . } \end{array}
|
| 139 |
+
$$
|
| 140 |
+
|
| 141 |
+
126 Nesterov’s Accelerated Gradient With $\nabla$ or $\nabla ^ { 2 }$ , first-order gradient algorithms or second-order
|
| 142 |
+
127 Newton–Raphson method are commonly applied in MLE to maxmise $\ln { \cal L }$ . In particular, Nesterov’s
|
| 143 |
+
128 Accelerated Gradient (NAG) is a practical solution for homomorphic MLR without frequent inversion
|
| 144 |
+
129 operations. It seems plausible that the NAG method is probably the best choice for privacy-preserving
|
| 145 |
+
130 model training.
|
| 146 |
+
|
| 147 |
+
# 3.2 Chiang’s Quadratic Gradient
|
| 148 |
+
|
| 149 |
+
132 Chiang's Quadratic Gradient (CQG) [15, 16, 9] is a faster, promising gradient variant that can
|
| 150 |
+
133 combine the first-order gradient descent/ascent algorithms and the second-order Newton–Raphson
|
| 151 |
+
134 method, accelerating the raw Newton–Raphson method with various gradient algorithms and probably
|
| 152 |
+
|
| 153 |
+
135 helpful to build super-quadratic algorithms. For a function $F _ { _ - } ( x )$ with its gradient $g$ and Hessian matrix 136 $H$ , to build CQG, we first construct a diagonal matrix $\bar { B }$ from the Hessian $H$ itself:
|
| 154 |
+
|
| 155 |
+
$$
|
| 156 |
+
\bar { B } = \left[ \begin{array} { c c c c c } { \frac { 1 } { \varepsilon + \sum _ { i = 0 } ^ { d } \vert \bar { h } _ { 0 i } \vert } } & { 0 } & { \dots } & { 0 } \\ { 0 } & { \frac { 1 } { \varepsilon + \sum _ { i = 0 } ^ { d } \vert \bar { h } _ { 1 i } \vert } } & { \dots } & { 0 } \\ { \vdots } & { \vdots } & { \ddots } & { \vdots } \\ { 0 } & { 0 } & { \dots } & { \frac { 1 } { \varepsilon + \sum _ { i = 0 } ^ { d } \vert \bar { h } _ { d i } \vert } } \end{array} \right] ,
|
| 157 |
+
$$
|
| 158 |
+
|
| 159 |
+
where 137 $\bar { h } _ { j i }$ is the elements of the matrix $H$ and $\varepsilon$ is a small constant positive number.
|
| 160 |
+
|
| 161 |
+
138 CQG for the function $F ( \mathbf { x } )$ , defined as $G = \bar { B } \cdot g$ , has the same dimension as the raw gradient $g$ . To
|
| 162 |
+
139 apply CQG in practice, we can use it in the same way as the first-order gradient algorithms, except
|
| 163 |
+
140 that we need to replace the naive gradient with the quadratic gradient and adopt a new learning rate
|
| 164 |
+
141 (usually by increasing 1 to the original learning rate).
|
| 165 |
+
142 For efficiency in applying CQG, a good bound matrix should be attempted to obtain in order to
|
| 166 |
+
143 replace the Hessian itself. Chiang has proposed the enhanced NAG method via CQG for MLR with a
|
| 167 |
+
144 fixed Hessian [17, 7, 18] substitute built from ${ \frac { 1 } { 2 } } X ^ { \mathsf { \tau } } X$ .
|
| 168 |
+
|
| 169 |
+
# 45 3.3 Approximating Softmax Function
|
| 170 |
+
|
| 171 |
+
146 It might be impractical to perfectly approximate Softmax function in the privacy-preserving domain
|
| 172 |
+
147 due to its uncertainty. To address this issue, we employ the thought of transformation from mathemat
|
| 173 |
+
148 ics: transforming one tough problem into another easier one. That is, instead of trying to approximate
|
| 174 |
+
149 the Softmax function, we attempt to approximate the Sigmoid function in the encryption domain,
|
| 175 |
+
150 which has been well-studied by several works using the least-square method.
|
| 176 |
+
|
| 177 |
+
In line with standard practice of the log-likelihood loss function involving the Softmax function, we should try to maximize the new loss function
|
| 178 |
+
|
| 179 |
+
$$
|
| 180 |
+
L _ { 1 } = \prod _ { i = 1 } ^ { n } \frac { 1 } { 1 + \exp ( - x _ { i } \cdot w _ { [ y _ { i } ] } ^ { \mathsf { T } } ) } .
|
| 181 |
+
$$
|
| 182 |
+
|
| 183 |
+
151 We can prove that $\ln { \cal L } _ { 1 }$ is concave and deduce that ${ \scriptstyle { \frac { 1 } { 4 } } } E \otimes X ^ { \tau } X$ can be used to build the CQG for
|
| 184 |
+
152 $\ln { \cal L } _ { 1 }$ . However, the performance of this loss function $\ln { \cal L } _ { 1 }$ is not ideal, probably because for the
|
| 185 |
+
153 individual example its gradient and Hessian contain no information about any other class weights not
|
| 186 |
+
154 related to this example.
|
| 187 |
+
|
| 188 |
+
Squared Likelihood Error After many attempts to finding a proper loss function, we develop a novel loss function that can have a competitive performance to the log-likelihood loss function, which we term Squared Likelihood Error (SLE):
|
| 189 |
+
|
| 190 |
+
$$
|
| 191 |
+
{ \cal L } _ { 2 } = \prod _ { i = 1 } ^ { n } \prod _ { j = 0 } ^ { c - 1 } ( \bar { y } _ { i } - { \cal S } i g m o i d ( x _ { i } \cdot w _ { [ y _ { i } ] } ^ { \top } ) ^ { 2 } \longmapsto \ln { \cal L } _ { 2 } = \sum _ { i = 1 } ^ { n } \sum _ { j = 0 } ^ { c - 1 } \ln \left| \bar { y } _ { i } - { \cal S } i g m o i d ( x _ { i } \cdot w _ { [ y _ { i } ] } ^ { \top } ) \right| .
|
| 192 |
+
$$
|
| 193 |
+
|
| 194 |
+
155 We can also prove that $\ln { \cal L } _ { 2 }$ is concave and that ${ \scriptstyle { \frac { 1 } { 4 } } } E \otimes X ^ { \tau } X$ can be used to build the CQG for $\ln { \cal L } _ { 2 }$
|
| 195 |
+
156 The loss function SLE might be related to Mean Squared Error (MSE): the MSE loss function sums
|
| 196 |
+
157 all the squared errors while SLE calculates the cumulative product of all the squared likelihood errors.
|
| 197 |
+
158 Combining together all the techniques above, we now have the enhanced NAG method with the SLE
|
| 198 |
+
159 loss function for MLR training, described in detail in Algorithm 1.
|
| 199 |
+
160 Performance Evaluation We test the convergence speed of the raw NAG method with log
|
| 200 |
+
161 likelihood loss function (denoted as RawNAG), the NAG method with SLE loss function (denoted
|
| 201 |
+
162 as SigmoidNAG), and the enhanced NAG method via CQG with SLE loss function (denoted as
|
| 202 |
+
163 SigmoidNAGQG) on the three datasets described above: USPS, MNIST, and CIFAR10. Since two
|
| 203 |
+
164 different types of loss functions are used in these three methods, the loss function directly measuring
|
| 204 |
+
165 the performance of various methods will not be selected as the indicator. Instead, we select precision
|
| 205 |
+
166 as the only indicator in the following Python experiments. Note that we use REGNET_X_400MF to in
|
| 206 |
+
|
| 207 |
+
Input: training dataset $X \in \mathbb { R } ^ { n \times ( 1 + d ) }$ ; one-hot encoding training label $Y \in \mathbb { R } ^ { n \times c }$ ; and the number $\kappa$ of iterations;
|
| 208 |
+
|
| 209 |
+
Output: the parameter matrix $V \in \mathbb { R } ^ { c \times ( 1 + d ) }$ of the MLR
|
| 210 |
+
1: Set $\bar { H } - { \textstyle \frac { 1 } { 4 } } X ^ { \intercal } X$ $\begin{array} { r l r } & { } & { \triangleright \bar { H } \in \mathbb { R } ^ { ( 1 + d ) \times ( 1 + d ) } } \\ & { } & { \triangleright V \in \mathbb { R } ^ { c \times ( 1 + d ) } , W \in \mathbb { R } ^ { c \times ( 1 + d ) } , \bar { B } \in \mathbb { R } ^ { c \times ( 1 + d ) } } \end{array}$
|
| 211 |
+
2: Set $V \mathbf { 0 }$ , $W \mathbf { 0 }$ , $\bar { B } { \bf 0 }$
|
| 212 |
+
3: for $j : = 0$ to $d$ do
|
| 213 |
+
4: $\bar { B } [ 0 ] [ j ] \varepsilon$ . $\varepsilon$ is a small positive constant such as $1 e - 1 0$
|
| 214 |
+
5: for $i : = 0$ to $d$ do
|
| 215 |
+
6: $\bar { B } [ 0 ] [ j ] \bar { B } [ 0 ] [ j ] + | \bar { H } [ i ] [ j ] |$
|
| 216 |
+
7: end for
|
| 217 |
+
8: for $i : = 1$ to $c - 1$ do
|
| 218 |
+
9: $\bar { B } [ i ] [ j ] \bar { B } [ 0 ] [ j ]$
|
| 219 |
+
10: end for
|
| 220 |
+
11: for $i : = 0$ to $c - 1$ do
|
| 221 |
+
12: $\bar { B } [ i ] [ j ] 1 . 0 / \bar { B } [ i ] [ j ]$
|
| 222 |
+
13: end for
|
| 223 |
+
14: end for
|
| 224 |
+
15: Set $\alpha _ { 0 } \gets 0 . 0 1$ , $\alpha _ { 1 } 0 . 5 \times ( 1 + \sqrt { 1 + 4 \times \alpha _ { 0 } ^ { 2 } } )$
|
| 225 |
+
16: for count $: = 1$ to $\kappa$ do
|
| 226 |
+
17: Set $Z X \times V ^ { \tau }$ $\mathsf { D } Z \in \mathbb { R } ^ { n \times c }$ and $V ^ { \intercal }$ means the transpose of matrix V
|
| 227 |
+
18: for $i : = 1$ to $n$ do . $Z$ is going to store the inputs to the Sigmoid function
|
| 228 |
+
19: for $j : = 0$ to $d$ do
|
| 229 |
+
20: $Z [ i ] [ j ] 1 / ( 1 + e ^ { - Z [ i ] [ j ] } )$
|
| 230 |
+
21: end for
|
| 231 |
+
22: end for
|
| 232 |
+
23: Set $\pmb { g } ( Y - Z ) \ d { \tau } \times X$ . g Rc×(1+d)
|
| 233 |
+
24: Set $G 0$
|
| 234 |
+
25: for $i : = 0$ to $c - 1$ do
|
| 235 |
+
26: for $j : = 0$ to $d$ do
|
| 236 |
+
27: $\mathsf { \bar { \mathbf { { G } } } } [ i ] [ j ] \gets \bar { B } [ i ] [ j ] \times \mathbf { \mathbf { \mathbf { \mathbf { g } } } } [ i ] [ j ]$
|
| 237 |
+
28: end for
|
| 238 |
+
29: end for
|
| 239 |
+
30: $\begin{array} { l } { { \mathrm { S e t } \eta ( 1 - \alpha _ { 0 } ) / \alpha _ { 1 } , \gamma 1 / ( n \times c o u n t ) } } \\ { { w _ { t e m p } W + ( 1 + \gamma ) \times G } } \\ { { W ( 1 - \eta ) \times w _ { t e m p } + \eta \times V } } \\ { { V w _ { t e m p } } } \\ { { \alpha _ { 0 } \alpha _ { 1 } , \alpha _ { 1 } 0 . 5 \times ( 1 + \sqrt { 1 + 4 \times \alpha _ { 0 } ^ { 2 } } ) } } \end{array}$ $\triangleright n$ is the size of training data
|
| 240 |
+
31:
|
| 241 |
+
32:
|
| 242 |
+
33:
|
| 243 |
+
34:
|
| 244 |
+
35: end for
|
| 245 |
+
36: return W
|
| 246 |
+
167 advance extract the features of USPS, MNIST, and CIFAR10, resulting in a new same-size dataset
|
| 247 |
+
168 with 401 features of each example. Figure 1 shows that our enhanced methods all converge faster
|
| 248 |
+
169 than other algorithms on the three datasets.
|
| 249 |
+
|
| 250 |
+
# 170 3.4 Double Volley Revolver
|
| 251 |
+
|
| 252 |
+
171 Unlike those efficient, complex encoding methods [3], Volley Revolver is a simple, flexible
|
| 253 |
+
172 matrix-encoding method specialized for privacy-preserving machine-learning applications, whose
|
| 254 |
+
173 basic idea in a simple version is to encrypt the transpose of the second matrix for two matrices to
|
| 255 |
+
174 perform multiplication. Figure 2 describes a simple case for the algorithm adopted in this encoding
|
| 256 |
+
175 method.
|
| 257 |
+
176 The encoding method actually plays a significant role in implementing privacy-preserving CNN
|
| 258 |
+
177 training. Just as Chiang mentioned in [4], we show that Volley Revolver can indeed be used to
|
| 259 |
+
178 implement homomorphic CNN training. This simple encoding method can help to control and
|
| 260 |
+
179 manage the data flow through ciphertexts.
|
| 261 |
+
180 However, we don’t need to stick to encrypting the transpose of the second matrix. Instead, either of
|
| 262 |
+
181 the two matrices is transposed would do the trick: we could also encrypt the transpose of the first
|
| 263 |
+
182 matrix, and the corresponding multiplication algorithm due to this change is similar to the Algorithm
|
| 264 |
+
183 2 from [4].
|
| 265 |
+
184 Also, if each of the two matrices are too large to be encrypted into a single ciphertext, we could also
|
| 266 |
+
185 encrypt the two matrices into two teams $A$ and $B$ of multiple ciphertexts. In this case, we can see this
|
| 267 |
+
186 encoding method as Double Volley Revolver, which has two loops: the outside loop deals with
|
| 268 |
+
187 the calculations between ciphertexts from two teams while the inside loop literally calculates two
|
| 269 |
+
188 sub-matrices encrypted by two ciphertexts $A _ { [ i ] }$ and $B _ { [ j ] }$ using the raw algorithm of Volley Revolver.
|
| 270 |
+
|
| 271 |
+

|
| 272 |
+
Figure 1: Training and Testing precision results for raw NAG vs. NAG with SLE vs. The enhanced NAG with SLE
|
| 273 |
+
|
| 274 |
+

|
| 275 |
+
Figure 2: The matrix multiplication algorithm of Volley Revolver for the $4 \times 2$ matrix $A$ and the matrix $B$ of size $2 \times 2$
|
| 276 |
+
|
| 277 |
+
# 189 4 Privacy-preserving CNN Training
|
| 278 |
+
|
| 279 |
+
# 4.1 Polynomial Approximation
|
| 280 |
+
|
| 281 |
+
191 Although Algorithm 1 enables us to avoid computing the Softmax function in the encryption domain,
|
| 282 |
+
192 we still need to calculate the Sigmoid function using HE technique. This problem has been well
|
| 283 |
+
193 studied by several works and we adopt a simple one [19], that is (1) we first use the least-square method
|
| 284 |
+
194 to perfectly approximate the sigmoid function over the range $[ - 8 , + 8 ]$ , obtaining a polynomial $Z _ { 1 1 }$
|
| 285 |
+
195 of degree 11; and (2) we use a polynomial $Z _ { 3 }$ of degree 3 to approximate the Sigmoid by minimizing
|
| 286 |
+
196 the cost function $F$ including the squared gradient difference:
|
| 287 |
+
|
| 288 |
+
$$
|
| 289 |
+
F = \lambda _ { 0 } \cdot \int _ { - 8 } ^ { + 8 } ( Z _ { 1 1 } - Z _ { 3 } ) ^ { 2 } d x + \lambda _ { 1 } \cdot \int _ { - 8 } ^ { + 8 } ( Z _ { 1 1 } ^ { ' } - Z _ { 3 } ^ { ' } ) ^ { 2 } d x ,
|
| 290 |
+
$$
|
| 291 |
+
|
| 292 |
+
197 where $\lambda _ { 0 }$ and $\lambda _ { 1 }$ are two positive float numbers to control the shape of the polynomial to approximate.
|
| 293 |
+
|
| 294 |
+
198 Setting $\lambda _ { 0 } = 1 2 8$ and $\lambda _ { 1 } = 1$ would result in the polynomial we used in our privacy-preserving CNN training:199 $Z _ { 3 } = 0 . 5 + 0 . 1 0 6 7 9 5 3 4 5 0 3 2 \cdot x - 0 . 0 0 0 3 8 5 0 3 2 5 9 8 \cdot x ^ { 3 }$ .
|
| 295 |
+
|
| 296 |
+
Before the homomorphic CNN training starts, the client needs to encrypt the dataset $X$ , the data labels $\bar { Y }$ , the matrix $\vec { B }$ and the weight $W$ into ciphertexts $E n c ( X ) , E n c ( \hat { Y } ) , E n c ( \hat { B } )$ and $E n c ( W )$ , respectively, and upload them to the cloud. For simplicity in presentation, we can just regard the whole pipeline of homomorphic evaluation of Algorithm 1 as updating the weight ciphertext: $W = W \dot { + } \hat { B } \odot ( \bar { Y } - Z _ { 3 } ( X \times \hat { W } ^ { \bar { \mathsf { T } } } ) ) ^ { \bar { \mathsf { T } } } \times X$ , regardless of the subtle control of the enhanced NAG method with the SLE loss function.
|
| 297 |
+
|
| 298 |
+
Since Volley Revolver only needs one of the two matrices to be transposed ahead before encryption and $( \bar { Y } - Z _ { 3 } ( X \times \bar { W } ^ { \bar { \mathsf { T } } } ) ) ^ { \bar { \mathsf { T } } } \times X$ happened to suffice this situation between any matrix multiplication, we can complete the homomorphic evaluation of CQG for MLR.
|
| 299 |
+
|
| 300 |
+
# 5 Experiments
|
| 301 |
+
|
| 302 |
+
The $\mathrm { C } { + } { + }$ source code to implement the experiments in this section is openly available at: https://anonymous.4open.science/r/HE-CNNtraining-B355/ .
|
| 303 |
+
|
| 304 |
+
Implementation We implement the enhanced NAG with the SLE loss function based on HE with the library HEAAN. All the experiments on the ciphertexts were conducted on a public cloud with 64 vCPUs and 192 GB RAM.
|
| 305 |
+
|
| 306 |
+
We adopt the first 128 MNIST training images as the training data and the whole test dataset as the testing data. Both the training images and testing images have been processed in advance with the pre-trained model REGNET_X_400MF, resulting in a new dataset with each example of size 401.
|
| 307 |
+
|
| 308 |
+
# 5.1 Parameters
|
| 309 |
+
|
| 310 |
+
The parameters of HEAAN we selected are: $l o g N = 1 6$ , $l o g Q = 9 9 0$ , $l o g p = 4 5$ , $s l o t s = 3 2 7 6 8$ , which ensure the security level $\lambda = 1 2 8$ . Refer [6] for the details of these parameters. We didn’t use bootstrapping to refresh the weight ciphertexts and thus it can only perform 2 iterations of our algorithm. Each iteration takes $\sim 1 1$ mins. The maximum runtime memory in this case is $\sim 1 8$ GB. The 128 MNIST training images are encrypted into 2 ciphertexts. The client who own the private data has to upload these two ciphertexts, two ciphertexts encrypting the one-hot labels $\bar { Y }$ , one ciphertext encrypting the $\bar { B }$ and one ciphertext encrypting the weight $W$ to the cloud. The inticial weight matrix $W _ { 0 }$ we adopted is the zero matrix. The resulting MLR model after 2-iteration training has reached a pricision of $2 1 . 4 9 \%$ and obtain the loss of −147206, which are consistent with the Python simulation experiment.
|
| 311 |
+
|
| 312 |
+
# 6 Conclusion
|
| 313 |
+
|
| 314 |
+
In this work, we initiated to implement privacy-persevering CNN training based on mere HE techniques by presenting a faster HE-friendly algorithm.
|
| 315 |
+
|
| 316 |
+
The HE operation bootstrapping could be adopted to refresh the weight ciphertexts. Python experiments imitating the privacy-preserving CNN training using $Z _ { 3 }$ as Sigmoid substitution showed that using a large amount of data such as 8,192 images to train the MLE model for hundreds of iterations would finally reach $9 5 \%$ precision. The real experiments over ciphertexts conducted on a high-performance cloud with many vCPUs would take weeks to complete this test, if not months.
|
| 317 |
+
|
| 318 |
+
# References
|
| 319 |
+
|
| 320 |
+
[1] Ran Gilad-Bachrach, Nathan Dowlin, Kim Laine, Kristin Lauter, Michael Naehrig, and John Wernsing. Cryptonets: Applying neural networks to encrypted data with high throughput and accuracy. In International conference on machine learning, pages 201–210. PMLR, 2016.
|
| 321 |
+
|
| 322 |
+
[2] Hervé Chabanne, Amaury De Wargny, Jonathan Milgram, Constance Morel, and Emmanuel Prouff. Privacy-preserving classification on deep neural network. Cryptology ePrint Archive, 2017.
|
| 323 |
+
|
| 324 |
+
[3] Xiaoqian Jiang, Miran Kim, Kristin Lauter, and Yongsoo Song. Secure outsourced matrix computation and application to neural networks. In Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security, pages 1209–1222, 2018. [4] John Chiang. A novel matrix-encoding method for privacy-preserving neural networks (inference). arXiv preprint arXiv:2201.12577, 2022. [5] Florian Bourse, Michele Minelli, Matthias Minihold, and Pascal Paillier. Fast homomorphic evaluation of deep discretized neural networks. In Advances in Cryptology–CRYPTO 2018: 38th Annual International Cryptology Conference, Santa Barbara, CA, USA, August 19–23, 2018, Proceedings, Part III 38, pages 483–512. Springer, 2018. [6] Andrey Kim, Yongsoo Song, Miran Kim, Keewoo Lee, and Jung Hee Cheon. Logistic regression model training based on the approximate homomorphic encryption. BMC medical genomics, 11(4):83, 2018. [7] Charlotte Bonte and Frederik Vercauteren. Privacy-preserving logistic regression training. BMC medical genomics, 11(4):86, 2018. [8] Miran Kim, Yongsoo Song, Shuang Wang, Yuhou Xia, and Xiaoqian Jiang. Secure logistic regression based on homomorphic encryption: Design and evaluation. JMIR medical informatics, 6(2):e19, 2018. [9] John Chiang. Privacy-preserving logistic regression training with a faster gradient variant. arXiv preprint arXiv:2201.10838, 2022. [10] Craig Gentry. Fully homomorphic encryption using ideal lattices. In Proceedings of the forty-first annual ACM symposium on Theory of computing, pages 169–178, 2009. [11] Zvika Brakerski, Craig Gentry, and Vinod Vaikuntanathan. (leveled) fully homomorphic encryption without bootstrapping. ACM Transactions on Computation Theory (TOCT), 6(3):1– 36, 2014. [12] N.P. Smart and F. Vercauteren. Fully homomorphic simd operations. Cryptology ePrint Archive, Report 2011/133, 2011. https://ia.cr/2011/133. [13] Jung Hee Cheon, Andrey Kim, Miran Kim, and Yongsoo Song. Homomorphic encryption for arithmetic of approximate numbers. In International Conference on the Theory and Application of Cryptology and Information Security, pages 409–437. Springer, 2017. [14] Kyoohyung Han, Seungwan Hong, Jung Hee Cheon, and Daejun Park. Logistic regression on homomorphic encrypted data at scale. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 9466–9471, 2019.
|
| 325 |
+
7 [15] John Chiang. Multinomial logistic regression algorithms via quadratic gradient, 2023.
|
| 326 |
+
78 [16] John Chiang. Quadratic gradient: Uniting gradient algorithm and newton method as one. arXiv preprint arXiv:2209.03282, 2022. [17] Dankmar Böhning and Bruce G Lindsay. Monotonicity of quadratic-approximation algorithms. Annals of the Institute of Statistical Mathematics, 40(4):641–663, 1988. [18] Dankmar Böhning. Multinomial logistic regression algorithm. Annals of the institute of Statistical Mathematics, 44(1):197–200, 1992.
|
| 327 |
+
84 [19] John Chiang. On polynomial approximation of activation function. arXiv preprint arXiv:2202.00004, 2022.
|
md/dev/cJPkX1g9PQS/cJPkX1g9PQS.md
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RETHINKING SELF-SUPERVISION OBJECTIVES FOR GENERALIZABLE COHERENCE MODELING
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Although large-scale pre-trained neural models have shown impressive performances in a variety of tasks, their ability to generate coherent text that appropriately models discourse phenomena is harder to evaluate and less understood. Given the claims of improved text generation quality across various systems, we consider the coherence evaluation of machine generated text to be one of the principal applications of coherence models that needs to be investigated. We explore training data and self-supervision objectives that result in a model that generalizes well across tasks and can be used off-the-shelf to perform such evaluations.
|
| 8 |
+
|
| 9 |
+
Prior work in neural coherence modeling has primarily focused on devising new architectures, and trained the model to distinguish coherent and incoherent text through pairwise self-supervision on the permuted documents task. We instead use a basic model architecture and show significant improvements over state of the art within the same training regime. We then design a harder self-supervision objective by increasing the ratio of negative samples within a contrastive learning setup, and enhance the model further through automatic hard negative mining coupled with a large global negative queue encoded by a momentum encoder. We show empirically that increasing the density of negative samples improves the basic model, and using a global negative queue further improves and stabilizes the model while training with hard negative samples. We evaluate the coherence model on task-independent test sets that resemble real-world use cases and show significant improvements in coherence evaluations of downstream applications.
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
Coherence is a property of a well-written text that makes it different from a random set of sentences: sentences in a coherent text are connected in systematic ways such that each sentence follows naturally from previous ones and leads into the following ones (Halliday & Hasan, 1976; Grosz & Sidner, 1986). Coherence models (Barzilay & Lapata, 2005) that can distinguish a coherent text from incoherent ones have a wide range of applications in language generation, summarization, and coherence assessment tasks such as essay scoring and sentence ordering.
|
| 14 |
+
|
| 15 |
+
With the advancements of neural methods in recent years, claims of fluency in summarization (Liu et al., 2017; Celikyilmaz et al., 2018), language modeling (Radford et al., 2019; Brown et al., 2020), response generation (Zhang et al., 2020; Hosseini-Asl et al., 2020) and human parity in machine translation (Hassan et al., 2018) have led to calls for finer-grained discourse-level evaluations (Laubli ¨ et al., 2018; Sharma et al., 2019; Popel et al., 2020), since traditional metrics such as BLEU and ROUGE are unable to measure text quality and readability (Paulus et al., 2018; Reiter, 2018). Coherence models that can evaluate machine-generated text have become the need of the hour.
|
| 16 |
+
|
| 17 |
+
A majority of coherence models proposed optimize their learning objectives on the permuted document task that uses the Penn Treebank (WSJ) corpus. The current paradigm of coherence modeling that uses permuted documents to train pairwise ranking models was originally proposed by Barzilay & Lapata (2005; 2008) to emulate entity-based incoherence, which has its origins in Centering Theory (Grosz et al., 1995). An original article is considered a ‘positive’ sample of a coherent document, while a permutation of its sentences is considered a ‘negative’ or incoherent sample (see Appendix A.1 for an example). Models are usually trained in a pairwise ranking fashion to distinguish the two.
|
| 18 |
+
|
| 19 |
+
The basic entity-grid model proposed by Barzilay & Lapata (2005; 2008) was extended to incorporate entity-specific features (Elsner & Charniak, 2011), multiple ranks (Feng & Hirst, 2012), and coherence relations (Lin et al., 2011; Feng et al., 2014). Their neural extensions have also been proposed (Nguyen & Joty, 2017; Mohiuddin et al., 2018). More recent state-of-the-art models like the Transferable Neural model (Xu et al., 2019) consider coherence at a local level by training a forward and backward model only on adjacent sentences, in addition to generative pre-training of the sentence encoders. The Unified Coherence model (Moon et al., 2019) uses bi-linear layer and lightweight convolution-pooling in a Siamese framework to capture discourse relations and topic structures, along with an explicit language model loss to capture syntactic patterns.
|
| 20 |
+
|
| 21 |
+
Mohiuddin et al. (2021) recently tested these state-of-the-art models by conducting coherence evaluations on the WSJ permuted document task, machine translation, summarization and next utterance ranking tasks. They found that while models performed well on the permuted document task, when tested off-the-shelf, models generalized poorly to downstream evaluation tasks. They call for more comprehensive evaluations of coherence models. Pishdad et al. (2020) also reached a similar conclusion. They retrained several neural coherence models for tasks analogous to coherence modeling such as detecting connective substitution and topic switching. They found that performance on the permuted document task is only partially indicative of a model’s coherence modeling capabilities.
|
| 22 |
+
|
| 23 |
+
In light of these recent findings, our aim in this work is to propose a coherence model that generalizes well to other tasks, and can be used off-the-shelf for coherence evaluations of downstream applications such as machine generated text. We train our model purely through self-supervision, without tailoring the model architecture to be specific to the permuted document task or any other form of supervision. Our main hypothesis is that large-scale pre-trained models like XLNet (Yang et al., 2019) are expressive enough to capture coherence information given the right self-supervision.
|
| 24 |
+
|
| 25 |
+
Li & Jurafsky (2017) point out that coherence models are exposed to a limited number of incoherent samples in the pairwise setup, since only a small sample of all possible incoherent permutations of a document are used to train models. Learning with more negatives can better maximize the mutual information between their representations (van den Oord et al., 2018). By using a contrastive learning (Gutmann & Hyvarinen, 2010) setup, where each ‘positive’ document is compared with ¨ multiple ‘negative’ documents, we increase the proportion of negative samples that the model is exposed to, and show that the coherence model shows significant improvements in performance.
|
| 26 |
+
|
| 27 |
+
Wu et al. (2020) recently show that the difficulty of the negative samples used for contrastive training can strongly influence model success for visual representation learning. Guided by this principle, we train the model with hard negative samples that are automatically mined, coupled with a large global negative queue encoded by a momentum encoder (He et al., 2019).
|
| 28 |
+
|
| 29 |
+
We evaluate our model on various independent test sets that demonstrate its applicability in downstream applications: machine generated summaries, language model outputs and commonsense reasoning, in addition to testing on coherence-specific test sets. In summary, our contributions are:
|
| 30 |
+
|
| 31 |
+
• A neural coherence model trained purely through well-designed self-supervision tasks that generalizes well to downstream applications and can be used off-the-shelf for coherence evaluation.
|
| 32 |
+
• Evaluation on multiple independent test sets that are more indicative of real-world performance of the coherence model.
|
| 33 |
+
• Empirical results demonstrating that an increase in the density and quality of negative samples leads to better generalization for coherence models.
|
| 34 |
+
|
| 35 |
+
# 2 DATASETS
|
| 36 |
+
|
| 37 |
+
In order to ensure that our coherence model is useful for evaluation in downstream applications, we use a selection of task-independent test sets that cover a variety of domains and genres, including machine generated text from summarization systems and language models. Following Pishdad et al. (2020), we also evaluate the models on a commonsense reasoning narrative dataset. Since our objective is to find the best training paradigm that can be used off-the-shelf for coherence evaluation, we train (and validate) the coherence models on standard WSJ data, while using the rest as “independent” test sets to indicate the generalizability of the trained models. All evaluations on the independent test sets are conducted in a pairwise setting to enable a fair comparison.
|
| 38 |
+
|
| 39 |
+
# 2.1 TRAINING DATA
|
| 40 |
+
|
| 41 |
+
WSJ The Wall Street Journal (WSJ) corpus consists of news articles which are divided into 1,240 documents for training, 138 documents for development and 1,053 documents for testing in the standard setup. We exclude documents with fewer than 4 sentences and truncate them to a maximum length of 600 tokens. In order to maximally utilize documents which are otherwise truncated due to GPU memory constraints, we partition documents with $^ { 2 0 + }$ sentences into blocks of 10 sentences and consider each block as a separate positive document. This increases the number of coherent ‘documents’ that we can use to generate a much larger training set. Moon et al. (2019) use upto 20 permutations of a document to train their model; since their training setup is pairwise, it means that the original positive document is repeated 20 times. We regenerate the permuted documents similarly, sampling a larger set of permutations for our contrastive learning setup.1 This gives us 46,522 instances of positive and their corresponding negative documents for training and 4,522 instances for development. We use the original pairwise test set used by Moon et al. (2019) with 20,411 instances for testing.
|
| 42 |
+
|
| 43 |
+
# 2.2 MACHINE GENERATED TEXTS
|
| 44 |
+
|
| 45 |
+
SUMMEVAL Fabbri et al. (2020) conduct a manual coherence evaluation of the summaries generated by 16 different summarization systems for 100 source articles based on the CNN/DailyMail (Hermann et al., 2015) dataset. Likert-style coherence ratings from 3 expert annotators are available for each summarized text. We adapt this to the pairwise setting by creating pairs of summaries from every system for each unique source article. The summary with the higher average coherence rating is designated as the positive document, while the summary with the lower rating is the negative document for that pair. This results in $( \mathbf { \Phi } _ { 2 } ^ { 1 6 } ) \times 1 0 0 = 1 2 , 0 0 0$ pairs for evaluation.
|
| 46 |
+
|
| 47 |
+
LMVLM To cover a wider variety of machine generated text, we generated texts from various language models using prompts taken from the validation and test sets of the WritingPrompts dataset (Fan et al., 2018). Four language models were chosen for this purpose: GPT2-Small, GPT2-XL, CTRL and GPT3. The continuations produced by these models for each prompt were truncated at approximately 150 tokens and paired together. Using these texts, we conducted a user study on Amazon Mechanical Turk. Workers were instructed about the concept of coherence and shown examples of coherent and incoherent texts. Given the prompt, they were asked to choose the more coherent text out of two given language model outputs; they were also given an option to choose neither in case the texts were equally coherent/incoherent (see Appendix A.3 for more details such as the study interface). After removing the samples with low agreements and ties, a total of 1046 pairs with judgments from 3 annotators each were collected. The Krippendorff’s alpha coefficient (Krippendorff, 2011) between the annotators was 0.84. We calculate the agreements of the coherence model ranking with these judgments, designated LMVLM.
|
| 48 |
+
|
| 49 |
+
# 2.3 CURATED TEST SETS
|
| 50 |
+
|
| 51 |
+
INSTED Shen et al. (2021) propose a sentence intrusion detection task in order to test the coherence modeling capabilities of pre-trained language models. Incoherent documents are created by substituting a sentence from a document with another sentence from a different document, ensuring that the replacement sentence is similar to the original document to make the task sufficiently hard. We adapt their task to the pairwise setting by pairing the original coherent and the corrupted incoherent document, giving us 7,168 instances from their CNN test set (INSTED-CNN) and 3,666 instances from their Wikipedia test set (INSTED-WIKI) for evaluation. Shen et al. (2021) also create a hand-crafted linguistic probe test set, where incoherence is manually inserted based on a range of linguistic phenomena; we use this test set for analysis (§4).
|
| 52 |
+
|
| 53 |
+
STORYCLOZE The STORYCLOZE dataset (created from ROCSTORIES (Sharma et al., 2018)) consists of a short narrative-style text with two possible endings, one of which is implausible. The test set labels are not public so we use the validation set. We designate the text with the correct ending as the positive document and the text with the incorrect ending as the negative document, resulting in a total of 1, 571 pairs for evaluation.
|
| 54 |
+
|
| 55 |
+
# 3 METHODOLOGY
|
| 56 |
+
|
| 57 |
+
# 3.1 MODEL ARCHITECTURE
|
| 58 |
+
|
| 59 |
+
Previous work on coherence modeling proposed elaborate architectures to capture various aspects of coherence (see $\ S 1$ ). However, our key hypothesis is that large-scale pre-trained models are expressive enough to model coherence given the right self-supervision; Abhishek et al. (2021) show some results to this effect. Effective bi-directional encoding through large Transformer networks (Vaswani et al., 2017) can consider longer language context, while language modeling objectives enforce syntactic and local coherence patterns in the model.
|
| 60 |
+
|
| 61 |
+
In our work, we adopt XLNet (Yang et al., 2019) as the backbone model. It is trained using a permuted language modeling objective, in which the expected log-likelihood of a sequence with respect to all permutations of the factorization order is maximized. This allows the modeling of bi-directional context, while maintaining the auto-regressive property and avoiding the pretrainfinetune discrepancy. In addition, XLNet also incorporates segment recurrence (or memory) and the relative encoding scheme of Transformer-XL (Dai et al., 2019), which makes it effective in modeling longer text sequences. This makes it suitable for our purpose of coherence modeling.
|
| 62 |
+
|
| 63 |
+
Given a document $\mathcal { D }$ with $n$ sentences $( s _ { 1 } , s _ { 2 } , \ldots , s _ { n } )$ as input, our model uses the representations obtained through XLNet (parameterized by $\phi$ in Figure 1) to assign a coherence score to the model. Specifically, for each sentence $s _ { i }$ with $k$ tokens $( w _ { 1 } , w _ { 2 } \dots w _ { k } )$ , XLNet maps each token $w _ { t }$ to its vector representation $v _ { t } \in \mathbb { R } ^ { d }$ where $d$ is the dimension of the embedding. In addition, the complete input $\mathcal { D }$ is also mapped to a document representation $\mathbf { z } \in \mathbb { R } ^ { d }$ (i.e., the representation of the [CLS] token). We simply add a linear layer to convert document representation $\mathbf { z }$ to obtain the final coherence score: $f _ { \boldsymbol { \theta } } ( \mathbf { \bar { \mathcal { D } } } ) = \mathbf { w } ^ { \top } \mathbf { z } + b$ , where w and $b$ are the weight and bias of the linear layer with $\theta = \{ \phi , { \bf w } , b \}$ being the entire parameter set of the model (see the upper part of Figure 1).
|
| 64 |
+
|
| 65 |
+
# 3.2 MARGIN-BASED PAIRWISE RANKING
|
| 66 |
+
|
| 67 |
+
Setup. Traditionally, coherence model training has been done in a pairwise ranking setup. In this setup, the model is trained to score the coherent or positive document higher than the incoherent or negative document, using a pairwise ranking loss (Collobert et al., 2011) defined as follows:
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\mathcal { L } _ { \boldsymbol { \theta } } ( \mathcal { D } ^ { + } , \mathcal { D } ^ { - } ) = \operatorname* { m a x } \big ( 0 , \tau - f _ { \boldsymbol { \theta } } ( \mathcal { D } ^ { + } ) + f _ { \boldsymbol { \theta } } ( \mathcal { D } ^ { - } ) \big )
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
where $f _ { \theta } ( \mathcal { D } ^ { + } )$ is the coherence score of the positive document, $f _ { \theta } ( \mathcal { D } ^ { - } )$ is the coherence score of the negative document and $\tau$ is the margin.
|
| 74 |
+
|
| 75 |
+
Baseline. Results from evaluation of existing coherence models by both Pishdad et al. (2020) and Mohiuddin et al. (2021) indicate that the Unified Coherence model or UNC (Moon et al., 2019) is overall the best-performing model (see Appendix A.5 for a full comparison). We retrain their model with our training data for comparison2. In addition, to ascertain the contribution of the pre-trained XLNet embeddings, we train our pairwise model without fine-tuning the representations, i.e., only the score-producing linear layer weights w and $b$ are trained on the pairwise ranking task.
|
| 76 |
+
|
| 77 |
+
Results. Results for the baseline models are given in Table 1 (see first two rows). We see that despite relatively high performance on the WSJ test set $( 9 4 . 1 1 \% )$ , UNC’s performance on the independent test sets is quite poor, often failing to do better than a random baseline of $50 \%$ in 3 out of 5 cases. The performance on the INSTED-CNN dataset, which is the same domain (news) as the training data, is relatively better at $6 7 . 2 1 \%$ . Our XLNet-Pairwise model trained without fine-tuning the representations (No FT) has some success on the SUMMEVAL and STORYCLOZE datasets compared to UNC, but overall the performance of this model is worse. This shows that the UNC model is in fact a strong baseline model despite using ELMo (Peters et al., 2018) pretrained representations. Our fully-trained XLNet-Pairwise model not only outperforms the SOTA UNC model on the standard WSJ permuted document task, but also significantly outperforms this model on the independent test sets, showing an absolute improvement of $1 5 \mathrm { - } 2 0 \%$ on the SUMMEVAL, INSTEDCNN, INSTED-WIKI and the STORYCLOZE datasets. On LMVLM, the UNC model has a better performance; we suspect that its explicit conditional language modeling loss might provide an additional advantage for this particular task. Overall, our results are consistent with observations from Mohiuddin et al. (2021) that show poor generalizability in the previous SOTA model.
|
| 78 |
+
|
| 79 |
+
Table 1: Results on the WSJ permuted document test set and the various independent test sets of the previous SOTA UNC model and our XLNet based models. Except for the LMVLM results which are reported in terms of Krippendorff’s alpha agreement with human annotators, all other results are reported in terms of accuracy of the models in scoring the positive document higher than the negative document. All results are averaged over 5 runs with different seeds.
|
| 80 |
+
|
| 81 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>WSJ</td><td rowspan=1 colspan=1>SUMMEVAL</td><td rowspan=1 colspan=1>LMvLM</td><td rowspan=1 colspan=3>INSTED-CNN|INSTED-WIKI STORYCLOZE</td></tr><tr><td rowspan=1 colspan=1>UNC</td><td rowspan=1 colspan=1>94.11±0.29</td><td rowspan=1 colspan=1>46.28±0.80</td><td rowspan=1 colspan=1>0.463±0.01</td><td rowspan=1 colspan=1>67.21±0.55</td><td rowspan=1 colspan=1>55.97±0.45</td><td rowspan=1 colspan=1>49.39±1.81</td></tr><tr><td rowspan=1 colspan=1>Our - Pairwise (No FT)</td><td rowspan=1 colspan=1>71.70±1.02</td><td rowspan=1 colspan=1>54.93±1.91</td><td rowspan=1 colspan=1>0.421±0.01</td><td rowspan=1 colspan=1>59.96±3.15</td><td rowspan=1 colspan=1>53.45±0.86</td><td rowspan=1 colspan=1>51.69±1.32</td></tr><tr><td rowspan=1 colspan=1>Our - Pairwise</td><td rowspan=1 colspan=1>98.23±0.20</td><td rowspan=1 colspan=1>64.83±1.03</td><td rowspan=1 colspan=1>0.458±0.02</td><td rowspan=1 colspan=1>91.96±1.09</td><td rowspan=1 colspan=1>70.85±1.85</td><td rowspan=1 colspan=1>71.84±2.33</td></tr><tr><td rowspan=2 colspan=1>Our - Contrastive Our - Full Model</td><td rowspan=2 colspan=1>98.59±0.2098.58±0.18</td><td rowspan=1 colspan=1>66.93±1.10</td><td rowspan=1 colspan=1>0.468±0.01</td><td rowspan=1 colspan=1>92.84±0.61</td><td rowspan=1 colspan=1>71.86±0.69</td><td rowspan=1 colspan=1>72.83±2.89</td></tr><tr><td rowspan=1 colspan=1>67.19±0.63</td><td rowspan=1 colspan=1>0.473±0.00</td><td rowspan=1 colspan=1>93.36±0.49</td><td rowspan=1 colspan=1>72.04±1.05</td><td rowspan=1 colspan=1>74.62±2.79</td></tr></table>
|
| 82 |
+
|
| 83 |
+
# 3.3 CONTRASTIVE LEARNING
|
| 84 |
+
|
| 85 |
+
Setup. In the pairwise ranking setup, each positive sample is only compared to one negative sample at a time. Contrastive learning (Gutmann & Hyvarinen, 2010) makes it general, where a single ¨ positive sample can be compared to multiple negative samples, which can be particularly useful in the permuted document task where the number of possible incoherent samples per coherent document can be very large. The number of negatives considered and their quality can affect the model performance (Arora et al., 2019). Wu et al. (2020) show that contrastive loss maximizes a lower bound on the mutual information between representations. A larger number of negatives increases the tightness of the bound; learning with more negatives can better maximise the mutual information. We train our model with a margin-based contrastive loss defined as:
|
| 86 |
+
|
| 87 |
+
$$
|
| 88 |
+
\mathcal { L } _ { \theta } ( \mathcal { D } ^ { + } , \mathcal { D } _ { 1 } ^ { - } , \cdot \cdot , \mathcal { D } _ { N } ^ { - } ) = - \log \Big ( \frac { e ^ { f _ { \theta } ( \mathcal { D } ^ { + } ) } } { e ^ { f _ { \theta } ( \mathcal { D } ^ { + } ) } + \sum _ { j = 1 } ^ { N } e ^ { ( f _ { \theta } ( \mathcal { D } _ { j } ^ { - } ) - \tau ) } } \Big )
|
| 89 |
+
$$
|
| 90 |
+
|
| 91 |
+
where $f _ { \boldsymbol { \theta } } ( \mathcal { D } ^ { + } )$ is the coherence score of the positive document, $f _ { \theta } ( \mathcal { D } _ { 1 } ^ { - } ) , \cdot \cdot \cdot , f _ { \theta } ( \mathcal { D } _ { N } ^ { - } )$ are the scores of the $N$ negative documents, and $\tau$ is the margin.
|
| 92 |
+
|
| 93 |
+
Training. We use the same training data as the baseline models to train our contrastive model; the positive documents remain the same, while we use 5 negative documents per instance (instead of only 1 in the pairwise setup). Effectively, the model sees the same number of positive or coherent documents, but five times as many negative samples during training compared to the pairwise setting. See Appendix A.4 for the full set of our hyperparameters.
|
| 94 |
+
|
| 95 |
+
Results. From the results in Table 1, we see that the contrastive model (row 3) further improves the results across all the independent test sets; the results on the LMVLM dataset also improve, now surpassing the UNC model performance. Although the improvement on the WSJ permuted document task is small, the improvement in the generalizability of the model is more significant.
|
| 96 |
+
|
| 97 |
+
# 3.4 MOMENTUM ENCODER WITH HARD NEGATIVE MINING
|
| 98 |
+
|
| 99 |
+
While increasing the number of negative samples per instance has been shown to be effective for constrastive learning, resource constraints can limit the number of negatives that can be considered per instance. One solution is to consider other positive instances in the same training batch as negatives (Karpukhin et al., 2020; Chen et al., 2020). However, this method is not suitable for the permuted document task since the negatives are instance-specific. While a permuted document is still independently incoherent, training with permuted versions of other documents will not provide the same cues for coherence modeling as the original self-supervision.
|
| 100 |
+
|
| 101 |
+
Another solution is to maintain a large global queue of negative samples that are independent of the current training instance. During training, negative samples (more specifically, their representations) from the latest batch are enqueued to build a queue upto some size l. As training continues, the negative samples from the oldest batch are dequeued to accommodate newer samples. However, representations of the documents will evolve through training as the model parameters get updated; this will make the negative samples in the queue inconsistent with each other and the training instances in the current batch. Moreover, the issue of mismatched self-supervision with negatives that are permuted versions of other documents still remains.
|
| 102 |
+
|
| 103 |
+
Momentum Encoder. To address these issues, we add an auxiliary momentum encoder (He et al., 2019), which is also XLNet (Yang et al., 2019). Figure 1 shows the overall architecture. Keeping the base contrastive setup the same (the upper part), we add an additional contrastive objective based on representations from the momentum encoder. Specifically, we re-encode the positive and negative samples through the momentum encoder; the negative samples thus encoded are used to build the queue. We train the model to promote the similarity between the positive representations from the momentum encoder and the positive representations from our base encoder over the similarity with the negative samples from the queue, $Q$ . Specifically, we define a momentum loss ${ \mathcal { L } } _ { \theta } ^ { \mathrm { m o m } }$ as:
|
| 104 |
+
|
| 105 |
+

|
| 106 |
+
Figure 1: Our coherence model with the auxiliary momentum encoder. $\phi$ is our base encoder similar to our setup in $\ S 3 . 3$ , while $\phi ^ { \prime }$ is our momentum encoder. $\dot { u } ^ { + } = f _ { \theta } ( \mathcal { D } ^ { + } )$ and $u ^ { - } = f _ { \theta } ( \mathcal { D } ^ { - } )$ are the coherence scores of the positive and negative documents respectively. Note that only the parameters of $\phi$ and the linear layer are updated through backpropagation.
|
| 107 |
+
|
| 108 |
+
$$
|
| 109 |
+
c ^ { + } = \frac { ( \mathbf { z } ^ { + } ) ^ { \top } ( \mathbf { z } _ { m } ^ { + } ) } { | | \mathbf { z } ^ { + } | | \mid | \mathbf { z } _ { m } ^ { + } | | } ; \quad c _ { j } ^ { - } = \frac { ( \mathbf { z } _ { m } ^ { + } ) ^ { \top } \mathbf { q } _ { j } } { | | \mathbf { z } _ { m } ^ { + } | | \mid | \mathbf { q } _ { j } | | } ; \quad \mathcal { L } _ { \theta } ^ { \mathrm { m o m } } = - \log \Big ( \frac { e ^ { c ^ { + } } } { e ^ { c ^ { + } } + \sum _ { j = 1 } ^ { l } e ^ { ( c _ { j } ^ { - } - \tau ) } } \Big )
|
| 110 |
+
$$
|
| 111 |
+
|
| 112 |
+
where ${ \mathbf z } ^ { + }$ and $\mathbf { z } _ { m } ^ { + }$ are the positive representations from the base encoder $( \phi )$ and the momentum encoder $( \phi ^ { \prime } )$ respectively, ${ \bf q } _ { 1 } , \ldots , { \bf q } _ { l }$ indexed by $j$ are the negative representations from $\phi ^ { \prime }$ in the queue, and $\tau$ is the margin. The momentum encoder $\phi ^ { \prime }$ is updated based on the base encoder $\phi$ as:
|
| 113 |
+
|
| 114 |
+
$$
|
| 115 |
+
\phi ^ { \prime } \mu * \phi ^ { \prime } + ( 1 - \mu ) * \phi
|
| 116 |
+
$$
|
| 117 |
+
|
| 118 |
+
where $\mu \in [ 0 , 1 )$ is the momentum coefficient; only $\phi$ is updated through backpropagation.
|
| 119 |
+
|
| 120 |
+
Our full model is trained with a combination of the original contrastive learning objective (Eq. 2) and the momentum encoded contrastive similarity objective (Eq. 3):
|
| 121 |
+
|
| 122 |
+
$$
|
| 123 |
+
\mathcal { L } _ { \theta } = \lambda \mathcal { L } _ { \theta } + ( 1 - \lambda ) \mathcal { L } _ { \theta } ^ { \mathrm { m o m } }
|
| 124 |
+
$$
|
| 125 |
+
|
| 126 |
+
where $\lambda$ is a weighting hyperparameter. The momentum encoder can be considered as a temporal ensemble model consisting of exponential-moving-average versions of the base model. Due to this, gradients from the momentum loss (Eq. 3) also help in stabilising the overall training (§4).
|
| 127 |
+
|
| 128 |
+
Length Invariance Training. In the permuted document task, both the positive and the negative samples have the same number of sentences. This is not necessarily the case for real world applications. In order to incorporate length invariance into our model, we encode a random contiguous slice of the positive document through the momentum encoder $\phi ^ { \prime }$ . 3
|
| 129 |
+
|
| 130 |
+
Hard Negative Mining. It has been shown that the difficulty of the negative samples used for contrastive training can strongly influence model success (Wu et al., 2020). We therefore automatically mine hard negative samples during training. For the permuted document task, we can take advantage of the fact that the negative sample space can be huge; for a document with $n$ sentences, the candidate pool of permutations has $n ! - 1$ incoherent documents from which we can mine hard negatives. For the problem of dense text retrieval, Xiong et al. (2020) find global hard negatives by computing document encodings using a recent checkpoint to build an asynchronous index of the entire corpus, and sampling negative documents from the index. However, the huge candidate pool for permuted documents also makes it infeasible to mine global negatives in our case.
|
| 131 |
+
|
| 132 |
+
Instead, we perform local negative sample ranking. For each positive instance in the training data, we sample a larger number of permuted documents $( h )$ per instance than we need for training (i.e., $h > N ,$ ). We score these negative documents using the model updated thus far and use the highest ranking negative documents for training. Specifically, the model is first trained with $x$ instances ( $\scriptstyle { \dot { x } }$ is a hyperparameter) of data, by using 5 negative samples randomly chosen out of $h$ . The updated model is then used to score all the $h$ negative samples each for another set of $x$ instances from the training data. The scores of the $h$ negative samples are ranked and the top scoring 5 negative samples for each instance are used to train the model for the next $x$ gradient steps. This process is repeated throughout training; the model therefore iteratively mines harder and harder negative samples as it improves. See Algorithm 1 in Appendix A.2 for the pseudocode.
|
| 133 |
+
|
| 134 |
+
We use the hard negative training in combination with the momentum encoder since we find that using hard negative samples directly leads to instability in model training (see $\ S 4$ ). The global negatives queue $Q$ is thus also constructed from the mined hard negative samples used for training. Our model is therefore trained to rely not only on comparative coherence cues from the traditional permuted document setup, but also to recognize more independent cues for coherence through the global queue, which is additionally enhanced by incorporating length invariance and automatically mined hard negative samples.
|
| 135 |
+
|
| 136 |
+
Training. We train the model with the same training data, this time sampling $h = 5 0$ negatives4 per instance for hard negative ranking, and setting the training steps (or instances) $x = 2 0 0$ . We use a queue size of $l = 1 0 0 0$ and set our momentum coefficient $\mu = 0 . 9 9 9 9 9 9 9$ , with loss weighting parameter $\lambda = 0 . 8 5$ . Due to GPU memory constraints (24GB, Quadro RTX 6000), we train our model with a batch size of 1. See Appendix A.4 for the full set of hyperparameters.
|
| 137 |
+
|
| 138 |
+
Results. The results in Table 1 (last row) show that our momentum encoder model with hard negative mining outperforms all previous models across the independent testsets. This improvement comes despite a very similar performance on the WSJ test set; we believe that our model truly improves in generalizability without overfitting to the permuted document task. The improvements on the out-of-domain test sets, particularly on LMVLM and STORYCLOZE, support this conclusion.
|
| 139 |
+
|
| 140 |
+
# 4 ANALYSIS
|
| 141 |
+
|
| 142 |
+
# 4.1 HARD NEGATIVE TRAINING WITH MOMENTUM MODEL
|
| 143 |
+
|
| 144 |
+
We only train our complete model (i.e., base contrastive plus momentum model) by mining hard negative samples $( \ S 3 . 4 )$ , because we find that training the base contrastive model directly with hard negatives leads to instability during training. Figure 2a plots development set accuracies of our base model trained with and without hard negative mining, and our complete model trained with hard negative mining (evaluated every 1000 steps). As seen in the figure, the contrastive model displays significant volatility when trained with hard negatives only, while the complete model is quite stable. This is inline with the finding of Xuan et al. (2020) who show that training with the hardest negative samples leads to bad local minima. This can be explained with the gradient analysis of such negatives which have a larger gradient norm (Xiong et al., 2020), resulting in abrupt gradient steps. The momentum encoder being a temporal ensemble of the base models has a regularizing effect, addressing this issue and leading to stable and improved results (see $\ S 3 . 4 \AA$ .
|
| 145 |
+
|
| 146 |
+
# 4.2 EFFECTS OF HYPERPARAMETERS
|
| 147 |
+
|
| 148 |
+
Number of Ranked Negatives. Figure 2b shows the results across the test sets for different numbers of negative samples considered for ranking $( h )$ during hard negative mining. We see that increasing the number of negatives considered improves results across the board, with results on out-of-domain test sets LMVLM and STORYCLOZE showing particular improvement.
|
| 149 |
+
|
| 150 |
+
Momentum Coefficient. Figure 2c shows the variation in the model performance across the test sets for different values of the momentum coefficient $\mu$ . We see that apart from a slight drop on the INSTED-WIKI dataset at $\mu = 0 . 9 9 9 9 9 9 9$ , overall an increasing $\mu$ value leads to better generalization on the independent test sets, presumably due to a more consistent global negative queue.
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
Figure 2: (a) A plot of the development accuracy during training our contrastive model with and without hard negative mining, and our complete model with hard negative mining. The accuracies are evaluated after every 1000 gradient steps. (b) Results on the various test sets for our model trained with hard negative mining by sampling different number of negatives $( h )$ for ranking. (c) Results on the various test sets for our complete model trained with different momentum coefficient $( \mu )$ values. (d) Results on the various test sets for our model trained with different global queue $\ b { Q }$ sizes. Please note that the agreement values for LMVLM test set have been scaled by a factor of 100 to facilitate visualization in figures (b), (c) and (d).
|
| 154 |
+
|
| 155 |
+
Queue Size. Figure 2d shows the variation in model performance across different test sets for various sizes of the global negative queue $Q$ . We see that while increasing the queue size generally leads to an improvement in scores, at high queue sizes the improvement is limited to test sets from the same domain (WSJ, SUMMEVAL and INSTED-CNN), and the model’s generalizability is affected.
|
| 156 |
+
|
| 157 |
+
# 4.3 EFFECTS OF VARYING TASK & DATASET
|
| 158 |
+
|
| 159 |
+
So far, we have reported the results of training our model on the permuted document task using documents from the WSJ corpus as was done by most prior work (Elsner & Charniak, 2011; Moon et al., 2019). We now test the effectiveness of other datasets, both by varying the task itself and by using a different dataset for the permuted document task.
|
| 160 |
+
|
| 161 |
+
Sentence Intrusion. As described in $\ S 2 . 3$ , Shen et al. (2021) propose a sentence intrusion task to test coherence modeling capabilities of pre-trained language models. We adapt their dataset to the pairwise setting by pairing the original coherent document (positive) with the corrupted (negative) document; setting aside $10 \%$ of the data for development gives us 25,852 positive-negative training pairs for INSTED-CNN and 41,135 pairs for INSTED-WIKI. We train our pairwise (§3.2) model on this task. From the results in Table 2 (first two rows), we see that the performance on the same domain/task (as the training) and the performance on the LMVLM dataset is high, but the models trained on this task generalize poorly to the other independent test sets.
|
| 162 |
+
|
| 163 |
+
Permuted Document Task with INSTED We now train our model on the permuted document task using the INSTED datasets. We generate 52,607 and 66,679 positive-negative pairs for INSTED-CNN and INSTED-WIKI respectively by sampling permutations, similar to our training data (see $\ S 2 . 1$ ), and train our pairwise model with this data. The results are shown in Table 2, highlighted in blue. Specifically for machine generated texts, the sentence intrusion task training does better on the LMVLM dataset. On the other hand, the permuted document task training does better on SUMMEVAL. This could be because the documents in SUMMEVAL are summaries of the same source article and therefore similar in content (detecting incoherence through permutations might help here), while the text generated by language models even for the same prompt tends to differ in content more significantly (detecting intruder sentences might help here). Additionally, the performance of our WSJ model on the INSTED-CNN and INSTED-WIKI datasets is comparable to the performance of the respective in-domain pairwise models, while outperforming both the other models on the STORYCLOZE dataset. Overall, the WSJ model generalizes well.
|
| 164 |
+
|
| 165 |
+
Table 2: Results on the WSJ permuted document test set and other independent test sets on the pairwise and contrastive models trained on different datasets. All results are averaged over 5 runs with different seeds.
|
| 166 |
+
|
| 167 |
+
<table><tr><td>Train Dataset</td><td>Neg.Type</td><td>Model</td><td>WSJ</td><td>SUMMEVAL</td><td>LMvLM</td><td>INSTED-CNN|</td><td>INSTED-WIKI</td><td>STORYCLOZE</td></tr><tr><td>INSTED-WIKI</td><td>Intrusion</td><td>Pairwise</td><td>95.24±0.37</td><td>53.03±1.49</td><td>0.490±0.01</td><td>94.07±0.29</td><td>82.01±0.24</td><td>64.21±1.98</td></tr><tr><td>INSTED-CNN</td><td>Intrusion</td><td>Pairwise</td><td>95.48±0.47</td><td>57.85±2.47</td><td>0.502±0.01</td><td>97.83±0.15</td><td>73.52±1.17</td><td>71.75±1.81</td></tr><tr><td> INSTED-WIKI</td><td>Permuted</td><td>Pairwise</td><td>96.89±0.23</td><td>64.53±0.82</td><td>0.491±0.01</td><td>84.17±1.50</td><td>71.35±0.88</td><td>69.09±2.29</td></tr><tr><td>INSTED-CNN</td><td>Permuted</td><td>Pairwise</td><td>97.03±0.12</td><td>66.63±0.97</td><td>0.483±0.01</td><td>92.61±0.62</td><td>69.88±0.64</td><td>68.95±1.02</td></tr><tr><td>WSJ</td><td>Permuted</td><td>Pairwise</td><td>98.23±0.20</td><td>64.83±1.03</td><td>0.458±0.02</td><td>91.96±1.09</td><td>70.85±1.85</td><td>71.84±2.33</td></tr></table>
|
| 168 |
+
|
| 169 |
+
Table 3: Accuracies of the best performing UNC and our full model on the hand-crafted linguistic probe dataset constructed by Shen et al. (2021). Examples (abridged for brevity) shown indicate the manual changes made to make the text incoherent; the original words are shown in blue while the modified/added words are shown in red. Checks $( \pmb { \nu } )$ indicate our model correctly scored the coherent text higher for that example, while crosses $( { \pmb x } )$ indicate that our model failed to do so.
|
| 170 |
+
|
| 171 |
+
<table><tr><td>Linguistic Probe</td><td>UNC</td><td>Our</td><td></td><td>Example</td></tr><tr><td>Pronoun Animacy Downgrade</td><td>76.0</td><td>100.0</td><td></td><td>She→It was the mother of twins Lakshmana and Shatrughna.</td></tr><tr><td>Pronoun Animacy Upgrade</td><td>63.0</td><td>100.0</td><td>:</td><td>It→She has been collected in two tankobon volumes.</td></tr><tr><td>Pronoun Gender Flip</td><td>55.0</td><td>100.0</td><td></td><td>She→He is also well known for her-→his role as Mary, the mother of Jesus.</td></tr><tr><td>Past to Future Flip</td><td>86.0</td><td>96.0</td><td>X</td><td>The Danes finished-→willfinish first in the 2O14 World Junior Hockey Championship.</td></tr><tr><td>Single Determiner Flip</td><td>62.1</td><td>83.2</td><td>X</td><td>In 1969, he was again sold, this→these time to the Milwaukee Bucks.</td></tr><tr><td>Number</td><td>58.0</td><td>80.0</td><td>X</td><td>He had a career record of 67→6.7wins and 62→-6.2 losses.</td></tr><tr><td>Conjunction Flip</td><td>55.0</td><td>78.0</td><td>X</td><td>The school was founded in 19O8,and→but has been a non-profit organization since 1956.</td></tr><tr><td>Negation</td><td>60.0</td><td>78.0</td><td>X</td><td>He was not named as the Australian squad captain and was not captain of the Wallabies.</td></tr></table>
|
| 172 |
+
|
| 173 |
+
# 4.4 LINGUISTIC PROBE ANALYSIS
|
| 174 |
+
|
| 175 |
+
Shen et al. (2021) create eight hand-crafted linguistic probe test sets by manually modifying words in coherent texts based on various linguistic phenomena, ensuring that the incoherent text produced as a result remains syntactically correct. Except for the words targeted by the probe, the rest of the text remains identical. Each test set has 100 samples each.5
|
| 176 |
+
|
| 177 |
+
We evaluate the best performing UNC and our full models on these test sets. The results are shown in Table 3 along with some examples from the dataset. The UNC model has the most success with the tense agreement test set and mixed success on the pronoun test sets. We see that our model has perfect accuracy on all pronoun-related test sets and near-perfect accuracy on the tense agreement test set. This shows that our model is indeed capturing the discourse-level phenomena that constitute coherence. Where our model falters is in cases which may require commonsense knowledge, such as identifying that $6 . 7$ wins is not possible. Overall, our model is quite successful in detecting several kinds of incoherence.
|
| 178 |
+
|
| 179 |
+
# 5 CONCLUSION
|
| 180 |
+
|
| 181 |
+
With the goal of making our coherence model generalizable and useful for off-the-shelf evaluations, in this work we have explored self-supervision objectives to improve coherence models without adapting our model architecture to a specific training task like previous work. We upgrade the self-supervision objective from the existing pairwise ranking paradigm to a contrastive learning setup. We further enhance this model with a momentum encoder to maintain a large global queue of negative samples, and also perform hard negative mining to refine the quality of the negative samples. We show empirically that increasing the ratio and quality of negative samples improves the generalizability of the coherence model. We also test our model on a wide-ranging collection of independent test sets that resemble downstream applications, including machine generated text, on which our model significantly outperforms the previous SOTA model. Our work thus also sets a new evaluation standard for future research in coherence modeling. We will open source our code base to encourage research in a new paradigm of coherence modeling.
|
| 182 |
+
|
| 183 |
+
# REPRODUCIBILITY STATEMENT
|
| 184 |
+
|
| 185 |
+
CODE AND HYPERPARAMETERS
|
| 186 |
+
|
| 187 |
+
Code for the various models will be open-sourced. Specific hyperparameters used for experiments are described in $\ S 3 . 3$ and $\ S 3 . 4$ , while a full list of hyperparameters is included in Appendix A.4.
|
| 188 |
+
|
| 189 |
+
# DATA
|
| 190 |
+
|
| 191 |
+
A description of the data pre-processing is provided in $\ S 2 . 1$ . Datasets that we created will be opensourced. In the case of the WSJ dataset, the data is licensed for use only to members by the Linguistic Data Consortium. Consequently, we only release scripts to generate the data we use and not the data itself. We highlight however that the permuted document self-supervision task that we train on is independent of the dataset used and the task can be reproduced on any other corpus; see also $\ S 4 . 3$ . All other datasets we use are licensed freely for academic use.
|
| 192 |
+
|
| 193 |
+
# ETHICS STATEMENT
|
| 194 |
+
|
| 195 |
+
# ANNOTATION OF LMVLM DATASET
|
| 196 |
+
|
| 197 |
+
We conduct a user study to collect pairwise coherence judgments on our language model output dataset. As part of our crowd-sourced user study on Amazon Mechanical Turk to collect these coherence judgements, we do not collect any personal information from the participants. Based on the average time spent to perform the tasks, participants were paid the equivalent of 16 USD per hour for their work. The annotation instructions and interface provided to the participants are included in Appendix A.3.
|
| 198 |
+
|
| 199 |
+
One potential issue is that the language model output that we generate from prompts may lead to malicious text generation by the models. We flagged the task to warn the workers that there may be potentially offensive content, and manually checked the final dataset post curation.
|
| 200 |
+
|
| 201 |
+
# REFERENCES
|
| 202 |
+
|
| 203 |
+
Tushar Abhishek, Daksh Rawat, Manish Gupta, and Vasudeva Varma. Transformer models for text coherence assessment. ArXiv, abs/2109.02176, 2021.
|
| 204 |
+
|
| 205 |
+
Sanjeev Arora, Hrishikesh Khandeparkar, Mikhail Khodak, Orestis Plevrakis, and Nikunj Saunshi. A theoretical analysis of contrastive unsupervised representation learning. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 5628–5637. PMLR, 09–15 Jun 2019. URL http://proceedings.mlr.press/v97/saunshi19a.html.
|
| 206 |
+
|
| 207 |
+
R. Barzilay and Mirella Lapata. Modeling local coherence: An entity-based approach. Computational Linguistics, 34:1–34, 2008.
|
| 208 |
+
|
| 209 |
+
Regina Barzilay and Mirella Lapata. Modeling local coherence: An entity-based approach. In Proceedings of the 43rd Annual Meeting on Association for Computational Linguistics, ACL $^ { , } 0 5$ , pp. 141–148, Ann Arbor, Michigan, 2005. Association for Computational Linguistics.
|
| 210 |
+
|
| 211 |
+
T. Brown, B. Mann, Nick Ryder, Melanie Subbiah, J. Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, G. Kruger, T. Henighan, R. Child, Aditya Ramesh, D. Ziegler, Jeffrey Wu, Clemens Winter, ¨ Christopher Hesse, Mark Chen, E. Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, J. Clark, Christopher Berner, Sam McCandlish, A. Radford, Ilya Sutskever, and Dario Amodei. Language models are few-shot learners. ArXiv, abs/2005.14165, 2020.
|
| 212 |
+
|
| 213 |
+
Asli Celikyilmaz, Antoine Bosselut, Xiaodong He, and Yejin Choi. Deep communicating agents for abstractive summarization. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume
|
| 214 |
+
|
| 215 |
+
1 (Long Papers), pp. 1662–1675, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. doi: 10.18653/v1/N18-1150. URL https://www.aclweb.org/ anthology/N18-1150.
|
| 216 |
+
|
| 217 |
+
Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey E. Hinton. A simple framework for contrastive learning of visual representations. ArXiv, abs/2002.05709, 2020.
|
| 218 |
+
|
| 219 |
+
Ronan Collobert, Jason Weston, Leon Bottou, Michael Karlen, Koray Kavukcuoglu, and Pavel ´ Kuksa. Natural language processing (almost) from scratch. The Journal of Machine Learning Research, 12:2493–2537, 2011.
|
| 220 |
+
|
| 221 |
+
Zihang Dai, Z. Yang, Yiming Yang, J. Carbonell, Quoc V. Le, and R. Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. In ACL, 2019.
|
| 222 |
+
|
| 223 |
+
Micha Elsner and Eugene Charniak. Extending the entity grid with entity-specific features. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies: Short Papers - Volume 2, HLT ’11, pp. 125–129, Portland, Oregon, 2011. Association for Computational Linguistics.
|
| 224 |
+
|
| 225 |
+
Alexander R Fabbri, Wojciech Krysci ´ nski, Bryan McCann, Caiming Xiong, Richard Socher, ´ and Dragomir Radev. Summeval: Re-evaluating summarization evaluation. arXiv preprint arXiv:2007.12626, 2020.
|
| 226 |
+
|
| 227 |
+
Angela Fan, Mike Lewis, and Yann Dauphin. Hierarchical neural story generation. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 889–898, Melbourne, Australia, July 2018. Association for Computational Linguistics. doi: 10.18653/v1/P18-1082. URL https://www.aclweb.org/anthology/P18-1082.
|
| 228 |
+
|
| 229 |
+
Vanessa Wei Feng and Graeme Hirst. Extending the entity-based coherence model with multiple ranks. In Proceedings of the 13th Conference of the European Chapter of the Association for Computational Linguistics, EACL ’12, pp. 315–324, Avignon, France, 2012. Association for Computational Linguistics.
|
| 230 |
+
|
| 231 |
+
Vanessa Wei Feng, Ziheng Lin, and Graeme Hirst. The impact of deep hierarchical discourse structures in the evaluation of text coherence. In COLING, 2014.
|
| 232 |
+
|
| 233 |
+
B. Grosz and C. Sidner. Attention, intentions, and the structure of discourse. Comput. Linguistics, 12:175–204, 1986.
|
| 234 |
+
|
| 235 |
+
B. Grosz, A. Joshi, and S. Weinstein. Centering: A framework for modeling the local coherence of discourse. Comput. Linguistics, 21:203–225, 1995.
|
| 236 |
+
|
| 237 |
+
Michael Gutmann and Aapo Hyvarinen. Noise-contrastive estimation: A new estimation principle ¨ for unnormalized statistical models. In Yee Whye Teh and Mike Titterington (eds.), Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, volume 9 of Proceedings of Machine Learning Research, pp. 297–304, Chia Laguna Resort, Sardinia, Italy, 13–15 May 2010. PMLR. URL http://proceedings.mlr.press/v9/gutmann10a. html.
|
| 238 |
+
|
| 239 |
+
Michael Halliday and Ruqaiya Hasan. Cohesion in English, chapter xx. Longman, London, 1976.
|
| 240 |
+
|
| 241 |
+
Hany Hassan, Anthony Aue, Chang Chen, Vishal Chowdhary, Jonathan R. Clark, Christian Federmann, Xuedong Huang, Marcin Junczys-Dowmunt, William Lewis, Mu Li, Shujie Liu, T. M. Liu, Renqian Luo, Arul Menezes, Tao Qin, Frank Seide, Xu Tan, Fei Tian, Lijun Wu, Shuangzhi Wu, Yingce Xia, Dongdong Zhang, Zhirui Zhang, and Ming Zhou. Achieving human parity on automatic chinese to english news translation. ArXiv, abs/1803.05567, 2018.
|
| 242 |
+
|
| 243 |
+
Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. arXiv preprint arXiv:1911.05722, 2019.
|
| 244 |
+
|
| 245 |
+
K. Hermann, Tomas Kocisk ´ y, Edward Grefenstette, Lasse Espeholt, W. Kay, Mustafa Suleyman, ´ and P. Blunsom. Teaching machines to read and comprehend. In NIPS, 2015.
|
| 246 |
+
|
| 247 |
+
Ehsan Hosseini-Asl, Bryan McCann, Chien-Sheng Wu, Semih Yavuz, and Richard Socher. A simple language model for task-oriented dialogue, 2020.
|
| 248 |
+
|
| 249 |
+
Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis, Ledell Yu Wu, Sergey Edunov, Danqi ˘ Chen, and Wen tau Yih. Dense passage retrieval for open-domain question answering. ArXiv, abs/2004.04906, 2020.
|
| 250 |
+
|
| 251 |
+
K. Krippendorff. Computing krippendorff’s alpha-reliability. 2011.
|
| 252 |
+
|
| 253 |
+
Samuel Laubli, Rico Sennrich, and Martin Volk. Has machine translation achieved human parity? a ¨ case for document-level evaluation. In EMNLP, 2018.
|
| 254 |
+
|
| 255 |
+
Jiwei Li and Dan Jurafsky. Neural net models of open-domain discourse coherence. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pp. 198–209, Copenhagen, Denmark, September 2017. Association for Computational Linguistics.
|
| 256 |
+
|
| 257 |
+
Ziheng Lin, Hwee Tou $\mathrm { N g }$ , and Min-Yen Kan. Automatically evaluating text coherence using discourse relations. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies - Volume 1, HLT ’11, pp. 997–1006, Portland, Oregon, 2011. Association for Computational Linguistics.
|
| 258 |
+
|
| 259 |
+
Linqing Liu, Yao Lu, Min Yang, Qiang Qu, Jia Zhu, and Hongyan Li. Generative adversarial network for abstractive text summarization. ArXiv, abs/1711.09357, 2017.
|
| 260 |
+
|
| 261 |
+
Mohsen Mesgar and Michael Strube. A neural local coherence model for text quality assessment. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 4328–4339, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/D18-1464.
|
| 262 |
+
|
| 263 |
+
Muhammad Tasnim Mohiuddin, Shafiq Joty, and Dat Tien Nguyen. Coherence modeling of asynchronous conversations: A neural entity grid approach. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 558–568, Melbourne, Australia, July 2018. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/P18-1052.
|
| 264 |
+
|
| 265 |
+
Tasnim Mohiuddin, Prathyusha Jwalapuram, Xiang Lin, and Shafiq Joty. Rethinking coherence modeling: Synthetic vs. downstream tasks. In Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume, pp. 3528–3539, Online, April 2021. Association for Computational Linguistics. URL https://www.aclweb.org/ anthology/2021.eacl-main.308.
|
| 266 |
+
|
| 267 |
+
Han Cheol Moon, Tasnim Mohiuddin, Shafiq R. Joty, and Xiaofei Chi. A unified neural coherence model. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing, pp. 2262–2272, 2019. URL https://www.aclweb.org/anthology/D19-1231.pdf.
|
| 268 |
+
|
| 269 |
+
Dat Nguyen and Shafiq Joty. A neural local coherence model. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1320–1330. Association for Computational Linguistics, 2017. doi: 10.18653/v1/P17-1121. URL http://www.aclweb.org/anthology/P17-1121.
|
| 270 |
+
|
| 271 |
+
Romain Paulus, Caiming Xiong, and R. Socher. A deep reinforced model for abstractive summarization. ArXiv, abs/1705.04304, 2018.
|
| 272 |
+
|
| 273 |
+
Matthew E. Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer. Deep contextualized word representations. In Proc. of NAACL, 2018.
|
| 274 |
+
|
| 275 |
+
L. Pishdad, Federico Fancellu, Ran Zhang, and A. Fazly. How coherent are neural models of coherence? In COLING, 2020.
|
| 276 |
+
|
| 277 |
+
M. Popel, M. Tomkova, J. Tomek, Łukasz Kaiser, Jakob Uszkoreit, Ondrej Bojar, and Z. ´ Zabokrtsk ˇ y.´ Transforming machine translation: a deep learning system reaches news translation quality comparable to human professionals. Nature Communications, 11, 2020.
|
| 278 |
+
|
| 279 |
+
Alec Radford, Jeffrey Wu, Dario Amodei, Daniela Amodei, Jack Clark, Miles Brundage, and Ilya Sutskever. Better language models and their implications. OpenAI Blog, 2019. URL https: //openai.com/blog/better-language-models/.
|
| 280 |
+
|
| 281 |
+
Ehud Reiter. A structured review of the validity of BLEU. Computational Linguistics, 44(3):393– 401, 2018.
|
| 282 |
+
|
| 283 |
+
Eva Sharma, Luyang Huang, Zhe Hu, and Lu Wang. An entity-driven framework for abstractive summarization. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 3271–3282, 2019.
|
| 284 |
+
|
| 285 |
+
Rishi Sharma, J. Allen, Omid Bakhshandeh, and N. Mostafazadeh. Tackling the story ending biases in the story cloze test. In ACL, 2018.
|
| 286 |
+
|
| 287 |
+
Aili Shen, Meladel Mistica, Bahar Salehi, Hang Li, Timothy Baldwin, and Jianzhong Qi. Evaluating Document Coherence Modeling. Transactions of the Association for Computational Linguistics, 9:621–640, 07 2021. ISSN 2307-387X. doi: 10.1162/tacl a 00388. URL https://doi.org/ 10.1162/tacl_a_00388.
|
| 288 |
+
|
| 289 |
+
Aaron van den Oord, Y. Li, and Oriol Vinyals. Representation learning with contrastive predictive ¨ coding. ArXiv, abs/1807.03748, 2018.
|
| 290 |
+
|
| 291 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin. Attention is all you need. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. URL https://proceedings.neurips.cc/paper/2017/file/ 3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf.
|
| 292 |
+
|
| 293 |
+
M. Wu, Chengxu Zhuang, M. Mosse, D. Yamins, and Noah D. Goodman. On mutual information in contrastive learning for visual representations. ArXiv, abs/2005.13149, 2020.
|
| 294 |
+
|
| 295 |
+
Lee Xiong, Chenyan Xiong, Ye Li, Kwok-Fung Tang, Jialin Liu, Paul N. Bennett, Junaid Ahmed, and Arnold Overwijk. Approximate nearest neighbor negative contrastive learning for dense text retrieval. ICLR, abs/2007.00808, 2020.
|
| 296 |
+
|
| 297 |
+
Peng Xu, Hamidreza Saghir, Jin Sung Kang, Teng Long, Avishek Joey Bose, Yanshuai Cao, and Jackie Chi Kit Cheung. A cross-domain transferable neural coherence model. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 678–687, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1067.
|
| 298 |
+
|
| 299 |
+
Hong Xuan, Abby Stylianou, Xiaotong Liu, and Robert Pless. Hard negative examples are hard, but useful. In ECCV, 2020.
|
| 300 |
+
|
| 301 |
+
Z. Yang, Zihang Dai, Yiming Yang, J. Carbonell, R. Salakhutdinov, and Quoc V. Le. Xlnet: Generalized autoregressive pretraining for language understanding. In NeurIPS, 2019.
|
| 302 |
+
|
| 303 |
+
Yizhe Zhang, Siqi Sun, Michel Galley, Yen-Chun Chen, Chris Brockett, Xiang Gao, Jianfeng Gao, Jingjing Liu, and Bill Dolan. Dialogpt: Large-scale generative pre-training for conversational response generation. In ACL, system demonstration, 2020.
|
| 304 |
+
|
| 305 |
+
# A APPENDIX
|
| 306 |
+
|
| 307 |
+
# A.1 WSJ PERMUTED DOCUMENT TASK
|
| 308 |
+
|
| 309 |
+
The examples for the permuted document task on the WSJ data are shown in Table 4.
|
| 310 |
+
|
| 311 |
+
A.2 HARD NEGATIVE RANKING PSEUDOCODE
|
| 312 |
+
|
| 313 |
+
The pseudocode for our hard negative mining through local sample ranking is given in Algorithm 1.
|
| 314 |
+
|
| 315 |
+
Table 4: Examples showing the original coherent document and the incoherent document created by permuting the sentences of the original. Text taken from WSJ-1778.
|
| 316 |
+
|
| 317 |
+
<table><tr><td></td><td>Original Document</td></tr><tr><td>to my feet.</td><td>(S1)Judy and I were in our back yard when the lawn started rolling like ocean waves. (S2)We ran into the house to get Mame,but the next tremor threw me in the air and bounced meas Itried to get</td></tr><tr><td></td><td>(S3) We are all fine here,although Mame was extremely freaked. (S4) Books and tapes all over my room.</td></tr><tr><td></td><td>(S5) Not one thing in the house is where it is supposed to be,but the structure is fine.</td></tr><tr><td></td><td>Permuted Document</td></tr><tr><td></td><td>(S4) Books and tapes all over my room.</td></tr><tr><td></td><td>(S3) We are all fine here,although Mame was extremely freaked.</td></tr><tr><td></td><td>(S2)Weran into the house to get Mame,but the next tremor threw me in the air and bounced meas Itried to get</td></tr><tr><td></td><td>to my feet.</td></tr><tr><td></td><td>(S5) Not one thing in the house is where it is supposed to be,but the structure is fine.</td></tr><tr><td></td><td>(S1) Judy and I were in our back yard when the lawn started rolling like ocean waves.</td></tr></table>
|
| 318 |
+
|
| 319 |
+
# Algorithm 1 Local Negative Sample Ranking
|
| 320 |
+
|
| 321 |
+
Require: Training data $D$ in which each instance consists of a positive document and $h$ negative
|
| 322 |
+
documents, model $\theta$
|
| 323 |
+
1: Initialize empty hard negative array $\hat { D } ^ { - }$ for each instance $\in { \cal D }$
|
| 324 |
+
2: procedure HARDNEGATIVERANKING $( \theta , D )$
|
| 325 |
+
3: Partition the dataset into sets of $x$ instances $D _ { 1 } \ldots D _ { r }$
|
| 326 |
+
4: for $i = 1 \dots r$ do
|
| 327 |
+
5: if $\scriptstyle \mathrm { i } = = 0$ then . No hard negatives for first iteration
|
| 328 |
+
6: for $j = 1 \ldots x$ do
|
| 329 |
+
7: Randomly sample N negatives from D−(i,j) and store in Dˆ −(i,j)
|
| 330 |
+
8: Train $\theta$ with $( D _ { i } ^ { + } , \hat { D } _ { i } ^ { - } )$
|
| 331 |
+
9: for $j = 1 \ldots x$ do
|
| 332 |
+
10: Score all the h negative documents in D−(i+1,j)
|
| 333 |
+
11: Sort D−(i+1,j) in descending order of scores
|
| 334 |
+
12: Get $N$ top scoring negative documents and store in $\hat { D } _ { ( i + 1 , j ) } ^ { - }$
|
| 335 |
+
13: . Store hard negatives for the next iteration
|
| 336 |
+
|
| 337 |
+
# A.3 LMVLM USER STUDY
|
| 338 |
+
|
| 339 |
+
The instructions and the interface provided to the workers in the user study comparing pairs of language model outputs is given in Figure 3. Workers were restricted to the native English speaking regions of Canada, United Kingdom and the United States and could only participate in our task if they had completed $> 1 0$ , 000 HITs with $\mathrm { a > 9 8 \% }$ acceptance rate. Each task was estimated to take 2 minutes, and workers were paid the equivalent of 16 USD per hour.
|
| 340 |
+
|
| 341 |
+
# A.4 HYPERPARAMETERS
|
| 342 |
+
|
| 343 |
+
The hyperparameters used in our experiments are given in Table 5.
|
| 344 |
+
|
| 345 |
+
# A.5 COMPARISON OF EXISTING STATE-OF-THE-ART COHERENCE MODELS
|
| 346 |
+
|
| 347 |
+
We report the results obtained by Mohiuddin et al. (2021) and Pishdad et al. (2020) on their evaluation tasks for SOTA neural coherence models in Table 6.
|
| 348 |
+
|
| 349 |
+
For example, consider:
|
| 350 |
+
|
| 351 |
+
a. Jane took a train from Paris to Istanbul. She had to attend a conference.
|
| 352 |
+
|
| 353 |
+
This is an example of a coherent text. Here, the second sentence gives a reason for Jane's action in the first sentence
|
| 354 |
+
|
| 355 |
+
b. John took a train from Paris to Istanbul. He hates spinach.
|
| 356 |
+
|
| 357 |
+
toconvey.
|
| 358 |
+
|
| 359 |
+
other indicationofcoherence in texts is whenatextisconsistentlytalkingabout someone orsomething.Consider this example:
|
| 360 |
+
|
| 361 |
+
bought was hard to get up to that floor.
|
| 362 |
+
|
| 363 |
+
eeii
|
| 364 |
+
|
| 365 |
+
I whichtexoutfthtoiventextsisoreceentasedoneeplaatioofohreceprovdedtoundtheeealalttet
|
| 366 |
+
|
| 367 |
+
option sparingly, and only if there is absolutely no diffrence in coherence between the two texts.
|
| 368 |
+
|
| 369 |
+

|
| 370 |
+
Figure 3: Instructions and study interface for the user study conducted on language model outputs.
|
| 371 |
+
|
| 372 |
+
Table 5: Configuration parameters for training
|
| 373 |
+
|
| 374 |
+
<table><tr><td>Parameters</td><td>Values</td></tr><tr><td colspan="2">Margin-based Pairwise Ranking</td></tr><tr><td>- margin - optimizer</td><td>0.1 AdamW</td></tr><tr><td>- scheduler</td><td>SWALR</td></tr><tr><td>- learning rate - annealed to</td><td>5e-6</td></tr><tr><td>- anneal rate</td><td>1e-6</td></tr><tr><td></td><td>5000 steps</td></tr><tr><td>- batch-size</td><td>1</td></tr><tr><td>- XLNet model</td><td>base</td></tr><tr><td>- dimension size</td><td>768</td></tr><tr><td colspan="2">Contrastive Learning</td></tr><tr><td>- margin</td><td>0.1</td></tr><tr><td>- optimizer</td><td>AdamW</td></tr><tr><td>- scheduler</td><td>SWALR</td></tr><tr><td>- learning rate</td><td>5e-6</td></tr><tr><td>- annealed to</td><td>1e-6</td></tr><tr><td>- anneal rate</td><td>5000 steps</td></tr><tr><td>- batch-size</td><td>1</td></tr><tr><td>- XLNet model</td><td>base</td></tr><tr><td>- dimension size</td><td>768</td></tr><tr><td colspan="2">Momentum Encoder with Hard Negative Mining</td></tr><tr><td>- margin</td><td>0.1</td></tr><tr><td>- optimizer</td><td>AdamW</td></tr><tr><td>- scheduler</td><td>SWALR</td></tr><tr><td>- learning rate</td><td>5e-6</td></tr><tr><td>- annealed to</td><td>1e-6</td></tr><tr><td>- anneal rate</td><td>1000 steps</td></tr><tr><td>- batch-size</td><td>1</td></tr><tr><td>- XLNet model</td><td>base</td></tr><tr><td>- dimension size</td><td>768</td></tr></table>
|
| 375 |
+
|
| 376 |
+
Table 6: Results reported by Mohiuddin et al. (2021) and Pishdad et al. (2020) on various tasks and datasets that compare the UNC model to two other SOTA neural coherence models proposed by $\mathrm { X u }$ et al. (2019) and Mesgar & Strube (2018). Except those marked by (Agr.) which report agreement with humans, all other tasks report accuracies. We only include tasks that directly test discourse coherence phenomena.
|
| 377 |
+
|
| 378 |
+
<table><tr><td colspan="4">As reported by Pishdad et al. (2020)</td></tr><tr><td>Task</td><td>Dataset</td><td>UNC</td><td>Mesgar & Strube (2018)</td></tr><tr><td>Permuted Document</td><td>Visual Storytelling</td><td>88.42</td><td>82.25</td></tr><tr><td>Permuted Document</td><td>ROCStories</td><td>94.80</td><td>89.55</td></tr><tr><td>Permuted Document</td><td>Dialogue</td><td>97.21</td><td>90.79</td></tr><tr><td>Permuted Document</td><td>HellaSwag</td><td>83.92</td><td>69.38</td></tr><tr><td>Permuted Document</td><td>PDTB</td><td>92.85</td><td>61.96</td></tr><tr><td>Connective Substitution</td><td>PDTB</td><td>96.46</td><td>84.99</td></tr><tr><td>Topic Switching</td><td>Visual Storytelling</td><td>92.10</td><td>64.81</td></tr><tr><td>Topic Switching</td><td>ROCStories</td><td>94.62</td><td>67.85</td></tr><tr><td>Topic Switching</td><td>Dialogue</td><td>71.74</td><td>68.41</td></tr><tr><td>Topic Switching</td><td>PDTB</td><td>70.89</td><td>52.33</td></tr><tr><td colspan="4">As reported by Mohiuddin et al. (2021)</td></tr><tr><td>Task</td><td>Dataset</td><td>UNC</td><td>Xu et al. (2019)</td></tr><tr><td>Permuted Document</td><td>WSJ</td><td>93.19</td><td>91.77</td></tr><tr><td>Abstractive Summarization (Agr.)</td><td>CNN</td><td>0.68</td><td>0.55</td></tr><tr><td>Extractive Summarization (Agr.)</td><td>DUC</td><td>0.35</td><td>0.38</td></tr><tr><td>Machine Translation (Agr.)</td><td>WMT</td><td>0.77</td><td>0.78</td></tr><tr><td>(Trained) Machine Translation (Agr.)</td><td>WMT</td><td>0.83</td><td>0.75</td></tr></table>
|
md/dev/hQwb-lbM6EL/hQwb-lbM6EL.md
ADDED
|
@@ -0,0 +1,550 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# INCODER: A GENERATIVE MODEL FOR CODE INFILLING AND SYNTHESIS
|
| 2 |
+
|
| 3 |
+
Daniel Fried∗♡†♢ Armen Aghajanyan∗♡ Jessy Lin Sida Wang♡ Eric Wallace♣ Freda Shi△ Ruiqi Zhong Wen-tau Yih♡ Luke Zettlemoyer♡† Mike Lewis♡ Facebook AI Research♡ University of Washington† UC Berkeley TTI-Chicago Carnegie Mellon University dfried@cs.cmu.edu, {armenag,mikelewis}@fb.com
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Code is seldom written in a single left-to-right pass and is instead repeatedly edited and refined. We introduce INCODER, a unified generative model that can perform program synthesis (via left-to-right generation) as well as editing (via masking and infilling). InCoder is trained to generate code files from a large corpus of permissively licensed code, where regions of code have been randomly masked and moved to the end of each file, allowing code infilling with bidirectional context. Our model is the first large generative code model that is able to infill arbitrary regions of code, which we evaluate in a zero-shot setting on challenging tasks such as type inference, comment generation, and variable re-naming. We find that the ability to condition on bidirectional context substantially improves performance on these tasks, while still performing comparably on standard program synthesis benchmarks in comparison to left-to-right only models pretrained at similar scale.
|
| 8 |
+
|
| 9 |
+
Our models and code are publicly released.1
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
Large language models trained on vast repositories of code have demonstrated remarkable progress in neural program synthesis and related tasks (Chen et al., 2021a; Austin et al., 2021; Xu et al., 2022; Nijkamp et al., 2022; Chowdhery et al., 2022). However, such models generate code leftto-right, which makes them less directly applicable to many ubiquitous code editing tasks, such as fixing bugs, adding comments, or re-naming variables. We introduce INCODER, a unified model for program synthesis and editing. Like prior work, INCODER is trained to maximize the likelihood of a corpus of code. However, we adopt a causal masking objective (Aghajanyan et al., 2022a), allowing INCODER to infill blocks of code conditioned on arbitrary left and right contexts.
|
| 14 |
+
|
| 15 |
+
More specifically, we learn to infill by randomly replacing spans of code with a sentinel token and moving them to the end of the sequence (Figure 1, top). The model is trained to predict all tokens in the complete sequence in this permuted ordering. During inference, we can edit code by replacing spans with sentinel tokens, prompting the model with the new sequence, and having it generate new tokens to replace the masked spans (Figure 1, bottom). Because the model can also trivially generate without sentinel tokens, the result is a unified approach for both program synthesis (via left-to-right generation) and editing (via infilling).
|
| 16 |
+
|
| 17 |
+
We evaluate performance on a range of zero-shot code infilling tasks (Sec. 4), both new and from existing work, including challenging use cases such as type prediction, variable re-naming, comment generation, and completing missing lines of code. Zero-shot infilling with bidirectional context substantially outperforms approaches based on left-to-right-only models, and on several tasks obtains performance comparable to state-of-the-art models fine-tuned on the tasks. Ablation experiments (Sec. 5) show that this does not come at the cost of left-to-right generation ability; our causal masking model achieves similar performance to a standard language model on program synthesis benchmarks (Chen et al., 2021a; Austin et al., 2021) despite its more general training objective.
|
| 18 |
+
|
| 19 |
+
# Training
|
| 20 |
+
|
| 21 |
+

|
| 22 |
+
|
| 23 |
+
# Zero-shot Inference
|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
Docstring Generation
|
| 27 |
+
|
| 28 |
+

|
| 29 |
+
Multi-Region Infilling
|
| 30 |
+
Figure 1: At training time (top), our causal masking objective samples one or more spans of code in training documents (in the upper left figure, a single span) and moves these spans to the end of the document, with their original location denoted by special mask sentinel tokens. An autoregressive language model is trained to produce these entire masked documents, allowing it to learn to generate insertion text conditioned on bidirectional context. At inference time (bottom), we can perform a variety of code editing and infilling tasks in a zero-shot fashion by inserting mask tokens at desired locations and allowing the model to generate code to insert there. All examples shown are real outputs from our INCODER-6.7B model, with the regions inserted by the model highlighted in orange.
|
| 31 |
+
|
| 32 |
+
# 2 INFILLING AND SYNTHESIS VIA CAUSAL MASKING
|
| 33 |
+
|
| 34 |
+
Neural models for code generation have either utilized a left-to-right (causal) autoregressive language modeling objective (Brown et al., 2020; Chen et al., 2021a) or, as BERT does, a masked language modeling objective (Devlin et al., 2019; Feng et al., 2020). Both approaches have strengths and weaknesses. Causal models only condition on context to the left of the generated tokens, thus preventing infilling, but they can autoregressively generate entire documents. On the other hand, masked language models can condition on both the left and right contexts to infill a masked region, however, their training objective is typically limited to generating only about $15 \%$ of a document. In this paper, we adopt the recently proposed causal masking objective (Aghajanyan et al., 2022a), which aims to combine the strengths of both causal and masked language models.
|
| 35 |
+
|
| 36 |
+
# 2.1 TRAINING
|
| 37 |
+
|
| 38 |
+
At training time, the causal masking procedure samples a number of spans of contiguous tokens in each document to mask (Figure 1, top left). We sample the number of spans from a Poisson distribution with a mean of one, truncated to the support [1, 256], so that there are typically a small number of spans (with a single span around $50 \%$ of the time), but the distribution has a long tail (up to 256 spans). Each span’s endpoints are sampled uniformly from the length of the document and the set of sampled spans is rejected and resampled if any spans overlap.
|
| 39 |
+
|
| 40 |
+
Once spans are sampled, each span $k$ is replaced with a special mask sentinel token, <Mask:k>. The sequence of tokens in the span is then moved to the end of the document (Figure 1, top right), with the mask sentinel token prepended and a special end-of-mask token $\mathsf { \mathrm { \tt { E O M } > } }$ token appended. In other words, when a mask token appears for the first time in the left-to-right ordering, it marks the location the span was removed from; when it appears for the second time, it marks the start of the moved span text. More formally, assume we have a document D with $N$ tokens, and we have sampled one span $\mathsf { S p a n } = \mathsf { D } _ { i : j }$ . Let Left be the left context $\mathsf { D } _ { 0 : i }$ and Right be the right context $\mathsf { D } _ { j : N }$ . Then, we maximize the log probability of the masked document:
|
| 41 |
+
|
| 42 |
+
$$
|
| 43 |
+
\log P ( [ \mathsf { L e f t } ; \mathsf { \texttt { < M a s k : } } 0 > ; \mathsf { R i g h t } ; \mathsf { \texttt { < M a s k : } } 0 > ; \mathsf { \texttt { S p a n } } ; \mathsf { \texttt { < E O M > } } ] )
|
| 44 |
+
$$
|
| 45 |
+
|
| 46 |
+
where ; denotes sequence concatenation. If more than one span were sampled, each would be similarly appended at the end of the document in order. As in standard left-to-right generative language modeling, we compute the probability of the sequence auto-regressively and train the model using cross-entropy loss on all tokens except the mask sentinel tokens <Mask:k>, so that the model does not generate these tokens during inference.
|
| 47 |
+
|
| 48 |
+
# 2.2 INFERENCE
|
| 49 |
+
|
| 50 |
+
During inference, the model can either be used for left-to-right generation in the standard way (by sampling autoregressively from the model, without using any special tokens), or it can insert code at arbitrary locations in an existing document by inserting a <Mask:k> tokens at the desired location(s) and continuing generation at the end of the document. Assuming for simplicity of notation that we want to insert text at only a single location, we can generate a span to insert between the location’s Left and Right context sequences by sampling tokens autoregressively from the distribution
|
| 51 |
+
|
| 52 |
+
$$
|
| 53 |
+
P ( \cdot \mid [ \mathsf { L e f t } ; \mathsf { < M a s k : } 0 > ; \mathsf { R i g h t } ; \mathsf { < M a s k : } 0 > ] )
|
| 54 |
+
$$
|
| 55 |
+
|
| 56 |
+
until either an ${ \tt { \tt { \tt { E 0 M } } } } >$ token is generated or a task-dependent stopping criterion is achieved.2 When applied to code, this allows us to perform tasks that benefit from the bidirectional context in a zero-shot fashion, as shown in Figure 1, bottom. For example, we can perform Python docstring generation conditioned on both the left context (function signature) and right context (function implementation). We can also infill multiple dependent regions, e.g., generate imports required by a function that the model is generating. See Section B.2 for details, including multi-region infilling.
|
| 57 |
+
|
| 58 |
+
# 3 MODELS
|
| 59 |
+
|
| 60 |
+
Our primary model is INCODER-6.7B, a 6.7B Transformer (Vaswani et al., 2017) language model. We use the same architecture as the dense 6.7B models described in Artetxe et al. (2021); the Fairseq architecture description can be found in Table 6 in the appendix. All experiments use this model unless stated otherwise (we train smaller models for comparison in Section 5).
|
| 61 |
+
|
| 62 |
+
To train our models, we collect a corpus of (1) public code with permissive, non-copyleft, opensource licenses from GitHub and GitLab and (2) StackOverflow questions, answers, and comments. Our primary focus in this paper is on the Python language, but we also include code files from 28 total languages and StackOverflow content from all available languages. We decontaminate our pre-training corpus by removing all datasets which we use in our evaluation experiments. See Section A.1 for details. Our final pre-training corpus contains a total of 159 GB of code, $5 2 \mathrm { G B }$ of it in Python, and a total of 57 GB of content from StackOverflow. See Figure 3 for size by language.
|
| 63 |
+
|
| 64 |
+
# 4 INFILLING EXPERIMENTS
|
| 65 |
+
|
| 66 |
+
Our primary evaluation is performing zero-shot infilling for a diverse set of tasks: inserting lines of code, predicting function return types, generating docstrings, renaming variables, and inserting missing code tokens. We formulate each task as filling in one or more masked-out regions of code.
|
| 67 |
+
|
| 68 |
+
To evaluate how INCODER benefits from bidirectional context when generating infills, we compare three different inference methods: the causal masking inference procedure described in Section 2, a standard left-to-right generation approach (left-to-right single), and a left-to-right generation and reranking approach (left-to-right reranking). Since our model is also able to generate left-to-right, we can compare all three inference methods using the same INCODER-6.7B model and thus avoid any confounding effects due to a change in the model. For all three inference methods, we obtain generations from the model using top- $p$ (nucleus) sampling (Holtzman et al., 2020) with $p = 0 . 9 5$ and a temperature tuned for each task and inference method using the task’s development data.
|
| 69 |
+
|
| 70 |
+
Left-to-right single. This baseline does not use the context to the right of the masked location at all. It generates a single completion for the location by conditioning on the left context and sampling tokens autoregressively from the model $P ( \cdot \mid$ Left) until a task-specific stop condition is reached (e.g., for comment generation, when a comment-ending delimiter is produced).
|
| 71 |
+
|
| 72 |
+
Left-to-right reranking. This baseline uses only the left context to propose candidates to infill the blank, but uses both the left and right contexts to choose among these candidates. Concretely, we first generate $K$ possible completions for the blank region, $\mathsf { S p a n } _ { 1 } \ldots \mathsf { S p a n } _ { K }$ following the same procedure as left-to-right single, using $K = 1 0$ unless otherwise specified. We then evaluate each candidate by substituting it into the blank and scoring the completed document. We use either total log probability of the completed document $\log P ( [ \mathsf { L e f t } ; \mathsf { S p a n } _ { k } ; \mathsf { R i g h t }$ ]) or, following Chen et al. (2021a), log probability averaged across the number of tokens in the completed document. We select between these two scoring methods for each task using performance on the task’s development data.
|
| 73 |
+
|
| 74 |
+
# 4.1 INFILLING LINES OF CODE (HUMANEVAL)
|
| 75 |
+
|
| 76 |
+
We create an infilling benchmark for complete lines of code from the HumanEval dataset (Chen et al., 2021a). This dataset provides comment descriptions of functions paired with a canonical implementation of each function and several input–output pairs that the function should pass. HumanEval was introduced as a benchmark for the synthesis of entire Python functions; we evaluate our models on this original synthesis setting in Section C.6. We use this dataset because it affords functional testing of completed code (as opposed to relying solely on an evaluation of the code surface form), which is particularly important when infilling longer regions that have more potential ways to be completed correctly. We construct two infilling tasks from the dataset, for single lines and multiple lines:
|
| 77 |
+
|
| 78 |
+
Single-line infilling. In this task, we mask out each non-blank line of code in the canonical function implementation in turn (creating $N$ examples for a function with $N$ non-blank lines). The task is to generate a single-line completion for the blank conditioned on the natural language description of the function and the code lines before and after the blank. We evaluate using (1) pass rate: the rate at which the completed function passes all of the function’s input–output pairs (i.e., analogous to the pass $@ 1$ metric from Chen et al. (2021a) and (2) exact match: percentage of times that the completed lines exactly match the masked lines in the canonical implementation. Performance is averaged across all examples generated for all programs in the dataset.
|
| 79 |
+
|
| 80 |
+
Multi-line infilling. This task is constructed in the same way as single-line infilling above but allows each masked region to contain multiple lines of code, creating $N \times ( N + 1 ) / 2$ examples for a function with $N$ non-blank lines. We again evaluate completions using pass rate and exact match, averaged across all infilling examples.
|
| 81 |
+
|
| 82 |
+
Inference details. To choose when to end the infill produced by our inference methods, we truncate the candidates generated by the left-to-right (L-R) baselines to the actual number of lines in the blanked-out region. For our causal-masked (CM) infilling method, we end the infill when the model generates the $\mathsf { \mathrm { \tt { E O M } } } \mathrm { \mathrm { > } }$ token. For the L-R single and CM infilling methods, we sample using a temperature of 0.2. For the L-R rerank method, we use a temperature of 0.8 to sample $K = 1 0$ candidates and rescore with the total log probability of the completed function.
|
| 83 |
+
|
| 84 |
+
<table><tr><td>Method</td><td>Pass Rate</td><td>Exact Match</td></tr><tr><td>L-R single</td><td>48.2</td><td>38.7</td></tr><tr><td>L-R reranking</td><td>54.9</td><td>44.1</td></tr><tr><td>CM infilling</td><td>69.0</td><td>56.3</td></tr><tr><td>PLBART</td><td>41.6</td><td>一</td></tr><tr><td>code-cushman-001</td><td>53.1</td><td>42.0</td></tr><tr><td>code-davinci-001</td><td>63.0</td><td>56.0</td></tr></table>
|
| 85 |
+
|
| 86 |
+
<table><tr><td>Method</td><td>Pass Rate</td><td>Exact Match</td></tr><tr><td>L-R single</td><td>24.9</td><td>15.8</td></tr><tr><td>L-R reranking</td><td>28.2</td><td>17.6</td></tr><tr><td>CM infilling</td><td>38.6</td><td>20.6</td></tr><tr><td>PLBART</td><td>13.1</td><td>一</td></tr><tr><td>code-cushman-001</td><td>30.8</td><td>17.4</td></tr><tr><td>code-davinci-001</td><td>37.8</td><td>19.8</td></tr></table>
|
| 87 |
+
|
| 88 |
+
Table 1: On our single- and multi-line code infilling benchmarks that we construct from HumanEval, our causal-masked (CM) approach obtains substantial improvements over left-to-right single candidate and left-to-right reranking baselines in both function test pass rate and exact match.
|
| 89 |
+
|
| 90 |
+

|
| 91 |
+
(a) Single-line infilling. (b) Multi-line infilling.
|
| 92 |
+
Figure 2: Infilling pass rate by the fraction of the function’s lines which are provided to the right of the region that must be infilled, for single-line infilling (left) and multi-line infilling (right). Shaded regions give $9 5 \%$ confidence intervals, estimated using bootstrap resampling. Our causal-masked (CM) infilling method, blue, consistently outperforms both of the left-to-right (L-R) baselines, with larger gains as more right-sided context becomes available (the right side of both graphs).
|
| 93 |
+
|
| 94 |
+
Results. Table 1 shows the results for the single-line (left) and multi-line settings (right). In both settings, CM infilling improves substantially over the L-R single baseline and the L-R reranking baseline. Note that these results are computed by averaging over all examples, which includes masked regions at all positions in functions (including the beginning, when no left context is available, and end, when no right context is available). Figure 2 shows a finer-grained comparison, where we group examples by the fraction of lines in the canonical function which are contained in the context to the right of the infill. The CM infilling method sees larger improvements over the L-R baselines as more right-sided context becomes available (i.e., when the blanked region occurs earlier in the function).
|
| 95 |
+
|
| 96 |
+
We also compare against two alternate zero-shot methods for incorporating right-sided context: (1) an encoder-decoder code model trained with a denoising infilling objective (PLBART, Ahmad et al. 2021), and (2) templated prompting of large left-to-right generative code models (the cushman-001 and davinci-001 Codex models available through OpenAI’s API). See Section C.1 for details on these experiments.5 InCoder outperforms all models in both single-line and multi-line infilling, despite having lower performance in left-to-right generation than Codex (see Table 11), demonstrating that causal masking training benefits infilling.
|
| 97 |
+
|
| 98 |
+
<table><tr><td>Method</td><td>BLEU</td></tr><tr><td>Ours: L-R single</td><td>16.05</td></tr><tr><td>Ours: : L-R reranking Ours: :Causal-masked infilling</td><td>17.14</td></tr><tr><td></td><td>18.27</td></tr><tr><td>RoBERTa (Finetuned) CodeBERT (Finetuned)</td><td>18.14</td></tr><tr><td>PLBART (Finetuned)</td><td>19.06 19.30</td></tr><tr><td>CodeT5 (Finetuned)</td><td>20.36</td></tr></table>
|
| 99 |
+
|
| 100 |
+
Table 2: CodeXGLUE Python Docstring generation BLEU scores. Our model is evaluated in a zero-shot setting, with no fine-tuning for docstring generation, but it approaches the performance of pretrained code models that are fine-tuned on the task’s 250K examples (bottom block).
|
| 101 |
+
|
| 102 |
+
# 4.2 DOCSTRING GENERATION (CODEXGLUE)
|
| 103 |
+
|
| 104 |
+
We next evaluate documentation string (docstring) generation, where models must generate a natural language docstring that summarizes a Python code snippet. Right context may be particularly useful for docstring generation, as conditioning on the function body can allow models to generate more informative descriptions. Prior neural code generation models are fine-tuned on supervised docstring-code pairs to perform this task (e.g., Clement et al. 2020; Chen et al. 2021a; Lu et al. 2021; Ahmad et al. 2021), however we evaluate our model zero-shot, with no explicit supervision.
|
| 105 |
+
|
| 106 |
+
We use the CodeXGLUE code-to-text docstring generation task (Lu et al., 2021), which is constructed from CodeSearchNet (Husain et al., 2019), consisting of docstring-code pairs scraped from publicly available GitHub repositories. The L-R single candidate baseline is prompted with the function signature in the left context preceding the docstring. The CM infilling and L-R reranking methods also observe the right context, consisting of the function body.
|
| 107 |
+
|
| 108 |
+
We compare models following the original automatic evaluation setup for the task. In Table 2, we report smoothed 4-gram BLEU scores for all models, using the reference docstrings provided in the dataset. These references have been preprocessed to strip extraneous content (e.g., argument definitions) from the original scraped docstrings. We use greedy generation for the CM infilling and L-R single candidate generation methods and sample $K = 1 0$ candidates at temperature 0.8 with average log probability scoring for the L-R reranking method (selected by tuning on the validation set of the task). For all inference methods, we stop generation if the model generates a newline. We also include the performance of the supervised baseline from the CodeXGLUE paper: an encoderdecoder model with a CodeBERT encoder fine-tuned on $\sim 2 5 0 \mathrm { K }$ training examples from the dataset. Our zero-shot performance approaches the performance of the fine-tuned CodeBERT model.
|
| 109 |
+
|
| 110 |
+
# 4.3 RETURN TYPE PREDICTION
|
| 111 |
+
|
| 112 |
+
Predicting return type hints for Python functions is a challenging structured generation task (see Figure 1, “type inference”). We evaluate on two datasets: one we construct from CodeXGLUE and the dataset from TypeWriter OSS (Pradel et al., 2020).
|
| 113 |
+
|
| 114 |
+
CodeXGLUE. We develop a benchmark for return type prediction using the same Python CodeXGLUE dataset used in the code-to-text (docstring generation) task. We run an abstract syntax tree (AST) processor on all functions in the development and test sets of this dataset to (1) identify functions with a PEP $4 8 4 ^ { 6 }$ return type hint annotation that is not None and (2) remove all other type hints (e.g., for function arguments and variable declarations) from the function. This leaves 232 functions in the development and 469 functions in the test set.
|
| 115 |
+
|
| 116 |
+
The task is to condition on the function signature and body and predict the type hint. We compare the type hints predicted by our various methods to the annotated type hint in the original function, using exact match accuracy on the normalized type hint.7
|
| 117 |
+
|
| 118 |
+
<table><tr><td>Method</td><td>Accuracy</td></tr><tr><td>Left-to-right single</td><td>12.0</td></tr><tr><td>Left-to-right reranking</td><td>12.4</td></tr><tr><td>Causal-masked infilling</td><td>58.1</td></tr></table>
|
| 119 |
+
|
| 120 |
+
(a) Results on the test set of the benchmark that we construct from CodeXGLUE.
|
| 121 |
+
|
| 122 |
+
<table><tr><td>Method</td><td>Precision</td><td>Recall</td><td>F1</td></tr><tr><td>Ours: Left-to-right single</td><td>30.8</td><td>30.8</td><td>30.8</td></tr><tr><td>Ours: :Left-to-right reranking</td><td>33.3</td><td>33.3</td><td>33.3</td></tr><tr><td>Ours: :Causal-masked infilling</td><td>59.2</td><td>59.2</td><td>59.2</td></tr><tr><td>TypeWriter (Supervised)</td><td>54.9</td><td>43.2</td><td>48.3</td></tr></table>
|
| 123 |
+
|
| 124 |
+
(b) Results on a subset of the TypeWriter’s OSS dataset (Pradel et al., 2020). We include examples from which we were able to obtain source files, successfully extract functions and types, that have non-None return type hints, and that were not included in our model’s training data.
|
| 125 |
+
|
| 126 |
+
Table 3: Results for predicting Python function return type hints on two datasets. We see substantial improvements from causal masked infilling over baseline methods using left-to-right inference.
|
| 127 |
+
|
| 128 |
+
To compare our three generation methods, we stop generation when a : is generated, which ends the type hint and signals the start of the function body. We tune inference hyperparameters on the development set, and we use a temperature of 0.2 for left-to-right-single, 0.8 for left-to-right reranking, and greedy generation for causal masked infilling. Results on the test set are given in Table 3a. Conditioning on the right context (i.e., the function body) gives some benefit in the leftto-right reranking setting, but gives a substantial improvement via our causal masked infilling.
|
| 129 |
+
|
| 130 |
+
TypeWriter OSS. Some recent work has developed supervised machine learning approaches for predicting type annotations for dynamically-typed languages including Python (Xu et al., 2016; Allamanis et al., 2020; Pradel et al., 2020) and TypeScript (Hellendoorn et al., 2018; Wei et al., 2020; Jesse et al., 2021). We compare our zero-shot model to one such approach for Python, TypeWriter (Pradel et al., 2020), which combines a neural architecture for type hint prediction with a search-based incremental type validation procedure.
|
| 131 |
+
|
| 132 |
+
To compare to the supervised TypeWriter approach, we obtain its predictions on the open-source software (OSS) dataset used in that work (Pradel et al., 2020), consisting of Python functions from GitHub. Unfortunately, we could not evaluate on their full evaluation set since much of it was included in our model’s training data. We filter to instances that were not included in our training data, for which we were able to obtain files and extract functions and types from via AST parsing, and which have non-NONE return type hints. This leaves 2,092 examples (about $1 2 \%$ of their evaluation set). We otherwise emulate their exact setup, which allows our model to condition on file imports, the function body, and the function signature to predict return type hints. We use the same inference hyperparameters as we did for CodeXGLUE type hint prediction.
|
| 133 |
+
|
| 134 |
+
We present our results in two tables: Table 3b containing metrics across non-None types, and Table 10 in the Appendix, which includes None types as well (following Pradel et al. 2020).8 We again see benefits from causal masked infilling’s ability to condition on the function body when generating return types, and find that our zero-shot model outperforms the supervised TypeWriter model.
|
| 135 |
+
|
| 136 |
+
# 4.4 VARIABLE NAME PREDICTION
|
| 137 |
+
|
| 138 |
+
Variable name prediction is a less-constrained code generation task that requires modeling bidirectional context. We again use the test set from the CodexGlue code-to-text task (docstring generation) and run an AST transform to isolate and either mask all the occurrences of the variable name (infilling) or take the left-most context from the first variable name (left-to-right mode). In the infilling setting, given that we generate the number of masks equivalent to the number of times a variable is seen, we select the most common prediction as our singular prediction. Furthermore, we only evaluate the set of variable names containing four or more characters. For our re-ranking, we consider a candidate set of 25 variables. We present our results in Table 4. We again see substantial benefits from using both left and right context: left-to-right reranking and causal-masked infilling both outperform the left-to-right single baseline (which uses only the left context). Causal-masked
|
| 139 |
+
|
| 140 |
+
<table><tr><td>Method</td><td>Accuracy</td></tr><tr><td>Left-to-right single</td><td>18.4</td></tr><tr><td>Left-to-right reranking</td><td>23.5</td></tr><tr><td>Causal-masked infilling</td><td>30.6</td></tr></table>
|
| 141 |
+
|
| 142 |
+
Table 4: Results on the variable renaming benchmark that we construct from CodeXGLUE. Our model benefits from using the right-sided context in selecting (L-R reranking and CM infilling) and proposing (CM infilling) variable names.
|
| 143 |
+
|
| 144 |
+
infilling substantially on the left-to-right reranking method, demonstrating the value of conditioning on the right context when proposing candidate completions.
|
| 145 |
+
|
| 146 |
+
# 5 ABLATION EXPERIMENTS
|
| 147 |
+
|
| 148 |
+
For an analysis of the effects of training a model with causal masking (rather than the standard language modeling objective, as well as model size and the training data, we train several variations of our model. We compare model pass $@ 1$ scores on the HumanEval (Chen et al., 2021a) and MBPP (Austin et al., 2021) left-to-right synthesis benchmarks, with results in Table 5.
|
| 149 |
+
|
| 150 |
+
Objective. Comparing 1.3B parameter models trained on the same training data with the causal masked (CM) objective (row 2) and the standard left-to-right language modeling (LM) objective (row 3), we see that the causal-masked model obtains slightly higher performance on the HumanEval and MBPP tasks in pass $@ 1$ score. This provides further evidence that causal masking training does not hurt the model’s ability to perform standard left-to-right generation, at least to the 1.3B parameter scale, in line with the findings of Bavarian et al. (2022).
|
| 151 |
+
|
| 152 |
+
Model size. With data fixed, increasing model size consistently improves performance (comparing the 6.7B and 1.3B CM models in rows 1 and 2, and the 1.3B and 2.3B LM models in rows 3 and 6).
|
| 153 |
+
|
| 154 |
+
Effects of data. We compare models trained on our entire dataset of multiple code languages and StackOverflow (multi lang $+ \ S O$ , described in Section A.1) to data ablations that train only on Python code files and StackOverflow (Python $+ \ S O$ ) and only Python code files (Python). We find that training on multiple languages gives a slight reduction in performance on these Python evaluations. However, comparing rows 4 and 5, we see that including StackOverflow data in training substantially improves performance on both HumanEval and MBPP. This suggests that future work on generative code models for language-guided synthesis tasks should consider using StackOverflow or other corpora that mix natural language and code as training data.
|
| 155 |
+
|
| 156 |
+
# 6 QUALITATIVE EXAMPLES
|
| 157 |
+
|
| 158 |
+
We show a variety of qualitative examples from our model in Section D.2 in both the infilling and left-to-right generation modes: docstring generation, metadata conditioning, class attribute inference from class usage, comment-conditioned code editing, StackOverflow title and tag generation, and zero-shot bidirectional translation of technical jargon between Chinese and English.
|
| 159 |
+
Table 5: Ablation results, comparing model performance on the Python portion of a validation set held out from our training corpora as well as the HumanEval and MBPP benchmarks. We compare models by size (in billions of parameters), objective (causal masked, CM, versus standard left-toright language modeling, LM), training data, and total amount of compute in training (in zettaflops).
|
| 160 |
+
|
| 161 |
+
<table><tr><td>#</td><td>Size (B)</td><td>Obj.</td><td>Training Data</td><td>Data Size</td><td>Train Tokens</td><td>Train Compute</td><td>HumanEval Pass@1</td><td>MBPP Pass@1</td></tr><tr><td>1)</td><td>6.7</td><td>CM</td><td>multi lang + SO</td><td>204 GB</td><td>52B</td><td>3.0Z</td><td>15</td><td>19.4</td></tr><tr><td>2)</td><td>1.3</td><td>CM</td><td>multi lang + SO</td><td>204 GB</td><td>52B</td><td>0.6Z</td><td>8</td><td>10.9</td></tr><tr><td>3)</td><td>1.3</td><td>LM</td><td>multi lang + SO</td><td>204 GB</td><td>52B</td><td>0.6Z</td><td>6</td><td>8.9</td></tr><tr><td>4)</td><td>1.3</td><td>LM</td><td>Python + SO</td><td>104 GB</td><td>25B</td><td>0.3Z</td><td>9</td><td>9.8</td></tr><tr><td>5)</td><td>1.3</td><td>LM</td><td>Python</td><td>49 GB</td><td>11B</td><td>0.1Z</td><td>5</td><td>6.1</td></tr><tr><td>6</td><td>2.3</td><td>LM</td><td>multi lang + SO</td><td>204 GB</td><td>52B</td><td>1.1Z</td><td>9</td><td>12.7</td></tr></table>
|
| 162 |
+
|
| 163 |
+
# 7 RELATED WORK
|
| 164 |
+
|
| 165 |
+
Language Models for Code There has been a flurry of recent work on training large-scale neural language models on source code. Existing models differ in their architectural design and training objectives, e.g., decoder-only language models (Austin et al., 2021; Chen et al., 2021a; Izadi et al., 2022; Xu et al., 2022; Nijkamp et al., 2022), encoder-only masked language models (Feng et al., 2020; Kanade et al., 2020), and encoder-decoder models (Ahmad et al., 2021; Li et al., 2022; Roziere et al., 2021; Wang et al., 2021). Decoder-only language models have grown in popularity as they can perform zero-shot program synthesis by generating in a left-to-right fashion. On the other hand, InCoder is a decoder-only causally-masked language model that can infill arbitrary spans of text. This allows the model to perform program synthesis and many other code infilling tasks.
|
| 166 |
+
|
| 167 |
+
Infilling Models Many real-world applications require infilling sequences using left and right context, e.g., editing sentences (Shih et al., 2019), restoring ancient text (Assael et al., 2019), and fixing bugs in source code. Unfortunately, standard left-to-right language models cannot directly infill text, and popular masked language models are mainly trained to infill very short spans (Chan et al., 2019; Devlin et al., 2019; Raffel et al., 2020; Roziere et al., 2021). Recent work addresses this by changing model architectures, inference procedures, and training objectives (Aghajanyan et al., 2022a; Stern et al., 2019; West et al., 2021; Aghajanyan et al., 2022b). Most related to our approach is the work of Donahue et al. (2020) and CM3 (Aghajanyan et al., 2022a), who train left-to-right language models to fill in masked token segments of varying lengths; and the work of Alon et al. (2020), who train an infilling-capable, AST-structured generative model of code on a smaller scale. In addition, concurrent to our work, OpenAI developed a fill-in-the-middle (FIM) training objective similar to the causal masking objective we use, trained code models with it, and evaluated on the HumanEval infilling tasks we introduce here (Bavarian et al., 2022). Similar to our findings in Section 5, they find that the infilling capability does not adversely affect left-to-right performance. Our objective, in contrast, allows infilling multiple regions of code, and we demonstrate the benefits of infilling across a broader range of natural programming tasks.
|
| 168 |
+
|
| 169 |
+
Machine Learning for Code Assistance There is an extensive literature on using machine learning models to aid human programmers. This includes methods to infer variable types (Pradel et al., 2020; Wei et al., 2020), generate unit tests (Fraser & Arcuri, 2011), repair programs (Gupta et al., 2017; Yasunaga & Liang, 2020; Chen et al., 2021c; Yasunaga & Liang, 2021), and verify program correctness (Ryan et al., 2020). Our model can infill arbitrary spans of code, allowing it to complete many of these tasks, as well as perform standard left-to-right generation, in a single approach.
|
| 170 |
+
|
| 171 |
+
Machine Learning for Program Synthesis Program synthesis approaches directly generate programs from a specification of functionality (Gulwani et al., 2017). Such models work by taking e.g., input-output examples (Balog et al., 2017; Gulwani, 2011; Chen et al., 2021b; Bavishi et al., 2019), partial implementations (Solar-Lezama et al., 2006), or natural language descriptions (Zelle & Mooney, 1996; Yu et al., 2018; Yin et al., 2018; Kulal et al., 2019; Chen et al., 2021a) of the desired program as input. Our InCoder model differs from this past work as it can both synthesize and infill arbitrary spans of code, conditioning on natural language and partial implementations.
|
| 172 |
+
|
| 173 |
+
# 8 CONCLUSION
|
| 174 |
+
|
| 175 |
+
We demonstrated that using a causal masking objective when training a generative model of code enables strong zero-shot performance on many challenging and practical code infilling and editing tasks. The model’s additional infilling capability does not appear to harm its ability to do standard left-to-right generation: ablation and comparison experiments show that our causal-masked models have comparable performance to similarly-resourced models on standard left-to-right language-tocode synthesis benchmarks. Looking forward, we expect our model performance to continue to increase with more parameters, data, and training steps (Kaplan et al., 2020; Henighan et al., 2020). Moreover, fine-tuning would allow our models to be better able to condition on natural language instructions and other indications of human intent (Zhong et al., 2021; Wei et al., 2022; Ouyang et al., 2022). Finally, our model lays a foundation for future work on supervised infilling & editing via model fine-tuning, as well as performing iterative decoding, where the model can be used to refine its own output (Ghazvininejad et al., 2019).
|
| 176 |
+
|
| 177 |
+
# REFERENCES
|
| 178 |
+
|
| 179 |
+
Rajas Agashe, Srinivasan Iyer, and Luke Zettlemoyer. JuICe: A large scale distantly supervised dataset for open domain context-based code generation. In Proceedings of EMNLP, 2019. URL https://aclanthology.org/D19-1546.
|
| 180 |
+
|
| 181 |
+
Armen Aghajanyan, Bernie Huang, Candace Ross, Vladimir Karpukhin, Hu Xu, Naman Goyal, Dmytro Okhonko, Mandar Joshi, Gargi Ghosh, Mike Lewis, and Luke Zettlemoyer. CM3: A causal masked multimodal model of the Internet. arXiv preprint arXiv:2201.07520, 2022a.
|
| 182 |
+
|
| 183 |
+
Armen Aghajanyan, Dmytro Okhonko, Mike Lewis, Mandar Joshi, Hu Xu, Gargi Ghosh, and Luke Zettlemoyer. HTLM: Hyper-text pre-training and prompting of language models. In ICLR, 2022b.
|
| 184 |
+
|
| 185 |
+
Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. Unified pre-training for program understanding and generation. In NAACL, 2021.
|
| 186 |
+
|
| 187 |
+
Miltiadis Allamanis. The adverse effects of code duplication in machine learning models of code. In SPLASH, 2019.
|
| 188 |
+
|
| 189 |
+
Miltiadis Allamanis, Earl T Barr, Soline Ducousso, and Zheng Gao. Typilus: Neural type hints. In PLDI, 2020.
|
| 190 |
+
|
| 191 |
+
Uri Alon, Roy Sadaka, Omer Levy, and Eran Yahav. Structural language models of code. In ICML, pp. 245–256. PMLR, 2020.
|
| 192 |
+
|
| 193 |
+
Mikel Artetxe, Shruti Bhosale, Naman Goyal, Todor Mihaylov, Myle Ott, Sam Shleifer, Xi Victoria Lin, Jingfei Du, Srinivasan Iyer, Ramakanth Pasunuru, et al. Efficient large scale language modeling with mixtures of experts. arXiv preprint arXiv:2112.10684, 2021.
|
| 194 |
+
|
| 195 |
+
Yannis M. Assael, Thea Sommerschield, and J. Prag. Restoring ancient text using deep learning: a case study on Greek epigraphy. In EMNLP, 2019.
|
| 196 |
+
|
| 197 |
+
Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie J. Cai, Michael Terry, Quoc V. Le, and Charles Sutton. Program synthesis with large language models. arXiv preprint arXiv:2108.07732, 2021.
|
| 198 |
+
|
| 199 |
+
Mandeep Baines, Shruti Bhosale, Vittorio Caggiano, Naman Goyal, Siddharth Goyal, Myle Ott, Benjamin Lefaudeux, Vitaliy Liptchinsky, Mike Rabbat, Sam Sheiffer, Anjali Sridhar, and Min Xu. FairScale: A general purpose modular PyTorch library for high performance and large scale training. https://github.com/facebookresearch/fairscale, 2021.
|
| 200 |
+
|
| 201 |
+
Matej Balog, Alexander L. Gaunt, Marc Brockschmidt, Sebastian Nowozin, and Daniel Tarlow. DeepCoder: Learning to write programs. In ICLR, 2017.
|
| 202 |
+
|
| 203 |
+
Mohammad Bavarian, Heewoo Jun, Nikolas Tezak, John Schulman, Christine McLeavey, Jerry Tworek, and Mark Chen. Efficient training of language models to fill in the middle. arXiv preprint arXiv:2207.14255, 2022.
|
| 204 |
+
|
| 205 |
+
Rohan Bavishi, Caroline Lemieux, Roy Fox, Koushik Sen, and Ion Stoica. AutoPandas: neuralbacked generators for program synthesis. PACMPL, 2019.
|
| 206 |
+
|
| 207 |
+
Sid Black, Stella Biderman, Eric Hallahan, Quentin Anthony, Leo Gao, Laurence Golding, Horace He, Connor Leahy, Kyle McDonell, Jason Phang, Michael Pieler, USVSN Sai Prashanth, Shivanshu Purohit, Laria Reynolds, Jonathan Tow, Ben Wang, and Samuel Weinbach. GPT-NeoX-20B: An open-source autoregressive language model. 2022.
|
| 208 |
+
|
| 209 |
+
Burton H Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 1970.
|
| 210 |
+
|
| 211 |
+
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. In NeurIPS, 2020.
|
| 212 |
+
|
| 213 |
+
William Chan, Nikita Kitaev, Kelvin Guu, Mitchell Stern, and Jakob Uszkoreit. KERMIT: Generative insertion-based modeling for sequences. arXiv preprint arXiv:1906.01604, 2019.
|
| 214 |
+
|
| 215 |
+
Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021a.
|
| 216 |
+
|
| 217 |
+
Xinyun Chen, Petros Maniatis, Rishabh Singh, Charles Sutton, Hanjun Dai, Max Lin, and Denny Zhou. SpreadsheetCoder: Formula prediction from semi-structured context. In ICML, 2021b.
|
| 218 |
+
|
| 219 |
+
Zimin Chen, Steve Kommrusch, Michele Tufano, Louis-Noel Pouchet, Denys Poshyvanyk, and ¨ Monperrus Martin. SequenceR: Sequence-to-sequence learning for end-to-end program repair. IEEE Transactions on Software Engineering, 2021c.
|
| 220 |
+
|
| 221 |
+
Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. PaLM: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022.
|
| 222 |
+
|
| 223 |
+
Colin Clement, Dawn Drain, Jonathan Timcheck, Alexey Svyatkovskiy, and Neel Sundaresan. PyMT5: multi-mode translation of natural language and python code with transformers. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 9052–9065, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.728. URL https://aclanthology.org/2020. emnlp-main.728.
|
| 224 |
+
|
| 225 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL, 2019.
|
| 226 |
+
|
| 227 |
+
Chris Donahue, Mina Lee, and Percy Liang. Enabling language models to fill in the blanks. In ACL, 2020.
|
| 228 |
+
|
| 229 |
+
Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, et al. CodeBERT: A pre-trained model for programming and natural languages. In EMNLP Findings, 2020.
|
| 230 |
+
|
| 231 |
+
Gordon Fraser and Andrea Arcuri. EvoSuite: Automatic test suite generation for object-oriented software. In ACM SIGSOFT, 2011.
|
| 232 |
+
|
| 233 |
+
Leo Gao, Stella Biderman, Sid Black, Laurence Golding, Travis Hoppe, Charles Foster, Jason Phang, Horace He, Anish Thite, Noa Nabeshima, et al. The Pile: An 800GB dataset of diverse text for language modeling. arXiv preprint arXiv:2101.00027, 2020.
|
| 234 |
+
|
| 235 |
+
Marjan Ghazvininejad, Omer Levy, Yinhan Liu, and Luke Zettlemoyer. Mask-Predict: Parallel decoding of conditional masked language models. In EMNLP, 2019.
|
| 236 |
+
|
| 237 |
+
Sumit Gulwani. Automating string processing in spreadsheets using input-output examples. ACM SIGPLAN Notices, 2011.
|
| 238 |
+
|
| 239 |
+
Sumit Gulwani, Oleksandr Polozov, and Rishabh Singh. Program synthesis. In Foundations and Trends in Programming Languages, 2017.
|
| 240 |
+
|
| 241 |
+
Rahul Gupta, Soham Pal, Aditya Kanade, and Shirish Shevade. DeepFix: Fixing common C language errors by deep learning. In AAAI, 2017.
|
| 242 |
+
|
| 243 |
+
Vincent J Hellendoorn, Christian Bird, Earl T Barr, and Miltiadis Allamanis. Deep learning type inference. In ESEC/FSE 2018, 2018.
|
| 244 |
+
|
| 245 |
+
Tom Henighan, Jared Kaplan, Mor Katz, Mark Chen, Christopher Hesse, Jacob Jackson, Heewoo Jun, Tom B Brown, Prafulla Dhariwal, Scott Gray, et al. Scaling laws for autoregressive generative modeling. arXiv preprint arXiv:2010.14701, 2020.
|
| 246 |
+
|
| 247 |
+
Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. In ICLR, 2020.
|
| 248 |
+
|
| 249 |
+
Hamel Husain, Ho-Hsiang Wu, Tiferet Gazit, Miltiadis Allamanis, and Marc Brockschmidt. CodeSearchNet challenge: Evaluating the state of semantic code search. arXiv preprint arXiv:1909.09436, 2019.
|
| 250 |
+
|
| 251 |
+
Maliheh Izadi, Roberta Gismondi, and Georgios Gousios. CodeFill: Multi-token code completion by jointly learning from structure and naming sequences. In ICSE, 2022.
|
| 252 |
+
|
| 253 |
+
Kevin Jesse, Premkumar T. Devanbu, and Toufique Ahmed. Learning type annotation: Is big data enough? In ESEC/FSE, 2021.
|
| 254 |
+
|
| 255 |
+
Aditya Kanade, Petros Maniatis, Gogul Balakrishnan, and Kensen Shi. Learning and evaluating contextual embedding of source code. In ICML, 2020.
|
| 256 |
+
|
| 257 |
+
Nikhil Kandpal, Eric Wallace, and Colin Raffel. Deduplicating training data mitigates privacy risks in language models. arXiv preprint arXiv:2202.06539, 2022.
|
| 258 |
+
|
| 259 |
+
Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020.
|
| 260 |
+
|
| 261 |
+
Nitish Shirish Keskar, Bryan McCann, Lav R Varshney, Caiming Xiong, and Richard Socher. CTRL: A conditional transformer language model for controllable generation. arXiv preprint arXiv:1909.05858, 2019.
|
| 262 |
+
|
| 263 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
|
| 264 |
+
|
| 265 |
+
Sumith Kulal, Panupong Pasupat, Kartik Chandra, Mina Lee, Oded Padon, Alex Aiken, and Percy S Liang. SPoC: Search-based pseudocode to code. In NeurIPS, 2019.
|
| 266 |
+
|
| 267 |
+
Katherine Lee, Daphne Ippolito, Andrew Nystrom, Chiyuan Zhang, Douglas Eck, Chris CallisonBurch, and Nicholas Carlini. Deduplicating training data makes language models better. In ACL, 2022.
|
| 268 |
+
|
| 269 |
+
Mike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad, Abdelrahman Mohamed, Omer Levy, Ves Stoyanov, and Luke Zettlemoyer. Bart: Denoising sequence-to-sequence pretraining for natural language generation, translation, and comprehension. arXiv preprint arXiv:1910.13461, 2019.
|
| 270 |
+
|
| 271 |
+
Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Remi Leblond, Tom ´ Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, et al. Competition-level code generation with AlphaCode. arXiv preprint arXiv:2203.07814, 2022.
|
| 272 |
+
|
| 273 |
+
Shuai Lu, Daya Guo, Shuo Ren, Junjie Huang, Alexey Svyatkovskiy, Ambrosio Blanco, Colin Clement, Dawn Drain, Daxin Jiang, Duyu Tang, et al. CodeXGlue: A machine learning benchmark dataset for code understanding and generation. In NeurIPS, 2021.
|
| 274 |
+
|
| 275 |
+
Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, and Caiming Xiong. A conversational paradigm for program synthesis. arXiv preprint arXiv:2203.13474, 2022.
|
| 276 |
+
|
| 277 |
+
Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan Ng, David Grangier, and Michael Auli. Fairseq: A fast, extensible toolkit for sequence modeling. arXiv preprint arXiv:1904.01038, 2019.
|
| 278 |
+
|
| 279 |
+
Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke E. Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul Francis Christiano, Jan Leike, and Ryan J. Lowe. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02155, 2022.
|
| 280 |
+
|
| 281 |
+
Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. PyTorch: An imperative style, high-performance deep learning library. In NeurIPS, 2019.
|
| 282 |
+
|
| 283 |
+
Michael Pradel, Georgios Gousios, Jason Liu, and Satish Chandra. TypeWriter: Neural type prediction with search-based validation. In ACM SIGSOFT, 2020.
|
| 284 |
+
|
| 285 |
+
Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. Technical report, OpenAI, 2019.
|
| 286 |
+
|
| 287 |
+
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. In JMLR, 2020.
|
| 288 |
+
|
| 289 |
+
Ronald Rivest. RFC1321: The MD5 message-digest algorithm, 1992.
|
| 290 |
+
|
| 291 |
+
Baptiste Roziere, Marie-Anne Lachaux, Marc Szafraniec, and Guillaume Lample. DOBF: A deobfuscation pre-training objective for programming languages. In NeurIPS, 2021.
|
| 292 |
+
|
| 293 |
+
Gabriel Ryan, Justin Wong, Jianan Yao, Ronghui Gu, and Suman Sekhar Jana. CLN2INV: Learning loop invariants with continuous logic networks. In ICLR, 2020.
|
| 294 |
+
|
| 295 |
+
Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In ACL, Berlin, Germany, 2016. URL https://aclanthology.org/P16-1162.
|
| 296 |
+
|
| 297 |
+
Yong-Siang Shih, Wei-Cheng Chang, and Yiming Yang. XL-Editor: Post-editing sentences with XLNet. arXiv preprint arXiv:1910.10479, 2019.
|
| 298 |
+
|
| 299 |
+
Armando Solar-Lezama, Liviu Tancau, Rastislav Bodik, Sanjit Seshia, and Vijay Saraswat. Combinatorial sketching for finite programs. In ASPLOS, 2006.
|
| 300 |
+
|
| 301 |
+
Mitchell Stern, William Chan, Jamie Kiros, and Jakob Uszkoreit. Insertion transformer: Flexible sequence generation via insertion operations. In ICML, 2019.
|
| 302 |
+
|
| 303 |
+
Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. LaMDA: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022.
|
| 304 |
+
|
| 305 |
+
Lewis Tunstall, Leandro von Werra, and Thomas Wolf. Natural Language Processing with Transformers. O’Reilly Media, Inc., 2022.
|
| 306 |
+
|
| 307 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. NeurIPS, 2017.
|
| 308 |
+
|
| 309 |
+
Ben Wang and Aran Komatsuzaki. GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model. https://github.com/kingoflolz/mesh-transformer-jax, May 2021.
|
| 310 |
+
|
| 311 |
+
Yue Wang, Weishi Wang, Shafiq Joty, and Steven CH Hoi. CodeT5: Identifier-aware unified pretrained encoder-decoder models for code understanding and generation. In EMNLP, 2021.
|
| 312 |
+
|
| 313 |
+
Jason Wei, Maarten Bosma, Vincent Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V. Le. Finetuned language models are zero-shot learners. In ICLR, 2022.
|
| 314 |
+
|
| 315 |
+
Jiayi Wei, Maruth Goyal, Greg Durrett, and Isil Dillig. LambdaNet: Probabilistic type inference using graph neural networks. In ICLR, 2020.
|
| 316 |
+
|
| 317 |
+
Peter West, Ximing Lu, Ari Holtzman, Chandra Bhagavatula, Jena Hwang, and Yejin Choi. Reflective decoding: Beyond unidirectional generation with off-the-shelf language models. In ACL, 2021.
|
| 318 |
+
|
| 319 |
+
Frank F Xu, Uri Alon, Graham Neubig, and Vincent J Hellendoorn. A systematic evaluation of large language models of code. arXiv preprint arXiv:2202.13169, 2022.
|
| 320 |
+
|
| 321 |
+
Zhaogui Xu, Xiangyu Zhang, Lin Chen, Kexin Pei, and Baowen Xu. Python probabilistic type inference with natural language support. In SIGSOFT, 2016.
|
| 322 |
+
|
| 323 |
+
Michihiro Yasunaga and Percy Liang. Graph-based, self-supervised program repair from diagnostic feedback. In ICML. PMLR, 2020.
|
| 324 |
+
|
| 325 |
+
Michihiro Yasunaga and Percy Liang. Break-it-fix-it: Unsupervised learning for program repair. In ICML, 2021.
|
| 326 |
+
|
| 327 |
+
Pengcheng Yin, Bowen Deng, Edgar Chen, Bogdan Vasilescu, and Graham Neubig. Learning to mine aligned code and natural language pairs from stack overflow. In ACM MSR, 2018.
|
| 328 |
+
|
| 329 |
+
Tao Yu, Rui Zhang, Kai-Chou Yang, Michihiro Yasunaga, Dongxu Wang, Zifan Li, James Ma, Irene Z Li, Qingning Yao, Shanelle Roman, Zilin Zhang, and Dragomir R. Radev. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-toSQL task. In EMNLP, 2018.
|
| 330 |
+
|
| 331 |
+
John M Zelle and Raymond J Mooney. Learning to parse database queries using inductive logic programming. In AAAI, 1996.
|
| 332 |
+
|
| 333 |
+
Rowan Zellers, Ari Holtzman, Hannah Rashkin, Yonatan Bisk, Ali Farhadi, Franziska Roesner, and Yejin Choi. Defending against neural fake news. In NeurIPS, 2019.
|
| 334 |
+
|
| 335 |
+
Ruiqi Zhong, Kristy Lee, Zheng Zhang, and Dan Klein. Adapting language models for zero-shot learning by meta-tuning on dataset and prompt collections. In EMNLP, 2021.
|
| 336 |
+
|
| 337 |
+
# A DATA
|
| 338 |
+
|
| 339 |
+
# A.1 CODE DATA
|
| 340 |
+
|
| 341 |
+
Sources. We obtained code files and repository metadata from GitHub and GitLab through the sites’ public APIs over a period ending on December 9th, 2021. We obtained approximately 670,000 public non-fork repositories which GitHub/GitLab detected as containing primarily Python, JavaScript, or Jupyter Notebook files, and with either an MIT, Apache 2.0, BSD-2, or BSD-3 clause license. We included all code from a list of 28 languages (determined by file extension) contained in these repositories.9 Since Python files can also be contained in non-majority-Python repositories, we also included all other Python and Jupyter files obtainable through the GitHub archive on BigQuery that we did not already obtain from GitHub directly.10 We preprocess Jupyter notebooks by including all text and code (with Markdown formatting removed from text cells), with cells demarcated by XML-style tags (see Section A.3).
|
| 342 |
+
|
| 343 |
+
Deduplication. Recent work has shown that deduplicating training data can improve model performance and reduce the risk of memorizing training data (Allamanis, 2019; Lee et al., 2022; Kandpal et al., 2022). Our deduplication scheme removes code files using exact match on the sequence of alphanumeric tokens in the file.11 This removed approximately $7 5 \%$ of the corpus by file size (reducing from 1 TB to 250 GB) as there are numerous duplicated repositories, library dependencies included as source files, and common boilerplate code files (e.g., for Python web frameworks). We also use regular expressions to detect email addresses in the code files and replace them with a dummy address,12 to reduce the risks of the model memorizing real email addresses or hallucinating fake ones.
|
| 344 |
+
|
| 345 |
+
Decontamination. To ensure that our code generation models can be evaluated on several current code generation benchmarks, we perform data decontamination: removing overlap between our training data and the evaluation sets of these benchmarks. We remove any repositories contained in the validation and test sets of CodeSearchNet (Husain et al., 2019), as these are used to construct validation and test sets for several of the tasks in CodeXGLUE (Lu et al., 2021).13
|
| 346 |
+
|
| 347 |
+
Filtering. Our filtering is similar to past work on generative models of code Chen et al. (2021a); Nijkamp et al. (2022); Xu et al. (2022): we remove files that contain any line longer than 3000 tokens or an average line length greater than 100 tokens, have less than $40 \%$ of their characters being alphanumeric or underscores, or appear to be automatically generated, which we determine using substring match on a small number of phrases produced by automatic code and documentation generation systems.14 Our decontamination and filtering steps together remove roughly $10 \%$ of Python files.
|
| 348 |
+
|
| 349 |
+
# A.2 STACKOVERFLOW
|
| 350 |
+
|
| 351 |
+
The second component of our corpus consists of questions, answers, and comments from StackOverflow. The Pile (Gao et al., 2020), which was used to train recent generative code models that we compare to in Section 5, also contains these questions and answers but does not contain comments. We include all questions that have at least one answer, up to ten answers with a non-negative score (sorted by score) per question, and up to five comments per question/answer. Qualitatively, we find that comments, together with the infilling ability of the model, allow our model to have some capability to do interactive code editing guided by language (see Figure 11).
|
| 352 |
+
|
| 353 |
+
# A.3 METADATA
|
| 354 |
+
|
| 355 |
+
We include some metadata on the code files and StackOverflow questions/answers directly in our training data to allow attribute-conditioned generation (Keskar et al., 2019; Zellers et al., 2019) and attribute prediction. For code file data, our attributes are the code filename, the file extension (as a proxy for language), the file source (GitHub or GitLab), and, for GitHub repositories, the number of stars binned into six buckets.15 To allow this metadata to be optional when performing leftto-right prompting of the model, we insert each attribute it the beginning of its document with a probability of $50 \%$ (allowing the model to learn metadata conditioning); otherwise, we insert it at the end of its document (allowing metadata prediction). See Figure 6a and Figure 6b for examples. For StackOverflow, our metadata attributes are the question tags for the topic (e.g., python,django) and the number of votes for each question and answer, binned in the same way as repository stars. We insert comments directly after the questions or answers they were written for. See Figure 6c for examples.
|
| 356 |
+
|
| 357 |
+
# A.4 TOKENIZATION
|
| 358 |
+
|
| 359 |
+
To increase the amount of context that our code model can condition on, the length of documents that the model can generate, and the efficiency of training and inference, we train a byte-level BPE tokenizer Sennrich et al. (2016); Radford et al. (2019). We allow tokens to extend across whitespace (excluding newline characters) so that common code idioms (e.g., import numpy as np) are represented as single tokens in the vocabulary. This substantially improves the tokenizer’s efficiency— reducing the total number of tokens required to encode our training corpus by $45 \%$ relative to the byte-level BPE tokenizer and vocabulary of GPT-2.
|
| 360 |
+
|
| 361 |
+

|
| 362 |
+
Figure 3: Code corpus composition (after deduplication and filtering) by total file size for the most common languages, as determined by file extension.
|
| 363 |
+
|
| 364 |
+
# A.5 CORPUS STATISTICS
|
| 365 |
+
|
| 366 |
+
See Figure 3 for a plot showing code corpus composition (after deduplication and filtering) by total file size for the most common languages, as determined by file extension.
|
| 367 |
+
|
| 368 |
+
# B MODEL AND INFERENCE DETAILS
|
| 369 |
+
|
| 370 |
+
B.1 MODEL
|
| 371 |
+
|
| 372 |
+
Table 6: Fairseq architecture hyperparameters for our INCODER models.
|
| 373 |
+
|
| 374 |
+
<table><tr><td>Parameter</td><td>INCODER-1.3B</td><td>INCODER-6.7B</td></tr><tr><td>-decoder-embed-dim</td><td>2048</td><td>4096</td></tr><tr><td>-decoder-output-dim</td><td>2048</td><td>4096</td></tr><tr><td>-decoder-input-dim</td><td>2048</td><td>4096</td></tr><tr><td>-decoder-ffn-embed-dim</td><td>8192</td><td>16384</td></tr><tr><td>-decoder-layers</td><td>24</td><td>32</td></tr><tr><td>-decoder-normalize-before</td><td>True</td><td>True</td></tr><tr><td>-decoder-attention-heads</td><td>32</td><td>32</td></tr><tr><td>-share-decoder-input-output-embed</td><td>True</td><td>True</td></tr><tr><td>-decoder-learned-pos</td><td>False</td><td>False</td></tr></table>
|
| 375 |
+
|
| 376 |
+
Our primary model is INCODER-6.7B, a 6.7B Transformer Vaswani et al. (2017) language model. We use the same architecture as the dense 6.7B models described in Artetxe et al. (2021); the Fairseq architecture description can be found in Table 6. INCODER-6.7B was trained on 248 V100 GPUs for
|
| 377 |
+
|
| 378 |
+

|
| 379 |
+
Figure 4: Loss curves show that perplexity is still improving after one epoch and that perplexity improves substantially with a larger model size. This suggests that increasing epochs, data size, or model size would improve performance.
|
| 380 |
+
|
| 381 |
+

|
| 382 |
+
Figure 5: Performance of INCODER-6.7B on the HumanEval left-to-right synthesis benchmark generally increases over the course of pretraining. We plot a line of best fit along with a $9 5 \%$ confidence interval via bootstrap resampling.
|
| 383 |
+
|
| 384 |
+
24 days. We perform one epoch on the training data, using each training document exactly once. Our implementation utilized the causal masking implementation (Aghajanyan et al., 2022a) available in Fairseq (Ott et al., 2019), with the underlying library being PyTorch (Paszke et al., 2019). Our perGPU batch size was 8, with a maximum token sequence length of 2048. We clip all gradient norms to 1.0 and used the Adam optimizer with $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 8$ (Kingma & Ba, 2015). For our learning rate scheduler, we use the built-in polynomial decay learning rate scheduler available in Paszke et al. (2019) with 1500 warmup updates. Fairscale was used for improving memory efficiency through fully sharding model states (Baines et al., 2021).
|
| 385 |
+
|
| 386 |
+
We compare the validation perplexity of the 6B parameter model and a smaller 1.3B parameter model (see Section 5 for details on the training of this 1.3B model) in Figure 4, showing comparable scaling laws to those reported by Aghajanyan et al. Aghajanyan et al. (2022a). Our models have also not yet saturated and would benefit from further training; we report the performance of the 6.7B model on the HumanEval Python function synthesis benchmark (Chen et al., 2021a) (see Section C.6 for a description of this benchmark) and see a consistent increase in performance over the course of training (Figure 5).
|
| 387 |
+
|
| 388 |
+
# B.2 INFERENCE DETAILS
|
| 389 |
+
|
| 390 |
+
In practice, to generate a single infill we sample from the distribution $\begin{array} { r l } { P ( \cdot } & { { } \ l } \end{array}$ [Left; <Mask: $\varnothing >$ ; Right; <Mask: $\uparrow >$ ; $\angle M a s k : 0 > ]$ ), where we insert an artificial $\angle M a s k : 1 >$ token. Not inserting <Mask: $\uparrow >$ gives an implicit size hint to the model that the <Mask: $\varnothing >$ token should be expanded to fill the rest of the 2048 token context window. Instead, inserting a <Mask: $\uparrow >$ token indicates to the model that some amount of the document is omitted after the right context. We found that including this substantially improved the ability of the model to predict $\tt { < E O M > }$ appropriately when generating an infill for <Mask: $\varnothing >$ . See Aghajanyan et al. (2022a) for more.
|
| 391 |
+
|
| 392 |
+
More generally, when inserting at multiple locations, we condition on the document with multiple mask sentinel tokens inserted and a final mask token appended. For example, to insert at two locations we use [A; <Mask: $\varnothing >$ ; C; <Mask: $\uparrow >$ ; E; <Mask:2>]) and infill the masks in order, appending the appropriate <Mask:k> sentinel tokens to signal the start of generation for the next span, i.e., the completed document for two insertion locations is represented by [A; <Mask: $\varnothing >$ ; C; <Mask:1>; E; <Mask: $^ { 2 > }$ ; <Mask: $0 >$ ; B; <EOM>; <Mask:1>; D; $\angle E O M > ]$ , where regions B and D have been infilled.
|
| 393 |
+
|
| 394 |
+
# C EXPERIMENTAL DETAILS AND SUPPLEMENTARY RESULTS
|
| 395 |
+
|
| 396 |
+
# C.1 INFILLING COMPARISONS
|
| 397 |
+
|
| 398 |
+
We describe our adaptation of models from prior work to the zero-shot infilling setting, for the experiments described in Section 4.
|
| 399 |
+
|
| 400 |
+
Encoder-decoder (PLBART). We use PLBART-Large (Ahmad et al., 2021), an encoder-decoder model trained on code (including 220GB of Python) using a BART (Lewis et al., 2019) masked denoising objective. We pre- and post-process each HumanEval infilling example as needed for PLBART: we represent each example as a stream of space-separated tokens (as identified by Python’s built-in lexer) with newlines and indentations replaced by control characters, and use a <mask> token to represent the line to be infilled. We extract the infilled region from the output by searching for the longest suffix of the left context contained in the output, and (as in our left-to-right baselines) take the ground-truth number of lines following this left context suffix as the infill.
|
| 401 |
+
|
| 402 |
+
Left-to-right with templated prompting (Codex). We perform zero-shot prompting on the Codex code-cushman-001 and code-davinci-001 OpenAI API models using the following template:
|
| 403 |
+
|
| 404 |
+
[code before the infill mask] <INFILL> [code after the infill mask] # Complete the above code by replacing the <INFILL> tag. [code before the infill mask]
|
| 405 |
+
|
| 406 |
+
We take [code after the infill mask] as the indicator of completion.
|
| 407 |
+
|
| 408 |
+
# C.2 CODE CLOZE (CODEXGLUE)
|
| 409 |
+
|
| 410 |
+
CodeXGLUE cloze is created from CodeSearchNet to evaluate CodeBERT and consists of a short natural language description followed by code in several programming languages. We evaluate on the max/min subtask, where the model has to decide if the given mask should be filled with either max or min. Since there are only two options in this task, we can closely compare the causal-masked infilling and left-to-right setups by scoring both options and selecting the sequence with the highest likelihood.
|
| 411 |
+
|
| 412 |
+
Table 7 contains the main results. Using the causal-masked infill format with a single token (containing min/max) as the masked region (CM infill-token) performs better than using just the left context, but not as well as scoring the entire sequence left to right. Masking a larger region (CM infill-region), containing the left prefix and 10 right-side tokens in the masked region, performs comparably to scoring the whole sequence. Infill region length and tokenization can affect the performance, see C.3 for more details and more comparisons.
|
| 413 |
+
|
| 414 |
+
Table 7: Accuracy on the CodeXGLUE max/min cloze task. We compare four different inference methods. Left-to-right single: scoring with left-to-right ordering using only the left context and the completion (containing max or min); Left-to-right reranking: scoring with left-to-right ordering using the left context, completion, and right context; CM infill-token: causal masking scoring, using only a single token (containing max or min) as the infill, CM infill-region: causal masking scoring that additionally contains 10 tokens from the right side context.
|
| 415 |
+
|
| 416 |
+
<table><tr><td>Method</td><td>Python</td><td> JavaScript</td><td>Ruby</td><td>Go</td><td>Java</td><td>PHP</td></tr><tr><td>Left-to-right single</td><td>76.9</td><td>77.6</td><td>65.8</td><td>70.4</td><td>74.1</td><td>77.1</td></tr><tr><td>Left-to-right reranking</td><td>87.9</td><td>90.1</td><td>76.3</td><td>92.8</td><td>91.7</td><td>90.4</td></tr><tr><td>CM infill-token</td><td>81.8</td><td>73.9</td><td>81.6</td><td>95.4</td><td>77.6</td><td>87.0</td></tr><tr><td>CM infill-region</td><td>86.2</td><td>91.2</td><td>78.9</td><td>94.7</td><td>89.8</td><td>91.4</td></tr><tr><td>CodeBERT</td><td>82.2</td><td>86.4</td><td>86.8</td><td>90.8</td><td>90.5</td><td>88.2</td></tr></table>
|
| 417 |
+
|
| 418 |
+
Note that comparing the scores of the sequences, which differ in their infills, with the left-to-right setup is more computationally expensive than with the CM infilling setup, as the Transformer intermediate activations can be cached and shared across identical sequence prefixes, and in the CM infill setup all sequence differences occur at the ends.
|
| 419 |
+
|
| 420 |
+
C.3 CLOZE AND SINGLE TOKEN INFILL DETAILS
|
| 421 |
+
Table 8: Accuracy on CodeXGLUE cloze max/min. Left: scoring using only the left context, Leftright: score the whole program, Infill: score the infilling sequence, -region: include left context and 10 tokens from the right. -break: break tokenization on the infilled token. Codex : version code-davinci-001 of OpenAI’s Codex model, as accessed through their API. Information on the training data for this model is unclear, and it may contain portions of CodeSearchNet (which contains this task’s evaluation set).
|
| 422 |
+
|
| 423 |
+
<table><tr><td></td><td>Python</td><td>Javascript</td><td>Ruby</td><td>Go</td><td>Java</td><td>PHP</td></tr><tr><td>Left-break</td><td>72.4</td><td>72.1</td><td>68.4</td><td>71.7</td><td>74.1</td><td>76.9</td></tr><tr><td>Left-token</td><td>76.9</td><td>77.6</td><td>65.8</td><td>70.4</td><td>74.1</td><td>77.1</td></tr><tr><td>Left-region</td><td>84.2</td><td>88.6</td><td>73.7</td><td>85.5</td><td>87.6</td><td>87.0</td></tr><tr><td>Left-right-break</td><td>77.9</td><td>79.4</td><td>63.2</td><td>89.5</td><td>82.0</td><td>85.3</td></tr><tr><td>Left-right</td><td>87.9</td><td>90.1</td><td>76.3</td><td>92.8</td><td>91.7</td><td>90.4</td></tr><tr><td>Infill-break</td><td>79.1</td><td>83.1</td><td>84.2</td><td>90.1</td><td>84.0</td><td>85.3</td></tr><tr><td>Infill-token</td><td>81.8</td><td>73.9</td><td>81.6</td><td>95.4</td><td>77.6</td><td>87.0</td></tr><tr><td>Infill-region</td><td>86.2</td><td>91.2</td><td>78.9</td><td>94.7</td><td>89.8</td><td>91.4</td></tr><tr><td>CodeBERT</td><td>82.2</td><td>86.4</td><td>86.8</td><td>90.8</td><td>90.5</td><td>88.2</td></tr><tr><td>Codex*</td><td>93.6</td><td>93.4</td><td>94.7</td><td>99.3</td><td>95.0</td><td>94.3</td></tr></table>
|
| 424 |
+
|
| 425 |
+
As shown in Table 8, breaking tokenization (-break) on infill decreases the performance using all scoring methods. For example, whereas Math.max( was a single token in the full sequence, the sequence is broken into Math., max, and ( for infilling. Infilling with the original tokenization increases the performance slightly, but does not match full left-right scoring. We suspect this is because the model was not trained on infilling single tokens, unlike CodeBERT. A way to fix this is to include a larger region on the left and a few more tokens on the right. This will only slightly increase the scoring complexity. To show that our model uses the right context, we compare it with scoring the left-only model. More precisely, the sequences being scored are
|
| 426 |
+
|
| 427 |
+
Left-to-right single: [Left; Token] Left-to-right reranking: [Left; Token; Right] Infill-token: [Left; <Mask:0>; Right; <Mask:1>; <Mask:0>; Token; <EOSS>] Left-region: [Left; Token; Right[:10]] Infill-region: [ <Mask: $\varnothing >$ ; Right[10:]; <Mask:1>; <Mask:0>; Left; Token; Right[:10]; <EOSS>]
|
| 428 |
+
|
| 429 |
+
# C.4 COMPARISON TO OPENAI’S CODE API
|
| 430 |
+
|
| 431 |
+
We evaluate OpenAI’s proprietary code-davinci-002 system, accessed through their API, on our single-line HumanEval infilling task, with results given in Table 9, There is limited public information about this system, including on its training data or procedure (although Bavarian et al. 2022 describes their FIM objective as early research that helps power the model), how it performs infills, or whether any postprocessing is done on model outputs, but we report its performance to help gauge the difficulty of our new task. For both code-davinci-002 and our INCODER-6.7B model, conditioning on right-sided context improves performance, with the most substantial improvements from infilling.
|
| 432 |
+
|
| 433 |
+
<table><tr><td>Model</td><td>Inference</td><td>Pass Rate</td><td>Exact Match</td></tr><tr><td>INCODER-6.7B</td><td>Left-to-right single</td><td>48.2</td><td>38.7</td></tr><tr><td>INCODER-6.7B</td><td>Left-to-right reranking</td><td>54.9</td><td>44.1</td></tr><tr><td>INCODER-6.7B</td><td>Infilling</td><td>69.0</td><td>56.3</td></tr><tr><td>code-davinci-002</td><td>Left-to-right single</td><td>63.7</td><td>48.4</td></tr><tr><td>code-davinci-002</td><td>Left-to-right reranking</td><td>71.8</td><td>52.0</td></tr><tr><td>code-davinci-002</td><td>Infilling</td><td>87.4</td><td>69.6</td></tr></table>
|
| 434 |
+
|
| 435 |
+
Table 9: We evaluate OpenAI’s proprietary code-davinci-002 system, accessed through their API, on our single-line HumanEval infilling task. Although no information is currently public about this system, its training data or procedure, how it performs infills, or whether any postprocessing is done on model outputs, we report its performance to help gauge the difficulty of our new task. For both code-davinci-002 and our INCODER-6.7B model, conditioning on right-sided context improves performance, with the most substantial improvements from infilling.
|
| 436 |
+
|
| 437 |
+
# C.5 ADDITIONAL TYPE HINT PREDICTION SETTING
|
| 438 |
+
|
| 439 |
+
Our results in Section 4.3 filtered out functions from the TypeWriter prediction set which had a return type hint of None, as these type hints are are overrepresented in the dataset in compared to naturally-occurring code, due to the filtering process used to construct it. For a closer comparison to the setting used in the original TypeWriter paper, we present results including these functions in Table 10. Given TypeWriter’s static analysis capabilities, and the overrepresentation of None types in this evaluation set, we add a simple post-processing step (return checks) that predicts None if the function does not have any non-trivial return statements, which captures some of the effect of TypeWriter’s analysis capabilities. In all settings, our zero-shot infill approach outperforms the left-to-right baselines, and obtains performance comparable to the supervised TypeWriter approach when return checks are used.
|
| 440 |
+
|
| 441 |
+
<table><tr><td>Method</td><td>Precision</td><td>Recall</td><td>F1</td></tr><tr><td>Ours: Left-to-right single</td><td>20.0</td><td>20.0</td><td>20.0</td></tr><tr><td>Ours: Left-to-right rerank</td><td>24.2</td><td>24.2</td><td>24.2</td></tr><tr><td>Ours: Infill</td><td>46.8</td><td>46.8</td><td>46.8</td></tr><tr><td>Ours: Left-to-right single + Return checks</td><td>63.2</td><td>63.2</td><td>63.2</td></tr><tr><td>Ours: Left-to-right rerank + Return checks</td><td>64.3</td><td>64.3</td><td>64.3</td></tr><tr><td>Ours: Infill + Return checks</td><td>76.7</td><td>76.7</td><td>76.7</td></tr><tr><td>TypeWriter (Supervised)</td><td>78.8</td><td>69.9</td><td>74.1</td></tr></table>
|
| 442 |
+
|
| 443 |
+
Table 10: Return type hint prediction results on the $2 5 \%$ subset of TypeWriter’s OSS dataset where were able to obtain source files, extract functions and types from, and that were not contained in our model’s training set. Given an overrepresentation of functions with None in this dataset, and the static analysis capabilities of TypeWriter, we also give results using a simple post-processing step that predicts None if the function does not have any non-trivial return statements.
|
| 444 |
+
|
| 445 |
+
# C.6 COMPARISON TO LEFT-TO-RIGHT GENERATIVE MODELS ON CODE SYNTHESIS
|
| 446 |
+
|
| 447 |
+
We compare to past published work on generative code models on the HumanEval (Chen et al., 2021a) and MBPP (Austin et al., 2021) benchmarks, which require models to condition on natural language descriptions (docstrings) to produce Python programs (typically a single function), and evaluates overall functional accuracy (pass rate) across examples using several test cases for each program.
|
| 448 |
+
|
| 449 |
+
We evaluate our INCODER-6.7B model in zero-shot evaluation on both of these benchmarks. For HumanEval, we follow past work by prompting with function signatures and docstring descriptions, sample 200 candidate program completions, and compute pass $@ 1$ , pass $@ 1 0$ , and pass $@ 1 0 0$ using the unbiased sampling estimator of Chen et al. (Chen et al., 2021a). For MBPP, which
|
| 450 |
+
|
| 451 |
+
<table><tr><td rowspan="2">Model</td><td>Size (B)</td><td>Python Code (GB)</td><td>Other Code (GB)</td><td>Other</td><td>Code License</td><td rowspan="2">Infill?</td><td>HE @1</td><td>HE @10</td><td>HE</td><td>MBPP @1</td></tr><tr><td></td><td></td><td></td><td>(GB)</td><td></td><td></td><td></td><td></td><td>@100</td></tr><tr><td>Released</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>CodeParrot (Tunstall et al.,2022)</td><td>1.5</td><td>50</td><td>None</td><td>None</td><td></td><td></td><td>4.0</td><td>8.7</td><td>17.9</td><td></td></tr><tr><td>PolyCoder (Xu et al.,2022)</td><td>2.7</td><td>16</td><td>238</td><td>None</td><td></td><td></td><td>5.6</td><td>9.8</td><td>17.7</td><td></td></tr><tr><td>GPT-J(Wang & Komatsuzaki,2021; Chen et al.,2021a)</td><td>6</td><td>6</td><td>90</td><td>730</td><td></td><td></td><td>11.6</td><td>15.7</td><td>27.7</td><td></td></tr><tr><td>INCODER-6.7B</td><td>6.7</td><td>52</td><td>107</td><td>57</td><td>Permissive</td><td>√</td><td>15.2</td><td>27.8</td><td>47.0</td><td>19.4</td></tr><tr><td>GPT-NeoX (Black et al., 2022)</td><td>20</td><td>6</td><td>90</td><td>730</td><td></td><td></td><td>15.4</td><td>25.6</td><td>41.2</td><td></td></tr><tr><td>CodeGen-Multi (Nijkamp et al.,2022)</td><td>6.1</td><td>62</td><td>375</td><td>1200</td><td></td><td></td><td>18.2</td><td>28.7</td><td>44.9</td><td></td></tr><tr><td>CodeGen-Mono (Nijkamp et al.,2022)</td><td>6.1</td><td>279</td><td>375</td><td>1200</td><td></td><td></td><td>26.1</td><td>42.3</td><td>65.8</td><td></td></tr><tr><td>CodeGen-Mono (Nijkamp et al.,2022)</td><td>16.1</td><td>279</td><td>375</td><td>1200</td><td></td><td></td><td>29.3</td><td>49.9</td><td>75.0</td><td></td></tr><tr><td>Unreleased</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LaMDA (Austin et al.,2021; Thoppilan</td><td>137</td><td>None</td><td>None</td><td>???</td><td></td><td></td><td>14.0</td><td></td><td>47.3</td><td>14.8</td></tr><tr><td>et al.,2022; Chowdhery et al.,2022) AlphaCode (Li et al.,2022)</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Codex-2.5B (Chen et al.,2021a)</td><td>1.1</td><td>54</td><td>660</td><td>None</td><td></td><td></td><td>17.1</td><td>28.2 35.4</td><td>45.3</td><td></td></tr><tr><td></td><td>2.5</td><td>180</td><td>None None</td><td>> 570</td><td></td><td></td><td>21.4</td><td></td><td>59.5</td><td></td></tr><tr><td>Codex-12B (Chen et al.,2021a)</td><td>12</td><td>180</td><td></td><td>> 570</td><td></td><td></td><td>28.8 36.0</td><td>46.8</td><td>72.3 88.4</td><td></td></tr><tr><td>PaLM-Coder (Chowdhery et al.,2022)</td><td>540</td><td>~20</td><td>~200</td><td>~4000</td><td>Permissive</td><td></td><td></td><td>一</td><td></td><td>47.0</td></tr></table>
|
| 452 |
+
|
| 453 |
+
Table 11: A comparison of our INCODER-6.7B model to published code generation systems using pass rates $@ \ K$ candidates sampled on the HumanEval and MBPP benchmarks. All models are decoder-only transformer models. A “Permissive” code license indicates models trained on only open-source repositories with non-copyleft licenses. The GPT-J, GPT-NeoX, and CodeGen models are pre-trained on The Pile (Gao et al., 2020), which contains a portion of GitHub code without any license filtering, including 6 GB of Python. Although the LaMDA model does not train on code repositories, its training corpus includes $\sim 1 8 \mathrm { ~ B ~ }$ tokens of code from web documents. The total file size of the LaMDA corpus was not reported, but it contains $2 . 8 \mathrm { ~ T ~ }$ tokens total. We estimate the corpus size for PaLM using the reported size of the code data and the token counts per section of the corpus.
|
| 454 |
+
|
| 455 |
+
does not include function signatures, we prompt only with the docstring description and compute pass $@ 1$ (Chowdhery et al., 2022) using a single candidate.16 We use top-p sampling with $p = 0 . 9 5$ , with a temperature of 0.2 for pass $@ 1$ and 0.8 for pass $@ 1 0$ and pass $@ 1 0 0$ .
|
| 456 |
+
|
| 457 |
+
We compare our INCODER-6.7B model to models from past work (which have all been left-toright only) in Table 11, giving the model size and training data summary statistics as reported (or estimated, in cases when a paper only reports token counts, as tokenizer efficiencies vary) in these papers.While differences in details of the Transformer model architectures, datasets, and training procedures across papers and experimental setups make a rigorous comparison impossible, we note that our model achieves roughly comparable performance on the HumanEval metrics to CodeGenMulti (Nijkamp et al., 2022), which is also a $\sim 6 \mathrm { B }$ parameter model trained on roughly the same amount of Python code, as well as AlphaCode’s 1.1B decoder-only model (Li et al., 2022) which also uses a similar amount of Python training data.
|
| 458 |
+
|
| 459 |
+
# D EXAMPLES
|
| 460 |
+
|
| 461 |
+
# D.1 METADATA EXAMPLES
|
| 462 |
+
|
| 463 |
+

|
| 464 |
+
|
| 465 |
+
(a) Metadata for code includes the file extension, source (github or gitlab), filename, and binned number of stars for GitHub repositories (in logarithmically-sized bins numbered 0 to 5, see Section A.3).
|
| 466 |
+
|
| 467 |
+

|
| 468 |
+
|
| 469 |
+
(b) In addition to the standard metadata used for all other code files, Jupyter Notebook metadata includes the kernel type (in this instance, Python) as well as the type of the cells in the notebook (either code or text).
|
| 470 |
+
|
| 471 |
+

|
| 472 |
+
|
| 473 |
+
(c) Metadata attributes for StackOverflow include question tags and discretized scores of questions and answers.
|
| 474 |
+
|
| 475 |
+
Figure 6: Examples of metadata attributes included in the training data to allow attribute-conditioned generation and attribute prediction. To allow both generation and prediction, attributes are randomly included either at the beginning of the document or at the end (with probability 0.5 each). Attributes occur in random order to allow arbitrary orderings at inference time.
|
| 476 |
+
|
| 477 |
+
# D.2 EXAMPLE MODEL OUTPUTS
|
| 478 |
+
|
| 479 |
+

|
| 480 |
+
|
| 481 |
+
(a) Reference docstring: Returns a snowflake.connection object.
|
| 482 |
+
Model docstring: Establishes a connection to the Snowflake cluster. (b) Reference docstring: Format text with color or other effects into ANSI escaped string.
|
| 483 |
+
Model docstring: Prints a string with ANSI color codes.
|
| 484 |
+
|
| 485 |
+

|
| 486 |
+
|
| 487 |
+
Figure 7: Example docstring generations for the CodeXGLUE code-to-text dataset. Captions for each example give the reference human-written docstring and the output from our INCODER-6.7B model with causal-masked infilling. The model generates docstrings zero-shot by inserting text between the """ comment delimiters.
|
| 488 |
+
|
| 489 |
+

|
| 490 |
+
Figure 8: Meta-data conditioning on file extensions for Python (left) and Shell (right) allows completing the same text comment as either a Python script or a pipelined bash command, respectively. Regions highlighted in orange are left-to-right generations from our INCODER-6.7B model.
|
| 491 |
+
|
| 492 |
+

|
| 493 |
+
Figure 9: Given the beginning of a class definition and right-sided context of the class being used, the model is able to infer plausible attribute names for the class (e.g., “Eren” is likely to be a name, 18 is age, “Male” is the gender.) The region highlighted in orange is an infill generation from our INCODER-6.7B model.
|
| 494 |
+
|
| 495 |
+

|
| 496 |
+
Figure 10: By inserting a comment (# use a Huber loss) in the code and replacing the line after with a mask token, a user can prompt the model to in-fill a region of code with a contextuallyappropriate replacement. Lines in orange are in-fill generations from our INCODER-6.7B model.
|
| 497 |
+
|
| 498 |
+
´» Generate ansµer cond¼t¼oned on quest¼on
|
| 499 |
+
|
| 500 |
+
I need to write a Python function called \`snake_to_camel\`. Here's a description:
|
| 501 |
+
"Write a function to convert a snake case string to a camel case string."
|
| 502 |
+
<| q tags=python |>
|
| 503 |
+
<| a |>
|
| 504 |
+
You can use str.title:
|
| 505 |
+
<code>
|
| 506 |
+
>>> 'my_snake_case'.title()
|
| 507 |
+
'MySnakeCase'
|
| 508 |
+
</code>
|
| 509 |
+
</ a tags=python dscor $a = 3$ |>
|
| 510 |
+
|
| 511 |
+
# 2. Add comment
|
| 512 |
+
|
| 513 |
+
I need to write a Python function called \`snake_to_camel\`. Here's a description: "Write a function to convert a snake case string to a camel case string." <| q tags ${ } , = { }$ python |>
|
| 514 |
+
<| a |>
|
| 515 |
+
You can use str.title:
|
| 516 |
+
<code>
|
| 517 |
+
>>> 'my_snake_case'.title()
|
| 518 |
+
'MySnakeCase'
|
| 519 |
+
</code>
|
| 520 |
+
</ a tags ${ } _ { , } = { }$ python dscore $^ { \cdot = 3 }$ |>
|
| 521 |
+
<| c |>
|
| 522 |
+
Close, but you need to replace the underscores with an empty string.
|
| 523 |
+
<|/ c |>
|
| 524 |
+
<| c |>
|
| 525 |
+
Thanks, edited!
|
| 526 |
+
<|/ c |>
|
| 527 |
+
|
| 528 |
+
# 3. Regenerate ¼nfill cond¼t¼oned on comment
|
| 529 |
+
|
| 530 |
+
I need to write a Python function called \`snake_to_camel\`. Here's a description: "Write a function to convert a snake case string to a camel case string." <| q tags $; =$ python |>
|
| 531 |
+
<| a |>
|
| 532 |
+
<code>
|
| 533 |
+
def snake_to_camel(name):
|
| 534 |
+
return ''.join(x.title() for x in name.split('_'))
|
| 535 |
+
</code>
|
| 536 |
+
$< /$ a tag ${ \sf S } ^ { \sf = }$ python dscor $e = 3$ |>
|
| 537 |
+
<| c |>
|
| 538 |
+
Close, but you need to replace the underscores with an empty string.
|
| 539 |
+
<|/ c |>
|
| 540 |
+
<| c |>
|
| 541 |
+
Thanks, edited!
|
| 542 |
+
<|/ c |>
|
| 543 |
+
|
| 544 |
+
Figure 11: Pretraining on StackOverflow, and our model’s infilling capability, allows it to perform zero-shot interactive refinement of a function. In the first example, the model has generated the orange region conditioned on the user description. In the second example, the user has added a comment specifying a refinement to the function, and selected the text for the model to replace. In the third example, the orange region has been infilled by the model.
|
| 545 |
+
|
| 546 |
+

|
| 547 |
+
Figure 12: Question tag and title prediction from the text of a StackOverflow question. Regions highlighted in orange are infill generations from our INCODER-6.7B model.
|
| 548 |
+
|
| 549 |
+

|
| 550 |
+
Figure 13: Zero-shot bidirectional technical jargon translation between Chinese and English. Regions in orange are infill generations from our INCODER-6.7B model.
|
md/dev/k7p_YAO7yE/k7p_YAO7yE.md
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MAPTR: STRUCTURED MODELING AND LEARNING FOR ONLINE VECTORIZED HD MAP CONSTRUCTION
|
| 2 |
+
|
| 3 |
+
Bencheng Liao $^ { 1 , 2 , 3 * }$ Shaoyu Chen $^ { 2 , 3 \ * }$ Xinggang Wang 2 † Tianheng Cheng 2, 3 Qian Zhang 3 Wenyu Liu 2 Chang Huang
|
| 4 |
+
|
| 5 |
+
1 Institute of Artificial Intelligence, Huazhong University of Science & Technology
|
| 6 |
+
2 School of EIC, Huazhong University of Science & Technology
|
| 7 |
+
3 Horizon Robotics
|
| 8 |
+
{bcliao,shaoyuchen,xgwang,thch,liuwy}@hust.edu.cn
|
| 9 |
+
{qian01.zhang, chang.huang}@horizon.ai
|
| 10 |
+
|
| 11 |
+
# ABSTRACT
|
| 12 |
+
|
| 13 |
+
High-definition (HD) map provides abundant and precise environmental information of the driving scene, serving as a fundamental and indispensable component for planning in autonomous driving system. We present MapTR, a structured end-to-end Transformer for efficient online vectorized HD map construction. We propose a unified permutation-equivalent modeling approach, i.e., modeling map element as a point set with a group of equivalent permutations, which accurately describes the shape of map element and stabilizes the learning process. We design a hierarchical query embedding scheme to flexibly encode structured map information and perform hierarchical bipartite matching for map element learning. MapTR achieves the best performance and efficiency with only camera input among existing vectorized map construction approaches on nuScenes dataset. In particular, MapTR-nano runs at real-time inference speed (25.1 FPS) on RTX 3090, $8 \times$ faster than the existing state-of-the-art camera-based method while achieving 5.0 higher mAP. Even compared with the existing stateof-the-art multi-modality method, MapTR-nano achieves 0.7 higher mAP , and MapTR-tiny achieves 13.5 higher mAP and $3 \times$ faster inference speed. Abundant qualitative results show that MapTR maintains stable and robust map construction quality in complex and various driving scenes. MapTR is of great application value in autonomous driving. Code and more demos are available at https://github.com/hustvl/MapTR.
|
| 14 |
+
|
| 15 |
+
# 1 INTRODUCTION
|
| 16 |
+
|
| 17 |
+
High-definition (HD) map is the high-precision map specifically designed for autonomous driving, composed of instance-level vectorized representation of map elements (pedestrian crossing, lane divider, road boundaries, etc.). HD map contains rich semantic information of road topology and traffic rules, which is vital for the navigation of self-driving vehicle.
|
| 18 |
+
|
| 19 |
+
Conventionally HD map is constructed offline with SLAM-based methods (Zhang & Singh, 2014; Shan & Englot, 2018; Shan et al., 2020), incurring complicated pipeline and high maintaining cost. Recently, online HD map construction has attracted ever-increasing interests, which constructs map around ego-vehicle at runtime with vehicle-mounted sensors, getting rid of offline human efforts.
|
| 20 |
+
|
| 21 |
+
Early works (Chen et al., 2022a; Liu et al., 2021a; Can et al., 2021) leverage line-shape priors to perceive open-shape lanes based on the front-view image. They are restricted to single-view perception and can not cope with other map elements with arbitrary shapes. With the development of bird’s eye view (BEV) representation learning, recent works (Chen et al., 2022b; Zhou & Krahenb ¨ uhl ¨ , 2022; Hu et al., 2021; Li et al., 2022c) predict rasterized map by performing BEV semantic segmentation. However, the rasterized map lacks vectorized instance-level information, such as the lane structure, which is important for the downstream tasks (e.g., motion prediction and planning). To construct vectorized HD map, HDMapNet (Li et al., 2022a) groups pixel-wise segmentation results, which requires complicated and time-consuming post-processing. VectorMapNet (Liu et al., 2022a) represents each map element as a point sequence. It adopts a cascaded coarse-to-fine framework and utilizes auto-regressive decoder to predict points sequentially, leading to long inference time.
|
| 22 |
+
|
| 23 |
+

|
| 24 |
+
Figure 1. MapTR maintains stable and robust vectorized HD map construction quality in complex and various driving scenes.
|
| 25 |
+
|
| 26 |
+
Current online vectorized HD map construction methods are restricted by the efficiency and not applicable in real-time scenarios. Recently, DETR (Carion et al., 2020) employs a simple and efficient encoder-decoder Transformer architecture and realizes end-to-end object detection.
|
| 27 |
+
|
| 28 |
+
It is natural to ask a question: Can we design a DETR-like paradigm for efficient end-to-end vectorized HD map construction? We show that the answer is affirmative with our proposed Map TRansformer (MapTR).
|
| 29 |
+
|
| 30 |
+
Different from object detection in which objects can be easily geometrically abstracted as bounding box, vectorized map elements have more dynamic shapes. To accurately describe map elements, we propose a novel unified modeling method. We model each map element as a point set with a group of equivalent permutations. The point set determines the position of the map element. And the permutation group includes all the possible organization sequences of the point set corresponding to the same geometrical shape, avoiding the ambiguity of shape.
|
| 31 |
+
|
| 32 |
+
Based on the permutation-equivalent modeling, we design a structured framework which takes as input images of vehicle-mounted cameras and outputs vectorized HD map. We streamline the online vectorized HD map construction as a parallel regression problem. Hierarchical query embeddings are proposed to flexibly encode instance-level and point-level information. All instances and all points of instance are simultaneously predicted with a unified Transformer structure. And the training pipeline is formulated as a hierarchical set prediction task, where we perform hierarchical bipartite matching to assign instances and points in turn. And we supervise the geometrical shape in both point and edge levels with the proposed point2point loss and edge direction loss.
|
| 33 |
+
|
| 34 |
+
With all the proposed designs, we present MapTR, an efficient end-to-end online vectorized HD map construction method with unified modeling and architecture. MapTR achieves the best performance and efficiency among existing vectorized map construction approaches on nuScenes (Caesar et al., 2020) dataset. In particular, MapTR-nano runs at real-time inference speed (25.1 FPS) on RTX 3090, $8 \times$ faster than the existing state-of-the-art camera-based method while achieving 5.0 higher mAP. Even compared with the existing state-of-the-art multi-modality method, MapTR-nano achieves 0.7 higher mAP and $8 \times$ faster inference speed, and MapTR-tiny achieves 13.5 higher mAP and $3 \times$ faster inference speed. As the visualization shows (Fig. 1), MapTR maintains stable and robust map construction quality in complex and various driving scenes.
|
| 35 |
+
|
| 36 |
+
Our contributions can be summarized as follows:
|
| 37 |
+
|
| 38 |
+
• We propose a unified permutation-equivalent modeling approach for map elements, i.e., modeling map element as a point set with a group of equivalent permutations, which accurately describes the shape of map element and stabilizes the learning process. Based on the novel modeling, we present MapTR, a structured end-to-end framework for efficient online vectorized HD map construction. We design a hierarchical query embedding scheme to flexibly encode instance-level and point-level information, perform hierarchical bipartite matching for map element learning, and supervise the geometrical shape in both point and edge levels with the proposed point2point loss and edge direction loss. • MapTR is the first real-time and SOTA vectorized HD map construction approach with stable and robust performance in complex and various driving scenes.
|
| 39 |
+
|
| 40 |
+
# 2 RELATED WORK
|
| 41 |
+
|
| 42 |
+
HD Map Construction. Recently, with the development of 2D-to-BEV methods (Ma et al., 2022), HD map construction is formulated as a segmentation problem based on surround-view image data captured by vehicle-mounted cameras. Chen et al. (2022b); Zhou & Krahenb ¨ uhl ¨ (2022); Hu et al. (2021); Li et al. (2022c); Philion & Fidler (2020); Liu et al. (2022b) generate rasterized map by performing BEV semantic segmentation. To build vectorized HD map, HDMapNet (Li et al., 2022a) groups pixel-wise semantic segmentation results with heuristic and time-consuming post-processing to generate instances. VectorMapNet (Liu et al., 2022a) serves as the first end-to-end framework, which adopts a two-stage coarse-to-fine framework and utilizes auto-regressive decoder to predict points sequentially, leading to long inference time and the ambiguity about permutation. Different from VectorMapNet, MapTR introduces novel and unified modeling for map element, solving the ambiguity and stabilizing the learning process. And MapTR builds a structured and parallel onestage framework with much higher efficiency.
|
| 43 |
+
|
| 44 |
+
Lane Detection. Lane detection can be viewed as a sub task of HD map construction, which focuses on detecting lane elements in the road scenes. Since most datasets of lane detection only provide single view annotations and focus on open-shape elements, related methods are restricted to single view. LaneATT (Tabelini et al., 2021) utilizes anchor-based deep lane detection model to achieve good trade-off between accuracy and efficiency. LSTR (Liu et al., 2021a) adopts the Transformer architecture to directly output parameters of a lane shape model. GANet (Wang et al., 2022) formulates lane detection as a keypoint estimation and association problem and takes a bottom-up design. Feng et al. (2022) proposes parametric Bezier curve-based method for lane detection. Instead of detecting lane in the 2D image coordinate, Garnett et al. (2019) proposes 3D-LaneNet which performs 3D lane detection in BEV. STSU (Can et al., 2021) represents lanes as a directed graph in BEV coordinates and adopts curve-based Bezier method to predict lanes from monocular camera image. Persformer (Chen et al., 2022a) provides better BEV feature representation and optimizes anchor design to unify 2D and 3D lane detection simultaneously. Instead of only detecting lanes in the limited single view, MapTR can perceive various kinds of map elements of $3 6 0 ^ { \circ }$ horizontal FOV, with a unified modeling and learning framework.
|
| 45 |
+
|
| 46 |
+

|
| 47 |
+
Figure 2. Typical cases for illustrating the ambiguity of map element about start point and direction. (a) Polyline: for the lane divider between two opposite lanes, defining its direction is difficult. Both endpoints of the lane divider can be regarded as the start point and the point set can be organized in two directions. (b) Polygon: for the pedestrian crossing, each point of the polygon can be regarded as the start point, and the polygon can be connected in two opposite directions (counter-clockwise and clockwise).
|
| 48 |
+
|
| 49 |
+
Contour-based Instance Segmentation. Another line of work related to MapTR is contour-based 2D instance segmentation (Zhu et al., 2022; Xie et al., 2020; Xu et al., 2019; Liu et al., 2021c). These methods reformulate 2D instance segmentation as object contour prediction task, and estimate the image coordinates of the contour vertices. CurveGCN (Ling et al., 2019) utilizes Graph Convolution Networks to predict polygonal boundaries. Lazarow et al. (2022); Liang et al. (2020); Li et al. (2021); Peng et al. (2020) rely on intermediate representations and adopt a two-stage paradigm, i.e., the first stage performs segmentation / detection to generate vertices and the second stage converts vertices to polygons. These works model contours of 2D instance masks as polygons. Their modeling methods cannot cope with line-shape map elements and are not applicable for map construction. Differently, MapTR is tailored for HD map construction and models various kinds of map elements in a unified manner. Besides, MapTR does not rely on intermediate representations and has an efficient and compact pipeline.
|
| 50 |
+
|
| 51 |
+
# 3 MAPTR
|
| 52 |
+
|
| 53 |
+
# 3.1 PERMUTATION-EQUIVALENT MODELING
|
| 54 |
+
|
| 55 |
+
MapTR aims at modeling and learning the HD map in a unified manner. HD map is a collection of vectorized static map elements, including pedestrian crossing, lane divider, road boundarie, etc. For structured modeling, MapTR geometrically abstracts map elements as closed shape (like pedestrian crossing) and open shape (like lane divider). Through sampling points sequentially along the shape boundary, closed-shape element is discretized into polygon while open-shape element is discretized into polyline.
|
| 56 |
+
|
| 57 |
+
Preliminarily, both polygon and polyline can be represented as an ordered point set ${ \begin{array} { r l } { V ^ { F } } & { = } \end{array} }$ $\left[ v _ { 0 } , v _ { 1 } , \ldots , v _ { N _ { v } - 1 } \right]$ (see Fig. 3 (Vanilla)). $N _ { v }$ denotes the number of points. However, the permutation of the point set is not explicitly defined and not unique. There exist many equivalent permutations for polygon and polyline. For example, as illustrated in Fig. 2 (a), for the lane divider (polyline) between two opposite lanes, defining its direction is difficult. Both endpoints of the lane divider can be regarded as the start point and the point set can be organized in two directions. In Fig. 2 (b), for the pedestrian crossing (polygon), the point set can be organized in two opposite directions (counter-clockwise and clockwise). And circularly changing the permutation of point set has no influence on the geometrical shape of the polygon. Imposing a fixed permutation to the point set as supervision is not rational. The imposed fixed permutation contradicts with other equivalent permutations, hampering the learning process.
|
| 58 |
+
|
| 59 |
+
To bridge this gap, MapTR models each map element with $ { \boldsymbol { \nu } } = ( V , { \Gamma } )$ . $V = \{ v _ { j } \} _ { j = 0 } ^ { N _ { v } - 1 }$ denotes the point set of the map element ( $N _ { v }$ is the number of points). $\Gamma = \{ \gamma ^ { k } \}$ denotes a group of equivalent permutations of the point set $V$ , covering all the possible organization sequences.
|
| 60 |
+
|
| 61 |
+
Specifically, for polyline element (see Fig. 3 (left)), $\Gamma$ includes 2 kinds of equivalent permutations:
|
| 62 |
+
|
| 63 |
+
$$
|
| 64 |
+
\Gamma _ { \mathrm { p o l y l i n e } } = \{ \gamma ^ { 0 } , \gamma ^ { 1 } \} \left\{ \begin{array} { c } { { \gamma ^ { 0 } ( j ) = j \mod N _ { v } , } } \\ { { \gamma ^ { 1 } ( j ) = ( N _ { v } - 1 ) - j \mod N _ { v } . } } \end{array} \right.
|
| 65 |
+
$$
|
| 66 |
+
|
| 67 |
+

|
| 68 |
+
Figure 3. Illustration of permutation-equivalent modeling of MapTR. Map elements are geometrically abstracted and discretized into polylines and polygons. MapTR models each map element with $( V , \Gamma )$ (a point set $V$ and a group of equivalent permutations $\Gamma$ ), avoiding the ambiguity and stabilizing the learning process.
|
| 69 |
+
|
| 70 |
+
For polygon element (see Fig. 3 (right)), $\Gamma$ includes $2 \times N _ { v }$ kinds of equivalent permutations:
|
| 71 |
+
|
| 72 |
+
$$
|
| 73 |
+
\Gamma _ { \mathrm { p o l y g o n } } = \{ \gamma ^ { 0 } , \dots , \gamma ^ { 2 \times N _ { v } - 1 } \} \left\{ \begin{array} { l l } { \gamma ^ { 0 } ( j ) = j \quad \mathrm { m o d } \ N _ { v } , } \\ { \gamma ^ { 1 } ( j ) = ( N _ { v } - 1 ) - j \quad \mathrm { m o d } \ N _ { v } , } \\ { \gamma ^ { 2 } ( j ) = ( j + 1 ) \quad \mathrm { m o d } \ N _ { v } , } \\ { \gamma ^ { 3 } ( j ) = ( N _ { v } - 1 ) - ( j + 1 ) \quad \mathrm { m o d } \ N _ { v } , } \\ { \dots } \\ { \gamma ^ { 2 \times N _ { v } - 2 } ( j ) = ( j + N _ { v } - 1 ) \quad \mathrm { m o d } \ N _ { v } , } \\ { \gamma ^ { 2 \times N _ { v } - 1 } ( j ) = ( N _ { v } - 1 ) - ( j + N _ { v } - 1 ) \quad \mathrm { m o d } \ N _ { v } . } \end{array} \right.
|
| 74 |
+
$$
|
| 75 |
+
|
| 76 |
+
By introducing the conception of equivalent permutations, MapTR models map elements in a unified manner and addresses the ambiguity issue. MapTR further introduces hierarchical bipartite matching (see Sec. 3.2 and Sec. 3.3) for map element learning, and designs a structured encoder-decoder Transformer architecture to efficiently predict map elements (see Sec. 3.4).
|
| 77 |
+
|
| 78 |
+
# 3.2 HIERARCHICAL MATCHING
|
| 79 |
+
|
| 80 |
+
MapTR parallelly infers a fixed-size set of $N$ map elements in a single pass, following the endtoend paradigm of query-based object detection and segmentation paradigm (Carion et al., 2020; Fang et al., 2021a;b). $N$ is set to be larger than the typical number of map elements in a scene. Let’s denote the set of $N$ predicted map elements by $\hat { Y } = \{ \hat { y } _ { i } \} _ { i = 0 } ^ { N - 1 }$ . The set of ground-truth (GT) map elements is padded with $\mathcal { D }$ (no object) to form a set with size $N$ , denoted by $Y = \{ y _ { i } \} _ { i = 0 } ^ { N - 1 }$ . $y _ { i } = ( c _ { i } , V _ { i } , \Gamma _ { i } )$ , where $c _ { i }$ , $V _ { i }$ and $\Gamma _ { i }$ are respectively the target class label, point set and permutation group of GT map element $y _ { i }$ . $\hat { y } _ { i } = ( \hat { p } _ { i } , \hat { V } _ { i } )$ , where $\hat { p } _ { i }$ and $\hat { V } _ { i }$ are respectively the predicted classification score and predicted point set. To achieve structured map element modeling and learning, MapTR introduces hierarchical bipartite matching, i.e., performing instance-level matching and point-level matching in order.
|
| 81 |
+
|
| 82 |
+
Instance-level Matching. First, we need to find an optimal instance-level label assignment $\hat { \pi }$ between predicted map elements $\left\{ \hat { y } _ { i } \right\}$ and GT map elements $\{ y _ { i } \}$ . $\hat { \pi }$ is a permutation of $N$ elements $( { \hat { \pi } } \in \Pi _ { N } )$ ) with the lowest instance-level matching cost:
|
| 83 |
+
|
| 84 |
+
$$
|
| 85 |
+
\hat { \pi } = \underset { \pi \in \Pi _ { N } } { \arg \operatorname* { m i n } } \sum _ { i = 0 } ^ { N - 1 } \mathcal { L } _ { \mathrm { i n s \_ m a t c h } } \big ( \hat { y } _ { \pi ( i ) } , y _ { i } \big ) .
|
| 86 |
+
$$
|
| 87 |
+
|
| 88 |
+
$\mathcal { L } _ { \mathrm { i n s . m a t c h } } \big ( \hat { y } _ { \pi ( i ) } , y _ { i } \big )$ is a pair-wise matching cost between prediction $\hat { y } _ { \pi ( i ) }$ and $\mathrm { G T } y _ { i }$ , which considers both the class label of map element and the position of point set:
|
| 89 |
+
|
| 90 |
+
$$
|
| 91 |
+
\mathcal { L } _ { \mathrm { i n s . m a t c h } } ( \hat { y } _ { \pi ( i ) } , y _ { i } ) = \mathcal { L } _ { \mathrm { F o c a l } } \big ( \hat { p } _ { \pi ( i ) } , c _ { i } \big ) + \mathcal { L } _ { \mathrm { p o s i t i o n } } \big ( \hat { V } _ { \pi ( i ) } , V _ { i } \big ) .
|
| 92 |
+
$$
|
| 93 |
+
|
| 94 |
+
$\mathcal { L } _ { \mathrm { F o c a l } } ( \hat { p } _ { \pi ( i ) } , c _ { i } )$ is the class matching cost term, defined as the Focal Loss (Lin et al., 2017) between predicted classification score $\hat { p } _ { \pi ( i ) }$ and target class label $c _ { i }$ . $\mathcal { L } _ { \mathrm { p o s i t i o n } } ( \hat { V } _ { \pi ( i ) } , V _ { i } )$ is the position matching cost term, which reflects the position correlation between the predicted point set $\hat { V } _ { \pi ( i ) }$ and the GT point set $V _ { i }$ (refer to Sec. B for more details). Hungarian algorithm is utilized to find the optimal instance-level assignment $\hat { \pi }$ following DETR.
|
| 95 |
+
|
| 96 |
+
Point-level Matching. After instance-level matching, each predicted map element $\hat { y } _ { \hat { \pi } ( i ) }$ is assigned with a GT map element $y _ { i }$ . Then for each predicted instance assigned with positive labels $( c _ { i } \neq \emptyset )$ ), we perform point-level matching to find an optimal point2point assignment $\hat { \gamma } \in \Gamma$ between predicted point set $\hat { V } _ { \hat { \pi } ( i ) }$ and GT point set $V _ { i }$ . $\hat { \gamma }$ is selected among the predefined permutation group $\Gamma$ and with the lowest point-level matching cost:
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
\hat { \gamma } = \underset { \gamma \in \Gamma } { \arg \operatorname* { m i n } } \sum _ { j = 0 } ^ { N _ { v } - 1 } D _ { \mathrm { M a n h a t t a n } } \big ( \hat { v } _ { j } , v _ { \gamma ( j ) } \big ) .
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
$D _ { \mathrm { M a n h a t t a n } } \big ( \hat { v } _ { j } , v _ { \gamma ( j ) } \big )$ is the Manhattan distance between the $j$ -th point of the predicted point set $\hat { V }$ and the $\gamma ( j )$ -th point of the GT point set $V$ .
|
| 103 |
+
|
| 104 |
+
# 3.3 TRAINING LOSS
|
| 105 |
+
|
| 106 |
+
MapTR is trained based on the optimal instance-level and point-level assignment $\hat { \pi }$ and $\{ \hat { \gamma } _ { i } \}$ ). The loss function is composed of three parts, classification loss, point2point loss and edge direction loss:
|
| 107 |
+
|
| 108 |
+
$$
|
| 109 |
+
\begin{array} { r } { \mathcal { L } = \lambda \mathcal { L } _ { \mathrm { c l s } } + \alpha \mathcal { L } _ { \mathrm { p 2 p } } + \beta \mathcal { L } _ { \mathrm { d i r } } , } \end{array}
|
| 110 |
+
$$
|
| 111 |
+
|
| 112 |
+
where $\lambda$ , $\alpha$ and $\beta$ are the weights for balancing different loss terms.
|
| 113 |
+
|
| 114 |
+
Classification Loss. With the instance-level optimal matching result $\hat { \pi }$ , each predicted map element is assigned with a class label . The classification loss is a Focal Loss term formulated as:
|
| 115 |
+
|
| 116 |
+
$$
|
| 117 |
+
\mathcal { L } _ { \mathrm { c l s } } = \sum _ { i = 0 } ^ { N - 1 } \mathcal { L } _ { \mathrm { F o c a l } } \mathopen { } \mathclose \bgroup \left( \hat { p } _ { \hat { \pi } ( i ) } , c _ { i } \aftergroup \egroup \right) .
|
| 118 |
+
$$
|
| 119 |
+
|
| 120 |
+
Point2point Loss. Point2point loss supervises the position of each predicted point. For each GT instance with index $i$ , according to the point-level optimal matching result $\hat { \gamma } _ { i }$ , each predicted point $\hat { v } _ { \hat { \pi } ( i ) , j }$ is assigned with a GT point $v _ { i , \hat { \gamma } _ { i } ( j ) }$ . The point2point loss is defined as the Manhattan distance computed between each assigned point pair:
|
| 121 |
+
|
| 122 |
+
$$
|
| 123 |
+
\mathcal { L } _ { \mathrm { p 2 p } } = \sum _ { i = 0 } ^ { N - 1 } \mathbb { 1 } _ { \{ c _ { i } \neq \emptyset \} } \sum _ { j = 0 } ^ { N _ { v } - 1 } D _ { \mathrm { M a n h a t t a n } } \big ( \hat { v } _ { \hat { \pi } ( i ) , j } , v _ { i , \hat { \gamma } _ { i } ( j ) } \big ) .
|
| 124 |
+
$$
|
| 125 |
+
|
| 126 |
+
Edge Direction Loss. Point2point loss only supervises the node point of polyline and polygon, not considering the edge (the connecting line between adjacent points). For accurately representing map elements, the direction of the edge is important. Thus, we further design edge direction loss to supervise the geometrical shape in the higher edge level. Specifically, we consider the cosine similarity of the paired predicted edge $\hat { e } _ { \hat { \pi } ( i ) , j }$ and GT edge $e _ { i , \hat { \gamma } _ { i } ( j ) }$ :
|
| 127 |
+
|
| 128 |
+
$$
|
| 129 |
+
\mathcal { L } _ { \mathrm { d i r } } = - \sum _ { i = 0 } ^ { N - 1 } \mathbb { 1 } _ { \{ c _ { i } \neq \emptyset \} } \sum _ { j = 0 } ^ { N _ { v } - 1 } \mathrm { c o s i n e \_ s i m i l a r i t y } \big ( \hat { e } _ { \hat { \pi } ( i ) , j } , e _ { i , \hat { \gamma } _ { i } ( j ) } \big ) ,
|
| 130 |
+
$$
|
| 131 |
+
|
| 132 |
+
# 3.4 ARCHITECTURE
|
| 133 |
+
|
| 134 |
+
MapTR designs an encoder-decoder paradigm. The overall architecture is depicted in Fig. 4.
|
| 135 |
+
|
| 136 |
+

|
| 137 |
+
Figure 4. The overall architecture of MapTR. MapTR adopts an encoder-decoder paradigm. The map encoder transforms sensor input to a unified BEV representation. The map decoder adopts a hierarchical query embedding scheme to explicitly encode map elements and performs hierarchical matching based on the permutationequivalent modeling. MapTR is fully end-to-end. The pipeline is highly structured, compact and efficient.
|
| 138 |
+
|
| 139 |
+
Input Modality. MapTR takes surround-view images of vehicle-mounted cameras as input. MapTR is also compatible with other vehicle-mounted sensors (e.g., LiDAR and RADAR). Extending MapTR to multi-modality data is straightforward and trivial. And thanks to the rational permutation-equivalent modeling, even with only camera input, MapTR significantly outperforms other methods with multi-modality input.
|
| 140 |
+
|
| 141 |
+
Map Encoder. The map encoder of MapTR extracts features from images of multiple vehiclemounted cameras and transforms the features into a unified feature representation, i.e., BEV representation. Given multi-view images $\mathcal { T } = \{ I _ { 1 } , \ldots , I _ { K } \}$ , we leverage a conventional backbone to generate multi-view feature maps $\mathcal { F } = \{ F _ { 1 } , \ldots , F _ { K } \}$ . Then 2D image features $\mathcal { F }$ are transformed to BEV features $B \in \mathbb { R } ^ { H \times W \times C }$ . By default, we adopt GKT (Chen et al., 2022b) as the basic 2D-toBEV transformation module, considering its easy-to-deploy property and high efficiency. MapTR is compatible with other transformation methods and maintains stable performance, e.g., CVT (Zhou & Krahenb ¨ uhl ¨ , 2022), LSS (Philion & Fidler, 2020; Liu et al., 2022c; Li et al., 2022b; Huang et al., 2021), Deformable Attention (Li et al., 2022c; Zhu et al., 2021) and IPM (Mallot et al., 1991). Ablation studies are presented in Tab. 4.
|
| 142 |
+
|
| 143 |
+
Map Decoder. We propose a hierarchical query embedding scheme to explicitly encode each map element. Specifically, we define a set of instance-level queries $\{ q _ { i } ^ { \mathrm { i n s } } \} _ { i = 0 } ^ { N - 1 }$ and a set of point-level queries {qptj }Nv−j=0 shared by all instances. Each map element (with index $i$ ) corresponds to a set of hierarchical queries {qhieij }Nv−1j=0 The hierarchical query of $j$ -th point of $i$ -th map element is formulated as:
|
| 144 |
+
|
| 145 |
+
$$
|
| 146 |
+
q _ { i j } ^ { \mathrm { h i e } } = q _ { i } ^ { \mathrm { i n s } } + q _ { j } ^ { \mathrm { p t } } .
|
| 147 |
+
$$
|
| 148 |
+
|
| 149 |
+
The map decoder contains several cascaded decoder layers which update the hierarchical queries iteratively. In each decoder layer, we adopt MHSA to make hierarchical queries exchange information with each other (both inter-instance and intra-instance). We then adopt Deformable Attention (Zhu et al., 2021) to make hierarchical queries interact with BEV features, inspired by BEVFormer (Li et al., 2022c). Each query qhieij predicts the 2-dimension normalized BEV coordinate $( x _ { i j } , y _ { i j } )$ of the reference point $p _ { i j }$ . We then sample BEV features around the reference points and update queries.
|
| 150 |
+
|
| 151 |
+
Map elements are usually with irregular scorresponds to a set of reference points $\{ p _ { i j } \} _ { j = 0 } ^ { N _ { v } - 1 }$ require long-range context. Each map element with flexible and dynamic distribution. The reference points {pij}Nv−j=0 can adapt to the arbitrary shape of map element and capture informative context for map element learning.
|
| 152 |
+
|
| 153 |
+
The prediction head of MapTR is simple, consisting of a classification branch and a point regression branch. The classification branch predicts instance class score. The point regression branch predicts the positions of the point sets $\hat { V }$ . For each map element, it outputs a $2 N _ { v }$ -dimension vector, which represents normalized BEV coordinates of the $N _ { v }$ points.
|
| 154 |
+
|
| 155 |
+
# 4 EXPERIMENTS
|
| 156 |
+
|
| 157 |
+
Dataset and Metric. We evaluate MapTR on the popular nuScenes (Caesar et al., 2020) dataset, which contains 1000 scenes of roughly 20s duration each. Key samples are annotated at 2Hz. Each sample has RGB images from 6 cameras and covers $3 6 0 ^ { \circ }$ horizontal FOV of the ego-vehicle. Following the previous methods (Li et al., 2022a; Liu et al., 2022a), three kinds of map elements are chosen for fair evaluation – pedestrian crossing, lane divider, and road boundary. The perception ranges are $[ - 1 5 . 0 m , 1 5 . 0 m ]$ for the $X$ -axis and $[ - 3 0 . 0 m , 3 0 . 0 m ]$ for the $Y$ -axis. And we adopt average precision (AP) to evaluate the map construction quality. Chamfer distance $D _ { C h a m f e r }$ is used to determine whether the prediction and GT are matched or not. We calculate the $\mathrm { A P } _ { \tau }$ under several $D _ { C h a m f e r }$ thresholds $( \tau \in T , T = \{ 0 . 5 , 1 . 0 , 1 . 5 \} )$ , and then average across all thresholds as the final AP metric:
|
| 158 |
+
|
| 159 |
+
$$
|
| 160 |
+
\mathrm { A P } = { \frac { 1 } { | \mathrm { T } | } } \sum _ { \tau \in \mathrm { T } } \mathrm { A P } _ { \tau } .
|
| 161 |
+
$$
|
| 162 |
+
|
| 163 |
+
Implementation Details. MapTR is trained with 8 NVIDIA GeForce RTX 3090 GPUs. We adopt AdamW (Loshchilov & Hutter, 2019) optimizer and cosine annealing schedule. For MapTR-tiny, we adopt ResNet50 (He et al., 2016) as the backbone. We train MapTR-tiny with a total batch size of 32 (containig 6 view images). All ablation studies are based on MapTR-tiny trained with 24 epochs. MapTR-nano is designed for real-time applications. We adopt ResNet18 as the backbone. More details are provided in Appendix A.
|
| 164 |
+
|
| 165 |
+
# 4.1 COMPARISONS WITH STATE-OF-THE-ART METHODS
|
| 166 |
+
|
| 167 |
+
In Tab. 1, we compare MapTR with state-of-the-art methods. MapTR-nano runs at real-time inference speed (25.1 FPS) on RTX 3090, $8 \times$ faster than the existing state-of-the-art camera-based method (VectorMapNet-C) while achieving 5.0 higher mAP. Even compared with the existing stateof-the-art multi-modality method, MapTR-nano achieves 0.7 higher mAP and $8 \times$ faster inference speed, and MapTR-tiny achieves 13.5 higher mAP and $3 \times$ faster inference speed. MapTR is also a fast converging method, which demonstrate advanced performance with 24-epoch schedule.
|
| 168 |
+
|
| 169 |
+
<table><tr><td>Method</td><td>Modality</td><td>Backbone</td><td>Epochs</td><td>APped</td><td>APdivider</td><td>APboundary</td><td>mAP</td><td>FPS</td></tr><tr><td>HDMapNet</td><td>C</td><td>Eff-BO</td><td>30</td><td>14.4</td><td>21.7</td><td>33.0</td><td>23.0</td><td>0.8</td></tr><tr><td>HDMapNet</td><td>L</td><td>PointPillars</td><td>30</td><td>10.4</td><td>24.1</td><td>37.9</td><td>24.1</td><td>1.0</td></tr><tr><td>HDMapNet</td><td>C&L</td><td>Eff-BO & PointPillars</td><td>30</td><td>16.3</td><td>29.6</td><td>46.7</td><td>31.0</td><td>0.5</td></tr><tr><td>VectorMapNet</td><td>C</td><td>R50</td><td>110</td><td>36.1</td><td>47.3</td><td>39.3</td><td>40.9</td><td>2.9</td></tr><tr><td>VectorMapNet</td><td>L</td><td>PointPillars</td><td>110</td><td>25.7</td><td>37.6</td><td>38.6</td><td>34.0</td><td>1</td></tr><tr><td>VectorMapNet</td><td>C&L</td><td>R50 & PointPillars</td><td>110</td><td>37.6</td><td>50.5</td><td>47.5</td><td>45.2</td><td>-</td></tr><tr><td>MapTR-nano</td><td>C</td><td>R18</td><td>110</td><td>39.6</td><td>49.9</td><td>48.2</td><td>45.9</td><td>25.1</td></tr><tr><td>MapTR-tiny</td><td>C</td><td>R50</td><td>24</td><td>46.3</td><td>51.5</td><td>53.1</td><td>50.3</td><td>11.2</td></tr><tr><td>MapTR-tiny</td><td>C</td><td>R50</td><td>110</td><td>56.2</td><td>59.8</td><td>60.1</td><td>58.7</td><td>11.2</td></tr></table>
|
| 170 |
+
|
| 171 |
+
Table 1. Comparisons with state-of-the-art methods (Liu et al., 2022a; Li et al., 2022a) on nuScenes val set. “C” and ���L” respectively denotes camera and LiDAR. “Effi-B0” and “PointPillars” respectively correspond to Tan & Le (2019) and Lang et al. (2019). The APs of other methods are taken from the paper of VectorMapNet. The FPS of VectorMapNet-C is provided by its authors and measured on RTX 3090. Other FPSs are measured on the same machine with RTX 3090. “-” means that the corresponding results are not available. Even with only camera input, MapTR-tiny significantly outperforms multi-modality counterparts $\mathrm { ( + 1 3 . 5 \ m A P ) }$ ). MapTRnano achieves SOTA camera-based performance and runs at 25.1 FPS, realizing real-time vectorized map construction for the first time.
|
| 172 |
+
|
| 173 |
+
# 4.2 ABLATION STUDY
|
| 174 |
+
|
| 175 |
+
To validate the effectiveness of different designs, we conduct ablation experiments on nuScenes val set. More ablation studies are in Appendix B.
|
| 176 |
+
|
| 177 |
+
Effectiveness of Permutation-equivalent Modeling. In Tab. 2, we provide ablation experiments to validate the effectiveness of the proposed permutation-equivalent modeling. Compared with vanilla modeling method which imposes a unique permutation to the point set, permutationequivalent modeling solves the ambiguity of map element and brings an improvement of $5 . 9 \mathrm { \ m A P } .$ For pedestrian crossing, the improvement even reaches 11.9 AP, proving the superiority in modeling polygon elements. We also visualize the learning process in Fig. 5 to show the stabilization of the proposed modeling.
|
| 178 |
+
|
| 179 |
+
<table><tr><td>Modeling method</td><td>APped</td><td>APdivider</td><td>AP boundary</td><td>mAP</td></tr><tr><td>Fixed-order VF w/ ambiguity</td><td>34.4</td><td>48.1</td><td>50.7</td><td>44.4</td></tr><tr><td>Permutation-equivalent (V,I) w/o ambiguity</td><td>46.3</td><td>51.5</td><td>53.1</td><td>50.3</td></tr></table>
|
| 180 |
+
|
| 181 |
+
Table 2. Ablations about modeling method. Vanilla modeling method imposes a unique permutation to the point set, leading to ambiguity. MapTR introduces permutation-equivalent modeling to avoid the ambiguity, which stabilizes the learning process and significantly improves performance ( $+ 5 . 9 \mathrm { m A P }$ ).
|
| 182 |
+
|
| 183 |
+
Effectiveness of Edge Direction Loss. Ablations about the weight of edge direction loss are presented in Tab. 3. $\beta = 0$ means that we do not use edge direction loss. $\beta = 5 e ^ { - 3 }$ corresponds to appropriate supervision and is adopted as the default setting.
|
| 184 |
+
|
| 185 |
+
Table 3. Ablations about the weight $\beta$ of edge direction loss.
|
| 186 |
+
|
| 187 |
+
<table><tr><td>β</td><td>APped</td><td>APdivider</td><td>APboundary</td><td>mAP</td></tr><tr><td>0</td><td>41.4</td><td>51.3</td><td>51.9</td><td>48.2</td></tr><tr><td>3e-3</td><td>44.8</td><td>50.4</td><td>52.1</td><td>49.1</td></tr><tr><td>5e-3</td><td>46.3</td><td>51.5</td><td>53.1</td><td>50.3</td></tr><tr><td>1e-2</td><td>41.9</td><td>50.9</td><td>52.0</td><td>48.3</td></tr></table>
|
| 188 |
+
|
| 189 |
+
2D-to-BEV Transformation. In Tab. 4, we ablate on the 2D-to-BEV transformation methods (e.g., IPM (Mallot et al., 1991), LSS (Liu et al., 2022c; Philion & Fidler, 2020), Deformable Attention (Li et al., 2022c) and GKT (Chen et al., 2022b)). We use an optimized implementation of LSS (Liu et al., 2022c). And for fair comparison with IPM and LSS, GKT and Deformable Attention both adopt one-layer configuration. Experiments show MapTR is compatible with various 2D-to-BEV methods and achieves stable performance. We adopt GKT as the default configuration of MapTR, considering its easy-to-deploy property and high efficiency.
|
| 190 |
+
|
| 191 |
+
<table><tr><td>Method</td><td>mAP</td><td>FPS</td><td>Param.</td></tr><tr><td>IPM</td><td>46.2</td><td>11.7</td><td>35.7M</td></tr><tr><td rowspan="2">LSS Deform. Atten.</td><td>49.5</td><td>10.0</td><td>37.1M</td></tr><tr><td>49.7</td><td>11.2</td><td>36.0M</td></tr><tr><td>GKT</td><td>50.3</td><td>11.2</td><td>35.9M</td></tr></table>
|
| 192 |
+
|
| 193 |
+
Table 4. Ablations about 2D-to-BEV transformation methods. MapTR is compatible with various 2D-to-BEV methods and achieves stable performance.
|
| 194 |
+
|
| 195 |
+
# 4.3 QUALITATIVE VISUALIZATION
|
| 196 |
+
|
| 197 |
+
We show the predicted vectorized HD map results of complex and various driving scenes in Fig. 1. MapTR maintains stable and impressive results. More qualitative results are provided in Appendix C. We also provide videos (in the supplementary materials) to show the robustness.
|
| 198 |
+
|
| 199 |
+
# 5 CONCLUSION
|
| 200 |
+
|
| 201 |
+
MapTR is a structured end-to-end framework for efficient online vectorized HD map construction, which adopts a simple encoder-decoder Transformer architecture and hierarchical bipartite matching to perform map element learning based on the proposed permutation-equivalent modeling. Extensive experiments show that the proposed method can precisely perceive map elements of arbitrary shape in the challenging nuScenes dataset. We hope MapTR can serve as a basic module of self-driving system and boost the development of downstream tasks (e.g., motion prediction and planning).
|
| 202 |
+
|
| 203 |
+
# ACKNOWLEDGMENT
|
| 204 |
+
|
| 205 |
+
This work was in part supported by NSFC (No. 6227072399). We would like to thank Yicheng Liu for his guidance on evaluation and constructive discussions.
|
| 206 |
+
|
| 207 |
+
# REFERENCES
|
| 208 |
+
|
| 209 |
+
Holger Caesar, Varun Bankiti, Alex H Lang, Sourabh Vora, Venice Erin Liong, Qiang Xu, Anush Krishnan, Yu Pan, Giancarlo Baldan, and Oscar Beijbom. nuscenes: A multimodal dataset for autonomous driving. In CVPR, 2020.
|
| 210 |
+
|
| 211 |
+
Yigit Baran Can, Alexander Liniger, Danda Pani Paudel, and Luc Van Gool. Structured bird’s-eyeview traffic scene understanding from onboard images. In ICCV, 2021.
|
| 212 |
+
|
| 213 |
+
Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In ECCV, 2020.
|
| 214 |
+
|
| 215 |
+
Li Chen, Chonghao Sima, Yang Li, Zehan Zheng, Jiajie Xu, Xiangwei Geng, Hongyang Li, Conghui He, Jianping Shi, Yu Qiao, and Junchi Yan. Persformer: 3d lane detection via perspective transformer and the openlane benchmark. In ECCV, 2022a.
|
| 216 |
+
|
| 217 |
+
Shaoyu Chen, Tianheng Cheng, Xinggang Wang, Wenming Meng, Qian Zhang, and Wenyu Liu. Efficient and robust 2d-to-bev representation learning via geometry-guided kernel transformer. arXiv preprint arXiv:2206.04584, 2022b.
|
| 218 |
+
|
| 219 |
+
Yuxin Fang, Bencheng Liao, Xinggang Wang, Jiemin Fang, Jiyang Qi, Rui Wu, Jianwei Niu, and Wenyu Liu. You only look at one sequence: Rethinking transformer in vision through object detection. Advances in Neural Information Processing Systems, 34:26183–26197, 2021a.
|
| 220 |
+
|
| 221 |
+
Yuxin Fang, Shusheng Yang, Xinggang Wang, Yu Li, Chen Fang, Ying Shan, Bin Feng, and Wenyu Liu. Instances as queries. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 6910–6919, 2021b.
|
| 222 |
+
|
| 223 |
+
Zhengyang Feng, Shaohua Guo, Xin Tan, Ke Xu, Min Wang, and Lizhuang Ma. Rethinking efficient lane detection via curve modeling. In CVPR, 2022.
|
| 224 |
+
|
| 225 |
+
Noa Garnett, Rafi Cohen, Tomer Pe’er, Roee Lahav, and Dan Levi. 3d-lanenet: end-to-end 3d multiple lane detection. In ICCV, 2019.
|
| 226 |
+
|
| 227 |
+
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
|
| 228 |
+
|
| 229 |
+
Anthony Hu, Zak Murez, Nikhil Mohan, Sof´ıa Dudas, Jeffrey Hawke, Vijay Badrinarayanan, Roberto Cipolla, and Alex Kendall. FIERY: Future instance segmentation in bird’s-eye view from surround monocular cameras. In ICCV, 2021.
|
| 230 |
+
|
| 231 |
+
Junjie Huang, Guan Huang, Zheng Zhu, Ye Yun, and Dalong Du. Bevdet: High-performance multicamera 3d object detection in bird-eye-view. arXiv preprint arXiv:2112.11790, 2021.
|
| 232 |
+
|
| 233 |
+
Alex H. Lang, Sourabh Vora, Holger Caesar, Lubing Zhou, Jiong Yang, and Oscar Beijbom. Pointpillars: Fast encoders for object detection from point clouds. In CVPR, 2019.
|
| 234 |
+
|
| 235 |
+
Justin Lazarow, Weijian Xu, and Zhuowen Tu. Instance segmentation with mask-supervised polygonal boundary transformers. In CVPR, 2022.
|
| 236 |
+
|
| 237 |
+
Qi Li, Yue Wang, Yilun Wang, and Hang Zhao. Hdmapnet: An online hd map construction and evaluation framework. In ICRA, 2022a.
|
| 238 |
+
|
| 239 |
+
Weijia Li, Wenqian Zhao, Huaping Zhong, Conghui He, and Dahua Lin. Joint semantic-geometric learning for polygonal building segmentation. In AAAI, 2021.
|
| 240 |
+
|
| 241 |
+
Yinhao Li, Zheng Ge, Guanyi Yu, Jinrong Yang, Zengran Wang, Yukang Shi, Jianjian Sun, and Zeming Li. Bevdepth: Acquisition of reliable depth for multi-view 3d object detection. arXiv preprint arXiv:2206.10092, 2022b.
|
| 242 |
+
|
| 243 |
+
Zhiqi Li, Wenhai Wang, Hongyang Li, Enze Xie, Chonghao Sima, Tong Lu, Yu Qiao, and Jifeng Dai. Bevformer: Learning bird’s-eye-view representation from multi-camera images via spatiotemporal transformers. In ECCV, 2022c.
|
| 244 |
+
|
| 245 |
+
Justin Liang, Namdar Homayounfar, Wei-Chiu Ma, Yuwen Xiong, Rui Hu, and Raquel Urtasun. Polytransform: Deep polygon transformer for instance segmentation. In CVPR, 2020.
|
| 246 |
+
|
| 247 |
+
Tsung-Yi Lin, Priya Goyal, Ross B. Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense´ object detection. In ICCV, 2017.
|
| 248 |
+
|
| 249 |
+
Huan Ling, Jun Gao, Amlan Kar, Wenzheng Chen, and Sanja Fidler. Fast interactive object annotation with curve-gcn. In CVPR, 2019.
|
| 250 |
+
|
| 251 |
+
Ruijin Liu, Zejian Yuan, Tie Liu, and Zhiliang Xiong. End-to-end lane shape prediction with transformers. In WACV, 2021a.
|
| 252 |
+
|
| 253 |
+
Yicheng Liu, Yue Wang, Yilun Wang, and Hang Zhao. Vectormapnet: End-to-end vectorized hd map learning. arXiv preprint arXiv:2206.08920, 2022a.
|
| 254 |
+
|
| 255 |
+
Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 10012–10022, 2021b.
|
| 256 |
+
|
| 257 |
+
Zhi Liu, Shaoyu Chen, Xiaojie Guo, Xinggang Wang, Tianheng Cheng, Hongmei Zhu, Qian Zhang, Wenyu Liu, and Yi Zhang. Vision-based uneven bev representation learning with polar rasterization and surface estimation. arXiv preprint arXiv:2207.01878, 2022b.
|
| 258 |
+
|
| 259 |
+
Zhijian Liu, Haotian Tang, Alexander Amini, Xingyu Yang, Huizi Mao, Daniela Rus, and Song Han. Bevfusion: Multi-task multi-sensor fusion with unified bird’s-eye view representation. arXiv preprint arXiv:2205.13542, 2022c.
|
| 260 |
+
|
| 261 |
+
Zichen Liu, Jun Hao Liew, Xiangyu Chen, and Jiashi Feng. Dance: A deep attentive contour model for efficient instance segmentation. In WACVW, 2021c.
|
| 262 |
+
|
| 263 |
+
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In ICLR, 2019.
|
| 264 |
+
|
| 265 |
+
Yuexin Ma, Tai Wang, Xuyang Bai, Huitong Yang, Yuenan Hou, Yaming Wang, Y. Qiao, Ruigang Yang, Dinesh Manocha, and Xinge Zhu. Vision-centric bev perception: A survey. arXiv preprint arXiv:2208.02797, 2022.
|
| 266 |
+
|
| 267 |
+
Hanspeter A Mallot, Heinrich H Bulthoff, JJ Little, and Stefan Bohrer. Inverse perspective mapping ¨ simplifies optical flow computation and obstacle detection. Biological cybernetics, 1991.
|
| 268 |
+
|
| 269 |
+
Sida Peng, Wen Jiang, Huaijin Pi, Xiuli Li, Hujun Bao, and Xiaowei Zhou. Deep snake for real-time instance segmentation. In CVPR, 2020.
|
| 270 |
+
|
| 271 |
+
Jonah Philion and Sanja Fidler. Lift, splat, shoot: Encoding images from arbitrary camera rigs by implicitly unprojecting to 3d. In ECCV, 2020.
|
| 272 |
+
|
| 273 |
+
Tixiao Shan and Brendan Englot. Lego-loam: Lightweight and ground-optimized lidar odometry and mapping on variable terrain. In IROS, 2018.
|
| 274 |
+
|
| 275 |
+
Tixiao Shan, Brendan J. Englot, Drew Meyers, Wei Wang, Carlo Ratti, and Daniela Rus. LIO-SAM: tightly-coupled lidar inertial odometry via smoothing and mapping. In IROS, 2020.
|
| 276 |
+
|
| 277 |
+
Lucas Tabelini, Rodrigo Berriel, Thiago M Paixao, Claudine Badue, Alberto F De Souza, and Thiago Oliveira-Santos. Keep your eyes on the lane: Real-time attention-guided lane detection. In CVPR, 2021.
|
| 278 |
+
|
| 279 |
+
Mingxing Tan and Quoc V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In ICML, 2019.
|
| 280 |
+
|
| 281 |
+
Jinsheng Wang, Yinchao Ma, Shaofei Huang, Tianrui Hui, Fei Wang, Chen Qian, and Tianzhu Zhang. A keypoint-based global association network for lane detection. In CVPR, 2022.
|
| 282 |
+
|
| 283 |
+
Enze Xie, Peize Sun, Xiaoge Song, Wenhai Wang, Xuebo Liu, Ding Liang, Chunhua Shen, and Ping Luo. Polarmask: Single shot instance segmentation with polar representation. In CVPR, 2020.
|
| 284 |
+
Wenqiang Xu, Haiyang Wang, Fubo Qi, and Cewu Lu. Explicit shape encoding for real-time instance segmentation. In ICCV, 2019.
|
| 285 |
+
Ji Zhang and Sanjiv Singh. LOAM: lidar odometry and mapping in real-time. In Robotics: Science and Systems X, University of California, 2014.
|
| 286 |
+
Brady Zhou and Philipp Krahenb ¨ uhl. Cross-view transformers for real-time map-view semantic ¨ segmentation. In CVPR, 2022.
|
| 287 |
+
Chenming Zhu, Xuanye Zhang, Yanran Li, Liangdong Qiu, Kai Han, and Xiaoguang Han. Sharpcontour: A contour-based boundary refinement approach for efficient and accurate instance segmentation. In CVPR, 2022.
|
| 288 |
+
Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable DETR: deformable transformers for end-to-end object detection. In ICLR, 2021.
|
| 289 |
+
|
| 290 |
+
# Appendix
|
| 291 |
+
|
| 292 |
+
# A IMPLEMENTATION DETAILS
|
| 293 |
+
|
| 294 |
+
This section provides more implementation details of the method and experiments.
|
| 295 |
+
|
| 296 |
+
Data Augmentation. The resolution of source images is $1 6 0 0 \times 9 0 0$ . For MapTR-nano, we resize the source images with 0.2 ratio. For MapTR-tiny, we resize the source images with 0.5 ratio. Color jitter is used by default.
|
| 297 |
+
|
| 298 |
+
Model Setting. For all experiments, $\lambda$ is set to 2, $\alpha$ is set to 5, and $\beta$ is set to $5 e ^ { - 3 }$ during training. For MapTR-tiny, we set the number of instance-level queries and point-level queries to 50 and 20 respectively. And we set the size of each BEV grid to $0 . 3 m$ and stack 6 transformer decoder layers. We train MapTR-tiny with a total batch size of 32 (containig 6 view images), a learning rate of $6 e ^ { - 4 }$ , learning rate multiplier of the backbone is 0.1. All ablation studies are based on MapTR-tiny trained with 24 epochs. For MapTR-nano, we set the number of instance-level queries and pointlevel queries to 100 and 20 respectively. And we set the size of each BEV grid to $0 . 7 5 m$ and stack 2 transformer decoder layers. We train MapTR-nano with 110 epochs, a total batch size of 192, a learning rate of $4 e ^ { - 3 }$ , learning rate multiplier of the backbone is 0.1. We employ GKT (Chen et al., 2022b) as the default 2D-to-BEV module of MapTR.
|
| 299 |
+
|
| 300 |
+
Dataset Preprocessing. We process the map annotations following Liu et al. (2022a); Li et al. (2022a). Map elements in the perception ranges of ego-vehicle are extracted as ground-truth map elements. By default, The perception ranges are $[ - 1 5 . 0 m , 1 5 . 0 m ]$ for the $X$ -axis and $[ - \bar { 3 } 0 . 0 m , 3 0 . 0 m ]$ for the $Y$ -axis.
|
| 301 |
+
|
| 302 |
+
# B ABLATION STUDY
|
| 303 |
+
|
| 304 |
+

|
| 305 |
+
Figure 5. Convergence curves of permutation modeling methods .
|
| 306 |
+
|
| 307 |
+
Point Number. Ablations about the number of points for modeling each map element are presented in Tab. 5. Too few points can not describe the complex geometrical shape of the map element. Too many points affect the efficiency. We adopt 20 points as the default setting of MapTR.
|
| 308 |
+
|
| 309 |
+
Element Number. Ablations about the number of map elements are presented in Tab. 6. We adopt 50 as the default number of map elements for MapTR-tiny.
|
| 310 |
+
|
| 311 |
+
Table 5. Ablations about the number of points for modeling each map element.
|
| 312 |
+
|
| 313 |
+
<table><tr><td>Pt. num.</td><td>APped</td><td> APdivider</td><td>APboundary</td><td>mAP</td><td>FPS</td></tr><tr><td>10</td><td>42.5</td><td>51.3</td><td>50.1</td><td>48.0</td><td>12.3</td></tr><tr><td>20</td><td>46.3</td><td> 51.5</td><td>53.1</td><td>50.3</td><td>11.2</td></tr><tr><td>40</td><td>44.7</td><td>52.4</td><td>52.9</td><td>50.0</td><td>10.8</td></tr></table>
|
| 314 |
+
|
| 315 |
+
<table><tr><td>Ele. num.</td><td>APped</td><td> APdivider</td><td> AP boundary</td><td>mAP</td><td>FPS</td></tr><tr><td>25</td><td>36.3</td><td>43.8</td><td>44.7</td><td>41.6</td><td>11.4</td></tr><tr><td>50</td><td>46.3</td><td>51.5</td><td>53.1</td><td>50.3</td><td>11.2</td></tr><tr><td>75</td><td>48.2</td><td>53.1</td><td>55.3</td><td>52.2</td><td>11.1</td></tr></table>
|
| 316 |
+
|
| 317 |
+
Table 6. Ablations about the number of map elements.
|
| 318 |
+
|
| 319 |
+
Decoder Layer Number. Ablations about the layer number of map decoder are presented in Tab. 7. The map construction performance improves with more layers, but gets saturated when the layer number reaches 6.
|
| 320 |
+
|
| 321 |
+
<table><tr><td>Layer num.</td><td>APped</td><td>APdivider</td><td>APboundary</td><td>mAP</td><td>FPS</td></tr><tr><td>1</td><td>20.8</td><td>30.2</td><td>36.3</td><td>29.1</td><td>15.2</td></tr><tr><td>2</td><td>36.0</td><td>43.1</td><td>48.0</td><td>42.4</td><td>14.2</td></tr><tr><td>3</td><td>38.2</td><td>44.1</td><td>49.5</td><td>44.0</td><td>13.5</td></tr><tr><td>6</td><td>46.3</td><td>51.5</td><td>53.1</td><td>50.3</td><td>11.2</td></tr><tr><td>8</td><td>39.6</td><td>51.9</td><td>51.2</td><td>47.6</td><td>10.6</td></tr></table>
|
| 322 |
+
|
| 323 |
+
Table 7. Ablations about the number of decoder.
|
| 324 |
+
|
| 325 |
+
Position Matching Cost. As mentioned in Sec. 3.2, we adopt the position matching cost term $\mathcal { L } _ { \mathrm { p o s i t i o n } } ( \hat { V } _ { \pi ( i ) } , V _ { i } )$ in instance-level matching, for reflecting the position correlation between the predicted point set $\hat { V } _ { \pi ( i ) }$ and the GT point set $V _ { i }$ . In Tab. 8, we compare two kinds of cost design. i.e., Chamfer distance cost and point2point cost. Point2point cost is similar to the point-level matching cost. Specifically, we find the best point2point assignment, and sum the Manhattan distance of all point pairs as the position matching cost of two point sets. The experiments show point2point cost is better than Chamfer distance cost.
|
| 326 |
+
|
| 327 |
+
<table><tr><td>Position matching cost</td><td>APped</td><td>APdivider</td><td>APboundary</td><td>mAP</td></tr><tr><td>Chamfer distance cost</td><td>40.3</td><td>53.8</td><td>48.5</td><td>47.5</td></tr><tr><td>Point2point cost</td><td>46.3</td><td>51.5</td><td>53.1</td><td>50.3</td></tr></table>
|
| 328 |
+
|
| 329 |
+
Table 8. Ablations about the position matching cost term.
|
| 330 |
+
|
| 331 |
+
Swin Transformer Backbones. Ablations about the Swin Transformer backbones (Liu et al., 2021b) are presented in Tab. 9.
|
| 332 |
+
|
| 333 |
+
<table><tr><td>Method</td><td>Backbone</td><td>APped</td><td> APdivider</td><td> APboundary</td><td>mAP</td><td>FPS</td><td> Param.</td></tr><tr><td>MapTR-tiny</td><td>R50</td><td>46.3</td><td>51.5</td><td>53.1</td><td>50.3</td><td>11.2</td><td>35.9M</td></tr><tr><td>MapTR-tiny</td><td>Swin-tiny</td><td>45.2</td><td>52.7</td><td>52.3</td><td>50.1</td><td>9.1</td><td>39.9M</td></tr><tr><td>MapTR-small</td><td>Swin-small</td><td>50.2</td><td>55.4</td><td>57.3</td><td>54.3</td><td>7.3</td><td>61.2M</td></tr><tr><td>MapTR-base</td><td>Swin-base</td><td>50.6</td><td>58.7</td><td>58.4</td><td>55.9</td><td>6.1</td><td>99.2M</td></tr></table>
|
| 334 |
+
|
| 335 |
+
Table 9. Ablations about Swin Transformer backbones.
|
| 336 |
+
|
| 337 |
+
Modality. Multi-sensor perception is crucial for the safety of autonomous vehicles, and MapTR is compatible with other vehicle-mounted sensors like LiDAR. As illustrated in Tab. 10, with the schedule of only 24 epochs, multi-modality MapTR significantly outperform previous state-of-theart result by $1 7 . 3 \mathrm { m A P }$ while being $2 \times$ faster.
|
| 338 |
+
|
| 339 |
+
Robustness to the camera deviation. In real applications, the camera intrinsics are usually accurate and change little, but the camera extrinsics may be inaccurate due to the shift of camera position, calibration error, etc. To validate the robustness, we traverse the validation sets and randomly generate noise for each sample. We respectively add translation and rotation deviation of different degrees. Note that we add noise to all cameras and all coordinates. And the noise is subject to normal distribution. There exists extremely large deviation in some samples, which affect the performance a lot. As illustrated in Tab. 11 and Tab. 12, when the standard deviation of $\Delta _ { x } , \Delta _ { y } , \Delta _ { z }$ is $0 . 1 m$ or the standard deviation of $\theta _ { x } , \theta _ { y } , \theta _ { z }$ is $0 . 0 2 r a d$ , MapTR still keeps comparable performance.
|
| 340 |
+
|
| 341 |
+
Table 10. Ablations about the modality.
|
| 342 |
+
|
| 343 |
+
<table><tr><td>Method</td><td>Modality</td><td>Epochs</td><td>APped</td><td>APdivider</td><td> AP boundary</td><td>mAP</td><td>FPS</td></tr><tr><td>HDMapNet</td><td>C&L</td><td>30</td><td>16.3</td><td>29.6</td><td>46.7</td><td>31.0</td><td>0.5</td></tr><tr><td>VectorMapNet</td><td>C&L</td><td>110</td><td>37.6</td><td>50.5</td><td>47.5</td><td>45.2</td><td><2.9</td></tr><tr><td>MapTR-tiny</td><td>C</td><td>24</td><td>46.3</td><td> 51.5</td><td>53.1</td><td>50.3</td><td>11.2</td></tr><tr><td>MapTR-tiny</td><td>L</td><td>24</td><td>48.5</td><td>53.7</td><td>64.7</td><td>55.6</td><td>7.2</td></tr><tr><td>MapTR-tiny</td><td>C&L</td><td>24</td><td>55.9</td><td>62.3</td><td>69.3</td><td>62.5</td><td>5.8</td></tr></table>
|
| 344 |
+
|
| 345 |
+
Table 11. Robustness to the translation deviation of camera. The metric is mAP. $\sigma _ { 1 }$ is the standard deviation of $\Delta _ { x } , \Delta _ { y } , \Delta _ { z }$ .
|
| 346 |
+
|
| 347 |
+
<table><tr><td rowspan="2"> Method</td><td colspan="4">01(m)</td></tr><tr><td>0</td><td>0.05</td><td>0.1 0.5</td><td>1.0</td></tr><tr><td>MapTR-tiny</td><td> 50.3</td><td>49.9</td><td>49.0</td><td>34.0 17.0</td></tr></table>
|
| 348 |
+
|
| 349 |
+
<table><tr><td rowspan="2">Method</td><td colspan="5">σ2(rad)</td></tr><tr><td>0</td><td>0.005</td><td>0.01</td><td>0.02</td><td>0.05</td></tr><tr><td>MapTR-tiny</td><td> 50.3</td><td>49.4</td><td>47.5</td><td>42.0</td><td>24.7</td></tr></table>
|
| 350 |
+
|
| 351 |
+
Table 12. Robustness to the rotation deviation of camera. The metric is mAP. $\sigma _ { 2 }$ is the standard deviation of $\theta _ { x } , \theta _ { y } , \theta _ { z }$ .
|
| 352 |
+
|
| 353 |
+
Detailed running time. To have a deeper understanding on the efficiency of MapTR, we present the detailed running time of each component in MapTR-tiny with only multi-camera input in Tab. 13.
|
| 354 |
+
|
| 355 |
+
<table><tr><td>Component</td><td>Runtime (ms)</td><td>Proportion</td></tr><tr><td>Backbone</td><td>55.5</td><td>62.1%</td></tr><tr><td>2D-to-BEV module (GKT)</td><td>12.3</td><td>13.8%</td></tr><tr><td>Map decoder</td><td>21.5</td><td>24.1%</td></tr><tr><td>Total</td><td>89.3</td><td>100 %</td></tr></table>
|
| 356 |
+
|
| 357 |
+
Table 13. Detailed running time for each component in MapTR-tiny on a RTX 3090.
|
| 358 |
+
|
| 359 |
+
# C QUALITATIVE VISUALIZATION
|
| 360 |
+
|
| 361 |
+
We visualize map construction results of MapTR under various weather conditions and challenging road environment on nuScenes val set. As shown in Fig. 6, Fig. 7 and Fig. 8, MapTR maintains stable and impressive results. Video results are provided in the supplementary materials.
|
| 362 |
+
|
| 363 |
+

|
| 364 |
+
Figure 6. Visualization under sunny and cloudy weather.
|
| 365 |
+
|
| 366 |
+

|
| 367 |
+
Figure 7. Visualization under rainy weather.
|
| 368 |
+
|
| 369 |
+

|
| 370 |
+
Figure 8. Visualization at night.
|
md/dev/mTiHLHu3sP/mTiHLHu3sP.md
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GPT-RE: In-context Learning for Relation Extraction using Large Language Models
|
| 2 |
+
|
| 3 |
+
Zhen Wan 1 Fei Cheng Zhuoyuan Mao 1
|
| 4 |
+
Qianying Liu1 Haiyue Song1 Jiwei $\mathbf { L i } ^ { 2 }$ Sadao Kurohashi1 1 Kyoto University, Japan 2 Zhejiang University, China
|
| 5 |
+
{zhenwan, zhuoyuanmao, ying, song}@nlp.ist.i.kyoto-u.ac.jp {feicheng, kuro}@i.kyoto-u.ac.jp {jiwei_li}@zju.edu.cn
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
In spite of the potential for ground-breaking achievements offered by large language models (LLMs) (e.g., GPT-3) via in-context learning (ICL), they still lag significantly behind fullysupervised baselines (e.g., fine-tuned BERT) in relation extraction (RE). This is due to the two major shortcomings of ICL for RE: (1) low relevance regarding entity and relation in existing sentence-level demonstration retrieval approaches for ICL; and (2) the lack of explaining input-label mappings of demonstrations leading to poor ICL effectiveness.
|
| 10 |
+
|
| 11 |
+
In this paper, we propose GPT-RE to successfully address the aforementioned issues by (1) incorporating task-aware representations in demonstration retrieval; and (2) enriching the demonstrations with gold label-induced reasoning logic. We evaluate GPT-RE on four widely-used RE datasets and observe that GPTRE achieves improvements over not only existing GPT-3 baselines, but also fully-supervised baselines as in Figure 1. Specifically, GPT-RE achieves SOTA performances on the Semeval and SciERC datasets, and competitive performances on the TACRED and ACE05 datasets.
|
| 12 |
+
|
| 13 |
+
Additionally, a critical issue of LLMs revealed by previous work, the strong inclination to wrongly classify NULL examples into other predefined labels, is substantially alleviated by our method. We show an empirical analysis.1
|
| 14 |
+
|
| 15 |
+
# 1 Introduction
|
| 16 |
+
|
| 17 |
+
The emergence of large language models (LLMs) such as GPT-3 (Brown et al., 2020; Thoppilan et al., 2022; Chowdhery et al., 2022; Rae et al., 2021; Hoffmann et al., 2022) represents a significant advancement in natural language processing (NLP). Instead of following a pretraining-and-finetuning pipeline (Devlin et al., 2019; Beltagy et al., 2019; Raffel et al., 2019; Lan et al., 2019; Zhuang et al., 2021), which finetunes a pre-trained model on a task-specific dataset in a fully-supervised manner, LLMs employ a new paradigm known as incontext learning (ICL) (Brown et al., 2020; Min et al., 2022a) which formulates an NLP task under the paradigm of language generation and makes predictions by learning from a few demonstrations. Under the framework of ICL, LLMs achieve remarkable performance rivaling previous fullysupervised methods even with only a limited number of demonstrations provided in various tasks such as solving math problems, commonsense reasoning, text classification, fact retrieval, natural language inference, and semantic parsing (Brown et al., 2020; Min et al., 2022b; Zhao et al., 2021; Liu et al., 2022b; Shin et al., 2021).
|
| 18 |
+
|
| 19 |
+

|
| 20 |
+
Figure 1: Micro F1 performances on two RE datasets. Previous GPT baselines (GPT-Random: randomly selected demonstrations and $G P T – S e n t$ : sentence-level demonstration retrieval) largely underperform finetuning baseline PURE while our GPT-RE substantially outperforms all baselines.
|
| 21 |
+
|
| 22 |
+
Despite the overall promising performance of LLMs, the utilization of ICL for relation extraction (RE) is still suboptimal. RE is the central task for knowledge retrieval requiring a deep understanding of natural language, which seeks to identify a predefined relation between a specific entity pair mentioned in the input sentence or NULL if no relation is found. Given a test input, ICL for RE prompts the input of LLMs with the task instruction, a few demonstrations retrieved from the training data, and the test input itself. Then LLMs generate the corresponding relation. Recent research (Gutiérrez et al., 2022) has sought to apply GPT-3 ICL to biomedical RE, but the results are relatively negative and suggest that GPT-3 ICL still significantly underperforms fine-tuned models.
|
| 23 |
+
|
| 24 |
+

|
| 25 |
+
Figure 2: Retrieval without considering the task-aware triplet results in noisy demonstrations.
|
| 26 |
+
|
| 27 |
+
The reasons that cause the pitfall of GPT-3 ICL in RE are two folds: (1) The low relevance regarding entity and relation in the retrieved demonstrations for ICL. Demonstrations are selected randomly or via $k$ -nearest neighbor $( k \mathbf { N N } )$ search based on sentence embedding (Liu et al., 2022b; Gutiérrez et al., 2022). Regrettably, $k \mathbf { N N }$ -retrieval based on sentence embedding is more concerned with the relevance of the overall sentence semantics and not as much with the specific entities and relations it contains, which leads to low-quality demonstrations. As shown in Figure 2, the test input retrieves a semantically similar sentence but is not desired in terms of entities and relations.
|
| 28 |
+
|
| 29 |
+
(2) The lack of explaining input-label mappings in demonstrations leads to poor ICL effectiveness: A vanilla form of ICL lists all demonstrations as input-label pairs without any explanations. This may mislead LLMs to learn shallow clues from surface words, while a relation can be presented in diverse forms due to language complexity. Especially when ICL has a maximal input length, optimizing the learning efficiency of each single demonstration becomes extremely important.
|
| 30 |
+
|
| 31 |
+
To this end, we propose GPT-RE for the RE task. GPT-RE employs two strategies to resolve the issues above: (1) task-aware retrieval and (2) gold label-induced reasoning. For (1) task-aware retrieval, its core is to use representations that deliberately encode and emphasize entity and relation information rather than sentence embedding for $k \mathbf { N N }$ search. We achieve this by two different retrieval approaches: (a) entity-prompted sentence embedding; (b) fine-tuned relation representation, which naturally places emphasis on entities and relations. Both methods contain more RE-specific information than sentence semantics, thus effectively addressing the problem of low relevance.
|
| 32 |
+
|
| 33 |
+

|
| 34 |
+
Figure 3: Confusion matrix on Semeval dataset with three selected relation labels. The NULL examples are overpredicted to other relations by GPT-3. CE: CauseEffect, IA: Instrument-Agency, PP: Product-Producer.
|
| 35 |
+
|
| 36 |
+
For (2) gold label-induced reasoning, we propose to inject the reasoning logic into the demonstration to provide more evidence to align an input and the label, a strategy akin to the Chain-ofThought (CoT) research (Wei et al., 2022; Wang et al., 2022b; Kojima et al., 2022). But different from previous work, we allow LLMs to elicit the reasoning process to explain not only why a given sentence should be classified under a particular label but also why a NULL example should not be assigned to any of the pre-defined categories. This process significantly improves the ability of LLMs to align the relations with diverse expression forms.
|
| 37 |
+
|
| 38 |
+
Recent work reveals another crucial problem named “overpredicting” as shown in Figure 3: we observe that LLMs have the strong inclination to wrongly classify NULL examples into other predefined labels . A similar phenomenon has also been observed in other tasks such as NER (Gutiérrez et al., 2022; Blevins et al., 2022). In this paper, we show that this issue can be alleviated if the representations for retrieval can be supervised with the whole set of NULL in the training data.
|
| 39 |
+
|
| 40 |
+
We evaluate our proposed method on three popular general domain RE datasets: Semeval 2010 task 8, TACRED and ACE05, and one scientific domain dataset SciERC. We observe that GPT-RE achieves improvements over not only existing GPT-3 baselines, but also fully-supervised baselines. Specifically, GPT-RE achieves SOTA performances on the Semeval and SciERC datasets, and competitive performances on the TACRED and ACE05 datasets.
|
| 41 |
+
|
| 42 |
+

|
| 43 |
+
Figure 4: An illustration of GPT-RE. Given a test input, we first leverage two different task-aware retrieval methods to search for highly relevant demonstrations from the training set, and then incorporate the gold label-induced reasoning for each demonstration. Above contents will then be included in the prompt construction to make the prediction.
|
| 44 |
+
|
| 45 |
+
# 2 Methodology: GPT-RE
|
| 46 |
+
|
| 47 |
+
# 2.1 Task Definition
|
| 48 |
+
|
| 49 |
+
Let $\mathcal { C }$ denote the input context and $e _ { \mathrm { s u b } } ~ \in ~ \mathcal { C }$ $e _ { \mathrm { o b j } } \in { \mathcal { C } }$ denote the pair of subject and object entity. Given a set of pre-defined relation classes $\mathbb { R }$ , relation extraction aims to predict the relation $y \in \mathbb { R }$ between the pair of entities $( e _ { \mathrm { s u b } } , e _ { \mathrm { o b j } } )$ within the context $\mathcal { C }$ , or if there is no pre-defined relation between them, predict $y = \mathrm { N U L L }$ .
|
| 50 |
+
|
| 51 |
+
# 2.2 Overview
|
| 52 |
+
|
| 53 |
+
We will first introduce the prompt construction to formalize RE as a language generation task in Sec. 2.3. Then to improve the ICL framework for RE, we will introduce two modules: (1) task-aware demonstration retrieval to select higherquality demonstrations (Sec. 2.4); (2) gold labelinduced reasoning to enrich each demonstration with explanations (Sec. 2.5). In Figure 4, we show the concrete workflow of processing a test input.
|
| 54 |
+
|
| 55 |
+
# 2.3 Prompt Construction
|
| 56 |
+
|
| 57 |
+
We construct a prompt for each given test example, which is fed to the GPT-3 model. Each prompt consists of the following components:
|
| 58 |
+
|
| 59 |
+
Instructions $\mathcal { T }$ We provide a succinct overview of the RE task description and the set of pre-defined classes $\mathbb { R }$ . The model is explicitly asked to output the relation, which belongs to the pre-defined classes. Otherwise, the model will output NULL.
|
| 60 |
+
|
| 61 |
+
ICL Demonstrations $\mathcal { D }$ We first leverage a taskaware retriever to acquire a $k$ -shot demonstration set, then enrich each demonstration $( x _ { i } , y _ { i } )$ with the gold label-induced reasoning $r _ { i }$ to build a new set of $( x _ { i } , y _ { i } , r _ { i } )$ as $\mathcal { D }$ .
|
| 62 |
+
|
| 63 |
+
Test Input $x _ { t e s t }$ Similar to the demonstrations, we offer the test input $x _ { t e s t }$ , and GPT-3 is expected to generate the corresponding relation $y _ { t e s t }$ .
|
| 64 |
+
|
| 65 |
+
In summary, GPT-RE can be formulated as:
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
p \left( y _ { t e s t } \in \mathbb { R } \cup \left\{ \mathrm { N U L L } \right\} \vert \mathbb { Z } , \mathcal { D } , x _ { t e s t } \right)
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
# 2.4 Task-aware Demonstration Retrieval
|
| 72 |
+
|
| 73 |
+
Since ICL demonstrations closer to the test sample in the embedding space result in more consistent and robust performance (Liu et al., 2022b). Recent work (Gutiérrez et al., 2022; Liu et al., 2022b) employs the $k \mathbf { N N }$ to retrieve the most similar examples in the training set as the few-shot demonstrations for each test input. As $k \mathbf { N N }$ relies on the choice of the embedding space to encode both test input and examples in the training set, they propose to obtain sentence embedding using pre-trained language models, or other improved sentence embedding.
|
| 74 |
+
|
| 75 |
+
However, using sentence embedding for $k \mathbf { N N }$ retrieval has a severe drawback: relation extraction focuses on pair-wise entities, which diverge from the semantic meaning of the entire sentence, leading to an ambiguous retrieval using sentence embedding. In this study, we propose two novel methods to provide more robust representations for better retrieval quality: (1) a naive entity-prompted sentence embedding in Sec. 2.4.1; (2) an advanced fine-tuned relation representation in Sec. 2.4.2.
|
| 76 |
+
|
| 77 |
+
# 2.4.1 Entity-Prompted Sentence Embedding
|
| 78 |
+
|
| 79 |
+
Given the discrepancy between sentence embedding and relation extraction, the original context is insufficient for demonstration retrieval. Considering the importance of entity information in RE, we propose reconstructing the context by incorporating entity pair information. For example, given the context $^ { \circ \circ } \underline { { H } } e$ has a sister Lisa,” the reconstructed context with the entity prompted will be “The relation between ‘He’ and ‘Lisa’ in the context: He has a sister Lisa.” This approach preserves both the semantic meaning of the sentence and the entity pair-centered information during retrieval. In the paper, we employ the latest robust model SimCSE (Gao et al., 2021) for computing sentence embedding-based similarity.
|
| 80 |
+
|
| 81 |
+
# 2.4.2 Fine-tuned Relation Representation
|
| 82 |
+
|
| 83 |
+
Compared to prompt entity information into context sentences, a more straightforward solution is to extract the relation representation from a fine-tuned RE model for retrieving demonstrations.
|
| 84 |
+
|
| 85 |
+
Current BERT-based fine-tuning methods for RE (Baldini Soares et al., 2019; Zhong and Chen, 2021; Wan et al., 2022) attempts to capture both the context information and the entity information by adding extra marker tokens to highlight the subject and object entities and their types. Specifically, given an example: $^ { \circ \circ } \underline { { H } } e$ has a sister Lisa.”, the input tokens are “[CLS] [SUB_PER] He [/SUB_PER] has a sister [OBJ_PER] Lisa [/OBJ_PER]. [SEP]” where “PER” is the entity type if provided. Denote the $n$ -th hidden representation of the BERT encoder as $\mathbf { h } _ { n }$ . Assuming $i$ and $j$ are the indices of two beginning entity markers [SUB_PER] and [OBJ_PER], we define the relation representation as $\mathbf { R e l } = \mathbf { h } _ { i } \oplus \mathbf { h } _ { j }$ where $\bigoplus$ stands for concatenation of representations in the first dimension. Subsequently, this representation is fed into a feedforward network for predicting the relation probability $p ( y \in \mathbb { R } \cup \{ \mathrm { N U L L } \} \mid \mathbf { R e l } )$ .
|
| 86 |
+
|
| 87 |
+
The entity markers have explicitly encoded subject and object entities and the relation representation $\mathbf { R e l }$ is naturally enriched with the entity information. We believe this approach can potentially compensate for the limitations of GPT-3 in RE. While GPT-3 ICL has a constraint of limited demonstrations, the fine-tuning process is unbundled and can be done on the whole train data. It has two subsequent merits. First, the relation representations are directly fine-tuned to fit the RE task, which could significantly boost the overall retrieval quality. Second, the overpredicting NULL issue will be substantially alleviated because the similar NULL demonstrated can be accurately recognized by the fine-tuned model.
|
| 88 |
+
|
| 89 |
+

|
| 90 |
+
Figure 5: An illustration of adding reasoning.
|
| 91 |
+
|
| 92 |
+
Table 1: Statistics of datasets.
|
| 93 |
+
|
| 94 |
+
<table><tr><td>Dataset</td><td>#Relation</td><td># Train</td><td>#Dev</td><td># Test (# Subset)</td><td>NULL (%)</td></tr><tr><td>Semeval</td><td>9</td><td>6.507</td><td>1,493</td><td>2,717 (2,717)</td><td>17.40%</td></tr><tr><td>TACRED</td><td>41</td><td>68,124</td><td>22.631</td><td>15,509 (1,600)</td><td>79.40%</td></tr><tr><td>SciERC</td><td>7</td><td>16,872</td><td>2.033</td><td>4,088 (4.088)</td><td>90.16%</td></tr><tr><td>ACE05</td><td>6</td><td>121,368</td><td>27,597</td><td>24,420 (2,442)</td><td>95.60%</td></tr></table>
|
| 95 |
+
|
| 96 |
+
# 2.5 Gold Label-induced Reasoning
|
| 97 |
+
|
| 98 |
+
Recent CoT work has reported significant progress in the commonsense and numerical reasoning tasks by automatically eliciting the reasoning steps for solving a question. While in the RE task, two entities can possibly hold multiple relations, e.g., “Joe Biden” can be either the president of or lives in “U.S.”. The reasoning generation could be out of focus if it lacks interaction with the gold label.
|
| 99 |
+
|
| 100 |
+
In this section, we propose to let GPT-3 induce the reasoning logic for each demonstration by the corresponding gold relation label. As shown in Figure 5, given a selected demonstration, we first generate a query prompt “What are the clues that lead to the relation between [entity1] and [entity2] to be [relation] in the sentence [context]?” based on the demonstration and subsequently ask GPT-3 to generate clues “It is because: ...” on the labeled relation between the pair of entities in the context. Finally, we augment the demonstration by incorporating the generated clues induced by GPT-3.
|
| 101 |
+
|
| 102 |
+
Table 2: Main Results on four RE datasets. All results are given by Micro-F1. \* denotes the same $k$ -shot for the comparison with $^ +$ Reasoning. Due to the costly GPT-3 expense, we conducted Reasoning experiments on the two relatively smaller datasets Semeval and TACRED. $\clubsuit$ denotes that this performance is not comparable as it evaluates on the entire test set. The underline denotes the results outperforming the fine-tuning baseline PURE.
|
| 103 |
+
|
| 104 |
+
<table><tr><td>Methods</td><td>Retriever</td><td>Semeval</td><td>TACRED</td><td>SciERC</td><td>ACE05</td></tr><tr><td colspan="6">GPT-3 Baselines (Best k-shot)</td></tr><tr><td>GPT-Random</td><td></td><td>70.04 (30)</td><td>32.49 (15)</td><td>17.92 (25)</td><td>9.04 (25)</td></tr><tr><td>GPT-Sent</td><td>SimCSE</td><td>79.94 (30)</td><td>33.45 (15)</td><td>20.96 (25)</td><td>6.31 (25)</td></tr><tr><td colspan="6">Ours (Best k-shot)</td></tr><tr><td>GPT-RE_SimCSE</td><td>SimCSE</td><td>81.02 (30)</td><td>37.44 (15)</td><td>26.46 (25)</td><td>8.67 (25)</td></tr><tr><td>GPT-RE_SimCSE*</td><td>SimCSE</td><td>77.49 (15)</td><td>31.58 (10)</td><td>-</td><td>-</td></tr><tr><td>+ Reasoning</td><td>SimCSE</td><td>79.88 (15)</td><td>33.18 (10)</td><td>-</td><td>:</td></tr><tr><td>GPT-RE_FT</td><td>PURE</td><td>91.90 (25)</td><td>72.14 (15)</td><td>69.00 (30)</td><td>68.73 (25)</td></tr><tr><td>GPT-RE_FT*</td><td>PURE</td><td>91.11 (15)</td><td>70.38 (10)</td><td></td><td>-</td></tr><tr><td>+ Reasoning</td><td>PURE</td><td>91.82 (15)</td><td>70.97 (10)</td><td></td><td>■</td></tr><tr><td colspan="6">Fine-tuned RE Baselines</td></tr><tr><td>Cohen et al. (2020)</td><td></td><td>91.90</td><td>1</td><td></td><td></td></tr><tr><td>Wang et al. (2022a)</td><td></td><td>1</td><td>$76.80</td><td></td><td></td></tr><tr><td>PURE (Zhong and Chen, 2021)</td><td></td><td>89.90</td><td>69.72</td><td>68.45</td><td>70.09</td></tr></table>
|
| 105 |
+
|
| 106 |
+
# 3 Experiment Setup
|
| 107 |
+
|
| 108 |
+
# 3.1 Datasets
|
| 109 |
+
|
| 110 |
+
We evaluate on three popular general domain RE datasets and one scientific domain dataset. Due to the cost of running the model in the API with GPT-3, in our main results, we sample a subset (See Appendix C) from the original test set for two datasets: ACE05 and TACRED as shown in Table 1.
|
| 111 |
+
|
| 112 |
+
Semeval 2010 task 8 Hendrickx et al. (2010) focuses on semantic relations between pairs of nominals collected from general domain resources.
|
| 113 |
+
|
| 114 |
+
TACRED Zhang et al. (2017) is a large-scale relation extraction dataset with 106,264 examples built over newswire and web text.
|
| 115 |
+
|
| 116 |
+
prompt construction (Sec. 2.3) via OpenAI API. We implement two categories of GPT-3 baselines:
|
| 117 |
+
|
| 118 |
+
(1) GPT-Random Instead of randomly selecting few-shot demonstrations from the training data for each test input, we add extra constraints to make the label distribution of selected demonstrations more uniform. Our preliminary experiments suggest that this is a stronger baseline than the vanilla random.
|
| 119 |
+
|
| 120 |
+
(2) GPT-Sent Previous work attempts various sentence embedding in retrieval. In this work, our implementation adopted SimCSE (Gao et al., 2021), which has been demonstrated to be the state-of-theart method for sentence similarity tasks.
|
| 121 |
+
|
| 122 |
+
SciERC Luan et al. (2018) collects AI paper abstracts and annotated relations, especially for scientific knowledge graph construction.
|
| 123 |
+
|
| 124 |
+
ACE05 contains the entity, relation, and event annotations collected from domains including newswire, broadcast, discussion forums, etc.
|
| 125 |
+
|
| 126 |
+
# 3.2 Baseline Methods
|
| 127 |
+
|
| 128 |
+
GPT-3 baselines For GPT-3 baselines and our methods, we select “text-davinci-003” with maximal 4,097 input tokens and use the identical
|
| 129 |
+
|
| 130 |
+
Fine-tuned RE Models In our experiment, we choose PURE (Zhong and Chen, 2021), an entity marker-based fine-tuned model mentioned in Sec. 2.4.2 to obtain the representations for retrieval. Meanwhile, PURE performs as a directly comparable baseline. We also compare with corresponding SOTA fine-tuned baselines on Semeval Cohen et al. (2020) (reformulate RE as the question answering task) and TACRED Wang et al. (2022a) (extra pretraining to capture RE structure) datasets.
|
| 131 |
+
|
| 132 |
+
All implementation details are in Appendix A.
|
| 133 |
+
|
| 134 |
+

|
| 135 |
+
Figure 6: Ablation study on the retrieval and reasoning components on Semeval. We sampled a subset from the test data with 300 examples. We show the ‘w/o reasoning’ results with $k = 3 0$ for comparison.
|
| 136 |
+
|
| 137 |
+
# 4 Experimental Results
|
| 138 |
+
|
| 139 |
+
# 4.1 Main Results
|
| 140 |
+
|
| 141 |
+
We compare our main experiment results with previous methods in Table 2. GPT-RE_SimCSE denotes our entity-prompted sentence embedding for retrieval and GPT-RE_FT denotes our fine-tuned relation representation for retrieval. From the table, we can observe that: (1) both GPT-RE_SimCSE and $G P T – R E \_ F T$ outperform the retrieval-based GPTSent, indicating that it is necessary to inject the taskspecific information into sentence embedding for selecting proper demonstrations; (2) GPT-RE_FT succeeds to outperform the fine-tuning baseline PURE on three datasets by $+ 2 . 0 0$ , $+ 2 . 4 2$ , $+ 0 . 5 5$ Micro-F1. It suggests that GPT-3 has the potential to beat fine-tuning when the retriever has prior task knowledge. GPT-RE_FT eventually achieves SOTA results on Semeval and SciERC. (3) reasoning module improves $G P T – R E \_ S i m C S E$ by around $2 \%$ Micro-F1, indicating that gold label-induced reasoning successfully enriches the knowledge of demonstrations. Meanwhile, the high-quality demonstrations obtained by $G P T – R E \_ F T$ offset the effort of enriching reasoning into demonstrations, which shows relatively trivial improvements. Since reasoning aims at enriching demonstrations, this feature potentially works better with fewer demonstrations, as shown in Section 4.3.
|
| 142 |
+
|
| 143 |
+

|
| 144 |
+
Micro-F1
|
| 145 |
+
Figure 7: Low-resource Scenario on Semeval. We limit the percentage of training data for both fine-tuning and retrieval in GPT-RE.
|
| 146 |
+
|
| 147 |
+
# 4.2 Ablation Study on Task-aware Retrieval
|
| 148 |
+
|
| 149 |
+
We first implement the ablation experiments of the retrieval component with the setting of increasing $k$ -shot demonstrations (Figure 6a). We find that: (1) compared to GPT-Random, all the retrievalbased models have higher F1 scores and large gradients of the performance curves. It means that GPT-3 can learn from high-quality demonstrations more effectively; (2) after adding entity information to the SimCSE retrieval, $G P T – R E \_ S i m C S E$ achieves better performance throughout all $K$ shots, indicating that task-aware sentence embedding can capture the feature of RE and provide more proper demonstrations; (3) finally, the fine-tuned relation representation retriever $G P T – R E \_ F T$ significantly outperforms all retrieval-based methods and beats the fine-tuning baseline when $k > 1 5$ . Note that even with $k = 5$ demonstrations, $G P T – R E \_ F T$ still works better than $G P T – R E \_ S i m C S E$ with $k = 3 0$ $( 8 0 . 3 0 8 3 . 4 3 ( + 3 . 1 3 ) )$ , which indicates that the quality of demonstrations shows much more important than the number of demonstrations.
|
| 150 |
+
|
| 151 |
+
# 4.3 Ablation Study on Reasoning Enhancing
|
| 152 |
+
|
| 153 |
+
We then check the influence of our proposed reasoning-enhanced demonstration, as shown in Figure 6b. Due to the limited amount of input tokens of GPT-3, we have to set the $k \leq 1 5$ for the tokens of reasoning, leading to a trade-off between adding reasoning and adding more demonstrations. From the result, we find that: (1) with reasoningenhanced demonstrations, GPT-3 always achieves better scores across all the $k$ -shot settings of both $G P T – R E \_ S i m C S E$ and $G P T – R E \_ F T$ , indicating that the reasoning induced from ground truth relation labels can effectively unlock the reasoning ability of GPT-3 and improve the ICL with a deeper understanding of demonstrations. Specifically, for GPT$R E { \_ } F T ,$ , the performance improvement becomes less significant when more demonstrations are provided, which is feasible as with more high-quality demonstrations available, GPT-3 can already learn the internal reasoning behind each demonstration; (2) since the reasoning enhancement works better with fewer demonstrations, we expect this method can be an effective solution to low-shot relation extraction (Han et al., 2018; Geng et al., 2020; Liu et al., 2022a), which aims at recognizing novel relations with very few or no examples, and we leave this for future work.
|
| 154 |
+
|
| 155 |
+

|
| 156 |
+
Figure 8: Analysis on the effects of NULL examples. w/o NULL refers to the classification setting that NULL examples are excluded from the train and test data. $\mathsf { w } /$ NULL refers to the original extraction setting. We use the full test set for the evaluation.
|
| 157 |
+
|
| 158 |
+
# 4.4 Low-resource Scenario
|
| 159 |
+
|
| 160 |
+
We conduct the experiment for observing the lowresource performance in the general domain Semeval task. As shown in Figure 7, we observe that: (1) all the GPT-3 based results work better than fine-tuning in when the training examples are less than # 650 $( 1 0 \% )$ . It indicates that in the general domain RE, GPT-3 benefits from its abundant prior knowledge to understand the relations; (2) GPT-RE_SimCSE starts to show a substantial difference to GPT-Sent after the training size surpasses $30 \%$ . We believe fewer training candidates could limit the effects of retrieval; (3) GPT-RE_FT achieves an upper bound performance in all settings, even when the fine-tuned model shows poor performance with hundreds of training data (from #100 to $\# 4 0 0$ ). This emphasizes the impressive effectiveness of fine-tuned relation representations for capturing higher-quality demonstrations. The observation in the low-resource setting is very different from Gutiérrez et al. (2022). We assume the difference could be caused by the domain and NULL proportion of the task.
|
| 161 |
+
|
| 162 |
+
# 5 Analysis
|
| 163 |
+
|
| 164 |
+
# 5.1 The Issue of “Overpredicting”
|
| 165 |
+
|
| 166 |
+
To analyze the influence of NULL class, we compare the effectiveness of each method for alleviating this issue on two datasets: general domain Semeval with $1 7 . 4 \%$ NULL examples and scientific domain SciERC with $9 0 . 1 6 \%$ NULL examples. As shown in Figure 8, (1) by comparing the performance on Semeval and SciERC, a larger percentage of NULL examples results in more significant performance drop showing the negative influence of overpredicting NULL examples; (2) by comparing w/o NULL and w/ NULL, our $G P T – R E \_ F T$ shows the most robustness to the influence of NULL examples, indicating that the RE fine-tuned representations in retrieval can release the overpredicting issue of GPT-3 by providing higher-quality demonstrations; (3) however, even with task-aware representations, all GPT-3 methods still underperform the fine-tuning baseline on NULL examples, this is due to the confusing definition of NULL, in many cases, there is a certain relation between entities in the context, but out of the distribution of predefined classes. In these cases, GPT-3 tends to overpredict as the relation information may be covered in its prior knowledge. We think this ability of GPT-3 can be useful in more open fields, such as open RE (Banko and Etzioni, 2008) which has no pre-defined relation classes.
|
| 167 |
+
|
| 168 |
+

|
| 169 |
+
Figure 9: A case study of demonstration quality on Semeval. [NULL] is the gold label here.
|
| 170 |
+
|
| 171 |
+
# 5.2 Case Study of Demonstration Quality
|
| 172 |
+
|
| 173 |
+
We select one typical test example to better illustrate the amendment of our task-aware demonstration retrieval. As shown in Figure 9, given the NULL Example, we show the most similar demonstration in retrieval based on three methods. The GPT-Sent retrieved demonstration focuses on the semantic meaning of “CONTENT AND CONTAINER” which is shared in the test context, but not revealed in the target entity pair. This mismatch confirms the problem of lacking entity information in retrieval. Instead, GPT-RE_SimCSE retrieves a much more relevant demonstration that shows the same semantic relation between “catch” and “fish” but still faces a minor mismatch as the gold label is between “catch” and “scuttle.” Finally, GPT$R E \_ F T$ demonstration shares a similar structure with the test input regarding the pair of entities, which is the key clue for predicting the relation between entities. This result shows a level-bylevel enhancement with more entity information provided in retrieval. We also show some other case examples in Appendix B.
|
| 174 |
+
|
| 175 |
+
# 6 Related Work
|
| 176 |
+
|
| 177 |
+
In-context Learning Recent work shows that ICL of GPT-3 (Brown et al., 2020) can perform numerous tasks when provided a few examples in a natural language prompt. Existing work focuses on various aspects to effectively utilize the advantages of GPT-3, from prompt design (Perez et al., 2021) for proper input to coherence calibration (Malkin et al., 2022) for tackling the diverse generated output. Another research path locates in the demonstration part, including ordered prompts (Lu et al., 2022) and retrieval-based demonstrations (Rubin et al., 2022; Liu et al., 2022b; Shin et al., 2021).
|
| 178 |
+
|
| 179 |
+
To the best of our knowledge, there is no previous work exploring the potential of GPT-3 on general domain RE tasks. A recent work attempts to leverage GPT-3 in biomedical information extraction (NER and RE), and reveals issues of ICL that may be detrimental to IE tasks in general. Our work succeeds in overcoming these issues to some extent and confirms the potential of GPT-3 in both general and the scientific domain RE.
|
| 180 |
+
|
| 181 |
+
Retrieval-based Demonstrations Several studies have demonstrated that dynamically selecting few-shot demonstrations for each test example, instead of utilizing a fixed set, leads to significant improvement in GPT-3 ICL (Liu et al., 2022b; Shin et al., 2021; Rubin et al., 2022). They also show that nearest neighbor in-context examples yield much better results than the farthest ones. This leads to the significance of better retrieval modules for demonstrations. Existing attempts rely on sentence embedding in retrieval, including the sentence encoders of PLMs such as BERT (Devlin et al., 2019), RoBERTa (Zhuang et al., 2021) KATE (Liu et al., 2022b) , SimCSE (Gao et al., 2021), Sentence-BERT (Reimers and Gurevych, 2019; Wolf et al., 2020). Unlike these sentence embeddings, we propose to fine-tune PLMs on our target RE tasks to produce more task-specific and robust representations for retrieval.
|
| 182 |
+
|
| 183 |
+
# 7 Conclusions
|
| 184 |
+
|
| 185 |
+
This work explores the potential of GPT-3 ICL on RE for bridging the performance gap to the fine-tuning baselines via two strategies: (1) taskaware demonstration retrieval emphasizes entity and relation information for improving the accuracy of searching demonstrations; (2) gold labelinduced reasoning enriches the reasoning evidence of each demonstration. To the best of our knowledge, GPT-RE is the first GPT-3 ICL research that significantly outperforms the fine-tuning baseline on three datasets and achieves SOTA on Semeval and SciERC. We implement detailed studies to explore how GPT-3 overcomes the difficulties such as NULL example influence.
|
| 186 |
+
|
| 187 |
+
# Limitations
|
| 188 |
+
|
| 189 |
+
Despite the overall positive results, GPT-RE still faces two shortcomings: (1) the issue of overpredicting has been significantly alleviated but not completely solved, and the NULL recall still lags behind full-supervised baselines, especially on the datasets containing a large proportion of NULL examples such as ACE05 $( ^ { 6 6 } 9 5 . 6 0 \% ^ { 3 3 } )$ ; (2) Though the task-aware retriever optimizes the representations of PLMs such as SimCSE and BERT, it is widely considered that LLMs can generate more robust representations than small PLMs. Future work can replace representations generated by smaller PLMs with GPT-3 itself. However, due to the access limitation to the representations of GPT-3, we can nearly confirm this proposal up to now.
|
| 190 |
+
|
| 191 |
+
# References
|
| 192 |
+
|
| 193 |
+
Livio Baldini Soares, Nicholas FitzGerald, Jeffrey Ling, and Tom Kwiatkowski. 2019. Matching the blanks: Distributional similarity for relation learning. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 2895– 2905, Florence, Italy. Association for Computational Linguistics.
|
| 194 |
+
|
| 195 |
+
Michele Banko and Oren Etzioni. 2008. The tradeoffs between open and traditional relation extraction. In Proceedings of ACL-08: HLT, pages 28–36, Columbus, Ohio. Association for Computational Linguistics.
|
| 196 |
+
|
| 197 |
+
Iz Beltagy, Kyle Lo, and Arman Cohan. 2019. SciBERT: A pretrained language model for scientific text. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 3615– 3620, Hong Kong, China. Association for Computational Linguistics.
|
| 198 |
+
|
| 199 |
+
Terra Blevins, Hila Gonen, and Luke Zettlemoyer. 2022. Prompting language models for linguistic structure. CoRR, abs/2211.07830.
|
| 200 |
+
|
| 201 |
+
Samuel R. Bowman, Gabor Angeli, Christopher Potts, and Christopher D. Manning. 2015. A large annotated corpus for learning natural language inference.
|
| 202 |
+
|
| 203 |
+
In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pages 632–642, Lisbon, Portugal. Association for Computational Linguistics.
|
| 204 |
+
|
| 205 |
+
Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020. Language models are few-shot learners. In Advances in Neural Information Processing Systems, volume 33, pages 1877–1901. Curran Associates, Inc.
|
| 206 |
+
|
| 207 |
+
akanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel. 2022. Palm: Scaling language modeling with pathways. CoRR, abs/2204.02311.
|
| 208 |
+
|
| 209 |
+
Amir D. N. Cohen, Shachar Rosenman, and Yoav Goldberg. 2020. Relation extraction as two-way spanprediction. CoRR, abs/2010.04829.
|
| 210 |
+
|
| 211 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, Minneapolis, Minnesota. Association for Computational Linguistics.
|
| 212 |
+
|
| 213 |
+
Tianyu Gao, Xingcheng Yao, and Danqi Chen. 2021. SimCSE: Simple contrastive learning of sentence embeddings. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 6894–6910, Online and Punta Cana, Dominican Republic. Association for Computational Linguistics.
|
| 214 |
+
|
| 215 |
+
Xiaoqing Geng, Xiwen Chen, Kenny Q. Zhu, Libin Shen, and Yinggong Zhao. 2020. MICK: A metalearning framework for few-shot relation classification with small training data. In CIKM ’20: The 29th ACM International Conference on Information and Knowledge Management, Virtual Event, Ireland, October 19-23, 2020, pages 415–424. ACM.
|
| 216 |
+
|
| 217 |
+
Bernal Jiménez Gutiérrez, Nikolas McNeal, Clay Washington, You Chen, Lang Li, Huan Sun, and Yu Su. 2022. Thinking about GPT-3 in-context learning for biomedical ie? think again. CoRR, abs/2203.08410.
|
| 218 |
+
|
| 219 |
+
Xu Han, Hao Zhu, Pengfei Yu, Ziyun Wang, Yuan Yao, Zhiyuan Liu, and Maosong Sun. 2018. FewRel: A large-scale supervised few-shot relation classification dataset with state-of-the-art evaluation. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 4803–4809, Brussels, Belgium. Association for Computational Linguistics.
|
| 220 |
+
|
| 221 |
+
Iris Hendrickx, Su Nam Kim, Zornitsa Kozareva, Preslav Nakov, Diarmuid Ó Séaghdha, Sebastian Padó, Marco Pennacchiotti, Lorenza Romano, and Stan Szpakowicz. 2010. SemEval-2010 task 8: Multiway classification of semantic relations between pairs of nominals. In Proceedings of the 5th International Workshop on Semantic Evaluation, pages 33–38, Uppsala, Sweden. Association for Computational Linguistics.
|
| 222 |
+
|
| 223 |
+
Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, Tom Hennigan, Eric Noland, Katie Millican, George van den Driessche, Bogdan Damoc, Aurelia Guy, Simon Osindero, Karen Simonyan, Erich Elsen, Jack W. Rae, Oriol Vinyals, and Laurent Sifre. 2022. Training compute-optimal large language models.
|
| 224 |
+
|
| 225 |
+
Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. 2022. Large language models are zero-shot reasoners. CoRR, abs/2205.11916.
|
| 226 |
+
|
| 227 |
+
Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. 2019. Albert: A lite bert for self-supervised learning of language representations.
|
| 228 |
+
|
| 229 |
+
Fangchao Liu, Hongyu Lin, Xianpei Han, Boxi Cao, and Le Sun. 2022a. Pre-training to match for unified lowshot relation extraction. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 5785– 5795, Dublin, Ireland. Association for Computational Linguistics.
|
| 230 |
+
|
| 231 |
+
Jiachang Liu, Dinghan Shen, Yizhe Zhang, Bill Dolan, Lawrence Carin, and Weizhu Chen. 2022b. What makes good in-context examples for GPT-3? In Proceedings of Deep Learning Inside Out (DeeLIO 2022): The 3rd Workshop on Knowledge Extraction and Integration for Deep Learning Architectures, pages 100–114, Dublin, Ireland and Online. Association for Computational Linguistics.
|
| 232 |
+
|
| 233 |
+
Yao Lu, Max Bartolo, Alastair Moore, Sebastian Riedel, and Pontus Stenetorp. 2022. Fantastically ordered prompts and where to find them: Overcoming fewshot prompt order sensitivity. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 8086–8098, Dublin, Ireland. Association for Computational Linguistics.
|
| 234 |
+
|
| 235 |
+
Yi Luan, Luheng He, Mari Ostendorf, and Hannaneh Hajishirzi. 2018. Multi-task identification of entities, relations, and coreference for scientific knowledge graph construction. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 3219–3232, Brussels, Belgium. Association for Computational Linguistics.
|
| 236 |
+
|
| 237 |
+
Nikolay Malkin, Zhen Wang, and Nebojsa Jojic. 2022. Coherence boosting: When your pretrained language model is not paying enough attention. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 8214–8236, Dublin, Ireland. Association for Computational Linguistics.
|
| 238 |
+
|
| 239 |
+
Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. 2022a. Rethinking the role of demonstrations: What makes in-context learning work?
|
| 240 |
+
|
| 241 |
+
Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. 2022b. Rethinking the role of demonstrations: What makes in-context learning work? CoRR, abs/2202.12837.
|
| 242 |
+
|
| 243 |
+
Ethan Perez, Douwe Kiela, and Kyunghyun Cho. 2021. True few-shot learning with language models. In Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, pages 11054–11070.
|
| 244 |
+
|
| 245 |
+
Jack W. Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, Eliza Rutherford, Tom Hennigan, Jacob Menick, Albin Cassirer, Richard Powell, George van den Driessche, Lisa Anne Hendricks, Maribeth Rauh, Po-Sen Huang, Amelia Glaese, Johannes Welbl, Sumanth Dathathri, Saffron Huang, Jonathan Uesato, John Mellor, Irina Higgins, Antonia Creswell, Nat McAleese, Amy Wu, Erich Elsen, Siddhant Jayakumar, Elena Buchatskaya, David Budden, Esme Sutherland, Karen Simonyan, Michela Paganini, Laurent Sifre, Lena Martens, Xiang Lorraine Li, Adhiguna Kuncoro, Aida Nematzadeh, Elena Gribovskaya, Domenic Donato, Angeliki Lazaridou, Arthur Mensch, Jean-Baptiste Lespiau, Maria Tsimpoukelli, Nikolai Grigorev, Doug Fritz, Thibault Sottiaux, Mantas Pajarskas, Toby Pohlen, Zhitao Gong, Daniel Toyama, Cyprien de Masson d’Autume, Yujia
|
| 246 |
+
|
| 247 |
+
Li, Tayfun Terzi, Vladimir Mikulik, Igor Babuschkin, Aidan Clark, Diego de Las Casas, Aurelia Guy, Chris Jones, James Bradbury, Matthew Johnson, Blake Hechtman, Laura Weidinger, Iason Gabriel, William Isaac, Ed Lockhart, Simon Osindero, Laura Rimell, Chris Dyer, Oriol Vinyals, Kareem Ayoub, Jeff Stanway, Lorrayne Bennett, Demis Hassabis, Koray Kavukcuoglu, and Geoffrey Irving. 2021. Scaling language models: Methods, analysis & insights from training gopher.
|
| 248 |
+
|
| 249 |
+
Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. 2019. Exploring the limits of transfer learning with a unified text-to-text transformer.
|
| 250 |
+
|
| 251 |
+
Nils Reimers and Iryna Gurevych. 2019. SentenceBERT: Sentence embeddings using Siamese BERTnetworks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 3982–3992, Hong Kong, China. Association for Computational Linguistics.
|
| 252 |
+
|
| 253 |
+
Ohad Rubin, Jonathan Herzig, and Jonathan Berant. 2022. Learning to retrieve prompts for in-context learning. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2655–2671, Seattle, United States. Association for Computational Linguistics.
|
| 254 |
+
|
| 255 |
+
Richard Shin, Christopher Lin, Sam Thomson, Charles Chen, Subhro Roy, Emmanouil Antonios Platanios, Adam Pauls, Dan Klein, Jason Eisner, and Benjamin Van Durme. 2021. Constrained language models yield few-shot semantic parsers. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 7699–7715, Online and Punta Cana, Dominican Republic. Association for Computational Linguistics.
|
| 256 |
+
|
| 257 |
+
Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, YaGuang Li, Hongrae Lee, Huaixiu Steven Zheng, Amin Ghafouri, Marcelo Menegali, Yanping Huang, Maxim Krikun, Dmitry Lepikhin, James Qin, Dehao Chen, Yuanzhong Xu, Zhifeng Chen, Adam Roberts, Maarten Bosma, Vincent Zhao, Yanqi Zhou, ChungChing Chang, Igor Krivokon, Will Rusch, Marc Pickett, Pranesh Srinivasan, Laichee Man, Kathleen Meier-Hellstern, Meredith Ringel Morris, Tulsee Doshi, Renelito Delos Santos, Toju Duke, Johnny Soraker, Ben Zevenbergen, Vinodkumar Prabhakaran, Mark Diaz, Ben Hutchinson, Kristen Olson, Alejandra Molina, Erin Hoffman-John, Josh Lee, Lora Aroyo, Ravi Rajakumar, Alena Butryna, Matthew Lamm, Viktoriya Kuzmina, Joe Fenton, Aaron Cohen, Rachel Bernstein, Ray Kurzweil, Blaise AgueraArcas, Claire Cui, Marian Croak, Ed Chi, and Quoc Le. 2022. Lamda: Language models for dialog applications.
|
| 258 |
+
|
| 259 |
+
Zhen Wan, Qianying Liu, Zhuoyuan Mao, Fei Cheng, Sadao Kurohashi, and Jiwei Li. 2022. Rescue implicit and long-tail cases: Nearest neighbor relation extraction. CoRR, abs/2210.11800.
|
| 260 |
+
|
| 261 |
+
Chenguang Wang, Xiao Liu, Zui Chen, Haoyun Hong, Jie Tang, and Dawn Song. 2022a. DeepStruct: Pretraining of language models for structure prediction. In Findings of the Association for Computational Linguistics: ACL 2022, pages 803–823, Dublin, Ireland. Association for Computational Linguistics.
|
| 262 |
+
|
| 263 |
+
Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc V. Le, Ed H. Chi, and Denny Zhou. 2022b. Selfconsistency improves chain of thought reasoning in language models. CoRR, abs/2203.11171.
|
| 264 |
+
|
| 265 |
+
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed H. Chi, Quoc Le, and Denny Zhou. 2022. Chain of thought prompting elicits reasoning in large language models. CoRR, abs/2201.11903.
|
| 266 |
+
|
| 267 |
+
Adina Williams, Nikita Nangia, and Samuel Bowman. 2018. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 1112–1122, New Orleans, Louisiana. Association for Computational Linguistics.
|
| 268 |
+
|
| 269 |
+
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Remi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander Rush. 2020. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 38–45, Online. Association for Computational Linguistics.
|
| 270 |
+
|
| 271 |
+
Yuhao Zhang, Victor Zhong, Danqi Chen, Gabor Angeli, and Christopher D. Manning. 2017. Position-aware attention and supervised data improve slot filling. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pages 35–45, Copenhagen, Denmark. Association for Computational Linguistics.
|
| 272 |
+
|
| 273 |
+
Zihao Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. 2021. Calibrate before use: Improving few-shot performance of language models. In Proceedings of the 38th International Conference on Machine Learning, ICML 2021, 18-24 July 2021, Virtual Event, volume 139 of Proceedings of Machine Learning Research, pages 12697–12706. PMLR.
|
| 274 |
+
|
| 275 |
+
Zexuan Zhong and Danqi Chen. 2021. A frustratingly easy approach for entity and relation extraction. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 50–61, Online. Association for Computational Linguistics.
|
| 276 |
+
|
| 277 |
+
Liu Zhuang, Lin Wayne, Shi Ya, and Zhao Jun. 2021. A robustly optimized BERT pre-training approach with post-training. In Proceedings of the 20th Chinese National Conference on Computational Linguistics, pages 1218–1227, Huhhot, China. Chinese Information Processing Society of China.
|
| 278 |
+
|
| 279 |
+
Table 3: GPT-3 Hyperparamters.
|
| 280 |
+
|
| 281 |
+
<table><tr><td>Hyperparameter</td><td>In Experiment</td></tr><tr><td>Engine</td><td>text-davinci-003</td></tr><tr><td>Temperature</td><td>0.0</td></tr><tr><td>Max_tokens</td><td>256</td></tr><tr><td>Top_p</td><td>1</td></tr><tr><td>Frequency_penalty</td><td>0.0</td></tr><tr><td>Presence_penalty</td><td>0.0</td></tr><tr><td>Best_of</td><td>1</td></tr><tr><td>Logprob</td><td>1</td></tr></table>
|
| 282 |
+
|
| 283 |
+
Table 4: Search range for each dataset.
|
| 284 |
+
|
| 285 |
+
<table><tr><td>Dataset</td><td>Lower bound</td><td>Upper bound</td></tr><tr><td>Semeval</td><td>5</td><td>30</td></tr><tr><td>TACRED</td><td>5</td><td>15</td></tr><tr><td>SciERC</td><td>5</td><td>30</td></tr><tr><td>ACE05</td><td>5</td><td>25</td></tr></table>
|
| 286 |
+
|
| 287 |
+
# A Hyperparameters
|
| 288 |
+
|
| 289 |
+
# A.1 GPT-3 Hyperparameters
|
| 290 |
+
|
| 291 |
+
We use the GPT-3 API during the experiments and set the hyperparameters as in Table 3. Since the “Temperature” is set to be 0.0, denoting the stable output of GPT-3, we report the result of the single run for all experiments. Due to the input length limitation of GPT-3 and the various average lengths of contexts from each dataset, we set different search ranges for the number of demonstrations of each dataset as shown in Table 4.
|
| 292 |
+
|
| 293 |
+
# A.2 Fine-tuning Baseline PURE
|
| 294 |
+
|
| 295 |
+
We follow their single-sentence setup to keep consistency among datasets as Semeval and TACRED are both sentence-level RE datasets. For the PLMs, we also follow PURE by using scibert-scivocabuncased (Beltagy et al., 2019) as the base encoder for SciERC and bert-base-uncased (Devlin et al., 2019) for the remaining three general domain datasets. We follow hyperparameters in their paper. We used 2 NVIDIA RTX3090 for training.
|
| 296 |
+
|
| 297 |
+
# A.3 Sentence Embedding Methods
|
| 298 |
+
|
| 299 |
+
Gutiérrez et al. (2022) uses the [CLS] of RoBERTalarge as the representation in retrieval, Liu et al. (2022b) fine-tunes RoBERTa-large on two natural language inference (NLI) datasets: SNLI (Bowman et al., 2015) and MultiNLI (Williams et al., 2018) to enhance the quality of sentence embedding. For the sentence embedding method SimCSE in our experiment, we utilize the version: sup-simcse-bert-base-uncased.
|
| 300 |
+
|
| 301 |
+

|
| 302 |
+
|
| 303 |
+

|
| 304 |
+
Figure 10: More casees.
|
| 305 |
+
|
| 306 |
+
(b) [ENTITY AND DESTINATION] denotes the gold label.
|
| 307 |
+
|
| 308 |
+
Table 5: ACE05
|
| 309 |
+
|
| 310 |
+
<table><tr><td>Label</td><td># Num</td></tr><tr><td>PHYS</td><td>28</td></tr><tr><td>GEN-AFF</td><td>12</td></tr><tr><td>PER-SOC</td><td>11</td></tr><tr><td>GEN-AFF</td><td>33</td></tr><tr><td>PART-WHOLE</td><td>13</td></tr><tr><td>ART</td><td>19</td></tr><tr><td>NULL</td><td>2329</td></tr></table>
|
| 311 |
+
|
| 312 |
+
# B Case Study
|
| 313 |
+
|
| 314 |
+
To verify the effectiveness of our task-aware demonstration retrieval, we provide more cases.
|
| 315 |
+
|
| 316 |
+
For Figure 10a, GPT-Sent retrieves a demonstration that shares the same semantic meaning of “design” with the test input. However, the entity pair is irrelevant to the concept “design” resulting in a noisy demonstration. Instead, GPT-RE_SimCSE retrieves a more relative demonstration with closer pair of entities sharing the same relation label. Furthermore, GPT-RE_FT retrieves the demonstration containing both the closing entity pair and the same linguistic structure between entities. This case emphasizes level-by-level improvement using our proposed methods. Figure 10b shows a similar phenomenon.
|
| 317 |
+
|
| 318 |
+
# C Subset
|
| 319 |
+
|
| 320 |
+
The number of sampled examples is not only related to the size of the training data itself. A more important factor is the proportion of NULL. We have to maintain the original label distribution in datasets with a high proportion of NULL. Thus, the rule to sample the subset is to keep the proportion of each relation label consistent with the original test set. Table 5 6 are label distributions of two subsets.
|
| 321 |
+
|
| 322 |
+
GPT-RE_FT on TACRED surpasses the supervised baseline in the current subset. As we show above, some labels in TACRED are indeed not well presented (only 1 example), since TACRED dataset contains some long-tail labels. We decided to add additional results of GPT-RE_FT by enlarging our sampled set to $\# 3 2 0 0$ (2 times the current version), and the performance of GPT-RE_FT $( { \bf k } = 1 5 )$ ) is 73.16 while the performance of PURE is 70.48.
|
| 323 |
+
|
| 324 |
+
Table 6: TACRED
|
| 325 |
+
|
| 326 |
+
<table><tr><td colspan="2">Label</td></tr><tr><td>Per:title</td><td>#Num 40</td></tr><tr><td>PER:city_of_death</td><td>1</td></tr><tr><td>Org:shareholders</td><td>2</td></tr><tr><td>Per:origin</td><td>12</td></tr><tr><td>Org:top_members/employees</td><td>36</td></tr><tr><td>Org:city_of_headquarters</td><td>11</td></tr><tr><td>Per:religion</td><td>4</td></tr><tr><td>Per:city_of_birth</td><td>1</td></tr><tr><td>Per:employee_of</td><td>27</td></tr><tr><td>Per:data_of_death</td><td>3</td></tr><tr><td>Per:other_family</td><td>5</td></tr><tr><td>Org:website</td><td>6</td></tr><tr><td>Per:cause_of_death</td><td>3</td></tr><tr><td>Org:subsidiaries</td><td>4</td></tr><tr><td>Org:stateorprovince_of_headquarters</td><td>5</td></tr><tr><td>Per:countries_of_residence</td><td>10</td></tr><tr><td>Per:siblings</td><td>5</td></tr><tr><td>Per:stateorprovinces_of_residence</td><td>11</td></tr><tr><td>Org:alternate_names</td><td>27</td></tr><tr><td>Per:spouse</td><td>4</td></tr><tr><td>Per:parents</td><td>7</td></tr><tr><td>Org:country_of_headquarters</td><td>9</td></tr><tr><td>Per:age</td><td>21</td></tr><tr><td>Per:date_of_birth</td><td></td></tr><tr><td>Per:country_of_death</td><td></td></tr><tr><td>Per:schools_attended</td><td>4</td></tr><tr><td>Org:member_of</td><td>3</td></tr><tr><td>Per:children</td><td>5</td></tr><tr><td>Org:parents</td><td>7</td></tr><tr><td>Per:cities_of_residence</td><td>24</td></tr><tr><td>Per:stateorprovince_of_brith</td><td>1</td></tr><tr><td>Per:charges</td><td>12</td></tr><tr><td>Org:founded</td><td>2</td></tr><tr><td>Org:country_founded_by</td><td>5</td></tr><tr><td>Per:stateorprovince_of_death</td><td></td></tr><tr><td>Org:members</td><td>4</td></tr><tr><td>Per:country_of_birth</td><td></td></tr><tr><td>Per:alternate_names</td><td></td></tr><tr><td>Org:number_of_employees/members</td><td>1</td></tr><tr><td>Org:dissolved</td><td></td></tr><tr><td>Org:political/religious_affiliation</td><td>1</td></tr><tr><td>NULL</td><td>1271</td></tr></table>
|
md/dev/nJJjv0JDJju/nJJjv0JDJju.md
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Improving Diffusion Models for Inverse Problems using Manifold Constraints
|
| 2 |
+
|
| 3 |
+
# Hyungjin Chung∗,1
|
| 4 |
+
|
| 5 |
+
Byeongsu $\mathbf { S i m ^ { * , 2 } }$
|
| 6 |
+
|
| 7 |
+
Dohoon Ryu1
|
| 8 |
+
|
| 9 |
+
Jong Chul Ye3,1,2
|
| 10 |
+
|
| 11 |
+
1 Dept. of Bio and Brain Engineering 2 Dept. of Mathematical Sciences 3Kim Jaechul Graduate School of AI ∗Equal contribution
|
| 12 |
+
|
| 13 |
+
Korea Advanced Institute of Science and Technology (KAIST) {hj.chung, byeongsu.s, dh.ryu, jong.ye}@kaist.ac.kr
|
| 14 |
+
|
| 15 |
+
# Abstract
|
| 16 |
+
|
| 17 |
+
Recently, diffusion models have been used to solve various inverse problems in an unsupervised manner with appropriate modifications to the sampling process. However, the current solvers, which recursively apply a reverse diffusion step followed by a projection-based measurement consistency step, often produce suboptimal results. By studying the generative sampling path, here we show that current solvers throw the sample path off the data manifold, and hence the error accumulates. To address this, we propose an additional correction term inspired by the manifold constraint, which can be used synergistically with the previous solvers to make the iterations close to the manifold. The proposed manifold constraint is straightforward to implement within a few lines of code, yet boosts the performance by a surprisingly large margin. With extensive experiments, we show that our method is superior to the previous methods both theoretically and empirically, producing promising results in many applications such as image inpainting, colorization, and sparse-view computed tomography. Code available here
|
| 18 |
+
|
| 19 |
+
# 1 Introduction
|
| 20 |
+
|
| 21 |
+
Diffusion models have shown impressive performance both as generative models themselves [41, 13], and also as unsupervised inverse problem solvers [41, 8, 9, 25] that do not require problem-specific training. Specifically, given a pre-trained unconditional score function (i.e. denoiser), solving the reverse stochastic differential equation (SDE) numerically would amount to sampling from the data generating distribution [41]. For many different inverse problems (e.g. super-resolution [8, 9], inpainting [41, 9], compressed-sensing MRI (CS-MRI) [40, 9], sparse view CT (SV-CT) [40], etc.), it was shown that simple incorporation of the measurement process produces satisfactory conditional samples, even when the model was not trained for the specific problem.
|
| 22 |
+
|
| 23 |
+
Nevertheless, for certain problems (e.g. inpainting), currently used algorithms often produce unsatisfactory results when implemented naively (e.g. boundary artifacts, as shown in Fig. 1 (b)). The authors in [32] showed that in order to produce high quality reconstructions, one needs to iterate back and forth between the noising and the denoising step at least $> 1 0$ times per iteration. These iterations are computationally demanding and should be avoided, considering that diffusion models are slow to sample from even without such iterations. On the other hand, a classic result of Tweedie’s formula [37, 42] shows that one can perform Bayes optimal denoising in one step, once we know the gradient of the log density. Extending such result, it was recently shown that one can indeed perform a single-step denoising with learned score functions for denoising problems from the general exponential family [28].
|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
Figure 1: Visual schematic of the MCG correction step. (a) $\textcircled{1}$ Unconditional reverse diffusion generates $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ ; $\textcircled { 2 } Q _ { i }$ maps the noisy $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ to generate $\scriptstyle { \hat { \mathbf { x } } } _ { 0 }$ ; $\textcircled{3}$ Manifold Constrained Gradient (MCG) $\begin{array} { r l } { \frac { \partial } { \partial { \bf x } _ { i } } \| { \bf W } ( { \bf y } - { \bf H } \hat { \bf x } _ { 0 } ) \| _ { 2 } ^ { 2 } } \end{array}$ is applied to fix the iteration on manifold; $\textcircled{4}$ Takes the orthogonal complement; $\textcircled{5}$ Samples from $p ( \pmb { y } _ { i } | \pmb { y } )$ , then combines $\pmb { A x } _ { i - 1 } ^ { \prime }$ and $\mathbf { \nabla } _ { \mathbf { \boldsymbol { y } } _ { i } }$ . (b) Representative results of inpainting, compared with score-SDE [41]. Reconstructions with score-SDE produce incoherent results, while our method produces high fidelity solutions.
|
| 27 |
+
|
| 28 |
+
In this work, we leverage the denoising result through Tweedie’s formula and show that such denoised samples can be the key to significantly improving the performance of reconstruction using diffusion models across arbitrary linear inverse problems, despite the simplicity in the implementation. Moreover, we theoretically prove that if the score function estimation is globally optimal, the correction term from the manifold constraint enforces the sample path to stay on the plane tangent to the data manifold1, so by combining with the reverse diffusion step, the solution becomes more stable and accurate.
|
| 29 |
+
|
| 30 |
+
# 2 Related Works
|
| 31 |
+
|
| 32 |
+
# 2.1 Diffusion Models
|
| 33 |
+
|
| 34 |
+
Continuous Form For a continuous diffusion process $\pmb { x } ( t ) \in \mathbb { R } ^ { n } , t \in [ 0 , 1 ]$ , we set $x ( 0 ) \sim$ $p _ { 0 } ( { \pmb x } ) = p _ { d a t a }$ , where $p _ { d a t a }$ represents the data distribution of interest, and $\pmb { x } ( \bar { 1 } ) \sim p _ { 1 } ( \pmb { x } )$ , with $p _ { 1 } ( { \pmb x } )$ approximating spherical Gaussian distribution, containing no information of data. Here, the forward noising process is defined with the following Itˆo stochastic differential equation (SDE) [41]:
|
| 35 |
+
|
| 36 |
+
$$
|
| 37 |
+
\begin{array} { r } { d { \pmb x } = \bar { \pmb f } ( { \pmb x } , t ) d t + \bar { \pmb g } ( t ) d { \pmb w } , } \end{array}
|
| 38 |
+
$$
|
| 39 |
+
|
| 40 |
+
with $\bar { \pmb f } : \mathbb { R } ^ { d } \mapsto \mathbb { R } ^ { d }$ defining the linear drift function, $\bar { g } ( t ) : \mathbb { R } \mapsto \mathbb { R }$ defining a scalar diffusion coefficient, and $\pmb { w } \in \mathbb { R } ^ { n }$ denoting the standard $n -$ dimensional Wiener process. The forward SDE in (1) is coupled with the following reverse SDE by the Anderson’s theorem [1, 41]:
|
| 41 |
+
|
| 42 |
+
$$
|
| 43 |
+
\begin{array} { r } { d \pmb { x } = [ \pmb { \bar { f } } ( \pmb { x } , t ) - \bar { g } ( t ) ^ { 2 } \nabla _ { \pmb { x } } \log p _ { t } ( \pmb { x } ) ] d t + \bar { g } ( t ) d \bar { w } , } \end{array}
|
| 44 |
+
$$
|
| 45 |
+
|
| 46 |
+
with $d t$ denoting the infinitesimal negative time step, and $\bar { \mathbf { \Gamma } } _ { \bar { \mathbf { \Gamma } } } ^ { \bar { \mathbf { \Gamma } } } \bar { \mathbf { \Gamma } } _ { \bar { \mathbf { \Gamma } } } ^ { \bar { \mathbf { \Gamma } } }$ defining the standard Wiener process running backward in time. Note that the reverse SDE defines the generative process through the score function $\nabla _ { \pmb { x } } \log \ p _ { t } ( \pmb { x } )$ , which in practice, is typically replaced with $\nabla _ { \pmb { x } } \log p _ { 0 t } ( \pmb { x } ( t ) | \pmb { x } ( 0 ) )$ to minimize the following denoising score-matching objective
|
| 47 |
+
|
| 48 |
+
$$
|
| 49 |
+
\operatorname* { m i n } _ { \theta } \mathbb { E } _ { t \sim U ( \varepsilon , 1 ) , x ( 0 ) \sim p _ { 0 } ( x ) , x ( t ) \sim p _ { 0 t } ( x ( t ) | x ( 0 ) ) } \left[ \| s _ { \theta } ( x ( t ) , t ) - \nabla _ { x _ { t } } \log p _ { 0 t } ( x ( t ) | x ( 0 ) ) \| _ { 2 } ^ { 2 } \right] .
|
| 50 |
+
$$
|
| 51 |
+
|
| 52 |
+
Once the parameter $\theta ^ { * }$ for the score function is estimated, one can replace the score function in (2) with $s _ { \theta ^ { * } } ( \bar { { \boldsymbol { x } } } ( t ) , t )$ to solve the reverse SDE [41].
|
| 53 |
+
|
| 54 |
+
Discrete Form Due to the linearity of $\bar { \pmb f }$ and $\bar { g }$ , the forward diffusion step can be implemented with a simple reparameterization trick [29]. Namely, the general form of the forward diffusion is
|
| 55 |
+
|
| 56 |
+
$$
|
| 57 |
+
\begin{array} { r } { \pmb { x } _ { i } = a _ { i } \pmb { x } _ { 0 } + b _ { i } \pmb { z } , \quad \pmb { z } \sim \mathcal { N } ( 0 , \pmb { I } ) , } \end{array}
|
| 58 |
+
$$
|
| 59 |
+
|
| 60 |
+
where we have replaced the continuous index $t \in [ 0 , 1 ]$ with the discrete index $i \in \mathbb N$ . On the other hand, the discrete reverse diffusion step can in general be represented as
|
| 61 |
+
|
| 62 |
+
$$
|
| 63 |
+
\begin{array} { r } { \pmb { x } _ { i - 1 } = \pmb { f } ( \pmb { x } _ { i } , \pmb { s } _ { \theta ^ { * } } ) + g ( \pmb { x } _ { i } ) \pmb { z } , \quad \pmb { z } \sim \mathcal { N } ( 0 , \pmb { I } ) , } \end{array}
|
| 64 |
+
$$
|
| 65 |
+
|
| 66 |
+
where we have replaced the ground truth score function with the trained one. We detail the choice of $a _ { i } , b _ { i } , f , g$ in Appendix. B.
|
| 67 |
+
|
| 68 |
+
# 2.2 Conditional Generative models for Inverse problems
|
| 69 |
+
|
| 70 |
+
The main problem of our interest in this paper is the inverse problem, retrieving the unknown $\pmb { x } \in \mathbb { R } ^ { n }$ from a measurement $\textbf { { y } }$ :
|
| 71 |
+
|
| 72 |
+
$$
|
| 73 |
+
\pmb { y } = \pmb { H } \pmb { x } + \epsilon , \pmb { y } \in \mathbb { R } ^ { m } , \pmb { H } \in \mathbb { R } ^ { m \times n } ,
|
| 74 |
+
$$
|
| 75 |
+
|
| 76 |
+
where $\epsilon \in \mathbb { R } ^ { m }$ is the noise in the measurement. Accordingly, for the case of the inverse problems, our goal is to generate samples from a conditional distribution with respect to the measurement $\textbf { { y } }$ , i.e. $p ( { \pmb x } | { \pmb y } )$ . Accordingly, the score function $\nabla _ { \pmb { x } } \log p _ { t } ( \pmb { x } )$ in (2) should be replaced by the conditional score $\nabla _ { \pmb { x } } \log p _ { t } ( \pmb { x } | \pmb { y } )$ . Unfortunately, this strictly restricts the generalization capability of the neural network since the conditional score should be retrained whenever the conditions change. To address this, recent conditional diffusion models [22, 41, 8, 9] utilize the unconditional score function $\nabla _ { \pmb { x } } \log p _ { t } ( \pmb { x } )$ but rely on a projection-based measurement constraint to impose the conditions. Specifically, one can apply the following:
|
| 77 |
+
|
| 78 |
+
$$
|
| 79 |
+
\begin{array} { r l } & { \pmb { x } _ { i - 1 } ^ { \prime } = \pmb { f } ( \pmb { x } _ { i } , s _ { \theta } ) + g ( \pmb { x } _ { i } ) \pmb { z } , \quad \pmb { z } \sim \mathcal { N } ( 0 , \pmb { I } ) , } \\ & { \pmb { x } _ { i - 1 } = \pmb { A } \pmb { x } _ { i - 1 } ^ { \prime } + \pmb { b } _ { i } , } \end{array}
|
| 80 |
+
$$
|
| 81 |
+
|
| 82 |
+
where $A , b _ { i }$ are functions of $H , y$ , and $\scriptstyle { \mathbf { { \vec { x } } } } _ { 0 }$ . Note that (7) is identical to the unconditional reverse diffusion step in (5), whereas (8) effectively imposes the condition. It was shown in [9] that any general contraction mapping (e.g. projection onto convex sets, gradient step) may be utilized as (8) to impose the constraint.
|
| 83 |
+
|
| 84 |
+
Another recent work [25] advancing [26] establishes the state-of-the-art (SOTA) in solving noisy inverse problems with unconditional diffusion models, by running the conditional reverse diffusion process in the spectral domain achieved by performing singular value decomposition (SVD), and leveraging approximate gradient of the log likelihood term in the spectral space. The authors show that feasible solutions can be obtained with as small as 20 diffusion steps.
|
| 85 |
+
|
| 86 |
+
Prior to the development of diffusion models, Plug-and-Play $( \mathrm { P n P } )$ models [47, 53, 44] were used in a similar fashion by utilizing a general-purpose unconditional denoiser in the place of proximal mappings in model-based iterative reconstruction methods [5, 3]. Similarly, outside the context of diffusion models, iterative denoising followed by projection-based data consistency was proposed in [44]. In such view, diffusion models can be understood as generative variant of PnPs trained with multiple scales of noise.
|
| 87 |
+
|
| 88 |
+
GAN-based solvers are also widly explored [4, 10, 20], where the pre-trained generators are tuned at the test time by optimizing over the latent, the parameters, or jointly.
|
| 89 |
+
|
| 90 |
+
# 2.3 Tweedie’s formula for denoising
|
| 91 |
+
|
| 92 |
+
In the case of Gaussian noise, a classic result of Tweedie’s formula [37] tells us that one can achieve the denoised result by computing the posterior expectation:
|
| 93 |
+
|
| 94 |
+
$$
|
| 95 |
+
\begin{array} { r } { \mathbb { E } [ { \pmb x } | { \tilde { \pmb x } } ] = \tilde { \pmb x } + \sigma ^ { 2 } \nabla _ { \tilde { \pmb x } } \log p ( \tilde { \pmb x } ) , } \end{array}
|
| 96 |
+
$$
|
| 97 |
+
|
| 98 |
+
where the noise is modeled by $\tilde { \pmb { x } } \sim \mathcal { N } ( \pmb { x } , \sigma ^ { 2 } I )$ . If we consider a diffusion model in which the forward step is modeled as $\pmb { x } _ { i } \sim \mathcal { N } ( a _ { i } \pmb { x } _ { 0 } , b _ { i } ^ { 2 } I )$ (discrete form), the Tweedie’s formula can be rewritten as:
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
\begin{array} { r } { \mathbb { E } [ \pmb { x } _ { 0 } | \pmb { x } _ { i } ] = ( \pmb { x } _ { i } + b _ { i } ^ { 2 } \nabla _ { \pmb { x } _ { i } } \log p ( \pmb { x } _ { i } ) ) / a _ { i } . } \end{array}
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
Tweedie’s formula is in fact not only relevant to Gaussian denoising in the Bayesian framework, but have also been extended to be in close relation with kernel regression [34]. Moreover, it was shown that it can be applied to arbitrary exponential noise distributions beyond Gaussian [14, 28]. In the following, we use this key property to develop our algorithm.
|
| 105 |
+
|
| 106 |
+
# 3 Conditional Diffusion using Manifold Constraints
|
| 107 |
+
|
| 108 |
+
Although our original motivation of using the measurement constraint step in (8) was to utilize the unconditionally trained score function in the reverse diffusion step in (7), there is room for imposing additional constraints while still using the unconditionally trained score function.
|
| 109 |
+
|
| 110 |
+
Specifically, the Bayes rule $p ( { \pmb x } | { \pmb y } ) = p ( { \pmb y } | { \pmb x } ) p ( { \pmb x } ) / p ( { \pmb y } )$ leads to
|
| 111 |
+
|
| 112 |
+
$$
|
| 113 |
+
\nabla _ { \pmb { x } } \log p ( \pmb { x } | \pmb { y } ) = \nabla _ { \pmb { x } } \log p ( \pmb { x } ) + \nabla _ { \pmb { x } } \log p ( \pmb { y } | \pmb { x } ) .
|
| 114 |
+
$$
|
| 115 |
+
|
| 116 |
+
Hence, the score function in the reverse SDE in (7) can be replaced by (11), leading to
|
| 117 |
+
|
| 118 |
+
$$
|
| 119 |
+
x _ { i - 1 } ^ { \prime } = f ( x _ { i } , s _ { \theta } ) - \alpha \frac { \partial } { \partial x _ { i } } \| W ( y - H x _ { i } ) \| _ { 2 } ^ { 2 } + g ( x _ { i } ) z , \quad z \sim \mathcal { N } ( 0 , I )
|
| 120 |
+
$$
|
| 121 |
+
|
| 122 |
+
where $\alpha$ and $W$ depend on the noise covariance, if the noise $\epsilon$ in (6) is Gaussian.
|
| 123 |
+
|
| 124 |
+
Now, one of the important contributions of this paper is to reveal that the Bayes optimal denoising step in (10) from the Tweedie’s formula leads to a preferred condition both empirically and theoretically. Specifically, we define the set constraint for $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ , called the manifold constrained gradient (MCG), so that the gradient of the measurement term stays on the manifold (see Theorem 1):
|
| 125 |
+
|
| 126 |
+
$$
|
| 127 |
+
\pmb { x } \in \mathcal { X } _ { i } , \quad \mathrm { w h e r e } \quad \mathcal { X } _ { i } = \{ \pmb { x } \in \mathbb { R } ^ { n } | \pmb { x } = ( \pmb { x } + b _ { i } ^ { 2 } \pmb { s } _ { \theta } ( \pmb { x } , i ) ) / a _ { i } \}
|
| 128 |
+
$$
|
| 129 |
+
|
| 130 |
+
To deal with the potential deviation from the measurement consistency, we again impose the data consistency step (8). Putting them together, the discrete reverse diffusion under the additional manifold constraint and the data consistency can be represented by
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
\begin{array} { l } { { \displaystyle x _ { i - 1 } ^ { \prime } = f ( x _ { i } , s _ { \theta } ) - \alpha \frac { \partial } { \partial x _ { i } } \| W ( y - H \hat { x } _ { 0 } ( x _ { i } ) ) \| _ { 2 } ^ { 2 } + g ( x _ { i } ) z , \quad z \sim \mathcal { N } ( 0 , I ) , } } \\ { { \displaystyle x _ { i - 1 } = A x _ { i - 1 } ^ { \prime } + b . } } \end{array}
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+
We illustrate our scheme visually in Fig. 1 (a), specifically for the task of image inpainting. The additional step leads to a dramatic performance boost, as can be seen in Fig. 1 (b). Note that while the mapping (10) does not rely on the measurement, our gradient term in (14) incorporates the information of $\textbf { { y } }$ so that the gradient of the measurement terms stays on the manifold. In the following, we study the theoretical properties of the method. Further algorithmic details and adaptations to each problem that we tackle are presented in Section C.
|
| 137 |
+
|
| 138 |
+
We note that the authors of [19] proposed a similar gradient method for the application of temporal imputation and super-resolution. When combining (14) with (15), one can arrive at a similar gradient method proposed in [19], and hence our method can be seen as a generalization to arbitrary linear inverse problems. Furthermore, there are vast literature in the context of $\mathrm { P n P }$ models that utilize pretrained denoisers together with gradient of the log-likelihood to solve inverse problems [30, 48, 11]. Among them, [30] is especially relevant to this work since their method relies on modified Langevin diffusion, together with Tweedie’s denoising and projections to the measurement subspace.
|
| 139 |
+
|
| 140 |
+
# 4 Geometry of Diffusion Models and Manifold Constrained Gradient
|
| 141 |
+
|
| 142 |
+
In this section, we theoretically support the effectiveness of the proposed algorithm by showing the problematic behavior of the earlier algorithm and how the proposed algorithm resolves the problem. We defer all proofs in the supplementary section. To begin with, we borrow a geometrical viewpoint of the data manifold.
|
| 143 |
+
|
| 144 |
+
Notation For a scalar $a$ , points $\mathbf { \nabla } _ { \mathbf { x } , \mathbf { y } }$ and a set $A$ , we use the following notations. $a A : = \{ a x : x \in$ $A \}$ ; $d ( \pmb { x } , A ) : = \operatorname* { i n f } _ { \pmb { y } \in A } \widetilde { | } | \pmb { x } - \pmb { y } | | _ { 2 }$ ; $B _ { r } ( A ) : = \{ { \pmb x } : d ( { \pmb x } , A ) < r \}$ ; $T _ { x } { \mathcal { M } }$ : the tangent space to a manifold $\mathcal { M }$ at $_ { \textbf { \em x } }$ ; $J _ { f }$ : the Jacobian matrix of a vector valued function $f$ . We define $p _ { 0 } = p _ { d a t a }$ .
|
| 145 |
+
|
| 146 |
+
To develop the theory, we need an assumption on the data distribution.
|
| 147 |
+
|
| 148 |
+
Assumption 1 (Strong manifold assumption: linear structure). Suppose $\mathcal { M } \subset \mathbb { R } ^ { n }$ is the set of all data points, here we call the data manifold. Then, the manifold coincides with the tangent space with dimension $l \ll n$ .
|
| 149 |
+
|
| 150 |
+
$$
|
| 151 |
+
\mathcal { M } \cap B _ { R } ( { \pmb x } _ { 0 } ) = T _ { { \pmb x } _ { 0 } } \mathcal { M } \cap B _ { R } ( { \pmb x } _ { 0 } ) a n d T _ { { \pmb x } _ { 0 } } \mathcal { M } \cong \mathbb { R } ^ { l } .
|
| 152 |
+
$$
|
| 153 |
+
|
| 154 |
+
Moreover, the data distribution $p _ { 0 }$ is the uniform distribution on the data manifold $\mathcal { M }$
|
| 155 |
+
|
| 156 |
+

|
| 157 |
+
(a) Geometry of diffusion model
|
| 158 |
+
|
| 159 |
+

|
| 160 |
+
(b) MCG correction
|
| 161 |
+
Figure 2: In both (a) and (b), the central manifolds represent the data manifold $\mathcal { M }$ , encircled by manifolds of noisy data $\mathcal { M } _ { i }$ . The concentration on the manifold of noisy data and the distance from the clean data manifold are prescribed by Proposition 1. In (a), the backward (resp. forward) step depicted by blue (resp. red) arrows can be considered as transitions from $\mathcal { M } _ { i }$ to $\mathcal { M } _ { i - 1 }$ (resp. $\mathcal { M } _ { i - 1 }$ to $\mathcal { M } _ { i }$ ). In (b), arrows refer to the directions of conventional projection onto convex sets (POCS) step (green arrow) and MCG step (red arrow) which can be predicted by Theorem 1.
|
| 162 |
+
|
| 163 |
+
We need to recall that the conventional manifold assumption is about the intrinsic geometry of data points having a low dimensional nature. However, we assume more in this work: the manifold is locally linear. Although this stronger assumption might narrow the practice of the theory, the geometric approach may provide new insights on diffusion models. Under this assumption, the following proposition shows how the data perturbed by noise lies in the ambient space, illustrated pictorially in Fig. 2a.
|
| 164 |
+
|
| 165 |
+
Proposition 1 (Concentration of noisy data). Consider the distribution of noisy data $p _ { i } ( { \pmb x } _ { i } ) =$ $\begin{array} { r } { \int p ( \mathbf { \bar { x } } _ { i } | \mathbf { { x } } ) p _ { 0 } ( \mathbf { { x } } ) d \mathbf { { x } } , p ( \mathbf { { x } } _ { i } | \mathbf { { x } } ) \sim \mathcal { N } ( a _ { i } x , b _ { i } ^ { 2 } I ) } \end{array}$ . Then $p _ { i } ( { \pmb x } _ { i } )$ is concentrated on $( n - 1 )$ -dim manifold $\mathcal { M } _ { i } : = \{ \pmb { y } \in \mathbb { R } ^ { n } : d ( \pmb { y } , a _ { i } \mathcal { M } ) = r _ { i } : = b _ { i } \sqrt { n - l } \}$ . Rigorously, $p _ { i } ( B _ { \epsilon r _ { i } } ( \mathcal { M } _ { i } ) ) > 1 - \delta$ , for some small $\epsilon , \delta > 0$ .
|
| 166 |
+
|
| 167 |
+
Remark 1 (Geometric interpretation of the diffusion process). Considering Proposition $I$ , the manifolds of noisy data can be interpreted as interpolating manifolds between the two: the hypersphere, where pure noise $\mathcal { N } ( a _ { \infty } x _ { 0 } , b _ { \infty } ^ { 2 } )$ is concentrated, and the clean data manifold. In this regard, the diffusion steps are mere transitions from one manifold to another and the diffusion process is a transport from the data manifold to the hypersphere through interpolating manifolds. See Fig. 2a.
|
| 168 |
+
|
| 169 |
+
Remark 2. We can infer from the proposition that the score functions are trained only with the data points concentrated on the noisy data manifolds. Therefore, inaccurate inference might be caused by application of a score function on points away from the noisy data manifold.
|
| 170 |
+
|
| 171 |
+
Proposition 2 (score function). Suppose sθ is the minimizer of the denoising score matching loss in (3). Let $Q _ { i }$ be the function that maps $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ to $\scriptstyle { \hat { \mathbf { x } } } _ { 0 }$ for each $i$ ,
|
| 172 |
+
|
| 173 |
+
$$
|
| 174 |
+
Q _ { i } : \mathbb { R } ^ { d } \mathbb { R } ^ { d } , \mathbf { x } _ { i } \mapsto \hat { \pmb x } _ { 0 } : = \frac { 1 } { a _ { i } } ( \mathbf { x } _ { i } + b _ { i } ^ { 2 } s _ { \theta } ( \mathbf { x } _ { i } , i ) ) .
|
| 175 |
+
$$
|
| 176 |
+
|
| 177 |
+
Then, $Q _ { i } ( \pmb { x } _ { i } ) \in \mathcal { M }$ and $\pmb { J } _ { Q _ { i } } ^ { 2 } = \pmb { J } _ { Q _ { i } } = \pmb { J } _ { Q _ { i } } ^ { T } : \mathbb { R } ^ { d } T _ { Q _ { i } ( \pmb { x } _ { i } ) } \mathcal { M }$ . Intuitively, $Q _ { i }$ is locally an orthogonal projection onto $\bar { \mathcal { M } }$ .
|
| 178 |
+
|
| 179 |
+
According to the proposition, the score function only concerns the normal direction of the data manifold. In other words, the score function cannot discriminate two data points whose difference is tangent to the manifold. In solving inverse problems, however, we desire to discriminate data points to reconstruct the original signal, and the discrimination is achievable by measurement fidelity. In order to achieve the original signal, the measurement plays a role in correcting the tangent component near the data manifold. Furthermore, with regard to remark 2, diffusion model-based inverse problem solvers should follow the tangent component. The following theorem shows how existing algorithms and the proposed method are different in this regard.
|
| 180 |
+
|
| 181 |
+

|
| 182 |
+
Figure 3: Inpainting results on FFHQ (1st, 2nd row) and ImageNet (3rd, 4th row). (a) Measurement, (b) Ground truth, (c) IAGAN [20] for FFHQ, LaMa [43] for ImageNet, (d) DDRM [25], (e) ScoreSDE [41], (f) RePAINT [32], (g) MCG (Ours). Out of $2 5 6 \times 2 5 6$ image, the 1st and the 3rd row is masked with size $1 2 8 \times 1 2 8$ box. $92 \%$ of pixels (all RGB channels) from the images in the 2nd and 4th row are blocked.
|
| 183 |
+
|
| 184 |
+
Theorem 1 (Manifold constrained gradient). A correction by the manifold constrained gradient does not leave the data manifold. Formally,
|
| 185 |
+
|
| 186 |
+
$$
|
| 187 |
+
\frac { \partial } { \partial x _ { i } } \| { \cal W } ( y - H \hat { x } _ { 0 } ) \| _ { 2 } ^ { 2 } = - 2 { \cal J } _ { Q _ { i } } ^ { T } H ^ { T } { \cal W } ^ { T } { \cal W } ( y - H \hat { x } _ { 0 } ) \in T _ { \hat { x } _ { 0 } } { \mathcal { M } } ,
|
| 188 |
+
$$
|
| 189 |
+
|
| 190 |
+
the gradient is the projection of the data fidelity term onto $T _ { \hat { \pmb { x } } _ { 0 } } \mathcal { M }$ ,
|
| 191 |
+
|
| 192 |
+
This theorem suggests that in diffusion models, the naive measurement fidelity step (without considering the data manifold) pushes the inference path out of the manifolds and might lead to inaccurate reconstruction. (To see this pictorially, see section. D, and Fig. 7.) On the other hand, our correction term from the manifold constraint guides the diffusion to lie on the data manifold, leading to better reconstruction. Such geometric views are illustrated in Fig. 2b.
|
| 193 |
+
|
| 194 |
+
Remark 3. One may concern that the suboptimality of the denoising score matching loss optimization may lead to inaccurate inference of the MCG steps. In practice, however, most of the error in denoising score matching is concentrated on $t \sim 1 / 9 I$ , and in such region, the Tweedie’s inference cannot make meaningful images. That is, the score function cannot detect the data manifold. Nonetheless, in this regime, the magnitudes of the MCGs are small when the denoising score is inaccurate, and hence the matters arising from suboptimality is minimal. As $t 0$ , the estimation becomes exact, and subsequently leads to accurate implementation of the MCG.
|
| 195 |
+
|
| 196 |
+
# 5 Experiments
|
| 197 |
+
|
| 198 |
+
For all tasks, we aim to verify the superiority of our method against other diffusion model-based approaches, and also against strong supervised learning-based baselines. Further details can be found in Section. F.
|
| 199 |
+
|
| 200 |
+
Datasets and Implementation For inpainting, we use FFHQ $2 5 6 \times 2 5 6$ [24], and ImageNet $2 5 6 \times 2 5 6$ [12] to validate our method. We utilize pre-trained models from the open sourced repository based on the implementation of ADM (VP-SDE) [13]. We validate the performance on 1000 held-out validation set images for both FFHQ and ImageNet dataset. For the colorization task, we use FFHQ $2 5 6 \times 2 5 6$ , and LSUN-bedroom $2 5 6 \times 2 5 6$ [51]. We use pre-trained score functions from score-SDE [41] based on VE-SDE. We use 300 validation images for testing the performance with respect to the LSUN-bedroom dataset. For experiments with CT, we train our model based on ncsnpp as a VE-SDE from score-SDE [41], on the 2016 American Association of Physicists in Medicine (AAPM) grand challenge dataset, and we process the data as in [23]. Specifically, the dataset contains 3839 training images resized to $2 5 6 \times 2 5 6$ resolution. We simulate the CT measurement process with parallel beam geometry with evenly-spaced 180 degrees. Evaluation is performed on 421 held-out validation images from the AAPM challenge.
|
| 201 |
+
|
| 202 |
+
Table 1: Quantitative evaluation (FID, LPIPS) of inpainting task on FFHQ and ImageNet. ∗: Reimplemented with our score function. MCG, Score-SDE, RePAINT, and DDRM all share the same score function and differ only in the inference method. Bold: Best, under: second best.
|
| 203 |
+
|
| 204 |
+
<table><tr><td></td><td colspan="8">FFHQ(256×256)</td><td colspan="5">ImageNet (256 × 256)</td></tr><tr><td></td><td colspan="2">Box</td><td colspan="2">Random</td><td colspan="2">Extreme</td><td colspan="2">Wide masks</td><td colspan="2">Box</td><td colspan="2">Random</td><td colspan="2">Wide masks</td></tr><tr><td>Method</td><td></td><td>FID↓LPIPS ←</td><td>FID↓LPIPS</td><td>√</td><td></td><td>FID↓LPIPS ↓</td><td>FID↓LPIPS↓</td><td></td><td>FID↓LPIPS</td><td>↓</td><td>FID↓LPIPS</td><td>←</td><td>FID↓LPIPS</td><td></td></tr><tr><td>MCG (ours)</td><td>23.7</td><td>0.089</td><td>21.4</td><td>0.186</td><td>30.6</td><td>0.366</td><td>22.1</td><td>0.099</td><td>25.4</td><td>0.157</td><td>34.8</td><td>0.308</td><td>21.9</td><td>0.148</td></tr><tr><td>Score-SDE [41] 30.3</td><td></td><td>0.135</td><td>109.3 0.674</td><td></td><td>48.6</td><td>0.488</td><td>29.8</td><td>0.132</td><td>43.5</td><td>0.199</td><td>143.5 0.758</td><td></td><td>25.9</td><td>0.150</td></tr><tr><td>RePAINT*[32]</td><td>25.7</td><td>0.093</td><td>38.1</td><td>0.240</td><td>35.9</td><td>0.398</td><td>24.2</td><td>0.108</td><td>26.1</td><td>0.156</td><td>59.3</td><td>0.387</td><td>37.0</td><td>0.205</td></tr><tr><td>DDRM [25]</td><td>28.4</td><td>0.109</td><td>111.6 0.774</td><td></td><td>48.1</td><td>0.532</td><td>27.5</td><td>0.113</td><td>88.8</td><td>0.386</td><td>99.6</td><td>0.767</td><td>80.6</td><td>0.398</td></tr><tr><td>LaMa [43]</td><td>27.7</td><td>0.086</td><td>188.7 0.648</td><td></td><td>61.7</td><td>0.492</td><td>23.2</td><td>0.096</td><td>26.8</td><td>0.139</td><td>134.1</td><td>0.567</td><td>20.4</td><td>0.140</td></tr><tr><td>AOT-GAN [52]</td><td>29.2</td><td>0.108</td><td>97.2</td><td>0.514</td><td>69.5</td><td>0.452</td><td>28.3</td><td>0.106</td><td>35.3</td><td>0.163</td><td>119.6 0.583</td><td></td><td>29.8</td><td>0.161</td></tr><tr><td>ICT[49]</td><td>27.3</td><td>0.103</td><td>91.3</td><td>0.445</td><td>56.7</td><td>0.425</td><td>26.9</td><td>0.104</td><td>31.9</td><td>0.148</td><td>131.4 0.584</td><td></td><td>25.4</td><td>0.148</td></tr><tr><td>DSI [35]</td><td>27.9</td><td>0.096</td><td>126.4 0.601</td><td></td><td>77.5</td><td>0.463</td><td>28.3</td><td>0.102</td><td>34.5</td><td>0.155</td><td>132.9 0.549</td><td></td><td>24.3</td><td>0.154</td></tr><tr><td>IAGAN [20]</td><td>26.3</td><td>0.098</td><td>41.5</td><td>0.279</td><td>56.1</td><td>0.417</td><td>23.8</td><td>0.110</td><td>1</td><td>1</td><td>-</td><td>-</td><td>-</td><td>-</td></tr></table>
|
| 205 |
+
|
| 206 |
+
Inpainting Score-SDE [41], REPAINT [32], DDRM [25] were chosen as baseline diffusion models to compare against the proposed method. For a fair comparison, we use the same score function for all methods including MCG, and only differentiate the inference method that is used. Another class of generative models: GAN-based inverse problem solver, IAGAN [20] is considered as a comparison method for FFHQ specifically. We also include comparisons against supervised learning based base
|
| 207 |
+
|
| 208 |
+
<table><tr><td>Data</td><td colspan="2">FFHQ(256×256) LSUN(256×256)</td></tr><tr><td>Method</td><td>SSIM↑ LPIPS↓</td><td>SSIM↓ LPIPS↓</td></tr><tr><td>MCG (ours)</td><td>0.951 0.146</td><td>0.959 0.160</td></tr><tr><td>Score-SDE [41]</td><td>0.936 0.180</td><td>0.945 0.199</td></tr><tr><td>DDRM[25]</td><td>0.948 0.154</td><td>0.957 0.182</td></tr><tr><td>cINN[2]</td><td>0.952 0.166 0.935</td><td>0.952 0.180</td></tr><tr><td>pix2pix [21]</td><td>0.184</td><td>0.947 0.174</td></tr></table>
|
| 209 |
+
|
| 210 |
+
Table 2: Quantitative evaluation (SSIM, LPIPS) of colorization task. Bold: best, under: second best.
|
| 211 |
+
|
| 212 |
+
lines: LaMa [43], AOT-GAN [52], ICT [49], and DSI [35]. We use various forms of inpainting masks: box $1 2 8 \times 1 2 8$ sized square region is missing2), extreme (only the box region is existent), random $( 9 0 - 9 5 \%$ of pixels are missing), and LaMa-wide. Quantitative evaluation is performed with two metrics - Frechet Inception Distance (FID)-1k [17], and Learned Perceptual Image Patch Similarity (LPIPS) [54].
|
| 213 |
+
|
| 214 |
+
Our method outperforms the diffusion model baselines [41, 32, 25] by a large margin. Moreover, our method is also competitive with, or even better than the best-in-class fully supervised methods, as can be seen in Table 1. In Fig. 3, we depict representative results that show the superiority of the method, where we see in both the box-type and random dropping that MCG performs very well on all experiments.
|
| 215 |
+
|
| 216 |
+
Table 3: Quantitative evaluation (PSNR, SSIM) of CT reconstruction task. Bold: best.
|
| 217 |
+
|
| 218 |
+
<table><tr><td></td><td colspan="2">AAPM(256×256)</td></tr><tr><td>Views</td><td>18</td><td>30</td></tr><tr><td>Method</td><td>PSNR 个 SSIM↑</td><td>PSNR 个 SSIM↑</td></tr><tr><td>MCG (ours)</td><td>33.57 0.956</td><td>36.09 0.971</td></tr><tr><td>Score-CT[40]</td><td>29.85 0.897</td><td>31.97</td><td>0.913</td></tr><tr><td>SIN-4c-PRN[50]</td><td>26.96</td><td>0.850 30.23</td><td>0.917</td></tr><tr><td>cGAN [15]</td><td>24.38</td><td>0.823 27.45 23.92</td><td>0.927</td></tr><tr><td>FISTA-TV [3]</td><td>21.57</td><td>0.791</td><td>0.861</td></tr></table>
|
| 219 |
+
|
| 220 |
+
Colorization We choose score-SDE [41], and DDRM [25] as diffusion-model based compar
|
| 221 |
+
|
| 222 |
+
ison methods, and also compare against cINN [2], and pix2pix [21]. Two metrics were used for evaluation: structural similarity index (SSIM), and LPIPS. Consistent with the findings from inpainting, we achieve much improved performance than score-SDE, and also is favorable against state-of-the-art (SOTA) superivsed learning based methods. In Table 2, we see that the proposed method outperforms all other methods in terms of both PSNR/LPIPS in LSUN-bedroom, and also achieves strong performance in the colorization of FFHQ dataset.
|
| 223 |
+
|
| 224 |
+

|
| 225 |
+
Figure 4: Colorization results on FFHQ / LSUN-bedroom, Sparse view CT reconstruction results on AAPM.
|
| 226 |
+
|
| 227 |
+
CT reconstruction To the best of our knowledge, [40] is the only method that tackles CT reconstruction directly with diffusion models. We compare our method against [40], which we refer to as score-CT henceforth. We also compare with the best-in-class supervised learning methods, cGAN [15] and SIN- $\scriptscriptstyle \cdot 4 \mathrm { c }$ -PRN [50]. As a compressed sensing baseline, FISTA-TV [3] was included, along with the analytical reconstruction method, FBP. We use two standard metrics - peak-signalto-noise-ratio (PSNR), and SSIM for quantitative evaluation. From Table 3, we see that the newly proposed MCG method outperforms the previous score-CT [40] by a large margin. We can observe the superiority of MCG over other methods more clearly in Fig. 4, where MCG reconstructs the measurement with high fidelity and detail. All other methods including the fully supervised baselines fall behind the proposed method.
|
| 228 |
+
|
| 229 |
+
Ablation studies We perform three ablation studies: 1) As both the MCG term and the projection term contain information about the measurement $\textbf { { y } }$ , we observe the contribution of each term to the fixed solution. To further clarify the efficacy of the gradient step combined with Tweedie’s denoising, we also consider the case where the gradient of the log likelihood is computed not in the noiseless regime, but in the noise level matching the current iteration. Specifically, we define $\pmb { x } _ { i - 1 } ^ { \prime } : = \pmb { f } ( \pmb { x } _ { i } , \pmb { s } _ { \theta } ) + g ( \pmb { x } _ { i } ) z$ , $\ z \sim$ $\bar { \mathcal { N } } ( 0 , \pmb { I } )$ , ${ \pmb y } _ { i - 1 } \sim p ( { \pmb y } _ { i - 1 } | { \pmb y } _ { 0 } )$ , and implement the gradient step as $\nabla _ { \pmb { x } _ { i } } \| \pmb { y } _ { i - 1 } - \pmb { H } \pmb { x } _ { i - 1 } ^ { \prime } \| _ { 2 } ^ { 2 }$ . 2) As the performance of diffusion models depend heavily on the number of NFEs, we observe the trade-off of each diffusion model when varying the NFE from 20 to 1000. Moreover, for completeness, we measure the runtime of each algorithms including the non-diffusion based methods in wall-clock time computed with a commodity GPU in Table. 4. 3) Setting $\alpha = 0 . 0$ reduces our method to [9]. We show the difference in the performance by varying the values of $\alpha$ .
|
| 230 |
+
|
| 231 |
+
Table 4: Runtime for each algorithm in Wall-clock time: Computed with a single GTX 1080Ti GPU.
|
| 232 |
+
|
| 233 |
+
<table><tr><td rowspan=1 colspan=1>Method Wall-clock time [s]</td></tr><tr><td rowspan=1 colspan=1>Score-SDE [41] 38.68RePAINT[32] 247.6</td></tr><tr><td rowspan=1 colspan=1>DDRM[25] 2.117</td></tr><tr><td rowspan=1 colspan=1>LaMa [43] 0.629</td></tr><tr><td rowspan=1 colspan=1>AOT-GAN [52] 0.082</td></tr><tr><td rowspan=1 colspan=1>ICT[49] 144.6</td></tr><tr><td rowspan=1 colspan=1>DSI[35] 36.64</td></tr><tr><td rowspan=1 colspan=1>IAGAN [20] 518.47</td></tr><tr><td rowspan=1 colspan=1>Ours 81.59</td></tr></table>
|
| 234 |
+
|
| 235 |
+
First, we see in Table. 5 that using only the MCG step leads to improved performance in terms of LPIPS, but introduces error in the measurement consistency (measured with MSE). Combining both the projection and MCG leads to perfect data consistency along with further improved
|
| 236 |
+
|
| 237 |
+
Table 5: LPIPS & Measurement consistency (MC) vs. method
|
| 238 |
+
|
| 239 |
+
<table><tr><td>Method</td><td colspan="2">LPIPS(↓) MSE(MC)</td></tr><tr><td>Proj.</td><td>0.138</td><td>0</td></tr><tr><td>Vllyi-1-Hx-1ll2</td><td>0.271</td><td>12.99</td></tr><tr><td>Vaillyi-1-Hx-ill2+Proj.</td><td>0.128</td><td>0</td></tr><tr><td>Vally-Hxoll2</td><td>0.124</td><td>10.7</td></tr><tr><td>Vxlly-Hxoll2+Proj. (Ours)</td><td>0.089</td><td>0</td></tr></table>
|
| 240 |
+
|
| 241 |
+

|
| 242 |
+
Figure 5: Ablation studies performed with box inpainting task on FFHQ $2 5 6 \times 2 5 6$ data.
|
| 243 |
+
|
| 244 |
+
reconstruction. When considering gradient steps without Tweedie’s denoising (i.e. keeping the noise level at the $i ^ { \mathrm { { t h } } }$ step), the performance heavily degrades, especially when implemented without the projection steps. Here, we see that the proposed denoising step to utilize $\scriptstyle { \hat { \mathbf { x } } } _ { 0 }$ is indeed the key to the superior performance.
|
| 245 |
+
|
| 246 |
+
Second, looking at Fig. 5a, we immediately see that the graph of MCG stays in the lowest (best) LPIPS regime across all NFEs by a large margin, except for when the NFE drops below 100. Here, DDRM [25] takes over the 1st place - allegedly due to the DDIM sampling strategy they take. The performance of RePAINT deteriorates rapidly as we decrease NFE. Furthermore, we observe that the LPIPS of score-SDE [41] actually increases (i.e. worsen), as we increase the number of NFEs from a few hundred to one thousand. This suggests that the inference process that score-SDE takes (i.e. projection only) is inherently flawed, and cannot be corrected by taking small enough steps. In Table. 4, we list the runtime of all the methods that were used for comparison in the task of inpainting. Note that the proposed method takes longer for compute than score-SDE albeit having the same NFE. The gap is due to the backpropagation steps that are required for the MCG step, where the gap can be potentially ameliorated by switching to JAX [6] implementation from the current PyTorch implementation.
|
| 247 |
+
|
| 248 |
+
Lastly, we observe the difference in the performance as we vary the values of $\alpha$ . Implementation-wise, we find that we yield superior results when normalizing the squared norm with the norm of itself (e.g. $\alpha = \alpha ^ { \prime } / \lVert \dot { \mathbf { W } } ( \pmb { y } - \hat { \pmb { H } } \hat { \pmb { x } } _ { 0 } ) \rVert$ , where $\alpha ^ { \prime }$ is some constant). In order to avoid cluttered notation, we instead experiment with changing the values of $\alpha ^ { \prime }$ in Fig. 5b. Inspecting Fig. 5b, we see that $\alpha$ values within the range [0.1, 1.0] produce satisfactory results. $\alpha$ values that are too low do not fully enjoy the advantages of MCG and collapses to the projection-only method, while using too high values of $\alpha$ results in exploding gradients, and the reconstruction saturates.
|
| 249 |
+
|
| 250 |
+
Properties of our method Our proposed method is fully unsupervised and is not trained on solving a specific inverse problem. For example, our box masks and random masks have very different forms of erasing the pixel values. Nevertheless, our method generalizes perfectly well to such different measurement conditions, while other methods have a large performance gap between the different mask shapes. We further note two appealing properties of our method as an inverse problem solver: 1) the ability to generate multiple solutions given a condition, and 2) the ability to maintain perfect measurement consistency. The former ability often lacks in supervised learningbased methods [43, 50], and the latter is often not satisfied for some unsupervised GAN-based solutions [10, 4].
|
| 251 |
+
|
| 252 |
+
# 6 Conclusion
|
| 253 |
+
|
| 254 |
+
In this work, we proposed a general framework that can greatly enhance the performance of the diffusion model-based solvers for solving inverse problems. We showed several promising applications - inpainting, colorization, sparse view CT reconstruction, and showed that our method can outperform the current state-of-the-art methods. We analyzed our method theoretically and show that
|
| 255 |
+
|
| 256 |
+
MCG prevents the data generation process from falling off the manifold, thereby reducing the errors that might accumulate at every step. Further, we showed that MCG controls the direction tangent to the data manifold, whereas the score function controls the direction that is normal, such that the two components complement each other.
|
| 257 |
+
|
| 258 |
+
Limitations and Broader Impact The proposed method is inherently stochastic since the diffusion model is the main workhorse of the algorithm. When the dimension $m$ is pushed to low values, at times, our method fails to produce high quality reconstructions, albeit being better than the other methods overall. For extreme cases of inpainting (e.g. Half masks) with the ImageNet model, we often observe artifacts in our reconstruction (e.g. generating perfectly symmetric images), which we discuss in further detail in Sec. E. We note that our method is slow to sample from, inheriting the existing limitations of diffusion models. This would likely benefit from leveraging recent solvers aimed at accelerating the inference speed of diffusion models. In line with the arguments of other generative model-based inverse problem solvers, our method is a solver that relies heavily on the underlying diffusion model, and can thus potentially create malicious content such as deepfakes. Further, the reconstructions could intensify the social bias that is already existent in the training dataset.
|
| 259 |
+
|
| 260 |
+
# Acknowledgments and Disclosure of Funding
|
| 261 |
+
|
| 262 |
+
This research was supported by Field-oriented Technology Development Project for Customs Administration through National Research Foundation of Korea(NRF) funded by the Ministry of Science & ICT and Korea Customs Service (NRF-2021M3I1A1097938, NRF-2021M3I1A1097910), by the Korea Health Technology R&D Project through the Korea Health Industry Development Institute (KHIDI), which is funded by the Ministry of Health & Welfare, Republic of Korea (grant number: HU21C0222), and by the KAIST Key Research Institute (Interdisciplinary Research Group) Project.
|
| 263 |
+
|
| 264 |
+
# References
|
| 265 |
+
|
| 266 |
+
[1] Brian DO Anderson. Reverse-time diffusion equation models. Stochastic Processes and their Applications, 12(3):313–326, 1982.
|
| 267 |
+
[2] Lynton Ardizzone, Carsten Lüth, Jakob Kruse, Carsten Rother, and Ullrich Köthe. Guided image generation with conditional invertible neural networks. arXiv preprint arXiv:1907.02392, 2019.
|
| 268 |
+
[3] Amir Beck and Marc Teboulle. A fast iterative shrinkage-thresholding algorithm for linear inverse problems. SIAM journal on imaging sciences, 2(1):183–202, 2009.
|
| 269 |
+
[4] Ashish Bora, Ajil Jalal, Eric Price, and Alexandros G Dimakis. Compressed sensing using generative models. In International Conference on Machine Learning, pages 537–546. PMLR, 2017.
|
| 270 |
+
[5] Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, Jonathan Eckstein, et al. Distributed optimization and statistical learning via the alternating direction method of multipliers. Foundations and Trends® in Machine learning, 3(1):1–122, 2011.
|
| 271 |
+
[6] James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018.
|
| 272 |
+
[7] Thorsten M Buzug. Computed tomography. In Springer handbook of medical technology, pages 311–342. Springer, 2011.
|
| 273 |
+
[8] Jooyoung Choi, Sungwon Kim, Yonghyun Jeong, Youngjune Gwon, and Sungroh Yoon. ILVR: Conditioning method for denoising diffusion probabilistic models. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2021.
|
| 274 |
+
[9] Hyungjin Chung, Byeongsu Sim, and Jong Chul Ye. Come-Closer-Diffuse-Faster: Accelerating Conditional Diffusion Models for Inverse Problems through Stochastic Contraction. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022.
|
| 275 |
+
|
| 276 |
+
[10] Giannis Daras, Joseph Dean, Ajil Jalal, and Alexandros G Dimakis. Intermediate layer optimization for inverse problems using deep generative models. In International Conference on Machine Learning, 2021.
|
| 277 |
+
|
| 278 |
+
[11] Valentin De Bortoli, Alain Durmus, Marcelo Pereyra, and Ana Fernandez Vidal. Maximum likelihood estimation of regularization parameters in high-dimensional inverse problems: an empirical bayesian approach. part ii: Theoretical analysis. SIAM Journal on Imaging Sciences, 13(4):1990–2028, 2020.
|
| 279 |
+
|
| 280 |
+
[12] 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.
|
| 281 |
+
|
| 282 |
+
[13] Prafulla Dhariwal and Alexander Quinn Nichol. Diffusion models beat GANs on image synthesis. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, 2021.
|
| 283 |
+
|
| 284 |
+
[14] Bradley Efron. Tweedie’s formula and selection bias. Journal of the American Statistical Association, 106(496):1602–1614, 2011.
|
| 285 |
+
|
| 286 |
+
[15] Muhammad Usman Ghani and W Clem Karl. Deep learning-based sinogram completion for low-dose ct. In 2018 IEEE 13th Image, Video, and Multidimensional Signal Processing Workshop (IVMSP), pages 1–5. IEEE, 2018.
|
| 287 |
+
|
| 288 |
+
[16] Richard Gordon, Robert Bender, and Gabor T Herman. Algebraic reconstruction techniques (art) for three-dimensional electron microscopy and x-ray photography. Journal of theoretical Biology, 29(3):471–481, 1970.
|
| 289 |
+
|
| 290 |
+
[17] Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017.
|
| 291 |
+
|
| 292 |
+
[18] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In Advances in Neural Information Processing Systems, volume 33, pages 6840–6851, 2020.
|
| 293 |
+
|
| 294 |
+
[19] Jonathan Ho, Tim Salimans, Alexey Gritsenko, William Chan, Mohammad Norouzi, and David J Fleet. Video diffusion models. arXiv preprint arXiv:2204.03458, 2022.
|
| 295 |
+
|
| 296 |
+
[20] Shady Abu Hussein, Tom Tirer, and Raja Giryes. Image-adaptive gan based reconstruction. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 3121–3129, 2020.
|
| 297 |
+
|
| 298 |
+
[21] Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1125–1134, 2017.
|
| 299 |
+
|
| 300 |
+
[22] Zahra Kadkhodaie and Eero Simoncelli. Stochastic solutions for linear inverse problems using the prior implicit in a denoiser. In Advances in Neural Information Processing Systems, volume 34, pages 13242–13254. Curran Associates, Inc., 2021.
|
| 301 |
+
|
| 302 |
+
[23] Eunhee Kang, Junhong Min, and Jong Chul Ye. A deep convolutional neural network using directional wavelets for low-dose $\mathbf { X }$ -ray ct reconstruction. Medical physics, 44(10):e360–e375, 2017.
|
| 303 |
+
|
| 304 |
+
[24] Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 4401–4410, 2019.
|
| 305 |
+
|
| 306 |
+
[25] Bahjat Kawar, Michael Elad, Stefano Ermon, and Jiaming Song. Denoising diffusion restoration models. In ICLR Workshop on Deep Generative Models for Highly Structured Data, 2022.
|
| 307 |
+
|
| 308 |
+
[26] Bahjat Kawar, Gregory Vaksman, and Michael Elad. Snips: Solving noisy inverse problems stochastically. Advances in Neural Information Processing Systems, 34:21757–21769, 2021.
|
| 309 |
+
|
| 310 |
+
[27] Daniil Kazantsev, Edoardo Pasca, Martin J Turner, and Philip J Withers. Ccpi-regularisation toolkit for computed tomographic image reconstruction with proximal splitting algorithms. SoftwareX, 9:317–323, 2019.
|
| 311 |
+
[28] Kwanyoung Kim and Jong Chul Ye. Noise2score: Tweedie’s approach to self-supervised image denoising without clean images. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, 2021.
|
| 312 |
+
[29] Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In 2nd International Conference on Learning Representations, ICLR, 2014.
|
| 313 |
+
[30] Rémi Laumont, Valentin De Bortoli, Andrés Almansa, Julie Delon, Alain Durmus, and Marcelo Pereyra. Bayesian imaging using plug & play priors: when langevin meets tweedie. SIAM Journal on Imaging Sciences, 15(2):701–737, 2022.
|
| 314 |
+
[31] Beatrice Laurent and Pascal Massart. Adaptive estimation of a quadratic functional by model selection. Annals of Statistics, pages 1302–1338, 2000.
|
| 315 |
+
[32] Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, and Luc Van Gool. RePaint: Inpainting using Denoising Diffusion Probabilistic Models. arXiv preprint arXiv:2201.09865, 2022.
|
| 316 |
+
[33] Xudong Mao, Qing Li, Haoran Xie, Raymond YK Lau, Zhen Wang, and Stephen Paul Smolley. Least squares generative adversarial networks. In Proceedings of the IEEE international conference on computer vision, pages 2794–2802, 2017.
|
| 317 |
+
[34] Frank Ong, Peyman Milanfar, and Pascal Getreuer. Local kernels that approximate bayesian regularization and proximal operators. IEEE Transactions on Image Processing, 28(6):3007– 3019, 2019.
|
| 318 |
+
[35] Jialun Peng, Dong Liu, Songcen Xu, and Houqiang Li. Generating diverse structure for image inpainting with hierarchical VQ-VAE. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10775–10784, 2021.
|
| 319 |
+
[36] Ali Razavi, Aaron Van den Oord, and Oriol Vinyals. Generating diverse high-fidelity images with vq-vae-2. Advances in neural information processing systems, 32, 2019.
|
| 320 |
+
[37] Herbert E Robbins. An empirical bayes approach to statistics. In Breakthroughs in statistics, pages 388–394. Springer, 1992.
|
| 321 |
+
[38] Simo Särkkä and Arno Solin. Applied stochastic differential equations, volume 10. Cambridge University Press, 2019.
|
| 322 |
+
[39] Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In 3rd International Conference on Learning Representations, ICLR, 2015.
|
| 323 |
+
[40] Yang Song, Liyue Shen, Lei Xing, and Stefano Ermon. Solving inverse problems in medical imaging with score-based generative models. In International Conference on Learning Representations, 2022.
|
| 324 |
+
[41] Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In 9th International Conference on Learning Representations, ICLR, 2021.
|
| 325 |
+
[42] Charles M Stein. Estimation of the mean of a multivariate normal distribution. The annals of Statistics, pages 1135–1151, 1981.
|
| 326 |
+
[43] Roman Suvorov, Elizaveta Logacheva, Anton Mashikhin, Anastasia Remizova, Arsenii Ashukha, Aleksei Silvestrov, Naejin Kong, Harshith Goka, Kiwoong Park, and Victor Lempitsky. Resolution-robust large mask inpainting with fourier convolutions. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pages 2149–2159, 2022.
|
| 327 |
+
[44] Tom Tirer and Raja Giryes. Image restoration by iterative denoising and backward projections. IEEE Transactions on Image Processing, 28(3):1220–1234, 2018.
|
| 328 |
+
|
| 329 |
+
[45] Github PK Tool, Nov Sun Mon Tue Wed Thu, and Fri Sat. dkazanc/tomobar.
|
| 330 |
+
|
| 331 |
+
[46] Aaron Van Den Oord, Oriol Vinyals, et al. Neural discrete representation learning. Advances in neural information processing systems, 30, 2017.
|
| 332 |
+
|
| 333 |
+
[47] Singanallur V Venkatakrishnan, Charles A Bouman, and Brendt Wohlberg. Plug-and-play priors for model based reconstruction. In 2013 IEEE Global Conference on Signal and Information Processing, pages 945–948. IEEE, 2013.
|
| 334 |
+
|
| 335 |
+
[48] Ana Fernandez Vidal, Valentin De Bortoli, Marcelo Pereyra, and Alain Durmus. Maximum likelihood estimation of regularization parameters in high-dimensional inverse problems: An empirical bayesian approach part i: Methodology and experiments. SIAM Journal on Imaging Sciences, 13(4):1945–1989, 2020.
|
| 336 |
+
|
| 337 |
+
[49] Ziyu Wan, Jingbo Zhang, Dongdong Chen, and Jing Liao. High-fidelity pluralistic image completion with transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 4692–4701, 2021.
|
| 338 |
+
|
| 339 |
+
[50] Haoyu Wei, Florian Schiffers, Tobias Würfl, Daming Shen, Daniel Kim, Aggelos K Katsaggelos, and Oliver Cossairt. 2-step sparse-view ct reconstruction with a domain-specific perceptual network. arXiv preprint arXiv:2012.04743, 2020.
|
| 340 |
+
|
| 341 |
+
[51] Fisher Yu, Ari Seff, Yinda Zhang, Shuran Song, Thomas Funkhouser, and Jianxiong Xiao. Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop. arXiv preprint arXiv:1506.03365, 2015.
|
| 342 |
+
|
| 343 |
+
[52] Yanhong Zeng, Jianlong Fu, Hongyang Chao, and Baining Guo. Aggregated contextual transformations for high-resolution image inpainting. IEEE Transactions on Visualization and Computer Graphics, 2022.
|
| 344 |
+
|
| 345 |
+
[53] Kai Zhang, Wangmeng Zuo, Shuhang Gu, and Lei Zhang. Learning deep cnn denoiser prior for image restoration. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3929–3938, 2017.
|
| 346 |
+
|
| 347 |
+
[54] Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 586–595, 2018.
|
| 348 |
+
|
| 349 |
+
[55] Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE international conference on computer vision, pages 2223–2232, 2017.
|
| 350 |
+
|
| 351 |
+
# Checklist
|
| 352 |
+
|
| 353 |
+
1. For all authors...
|
| 354 |
+
|
| 355 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 356 |
+
(b) Did you describe the limitations of your work? [Yes] We discuss the limitations in (6).
|
| 357 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] We discuss potential negative impacts in (6).
|
| 358 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 359 |
+
|
| 360 |
+
2. If you are including theoretical results...
|
| 361 |
+
|
| 362 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes] We provide all proofs of results in supplementary material.
|
| 363 |
+
|
| 364 |
+
3. If you ran experiments...
|
| 365 |
+
|
| 366 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] We include all code for our experiments in the supplementary material. We will release the code once the paper is published.
|
| 367 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 368 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Due to our limited resources we do not have time to run multiple sets of experiments.
|
| 369 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
|
| 370 |
+
|
| 371 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 372 |
+
|
| 373 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes] We have cited the original works that released the datasets.
|
| 374 |
+
(b) Did you mention the license of the assets? [No] Licenses are standard and can be found online.
|
| 375 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We include our implementation as the supplementary material. We will release the code upon publication.
|
| 376 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [No] All datasets used in our work are publicly available.
|
| 377 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 378 |
+
|
| 379 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 380 |
+
|
| 381 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 382 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 383 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/pAq8iDy00Oa/pAq8iDy00Oa.md
ADDED
|
@@ -0,0 +1,615 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Incorporating Prior Knowledge into Neural Networks through an Implicit Composite Kernel
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 It is challenging to guide neural network (NN) learning with prior knowledge.
|
| 11 |
+
2 In contrast, many known properties, such as spatial smoothness or seasonality,
|
| 12 |
+
3 are straightforward to model by choosing an appropriate kernel in a Gaussian
|
| 13 |
+
4 process (GP). Many deep learning applications could be enhanced by modeling
|
| 14 |
+
5 such known properties. For example, convolutional neural networks (CNNs) are
|
| 15 |
+
6 frequently used in remote sensing, which is subject to strong seasonal effects. We
|
| 16 |
+
7 propose to blend the strengths of deep learning and the clear modeling capabilities
|
| 17 |
+
8 of GPs by using a composite kernel that combines a kernel implicitly defined by a
|
| 18 |
+
9 neural network with a second kernel function chosen to model known properties
|
| 19 |
+
10 (e.g., seasonality). Then, we approximate the resultant GP by combining a deep
|
| 20 |
+
11 network and an efficient mapping based on the Nyström approximation, which we
|
| 21 |
+
12 call Implicit Composite Kernel (ICK). ICK is flexible and can be used to include
|
| 22 |
+
13 prior information in neural networks in many applications. We demonstrate the
|
| 23 |
+
14 strength of our framework by showing its superior performance and flexibility
|
| 24 |
+
15 on both synthetic and real-world data sets. The code is available at: https:
|
| 25 |
+
16 //anonymous.4open.science/r/ICK_NNGP-17C5/.
|
| 26 |
+
|
| 27 |
+
# 17 1 Introduction
|
| 28 |
+
|
| 29 |
+
18 In complex regression tasks, input data often contains multiple sources of information. These sources
|
| 30 |
+
19 can be presented in both high-dimensional (e.g. images, audios, texts, etc.) and low-dimensional
|
| 31 |
+
20 (e.g. timestamps, spatial locations, etc.) forms. A common approach to learn from high-dimensional
|
| 32 |
+
21 information is to use neural networks (NNs) [21, 33], as NNs are powerful enough to capture the
|
| 33 |
+
22 relationship between complex high-dimensional data and target variables of interest. In many areas,
|
| 34 |
+
23 NNs are standard practice, such as the dominance of Convolutional Neural Networks (CNNs) for
|
| 35 |
+
24 image analysis [26, 61, 62]. In contrast, for low-dimensional information, we usually have some
|
| 36 |
+
25 prior knowledge on how the information relates to the predictions. As a concrete example, consider
|
| 37 |
+
26 a remote sensing problem where we predict ground measurements from satellite imagery with
|
| 38 |
+
27 associated timestamps. A priori, we expect the ground measurements to vary periodically with
|
| 39 |
+
28 respect to time between summer and winter due to seasonal effects. We would typically use a CNN
|
| 40 |
+
29 to capture the complex relationship between the imagery and the ground measurements. In this case,
|
| 41 |
+
30 we want to guide the learning of the CNN with our prior knowledge about the seasonality. This is
|
| 42 |
+
31 challenging because knowledge represented in NNs pertains mainly to correlation between network
|
| 43 |
+
32 units instead of quantifiable statements [36].
|
| 44 |
+
33 Conversely, Gaussian processes (GPs) have been used historically to incorporate relevant prior beliefs
|
| 45 |
+
34 by specifying the appropriate form of its kernel function (or covariance function) [2, 54]. One
|
| 46 |
+
35 approach to modeling multiple sources of information is to assign a relevant kernel function to each
|
| 47 |
+
36 source of information respectively and combine them through addition or multiplication, resulting in a
|
| 48 |
+
37 composite kernel function [14]. This formulation means that specifying a kernel to match prior beliefs
|
| 49 |
+
38 on one source of information is straightforward. Such composite kernel learning techniques are
|
| 50 |
+
39 extensively used in many application areas such as multi-media data [40], neuroimaging [60], spatial
|
| 51 |
+
40 data analysis, and environmental data analysis [28, 44]. In view of the clear modeling capabilities of
|
| 52 |
+
41 GP, it is desirable to examine how a NN could be imbued with the same modeling ease.
|
| 53 |
+
42 In recent years, researchers have come up with a variety of methods to incorporate prior knowledge
|
| 54 |
+
43 into NNs. These efforts can be broken into many categories, such as those that add prior information
|
| 55 |
+
44 through loss terms like physics-informed NNs [32, 41]. Here, we focus on the major category of those
|
| 56 |
+
45 methods that build integrated models of NNs and GPs with various structures [50, 57, 58]. Related
|
| 57 |
+
46 to our proposed methodology, Pearce et al. [43] exploited the fact that a Bayesian neural network
|
| 58 |
+
47 (BNN) approximates a GP to construct additive and multiplicative kernels, but they were limited
|
| 59 |
+
48 to specific predefined kernels. Matsubara et al. [38] then resolved this limitation by constructing
|
| 60 |
+
49 priors of BNN parameters based on the ridgelet transform and its dual, but they did not explicitly
|
| 61 |
+
50 show how their approach works for data with multiple sources of information. To our knowledge,
|
| 62 |
+
51 none of these existing approaches allows a modeler to choose any appropriate kernel of known prior
|
| 63 |
+
52 information from multiple sources. We address this limitation by presenting a simple yet novel
|
| 64 |
+
53 Implicit Composite Kernel (ICK) framework, which processes high-dimensional information using a
|
| 65 |
+
54 kernel implicitly defined by a neural network and low-dimensional information using a chosen kernel
|
| 66 |
+
55 function. The low-dimensional kernels are mapped into the neural network framework to create a
|
| 67 |
+
56 straightforward and simple-to-learn implementation. Our key results and contributions are:
|
| 68 |
+
|
| 69 |
+
• We analytically show our ICK framework, under reasonable assumptions, is approximately equivalent to a Gaussian process regression (GPR) model with a composite kernel a priori. • We demonstrate that our ICK framework yields better performance on both prediction and forecasting tasks even with very limited data. • We compare to joint deep learning models, such as a neural network-random forest joint model, to show that ICK can flexibly capture the patterns of the low-dimensional information without deliberately designing a pre-processing procedure or complex NN structures.
|
| 70 |
+
|
| 71 |
+
Based on these contributions, we believe ICK will be useful in the context of learning from complex hybrid data with prior knowledge, especially in the field of remote sensing and spatial statistics.
|
| 72 |
+
|
| 73 |
+
# 2 Related Work
|
| 74 |
+
|
| 75 |
+
67 Equivalence between NNs and GPs The equivalence between GPs and randomly initialized single
|
| 76 |
+
68 layer NNs with infinite width was first shown by Neal [42]. With the development of modern deep
|
| 77 |
+
69 learning, researchers further extended this relationship to deep networks [34, 39] and convolutional
|
| 78 |
+
70 neural networks (CNNs) [17]. This relationship is crucial for proving the resemblance between GPR
|
| 79 |
+
71 and our ICK framework, which will be discussed in Section 4.1.
|
| 80 |
+
72 NNs with prior knowledge As mentioned before, one approach to equip NNs with prior knowledge
|
| 81 |
+
73 is to modify the loss function. For example, Lagaris et al. [32] solved differential equations (DEs)
|
| 82 |
+
74 using NNs by setting the loss to be a function whose derivative satisfies the DE conditions. Another
|
| 83 |
+
75 approach is to build integrated models of NNs and GPs. For example, Wilson et al. [58] implemented
|
| 84 |
+
76 a regression network with GP priors over latent variables and made inference by approximating
|
| 85 |
+
77 the posterior using Variational Bayes or sampling from the posterior using Gibbs sampling scheme.
|
| 86 |
+
78 Garnelo et al. [16] introduced a class of neural latent variable models called Neural Processes (NPs)
|
| 87 |
+
79 which are capable of learning efficiently from the data and adapting rapidly to new observations. Zhu
|
| 88 |
+
80 et al. [10] proposed NeuralEF which can accurately approximately kernel functions by using a series
|
| 89 |
+
81 of objective functions parameterized by NNs under the principle of eigen-decomposition.
|
| 90 |
+
82 GP with composite kernels Composite kernel GPs are widely used in both machine learning
|
| 91 |
+
83 [14, 54] and geostatistical modeling [9, 18]. GPR in geostatistical modeling is also known as kriging
|
| 92 |
+
84 [27, 31], which serves as a surrogate model to replace expensive function evaluations. The inputs for
|
| 93 |
+
85 a composite GP are usually low-dimensional (e.g. spatial distance) as GPs do not scale well with the
|
| 94 |
+
86 number of samples for high-dimensional inputs [4, 5]. To overcome this issue, Pearce et al. [43] and
|
| 95 |
+
87 Matsubara et al. [38] developed BNN analogue for composite GPs. Similar to these studies, our ICK
|
| 96 |
+
88 framework can also be viewed as a simulation for composite GPs.
|
| 97 |
+
89 Approximation methods for GP For large data sets, approximation methods are needed as exact
|
| 98 |
+
90 kernel learning and inference scales $\mathcal { O } ( N ^ { 3 } )$ . Nyström low-rank matrix approximation [12, 53] and
|
| 99 |
+
91 Random Fourier Features [45, 46] are two of the most commonly used methods. A common technique
|
| 100 |
+
92 is to choose inducing points as pseudo-inputs to efficiently approximate the full kernel matrix [49, 23].
|
| 101 |
+
93 Our work is inspired by these approximation techniques and we use them as transformation functions
|
| 102 |
+
94 to map the kernel matrix into latent space representations in Section 4.2.
|
| 103 |
+
|
| 104 |
+
# 95 3 Background
|
| 105 |
+
|
| 106 |
+
Before elaborating on the details of our ICK framework, we introduce our notation, briefly go over the concepts of composite GPs, and describe the relationship between GPs and NNs.
|
| 107 |
+
|
| 108 |
+
# 3.1 Problem Setup
|
| 109 |
+
|
| 110 |
+
To formalize the problem, we have a training data set which contains $N$ data points $\begin{array} { r l } { \boldsymbol { X } } & { { } = } \end{array}$ $[ \pmb { x } _ { i } ] _ { i = 1 } ^ { N } = [ \pmb { x } _ { 1 } , \pmb { x } _ { 2 } , . . . , \pmb { x } _ { N } ] ^ { T }$ and the corresponding labels of these data points are $\begin{array} { r } { \mathbf { y } = [ y _ { i } ] _ { i = 1 } ^ { N } = } \end{array}$ $[ y _ { 1 } , y _ { 2 } , . . . , y _ { N } ] ^ { T }$ where $y _ { i } \in \mathbb { R }$ . Each data point $\pmb { x } _ { i } = \left\{ x _ { i } ^ { ( 1 ) } , x _ { i } ^ { ( 2 ) } , . . . , x _ { i } ^ { ( M ) } \right\}$ is composed of information from $M$ different sources where the $m ^ { t h }$ source of information of the $i ^ { t h }$ data point is denoted as $x _ { i } ^ { ( m ) } \in \mathbb { R } ^ { D _ { m } }$ . Our goal is to learn a function $\hat { y } _ { i } = f ( \pmb { x } _ { i } ) : \{ \mathbb { R } ^ { D _ { 1 } } , \mathbb { R } ^ { D _ { 2 } } , . . . , \mathbb { R } ^ { D _ { M } } \} \mathbb { R }$ which takes in a data point $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ and outputs a predicted value $\hat { y } _ { i }$ .
|
| 111 |
+
|
| 112 |
+
# 3.2 Composite GPs
|
| 113 |
+
|
| 114 |
+
106 A Gaussian process (GP) describes a distribution over functions [54]. A key property of GP is that
|
| 115 |
+
107 it can be completely defined by a mean function $\mu ( { \pmb x } )$ and a kernel function $K ( \pmb { x } , \pmb { x } ^ { \prime } )$ . The mean
|
| 116 |
+
108 function $\mu ( { \pmb x } )$ is often assumed to be zero for simplicity. In that case, the outcome function is
|
| 117 |
+
|
| 118 |
+
$$
|
| 119 |
+
f ( \pmb { x } ) \sim \mathcal { G P } \left( 0 , K ( \pmb { x } , \pmb { x } ^ { \prime } ) \right) .
|
| 120 |
+
$$
|
| 121 |
+
|
| 122 |
+
109 Any finite subset of these random variables has a multivariate Gaussian distribution with mean 0
|
| 123 |
+
110 and kernel matrix $\kappa$ whose entries can be calculated as $K _ { i j } = K ( \pmb { x } _ { i } , \pmb { x } _ { j } )$ . In many situations, the
|
| 124 |
+
111 full kernel function is built by a composite kernel by combining simple kernels through addition
|
| 125 |
+
112 $K _ { \mathrm { c o m p } } ( { \pmb x } , { \pmb x } ^ { \prime } ) = K _ { 1 } ( { \pmb x } , { \pmb x } ^ { \prime } ) + K _ { 2 } ( { \pmb x } , { \pmb x } ^ { \prime } )$ or multiplication $K _ { \mathrm { c o m p } } ( { \pmb x } , { \pmb x } ^ { \prime } ) = K _ { 1 } ( { \pmb x } , { \pmb x } ^ { \prime } ) K _ { 2 } ( { \pmb x } , { \pmb x } ^ { \prime } )$
|
| 126 |
+
113 [14]. A useful property that ICK exploits is that $K _ { 1 }$ and $K _ { 2 }$ can take different subparts of $_ { \textbf { \em x } }$ as
|
| 127 |
+
114 their inputs. For example, $K _ { \mathrm { c o m p } } ( \pmb { x } , \pmb { x } ^ { \prime } ) = K _ { 1 } \left( \pmb { x } ^ { ( 1 ) } , \pmb { x } ^ { ( 1 ) ^ { \prime } } \right) + K _ { 2 } \left( \pmb { x } ^ { ( 2 ) } , \pmb { x } ^ { ( 2 ) ^ { \prime } } \right)$ or $K _ { \mathrm { c o m p } } ( { \pmb x } , { \pmb x } ^ { \prime } ) =$
|
| 128 |
+
115 $K _ { 1 } \left( x ^ { ( 1 ) } , x ^ { ( 1 ) ^ { \prime } } \right) K _ { 2 } \left( x ^ { ( 2 ) } , x ^ { ( 2 ) ^ { \prime } } \right)$ . Other methods such as functional mapping are also valid if the
|
| 129 |
+
116 resulting kernel matrix $\kappa$ is positive semidefinite (PSD) for all possible choices of data set $\boldsymbol { X }$ [47].
|
| 130 |
+
|
| 131 |
+
# 3.3 Correspondence between GPs and NNs
|
| 132 |
+
|
| 133 |
+
118 Neal [42] proved that a single-hidden layer network with infinite width is exactly equivalent to a GP
|
| 134 |
+
119 over data indices $i = 1 , 2 , . . . , N$ under the assumption that the weight and bias parameters of the
|
| 135 |
+
120 hidden layer are i.i.d. Gaussian with zero mean. Lee et al. [34] and Garriga et al. [17] then extended
|
| 136 |
+
121 this statement to deep neural networks and convolutional neural networks (CNNs), respectively.
|
| 137 |
+
122 However, if the width (or the number of channels) of a network is finite, then these results state that
|
| 138 |
+
123 the network approximately converges to a GP with zero mean as in the following lemma.
|
| 139 |
+
124 Lemma 1 Let $z = f _ { N N } ( x ^ { ( 1 ) } ) : \mathbb { R } ^ { D _ { 1 } } \mathbb { R } ^ { p }$ be the latent representation extracted from $x ^ { ( 1 ) }$ where
|
| 140 |
+
125 $p$ is the dimension of the extracted representation and fNN is a neural network with finite width
|
| 141 |
+
126 and zero-mean i.i.d. parameters. The $\mathbf { \dot { \boldsymbol { k } } } ^ { t h }$ entry of this representation will approximately follow $a$
|
| 142 |
+
127 NN-implied $G P$
|
| 143 |
+
|
| 144 |
+
$$
|
| 145 |
+
z _ { k } = f _ { N N } \left( x ^ { ( 1 ) } \right) _ { k } \sim \mathcal { G P } _ { a p p r o x } \left( 0 , K _ { N N } \left( x ^ { ( 1 ) } , x ^ { ( 1 ) ^ { \prime } } \right) \right) .
|
| 146 |
+
$$
|
| 147 |
+
|
| 148 |
+
128 That is to say, the $k ^ { t h }$ component $z _ { k }$ of the representation extracted by the network has zero mean
|
| 149 |
+
129 $\mathbb { E } _ { p \big ( \theta ^ { ( 1 ) } \big ) } \left[ z _ { i k } ^ { ( 1 ) } \right] = 0$ for all $i = 1 , 2 , . . . , N$ where $\theta$ represents the network parameters. The co
|
| 150 |
+
130 variance between z(1)ik and $z _ { j k } ^ { ( 1 ) }$ for different data indices $i , j = 1 , 2 , . . . , N$ can be approximated as
|
| 151 |
+
|
| 152 |
+

|
| 153 |
+
Figure 1: Given data containing 2 sources of information $x ^ { ( 1 ) }$ and $x ^ { ( 2 ) }$ , we can process the data using either (Left) a composite Gaussian process regression (GPR) model or (Right) our ICK framework where $\mathbf { \widetilde { \mathcal { X } } } _ { \mathcal { X } } ^ { ( 1 ) }$ is processed with a neural network $f _ { \mathrm { N N } } ( \cdot )$ and $x ^ { ( 2 ) }$ is processed with $\overset { \cdot } { g } ( \cdot )$ where $g ( \cdot )$ consists of a kernel function $K _ { 2 }$ and some transformation which maps the kernel matrix $K _ { 2 }$ into the latent space.
|
| 154 |
+
|
| 155 |
+
cov $\begin{array} { r } { \left( z _ { i k } ^ { ( 1 ) } , z _ { j k } ^ { ( 1 ) } \right) = \mathbb { E } _ { p \left( \theta ^ { ( 1 ) } \right) } \left[ z _ { i k } ^ { ( 1 ) } z _ { j k } ^ { ( 1 ) } \right] \approx K _ { \mathrm { N N } } \left( x _ { i } ^ { ( 1 ) } , x _ { j } ^ { ( 1 ) } \right) } \end{array}$ where $x _ { i } ^ { ( 1 ) }$ and $\boldsymbol { x } _ { j } ^ { ( 1 ) }$ are the correspond32 ing inputs for the network and $K _ { \mathrm { N N } }$ is the kernel function implied by the network.
|
| 156 |
+
|
| 157 |
+
# 133 4 Implicit Composite Kernel (ICK) Framework
|
| 158 |
+
|
| 159 |
+
We show the structure of a composite GPR model and our ICK framework in Figure 1. To make the illustration clear, we limit ourselves to data with information from 2 different sources ${ \textbf { \em x } } =$ $\{ x ^ { ( 1 ) } , x ^ { ( 2 ) } \}$ where $x ^ { ( 1 ) }$ is high-dimensional and $x ^ { ( 2 ) }$ is low-dimensional (i.e. $D _ { 1 } \gg D _ { 2 }$ ) with some known relationship with the target $y$ . We are inspired by composite GPR, which computes 2 different kernel matrices $K _ { 1 }$ and $K _ { 2 }$ and then combines them into a single composite kernel matrix $K _ { \mathrm { c o m p } }$ However, as discussed before, it is more suitable to use a NN to learn from the high dimensional information $x ^ { ( 1 ) }$ . In our ICK framework, we process $x ^ { ( 1 ) }$ with a NN $f _ { \mathrm { N N } } ( \cdot ) : \mathbb { R } ^ { D _ { 1 } } \to \mathbb { R } ^ { p }$ and $x ^ { ( 2 ) }$ with a mapping $g ( \cdot ) : \mathbb { R } ^ { D _ { 2 } } \to \mathbb { R } ^ { p }$ which consists of a kernel function $K _ { 2 }$ followed by a kernelto-latent-space transformation (described in Section 4.2), resulting in two latent representations $ { \boldsymbol { z } } ^ { ( 1 ) } , { \boldsymbol { z } } ^ { ( 2 ) } \in \mathbb { R } ^ { p }$ . Then, we make a prediction $\hat { y }$ by doing an inner product between these two representations $\hat { y } = f _ { \mathrm { N N } } \left( x _ { \dots } ^ { ( 1 ) } \right) \cdot g \left( \bar { x ^ { ( 2 ) } } \right)$ . Finally, the parameters of both the NN and the kernel function are learned via gradient-based optimization methods [3, 30].
|
| 160 |
+
|
| 161 |
+
In the sections below, we first analytically show that our ICK framework is approximately equivalent to a composite GPR model a priori using a multiplicative kernel between the kernel implicitly defined by the NN on $x ^ { ( 1 ) }$ and the chosen kernel on $x ^ { ( 2 ) }$ . This theory is used to motivate the model form. The model will deviate from the GP solution after learning, but we note that recent work suggests that the predictions from a trained NN may not vary too much from its GP equivalent [34]. We then show how we implement the kernel-to-latent-space transformation in detail. Here, we note that we apply ICK for multiplicative kernels but note that an additive kernel may be constructed using the 3 methods of Pearce et al. [43].
|
| 162 |
+
|
| 163 |
+
# 4.1 Resemblance between Composite GPR and ICK
|
| 164 |
+
|
| 165 |
+
We will analytically prove the following theorem for data with information from 2 different sources $\pmb { x } = \{ x ^ { ( 1 ) } , \acute { x } ^ { ( 2 ) } \}$ for clarity, and we note this theorem can be straightforwardly extended to $M > 2$
|
| 166 |
+
|
| 167 |
+
Theorem 1 Let $f _ { N N } : \mathbb { R } ^ { D _ { 1 } } \mathbb { R } ^ { p }$ be a NN function with random weights and $g : \mathbb { R } ^ { D _ { 2 } } \mathbb { R } ^ { p }$ be $a$ mapping function, and define an inner product $\hat { y }$ between the representations $z ^ { ( \mathrm { 1 } ) } = f _ { N N } \left( x ^ { ( \mathrm { 1 } ) } \right)$ an d $z ^ { ( 2 ) } = g \left( x ^ { ( 2 ) } \right)$ . Then this inner product approximately follows a composite GPR model
|
| 168 |
+
|
| 169 |
+
$$
|
| 170 |
+
\hat { y } = f _ { I C K } \left( x ^ { ( 1 ) } , x ^ { ( 2 ) } \right) = f _ { N N } \left( x ^ { ( 1 ) } \right) \cdot g \left( x ^ { ( 2 ) } \right) \sim \mathcal { G P } _ { a p p r o x } \left( 0 , K _ { N N } ^ { ( 1 ) } K ^ { ( 2 ) } \right) ,
|
| 171 |
+
$$
|
| 172 |
+
|
| 173 |
+
160 if g includes the following deterministic kernel-to-latent-space transformation
|
| 174 |
+
|
| 175 |
+
$$
|
| 176 |
+
{ \cal K } ^ { ( 2 ) } \left( x _ { i } ^ { ( 2 ) } , x _ { j } ^ { ( 2 ) } \right) \approx z _ { i } ^ { ( 2 ) } { } ^ { T } z _ { j } ^ { ( 2 ) } = g \left( x _ { i } ^ { ( 2 ) } \right) ^ { T } g \left( x _ { j } ^ { ( 2 ) } \right) ,
|
| 177 |
+
$$
|
| 178 |
+
|
| 179 |
+
To prove Theorem 1, we first make the following assumption.
|
| 180 |
+
|
| 181 |
+
Assumption 1 For latent representations $\boldsymbol { z } _ { i } ^ { ( m ) }$ and $\boldsymbol { z } _ { j } ^ { ( m ) }$ extracted from different data points $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ and $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { j } }$ where $i \neq j$ and $m \in \{ 1 , 2 \}$ , the interactions between different entries of $\boldsymbol { z } _ { i } ^ { ( m ) }$ and $\boldsymbol { z } _ { j } ^ { ( m ) }$ can be reasonably ignored. In other words, let $\theta ^ { ( m ) }$ be the parameters of the network or the kernel function which takes in x(m) and outputs z(m), we have Ep(θ(m)) $\begin{array} { r } { \mathbb { E } _ { p \big ( \theta ^ { ( m ) } \big ) } \left[ z _ { i k } ^ { ( m ) } z _ { j l } ^ { ( m ) } \right] = 0 _ { \cdot } } \end{array}$ for all $k \neq l$ .
|
| 182 |
+
|
| 183 |
+
With Assumption 1 and Lemma 1, let 167 $\Theta = \left\{ \theta ^ { ( 1 ) } , \theta ^ { ( 2 ) } \right\}$ represent the parameters of the ICK frame168 work, we can calculate the covariance between $\hat { y } _ { i }$ and $\hat { y } _ { j }$ for different data indices $i \neq j$ as follows
|
| 184 |
+
|
| 185 |
+
$$
|
| 186 |
+
\begin{array} { r l } { \mathrm { c o v } ( \hat { y } _ { i } , \hat { y } _ { j } ) = \mathbb { E } _ { p ( \Theta ) } [ \hat { y } _ { i } \hat { y } _ { j } ] - \mathbb { E } _ { p ( \Theta ) } [ \hat { y } _ { i } ] \mathbb { E } _ { p ( \Theta ) } [ \hat { y } _ { j } ] } & { } \\ & { = \mathbb { E } _ { p ( \Theta ) } \left[ \left( \sum _ { k = 1 } ^ { p } z _ { i k } ^ { ( 1 ) } z _ { i k } ^ { ( 2 ) } \right) \left( \sum _ { k = 1 } ^ { p } z _ { j k } ^ { ( 1 ) } z _ { j k } ^ { ( 2 ) } \right) \right] } \\ & { = \mathbb { E } _ { p ( \Theta ) } \left[ \sum _ { k = 1 } ^ { p } \sum _ { l = 1 } ^ { p } z _ { i k } ^ { ( 1 ) } z _ { j l } ^ { ( 1 ) } z _ { i k } ^ { ( 2 ) } z _ { j l } ^ { ( 2 ) } \right] } \\ & { = \mathbb { E } _ { p ( \Theta ) } \left[ \sum _ { k = 1 } ^ { p } z _ { i k } ^ { ( 1 ) } z _ { j k } ^ { ( 1 ) } z _ { i k } ^ { ( 2 ) } z _ { j k } ^ { ( 2 ) } \right] } \\ & { = \sum _ { k = 1 } ^ { p } \mathbb { E } _ { p \left( \theta ^ { ( 1 ) } \right) } \left[ z _ { i k } ^ { ( 1 ) } z _ { j k } ^ { ( 1 ) } \right] \mathbb { E } _ { p \left( \theta ^ { ( 2 ) } \right) } \left[ z _ { i k } ^ { ( 2 ) } z _ { j k } ^ { ( 2 ) } \right] } \\ & { \approx K _ { \mathrm { N N } } ^ { ( 1 ) } \left( x _ { i } ^ { ( 1 ) } , x _ { j } ^ { ( 1 ) } \right) \sum _ { k = 1 } ^ { p } \mathbb { E } _ { p \left( \theta ^ { ( 2 ) } \right) } \left[ z _ { i k } ^ { ( 2 ) } z _ { j k } ^ { ( 2 ) } \right] . } \end{array}
|
| 187 |
+
$$
|
| 188 |
+
|
| 189 |
+
169 Here, from Equation 5 to Equation 6, we use the statement Ep(θ(1)) h $\mathbb { E } _ { p \left( \theta ^ { ( 1 ) } \right) } \left[ z _ { i k } ^ { ( 1 ) } \right] = 0$ from Lemma 1 and the
|
| 190 |
+
170 independence between $\theta ^ { ( 1 ) }$ and $\theta ^ { ( 2 ) }$ , which leads to $\mathbb { E } _ { p ( \Theta ) } [ \hat { y } _ { i } ] = \mathbb { E } _ { p ( \Theta ) } [ \hat { y } _ { j } ] = 0$ . From Equation 7 to
|
| 191 |
+
171 Equation 8, we get rid of all the cross terms under Assumption 1. From Equation 8 to Equation 9, we
|
| 192 |
+
172 again make use of the independence between $\theta ^ { ( 1 ) }$ and $\theta ^ { ( 2 ) }$ . From Equation 9 to Equation 10, we use
|
| 193 |
+
173 the statement Ep(θ(1)) $\mathbb { E } _ { p \left( \theta ^ { ( 1 ) } \right) } \left[ z _ { i k } ^ { ( \bar { 1 } ) } z _ { j k } ^ { ( 1 ) } \right] \approx K _ { \mathrm { N N } } \left( x _ { i } ^ { ( 1 ) } , x _ { j } ^ { ( 1 ) } \right)$ from Lemma 1. If the kernel-to-latent-space
|
| 194 |
+
174 transformation in $g ( \cdot )$ is deterministic, we can remove the expectation sign from the summation term
|
| 195 |
+
175 in Equation 10 and the covariance can be further expressed as
|
| 196 |
+
|
| 197 |
+
$$
|
| 198 |
+
\begin{array} { r } { \mathrm { c o v } ( \hat { y } _ { i } , \hat { y } _ { j } ) \approx K _ { \mathrm { N N } } ^ { ( 1 ) } \left( x _ { i } ^ { ( 1 ) } , x _ { j } ^ { ( 1 ) } \right) \left( z _ { i } ^ { ( 2 ) ^ { T } } z _ { j } ^ { ( 2 ) } \right) = K _ { \mathrm { N N } } ^ { ( 1 ) } \left( x _ { i } ^ { ( 1 ) } , x _ { j } ^ { ( 1 ) } \right) K ^ { ( 2 ) } \left( x _ { i } ^ { ( 2 ) } , x _ { j } ^ { ( 2 ) } \right) , } \end{array}
|
| 199 |
+
$$
|
| 200 |
+
|
| 201 |
+
which means that 176 $\hat { y }$ approximately follows a GP with composite kernel $K _ { \mathrm { c o m p } } ( { \pmb x } _ { i } , { \pmb x } _ { j } ) =$ 177 $K _ { \mathrm { N N } } ^ { ( 1 ) } \left( x _ { i } ^ { ( 1 ) } , x _ { j } ^ { ( 1 ) } \right) K ^ { ( 2 ) } \left( x _ { i } ^ { ( 2 ) } , x _ { j } ^ { ( 2 ) } \right)$ a priori. This completes our proof of Theorem 1.
|
| 202 |
+
|
| 203 |
+
# 178 4.2 Kernel-to-latent-space Transformation
|
| 204 |
+
|
| 205 |
+
We now show how we can construct an appropriate mapping $g ( \cdot )$ that approximately satisfies the assumed form of (4) and is used in the derivation of ICK from (10) to (11). Here we adopt two methods, Nyström approximation and Random Fourier Features (RFF), to map the kernel matrix into the latent space. Below, we give the formulations and results for the Nyström method, and give the methods and results for RFF in Appendix B. According to Yang et al. [59], the Nyström method will yield much better performance than RFF if there exists a large gap in the eigen-spectrum of the kernel matrix. In our applications, we also observe a large eigen-gap (see details in Appendix C) and Nyström method does generalize much better than RFF. We name our framework with Nyström method and random Fourier Features ICKy and $\operatorname { I C K } r$ , respectively.
|
| 206 |
+
|
| 207 |
+
# 4.2.1 Nyström Method
|
| 208 |
+
|
| 209 |
+
189 The main idea of Nyström method [53] is to approximate the kernel matrix $\pmb { K } \in \mathbb { R } ^ { N \times N }$ with a much
|
| 210 |
+
190 smaller low-rank matrix $K _ { q } \in \mathbb { R } ^ { q \times q }$ where $q \ll N$ so both the computational and space complexity
|
| 211 |
+
191 of kernel learning can be significantly reduced
|
| 212 |
+
|
| 213 |
+
$$
|
| 214 |
+
\begin{array} { r } { { \cal K } \approx \hat { \cal K } = { \cal K } _ { n q } { \cal K } _ { q } ^ { - 1 } { \cal K } _ { n q } ^ { T } . } \end{array}
|
| 215 |
+
$$
|
| 216 |
+
|
| 217 |
+
192 The entries of $K _ { q }$ and $K _ { n q }$ can be calculated as $\left( \mathbf { { K } } _ { q } \right) _ { i j } \ = \ { K } ( \hat { x } _ { i } , \hat { x } _ { j } ) , i , j \ \in \ \{ 1 , 2 , . . . , q \}$ and
|
| 218 |
+
193 $\left( { \cal K } _ { n q } \right) _ { i j } = { \cal K } ( x _ { i } , \hat { x } _ { j } ) , i \in \{ 1 , 2 , . . . , N \} , j \in \{ 1 , 2 , . . . , q \}$ , respectively. $x$ represents the original
|
| 219 |
+
194 data points and $\hat { x }$ represents pre-defined inducing points (or pseudo-inputs [49]). In our study, these
|
| 220 |
+
195 inducing points are chosen by defining an evenly spaced vector over the range of original data points.
|
| 221 |
+
196 By performing Cholesky decomposition $K _ { q } ^ { - 1 } = U ^ { T } U$ , where $U \in \mathbb { R } ^ { q \times q }$ , $\hat { \pmb K }$ is
|
| 222 |
+
|
| 223 |
+
$$
|
| 224 |
+
\hat { \boldsymbol { K } } = \boldsymbol { K } _ { n q } \boldsymbol { K } _ { q } ^ { - 1 } \boldsymbol { K } _ { n q } ^ { T } = \boldsymbol { K } _ { n q } \boldsymbol { U } ^ { T } \boldsymbol { U } \boldsymbol { K } _ { n q } ^ { T } = \left( \boldsymbol { U } \boldsymbol { K } _ { n q } ^ { T } \right) ^ { T } \left( \boldsymbol { U } \boldsymbol { K } _ { n q } ^ { T } \right) .
|
| 225 |
+
$$
|
| 226 |
+
|
| 227 |
+
Therefore, if we set the number of inducing points to be 197 $q = p$ , then we can use $z _ { i } \triangleq U \left( K _ { n p } ^ { T } \right) _ { : , i }$
|
| 228 |
+
|
| 229 |
+
198 as a kernel-to-latent-space transformation because each element in $\kappa$ approximately satisfies (4)
|
| 230 |
+
199 as stated in Theorem 1: $K \left( x _ { i } , x _ { j } \right) = K _ { i j } \approx \hat { K } _ { i j } = z _ { i } ^ { T } z _ { j }$ . Conveniently, modern deep learning
|
| 231 |
+
200 frameworks can propagate gradients through the Cholesky operation, making it straightforward to
|
| 232 |
+
201 update the kernel parameters with gradient methods. Note that as we increase the number of inducing
|
| 233 |
+
202 points $p$ , the approximation error between $\kappa$ and $\hat { \pmb K }$ decreases. However, it is not recommended to
|
| 234 |
+
203 set $p$ very large as updating the Cholesky decomposition requires $\mathcal { O } ( p ^ { 3 } )$ . The empirical impact of
|
| 235 |
+
204 $p$ on computational time and performance is shown in Appendix E. In our experiments, only mild
|
| 236 |
+
205 values of $p$ are necessary and the impact on computational is relatively small.
|
| 237 |
+
|
| 238 |
+
# 5 Experimental Results
|
| 239 |
+
|
| 240 |
+
We evaluate ICKy on 3 different data sets: a synthetic data set, a remote sensing data set, and a data set obtained from UCI Machine Learning Repository [13]. Note that in all the 3 experiments, our ICKy framework only consists of 2 kernels (i.e. $M = 2$ ), one NN-implied kernel and one chosen kernel function with trainable parameters. To verify that ICKy can work with more than 2 kernels, we create another synthetic data set with 3 kernels and show the corresponding results in Appendix A. In addition, the experimental results for $\mathbf { I C K } r$ is provided in Appendix B. All experiments are conducted on a computer cluster equipped with a GeForce RTX 2080 Ti GPU. The implementation details of all the experiments in this section are provided in Appendix G.
|
| 241 |
+
|
| 242 |
+
# 5.1 Synthetic Data
|
| 243 |
+
|
| 244 |
+
To verify that $\mathrm { I C K y }$ can simulate a multiplicative kernel, we create a synthetic data set $y \sim$ $\mathcal { G P } ( 0 , K _ { 1 } K _ { 2 } )$ containing 3000 data points where $x ^ { ( 1 ) } \in [ 0 , 1 ]$ is the input for the linear kernel $K _ { 1 }$ and $x ^ { ( 2 ) } \in [ 0 , 2 ]$ is the input for the spectral mixture kernel [56] $K _ { 2 }$ with 2 components. With $\mathrm { I C K y }$ , we process $x ^ { ( 1 ) }$ with a single-hidden-layer NN and $x ^ { ( 2 ) }$ with a spectral mixture kernel function. We evaluate ICKy on both a prediction task (where we first randomly shuffle the data points and do a 50:50 train-test split) and a forecasting task (where we use only the data points with $x ^ { ( 2 ) } < 0 . 6$ for training and the rest for testing).
|
| 245 |
+
|
| 246 |
+
223 We then compare $\mathrm { I C K y }$ with two models: a plain multi-layer perceptron (MLP) applied to the
|
| 247 |
+
224 concatenated features and a novel multi-layer perceptron-random forest (MLP-RF) joint model
|
| 248 |
+
225 employed by Zheng et al. [61] where MLP learns from $x ^ { ( 1 ) }$ and RF learns from $x ^ { ( 2 ) }$ . We believe
|
| 249 |
+
226 MLP-RF serves as a good benchmark model as it is a joint model with similar architecture to our
|
| 250 |
+
227 $\mathrm { I C K y }$ framework. To see how ICKy simulates the spectral mixture kernel, we plot only $x ^ { ( 2 ) }$ against
|
| 251 |
+
228 the predicted value of $y$ as shown in Figure 2. As can be seen from the figure, in the prediction task
|
| 252 |
+
229 (top row), plain MLP only captures the linear trend. MLP-RF only captures the mean of the spectral
|
| 253 |
+
230 mixture components. In contrast, our ICKy framework captures both the mean and the variance of the
|
| 254 |
+
231 spectral mixture kernel. In the forecasting task (bottom row), $\mathrm { I C K y }$ also outperforms plain MLP and
|
| 255 |
+
232 MLP-RF as it approximately captures the rising trend in the range of $x ^ { ( 2 ) } \in \mathsf { [ 0 . 6 , 1 ] }$ . When $x ^ { ( 2 ) } > 1$ ,
|
| 256 |
+
233 ICKy is unable to confidently extrapolate, so it starts to "fail gracefully," by which we mean that the
|
| 257 |
+
234 prediction reverts to the mean of the prior (e.g., no observed information case.), just as would be
|
| 258 |
+
235 expected in a GP. However, we do not evaluate the posterior distribution to get a full sense of the
|
| 259 |
+
236 posterior uncertainty.
|
| 260 |
+
237 We also test plain MLP, MLP-RF, and ICKy on the prediction task using different number of training
|
| 261 |
+
238 samples. As displayed in Figure 3, ICKy yields the smallest error among all the 3 frameworks even
|
| 262 |
+
239 with very limited data. In addition, to test the robustness of $\mathrm { I C K y }$ , we conduct the same experiments
|
| 263 |
+
240 on another synthetic data set in Appendix D to confirm that ICKy can simulate an additive kernel.
|
| 264 |
+
|
| 265 |
+

|
| 266 |
+
Figure 2: Prediction (top row) and forecasting (bottom row) of $y \sim \mathcal { G P } ( 0 , K _ { 1 } K _ { 2 } )$ , where $x ^ { ( 1 ) }$ is input to a linear kernel $K _ { 1 }$ and $x ^ { ( 2 ) }$ is input to a spectral mixture kernel $K _ { 2 }$ . We plot $x ^ { ( 2 ) }$ against the predicted $y$ . We show results from a plain MLP (left column), MLP-RF (middle left column), and $\mathrm { I C K y }$ framework (middle right column), and we compare to the true values of $y$ (right column).
|
| 267 |
+
|
| 268 |
+
We believe ICKy will be particularly useful for remote sensing applications. In this experiment, we collect remote sensing data from 51 air quality monitoring (AQM) stations located in the National Capital Territory (NCT) of Delhi and its satellite cities over the period from January 1, 2018 to June 30, 2020 (see Appendix F for notes on data availability). Each data point ${ \pmb x } = \{ { \boldsymbol x } , t \}$ contains 2 sources of information: a three-band natural color (red-blue-green) satellite image $x$ as the high-dimensional information and the corresponding timestamp as the low-dimensional information. Note that we convert the timestamps into numerical values $t$ (where the day 2018-01-01 corresponds to $t = 0$ ) before feeding them into the models. Our goal is to predict the ground-level $\mathrm { P M } _ { 2 . 5 }$ concentration $\hat { y } = f ( x , t )$ using both sources of information.
|
| 269 |
+
|
| 270 |
+

|
| 271 |
+
Figure 3: Prediction error of plain MLP, MLPRF, and $\mathrm { I C K y }$ with different amount of training data generated by $\begin{array} { r } { y = \mathcal { G P } ( 0 , K _ { 1 } K _ { 2 } ) } \end{array}$ .
|
| 272 |
+
|
| 273 |
+
We split the train and test data set based on $t$ . Specifically, we use all the data points with $t \geq 5 0 0$ for testing and the rest for training. As $\mathrm { P M } _ { 2 . 5 }$ varies with time on a yearly basis, we use an exponentialsine-squared kernel with a period of $T = 3 6 5$ (days) to process the low-dimensional information $t$ . The satellite images are processed with a CNN. Figure 4 shows the true versus the forecasted $\mathrm { P M } _ { 2 . 5 }$ values by both ICKy and 2 benchmarks: a Convolutional Neural Network-Random Forest (CNN-RF) joint model [61, 62] (similar to the MLP-RF model in Section 5.1, where RF learns the temporal variation of $\mathrm { P M } _ { 2 . 5 }$ and CNN captures the spatial variation of $\mathrm { P M } _ { 2 . 5 }$ from satellite images) and a carefully designed CNN-RF model that maps $t$ into two new features, $\sin ( 2 \pi t / 3 6 5 )$ and $\cos ( 2 \pi t / 3 6 5 )$ , to explicitly model seasonality. As can be seen, ICKy outperforms both benchmarks with the highest correlation coefficients and the lowest errors on the forecasting task. Specifically, regular CNN-RF joint model fails to forecast $\mathrm { P M } _ { 2 . 5 }$ as shown in Figure 4a. After including seasonality, CNN-RF performs significantly better as shown in Figure 4b, but the forecasted $\mathrm { P M } _ { 2 . 5 }$ values are still less smooth than those from ICKy (Figure 4c) due to the discontinuous nature of the RF regressor [6, 19]. We also visualize these results in the form of time series in Appendix F
|
| 274 |
+
|
| 275 |
+
Table 1: Correlation and error statistics of $\mathrm { I C K y }$ and other joint deep models with both convolutional and attention-based architectures on the $\mathrm { P M } _ { 2 . 5 }$ forecasting task
|
| 276 |
+
|
| 277 |
+
<table><tr><td></td><td>Spearman R↑</td><td>Pearson R↑</td><td>RMSE↓</td><td>MAE↓</td></tr><tr><td>CNN-RF[61]</td><td>0.48</td><td>0.32</td><td>70.09</td><td>54.28</td></tr><tr><td>ViT-RF[11]</td><td>0.42</td><td>0.32</td><td>70.58</td><td>55.15</td></tr><tr><td>Seasonal CNN-RF</td><td>0.65</td><td>0.73</td><td>52.60</td><td>39.25</td></tr><tr><td>Seasonal ViT-RF</td><td>0.66</td><td>0.74</td><td>49.92</td><td>36.22</td></tr><tr><td>Seasonal DeepViT-RF[63]</td><td>0.68</td><td>0.76</td><td>48.87</td><td>35.32</td></tr><tr><td>Seasonal MAE-ViT-RF[22]</td><td>0.68</td><td>0.76</td><td>48.43</td><td>34.92</td></tr><tr><td>CNN-ICKy</td><td>0.70</td><td>0.77</td><td>47.15</td><td>32.84</td></tr><tr><td>ViT-ICKy</td><td>0.66</td><td>0.77</td><td>47.17</td><td>34.00</td></tr><tr><td>DeepViT-ICKy</td><td>0.62</td><td>0.73</td><td>48.68</td><td>34.10</td></tr></table>
|
| 278 |
+
|
| 279 |
+
273 We note that the inner product operation in ICK is similar in mathematical structure to attention-based
|
| 280 |
+
274 mechanisms [51] popular in many deep learning frameworks. Therefore, we compare ICKy with
|
| 281 |
+
275 4 attention-based benchmarks that we constructured based off of a Vision Transformer (ViT) [11]
|
| 282 |
+
276 architecture, including ViT-RF, Seasonal ViT-RF, Seasonal DeepViT-RF [63], and Seasonal MAE
|
| 283 |
+
277 ViT-RF where ViT is pre-trained by a Masked Autoencoder [22], as displayed in Table 1. These use
|
| 284 |
+
278 the same RF and sinsusoidal mappings as described previously to input the temporal information into
|
| 285 |
+
279 the model. We note that we are unaware of Vision Transformers being used in this manner, and that
|
| 286 |
+
280 all these models represent novel formulations. It can be observed that standard ViT-RF model fails to
|
| 287 |
+
281 forecast $\mathrm { P M } _ { 2 . 5 }$ without seasonality incorporated, just as in CNN-RF. After introducing seasonality
|
| 288 |
+
282 by mapping $t$ into sinusoidal features, ViT-based joint models yield higher correlation and smaller
|
| 289 |
+
283 error than CNN-RF but still underperform CNN-based ICKy. We also considered using a ViT-based
|
| 290 |
+
284 architecture for the CNN $\mathrm { I C K y }$ , and observed similar performance in these ICKy variants.
|
| 291 |
+
|
| 292 |
+
# 5.3 UCI Machine Learning Repository Data
|
| 293 |
+
|
| 294 |
+
To see if our ICKy framework generalizes to other domains, we acquire another data set containing the normalized productivity and corresponding features of garment workers from the UCI Machine Learning Repository. Imran et al. [1] employed a dense MLP with 2 hidden layers to predict the worker productivity with collected features such as date, team number, targeted productivity, etc. To test our ICKy framework, we separate out the date and use it as the low-dimensional information. The rest of the features (excluding the temporal information) are then concatenated together to serve as the high-dimensional information. Observing that the daily averaged worker productivity has an approximate monthly trend, we again use an exponential-sine-squared kernel. The network architecture of ICKy is the same as that of the two-hidden-layer MLP benchmark. To demonstrate the strength of ICKy compared to other methods that equip NNs with GPs, we also add 2 additional benchmarks here: a Gaussian Neural Process (GNP) [7] and an Attentive Gaussian Neural Process (AGNP) [29]. Based on the results shown in Table 2, ICKy has the best performance when the period parameter of the kernel is set to be $T = 3 0$ (days) and it outperforms both MLP and NP benchmarks by almost one order of magnitude. When we set $T = 2$ or $T = 7$ , this improvement is less significant, which aligns with our initial observation that the daily averaged productivity has a monthly seasonal trend. It is also worth noting that the GNP benchmarks here yield larger errors than MLPs. A possible explanation is that GNP does not allow explicit assignment of a stationary kernel (as the kernel models a posterior covariance) so it is hard for GNP to identify specific patterns in the data such as seasonality without being given the pattern a priori.
|
| 295 |
+
|
| 296 |
+
Table 2: Prediction error of actual worker productivity on the test data set with $\mathrm { I C K y }$ and other benchmark models (MLPs and NPs)
|
| 297 |
+
|
| 298 |
+
<table><tr><td></td><td>MSE↓(*10-)</td><td>MAE↓(*10-2)</td><td>MAPE↓</td></tr><tr><td>MLP[1]</td><td>20.16 ± 1.26</td><td>9.93 ± 0.36</td><td>17.30 ± 0.82</td></tr><tr><td>Cyclic MLP</td><td>20.97 ± 1.98</td><td>10.16 ± 0.77</td><td>17.48 ± 1.37</td></tr><tr><td>GNP [7, 37]</td><td>57.25 ± 4.31</td><td>19.39 ± 0.94</td><td>29.58 ± 1.63</td></tr><tr><td>AGNP [29]</td><td>43.11 ± 5.95</td><td>14.38 ± 0.88</td><td>22.59 ± 1.42</td></tr><tr><td>ICKy,T = 2</td><td>3.43 ± 1.42</td><td>4.85 ± 1.00</td><td>6.74 ± 1.37</td></tr><tr><td>ICKy,T= 7</td><td>0.44 ± 0.13</td><td>1.43 ± 0.15</td><td>2.22 ± 0.21</td></tr><tr><td>ICKy,T = 30</td><td>0.31 ± 0.09</td><td>1.17 ± 0.14</td><td>1.79 ± 0.22</td></tr></table>
|
| 299 |
+
|
| 300 |
+

|
| 301 |
+
Figure 4: Density plots of the true $\mathrm { P M } _ { 2 . 5 }$ concentrations against the forecasted $\mathrm { P M } _ { 2 . 5 }$ concentrations for $t \geq 5 0 0$ using (a) a CNN-RF joint model [61, 62], (b) a CNN-RF joint model with seasonality incorporated, and (c) our ICKy framework
|
| 302 |
+
|
| 303 |
+
# 305 6 Discussion
|
| 304 |
+
|
| 305 |
+
306
|
| 306 |
+
307
|
| 307 |
+
308
|
| 308 |
+
309
|
| 309 |
+
310
|
| 310 |
+
311
|
| 311 |
+
312
|
| 312 |
+
313
|
| 313 |
+
314
|
| 314 |
+
315
|
| 315 |
+
316
|
| 316 |
+
317
|
| 317 |
+
318
|
| 318 |
+
|
| 319 |
+
Efficiency, Flexibility, and Generalization Compared to exact composite GP models which scale $\mathcal { O } ( N ^ { 3 } )$ , the training process of our ICK framework is more efficient as it leverages standard backpropagation to learn both the paramters of NN and the kernel function. In addition, the network architecture of ICK can be very simple, as can be seen in all 3 experiments of ours, which further reduces its time and space complexity. Besides efficiency, our ICK framework is more flexible compared to other joint models (i.e. BNNs and CNN-RF). To be specific, the BNNs implemented by Pearce et al. [43] cannot simulate complicated kernels such as the spectral mixture kernel we use in Section 5.1. The CNN-RF joint model implemented by Zheng et al. [61] requires us to carefully design the input pre-processing procedure. Also, ICK generalizes well to unseen data even with very limited training samples. There is a potential concern that ICKy may run into computational challenges when a large number of inducing points are required. This was not a problem in our experiments, but in large scale models this could be tackled by considering conjugate gradient methods, which have been recently popular in GP inference [15].
|
| 320 |
+
|
| 321 |
+
319 Limitations A major limitation of ICK lies in our method of combining latent representations as the
|
| 322 |
+
320 nature of inner product (i.e. the effect of multiplying small numbers) may cause vanishing gradient
|
| 323 |
+
321 problems when we have a large number of sources of information (i.e. $M$ is large). Furthermore,
|
| 324 |
+
322 this paper only discusses the theoretical relationship between ICK and composite GPR a priori. This
|
| 325 |
+
323 relationship will not exactly hold true a posteriori, although empirical results [34] and theoretical
|
| 326 |
+
324 results [24] in slightly different contexts suggest that they may be close. Future work will evaluate
|
| 327 |
+
325 this gap by exploring Bayesian neural networks and a posteriori properties.
|
| 328 |
+
|
| 329 |
+
Broader Impacts We believe our framework is extensively applicable to regression problems in many fields of study involving high-dimensional data and multiple sources of information with perceptible trends, such as remote sensing, spatial statistics, or clinical diagnosis.
|
| 330 |
+
|
| 331 |
+
# 329 7 Conclusion
|
| 332 |
+
|
| 333 |
+
330 This paper presents a novel yet surprisingly simple Implicit Composite Kernel (ICK) framework to
|
| 334 |
+
331 learn from hybrid data containing both high-dimensional information and low-dimensional informa
|
| 335 |
+
332 tion with prior knowledge. We first analytically show the resemblance between ICK and composite
|
| 336 |
+
333 GPR models and then conduct experiments using both synthetic and real-world data. It appears
|
| 337 |
+
334 that ICK outperforms various benchmark models in our experiments with lowest prediction errors
|
| 338 |
+
335 and highest correlations even with very limited data. Overall, we show that our ICK framework is
|
| 339 |
+
336 exceptionally powerful when learning from hybrid data with our prior knowledge incorporated, and
|
| 340 |
+
337 we hope our work can inspire more future research on joint machine learning models, enhancing their
|
| 341 |
+
338 performance, efficiency, flexibility, and generalization capability.
|
| 342 |
+
|
| 343 |
+
[1] Abdullah Al Imran, Md Nur Amin, Md Rifatul Islam Rifat, and Shamprikta Mehreen. Deep neural network approach for predicting the productivity of garment employees. In 2019 6th International Conference on Control, Decision and Information Technologies (CoDIT), pages 1402–1407. IEEE, 2019.
|
| 344 |
+
[2] Christopher M Bishop and Nasser M Nasrabadi. Pattern recognition and machine learning, volume 4. Springer, 2006.
|
| 345 |
+
[3] Léon Bottou, Frank E Curtis, and Jorge Nocedal. Optimization methods for large-scale machine learning. Siam Review, 60(2):223–311, 2018.
|
| 346 |
+
[4] Mohamed A Bouhlel and Joaquim RRA Martins. Gradient-enhanced kriging for highdimensional problems. Engineering with Computers, 35(1):157–173, 2019.
|
| 347 |
+
[5] Mohamed Amine Bouhlel, Nathalie Bartoli, Abdelkader Otsmane, and Joseph Morlier. Improving kriging surrogates of high-dimensional design models by partial least squares dimension reduction. Structural and Multidisciplinary Optimization, 53(5):935–952, 2016.
|
| 348 |
+
[6] Leo Breiman. Random forests. Machine learning, 45(1):5–32, 2001.
|
| 349 |
+
[7] Wessel P Bruinsma, James Requeima, Andrew YK Foong, Jonathan Gordon, and Richard E Turner. The gaussian neural process. arXiv preprint arXiv:2101.03606, 2021.
|
| 350 |
+
[8] Nidhan Choudhuri, Subhashis Ghosal, and Anindya Roy. Nonparametric binary regression using a gaussian process prior. Statistical Methodology, 4(2):227–243, 2007.
|
| 351 |
+
[9] Abhirup Datta, Sudipto Banerjee, Andrew O Finley, and Alan E Gelfand. Hierarchical nearestneighbor gaussian process models for large geostatistical datasets. Journal of the American Statistical Association, 111(514):800–812, 2016.
|
| 352 |
+
[10] Zhijie Deng, Jiaxin Shi, and Jun Zhu. Neuralef: Deconstructing kernels by deep neural networks. arXiv preprint arXiv:2205.00165, 2022.
|
| 353 |
+
[11] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
|
| 354 |
+
[12] Petros Drineas, Michael W Mahoney, and Nello Cristianini. On the nyström method for approximating a gram matrix for improved kernel-based learning. journal of machine learning research, 6(12), 2005.
|
| 355 |
+
[13] Dheeru Dua and Casey Graff. UCI machine learning repository, 2017.
|
| 356 |
+
[14] David Duvenaud. Automatic model construction with Gaussian processes. PhD thesis, University of Cambridge, 2014.
|
| 357 |
+
[15] Jacob Gardner, Geoff Pleiss, Kilian Q Weinberger, David Bindel, and Andrew G Wilson. Gpytorch: Blackbox matrix-matrix gaussian process inference with gpu acceleration. Advances in neural information processing systems, 31, 2018.
|
| 358 |
+
[16] Marta Garnelo, Jonathan Schwarz, Dan Rosenbaum, Fabio Viola, Danilo J Rezende, SM Eslami, and Yee Whye Teh. Neural processes. arXiv preprint arXiv:1807.01622, 2018.
|
| 359 |
+
[17] Adrià Garriga-Alonso, Carl Edward Rasmussen, and Laurence Aitchison. Deep convolutional networks as shallow gaussian processes. arXiv preprint arXiv:1808.05587, 2018.
|
| 360 |
+
[18] Alan E Gelfand and Erin M Schliep. Spatial statistics and gaussian processes: A beautiful marriage. Spatial Statistics, 18:86–104, 2016.
|
| 361 |
+
[19] Pierre Geurts, Damien Ernst, and Louis Wehenkel. Extremely randomized trees. Machine learning, 63(1):3–42, 2006.
|
| 362 |
+
[20] Mark Girolami and Simon Rogers. Variational bayesian multinomial probit regression with gaussian process priors. Neural Computation, 18(8):1790–1817, 2006.
|
| 363 |
+
[21] Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep learning. MIT press, 2016.
|
| 364 |
+
[22] Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollár, and Ross Girshick. Masked autoencoders are scalable vision learners. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16000–16009, 2022.
|
| 365 |
+
[23] James Hensman, Nicolo Fusi, and Neil D Lawrence. Gaussian processes for big data. arXiv preprint arXiv:1309.6835, 2013.
|
| 366 |
+
[24] Arthur Jacot, Franck Gabriel, and Clément Hongler. Neural tangent kernel: Convergence and generalization in neural networks. Advances in neural information processing systems, 31, 2018.
|
| 367 |
+
[25] Max Jaderberg, Karen Simonyan, Andrew Zisserman, et al. Spatial transformer networks. Advances in neural information processing systems, 28, 2015.
|
| 368 |
+
[26] Ziyang Jiang, Tongshu Zheng, Mike Bergin, and David Carlson. Improving spatial variation of ground-level pm2. 5 prediction with contrastive learning from satellite imagery. Science of Remote Sensing, page 100052, 2022.
|
| 369 |
+
[27] Andre G Journel and Charles J Huijbregts. Mining geostatistics. The Blackburn Press, 1976.
|
| 370 |
+
[28] Hyoung-Moon Kim, Bani K Mallick, and Chris C Holmes. Analyzing nonstationary spatial data using piecewise gaussian processes. Journal of the American Statistical Association, 100(470):653–668, 2005.
|
| 371 |
+
[29] Hyunjik Kim, Andriy Mnih, Jonathan Schwarz, Marta Garnelo, Ali Eslami, Dan Rosenbaum, Oriol Vinyals, and Yee Whye Teh. Attentive neural processes. arXiv preprint arXiv:1901.05761, 2019.
|
| 372 |
+
[30] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 373 |
+
[31] Daniel G Krige. A statistical approach to some basic mine valuation problems on the witwatersrand. Journal of the Southern African Institute of Mining and Metallurgy, 52(6):119–139, 1951.
|
| 374 |
+
[32] Isaac E Lagaris, Aristidis Likas, and Dimitrios I Fotiadis. Artificial neural networks for solving ordinary and partial differential equations. IEEE transactions on neural networks, 9(5):987– 1000, 1998.
|
| 375 |
+
[33] Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. nature, 521(7553):436–444, 2015.
|
| 376 |
+
[34] Jaehoon Lee, Yasaman Bahri, Roman Novak, Samuel S Schoenholz, Jeffrey Pennington, and Jascha Sohl-Dickstein. Deep neural networks as gaussian processes. arXiv preprint arXiv:1711.00165, 2017.
|
| 377 |
+
[35] Chris J Maddison, Andriy Mnih, and Yee Whye Teh. The concrete distribution: A continuous relaxation of discrete random variables. arXiv preprint arXiv:1611.00712, 2016.
|
| 378 |
+
[36] Gary Marcus. Deep learning: A critical appraisal. arXiv preprint arXiv:1801.00631, 2018.
|
| 379 |
+
[37] Stratis Markou, James Requeima, Wessel Bruinsma, and Richard Turner. Efficient gaussian neural processes for regression. arXiv preprint arXiv:2108.09676, 2021.
|
| 380 |
+
[38] Takuo Matsubara, Chris J Oates, and François-Xavier Briol. The ridgelet prior: A covariance function approach to prior specification for bayesian neural networks. arXiv preprint arXiv:2010.08488, 2020.
|
| 381 |
+
[39] Alexander G de G Matthews, Mark Rowland, Jiri Hron, Richard E Turner, and Zoubin Ghahramani. Gaussian process behaviour in wide deep neural networks. arXiv preprint arXiv:1804.11271, 2018.
|
| 382 |
+
[40] Brian McFee, Gert Lanckriet, and Tony Jebara. Learning multi-modal similarity. Journal of machine learning research, 12(2), 2011.
|
| 383 |
+
[41] Ben Moseley, Andrew Markham, and Tarje Nissen-Meyer. Solving the wave equation with physics-informed deep learning. arXiv preprint arXiv:2006.11894, 2020.
|
| 384 |
+
[42] Radford M Neal. Priors for infinite networks. In Bayesian Learning for Neural Networks, pages 29–53. Springer, 1996.
|
| 385 |
+
[43] Tim Pearce, Russell Tsuchida, Mohamed Zaki, Alexandra Brintrup, and Andy Neely. Expressive priors in bayesian neural networks: Kernel combinations and periodic functions. In Uncertainty in artificial intelligence, pages 134–144. PMLR, 2020.
|
| 386 |
+
[44] Dejan Petelin, Alexandra Grancharova, and Juš Kocijan. Evolving gaussian process models for prediction of ozone concentration in the air. Simulation modelling practice and theory, 33:68–80, 2013.
|
| 387 |
+
[45] Ali Rahimi and Benjamin Recht. Random features for large-scale kernel machines. Advances in neural information processing systems, 20, 2007.
|
| 388 |
+
[46] Ali Rahimi and Benjamin Recht. Weighted sums of random kitchen sinks: Replacing minimization with randomization in learning. Advances in neural information processing systems, 21, 2008.
|
| 389 |
+
[47] John Shawe-Taylor, Nello Cristianini, et al. Kernel methods for pattern analysis. Cambridge university press, 2004.
|
| 390 |
+
[48] Tao Shi and Steve Horvath. Unsupervised learning with random forest predictors. Journal of Computational and Graphical Statistics, 15(1):118–138, 2006.
|
| 391 |
+
[49] Edward Snelson and Zoubin Ghahramani. Sparse gaussian processes using pseudo-inputs. Advances in neural information processing systems, 18, 2005.
|
| 392 |
+
[50] Mark Van der Wilk, Carl Edward Rasmussen, and James Hensman. Convolutional gaussian processes. Advances in Neural Information Processing Systems, 30, 2017.
|
| 393 |
+
[51] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
|
| 394 |
+
[52] Hao Wang, Hao He, and Dina Katabi. Continuously indexed domain adaptation. International Conference on Machine Learning, 2020.
|
| 395 |
+
[53] Christopher Williams and Matthias Seeger. Using the nyström method to speed up kernel machines. Advances in neural information processing systems, 13, 2000.
|
| 396 |
+
[54] Christopher K Williams and Carl Edward Rasmussen. Gaussian processes for machine learning, volume 2. MIT press Cambridge, MA, 2006.
|
| 397 |
+
[55] Christopher KI Williams and David Barber. Bayesian classification with gaussian processes. IEEE Transactions on pattern analysis and machine intelligence, 20(12):1342–1351, 1998.
|
| 398 |
+
[56] Andrew Wilson and Ryan Adams. Gaussian process kernels for pattern discovery and extrapolation. In International conference on machine learning, pages 1067–1075. PMLR, 2013.
|
| 399 |
+
[57] Andrew Gordon Wilson, Zhiting Hu, Ruslan Salakhutdinov, and Eric P Xing. Deep kernel learning. In Artificial intelligence and statistics, pages 370–378. PMLR, 2016.
|
| 400 |
+
[58] Andrew Gordon Wilson, David A Knowles, and Zoubin Ghahramani. Gaussian process regression networks. arXiv preprint arXiv:1110.4411, 2011.
|
| 401 |
+
[59] Tianbao Yang, Yu-Feng Li, Mehrdad Mahdavi, Rong Jin, and Zhi-Hua Zhou. Nyström method vs random fourier features: A theoretical and empirical comparison. Advances in neural information processing systems, 25, 2012.
|
| 402 |
+
[60] Daoqiang Zhang, Yaping Wang, Luping Zhou, Hong Yuan, Dinggang Shen, Alzheimer’s Disease Neuroimaging Initiative, et al. Multimodal classification of alzheimer’s disease and mild cognitive impairment. Neuroimage, 55(3):856–867, 2011.
|
| 403 |
+
[61] Tongshu Zheng, Michael Bergin, Guoyin Wang, and David Carlson. Local pm2. 5 hotspot detector at $3 0 0 \mathrm { m }$ resolution: A random forest–convolutional neural network joint model jointly trained on satellite images and meteorology. Remote Sensing, 13(7):1356, 2021.
|
| 404 |
+
[62] Tongshu Zheng, Michael H Bergin, Shijia Hu, Joshua Miller, and David E Carlson. Estimating ground-level pm2. 5 using micro-satellite images by a convolutional neural network and random forest approach. Atmospheric Environment, 230:117451, 2020.
|
| 405 |
+
[63] Daquan Zhou, Bingyi Kang, Xiaojie Jin, Linjie Yang, Xiaochen Lian, Zihang Jiang, Qibin Hou, and Jiashi Feng. Deepvit: Towards deeper vision transformer. arXiv preprint arXiv:2103.11886, 2021.
|
| 406 |
+
|
| 407 |
+
1. For all authors...
|
| 408 |
+
|
| 409 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Section 1.
|
| 410 |
+
(b) Did you describe the limitations of your work? [Yes] See Section 6
|
| 411 |
+
(c) Did you discuss any potential negative societal impacts of your work? [No] We are unaware of direct negative societal impacts.
|
| 412 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 413 |
+
|
| 414 |
+
2. If you are including theoretical results...
|
| 415 |
+
|
| 416 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 4.1
|
| 417 |
+
(b) Did you include complete proofs of all theoretical results? [Yes] See Section 4.1
|
| 418 |
+
|
| 419 |
+
3. If you ran experiments...
|
| 420 |
+
|
| 421 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] The code, data, and instructions to reproduce the experimental results are provided via the anonymous repository URL in the abstract.
|
| 422 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 5.
|
| 423 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See Section 5.1 and 5.3.
|
| 424 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See section 5
|
| 425 |
+
|
| 426 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 427 |
+
|
| 428 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 429 |
+
(b) Did you mention the license of the assets? [Yes] See Appendix I
|
| 430 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [Yes] We have included code, with the link in the abstract to an anonymous repository. This will be switched to a user-maintained repository if accepted.
|
| 431 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] We do not release data.
|
| 432 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] None of our datasets contain personally identifiable information or offensive content.
|
| 433 |
+
|
| 434 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 435 |
+
|
| 436 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 437 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 438 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
| 439 |
+
|
| 440 |
+

|
| 441 |
+
Figure A1: Scatter plots of the true values of $y$ against the predicted values of $y$ using our ICKy framework with (a) one source, (b) 2 sources, and (c) 3 sources of information
|
| 442 |
+
|
| 443 |
+

|
| 444 |
+
Figure A2: Given data containing $M$ sources of information $\pmb { x } = \{ x ^ { ( 1 ) } , x ^ { ( 2 ) } , . . . , x ^ { ( M ) } \}$ , we can process the data using our ICK framework where high-dimensional information (e.g. $x ^ { ( 1 ) }$ in the figure) is processed using a neural network and low-dimensional information (e.g. $x ^ { ( 2 ) }$ in the figure) is processed using a kernel function followed by Nyström or RFF transformation.
|
| 445 |
+
|
| 446 |
+
# 529 A ICK with More Than Two Kernels
|
| 447 |
+
|
| 448 |
+
530 Besides the visualization presented in Figure 1, we also show our ICK framework for processing data
|
| 449 |
+
531 $\pmb { x } = \left\{ x ^ { ( 1 ) } , x ^ { ( 2 ) } , . . . , x ^ { ( M ) } \right\}$ with $M > 2$ sources of information in Figure A2. Here ${ \bf \bar { \cal K } } ^ { ( 2 ) } , . . . , { \bf \bar { \cal K } } ^ { ( M ) }$
|
| 450 |
+
532 represent different types of kernels with trainable parachained inner product of all extracted representations ction is calculated by a.
|
| 451 |
+
533 $\begin{array} { r } { \hat { y } = \sum _ { k = 1 } ^ { p } \prod _ { m = 1 } ^ { M } z _ { k } ^ { ( m ) } } \end{array}$
|
| 452 |
+
534 To confirm that $\mathrm { I C K y }$ can work with more than 2 kernels, we construct another synthetic data set
|
| 453 |
+
535 containing 3000 data points in total. Each input $\pmb { x } = \left\{ x ^ { ( 1 ) } , x ^ { ( 2 ) } , x ^ { ( 3 ) } \right\}$ has 3 sources of information.
|
| 454 |
+
536 The output $y$ is generated by $y = x ^ { ( 3 ) } \operatorname { t a n h } \left( 2 x ^ { ( 1 ) } \cos ^ { 2 } \left( \pi x ^ { ( 2 ) } / 5 0 \right) \right) + \epsilon$ where $\epsilon$ is a Gaussian noise
|
| 455 |
+
537 term. We process $x ^ { ( 1 ) }$ with a small single-hidden-layer NN, $x ^ { ( 2 ) }$ with an exponential sine squared
|
| 456 |
+
538 kernel, and $x ^ { ( 3 ) }$ with a radial-basis function (RBF) kernel. Figure A1 shows the prediction results
|
| 457 |
+
539 as we progressively add more sources of information into our $\mathrm { I C K y }$ framework with corresponding
|
| 458 |
+
540 kernel functions. It can be observed that $\mathrm { I C K y }$ yields both smallest error and highest correlation
|
| 459 |
+
541 with information from all 3 different sources. Hence, ICKy works well with the $M = 3$ case and the
|
| 460 |
+
542 regression performance is improved as we add in more information related to the target.
|
| 461 |
+
|
| 462 |
+

|
| 463 |
+
Figure B1: Scatter plots of the true values of $y$ against the predicted values of $y$ using our $\mathrm { I C K } r$ framework with (a) one source of information, (b) 2 sources of information, and (c) 3 sources of information. Note that here we use RFF for kernel-to-latent-space transformation.
|
| 464 |
+
|
| 465 |
+
# 43 B Random Fourier Features
|
| 466 |
+
|
| 467 |
+
# B.1 Methodology
|
| 468 |
+
|
| 469 |
+
Random Fourier Features (RFF) is another popular approximation method used for kernel learning [45]. Unlike the Nyström method which approximates the entire kernel matrix, RFF directly approximates the kernel function $K$ using some randomized feature mapping $\phi : \mathbb { R } ^ { D _ { m } } \mathbb { R } ^ { 2 d _ { m } }$ such that $K \left( x _ { i } ^ { ( m ) } , x _ { j } ^ { ( m ) } \right) \approx \phi \left( x _ { i } ^ { ( m ) } \right) ^ { T } \phi \left( x _ { j } ^ { ( m ) } \right) .$ . To obtain the feature mapping $\phi$ , based on Bochner’s theorem, we first compute the Fourier transform $p$ of kernel $K$
|
| 470 |
+
|
| 471 |
+
$$
|
| 472 |
+
p ( \omega ) = \frac { 1 } { ( 2 \pi ) ^ { D _ { m } } } \int _ { - \infty } ^ { + \infty } e ^ { - j \omega ^ { T } \delta } K ( \delta ) d \delta ,
|
| 473 |
+
$$
|
| 474 |
+
|
| 475 |
+
where δ = x(m)i −550 x(m)j . Then we draw dm i.i.d. samples ω1, ω2, ..., ωdm from p(ω) and construct 551 the feature mapping $\phi$ as follows
|
| 476 |
+
|
| 477 |
+
$$
|
| 478 |
+
\begin{array} { r l } & { \phi \left( x ^ { ( m ) } \right) \equiv } \\ & { d _ { m } ^ { - 1 / 2 } \left[ \cos \left( \omega _ { 1 } ^ { T } x ^ { ( m ) } \right) , . . . , \cos \left( \omega _ { d _ { m } } ^ { T } x ^ { ( m ) } \right) , \sin \left( \omega _ { 1 } ^ { T } x ^ { ( m ) } \right) , . . . , \sin \left( \omega _ { d _ { m } } ^ { T } x ^ { ( m ) } \right) \right] . } \end{array}
|
| 479 |
+
$$
|
| 480 |
+
|
| 481 |
+
552 Since $\phi \left( \boldsymbol { x } ^ { ( m ) } \right) \in \mathbb { R } ^ { 2 d _ { m } }$ , we need to set $d _ { m } = p / 2$ when using RFF as a kernel-to-latent-space
|
| 482 |
+
553 transformation. In addition, since RFF involves sampling from a distribution, the kernel parameters
|
| 483 |
+
554 are thus not directly differentiable and we need to apply a reparameterization trick [35] to learn those
|
| 484 |
+
555 parameters.
|
| 485 |
+
|
| 486 |
+
# B.2 Experimental Results
|
| 487 |
+
|
| 488 |
+
# B.2.1 Synthetic Data
|
| 489 |
+
|
| 490 |
+
We use the same toy data set where each data point $\pmb { x } = \left\{ x ^ { ( 1 ) } , x ^ { ( 2 ) } , x ^ { ( 3 ) } \right\}$ contains 3 sources of information as described in Appendix A. Also, we use the same types of kernels as those in $\mathrm { I C K y }$ as discussed in Appendix A. The only difference here is that we use RFF instead of Nyström method to transform the kernel matrix into the latent space in $\mathrm { I C K } r$ framework.
|
| 491 |
+
|
| 492 |
+
562 The results are displayed in Figure B1. It can be observed that when we add in only the side
|
| 493 |
+
563 information $x ^ { ( 2 ) }$ along with the exponential sine squared kernel, both the correlation and the predictive
|
| 494 |
+
564 performance are improved (though not as good as the results from $\mathrm { I C K y }$ as shown in Figure A1).
|
| 495 |
+
565 However, after we further include $x ^ { ( 3 ) }$ with the $R B F$ kernel, we realize that the parameters of $\mathrm { I C K } r$
|
| 496 |
+
566 become very hard to optimize and it fails to make valid predictions and starts to guess randomly
|
| 497 |
+
567 around zero.
|
| 498 |
+
|
| 499 |
+

|
| 500 |
+
Figure B2: Density plots of the true $\mathrm { P M } _ { 2 . 5 }$ concentrations against the forecasted $\mathrm { P M } _ { 2 . 5 }$ concentrations for $t \geq 5 0 0$ using our ICK framework with (a) $\mathrm { I C K y }$ and (b) $\mathrm { I C K } r$
|
| 501 |
+
|
| 502 |
+
# B.2.2 Remote Sensing Data
|
| 503 |
+
|
| 504 |
+
We also try $\mathrm { I C K } r$ on the forecasting task using the remote sensing data (see Section 5.2) and compare the results with those from $\mathrm { I C K y }$ . Each data point ${ \pmb x } = \{ { \boldsymbol x } , t \}$ contains a satellite image $x$ as the high-dimensional information and its corresponding timestamp $t$ as the low-dimensional information. The satellite images are processed with a two-layer CNN and the timestamps are processed with an exponential-sine-squared kernel with a period of $T = 3 6 5$ (days). As can be observed from Figure B2, ICKr yields much higher error compared to $\mathrm { I C K y }$ .
|
| 505 |
+
|
| 506 |
+

|
| 507 |
+
575 C Estimated Kernel Matrix and its Eigen-spectrum
|
| 508 |
+
Figure C1: Visualization of (a) True matrix (b) estimated matrix by our ICKy framework, and (c) absolute difference between the true and estimated matrix for the spectral mixture kernel
|
| 509 |
+
|
| 510 |
+
576 We first examine whether $\mathrm { I C K y }$ can retrieve the spectral mixture kernel in the prediction task. After
|
| 511 |
+
577 fitting the parameters of the spectral mixture kernel in $\mathrm { I C K y }$ , we compute the kernel matrix $K _ { \mathrm { I C K y } }$
|
| 512 |
+
578 using these learned parameters and compare it with the true kernel matrix $K _ { \mathrm { t r u e } }$ by calculating the
|
| 513 |
+
579 absolute difference between them as displayed in Figure C1. As can be observed, $K _ { \mathrm { I C K y } }$ and ${ \cal K } _ { \mathrm { t r u e } }$
|
| 514 |
+
580 are similar and their absolute difference is relatively small, indicating that ICKy can approximately
|
| 515 |
+
581 retrieve the spectral mixture kernel.
|
| 516 |
+
582 Yang et al. [59] studied the fundamental difference
|
| 517 |
+
583 between Nyström method and Random Fourier Fea
|
| 518 |
+
584 tures (RFF). They conclude that Nyström-method
|
| 519 |
+
585 based approaches can yield much better generaliza
|
| 520 |
+
586 tion error bound than RFF-based approaches if there
|
| 521 |
+
587 exists a large gap in the eigen-spectrum of the kernel
|
| 522 |
+
588 matrix. This phenomenon is mainly caused by how
|
| 523 |
+
589 these two methods construct their basis functions. In
|
| 524 |
+
590 particular, the basis functions used by RFF are sam
|
| 525 |
+
591 pled from a Gaussian distribution that is independent
|
| 526 |
+
592 from the training examples, while the basis functions
|
| 527 |
+
593 used by the Nyström method are sampled from the
|
| 528 |
+
594 training samples so they are data-dependent. In our
|
| 529 |
+
595 synthetic data experiments, we train our ICK frame
|
| 530 |
+
596 work using a batch size of 50. The eigenvalues of the
|
| 531 |
+
597 kernel matrices computed from the first 4 batches of
|
| 532 |
+
598 the synthetic data set are displayed in Figure C2. It
|
| 533 |
+
599 can be observed that the first few eigenvalues of the
|
| 534 |
+
600 kernel matrix are much larger than the remaining eigenvalues. Namely, there exists a large gap in the
|
| 535 |
+
601 eigen-spectrum of the kernel matrix, which helps explain why ICKy has a much better performance
|
| 536 |
+
602 than ICKr.
|
| 537 |
+
|
| 538 |
+

|
| 539 |
+
Figure C2: Eigenvalues of the kernel matrix computed from the first 4 batches of training data
|
| 540 |
+
|
| 541 |
+

|
| 542 |
+
Figure D1: Prediction (top row) and forecasting (bottom row) of $\boldsymbol { y } \sim \mathcal { G P } ( \boldsymbol { 0 } , K _ { 1 } + K _ { 2 } )$ , where $x ^ { ( 1 ) }$ is input to a linear kernel $K _ { 1 }$ and $x ^ { ( 2 ) }$ is input to a spectral mixture kernel $K _ { 2 }$ . Here we only plot $x ^ { ( 2 ) }$ against the predicted $y$ . We implement 3 types of models: plain MLP (left column), MLP-RF (middle left column), and our $\mathrm { I C K y }$ framework (middle right column), and we compare the results with the true values of $y$ (right column).
|
| 543 |
+
|
| 544 |
+
# 603 D Simulation of an Additive Kernel
|
| 545 |
+
|
| 546 |
+
604 While ICK is designed to capture multiplicative ker
|
| 547 |
+
605 nels, we evaluated how well it could capture addi
|
| 548 |
+
606 tive kernels. We conduct experiments using another
|
| 549 |
+
607 synthetic data set generated by an additive kernel
|
| 550 |
+
608 $\bar { y } \sim \mathcal { G P } ( 0 , K _ { 1 } + \bar { K _ { 2 } } )$ with the same training settings.
|
| 551 |
+
609 As shown in Figure D1, ICKy again outperforms
|
| 552 |
+
610 plain MLP and MLP-RF in both the prediction and
|
| 553 |
+
611 the forecasting tasks. Moreover, we again test plain
|
| 554 |
+
612 MLP, MLP-RF, and ICKy on the prediction task using
|
| 555 |
+
613 different number of training samples. As displayed
|
| 556 |
+
614 in Figure D2, ICKy yields the smallest error among
|
| 557 |
+
615 all the 3 frameworks. Also, the performance gap
|
| 558 |
+
616 between $\mathrm { I C K y }$ and the other 2 benchmark models
|
| 559 |
+
617 shrink as we feed in more training data. Therefore,
|
| 560 |
+
618 we conclude $\mathrm { I C K y }$ is robust enough to simulate both
|
| 561 |
+
619 additive and multiplicative kernels.
|
| 562 |
+
|
| 563 |
+

|
| 564 |
+
Figure D2: Prediction error of plain MLP, MLP-RF, and $\mathrm { I C K y }$ with different amount of training data generated by $y \sim \mathcal { G P } ( 0 , K _ { 1 } +$ $K _ { 2 }$ )
|
| 565 |
+
|
| 566 |
+
# 620 E Number of Inducing Points
|
| 567 |
+
|
| 568 |
+
As discussed in Section 4.2.1, as we increase the number of inducing points $p$ , we expect the approximation error between the true kernel matrix $\kappa$ and the approximated kernel matrix $\hat { \pmb K }$ to decrease. Here, we empirically show how the value of $p$ impacts our predictions. In Figure E1a, we plot the prediction error of $\hat { y } = f _ { \mathrm { I C K } y } \left( x ^ { ( 1 ) } , x ^ { ( 2 ) } , x ^ { ( 3 ) } \right)$ against the number of inducing points using the synthetic data generated in Appendix A. As can be observed, the prediction error drops sharply as we raise $p$ from a small value (e.g. $p = 2$ ). When $p$ is relatively large, increasing $p$ yields smaller improvement on the predictions. Additionally, in Figure E1b, we plot the total training time against $p$ . The total training time is dependent on how long a single iteration takes and the total number of epochs required. We note that once $p > 8 0$ the training time is relatively flat, which is due to the fact that the total computation in the Cholesky is less than the computation in the neural network. Interestingly, it appears that when $p$ is very small, ICKy takes longer to converge due to the need for many more epochs. As we increase $p$ , the training time goes down and then goes up again due to the
|
| 569 |
+
|
| 570 |
+

|
| 571 |
+
Figure E1: Plots of (a) prediction error and (b) training time of $\hat { y } = f _ { \mathrm { I C K } y } \left( x ^ { ( 1 ) } , x ^ { ( 2 ) } , x ^ { ( 3 ) } \right)$ against the number of inducing points $p$
|
| 572 |
+
|
| 573 |
+
633 computational complexity, i.e. $\mathcal { O } ( p ^ { 3 } )$ , of the Cholesky decomposition. Based on these observations,
|
| 574 |
+
634 we are overly concerned about the computational complexity for reasonable values of $p$ .
|
| 575 |
+
|
| 576 |
+
# 635 F Visualization of Remote Sensing Data as Time Series
|
| 577 |
+
|
| 578 |
+
To better illustrate the results in Section 5.2, we visualize those results in the form of time series. As shown in Figure F1, the plain CNN-RF model does not work as it tends to forecast constant $\mathrm { P M } _ { 2 . 5 }$ values. In contrast, both the seasonal CNN-RF model and our ICKy framework captures the overall trend of the true daily averaged $\mathrm { P M } _ { 2 . 5 }$ values, but the forecasted values by $\mathrm { I C K y }$ are smoother and yield smaller error.
|
| 579 |
+
|
| 580 |
+

|
| 581 |
+
Figure F1: Time series visualization of the true against the forecasted daily averaged $\mathrm { P M } _ { 2 . 5 }$ concentrations for $t \geq 5 0 0$ using (a) a CNN-RF joint model [61, 62], (b) a CNN-RF joint model with seasonality incorporated, and (c) our $\mathrm { I C K y }$ framework
|
| 582 |
+
|
| 583 |
+
# G Experimental Details
|
| 584 |
+
|
| 585 |
+
# G.1 Synthetic Data
|
| 586 |
+
|
| 587 |
+
We use the GPytorch package [15] to generate the synthetic data. Before feeding $x ^ { ( 1 ) }$ into MLP, we first map $x ^ { ( 1 ) }$ into higher dimension using an unsupervised algorithm called Totally Random Trees Embedding [48]. All the MLP structures in this experiment (including those in MLP-RF and ICKy) contain one single fully connected (FC) layer of width 1000, which serves as a simple benchmark since a one-hidden-layer MLP can only capture linear relationship between the input and output. For model training, we optimize a Mean Squared Error (MSE) objective using Adam optimizer [30] with a weight decay of 0.1.
|
| 588 |
+
|
| 589 |
+
Table 3: Model architecture and training details for remote sensing data experiment in Section 5.2
|
| 590 |
+
|
| 591 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Backbone architecturedetails</td><td rowspan=1 colspan=1>Output FC layersdimension</td><td rowspan=1 colspan=1>Optimizer</td></tr><tr><td rowspan=1 colspan=1>CNN-RF</td><td rowspan=1 colspan=1># Conv blocks =1, # Channels = 16,Kernel size = 3, Stride = 1</td><td rowspan=1 colspan=1>1000, 512, 512, 1</td><td rowspan=1 colspan=1>Adamβ1= 0.9β2 = 0.999</td></tr><tr><td rowspan=1 colspan=1>ViT-RF</td><td rowspan=1 colspan=1># Transformer blocks= 6,# Attention heads = 8,Dropout ratio = 0.1</td><td rowspan=1 colspan=1>1000,512,512, 1</td><td rowspan=1 colspan=1>Adamβ1= 0.9β2 = 0.999</td></tr><tr><td rowspan=1 colspan=1>DeepViT-RF</td><td rowspan=1 colspan=1># Transformer blocks= 6,# Attention heads = 8,Dropout ratio = 0.1</td><td rowspan=1 colspan=1>1000, 512,512, 1</td><td rowspan=1 colspan=1>Adamβ1=0.9β2 = 0.999</td></tr><tr><td rowspan=1 colspan=1>MAE-ViT-RF</td><td rowspan=1 colspan=1># Transformer blocks= 6,# Attention heads = 8,Dropout ratio = 0.1,Masking ratio = 0.75</td><td rowspan=1 colspan=1>1000,512,512, 1</td><td rowspan=1 colspan=1>Adamβ1= 0.9β2 = 0.999</td></tr><tr><td rowspan=1 colspan=1>CNN-ICKy</td><td rowspan=1 colspan=1># Conv blocks=1, # Channels=16,Kernel size = 3, Stride = 1</td><td rowspan=1 colspan=1>1000, 512, p</td><td rowspan=1 colspan=1>SGDmomentum = 0.9</td></tr><tr><td rowspan=1 colspan=1>ViT-ICKy</td><td rowspan=1 colspan=1># Transformer blocks = 6,# Attention heads = 8,Dropout ratio = 0.1</td><td rowspan=1 colspan=1>1000, 512, p</td><td rowspan=1 colspan=1>SGDmomentum = 0.9</td></tr><tr><td rowspan=1 colspan=1>DeepViT-ICKy</td><td rowspan=1 colspan=1># Transformer blocks=6,# Attention heads = 8,Dropout ratio = 0.1</td><td rowspan=1 colspan=1>1000, 512, p</td><td rowspan=1 colspan=1>SGDmomentum = 0.9</td></tr></table>
|
| 592 |
+
|
| 593 |
+
# 650 G.2 Remote Sensing Data
|
| 594 |
+
|
| 595 |
+
The model architecture and training details are listed in Table 3. Here $p$ denotes the length of latent representations $_ { z }$ as discussed in Section 4. Note that we use stochastic gradient descent (SGD) optimizer with a momentum of 0.9 for ICKy as we realize that SGD helps ICKy find a local minimum on the objective more efficiently. We use MSE objective for ICKy and all benchmark models in this experiment.
|
| 596 |
+
|
| 597 |
+
# G.3 UCI Machine Learning Repository Data
|
| 598 |
+
|
| 599 |
+
The MLPs (including the MLP part in ICKy) in this experiment share the same structure as the one used in [1], which consist of 3 hidden layers of width 128, 32, and 32, respectively. For plain MLP, cyclic MLP, and $\mathrm { I C K y }$ , we use the mean absolute error (MAE) objective to put less weight on the outliers and thus enhance the model performance. For GNP and AGNP, we maximize a biased Monte Carlo estimate of the log-likelihood objective as discussed in [37]. All these objectives are optimized by an Adam optimizer with $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 9 9$ .
|
| 600 |
+
|
| 601 |
+
# 663 H Adapting ICK for Classification
|
| 602 |
+
|
| 603 |
+
While regression tasks are the primary motivation for this paper, there are many ways to adapt GPR for classification tasks. For example, a binary classification model can be created by using a sigmoid [55] or probit link [8] on the output of the GP. Succinctly, given a function $f ( \pmb { x } ) \sim \mathcal { G P } \left( 0 , K ( \pmb { x } , \pmb { x } ^ { \prime } ) \right)$ , the binary outcome probability is be given as $p ( y = 1 | f ( x ) ) = \sigma ( f ( x ) )$ . Likewise, a multiple classification model can be constructed by using a multi-output GP (or multiple GPs) and putting the outputs through a softmax function [55] or multinomial probit link [20]. This strategy can be summarized by calculating $C$ different functions $f _ { c } ( x ) \sim \mathcal { G P } \left( 0 , K ( \pmb { x } , \pmb { x } ^ { \prime } ) \right)$ for $c = 1 , . . . , C$ , where $C$ is the number of classes, and then calculating the class probabilities through a link function, $p ( y | x ) = \operatorname { s o f t m a x } \ ( [ f _ { 1 } ( x ) , f _ { 2 } ( x ) , . . . , f _ { C } ( x ) ] )$ .
|
| 604 |
+
|
| 605 |
+
This same logic can be used to construct a multiple classification model from ICKy. Succinctly, let $r _ { c } = f _ { N N , c } ( x ^ { ( 1 ) } ) \odot z _ { c } ^ { ( 2 ) }$ , where $f _ { N N , c }$ denotes a neural network specific to the $c ^ { t h }$ class and $z _ { c } ^ { ( 2 ) }$ represents the Nyström approximation specific to the kernel for the $c ^ { t h }$ class. We note that often in
|
| 606 |
+
|
| 607 |
+
676 a multi-output case the kernel parameters are shared, and so $z _ { c } ^ { ( 2 ) }$ would be an identical vector for
|
| 608 |
+
677 each class. Then, the output probabilities for a data sample as $p ( y | x ) = \operatorname { s o f t m a x } ( [ r _ { 1 } , . . . , r _ { C } ] )$ . This
|
| 609 |
+
678 framework is learned with a cross-entropy loss.
|
| 610 |
+
|
| 611 |
+
To provide proof-of-concept of this multiple classification strategy, we implemented this model on a version of Rotating MNIST. In this task, a dataset was created by rotating each image in the dataset by a uniform random value $\phi \in [ 0 , 2 \pi )$ , thus creating a dataset with 60,000 images each with an associated rotation covariate $\phi$ . We implemented the above multiple classification model with a periodic kernel over the rotation angle. This strategy yielded an accuracy of $9 2 . 3 \%$ on the validation data. This is lower than methods such as spatial transformers [25] that report accuracy greater than $9 9 \%$ . However, those models explicitly use the fact that the information is simply rotated, whereas ICK is modeling a smooth transformation in the prediction function as a function of angle. This ICK classification model is much closer in concept to the way Rotating MNIST is used to evaluate unsupervised domain adaptation. While the evaluation strategy is different than our random validation set, the state-of-the-art accuracy on unsupervised domain adaption is $8 7 . 1 \%$ [52]. Due to the lack of complete and fair comparisons, we are not claiming that ICKy is state-of-the-art for classification, but ICKy’s classification model does seem reasonable and viable based upon this result.
|
| 612 |
+
|
| 613 |
+
# 692 I Generation, Accessibility, and Restrictions of the Data
|
| 614 |
+
|
| 615 |
+
The synthetic data $y \sim \mathcal { G P } ( 0 , K _ { 1 } K _ { 2 } )$ in Section 5.1 and $y \sim \mathcal { G P } ( 0 , K _ { 1 } + K _ { 2 } )$ in Appendix D are generated using the GPyTorch package. The remote sensing data in Section 5.2 is downloaded using PlanetScope API whose content is protected by copyright and/or other intellectual property laws. To access the data on PlanetScope, the purchase of an end-user license is required. When this manuscript is accepted, we will provide the codes we used to acquire the data. The UCI machine learning repository data we use in Section 5.3 has an open access license, meaning that the data is freely available online.
|
md/dev/peZSbfNnBp4/peZSbfNnBp4.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ensemble of Averages: Improving Model Selection and Boosting Performance in Domain Generalization
|
| 2 |
+
|
| 3 |
+
Devansh Arpit, Huan Wang, Yingbo Zhou, Caiming Xiong Salesforce Research, USA devansharpit@gmail.com
|
| 4 |
+
|
| 5 |
+
# Abstract
|
| 6 |
+
|
| 7 |
+
In Domain Generalization (DG) settings, models trained independently on a given set of training domains have notoriously chaotic performance on distribution shifted test domains, and stochasticity in optimization (e.g. seed) plays a big role. This makes deep learning models unreliable in real world settings. We first show that this chaotic behavior exists even along the training optimization trajectory of a single model, and propose a simple model averaging protocol that both significantly boosts domain generalization and diminishes the impact of stochasticity by improving the rank correlation between the in-domain validation accuracy and out-domain test accuracy, which is crucial for reliable early stopping. Taking advantage of our observation, we show that instead of ensembling unaveraged models (that is typical in practice), ensembling moving average models (EoA) from independent runs further boosts performance. We theoretically explain the boost in performance of ensembling and model averaging by adapting the well known Bias-Variance trade-off to the domain generalization setting. On the DomainBed benchmark, when using a pre-trained ResNet-50, this ensemble of averages achieves an average of $6 8 . 0 \%$ , beating vanilla ERM (w/o averaging/ensembling) by $\sim 4 \%$ , and when using a pre-trained RegNetY-16GF, achieves an average of $7 6 . 6 \%$ , beating vanilla ERM by $6 \%$ . Our code is available at https://github.com/salesforce/ ensemble-of-averages.
|
| 8 |
+
|
| 9 |
+
# 1 Introduction
|
| 10 |
+
|
| 11 |
+
Domain generalization (DG, [5]) aims at learning predictors that generalize well on data sampled from test distributions that are different from the training distribution. Currently, deep learning models have been shown to be poor at this form of generalization [10], and excel primarily in the IID setting [51].
|
| 12 |
+
|
| 13 |
+
While a number of algorithms have been proposed to mitigate this problem (cf [51] for a survey), [18] demonstrate that models trained using empirical risk minimization (ERM, [43]) along with proper model selection (i.e. early stopping using validation set), using a subset of data from all the training domains, largely match or even outperform the performance of most existing domain generalization algorithms. This suggests that model selection plays an important role in domain generalization. Despite its importance, there has not been much investigation into the reliability of model selection. As we demonstrate in Figure 1, the out-domain performance varies greatly along the optimization trajectory of a model during training, even though the in-domain performance does not. This instability therefore hurts the reliability of model selection, and can become a problem in realistic settings where test domain data is unavailable, because it causes the rank correlation between in-domain validation accuracy and out-domain test accuracy to be weak.
|
| 14 |
+
|
| 15 |
+
In this paper, we first investigate a simple protocol for model averaging that both boosts DG within the ERM framework, and mitigates performance instability of deep models on out-domain data, specifically with respect to in-domain validation data. This makes model selection more reliable. Next, taking advantage of our observation, we show that ensembling moving average models further boosts performance, making it a better choice for practical scenarios. Note that we do not claim that model averaging or ensembling can fully solve the problem of DG. The observation that model averaging can boost domain generalization performance is not new, and was exposed by SWAD [8], which inspired our work. Our contribution in this respect are as follows:
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Model averaging improves out-domain performance stability. Left: In-domain validation accuracy and out-domain test accuracy during training of models using ERM. Right: Same as left, except validation and test predictions are made using a simple moving average of the model being optimized, along its optimization path. Details: The plots are for the TerraIncognita dataset with domain L38 used as the test domain, and others as training/validation data, and ResNet-50. Solid lines denote accuracy, dashed lines denote training loss, and dash-dot lines denote best accuracy achieved during training and all runs (for reference). Each color denotes a different run with a different random seed and training/validation split. Gist: Model averaging reduces out-domain performance instability, and makes the test curves correlate better with the validation curves, making model selection using in-domain validation set more reliable during optimization. We see a similar pattern when using ensemble of models, with and without model averaging, in Figure 2.
|
| 19 |
+
|
| 20 |
+
1. Hyperparameter-free:In contrast to SWAD, which introduces three additional hyper-parameters for its model averaging algorithm that need tuning, we show that the simple strategy of maintaining a simple moving average (SMA) of the model parameters throughout the optimization trajectory, starting near initialization (Appendix Figure 5), works just as well (when a pre-trained model is used as initialization). Although model averaging technically requires two hyper-parameters– averaging frequency and starting iteration, through empirical analysis, we show that setting the frequency to 1 and setting the start iteration close to 0 works well on multiple datasets and architectures, making our proposal hyperparameter-free in practice.
|
| 21 |
+
|
| 22 |
+
2. Computationally efficient:SWAD requires computing validation performance more frequently than is typically done $2 \mathrm { x } \mathrm { - } 6 \mathrm { x }$ on the DomainBed datasets), which is needed because it needs to find the start and end iteration between which model averaging is done. This increases compute requirements. This segment is selected based on the validation performance computed using the model being trained. Our proposal to instead use the SMA model to perform early stopping and inference, side-steps this need and does not require frequent validation performance check. We show that the root cause for this difference is that the model being trained has unstable performance on OOD data, while the SMA model has a more stable OOD performance (see Figure 1 and Table 2). Thus this observation results in our hyperparameter-free and more efficient model averaging strategy.
|
| 23 |
+
|
| 24 |
+
3. EoA: Taking advantage of our efficient model averaging protocol (section 2.2), we find that an ensemble of moving average models (EoA) outperforms a traditional ensemble of unaveraged models (Table 4). We also show ablation analysis that the rank correlation between in-domain validation performance and out-domain test performance is better for the ensemble of average models (Table 3).
|
| 25 |
+
|
| 26 |
+
4. Theoretical explanation: To explain why both model averaging and ensembling improve OOD performance under a unified theoretical framework, we adapt the well known Bias-Variance decomposition to the domain generalization setting, and argue that the expected OOD loss for individual models comprises of both the bias and the variance term, while the expected OOD loss for ensembles and averaged models comprises mainly of the bias term only, and is thus strictly lower (section 3.2). Our explanation is in contrast with SWAD, which uses flat minima to explain the improved OOD generalization, which applies to model averaging, but is less straight forward for explaining the boost by ensembles.
|
| 27 |
+
|
| 28 |
+
5. Benchmarking: For benchmarking, we experiment with three different pre-trained models as initializations for DG training, with increasing pre-training dataset size and model size. In these experiments we find that EoA provides a larger gain over the corresponding ERM baseline with increasing dataset and model size. These gains range from $4 \% - 6 \%$ (Table 4). Notice that this claim is different from existing work [20], which states that the baseline ERM performance improves with larger pre-training data and model size.
|
| 29 |
+
|
| 30 |
+
# 2 Model Averaging
|
| 31 |
+
|
| 32 |
+
# 2.1 Terminology
|
| 33 |
+
|
| 34 |
+
Online Model: For a given supervised learning objective function, let $f _ { \theta } ( . )$ denote the deep network being optimized using gradient based optimizer, where $\theta$ denotes the parameters of this model. We refer to $f _ { \theta }$ as the online model, or unaveraged model. The output of $f _ { \theta } ( . )$ is a vector of $K$ logits corresponding to the $K$ classes in the supervised task.
|
| 35 |
+
|
| 36 |
+
Moving Average (MA) Model: While the online model is being trained, we maintain a moving average of the online model’s parameters. This process is sometime referred to as iterate averaging in existing literature. The deep network whose parameters are set to be this moving average is referred to as the moving average model, or more specifically simple moving average (SMA) model because of its use in our work. We denote the parameters of this model by $\hat { \theta }$ .
|
| 37 |
+
|
| 38 |
+
# 2.2 Model Averaging Protocol
|
| 39 |
+
|
| 40 |
+
We use a simple moving average (SMA) of the online model. Instead of calculating the moving average starting from initialization (as done in Polyak-Ruppert averaging), we instead start after a certain number of iterations $t _ { 0 }$ during training (tail averaging), and maintain the moving average until the end of training. As we discuss in the next section, $t _ { 0 }$ is chosen to be close, but not equal to the initialization when a pre-trained model is used as initialization. At any iteration $t$ , we denote:
|
| 41 |
+
|
| 42 |
+
$$
|
| 43 |
+
\begin{array} { r } { \hat { \theta } _ { t } = \left\{ \begin{array} { l l } { \theta _ { t } , } & { \mathrm { i f ~ } t \leq t _ { 0 } } \\ { \frac { t - t _ { 0 } } { t - t _ { 0 } + 1 } \cdot \hat { \theta } _ { t - 1 } + \frac { 1 } { t - t _ { 0 } + 1 } \cdot \theta _ { t } , } & { \mathrm { o t h e r w i s e } } \end{array} \right. } \end{array}
|
| 44 |
+
$$
|
| 45 |
+
|
| 46 |
+
where $\theta _ { t }$ is the online model’s state at iteration $t$ . Note that effectively, $\begin{array} { r } { \widehat { \theta } _ { t } : = \frac { 1 } { t - t _ { 0 } + 1 } \cdot \sum _ { t ^ { \prime } = t _ { 0 } } ^ { t } \theta _ { t ^ { \prime } } } \end{array}$ Further, at iteration $t$ , if we need to calculate validation performance, we use $\widehat { \theta } _ { t }$ to do so, and not $\theta _ { t }$ . As we show in the next section, the benefit of doing so is that the rank correlation between in-domain validation accuracy and out-domain test accuracy is significantly better when predictions are made using $\widehat { \theta } _ { t }$ . This makes model selection more reliable for domain generalization. Finally, for a given run, model selection selects $\widehat { \theta } _ { t ^ { * } }$ for making test set predictions, such that $\widehat { \theta } _ { t ^ { * } }$ achieves the best validation performance. We discuss some theoretical perspectives on why model averaging can help domain generalization in section 5.1.
|
| 47 |
+
|
| 48 |
+
# 2.3 Ablation Analysis
|
| 49 |
+
|
| 50 |
+
Here we perform four ablation studies: 1) impact of the start iteration $t _ { 0 }$ used in our SMA protocol in Eq. 1; 2) the frequency of model averaging; 3) instability reduction of SMA model compared to the online mode along the optimization trajectory on out-domain data; 4) correlation between in-domain and out-domain accuracy across independently trained models.
|
| 51 |
+
|
| 52 |
+
Due to space limitation, we show experiments for 1,2 and 4 in Appendix section C. In summary, we find that: 1) starting averaging close to initialization results in improved out-domain performance (Figure 5 in Appendix) when the parameters are initialized used a pre-trained model; 2) the frequency of SMA does not have a significant impact on performance, unless sampling is done at too large intervals (Figure 6 in Appendix); 4) the rank correlation is poor between validation and test accuracy of independently trained models (Figure 8 in Appendix). An implication of this is that it is difficult to discover the best model (for out-domain performance) from a pool of independently trained models, based only on their in-domain validation performance (echoing the findings of [10]).
|
| 53 |
+
|
| 54 |
+
Table 1: Spearman correlation (closer to 1 is better) between within-run in-domain validation accuracy and out-domain test accuracy on multiple datasets. Model averaging improves rank correlation for both individual models (left) and ensemble of averages (right).
|
| 55 |
+
Table 2: Individual Models
|
| 56 |
+
|
| 57 |
+
<table><tr><td>TerraIncognita</td><td>w/o avg</td><td>w/avg</td></tr><tr><td>L100</td><td>0.21± 0.07</td><td>0.90 士 0.05</td></tr><tr><td>L38</td><td>0.12 ± 0.13</td><td>0.83 ± 0.05</td></tr><tr><td>L43</td><td>0.30 ± 0.06</td><td>0.67 士 0.18</td></tr><tr><td>L46</td><td>0.03 ± 0.11</td><td>0.52 士 0.14</td></tr></table>
|
| 58 |
+
|
| 59 |
+
Table 3: Ensembles
|
| 60 |
+
|
| 61 |
+
<table><tr><td>TerraIncognita</td><td>w/o avg</td><td>w/ avg</td></tr><tr><td>L100</td><td>0.48</td><td>1</td></tr><tr><td>L38</td><td>0.17</td><td>0.95</td></tr><tr><td>L43</td><td>0.59</td><td>0.38</td></tr><tr><td>L46</td><td>0.08</td><td>0.61</td></tr></table>
|
| 62 |
+
|
| 63 |
+
# 2.3.1 Instability Reduction: Rank Correlation
|
| 64 |
+
|
| 65 |
+
We study the reliability of model selection for domain generalization when using online models vs moving average models, using rank correlation (see Appendix C.4 for definition). To do so, we train models on a dataset, both with and without model averaging, and compute Spearman correlation between the in-domain validation accuracy and out-domain test accuracy sampled at regular intervals during the training process. Since there are multiple runs where a given domain acts as the test domain, we calculate the mean and standard error of these values over these runs.
|
| 66 |
+
|
| 67 |
+
The rank correlations are shown in Table 2 (and Table 8 in Appendix) for the PACS, VLCS, OfficeHome, TerraIncognita and DomainNet datasets. We find that in majority of the cases, using model averaging results in a significantly better rank correlation compared to using the online model. These experiments therefore suggest that the reliability of model selection is significantly higher within a run when using model averaging.
|
| 68 |
+
|
| 69 |
+
# 3 Ensemble of Averages (EoA)
|
| 70 |
+
|
| 71 |
+
[18] propose a rigorous framework for evaluation in the domain generalization setting which accounts for randomness due to seed and hyper-parameter values, and recommend reporting the average test accuracy over all the runs computed using a model selection criteria. However, in practice, it is desirable to have a single predictor that has a high accuracy. An ensemble combines predictions from multiple models, and is a well known approach for achieving this goal [11] by exploiting function diversity [14]. However, as we show, even ensembles suffer from instability in the domain generalization setting. Building on the observations of the previous section, we investigate the behavior of ensemble of moving average models and find that it mitigates this issue. We begin by describing the EoA protocol below.
|
| 72 |
+
|
| 73 |
+
EoA Protocol: We perform experiments with ensemble of multiple independently trained models (i.e., with different hyper-parameters and seeds). When each of these models are moving average models from their corresponding runs, we refer to this ensemble in short as the ensemble of averages $( E o A )$ . Identical to how we make predictions for traditional ensembles (specifically the bagging method [6]), the class $\hat { y }$ predicted by an EoA for an input $\mathbf { x }$ is given by the formula:
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\hat { y } = \arg \operatorname* { m a x } _ { k } { S o f t m a x ( \frac { 1 } { E } \sum _ { i = 1 } ^ { E } f ( \mathbf { x } ; \hat { \boldsymbol { \theta } } _ { i } ) ) _ { k } }
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
where $E$ is the total number of models in the ensemble, ${ \hat { \theta } } _ { i }$ denotes the parameters of the $i ^ { t h }$ moving average model, and the sub-script $( . ) _ { k }$ denotes the $k ^ { t h }$ element of the vector argument. Finally, the state ${ \hat { \theta } } _ { i }$ of the $i ^ { t h }$ moving average model used in the ensemble is selected from its corresponding run using its in-domain validation set performance (described in section 2.2). We now investigate the behavior of EoA compared with ensembles of online models on domain generalization tasks.
|
| 80 |
+
|
| 81 |
+
# 3.1 Analysis
|
| 82 |
+
|
| 83 |
+
Qualitative visualization: For the purpose of contrasting the behavior of traditional ensembles vs ensemble of averages, we begin by qualitatively studying the stability of out-domain performance of these two ensembling techniques during the training process. To do so, we use the TerraIncognita dataset, and fix one of its domains as the test domain while using the others as training/validation data. We then train 6 different models independently for 5, 000 iterations with different seeds, hyper-parameters and training-validation splits identical to the [18] protocol. We also maintain moving average models corresponding to each of these 6 models. At every 300 iterations, we form an ensemble of the 6 online models from their corresponding runs and compute the out-domain test accuracy. Since, each run has a different training-validation split, we calculate the mean validation accuracy of each of these online models at that iteration. We follow an identical procedure for the moving average models and plot these performances in Figure 2. We find that the ensemble of averages has a better stability on out-domain test set compared to the ensemble of online models.
|
| 84 |
+
|
| 85 |
+

|
| 86 |
+
Figure 2: Ensemble of moving averages (EoA) (right) has better out-domain test performance stability compared with ensemble of online models (left), w.r.t. in-domain validation accuracy. Details: The plots are for the TerraIncognita dataset with domain L38 used as the test domain, and others as training/validation domain, and ResNet-50. Each ensemble has 6 different models from independent runs with different random seeds, hyper-parameters, and training/validation split.
|
| 87 |
+
|
| 88 |
+
For clarity, note that this procedure for calculating test accuracy at regular intervals is different from what we proposed earlier for EoA for practical purposes. This experiment is only meant to highlight the fact that making predictions on out-domain data using an ensemble of online models suffers from instability along the optimization trajectory, while an ensemble of averages mitigates this issue. For plots on other domains of TerraIncognita, see Figure 10 in the Appendix.
|
| 89 |
+
|
| 90 |
+
Rank correlation: We now measure the rank correlation between in-domain validation accuracy and out-domain test accuracy for a quantitative evaluation. The details of the metric and motivations behind this experiment are same as those described in section 2.3.1. Here we use the same experimental setup described in the qualitative analysis above. But in addition, we also conduct experiments on VLCS, OfficeHome and DomainNet datasets. The results are shown in Table 3 (and Table 9 in Appendix). We find that in majority of the cases, using EoA results in a significantly better rank correlation compared to using the online model ensemble. These results show more concretely the fact that predictions by an ensemble of online models on out-domain data suffers from instability along the optimization trajectory, and EoA mitigates this problem.
|
| 91 |
+
|
| 92 |
+
# 3.2 Why does Ensembling and Model Averaging Improve Performance?
|
| 93 |
+
|
| 94 |
+
We explain the performance boost achieved by ensemble of averages (see next section) by adapting the Bias-Variance decomposition [17] to the domain generalization setting. For classification tasks with one-hot labels, the Bias-Variance decomposition is given as [49],
|
| 95 |
+
|
| 96 |
+
$$
|
| 97 |
+
\begin{array} { r } { \mathbb { E } _ { \mathbf { x } , y } \mathbb { E } _ { \mathcal { T } } [ C E ( y , f ( \mathbf { x } ; \mathcal { T } ) ) ] = \underbrace { \mathbb { E } _ { \mathbf { x } , y } [ C E ( y , \bar { f } ( \mathbf { x } ) ) ] } _ { \mathrm { B i a s } ^ { 2 } } + \underbrace { \mathbb { E } _ { \mathbf { x } , \mathcal { T } } [ K L ( \bar { f } ( \mathbf { x } ) , f ( \mathbf { x } ; \mathcal { T } ) ) ] } _ { \mathrm { V a r i a n c e } } } \end{array}
|
| 98 |
+
$$
|
| 99 |
+
|
| 100 |
+
where $C E$ denotes the cross entropy loss, $K L$ denotes KL divergence, $\mathcal { T } = \{ ( \mathbf { x } _ { i } ^ { i n } , y _ { i } ^ { i n } ) \} _ { i = 1 } ^ { N }$ are $N$ IID samples drawn from the in-domain training distribution $\mathbb { P } ^ { i n }$ , $f ( \mathbf { x } ; \mathcal { T } )$ denotes the prediction of the model $f$ on sample $\mathbf { x }$ such that the model is trained on the dataset $\tau$ , and $\bar { f } ( \mathbf { x } ) = \bar { \mathbb { E } } _ { \mathcal { T } } [ f ( \mathbf { x } ; \mathcal { T } ) ]$ . Finally $( \mathbf { x } , y ) \sim \mathbb { P } ^ { o u t }$ where $\mathbb { P } ^ { o u t }$ is the out-domain distribution. Notice how $\tau$ and $\left( \mathbf { x } , y \right)$ come from different distributions. For instance, in PACS dataset, $\mathbb { P } ^ { i n }$ could be the union of art, cartoon and photo domains, and $\mathbb { P } ^ { o u t }$ could be the sketch domain.
|
| 101 |
+
|
| 102 |
+
The L.H.S. of the above equation is the expected cross entropy loss on the out-domain distribution achieved by individual models, i.e., when we train an individual model on a particular instance of the training dataset $\tau$ , the expected out-domain test loss is denoted by L.H.S. Importantly, the Bias term on the R.H.S. denotes the expected cross entropy loss on the out-domain distribution achieved by the function $\bar { f } ( . )$ , which is essentially an ensemble. Finally, the variance term captures how much the prediction of individual models differs in expectation from the ensemble prediction, which makes this term strictly greater than zero.
|
| 103 |
+
|
| 104 |
+

|
| 105 |
+
Figure 3: Left: Effect of ensemble size (number of models in an ensemble) on out-domain performance (mean and standard error) for models with and without moving average (MA) parameters for ResNet-50 pre-trained on ImageNet. Right: Using the performance of ensemble of size 1 (shown in the left plot) as reference, right plot shows the percentage point improvement for ensembles of size $> 1$ . The plots show that i) ensemble of averages (solid lines in left plot) are consistently better than ensemble of models without averaging (dashed lines in left plot); ii) ensemble of averages consistently improves performance over averaged models (ensemble of size 1 in right plot).
|
| 106 |
+
|
| 107 |
+
Therefore, the above decomposition tells us that the expected test domain error of an ensemble is strictly less than that of an individual model. This interpretation directly explains why a traditional ensemble of unaveraged models can be expected to perform better than individual unaveraged models. However, it is still not clear why EoA performs better that a traditional ensemble in practice. To establish this connection, we note that in practice, we typically train a small number of independent models to form a traditional ensemble due to computational constraints. Thus such ensembles do not behave identically to the expected ensemble $\bar { f } ( . )$ described above. Model averaging on the other hand has been shown to approximate an ensemble [23]. To see this, consider without any loss of generality that the ensemble contains models with parameters $\{ \theta _ { 1 } , \theta _ { 2 } \dots \theta _ { T } \}$ , and denote $\begin{array} { r } { \widehat { \theta } _ { T } : = \frac { 1 } { T } \cdot \sum _ { t = 1 } ^ { T } \widehat { \theta _ { t } } } \end{array}$ Then note that the second order Taylor’s expansion around $\hat { \theta } _ { T }$ of each model’s $k ^ { t h }$ dimension’s prediction is given by,
|
| 108 |
+
|
| 109 |
+
$$
|
| 110 |
+
\frac { 1 } { T } \cdot \sum _ { t = 1 } ^ { T } f ( \theta _ { t } ) _ { k } \approx f ( \hat { \theta } _ { T } ) _ { k } + \frac { 1 } { T } \cdot \sum _ { t = 1 } ^ { T } ( \hat { \theta } _ { T } - \theta _ { t } ) ^ { T } \frac { \partial f ( \hat { \theta } _ { T } ) _ { k } } { \partial \hat { \theta } _ { T } } + 0 . 5 ( \hat { \theta } _ { T } - \theta _ { t } ) ^ { T } \frac { \partial ^ { 2 } f ( \hat { \theta } _ { T } ) _ { k } } { \partial \hat { \theta } _ { T } ^ { 2 } } ( \hat { \theta } _ { T } - \theta _ { t } )
|
| 111 |
+
$$
|
| 112 |
+
|
| 113 |
+
Notice that $f ( . )$ is the model output and therefore the first and second order terms are the derivatives of the model output and not the loss gradient and Hessian. The first order term is zero due to ference of o $\begin{array} { r } { \widehat { \theta } _ { T } : = \frac { 1 } { T } \cdot \sum _ { t = 1 } ^ { T } \theta _ { t } } \end{array}$ . A crucial dif-d to [23] is that they average model states that lie near different loss minima, while we perform tail averaging. Therefore, the term $( \widehat { \theta } _ { T } - \theta _ { t } )$ may not behave similar to that in their case. To shed light on its behavior, we plot the histogram of the second order term and the moving average model’s logit $f ( { \widehat { \theta } } _ { T } ) _ { k }$ in Eq. 3 for the first dimension $k = 1$ ) for test domain data in figure 4 (details and additional experiments provided in Appendix D). The histogram shows that the second order term
|
| 114 |
+
|
| 115 |
+

|
| 116 |
+
Figure 4: The scale of terms– moving average model’s logit and the second order term in Eq. 3. The latter concentrates around 0, suggesting our model averaging protocol approximates ensembles.
|
| 117 |
+
|
| 118 |
+
concentrates near zeros while the logit values span a wider range, which implies that under the second order approximation, the model averaging protocol used in our work behaves like an ensemble. Finally, to study the impact of ensemble size on out-domain performance, we plot the test domain accuracy as a function of ensemble size in figure 3. The plots show that i. EoA outperforms traditional ensembles for all ensemble sizes (left); and ii. ensembles of larger size typically have better
|
| 119 |
+
|
| 120 |
+
Table 4: Performance benchmarking on 5 datasets of the DomainBed benchmark using two different pre-trained models. SWAD and MIRO are the previous SOTA. See Table 10 in Appendix for comparison with more methods. Note that ensembles do not have confidence interval because an ensemble uses all the models to make a prediction. Gray background shows our proposal. Our runs implies we ran experiments, but we did not propose it. Experiments use the training-domain validation protocol from [18].
|
| 121 |
+
|
| 122 |
+
<table><tr><td>Algorithm</td><td>PACS</td><td>VLCS</td><td>OfficeHome</td><td>TerraIncognita</td><td>DomainNet</td><td>Avg.</td></tr><tr><td colspan="7">ResNet-50 (25MParameters,Pre-trained on ImageNet)</td></tr><tr><td>ERM (our runs) Ensemble (our runs)</td><td>84.4± 0.8 87.6</td><td>77.1 ± 0.5 78.5</td><td>66.6±0.2 70.8</td><td>48.3±0.2 49.2</td><td>43.6± 0.1 47.7</td><td>64.0 66.8</td></tr><tr><td>ERM[18]</td><td>85.7 ± 0.5</td><td>77.4 ± 0.3</td><td>67.5 ± 0.5 70.6 ± 0.3</td><td>47.2 ± 0.4 50.0 ± 0.4</td><td>41.2 ± 0.2 46.5 ± 0.2</td><td>63.8</td></tr><tr><td>SWAD [8] MIRO [9]</td><td>88.1 ± 0.4 85.4± 0.4</td><td>79.1 ± 0.4 79.0± 0.</td><td>70.5 ± 0.4</td><td>50.4 ± 1.1</td><td>44.3 ± 0.2</td><td>66.9 65.9</td></tr><tr><td>SMA (ours) EoA (ours)</td><td>87.5 ± 0.2 88.6</td><td>78.2 ± 0.2 79.1 72.5</td><td>70.6 ± 0.1</td><td>50.3 ± 0.5 52.3</td><td>46 ± 0.1 47.4</td><td>66.5 68.0</td></tr><tr><td colspan="7">ResNeXt-5032x4d [48] (25MParameters,Pre-trained1B Images)</td></tr><tr><td>ERM (our runs)</td><td>88.9± 0.3</td><td>79.0± 0.1</td><td>70.9± 0.5</td><td>51.4 ± 1.2</td><td>48.1±0.2</td><td>67.7</td></tr><tr><td>Ensemble (our runs)</td><td>91.2</td><td>80.3</td><td>77.8</td><td>53.5</td><td>52.8</td><td>71.1</td></tr><tr><td>SMA (ours) EoA (ours)</td><td>92.7 ± 0.3 93.2</td><td>79.7 ± 0.3 80.4</td><td>78.6 ± 0.1 80.2</td><td>53.3 ± 0.1 55.2</td><td>53.5 ± 0.1 54.6</td><td>71.6</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td> 72.7</td></tr><tr><td></td><td colspan="4">RegNetY-16GF[40] (81MParameters,Pre-trained on 3.6B Images)</td><td></td><td></td></tr><tr><td>ERM (our runs)</td><td>92 ± 0.4</td><td>78.6± 0.6</td><td>73.8± 0.5</td><td>55.6± 0.9</td><td>53.1± 0.2</td><td>70.6</td></tr><tr><td>Ensemble (our runs)</td><td>95.1</td><td>80.6</td><td>80.5</td><td>59.5</td><td>57.8</td><td>74.7</td></tr><tr><td>ERM[9]</td><td>89.6 ± 0.4</td><td>78.6 ± 0.3</td><td>71.9 ± 0.6</td><td>51.4 ± 1.8</td><td>48.5 ± 0.6</td><td>68.0</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>SWAD [9]</td><td>94.7 ± 0.2</td><td>79.7 ± 0.2</td><td>80.0± 0.1</td><td>57.9 ± 0.7</td><td>53.6± 0.6</td><td>73.2</td></tr><tr><td>MIRO [9]</td><td>97.4 ± 0.2</td><td>79.9 ± 0.6</td><td>80.4± 0.2</td><td>58.9 ±1.3</td><td>53.8 ± 0.1</td><td>74.1</td></tr><tr><td>SMA (ours)</td><td>95.5 ± 0.0</td><td>80.7 ± 0.1</td><td>82.0± 0.0</td><td>59.7 ± 0.0</td><td>60.0± 0.0</td><td>75.6</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>EoA (ours)</td><td>95.8</td><td>81.1</td><td>83.9</td><td>61.1</td><td>60.9</td><td>76.6</td></tr></table>
|
| 123 |
+
|
| 124 |
+
out-domain performance. See a discussion on functional diversity of ensembles vs model averaging in Appendix E.
|
| 125 |
+
|
| 126 |
+
# 4 Empirical Results
|
| 127 |
+
|
| 128 |
+
# 4.1 DomainBed Benchmarking
|
| 129 |
+
|
| 130 |
+
We now benchmark our model averaging protocol (SMA) and ensemble of averages against online models (ERM, without MA) and ensemble of online models (ensembles). Note that all these models are trained using the ERM objective as before. We evaluate on PACS [27], VLCS [13], OfficeHome [45], TerraIncognita [3] and DomainNet [35] datasets in DomainBed. The training-evaluation protocols are the same as described in section 2.3 for moving average and online models, and in section 3 for ensembles. Full details can be found in section B in the Appendix.
|
| 131 |
+
|
| 132 |
+
Comparison with existing results using ResNet-50 pre-trained on ImageNet: Here we compare existing methods with our runs. All methods use ResNet-50 (25M parameters) [19] pre-trained on ImageNet as initialization. Comparing ERM [18] and ERM (our runs), we find that they perform similarly, especially considering we have used a smaller hyper-parameter space (further discussion in Appendix E). A comparison between SWAD and SMA shows that SWAD is slightly better (by $0 . 4 \%$ on average). However, recall that our protocol retains the advantage of not tuning any hyperparameters while SWAD has 3 additional ones that they tune separately in addition to the optimization hyper-parameters. Interestingly, traditional ensembles and SMA achieve similar performance $( 6 6 . 8 \%$ and $6 6 . 5 \%$ respectively). Finally, EoA outperforms all the existing results: ERM by $4 \%$ and SWAD (previous SOTA) by $1 . 1 \%$ . Importantly, note that while all non-ensemble models report the average test accuracy of multiple models following the protocol of [18], EoA test accuracy is achieved by a single predictor that combines the output of multiple models.
|
| 133 |
+
|
| 134 |
+
Experiments with larger pre-training datasets and larger models: In addition to ResNet-50 pre-trained on ImageNet, we now also experiment with ResNeXt-50 32x4d (25M parameters), that is pre-trained using semi-weakly supervised objective on Instagram 1B images and ImageNet labeled data [48], and RegNetY-16GF (81M parameters) pre-trained using Instagram 3.6B images. Note that both ResNet-50 and ResNeXt-50 32x4d have similar number of parameters, while RegNetY-16GF has more than $3 \mathbf { x }$ the number of parameters. On the other hand, also notice that the three architectures are respectively pre-trained on an increasing size of datasets. The rationale behind this choice is that recent trends in deep learning has shown that models pre-trained on larger datasets and architectures achieve better downstream transfer performance [12, 32, 20]. Therefore, we expect the latter models to improve the ERM baseline, and our goal is to investigate the out-domain performance gain by model averaging and EoA relative to the corresponding ERM baseline with increasing pre-training dataset size and model size.
|
| 135 |
+
|
| 136 |
+
The experimental results are shown in Table 4. To investigate models with the same size, but one pre-trained on a larger dataset, we compare the results of ResNet-50 and ResNeXt-50 32x4d. On average across all five datasets, the gain of SMA over ERM (our runs) is $2 . 5 \%$ for ResNet-50 and $3 . 9 \%$ for $\mathrm { R e s N e X t - } 5 0 \ 3 2 \mathrm { x } 4 \mathrm { d } .$ . The gain of EoA over ERM is larger: $4 \%$ vs $5 \%$ respectively. This suggests that pre-training the model on a larger dataset increases the gain of model averaging and EoA over the corresponding ERM baseline, while the ERM performance itself improves.
|
| 137 |
+
|
| 138 |
+
Next, to investigate the impact of both larger model size and larger pre-training dataset, we compare the results of $\mathrm { R e s N e X t - } 5 0 \ 3 2 \mathrm { x } 4 \mathrm { d }$ and RegNetY-16GF. On average across all five datasets, the gain of SMA over ERM (our runs) is $3 . 9 \%$ for ResNeXt-50 32x4d and $5 \%$ for RegNetY-16GF. The gain of EoA over ERM is again larger: $5 \%$ vs $6 \%$ respectively. This suggests that increasing both model size and pre-training dataset size allow model averaging and EoA to provide larger out-domain gains over the corresponding ERM baseline. Notice that these claims are different from existing work [20], which states that the baseline ERM performance improves with larger pre-training data and model size.
|
| 139 |
+
|
| 140 |
+
# 4.2 In-domain Performance Improvement using Model Averaging
|
| 141 |
+
|
| 142 |
+
We study the in-domain test accuracy on PACS and OfficeHome datasets using ImageNet pretrained ResNet-50 with and without our SMA protocol. In this experiment, we combine all the domains of PACS and split it into training/- validation/test splits (0.8/0.1/0.1). We run 10
|
| 143 |
+
|
| 144 |
+
Table 5: SMA outperforms ERM without model averaging in the IID setting.
|
| 145 |
+
|
| 146 |
+
<table><tr><td rowspan=1 colspan=1>Algorithm</td><td rowspan=1 colspan=1>PACS</td><td rowspan=1 colspan=1>OfficeHome</td></tr><tr><td rowspan=1 colspan=1>ERM (no averaging)</td><td rowspan=1 colspan=1>94.39 ± 0.46</td><td rowspan=1 colspan=1>77.09± 0.57</td></tr><tr><td rowspan=1 colspan=1>SMA (ours)</td><td rowspan=1 colspan=1>96.77 ± 0.20</td><td rowspan=1 colspan=1>83.56± 0.21</td></tr></table>
|
| 147 |
+
|
| 148 |
+
different runs with different seeds and randomly chosen splits for each dataset. The best model for each run is chosen using the validation set. The remaining optimization details are identical to those used in the previous section. The test accuracy mean and standard error using these best models are shown in Table 5. As expected, SMA outperforms models without averaging.
|
| 149 |
+
|
| 150 |
+
# 5 Related Work
|
| 151 |
+
|
| 152 |
+
# 5.1 Model Averaging
|
| 153 |
+
|
| 154 |
+
A theoretical perspective: In our model averaging protocol, we compute a simple moving average of the model parameters starting early during training. This is known as tail-averaging [24], which is slightly different from Polyak-Ruppert averaging [36] in that the latter starts averaging from the very beginning of training. In the context of least square regression in the IID setting, [24] theoretically study the behavior of tail averaging and show that the excess risk of the moving average model is upper bounded by a bias and a variance term. This bias term depends on the initialization state of the parameter, but interestingly, it decays exponentially with $t _ { 0 }$ , where $t _ { 0 }$ is the iteration at which model averaging is started. The variance term on the other hand depends on the covariance of the noise inherent in the data w.r.t. the optimal parameter, and is shown to decay at a faster rate when using model averaging, as opposed to a slower rate without averaging. This motivated them to propose tail-averaging.
|
| 155 |
+
|
| 156 |
+
Model averaging has also been shown to have a regularization effect [34] similar to that of Tikhonov regularization [42]. This regularization has been classically used in ill-posed optimization problems (typically least squared regression), which are under-specified. This property provides an interesting connection between model averaging and the under-specification problem discussed in [10], where the authors perform large scale experiments showing that the performance of multiple over-parameterized deep models, trained independently with different hyper-parameters and seeds, have a high variance on out-domain data, even though their in-domain performances are very close together. Based on this connection, a simple intuition why one can expect model averaging to help in domain generalization is its Tikhonov regularization effect. However, this intuition requires a more thorough investigation.
|
| 157 |
+
|
| 158 |
+
SWAD [8]: SWAD propose flat minima as a means for improving domain generalization. Following the intuition of stochastic weight averaging (SWA, [23]), they use model averaging to find flat minima. However, their proposal is different from sampling model states at regular intervals and towards the end of training (as done in SWA). SWAD selects contiguous model states along the optimization path for averaging, based on their validation loss. This is done to prevent including an under-performing state (determined using the in-domain validation set) in the moving average model. SWAD however adds additional hyper-parameters of its own: the validation loss threshold below which the the model states are selected, and patience parameters (number of iterations that determine the start and end of the averaging process). Note that this also requires computing validation loss more frequently during training. In this context, we show that instead of finding the start and end period for model averaging meticulously, we can simply start model averaging early during training and continue till the end. This difference arises from the fact that SWAD uses the online network to calculate validation performance while we use the SMA model in our protocol. This is explained further in section 2.2. The benefit our observations provide over SWAD is that they allow us to take advantage of model averaging without the additional hyper-parameters and compute required by SWAD.
|
| 159 |
+
|
| 160 |
+
# 5.2 Domain Generalization
|
| 161 |
+
|
| 162 |
+
Existing methods aimed at domain generalization can be broadly categorized into techniques that perform domain alignment, regularization, data augmentation, and meta-learning. Domain alignment is perhaps the most intuitive direction, in which methods aim to learn latent representations which have similar distributions across different domains [41, 30, 39, 37]. There are different variants of this idea, such as minimizing some divergence metric between the latent representation of different domains (E.g. DANN [16]), or less strictly, minimizing the difference between the latent statistics of different domains (E.g. DICA [33], CORAL [41]). In the meta learning category, source domains are typically split into 2 subsets to be used as the training and test domains in episodes to simulate the domain generalization setting [28, 29]. Data augmentation is also a popular tool used for improving domain generalization. It ranges from introducing various types of augmentations to simulate unseen test domain conditions (E.g. style transfer [50, 52]) to self-supervised learning involving matching the representations of an image with different augmentations (E.g. [1, 7]). Finally, different ways of regularizing models (implicit and explicit) have also been developed with the goal of encouraging domain-invariant feature learning [38, 47, 46]. For instance, invariant risk minimization [2] propose a regularization such that the classifier is optimal in all the environments. Representation SelfChallenging [21] propose to suppress the dominant features that get activated on the training data, which forces the network to use other features that correlate with labels. Risk extrapolation [26] propose a regularization that minimizes the variance between domain-wise loss, in the hope that it is representative of the variance including unseen test domains. See [51] for a survey on DG methods.
|
| 163 |
+
|
| 164 |
+
Our investigation in this work is complementary to all these domain generalization methods. Additionally, one of our main focus is to also study and improve performance instability on out-domain data during training, which results in more reliable model selection. This aspect has not received much attention.
|
| 165 |
+
|
| 166 |
+
# 6 Conclusion
|
| 167 |
+
|
| 168 |
+
We investigated a hyperparameter-free and efficient protocol for model averaging in the ERM framework, and showed that it provides a significant boost to out-domain performance compared to un-averaged models. Building on this observation, we showed that an ensemble of moving average models performs better compared to an ensemble of un-averaged models. Importantly, we showed that in both cases, model averaging significantly improves the rank correlation between in-domain validation accuracy and out-domain test accuracy, which is crucial for reliable model selection using in-domain validation data. We experimented with three pre-trained models with increasing pre-training dataset and model size, and found that EoA provides a proportionally larger gain compared to the corresponding ERM baseline, and lies in the range of $4 \% - 6 \%$ . Finally, we explain the performance boost of EoA by adapting the Bias-Variance trade-off perspective to the domain generalization setting. Further discussions along with limitations of our work are provided in Appendix E.
|
| 169 |
+
|
| 170 |
+
References
|
| 171 |
+
[1] Isabela Albuquerque, Nikhil Naik, Junnan Li, Nitish Keskar, and Richard Socher. Improving out-of-distribution generalization via multi-task self-supervised pretraining. arXiv preprint arXiv:2003.13525, 2020.
|
| 172 |
+
[2] Martin Arjovsky, Léon Bottou, Ishaan Gulrajani, and David Lopez-Paz. Invariant risk minimization. arXiv preprint arXiv:1907.02893, 2019.
|
| 173 |
+
[3] Sara Beery, Grant Van Horn, and Pietro Perona. Recognition in terra incognita. In Proceedings of the European conference on computer vision (ECCV), pages 456–473, 2018.
|
| 174 |
+
[4] Shai Ben-David, John Blitzer, Koby Crammer, and Fernando Pereira. Analysis of representations for domain adaptation. Advances in neural information processing systems, 19, 2006.
|
| 175 |
+
[5] Gilles Blanchard, Gyemin Lee, and Clayton Scott. Generalizing from several related classification tasks to a new unlabeled sample. Advances in neural information processing systems, 24:2178–2186, 2011.
|
| 176 |
+
[6] Leo Breiman. Bagging predictors. Machine learning, 24(2):123–140, 1996.
|
| 177 |
+
[7] Silvia Bucci, Antonio D’Innocente, Yujun Liao, Fabio Maria Carlucci, Barbara Caputo, and Tatiana Tommasi. Self-supervised learning across domains. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
|
| 178 |
+
[8] Junbum Cha, Sanghyuk Chun, Kyungjae Lee, Han-Cheol Cho, Seunghyun Park, Yunsung Lee, and Sungrae Park. Swad: Domain generalization by seeking flat minima. arXiv preprint arXiv:2102.08604, 2021.
|
| 179 |
+
[9] Junbum Cha, Kyungjae Lee, Sungrae Park, and Sanghyuk Chun. Domain generalization by mutual-information regularization with pre-trained models. arXiv preprint arXiv:2203.10789, 2022.
|
| 180 |
+
[10] Alexander D’Amour, Katherine Heller, Dan Moldovan, Ben Adlam, Babak Alipanahi, Alex Beutel, Christina Chen, Jonathan Deaton, Jacob Eisenstein, Matthew D Hoffman, et al. Underspecification presents challenges for credibility in modern machine learning. arXiv preprint arXiv:2011.03395, 2020.
|
| 181 |
+
[11] Thomas G Dietterich. Ensemble methods in machine learning. In International workshop on multiple classifier systems, pages 1–15. Springer, 2000.
|
| 182 |
+
[12] 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.
|
| 183 |
+
[13] Chen Fang, Ye Xu, and Daniel N Rockmore. Unbiased metric learning: On the utilization of multiple datasets and web images for softening bias. In Proceedings of the IEEE International Conference on Computer Vision, pages 1657–1664, 2013.
|
| 184 |
+
[14] Stanislav Fort, Huiyi Hu, and Balaji Lakshminarayanan. Deep ensembles: A loss landscape perspective. arXiv preprint arXiv:1912.02757, 2019.
|
| 185 |
+
[15] Yarin Gal and Zoubin Ghahramani. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conference on machine learning, pages 1050–1059. PMLR, 2016.
|
| 186 |
+
[16] Yaroslav Ganin, Evgeniya Ustinova, Hana Ajakan, Pascal Germain, Hugo Larochelle, François Laviolette, Mario Marchand, and Victor Lempitsky. Domain-adversarial training of neural networks. The journal of machine learning research, 17(1):2096–2030, 2016.
|
| 187 |
+
[17] Stuart Geman, Elie Bienenstock, and René Doursat. Neural networks and the bias/variance dilemma. Neural computation, 4(1):1–58, 1992.
|
| 188 |
+
|
| 189 |
+
[18] Ishaan Gulrajani and David Lopez-Paz. In search of lost domain generalization. arXiv preprint arXiv:2007.01434, 2020.
|
| 190 |
+
|
| 191 |
+
[19] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
|
| 192 |
+
|
| 193 |
+
[20] Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Zhu, Samyak Parajuli, Mike Guo, et al. The many faces of robustness: A critical analysis of out-of-distribution generalization. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 8340–8349, 2021.
|
| 194 |
+
|
| 195 |
+
[21] Zeyi Huang, Haohan Wang, Eric P Xing, and Dong Huang. Self-challenging improves crossdomain generalization. In Computer Vision–ECCV 2020: 16th European Conference, Glasgow, UK, August 23–28, 2020, Proceedings, Part II 16, pages 124–140. Springer, 2020.
|
| 196 |
+
|
| 197 |
+
[22] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International conference on machine learning, pages 448–456. PMLR, 2015.
|
| 198 |
+
|
| 199 |
+
[23] Pavel Izmailov, Dmitrii Podoprikhin, Timur Garipov, Dmitry Vetrov, and Andrew Gordon Wilson. Averaging weights leads to wider optima and better generalization. arXiv preprint arXiv:1803.05407, 2018.
|
| 200 |
+
|
| 201 |
+
[24] Prateek Jain, Sham Kakade, Rahul Kidambi, Praneeth Netrapalli, and Aaron Sidford. Parallelizing stochastic gradient descent for least squares regression: mini-batching, averaging, and model misspecification. Journal of Machine Learning Research, 18, 2018.
|
| 202 |
+
|
| 203 |
+
[25] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 204 |
+
|
| 205 |
+
[26] David Krueger, Ethan Caballero, Joern-Henrik Jacobsen, Amy Zhang, Jonathan Binas, Dinghuai Zhang, Remi Le Priol, and Aaron Courville. Out-of-distribution generalization via risk extrapolation (rex). In International Conference on Machine Learning, pages 5815–5826. PMLR, 2021.
|
| 206 |
+
|
| 207 |
+
[27] Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Deeper, broader and artier domain generalization. In Proceedings of the IEEE international conference on computer vision, pages 5542–5550, 2017.
|
| 208 |
+
|
| 209 |
+
[28] Da Li, Yongxin Yang, Yi-Zhe Song, and Timothy M Hospedales. Learning to generalize: Meta-learning for domain generalization. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
|
| 210 |
+
|
| 211 |
+
[29] Da Li, Jianshu Zhang, Yongxin Yang, Cong Liu, Yi-Zhe Song, and Timothy M Hospedales. Episodic training for domain generalization. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1446–1455, 2019.
|
| 212 |
+
|
| 213 |
+
[30] Haoliang Li, Sinno Jialin Pan, Shiqi Wang, and Alex C Kot. Domain generalization with adversarial feature learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 5400–5409, 2018.
|
| 214 |
+
|
| 215 |
+
[31] Ya Li, Xinmei Tian, Mingming Gong, Yajing Liu, Tongliang Liu, Kun Zhang, and Dacheng Tao. Deep domain generalization via conditional invariant adversarial networks. In Proceedings of the European Conference on Computer Vision (ECCV), pages 624–639, 2018.
|
| 216 |
+
|
| 217 |
+
[32] Dhruv Mahajan, Ross Girshick, Vignesh Ramanathan, Kaiming He, Manohar Paluri, Yixuan Li, Ashwin Bharambe, and Laurens Van Der Maaten. Exploring the limits of weakly supervised pretraining. In Proceedings of the European conference on computer vision (ECCV), pages 181–196, 2018.
|
| 218 |
+
|
| 219 |
+
[33] Krikamol Muandet, David Balduzzi, and Bernhard Schölkopf. Domain generalization via invariant feature representation. In International Conference on Machine Learning, pages 10–18. PMLR, 2013.
|
| 220 |
+
|
| 221 |
+
[34] Gergely Neu and Lorenzo Rosasco. Iterate averaging as regularization for stochastic gradient descent. In Conference On Learning Theory, pages 3222–3242. PMLR, 2018.
|
| 222 |
+
[35] Xingchao Peng, Qinxun Bai, Xide Xia, Zijun Huang, Kate Saenko, and Bo Wang. Moment matching for multi-source domain adaptation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1406–1415, 2019.
|
| 223 |
+
[36] Boris T Polyak and Anatoli B Juditsky. Acceleration of stochastic approximation by averaging. SIAM journal on control and optimization, 30(4):838–855, 1992.
|
| 224 |
+
[37] Alexandre Rame, Corentin Dancette, and Matthieu Cord. Fishr: Invariant gradient variances for out-of-distribution generalization. arXiv preprint arXiv:2109.02934, 2021.
|
| 225 |
+
[38] Shiori Sagawa, Pang Wei Koh, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. arXiv preprint arXiv:1911.08731, 2019.
|
| 226 |
+
[39] Yuge Shi, Jeffrey Seely, Philip HS Torr, N Siddharth, Awni Hannun, Nicolas Usunier, and Gabriel Synnaeve. Gradient matching for domain generalization. arXiv preprint arXiv:2104.09937, 2021.
|
| 227 |
+
[40] Mannat Singh, Laura Gustafson, Aaron Adcock, Vinicius de Freitas Reis, Bugra Gedik, Raj Prateek Kosaraju, Dhruv Mahajan, Ross Girshick, Piotr Dollár, and Laurens van der Maaten. Revisiting weakly supervised pre-training of visual perception models. arXiv preprint arXiv:2201.08371, 2022.
|
| 228 |
+
[41] Baochen Sun and Kate Saenko. Deep coral: Correlation alignment for deep domain adaptation. In European conference on computer vision, pages 443–450. Springer, 2016.
|
| 229 |
+
[42] Andrey Nikolayevich Tikhonov. On the stability of inverse problems. In Dokl. Akad. Nauk SSSR, volume 39, pages 195–198, 1943.
|
| 230 |
+
[43] Vladimir Vapnik and Vlamimir Vapnik. Statistical learning theory wiley. New York, 1(624):2, 1998.
|
| 231 |
+
[44] Ramakrishna Vedantam, David Lopez-Paz, and David J Schwab. An empirical investigation of domain generalization with empirical risk minimizers. Advances in Neural Information Processing Systems, 34, 2021.
|
| 232 |
+
[45] Hemanth Venkateswara, Jose Eusebio, Shayok Chakraborty, and Sethuraman Panchanathan. Deep hashing network for unsupervised domain adaptation. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 5018–5027, 2017.
|
| 233 |
+
[46] Yufei Wang, Haoliang Li, and Alex C Kot. Heterogeneous domain generalization via domain mixup. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 3622–3626. IEEE, 2020.
|
| 234 |
+
[47] Minghao Xu, Jian Zhang, Bingbing Ni, Teng Li, Chengjie Wang, Qi Tian, and Wenjun Zhang. Adversarial domain adaptation with domain mixup. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 6502–6509, 2020.
|
| 235 |
+
[48] I Zeki Yalniz, Hervé Jégou, Kan Chen, Manohar Paluri, and Dhruv Mahajan. Billion-scale semi-supervised learning for image classification. arXiv preprint arXiv:1905.00546, 2019.
|
| 236 |
+
[49] Zitong Yang, Yaodong Yu, Chong You, Jacob Steinhardt, and Yi Ma. Rethinking bias-variance trade-off for generalization of neural networks. In International Conference on Machine Learning, pages 10767–10777. PMLR, 2020.
|
| 237 |
+
[50] Xiangyu Yue, Yang Zhang, Sicheng Zhao, Alberto Sangiovanni-Vincentelli, Kurt Keutzer, and Boqing Gong. Domain randomization and pyramid consistency: Simulation-to-real generalization without accessing target domain data. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2100–2110, 2019.
|
| 238 |
+
[51] Kaiyang Zhou, Ziwei Liu, Yu Qiao, Tao Xiang, and Chen Change Loy. Domain generalization: A survey. arXiv preprint arXiv:2103.02503, 2021.
|
| 239 |
+
|
| 240 |
+
[52] Kaiyang Zhou, Chen Change Loy, and Ziwei Liu. Semi-supervised domain generalization with stochastic stylematch. arXiv preprint arXiv:2106.00592, 2021.
|
| 241 |
+
|
| 242 |
+
# Checklist
|
| 243 |
+
|
| 244 |
+
1. For all authors...
|
| 245 |
+
|
| 246 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 247 |
+
(b) Did you describe the limitations of your work? [Yes] In Appendix E, we have discussed various aspects including the limitations of our and existing methods in addressing domain generalization, functional diversity of ensembles vs model averaging strategy, and more.
|
| 248 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] See Appendix A.
|
| 249 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 250 |
+
|
| 251 |
+
2. If you are including theoretical results...
|
| 252 |
+
|
| 253 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] See section 3.2. (b) Did you include complete proofs of all theoretical results? [N/A]
|
| 254 |
+
|
| 255 |
+
3. If you ran experiments...
|
| 256 |
+
|
| 257 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes]
|
| 258 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 259 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes]
|
| 260 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
|
| 261 |
+
|
| 262 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 263 |
+
|
| 264 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 265 |
+
(b) Did you mention the license of the assets? [No]
|
| 266 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 267 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 268 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 269 |
+
|
| 270 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 271 |
+
|
| 272 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 273 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 274 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/rFbR4Fv-D6-/rFbR4Fv-D6-.md
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOMATED SELF-SUPERVISED LEARNING FOR GRAPHS
|
| 2 |
+
|
| 3 |
+
Wei Jin ∗ Michigan State University jinwei2@msu.edu
|
| 4 |
+
|
| 5 |
+
Xiaorui Liu Michigan State University xiaorui@msu.edu
|
| 6 |
+
|
| 7 |
+
Xiaoyu Zhao City University of Hong Kong xy.zhao@cityu.edu.hk
|
| 8 |
+
|
| 9 |
+
# Yao Ma
|
| 10 |
+
|
| 11 |
+
Neil Shah
|
| 12 |
+
Snap Inc.
|
| 13 |
+
nshah@snap.com
|
| 14 |
+
|
| 15 |
+
New Jersey Institute of Technology yao.ma@njit.edu
|
| 16 |
+
|
| 17 |
+
Jiliang Tang Michigan State University tangjili@msu.edu
|
| 18 |
+
|
| 19 |
+
# ABSTRACT
|
| 20 |
+
|
| 21 |
+
Graph self-supervised learning has gained increasing attention due to its capacity to learn expressive node representations. Many pretext tasks, or loss functions have been designed from distinct perspectives. However, we observe that different pretext tasks affect downstream tasks differently across datasets, which suggests that searching over pretext tasks is crucial for graph self-supervised learning. Different from existing works focusing on designing single pretext tasks, this work aims to investigate how to automatically leverage multiple pretext tasks effectively. Nevertheless, evaluating representations derived from multiple pretext tasks without direct access to ground truth labels makes this problem challenging. To address this obstacle, we make use of a key principle of many real-world graphs, i.e., homophily, or the principle that “like attracts like,” as the guidance to effectively search various self-supervised pretext tasks. We provide theoretical understanding and empirical evidence to justify the flexibility of homophily in this search task. Then we propose the AUTOSSL framework to automatically search over combinations of various self-supervised tasks. By evaluating the framework on 8 real-world datasets, our experimental results show that AUTOSSL can significantly boost the performance on downstream tasks including node clustering and node classification compared with training under individual tasks.
|
| 22 |
+
|
| 23 |
+
# 1 INTRODUCTION
|
| 24 |
+
|
| 25 |
+
Graphs are pivotal data structures describing the relationships between entities in various domains such as social media, biology, transportation and financial systems (Wu et al., 2019b; Battaglia et al., 2018). Due to their prevalence and rich descriptive capacity, pattern mining and discovery on graph data is a prominent research area with powerful implications. As the generalization of deep neural networks on graph data, graph neural networks (GNNs) have proved to be powerful in learning representations for graphs and associated entities (nodes, edges, subgraphs), and they have been employed in various applications such as node classification (Kipf & Welling, 2016a; Velickovi ˇ c´ et al., 2018), node clustering (Pan et al., 2018), recommender systems (Ying et al., 2018) and drug discovery (Duvenaud et al., 2015).
|
| 26 |
+
|
| 27 |
+
In recent years, the explosive interest in self-supervised learning (SSL) has suggested its great potential in empowering stronger neural networks in an unsupervised manner (Chen et al., 2020; Kolesnikov et al., 2019; Doersch et al., 2015). Many self-supervised methods have also been developed to facilitate graph representation learning (Jin et al., 2020; Xie et al., 2021; Wang et al., 2022) such as DGI (Velickovi ˇ c et al., 2019), P ´ AR/CLU (You et al., 2020) and MVGRL (Hassani & Khasahmadi, 2020). Given graph and node attribute data, they construct pretext tasks, which are called SSL tasks, based on structural and attribute information to provide self-supervision for training graph neural networks without accessing any labeled data. For example, the pretext task of
|
| 28 |
+
|
| 29 |
+

|
| 30 |
+
Figure 1: (a)(b): Performance of 5 SSL tasks ranked best (1) to worst (5) by color on node clustering and classification, showing disparate performance across datasets and tasks. (c): Clustering performance heatmap on Citeseer when combining 2 SSL tasks, PAIRSIM and PAIRDIS, with different weights. (d) AUTOSSL’s search trajectory for task weights, achieving near-ideal performance.
|
| 31 |
+
|
| 32 |
+
PAR is to predict the graph partitions of nodes. We examine how a variety of SSL tasks including DGI, PAR, CLU, PAIRDIS (Peng et al., 2020) and PAIRSIM (Jin et al., 2020; 2021) perform over 3 datasets. Their node clustering and node classification performance ranks are illustrated in Figure 1a and 1b, respectively. From these figures, we observe that different SSL tasks have distinct downstream performance cross datasets. This observation suggests that the success of SSL tasks strongly depends on the datasets and downstream tasks. Learning representations with a single task naturally leads to ignoring useful information from other tasks. As a result, searching SSL tasks is crucial, which motivates us to study on how to automatically compose a variety of graph self-supervised tasks to learn better node representations.
|
| 33 |
+
|
| 34 |
+
However, combining multiple different SSL tasks for unlabeled representation learning is immensely challenging. Although promising results have been achieved in multi-task self-supervised learning for computer vision, most of them assign equal weights to SSL tasks (Doersch & Zisserman, 2017; Ren & Lee, 2018; Zamir et al., 2018). Such combination might not always yield better performance than a single task, as different tasks have distinct importance according to specific dataset and downstream tasks. To illustrate this intuition, we combine two SSL tasks, PAIRDIS and PAIRSIM, with varied weights and illustrate the corresponding node clustering performance in Figure 1c. It clearly indicates that different choices of weights yield different performance. To circumvent this problem, we could plausibly search different weights for SSL tasks to optimize downstream tasks. However, to achieve such goal, we have two obstacles. First, the search space is huge, and thus search can be highly expensive. Hence, it is desirable to automatically learn these weights. Second, searching for optimal task weights typically requires guidance from downstream performance, which is naturally missing under the unsupervised setting. Thus, how to design an unsupervised surrogate evaluation measure that can guide the search process is necessary.
|
| 35 |
+
|
| 36 |
+
It is evident that many real-world graphs such as friendship networks, citation networks, coauthorship networks and co-purchase networks (McPherson et al., 2001; Shchur et al., 2018) satisfy the homophily assumption, i.e., “like attracts like”, or that connected nodes tend to share the same label. This is useful prior knowledge, as it directly relates the label information of downstream tasks to the graph structure. In this work, we explicitly take advantage of this prior knowledge and assume that the predicted labels from good node embeddings should also adhere to homophily. Given the lack of ground-truth labels during SSL, we propose a pseudo-homophily measure to evaluate the quality of the node embeddings trained from specific combinations of SSL task. With pseudohomophily, we are able to design an automated framework for SSL task search, namely AUTOSSL. Our work makes three significant contributions:
|
| 37 |
+
|
| 38 |
+
(1) To bridge the gap between unsupervised representation and downstream labels, we propose pseudo-homophily to measure the quality of the representation. Moreover, given graphs with high homophily, we theoretically show that pseudo-homophily maximization can help maximize the upper bound of mutual information between pseudo-labels and downstream labels.
|
| 39 |
+
(2) Based on pseudo-homophily, we propose two strategies to efficiently search SSL tasks, one employing evolution algorithm and the other performing differentiable search via meta-gradient descent. AUTOSSL is able to adjust the task weights during search as shown in Figure 1d.
|
| 40 |
+
(3) We evaluate the proposed AUTOSSL by composing various individual tasks on 8 real-world datasets. Extensive experiments have demonstrated that AUTOSSL can significantly improve
|
| 41 |
+
|
| 42 |
+
the performance of individual tasks on node clustering and node classification (e.g., up to $10 . 0 \%$ relative improvement on node clustering).
|
| 43 |
+
|
| 44 |
+
# 2 BACKGROUND AND RELATED WORK
|
| 45 |
+
|
| 46 |
+
Graph Neural Networks. Graph neural networks (GNNs) are powerful tools for extracting useful information from graph data (Liu et al., 2021; Wu et al., 2019b; Kipf & Welling, 2016a; Velickovi ˇ c´ et al., 2018; Hamilton et al., 2017; Kipf & Welling, 2016b; Pan et al., 2018; Liu et al., 2020). They aim to learn a mapping function $f _ { \theta }$ parameterized by $\theta$ to map the input graph into a low-dimensional space. Most graph neural networks follow a message passing scheme (Gilmer et al., 2017) where the node representation is obtained by aggregating the representation of its neighbors.
|
| 47 |
+
|
| 48 |
+
Self-Supervised Learning in GNNs. Graph neural networks have achieved superior performance in various applications; but they also require costly task-dependent labels to learn rich representations. To alleviate the need for the huge amount of labeled data, recent studies have employed self-supervised learning in graph neural networks to provide additional supervision (Jin et al., 2020; Velickovi ˇ c et al., 2019; You et al., 2020; Hassani & Khasahmadi, 2020; Hu et al., 2019; Qiu et al., ´ 2020; Zhu et al., 2020b). Specifically, those SSL methods construct a pre-defined pretext task to assign pseudo-labels for unlabeled nodes/graphs and then train the model on the designed pretext task to learn representations. A recent work JOAO (You et al., 2021) on graph contrastive learning is proposed to automatically select data augmentation and focuses on graph classification task. Another related work is AUX-TS (Han et al., 2021), which also adaptively combines different SSL tasks but the combination happens at the fine-tuning stage and thus requires label information.
|
| 49 |
+
|
| 50 |
+
Multi-Task Self-Supervised Learning. Our work is also related to multi-task self-supervised learning (Doersch & Zisserman, 2017; Ren & Lee, 2018; Zamir et al., 2018). Most of them assume the tasks with equal weights and perform training under the supervised setting. But our work learns different weights for different tasks and does not require access to labeled data.
|
| 51 |
+
|
| 52 |
+
Automated Loss Function Search. Tremendous efforts have been paid to automate every aspect of machine learning applications (Yao et al., 2018; Liu et al., 2018; Zhao et al., 2021b), such as feature engineering, model architecture search and loss function search. Among them, our work is highly related to loss function search (Zhao et al., 2021a; Xu et al., 2018; Wang et al., 2020; Li et al., 2019). However, these methods are developed under the supervised setting and not applicable in selfsupervised learning. Another related work, ELo (Piergiovanni et al., 2020), evolves multiple selfsupervised losses based on Zipf distribution matching for action recognition. However, it is designed exclusively for image data and not applicable to non-grid graph-structured data. The problem of self-supervised loss search for graphs remains rarely explored. To bridge the gap, we propose an automated framework for searching SSL losses towards graph data in an unsupervised manner.
|
| 53 |
+
|
| 54 |
+
# 3 AUTOMATED SELF-SUPERVISED TASK SEARCH WITH AUTOSSL
|
| 55 |
+
|
| 56 |
+
In this section, we present the proposed framework of automated self-supervised task search, namely AUTOSSL. Given a graph $\mathcal { G }$ , a GNN encoder $f _ { \theta } ( \cdot )$ and a set of $n$ self-supervised losses (tasks) $\{ \ell _ { 1 } , \ell _ { 2 } , \dots , \ell _ { n } \}$ , we aim at learning a set of loss weights $\{ \lambda _ { 1 } , \lambda _ { 2 } , \ldots , \lambda _ { n } \}$ such that $f _ { \theta } ( \cdot )$ trained with the weighted loss combination data. The key challenge is how to $\textstyle \sum _ { i = 1 } ^ { n } \lambda _ { i } \ell _ { i }$ can extract meaningful features from the given graphically define “meaningful features”. If we have the access to the labels of the downstream task, we can define “meaningful features” as the features (node embeddings) that can have high performance on the given downstream task. Then we can simply adopt the downstream performance as the optimization goal and formulate the problem of automated self-supervised task search as follows:
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
\operatorname* { m i n } _ { \lambda _ { 1 } , \cdots , \lambda _ { n } } \mathcal { H } ( f _ { \theta ^ { * } } ( \mathcal { G } ) ) , \quad \mathrm { s . t . } \theta ^ { * } = \arg \operatorname* { m i n } _ { \theta } \mathcal { L } ( f _ { \theta } , \{ \lambda _ { i } \} , \{ \ell _ { i } \} ) = \arg \operatorname* { m i n } _ { \theta } \sum _ { i = 1 } ^ { n } \lambda _ { i } \ell _ { i } ( f _ { \theta } ( \mathcal { G } ) ) ,
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
where $\mathcal { H }$ denotes the quality measure for the obtained node embeddings, and it can be any metric that evaluates the downstream performance such as cross-entropy loss for the node classification task. However, under the self-supervised setting, we do not have the access to labeled data and thus cannot employ the downstream performance to measure the embedding quality. Instead, we need an unsupervised quality measure $\mathcal { H }$ to evaluate the quality of obtained embeddings. In a nutshell, one challenge of automated self-supervised learning is: how to construct the goal of automated task search without the access to label information of the downstream tasks.
|
| 63 |
+
|
| 64 |
+
# 3.1 PSEUDO-HOMOPHILY
|
| 65 |
+
|
| 66 |
+
Most common graphs adhere to the principle of homophily, i.e., “birds of a feather flock together” (McPherson et al., 2001), which suggests that connected nodes often belong to the same class; e.g. connected publications in a citation network often have the same topic, and friends in social networks often share interests (Newman, 2018). Homophily is often calculated as the fraction of intra-class edges in a graph (Zhu et al., 2020a). Formally, it can be defined as follows,
|
| 67 |
+
|
| 68 |
+
Definition 1 (Homophily). The homophily of a graph $\mathcal { G }$ with node label vector $y$ is given by
|
| 69 |
+
|
| 70 |
+
$$
|
| 71 |
+
h ( \mathcal { G } , y ) = \frac { 1 } { \vert \mathcal { E } \vert } \sum _ { ( v _ { 1 } , v _ { 2 } ) \in \mathcal { E } } \mathbb { 1 } ( y _ { v _ { 1 } } = y _ { v _ { 2 } } ) ,
|
| 72 |
+
$$
|
| 73 |
+
|
| 74 |
+
where $y _ { v _ { i } }$ indicates node $v _ { i }$ ’s label and $\mathbb { 1 } ( \cdot )$ is the indicator function.
|
| 75 |
+
|
| 76 |
+
We calculate the homophily for seven widely used datasets as shown in Appendix A and we find that they all have high homophily, e.g., 0.93 in the Physics dataset. Considering the high homophily in those datasets, intuitively the predicted labels from the extracted node features should also have high homophily. Hence, the prior information of graph homophily in ground truth labels can serve as strong guidance for searching combinations of self-supervised tasks. As mentioned before, in self-supervised tasks, the ground truth labels are not available. Motivated by DeepCluster (Caron et al., 2018) which uses the cluster assignments of learned features as pseudo-labels to train the neural network, we propose to calculate the homophily based on the cluster assignments, which we term as pseudo-homophily. Specifically, we first perform $k$ -means clustering on the obtained node embeddings to get $k$ clusters. Then the cluster results are used as the pseudo labels to calculate homophily based on Eq. (2). Note that though many graphs in the real world have high homophily, there also exist heterophily graphs (Zhu et al., 2020a; Pei et al., 2020) which have low homophily. We include a discussion on the homophily assumption in Appendix D.
|
| 77 |
+
|
| 78 |
+
Theoretical analysis. In this work, we propose to achieve self-supervised task search via maximizing pseudo-homophily. To understand its rationality, we develop the following theorem to show that pseudo-homophily maximization is related to the upper bound of mutual information between pseudo-labels and ground truth labels.
|
| 79 |
+
|
| 80 |
+
Theorem 1. Suppose that we are given with a graph $\mathcal { G } = \{ \nu , \varepsilon \}$ , a pseudo label vector $A \ \in$ $\{ 0 , 1 \} ^ { N }$ and a ground truth label vector $B \in \{ 0 , \bar { 1 } \} ^ { N }$ defined on the node set. We denote the homophily of $A$ and $B$ over $\mathcal { G }$ as $h _ { A }$ and $h _ { B }$ , respectively. If the classes in $A$ and $B$ are balanced and $h _ { A } < h _ { B }$ , the following results hold: $( l )$ the mutual information between $A$ and $B _ { i }$ , i.e., $M I ( A , B )$ , has an upper bound $\mathcal { U } _ { A , B }$ , where $\begin{array} { r } { \mathcal { U } _ { A , B } = \frac { 1 } { N } \left[ 2 \Delta \log \left( \frac { 4 } { N } \Delta \right) + 2 ( \frac { N } { 2 } - \Delta ) \log \left( \frac { 4 } { N } ( \frac { N } { 2 } - \Delta ) \right) \right] } \end{array}$ with ∆ = (hB−hA)|E|2d and dmax denoting the largest node degree in the graph; (2) if hA < hA0 < hB, we have $\mathcal { U } _ { A , B } \backslash \mathcal { < } \mathcal { U } _ { A ^ { \prime } , B }$ .
|
| 81 |
+
|
| 82 |
+
Proof. The detailed proof of this theorem can be found in Appendix B.
|
| 83 |
+
|
| 84 |
+
The above theorem suggests that a larger difference between pseudo-homophily and real homophily results in a lower upper bound of mutual information between the pseudo-labels and ground truth labels. Thus, maximizing pseudo-homophily is to maximize the upper bound of mutual information between pseudo-labels and ground truth labels, since we assume high homophily of the graph. Notably, while maximizing the upper bound does not guarantee the optimality of the mutual information, we empirically found that it works well in increasing the NMI value in different datasets, showing that it provides the right direction to promote the mutual information.
|
| 85 |
+
|
| 86 |
+
# 3.2 SEARCH ALGORITHMS
|
| 87 |
+
|
| 88 |
+
In the last subsection, we have demonstrated the importance of maximizing pseudo-homophily. Thus in the optimization problem of Eq. (1), we can simply set $\mathcal { H }$ to be negative pseudo-homophily. However, the evaluation of a specific task combination involves fitting a model and evaluating its pseudo-homophily, which can be highly expensive. Therefore, another challenge for automated selfsupervised task search is how to design an efficient algorithm. In the following, we introduce the details of the search strategies designed in this work, i.e. AUTOSSL-ES and AUTOSSL-DS.
|
| 89 |
+
|
| 90 |
+
# 3.2.1 AUTOSSL-ES: EVOLUTIONARY STRATEGY
|
| 91 |
+
|
| 92 |
+
Evolution algorithms are often used in automated machine learning such as hyperparameter tuning due to their parallelism nature by design (Loshchilov & Hutter, 2016). In this work, we employ the covariance matrix adaptation evolution strategy (CMA-ES) (Hansen et al., 2003), a state-of-theart optimizer for continuous black-box functions, to evolve the combined self-supervised loss. We name this self-supervised task search approach as AUTOSSL-ES. In each iteration of CMA-ES, it samples a set of candidate solutions (i.e., task weights $\{ \lambda _ { i } \} )$ from a multivariate normal distribution and trains the GNN encoder under the combined loss function. The embeddings from the trained encoder are then evaluated by $\mathcal { H }$ . Based on $\mathcal { H }$ , CMA-ES adjusts the normal distribution to give higher probabilities to good samples that can potentially produce a lower value of $\mathcal { H }$ . Note that we constrain $\{ \lambda _ { i } \}$ in [0, 1] and sample 8 candidate combinations for each iteration, which is trivially parallelizable as every candidate combination can be evaluated independently.
|
| 93 |
+
|
| 94 |
+
# 3.2.2 AUTOSSL-DS: DIFFERENTIABLE SEARCH VIA META-GRADIENT DESCENT
|
| 95 |
+
|
| 96 |
+
While the aforementioned AUTOSSL-ES is parallelizable, the search cost is still expensive because it requires to evaluate a large population of candidate combinations where every evaluation involves fitting the model in large training epochs. Thus, it is desired to develop gradient-based search methods to accelerate the search process. In this subsection, we introduce the other variant of our proposed framework, AUTOSSL-DS, which performs differentiable search via meta-gradient descent. However, pseudo-homophily is not differentiable as it is based on hard cluster assignments from $k$ -means clustering. Next, we will first present how to make the clustering process differentiable and then introduce how to perform differentiable search.
|
| 97 |
+
|
| 98 |
+
Soft Clustering. Although $k$ -means clustering assigns hard assignments of data samples to clusters, it can be viewed as a special case of Gaussian mixture model which makes soft assignments based on the posterior probabilities (Bishop, 2006). Given a Gaussian mixture model with centroids $\{ \mathbf { c } _ { 1 } , \mathbf { c } _ { 2 } , \ldots , \mathbf { c } _ { k } \}$ and fixed variances $\sigma ^ { 2 }$ , we can calculate the posterior probability as follows:
|
| 99 |
+
|
| 100 |
+
$$
|
| 101 |
+
p \left( \mathbf { x } \mid \mathbf { c } _ { i } \right) = \frac { 1 } { \sqrt { 2 \pi \sigma ^ { 2 } } } \exp \left( - \frac { \left\| \mathbf { x } - \mathbf { c } _ { i } \right\| _ { 2 } } { 2 \sigma ^ { 2 } } \right) ,
|
| 102 |
+
$$
|
| 103 |
+
|
| 104 |
+
where $\mathbf { x }$ is the feature vector of data samples. By Bayes rule and considering an equal prior, i.e., $p ( \mathbf { c } _ { 1 } ) = p ( \mathbf { c } _ { 2 } ) = . . . = p ( \mathbf { c } _ { k } )$ , we can compute the probability of a feature vector $\mathbf { x }$ belonging to a cluster $\mathbf { c } _ { i }$ as:
|
| 105 |
+
|
| 106 |
+
$$
|
| 107 |
+
p \left( \mathbf { c } _ { i } \mid \mathbf { x } \right) = { \frac { p \left( \mathbf { c } _ { i } \right) p \left( \mathbf { x } \mid \mathbf { c } _ { i } \right) } { \sum _ { j } ^ { k } p \left( \mathbf { c } _ { j } \right) p \left( \mathbf { x } \mid \mathbf { c } _ { j } \right) } } = { \frac { \exp - { \frac { ( \mathbf { x } - \mathbf { c } _ { i } ) ^ { 2 } } { 2 \sigma ^ { 2 } } } } { \sum _ { j = 1 } ^ { k } \exp - { \frac { \left( \mathbf { x } - \mathbf { c } _ { j } \right) ^ { 2 } } { 2 \sigma ^ { 2 } } } } } .
|
| 108 |
+
$$
|
| 109 |
+
|
| 110 |
+
If $\sigma 0$ , we can obtain the hard assignments as the $k$ -means algorithm. As we can see, the probability of each feature vector belonging to a cluster reduces to computing the distance between them. Then we can construct our homophily loss function as follows:
|
| 111 |
+
|
| 112 |
+
$$
|
| 113 |
+
{ \mathcal H } ( f _ { \theta ^ { * } } ( \boldsymbol { \mathcal G } ) ) = \frac { 1 } { k | \mathcal { E } | } \sum _ { i = 1 } ^ { k } \sum _ { ( v _ { 1 } , v _ { 2 } ) \in \mathcal E } \ell ( p ( \mathbf { c } _ { i } | \mathbf { x } _ { v _ { 1 } } ) , p ( \mathbf { c } _ { i } | \mathbf { x } _ { v _ { 2 } } ) ) ,
|
| 114 |
+
$$
|
| 115 |
+
|
| 116 |
+
where $\ell$ is a loss function measuring the difference between the inputs. With soft assignments, the gradient of $\mathcal { H }$ w.r.t. $\theta$ becomes tractable.
|
| 117 |
+
|
| 118 |
+
Search via Meta Gradient Descent. We now detail the differentiable search process for AUTOSSL-DS. A naive method to tackle bilevel problems is to alternatively optimize the inner and outer problems through gradient descent. However, we cannot perform gradient descent for the outer problem in Eq. (1) where $\mathcal { H }$ is not directly related to $\{ \lambda _ { i } \}$ . To address this issue, we can utilize meta-gradients, i.e., gradients w.r.t. hyperparameters, which have been widely used in solving bi-level problems in meta learning (Finn et al., 2017; Zugner¨ $\&$ G unnemann, 2019). To obtain meta- ¨ gradients, we need to backpropagate through the learning phase of the neural network. Concretely, the meta-gradient of $\mathcal { H }$ with respect to $\{ \lambda _ { i } \}$ is expressed as
|
| 119 |
+
|
| 120 |
+
$$
|
| 121 |
+
\nabla _ { \{ \lambda _ { i } \} } ^ { \mathrm { m e t a } } : = \nabla _ { \{ \lambda _ { i } \} } \mathcal { H } ( f _ { \theta ^ { * } } ( G ) ) \quad \mathrm { s . t . } \ \theta ^ { * } = \mathrm { o p t } _ { \theta } ( \mathcal { L } ( f _ { \theta } , \{ \lambda _ { i } , \ell _ { i } \} ) ) ,
|
| 122 |
+
$$
|
| 123 |
+
|
| 124 |
+
where $\operatorname { o p t } _ { \theta }$ stands for the inner optimization that obtains $\theta ^ { * }$ and it is typically multiple steps of gradient descent. As an illustration, we consider $\operatorname { o p t } _ { \theta }$ as $T + 1$ steps of vanilla gradient descent with learning rate $\epsilon$ ,
|
| 125 |
+
|
| 126 |
+
$$
|
| 127 |
+
\boldsymbol { \theta } _ { t + 1 } = \boldsymbol { \theta } _ { t } - \epsilon \nabla _ { \boldsymbol { \theta } _ { t } } \mathcal { L } \big ( f _ { \boldsymbol { \theta } _ { t } } , \{ \lambda _ { i } , \boldsymbol { \ell } _ { i } \} \big ) .
|
| 128 |
+
$$
|
| 129 |
+
|
| 130 |
+
By unrolling the training procedure, we can express meta-gradient as
|
| 131 |
+
|
| 132 |
+
$$
|
| 133 |
+
\begin{array} { r } { \nabla _ { \{ \lambda _ { i } \} } ^ { \mathrm { m e t a } } : = \nabla _ { \{ \lambda _ { i } \} } \mathcal { H } ( f _ { \theta _ { T } } ( G ) ) = \nabla _ { f _ { \theta _ { T } } } \mathcal { H } ( f _ { \theta _ { T } } ( G ) ) \cdot [ \nabla _ { \{ \lambda _ { i } \} } f _ { \theta _ { T } } ( G ) + \nabla _ { \theta _ { T } } f _ { \theta _ { T } } ( G ) \nabla _ { \{ \lambda _ { i } \} } \theta _ { T } ] , } \end{array}
|
| 134 |
+
$$
|
| 135 |
+
|
| 136 |
+
with $\begin{array} { r l } & { \nabla _ { \{ \lambda _ { i } \} } \theta _ { T } = \nabla _ { \{ \lambda _ { i } \} } \theta _ { T - 1 } - \epsilon \nabla _ { \{ \lambda _ { i } \} } \nabla _ { \theta _ { T - 1 } } \mathcal { L } ( f _ { \theta _ { T - 1 } } , \{ \lambda _ { i } , \ell _ { i } \} ) . \mathrm { S i n c e } \ \nabla _ { \{ \lambda _ { i } \} } f _ { \theta _ { T } } ( G ) = } \\ & { \qquad \nabla _ { \{ \lambda _ { i } \} } ^ { \mathrm { m e t a } } : = \nabla _ { \{ \lambda _ { i } \} } \mathcal { H } ( f _ { \theta _ { T } } ( G ) ) = \nabla _ { f _ { \theta _ { T } } } \mathcal { H } ( f _ { \theta _ { T } } ( G ) ) \cdot \nabla _ { \theta _ { T } } f _ { \theta _ { T } } ( G ) \nabla _ { \{ \lambda _ { i } \} } \theta _ { T } . } \end{array}$ , we have (9)
|
| 137 |
+
|
| 138 |
+
Note that $\theta _ { T - 1 }$ also depends on the task weights $\{ \lambda _ { i } \}$ (see Eq. (7)). Thus, its derivative w.r.t. the task weights chains back until $\theta _ { 0 }$ . By unrolling all the inner optimization steps, we can obtain the meta-gradient $\nabla _ { \{ \lambda _ { i } \} } ^ { \mathrm { m e t a } }$ and use it to perform gradient descent on $\{ \lambda _ { i } \}$ to reduce $\mathcal { H }$ :
|
| 139 |
+
|
| 140 |
+
$$
|
| 141 |
+
\{ \lambda _ { i } \} \{ \lambda _ { i } \} - \eta \nabla _ { \{ \lambda _ { i } \} } ^ { \mathrm { m e t a } } ,
|
| 142 |
+
$$
|
| 143 |
+
|
| 144 |
+
where $\eta$ is the learning rate for meta-gradient descent (outer optimization).
|
| 145 |
+
|
| 146 |
+
However, if we use the whole training trajectory $\theta _ { 0 } , \theta _ { 1 } , \ldots , \theta _ { T }$ to calculate the precise metagradient, it would have an extremely high memory footprint since we need to store $\theta _ { 0 } , \theta _ { 1 } , \ldots , \theta _ { T }$ in memory. Thus, inspired by DARTS (Liu et al., 2018), we use an online updating rule where we only perform one step gradient descent on $\theta$ and then update $\{ \lambda _ { i } \}$ in each iteration. During the process, we constrain $\{ \lambda _ { i } \}$ in [0, 1] and dynamically adjust the task weights in a differentiable manner. The detailed algorithm for AUTOSSL-DS is summarized in Appendix C.
|
| 147 |
+
|
| 148 |
+
# 4 EXPERIMENTAL EVALUATION
|
| 149 |
+
|
| 150 |
+
In this section, we empirically evaluate the effectiveness of the proposed AUTOSSL on selfsupervised task search on real-world datasets. We aim to answer four questions as follows. Q1: Can AUTOSSL achieve better performance compared to training on individual SSL tasks? Q2: How does AUTOSSL compare to other unsupervised and supervised node representation learning baselines? Q3: Can we observe relations between AUTOSSL’s pseudo-homophily objective and downstream classification performance? and Q4: How do the SSL task weights, pseudo-homophily objective, and downstream performance evolve during AUTOSSL’s training?
|
| 151 |
+
|
| 152 |
+
# 4.1 EXPERIMENTAL SETTING
|
| 153 |
+
|
| 154 |
+
Since our goal is to enable automated combination search and discovery of SSL tasks, we use 5 such tasks including 1 contrastive learning method and 4 predictive methods – (1) DGI (Velickovi ˇ c´ et al., 2019): it is a contrastive learning method maximizing the mutual information between graph representation and node representation; (2) CLU (You et al., 2020), it predicts partition labels from Metis graph partition (Karypis & Kumar, 1998); (3) PAR (You et al., 2020), it predicts clustered labels from $k$ -means clustering on node features; (4) PAIRSIM (Jin et al., 2020; 2021), it predicts pairwise feature similarity between node pairs and (5) PAIRDIS (Peng et al., 2020), it predicts shortest path length between node pairs. The proposed AUTOSSL framework automatically learns to jointly leverage the 5 above tasks and carefully mediate their influence. We also note that (1) the recent contrastive learning method, MVGRL (Hassani & Khasahmadi, 2020), needs to deal with a dense diffusion matrix and is prohibitively memory/time-consuming for larger graphs; thus, we only include it as a baseline to compare as shown in Table 2; and (2) the proposed framework is general and it is straightforward to combine other SSL tasks.
|
| 155 |
+
|
| 156 |
+
We perform experiments on 8 real-world datasets widely used in the literature (Yang et al., 2016; Shchur et al., 2018; Mernyei & Cangea, 2020; Hu et al., 2020), i.e., Physics, CS, Photo, Computers, WikiCS, Citeseer, CoraFull, and ogbn-arxiv. To demonstrate the effectiveness of the proposed framework, we follow (Hassani & Khasahmadi, 2020) and evaluate all methods on two different downstream tasks: node clustering and node classification. For the task of node clustering, we perform $k$ -means clustering on the obtained embeddings. We set the number of clusters to the number of ground truth classes and report the normalized mutual information (NMI) between the cluster results and ground truth labels. Regarding the node classification task, we train a logistic regression model on the obtained node embeddings and report the classification accuracy on test nodes. Note that labels are never used for self-supervised task search. All experiments are performed under 5 different random seeds and results are averaged. Following DGI and MVGRL, we use a simple one-layer GCN (Kipf & Welling, 2016a) as our encoder and set the size of hidden dimensions to 512. We set $2 \sigma ^ { 2 } = 0 . { \dot { 0 } } 0 1$ and use L1 loss in the homophily loss function throughout the experiments. Further details of experimental setup can be found in Appendix A.
|
| 157 |
+
|
| 158 |
+
# 4.2 PERFORMANCE COMPARISON WITH INDIVIDUAL TASKS
|
| 159 |
+
|
| 160 |
+
To answer Q1, Table 1 summarizes the results for individual self-supervised tasks and AUTOSSL under the two downstream tasks, i.e., node clustering and node classification. From the table, we make several observations. Obs. 1: individual self-supervised tasks have different node clustering and node classification performance for different datasets. For example, in Photo, DGI achieves the highest classification accuracy while PAR achieves the highest clustering performance; CLU performs better than PAIRDIS in both NMI and ACC on Physics while it cannot outperform PAIRDIS in WikiCS, Citeseer, Computers and CoraFull. This observation suggests the importance of searching suitable SSL tasks to benefit downstream tasks on different datasets. Obs. 2: Most of the time, combinations of SSL tasks searched by AUTOSSL can consistently improve the node clustering and classification performance over the best individual task on the all datasets. For example, the relative improvement over the best individual task on NMI from AUTOSSL-ES is $7 . 3 \%$ for WikiCS and $10 . 0 \%$ for Photo, and its relative improvement on ACC is $1 . 3 \%$ for WikiCS. These results indicate that composing multiple SSL tasks can help the model encode different types of information and avoid overfitting to one single task. Obs. 3: We further note that individual tasks resulted in different pseudo-homophily as shown in the P-H rows of Table 1. Among them, CLU tends to result in a low pseudo-homophily and often performs much worse than other tasks in node clustering task, which supports our theoretical analysis in Section 3.1. It also demonstrates the necessity to increase pseudo-homophily as the two variants of AUTOSSL effectively search tasks that lead to higher pseudo-homophily. Obs. 4: The performance of AUTOSSL-ES and AUTOSSLDS is close when their searched tasks lead to similar pseudo-homophily: the differences in pseudohomophily, NMI and ACC are relative smaller in datasets other than Photo and Computers. It is worth noting that sometimes AUTOSSL-DS can even achieve higher pseudo-homophily than AUTOSSL-ES. This indicates that the online updating rule for $\{ \lambda _ { i } \}$ in AUTOSSL-DS not only can greatly reduce the searching time but also can generate good task combinations. In addition to efficiency, we highlight another major difference between them: AUTOSSL-ES directly finds the best task weights while AUTOSSL-DS adjusts the task weights to generate appropriate gradients to update model parameters. Hence, if we hope to find the best task weights and retrain the model, we should turn to AUTOSSL-ES. More details on their differences can be found in Appendix E.3.
|
| 161 |
+
|
| 162 |
+
Table 1: Performance comparison of self-supervised tasks (losses) on node clustering and node classification. The NMI rows indicate node clustering performance; ACC rows indicate node classification accuracy $( \% )$ ; P-H stands for pseudo-homophily. AUTOSSL regularly outperforms individual pretext tasks. (Bold: best in all methods; Underline: best in individual tasks). Blue and red numbers indicate the statistically significant improvements over the best individual task, via paired t-test at level 0.05 and 0.1, respectively (same for Table 2 and Table 3).
|
| 163 |
+
|
| 164 |
+
<table><tr><td rowspan="2">Dataset</td><td rowspan="2">Metric</td><td colspan="5">Self-Supervised Task</td><td colspan="2">AUTOSSL</td></tr><tr><td>CLU</td><td>PAR</td><td>PAIRSIM</td><td>PAIRDIS</td><td>DGI</td><td>ES</td><td>DS</td></tr><tr><td rowspan="3">WikiCS</td><td>NMI</td><td>0.177±0.02</td><td>0.262±0.02</td><td>0.341±0.01</td><td>0.169±0.04</td><td>0.310±0.02</td><td>0.366±0.01</td><td>0.344±0.02</td></tr><tr><td>ACC</td><td>74.19±0.21</td><td>75.81±0.17</td><td>75.80±0.17</td><td>75.28±0.08</td><td>75.49±0.17</td><td>76.80±0.13</td><td>76.58±0.28</td></tr><tr><td>P-H</td><td>0.549</td><td>0.567</td><td>0.693</td><td>0.463</td><td>0.690</td><td>0.751</td><td>0.749</td></tr><tr><td rowspan="3">Citeseer</td><td>NMI</td><td>0.318±0.00</td><td>0.416±0.00</td><td>0.428±0.01</td><td>0.404±0.01</td><td>0.439±0.00</td><td>0.449±0.01</td><td>0.449±0.01</td></tr><tr><td>ACC</td><td>63.17±0.19</td><td>69.25±0.51</td><td>71.36±0.42</td><td>70.72±0.53</td><td>71.64±0.44</td><td>72.14±0.41</td><td>72.00±0.32</td></tr><tr><td>P-H</td><td>0.787</td><td>0.916</td><td>0.885</td><td>0.901</td><td>0.934</td><td>0.943</td><td>0.934</td></tr><tr><td rowspan="3">Computers</td><td>NMI</td><td>0.171±0.00</td><td>0.433±0.00</td><td>0.387±0.01</td><td>0.300±0.01</td><td>0.318±0.02</td><td>0.447±0.01</td><td>0.448±0.01</td></tr><tr><td>ACC</td><td>75.20±0.20</td><td>87.26±0.15</td><td>82.64±1.15</td><td>85.20±0.41</td><td>83.45±0.54</td><td>87.26±0.64</td><td>88.18±0.43</td></tr><tr><td>P-H</td><td>0.240</td><td>0.471</td><td>0.314</td><td>0.206</td><td>0.298</td><td>0.503</td><td>0.511</td></tr><tr><td rowspan="3">CoraFull</td><td>NMI</td><td>0.128±0.00</td><td>0.498±0.00</td><td>0.409±0.02</td><td>0.406±0.01</td><td>0.462±0.01</td><td>0.506±0.01</td><td>0.500±0.00</td></tr><tr><td>ACC</td><td>44.93±0.53</td><td>57.54±0.32</td><td>56.23±0.59</td><td>58.48±0.80</td><td>60.42±0.39</td><td>61.01±0.50</td><td>61.10±0.68</td></tr><tr><td>P-H</td><td>0.494</td><td>0.887</td><td>0.649</td><td>0.728</td><td>0.888</td><td>0.903</td><td>0.895</td></tr><tr><td rowspan="3">CS</td><td>NMI</td><td>0.658±0.01</td><td>0.767±0.01</td><td>0.749±0.01</td><td>0.635±0.03</td><td>0.747±0.01</td><td>0.772±0.01</td><td>0.771±0.01</td></tr><tr><td>ACC</td><td>88.58±0.27</td><td>92.75±0.12</td><td>92.68±0.09</td><td>89.56±1.01</td><td>90.91±0.51</td><td>93.26±0.16</td><td>93.35±0.09</td></tr><tr><td>P-H</td><td>0.845</td><td>0.882</td><td>0.886</td><td>0.786</td><td>0.883</td><td>0.895</td><td>0.890</td></tr><tr><td rowspan="3">Physics</td><td>NMI</td><td>0.692±0.00</td><td>0.704±0.00</td><td>0.674±0.00</td><td>0.420±0.05</td><td>0.670±0.00</td><td>0.725±0.00</td><td>0.726±0.00</td></tr><tr><td>ACC</td><td>93.60±0.07</td><td>95.07±0.06</td><td>95.05±0.10</td><td>91.69±1.02</td><td>94.03±0.15</td><td>95.57±0.02</td><td>95.13±0.36</td></tr><tr><td>P-H</td><td>0.911</td><td>0.913</td><td>0.905</td><td>0.821</td><td>0.906</td><td>0.921</td><td>0.923</td></tr><tr><td rowspan="3">Photo</td><td>NMI</td><td>0.327±0.00</td><td>0.509±0.01</td><td>0.439±0.04</td><td>0.293±0.08</td><td>0.376±0.03</td><td>0.560±0.04</td><td>0.515±0.03</td></tr><tr><td>ACC</td><td>90.33±0.22</td><td>91.75±0.25</td><td>91.13±0.35</td><td>91.97±0.32</td><td>92.08±0.37</td><td>92.04±0.89</td><td>92.71±0.32</td></tr><tr><td>P-H</td><td>0.434</td><td>0.602</td><td>0.428</td><td>0.327</td><td>0.401</td><td>0.791</td><td>0.616</td></tr><tr><td rowspan="3">ogbn-arxiv</td><td>NMI</td><td>0.305±0.01</td><td>0.410±0.01</td><td>0.379±0.01</td><td>0.314±0.01</td><td>0.319±0.01</td><td>0.424±0.00</td><td>0.417±0.00</td></tr><tr><td>ACC</td><td>66.68±0.34</td><td>67.90±0.10</td><td>67.82±0.20</td><td>67.63±0.13</td><td>67.95±0.56</td><td>68.31±0.05</td><td>69.13±0.04</td></tr><tr><td>P-H</td><td>0.441</td><td>0.660</td><td>0.482</td><td>0.326</td><td>0.390</td><td>0.830</td><td>0.780</td></tr><tr><td rowspan="2">Average Rank</td><td>NMI</td><td>6.3</td><td>3.5</td><td>4.1</td><td>6.5</td><td>4.6</td><td>1.3</td><td>1.5</td></tr><tr><td>ACC</td><td>6.8</td><td>3.9</td><td>4.9</td><td>5.4</td><td>3.9</td><td>1.8</td><td>1.4</td></tr></table>
|
| 165 |
+
|
| 166 |
+
To answer Q2, we compare AUTOSSL with representative unsupervised and supervised node representation learning baselines. Specifically, for node classification we include 4 unsupervised baselines, i.e., GAE (Kipf & Welling, 2016b), VGAE (Kipf & Welling, 2016b), ARVGA (Pan et al., 2018) and MVGRL, and 2 supervised baselines, i.e. GCN and GAT (Velickovi ˇ c et al., 2018). We also ´ provide the logistic regression performance on raw features and embeddings generated by a randomly initialized encoder, named as Raw-Feat and Random-Init, respectively. Note that the two supervised baselines, GCN and GAT, use label information for node representation learning in an end-to-end manner, while other baselines and AUTOSSL do not leverage label information to learn representations. The average performance and variances are reported in Table 2. From the table, we find that AUTOSSL outperforms unsupervised baselines in all datasets except Citeseer while the performance on Citeseer is still comparable to the state-of-the-art contrastive learning method MVGRL. When compared to supervised baselines, AUTOSSL-DS outperforms GCN and GAT in 4 out of 8 datasets, e.g., a $1 . 7 \%$ relative improvement over GAT on Computers. AUTOSSL-ES also outperforms GCN and GAT in 3/4 out of 8 datasets. In other words, our unsupervised representation learning AUTOSSL can achieve comparable performance with supervised representation learning baselines. In addition, we use the same unsupervised baselines for node clustering and report the results in Table 3. Both AUTOSSL-ES and AUTOSSL-DS show highly competitive clustering performance. For instance, AUTOSSL-ES achieves $2 2 . 2 \%$ and $2 7 . 5 \%$ relative improvement over the second best baseline on Physics and WikiCS; AUTOSSL-DS also achieves $2 2 . 2 \%$ and $1 9 . 8 \%$ relative improvement on these two datasets. These results further validate that composing SSL tasks appropriately can produce expressive and generalizable representations.
|
| 167 |
+
|
| 168 |
+
Table 2: Node classification accuracy $( \% )$ . The last two rows are supervised baselines. AUTOSSL consistently outperforms alternative self-supervised approaches, and frequently outperforms supervised ones. (Bold/Underline: best/runner-up among self-supervised approaches)
|
| 169 |
+
|
| 170 |
+
<table><tr><td>Model</td><td>WikiCs</td><td>Citeseer</td><td>Computers</td><td>CoraFull</td><td>Cs</td><td>Physics</td><td>Photo</td><td>ogbn-arxiv</td><td>Avg. Rank</td></tr><tr><td>Random-Init</td><td>75.07±0.15</td><td>64.06±2.28</td><td>74.42±0.29</td><td>45.07±0.38</td><td>28.57±0.90</td><td>53.33±0.52</td><td>87.01±0.39</td><td>67.55±0.27</td><td>6.0</td></tr><tr><td>Raw-Feat</td><td>72.06±0.03</td><td>61.50±0.00</td><td>74.15±0.48</td><td>37.17±0.30</td><td>87.12±0.42</td><td>92.81±0.24</td><td>79.03±0.37</td><td>51.07±0.00</td><td>7.0</td></tr><tr><td>GAE</td><td>74.85±0.24</td><td>64.76±1.35</td><td>80.25±0.42</td><td>57.85±0.29</td><td>92.35±0.09</td><td>94.66±0.10</td><td>91.51±0.39</td><td>52.57±0.04</td><td>4.1</td></tr><tr><td>VGAE</td><td>74.16±0.16</td><td>67.50±0.42</td><td>81.05±0.41</td><td>53.72±0.30</td><td>92.15±0.16</td><td>94.58±0.17</td><td>88.98±1.05</td><td>52.00±0.19</td><td>4.6</td></tr><tr><td>ARVGA</td><td>71.64±1.03</td><td>46.88±2.15</td><td>67.61±0.92</td><td>45.20±1.33</td><td>87.26±1.07</td><td>93.84±0.13</td><td>77.74±1.16</td><td>31.57±2.96</td><td>7.1</td></tr><tr><td>MvGRL</td><td>75.89±0.12</td><td>72.36±0.49</td><td>84.66±0.62</td><td>60.56±0.33</td><td>90.18±0.19</td><td>94.30±0.20</td><td>92.49±0.40</td><td>0OM</td><td>3.1</td></tr><tr><td>AUTOSSL-ES</td><td>76.80±0.13</td><td>72.14±0.41</td><td>87.26±0.64</td><td>61.01±0.50</td><td>93.26±0.16</td><td>95.57±0.02</td><td>92.04±0.89</td><td>68.31±0.05</td><td>1.9</td></tr><tr><td>AUTOSSL-DS</td><td>76.58±0.28</td><td>72.00±0.32</td><td>88.18±0.43</td><td>61.10±0.68</td><td>93.35±0.09</td><td>95.13±0.36</td><td>92.71±0.32</td><td>69.13±0.04</td><td>1.5</td></tr><tr><td>GCN</td><td>76.42±0.02</td><td>71.26±0.15</td><td>87.53±0.21</td><td>63.77±0.37</td><td>93.04±0.09</td><td>95.66±0.15</td><td>93.09±0.11</td><td>71.74±0.29</td><td>-</td></tr><tr><td>GAT</td><td>77.30±0.01</td><td>71.00±0.62</td><td>86.74±0.69</td><td>63.73±0.43</td><td>92.53±0.19</td><td>95.54±0.08</td><td>92.30±0.28</td><td>71.46±0.34</td><td>-</td></tr></table>
|
| 171 |
+
|
| 172 |
+
Table 3: Clustering performance (NMI). AUTOSSL embeddings routinely exhibit superior NMI to alternatives. (Bold: best; Underline: runner-up).
|
| 173 |
+
|
| 174 |
+
<table><tr><td>Model</td><td>Wikics</td><td>Citeseer</td><td>Computers</td><td>CoraFull</td><td>CS</td><td>Physics</td><td>Photo</td><td>ogbn-arxiv</td><td>Avg. Rank</td></tr><tr><td>Random-Init</td><td>0.107±0.02</td><td>0.354±0.03</td><td>0.155±0.01</td><td>0.318±0.01</td><td>0.716±0.02</td><td>0.551±0.01</td><td>0.246±0.04</td><td>0.306±0.01</td><td>6.4</td></tr><tr><td>Raw-Feat</td><td>0.182±0.00</td><td>0.316±0.00</td><td>0.166±0.00</td><td>0.215±0.00</td><td>0.642±0.00</td><td>0.489±0.00</td><td>0.282±0.00</td><td>0.150±0.01</td><td>7.1</td></tr><tr><td>GAE</td><td>0.243±0.02</td><td>0.313±0.02</td><td>0.441±0.00</td><td>0.485±0.00</td><td>0.731±0.01</td><td>0.545±0.06</td><td>0.616±0.01</td><td>0.325±0.01</td><td>4.3</td></tr><tr><td>VGAE</td><td>0.261±0.01</td><td>0.364±0.01</td><td>0.423±0.00</td><td>0.453±0.01</td><td>0.733±0.00</td><td>0.563±0.02</td><td>0.530±0.04</td><td>0.311±0.01</td><td>4.0</td></tr><tr><td>ARVGA</td><td>0.287±0.02</td><td>0.191±0.02</td><td>0.237±0.01</td><td>0.301±0.01</td><td>0.616±0.03</td><td>0.526±0.05</td><td>0.301±0.01</td><td>0.201±0.01</td><td>6.4</td></tr><tr><td>MvGRL</td><td>0.263±0.01</td><td>0.452±0.01</td><td>0.244±0.00</td><td>0.400±0.01</td><td>0.740±0.01</td><td>0.594±0.00</td><td>0.344±0.04</td><td>OOM</td><td>4.3</td></tr><tr><td>AUTOSSL-ES</td><td>0.366±0.01</td><td>0.449±0.01</td><td>0.447±0.01</td><td>0.506±0.01</td><td>0.772±0.01</td><td>0.725±0.00</td><td>0.560±0.04</td><td>0.424±0.00</td><td>1.6</td></tr><tr><td>AUTOSSL-DS</td><td>0.344±0.02</td><td>0.449±0.01</td><td>0.448±0.01</td><td>0.500±0.00</td><td>0.771±0.01</td><td>0.726±0.00</td><td>0.515±0.03</td><td>0.417±0.00</td><td>2.1</td></tr></table>
|
| 175 |
+
|
| 176 |
+
# 4.4 RELATION BETWEEN DOWNSTREAM PERFORMANCE AND PSEUDO-HOMOPHILY
|
| 177 |
+
|
| 178 |
+
In this subsection, we investigate the relation between downstream performance and pseudohomophily and correspondingly answer Q3. Specifically, we use the candidate task weights sampled in the AUTOSSL-ES searching trajectory, and illustrate their node clustering (NMI) and node classification performance (ACC) with respect to their pseudo-homophily. The results on Computers and WikiCS are shown in Figure 2 and results for other datasets are shown in Appendix E.1. We observe that the downstream performance tends to be better if the learned embeddings tend to have higher pseudo-homophily. We also can observe that clustering performance has a clear relation with pseudo-homophily for all datasets. Hence, the results empirically support our theoretical analysis in Section 3.1 that lower pseudo-homophily leads to a lower upper bound of mutual information with ground truth labels. While classification accuracy has a less evident pattern, we can still observe that higher accuracy tends to concentrate on the high pseudo-homophily regions for 5 out of 7 datasets.
|
| 179 |
+
|
| 180 |
+

|
| 181 |
+
Figure 2: Relationship between downstream performance and pseudo-homophily.
|
| 182 |
+
|
| 183 |
+

|
| 184 |
+
Figure 3: Visualization of Task Weights.
|
| 185 |
+
|
| 186 |
+

|
| 187 |
+
Figure 4: P-H change of AUTOSSL-ES
|
| 188 |
+
|
| 189 |
+
4.5 EVOLUTION OF SSL TASK WEIGHTS, PSEUDO-HOMOPHILY AND PERFORMANCE
|
| 190 |
+
|
| 191 |
+
To answer Q4, we visualize the final task weights searched by AUTOSSL-ES on all datasets through the heatmap in Figure 3a. From the figure, we make three observations. Obs. 1: The searched task weights vary significantly from dataset to dataset. For example, the weights for PAR and DGI are [0.198, 0.980] on Physics while they are [0.955, 0.066] on WikiCS. Obs. 2: In general, Par benefits co-purchase networks, i.e. Photo and Computers; DGI is crucial for citation/coauthorship networks, i.e. Physics, CS, Citeseer, and CoraFull. We conjecture that local structure information (the information that PAR captures) is essential for co-purchase networks while both local and global information (the information that DGI captures) are necessary in citation/coauthorship networks. Obs. 3: AUTOSSL-ES always gives very low weights to CLU, which indicates the pseudo-labels clustered from raw features are not good supervision on the selected datasets.
|
| 192 |
+
|
| 193 |
+
We also provide the evolution of task weights in AUTOSSL-DS for CoraFull dataset in Figure 3b. The weights of the 5 tasks eventually become stable: CLU and PAIRDIS are assigned with small values while PAIRSIM, DGI and CLU are assigned with large values. Thus, both AUTOSSL-ES and AUTOSSL-DS agree that PAIRDIS and PAR are less important for CoraFull.
|
| 194 |
+
|
| 195 |
+
We further investigate how pseudo-homophily changes over iterations. For AUTOSSL-ES, we illustrate the mean value of resulted pseudo-homophily in each iteration (round) in Figure 4. We only show the results on CoraFull and Citeseer while similar patterns are exhibited in other datasets. It is clear that AUTOSSL-ES can effectively increase the pseudo-homophily and thus search for better self-supervised task weights. The results for AUTOSSL-DS are deferred to Appendix E.2 due to the page limit.
|
| 196 |
+
|
| 197 |
+
# 5 CONCLUSION
|
| 198 |
+
|
| 199 |
+
Graph self-supervised learning has achieved great success in learning expressive node/graph representations. In this work, however, we find that SSL tasks designed for graphs perform differently on different datasets and downstream tasks. Thus, it is worth composing multiple SSL tasks to jointly encode multiple sources of information and produce more generalizable representations. However, without access to labeled data, it poses a great challenge in measuring the quality of the combinations of SSL tasks. To address this issue, we take advantage of graph homophily and propose pseudo-homophily to measure the quality of combinations of SSL tasks. We then theoretically show that maximizing pseudo-homophily can help maximize the upper bound of mutual information between the pseudo-labels and ground truth labels. Based on the pseudo-homophily measure, we develop two automated frameworks AUTOSSL-ES and AUTOSSL-DS to search the task weights efficiently. Extensive experiments have demonstrated that AUTOSSL is able to produce more generalize representations by combining various SSL tasks.
|
| 200 |
+
|
| 201 |
+
# ACKNOLWEDGEMENT
|
| 202 |
+
|
| 203 |
+
Wei Jin and Jiliang Tang are supported by the National Science Foundation (NSF) under grant numbers IIS1714741, CNS1815636, IIS1845081, IIS1907704, IIS1928278, IIS1955285, IOS2107215, and IOS2035472, the Army Research Office (ARO) under grant number W911NF-21-1-0198, the Home Depot, Cisco Systems Inc. and SNAP Inc.
|
| 204 |
+
|
| 205 |
+
# ETHICS STATEMENT
|
| 206 |
+
|
| 207 |
+
To the best of our knowledge, there are no ethical issues with this paper.
|
| 208 |
+
|
| 209 |
+
# REPRODUCIBILITY STATEMENT
|
| 210 |
+
|
| 211 |
+
To ensure reproducibility of our experiments, we provide our source code at https://github.
|
| 212 |
+
com/ChandlerBang/AutoSSL. The hyper-parameters are described in details in the appendix.
|
| 213 |
+
We also provide a pseudo-code implementation of our framework in the appendix.
|
| 214 |
+
|
| 215 |
+
# REFERENCES
|
| 216 |
+
|
| 217 |
+
Peter W Battaglia, Jessica B Hamrick, Victor Bapst, Alvaro Sanchez-Gonzalez, Vinicius Zambaldi, Mateusz Malinowski, Andrea Tacchetti, David Raposo, Adam Santoro, Ryan Faulkner, et al. Relational inductive biases, deep learning, and graph networks. arXiv preprint arXiv:1806.01261, 2018.
|
| 218 |
+
|
| 219 |
+
Emily M Bender, Timnit Gebru, Angelina McMillan-Major, and Shmargaret Shmitchell. On the dangers of stochastic parrots: Can language models be too big? In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, pp. 610–623, 2021.
|
| 220 |
+
|
| 221 |
+
Christopher M Bishop. Pattern recognition and machine learning. springer, 2006.
|
| 222 |
+
|
| 223 |
+
Mathilde Caron, Piotr Bojanowski, Armand Joulin, and Matthijs Douze. Deep clustering for unsupervised learning of visual features. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 132–149, 2018.
|
| 224 |
+
|
| 225 |
+
Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pp. 1597–1607. PMLR, 2020.
|
| 226 |
+
|
| 227 |
+
Enyan Dai and Suhang Wang. Say no to the discrimination: Learning fair graph neural networks with limited sensitive attribute information. In Proceedings of the 14th ACM International Conference on Web Search and Data Mining, pp. 680–688, 2021.
|
| 228 |
+
|
| 229 |
+
Carl Doersch and Andrew Zisserman. Multi-task self-supervised visual learning. In Proceedings of the IEEE International Conference on Computer Vision, pp. 2051–2060, 2017.
|
| 230 |
+
|
| 231 |
+
Carl Doersch, Abhinav Gupta, and Alexei A Efros. Unsupervised visual representation learning by context prediction. In ICCV, 2015.
|
| 232 |
+
|
| 233 |
+
David K Duvenaud, Dougal Maclaurin, Jorge Aguilera-Iparraguirre, Rafael Gomez-Bombarelli, ´ Timothy Hirzel, Alan Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs ´ for learning molecular fingerprints. In Advances in neural information processing systems, 2015.
|
| 234 |
+
|
| 235 |
+
Matthias Fey and Jan Eric Lenssen. Fast graph representation learning with pytorch geometric. arXiv preprint arXiv:1903.02428, 2019.
|
| 236 |
+
|
| 237 |
+
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning, pp. 1126–1135. PMLR, 2017.
|
| 238 |
+
|
| 239 |
+
Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In ICML, 2017.
|
| 240 |
+
|
| 241 |
+
Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In Advances in neural information processing systems, 2017.
|
| 242 |
+
|
| 243 |
+
Xueting Han, Zhenhuan Huang, Bang An, and Jing Bai. Adaptive transfer learning on graph neural networks. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery amp; Data Mining, KDD ’21, pp. 565–574. Association for Computing Machinery, 2021.
|
| 244 |
+
|
| 245 |
+
Nikolaus Hansen, Sibylle D Muller, and Petros Koumoutsakos. Reducing the time complexity of ¨ the derandomized evolution strategy with covariance matrix adaptation (cma-es). Evolutionary computation, 11(1):1–18, 2003.
|
| 246 |
+
|
| 247 |
+
Kaveh Hassani and Amir Hosein Khasahmadi. Contrastive multi-view representation learning on graphs. In International Conference on Machine Learning, 2020.
|
| 248 |
+
|
| 249 |
+
Weihua Hu, Bowen Liu, Joseph Gomes, Marinka Zitnik, Percy Liang, Vijay Pande, and Jure Leskovec. Strategies for pre-training graph neural networks. In International Conference on Learning Representations, 2019.
|
| 250 |
+
|
| 251 |
+
Weihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong, Hongyu Ren, Bowen Liu, Michele Catasta, and Jure Leskovec. Open graph benchmark: Datasets for machine learning on graphs. arXiv preprint arXiv:2005.00687, 2020.
|
| 252 |
+
|
| 253 |
+
Wei Jin, Tyler Derr, Haochen Liu, Yiqi Wang, Suhang Wang, Zitao Liu, and Jiliang Tang. Self-supervised learning on graphs: Deep insights and new direction. arXiv preprint arXiv:2006.10141, 2020.
|
| 254 |
+
|
| 255 |
+
Wei Jin, Tyler Derr, Yiqi Wang, Yao Ma, Zitao Liu, and Jiliang Tang. Node similarity preserving graph convolutional networks. In Proceedings of the 14th ACM International Conference on Web Search and Data Mining. ACM, 2021.
|
| 256 |
+
|
| 257 |
+
George Karypis and Vipin Kumar. A fast and high quality multilevel scheme for partitioning irregular graphs. SIAM Journal on scientific Computing, 1998.
|
| 258 |
+
|
| 259 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 260 |
+
|
| 261 |
+
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016a.
|
| 262 |
+
|
| 263 |
+
Thomas N Kipf and Max Welling. Variational graph auto-encoders. arXiv preprint arXiv:1611.07308, 2016b.
|
| 264 |
+
|
| 265 |
+
Alexander Kolesnikov, Xiaohua Zhai, and Lucas Beyer. Revisiting self-supervised visual representation learning. In In CVPR, pp. 1920–1929, 2019.
|
| 266 |
+
|
| 267 |
+
Chuming Li, Xin Yuan, Chen Lin, Minghao Guo, Wei Wu, Junjie Yan, and Wanli Ouyang. Am-lfs: Automl for loss function search. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 8410–8419, 2019.
|
| 268 |
+
|
| 269 |
+
Hanxiao Liu, Karen Simonyan, and Yiming Yang. Darts: Differentiable architecture search. arXiv preprint arXiv:1806.09055, 2018.
|
| 270 |
+
|
| 271 |
+
Meng Liu, Hongyang Gao, and Shuiwang Ji. Towards deeper graph neural networks. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining. ACM, 2020.
|
| 272 |
+
|
| 273 |
+
Xiaorui Liu, Wei Jin, Yao Ma, Yaxin Li, Hua Liu, Yiqi Wang, Ming Yan, and Jiliang Tang. Elastic graph neural networks. In International Conference on Machine Learning, 2021.
|
| 274 |
+
|
| 275 |
+
Ilya Loshchilov and Frank Hutter. Cma-es for hyperparameter optimization of deep neural networks. arXiv preprint arXiv:1604.07269, 2016.
|
| 276 |
+
|
| 277 |
+
Miller McPherson, Lynn Smith-Lovin, and James M Cook. Birds of a feather: Homophily in social networks. Annual review of sociology, 27(1):415–444, 2001.
|
| 278 |
+
|
| 279 |
+
Peter Mernyei and C ´ at˘ alina Cangea. Wiki-cs: A wikipedia-based benchmark for graph neural net- ˘ works. arXiv preprint arXiv:2007.02901, 2020.
|
| 280 |
+
|
| 281 |
+
Mark Newman. Networks. Oxford university press, 2018.
|
| 282 |
+
|
| 283 |
+
Shirui Pan, Ruiqi Hu, Guodong Long, Jing Jiang, Lina Yao, and Chengqi Zhang. Adversarially regularized graph autoencoder for graph embedding. In Proceedings of the 27th International Joint Conference on Artificial Intelligence, IJCAI’18, pp. 2609–2615. AAAI Press, 2018.
|
| 284 |
+
|
| 285 |
+
Hongbin Pei, Bingzhe Wei, Kevin Chen-Chuan Chang, Yu Lei, and Bo Yang. Geom-gcn: Geometric graph convolutional networks. arXiv preprint arXiv:2002.05287, 2020.
|
| 286 |
+
|
| 287 |
+
Zhen Peng, Yixiang Dong, Minnan Luo, Xiao-Ming Wu, and Qinghua Zheng. Self-supervised graph representation learning via global context prediction. arXiv preprint arXiv:2003.01604, 2020.
|
| 288 |
+
|
| 289 |
+
AJ Piergiovanni, Anelia Angelova, and Michael S Ryoo. Evolving losses for unsupervised video representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 133–142, 2020.
|
| 290 |
+
|
| 291 |
+
Jiezhong Qiu, Qibin Chen, Yuxiao Dong, Jing Zhang, Hongxia Yang, Ming Ding, Kuansan Wang, and Jie Tang. Gcc: Graph contrastive coding for graph neural network pre-training. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 1150–1160, 2020.
|
| 292 |
+
|
| 293 |
+
Zhongzheng Ren and Yong Jae Lee. Cross-domain self-supervised multi-task feature learning using synthetic imagery. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 762–771, 2018.
|
| 294 |
+
|
| 295 |
+
Claudia Veronica Roberts et al. Quantifying the extent to which popular pre-trained convolutional neural networks implicitly learn high-level protected attributes. PhD thesis, Princeton University, 2018.
|
| 296 |
+
|
| 297 |
+
Aravind Sankar, Yozen Liu, Jun Yu, and Neil Shah. Graph neural networks for friend ranking in large-scale social platforms. In Proceedings of the Web Conference 2021, pp. 2535–2546, 2021.
|
| 298 |
+
|
| 299 |
+
Oleksandr Shchur, Maximilian Mumme, Aleksandar Bojchevski, and Stephan Gunnemann. Pitfalls ¨ of graph neural network evaluation. arXiv preprint arXiv:1811.05868, 2018.
|
| 300 |
+
|
| 301 |
+
Shubhranshu Shekhar, Neil Shah, and Leman Akoglu. Fairod: Fairness-aware outlier detection. arXiv preprint arXiv:2012.03063, 2020.
|
| 302 |
+
|
| 303 |
+
Susheel Suresh, Vinith Budde, Jennifer Neville, Pan Li, and Jianzhu Ma. Breaking the limit of graph neural networks by improving the assortativity of graphs with local mixing patterns. arXiv preprint arXiv:2106.06586, 2021.
|
| 304 |
+
|
| 305 |
+
Xianfeng Tang, Yozen Liu, Neil Shah, Xiaolin Shi, Prasenjit Mitra, and Suhang Wang. Knowing your fate: Friendship, action and temporal explanations for user engagement prediction on social apps. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 2269–2279, 2020a.
|
| 306 |
+
|
| 307 |
+
Xianfeng Tang, Huaxiu Yao, Yiwei Sun, Yiqi Wang, Jiliang Tang, Charu Aggarwal, Prasenjit Mitra, and Suhang Wang. Investigating and mitigating degree-related biases in graph convoltuional networks. In Proceedings of the 29th ACM International Conference on Information & Knowledge Management, pp. 1435–1444, 2020b.
|
| 308 |
+
|
| 309 |
+
Petar Velickovi ˇ c, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua ´ Bengio. Graph attention networks. In ICLR, 2018.
|
| 310 |
+
|
| 311 |
+
Petar Velickovi ˇ c, William Fedus, William L. Hamilton, Pietro Li ´ o, Yoshua Bengio, and R Devon \` Hjelm. Deep Graph Infomax. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=rklz9iAcKQ.
|
| 312 |
+
|
| 313 |
+
Xiaobo Wang, Shuo Wang, Cheng Chi, Shifeng Zhang, and Tao Mei. Loss function search for face recognition. In International Conference on Machine Learning, pp. 10029–10038. PMLR, 2020.
|
| 314 |
+
|
| 315 |
+
Yu Wang, Wei Jin, and Tyler Derr. Graph neural networks: Self-supervised learning. In Graph Neural Networks: Foundations, Frontiers, and Applications, pp. 391–420. Springer, 2022.
|
| 316 |
+
|
| 317 |
+
Shu Wu, Yuyuan Tang, Yanqiao Zhu, Liang Wang, Xing Xie, and Tieniu Tan. Session-based recommendation with graph neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, pp. 346–353, 2019a.
|
| 318 |
+
|
| 319 |
+
Zonghan Wu, Shirui Pan, Fengwen Chen, Guodong Long, Chengqi Zhang, and Philip S Yu. A comprehensive survey on graph neural networks. arXiv preprint arXiv:1901.00596, 2019b.
|
| 320 |
+
|
| 321 |
+
Yaochen Xie, Zhao Xu, Jingtun Zhang, Zhengyang Wang, and Shuiwang Ji. Self-supervised learning of graph neural networks: A unified review. arXiv preprint arXiv:2102.10757, 2021.
|
| 322 |
+
|
| 323 |
+
Haowen Xu, Hao Zhang, Zhiting Hu, Xiaodan Liang, Ruslan Salakhutdinov, and Eric Xing. Autoloss: Learning discrete schedules for alternate optimization. arXiv preprint arXiv:1810.02442, 2018.
|
| 324 |
+
|
| 325 |
+
Zhilin Yang, William Cohen, and Ruslan Salakhudinov. Revisiting semi-supervised learning with graph embeddings. In International conference on machine learning, pp. 40–48. PMLR, 2016.
|
| 326 |
+
|
| 327 |
+
Quanming Yao, Mengshuo Wang, Yuqiang Chen, Wenyuan Dai, Yu-Feng Li, Wei-Wei Tu, Qiang Yang, and Yang Yu. Taking human out of learning applications: A survey on automated machine learning. arXiv preprint arXiv:1810.13306, 2018.
|
| 328 |
+
|
| 329 |
+
Rex Ying, Ruining He, Kaifeng Chen, Pong Eksombatchai, William L Hamilton, and Jure Leskovec. Graph convolutional neural networks for web-scale recommender systems. In KDD. ACM, 2018.
|
| 330 |
+
|
| 331 |
+
Yuning You, Tianlong Chen, Zhangyang Wang, and Yang Shen. When does self-supervision help graph convolutional networks? ICML, 2020.
|
| 332 |
+
|
| 333 |
+
Yuning You, Tianlong Chen, Yang Shen, and Zhangyang Wang. Graph contrastive learning automated. Proceedings of International Conference on Machine Learning, 2021.
|
| 334 |
+
|
| 335 |
+
Amir R Zamir, Alexander Sax, William Shen, Leonidas J Guibas, Jitendra Malik, and Silvio Savarese. Taskonomy: Disentangling task transfer learning. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 3712–3722, 2018.
|
| 336 |
+
|
| 337 |
+
Jieyu Zhao, Tianlu Wang, Mark Yatskar, Ryan Cotterell, Vicente Ordonez, and Kai-Wei Chang. Gender bias in contextualized word embeddings. arXiv preprint arXiv:1904.03310, 2019.
|
| 338 |
+
|
| 339 |
+
Xiangyu Zhao, Haochen Liu, Wenqi Fan, Hui Liu, Jiliang Tang, and Chong Wang. Autoloss: Automated loss function search in recommendations. In Proceedings of the 27th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, 2021a.
|
| 340 |
+
|
| 341 |
+
Yue Zhao, Ryan Rossi, and Leman Akoglu. Automatic unsupervised outlier model selection. Advances in Neural Information Processing Systems, 34, 2021b.
|
| 342 |
+
|
| 343 |
+
Jiong Zhu, Yujun Yan, Lingxiao Zhao, Mark Heimann, Leman Akoglu, and Danai Koutra. Beyond homophily in graph neural networks: Current limitations and effective designs. Advances in Neural Information Processing Systems, 33, 2020a.
|
| 344 |
+
|
| 345 |
+
Yanqiao Zhu, Yichen Xu, Feng Yu, Qiang Liu, Shu Wu, and Liang Wang. Graph contrastive learning with adaptive augmentation. arXiv preprint arXiv:2010.14945, 2020b.
|
| 346 |
+
|
| 347 |
+
Daniel Zugner and Stephan G ¨ unnemann. Adversarial attacks on graph neural networks via meta ¨ learning. arXiv preprint arXiv:1902.08412, 2019.
|
| 348 |
+
|
| 349 |
+
# A EXPERIMENTAL SETUP
|
| 350 |
+
|
| 351 |
+
Dataset Statistics. We evaluate the proposed framework on seven real-world datasets. The dataset statistics are shown in 4. All datasets can be loaded from PyTorch Geometric (Fey & Lenssen, 2019). When we evaluate the node classification performance, we need to use the training and test data. For WikiCS (Mernyei & Cangea, 2020), ogbn-arxiv (Hu et al., 2020) and Citeseer (Yang et al., 2016), we use the public data splits provided by the authors. For other datasets, we split the nodes into $1 0 \% / 1 0 \% / 8 0 \%$ for training/validation/test.
|
| 352 |
+
|
| 353 |
+
Table 4: Dataset statistics.
|
| 354 |
+
|
| 355 |
+
<table><tr><td>Dataset</td><td>Network Type</td><td>#Nodes</td><td>#Edges</td><td>#Classes</td><td>#Features</td><td>Homophily</td></tr><tr><td>WikiCS</td><td>Reference network</td><td>11,701</td><td>216,123</td><td>10</td><td>300</td><td>0.70</td></tr><tr><td>CS</td><td>Co-authorship network</td><td>18,333</td><td>81,894</td><td>15</td><td>6,805</td><td>0.81</td></tr><tr><td>Physics</td><td>Co-authorship network</td><td>34,493</td><td>247,962</td><td>5</td><td>8,415</td><td>0.93</td></tr><tr><td>Computers</td><td>Co-purchase network</td><td>13,381</td><td>245,778</td><td>10</td><td>767</td><td>0.78</td></tr><tr><td>Photo</td><td>Co-purchase network</td><td>7,487</td><td>119,043</td><td>8</td><td>745</td><td>0.83</td></tr><tr><td>CoraFull</td><td>Citation network</td><td>19,793</td><td>65,311</td><td>70</td><td>8,710</td><td>0.57</td></tr><tr><td>Citeseer</td><td>Citation network</td><td>3,327</td><td>4,732</td><td>6</td><td>3,703</td><td>0.74</td></tr><tr><td>ogbn-arxiv</td><td>Citation network</td><td>169,343</td><td>1,166,243</td><td>40</td><td>128</td><td>0.78</td></tr></table>
|
| 356 |
+
|
| 357 |
+
Hyper-parameter Settings. When calculating pseudo-homophily, we set the number of clusters to 10 for ogbn-arxiv and Computers, and 5 for other datasets. A small number of clusters can be more efficient but could be less stable. Following DGI (Velickovi ˇ c et al., 2019) and M ´ VGRL (Hassani & Khasahmadi, 2020), we we use a simple one-layer GCN (Kipf & Welling, 2016a) as our encoder. We set the size of hidden dimensions to 512, weight decay to 0, dropout rate to 0. For individual SSL methods and AUTOSSL-ES, we set learning rate to 0.001, use Adam optimizer (Kingma & Ba, 2014), train the models with 1000 epochs and adopt early stopping strategy. For AUTOSSLDS, we train the models with 1000 epochs and choose the model checkpoint that achieves the highest pseudo-homophily. We use Adam optimizer for both inner and outer optimization. The learning rate for outer optimization is set to 0.05. For AUTOSSL-ES, we use a population size of 8 for each round. Due to limited computational resources, we perform 80 rounds for Citeseer, 40 rounds for CS, Computers, CoraFull, Photo, Physics, Computers and WikiCS. We repeat the experiments on 5 different random seeds and report the mean values and variances for downstream performance. To fit DGI into GPU memory on larger datasets and accelerate its training, instead of using all the nodes we sample 2000 positive samples and 2000 negative samples for DGI on all datasets except Citeseer.
|
| 358 |
+
|
| 359 |
+
Hardware and Software Configurations. We perform experiments on one NVIDIA Tesla K80 GPU and one NVIDIA Tesla V100 GPU. Additionally, we use eight CPUs, with the model name as Intel(R) Xeon(R) Platinum 8260 CPU $\textcircled { a } 2 . 4 0 \mathrm { G H z }$ . The operating system we use is CentOS Linux 7 (Core).
|
| 360 |
+
|
| 361 |
+
# B PROOF
|
| 362 |
+
|
| 363 |
+
Theorem 1. Suppose that we are given with a graph $\mathcal { G } = \{ \nu , \varepsilon \}$ , a pseudo label vector $A \in$ $\{ 0 , 1 \} ^ { N }$ and a ground truth label vector $B \in \{ \breve { 0 } , \bar { 1 } \bar \} ^ { N }$ defined on the node set. We denote the homophily of $A$ and $B$ over $\mathcal { G }$ as $h _ { A }$ and $h _ { B }$ , respectively. If the classes in $A$ and $B$ are balanced and $h _ { A } \mathrm { ~ } / h _ { B }$ , the following results hold: $( l )$ the mutual information between $A$ and $B$ , i.e., $M I ( A , B )$ , has an upper bound $\mathcal { U } _ { A , B }$ , where $\begin{array} { r } { \mathcal { U } _ { A , B } = \frac { 1 } { N } \left[ 2 \Delta \log ( \frac { \check { \mathfrak { q } } } { N } \Delta ) + 2 ( \frac { N } { 2 } - \Delta ) \log \left( \frac { 4 } { N } ( \frac { N } { 2 } - \Delta ) \right) \right] } \end{array}$ with $\begin{array} { r } { \Delta = \frac { ( h _ { B } - h _ { A } ) | \mathcal { E } | } { 2 d _ { m a x } } } \end{array}$ and $d _ { m a x }$ denoting the largest node degree in the graph; (2) if $h _ { A } < h _ { A ^ { \prime } } < h _ { B }$ , we have $\mathcal { U } _ { A , B } < \mathcal { U } _ { A ^ { \prime } , B }$ .
|
| 364 |
+
|
| 365 |
+
Proof. (1) We start with the proof of the first result. The mutual information between two random variables $X$ and $Y$ is expressed as
|
| 366 |
+
|
| 367 |
+
$$
|
| 368 |
+
M I ( X , Y ) = \sum _ { y \in \mathcal { Y } } \sum _ { x \in \mathcal { X } } p _ { ( A , B ) } ( x , y ) \log \left( \frac { p _ { ( X , Y ) } ( x , y ) } { p _ { X } ( x ) p _ { Y } ( y ) } \right) .
|
| 369 |
+
$$
|
| 370 |
+
|
| 371 |
+
Let $\mathbf { \mathcal { A } } _ { i }$ and $B _ { i }$ denote the set of nodes in the $i$ -th class in $A$ and $B$ , respectively. Following the definition in Eq. (11), the mutual information between $A$ and $B$ can be formulated as,
|
| 372 |
+
|
| 373 |
+
$$
|
| 374 |
+
M I ( A , B ) = \sum _ { i = 0 } ^ { n _ { A } - 1 } \sum _ { j = 0 } ^ { n _ { B } - 1 } \frac { | A _ { i } \cap \mathcal { B } _ { j } | } { N } \log \frac { N | \mathcal { A } _ { i } \cap \mathcal { B } _ { j } | } { | \mathcal { A } _ { i } | | \mathcal { B } _ { j } | } ,
|
| 375 |
+
$$
|
| 376 |
+
|
| 377 |
+
where $n _ { A } , n _ { B }$ denote the number of classes in $A$ and $B$ . Since here we only consider 2 classes in $A$ and $B$ , we have
|
| 378 |
+
|
| 379 |
+
$$
|
| 380 |
+
\begin{array} { r l } & { \displaystyle M I ( A , B ) = \frac { \left| \mathcal A _ { 0 } \cap \mathcal B _ { 0 } \right| } { N } \log \frac { N \left| \mathcal A _ { 0 } \cap \mathcal B _ { 0 } \right| } { \left| \mathcal A _ { 0 } \right| \left| \mathcal B _ { 0 } \right| } + \frac { \left| \mathcal A _ { 0 } \cap \mathcal B _ { 1 } \right| } { N } \log \frac { N \left| \mathcal A _ { 0 } \cap \mathcal B _ { 1 } \right| } { \left| \mathcal A _ { 0 } \right| \left| \mathcal B _ { 1 } \right| } } \\ & { \quad \quad \quad \quad + \frac { \left| \mathcal A _ { 1 } \cap \mathcal B _ { 0 } \right| } { N } \log \frac { N \left| \mathcal A _ { 1 } \cap \mathcal B _ { 0 } \right| } { \left| \mathcal A _ { 1 } \right| \left| \mathcal B _ { 0 } \right| } + \frac { \left| \mathcal A _ { 1 } \cap \mathcal B _ { 1 } \right| } { N } \log \frac { N \left| \mathcal A _ { 1 } \cap \mathcal B _ { 1 } \right| } { \left| \mathcal A _ { 1 } \right| \left| \mathcal B _ { 1 } \right| } . } \end{array}
|
| 381 |
+
$$
|
| 382 |
+
|
| 383 |
+
Let $| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 0 } | = x , | \mathcal { A } _ { 0 } | = a$ and $| B _ { 0 } | = b$ . We then have
|
| 384 |
+
|
| 385 |
+
$$
|
| 386 |
+
\left\{ \begin{array} { l l } { \left| \mathcal { A } _ { 0 } \right| + \left| \mathcal { A } _ { 1 } \right| = N \Rightarrow \left| \mathcal { A } _ { 1 } \right| = N - a , } \\ { \left| \mathcal { B } _ { 0 } \right| + \left| \mathcal { B } _ { 1 } \right| = N \Rightarrow \left| \mathcal { B } _ { 1 } \right| = N - b , } \\ { \left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 0 } \right| + \left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 1 } \right| = \left| \mathcal { A } _ { 0 } \right| \Rightarrow \left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 1 } \right| = a - x , } \\ { \left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 0 } \right| + \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 0 } \right| = \left| \mathcal { B } _ { 0 } \right| \Rightarrow \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 0 } \right| = b - x , } \\ { \left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 1 } \right| + \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 1 } \right| = \left| \mathcal { B } _ { 1 } \right| \Rightarrow \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 1 } \right| = N - b - a + x . } \end{array} \right.
|
| 387 |
+
$$
|
| 388 |
+
|
| 389 |
+
With the equations above, we rewrite $M I ( A , B )$ as follows,
|
| 390 |
+
|
| 391 |
+
$$
|
| 392 |
+
\begin{array} { c } { { M I ( A , B ) = \displaystyle \frac { 1 } { N } [ x \log \displaystyle \frac { N x } { a b } + ( a - x ) \log \displaystyle \frac { N ( a - x ) } { a ( N - b ) } } } \\ { { + ( b - x ) \log \displaystyle \frac { N ( b - x ) } { ( N - a ) b } + ( N - b - a + x ) \log \displaystyle \frac { N ( N - b - a + x ) } { ( N - a ) ( N - b ) } ] . } } \end{array}
|
| 393 |
+
$$
|
| 394 |
+
|
| 395 |
+
Then we rewrite result (1) in the theorem as an optimization problem,
|
| 396 |
+
|
| 397 |
+
$$
|
| 398 |
+
\operatorname* { m a x } f ( x ) = M I ( A , B )
|
| 399 |
+
$$
|
| 400 |
+
|
| 401 |
+
with constraints,
|
| 402 |
+
|
| 403 |
+
$$
|
| 404 |
+
\left\{ \begin{array} { l l } { 0 \leq | A _ { 0 } \cap B _ { 0 } | \leq | A _ { 0 } | \Rightarrow 0 \leq x \leq a , } \\ { 0 \leq | A _ { 0 } \cap B _ { 0 } | \leq | B _ { 0 } | \Rightarrow 0 \leq x \leq b , } \\ { | A _ { 1 } \cap B _ { 1 } | \geq 0 \Rightarrow x \geq a + b - N , } \\ { | A _ { 0 } \cap B _ { 0 } | + | A _ { 1 } \cap B _ { 1 } | \leq N \Rightarrow x \leq \frac { a + b } { 2 } , } \\ { | A _ { 0 } \cap B _ { 1 } | + | A _ { 1 } \cap B _ { 0 } | \leq N \Rightarrow x \geq \frac { a + b - N } { 2 } , } \end{array} \right.
|
| 405 |
+
$$
|
| 406 |
+
|
| 407 |
+
Note that the equality of $\begin{array} { r } { \left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 0 } \right| + \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 1 } \right| \leq N } \end{array}$ holds when $A$ and $B$ are the same. However, $A$ and $B$ have different homophily, which indicates $\left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 0 } \right| + \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 1 } \right|$ cannot reach $N$ (the same for $\left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 1 } \right| + \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 0 } \right| )$ . Let $\mathcal { E } _ { A } , \mathcal { E } _ { B }$ denote the inter-class edges for $A$ and $B$ , respectively. Thus, $\begin{array} { r } { h _ { A } = 1 - \frac { | { \mathcal E } _ { A } | } { | { \mathcal E } | } } \end{array}$ and $\begin{array} { r } { h _ { B } = 1 - \frac { | { \mathcal E } _ { B } | } { | { \mathcal E } | } } \end{array}$ |EB ||E| . Since hA < hB , we have |EA| > |EB |. This indicates that there are at least $\left. \mathcal { E } _ { A } \right. - \left. \mathcal { E } _ { B } \right.$ edges in $A$ connecting nodes that belong to the same ground truth class, as shown in Figure 5.
|
| 408 |
+
|
| 409 |
+

|
| 410 |
+
Figure 5: Illustration for $\left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 0 } \right| + \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 1 } \right|$ . The two dashed rectangles divide the nodes into $\mathcal { A } _ { 0 }$ and $\mathcal { A } _ { 1 }$ ; red and blue nodes denote nodes in $B _ { 0 }$ and $\boldsymbol { B } _ { 1 }$ , respectively.
|
| 411 |
+
|
| 412 |
+
Let $d _ { \mathrm { m a x } }$ denote the maximum degree in the graph and we know that at least $\frac { | \mathcal { E } _ { A } | - | \mathcal { E } _ { B } | } { d _ { \operatorname* { m a x } } }$ nodes are “misplaced” in $A$ , e.g., in Figure 5 the red node in $\boldsymbol { \mathcal { A } } _ { 1 }$ should be placed in $A _ { 0 }$ to achieve $| { \mathcal { A } } _ { 0 } \cap B _ { 0 } | +$ |A1 ∩ B1| = N . Let ∆ = |EA|−|EB| = $\begin{array} { r } { \Delta = \frac { | \mathcal { E } _ { A } | - | \mathcal { E } _ { B } | } { 2 d _ { \operatorname* { m a x } } } = \frac { ( h _ { B } - h _ { A } ) | \mathcal { E } | } { 2 d _ { \operatorname* { m a x } } } } \end{array}$ (hB−hA)|E| , and we have |A0 ∩ B0| + |A1 ∩ B1| ≤ N − 2∆ and $\begin{array} { r } { \left| \mathcal { A } _ { 0 } \cap \mathcal { B } _ { 1 } \right| + \left| \mathcal { A } _ { 1 } \cap \mathcal { B } _ { 0 } \right| \le \overline { { N } } - 2 \Delta } \end{array}$ .
|
| 413 |
+
|
| 414 |
+
With the new constraints, we rewrite the optimization problem as
|
| 415 |
+
|
| 416 |
+
$$
|
| 417 |
+
\operatorname* { m a x } f ( x ) = M I ( A , B ) \quad { \mathrm { s . t . ~ } } { \left\{ \begin{array} { l l } { 0 \leq x \leq a , } \\ { x \leq b , } \\ { x \geq a + b - N , } \\ { x \leq { \frac { a + b - 2 \Delta } { 2 } } , } \\ { x \geq { \frac { a + b - ( N - 2 \Delta ) } { 2 } } , } \end{array} \right. }
|
| 418 |
+
$$
|
| 419 |
+
|
| 420 |
+
Further, the derivative of $f ( x )$ is expressed as follows,
|
| 421 |
+
|
| 422 |
+
$$
|
| 423 |
+
f ^ { \prime } ( x ) = \frac { 1 } { N } \log \frac { x ( N - b - a + x ) } { ( a - x ) ( b - x ) } .
|
| 424 |
+
$$
|
| 425 |
+
|
| 426 |
+
Let $f ^ { \prime } ( x ) \ > \ 0$ , we have $\begin{array} { l l l } { x } & { > } & { { \frac { a b } { N } } } \end{array}$ ; let $f ^ { \prime } ( x ) \ < \ 0$ , we have $\begin{array} { l l l } { x } & { < } & { { \frac { a b } { N } } } \end{array}$ . Thus, $f ( x )$ is g at . $\begin{array} { r } { [ \operatorname* { m a x } ( 0 , a + b - N , \frac { a + b - ( N - 2 \Delta ) } { 2 } ) , \frac { a b } { N } ] } \end{array}$ and monotonically increasing $\begin{array} { r } { [ \frac { a b } { N } , \operatorname* { m i n } ( a , b , \frac { a + b - 2 \Delta } { 2 } ) ] } \end{array}$
|
| 427 |
+
|
| 428 |
+
Note that in the theorem we assume the pseudo-labels and ground truth classes are balanced, i.e., $\begin{array} { r } { a = b = \frac { N } { 2 } } \end{array}$ . Then $M I ( A , B )$ becomes,
|
| 429 |
+
|
| 430 |
+
$$
|
| 431 |
+
M I ( A , B ) = f ( x ) = \frac { 1 } { N } \left[ 2 x \log \frac { 4 } { N } x + 2 ( \frac { N } { 2 } - x ) \log \left( \frac { 4 } { N } ( \frac { N } { 2 } - x ) \right) \right] .
|
| 432 |
+
$$
|
| 433 |
+
|
| 434 |
+
Hence, $f ( x )$ is monotonically decreasing at $[ \Delta , \frac { N } { 4 } ]$ and monotonically increasing $\begin{array} { r } { [ \frac { N } { 4 } , \frac { N } { 2 } - \Delta ] } \end{array}$ . So the maximum value of $f ( x )$ is at either $x = \Delta$ or $\begin{array} { r } { x = \frac { N } { 2 } - \Delta } \end{array}$ . Further it is easy to know that $\begin{array} { r } { f ( \frac { N } { 4 } - x ) = f ( \frac { N } { 4 } + x ) } \end{array}$ . Then we have $\begin{array} { r } { f ( \Delta ) = f ( \frac { N } { 2 } - \Delta ) } \end{array}$ , and we can get the maximum value of $f ( x )$ as follows,
|
| 435 |
+
|
| 436 |
+
$$
|
| 437 |
+
\mathcal { U } _ { A , B } = \operatorname* { m a x } f ( x ) = f ( \Delta ) = \frac { 1 } { N } \left[ 2 \Delta \log ( \frac { 4 } { N } \Delta ) + 2 ( \frac { N } { 2 } - \Delta ) \log \left( \frac { 4 } { N } ( \frac { N } { 2 } - \Delta ) \right) \right]
|
| 438 |
+
$$
|
| 439 |
+
|
| 440 |
+
with $\begin{array} { r } { \Delta \ = \ \frac { ( h _ { B } - h _ { A } ) | \mathcal { E } | } { 2 d _ { \operatorname* { m a x } } } } \end{array}$ . In other words, $M I ( A , B )$ reaches its upper bound when $\vert { \mathcal { A } } _ { 0 } \cap { \mathcal { B } } _ { 0 } \vert =$ $\frac { ( h _ { B } - h _ { A } ) | \varepsilon | } { 2 d _ { \operatorname* { m a x } } }$ or $\begin{array} { r l r } { { \frac { N } { 2 } - \frac { ( h _ { B } - h _ { A } ) | \mathcal { E } | } { 2 d _ { \operatorname* { m a x } } } } } \end{array}$
|
| 441 |
+
|
| 442 |
+
aints . Bas $\begin{array} { r } { x \le \frac { a + b - 2 \Delta } { 2 } } \end{array}$ nd sio $\begin{array} { r } { x \ge \frac { a + b - ( N - 2 \Delta ) } { 2 } } \end{array}$ h 8), we have is monotoni $\frac { a + b - ( N - 2 \Delta ) } { 2 } \leq$ $\begin{array} { r } { \frac { a + b - 2 \Delta } { 2 } \Rightarrow \Delta \leq \frac { N } { 4 } } \end{array}$ N4 ed on the discus n in (1), we know t at f (∆) cally decreasing $[ 0 , \frac { N } { 4 } ]$ $\Delta$ $f ( \Delta )$ $\mathcal { U } _ { A , B }$ Since $\begin{array} { r } { \dot { \Delta } = \frac { ( h _ { B } - h _ { A } ) | \mathcal { E } | } { 2 d _ { \operatorname* { m a x } } } } \end{array}$ , a decrease in $h _ { A }$ will lead to a increase in $\Delta$ . Then we have $\mathcal { U } _ { A , B } < \mathcal { U } _ { A ^ { \prime } , B }$ if $h _ { A } < h _ { A ^ { \prime } } < h _ { B } ^ { -- }$ .
|
| 443 |
+
|
| 444 |
+
Remark on a more generalized case. We now discuss the case where we do not have assumptions on $a$ and $b$ . As we demonstrated in the above discussion, $f ( x )$ is mono$\begin{array} { r } { [ \operatorname* { m a x } ( 0 , a \ + \ b \ - \ N , \frac { a + b - ( N - 2 \Delta ) } { 2 } ) , \frac { a b } { N } ] } \end{array}$ and monotonically incrhould be one of the valAs our goal is to show that $\begin{array} { r } { [ \frac { a b } { N } , \operatorname* { m i n } ( a , b , \frac { a + b - 2 \Delta } { 2 } ) ] } \end{array}$ $f ( x )$ $\bar { f ( 0 ) } , f ( a + b - \bar { N ) } , f ( \frac { a + b - ( N - 2 \Delta ) } { 2 } ) , f ( a ) , f ( b )$ $f ( \frac { a + b - 2 \Delta } { 2 } )$ $\mathcal { U } _ { A , B }$ would be small with low $h _ { A }$ , to simplify the analysis, we consider a large value of $\Delta$ (or a small value of $h _ { A }$ ) which satisfies $\Delta \ge \frac { 1 } { 2 } | \dot { N } - \mathbf { \bar { \Phi } } ( a + b ) |$ and $\Delta \geq { \frac { 1 } { 2 } } | a - b |$ . This indicates $x$ is bounded by $\big [ \frac { a + b - ( N - 2 \Delta ) } { 2 } , \frac { a + b - 2 \Delta } { 2 } \big ]$ . Then the maximum value of $f ( x )$ , i.e., $\mathcal { U } _ { A , B }$ , is expressed as
|
| 445 |
+
|
| 446 |
+
$$
|
| 447 |
+
\mathcal { U } _ { A , B } = \operatorname* { m a x } ( f ( \frac { a + b - ( N - 2 \Delta ) } { 2 } ) , f ( \frac { a + b - 2 \Delta } { 2 } ) ) .
|
| 448 |
+
$$
|
| 449 |
+
|
| 450 |
+
When to smaWhen $\begin{array} { r } { \frac { a + b - ( N - 2 \Delta ) } { 2 } \leq \frac { a b } { N } \leq \frac { a + b - 2 \Delta } { 2 } } \end{array}$ larger be cl. It d $\Delta$ (or smaller r to the mineases with t $h _ { A }$ ) will la point ncrease d.f $\mathcal { U } _ { A , B }$ $\frac { a + b ^ { - } ( N - 2 \Delta ) } { 2 }$ a+b−2∆ will ose im ab $\textstyle { \frac { a b } { N } }$ $\begin{array} { r } { \frac { a b } { N } \ \leq \ \frac { a + b - ( N - 2 \Delta ) } { 2 } \ \leq \ \frac { a + b - 2 \overline { { \Delta } } } { 2 } } \end{array}$ $\mathcal { U } _ { A , B } ~ = ~ f ( \frac { a + b - 2 \Delta } { 2 } )$ $\Delta$ $h _ { A }$ $\frac { a + b - 2 \Delta } { 2 }$ gets closer to the minises with the increase of point (or the $\textstyle { \frac { a b } { N } }$ . Similarcrease of when). To $\begin{array} { r } { \frac { a + b - ( N - 2 \Delta ) } { 2 } \leq \frac { a + b - 2 \Delta } { 2 } \leq \frac { a b } { N } , \mathcal { U } _ { A , B } } \end{array}$ $\Delta$ $h _ { A }$ sum up, for small $h _ { A } ^ { - }$ , the upper bound of $M I ( A , B )$ , decreases with the decrease of
|
| 451 |
+
|
| 452 |
+
# C ALGORITHM
|
| 453 |
+
|
| 454 |
+
The detailed algorithm for AUTOSSL-ES is shown in Algorithm 1. Concretely, for each round (iteration) of AUTOSSL-ES, we sample $K$ sets of task weights, i.e., $K$ different combinations of SSL tasks, from a multivariate normal distribution. Then we train $K$ graph neural networks independently on each set of task weights. Afterwards, we calculate the pseudo-homohily for each network and adjust the mean and variance of the multivariate normal distribution through CMA-ES based on their pseudo-homohily.
|
| 455 |
+
|
| 456 |
+
The detailed algorithm for AUTOSSL-DS is summarized in Algorithm 2. Specifically, we first update the GNN parameter $\theta$ through one step gradient descent; then we perform $k$ -means clustering to obtain centroids, which are used to calculate the homophily loss $\mathcal { H }$ . Afterwards, we calculate the meta-gradient ∇meta{λ }, update $\{ \lambda _ { i } \}$ through gradient descent and clip $\{ \lambda _ { i } \}$ to $[ 0 , 1 ]$ .
|
| 457 |
+
|
| 458 |
+
# Algorithm 1: AUTOSSL-ES: AutoSSL with Evolutionary Strategy
|
| 459 |
+
|
| 460 |
+
for $r$ in $\{ 0 , \ldots , R \}$ do
|
| 461 |
+
|
| 462 |
+
1. Sample $K$ sets of tasks weights from a multivariate normal distribution 2. Train $K$ networks w.r.t. each set of task weights from scratch 3. Calculate pseudo-homophily P-H of node embeddings from each network 4. Adjust the multivariate normal distribution through CMA-ES based on P-H nd
|
| 463 |
+
|
| 464 |
+
# Algorithm 2: AUTOSSL-DS: AutoSSL with Differential Search
|
| 465 |
+
|
| 466 |
+
Initialize self-supervised task weights $\{ \lambda _ { i } \}$ and GNN parameters $\theta$ ;
|
| 467 |
+
for t in $\{ 0 , \ldots , { \bar { T } } \}$ do 1. $\dot { \theta _ { t + 1 } } = \theta _ { t } - \epsilon \nabla _ { \theta _ { t } } \mathcal { L } ( f _ { \theta _ { t } } , \{ \lambda _ { i } , \ell _ { i } \} )$ 2. Perform $k$ -means clustering on $\dot { f } _ { \theta _ { t } } ( \mathcal { G } )$ and obtain centroids $\{ \mathbf { c } _ { 1 } , \mathbf { c } _ { 2 } , \ldots , \mathbf { c } _ { k } \}$ 3. Calculate $p \left( \mathbf { c } _ { i } \mid \mathbf { x } \right)$ according to Eq. (4) 4. Calculate homophily loss $\mathcal { H }$ according to Eq. (5) 5. $\{ \lambda _ { i } \} \{ \lambda _ { i } \} - \eta \nabla _ { \{ \lambda _ { i } \} } ^ { \mathrm { m e t a } }$ 6. Clip $\{ \lambda _ { i } \}$ to [0,1]
|
| 468 |
+
|
| 469 |
+
end
|
| 470 |
+
|
| 471 |
+
# D DISCUSSIONS ON HOMOPHILY ASSUMPTION
|
| 472 |
+
|
| 473 |
+
Most of the graphs in our real life satisfy the homophily assumption (McPherson et al., 2001), such as social networks, citation networks, co-purchase networks, etc. Thus, in general, we can treat homophily as a prior knowledge for a majority of real-world graphs. Moreover, it has been shown in (Zhu et al., 2020a; Pei et al., 2020) that most GNNs (such as GCN, GAT, ChebyNet and GraphSage) heavily rely on the homophily assumption and fail to generalize to low-homophily (heterophily) graphs even with label information. Thus, following the design of most GNNs, we focus on the homophily graphs. In addition, to apply our method on heterophily graphs, we can use the graph transformation algorithm (Suresh et al., 2021) to increase the homophily of a given graph. While heterophily graphs also exist in real-world applications, the research of GNNs on heterophily graphs is still at the very early stage even in the cases where the label information is available. Therefore, we will leave the research for heterophily graphs in the unsupervised setting as a future work.
|
| 474 |
+
|
| 475 |
+
# E ADDITIONAL EXPERIMENTAL RESULTS
|
| 476 |
+
|
| 477 |
+
# E.1 RELATIONSHIP BETWEEN DOWNSTREAM PERFORMANCE AND PSEUDO-HOMOPHILY
|
| 478 |
+
|
| 479 |
+
We provide more results on the relation between downstream performance and pseudo-homophily in Figure 6. Observations are already made in Section 4.4.
|
| 480 |
+
|
| 481 |
+

|
| 482 |
+
Figure 6: Relationship between downstream performance and pseudo-homophily.
|
| 483 |
+
|
| 484 |
+

|
| 485 |
+
Figure 7: Pseudo-homophily versus NMI/ACC/Loss on Citeseer for AUTOSSL-DS. The vertical dashed line indicates the iteration when pseudo-homophily reaches the maximum value.
|
| 486 |
+
|
| 487 |
+
# E.2 PSEUDO-HOMOPHILY OVER ITERATIONS
|
| 488 |
+
|
| 489 |
+
We investigate how pseudo-homophily changes over iterations for AUTOSSL-DS. The changes of pseudo-homophily, NMI, ACC and homophily loss (Eq. (5)) are plotted in Figure 7. From Figure 7a and 7b, we can observe that pseudo-homophily first increases and then becomes stable through iterations. The situation is a bit different for clustering and classification performance: NMI and ACC first increase with the increase of pseudo-homophily and then drop when pseudo-homophily is relatively stable. This indicates that overtraining can hurt downstream performance as the model will have the risk of overfitting on the combined SSL tasks. However, as shown in the figure, if we stop at the iteration when pseudo-homophily reaches the maximum value we can still get a high NMI and ACC. On a separate note, Figure $\mathrm { 7 c }$ shows how the homophily loss used in AUTOSSL-DS changes over iterations. We note that in the first iterations the homophily loss is low but the pseudohomophily is also low. This is because the embeddings in the first few epochs are less separable and would lead to very close soft-assignment of clusters. As shown in the figure, however, the problem is resolved as the embeddings become more distinguishable through iterations. Thus, we argue that the homophily loss in Eq. (5) is still a good proxy in optimizing pseudo-homophily.
|
| 490 |
+
|
| 491 |
+
# E.3 EFFICIENCY ANALYSIS
|
| 492 |
+
|
| 493 |
+
# E.3.1 TIME COMPLEXITY ANALYSIS
|
| 494 |
+
|
| 495 |
+
We analyze the time complexity of the proposed AUTOSSL. Here we call one set of task weights $\{ \lambda _ { i } \}$ as one candidate solution. We denote the time of training one epoch on a given set of SSL tasks as $t _ { o }$ and the evaluation time is $t _ { e }$ . Suppose we need to train $T$ epochs for the network. Then the time for running one single candidate solution is $T t _ { o } + t _ { e }$ ; the time of running $R$ rounds of AUTOSSL-ES should be $R T t _ { o } + R t _ { e }$ . For AUTOSSL-DS, the running time is $T t _ { o } + T t _ { e }$ . As an illustration, in an $L$ -layer GCN with $d$ as the number of hidden dimensions, $t _ { o }$ can be expressed as $O ( L | \mathcal { E } | d + L N d ^ { 2 } )$ and $t _ { e }$ has time complexity of $O ( K I N d )$ with $K$ being the number of clusters and $I$ being the number of iterations for $k$ -means. Hence, we also express the time complexity of AUTOSSL-ES as $O ( R T L | \mathcal { E } | d + R T L N d ^ { 2 } + R K I N d )$ and that of AUTOSSL-DS as $\bar { O } ( T \bar { L } | \mathcal { E } | d + T L N d ^ { 2 } +$ $T K I N d )$ . Both of them linearly increase with the number of nodes $N$ when $\mathcal { E }$ is proportional to $N$ . We note that in AUTOSSL-DS, the complexity of calculating the second-order derivatives in backward propagation has an additional factor of $O ( | \theta | | \{ \lambda _ { i } \} | )$ , which can be reduced to $O ( | \{ \lambda _ { i } \} | )$ with approximated Hessian-vector products. The factor can be neglected as the number of tasks $O ( | \{ \lambda _ { i } \} | )$ is small.
|
| 496 |
+
|
| 497 |
+
# E.3.2 EMPIRICAL COMPARISON
|
| 498 |
+
|
| 499 |
+
For empirical comparison, we take Citeseer, Photo, CoraFull as examples to illustrate. As shown in Table 5, we compare the running time of different methods for training 1000 epochs on one NVIDIA-K80 GPU. The column of 5-Tasks indicates the running time of training a combination of 5 SSL tasks, i.e. CLU, PAR, PAIRSIM, PAIRDIS and DGI, for 1000 epochs. Note that we report the running time of AUTOSSL-ES as the multiplication between 500 and the time of 5-Tasks, i.e., running 500 candidate solutions. From the table, we can see that the running time of AUTOSSLES depends on the number of candidate solutions and usually takes a long time to run. However, AUTOSSL-DS significantly reduces the running time of AUTOSSL-ES. It is worth noting the stateof-the-art SSL task, MVGRL, takes a long time to run and suffers from the OOM issue when the dataset gets larger.
|
| 500 |
+
|
| 501 |
+
Table 5: Comparison of running time for training 1000 epochs on one NVIDIA-K80 GPU (12 GB memory). OOM indicates out-of-memory on this GPU.
|
| 502 |
+
|
| 503 |
+
<table><tr><td></td><td>DGI</td><td>MvGRL</td><td>5-Tasks</td><td>AUTOSSL-ES</td><td>AUTOSSL-DS</td></tr><tr><td>Citeseer</td><td>222s</td><td>1220s</td><td>322s</td><td>322s×500</td><td>1222s</td></tr><tr><td>Photo</td><td>177s</td><td>1074s</td><td>507s</td><td>507s×500</td><td>1766s</td></tr><tr><td>CoraFull</td><td>553s</td><td>0OM</td><td>858s</td><td>858s×500</td><td>3584s</td></tr></table>
|
| 504 |
+
|
| 505 |
+
# F COMPARISON WITH DIFFERENT STRATEGY
|
| 506 |
+
|
| 507 |
+
In this subsection, we examine how other strategies of assigning task weights affect the quality of learned representations. The results are summarized in Table 6. In this table, “Best SSL” indicates the best performance achieved by the individual tasks; “Random Weight” indicates the performance achieved by randomly assigning task weights; “Equal Weight” indicates the performance achieved by assigning the same task weights (i.e., all 1). The values that outperform “Best SSL” are underlined. From the table, we make two observations. Obs 1. Unlike AUTOSSL, “Random Weight” and “Equal Weight” would hurt both NMI and ACC on some datasets, e.g., Citeseer. This suggests that SSL tasks might conflict with each other and thus harm the downstream performance. Obs 2. In some cases like Physics, “Equal Weight” can also improve both ACC and NMI, which aligns well with our initial motivation that combinations of SSL can help capture multiple sources of information and benefit the downstream performance. The two observations suggest that it is important to design a clever strategy that can automatically compose graph SSL tasks.
|
| 508 |
+
|
| 509 |
+
# G COMPARISON WITH RANDOM SEARCH
|
| 510 |
+
|
| 511 |
+
In this subsection, we choose Citeseer to study the difference between random search and evolutionary algorithm (AUTOSSL-ES), and report the result in Table 7. Specifically, the random search method randomly generates 800 sets of tasks weights and we evaluate the pseudo-homophily from the models trained with those task weights. Note that in AUTOSSL-ES we also evaluated 800 sets of tasks weights in total. From the table, we can see that random search is not as efficient as AUTOSSLES: with the same search cost, the resulted pseudo-homophily of random search is not as high as AUTOSSL-ES and the downstream performance is also inferior. This result suggests that search with evolutionary algorithm can find the optimum faster than random search.
|
| 512 |
+
|
| 513 |
+
Table 6: Performance comparison of different strategies of assigning task weights. The NMI rows indicate node clustering performance; ACC rows indicate node classification accuracy $( \% )$ ; P-H stands for pseudo-homophily. (Underline: better than “Best SSL”).
|
| 514 |
+
|
| 515 |
+
<table><tr><td>Dataset</td><td>Metric</td><td>Best SSL</td><td>Random Weight</td><td>Equal Weight</td><td>AUTOSSL-ES</td><td>AUTOSSL-DS</td></tr><tr><td rowspan="3">Citeseer</td><td>NMI</td><td>0.439±0.00</td><td>0.398±0.01</td><td>0.408±0.00</td><td>0.449±0.01</td><td>0.449±0.01</td></tr><tr><td>ACC</td><td>71.64±0.44</td><td>70.64±0.07</td><td>70.80±0.31</td><td>72.14±0.41</td><td>72.00±0.32</td></tr><tr><td>P-H</td><td>1</td><td>0.897</td><td>0.904</td><td>0.943</td><td>0.934</td></tr><tr><td rowspan="3">Computers</td><td>NMI</td><td>0.433±0.00</td><td>0.341±0.03</td><td>0.290±0.00</td><td>0.447±0.01</td><td>0.448±0.01</td></tr><tr><td>ACC</td><td>87.26±0.15</td><td>86.86±0.25</td><td>87.24±0.38</td><td>87.26±0.64</td><td>88.18±0.43</td></tr><tr><td>P-H</td><td>1</td><td>0.406</td><td>0.378</td><td>0.503</td><td>0.511</td></tr><tr><td rowspan="3">CoraFull</td><td>NMI</td><td>0.498±0.00</td><td>0.458±0.02</td><td>0.493±0.00</td><td>0.506±0.01</td><td>0.500 ±0.00</td></tr><tr><td>ACC</td><td>60.42±0.39</td><td>58.88±0.32</td><td>59.01±0.29</td><td>61.01 ±0.50</td><td>61.10±0.68</td></tr><tr><td>P-H</td><td>1</td><td>0.811</td><td>0.868</td><td>0.903</td><td>0.895</td></tr><tr><td rowspan="3">CS</td><td>NMI</td><td>0.767±0.01</td><td>0.761±0.01</td><td>0.770 2±0.01</td><td>0.772 2±0.01</td><td>0.771 ±0.01</td></tr><tr><td>ACC</td><td>92.75±0.12</td><td>92.88±0.20</td><td>93.22 ±0.12</td><td>93.26 ±0.16</td><td>93.35 2±0.09</td></tr><tr><td>P-H</td><td>一</td><td>0.879</td><td>0.881</td><td>0.895</td><td>0.890</td></tr><tr><td rowspan="3">Photo</td><td>NMI</td><td>0.509±0.01</td><td>0.341±0.02</td><td>0.366±0.02</td><td>0.560±0.04</td><td>0.511 ±0.03</td></tr><tr><td>ACC</td><td>92.08±0.37</td><td>92.04±0.28</td><td>92.54±0.29</td><td>92.04±0.89</td><td>92.71±0.32</td></tr><tr><td>P-H</td><td>1</td><td>0.412</td><td>0.472</td><td>0.791</td><td>0.626</td></tr><tr><td rowspan="3">Physics</td><td>NMI</td><td>0.704±0.00</td><td>0.692±0.00</td><td>0.709 ±0.01</td><td>0.725±0.00</td><td>0.726±0.00</td></tr><tr><td>ACC</td><td>95.07±0.06</td><td>95.09±0.08</td><td>95.39±0.10</td><td>95.57±0.02</td><td>95.13±0.36</td></tr><tr><td>P-H</td><td>1</td><td>0.914</td><td>0.916</td><td>0.921</td><td>0.923</td></tr><tr><td rowspan="3">WikiCS</td><td>NMI</td><td>0.341±0.01</td><td>0.305±0.01</td><td>0.323±0.01</td><td>0.366±0.01</td><td>0.344±0.02</td></tr><tr><td>ACC</td><td>75.81±0.17</td><td>76.29±0.17</td><td>76.49±0.21</td><td>76.80±0.13</td><td>76.58±0.28</td></tr><tr><td>P-H</td><td>1</td><td>0.675</td><td>0.690</td><td>0.751</td><td>0.749</td></tr></table>
|
| 516 |
+
|
| 517 |
+
Table 7: Comparison with random search. The NMI indicates node clustering performance; ACC indicates node classification accuracy $( \% )$ ; P-H stands for pseudo-homophily.
|
| 518 |
+
|
| 519 |
+
<table><tr><td>Dataset</td><td>Metric</td><td>Random Search</td><td>AUTOSSL-ES</td></tr><tr><td rowspan="4">Citeseer</td><td>NMI</td><td>0.443±0.00</td><td>0.449±0.01</td></tr><tr><td>ACC</td><td>71.68±0.55</td><td>72.14±0.41</td></tr><tr><td>P-H</td><td>0.934</td><td>0.943</td></tr><tr><td></td><td></td><td></td></tr></table>
|
| 520 |
+
|
| 521 |
+
# H BROADER IMPACT
|
| 522 |
+
|
| 523 |
+
Graph neural networks (GNNs) are commonly used for node and graph representation learning tasks due to their representational power. Such models have also been recently proposed for use in largescale social platforms for tasks including forecasting (Tang et al., 2020a), friend ranking (Sankar et al., 2021) and item recommendation (Ying et al., 2018; Wu et al., 2019a), which impact many end users. Like other machine learning models, GNNs can suffer from typical unfairness issues which may arise due to sensitive attributes, label parity issues, and more (Dai & Wang, 2021). Moreover, GNNs can also suffer from degree-related biases (Tang et al., 2020b). Self-supervised learning (SSL) is often used to learn high-quality representations without supervision from labeled data sources, and is especially useful in low-resource settings or in pre-training/fine-tuning scenarios. Several works have illustrated the potential for representations learned in a self-supervised way to encode bias unintentionally, for example in language modeling (Bender et al., 2021; Zhao et al., 2019), image representation learning (Roberts et al., 2018) and outlier detection (Shekhar et al., 2020).
|
| 524 |
+
|
| 525 |
+
Our work on automated self-supervised learning with graph neural networks shares the caveats of these two domains in terms of producing inadvertent or biased outcomes. We propose an approach to learn self-supervised representations by utilizing multiple types of pretext tasks in conjunction with one another. While this produces improved performance on standard tasks used for benchmarking representation quality, it does not guarantee that these representations are fair and should be used without typical fairness checks in industrial contexts. However, such concerns are not inherently posed by our proposed ideas, but by the foundations it builds on in GNNs and SSL. We anticipate our ideas will drive further research in more sophisticated and powerful self-supervised graph learning, and do not anticipate direct negative outcomes from this work.
|
md/dev/sE7-XhLxHA/sE7-XhLxHA.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DEBERTAV3: IMPROVING DEBERTA USINGELECTRA-STYLE PRE-TRAININGWITH GRADIENT-DISENTANGLED EMBEDDING SHAR-ING
|
| 2 |
+
|
| 3 |
+
Pengcheng $\mathbf { H e } ^ { 1 }$ , Jianfeng $\mathbf { G a o ^ { 2 } }$ , Weizhu Chen1 1 Microsoft Azure AI
|
| 4 |
+
2 Microsoft Research
|
| 5 |
+
{penhe,jfgao,wzchen}@microsoft.com
|
| 6 |
+
|
| 7 |
+
# ABSTRACT
|
| 8 |
+
|
| 9 |
+
This paper presents a new pre-trained language model, DeBERTaV3, which improves the original DeBERTa model by replacing masked language modeling (MLM) with replaced token detection (RTD), a more sample-efficient pre-training task. Our analysis shows that vanilla embedding sharing in ELECTRA hurts training efficiency and model performance, because the training losses of the discriminator and the generator pull token embeddings in different directions, creating the “tugof-war” dynamics. We thus propose a new gradient-disentangled embedding sharing method that avoids the tug-of-war dynamics, improving both training efficiency and the quality of the pre-trained model. We have pre-trained DeBERTaV3 using the same settings as DeBERTa to demonstrate its exceptional performance on a wide range of downstream natural language understanding (NLU) tasks. Taking the GLUE benchmark with eight tasks as an example, the DeBERTaV3 Large model achieves a $9 1 . 3 7 \%$ average score, which is $1 . 3 7 \%$ higher than DeBERTa and $1 . 9 1 \%$ higher than ELECTRA, setting a new state-of-the-art (SOTA) among the models with a similar structure. Furthermore, we have pre-trained a multilingual model mDeBERTaV3 and observed a larger improvement over strong baselines compared to English models. For example, the mDeBERTaV3 Base achieves a $7 9 . 8 \%$ zero-shot cross-lingual accuracy on XNLI and a $3 . 6 \%$ improvement over XLM-R Base, creating a new SOTA on this benchmark. Our models and code are publicly available at https://github.com/microsoft/DeBERTa.
|
| 10 |
+
|
| 11 |
+
# 1 INTRODUCTION
|
| 12 |
+
|
| 13 |
+
Recent advances in Pre-trained Language Models (PLMs) have created new state-of-the-art results on many natural language processing (NLP) tasks. While scaling up PLMs with billions or trillions of parameters (Raffel et al., 2020; Radford et al., 2019; Brown et al., 2020; He et al., 2020; Fedus et al., 2021) is a well-proved way to improve the capacity of the PLMs, it is more important to explore more energy-efficient approaches to build PLMs with fewer parameters and less computation cost while retaining high model capacity.
|
| 14 |
+
|
| 15 |
+
Towards this direction, there are a few works that significantly improve the efficiency of PLMs. The first is RoBERTa (Liu et al., 2019) which improves the model capacity with a larger batch size and more training data. Based on RoBERTa, DeBERTa (He et al., 2020) further improves the pre-training efficiency by incorporating disentangled attention which is an improved relative-position encoding mechanism. By scaling up to 1.5B parameters, which is about an eighth of the parameters of xxlarge T5 (Raffel et al., 2020), DeBERTa surpassed human performance on the SuperGLUE (Wang et al., 2019a) leaderboard for the first time. The second new pre-training approach to improve efficiency is Replaced Token Detection (RTD), proposed by ELECTRA (Clark et al., 2020). Unlike BERT (Devlin et al., 2019), which uses a transformer encoder to predict corrupt tokens with masked language modeling (MLM), RTD uses a generator to generate ambiguous corruptions and a discriminator to distinguish the ambiguous tokens from the original inputs, similar to Generative Adversarial
|
| 16 |
+
|
| 17 |
+
Networks (GAN). The effectiveness of RTD is also verified by several works, including CoCo-LM (Meng et al., 2021), XLM-E (Chi et al., 2021), CodeBERT(Feng et al., 2020) and SmallBenchNLP (Kanakarajan et al., 2021).
|
| 18 |
+
|
| 19 |
+
In this paper, we explore two methods of improving the efficiency of pre-training DeBERTa. Following ELECTRA-style training, we replace MLM in DeBERTa with RTD where the model is trained as a discriminator to predict whether a token in the corrupt input is either original or replaced by a generator. We show that DeBERTa trained with RTD significantly outperforms the model trained using MLM. The second is a new embedding sharing method. In ELECTRA, the discriminator and the generator share the same token embeddings. However, our analysis shows that embedding sharing hurts training efficiency and model performance, since the training losses of the discriminator and the generator pull token embeddings into opposite directions. This is because the training objectives between the generator and the discriminator are very different. The MLM used for training the generator tries to pull the tokens that are semantically similar close to each other while the RTD of the discriminator tries to discriminate semantically similar tokens and pull their embeddings as far as possible to optimize the binary classification accuracy, causing a conflict between their training objectives. In other words, this creates the “tug-of-war” dynamics that reduces the training efficiency and the model quality, as illustrated in Hadsell et al. (2020). On the other hand, we show that using separated embeddings for the generator and the discriminator results in significant performance degradation when we fine-tune the discriminator on downstream tasks, indicating the merit of embedding sharing, e.g., the embeddings of the generator are beneficial to produce a better discriminator, as argued in Clark et al. (2020). To balance these tradeoffs, we propose a new gradient-disentangled embedding sharing (GDES) method where the generator shares its embeddings with the discriminator but stops the gradients from the discriminator to the generator embeddings. This way, we avoid the tug-of-war effect and preserve the benefits of embedding sharing. We empirically demonstrate that GDES improves both pre-training efficiency and the quality of the pre-trained models.
|
| 20 |
+
|
| 21 |
+
We pre-train four variants of DeBERTaV3 models, i.e., $\mathrm { D e B E R T a V } 3 _ { \mathrm { l a r g e } }$ , DeBERTaV3base, DeBERTa $\mathrm { . V 3 _ { s m a l l } }$ and DeBERTaV3xsmall. We evaluate them on various representative natural language understanding (NLU) benchmarks and set new state-of-the-art numbers among models with a similar model structure. For example, DeBERTaV3large surpasses previous SOTA models with a similar model structure on GLUE (Wang et al., 2019b) benchmark with an average score over $+ 1 . 3 7 \%$ , which is significant. $\mathrm { D e B E R T a V } 3 _ { \mathrm { b a s e } }$ achieves a $9 0 . 6 \%$ accuracy score on the MNLI-matched (Williams et al., 2018) evaluation set and an $8 8 . 4 \%$ F1 score on the SQuAD $\mathrm { v } 2 . 0$ (Rajpurkar et al., 2018) evaluation set. This improves $\mathrm { D e B E R T a _ { b a s e } }$ by $1 . 8 \%$ and $2 . 2 \%$ , respectively. Without knowledge distillation, $\mathrm { D e B E R T a V } 3 _ { \mathrm { s m a l l } }$ and DeBERTaV3xsmall surpasses previous SOTA models with a similar model structure on both MNLI-matched and SQuAD $\mathrm { v } 2 . 0$ evaluation set by more than $1 . 2 \%$ in accuracy and $1 . 3 \%$ in F1, respectively. We also train DeBERTaV3base on the CC100 (Conneau et al., 2020) multilingual data using a similar setting as XLM-R (Conneau et al., 2020) but with only a third of the training passes. We denote the model as mDeBERTa $\mathrm { V } 3 _ { \mathrm { b a s e } }$ . Under the cross-lingual transfer setting, mDeBERTa $\mathrm { V } 3 _ { \mathrm { b a s e } }$ achieves a $7 9 . 8 \%$ average accuracy score on the XNLI (Conneau et al., 2018) task, which outperforms XLM- $\cdot \mathrm { R } _ { \mathrm { b a s e } }$ and $\mathrm { m T 5 _ { b a s e } }$ (Xue et al., 2021) by $3 . 6 \%$ and $4 . 4 \%$ , respectively. This makes mDeBERTaV3 the best model among multi-lingual models with a similar model structure. All these results strongly demonstrate the efficiency of DeBERTaV3 models and set a good base for future exploration towards more efficient PLMs.
|
| 22 |
+
|
| 23 |
+
# 2 BACKGROUND
|
| 24 |
+
|
| 25 |
+
# 2.1 TRANSFORMER
|
| 26 |
+
|
| 27 |
+
A Transformer-based language model is composed of $L$ stacked Transformer blocks (Vaswani et al., 2017). Each block contains a multi-head self-attention layer followed by a fully connected positional feed-forward network. The standard self-attention mechanism lacks a natural way to encode word position information. Thus, existing approaches add a positional bias to each input word embedding so that each input word is represented by a vector whose value depends on both its content and position. The positional bias can be implemented using absolute position embedding (Vaswani et al., 2017; Brown et al., 2020; Devlin et al., 2019) or relative position embedding (Huang et al., 2018; Yang et al., 2019). Several studies have shown that relative position representations are more effective for natural language understanding and generation tasks (Dai et al., 2019; Shaw et al., 2018; He et al., 2020).
|
| 28 |
+
|
| 29 |
+
# 2.2 DEBERTA
|
| 30 |
+
|
| 31 |
+
DeBERTa improves BERT with two novel components: DA (Disentangled Attention) and an enhanced mask decoder. Unlike existing approaches that use a single vector to represent both the content and the position of each input word, the DA mechanism uses two separate vectors: one for the content and the other for the position. Meanwhile, the DA mechanism’s attention weights among words are computed via disentangled matrices on both their contents and relative positions. Like BERT, DeBERTa is pre-trained using masked language modeling. The DA mechanism already considers the contents and relative positions of the context words, but not the absolute positions of these words, which in many cases are crucial for the prediction. DeBERTa uses an enhanced mask decoder to improve MLM by adding absolute position information of the context words at the MLM decoding layer.
|
| 32 |
+
|
| 33 |
+
# 2.3 ELECTRA
|
| 34 |
+
|
| 35 |
+
# 2.3.1 MASKED LANGUAGE MODEL
|
| 36 |
+
|
| 37 |
+
Large-scale Transformer-based PLMs are typically pre-trained on large amounts of text to learn contextual word representations using a self-supervision objective, known as MLM (Devlin et al., 2019). Specifically, given a sequence $X = \left\{ x _ { i } \right\}$ , we corrupt it into $\tilde { X }$ by masking $15 \%$ of its tokens at random and then train a language model parameterized by $\theta$ to reconstruct $\boldsymbol { X }$ by predicting the masked tokens $\tilde { x }$ conditioned on $\check { \bar { X } }$ :
|
| 38 |
+
|
| 39 |
+
$$
|
| 40 |
+
\operatorname* { m a x } _ { \theta } \log p _ { \theta } ( X | \tilde { X } ) = \operatorname* { m a x } _ { \theta } \sum _ { i \in \mathcal { C } } \log p _ { \theta } \big ( \tilde { x } _ { i } = x _ { i } | \tilde { X } \big )
|
| 41 |
+
$$
|
| 42 |
+
|
| 43 |
+
where $\mathcal { C }$ is the index set of the masked tokens in the sequence. The authors of BERT propose to keep $10 \%$ of the masked tokens unchanged, another $10 \%$ replaced with randomly picked tokens and the rest replaced with the [MASK] token.
|
| 44 |
+
|
| 45 |
+
# 2.3.2 REPLACED TOKEN DETECTION
|
| 46 |
+
|
| 47 |
+
Unlike BERT, which uses only one transformer encoder and trained with MLM, ELECTRA was trained with two transformer encoders in GAN style. One is called generator trained with MLM; the other is called discriminator trained with a token-level binary classifier. The generator is used to generate ambiguous tokens to replace masked tokens in the input sequence. Then the modified input sequence is fed to the discriminator. The binary classifier in the discriminator needs to determine if a corresponding token is either an original token or a token replaced by the generator. We use $\theta _ { G }$ and $\theta _ { D }$ to represent the parameters of the generator and the discriminator, respectively. The training objective in the discriminator is called RTD (Replaced Token Detection). The loss function of the generator can be written as,
|
| 48 |
+
|
| 49 |
+
$$
|
| 50 |
+
L _ { M L M } = \mathbb { E } \left( - \sum _ { i \in \mathcal { C } } \log p _ { \theta _ { G } } \left( \tilde { x } _ { i , G } = x _ { i } | \tilde { \mathbf { X } } _ { G } \right) \right)
|
| 51 |
+
$$
|
| 52 |
+
|
| 53 |
+
, where $\tilde { X } _ { G }$ is the input to the generator by randomly masking $1 5 \%$ tokens in $\boldsymbol { X }$ .
|
| 54 |
+
|
| 55 |
+
The input sequence of the discriminator is constructed by replacing masked tokens with new tokens sampled according to the output probability from the generator:
|
| 56 |
+
|
| 57 |
+
$$
|
| 58 |
+
\tilde { x } _ { i , D } = \left\{ \begin{array} { c c } { \tilde { x } _ { i } \sim p _ { \theta _ { G } } \left( \tilde { x } _ { i , G } = x _ { i } | \tilde { \mathbf { X } } _ { G } \right) , } & { i \in \mathcal { C } } \\ { x _ { i } , } & { i \notin \mathcal { C } } \end{array} \right.
|
| 59 |
+
$$
|
| 60 |
+
|
| 61 |
+
The loss function of the discriminator is written as,
|
| 62 |
+
|
| 63 |
+
$$
|
| 64 |
+
L _ { R T D } = \mathbb { E } \left( - \sum _ { i } \log p _ { \theta _ { D } } \left( \mathbb { 1 } \left( \tilde { x } _ { i , D } = x _ { i } \right) | \tilde { X } _ { D } , i \right) \right)
|
| 65 |
+
$$
|
| 66 |
+
|
| 67 |
+
, where $\mathbb { 1 } ( \cdot )$ is the indicator function and $\tilde { X } _ { D }$ is the input to the discriminator constructed via equation 3. In ELECTRA, $L _ { M L M }$ and $L _ { R T D }$ are optimized jointly, ${ \cal L } = { \cal L } _ { M L M } + \lambda { \cal L } _ { R T D }$ , where $\lambda$ is the weight of the discriminator loss $L _ { R T D }$ , which was set to 50 in ELECTRA.
|
| 68 |
+
|
| 69 |
+
# 3 DEBERTAV3
|
| 70 |
+
|
| 71 |
+
This section describes DeBERTaV3, which improves DeBERTa by using the RTD training loss of Clark et al. (2020) and a new weight-sharing method.
|
| 72 |
+
|
| 73 |
+
# 3.1 DEBERTA WITH RTD
|
| 74 |
+
|
| 75 |
+
Since RTD in ELECTRA and the disentangled attention mechanism in DeBERTa have proven to be sample-efficient for pre-training, we propose a new version of DeBERTa, referred to as DeBERTaV3, by replacing the MLM objective used in DeBERTa with the RTD objective to combine the strengths of the latter.
|
| 76 |
+
|
| 77 |
+
In this implementation, Wikipedia and the bookcorpus (Zhu et al., 2015) are used as training data, following the base model configuration of Devlin et al. (2019). The generator is the same width as the discriminator but is half the depth. The batch size is set to 2048, and the model is trained for 125,000 steps with a learning rate of 5e-4 and warmup steps of 10,000. Following Clark et al. (2020), we use $\lambda = 5 0$ with the same optimization hyperparameters. We validate the effectiveness of DeBERTaV3 on two representative NLU tasks, i.e., MNLI and SQuAD v2.0. The results, presented in $\textcircled{1}$ of Table 2, show that DeBERTaV3 significantly outperforms DeBERTa, i.e., $+ 2 . 5 \%$ on the MNLI-m accuracy and $+ 3 . 8 \%$ on the SQuAD v2.0 F1.
|
| 78 |
+
|
| 79 |
+
In the next two subsections, we will show that the performance of DeBERTaV3 can be further improved by replacing token Embedding Sharing (ES) used for RTD, originally proposed in Clark et al. (2020), by a new Gradient-Disentangled Embedding Sharing (GDES) method. We start with an analysis of ES in Section 3.2.
|
| 80 |
+
|
| 81 |
+
# 3.2 TOKEN EMBEDDING SHARING IN ELECTRA
|
| 82 |
+
|
| 83 |
+
To pre-train ELECTRA, we use a generator and a discriminator that share token embeddings, as shown in Figure 1 (a). This method, called Embedding Sharing (ES), allows the generator to provide informative inputs for the discriminator and reduces the number of parameters to learn. However, it also creates a multitask learning problem, where the generator’s and the discriminator’s objectives interfere with each other and slow down the training convergence.
|
| 84 |
+
|
| 85 |
+
Let $\pmb { { \cal E } }$ and $g _ { E }$ be the token embeddings and their gradients, respectively. In each training step of ELECTRA, we compute $g _ { E }$ by back-propagating the errors from both the generator’s Masked Language Modeling (MLM) loss and the discriminator’s Replaced Token Detection (RTD) loss, as $\begin{array} { r } { g _ { E } = \frac { \tilde { \mathcal { D } } L _ { M L M } } { \tilde { \mathcal { D } } E } + \lambda \frac { \tilde { \mathcal { D } } L _ { R T D } } { \tilde { \mathcal { D } } E } } \end{array}$ . This equation means that the token embeddings are updated by balancing the gradients from the two tasks, which can be seen as a tug-of-war procedure (Hadsell et al., 2020). The procedure can eventually converge if we control the update speed carefully (e.g., using a small learning rate or gradient clipping), but it can be very inefficient if the two tasks have different optimal directions for the embeddings. This is indeed the case for MLM and RTD, because they have opposite effects on the token embeddings. MLM encourages the embeddings of semantically similar tokens to be close to each other, while RTD tries to separate them to make the classification easier.
|
| 86 |
+
|
| 87 |
+
To verify our hypothesis, we implement a variant of ELECTRA that does not share token embeddings between the generator and the discriminator, which we refer to as No Embedding Sharing (NES), as illustrated in Figure 1 (b). In NES, we update the generator and the discriminator alternately in each training step. First, we run the generator to generate inputs for the discriminator, and then we update the generator’s parameters, including its token embeddings $E _ { G }$ , by back-propagating the MLM loss. Next, we run the discriminator using the inputs from the generator and update the discriminator’s parameters, including its token embeddings $E _ { D }$ , by back-propagating the RTD loss.
|
| 88 |
+
|
| 89 |
+
We compare ES and NES on three aspects: convergence speed, quality of the token embeddings, and performance on downstream Natural Language Understanding (NLU) tasks. Figure 2 shows that NES converges faster than ES, as expected, because it avoids the conflicting gradients between the two downstream tasks. We then measure the average cosine similarity scores of the token embeddings 1. Table 1 shows that NES produces two distinct embedding models, with $E _ { G }$ being more semantically coherent than $E _ { D }$ . This confirms our hypothesis. However, the embeddings learned by NES do not lead to any significant improvement on two representative downstream NLU tasks (i.e., MNLI and SQuAD v2.0), as shown in Table 2. This result supports the argument of Clark et al. (2020) that ES has the advantage of making the discriminator benefit from the generator’s embeddings, in addition to saving parameters. In the next subsection, we propose a new embedding sharing method that combines the strengths of ES and NES, while avoiding their drawbacks.
|
| 90 |
+
|
| 91 |
+

|
| 92 |
+
Figure 1: Illustration of different embedding sharing methods. (a) ES: $\pmb { { \cal E } }$ , $\theta _ { G }$ and $\theta _ { D }$ will be jointly updated in a single backward pass with regards to $L _ { M L M } + \lambda L _ { R T D }$ . (b) NES: $E _ { G }$ and $\theta _ { G }$ will first be updated via the backward pass with regards to $L _ { M L M }$ , then $E _ { D }$ and $\theta _ { D }$ will be updated via the backward pass with regards to $\lambda L _ { R T D }$ . (c) GDES: $E _ { G }$ and $\theta _ { G }$ will first be updated in the backward pass with regards to $L _ { M L M }$ , then $\pmb { { \cal E } } _ { \Delta }$ and $\theta _ { D }$ will be updated via the backward pass with regards to $\lambda L _ { R T D }$ and $E _ { G } \mathrm { ~ . ~ } s g$ is the stop gradient operator that prevents the discriminator from updating $\pmb { { \cal E } } _ { G }$
|
| 93 |
+
|
| 94 |
+
Table 1: Average cosine similarity of word embeddings of the generator and the discriminator with different embedding sharing methods.
|
| 95 |
+
|
| 96 |
+
<table><tr><td rowspan=1 colspan=1>Word Embedding Sharing</td><td rowspan=1 colspan=1>EG</td><td rowspan=1 colspan=1>ED</td><td rowspan=1 colspan=1>E</td></tr><tr><td rowspan=1 colspan=1>①ES</td><td rowspan=1 colspan=1>0.02</td><td rowspan=1 colspan=1>0.02</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>② NES</td><td rowspan=1 colspan=1>0.45</td><td rowspan=1 colspan=1>0.02</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=1 colspan=1>③ GDES</td><td rowspan=1 colspan=1>0.45</td><td rowspan=1 colspan=1>0.29</td><td rowspan=1 colspan=1>0.02</td></tr></table>
|
| 97 |
+
|
| 98 |
+
Table 2: Fine-tuning results on MNLI and SQuAD v2.0 tasks of base models trained with different embedding sharing methods.
|
| 99 |
+
|
| 100 |
+
<table><tr><td>Model</td><td>MNLI-m/mm Acc</td><td>SQuAD v2.0 F1/EM</td></tr><tr><td>BERTbase</td><td>84.3/84.7</td><td>76.3/73.7</td></tr><tr><td>ELECTRAbase DeBERTabase</td><td>85.8/- 86.3/86.2</td><td>-- 82.5/79.3</td></tr><tr><td>DeBERTa+RTDbase</td><td></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td>①ES</td><td>88.8/88.4</td><td>86.3/83.5</td></tr><tr><td>②NES</td><td>88.3/87.9</td><td>85.3/82.7</td></tr><tr><td>③GDES</td><td>89.3/89.0</td><td>87.2/84.5</td></tr></table>
|
| 101 |
+
|
| 102 |
+
# 3.3 GRADIENT-DISENTANGLED EMBEDDING SHARING
|
| 103 |
+
|
| 104 |
+
We propose the Gradient-Disentangled Embedding Sharing (GDES) method to overcome the drawbacks of ES and NES while retaining their advantages. As shown in Figure 1 (c), GDES shares the token embeddings between the generator and the discriminator, which enables the two models to learn from the same vocabulary and leverage the rich semantic information encoded in the embeddings. However, unlike ES, GDES does not allow the RTD loss to affect the gradients of the generator, thus avoiding the interference and inefficiency caused by the conflicting objectives. Instead, GDES only updates the generator embeddings with the MLM loss, which ensures the consistency and coherence of the generator output. As a result, GDES can achieve the same converging speed as NES, but without sacrificing the quality of the embeddings.
|
| 105 |
+
|
| 106 |
+
To implement GDES, we re-parameterize the discriminator embeddings as ${ \pmb { { \cal E } } } _ { D } = s g ( { \pmb { { \cal E } } } _ { G } ) + { \pmb { { \cal E } } } _ { \Delta }$ , where the stop gradient operator $s g$ prevents the gradients from flowing through the generator embeddings $E _ { G }$ and only updates the residual embeddings $\pmb { { \cal E } } _ { \Delta }$ . We initialize $\pmb { { \cal E } } _ { \Delta }$ as a zero matrix and train the model following the NES procedure. In each iteration, we first generate the inputs for the discriminator using the generator and update both $\pmb { { \cal E } } _ { G }$ and $E _ { D }$ with the MLM loss. Then, we run the discriminator on the generated inputs and update $\pmb { { \cal E } } _ { D }$ with the RTD loss, but only through $\pmb { { \cal E } } _ { \Delta }$ . After training, we add $\pmb { { \cal E } } _ { \Delta }$ to $E _ { G }$ and save the resulting matrix as $E _ { D }$ for the discriminator.
|
| 107 |
+
|
| 108 |
+
We conduct extensive experiments to evaluate the effectiveness of GDES compared to ES and NES. We measure the converging speed, the quality of the token embeddings, and the performance on downstream tasks. The results in Figure 2, Tables 1 and 2 demonstrate that GDES outperforms both ES and NES in various aspects. First, Figure 2 reveals that GDES converges faster than ES and matches the efficiency of NES. As GDES, ES and NES only differ at the way of embedding sharing, the computation cost of each step is the same. Second, Table 1 indicates that GDES produces two distinctive token embedding matrices, with the generator embeddings having higher average similarity
|
| 109 |
+
|
| 110 |
+

|
| 111 |
+
Figure 2: MLM training loss of the generator with different word embedding sharing methods.
|
| 112 |
+
|
| 113 |
+
scores than the discriminator embeddings. However, the difference is smaller than that in NES, suggesting that GDES preserves more semantic information in the discriminator embeddings through the partial weight sharing. Third, Table 2 shows that after fine-tuning, the model pre-trained with GDES achieves the best performance on two downstream tasks, MNLI and SQuAD v2.0. These results confirm that GDES is an effective weight-sharing method for language model pre-trained with MLM and RTD.
|
| 114 |
+
|
| 115 |
+
# 4 EXPERIMENT
|
| 116 |
+
|
| 117 |
+
# 4.1 MAIN RESULTS ON NLU TASKS
|
| 118 |
+
|
| 119 |
+
To further verify the effectiveness of those technologies, we combine RTD, GDES and DA (Disentangled Attention) to train models of different sizes(i.e., large, base and small) using standard pre-training settings. Since all of our experiments are modified based on DeBERTa code base and follow most of the settings of DeBERTa, we denote the new models as $\mathrm { D e B E R T a V } 3 _ { \mathrm { l a r g e } }$ , DeBERTaV3base, and DeBERTaV3small. The discriminator part of DeBERTaV3large and DeBER $\bar { \mathrm { T a V } } 3 _ { \mathrm { b a s e } }$ are the same as $\mathrm { D e B E R T a _ { l a r g e } }$ and $\mathrm { D e B E R T a _ { b a s e } }$ , respectively. The discriminator of $\mathrm { D e B E R T a V } 3 _ { \mathrm { s m a l l } }$ has the same width and attention heads as $\mathrm { D e B E R T a _ { b a s e } }$ and half the depth of $\mathrm { D e B E R T a _ { b a s e } }$ , i.e., 6 layers with 768 hidden size and 12 attention heads. The generator of DeBERTaV3 has the same width as the discriminator and half the depth of the discriminator. We train those models with 160GB data, which is the same as DeBERTaV2 and RoBERTa, and use the same SentencePiece (Kudo, 2018; Sennrich et al., 2016) vocabulary as DeBERTaV2 (He et al., 2020) which contains 128,000 tokens. All the models are trained for 500,000 steps with a batch size of 8192 and warming up steps of 10,000. The learning rate for base and small model is 5e-4, while the learning rate for large model is 3e-4. Following the DeBERTa setting, we use the AdamW (Loshchilov & Hutter, 2018) optimizer which is a fixed version of Adam (Kingma & Ba, 2014) with weight decay, and set $\beta _ { 1 } = 0 . 9$ , $\beta _ { 2 } = 0 . 9 8$ for the optimizer. After pre-training, the discriminators of those models are used for downstream task fine-tuning following the same paradigm as Transformer PLMs, such as BERT, RoBERTa, ELECTRA, and DeBERTa. We provide more details on the hyper parameters of pre-training and fine-tuning in the Appendix.
|
| 120 |
+
|
| 121 |
+
# 4.1.1 PERFORMANCE ON LARGE MODELS
|
| 122 |
+
|
| 123 |
+
Following previous studies on PLMs, we first evaluate our model on the eight NLU tasks in GLUE (Wang et al., 2019b), which are the most representative sentence classification tasks. We fine tune the pre-trained models on those tasks by plugging a classification head on top of the hidden states of the [CLS] token at the last layer. We summarize the results in Table 3, where DeBERTaV3 is compared with previous Transformer-based PLMs of similar structures (i.e., 24 layers with hidden size of 1024), including BERT, RoBERTa, XLNet (Yang et al., 2019), ALBERT (Lan et al., 2019), ELECTRA and DeBERTa. Compared to previous SOTA models, DeBERTaV3 performs consistently comparable or mostly better across all the tasks. Meanwhile, DeBERTaV3 outperforms XLNet in seven out of eight tasks. In terms of average GLUE score, DeBERTaV3 outperforms other SOTA PLMs with a large margin $( > 1 . 3 \%$ ). Particularly, compared with previous best numbers, there are big jumps on the performance of low resource tasks (i.e., RTE $( + 4 . 4 \% )$ , CoLA $\left( + 4 . 8 \% \right)$ ). This indicates DeBERTaV3 is more data efficient and has a better generalization performance. We also note that the improvements on SST-2, STS-B, and MRPC are relatively small $( < 0 . 3 \% )$ . We conjecture this is due to the performance on those tasks is close to be saturated, and thus even small but consistent improvements on them are valuable.
|
| 124 |
+
|
| 125 |
+
Table 3: Comparison results on the GLUE development set.
|
| 126 |
+
|
| 127 |
+
<table><tr><td rowspan=1 colspan=1>Model#Train</td><td rowspan=1 colspan=2>CoLAQQPMccAcc8.5k364k</td><td rowspan=1 colspan=1>MNLI-m/mmAcc393k</td><td rowspan=1 colspan=1>SST-2Acc67k</td><td rowspan=1 colspan=1>STS-BCorr7k</td><td rowspan=1 colspan=1>QNLI|Acc108k</td><td rowspan=1 colspan=1>RTEAcc2.5k</td><td rowspan=1 colspan=1>MRPCAcc3.7k</td><td rowspan=1 colspan=1>Avg.</td></tr><tr><td rowspan=1 colspan=1>BERTlarge</td><td rowspan=1 colspan=1>60.6</td><td rowspan=1 colspan=1>91.3</td><td rowspan=1 colspan=1>86.6/-</td><td rowspan=1 colspan=1>93.2</td><td rowspan=1 colspan=1>90.0</td><td rowspan=1 colspan=1>92.3</td><td rowspan=1 colspan=1>70.4</td><td rowspan=1 colspan=1>88.0</td><td rowspan=1 colspan=1>84.05</td></tr><tr><td rowspan=1 colspan=1>RoBERTalarge</td><td rowspan=1 colspan=1>68.0</td><td rowspan=1 colspan=1>92.2</td><td rowspan=1 colspan=1>90.2/90.2</td><td rowspan=1 colspan=1>96.4</td><td rowspan=1 colspan=1>92.4</td><td rowspan=1 colspan=1>93.9</td><td rowspan=1 colspan=1>86.6</td><td rowspan=1 colspan=1>90.9</td><td rowspan=1 colspan=1>88.82</td></tr><tr><td rowspan=1 colspan=1>XLNetlarge</td><td rowspan=1 colspan=1>69.0</td><td rowspan=1 colspan=1>92.3</td><td rowspan=1 colspan=1>90.8/90.8</td><td rowspan=1 colspan=1>97.0</td><td rowspan=1 colspan=1>92.5</td><td rowspan=1 colspan=1>94.9</td><td rowspan=1 colspan=1>85.9</td><td rowspan=1 colspan=1>90.8</td><td rowspan=1 colspan=1>89.15</td></tr><tr><td rowspan=1 colspan=1>ELECTRAlarge</td><td rowspan=1 colspan=1>69.1</td><td rowspan=1 colspan=1>92.4</td><td rowspan=1 colspan=1>90.9/-</td><td rowspan=1 colspan=1>96.9</td><td rowspan=1 colspan=1>92.6</td><td rowspan=1 colspan=1>95.0</td><td rowspan=1 colspan=1>88.0</td><td rowspan=1 colspan=1>90.8</td><td rowspan=1 colspan=1>89.46</td></tr><tr><td rowspan=1 colspan=1>DeBERTalarge</td><td rowspan=1 colspan=1>70.5</td><td rowspan=1 colspan=1>92.3</td><td rowspan=1 colspan=1>91.1/91.1</td><td rowspan=1 colspan=1>96.8</td><td rowspan=1 colspan=1>92.8</td><td rowspan=1 colspan=1>95.3</td><td rowspan=1 colspan=1>88.3</td><td rowspan=1 colspan=1>91.9</td><td rowspan=1 colspan=1>90.00</td></tr><tr><td rowspan=1 colspan=1>DeBERTaV3large</td><td rowspan=1 colspan=1>75.3</td><td rowspan=1 colspan=1>93.0</td><td rowspan=1 colspan=1>91.8/91.9</td><td rowspan=1 colspan=1>96.9</td><td rowspan=1 colspan=1>93.0</td><td rowspan=1 colspan=1>96.0</td><td rowspan=1 colspan=1>92.7</td><td rowspan=1 colspan=1>92.2</td><td rowspan=1 colspan=1>91.37</td></tr></table>
|
| 128 |
+
|
| 129 |
+
To further evaluate the model performance, in addition to GLUE, DeBERTaV3large is evaluated on three categories of representative NLU benchmarks: (1) Question Answering: SQuAD v2.0, RACE (Lai et al., 2017), ReCoRD (Zhang et al., 2018), and SWAG (Zellers et al., 2018); (2) Natural Language Inference: MNLI; and (3) NER: CoNLL-2003 (Sang & De Meulder, 2003). Among those tasks, RACE, SWAG, and MNLI are fine-tuned using a same way as sentence classification tasks. SQuAD v2.0, ReCoRD and NER are fine-tuned as sequence tagging tasks, where a token classification head is plugged on top of the hidden states of each token at the last layer. For comparison, we include ALBERTxxlarge 2, $\mathrm { D e B E R T a _ { l a r g e } }$ , $\mathrm { D e B E R T a _ { 1 . 5 B } }$ , and Megatron (Shoeybi et al., 2019) with three different model sizes, denoted as Megatron336M, Megatron1.3B and Megatron3.9B, which are trained using the same dataset as RoBERTa. Note that Megatron336M has a similar model size as other models mentioned above3. We summarize the results in Table 4. Compared to the previous
|
| 130 |
+
|
| 131 |
+
Table 4: Results on MNLI in/out-domain, SQuAD v2.0, RACE, ReCoRD, SWAG, CoNLL 2003 NER development set. Note that missing results in literature are signified by “-”.
|
| 132 |
+
|
| 133 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>MNLI-m/mmAcc</td><td rowspan=1 colspan=1>SQuAD v2.0|F1/EM</td><td rowspan=1 colspan=1>RACEAcc</td><td rowspan=1 colspan=2>ReCoRD SWAGF1/EM Acc</td><td rowspan=1 colspan=1>NERF1</td></tr><tr><td rowspan=1 colspan=1>BERTlarge</td><td rowspan=1 colspan=1>86.6/-</td><td rowspan=1 colspan=1>81.8/79.0</td><td rowspan=1 colspan=1>72.0</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>86.6</td><td rowspan=1 colspan=1>92.8</td></tr><tr><td rowspan=1 colspan=1>ALBERTlarge</td><td rowspan=1 colspan=1>86.5/-</td><td rowspan=1 colspan=1>84.9/81.8</td><td rowspan=1 colspan=1>75.2</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>RoBERTalarge</td><td rowspan=1 colspan=1>90.2/90.2</td><td rowspan=1 colspan=1>89.4/86.5</td><td rowspan=1 colspan=1>83.2</td><td rowspan=1 colspan=1>90.6/90.0</td><td rowspan=1 colspan=1>89.9</td><td rowspan=1 colspan=1>93.4</td></tr><tr><td rowspan=1 colspan=1>XLNet1arge</td><td rowspan=1 colspan=1>90.8/90.8</td><td rowspan=1 colspan=1>90.6/87.9</td><td rowspan=1 colspan=1>85.4</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>二</td></tr><tr><td rowspan=1 colspan=1>ELECTRAlarge</td><td rowspan=1 colspan=1>90.9/-</td><td rowspan=1 colspan=1>-/88.1</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>二</td><td rowspan=1 colspan=1>二</td><td rowspan=1 colspan=1>二</td></tr><tr><td rowspan=1 colspan=1>Megatron336M</td><td rowspan=1 colspan=1>89.7/90.0</td><td rowspan=1 colspan=1>88.1/84.8</td><td rowspan=1 colspan=1>83.0</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>1</td></tr><tr><td rowspan=1 colspan=1>DeBERTalarge</td><td rowspan=1 colspan=1>91.1/91.1</td><td rowspan=1 colspan=1>90.7/88.0</td><td rowspan=1 colspan=1>86.8</td><td rowspan=1 colspan=1>91.4/91.0</td><td rowspan=1 colspan=1>90.8</td><td rowspan=1 colspan=1>93.8</td></tr><tr><td rowspan=1 colspan=1>DeBERTaV3large</td><td rowspan=1 colspan=1>91.8/91.9</td><td rowspan=1 colspan=1>91.5/89.0</td><td rowspan=1 colspan=1>89.2</td><td rowspan=1 colspan=1>92.3/91.8</td><td rowspan=1 colspan=1>93.4</td><td rowspan=1 colspan=1>93.9</td></tr><tr><td rowspan=1 colspan=1>ALBERTxarge</td><td rowspan=1 colspan=1>90.8/-</td><td rowspan=1 colspan=1>90.2/87.4</td><td rowspan=1 colspan=1>86.5</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>二</td></tr><tr><td rowspan=1 colspan=1>Megatron1.3B</td><td rowspan=1 colspan=1>90.9/91.0</td><td rowspan=1 colspan=1>90.2/87.1</td><td rowspan=1 colspan=1>87.3</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>Megatron3.9B</td><td rowspan=1 colspan=1>91.4/91.4</td><td rowspan=1 colspan=1>91.2/88.5</td><td rowspan=1 colspan=1>89.5</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td></tr><tr><td rowspan=1 colspan=1>DeBERTa1.5B</td><td rowspan=1 colspan=1>91.7/91.9</td><td rowspan=1 colspan=1>92.2/89.7</td><td rowspan=1 colspan=1>90.8</td><td rowspan=1 colspan=1>94.5/94.0</td><td rowspan=1 colspan=1>92.3</td><td rowspan=1 colspan=1>-</td></tr></table>
|
| 134 |
+
|
| 135 |
+
SOTA PLMs with a similar model size (i.e., BERT, RoBERTa, XLNet, $\mathbf { A L B E R T _ { l a r g e } }$ , Megatron336M and $\mathrm { D e B E R T a _ { l a r g e } } ,$ ), DeBERTa $\mathrm { V } 3 _ { \mathrm { l a r g e } }$ shows superior performance on all six tasks. We see a big performance jump on RACE $( + 2 . 4 \% )$ and SWAG $( + 2 . 6 \% )$ , which require the models to have nontrivial reasoning capability and common-sense knowledge (Lai et al., 2017; Zellers et al., 2018). We conjecture those improvements indicate $\mathrm { D e B E R T a V } 3 _ { \mathrm { l a r g e } }$ has a better capability of reasoning and common sense knowledge. Although it is well proved to improve the model capacity by increasing the number of parameters (Raffel et al., 2020; Fedus et al., 2021), compared with larger models,
|
| 136 |
+
|
| 137 |
+
DeBERTaV3large outperforms $\mathbf { A L B E R T _ { x x l a r g e } }$ and Megatron1.3B by a large margin on all three tasks, as well as outperform Megatron3.3B on both MNLI and SQuAD v2.0. Compared with DeBERTa1.5B, which used to be the SOTA NLU models on GLUE and SuperGLUE leaderboards, DeBERTaV3large is still on par with it on MNLI but outperforms it on SWAG.
|
| 138 |
+
|
| 139 |
+
# 4.1.2 PERFORMANCE ON BASE AND SMALLER MODELS
|
| 140 |
+
|
| 141 |
+
We evaluate $\mathrm { D e B E R T a V } 3 _ { \mathrm { b a s e } }$ , $\mathrm { D e B E R T a V } 3 _ { \mathrm { s m a l l } }$ , and $\mathrm { D e B E R T a V } 3 _ { \mathrm { x s m a l l } }$ on two representative tasks, i.e., MNLI and SQuAD v2.0, and summarize the results in Table 5. DeBERTaV3base consistently outperforms $\mathrm { D e B E R T a _ { b a s e } }$ and ELECTR $\mathtt { A _ { b a s e } }$ by a larger margin than that in the Large models. For example, on MNLI-m, DeBERTa $\mathrm { V } 3 _ { \mathrm { b a s e } }$ obtains an improvement of $+ 1 . 8 ( 9 0 . 6 \%$ vs. $8 8 . 8 \%$ ) over both $\mathrm { D e B E R T a _ { b a s e } }$ and E $\mathrm { . E C T R A _ { b a s e } }$ . On $\mathrm { S Q u A D } \mathrm { v } 2 . 0$ in terms of the EM score, DeBERTaV3base achieves an improvement of $+ 4 . 9 \%$ $8 5 . 4 \%$ vs. $8 0 . 5 \%$ ) over ELECTRA $\mathbf { \nabla } \cdot \mathbf { b } \mathbf { a s e }$ and $+ 2 . 3 \%$ ( $8 5 . 4 \%$ vs $8 3 . 1 \%$ ) over DeBERTabase.
|
| 142 |
+
|
| 143 |
+
Table 5: Results on MNLI in/out-domain $\left( \mathrm { m } / \mathrm { m m } \right)$ and SQuAD $\mathrm { v } 2 . 0$ development set. TinyBERT $\mathrm { s m a l l }$ (Jiao et al., 2019), MiniL $\mathbf { M } \mathbf { v } 2 _ { \mathrm { s m a l l } }$ and MiniL $\mathbf { M } \mathbf { v } 2 _ { \mathrm { x s m a l l } }$ models are pre-trained with knowledge distillation while $\mathrm { B E R T _ { \mathrm { { s m a l l } } } }$ , $\mathrm { D e B E R T a V } 3 _ { \mathrm { s m a l l } }$ and $\mathrm { D e B E R T a V } 3 _ { \mathrm { x s m a l l } }$ are trained from scratch with MLM and RTD objective, respectively.
|
| 144 |
+
|
| 145 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>VocabularySize(K)</td><td rowspan=1 colspan=1>Backbone#Params(M)</td><td rowspan=1 colspan=1>MNLI-m/mmACC</td><td rowspan=1 colspan=1>SQuAD v2.0F1/EM</td></tr><tr><td rowspan=1 colspan=5>Base models:12 layers,768 hidden size,12 heads</td></tr><tr><td rowspan=1 colspan=1>BERTbase</td><td rowspan=1 colspan=1>30</td><td rowspan=1 colspan=1>86</td><td rowspan=1 colspan=1>84.3/84.7</td><td rowspan=1 colspan=1>76.3/73.7</td></tr><tr><td rowspan=1 colspan=1>RoBERTabase</td><td rowspan=1 colspan=1>50</td><td rowspan=1 colspan=1>86</td><td rowspan=1 colspan=1>87.6/-</td><td rowspan=1 colspan=1>83.7/80.5</td></tr><tr><td rowspan=1 colspan=1>XLNetbase</td><td rowspan=1 colspan=1>32</td><td rowspan=1 colspan=1>92</td><td rowspan=1 colspan=1>86.8/-</td><td rowspan=1 colspan=1>-/80.2</td></tr><tr><td rowspan=1 colspan=1>ELECTRAbase</td><td rowspan=1 colspan=1>30</td><td rowspan=1 colspan=1>86</td><td rowspan=1 colspan=1>88.8/-</td><td rowspan=1 colspan=1>-/80.5</td></tr><tr><td rowspan=1 colspan=1>DeBERTabase</td><td rowspan=1 colspan=1>50</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>88.8/88.5</td><td rowspan=1 colspan=1>86.2/83.1</td></tr><tr><td rowspan=1 colspan=1>DeBERTaV3base</td><td rowspan=1 colspan=1>128</td><td rowspan=1 colspan=1>86</td><td rowspan=1 colspan=1>90.6/90.7</td><td rowspan=1 colspan=1>88.4/85.4</td></tr><tr><td rowspan=1 colspan=5>Small models:6 layers,768 hidden size,12 heads</td></tr><tr><td rowspan=1 colspan=1>TinyBERTsmall</td><td rowspan=1 colspan=1>30</td><td rowspan=1 colspan=1>44</td><td rowspan=1 colspan=1>84.5/-</td><td rowspan=1 colspan=1>77.71-</td></tr><tr><td rowspan=1 colspan=1>MiniLMv2small</td><td rowspan=1 colspan=1>30</td><td rowspan=1 colspan=1>44</td><td rowspan=1 colspan=1>87.0/-</td><td rowspan=1 colspan=1>81.6/</td></tr><tr><td rowspan=1 colspan=1>BERTsmall</td><td rowspan=1 colspan=1>30</td><td rowspan=1 colspan=1>44</td><td rowspan=1 colspan=1>81.8/-</td><td rowspan=1 colspan=1>73.2/-</td></tr><tr><td rowspan=1 colspan=1>DeBERTaV3smalI</td><td rowspan=1 colspan=1>128</td><td rowspan=1 colspan=1>44</td><td rowspan=1 colspan=1>88.2/87.9</td><td rowspan=1 colspan=1>82.9/80.4</td></tr><tr><td rowspan=1 colspan=5>XSmall models:12 layers,384 hidden size,6 heads</td></tr><tr><td rowspan=1 colspan=1>MiniLMv2xsmall</td><td rowspan=1 colspan=1>30</td><td rowspan=1 colspan=1>22</td><td rowspan=1 colspan=1>86.9/-</td><td rowspan=1 colspan=1>82.3/</td></tr><tr><td rowspan=1 colspan=1>DeBERTaV3xsmall</td><td rowspan=1 colspan=1>128</td><td rowspan=1 colspan=1>22</td><td rowspan=1 colspan=1>88.1/88.3</td><td rowspan=1 colspan=1>84.8/82.0</td></tr></table>
|
| 146 |
+
|
| 147 |
+
Compared with smaller size models with similar model structures, DeBERTa $\mathrm { . V 3 _ { s m a l l } }$ outperforms $\mathrm { B E R T _ { \mathrm { { s m a l l } } } }$ (Wang et al., 2020b) by a large margin on those two tasks (i.e., a $6 . 4 \%$ improvement on MNLI- $\mathbf { m }$ and a $9 . 7 \%$ F1 score improvement on $\mathrm { S Q u A D \ v { 2 . 0 } } )$ . Surprisingly, even though $\mathrm { D e B E R T a V } 3 _ { \mathrm { x s m a l l } }$ has only half the parameters of $\mathrm { D e B E R T a V } 3 _ { \mathrm { s m a l l } }$ , it performs on par or even better than $\mathrm { D e B E R T a V } 3 _ { \mathrm { s m a l l } }$ on these two tasks. We conjecture that this is due to DeBERTaV3xsmall has deeper layers which allows to extract better semantic features. Without knowledge distillation, DeBERTaV3small outperforms $\mathbf { M i n i L M v } 2 _ { \mathrm { s m a l l } }$ (Wang et al., 2020a) by $1 . 2 \%$ and $1 . 3 \%$ on MNLI-m and SQuAD v2.0, respectively. DeBERTa $. \mathrm { V } 3 _ { \mathrm { x s m a l l } }$ outperforms MiniL $\mathrm { M v } 2 _ { \mathrm { x s m a l l } }$ (Wang et al., 2020a) by $1 . 2 \%$ and $2 . 5 \%$ on MNLI-m and SQuAD v2.0, respectively. It’s worth noting that, even though DeBERTaV3xsmall has only 1/4 backbone parameters of $\mathrm { R o B E R T a _ { b a s e } }$ and $\mathbf { X L N e t } _ { \mathrm { b a s e } }$ , the former significantly outperforms both models on these two representative tasks (i.e., $0 . 5 \%$ improvement on MNLI-m and $1 . 5 \%$ EM score improvement on SQuAD v2.0). This further demonstrates the efficiency of the DeBERTaV3 models.
|
| 148 |
+
|
| 149 |
+
# 4.2 MULTILINGUAL MODEL
|
| 150 |
+
|
| 151 |
+
As an important extension, we extend DeBERTaV3 to multi-lingual. We train the multi-lingual model with the 2.5T CC100 multi-lingual dataset which is the same as XLM-R. We denote the model as mDeBERTaV3base. We use the same SentencePiece vocabulary as mT5 which has $2 5 0 \mathrm { k }$ tokens. The model structure is the same as our base model, i.e., 768 hidden size, 12 layers, and 12 attention heads. It is worth noting that, unlike XLM or XLM-E, we have not trained our model with any parallel data
|
| 152 |
+
|
| 153 |
+
4. The pre-training settings are similar to XLM-R, except that we only train the model with $5 0 0 \mathrm { k }$ steps instead of 1.5M steps.
|
| 154 |
+
|
| 155 |
+
Table 6: Results on XNLI test set under the cross-lingual transfer and the translate-train-all settings.
|
| 156 |
+
|
| 157 |
+
<table><tr><td>Model</td><td>en</td><td>fr</td><td>es</td><td>de</td><td>el</td><td>bg</td><td>ru</td><td>tr</td><td>ar</td><td>vi</td><td>th</td><td>zh</td><td>hi</td><td>sw</td><td>ur</td><td>Avg</td></tr><tr><td>Cross-lingual transfer</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>XLM</td><td>83.2</td><td>76.7</td><td>77.7</td><td>74.0</td><td>72.7</td><td>74.1</td><td>72.7</td><td>68.7</td><td>68.6</td><td>72.9</td><td>68.9</td><td>72.5</td><td>65.6</td><td>58.2</td><td>62.4</td><td>70.7</td></tr><tr><td>mT5base</td><td>84.7</td><td>79.1</td><td>80.3</td><td>77.4</td><td>77.1</td><td>78.6</td><td>77.1</td><td>72.8</td><td>73.3</td><td>74.2</td><td>73.2</td><td>74.1</td><td>70.8</td><td>69.4</td><td>68.3</td><td>75.4</td></tr><tr><td>XLM-Rbase</td><td>85.8</td><td>79.7</td><td>80.7</td><td>78.7</td><td>77.5</td><td>79.6</td><td>78.1</td><td>74.2</td><td>73.8</td><td>76.5</td><td>74.6</td><td>76.7</td><td>72.4</td><td>66.5</td><td>68.3</td><td>76.2</td></tr><tr><td>mDeBERTaV3base</td><td>88.2</td><td>82.6</td><td>84.4</td><td>82.7</td><td>82.3</td><td>82.4</td><td>80.8</td><td>79.5</td><td>78.5</td><td>78.1</td><td>76.4</td><td>79.5</td><td>75.9</td><td>73.9</td><td>72.4</td><td>79.8</td></tr><tr><td>Translate train all</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>XLM</td><td>84.5</td><td>80.1</td><td>81.3</td><td>79.3</td><td>78.6</td><td>79.4</td><td>77.5</td><td>75.2</td><td>75.6</td><td>78.3</td><td>75.7</td><td>78.3</td><td>72.1</td><td>69.2</td><td>67.7</td><td>76.9</td></tr><tr><td>mT5base</td><td>82.0</td><td>77.9</td><td>79.1</td><td>77.7</td><td>78.1</td><td>78.5</td><td>76.5</td><td>74.8</td><td>74.4</td><td>74.5</td><td>75.0</td><td>76.0</td><td>72.2</td><td>71.5</td><td>70.4</td><td>75.9</td></tr><tr><td>XLM-Rbase</td><td>85.4</td><td>81.4</td><td>82.2</td><td>80.3</td><td>80.4</td><td>81.3</td><td>79.7</td><td>78.6</td><td>77.3</td><td>79.7</td><td>77.9</td><td>80.2</td><td>76.1</td><td>73.1</td><td>73.0</td><td>79.1</td></tr><tr><td>mDeBERTaV3base</td><td>88.9</td><td>84.4</td><td>85.3</td><td>84.8</td><td>84.0</td><td>84.5</td><td>83.2</td><td>82.0</td><td>81.6</td><td>82.0</td><td>79.8</td><td>82.6</td><td>79.3</td><td>77.3</td><td>73.6</td><td>82.2</td></tr></table>
|
| 158 |
+
|
| 159 |
+
As XNLI is one of the major benchmarks to measure multi-lingual model generalization performance, we evaluate the performance of mDeBERTaV3 on XNLI across 15 languages. Following previous multi-lingual PLMs, we report both the zero-shot cross-lingual transfer performance and the translatetrain-all performance. Zero-shot cross-lingual transfer is to fine-tune the model with English data only and evaluate it on multi-lingual test sets. translate-train-all is to fine-tune the model with English data and multi-lingual data translated from English data which is provided together with the XNLI dataset(Conneau et al., 2018), and then evaluate the model on multi-lingual test sets. As shown in Table 6, mDeBERTaV3base significantly outperforms previous SOTA model XLM- $\mathbf { \cdot R _ { b a s e } }$ on all languages under both settings. With regards to the average score, mDeBERTaV3base obtains an improvement of $+ 3 . 6 \%$ $7 9 . 8 \%$ v.s. $7 6 . 2 \%$ ) compared with XLM- $\mathbf { \cdot R _ { b a s e } }$ in the cross-lingual transfer setting, as well as achieves an improvement of $+ 3 . 1 \%$ $8 2 . 2 \%$ v.s. $7 9 . 1 \%$ ) compared with XLM- $\mathbf { \cdot R _ { b a s e } }$ under the translate-train-all setting. These results clearly show the effectiveness of DeBERTaV3 and the disentanglement is simultaneously valuable to multi-lingual pre-training.
|
| 160 |
+
|
| 161 |
+
All this clearly demonstrates the efficiency of the DeBERTaV3 models. The consistent improvements over a large range of the downstream tasks also show the huge value of improving pre-trained language models.
|
| 162 |
+
|
| 163 |
+
# 5 CONCLUSIONS
|
| 164 |
+
|
| 165 |
+
In this paper, we propose a novel pre-training paradigm for language models based on the combination of DeBERTa and ELECTRA, two state-of-the-art models that use relative position encoding and replaced token detection (RTD) respectively. We show that simply combining these two models leads to pre-training instability and inefficiency, due to a critical interference issue between the generator and the discriminator in the RTD framework which is well known as the “tug-of-war” dynamics. To address this issue, we introduce a novel embedding sharing paradigm called GDES, which is the main innovation and contribution of this work. GDES allows the discriminator to leverage the semantic information encoded in the generator’s embedding layer without interfering with the generator’s gradients and thus improves the pre-training efficiency. GDES defines a new way of sharing information between the generator and the discriminator in the RTD framework, which can be easily applied to other RTD-based language models. We conduct extensive analysis and experiments to compare GDES with other alternatives to verify its effectiveness.
|
| 166 |
+
|
| 167 |
+
Furthermore, we show that DeBERTaV3 with GDES achieves significant improvements over previous state-of-the-art (SOTA) models on various NLU tasks that cover different aspects of natural language understanding. For example, DeBERTaV3Large surpasses other models with a similar architecture by more than $1 . 3 7 \%$ on the GLUE average score and $\mathrm { m D e B E R T a V } 3 _ { \mathrm { b a s e } }$ beats $\mathbf { X L M - R _ { b a s e } }$ by $3 . 6 \%$ on the cross lingual transfer accuracy of the XNLI task. These results highlight the effectiveness of all the DeBERTaV3 models and establish DeBERTaV3 as the new SOTA pre-trained language models (PLMs) for natural language understanding at different model scales, i.e., Large, Base, Small and XSmall. Meanwhile, this work clearly shows huge potential to further improve model’s parameter efficiency and provide some direction for future studies of far more parameter-efficient pre-trained language models.
|
| 168 |
+
|
| 169 |
+
# REFERENCES
|
| 170 |
+
|
| 171 |
+
Roy Bar-Haim, Ido Dagan, Bill Dolan, Lisa Ferro, and Danilo Giampiccolo. The second PASCAL recognising textual entailment challenge. In Proceedings of the Second PASCAL Challenges Workshop on Recognising Textual Entailment, 01 2006.
|
| 172 |
+
|
| 173 |
+
Luisa Bentivogli, Ido Dagan, Hoa Trang Dang, Danilo Giampiccolo, and Bernardo Magnini. The fifth pascal recognizing textual entailment challenge. In In Proc Text Analysis Conference (TAC’09, 2009.
|
| 174 |
+
|
| 175 |
+
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.
|
| 176 |
+
|
| 177 |
+
Daniel Cer, Mona Diab, Eneko Agirre, Inigo Lopez-Gazpio, and Lucia Specia. Semeval-2017 task 1: Semantic textual similarity-multilingual and cross-lingual focused evaluation. arXiv preprint arXiv:1708.00055, 2017.
|
| 178 |
+
|
| 179 |
+
Zewen Chi, Shaohan Huang, Li Dong, Shuming Ma, Saksham Singhal, Payal Bajaj, Xia Song, and Furu Wei. Xlm-e: Cross-lingual language model pre-training via electra. arXiv preprint arXiv:2106.16138, 2021.
|
| 180 |
+
|
| 181 |
+
Kevin Clark, Minh-Thang Luong, Quoc V. Le, and Christopher D. Manning. ELECTRA: Pre-training text encoders as discriminators rather than generators. In ICLR, 2020.
|
| 182 |
+
|
| 183 |
+
Alexis Conneau, Ruty Rinott, Guillaume Lample, Adina Williams, Samuel Bowman, Holger Schwenk, and Veselin Stoyanov. Xnli: Evaluating cross-lingual sentence representations. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2475–2485, 2018.
|
| 184 |
+
|
| 185 |
+
Alexis Conneau, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzmán, Édouard Grave, Myle Ott, Luke Zettlemoyer, and Veselin Stoyanov. Unsupervised cross-lingual representation learning at scale. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 8440–8451, 2020.
|
| 186 |
+
|
| 187 |
+
Ido Dagan, Oren Glickman, and Bernardo Magnini. The pascal recognising textual entailment challenge. In Proceedings of the First International Conference on Machine Learning Challenges: Evaluating Predictive Uncertainty Visual Object Classification, and Recognizing Textual Entailment, MLCW’05, Berlin, Heidelberg, 2006.
|
| 188 |
+
|
| 189 |
+
Zihang Dai, Zhilin Yang, Yiming Yang, Jaime G Carbonell, Quoc Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 2978–2988, 2019.
|
| 190 |
+
|
| 191 |
+
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, 2019.
|
| 192 |
+
|
| 193 |
+
William B Dolan and Chris Brockett. Automatically constructing a corpus of sentential paraphrases. In Proceedings of the Third International Workshop on Paraphrasing (IWP2005), 2005.
|
| 194 |
+
|
| 195 |
+
William Fedus, Barret Zoph, and Noam Shazeer. Switch transformers: Scaling to trillion parameter models with simple and efficient sparsity. arXiv preprint arXiv:2101.03961, 2021.
|
| 196 |
+
|
| 197 |
+
Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, et al. Codebert: A pre-trained model for programming and natural languages. arXiv preprint arXiv:2002.08155, 2020.
|
| 198 |
+
|
| 199 |
+
Danilo Giampiccolo, Bernardo Magnini, Ido Dagan, and Bill Dolan. The third PASCAL recognizing textual entailment challenge. In Proceedings of the ACL-PASCAL Workshop on Textual Entailment and Paraphrasing, pp. 1–9, Prague, June 2007. Association for Computational Linguistics. URL https://www.aclweb.org/anthology/W07-1401.
|
| 200 |
+
|
| 201 |
+
Raia Hadsell, Dushyant Rao, Andrei A Rusu, and Razvan Pascanu. Embracing change: Continual learning in deep neural networks. Trends in Cognitive Sciences, 24(12):1028–1040, 2020.
|
| 202 |
+
|
| 203 |
+
Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. Deberta: Decoding-enhanced bert with disentangled attention. In International Conference on Learning Representations, 2020.
|
| 204 |
+
|
| 205 |
+
Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Ian Simon, Curtis Hawthorne, Noam Shazeer, Andrew M Dai, Matthew D Hoffman, Monica Dinculescu, and Douglas Eck. Music transformer: Generating music with long-term structure. 2018.
|
| 206 |
+
|
| 207 |
+
Xiaoqi Jiao, Yichun Yin, Lifeng Shang, Xin Jiang, Xiao Chen, Linlin Li, Fang Wang, and Qun Liu. Tinybert: Distilling bert for natural language understanding. arXiv preprint arXiv:1909.10351, 2019.
|
| 208 |
+
|
| 209 |
+
Kamal Raj Kanakarajan, Bhuvana Kundumani, and Malaikannan Sankarasubbu. Small-bench nlp: Benchmark for small single gpu trained models in natural language processing. ArXiv, abs/2109.10847, 2021.
|
| 210 |
+
|
| 211 |
+
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 212 |
+
|
| 213 |
+
Taku Kudo. Subword regularization: Improving neural network translation models with multiple subword candidates. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 66–75, 2018.
|
| 214 |
+
|
| 215 |
+
Guokun Lai, Qizhe Xie, Hanxiao Liu, Yiming Yang, and Eduard Hovy. Race: Large-scale reading comprehension dataset from examinations. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pp. 785–794, 2017.
|
| 216 |
+
|
| 217 |
+
Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. Albert: A lite bert for self-supervised learning of language representations. In International Conference on Learning Representations, 2019.
|
| 218 |
+
|
| 219 |
+
Hector Levesque, Ernest Davis, and Leora Morgenstern. The winograd schema challenge. In Thirteenth International Conference on the Principles of Knowledge Representation and Reasoning, 2012.
|
| 220 |
+
|
| 221 |
+
Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
|
| 222 |
+
|
| 223 |
+
Ilya Loshchilov and Frank Hutter. Fixing weight decay regularization in adam. 2018.
|
| 224 |
+
|
| 225 |
+
Yu Meng, Chenyan Xiong, Payal Bajaj, Saurabh Tiwary, Paul Bennett, Jiawei Han, and Xia Song. Coco-lm: Correcting and contrasting text sequences for language model pretraining. arXiv preprint arXiv:2102.08473, 2021.
|
| 226 |
+
|
| 227 |
+
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI Blog, 1(8), 2019.
|
| 228 |
+
|
| 229 |
+
Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21(140):1–67, 2020. URL http://jmlr.org/papers/v21/20-074.html.
|
| 230 |
+
|
| 231 |
+
Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. SQuAD: $^ { 1 0 0 , 0 0 0 + }$ questions for machine comprehension of text. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, November 2016.
|
| 232 |
+
|
| 233 |
+
Pranav Rajpurkar, Robin Jia, and Percy Liang. Know what you don’t know: Unanswerable questions for squad. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 2: Short Papers), pp. 784–789, 2018.
|
| 234 |
+
|
| 235 |
+
Erik Tjong Kim Sang and Fien De Meulder. Introduction to the conll-2003 shared task: Languageindependent named entity recognition. In Proceedings of the Seventh Conference on Natural Language Learning at HLT-NAACL 2003, pp. 142–147, 2003.
|
| 236 |
+
|
| 237 |
+
Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1715–1725, Berlin, Germany, August 2016. Association for Computational Linguistics. doi: 10.18653/v1/P16-1162. URL https://aclanthology. org/P16-1162.
|
| 238 |
+
|
| 239 |
+
Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), pp. 464–468, 2018.
|
| 240 |
+
|
| 241 |
+
Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley, Jared Casper, and Bryan Catanzaro. Megatron-lm: Training multi-billion parameter language models using gpu model parallelism. arXiv preprint arXiv:1909.08053, 2019.
|
| 242 |
+
|
| 243 |
+
Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D Manning, Andrew $\mathrm { N g }$ , and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 conference on empirical methods in natural language processing, pp. 1631–1642, 2013.
|
| 244 |
+
|
| 245 |
+
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998–6008, 2017.
|
| 246 |
+
|
| 247 |
+
Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel Bowman. Superglue: A stickier benchmark for general-purpose language understanding systems. In Advances in neural information processing systems, pp. 3266–3280, 2019a.
|
| 248 |
+
|
| 249 |
+
Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel Bowman. Glue: A multi-task benchmark and analysis platform for natural language understanding. In 7th International Conference on Learning Representations, ICLR 2019, 2019b.
|
| 250 |
+
|
| 251 |
+
Wenhui Wang, Hangbo Bao, Shaohan Huang, Li Dong, and Furu Wei. Minilmv2: Multi-head self-attention relation distillation for compressing pretrained transformers. arXiv preprint arXiv:2012.15828, 2020a.
|
| 252 |
+
|
| 253 |
+
Wenhui Wang, Furu Wei, Li Dong, Hangbo Bao, Nan Yang, and Ming Zhou. Minilm: Deep selfattention distillation for task-agnostic compression of pre-trained transformers. arXiv preprint arXiv:2002.10957, 2020b.
|
| 254 |
+
|
| 255 |
+
Alex Warstadt, Amanpreet Singh, and Samuel R Bowman. Neural network acceptability judgments. arXiv preprint arXiv:1805.12471, 2018.
|
| 256 |
+
|
| 257 |
+
Adina Williams, Nikita Nangia, and Samuel Bowman. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 1112–1122. Association for Computational Linguistics, 2018. URL http://aclweb.org/anthology/N18-1101.
|
| 258 |
+
|
| 259 |
+
Linting Xue, Noah Constant, Adam Roberts, Mihir Kale, Rami Al-Rfou, Aditya Siddhant, Aditya Barua, and Colin Raffel. mt5: A massively multilingual pre-trained text-to-text transformer. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 483–498, 2021.
|
| 260 |
+
|
| 261 |
+
Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Russ R Salakhutdinov, and Quoc V Le. Xlnet: Generalized autoregressive pretraining for language understanding. In Advances in neural information processing systems, pp. 5754–5764, 2019.
|
| 262 |
+
|
| 263 |
+
Rowan Zellers, Yonatan Bisk, Roy Schwartz, and Yejin Choi. Swag: A large-scale adversarial dataset for grounded commonsense inference. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 93–104, 2018.
|
| 264 |
+
|
| 265 |
+
Sheng Zhang, Xiaodong Liu, Jingjing Liu, Jianfeng Gao, Kevin Duh, and Benjamin Van Durme. ReCoRD: Bridging the gap between human and machine commonsense reading comprehension. arXiv preprint 1810.12885, 2018.
|
| 266 |
+
|
| 267 |
+
Yukun Zhu, Ryan Kiros, Rich Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja Fidler. Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. In Proceedings of the IEEE international conference on computer vision, pp. 19–27, 2015.
|
| 268 |
+
|
| 269 |
+
# A APPENDIX
|
| 270 |
+
|
| 271 |
+
# A.1 DATASET
|
| 272 |
+
|
| 273 |
+
Table 7: Summary information of the NLP application benchmarks.
|
| 274 |
+
|
| 275 |
+
<table><tr><td rowspan=1 colspan=2>Corpus Task</td><td rowspan=1 colspan=2>#Train #Dev</td><td rowspan=1 colspan=1>#Test</td><td rowspan=1 colspan=2>#Label Metrics</td></tr><tr><td rowspan=1 colspan=7>General Language Understanding Evaluation (GLUE)</td></tr><tr><td rowspan=1 colspan=1>CoLA</td><td rowspan=1 colspan=1>Acceptability</td><td rowspan=1 colspan=1>8.5k</td><td rowspan=1 colspan=1>1k</td><td rowspan=1 colspan=1>1k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Matthews corr</td></tr><tr><td rowspan=1 colspan=1>SST</td><td rowspan=1 colspan=1>Sentiment</td><td rowspan=1 colspan=1>67k</td><td rowspan=1 colspan=1>872</td><td rowspan=1 colspan=1>1.8k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>MNLI</td><td rowspan=1 colspan=1>NLI</td><td rowspan=1 colspan=1>393k</td><td rowspan=1 colspan=1>20k</td><td rowspan=1 colspan=1>20k</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>RTE</td><td rowspan=1 colspan=1>NLI</td><td rowspan=1 colspan=1>2.5k</td><td rowspan=1 colspan=1>276</td><td rowspan=1 colspan=1>3k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>WNLI</td><td rowspan=1 colspan=1>NLI</td><td rowspan=1 colspan=1>634</td><td rowspan=1 colspan=1>71</td><td rowspan=1 colspan=1>146</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>QQP</td><td rowspan=1 colspan=1>Paraphrase</td><td rowspan=1 colspan=1>364k</td><td rowspan=1 colspan=1>40k</td><td rowspan=1 colspan=1>391k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy/F1</td></tr><tr><td rowspan=1 colspan=1>MRPC</td><td rowspan=1 colspan=1>Paraphrase</td><td rowspan=1 colspan=1>3.7k</td><td rowspan=1 colspan=1>408</td><td rowspan=1 colspan=1>1.7k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy/F1</td></tr><tr><td rowspan=1 colspan=1>QNLI</td><td rowspan=1 colspan=1>QA/NLI</td><td rowspan=1 colspan=1>108k</td><td rowspan=1 colspan=1>5.7k</td><td rowspan=1 colspan=1>5.7k</td><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>STS-B</td><td rowspan=1 colspan=1>Similarity</td><td rowspan=1 colspan=1>7k</td><td rowspan=1 colspan=1>1.5k</td><td rowspan=1 colspan=1>1.4k</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>Pearson/Spearman corr</td></tr><tr><td rowspan=1 colspan=7>Question Answering</td></tr><tr><td rowspan=1 colspan=1>SQuAD v1.1</td><td rowspan=1 colspan=1>MRC</td><td rowspan=1 colspan=1>87.6k</td><td rowspan=1 colspan=1>10.5k</td><td rowspan=1 colspan=1>9.5k</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>Exact Match (EM)/F1</td></tr><tr><td rowspan=1 colspan=1>SQuAD v2.0</td><td rowspan=1 colspan=1>MRC</td><td rowspan=1 colspan=1>130.3k</td><td rowspan=1 colspan=1>11.9k</td><td rowspan=1 colspan=1>8.9k</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>Exact Match (EM)/F1</td></tr><tr><td rowspan=1 colspan=1>ReCoRD</td><td rowspan=1 colspan=1>MRC</td><td rowspan=1 colspan=1>101k</td><td rowspan=1 colspan=1>10k</td><td rowspan=1 colspan=1>10k</td><td rowspan=1 colspan=1>:</td><td rowspan=1 colspan=1>ExactMatch (EM)/F1</td></tr><tr><td rowspan=1 colspan=1>RACE</td><td rowspan=1 colspan=1>MRC</td><td rowspan=1 colspan=1>87,866</td><td rowspan=1 colspan=1>4,887</td><td rowspan=1 colspan=1>4,934</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>SWAG</td><td rowspan=1 colspan=1>Multiple choice</td><td rowspan=1 colspan=1>73.5k</td><td rowspan=1 colspan=1>20k</td><td rowspan=1 colspan=1>20k</td><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=7>Token Classification</td></tr><tr><td rowspan=1 colspan=3>CoNLL2003 NER 14,987</td><td rowspan=1 colspan=1>3,466</td><td rowspan=1 colspan=1>3,684</td><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>F1</td></tr><tr><td rowspan=1 colspan=3>Multi-lingualNatura</td><td rowspan=1 colspan=4>Multi-lingual Natural Language Inference(XNLI)</td></tr><tr><td rowspan=1 colspan=1>XNLIcross-lingual</td><td rowspan=1 colspan=1>NLI</td><td rowspan=1 colspan=1>393k</td><td rowspan=1 colspan=1>37k</td><td rowspan=1 colspan=1>75k</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>XNLItranslate train</td><td rowspan=1 colspan=1>NLI</td><td rowspan=1 colspan=1>5.9M</td><td rowspan=1 colspan=1>37k</td><td rowspan=1 colspan=1>75k</td><td rowspan=1 colspan=1>3</td><td rowspan=1 colspan=1>Accuracy</td></tr></table>
|
| 276 |
+
|
| 277 |
+
‚ GLUE. The General Language Understanding Evaluation (GLUE) benchmark is a collection of nine natural language understanding (NLU) tasks. As shown in Table 7, it includes question answering (Rajpurkar et al., 2016), linguistic acceptability (Warstadt et al., 2018), sentiment analysis (Socher et al., 2013), text similarity (Cer et al., 2017), paraphrase detection (Dolan & Brockett, 2005), and natural language inference (NLI) (Dagan et al., 2006; Bar-Haim et al., 2006; Giampiccolo et al., 2007; Bentivogli et al., 2009; Levesque et al., 2012; Williams et al., 2018). The diversity of the tasks makes GLUE very suitable for evaluating the generalization and robustness of NLU models.
|
| 278 |
+
|
| 279 |
+
‚ RACE is a large-scale machine reading comprehension dataset collected from English examinations in China designed for middle school and high school students (Lai et al., 2017).
|
| 280 |
+
|
| 281 |
+
‚ SQuAD v1.1/v2.0 is the Stanford Question Answering Dataset (SQuAD) v1.1 and v2.0 (Rajpurkar et al., 2016; 2018), two popular machine reading comprehension benchmarks from approximately 500 Wikipedia articles with questions and answers obtained by crowdsourcing. The SQuAD v2.0 dataset includes unanswerable questions about the same paragraphs.
|
| 282 |
+
|
| 283 |
+
‚ SWAG is a large-scale adversarial dataset for the task of grounded commonsense inference, which unifies natural language inference and physically grounded reasoning (Zellers et al., 2018). SWAG consists of 113k multiple choice questions about grounded situations.
|
| 284 |
+
|
| 285 |
+
‚ CoNLL 2003 (Sang & De Meulder, 2003) is an English dataset consisting of text from a wide variety of sources. It has 4 types of named entities.
|
| 286 |
+
|
| 287 |
+
‚ XNLI (Conneau et al., 2018) comes with ground truth dev and test sets in 15 languages, and a ground-truth English training set which is same as MNLI training set. The training set has been machine-translated to the remaining 14 languages, providing synthetic training data for these languages as well.
|
| 288 |
+
|
| 289 |
+
# A.2 PRE-TRAINING DATASET
|
| 290 |
+
|
| 291 |
+
For DeBERTaV3 pre-training, we use same data as RoBERTa and DeBERTa1.5B, which is a combination of Wikipedia, Bookcorpus, CCNews, Stories and OpenWebText. The multi-lingual version
|
| 292 |
+
|
| 293 |
+
of DeBERTaV3 is trained with 2.5TB CC100 data which is the same as XLM-R. For pre-training, we also sample $5 \%$ of the training data as the validation set to monitor the training process. Table 8 compares datasets used in different pre-trained models.
|
| 294 |
+
|
| 295 |
+
Table 8: Comparison of the pre-training data.
|
| 296 |
+
|
| 297 |
+
<table><tr><td rowspan=1 colspan=1>Model</td><td rowspan=1 colspan=1>16GB</td><td rowspan=1 colspan=1>38GB</td><td rowspan=1 colspan=1>31GB</td><td rowspan=1 colspan=1>76GB</td><td rowspan=1 colspan=1>16GB</td><td rowspan=1 colspan=1>19GB</td><td rowspan=1 colspan=1>110GB</td><td rowspan=1 colspan=1>2.5TB</td></tr><tr><td rowspan=1 colspan=1>BERT</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>XLNet</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>ELECTRA</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>了</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>RoBERTa</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1>√</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>DeBERTaDeBERTa1.5BDeBERTaV3</td><td rowspan=1 colspan=1>√√√</td><td rowspan=1 colspan=1>√√√</td><td rowspan=1 colspan=1>√√1</td><td rowspan=1 colspan=1>√√</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>mDeBERTaV3base</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>√</td></tr></table>
|
| 298 |
+
|
| 299 |
+
# A.3 GENERALITY OF GDES
|
| 300 |
+
|
| 301 |
+
To demonstrate the generality of GDES as an enhancement for RTD, we applied it to the ELECTRA setting, which we reproduced with a base model of 12 layers for the discriminator and 6 layers for the generator, both with the same hidden size. We used wikipedia+bookcorpus data to pre-train the model from scratch with a learning rate of 5e-4 and a batch size of 2k for $1 2 5 \mathrm { k }$ steps. We then evaluated the pre-trained models on MNLI and SQuAD v2.0 using the same setting as in Table 2. The results in Table 9, show that GDES can also improve the training efficiency of RTD in this setting, consistent with the findings in Table 2.
|
| 302 |
+
|
| 303 |
+
Table 9: Fine-tuning results on MNLI and SQuAD v2.0 tasks of base ELECTRA models trained with different embedding sharing methods.
|
| 304 |
+
|
| 305 |
+
<table><tr><td>Model</td><td>MNLI-m/mm Acc</td><td>SQuAD v2.0 F1/EM</td></tr><tr><td>ELECTRAbase</td><td>85.8/-</td><td>-/-</td></tr><tr><td colspan="3">ELECTRAbase</td></tr><tr><td>① Reimplemented (ES)</td><td>87.9/87.4</td><td>85.0/82.3</td></tr><tr><td>②NES</td><td>86.3/85.6</td><td>81.7/78.9</td></tr><tr><td>③GDES</td><td>88.3/87.8</td><td>85.9/83.1</td></tr></table>
|
| 306 |
+
|
| 307 |
+
# A.4 IMPLEMENTATION DETAILS
|
| 308 |
+
|
| 309 |
+
Our pre-training almost follows the same setting as DeBERTa (He et al., 2020). The generators are trained with MLM where we randomly replace $15 \%$ input tokens with [MASK] tokens. The discriminator is trained with RTD which is the same as ELECTRA. The experiments in Section 3 are trained using Wikipedia English data and Bookcorpus data with a batch size of 2k for $1 2 5 \mathrm { k }$ steps. The experiments in Section 4 are trained using data listed in Table 8 with a batch size of 8k for $5 0 0 \mathrm { k }$ steps. We list the detailed hyper parameters of pre-training in Table 10. For pre-training, we use Adam (Kingma & Ba, 2014) as the optimizer with weight decay (Loshchilov & Hutter, 2018). For fine-tuning, we use Adam (Kingma & Ba, 2014) as the optimizer for a fair comparison. For fine-tuning, we train each task with a hyper-parameter search procedure, each run taking about 1-2 hours on a DGX-2 node. All the hyper-parameters are presented in Table 11. The model selection is based on the performance on the task-specific development sets.
|
| 310 |
+
|
| 311 |
+
Our code is implemented based on DeBERTa (He et al., 2020)5 and ELECTRA (Clark et al., 2020)6.
|
| 312 |
+
|
| 313 |
+
Table 10: Hyper-parameters for pre-training DeBERTaV3.
|
| 314 |
+
|
| 315 |
+
<table><tr><td rowspan=1 colspan=2>Hyper-parameter</td><td rowspan=1 colspan=1>|DeBERTaV3large</td><td rowspan=1 colspan=1>DeBERTaV3base</td><td rowspan=1 colspan=1>|DeBERTaV3small</td><td rowspan=1 colspan=1>|mDeBERTaV3base</td><td rowspan=1 colspan=1>DeBERTaV3base-analysis</td></tr><tr><td rowspan=7 colspan=2>Number of LayersHidden sizeFNN inner hidden sizeAttention HeadsAttention Head sizeDropoutWarmup Steps</td><td rowspan=1 colspan=1>24</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>6</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>12</td></tr><tr><td rowspan=1 colspan=1>1024</td><td rowspan=1 colspan=1>768</td><td rowspan=1 colspan=1>768</td><td rowspan=1 colspan=1>768</td><td rowspan=1 colspan=1>768</td></tr><tr><td rowspan=1 colspan=1>4096</td><td rowspan=1 colspan=1>3072</td><td rowspan=1 colspan=1>3072</td><td rowspan=1 colspan=1>3072</td><td rowspan=1 colspan=1>3072</td></tr><tr><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>12</td><td rowspan=1 colspan=1>12</td></tr><tr><td rowspan=1 colspan=1>64</td><td rowspan=1 colspan=1>64</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>64</td><td rowspan=1 colspan=1>64</td></tr><tr><td rowspan=1 colspan=1>0.1</td><td rowspan=1 colspan=1>0.1</td><td rowspan=1 colspan=1>0.1</td><td rowspan=1 colspan=1>0.1</td><td rowspan=1 colspan=1>0.1</td></tr><tr><td rowspan=1 colspan=1>10k</td><td rowspan=1 colspan=1>10k</td><td rowspan=1 colspan=1>10k</td><td rowspan=1 colspan=1>10k</td><td rowspan=1 colspan=1>10k</td></tr><tr><td rowspan=4 colspan=2>Learning RatesBatch SizeWeight DecayMax Steps</td><td rowspan=1 colspan=1>3e-4</td><td rowspan=1 colspan=1>6e-4</td><td rowspan=1 colspan=1>6e-4</td><td rowspan=1 colspan=1>6e-4</td><td rowspan=1 colspan=1>5e-4</td></tr><tr><td rowspan=1 colspan=1>8k</td><td rowspan=1 colspan=1>8k</td><td rowspan=1 colspan=1>8k</td><td rowspan=1 colspan=1>8k</td><td rowspan=2 colspan=1>2k0.01</td></tr><tr><td rowspan=1 colspan=1>0.01</td><td rowspan=1 colspan=1>0.01</td><td rowspan=1 colspan=1>0.01</td><td rowspan=1 colspan=1>0.01</td></tr><tr><td rowspan=1 colspan=1>500k</td><td rowspan=1 colspan=1>500k</td><td rowspan=1 colspan=1>500k</td><td rowspan=1 colspan=1>500k</td><td rowspan=1 colspan=1>125k</td></tr><tr><td rowspan=2 colspan=2>Learning Rate DecayAdam ∈</td><td rowspan=1 colspan=1>Linear</td><td rowspan=1 colspan=1>Linear</td><td rowspan=1 colspan=1>Linear</td><td rowspan=1 colspan=1>Linear</td><td rowspan=1 colspan=1>Linear</td></tr><tr><td rowspan=1 colspan=1>1e-6</td><td rowspan=1 colspan=1>1e-6</td><td rowspan=1 colspan=1>1e-6</td><td rowspan=1 colspan=1>1e-6</td><td rowspan=1 colspan=1>1e-6</td></tr><tr><td rowspan=3 colspan=2>Adam β1Adam β2Gradient Clipping</td><td rowspan=1 colspan=1>0.9</td><td rowspan=1 colspan=1>0.9</td><td rowspan=1 colspan=1>0.9</td><td rowspan=1 colspan=1>0.9</td><td rowspan=1 colspan=1>0.9</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>0.98</td><td rowspan=1 colspan=1>0.98</td><td rowspan=1 colspan=1>0.98</td><td rowspan=1 colspan=1>0.98</td><td rowspan=2 colspan=1>0.9991.0</td></tr><tr><td rowspan=1 colspan=1>1.0</td><td rowspan=1 colspan=1>1.0</td><td rowspan=1 colspan=1>1.0</td><td rowspan=1 colspan=1>1.0</td></tr></table>
|
| 316 |
+
|
| 317 |
+
Table 11: Hyper-parameters for fine-tuning DeBERTaV3 on down-streaming tasks.
|
| 318 |
+
|
| 319 |
+
<table><tr><td>Hyper-parameter</td><td>DeBERTaV3large</td><td>DeBERTaV3base</td><td>DeBERTaV3small</td><td>mDeBERTaV3base</td></tr><tr><td>Dropout of task layer Warmup Steps</td><td>{0,0.15,0.3} {50,100,500,1000}</td><td>{0,0.1,0.15}</td><td>{0,0.1,0.15}</td><td>{0,0.1,0.15}</td></tr><tr><td>Learning Rates</td><td>{5e-6,8e-6,9e-6,1e-5}</td><td>{50,100,500,1000}</td><td>{50,100,500,1000}</td><td>{50,100,500,1000}</td></tr><tr><td></td><td></td><td>{1.5e-5,2e-5,2.5e-5,3e-5}</td><td>{1.5e-5,2e-5,3e-5,4e-5}</td><td>{1.5e-5,2e-5,2.5e-5,3e-5}</td></tr><tr><td>Batch Size</td><td>{16,32,64}</td><td>{16,32,48,64}</td><td>{16,32,48,64}</td><td>{16,32,48,64}</td></tr><tr><td>Weight Decay</td><td>0.01</td><td>0.01</td><td>0.01</td><td>0.01</td></tr><tr><td>Maximun Training Epochs</td><td>10</td><td>10</td><td>10</td><td>10</td></tr><tr><td>Learning Rate Decay</td><td>Linear</td><td>Linear</td><td>Linear</td><td>Linear</td></tr><tr><td>Adam e</td><td>1e-6</td><td>1e-6</td><td>1e-6</td><td>1e-6</td></tr><tr><td>Adam β1</td><td>0.9</td><td>0.9</td><td>0.9</td><td>0.9</td></tr><tr><td>Adam β2</td><td>0.999</td><td>0.999</td><td>0.999</td><td>0.999</td></tr><tr><td>Gradient Clipping</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1.0</td></tr></table>
|
md/dev/sde_7ZzGXOE/sde_7ZzGXOE.md
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Is Out-of-Distribution Detection Learnable?
|
| 2 |
+
|
| 3 |
+
Zhen Fang1, Yixuan $\mathbf { L i } ^ { 2 }$ , Jie ${ { \bf L } { \bf u } ^ { 1 } }$ ∗, Jiahua $\mathbf { D o n g } ^ { 3 , 4 }$ , Bo Han5, Feng Liu1,6∗
|
| 4 |
+
|
| 5 |
+
1Australian Artificial Intelligence Institute, University of Technology Sydney. 2Department of Computer Sciences, University of Wisconsin-Madison. 3State Key Laboratory of Robotics, Shenyang Institute of Automation, Chinese Academy of Sciences. 4ETH Zurich, Switzerland. 5Department of Computer Science, Hong Kong Baptist University. 6School of Mathematics and Statistics, University of Melbourne. {zhen.fang,jie.lu}@uts.edu.au, sharonli@cs.wisc.edu, dongjiahua1995@gmail.com,bhanml@comp.hkbu.edu.hk,feng.liu1@unimelb.edu.au
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Supervised learning aims to train a classifier under the assumption that training and test data are from the same distribution. To ease the above assumption, researchers have studied a more realistic setting: out-of-distribution (OOD) detection, where test data may come from classes that are unknown during training (i.e., OOD data). Due to the unavailability and diversity of OOD data, good generalization ability is crucial for effective OOD detection algorithms. To study the generalization of OOD detection, in this paper, we investigate the probably approximately correct (PAC) learning theory of OOD detection, which is proposed by researchers as an open problem. First, we find a necessary condition for the learnability of OOD detection. Then, using this condition, we prove several impossibility theorems for the learnability of OOD detection under some scenarios. Although the impossibility theorems are frustrating, we find that some conditions of these impossibility theorems may not hold in some practical scenarios. Based on this observation, we next give several necessary and sufficient conditions to characterize the learnability of OOD detection in some practical scenarios. Lastly, we also offer theoretical supports for several representative OOD detection works based on our OOD theory.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
The success of supervised learning is established on an implicit assumption that training and test data share a same distribution, i.e., in-distribution (ID) [1, 2, 3, 4]. However, test data distribution in many real-world scenarios may violate the assumption and, instead, contain out-of-distribution (OOD) data whose labels have not been seen during the training process [5, 6]. To mitigate the risk of OOD data, researchers have considered a more practical learning scenario: OOD detection which determines whether an input is ID/OOD, while classifying the ID data into respective classes. OOD detection has shown great potential to ensure the reliable deployment of machine learning models in the real world. A rich line of algorithms have been developed to empirically address the OOD detection problem [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]. However, very few works study theory of OOD detection, which hinders the rigorous path forward for the field. This paper aims to bridge the gap.
|
| 14 |
+
|
| 15 |
+
In this paper, we provide a theoretical framework to understand the learnability of the OOD detection problem. We investigate the probably approximately correct (PAC) learning theory of OOD detection, which is posed as an open problem to date. Unlike the classical PAC learning theory in a supervised setting, our problem setting is fundamentally challenging due to the absence of OOD data in training.
|
| 16 |
+
|
| 17 |
+
In many real-world scenarios, OOD data can be diverse and priori-unknown. Given this, we study whether there exists an algorithm that can be used to detect various OOD data instead of merely some specified OOD data. Such is the significance of studying the learning theory for OOD detection [4]. This motivates our question: is OOD detection PAC learnable? i.e., is there the PAC learning theory to guarantee the generalization ability of OOD detection?
|
| 18 |
+
|
| 19 |
+
To investigate the learning theory, we mainly focus on two basic spaces: domain space and hypothesis space. The domain space is a space consisting of some distributions, and the hypothesis space is a space consisting of some classifiers. Existing agnostic PAC theories in supervised learning [21, 22] are distribution-free, i.e., the domain space consists of all domains. Yet, in Theorem 4, we shows that the learning theory of OOD detection is not distribution-free. In fact, we discover that OOD detection is learnable only if the domain space and the hypothesis space satisfy some special conditions, e.g., Conditions 1 and 3. Notably, there are many conditions and theorems in existing learning theories and many OOD detection algorithms in the literature. Thus, it is very difficult to analyze the relation between these theories and algorithms, and explore useful conditions to ensure the learnability of OOD detection, especially when we have to explore them from the scratch. Thus, the main aim of our paper is to study these essential conditions. From these essential conditions, we can know when OOD detection can be successful in practical scenarios. We restate our question and goal in following:
|
| 20 |
+
|
| 21 |
+
Given hypothesis spaces and several representative domain spaces, what are the conditions to ensure the learnability of OOD detection? If possible, we hope that these conditions are necessary and sufficient in some scenarios.
|
| 22 |
+
|
| 23 |
+
Main Results. We investigate the learnability of OOD detection starting from the largest space—the total space, and give a necessary condition (Condition 1) for the learnability. However, we find that the overlap between ID and OOD data may result in that the necessary condition does not hold. Therefore, we give an impossibility theorem to demonstrate that OOD detection fails in the total space (Theorem 4). Next, we study OOD detection in the separate space, where there are no overlaps between the ID and OOD data. Unfortunately, there still exists impossibility theorem (Theorem 5), which demonstrates that OOD detection is not learnable in the separate space under some conditions.
|
| 24 |
+
|
| 25 |
+
Although the impossibility theorems obtained in the separate space are frustrating, we find that some conditions of these impossibility theorems may not hold in some practical scenarios. Based on this observation, we give several necessary and sufficient conditions to characterize the learnability of OOD detection in the separate space (Theorems 6 and 10). Especially, when our model is based on fully-connected neural network (FCNN), OOD detection is learnable in the separate space if and only if the feature space is finite. Furthermore, we investigate the learnability of OOD detection in other more practical domain spaces, e.g., the finite-ID-distribution space (Theorem 8) and the densitybased space (Theorem 9). By studying the finite-ID-distribution space, we discover a compatibility condition (Condition 3) that is a necessary and sufficient condition for this space. Next, we further investigate the compatibility condition in the density-based space, and find that such condition is also the necessary and sufficient condition in some practical scenarios (Theorem 11).
|
| 26 |
+
|
| 27 |
+
Implications and Impacts of Theory. Our study is not of purely theoretical interest; it has also practical impacts. First, when we design OOD detection algorithms, we normally only have finite ID datasets, corresponding to the finite-ID-distribution space. In this case, Theorem 8 gives the necessary and sufficient condition to the success of OOD detection. Second, our theory provides theoretical support (Theorems 10 and 11) for several representative OOD detection works [7, 8, 23]. Third, our theory shows that OOD detection is learnable in image-based scenarios when ID images have clearly different semantic labels and styles (far-OOD) from OOD images. Fourth, we should not expect a universally working algorithm. It is necessary to design different algorithms in different scenarios.
|
| 28 |
+
|
| 29 |
+
# 2 Learning Setups
|
| 30 |
+
|
| 31 |
+
We start by introducing the necessary concepts and notations for our theoretical framework. Given a feature space $\mathcal { X } \subset \mathbb { R } ^ { d }$ and a label space $\mathcal { V } : = \{ 1 , . . . , K \}$ , we have an ID joint distribution $D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } }$ over $\mathcal { X } \times \mathcal { V }$ , where $X _ { \mathrm { I } } \ \in \ { \mathcal { X } }$ and $Y _ { \mathrm { I } } ~ \in ~ \mathcal { V }$ are random variables. We also have an OOD joint distribution $D _ { X _ { \mathrm { O } } Y _ { \mathrm { O } } }$ , where $X _ { \mathrm { O } }$ is a random variable from $\mathcal { X }$ , but $Y _ { \mathrm { O } }$ is a random variable whose outputs do not belong to $\mathcal { V }$ . During testing, we will meet a mixture of ID and OOD joint distributions: $D _ { X Y } : = ( 1 - \pi ^ { \mathrm { o u t } } ) D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } } + \pi ^ { \mathrm { o u t } } D _ { X _ { \mathrm { O } } Y _ { \mathrm { O } } }$ , and can only observe the marginal distribution $D _ { X } : =$ $( 1 - \pi ^ { \mathrm { o u t } } ) D _ { X _ { \mathrm { I } } } + \pi ^ { \mathrm { o u t } } D _ { X _ { \mathrm { O } } }$ , where the constant $\pi ^ { \mathrm { { o u t } } } \in [ 0 , 1 )$ is an unknown class-prior probability.
|
| 32 |
+
|
| 33 |
+
Problem 1 (OOD Detection [4]). Given an $I D$ joint distribution $D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } }$ and a training data $S : =$ $\{ ( \mathbf { x } ^ { 1 } , y ^ { 1 } ) , . . . , ( \mathbf { x } ^ { n } , y ^ { n } ) \}$ drawn independent and identically distributed from $D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } }$ , the aim of OOD detection is to train a classifier $f$ by using the training data $S$ such that, for any test data x drawn from the mixed marginal distribution $D _ { X }$ : 1) $i f \mathbf { x }$ is an observation from $D _ { X _ { \mathrm { I } } }$ , $f$ can classify x into correct $I D$ classes; and 2) $i f \mathbf { x }$ is an observation from $D _ { X _ { \mathrm { O } } }$ , $f$ can detect x as OOD data.
|
| 34 |
+
|
| 35 |
+
According to the survey [4], when $K > 1$ , OOD detection is also known as the open-set recognition or open-set learning [24, 25]; and when $K = 1$ , OOD detection reduces to one-class novelty detection and semantic anomaly detection [26, 27, 28].
|
| 36 |
+
|
| 37 |
+
OOD Label and Domain Space. Based on Problem 1, we know it is not necessary to classify OOD data into the correct OOD classes. Without loss of generality, let all OOD data be allocated to one big OOD class, i.e., $Y _ { 0 } = K + 1$ [24, 29]. To investigate the PAC learnability of OOD detection, we define a domain space ${ \mathcal { D } } _ { X Y }$ , which is a set consisting of some joint distributions $D _ { X Y }$ mixed by some ID joint distributions and some OOD joint distributions. In this paper, the joint distribution $D _ { X Y }$ mixed by ID joint distribution $D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } }$ and OOD joint distribution $D _ { X _ { \mathrm { O } } Y _ { \mathrm { O } } }$ is called domain.
|
| 38 |
+
|
| 39 |
+
Hypothesis Spaces and Scoring Function Spaces. A hypothesis space $\mathcal { H }$ is a subset of function space, i.e., $\mathcal { H } \subset \{ h : \mathcal { X } \mathcal { V } \cup \{ K + 1 \} \}$ . We set $\mathcal { H } ^ { \mathrm { i n } } \subset \{ h : \mathcal { X } \mathcal { Y } \}$ to the ID hypothesis space. We also define $\mathcal { H } ^ { \mathrm { b } } \subset \{ h : \mathcal { X } \{ 1 , 2 \} \}$ as the hypothesis space for binary classification, where 1 represents the ID data, and 2 represents the OOD data. The function $h$ is called the hypothesis function. A scoring function space is a subset of function space, i.e., $\mathcal { F } _ { l } \subset \{ \mathbf { f } : \mathcal { X } \mathbb { R } ^ { l } \}$ , where $l$ is the output’s dimension of the vector-valued function f . The function f is called the scoring function.
|
| 40 |
+
|
| 41 |
+
Loss and Risks. Let $\mathcal { V } _ { \mathrm { a l l } } = \mathcal { V } \cup \{ K + 1 \}$ . Given a loss function $\ell ^ { 2 } : \mathcal { V } _ { \mathrm { a l l } } \times \mathcal { V } _ { \mathrm { a l l } } \to \mathbb { R } _ { \ge 0 }$ satisfying that $\ell ( y _ { 1 } , y _ { 2 } ) = 0$ if and only if $y _ { 1 } = y _ { 2 }$ , and any $h \in \mathcal H$ , then the risk with respect to $\bar { D } _ { X Y }$ is
|
| 42 |
+
|
| 43 |
+
$$
|
| 44 |
+
R _ { D } ( h ) : = \mathbb { E } _ { ( \mathbf { x } , y ) \sim D _ { X Y } } \ell ( h ( \mathbf { x } ) , y ) .
|
| 45 |
+
$$
|
| 46 |
+
|
| 47 |
+
The $\alpha$ -risk $R _ { D } ^ { \alpha } ( h ) : = ( 1 - \alpha ) R _ { D } ^ { \mathrm { i n } } ( h ) + \alpha R _ { D } ^ { \mathrm { o u t } } ( h ) , \forall \alpha \in [ 0 , 1 ] .$ , where the risks $R _ { D } ^ { \mathrm { i n } } ( h ) , R _ { D } ^ { \mathrm { o u t } } ( h )$ are
|
| 48 |
+
|
| 49 |
+
$$
|
| 50 |
+
R _ { D } ^ { \mathrm { i n } } ( h ) : = \mathbb { E } _ { ( \mathbf { x } , y ) \sim D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } } } \ell ( h ( \mathbf { x } ) , y ) , ~ R _ { D } ^ { \mathrm { o u t } } ( h ) : = \mathbb { E } _ { \mathbf { x } \sim D _ { X _ { \mathrm { O } } } } \ell ( h ( \mathbf { x } ) , K + 1 ) .
|
| 51 |
+
$$
|
| 52 |
+
|
| 53 |
+
Learnability. We aim to select a hypothesis function $h \in \mathcal H$ with approximately minimal risk, based on finite data. Generally, we expect the approximation to get better, with the increase in sample size. Algorithms achieving this are said to be consistent. Formally, we introduce the following definition:
|
| 54 |
+
|
| 55 |
+
Definition 1 (Learnability of OOD Detection). Given a domain space ${ \mathcal { D } } _ { X Y }$ and a hypothesis space $\mathcal { H } \subset \{ h : \mathcal { X } \mathcal { Y } _ { \mathrm { a l l } } \}$ , we say $o o D$ detection is learnable in ${ \mathcal { D } } _ { X Y }$ for $\mathcal { H }$ , if there exists an algorithm $\mathbf { A } ^ { 3 } : \cup _ { n = 1 } ^ { + \infty } ( \mathcal { X } \times \mathcal { Y } ) ^ { n } \mathcal { H }$ and a monotonically decreasing sequence $\epsilon _ { \mathrm { c o n s } } ( n )$ , such that $\epsilon _ { \mathrm { c o n s } } ( n ) 0$ , as $n + \infty$ , and for any domain $D _ { X Y } \in \mathcal { D } _ { X Y }$ ,
|
| 56 |
+
|
| 57 |
+
$$
|
| 58 |
+
\mathbb { E } _ { S \sim D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } } ^ { n } } \big [ R _ { D } ( \mathbf { A } ( S ) ) - \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ( h ) \big ] \le \epsilon _ { \mathrm { c o n s } } ( n ) ,
|
| 59 |
+
$$
|
| 60 |
+
|
| 61 |
+
An algorithm A for which this holds is said to be consistent with respect to ${ \mathcal { D } } _ { X Y }$
|
| 62 |
+
|
| 63 |
+
Definition 1 is a natural extension of agnostic PAC learnability of supervised learning [30]. If for any $D _ { X Y } \in \mathcal { D } _ { X Y }$ , $\pi ^ { \mathrm { o u t } } = 0$ , then Definition 2 is the agnostic PAC learnability of supervised learning. Although the expression of Definition 1 is different from the normal definition of agnostic PAC learning in [21], one can easily prove that they are equivalent when $\ell$ is bounded, see Appendix D.3.
|
| 64 |
+
|
| 65 |
+
Since OOD data are unavailable, it is impossible to obtain information about the class-prior probability $\pi ^ { \mathrm { { o u t } } }$ . Furthermore, in the real world, it is possible that $\pi ^ { \mathrm { { o u t } } }$ can be any value in $[ 0 , 1 )$ . Therefore, the imbalance issue between ID and OOD distributions, and the priori-unknown issue (i.e., $\pi ^ { \mathrm { { o u t } } }$ is unknown) are the core challenges. To ease these challenges, researchers use AUROC, AUPR and FPR95 to estimate the performance of OOD detection [18, 31, 32, 33, 34, 35]. It seems that there is a gap between Definition 1 and existing works. To eliminate this gap, we revise Eq. (2) as follows:
|
| 66 |
+
|
| 67 |
+
$$
|
| 68 |
+
\mathbb { E } _ { S \sim D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } } ^ { n } } \big [ R _ { D } ^ { \alpha } ( { \mathbf A } ( S ) ) - \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \alpha } ( h ) \big ] \le \epsilon _ { \mathrm { c o n s } } ( n ) , \ \forall \alpha \in [ 0 , 1 ] .
|
| 69 |
+
$$
|
| 70 |
+
|
| 71 |
+
If an algorithm A satisfies Eq. (3), then the imbalance issue and the prior-unknown issue disappear. That is, $\mathbf { A }$ can simultaneously classify the ID data and detect the OOD data well. Based on the above discussion, we define the strong learnability of OOD detection as follows:
|
| 72 |
+
|
| 73 |
+
Definition 2 (Strong Learnability of OOD Detection). Given a domain space ${ \mathcal { D } } _ { X Y }$ and a hypothesis space $\mathcal { H } \subset \{ h : \mathcal { X } \mathcal { Y } _ { \mathrm { a l l } } \}$ , we say $o o D$ detection is strongly learnable in ${ \mathcal { D } } _ { X Y }$ for $\mathcal { H }$ , if there exists an algorithm $\mathbf { A } : \cup _ { n = 1 } ^ { + \infty } ( \mathcal { X } \times \mathcal { Y } ) ^ { n } \mathcal { H }$ and a monotonically decreasing sequence $\epsilon _ { \mathrm { c o n s } } ( n )$ , such that $\epsilon _ { \mathrm { c o n s } } ( n ) 0$ , as $n + \infty$ , and for any domain $D _ { X Y } \in \mathcal { D } _ { X Y }$ ,
|
| 74 |
+
|
| 75 |
+
$$
|
| 76 |
+
\mathbb { E } _ { S \sim D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } } ^ { n } } \big [ R _ { D } ^ { \alpha } ( \mathbf { A } ( S ) ) - \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \alpha } ( h ) \big ] \le \epsilon _ { \mathrm { c o n s } } ( n ) , \ \forall \alpha \in [ 0 , 1 ] .
|
| 77 |
+
$$
|
| 78 |
+
|
| 79 |
+
In Theorem 1, we have shown that the strong learnability of OOD detection is equivalent to the learnability of OOD detection, if the domain space ${ \mathcal { D } } _ { X Y }$ is a prior-unknown space (see Definition 3). In this paper, we mainly discuss the learnability in the prior-unknown space. Therefore, when we mention that OOD detection is learnable, we also mean that OOD detection is strongly learnable.
|
| 80 |
+
|
| 81 |
+
Goal of Theory. Note that the agnostic PAC learnability of supervised learning is distribution-free, i.e., the domain space ${ \mathcal { D } } _ { X Y }$ consists of all domains. However, due to the absence of OOD data during the training process [8, 14, 24], it is obvious that the learnability of OOD detection is not distribution-free (i.e., Theorem 4). In fact, we discover that the learnability of OOD detection is deeply correlated with the relationship between the domain space ${ \mathcal { D } } _ { X Y }$ and the hypothesis space $\mathcal { H }$ . That is, OOD detection is learnable only when the domain space ${ \mathcal { D } } _ { X Y }$ and the hypothesis space $\mathcal { H }$ satisfy some special conditions, e.g., Condition 1 and Condition 3. We present our goal as follows:
|
| 82 |
+
|
| 83 |
+
Goal: given a hypothesis space $\mathcal { H }$ and several representative domain spaces ${ \mathcal { D } } _ { X Y }$ , what are the conditions to ensure the learnability of OOD detection? Furthermore, $i f$ possible, we hope that these conditions are necessary and sufficient in some scenarios.
|
| 84 |
+
|
| 85 |
+
Therefore, compared to the agnostic PAC learnability of supervised learning, our theory doesn’t focus on the distribution-free case, but focuses on discovering essential conditions to guarantee the learnability of OOD detection in several representative and practical domain spaces ${ \mathcal { D } } _ { X Y }$ . By these essential conditions, we can know when OOD detection can be successful in real applications.
|
| 86 |
+
|
| 87 |
+
# 3 Learning in Priori-unknown Spaces
|
| 88 |
+
|
| 89 |
+
We first investigate a special space, called prior-unknown space. In such space, Definition 1 and Definition 2 are equivalent. Furthermore, we also prove that if OOD detection is strongly learnable in a space ${ \mathcal { D } } _ { X Y }$ , then one can discover a larger domain space, which is prior-unknown, to ensure the learnability of OOD detection. These results imply that it is enough to consider our theory in the prior-unknown spaces. The prior-unknown space is introduced as follows:
|
| 90 |
+
|
| 91 |
+
Definition 3. Given a domain space ${ \mathcal { D } } _ { X Y }$ , we say ${ \mathcal { D } } _ { X Y }$ is a priori-unknown space, if for any domain $D _ { X Y } \in \mathcal { D } _ { X Y }$ and any $\alpha \in [ 0 , 1 )$ , we have $D _ { X Y } ^ { \alpha } : = ( 1 - \alpha ) D _ { X _ { \mathrm { I } Y _ { \mathrm { I } } } } + \alpha D _ { X _ { \mathrm { O } Y _ { \mathrm { O } } } } \in \mathcal { D } _ { X Y }$ .
|
| 92 |
+
|
| 93 |
+
Theorem 1. Given domain spaces ${ \mathcal { D } } _ { X Y }$ and $\mathcal { D } _ { X Y . } ^ { \prime } = \{ D _ { X Y } ^ { \alpha } : \forall D _ { X Y } \in \mathcal { D } _ { X Y } , \forall \alpha \in [ 0 , 1 ) \}$ , then 1) $\mathcal { D } _ { X Y } ^ { \prime }$ is a priori-unknown space and $\mathcal { D } _ { X Y } \subset \mathcal { D } _ { X Y } ^ { \prime }$ ; 2) if ${ \mathcal { D } } _ { X Y }$ is a priori-unknown space, then Definition $I$ and Definition 2 are equivalent; 3) OOD detection is strongly learnable in ${ \mathcal { D } } _ { X Y }$ if and only if OOD detection is learnable in $\mathcal { D } _ { X Y } ^ { \prime }$ .
|
| 94 |
+
|
| 95 |
+
The second result of Theorem 1 bridges the learnability and strong learnability, which implies that if an algorithm A is consistent with respect to a prior-unknown space, then this algorithm A can address the imbalance issue between ID and OOD distributions, and the priori-unknown issue well. Based on Theorem 1, we focus on our theory in the prior-unknown spaces. Furthermore, to demystify the learnability of OOD detection, we introduce five representative priori-unknown spaces:
|
| 96 |
+
|
| 97 |
+
• Single-distribution space $\mathcal { D } _ { X Y } ^ { D _ { X Y } }$ . For a domain $D _ { X Y }$ , $\mathcal { D } _ { X Y } ^ { D _ { X Y } } : = \{ D _ { X Y } ^ { \alpha } : \forall \alpha \in [ 0 , 1 ) \}$ . • Total space $\mathcal { D } _ { X Y } ^ { \mathrm { a l l } }$ , which consists of all domains. • Separate space ${ \mathcal { D } } _ { X Y } ^ { s }$ , which consists of all domains that satisfy the separate condition, that is for any $D _ { X Y } \in \mathcal { D } _ { X Y } ^ { s }$ , $\mathrm { s u p p } D _ { X _ { 0 } } \cap \mathrm { s u p p } D _ { X _ { \mathrm { I } } } = \emptyset$ , where supp means the support set. • Finite-ID-distribution space $\mathcal { D } _ { X Y } ^ { F }$ , which is a prior-unknown space satisfying that the number of distinct ID joint distributions $D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } }$ in $\mathcal { D } _ { X Y } ^ { F }$ is finite, i.e., $\vert \{ D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } } : \forall D _ { X Y } \in \mathcal { D } _ { X Y } ^ { F } \} \vert < + \infty$ . • Density-bathat: for any ace , th $\mathcal { D } _ { X Y } ^ { \mu , b }$ , which is a prior-unknists a density function n spawith of in omaand $D _ { X Y }$ $f$ $1 / b \leq f \leq \bar { b }$ $\operatorname { s u p p } \mu$ $0 . 5 * D _ { X _ { \mathrm { I } } } +$ $\textstyle 0 . 5 * D _ { X _ { \mathrm { O } } } = \int f \mathrm { d } \mu$ , where $\mu$ is a measure defined over $\mathcal { X }$ . Note that if $\mu$ is discrete, then $D _ { X }$ is a discrete distribution; and if $\mu$ is the Lebesgue measure, then $D _ { X }$ is a continuous distribution.
|
| 98 |
+
|
| 99 |
+

|
| 100 |
+
Figure 1: Illustration of $\mathrm { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \alpha } ( h )$ (solid lines with triangle marks) and the estimated $\mathbb { E } _ { S \sim D _ { \mathrm { i n } } ^ { n } } R _ { D } ^ { \alpha } ( \mathbf { A } ( S ) )$ (dash lines) with $\alpha \in [ 0 , 1 )$ in different scenarios, where $D _ { \mathrm { i n } } = D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } }$ and the algorithm A is the free-energy OOD detection method [23]. Subfigure (a) shows the ID and OOD distributions. In (a), $\mathrm { g a p _ { I O } }$ represents the distance between the support sets of ID and OOD distributions. In (b), since there is an overlap between ID and OOD data, the solid line is a ployline. In (c), since there is no overlap between ID and OOD data, we can check that $\mathrm { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \alpha } ( h )$ forms a straight line (the solid line). However, since dash lines are always straight lines, two observations can be obtained from (b) and (c): 1) dash lines cannot approximate the solid ployline in (b), which implies the unlearnability of OOD detection; and 2) the solid line in (c) is a straight line and may be approximated by the dash lines in (c). The above observations motivate us to propose Condition 1.
|
| 101 |
+
|
| 102 |
+
The above representative spaces widely exist in real applications. For example, 1) if the images from different semantic labels with different styles are clearly different, then those images can form a distribution belonging to a separate space ${ \mathcal { D } } _ { X Y } ^ { s }$ ; and 2) when designing an algorithm, we only have finite ID datasets, e.g., CIFAR-10, MNIST, SVHN, and ImageNet, to build a model. Then, finite-ID-distribution space $\mathcal { D } _ { X Y } ^ { F }$ can handle this real scenario. Note that the single-distribution space is a special case of the finite-ID-distribution space. In this paper, we mainly discuss these five spaces.
|
| 103 |
+
|
| 104 |
+
# 4 Impossibility Theorems for OOD Detection
|
| 105 |
+
|
| 106 |
+
In this section, we first give a necessary condition for the learnability of OOD detection. Then, we show this necessary condition does not hold in the total space $\mathcal { D } _ { X Y } ^ { \mathrm { a l l } }$ and the separate space ${ \mathcal { D } } _ { X Y } ^ { s }$ .
|
| 107 |
+
|
| 108 |
+
Necessary Condition. We find a necessary condition for the learnability of OOD detection, i.e., Condition 1, motivated by the experiments in Figure 1. Details of Figure 1 can be found in Appendix C.2.
|
| 109 |
+
|
| 110 |
+
Condition 1 (Linear Condition). For any $D _ { X Y } \in \mathcal { D } _ { X Y }$ and any $\alpha \in [ 0 , 1 )$ ,
|
| 111 |
+
|
| 112 |
+
$$
|
| 113 |
+
\operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \alpha } ( h ) = ( 1 - \alpha ) \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { i n } } ( h ) + \alpha \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { o u t } } ( h ) .
|
| 114 |
+
$$
|
| 115 |
+
|
| 116 |
+
To reveal the importance of Condition 1, Theorem 2 shows that Condition 1 is a necessary and sufficient condition for the learnability of OOD detection if the ${ \mathcal { D } } _ { X Y }$ is the single-distribution space.
|
| 117 |
+
|
| 118 |
+
Theorem 2. Given a hypothesis space $\mathcal { H }$ and a domain $D _ { X Y }$ , OOD detection is learnable in the single-distribution space $\mathcal { D } _ { X Y } ^ { D _ { X Y } }$ for $\mathcal { H }$ if and only if linear condition (i.e., Condition 1) holds.
|
| 119 |
+
|
| 120 |
+
Theorem 2 implies that Condition 1 is important for the learnability of OOD detection. Due to the simplicity of single-distribution space, Theorem 2 implies that Condition 1 is the necessary condition for the learnability of OOD detection in the prior-unknown space, see Lemma 1 in Appendix F.
|
| 121 |
+
|
| 122 |
+
Impossibility Theorems. Here, we first study whether Condition 1 holds in the total space $\mathcal { D } _ { X Y } ^ { \mathrm { a l l } }$ . If Condition 1 does not hold, then OOD detection is not learnable. Theorem 3 shows that Condition 1 is not always satisfied, especially, when there is an overlap between the $\mathrm { I D }$ and OOD distributions:
|
| 123 |
+
|
| 124 |
+
Definition 4 (Overlap Between ID and OOD). We say a domain $D _ { X Y }$ has overlap between $I D$ and OOD distributions, if there is a $\sigma$ -finite measure $\tilde { \mu }$ such that $D _ { X }$ is absolutely continuous with respect to $\tilde { \mu }$ , and $\tilde { \mu } ( A _ { \mathrm { o v e r l a p } } ) > 0$ , where $A _ { \mathrm { o v e r l a p } } = \{ \mathbf { x } \in \mathcal { X } : f _ { \mathrm { I } } ( \mathbf { x } ) > 0$ and $\dot { f } _ { \mathrm { O } } ( { \bf x } ) > 0 \}$ . Here $f _ { \mathrm { I } }$ and $f _ { \mathrm { O } }$ are the representers of $D _ { X _ { \mathrm { I } } }$ and $D _ { X _ { \mathrm { O } } }$ in Radon–Nikodym Theorem $I 3 6 J ,$ ,
|
| 125 |
+
|
| 126 |
+
$$
|
| 127 |
+
D _ { X _ { \mathrm { I } } } = \int f _ { \mathrm { I } } \mathrm { d } \tilde { \mu } , ~ D _ { X _ { \mathrm { O } } } = \int f _ { \mathrm { O } } \mathrm { d } \tilde { \mu } .
|
| 128 |
+
$$
|
| 129 |
+
|
| 130 |
+
Theorem 3. Given a hypothesis space $\mathcal { H }$ and a prior-unknown space ${ \mathcal { D } } _ { X Y }$ , if there is $D _ { X Y } \in \mathcal { D } _ { X Y }$ which has overlap between $I D$ and $O O D$ , and $\begin{array} { r } { \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { i n } } ( h ) \bar { = } 0 } \end{array}$ and $\begin{array} { r } { \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { o u t } } ( h ) = 0 , } \end{array}$ , then Condition 1 does not hold. Therefore, $o o D$ detection is not learnable in ${ \mathcal { D } } _ { X Y }$ for $\mathcal { H }$ .
|
| 131 |
+
|
| 132 |
+
Theorem 3 clearly shows that under proper conditions, Condition 1 does not hold, if there exists a domain whose ID and OOD distributions have overlap. By Theorem 3, we can obtain that the OOD detection is not learnable in the total space $\mathcal { D } _ { X Y } ^ { \mathrm { a l l } }$ for any non-trivial hypothesis space $\mathcal { H }$ .
|
| 133 |
+
|
| 134 |
+
Theorem 4 (Impossibility Theorem for Total Space). OOD detection is not learnable in the total space $\mathcal { D } _ { X Y } ^ { \mathrm { a l l } }$ for $\mathcal { H }$ , i $f | \phi \circ { \mathcal { H } } | > 1$ , where $\phi$ maps $I D$ labels to 1 and maps OOD labels to 2.
|
| 135 |
+
|
| 136 |
+
Since the overlaps between ID and OOD distributions may cause that Condition 1 does not hold, we then consider studying the learnability of OOD detection in the separate space ${ \mathcal { D } } _ { X Y } ^ { s }$ , where there are no overlaps between the ID and OOD distributions. However, Theorem 5 shows that even if we consider the separate space, the OOD detection is still not learnable in some scenarios. Before introducing the impossibility theorem for separate space, i.e., Theorem 5, we need a mild assumption:
|
| 137 |
+
|
| 138 |
+
Assumption 1 (Separate Space for OOD). A hypothesis space $\mathcal { H }$ is separate for OOD data, if for each data point $\mathbf { x } \in \mathcal { X }$ , there exists at least one hypothesis function $h _ { \mathbf { x } } \in \mathcal { H }$ such that $h _ { \mathbf { x } } ( \mathbf { x } ) = K + 1$ .
|
| 139 |
+
|
| 140 |
+
Assumption 1 means that every data point x has the possibility to be detected as OOD data. Assumption 1 is mild and can be satisfied by many hypothesis spaces, e.g., the FCNN-based hypothesis space (Proposition 1 in Appendix K), score-based hypothesis space (Proposition 2 in Appendix K) and universal kernel space. Next, we use Vapnik–Chervonenkis (VC) dimension [22] to measure the size of hypothesis space, and study the learnability of OOD detection in ${ \mathcal { D } } _ { X Y } ^ { s }$ based on the VC dimension.
|
| 141 |
+
|
| 142 |
+
Theorem 5 (Impossibility Theorem for Separate Space). If Assumption 1 holds, ${ \mathrm { V C d i m } } ( \phi \circ { \mathcal { H } } ) <$ $+ \infty$ and $\begin{array} { r } { \operatorname* { s u p } _ { h \in \mathcal { H } } | \{ \mathbf { x } \in \mathcal { X } : h ( \mathbf { x } ) \in \mathcal { V } \} | = + \infty } \end{array}$ , then OOD detection is not learnable in separate space ${ \mathcal { D } } _ { X Y } ^ { s }$ for $\mathcal { H }$ , where $\phi$ maps $I D$ labels to 1 and maps OOD labels to 2.
|
| 143 |
+
|
| 144 |
+
The finite VC dimension normally implies the learnability of supervised learning. However, in our results, the finite VC dimension cannot guarantee the learnability of OOD detection in the separate space, which reveals the difficulty of the OOD detection. Although the above impossibility theorems are frustrating, there is still room to discuss the conditions in Theorem 5, and to find out the proper conditions for ensuring the learnability of OOD detection in the separate space (see Sections 5 and 6).
|
| 145 |
+
|
| 146 |
+
# 5 When OOD Detection Can Be Successful
|
| 147 |
+
|
| 148 |
+
Here, we discuss when the OOD detection can be learnable in the separate space ${ \mathcal { D } } _ { X Y } ^ { s }$ , finite-IDdistribution space $\mathcal { D } _ { X Y } ^ { F }$ and density-based space $\mathcal { D } _ { X Y } ^ { \mu , b }$ . We first study the separate space ${ \mathcal { D } } _ { X Y } ^ { s }$ .
|
| 149 |
+
|
| 150 |
+
OOD Detection in the Separate Space. Theorem 5 has indicated that $\mathrm { V C d i m } ( \phi \circ { \mathcal { H } } ) = + \infty$ or $\begin{array} { r } { \operatorname* { s u p } _ { h \in \mathcal { H } } | \{ \mathbf { x } \in \mathcal { X } : h ( \mathbf { x } ) \in \mathcal { V } \} | < + \infty } \end{array}$ is necessary to ensure the learnability of OOD detection in ${ \mathcal { D } } _ { X Y } ^ { s }$ if Assumption 1 holds. However, generally, hypothesis spaces generated by feed-forward neural networks with proper activation functions have finite VC dimension [37, 38]. Therefore, we study the learnability of OOD detection in the case that $| \mathcal { X } | < + \infty$ , which implies that $\begin{array} { r } { \operatorname* { s u p } _ { h \in \mathcal { H } } | \{ \mathbf { x } \in \mathcal { X } : \qquad } \end{array}$ $h ( \mathbf { x } ) \in \mathcal { V } \} | < + \infty$ . Additionally, Theorem 10 also implies that $| { \mathcal { X } } | < + \infty$ is the necessary and sufficient condition for the learnability of OOD detection in separate space, when the hypothesis space is generated by FCNN. Hence, $| { \mathcal { X } } | < + \infty$ may be necessary in the space ${ \mathcal { D } } _ { X Y } ^ { s }$ .
|
| 151 |
+
|
| 152 |
+
For simplicity, we first discuss the case that $K = 1$ , i.e., the one-class novelty detection. We show the necessary and sufficient condition for the learnability of OOD detection in ${ \mathcal { D } } _ { X Y } ^ { s }$ , when $| \mathcal { X } | < + \infty$
|
| 153 |
+
|
| 154 |
+
Theorem 6. Let $K = 1$ and $| { \mathcal { X } } | < + \infty$ . Suppose that Assumption 1 holds and the constant function $h ^ { \mathrm { i n } } : = 1 \in \mathcal { H }$ . Then OOD detection is learnable in ${ \mathcal { D } } _ { X Y } ^ { s }$ for $\mathcal { H }$ if and only if $\mathcal { H } _ { \mathrm { a l l } } -$ $\{ h ^ { \mathrm { o u t } } \} \subset \mathcal { H }$ , where $\mathcal { H } _ { \mathrm { a l l } }$ is the hypothesis space consisting of all hypothesis functions, and $h ^ { \mathrm { o u t } }$ is a constant function that $h ^ { \mathrm { o u t } } : = 2$ , here 1 represents $I D$ data and 2 represents OOD data.
|
| 155 |
+
|
| 156 |
+
The condition $h ^ { \mathrm { i n } } \in \mathcal { H }$ presented in Theorem 6 is mild. Many practical hypothesis spaces satisfy this condition, e.g., the FCNN-based hypothesis space (Proposition 1 in Appendix K), score-based hypothesis space (Proposition 2 in Appendix K) and universal kernel-based hypothesis space. Theorem 6 implies that if $K = 1$ and OOD detection is learnable in ${ \mathcal { D } } _ { X Y } ^ { s }$ for $\mathcal { H }$ , then the hypothesis space $\mathcal { H }$ should contain almost all hypothesis functions, implying that if the OOD detection can be learnable in the distribution-agnostic case, then a large-capacity model is necessary.
|
| 157 |
+
|
| 158 |
+
Next, we extend Theorem 6 to a general case, i.e., $K > 1$ . When $K > 1$ , we will first use a binary classifier $h ^ { b }$ to classify the ID and OOD data. Then, for the ID data identified by $h ^ { b }$ , an ID hypothesis function $h ^ { \mathrm { i n } }$ will be used to classify them into corresponding ID classes. We state this strategy as follows: given a hypothesis space $\mathcal { H } ^ { \mathrm { i n } }$ for ID distribution and a binary classification hypothesis space $\mathcal { H } ^ { \mathrm { b } }$ introduced in Section 2, we use $\mathcal { H } ^ { \mathrm { i n } }$ and $\mathcal { H } ^ { \mathrm { b } }$ to construct an OOD detection’s hypothesis space $\mathcal { H }$ , which consists of all hypothesis functions $h$ satisfying the following condition: there exist $h ^ { \mathrm { i n } } \in \mathcal { H } ^ { \mathrm { i n } }$ and $h ^ { \mathrm { b } } \in \mathcal { H } ^ { b }$ such that for any $\mathbf { x } \in \mathcal { X }$ ,
|
| 159 |
+
|
| 160 |
+
$$
|
| 161 |
+
h ( \mathbf { x } ) = i , \mathrm { i f } h ^ { \mathrm { i n } } ( \mathbf { x } ) = i \mathrm { a n d } h ^ { \mathrm { b } } ( \mathbf { x } ) = 1 ; \mathrm { o t h e r w i s e } , h ( \mathbf { x } ) = K + 1 .
|
| 162 |
+
$$
|
| 163 |
+
|
| 164 |
+
We use $\mathcal { H } ^ { \mathrm { i n } } \bullet \mathcal { H } ^ { \mathrm { b } }$ to represent a hypothesis space consisting of all $h$ defined in Eq. (4). In addition, we also need an additional condition for the loss function $\ell$ . This condition is shown as follows:
|
| 165 |
+
|
| 166 |
+
Condition 2. $\ell ( y _ { 2 } , y _ { 1 } ) \leq \ell ( K + 1 , y _ { 1 } )$ , for any in-distribution labels $y _ { 1 }$ and $y _ { 2 } \in \mathcal { D }$ .
|
| 167 |
+
|
| 168 |
+
Theorem 7. Let $| { \mathcal { X } } | < + \infty$ and $\mathcal { H } = \mathcal { H } ^ { \mathrm { i n } } \bullet \mathcal { H } ^ { \mathrm { b } }$ . If $\mathcal { H } _ { \mathrm { a l l } } - \{ h ^ { \mathrm { o u t } } \} \subset \mathcal { H } ^ { \mathrm { b } }$ and Condition 2 holds, then OOD detection is learnable in ${ \mathcal { D } } _ { X Y } ^ { s }$ for $\mathcal { H }$ , where $\mathcal { H } _ { \mathrm { a l l } }$ and $h ^ { \mathrm { o u t } }$ are defined in Theorem $\cdot$ .
|
| 169 |
+
|
| 170 |
+
OOD Detection in the Finite-ID-Distribution Space. Since researchers can only collect finite ID datasets as the training data in the process of algorithm design, it is worthy to study the learnability of OOD detection in the finite-ID-distribution space $\mathcal { D } _ { X Y } ^ { F }$ . We first show two necessary concepts below.
|
| 171 |
+
|
| 172 |
+
Definition 5 (ID Consistency). Given a domain space ${ \mathcal { D } } _ { X Y }$ , we say any two domains $D _ { X Y } \in \mathcal { D } _ { X Y }$ and $D _ { X Y } ^ { \prime } \in \mathcal { D } _ { X Y }$ are $I D$ consistency, if $\mathrm { { } ^ { c } } D _ { X _ { \mathrm { { I } } } Y _ { \mathrm { { I } } } } = D _ { X _ { \mathrm { { I } } } Y _ { \mathrm { { I } } } } ^ { \prime }$ . We use the notation $\sim t o$ represent the $I D$ consistency, i.e., $D _ { X Y } \sim D _ { X Y } ^ { \prime }$ if and only if $D _ { X Y }$ and $D _ { X Y } ^ { \prime }$ are $I D$ consistency.
|
| 173 |
+
|
| 174 |
+
It is easy to check that the ID consistency $\sim$ is an equivalence relation. Therefore, we define the set $\left[ D _ { X Y } \right] : = \{ D _ { X Y } ^ { \prime } \in \mathcal { D } _ { X Y } : D _ { X Y } \sim D _ { X Y } ^ { \prime } \}$ as the equivalence class with respect to space ${ \mathcal { D } } _ { X Y }$ .
|
| 175 |
+
|
| 176 |
+
Condition 3 (Compatibility). For any equivalence class $[ D _ { X Y } ^ { \prime } ]$ with respect to ${ \mathcal { D } } _ { X Y }$ and any $\epsilon > 0$ there exists a hypothesis function $h _ { \epsilon } \in \mathcal { H }$ such that for any domain $D _ { X Y } \in [ D _ { X Y } ^ { \prime } ]$ ,
|
| 177 |
+
|
| 178 |
+
$$
|
| 179 |
+
h _ { \epsilon } \in \{ h ^ { \prime } \in \mathcal { H } : R _ { D } ^ { \mathrm { o u t } } ( h ^ { \prime } ) \leq \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { o u t } } ( h ) + \epsilon \} \cap \{ h ^ { \prime } \in \mathcal { H } : R _ { D } ^ { \mathrm { i n } } ( h ^ { \prime } ) \leq \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { i n } } ( h ) + \epsilon \} .
|
| 180 |
+
$$
|
| 181 |
+
|
| 182 |
+
In Appendix F, Lemma 2 has implied that Condition 3 is a general version of Condition 1. Next, Theorem 8 indicates that Condition 3 is the necessary and sufficient condition in the space $\mathcal { D } _ { X Y } ^ { F }$ .
|
| 183 |
+
|
| 184 |
+
Theorem 8. Suppose that $\mathcal { X }$ is a bounded set. OOD detection is learnable in the finite-IDdistribution space $\mathcal { D } _ { X Y } ^ { F }$ for $\mathcal { H }$ if and only if the compatibility condition (i.e., Condition 3) holds.√ Furthermore, the learning rate $\epsilon _ { \mathrm { c o n s } } ( n )$ can attain $O ( 1 / \sqrt { n ^ { 1 - \theta } } )$ , for any $\theta \in ( 0 , 1 )$ .
|
| 185 |
+
|
| 186 |
+
Theorem 8 shows that, in the process of algorithm design, OOD detection cannot be successful without the compatibility condition. Theorem 8 also implies that Condition 3 is essential for the learnability of OOD detection. This motivates us to study whether OOD detection can be successful in more general spaces (e.g., the density-based space), when the compatibility condition holds.
|
| 187 |
+
|
| 188 |
+
OOD Detection in the Density-based Space. To ensure that Condition 3 holds, we consider a basic assumption in learning theory—Realizability Assumption (see Appendix D.2), i.e., for any $D _ { X Y } \in \mathcal { D } _ { X Y }$ , there exists $h ^ { \ast } \in \mathcal { H }$ such that $R _ { D } ( h ^ { * } ) = 0$ . We discover that in the density-based space $\mathcal { D } _ { X Y } ^ { \mu , b }$ , Realizability Assumption can conclude the compatibility condition (i.e., Condition 3). Based on this observation, we can prove the following theorem:
|
| 189 |
+
|
| 190 |
+
Theorem 9. Given a density-based space $\mathcal { D } _ { X Y } ^ { \mu , b }$ , if $\mu ( { \mathcal { X } } ) < + \infty ,$ , the Realizability Assumption holds, then when $\mathcal { H }$ has finite Natarajan dimension [21], OOD detection is learnable in √ $\mathcal { D } _ { X Y } ^ { \mu , b } f o r$ H. Furthermore, the learning rate $\epsilon _ { \mathrm { c o n s } } ( n )$ can attain $O ( 1 / \sqrt { n ^ { 1 - \theta } } ) _ { \mathrm { { } } }$ , for any $\theta \in ( 0 , 1 )$ .
|
| 191 |
+
|
| 192 |
+
To further investigate the importance and necessary of Realizability Assumption, Theorem 11 has indicated that in some practical scenarios, Realizability Assumption is the necessary and sufficient condition for the learnability of OOD detection in the density-based space. Therefore, Realizability Assumption may be indispensable for the learnability of OOD detection in some practical scenarios.
|
| 193 |
+
|
| 194 |
+
# 6 Connecting Theory to Practice
|
| 195 |
+
|
| 196 |
+
In Section 5, we have shown the successful scenarios where OOD detection problem can be addressed in theory. In this section, we will discuss how the proposed theory is applied to two representative hypothesis spaces—neural-network-based hypothesis spaces and score-based hypothesis spaces.
|
| 197 |
+
|
| 198 |
+
Fully-connected Neural Networks. Given a sequence $\mathbf { q } = ( l _ { 1 } , l _ { 2 } , . . . , l _ { g } )$ , where $l _ { i }$ and $g$ are positive integers and $g > 2$ , we use $g$ to represent the depth of neural network and use $l _ { i }$ to represent the width of the $i$ -th layer. After the activation function $\sigma$ is selected4, we can obtain the architecture of FCNN according to the sequence q. Let $\mathbf { f } _ { \mathbf { w } , \mathbf { b } }$ be the function generated by FCNN with weights w and bias b. An FCNN-based scoring function space is defined as: $\mathcal { F } _ { \mathbf { q } } ^ { \sigma } : = \{ \dot { \mathbf { f } } _ { \mathbf { w } , \mathbf { b } } : \forall$ weights $\mathbf { w }$ , $\forall$ bias $\mathbf { b } \}$ . In addition, for simplicity, given any two sequences $\mathbf { q } = ( l _ { 1 } , \mathit { \bar { . . . , l _ { g } } } )$ and $\mathbf { q } ^ { \prime } = ( l _ { 1 } ^ { \prime } , . . . , l _ { g ^ { \prime } } ^ { \prime } )$ , we use the notation $\mathbf { q } \lesssim \mathbf { q } ^ { \prime }$ to represent the following equations and inequalities:
|
| 199 |
+
|
| 200 |
+
$$
|
| 201 |
+
) g \leq g ^ { \prime } , l _ { 1 } = l _ { 1 } ^ { \prime } , l _ { g } = l _ { g ^ { \prime } } ^ { \prime } ; ~ 2 ) l _ { i } \leq l _ { i } ^ { \prime } , \forall i = 1 , . . . , g - 1 ; ~ \mathrm { a n d } ~ 3 ) l _ { g - 1 } \leq l _ { i } ^ { \prime } , \forall i = g , . . . , g ^ { \prime } - 1 .
|
| 202 |
+
$$
|
| 203 |
+
|
| 204 |
+
In Appendix L, Lemma 10 shows $\mathbf { q } \lesssim \mathbf { q } ^ { \prime } \Rightarrow \mathcal { F } _ { \mathbf { q } } ^ { \sigma } \subset \mathcal { F } _ { \mathbf { q } ^ { \prime } } ^ { \sigma }$ . We use $\lesssim$ to compare the sizes of FCNNs.
|
| 205 |
+
|
| 206 |
+
FCNN-based Hypothesis Space. Let $l _ { g } = K + 1$ . The FCNN-based scoring function space $\mathcal { F } _ { \mathbf { q } } ^ { \sigma }$ can induce an FCNN-based hypothesis space. For any $\mathbf { f _ { w , b } } \in \mathcal { F } _ { \mathbf { q } } ^ { \sigma }$ , the induced hypothesis function is:
|
| 207 |
+
|
| 208 |
+
$$
|
| 209 |
+
h _ { \mathbf { w } , \mathbf { b } } : = \operatorname * { a r g m a x } _ { k \in \{ 1 , \dots , K + 1 \} } f _ { \mathbf { w } , \mathbf { b } } ^ { k } , { \mathrm { ~ w h e r e ~ } } f _ { \mathbf { w } , \mathbf { b } } ^ { k } { \mathrm { ~ i s ~ } } { \mathrm { ~ t h e ~ } } k { \mathrm { - t h ~ c o o r d i n a t e ~ o f ~ } } \mathbf { f _ { w , b } } .
|
| 210 |
+
$$
|
| 211 |
+
|
| 212 |
+
Then, the FCNN-based hypothesis space is defined as $\mathcal { H } _ { \mathbf { q } } ^ { \sigma } : = \{ h _ { \mathbf { w } , \mathbf { b } } : \forall $ weights w, $\forall$ bias b}.
|
| 213 |
+
|
| 214 |
+
Score-based Hypothesis Space. Many OOD detection algorithms detect OOD data by using a score-based strategy. That is, given a threshold $\lambda$ , a scoring function space $\mathcal { F } _ { l } \subset \{ \mathbf { f } : \dot { \mathcal { X } } \mathbb { R } ^ { l } \}$ and a scoring function $E : \mathcal { F } _ { l } \mathbb { R }$ , then $\mathbf { x }$ is regarded as ID data if and only if $E ( \mathbf { f } ( \mathbf { x } ) ) \geq \lambda$ . We introduce several representative scoring functions $E$ as follows: for any $\mathbf { f } = [ f ^ { 1 } , . . . , f ^ { l } ] ^ { \top } \in \mathcal { F } _ { l }$ , $\bullet$ softmax-based function [7] and temperature-scaled function [8]: $\lambda \in ( \frac { 1 } { l } , 1 )$ and $T > 0$ ,
|
| 215 |
+
|
| 216 |
+
$$
|
| 217 |
+
E ( \mathbf { f } ) = \operatorname* { m a x } _ { k \in \{ 1 , \ldots , l \} } \frac { \exp { ( f ^ { k } ) } } { \sum _ { c = 1 } ^ { l } \exp { ( f ^ { c } ) } } , \qquad E ( \mathbf { f } ) = \operatorname* { m a x } _ { k \in \{ 1 , \ldots , l \} } \frac { \exp { ( f ^ { k } / T ) } } { \sum _ { c = 1 } ^ { l } \exp { ( f ^ { c } / T ) } } ;
|
| 218 |
+
$$
|
| 219 |
+
|
| 220 |
+
• energy-based function [23]: $\lambda \in ( 0 , + \infty )$ and $T > 0$ ,
|
| 221 |
+
|
| 222 |
+
$$
|
| 223 |
+
E ( \mathbf { f } ) = T \log \sum _ { c = 1 } ^ { l } \exp { ( f ^ { c } / T ) } .
|
| 224 |
+
$$
|
| 225 |
+
|
| 226 |
+
Using $E , \lambda$ and $\mathbf { f } \in \mathcal { F } _ { \mathbf { q } } ^ { \sigma }$ , we have a classifier: $h _ { \mathbf { f } , E } ^ { \lambda } ( \mathbf { x } ) = 1$ , if $E ( \mathbf { f } ( \mathbf { x } ) ) \geq \lambda$ ; otherwise, $h _ { \mathbf { f } , E } ^ { \lambda } ( \mathbf { x } ) = 2$ , hypothesis space where 1 represents the ID data and 2 represents the OOD data. Hence, a binary classification $\mathcal { H } ^ { b }$ , which consists of all $h _ { \mathbf { f } , E } ^ { \lambda }$ , is generated. We define $\mathcal { H } _ { \mathbf { q } , E } ^ { \sigma , \lambda } : = \{ h _ { \mathbf { f } , E } ^ { \lambda } : \forall \mathbf { f } \in \mathcal { F } _ { \mathbf { q } } ^ { \sigma } \}$
|
| 227 |
+
|
| 228 |
+
Learnability of OOD Detection in Different Hypothesis Spaces. Next, we present applications of our theory regarding the above two practical and important hypothesis spaces $\mathcal { H } _ { \mathbf { q } } ^ { \sigma }$ and $\mathcal { H } _ { \mathbf { q } , E } ^ { \sigma , \lambda }$ .
|
| 229 |
+
|
| 230 |
+
Theorem 1based, i.e., e thor holds an, where e hypois an sis space hypothe $\mathcal { H }$ is FCN space, core-and $\mathcal { H } = \mathcal { H } _ { \mathbf { q } } ^ { \sigma }$ $\mathcal { H } = \mathcal { H } ^ { \mathrm { i n } } \bullet \mathcal { H } ^ { \mathrm { b } }$ ${ \mathcal { H } } ^ { \mathrm { i n } }$ $I D$ $\mathcal { H } ^ { \mathrm { b } } = \mathcal { H } _ { \mathbf { q } , E } ^ { \sigma , \lambda }$ $\mathcal { H } = \mathcal { H } ^ { \mathrm { i n } } \bullet \mathcal { H } ^ { \mathrm { b } }$ is introduced below Eq. (4), here $E$ is introduced in Eqs. (5) or (6). Then
|
| 231 |
+
|
| 232 |
+
Furthermore, if $^ { c } | \mathcal { X } | < + \infty$ , then there exists a sequence $\overline { { \mathbf { q } = ( l _ { 1 } , . . . , l _ { g } ) } }$ such that for any sequence $\mathbf { q } ^ { \prime }$ satisfying that $\mathbf { q } \lesssim \mathbf { q } ^ { \prime }$ , OOD detection is learnable in ${ \mathcal { D } } _ { X Y } ^ { s }$ for $\mathcal { H }$ .
|
| 233 |
+
|
| 234 |
+
Theorem 10 states that 1) when the hypothesis space is FCNN-based or score-based, the finite feature space is the necessary and sufficient condition for the learnability of OOD detection in the separate space; and 2) a larger architecture of FCNN has a greater probability to achieve the learnability of
|
| 235 |
+
|
| 236 |
+
OOD detection in the separate space. Note that when we select Eqs. (5) or (6) as the scoring function $E$ , Theorem 10 also shows that the selected scoring functions $E$ can guarantee the learnability of OOD detection, which is a theoretical support for the representative works [8, 23, 7]. Furthermore, Theorem 11 also offers theoretical supports for these works in the density-based space, when $K = 1$ .
|
| 237 |
+
|
| 238 |
+
Theorem 11. Suppose that each domain (the finite discrete domains satisfy this). $D _ { X Y }$ $\mathcal { D } _ { X Y } ^ { \mu , b }$ is attainable, i.e., arnd the hypothesis sp $\begin{array} { r } { \operatorname* { m i n } _ { h \in \mathcal { H } } R _ { D } ( h ) \neq \emptyset } \end{array}$ $K = 1$ $\mathcal { H }$ $\mathcal { H } = \mathcal { H } _ { \mathbf { q } , E } ^ { \sigma , \lambda }$ , where $E$ is in Eqs. (5) or (6)) or FCNN-based $\mathcal { H } = \mathcal { H } _ { \mathbf { q } } ^ { \sigma } ,$ ). If $\mu ( \mathcal { X } ) < + \infty ,$ , then the following four conditions are equivalent:
|
| 239 |
+
|
| 240 |
+
Learnability in $\mathcal { D } _ { X Y } ^ { \mu , b }$ for $\mathcal { H } \iff$ Condition $l \iff$ Realizability Assumption ⇐⇒ Condition 3
|
| 241 |
+
|
| 242 |
+
Theorem 11 still holds if the function space $\mathcal { F } _ { \mathbf { q } } ^ { \sigma }$ is generated by Convolutional Neural Network.
|
| 243 |
+
|
| 244 |
+
Overlap and Benefits of Multi-class Case. We investigate when the hypothesis space is FCNN-based or score-based, what will happen if there exists an overlap between the ID and OOD distributions?
|
| 245 |
+
|
| 246 |
+
Theorem 12. Let $K = 1$ and the hypothesis space $\mathcal { H }$ be score-based $\mathcal { H } = \mathcal { H } _ { \mathbf { q } , E } ^ { \sigma , \lambda }$ , where $E$ is in Eqs. (5) or (6)) or FCNN-based $( \mathcal { H } = \mathcal { H } _ { \mathbf { q } } ^ { \sigma }$ ). Given a prior-unknown space ${ \mathcal { D } } _ { X Y }$ , if there exists $a$ domain $D _ { X Y } \in \mathcal { D } _ { X Y }$ , which has an overlap between $I D$ and OOD distributions (see Definition 4), then OOD detection is not learnable in the domain space ${ \mathcal { D } } _ { X Y }$ for $\mathcal { H }$ .
|
| 247 |
+
|
| 248 |
+
When $K = 1$ and the hypothesis space is FCNN-based or score-based, Theorem 12 shows that overlap between ID and OOD distributions is the sufficient condition for the unlearnability of OOD detection. Theorem 12 takes roots in the conditions $\begin{array} { r } { \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { i n } } ( h ) = 0 } \end{array}$ and $\begin{array} { r } { \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { o u t } } ( h ) = 0 } \end{array}$ . However, when $K > 1$ , we can ensure $\begin{array} { r } { \operatorname* { i n f } _ { h \in \mathcal { H } } R _ { D } ^ { \mathrm { i n } } ( h ) > 0 } \end{array}$ if ID distribution $D _ { X _ { \mathrm { I } } Y _ { \mathrm { I } } }$ has overlap between ID classes. By this observation, we conjecture that when $K > 1$ , OOD detection is learnable in some special cases where overlap exists, even if the hypothesis space is FCNN-based or score-based.
|
| 249 |
+
|
| 250 |
+
# 7 Discussion
|
| 251 |
+
|
| 252 |
+
Understanding Far-OOD Detection. Many existing works [7, 39] study the far-OOD detection issue. Existing benchmarks include 1) MNIST [40] as ID dataset, and Texture [41], CIFAR-10 [42] or Place365 [43] as OOD datasets; and 2) CIFAR-10 [42] as ID dataset, and MNIST [40], or FashionMNIST [43] as OOD datasets. In far-OOD case, we find that the ID and OOD datasets have different semantic labels and different styles. From the theoretical view, we can define far-OOD detection tasks as follows: for $\tau > 0$ , a domain space ${ \mathcal { D } } _ { X Y }$ is $\tau$ -far-OOD, if for any domain $D _ { X Y } \in \mathcal { D } _ { X Y }$ ,
|
| 253 |
+
|
| 254 |
+
$$
|
| 255 |
+
\mathrm { d i s t } ( \mathrm { s u p p } D _ { X _ { \mathrm { O } } } , \mathrm { s u p p } D _ { X _ { \mathrm { I } } } ) > \tau .
|
| 256 |
+
$$
|
| 257 |
+
|
| 258 |
+
Theorems 7, 8 and 10 imply that under appropriate hypothesis space, $\tau$ -far-OOD detection is learnable. In Theorem 7, the condition $| \mathcal { X } | < + \infty$ is necessary for the separate space. However, one can prove that in the far-OOD case, when $\mathcal { H } ^ { \mathrm { i n } }$ is agnostic PAC learnable for ID distribution, the results in Theorem 7 still holds, if the condition $| { \mathcal { X } } | < + \infty$ is replaced by a weaker condition that $\mathcal { X }$ is compact. In addition, it is notable that when ${ \mathcal { H } } ^ { \mathrm { i n } }$ is agnostic PAC learnable for ID distribution and $\mathcal { X }$ is compact, the KNN-based OOD detection algorithm [44] is consistent in the $\tau$ -far-OOD case.
|
| 259 |
+
|
| 260 |
+
Understanding Near-OOD Detection. When the ID and OOD datasets have similar semantics or styles, OOD detection tasks become more challenging. [45, 46] consider this issue and name it near-OOD detection. Existing benchmarks include 1) MNIST [40] as ID dataset, and Fashion-MNIST [43] or Not-MNIST [47] as OOD datasets; and 2) CIFAR-10 [42] as ID dataset, and CIFAR-100 [48] as OOD dataset. From the theoretical view, some near-OOD tasks may imply the overlap condition, i.e. Definition 4. Therefore, Theorems 3 and 12 imply that near-OOD detection may be not learnable. Developing a theory to understand the feasibility of near-OOD detection is still an open question.
|
| 261 |
+
|
| 262 |
+
Understanding One-class Novelty Detection. In one-class novelty detection and semantic anomaly detection (i.e. $K = 1$ ), Theorem 6 has revealed that it is necessary to use a large-capacity model to ensure the good generalization in the separate space. Theorem 3 and Theorem 12 suggest that we should try to avoid the overlap between ID and OOD distributions in the one-class case. If the overlap cannot be avoided, we suggest considering the multi-class OOD detection instead of the one-class case. Additionally, in the density-based space, Theorem 11 has shown that it is necessary to select a suitable hypothesis space satisfying the Realizability Assumption to ensure the learnability of OOD detection in the density-based space. Generally, a large-capacity model can be helpful to guarantee that the Realizability Assumption holds.
|
| 263 |
+
|
| 264 |
+
# 8 Related Work
|
| 265 |
+
|
| 266 |
+
We briefly review the related theoretical works below. See Appendix A for detailed related works.
|
| 267 |
+
|
| 268 |
+
OOD Detection Theory. [49] understands the OOD detection via goodness-of-fit tests and typical set hypothesis, and argues that minimal density estimation errors can lead to OOD detection failures without assuming an overlap between ID and OOD distributions. Beyond [49], [50] paves a new avenue to designing provable OOD detection algorithms. Compared to [50, 49], our theory focuses on the PAC learnable theory of OOD detection and identifies several necessary and sufficient conditions for the learnability of OOD detection, opening a door to study OOD detection in theory.
|
| 269 |
+
|
| 270 |
+
Open-set Learning Theory. [51] and [29, 52] propose the agnostic PAC learning bounds for open-set detection and open-set domain adaptation, respectively. Unfortunately, [29, 51, 52] all require that the test data are indispensable during the training process. To investigate open-set learning (OSL) without accessing the test data during training, [24] proposes and investigates the almost agnostic PAC learnability for OSL. However, the assumptions used in [24] are very strong and unpractical.
|
| 271 |
+
|
| 272 |
+
Learning Theory for Classification with Reject Option. Many works [53, 54] also investigate the classification with reject option (CwRO) problem, which is similar to OOD detection in some cases. [55, 56, 57, 58, 59] study the learning theory and propose the PAC learning bounds for CwRO. However, compared to our work regarding OOD detection, existing CwRO theories mainly focus on how the ID risk $R _ { D } ^ { \mathrm { i n } }$ (i.e., the risk that ID data is wrongly classified) is influenced by special rejection rules. Our theory not only focuses on the ID risk, but also pays attention to the OOD risk.
|
| 273 |
+
|
| 274 |
+
Robust Statistics. In the field of robust statistics [60], researchers aim to propose estimators and testers that can mitigate the negative effects of outliers (similar to OOD data). The proposed estimators are supposed to be independent of the potentially high dimensionality of the data [61, 62, 63]. Existing works [64, 65, 66] in the field have identified and resolved the statistical limits of outlier robust statistics by constructing estimators and proving impossibility results. In the future, it is a promising and interesting research direction to study the robustness of OOD detection based on robust statistics.
|
| 275 |
+
|
| 276 |
+
PQ Learning Theory. Under some conditions, PQ learning theory [67, 68] can be regarded as the PAC theory for OOD detection in the semi-supervised or transductive learning cases, i.e., test data are required during training. Besides, [67, 68] aim to give the PAC estimation under Realizability Assumption [21]. Our theory does not only study the PAC estimation in the realization cases, but also studies the other cases, which are more difficult than PAC theory under Realizability Assumption.
|
| 277 |
+
|
| 278 |
+
# 9 Conclusions and Future Works
|
| 279 |
+
|
| 280 |
+
Detecting OOD data has shown its significance in improving the reliability of machine learning. However, very few works discuss OOD detection in theory, which hinders real-world applications of OOD detection algorithms. In this paper, we are the first to provide the PAC theory for OOD detection. Our results imply that we cannot expect a universally consistent algorithm to handle all scenarios in OOD detection. Yet, it is still possible to make OOD detection learnable in certain scenarios. For example, when we design OOD detection algorithms, we normally only have finite ID datasets. In this real scenario, Theorem 8 provides a necessary and sufficient condition for the success of OOD detection. Our theory reveals many necessary and sufficient conditions for the learnability of OOD detection, hence opening a door to studying the learnability of OOD detection. In the future, we will focus on studying the robustness of OOD detection based on robust statistics [64, 69].
|
| 281 |
+
|
| 282 |
+
# Acknowledgment
|
| 283 |
+
|
| 284 |
+
JL and ZF were supported by the Australian Research Council (ARC) under FL190100149. YL is supported by the AFOSR Young Investigator Program Award. BH was supported by the RGC Early Career Scheme No. 22200720 and NSFC Young Scientists Fund No. 62006202. ZF would also like to thank Prof. Peter Bartlett and Dr. Tongliang Liu for productive discussions.
|
| 285 |
+
|
| 286 |
+
# References
|
| 287 |
+
|
| 288 |
+
[1] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In ICLR, 2021. [2] Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks. In CVPR, 2017.
|
| 289 |
+
[3] Yen-Chang Hsu, Yilin Shen, Hongxia Jin, and Zsolt Kira. Generalized ODIN: detecting out-of-distribution image without learning from out-of-distribution data. In CVPR, 2020.
|
| 290 |
+
[4] Jingkang Yang, Kaiyang Zhou, Yixuan Li, and Ziwei Liu. Generalized out-of-distribution detection: A survey. CoRR, abs/2110.11334, 2021.
|
| 291 |
+
[5] Abhijit Bendale and Terrance E Boult. Towards open set deep networks. In CVPR, 2016.
|
| 292 |
+
[6] Jiefeng Chen, Yixuan Li, Xi Wu, Yingyu Liang, and Somesh Jha. Atom: Robustifying out-ofdistribution detection using outlier mining. ECML, 2021.
|
| 293 |
+
[7] Dan Hendrycks and Kevin Gimpel. A baseline for detecting misclassified and out-of-distribution examples in neural networks. In ICLR, 2017.
|
| 294 |
+
[8] Shiyu Liang, Yixuan Li, and R. Srikant. Enhancing the reliability of out-of-distribution image detection in neural networks. In ICLR, 2018.
|
| 295 |
+
[9] Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. In NeurIPS, 2018.
|
| 296 |
+
[10] Bo Zong, Qi Song, Martin Renqiang Min, Wei Cheng, Cristian Lumezanu, Dae-ki Cho, and Haifeng Chen. Deep autoencoding gaussian mixture model for unsupervised anomaly detection. In ICLR, 2018.
|
| 297 |
+
[11] Stanislav Pidhorskyi, Ranya Almohsen, and Gianfranco Doretto. Generative probabilistic novelty detection with adversarial autoencoders. In NeurIPS, 2018.
|
| 298 |
+
[12] Eric T. Nalisnick, Akihiro Matsukawa, Yee Whye Teh, Dilan Gor¨ ur, and Balaji Lakshmi- ¨ narayanan. Do deep generative models know what they don’t know? In ICLR, 2019.
|
| 299 |
+
[13] Dan Hendrycks, Mantas Mazeika, and Thomas G. Dietterich. Deep anomaly detection with outlier exposure. In ICLR, 2019.
|
| 300 |
+
[14] Jie Ren, Peter J. Liu, Emily Fertig, Jasper Snoek, Ryan Poplin, Mark A. DePristo, Joshua V. Dillon, and Balaji Lakshminarayanan. Likelihood ratios for out-of-distribution detection. In NeurIPS, 2019.
|
| 301 |
+
[15] Ziqian Lin, Sreya Dutta Roy, and Yixuan Li. Mood: Multi-level out-of-distribution detection. In CVPR, 2021.
|
| 302 |
+
[16] Mohammadreza Salehi, Hossein Mirzaei, Dan Hendrycks, Yixuan Li, Mohammad Hossein Rohban, and Mohammad Sabokrou. A unified survey on anomaly, novelty, open-set, and out-of-distribution detection: Solutions and future challenges. arXiv preprint arXiv:2110.14051, 2021.
|
| 303 |
+
[17] Yiyou Sun, Chuan Guo, and Yixuan Li. React: Out-of-distribution detection with rectified activations. In NeurIPS, 2021.
|
| 304 |
+
[18] Rui Huang, Andrew Geng, and Yixuan Li. On the Importance of Gradients for Detecting Distributional Shifts in the Wild. In NeurIPS, 2021.
|
| 305 |
+
[19] Stanislav Fort, Jie Ren, and Balaji Lakshminarayanan. Exploring the Limits of Out-ofDistribution Detection. In NeurIPS, 2021.
|
| 306 |
+
[20] Yifei Ming, Hang Yin, and Yixuan Li. On the impact of spurious correlation for out-ofdistribution detection. AAAI, 2022.
|
| 307 |
+
[21] Shai Shalev-Shwartz and Shai Ben-David. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014.
|
| 308 |
+
[22] Mehryar Mohri, Afshin Rostamizadeh, and Ameet Talwalkar. Foundations of machine learning. MIT press, 2018.
|
| 309 |
+
[23] Weitang Liu, Xiaoyun Wang, John D. Owens, and Yixuan Li. Energy-based out-of-distribution detection. In NeurIPS, 2020.
|
| 310 |
+
[24] Zhen Fang, Jie Lu, Anjin Liu, Feng Liu, and Guangquan Zhang. Learning bounds for open-set learning. In ICML, 2021.
|
| 311 |
+
[25] Guangyao Chen, Peixi Peng, Xiangqian Wang, and Yonghong Tian. Adversarial reciprocal points learning for open set recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
|
| 312 |
+
[26] Lukas Ruff, Nico Gornitz, Lucas Deecke, Shoaib Ahmed Siddiqui, Robert A. Vandermeulen, ¨ Alexander Binder, Emmanuel Muller, and Marius Kloft. Deep one-class classification. In ¨ ICML, 2018.
|
| 313 |
+
[27] Sachin Goyal, Aditi Raghunathan, Moksh Jain, Harsha Vardhan Simhadri, and Prateek Jain. DROCC: deep robust one-class classification. In ICML, 2020.
|
| 314 |
+
[28] Lucas Deecke, Robert A. Vandermeulen, Lukas Ruff, Stephan Mandt, and Marius Kloft. Image anomaly detection with generative adversarial networks. In ECML, 2018.
|
| 315 |
+
[29] Z. Fang, Jie Lu, F. Liu, Junyu Xuan, and G. Zhang. Open set domain adaptation: Theoretical bound and algorithm. IEEE Transactions on Neural Networks and Learning Systems, 2020.
|
| 316 |
+
[30] Shai Shalev-Shwartz, Ohad Shamir, Nathan Srebro, and Karthik Sridharan. Learnability, stability and uniform convergence. J. Mach. Learn. Res., 11:2635–2670, 2010.
|
| 317 |
+
[31] Guangyao Chen, Limeng Qiao, Yemin Shi, Peixi Peng, Jia Li, Tiejun Huang, Shiliang Pu, and Yonghong Tian. Learning open set network with discriminative reciprocal points. ICCV, 2020.
|
| 318 |
+
[32] Jiefeng Chen, Yixuan Li, Xi Wu, Yingyu Liang, and Somesh Jha. Informative outlier matters: Robustifying out-of-distribution detection using outlier mining. ICML Workshop, 2020.
|
| 319 |
+
[33] Jiefeng Chen, Yixuan Li, Xi Wu, Yingyu Liang, and Somesh Jha. Robust out-of-distribution detection for neural networks. arXiv preprint arXiv:2003.09711, 2020.
|
| 320 |
+
[34] Wentao Bao, Qi Yu, and Yu Kong. Evidential deep learning for open set action recognition. ICCV, 2021.
|
| 321 |
+
[35] Wentao Bao, Qi Yu, and Yu Kong. Opental: Towards open set temporal action localization. CVPR, 2022.
|
| 322 |
+
[36] Donald L Cohn. Measure theory. Springer, 2013.
|
| 323 |
+
[37] Peter L. Bartlett, Nick Harvey, Christopher Liaw, and Abbas Mehrabian. Nearly-tight vcdimension and pseudodimension bounds for piecewise linear neural networks. Journal of Machine Learning Research, 20(63):1–17, 2019.
|
| 324 |
+
[38] Marek Karpinski and Angus Macintyre. Polynomial bounds for VC dimension of sigmoidal and general pfaffian neural networks. J. Comput. Syst. Sci., 54(1):169–176, 1997.
|
| 325 |
+
[39] Jingkang Yang, Kaiyang Zhou, and Ziwei Liu. Full-spectrum out-of-distribution detection. CoRR, 2022.
|
| 326 |
+
[40] Li Deng. The MNIST database of handwritten digit images for machine learning research [best of the web]. IEEE Signal Process. Mag., 2012.
|
| 327 |
+
[41] Gustaf Kylberg. Kylberg texture dataset v. 1.0. 2011.
|
| 328 |
+
[42] Alex Krizhevsky and Geoff Hinton. Convolutional deep belief networks on cifar-10. Technical report, Citeseer, 2009.
|
| 329 |
+
[43] Bolei Zhou, Agata Lapedriza, Aditya Khosla, Aude Oliva, and Antonio Torralba. Places: A 10 \` million image database for scene recognition. IEEE Trans. Pattern Anal. Mach. Intell., 2018.
|
| 330 |
+
[44] Yiyou Sun, Yifei Ming, Xiaojin Zhu, and Yixuan Li. Out-of-distribution detection with deep nearest neighbors. In ICML, 2022.
|
| 331 |
+
[45] Jie Ren, Stanislav Fort, Jeremiah Liu, Abhijit Guha Roy, Shreyas Padhy, and Balaji Lakshminarayanan. A simple fix to mahalanobis distance for improving near-ood detection. CoRR, abs/2106.09022, 2021.
|
| 332 |
+
[46] Stanislav Fort, Jie Ren, and Balaji Lakshminarayanan. Exploring the limits of out-of-distribution detection. In NeurIPS, 2021.
|
| 333 |
+
[47] Yaroslav Bulatov. Notmnist dataset. Google (Books/OCR), Tech. Rep.[Online]. Available: http://yaroslavvb. blogspot. it/2011/09/notmnist-dataset. html,2, 2011.
|
| 334 |
+
[48] Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. Cifar-10 and cifar-100 datasets. 2009.
|
| 335 |
+
[49] Lily H. Zhang, Mark Goldstein, and Rajesh Ranganath. Understanding failures in out-ofdistribution detection with deep generative models. In ICML, 2021.
|
| 336 |
+
[50] Peyman Morteza and Yixuan Li. Provable guarantees for understanding out-of-distribution detection. AAAI, 2022.
|
| 337 |
+
[51] Si Liu, Risheek Garrepalli, Thomas G. Dietterich, Alan Fern, and Dan Hendrycks. Open category detection with PAC guarantees. In ICML, 2018.
|
| 338 |
+
[52] Yadan Luo, Zijian Wang, Zi Huang, and Mahsa Baktashmotlagh. Progressive graph learning for open-set domain adaptation. In ICML, 2020.
|
| 339 |
+
[53] C. K. Chow. On optimum recognition error and reject tradeoff. IEEE Transactions on Information Theory, 1970.
|
| 340 |
+
[54] Vojtech Franc, Daniel Pru˚sa, and V. Voracek. Optimal strategies for reject option classifiers. ˇ CoRR, abs/2101.12523, 2021.
|
| 341 |
+
[55] Corinna Cortes, Giulia DeSalvo, and Mehryar Mohri. Learning with rejection. In ALT, 2016.
|
| 342 |
+
[56] Corinna Cortes, Giulia DeSalvo, and Mehryar Mohri. Boosting with abstention. In NeurIPS, 2016.
|
| 343 |
+
[57] Chenri Ni, Nontawat Charoenphakdee, Junya Honda, and Masashi Sugiyama. On the calibration of multiclass classification with rejection. In NeurIPS, 2019.
|
| 344 |
+
[58] Nontawat Charoenphakdee, Zhenghang Cui, Yivan Zhang, and Masashi Sugiyama. Classification with rejection based on cost-sensitive classification. In ICML, 2021.
|
| 345 |
+
[59] Peter L. Bartlett and Marten H. Wegkamp. Classification with a reject option using a hinge loss. Journal of Machine Learning Research, 2008.
|
| 346 |
+
[60] Peter J Rousseeuw, Frank R Hampel, Elvezio M Ronchetti, and Werner A Stahel. Robust statistics: the approach based on influence functions. John Wiley & Sons, 2011.
|
| 347 |
+
[61] Elvezio M Ronchetti and Peter J Huber. Robust statistics. John Wiley & Sons, 2009.
|
| 348 |
+
[62] Ilias Diakonikolas, Daniel M. Kane, and Ankit Pensia. Outlier robust mean estimation with subgaussian rates via stability. In NeurIPS, 2020.
|
| 349 |
+
[63] Ilias Diakonikolas, Daniel Kane, Sushrut Karmalkar, Eric Price, and Alistair Stewart. Outlierrobust high-dimensional sparse estimation via iterative filtering. In NeurIPS, 2019.
|
| 350 |
+
[64] Ilias Diakonikolas, Daniel M. Kane, Alistair Stewart, and Yuxin Sun. Outlier-robust learning of ising models under dobrushin’s condition. In COLT, 2021.
|
| 351 |
+
[65] Yu Cheng, Ilias Diakonikolas, Daniel M Kane, Rong Ge, Shivam Gupta, and Mahdi Soltanolkotabi. Outlier-robust sparse estimation via non-convex optimization. In NeurIPS, 2021.
|
| 352 |
+
[66] Ilias Diakonikolas, Daniel M Kane, Jasper CH Lee, and Ankit Pensia. Outlier-robust sparse mean estimation for heavy-tailed distributions. In NeurIPS, 2022.
|
| 353 |
+
[67] Shafi Goldwasser, Adam Tauman Kalai, Yael Kalai, and Omar Montasser. Beyond perturbations: Learning guarantees with arbitrary adversarial test examples. In NeurIPS, 2020.
|
| 354 |
+
[68] Adam Tauman Kalai and Varun Kanade. Efficient learning with arbitrary covariate shift. In ALT, Proceedings of Machine Learning Research, 2021.
|
| 355 |
+
[69] Ilias Diakonikolas and Daniel M. Kane. Recent advances in algorithmic high-dimensional robust statistics. A shorter version appears as an Invited Book Chapter in Beyond the Worst-Case Analysis of Algorithms, 2020.
|
| 356 |
+
[70] Akshay Raj Dhamija, Manuel Gunther, and Terrance E. Boult. Reducing network agnostophobia. ¨ In NeurIPS, pages 9175–9186, 2018.
|
| 357 |
+
[71] Haoran Wang, Weitang Liu, Alex Bocchieri, and Yixuan Li. Can multi-label classification networks know what they don’t know? In NeurIPS, 2021.
|
| 358 |
+
[72] Diederik P. Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. In NeurIPS, 2018.
|
| 359 |
+
[73] Zhisheng Xiao, Qing Yan, and Yali Amit. Likelihood regret: An out-of-distribution detection score for variational auto-encoder. In NeurIPS, 2020.
|
| 360 |
+
[74] Alireza Zaeemzadeh, Niccolo Bisagno, Zeno Sambugaro, Nicola Conci, Nazanin Rahnavard, ´ and Mubarak Shah. Out-of-distribution detection using union of 1-dimensional subspaces. In CVPR, 2021.
|
| 361 |
+
[75] Joost Van Amersfoort, Lewis Smith, Yee Whye Teh, and Yarin Gal. Uncertainty estimation using a single deep deterministic neural network. In ICML, 2020.
|
| 362 |
+
[76] Sachin Vernekar, Ashish Gaurav, Vahdat Abdelzad, Taylor Denouden, Rick Salay, and Krzysztof Czarnecki. Out-of-distribution detection in classifiers via generation. In NeurIPS Workshop, 2019.
|
| 363 |
+
[77] Ryuichi Kiryo, Gang Niu, Marthinus Christoffel du Plessis, and Masashi Sugiyama. Positiveunlabeled learning with non-negative risk estimator. In NeurIPS, 2017.
|
| 364 |
+
[78] Takashi Ishida, Gang Niu, and Masashi Sugiyama. Binary classification from positiveconfidence data. In NeurIPS, 2018.
|
| 365 |
+
[79] Shuo Chen, Gang Niu, Chen Gong, Jun Li, Jian Yang, and Masashi Sugiyama. Large-margin contrastive learning with distance polarization regularizer. In ICML, 2021.
|
| 366 |
+
[80] Jiahua Dong, Yang Cong, Gan Sun, Bineng Zhong, and Xiaowei Xu. What can be transferred: Unsupervised domain adaptation for endoscopic lesions segmentation. In CVPR, 2020.
|
| 367 |
+
[81] Zhen Fang, Jie Lu, Feng Liu, and Guangquan Zhang. Semi-supervised heterogeneous domain adaptation: Theory and algorithms. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
|
| 368 |
+
[82] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.
|
| 369 |
+
[83] Arthur Gretton, Karsten M. Borgwardt, Malte J. Rasch, Bernhard Scholkopf, and Alexander J. ¨ Smola. A kernel two-sample test. Journal of Machine Learning Research, 2012.
|
| 370 |
+
[84] Itay Safran and Ohad Shamir. Depth-width tradeoffs in approximating natural functions with neural networks. In ICML, 2017.
|
| 371 |
+
[85] Allan Pinkus. Approximation theory of the mlp model in neural networks. Acta numerica, 8: 143–195, 1999.
|
| 372 |
+
[86] Peter L Bartlett and Wolfgang Maass. Vapnik-chervonenkis dimension of neural nets. The handbook of brain theory and neural networks, 2003.
|
| 373 |
+
|
| 374 |
+
# Checklist
|
| 375 |
+
|
| 376 |
+
1. For all authors...
|
| 377 |
+
|
| 378 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
|
| 379 |
+
(b) Did you describe the limitations of your work? [Yes] See Appendix B
|
| 380 |
+
(c) Did you discuss any potential negative societal impacts of your work? [Yes] See Appendix B
|
| 381 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 382 |
+
|
| 383 |
+
2. If you are including theoretical results...
|
| 384 |
+
|
| 385 |
+
(a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes]
|
| 386 |
+
|
| 387 |
+
3. If you ran experiments...
|
| 388 |
+
|
| 389 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [N/A]
|
| 390 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [N/A]
|
| 391 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
|
| 392 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [N/A]
|
| 393 |
+
|
| 394 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 395 |
+
|
| 396 |
+
(a) If your work uses existing assets, did you cite the creators? [N/A]
|
| 397 |
+
(b) Did you mention the license of the assets? [N/A]
|
| 398 |
+
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A]
|
| 399 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 400 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 401 |
+
|
| 402 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 403 |
+
|
| 404 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 405 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 406 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
md/dev/uKiE0VIluA-/uKiE0VIluA-.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
md/dev/vKBdabh_WV/vKBdabh_WV.md
ADDED
|
@@ -0,0 +1,652 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Meta Optimal Transport
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 We study the use of amortized optimization to predict optimal transport (OT) maps
|
| 11 |
+
2 from the input measures, which we call Meta OT. This helps repeatedly solve sim
|
| 12 |
+
3 ilar OT problems between different measures by leveraging the knowledge and in
|
| 13 |
+
4 formation present from past problems to rapidly predict and solve new problems.
|
| 14 |
+
5 Otherwise, standard methods ignore the knowledge of the past solutions and sub
|
| 15 |
+
6 optimally re-solve each problem from scratch. We instantiate Meta OT models in
|
| 16 |
+
7 discrete and continuous (Wasserstein-2) settings between images, spherical data,
|
| 17 |
+
8 and color palettes and use them to improve the computational time of standard OT
|
| 18 |
+
9 solvers by multiple orders of magnitude.
|
| 19 |
+
|
| 20 |
+
# 10 1 Introduction
|
| 21 |
+
|
| 22 |
+
11 Optimal transportation [Villani, 2009, Ambrosio, 2003, Santambrogio, 2015, Peyré et al., 2019,
|
| 23 |
+
12 Merigot and Thibert, 2021] is thriving in domains including economics [Galichon, 2016], rein
|
| 24 |
+
13 forcement learning [Dadashi et al., 2021, Fickinger et al., 2021], style transfer [Kolkin et al., 2019],
|
| 25 |
+
14 generative modeling [Arjovsky et al., 2017, Seguy et al., 2018, Huang et al., 2020, Rout et al., 2021],
|
| 26 |
+
15 geometry [Solomon et al., 2015, Cohen et al., 2021], domain adaptation [Courty et al., 2017, Redko
|
| 27 |
+
16 et al., 2019], signal processing [Kolouri et al., 2017], fairness [Jiang et al., 2020], and cell repro
|
| 28 |
+
17 gramming [Schiebinger et al., 2019]. A core component in these settings is to couple two measures
|
| 29 |
+
18 $( \alpha , \beta )$ supported on domains $( \mathcal { X } , \mathcal { Y } )$ by solving a transport optimization problem such as the primal
|
| 30 |
+
19 Kantorovich problem, which is defined by:
|
| 31 |
+
|
| 32 |
+
$$
|
| 33 |
+
\pi ^ { \star } ( \alpha , \beta , c ) \in \mathop { \mathrm { a r g } } _ { \pi \in \mathcal { U } ( \alpha , \beta ) } \int _ { \mathcal { X } \times \mathcal { Y } } c ( x , y ) \mathrm { d } \pi ( x , y ) ,
|
| 34 |
+
$$
|
| 35 |
+
|
| 36 |
+
where the optimal coupling 20 $\pi ^ { \star }$ is a joint distribution over the product space, $\mathcal { U } ( \alpha , \beta )$ is the set of 21 admissible couplings between $\alpha$ and $\beta$ , and $c : \mathcal { X } \times \mathcal { Y } \mathbb { R }$ is the ground cost, that represents a 22 notion of distance between elements in $\mathcal { X }$ and elements in $\mathcal { V }$ .
|
| 37 |
+
|
| 38 |
+
23 Challenges. Unfortunately, solving eq. (1) once is computationally expensive between general mea
|
| 39 |
+
24 sures and computationally cheaper alternatives are an active research topic: Entropic optimal trans
|
| 40 |
+
25 port [Cuturi, 2013] smooths the transport problem with an entropy penalty, and sliced distances
|
| 41 |
+
26 [Kolouri et al., 2016, 2018, 2019, Deshpande et al., 2019] solve OT between 1-dimensional projec
|
| 42 |
+
27 tions of the measures, where eq. (1) can be solved easily.
|
| 43 |
+
28 Furthermore, when an optimal transport method is deployed in practice, eq. (1) is not just solved
|
| 44 |
+
29 a single time, but is repeatedly solved for new scenarios between different input measures $( \alpha , \beta )$ .
|
| 45 |
+
30 For example, the measures could be representations of images we care about optimally transporting
|
| 46 |
+
31 between and in deployment we would receive a stream of new images to couple. Repeatedly solving
|
| 47 |
+
32 optimal transport problems also comes up in the context of comparing seismic signals [Engquist
|
| 48 |
+
33 and Froese, 2013] and in single-cell perturbations [Bunne et al., 2021, 2022b,a]. Standard optimal
|
| 49 |
+
34 transport solvers deployed in this setting would re-solve the optimization problems from scratch, but
|
| 50 |
+
35 this ignores the shared structure and information present between different coupling problems.
|
| 51 |
+
36 Overview and outline. We study the use of amortized optimization and machine learning methods
|
| 52 |
+
37 to rapidly solve multiple optimal transport problems and predict the solution from the input measures
|
| 53 |
+
38 $( \alpha , \beta )$ . This setting involves learning a meta model to predict the solution to the optimal transport
|
| 54 |
+
39 problem, which we will refer to as Meta Optimal Transport. We learn Meta OT models to predict
|
| 55 |
+
40 the solutions to optimal transport problems and significantly improve the computational time and
|
| 56 |
+
41 number of iterations needed to solve eq. (1) between discrete (sect. 3.1) and continuous (sect. 3.2)
|
| 57 |
+
42 measures. The paper is organized as follows: sect. 2 recalls the main concepts needed for the rest
|
| 58 |
+
43 of the paper, in particular the formulations of the entropy regularized and unregularized optimal
|
| 59 |
+
44 transport problems and the basic notions of amortized optimization; sect. 3 presents the Meta OT
|
| 60 |
+
45 models and algorithms; and sect. 4 empirically demonstrates the effectiveness of Meta OT.
|
| 61 |
+
46 Settings that are not Meta OT. Meta OT is not useful in OT settings that do not involve repeatedly
|
| 62 |
+
47 solving OT problems over a fixed distribution, including 1) standard generative modeling settings,
|
| 63 |
+
48 such as Arjovsky et al. [2017] that estimate the OT distance between the data and model distri
|
| 64 |
+
49 butions, and 2) the out-of-sample setting of Seguy et al. [2018], Perrot et al. [2016] that couple
|
| 65 |
+
50 measures and then extrapolate the map to larger measures containing the original measures.
|
| 66 |
+
|
| 67 |
+
# 51 2 Preliminaries and background
|
| 68 |
+
|
| 69 |
+
# 2.1 Dual optimal transport solvers
|
| 70 |
+
|
| 71 |
+
53 We review foundations of optimal transportation, following the notation of Peyré et al. [2019] in
|
| 72 |
+
54 most places. The discrete setting often favors the entropic regularized version since it can be com
|
| 73 |
+
55 puted efficiently and in a parallelized way using the Sinkhorn algorithm. On the other hand, the
|
| 74 |
+
56 continuous setting is often solved from samples using convex potentials. While the primal Kan
|
| 75 |
+
57 torovich formulation in eq. (1) provides an intuitive problem description, optimal transport problems
|
| 76 |
+
58 are rarely solved directly in this form due to the high-dimensionality of the couplings $\pi$ and the diffi
|
| 77 |
+
59 culty of satisfying the coupling constraints $\mathcal { U } ( \alpha , \beta )$ . Instead, most computational OT solvers use the
|
| 78 |
+
60 dual of eq. (1), which we build our Meta OT solvers on top of in discrete and continuous settings.
|
| 79 |
+
|
| 80 |
+
# 2.1.1 Entropic OT between discrete measures with the Sinkhorn algorithm
|
| 81 |
+
|
| 82 |
+
Let 62 $\begin{array} { r } { \alpha : = \sum _ { i = 1 } ^ { m } a _ { i } \delta _ { x _ { i } } } \end{array}$ and $\beta : = \textstyle \sum _ { i = 1 } ^ { n } b _ { i } \delta _ { y _ { i } }$ be 63 discrete measures, where $\delta _ { z }$ is a Dirac at point 64 $z$ and $a \ \in \ \Delta _ { m - 1 }$ and $b \in \Delta _ { n - 1 }$ are in the 65 probability simplex defined by
|
| 83 |
+
|
| 84 |
+
$$
|
| 85 |
+
\Delta _ { k - 1 } : = \{ x \in \mathbb { R } ^ { k } : x \geq 0 { \mathrm { ~ a n d ~ } } \sum _ { i } x _ { i } = 1 \} .
|
| 86 |
+
$$
|
| 87 |
+
|
| 88 |
+
<table><tr><td>Algorithm1 Sinkhorn(α,β,c,∈,fo=0)</td></tr><tr><td>foriterationi=1to N do gi ←∈logb-∈log(KTexp{fi-1/ε})</td></tr><tr><td>fi←∈loga-∈log(Kexp{gi/∈}) end for</td></tr><tr><td>Compute PN from fN, gN using eq. (6)</td></tr><tr><td>return PN ≈ P*</td></tr></table>
|
| 89 |
+
|
| 90 |
+
66 Discrete OT. In the discrete setting, eq. (1) simplifies to the linear program
|
| 91 |
+
|
| 92 |
+
$$
|
| 93 |
+
P ^ { \star } ( \alpha , \beta , c ) \in \underset { P \in U ( a , b ) } { \arg \operatorname* { m i n } } \langle C , P \rangle \qquad U ( a , b ) : = \{ P \in \mathbb { R } _ { + } ^ { n \times m } : P 1 _ { m } = a , \quad P ^ { \top } 1 _ { n } = b \}
|
| 94 |
+
$$
|
| 95 |
+
|
| 96 |
+
where 67 $P$ is a coupling matrix, $P ^ { \star } ( \alpha , \beta )$ is the optimal coupling, and the cost can be discretized as a matrix 68 $C \in \mathbb { R } ^ { m \times n }$ with entries $C _ { i , j } : = c ( x _ { i } , y _ { j } )$ , and $\begin{array} { r } { \langle C , \mathbf { \tilde { \mathit { P } } } \rangle : = \sum _ { i , j } C _ { i , j } P _ { i , j } } \end{array}$ ,
|
| 97 |
+
|
| 98 |
+
69 Entropic OT. The linear program above can be regularized adding the entropy of the coupling to
|
| 99 |
+
70 smooth the objective as in Cominetti and Martín [1994], Cuturi [2013], resulting in:
|
| 100 |
+
|
| 101 |
+
$$
|
| 102 |
+
P ^ { \star } ( \alpha , \beta , c , \epsilon ) \in \underset { P \in U ( a , b ) } { \arg \operatorname* { m i n } } \langle C , P \rangle - \epsilon H ( P )
|
| 103 |
+
$$
|
| 104 |
+
|
| 105 |
+
where 71 $\begin{array} { r } { H ( P ) : = - \sum _ { i , j } P _ { i , j } ( \log ( P _ { i , j } ) - 1 ) } \end{array}$ is the discrete entropy of a coupling matrix $P$
|
| 106 |
+
|
| 107 |
+
72 Entropic OT dual. As presented in Peyré et al. [2019, Prop. 4.4], the dual of eq. (4) is
|
| 108 |
+
|
| 109 |
+
$$
|
| 110 |
+
\begin{array} { r } { f ^ { \star } , g ^ { \star } \in \underset { f \in \mathbb { R } ^ { n } , g \in \mathbb { R } ^ { m } } { \mathrm { a r g } \mathrm { m a x } } \ \langle f , a \rangle + \langle g , b \rangle - \epsilon \langle \exp \{ f / \epsilon \} , K \exp \{ g / \epsilon \} \rangle , \quad K _ { i , j } : = \exp \{ - C _ { i , j } / \epsilon \} , } \end{array}
|
| 111 |
+
$$
|
| 112 |
+
|
| 113 |
+
73 where $K \in \mathbb { R } ^ { m \times n }$ is the Gibbs kernel and the dual variables or potentials $f \in \mathbb { R } ^ { n }$ and $g \in \mathbb { R } ^ { m }$ are
|
| 114 |
+
74 associated, respectively, with the marginal constraints $P 1 _ { m } = a$ and $P ^ { \top } 1 _ { n } = b$ . The optimal duals
|
| 115 |
+
75 depend on the problem, e.g. $f ^ { \star } ( \alpha , \beta , \overline { { c } } , \epsilon )$ , but we omit this dependence for notational simplicity.
|
| 116 |
+
76 Recovering the primal solution from the duals. Given optimal duals $f ^ { \star } , g ^ { \star }$ that solve eq. (5) the
|
| 117 |
+
77 optimal coupling $P ^ { \star }$ to the primal problem in eq. (4) can be obtained by
|
| 118 |
+
|
| 119 |
+
$$
|
| 120 |
+
P _ { i , j } ^ { \star } ( \alpha , \beta , c , \epsilon ) : = \exp \{ f _ { i } ^ { \star } / \epsilon \} K _ { i , j } \exp \{ g _ { j } ^ { \star } / \epsilon \} \qquad ( K \mathrm { i s d e f i n e d i n e q . } ( 5 ) )
|
| 121 |
+
$$
|
| 122 |
+
|
| 123 |
+
78 The Sinkhorn algorithm. Algorithm 1 summarizes the log-space version, which takes closed-form
|
| 124 |
+
79 block coordinate ascent updates on eq. (5) obtained from the first-order optimality conditions [Peyré
|
| 125 |
+
80 et al., 2019, Remark 4.21]. We will use it to fine-tune predictions made by our Meta OT models.
|
| 126 |
+
81 Computing the error. Standard implementations of the Sinkhorn algorithm, such as Flamary et al.
|
| 127 |
+
82 [2021], Cuturi et al. [2022], measure the error of a candidate dual solution $( f , g )$ by computing the
|
| 128 |
+
83 deviation from the marginal constraints, which we will also use in comparing our solution quality:
|
| 129 |
+
|
| 130 |
+
$$
|
| 131 |
+
\begin{array} { r } { \mathrm { e r r } ( f , g ; \alpha , \beta , c ) : = \| P 1 _ { m } - a \| _ { 1 } + \| P ^ { \top } 1 _ { n } - b \| _ { 1 } \qquad ( \mathrm { c o m p u t e } P \mathrm { f r o m e q . } ( 6 ) ) } \end{array}
|
| 132 |
+
$$
|
| 133 |
+
|
| 134 |
+
84 Mapping between the duals. The first-order optimality conditions of eq. (5) also provide an equiv
|
| 135 |
+
85 alence between the optimal dual potentials that we will make use of:
|
| 136 |
+
|
| 137 |
+
$$
|
| 138 |
+
\begin{array} { r } { g ( f ; b , c ) : = \epsilon \log b - \epsilon \log \left( K ^ { \top } \exp \{ f / \epsilon \} \right) . } \end{array}
|
| 139 |
+
$$
|
| 140 |
+
|
| 141 |
+
# 86 2.1.2 Wasserstein-2 OT between continuous (Euclidean) measures with dual potentials
|
| 142 |
+
|
| 143 |
+
87 Let $\alpha$ and $\beta$ be continuous measures in Euclidean
|
| 144 |
+
88 space $\mathcal X = \mathcal y = \mathbb R ^ { d }$ (with $\alpha$ absolutely contin
|
| 145 |
+
89 uous with respect to the Lebesgue measure) and
|
| 146 |
+
90 the ground cost be the squared Euclidean distance
|
| 147 |
+
91 $c ( x , y ) : = \| x - y \| _ { 2 } ^ { 2 }$ . Then the minimum of eq. (1)
|
| 148 |
+
92 defines the square of the Wasserstein-2 distance:
|
| 149 |
+
|
| 150 |
+
<table><tr><td>Algorithm 2 W2GN(α, β,0)</td></tr><tr><td>foriterationi=1 to N do</td></tr><tr><td>Sample from (α,β) and estimate L(φi-1) Update i with approximation to VL(i-1)</td></tr><tr><td>end for</td></tr><tr><td>return TN(.) := VxψN(·) ≈ T*(·)</td></tr></table>
|
| 151 |
+
|
| 152 |
+
$$
|
| 153 |
+
W _ { 2 } ^ { 2 } ( \alpha , \beta ) : = \operatorname* { m i n } _ { \pi \in \mathcal { U } ( \alpha , \beta ) } \int _ { \mathcal { X } \times \mathcal { Y } } \| x - y \| _ { 2 } ^ { 2 } \mathrm { d } \pi ( x , y ) = \operatorname* { m i n } _ { T } \int _ { \mathcal { X } } \| x - T ( x ) \| _ { 2 } ^ { 2 } \mathrm { d } \alpha ( x ) ,
|
| 154 |
+
$$
|
| 155 |
+
|
| 156 |
+
93 where $T$ is a transport map pushing $\alpha$ to $\beta$ , i.e. $T _ { \# } \alpha = \beta$ with the pushforward operator defined by 94 $T _ { \# } \alpha ( B ) : = \alpha ( T ^ { - 1 } ( B ) )$ for any measurable set $B$ .
|
| 157 |
+
|
| 158 |
+
95 Convex dual potentials. The primal form in eq. (9) is difficult to solve, as in the discrete setting, due
|
| 159 |
+
96 to the difficulty of representing the coupling and satisfying the constraints. Makkuva et al. [2020],
|
| 160 |
+
97 Taghvaei and Jalali [2019], Korotin et al. [2019, 2021b, 2022] propose to instead solve the dual:
|
| 161 |
+
|
| 162 |
+
$$
|
| 163 |
+
\psi ^ { \star } ( { \bf \cdot } ; \alpha , \beta ) \in \mathop { \mathrm { a r g } } \operatorname* { m i n } _ { \psi \in \mathrm { c o n v e x } } \int _ { \mathcal { X } } \psi ( x ) \mathrm { d } \alpha ( x ) + \int _ { \mathcal { V } } \overline { { \psi } } ( y ) \mathrm { d } \beta ( y ) ,
|
| 164 |
+
$$
|
| 165 |
+
|
| 166 |
+
98 where $\psi$ is a convex function referred to as a convex potential, and ${ \overline { { \psi } } } ( y ) : = \operatorname* { m a x } _ { x \in { \mathcal { X } } } \langle x , y \rangle - \psi ( x )$ is
|
| 167 |
+
99 the Legendre-Fenchel transform or convex conjugate of $\psi$ [Fenchel, 1949, Rockafellar, 2015]. The
|
| 168 |
+
100 potential $\psi$ is often approximated with an input-convex neural network (ICNN) [Amos et al., 2017].
|
| 169 |
+
01 Recovering the primal solution from the dual. Given an optimal dual $\psi ^ { \star }$ for eq. (10), Brenier
|
| 170 |
+
02 [1991] remarkably shows that an optimal map $T ^ { \star }$ for eq. (9) can be obtained with differentiation:
|
| 171 |
+
|
| 172 |
+
$$
|
| 173 |
+
T ^ { \star } ( x ) = \nabla _ { x } \psi ^ { \star } ( x ) .
|
| 174 |
+
$$
|
| 175 |
+
|
| 176 |
+
103 Wasserstein-2 Generative Networks (W2GNs). Korotin et al. [2019] model $\psi _ { \varphi }$ and $\overline { { \psi _ { \varphi } } }$ in eq. (10)
|
| 177 |
+
104 with two separate ICNNs parameterized by $\varphi$ . The separate model for $\overline { { \psi _ { \varphi } } }$ is useful because the
|
| 178 |
+
105 conjugate operation in eq. (10) becomes computationally expensive. They optimize the loss:
|
| 179 |
+
|
| 180 |
+
$$
|
| 181 |
+
\mathcal { L } ( \varphi ) : = \underset { x \sim \alpha } { \mathbb { E } } [ \psi _ { \varphi } ( x ) ] + \underset { y \sim \beta } { \mathbb { E } } \left[ \langle \nabla \psi _ { \varphi } ( y ) , y \rangle - \psi _ { \varphi } ( \nabla \psi _ { \varphi } ( y ) ) \right] + \gamma \underset { y \sim \beta } { \mathbb { E } } \| \nabla \psi _ { \varphi } \circ \nabla \psi _ { \varphi } ( y ) - y \| _ { 2 } ^ { 2 } ,
|
| 182 |
+
$$
|
| 183 |
+
|
| 184 |
+
106 where $\varphi$ is a detached copy of the parameters and $\gamma$ is a hyper-parameter. The first term are the
|
| 185 |
+
107 cyclic monotone correlations [Chartrand et al., 2009, Taghvaei and Jalali, 2019], that optimize the
|
| 186 |
+
108 dual objective in eq. (10), and the second term provides cycle consistency [Zhu et al., 2017] to
|
| 187 |
+
109 estimate the conjugate $\overline { { \psi } }$ . Algorithm 2 shows how $\mathcal { L }$ is typically optimized using samples from the
|
| 188 |
+
110 measures, which we use to fine-tune Meta OT predictions.
|
| 189 |
+
|
| 190 |
+

|
| 191 |
+
Figure 1: Meta OT uses objective-based amortization for optimal transport. In the general formulation, the parameters $\theta$ capture shared structure in the optimal couplings $\pi ^ { \star }$ between multiple input measures and costs over some distribution $\mathcal { D }$ . In practice, we learn this shared structure over the dual potentials which map back to the coupling: $f ^ { \star }$ in discrete settings and $\psi ^ { \star }$ in continuous ones.
|
| 192 |
+
|
| 193 |
+
# 111 2.2 Amortized optimization and learning to optimize
|
| 194 |
+
|
| 195 |
+
112 Our paper is an application of amortized optimization methods that predict the solutions of opti
|
| 196 |
+
113 mization problems, as surveyed in, e.g., Chen et al. [2021], Amos [2022]. We use the basic setup
|
| 197 |
+
114 from Amos [2022], which considers unconstrained continuous optimization problems of the form
|
| 198 |
+
|
| 199 |
+
$$
|
| 200 |
+
z ^ { \star } ( \phi ) \in \arg \operatorname* { m i n } _ { z } J ( z ; \phi ) ,
|
| 201 |
+
$$
|
| 202 |
+
|
| 203 |
+
115 where $J$ is the objective, $z \in { \mathcal { Z } }$ is the domain, and $\phi \in \Phi$ is some context or parameterization. In
|
| 204 |
+
116 other words, the context conditions the objective but is not optimized over. Given a distribution over
|
| 205 |
+
117 contexts ${ \mathcal { P } } ( \phi )$ , we learn a model $\hat { z } _ { \theta }$ parameterized by $\theta$ to approximate eq. (13), i.e. $\hat { z } _ { \theta } ( \phi ) \approx z ^ { \star } ( \phi )$ .
|
| 206 |
+
118 $J$ will be differentiable for us, so we optimize the parameters using objective-based learning with
|
| 207 |
+
|
| 208 |
+
$$
|
| 209 |
+
\operatorname* { m i n } _ { \theta } \underset { \phi \sim \mathcal { P } ( \phi ) } { \mathbb { E } } J ( \hat { z } _ { \theta } ( \phi ) ; \phi ) ,
|
| 210 |
+
$$
|
| 211 |
+
|
| 212 |
+
119 which does not require ground-truth solutions $z ^ { \star }$ and can be optimized with a gradient-based solver.
|
| 213 |
+
120 While we focus on optimizing eq. (14) because we do not assume easy access to ground-truth solu
|
| 214 |
+
121 tions $z ^ { \star } ( \phi )$ , one alternative is regression-based learning if the solutions are easily available:
|
| 215 |
+
|
| 216 |
+
$$
|
| 217 |
+
\operatorname* { m i n } _ { \theta } \operatorname* { \mathbb { E } } _ { \phi \sim \mathcal { P } ( \phi ) } \| z ^ { \star } ( \phi ) - \hat { z } _ { \theta } ( \phi ) \| _ { 2 } ^ { 2 } .
|
| 218 |
+
$$
|
| 219 |
+
|
| 220 |
+
# 122 3 Meta Optimal Transport
|
| 221 |
+
|
| 222 |
+
Figure 1 illustrates our key contribution of connecting objective-based amortization in eq. (14) to optimal transport. We consider solving multiple OT problems and learning shared structure and correlations between them. We denote a joint meta-distribution over the input measures and costs with $\mathcal { D } ( \alpha , \beta , c )$ , which we call meta to distinguish it from the measures $\alpha , \beta$ .
|
| 223 |
+
|
| 224 |
+
127 In general, we could introduce a model that directly predicts the primal solution to eq. (1), i.e.
|
| 225 |
+
128 $\pi _ { \boldsymbol { \theta } } ( \widetilde { \alpha } , \beta , c ) \approx \pi ^ { \star } ( \alpha , \beta , c )$ for $( \alpha , \beta , c ) \sim \mathcal { D }$ . This is difficult for the same reason why most compu
|
| 226 |
+
129 tational methods do not operate directly in the primal space: the optimal coupling is often a high
|
| 227 |
+
130 dimensional joint distribution with non-trivial marginal constraints. We instead turn to predicting
|
| 228 |
+
131 the dual variables used by today’s solvers.
|
| 229 |
+
|
| 230 |
+
# 32 3.1 Meta OT between discrete measures
|
| 231 |
+
|
| 232 |
+
133 dardand ropicwith ed iand 1 between discrete coupled using a cost easures. In the
|
| 233 |
+
134 $\begin{array} { r } { \alpha : = \sum _ { i = 1 } ^ { m } a _ { i } \delta _ { x _ { i } } } \end{array}$ $\textstyle { \beta : = \sum _ { i = 1 } ^ { n } b _ { i } \delta _ { x _ { i } } }$ $a \in \Delta _ { m - 1 }$ $b \in \Delta _ { n - 1 }$ $c$
|
| 234 |
+
135 Meta OT setting, the measures and cost are the contexts for amortization and sampled from a meta
|
| 235 |
+
136 distribution, i.e. $( \alpha , \beta , c ) \sim \mathcal { D } ( \alpha , \beta , c )$ . For example, sects. 4.1 and 4.2 considers meta-distributions
|
| 236 |
+
137 over the weights of the atoms, i.e. $( a , b ) \sim \mathcal { D }$ , where $\mathcal { D }$ is a distribution over $\Delta _ { m - 1 } \times \Delta _ { n - 1 }$ .
|
| 237 |
+
138 Amortization objective. We will seek to predict the optimal potential. At optimality, the pair of
|
| 238 |
+
139 potentials are related to each other via eq. (8), i.e. $\begin{array} { r } { g ( f ; \hat { \alpha } , \beta , c ) : = \epsilon \log b - \epsilon \mathrm { l o g } \left( K ^ { \dagger } \exp \bigl \{ f / \epsilon \bigr \} \right) } \end{array}$
|
| 239 |
+
140 where $K \in \mathbb { R } ^ { m \times n }$ is the Gibbs kernel from eq. (5). Hence, it is sufficient to predict one of the
|
| 240 |
+
141 potentials, e.g. $f$ , and recover the other. We thus re-formulate eq. (5) to just optimize over $f$ with
|
| 241 |
+
|
| 242 |
+
<table><tr><td>Algorithm 3 Training Meta OT</td></tr><tr><td>Initialize amortization model with 0o foriterationdo Sample (α, β,c) ~ D Predict duals fe or eon the sample</td></tr></table>
|
| 243 |
+
|
| 244 |
+
<table><tr><td>Algorithm 4 Fine-tuning with Sinkhorn</td></tr><tr><td>Predict duals fe(α, β,c)</td></tr><tr><td>return Sinkhorn(α,β,c,∈, fe)</td></tr><tr><td>Algorithm 5 Fine-tuning with W2GN</td></tr><tr><td>Predict dual ICNN parameters e(α, β,c)</td></tr><tr><td>return W2GN(α, β,c,T,0)</td></tr></table>
|
| 245 |
+
|
| 246 |
+
$$
|
| 247 |
+
\displaystyle f ^ { \star } ( \alpha , \beta , c , \epsilon ) \in \ \arg \operatorname* { m i n } _ { f \in \mathbb { R } ^ { n } } \ J ( f ; \alpha , \beta , c ) ,
|
| 248 |
+
$$
|
| 249 |
+
|
| 250 |
+
142 where $- J ( f ; \alpha , \beta , c ) : = \langle f , a \rangle + \langle g , b \rangle - \epsilon \langle \exp \{ f / \epsilon \} , K \exp \{ g / \epsilon \} \rangle$ is the (negated) dual objective.
|
| 251 |
+
143 Even though most solvers optimize over $f$ and $g$ jointly as in eq. (16), amortizing over these would
|
| 252 |
+
144 likely need: 1) to have a higher capacity than a model just predicting $f$ , and 2) to learn how $f$ and $g$
|
| 253 |
+
145 are connected through eq. (8) while in eq. (16) we explicitly provide this knowledge.
|
| 254 |
+
146 Amortization model. We predict the solution to eq. (16) with $\hat { f } _ { \theta } ( \alpha , \beta , c )$ parameterized by $\theta$ ,
|
| 255 |
+
147 resulting in a computationally efficient approximation $\hat { f } _ { \boldsymbol { \theta } } \approx f ^ { \star }$ . Here we use the notation $\hat { f } _ { \theta } ( \alpha , \beta , c )$
|
| 256 |
+
148 to mean that the model $\hat { f } _ { \theta }$ depends on representations of the input measures and cost. In our settings,
|
| 257 |
+
149 we define ${ \hat { f } } _ { \theta }$ as a fully-connected MLP mapping from the atoms of the measures to the duals.
|
| 258 |
+
150 Amortization loss. Applying objective-based amortization from eq. (14) to the dual in eq. (16)
|
| 259 |
+
151 completes our learning setup. Our model should best-optimize the expectation of the dual objective
|
| 260 |
+
|
| 261 |
+
$$
|
| 262 |
+
\operatorname* { m i n } _ { \theta } \operatorname* { \mathbb { E } } _ { ( \alpha , \beta , c ) \sim \mathcal { D } } J ( \hat { f } _ { \theta } ( \alpha , \beta , c ) ; \alpha , \beta , c ) ,
|
| 263 |
+
$$
|
| 264 |
+
|
| 265 |
+
which is appealing as it does not require ground-truth solutions 152 $f ^ { \star }$ . Algorithm 3 shows a basic 153 training loop for eq. (17) using a gradient-based optimizer such as Adam [Kingma and Ba, 2014].
|
| 266 |
+
|
| 267 |
+
Sinkhorn fine-tuning. The dual prediction made by $\hat { f } _ { \theta }$ with an associated $\hat { g }$ can easily be input as the initialization to a standard Sinkhorn solver as shown in algorithm 4. This allows us to deploy the predicted potential with Sinkhorn to obtain the optimal potentials with only a few extra iterations.
|
| 268 |
+
|
| 269 |
+
On accelerated solvers. Here we have only considered fine-tuning the Meta OT prediction with a log-Sinkhorn solver. Meta OT can also be combined with accelerated variants of entropic OT solvers such as Thibault et al. [2017], Altschuler et al. [2017], Alaya et al. [2019], Lin et al. [2019] that would otherwise solve every problem from scratch.
|
| 270 |
+
|
| 271 |
+
# 3.2 Meta OT between continuous measures (Wasserstein-2)
|
| 272 |
+
|
| 273 |
+
162 We take an analogous approach to predicting the Wasserstein-2 map between continuous measures
|
| 274 |
+
163 for Wasserstein-2 as reviewed in sect. 2.1.2. Here the measures $\alpha , \beta$ are supported in continuous
|
| 275 |
+
164 space $\mathcal { X } = \mathcal { Y } = \mathbb { R } ^ { d }$ and we focus on computing Wasserstein-2 couplings from instances sampled
|
| 276 |
+
165 from a meta-distribution $( \alpha , \beta ) \sim \mathcal { D } ( \alpha , \beta )$ . The cost $c$ is not included in $\mathcal { D }$ as it remains fixed to the
|
| 277 |
+
166 squared Euclidean cost everywhere here.
|
| 278 |
+
167 One challenge here is that the optimal dual potential $\psi ^ { \star } ( \cdot ; \alpha , \beta )$ in eq. (10) is a convex function and
|
| 279 |
+
168 not simply a finite-dimensional real vector. The dual potentials in this setting are approximated by,
|
| 280 |
+
169 e.g., an ICNN. We thus propose a Meta ICNN that predicts the parameters $\varphi$ of an ICNN $\psi _ { \varphi }$ that
|
| 281 |
+
170 approximates the optimal dual potentials, which can be seen as a hypernetwork [Stanley et al., 2009,
|
| 282 |
+
171 Ha et al., 2016]. The dual prediction made by $\hat { \varphi } _ { \theta }$ can easily be input as the initial value to a standard
|
| 283 |
+
172 W2GN solver as shown in algorithm 5. App. B discusses other modeling choices we considered:
|
| 284 |
+
173 we tried models based on MAML [Finn et al., 2017] and neural processes [Garnelo et al., 2018b,a].
|
| 285 |
+
174 Amortization objective. We build on the W2GN formulation [Korotin et al., 2019] and seek pa
|
| 286 |
+
175 rameters $\varphi ^ { \star }$ optimizing the dual ICNN potentials $\psi _ { \varphi }$ and $\overline { { \psi _ { \varphi } } }$ with $\mathcal { L } ( \varphi ; \alpha , \beta )$ from eq. (12). We
|
| 287 |
+
176 chose W2GN due to the stability, but could also easily use other losses optimizing ICNN potentials.
|
| 288 |
+
177 Amortization model: the Meta ICNN. We predict the solution to eq. (12) with $\hat { \varphi } _ { \boldsymbol { \theta } } \big ( \alpha , \beta \big )$ param
|
| 289 |
+
178 eterized by $\theta$ , resulting in a computationally efficient approximation to the optimum $\hat { \varphi } _ { \boldsymbol { \theta } } \approx \varphi ^ { \star }$ .
|
| 290 |
+
179 Figure 3 instantiates a convolutional Meta ICNN model using a ResNet-18 [He et al., 2016] archi
|
| 291 |
+
180 tecture for coupling image-based measures. We again emphasize that $\alpha , \beta$ used with the model here
|
| 292 |
+
181 are representations of measures, which in our cases are simply images.
|
| 293 |
+
182 Amortization loss. Applying objective-based amortization from eq. (14) to the W2GN loss in
|
| 294 |
+
183 eq. (12) completes our learning setup. Our model should best-optimize the expectation of the loss:
|
| 295 |
+
|
| 296 |
+
Figure 2: Interpolations between MNIST test digits using couplings obtained from (left) solving the problem with Sinkhorn, and (right) Meta OT model’s initial prediction, which is $\mathbf { \approx 1 0 0 }$ times computationally cheaper and produces a nearly identical coupling.
|
| 297 |
+
|
| 298 |
+

|
| 299 |
+
Figure 3: A Meta ICNN for image-based input measures. A shared ResNet processes the input measures $\alpha$ and $\beta$ into latents $z$ that are decoded with an MLP into the parameters $\varphi$ of an ICNN dual potential $\psi _ { \varphi }$ . The derivative of the ICNN provides the transport map $\hat { T }$ .
|
| 300 |
+
|
| 301 |
+
Table 2: Color transfer runtimes and values.
|
| 302 |
+
|
| 303 |
+
<table><tr><td></td><td>Iter</td><td>Runtime (s)</td><td>Dual Value</td></tr><tr><td>Meta OT +W2GN</td><td>None 1k</td><td>3.5.10-3 ±2.7:10-4 0.93±2.27·10-2</td><td>0.90 ±6.08·10-2 1.0 ±2.57.10-3</td></tr><tr><td></td><td>2k</td><td>1.84 ±3.78 . 10-2</td><td>1.0 ±5.30 .10-3</td></tr><tr><td>W2GN</td><td>1k</td><td>0.90 ±1.62:10-2</td><td>0.96 ±2.62:10-2</td></tr><tr><td></td><td></td><td></td><td>0.99 ±1.14·10-2</td></tr><tr><td></td><td>2k</td><td>1.81 ±3.05:10-2</td><td></td></tr></table>
|
| 304 |
+
|
| 305 |
+
Table 1: Sinkhorn runtime (seconds) to reach a marginal error of $1 0 ^ { - 3 }$ . Meta OT’s initial prediction takes $\approx 5 \cdot 1 0 ^ { - 5 }$ seconds.
|
| 306 |
+
|
| 307 |
+
<table><tr><td>Initialization</td><td>MNIST</td><td>Spherical</td></tr><tr><td>Zeros</td><td>7.7:10-3 ±1.2.10-3</td><td>1.4 ±1.9 . 10-1</td></tr><tr><td>Gaussian</td><td>7.7·107 -3 ±1.4·10-3</td><td>1.1 ±2.0 · 10-1</td></tr><tr><td>Meta OT</td><td>3.9·10-3 ±1.6·10-3</td><td>0.44 ±1.5 10-1</td></tr></table>
|
| 308 |
+
|
| 309 |
+
We report the mean and standard deviation across 10 test instances.
|
| 310 |
+
|
| 311 |
+
$$
|
| 312 |
+
\operatorname* { m i n } _ { \theta } \operatorname* { l g } _ { ( \alpha , \beta ) \sim \mathcal { D } } \mathcal { L } ( \varphi _ { \theta } ( \alpha , \beta ) ; \alpha , \beta ) .
|
| 313 |
+
$$
|
| 314 |
+
|
| 315 |
+
As in the discrete setting, it does not require ground-truth solutions 184 $\varphi ^ { \star }$ and we learn it with Adam.
|
| 316 |
+
|
| 317 |
+
# 185 4 Experiments
|
| 318 |
+
|
| 319 |
+
186 We demonstrate how Meta OT models improve the convergence of the state-of-the-art solvers in
|
| 320 |
+
187 settings where solving multiple OT problems naturally arises. We implemented our code in JAX
|
| 321 |
+
188 [Bradbury et al., 2018] as an extension to the the Optimal Transport Tools (OTT) package [Cuturi
|
| 322 |
+
189 et al., 2022]. App. C covers further experimental and implementation details, and shows that all of
|
| 323 |
+
190 our experiments take a few hours to run on our single Quadro GP100 GPU.
|
| 324 |
+
|
| 325 |
+

|
| 326 |
+
Figure 4: Meta OT successfully predicts warm-start initializations that significantly improve the convergence of Sinkhorn iterations on test data. The error is the marginal error defined in eq. (7).
|
| 327 |
+
|
| 328 |
+
# 191 4.1 Discrete OT between MNIST digits
|
| 329 |
+
|
| 330 |
+
Images provide a natural setting for Meta OT where the distribution over images provide the metadistribution $\mathcal { D }$ over OT problems. Given a pair of images $\alpha _ { 0 }$ and $\alpha _ { 1 }$ , each grayscale image is cast as a discrete measure in 2-dimensional space where the intensities define the probabilities of the atoms. The goal is to compute the optimal transport interpolation between the two measures as in, e.g., Peyré et al. [2019, $\ S 7 ]$ . Formally, this means computing the optimal coupling $P ^ { \star }$ by solving the entropic optimal transport problem between $\alpha _ { 0 }$ and $\alpha _ { 1 }$ and computing the interpolates as $\alpha _ { t } = ( t \mathrm { p r o j } _ { y } + ( 1 - t ) \mathrm { p r o j } _ { x } ) _ { \# } P ^ { \star }$ , for $t \in [ 0 , 1 ]$ , where $\operatorname { p r o j } _ { x } ( x , y ) : = x$ and $\mathrm { p r o j } _ { y } ( x , y ) = y$ . We selected $\epsilon = 1 0 ^ { - 2 }$ as app. A shows that it gives interpolations that are not too blurry or sharp.
|
| 331 |
+
|
| 332 |
+
200 Our Meta OT model ${ \hat { f } } _ { \theta }$ (sect. 3.1) is an MLP that predicts the transport map between pairs of MNIST
|
| 333 |
+
201 digits. We train on every pair from the standard training dataset. Figure 2 shows that even without
|
| 334 |
+
202 fine-tuning, Meta OT’s predicted Wasserstein interpolations between the measures are close to the
|
| 335 |
+
203 ground-truth interpolations obtained from running the Sinkhorn algorithm to convergence. We then
|
| 336 |
+
204 fine-tune Meta OT’s prediction with Sinkhorn as in algorithm 4. Figure 4 shows that the near
|
| 337 |
+
205 optimal predictions can be quickly refined in fewer iterations than running Sinkhorn with the default
|
| 338 |
+
206 initialization, and table 1 shows the runtime required to reach the default threshold, which uses the
|
| 339 |
+
207 default marginal error threshold of $1 0 ^ { - 3 }$ . We compare our learned initialization to the standard zero
|
| 340 |
+
208 initialization, as well as the Gaussian initialization proposed in Thornton and Cuturi [2022], which
|
| 341 |
+
209 takes a continuous Gaussian approximation of the measures and initializes the potentials to be the
|
| 342 |
+
210 known coupling between the Gaussians. This Gaussian initialization assumes the squared Euclidean
|
| 343 |
+
211 cost, which is not the case in our spherical transport problem, but we find it is still helpful over the
|
| 344 |
+
212 zero initialization.
|
| 345 |
+
|
| 346 |
+
# 213 4.2 Discrete OT for supply-demand transportation on spherical data
|
| 347 |
+
|
| 348 |
+
We next set up a synthetic transport problem between supply and demand locations where the supply and demands may change locations or quantities frequently, creating another Meta OT setting to be able to rapidly solve the new instances. We specifically consider measures living on the 2-sphere defined by $S _ { 2 } ^ { \cdot } : = \{ x \in \mathbb { R } ^ { 3 } : \| x \| = 1 \} .$ , i.e. $\mathcal { X } = \mathcal { Y } = \mathcal { S } _ { 2 }$ , with the transport cost given by the spherical distance $c ( x , y ) = \operatorname { a r c c o s } ( \langle x , y \rangle )$ . We then randomly sample supply locations uniformly from Earth’s landmass and demand locations from Earth’s population density to induce a class of transport problems on the sphere obtained from the CC-licensed dataset from Doxsey-Whitfield et al. [2015]. Figure 5 shows that the predicted transport maps on test instances are close to the optimal maps obtained from Sinkhorn to convergence. Similar to the MNIST setting, fig. 4 and table 1 show improved convergence and runtime.
|
| 349 |
+
|
| 350 |
+
# 24 4.3 Continuous Wasserstein-2 color transfer
|
| 351 |
+
|
| 352 |
+
The problem of color transfer between two images consists in mapping the color palette of one image into the other one. The images are required to have the same number of channels, for example RGB images. The continuous formulation that we use from Korotin et al. [2019], takes i.e. $\mathcal { X } = \mathcal { Y } =$ $[ 0 , \bar { 1 } ] ^ { 3 }$ with $c$ being the squared Euclidean distance. We collected ${ \approx } 2 0 0$ public domain images from WikiArt and trained a Meta ICNN model from sect. 3.2 to predict the color transfer maps between
|
| 353 |
+
|
| 354 |
+

|
| 355 |
+
Figure 5: Test set coupling predictions of the spherical transport problem. Meta OT’s initial prediction is ${ \approx } \mathbf { 3 7 5 0 0 }$ times faster than solving Sinkhorn to optimality. Supply locations are shown as black dots and the blue lines show the spherical transport maps $T$ going to demand locations at the end. The sphere is visualized with the Mercator projection.
|
| 356 |
+
|
| 357 |
+

|
| 358 |
+
Figure 6: Color transfers with a Meta ICNN on test pairs of images. The objective is to optimally transport the continuous RGB measure of the first image $\alpha$ to the second $\beta$ , producing an invertible transport map $T$ . Meta OT’s prediction is ${ \approx } \mathbf { 1 0 0 0 }$ times faster than training W2GN from scratch. The image generating $\alpha$ is Market in Algiers by August Macke (1914) and $\beta$ is Argenteuil, The Seine by Claude Monet (1872), obtained from WikiArt.
|
| 359 |
+
|
| 360 |
+
230 every pair of them. Figure 6 shows the predictions on test pairs and fig. 7 shows the convergence in
|
| 361 |
+
31 comparison to the standard W2GN learning. Table 2 reports runtimes and app. E shows additional
|
| 362 |
+
232 results.
|
| 363 |
+
|
| 364 |
+
# 5 Related work
|
| 365 |
+
|
| 366 |
+
Efficiently estimating OT maps. To compute OT maps with fixed cost between pairs of measures efficiently, neural OT models [Korotin et al., 2019, Li et al., 2020, Korotin et al., 2021a, Mokrov et al., 2021, Korotin et al., 2021b] leverage ICNNs to estimate maps between continuous high
|
| 367 |
+
|
| 368 |
+
237 dimensional measures given samples from these, and Litvinenko et al. [2021], Scetbon et al. [2021],
|
| 369 |
+
238 Forrow et al. [2019], Sommerfeld et al. [2019], Scetbon et al. [2022], Muzellec and Cuturi [2019],
|
| 370 |
+
239 Bonet et al. [2021] leverage structural assumptions on coupling and cost matrices to reduce the
|
| 371 |
+
240 computational and memory complexity. In the meta-OT setting, we consider learning to rapidly
|
| 372 |
+
241 compute OT mappings between new pairs measures. All these works can hence potentially benefit
|
| 373 |
+
242 from an acceleration effect by leveraging amortization similarly.
|
| 374 |
+
|
| 375 |
+
Embedding measures where OT distances are discriminative. Effort has been invested in learning encodings/projections of measures through a nested optimization problem, which aims to find discriminative embeddings of the measures to be compared [Genevay et al., 2018, Deshpande et al., 2019, Nguyen and Ho, 2022]. While these works share an encoder and/or a projection across task with the aim of leveraging more discriminative alignments (and hence an OT distance with a metric different from the Euclidean metric), our work differs in the sense that we find good initializations to solve the OT problem itself with fixed cost more efficiently across tasks.
|
| 376 |
+
|
| 377 |
+
Optimal transport and amortization. Few previous works in the OT literature leverage amortization. Courty et al. [2018] learn a latent space in which the Wasserstein distance between the measure’s embeddings is equivalent to the Euclidean distance. Concurrent work [Nguyen and Ho, 2022] amortizes the estimation of the optimal projection in the max-sliced objective, which differs from our work where we instead amortize the estimation of the optimal coupling directly. Also, Lacombe et al. [2021] learns to predict Wasserstein barycenters of pixel images by training a convolutional networks that, given images as input, outputs their barycenters. Our work is hence a generalization of this pixel-based work to general measures – both discrete and continuous. A limitation of Lacombe et al. [2021] is that it does not provide alignments, as the amortization networks predicts the barycenter directly rather than individual couplings.
|
| 378 |
+
|
| 379 |
+

|
| 380 |
+
Figure 7: Convergence on color transfer test instances using W2GN. Meta ICNNs predicts warm-start initializations that significantly improve the (normalized) dual objective values.
|
| 381 |
+
|
| 382 |
+
# 6 Conclusions, future directions, and limitations
|
| 383 |
+
|
| 384 |
+
We have presented foundations for modeling and learning to solve OT problems with Meta OT by using amortized optimization to predict optimal transport plans. This works best in applications that require solving multiple OT problems with shared structure. We instantiated it to speed up entropic regularized optimal transport and unregularized optimal transport with squared cost by multiple orders of magnitude. We envision extensions of the work in:
|
| 385 |
+
|
| 386 |
+
1. Meta OT models. While we mostly consider models based on hypernetworks, other metalearning paradigms can be connected in. In the discrete setting, we only considered settings where the cost remains fixed, but the Meta OT model can also be conditioned on the cost by considering the entire cost matrix as an input (which may be too large for most models to handle), or considering a lower-dimensional parameterization of the cost that changes between the Meta OT problem instances.
|
| 387 |
+
2. OT algorithms. While we instantiated models on top of log-Sinkhorn and W2GN, Meta OT could be built on top of other methods.
|
| 388 |
+
3. OT applications that are computationally expensive and repeatedly solved, e.g. in multimarginal and barycentric settings, or for Gromov-Wasserstein distances between metricmeasure spaces.
|
| 389 |
+
|
| 390 |
+
285 Limitations. While we have illustrated successful applications of Meta OT, it is also important to
|
| 391 |
+
286 understand the limitations: 1) Meta OT does not make previously intractable problems tractable.
|
| 392 |
+
287 All of the baseline OT solvers we consider solve our problems within milliseconds or seconds. 2)
|
| 393 |
+
288 Out-of-distribution generalization. Meta OT may not generate good predictions on instances that
|
| 394 |
+
289 are not close to the training OT problems from the meta-distribution $\mathcal { D }$ over the measures and cost.
|
| 395 |
+
290 If the model makes a bad prediction, one fallback option is to re-solve the instance from scratch.
|
| 396 |
+
|
| 397 |
+
References Mokhtar Z Alaya, Maxime Berar, Gilles Gasso, and Alain Rakotomamonjy. Screening sinkhorn algorithm for regularized optimal transport. Advances in Neural Information Processing Systems, 32, 2019. Jason Altschuler, Jonathan Niles-Weed, and Philippe Rigollet. Near-linear time approximation algorithms for optimal transport via sinkhorn iteration. Advances in neural information processing systems, 30, 2017. Luigi Ambrosio. Lecture notes on optimal transport problems. In Mathematical aspects of evolving interfaces, pages 1–52. Springer, 2003.
|
| 398 |
+
298 Brandon Amos. Tutorial on amortized optimization for learning to optimize over continuous domains. arXiv preprint arXiv:2202.00665, 2022.
|
| 399 |
+
300 Brandon Amos, Lei Xu, and J Zico Kolter. Input convex neural networks. In International Conference on Machine Learning, pages 146–155. PMLR, 2017. Martin Arjovsky, Soumith Chintala, and Léon Bottou. Wasserstein generative adversarial networks. In International conference on machine learning, pages 214–223. PMLR, 2017. Clément Bonet, Titouan Vayer, Nicolas Courty, François Septier, and Lucas Drumetz. Subspace detours meet gromov–wasserstein. Algorithms, 14(12):366, 2021. James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs. GitHub, 2018. URL http://github.com/google/jax. Yann Brenier. Polar factorization and monotone rearrangement of vector-valued functions. Communications on pure and applied mathematics, 44(4):375–417, 1991. Charlotte Bunne, Stefan G Stark, Gabriele Gut, Jacobo Sarabia del Castillo, Kjong-Van Lehmann, Lucas Pelkmans, Andreas Krause, and Gunnar Ratsch. Learning single-cell perturbation responses using neural optimal transport. bioRxiv, 2021. Charlotte Bunne, Andreas Krause, and Marco Cuturi. Supervised training of conditional monge maps. arXiv preprint arXiv:2206.14262, 2022a. Charlotte Bunne, Laetitia Papaxanthos, Andreas Krause, and Marco Cuturi. Proximal optimal transport modeling of population dynamics. In International Conference on Artificial Intelligence and Statistics, pages 6511–6528. PMLR, 2022b.
|
| 400 |
+
319 Rick Chartrand, Brendt Wohlberg, Kevin Vixie, and Erik Bollt. A gradient descent solution to the mongekantorovich problem. Applied Mathematical Sciences, 3(22):1071–1080, 2009. Tianlong Chen, Xiaohan Chen, Wuyang Chen, Howard Heaton, Jialin Liu, Zhangyang Wang, and Wotao Yin. Learning to optimize: A primer and a benchmark. arXiv preprint arXiv:2103.12828, 2021. Samuel Cohen, Brandon Amos, and Yaron Lipman. Riemannian convex potential maps. In International Conference on Machine Learning, pages 2028–2038. PMLR, 2021. Roberto Cominetti and J San Martín. Asymptotic analysis of the exponential penalty trajectory in linear programming. Mathematical Programming, 67(1):169–187, 1994.
|
| 401 |
+
327 Nicolas Courty, Rémi Flamary, Amaury Habrard, and Alain Rakotomamonjy. Joint distribution optimal transportation for domain adaptation. Advances in Neural Information Processing Systems, 30, 2017.
|
| 402 |
+
329 Nicolas Courty, Rémi Flamary, and Mélanie Ducoffe. Learning wasserstein embeddings. In International Conference on Learning Representations, 2018. Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. Advances in neural information processing systems, 26:2292–2300, 2013. Marco Cuturi, Laetitia Meng-Papaxanthos, Yingtao Tian, Charlotte Bunne, Geoff Davis, and Olivier Teboul. Optimal transport tools (ott): A jax toolbox for all things wasserstein. arXiv preprint arXiv:2201.12324, 2022. Robert Dadashi, Léonard Hussenot, Matthieu Geist, and Olivier Pietquin. Primal wasserstein imitation learning. In ICLR 2021-Ninth International Conference on Learning Representations, 2021.
|
| 403 |
+
|
| 404 |
+
338 Ishan Deshpande, Yuan-Ting Hu, Ruoyu Sun, Ayis Pyrros, Nasir Siddiqui, Sanmi Koyejo, Zhizhen Zhao, David
|
| 405 |
+
339 Forsyth, and Alexander G Schwing. Max-sliced wasserstein distance and its use for gans. In Proceedings of
|
| 406 |
+
340 the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10648–10656, 2019.
|
| 407 |
+
341 Erin Doxsey-Whitfield, Kytt MacManus, Susana B Adamo, Linda Pistolesi, John Squires, Olena Borkovska,
|
| 408 |
+
342 and Sandra R Baptista. Taking advantage of the improved availability of census data: a first look at the
|
| 409 |
+
343 gridded population of the world, version 4. Papers in Applied Geography, 1(3):226–234, 2015.
|
| 410 |
+
344 Bjorn Engquist and Brittany D Froese. Application of the wasserstein metric to seismic signals. arXiv preprint
|
| 411 |
+
345 arXiv:1311.4581, 2013.
|
| 412 |
+
346 Werner Fenchel. On conjugate convex functions. Canadian Journal of Mathematics, 1(1):73–77, 1949.
|
| 413 |
+
347 Arnaud Fickinger, Samuel Cohen, Stuart Russell, and Brandon Amos. Cross-domain imitation learning via
|
| 414 |
+
348 optimal transport. In International Conference on Learning Representations, 2021.
|
| 415 |
+
349 Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep
|
| 416 |
+
350 networks. In Doina Precup and Yee Whye Teh, editors, Proceedings of the 34th International Conference
|
| 417 |
+
351 on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pages 1126–1135. PMLR,
|
| 418 |
+
352 06–11 Aug 2017. URL https://proceedings.mlr.press/v70/finn17a.html.
|
| 419 |
+
353 Rémi Flamary, Nicolas Courty, Alexandre Gramfort, Mokhtar Z Alaya, Aurélie Boisbunon, Stanislas Chambon,
|
| 420 |
+
354 Laetitia Chapel, Adrien Corenflos, Kilian Fatras, Nemo Fournier, et al. Pot: Python optimal transport.
|
| 421 |
+
355 Journal of Machine Learning Research, 22(78):1–8, 2021.
|
| 422 |
+
356 Aden Forrow, Jan-Christian Hütter, Mor Nitzan, Philippe Rigollet, Geoffrey Schiebinger, and Jonathan Weed.
|
| 423 |
+
357 Statistical optimal transport via factored couplings. In The 22nd International Conference on Artificial
|
| 424 |
+
358 Intelligence and Statistics, pages 2454–2465. PMLR, 2019.
|
| 425 |
+
359 Alfred Galichon. Optimal transport methods in economics. In Optimal Transport Methods in Economics.
|
| 426 |
+
360 Princeton University Press, 2016.
|
| 427 |
+
361 Marta Garnelo, Dan Rosenbaum, Christopher Maddison, Tiago Ramalho, David Saxton, Murray Shanahan,
|
| 428 |
+
362 Yee Whye Teh, Danilo Rezende, and SM Ali Eslami. Conditional neural processes. In International Con
|
| 429 |
+
363 ference on Machine Learning, pages 1704–1713. PMLR, 2018a.
|
| 430 |
+
364 Marta Garnelo, Jonathan Schwarz, Dan Rosenbaum, Fabio Viola, Danilo J Rezende, SM Eslami, and Yee Whye
|
| 431 |
+
365 Teh. Neural processes. arXiv preprint arXiv:1807.01622, 2018b.
|
| 432 |
+
366 Aude Genevay, Gabriel Peyre, and Marco Cuturi. Learning generative models with sinkhorn divergences. In
|
| 433 |
+
367 Amos Storkey and Fernando Perez-Cruz, editors, Proceedings of the Twenty-First International Conference
|
| 434 |
+
368 on Artificial Intelligence and Statistics, volume 84 of Proceedings of Machine Learning Research, pages
|
| 435 |
+
369 1608–1617. PMLR, 09–11 Apr 2018. URL https://proceedings.mlr.press/v84/genevay18a.
|
| 436 |
+
370 html.
|
| 437 |
+
371 David Ha, Andrew Dai, and Quoc V Le. Hypernetworks. arXiv preprint arXiv:1609.09106, 2016.
|
| 438 |
+
372 Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In
|
| 439 |
+
373 European conference on computer vision, pages 630–645. Springer, 2016.
|
| 440 |
+
374 Chin-Wei Huang, Ricky TQ Chen, Christos Tsirigotis, and Aaron Courville. Convex potential flows: Universal
|
| 441 |
+
375 probability distributions with optimal transport and convex optimization. In International Conference on
|
| 442 |
+
376 Learning Representations, 2020.
|
| 443 |
+
377 J. J. Hull. A database for handwritten text recognition research. IEEE Transactions on Pattern Analysis and
|
| 444 |
+
378 Machine Intelligence, 16(5):550–554, 1994. doi: 10.1109/34.291440.
|
| 445 |
+
379 Ray Jiang, Aldo Pacchiano, Tom Stepleton, Heinrich Jiang, and Silvia Chiappa. Wasserstein fair classification.
|
| 446 |
+
380 In Uncertainty in Artificial Intelligence, pages 862–872. PMLR, 2020.
|
| 447 |
+
381 Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint
|
| 448 |
+
382 arXiv:1412.6980, 2014.
|
| 449 |
+
383 Nicholas Kolkin, Jason Salavon, and Gregory Shakhnarovich. Style transfer by relaxed optimal transport and
|
| 450 |
+
384 self-similarity. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition,
|
| 451 |
+
385 pages 10051–10060, 2019.
|
| 452 |
+
386 Soheil Kolouri, Yang Zou, and Gustavo K Rohde. Sliced wasserstein kernels for probability distributions. In
|
| 453 |
+
387 Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 5258–5267, 2016.
|
| 454 |
+
|
| 455 |
+
88 Soheil Kolouri, Se Rim Park, Matthew Thorpe, Dejan Slepcev, and Gustavo K Rohde. Optimal mass transport: Signal processing and machine-learning applications. IEEE signal processing magazine, 34(4):43–59, 2017. Soheil Kolouri, Phillip E Pope, Charles E Martin, and Gustavo K Rohde. Sliced wasserstein auto-encoders. In International Conference on Learning Representations, 2018. Soheil Kolouri, Kimia Nadjahi, Umut Simsekli, Roland Badeau, and Gustavo K Rohde. Generalized sliced wasserstein distances. arXiv preprint arXiv:1902.00434, 2019.
|
| 456 |
+
Alexander Korotin, Vage Egiazarian, Arip Asadulaev, Alexander Safin, and Evgeny Burnaev. Wasserstein-2 generative networks. arXiv preprint arXiv:1909.13082, 2019. Alexander Korotin, Lingxiao Li, Aude Genevay, Justin M Solomon, Alexander Filippov, and Evgeny Burnaev. Do neural optimal transport solvers work? a continuous wasserstein-2 benchmark. Advances in Neural Information Processing Systems, 34:14593–14605, 2021a.
|
| 457 |
+
Alexander Korotin, Lingxiao Li, Justin Solomon, and Evgeny Burnaev. Continuous wasserstein-2 barycenter estimation without minimax optimization. arXiv preprint arXiv:2102.01752, 2021b. Alexander Korotin, Daniil Selikhanovych, and Evgeny Burnaev. Neural optimal transport. arXiv preprint arXiv:2201.12220, 2022.
|
| 458 |
+
Julien Lacombe, Julie Digne, Nicolas Courty, and Nicolas Bonneel. Learning to generate wasserstein barycenters, 2021. URL https://openreview.net/forum?id $\cdot ^ { = }$ 2ioNazs6lvw. Lingxiao Li, Aude Genevay, Mikhail Yurochkin, and Justin Solomon. Continuous regularized wasserstein barycenters. arXiv preprint arXiv:2008.12534, 2020. Tianyi Lin, Nhat Ho, and Michael I Jordan. On the acceleration of the sinkhorn and greenkhorn algorithms for optimal transport. arXiv preprint arXiv:1906.01437, 2019. Alexander Litvinenko, Youssef Marzouk, Hermann G Matthies, Marco Scavino, and Alessio Spantini. Computing f-divergences and distances of high-dimensional probability density functions–low-rank tensor approximations. arXiv preprint arXiv:2111.07164, 2021. Ashok Makkuva, Amirhossein Taghvaei, Sewoong Oh, and Jason Lee. Optimal transport mapping via input convex neural networks. In International Conference on Machine Learning, pages 6672–6681. PMLR, 2020. Quentin Merigot and Boris Thibert. Optimal transport: discretization and algorithms. In Handbook of Numerical Analysis, volume 22, pages 133–212. Elsevier, 2021. Petr Mokrov, Alexander Korotin, Lingxiao Li, Aude Genevay, Justin M Solomon, and Evgeny Burnaev. Largescale wasserstein gradient flows. Advances in Neural Information Processing Systems, 34:15243–15256, 2021. Boris Muzellec and Marco Cuturi. Subspace detours: Building transport plans that are optimal on subspace projections. Advances in Neural Information Processing Systems, 32, 2019. Khai Nguyen and Nhat Ho. Amortized projection optimization for sliced wasserstein generative models. arXiv preprint arXiv:2203.13417, 2022. Michaël Perrot, Nicolas Courty, Rémi Flamary, and Amaury Habrard. Mapping estimation for discrete optimal transport. Advances in Neural Information Processing Systems, 29, 2016. Gabriel Peyré, Marco Cuturi, et al. Computational optimal transport: With applications to data science. Foundations and Trends® in Machine Learning, 11(5-6):355–607, 2019. Ievgen Redko, Nicolas Courty, Rémi Flamary, and Devis Tuia. Optimal transport for multi-source domain adaptation under target shift. In The 22nd International Conference on Artificial Intelligence and Statistics, pages 849–858. PMLR, 2019. Ralph Tyrell Rockafellar. Convex analysis. In Convex analysis. Princeton university press, 2015. Litu Rout, Alexander Korotin, and Evgeny Burnaev. Generative modeling with optimal transport maps. In International Conference on Learning Representations, 2021. Andrei A Rusu, Dushyant Rao, Jakub Sygnowski, Oriol Vinyals, Razvan Pascanu, Simon Osindero, and Raia Hadsell. Meta-learning with latent embedding optimization. In International Conference on Learning Representations, 2018.
|
| 459 |
+
|
| 460 |
+
436 Filippo Santambrogio. Optimal transport for applied mathematicians. Birkäuser, NY, 55(58-63):94, 2015.
|
| 461 |
+
437 Meyer Scetbon, Marco Cuturi, and Gabriel Peyré. Low-rank sinkhorn factorization. In International Confer
|
| 462 |
+
438 ence on Machine Learning, pages 9344–9354. PMLR, 2021.
|
| 463 |
+
439 Meyer Scetbon, Gabriel Peyré, and Marco Cuturi. Linear-time gromov wasserstein distances using low rank
|
| 464 |
+
440 couplings and costs. In International Conference on Machine Learning, pages 19347–19365. PMLR, 2022.
|
| 465 |
+
441 Geoffrey Schiebinger, Jian Shu, Marcin Tabaka, Brian Cleary, Vidya Subramanian, Aryeh Solomon, Joshua
|
| 466 |
+
442 Gould, Siyan Liu, Stacie Lin, Peter Berube, Lia Lee, Jenny Chen, Justin Brumbaugh, Philippe Rigol
|
| 467 |
+
443 let, Konrad Hochedlinger, Rudolf Jaenisch, Aviv Regev, and Eric S. Lander. Optimal-transport analy
|
| 468 |
+
444 sis of single-cell gene expression identifies developmental trajectories in reprogramming. Cell, 176(4):
|
| 469 |
+
445 928–943.e22, 2019. ISSN 0092-8674. doi: https://doi.org/10.1016/j.cell.2019.01.006. URL https:
|
| 470 |
+
446 //www.sciencedirect.com/science/article/pii/S009286741930039X.
|
| 471 |
+
447 Vivien Seguy, Bharath Bhushan Damodaran, Remi Flamary, Nicolas Courty, Antoine Rolet, and Mathieu Blon
|
| 472 |
+
448 del. Large scale optimal transport and mapping estimation. In International Conference on Learning Repre
|
| 473 |
+
449 sentations, 2018.
|
| 474 |
+
450 Justin Solomon, Fernando De Goes, Gabriel Peyré, Marco Cuturi, Adrian Butscher, Andy Nguyen, Tao Du,
|
| 475 |
+
451 and Leonidas Guibas. Convolutional wasserstein distances: Efficient optimal transportation on geometric
|
| 476 |
+
452 domains. ACM Transactions on Graphics (TOG), 34(4):1–11, 2015.
|
| 477 |
+
453 Max Sommerfeld, Jörn Schrieber, Yoav Zemel, and Axel Munk. Optimal transport: Fast probabilistic approxi
|
| 478 |
+
454 mation with exact solvers. J. Mach. Learn. Res., 20:105–1, 2019.
|
| 479 |
+
455 Kenneth O Stanley, David B D’Ambrosio, and Jason Gauci. A hypercube-based encoding for evolving large
|
| 480 |
+
456 scale neural networks. Artificial life, 15(2):185–212, 2009.
|
| 481 |
+
457 Amirhossein Taghvaei and Amin Jalali. 2-wasserstein approximation via restricted convex potentials with
|
| 482 |
+
458 application to improved training for gans. arXiv preprint arXiv:1902.07197, 2019.
|
| 483 |
+
459 Matthew Tancik, Ben Mildenhall, Terrance Wang, Divi Schmidt, Pratul P Srinivasan, Jonathan T Barron, and
|
| 484 |
+
460 Ren Ng. Learned initializations for optimizing coordinate-based neural representations. In Proceedings of
|
| 485 |
+
461 the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2846–2855, 2021.
|
| 486 |
+
462 Alexis Thibault, Lenaic Chizat, Charles Dossal, and Nicolas Papadakis. Overrelaxed sinkhorn-knopp algorithm
|
| 487 |
+
463 for regularized optimal transport. arXiv preprint arXiv:1711.01851, 2017.
|
| 488 |
+
464 James Thornton and Marco Cuturi. Rethinking initialization of the sinkhorn algorithm. arXiv preprint
|
| 489 |
+
465 arXiv:2206.07630, 2022.
|
| 490 |
+
466 Cédric Villani. Optimal transport: old and new, volume 338. Springer, 2009.
|
| 491 |
+
467 Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using
|
| 492 |
+
468 cycle-consistent adversarial networks. In Proceedings of the IEEE international conference on computer
|
| 493 |
+
469 vision, pages 2223–2232, 2017.
|
| 494 |
+
470 Luisa Zintgraf, Kyriacos Shiarli, Vitaly Kurin, Katja Hofmann, and Shimon Whiteson. Fast context adaptation
|
| 495 |
+
471 via meta-learning. In International Conference on Machine Learning, pages 7693–7702. PMLR, 2019.
|
| 496 |
+
|
| 497 |
+
1. For all authors...
|
| 498 |
+
|
| 499 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] We hope so
|
| 500 |
+
(b) Did you describe the limitations of your work? [Yes] In sect. 6
|
| 501 |
+
(c) Did you discuss any potential negative societal impacts of your work? [No] We do not immediately foresee any that our work would add that the broader optimal transport field doesn’t already have
|
| 502 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 503 |
+
|
| 504 |
+
2. If you are including theoretical results... (This is not a theory paper)
|
| 505 |
+
|
| 506 |
+
(a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
|
| 507 |
+
|
| 508 |
+
3. If you ran experiments...
|
| 509 |
+
|
| 510 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes]
|
| 511 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 512 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We show results from multiple trials in most places
|
| 513 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes]
|
| 514 |
+
|
| 515 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 516 |
+
|
| 517 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 518 |
+
(b) Did you mention the license of the assets? [Yes]
|
| 519 |
+
(c) Did you include new assets either in the supplemental material or as a URL? [No]
|
| 520 |
+
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
|
| 521 |
+
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
|
| 522 |
+
|
| 523 |
+
5. If you used crowdsourcing or conducted research with human subjects...
|
| 524 |
+
|
| 525 |
+
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
|
| 526 |
+
(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
|
| 527 |
+
(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
|
| 528 |
+
|
| 529 |
+

|
| 530 |
+
Figure 8: We selected $\epsilon = 1 0 ^ { - 2 }$ for our MNIST coupling experiments as it results in transport maps that are not too blurry or sharp.
|
| 531 |
+
|
| 532 |
+
# 512 B Other models for continuous OT
|
| 533 |
+
|
| 534 |
+
While developing the hyper-network or Meta ICNN in sect. 3.2 for predicting couplings between continuous measures, we considered alternative modeling formulations briefly documented in this section. We finalized only the hyper-network model because it is conceptually the most similar to predicting the optimal dual variables in the continuous setting and results in rapid predictions.
|
| 535 |
+
|
| 536 |
+
# 517 B.1 Optimization-based meta-learning (MAML-inspired)
|
| 537 |
+
|
| 538 |
+
518 The model-agnostic meta-learning setup proposed in MAML [Finn et al., 2017] could also be ap
|
| 539 |
+
519 plied in the Meta OT setting to learn an adaptable initial parameterization. In the continuous setting,
|
| 540 |
+
520 one initial version would take a parameterized dual potential model $\psi _ { \varphi } ( x )$ and seek to learn an ini
|
| 541 |
+
521 tial parameterization $\varphi _ { 0 }$ so that optimizing a loss such as the W2GN loss $\mathcal { L }$ from eq. (12) results in
|
| 542 |
+
522 a minimal $\mathcal { L } ( \varphi _ { K } )$ after adapting the model for $K$ steps. Formally, this would optimize:
|
| 543 |
+
|
| 544 |
+
$$
|
| 545 |
+
\operatorname * { a r g m i n } _ { \varphi _ { 0 } } \mathcal { L } ( \varphi _ { K } ) \quad \mathrm { w h e r e } \quad \varphi _ { t + 1 } = \varphi _ { t } - \nabla _ { \varphi } \mathcal { L } ( \varphi _ { t } )
|
| 546 |
+
$$
|
| 547 |
+
|
| 548 |
+
Tancik et al. [2021] explores similar learned initializations for coordinate-based neural implicit representations for 2D images, CT scan reconstruction, and 3d shape and scene recovery from 2D observations.
|
| 549 |
+
|
| 550 |
+
Challenges for Meta OT. The transport maps given by $T = \nabla \psi$ can significantly vary depending on the input measures $\alpha , \beta$ . We found it difficult to learn an initialization that can be rapidly adapted, and optimizing eq. (19) is more computationally expensive than eq. (18) as it requires unrolling through many evaluations of the transport loss $\mathcal { L }$ . And, we found that only learning to predict the optimal parameters with eq. (18), conditional on the input measures, and then fine-tuning with W2GN to be stable.
|
| 551 |
+
|
| 552 |
+
532 Advantages for Meta OT. Exploring MAML-inspired methods could further incorporate the knowl
|
| 553 |
+
533 edge that the model’s prediction is going to be fine-tuned into the learning process. One promising
|
| 554 |
+
|
| 555 |
+
direction we did not try could be to integrate some of the ideas from LEO [Rusu et al., 2018] and CAVIA [Zintgraf et al., 2019], which propose to learn a latent space for the parameters where the initialization is also conditional on the input.
|
| 556 |
+
|
| 557 |
+
# B.2 Neural process and conditional Monge maps
|
| 558 |
+
|
| 559 |
+
The (conditional) neural process models considered in Garnelo et al. [2018b,a] can also be adapted for the Meta OT setting, and is similar to the model proposed in Bunne et al. [2022a]. In the continuous setting, this would result in a dual potential that is also conditioned on a representation of the input measures, e.g. $\psi _ { \varphi } ( x ; z )$ where $z : = f _ { \varphi } ^ { \mathrm { e m b } } ( \alpha , \beta )$ is a learned embedding of the input measures that is learned with the parameters of $\psi$ . This could be formulated as
|
| 560 |
+
|
| 561 |
+
$$
|
| 562 |
+
\underset { \varphi } { \arg \operatorname* { m i n } } \ \underset { ( \alpha , \beta ) \sim \mathcal { D } } { \mathbb { E } } \mathcal { L } ( \varphi , f _ { \varphi } ^ { \mathrm { e m b } } ( \alpha , \beta ) ) ,
|
| 563 |
+
$$
|
| 564 |
+
|
| 565 |
+
543 where $\mathcal { L }$ modifies the model used in the loss eq. (12) to also be conditioned on the context extracted
|
| 566 |
+
544 from the measures.
|
| 567 |
+
|
| 568 |
+
Challenges for Meta OT. This raises the issue on best-formulating the model to be conditional on the context. One way could be to append $z$ to the input point $x$ in the domain. Bunne et al. [2022a] proposes to use the Partially Input-Convex Neural Network (PICNN) from [Amos et al., 2017] to make the model convex with respect to $x$ and not $z$ .
|
| 569 |
+
|
| 570 |
+
Advantages for Meta OT. A large advantage is that the representation $z$ of the measures $\alpha , \beta$ would be significantly lower-dimensional than the parameters $\varphi$ that our Meta OT models are predicting.
|
| 571 |
+
|
| 572 |
+
# 551 C Additional experimental and implementation details
|
| 573 |
+
|
| 574 |
+
We have attached the Jax source code necessary to run and reproduce all of the experiments in our 553 paper and will open-source all of it. Here is a basic overview of the files:
|
| 575 |
+
|
| 576 |
+

|
| 577 |
+
|
| 578 |
+
555 Connecting to the data is one difficulty in running the experiments. The easiest experiment to re-run
|
| 579 |
+
556 is the MNIST one, which will automatically download the dataset:
|
| 580 |
+
557558 1 ./ train_discrete . py # Train the model , outputting to <exp_dir >
|
| 581 |
+
559 2 ./ eval_discrete . py < exp_dir > # Evaluate the learned models
|
| 582 |
+
560 3 ./ plot_mnist . py < exp_dir > # Produce further visualizations 561
|
| 583 |
+
|
| 584 |
+
# 562 C.1 Hyper-parameters
|
| 585 |
+
|
| 586 |
+
563 We briefly summarize the hyper-parameters we used for training, which we did not extensively tune.
|
| 587 |
+
564 In the discrete setting, we use the same hyper-parameters for the MNIST and spherical settings.
|
| 588 |
+
|
| 589 |
+
Table 3: Discrete OT hyper-parameters.
|
| 590 |
+
|
| 591 |
+
<table><tr><td>Name</td><td>Value</td></tr><tr><td>Batch size</td><td>128</td></tr><tr><td>Number of training iterations</td><td>50000</td></tr><tr><td>MLP Hidden Sizes</td><td>[1024,1024,1024]</td></tr><tr><td>Adam learning rate</td><td>1e-3</td></tr></table>
|
| 592 |
+
|
| 593 |
+
565
|
| 594 |
+
|
| 595 |
+
Table 4: Continuous OT hyper-parameters.
|
| 596 |
+
|
| 597 |
+
<table><tr><td>Name</td><td>Value</td></tr><tr><td>Meta batch size (for α,β)</td><td>8</td></tr><tr><td>Inner batch size (to estimate L) Cycle loss weight ()</td><td>1024</td></tr><tr><td>Adam learning rate</td><td>3. 1e-3</td></tr><tr><td>l2 weight penalty</td><td>1e-6</td></tr><tr><td>Max grad norm (for clipping)</td><td>1.</td></tr><tr><td>Number of training iterations</td><td>200000</td></tr><tr><td>MetaICNNEncoder</td><td>ResNet18</td></tr><tr><td>Encoder output size (both measures)</td><td></td></tr><tr><td>MetaICNNDecoderHidden Sizes</td><td>256×2 [512]</td></tr></table>
|
| 598 |
+
|
| 599 |
+
# 566 C.2 Sinkhorn convergence times, varying thresholds
|
| 600 |
+
|
| 601 |
+
In the main paper, table 1 reports the runtime of Sinkhorn to reach a convergence threshold of the marginal error being below a tolerance of $1 0 ^ { - 3 }$ , which is the default value used in many solvers. app. C.2 report the results from sweeping over other thresholds and show that Meta OT’s initialization is consistently able to help.
|
| 602 |
+
|
| 603 |
+
Table 5: Sinkhorn runtime to reach a thresholded marginal error on MNIST.
|
| 604 |
+
|
| 605 |
+
<table><tr><td>Initialization</td><td>Threshold=10-2</td><td>Threshold=10-3</td><td>Threshold=10-4</td><td>Threshold=10-5</td></tr><tr><td>Zeros</td><td>4.5. 10-3 ±1.5·10-3</td><td>7.7.10-3 ±1.2· 10-3</td><td>1.1.10-2 ±1.8.10-3</td><td>1.5.10-2 ±2.3.10-3</td></tr><tr><td>Gaussian</td><td>4.1· 10- ±1.2 ·10-3</td><td>7.7 · 10-3 ±1.4 10-3</td><td>1.1: 10-2 ±1.7· 10-3</td><td>1.4: 10-² ±2.4 · 10-3</td></tr><tr><td>Meta OT</td><td>2.3 · 10-3 ±9.2 · 10-6</td><td>3.9 · 10-3 ±1.6 · 10-3</td><td>6.7 · 10-3 ±1.4 · 10-3</td><td>1.0 · 10-² ±2.4 · 10-3</td></tr></table>
|
| 606 |
+
|
| 607 |
+
Table 6: Sinkhorn runtime to reach a thresholded marginal error on the spherical transport problem.
|
| 608 |
+
|
| 609 |
+
<table><tr><td>Initialization</td><td>Threshold=10-2</td><td>Threshold=10-3</td><td>Threshold=10-4</td><td>Threshold=10-5</td></tr><tr><td>Zeros</td><td>8.8.10-1 ±1.3·10-1</td><td>1.4 ±1.9 · 10-1</td><td>2.1 ±3.6:10-1</td><td>2.8 ±5.6.10-1</td></tr><tr><td>Gaussian</td><td>5.6.10-1 ±9.9.10-2</td><td>1.1 ±2.0 : 10-1</td><td>1.7 ±3.5 - 10-1</td><td>2.4 ±5.4 · 10-1</td></tr><tr><td>Meta OT</td><td> 7.8 · 10-² ±3.4· 10-²</td><td>0.44 ±1.5 10-1</td><td>0.97 ±3.2 - 10-1</td><td>1.7 ±6.8 10-1</td></tr></table>
|
| 610 |
+
|
| 611 |
+
572
|
| 612 |
+
573
|
| 613 |
+
574
|
| 614 |
+
|
| 615 |
+
App. C.3 shows the convergence during training of Meta OT models in the discrete and continuous settings over 10 trials on our single Quadro GP100 GPU. The MNIST models are consistently trained to optimality within 2 minutes (!) while the continuous model takes a few hours to train.
|
| 616 |
+
|
| 617 |
+

|
| 618 |
+
Figure 9: Convergence of Meta OT models during training, reported over iterations and wall-clock time. We run each experiment for 10 trials with different seeds and report each trial as a line.
|
| 619 |
+
|
| 620 |
+
# 575 D Out-of-distribution generalization
|
| 621 |
+
|
| 622 |
+
App. D tests the ability of Meta OT to predict potentials for out-of-distribution input data. We consider the pairwise training and evaluation on the following datasets: 1) MNIST; 2) USPS [Hull, 1994] (upscaled to have the same size as the MNIST); 3) Google Doodles dataset \* with classes Crab, Cat and Faces; 4) sparsified random uniform data in [0,1] where sparsity (zeroing values below 0.95) is used to mimic the sparse signal in black-and-white images. For each pair, eg, MNIST-USPS, we train on one dataset and use the other to predict the potentials. The comparison is done using the same metric as before, i.e., the deviation from the marginal constraints defined in eq. (7).
|
| 623 |
+
|
| 624 |
+

|
| 625 |
+
Figure 10: Cross-domain experiments.
|
| 626 |
+
|
| 627 |
+
# 583 E Additional color transfer results
|
| 628 |
+
|
| 629 |
+
84 We next show additional color transfer results from the experiments in sect. 4.3 on the following
|
| 630 |
+
85 public domain images from WikiArt:
|
| 631 |
+
|
| 632 |
+
• Distant View of the Pyramids by Winston Churchill (1921)
|
| 633 |
+
• Charing Cross Bridge, Overcast Weather by Claude Monet (1900)
|
| 634 |
+
• Houses of Parliament by Claude Monet (1904)
|
| 635 |
+
• October Sundown, Newport by Childe Hassam (1901)
|
| 636 |
+
• Landscape with House at Ceret by Juan Gris (1913)
|
| 637 |
+
• Irises in Monet’s Garden by Claude Monet (1900)
|
| 638 |
+
• Crystal Gradation by Paul Klee (1921)
|
| 639 |
+
• Senecio by Paul Klee (1922)
|
| 640 |
+
• Váza s kvetinami by Josef Capek (1914) ˇ
|
| 641 |
+
• Sower with Setting Sun by Vincent van Gogh (1888)
|
| 642 |
+
• Three Trees in Grey Weather by Claude Monet (1891)
|
| 643 |
+
• Vase with Daisies and Anemones by Vincent van Gogh (1887)
|
| 644 |
+
|
| 645 |
+

|
| 646 |
+
Figure 11: Meta ICNN (initial prediction). The sources are given in the beginning of app. E.
|
| 647 |
+
|
| 648 |
+

|
| 649 |
+
Figure 12: Meta ICNN $^ +$ W2GN fine-tuning. The sources are given in the beginning of app. E.
|
| 650 |
+
|
| 651 |
+

|
| 652 |
+
Figure 13: W2GN (final). The sources are given in the beginning of app. E.
|
md/dev/xT5rDp5VqKO/xT5rDp5VqKO.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Coincidence Detection Is All You Need
|
| 2 |
+
|
| 3 |
+
Anonymous Author(s)
|
| 4 |
+
Affiliation
|
| 5 |
+
Address
|
| 6 |
+
email
|
| 7 |
+
|
| 8 |
+
# Abstract
|
| 9 |
+
|
| 10 |
+
1 This paper demonstrates that the performance of coincidence detection - a classic
|
| 11 |
+
2 neuromorphic signal processing method found in Rosenblatt’s perceptrons with
|
| 12 |
+
3 distributed transmission times, can be competitive to a state-of-the-art deep learning
|
| 13 |
+
4 method for pattern recognition. Hence, we cannot remain comfortably numb to the
|
| 14 |
+
5 prevailing dogma that efficient matrix-vector operations is all we need; but should
|
| 15 |
+
6 enquire with greater vigour if more advanced continual learning methods (running
|
| 16 |
+
7 on spiking neural network hardware with neuromodulatory mechanisms at multiple
|
| 17 |
+
8 timescales) can beat the accuracy of task-specific deep learning methods.
|
| 18 |
+
|
| 19 |
+
# 9 1 Introduction
|
| 20 |
+
|
| 21 |
+
10 Frank Rosenblatt and his team (1957-1971) built and analyzed several kinds of perceptrons [1, 2, 3, 4]
|
| 22 |
+
11 - networks of sensory, association and receptor neurons; which in contemporary deep learning termi
|
| 23 |
+
12 nology relates to the input, hidden and output layers. The propagating signals were binary (compatible
|
| 24 |
+
13 with a spike-based view), the synaptic delays (transmission times) and weights (memory states) could
|
| 25 |
+
14 be analog, the network could be recurrent and was often randomly interconnected, and learning
|
| 26 |
+
15 often meant tuning the weights of the association-receptor subnetwork by some error-corrective
|
| 27 |
+
16 reinforcement. The synaptic delays were not learnt but instead randomly distributed in Rosenblatt’s
|
| 28 |
+
17 Tobermory perceptrons [5], and this was rich enough to realize concentration-invariant and uniform
|
| 29 |
+
18 time-warp invariant spatiotemporal classification by logarithmic encoding and coincidence detection.
|
| 30 |
+
19 However, the processing speed of commercial Von Neumann computers advanced exponentially
|
| 31 |
+
20 and outperformed neuromorphic hardware on yesterdecade’s benchmarks [6]. The Tobermory per
|
| 32 |
+
21 ceptron was forgotten, nevertheless, the utility of logarithmic encoding and coincidence detection
|
| 33 |
+
22 was formalized by John Hopfield [7] as an efficient solution to the analog match problem in pattern
|
| 34 |
+
23 recognition.
|
| 35 |
+
24 Now, half a century after the accidental demise of Rosenblatt, neuromorphic signal processors are
|
| 36 |
+
25 making a comeback. For example, (1) Intel’s Loihi with spike-time dependent plasticity mechanisms
|
| 37 |
+
26 for learning olfactory pattern recognizers [8]; (2) Physical reservoir computing networks [9] where
|
| 38 |
+
27 the interconnectivity of the hidden layer is unchanged, closer to the spirit of Rosenblatt’s randomly
|
| 39 |
+
28 interconnected sensory-association subnetwork.
|
| 40 |
+
29 Here, to strengthen the case for revisiting classic methods on novel and modern hardware, we evaluate
|
| 41 |
+
30 the performance of coincidence detection in comparison to a deep learning method. Nothing more,
|
| 42 |
+
31 nothing less, although this work was triggered by a rabid interest in employing artificial intelligence
|
| 43 |
+
32 to sniff out infections and prevent future pandemics.
|
| 44 |
+
|
| 45 |
+
Table 1: Test accuracy $( \% )$
|
| 46 |
+
|
| 47 |
+
<table><tr><td>ResNet-26</td><td>Coincidence detection</td></tr><tr><td>82.2±0.3 (from [10])</td><td>82.7 (this work)</td></tr></table>
|
| 48 |
+
|
| 49 |
+
# 33 2 Methods
|
| 50 |
+
|
| 51 |
+
34 Here, we consider the work [10] of an interdisciplinary team, where a 26 layer convolutional neural
|
| 52 |
+
35 network with residual connections (ResNet-26) was successfully trained for classifying pathogenic
|
| 53 |
+
36 bacteria by Raman spectroscopy. In their work, there are $N = 3 0$ classes of bacterial isolates and
|
| 54 |
+
37 they begin with a ResNet-26 pre-trained on $N { \times } 2 0 0 0$ spectra, then for each class $n = 1 : N$ there are
|
| 55 |
+
38 $M = 1 0 0$ training spectra, and similarly $N \times M = 3 0 0 0$ test spectra. Each spectrum $_ { \textbf { \em x } }$ contains 1000
|
| 56 |
+
39 floating-point numbers ranging between 0 and 1. Although compute intensive, their deep learning
|
| 57 |
+
40 method proved to be a tool of great convenience for pattern recognition in a challenging dataset,
|
| 58 |
+
41 where intra-isolate spectra were often more dissimilar than inter-isolate spectra.
|
| 59 |
+
42 Our method to tackle the above dataset, is inspired by the theory of how coincidence detection [7]
|
| 60 |
+
43 in animal brains is fundamental for odour classification in complex and turbulent mixtures. Each
|
| 61 |
+
44 class $n$ has a vector representation ${ \pmb w } _ { n }$ that is learnt, and an input vector $_ { \textbf { \em x } }$ results in an output
|
| 62 |
+
45 class $y ( \pmb { x } ) = \arg _ { n } \operatorname* { m a x } ( \pmb { x } \wedge \pmb { w } _ { n } )$ where we introduce the operator $\Lambda$ to represent the coincidence
|
| 63 |
+
46 between two signals. The analytical nature of coincidence detection depends on the specificities of the
|
| 64 |
+
47 ion-channels and the membranes involved [11], and may even incorporate nonlinear leaky-integrate
|
| 65 |
+
48 [12] multiple timescale mechanisms. We do not yet have a complete theory of neuromorphic signal
|
| 66 |
+
49 processing, so here we introduce an approximation for the translation and scale-invariant property of
|
| 67 |
+
50 coincidence detection as
|
| 68 |
+
|
| 69 |
+
$$
|
| 70 |
+
\operatorname { a r g } _ { n } \operatorname * { m a x } ( { \pmb x } \bigwedge { \pmb w } _ { n } ) \approx \arg _ { n } \operatorname * { m a x } ( { \pmb w } _ { n } \cdot { \hat { \pmb x } } ) ,
|
| 71 |
+
$$
|
| 72 |
+
|
| 73 |
+
51 where $\hat { \pmb x }$ is the zero-mean unit-variance normalization of $_ { \textbf { \em x } }$ .
|
| 74 |
+
|
| 75 |
+
52 Thus, the approximation in Eq. (1) allows $y ( \pmb { x } )$ to be learnt by a logistic regression on the normalized
|
| 76 |
+
53 dataset. We discard the pre-training data, pre-process the training and test spectra by a range-1 mean
|
| 77 |
+
54 filter, and use the default method for logistic regression in Wolfram Mathematica (L2-regularization
|
| 78 |
+
55 $= 0 . 0 0 0 1$ , optimization method $=$ limited-memory BFGS). Code is provided in the supplemental
|
| 79 |
+
56 material for reproducibility.
|
| 80 |
+
|
| 81 |
+
# 57 3 Result and outlook
|
| 82 |
+
|
| 83 |
+
58 The coincidence detection (via normalized logistic regression) method introduced here achieves a test
|
| 84 |
+
59 accuracy greater than ResNet-26 (see Table 1), and it took less than 3 seconds to train the classifier
|
| 85 |
+
60 on a modern desktop (without any special-purpose GPUs). Check the Appendix for a confusion
|
| 86 |
+
61 matrix plot of the training and test data. Note that the training data was fit all at once to a $100 \%$
|
| 87 |
+
62 accuracy. With a more neuromorphic coincidence detection method and a learning method that adapts
|
| 88 |
+
63 the synaptic delays $\pmb { w }$ continually, to keep track under changing environmental conditions, we may
|
| 89 |
+
64 achieve even greater accuracies.
|
| 90 |
+
|
| 91 |
+
# 5 References
|
| 92 |
+
|
| 93 |
+
6 [1] Frank Rosenblatt. The perceptron, a perceiving and recognizing automaton Project Para.
|
| 94 |
+
Cornell Aeronautical Laboratory, Inc. Report no. 85-460-1, 1957.
|
| 95 |
+
8 [2] Frank Rosenblatt. The perceptron: A theory of statistical separability in cognitive systems.
|
| 96 |
+
9 Cornell Aeronautical Laboratory, Inc. Report no. VG-1196-G-1, 1958.
|
| 97 |
+
0 [3] Frank Rosenblatt. Principles of neurodynamics. perceptrons and the theory of brain mechanisms.
|
| 98 |
+
1 Cornell Aeronautical Laboratory, Inc. Report no. 1196-G-8, 1961.
|
| 99 |
+
|
| 100 |
+
[4] Frank Rosenblatt. Cognitive systems research program. Technical report, Cornell University, Ithaca, New York, 1971. [5] Frank Rosenblatt. A description of the tobermory perceptron. In Collected Technical Papers, volume 2. Cornell University, Ithaca, New York, 1963. [6] George Nagy. Neural networks-then and now. IEEE Transactions on Neural Networks, 2(2):316– 318, 1991.
|
| 101 |
+
[7] John J Hopfield. Pattern recognition computation using action potential timing for stimulus representation. Nature, 376(6535):33–36, 1995. [8] Nabil Imam and Thomas A Cleland. Rapid online learning and robust recall in a neuromorphic olfactory circuit. Nature Machine Intelligence, 2(3):181–191, 2020. [9] G. Tanaka, T. Yamane, J.B. Héroux, R. Nakane, N. Kanazawa, S. Takeda, H. Numata, D. Nakano, and A. Hirose. Recent advances in physical reservoir computing: A review. Neural Networks, 115:100–123, 2019.
|
| 102 |
+
[10] Chi-Sing Ho, Neal Jean, Catherine A Hogan, Lena Blackmon, Stefanie S Jeffrey, Mark Holodniy, Niaz Banaei, Amr AE Saleh, Stefano Ermon, and Jennifer Dionne. Rapid identification of pathogenic bacteria using raman spectroscopy and deep learning. Nature communications, 10(1):1–8, 2019.
|
| 103 |
+
[11] Nelson Spruston. Pyramidal neurons: dendritic structure and synaptic integration. Nature Reviews Neuroscience, 9(3):206–221, 2008.
|
| 104 |
+
[12] Wondimu Teka, Toma M Marinov, and Fidel Santamaria. Neuronal spike timing adaptation described with a fractional leaky integrate-and-fire model. PLoS computational biology, 10(3):e1003526, 2014.
|
| 105 |
+
|
| 106 |
+
# 94 Checklist
|
| 107 |
+
|
| 108 |
+
1. For all authors...
|
| 109 |
+
|
| 110 |
+
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] See Table 1.
|
| 111 |
+
(b) Did you describe the limitations of your work? [Yes] Equation (1) makes it clear that we employ an approximation for coincidence detection.
|
| 112 |
+
(c) Did you discuss any potential negative societal impacts of your work? [N/A]
|
| 113 |
+
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
|
| 114 |
+
|
| 115 |
+
2. If you are including theoretical results...
|
| 116 |
+
|
| 117 |
+
(a) Did you state the full set of assumptions of all theoretical results? [N/A] (b) Did you include complete proofs of all theoretical results? [N/A]
|
| 118 |
+
|
| 119 |
+
3. If you ran experiments...
|
| 120 |
+
|
| 121 |
+
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] Check supplemental material
|
| 122 |
+
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes]
|
| 123 |
+
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
|
| 124 |
+
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] qualitatively, in the results section
|
| 125 |
+
|
| 126 |
+
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
|
| 127 |
+
|
| 128 |
+
(a) If your work uses existing assets, did you cite the creators? [Yes]
|
| 129 |
+
|
| 130 |
+
<table><tr><td>118</td><td>(b) Did you mention the license of the assets? [Yes] In the supplemental information</td></tr><tr><td>119</td><td>(c) Did you include any new assets either in the supplemental material or as a URL? [No]</td></tr><tr><td>120 121</td><td>(d) Did you discuss whether and how consent was obtained from people whose data you're using/curating?[N/A]</td></tr><tr><td>122 123</td><td>(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]</td></tr><tr><td>124</td><td> 5. If you used crowdsourcing or conducted research with human subjects...</td></tr><tr><td>125 126</td><td>(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]</td></tr><tr><td>127 128</td><td>(b) Did you describe any potential participant risks,with links to Institutional Review Board (IRB) approvals, if applicable?[N/A]</td></tr><tr><td>129 130</td><td>(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]</td></tr></table>
|
| 131 |
+
|
| 132 |
+
# 131 A Appendix
|
| 133 |
+
|
| 134 |
+

|
md/dev/yHdTscY6Ci/yHdTscY6Ci.md
ADDED
|
@@ -0,0 +1,618 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HuggingGPT: Solving AI Tasks with ChatGPT and its Friends in Hugging Face
|
| 2 |
+
|
| 3 |
+
Yongliang Shen $^ { 1 , 2 , * }$ , Kaitao $\mathbf { S o n g ^ { 2 , * , \dagger } }$ , Xu Tan2, Dongsheng $\mathbf { L i } ^ { 2 }$ , Weiming $\mathbf { L u } ^ { 1 , \dagger }$ , Yueting Zhuang1,† Zhejiang University1, Microsoft Research Asia2 {syl, luwm, yzhuang}@zju.edu.cn, {kaitaosong, xuta, dongsli}@microsoft.com
|
| 4 |
+
|
| 5 |
+
https://github.com/microsoft/JARVIS
|
| 6 |
+
|
| 7 |
+
# Abstract
|
| 8 |
+
|
| 9 |
+
Solving complicated AI tasks with different domains and modalities is a key step toward artificial general intelligence. While there are numerous AI models available for various domains and modalities, they cannot handle complicated AI tasks autonomously. Considering large language models (LLMs) have exhibited exceptional abilities in language understanding, generation, interaction, and reasoning, we advocate that LLMs could act as a controller to manage existing AI models to solve complicated AI tasks, with language serving as a generic interface to empower this. Based on this philosophy, we present HuggingGPT, an LLM-powered agent that leverages LLMs (e.g., ChatGPT) to connect various AI models in machine learning communities (e.g., Hugging Face) to solve AI tasks. Specifically, we use ChatGPT to conduct task planning when receiving a user request, select models according to their function descriptions available in Hugging Face, execute each subtask with the selected AI model, and summarize the response according to the execution results. By leveraging the strong language capability of ChatGPT and abundant AI models in Hugging Face, HuggingGPT can tackle a wide range of sophisticated AI tasks spanning different modalities and domains and achieve impressive results in language, vision, speech, and other challenging tasks, which paves a new way towards the realization of artificial general intelligence.
|
| 10 |
+
|
| 11 |
+
# 1 Introduction
|
| 12 |
+
|
| 13 |
+
Large language models (LLMs) [1, 2, 3, 4, 5, 6], such as ChatGPT, have attracted substantial attention from both academia and industry, due to their remarkable performance on various natural language processing (NLP) tasks. Based on large-scale pre-training on massive text corpora and reinforcement learning from human feedback [2], LLMs can exhibit superior capabilities in language understanding, generation, and reasoning. The powerful capability of LLMs also drives many emergent research topics (e.g., in-context learning [1, 7, 8], instruction learning [9, 10, 11, 12, 13, 14], and chain-of-thought prompting [15, 16, 17, 18]) to further investigate the huge potential of LLMs, and brings unlimited possibilities for us for advancing artificial general intelligence.
|
| 14 |
+
|
| 15 |
+
Despite these great successes, current LLM technologies are still imperfect and confront some urgent challenges on the way to building an advanced AI system. We discuss them from these aspects: 1) Limited to the input and output forms of text generation, current LLMs lack the ability to process complex information such as vision and speech, regardless of their significant achievements in NLP tasks; 2) In real-world scenarios, some complex tasks are usually composed of multiple sub-tasks, and thus require the scheduling and cooperation of multiple models, which are also beyond the capability of language models; 3) For some challenging tasks, LLMs demonstrate excellent results in zero-shot or few-shot settings, but they are still weaker than some experts (e.g., fine-tuned models). How to address these issues could be the critical step for LLMs toward artificial general intelligence.
|
| 16 |
+
|
| 17 |
+

|
| 18 |
+
Figure 1: Language serves as an interface for LLMs (e.g., ChatGPT) to connect numerous AI models (e.g., those in Hugging Face) for solving complicated AI tasks. In this concept, an LLM acts as a controller, managing and organizing the cooperation of expert models. The LLM first plans a list of tasks based on the user request and then assigns expert models to each task. After the experts execute the tasks, the LLM collects the results and responds to the user.
|
| 19 |
+
|
| 20 |
+
In this paper, we point out that in order to handle complicated AI tasks, LLMs should be able to coordinate with external models to harness their powers. Hence, the pivotal question is how to choose suitable middleware to bridge the connections between LLMs and AI models. To tackle this issue, we notice that each AI model can be described in the form of language by summarizing its function. Therefore, we introduce a concept: “Language as a generic interface for LLMs to collaborate with AI models”. In other words, by incorporating these model descriptions into prompts, LLMs can be considered as the brain to manage AI models such as planning, scheduling, and cooperation. As a result, this strategy empowers LLMs to invoke external models for solving AI tasks. However, when it comes to integrating multiple AI models into LLMs, another challenge emerges: solving numerous AI tasks needs collecting a large number of high-quality model descriptions, which in turn requires heavy prompt engineering. Coincidentally, we notice that some public ML communities usually offer a wide range of applicable models with well-defined model descriptions for solving specific AI tasks such as language, vision, and speech. These observations bring us some inspiration: Can we link LLMs (e.g., ChatGPT) with public ML communities (e.g., GitHub, Hugging Face 1, etc) for solving complex AI tasks via a language-based interface?
|
| 21 |
+
|
| 22 |
+
In this paper, we propose an LLM-powered agent named HuggingGPT to autonomously tackle a wide range of complex AI tasks, which connects LLMs (i.e., ChatGPT) and the ML community (i.e., Hugging Face) and can process inputs from different modalities. More specifically, the LLM acts as a brain: on one hand, it disassembles tasks based on user requests, and on the other hand, assigns suitable models to the tasks according to the model description. By executing models and integrating results in the planned tasks, HuggingGPT can autonomously fulfill complex user requests. The whole process of HuggingGPT, illustrated in Figure 1, can be divided into four stages:
|
| 23 |
+
|
| 24 |
+
• Task Planning: Using ChatGPT to analyze the requests of users to understand their intention, and disassemble them into possible solvable tasks.
|
| 25 |
+
|
| 26 |
+
• Model Selection: To solve the planned tasks, ChatGPT selects expert models that are hosted on Hugging Face based on model descriptions.
|
| 27 |
+
|
| 28 |
+
• Task Execution: Invoke and execute each selected model, and return the results to ChatGPT.
|
| 29 |
+
|
| 30 |
+

|
| 31 |
+
Figure 2: Overview of HuggingGPT. With an LLM (e.g., ChatGPT) as the core controller and the expert models as the executors, the workflow of HuggingGPT consists of four stages: 1) Task planning: LLM parses the user request into a task list and determines the execution order and resource dependencies among tasks; 2) Model selection: LLM assigns appropriate models to tasks based on the description of expert models on Hugging Face; 3) Task execution: Expert models on hybrid endpoints execute the assigned tasks; 4) Response generation: LLM integrates the inference results of experts and generates a summary of workflow logs to respond to the user.
|
| 32 |
+
|
| 33 |
+
• Response Generation: Finally, ChatGPT is utilized to integrate the predictions from all models and generate responses for users.
|
| 34 |
+
|
| 35 |
+
Benefiting from such a design, HuggingGPT can automatically generate plans from user requests and use external models, enabling it to integrate multimodal perceptual capabilities and tackle various complex AI tasks. More notably, this pipeline allows HuggingGPT to continually absorb the powers from task-specific experts, facilitating the growth and scalability of AI capabilities.
|
| 36 |
+
|
| 37 |
+
Overall, our contributions can be summarized as follows:
|
| 38 |
+
|
| 39 |
+
1. To complement the advantages of large language models and expert models, we propose HuggingGPT with an inter-model cooperation protocol. HuggingGPT applies LLMs as the brain for planning and decision, and automatically invokes and executes expert models for each specific task, providing a new way for designing general AI solutions.
|
| 40 |
+
|
| 41 |
+
2. By integrating the Hugging Face hub with numerous task-specific models around ChatGPT, HuggingGPT is able to tackle generalized AI tasks covering multiple modalities and domains. Through the open collaboration of models, HuggingGPT can provide users with multimodal and reliable conversation services.
|
| 42 |
+
3. We point out the importance of task planning and model selection in HuggingGPT (and autonomous agents), and formulate some experimental evaluations for measuring the capability of LLMs in planning and model selection.
|
| 43 |
+
4. Extensive experiments on multiple challenging AI tasks across language, vision, speech, and cross-modality demonstrate the capability and huge potential of HuggingGPT in understanding and solving complex tasks from multiple modalities and domains.
|
| 44 |
+
|
| 45 |
+
# 2 Related Works
|
| 46 |
+
|
| 47 |
+
In recent years, the field of natural language processing (NLP) has been revolutionized by the emergence of large language models (LLMs) [1, 2, 3, 4, 5, 19, 6], exemplified by models such as GPT3 [1], GPT-4 [20], PaLM [3], and LLaMa [6]. LLMs have demonstrated impressive capabilities in zero-shot and few-shot tasks, as well as more complex tasks such as mathematical problems and commonsense reasoning, due to their massive corpus and intensive training computation. To extend the scope of large language models (LLMs) beyond text generation, contemporary research can be divided into two branches: 1) Some works have devised unified multimodal language models for solving various AI tasks [21, 22, 23]. For example, Flamingo [21] combines frozen pre-trained vision and language models for perception and reasoning. BLIP-2 [22] utilizes a Q-former to harmonize linguistic and visual semantics, and Kosmos-1 [23] incorporates visual input into text sequences to amalgamate linguistic and visual inputs. 2) Recently, some researchers started to investigate the integration of using tools or models in LLMs [24, 25, 26, 27, 28]. Toolformer [24] is the pioneering work to introduce external API tags within text sequences, facilitating the ability of LLMs to access external tools. Consequently, numerous works have expanded LLMs to encompass the visual modality. Visual ChatGPT [26] fuses visual foundation models, such as BLIP [29] and ControlNet [30], with LLMs. Visual Programming [31] and ViperGPT [25] apply LLMs to visual objects by employing programming languages, parsing visual queries into interpretable steps expressed as Python code. More discussions about related works are included in Appendix B.
|
| 48 |
+
|
| 49 |
+
Distinct from these approaches, HuggingGPT advances towards more general AI capabilities in the following aspects: 1) HuggingGPT uses the LLM as the controller to route user requests to expert models, effectively combining the language comprehension capabilities of the LLM with the expertise of other expert models; 2) The mechanism of HuggingGPT allows it to address tasks in any modality or any domain by organizing cooperation among models through the LLM. Benefiting from the design of task planning in HuggingGPT, our system can automatically and effectively generate task procedures and solve more complex problems; 3) HuggingGPT offers a more flexible approach to model selection, which assigns and orchestrates tasks based on model descriptions. By providing only the model descriptions, HuggingGPT can continuously and conveniently integrate diverse expert models from AI communities, without altering any structure or prompt settings. This open and continuous manner brings us one step closer to realizing artificial general intelligence.
|
| 50 |
+
|
| 51 |
+
# 3 HuggingGPT
|
| 52 |
+
|
| 53 |
+
HuggingGPT is a collaborative system for solving AI tasks, composed of a large language model (LLM) and numerous expert models from ML communities. Its workflow includes four stages: task planning, model selection, task execution, and response generation, as shown in Figure 2. Given a user request, our HuggingGPT, which adopts an LLM as the controller, will automatically deploy the whole workflow, thereby coordinating and executing the expert models to fulfill the target. Table 1 presents the detailed prompt design in our HuggingGPT. In the following subsections, we will introduce the design of each stage.
|
| 54 |
+
|
| 55 |
+
# 3.1 Task Planning
|
| 56 |
+
|
| 57 |
+
Generally, in real-world scenarios, user requests usually encompass some intricate intentions and thus need to orchestrate multiple sub-tasks to fulfill the target. Therefore, we formulate task planning as the first stage of HuggingGPT, which aims to use LLM to analyze the user request and then decompose it into a collection of structured tasks. Moreover, we require the LLM to determine dependencies and execution orders for these decomposed tasks, to build their connections. To enhance the efficacy of task planning in LLMs, HuggingGPT employs a prompt design, which consists of specification-based instruction and demonstration-based parsing. We introduce these details in the following paragraphs.
|
| 58 |
+
|
| 59 |
+
Table 1: The details of the prompt design in HuggingGPT. In the prompts, we set some injectable slots such as {{ Demonstrations }} and {{ Candidate Models }}. These slots are uniformly replaced with the corresponding text before being fed into the LLM.
|
| 60 |
+
|
| 61 |
+
<table><tr><td rowspan=10 colspan=1>T1Trrad re</td><td rowspan=1 colspan=1>Prompt</td></tr><tr><td rowspan=1 colspan=1>#1 Task Planning Stage - The AI assistant performs task parsing on user input, generating a listof tasks with the following format: [{"task": task,"id",task_id, "dep": dependency_task_ids,</td></tr><tr><td rowspan=1 colspan=1>"args": {"text": text, "image": URL, "audio": URL, "video": URL}].The "dep" fielddenotes the id of the previous task which generates a new resource upon which the current taskrelies.The tag "<resource>-task_id" represents the generated text,image,audio,or video fromthe dependency task with the corresponding task_id.The task must be selected from the followingoptions:{{ Available Task List }}.Please note that there exists a logical connections and orderbetween the tasks. In case the user input cannot be parsed,an empty JSON response should beprovided.Here are several cases for your reference:{{ Demonstrations }}.To assist with taskplanning,the chat history is availableas {{ Chat Logs }},where you can trace the user-mentionedresources and incorporate them into the task planning stage.</td></tr><tr><td rowspan=1 colspan=1>Demonstrations</td></tr><tr><td rowspan=6 colspan=1>Can you tell me how many [{"task": "object-detection", "id": 0, "dep": [-1], "args": {"imobjects in e1.jpg? age": "e1.jpg"][{"task": "image-to-text", "id": 0, "dep":[-1], "args": {"image":"e2.jpg"1,{"task":"image-cls","id":1,"dep":1],"args":{"image":"e2.jpg",{"task":"object-detec-In e2.jpg,what's the animaltion”,"id":2,"dep":[-1],"args":{"image":"e2.jpg"and what's it doing?正{"task"::"visual-quesrion-answering", "id": 3, "dep":[-1],"args": {"text": "what's the animal doing?", "image": "e2.jpg"川First generate a HED image[{"task": "pose-detection", "id": O, "dep": [-1], "args": {"imof e3.jpg, then based on theage": "e3.jpg" }},{"task": "pose-text-to-image","id":1,"dep":HED image and a text“a[0],"args": {"text": "a girl reading a book", "image": "<re-girl readinga book",create source>-0" }}]anew image asa response.</td></tr><tr><td rowspan=1 colspan=1>tion”,"id":2,"dep":[-1],"args":{"image":"e2.jpg"</td></tr><tr><td rowspan=1 colspan=1>正{"task"::"visual-quesrion-answering", "id": 3, "dep":[-1],</td></tr><tr><td rowspan=1 colspan=1>"args": {"text": "what's the animal doing?", "image": "e2.jpg"</td></tr><tr><td rowspan=1 colspan=1>age": "e3.jpg" }},{"task": "pose-text-to-image","id":1,"dep":</td></tr><tr><td rowspan=1 colspan=1>[0],"args": {"text": "a girl reading a book", "image": "<re-</td></tr><tr><td rowspan=4 colspan=1>Wonesereren</td><td rowspan=1 colspan=1>Prompt</td></tr><tr><td rowspan=1 colspan=1>#2 Model Selection Stage - Given the user request and the call command, the AI assstant helps theuser to select a suitable model from a list of models to process the user request.The AI assistantmerely outputs the model id of the most appropriate model. The output must be in a strict JSONformat:{"id": "id", "reason": "your detail reason for the choice"}.We have a list of models foryou to choose from{{ Candidate Models }}.Please select one model from the list.</td></tr><tr><td rowspan=1 colspan=1>Candidate Models</td></tr><tr><td rowspan=1 colspan=1>{"model_id": model id #1,"metadata": meta-info #1,"description": description of model #1}{"model_id": model id #2,"metadata":meta-info #2,"description": description of model #2}{"model_id": model id #K,"metadata": meta-info #K,"description": description of model #K}</td></tr><tr><td rowspan=2 colspan=1>rrrrerer eerrer</td><td rowspan=1 colspan=1>Prompt</td></tr><tr><td rowspan=1 colspan=1>#4 Response Generation Stage -With the input and the inference results,the AI assstant needsto describe the process and results. The previous stages can be formed as - User Input: {{ UserInput}},Task Planning:{ Tasks }},Model Selection: { Model Assignment }},Task Execution:{{Predictions }}. You must first answer the user's request in a straightforward manner. Thendescribe the task process and show your analysis and model inference results to the user in the firstperson.If inference results contain a file path,must tell the user the complete fle path.If there isnothing in the results,please tell me you can't make it.</td></tr></table>
|
| 62 |
+
|
| 63 |
+
Specification-based Instruction To better represent the expected tasks of user requests and use them in the subsequent stages, we expect the LLM to parse tasks by adhering to specific specifications (e.g., JSON format). Therefore, we design a standardized template for tasks and instruct the LLM to conduct task parsing through slot filing. As shown in Table 1, the task parsing template comprises four slots ("task", "id", "dep", and "args") to represent the task name, unique identifier, dependencies and arguments. Additional details for each slot can be found in the template description (see the Appendix A.1.1). By adhering to these task specifications, HuggingGPT can automatically employ the LLM to analyze user requests and parse tasks accordingly.
|
| 64 |
+
|
| 65 |
+
Demonstration-based Parsing To better understand the intention and criteria for task planning, HuggingGPT incorporates multiple demonstrations in the prompt. Each demonstration consists of a user request and its corresponding output, which represents the expected sequence of parsed tasks. By incorporating dependencies among tasks, these demonstrations aid HuggingGPT in understanding the logical connections between tasks, facilitating accurate determination of execution order and identification of resource dependencies. The details of our demonstrations is presented in Table 1.
|
| 66 |
+
|
| 67 |
+
Furthermore, to support more complex scenarios (e.g., multi-turn dialogues), we include chat logs in the prompt by appending the following instruction: “To assist with task planning, the chat history is available as {{ Chat Logs }}, where you can trace the user-mentioned resources and incorporate them into the task planning.”. Here {{ Chat Logs }} represents the previous chat logs. This design allows HuggingGPT to better manage context and respond to user requests in multi-turn dialogues.
|
| 68 |
+
|
| 69 |
+
# 3.2 Model Selection
|
| 70 |
+
|
| 71 |
+
Following task planning, HuggingGPT proceeds to the task of matching tasks with models, i.e., selecting the most appropriate model for each task in the parsed task list. To this end, we use model descriptions as the language interface to connect each model. More specifically, we first gather the descriptions of expert models from the ML community (e.g., Hugging Face) and then employ a dynamic in-context task-model assignment mechanism to choose models for the tasks. This strategy enables incremental model access (simply providing the description of the expert models) and can be more open and flexible to use ML communities. More details are introduced in the next paragraph.
|
| 72 |
+
|
| 73 |
+
In-context Task-model Assignment We formulate the task-model assignment as a single-choice problem, where available models are presented as options within a given context. Generally, based on the provided user instruction and task information in the prompt, HuggingGPT is able to select the most appropriate model for each parsed task. However, due to the limits of maximum context length, it is not feasible to encompass the information of all relevant models within one prompt. To mitigate this issue, we first filter out models based on their task type to select the ones that match the current task. Among these selected models, we rank them based on the number of downloads 2 on Hugging Face and then select the top- $K$ models as the candidates. This strategy can substantially reduce the token usage in the prompt and effectively select the appropriate models for each task.
|
| 74 |
+
|
| 75 |
+
# 3.3 Task Execution
|
| 76 |
+
|
| 77 |
+
Once a specific model is assigned to a parsed task, the next step is to execute the task (i.e., perform model inference). In this stage, HuggingGPT will automatically feed these task arguments into the models, execute these models to obtain the inference results, and then send them back to the LLM. It is necessary to emphasize the issue of resource dependencies at this stage. Since the outputs of the prerequisite tasks are dynamically produced, HuggingGPT also needs to dynamically specify the dependent resources for the task before launching it. Therefore, it is challenging to build the connections between tasks with resource dependencies at this stage.
|
| 78 |
+
|
| 79 |
+
Resource Dependency To address this issue, we use a unique symbol, “<resource>”, to maintain resource dependencies. Specifically, HuggingGPT identifies the resources generated by the prerequisite task as <resource>-task_id, where task_id is the id of the prerequisite task. During the task planning stage, if some tasks are dependent on the outputs of previously executed tasks (e.g., task_id), HuggingGPT sets this symbol (i.e., <resource>-task_id) to the corresponding resource subfield in the arguments. Then in the task execution stage, HuggingGPT dynamically replaces this symbol with the resource generated by the prerequisite task. As a result, this strategy empowers HuggingGPT to efficiently handle resource dependencies during task execution.
|
| 80 |
+
|
| 81 |
+

|
| 82 |
+
Table 2: Evaluation for task planning in different task types.
|
| 83 |
+
|
| 84 |
+
Furthermore, for the remaining tasks without any resource dependencies, we will execute these tasks directly in parallel to further improve inference efficiency. This means that multiple tasks can be executed simultaneously if they meet the prerequisite dependencies. Additionally, we offer a hybrid inference endpoint to deploy these models for speedup and computational stability. For more details, please refer to Appendix A.1.3.
|
| 85 |
+
|
| 86 |
+
# 3.4 Response Generation
|
| 87 |
+
|
| 88 |
+
After all task executions are completed, HuggingGPT needs to generate the final responses. As shown in Table 1, HuggingGPT integrates all the information from the previous three stages (task planning, model selection, and task execution) into a concise summary in this stage, including the list of planned tasks, the selected models for the tasks, and the inference results of the models.
|
| 89 |
+
|
| 90 |
+
Most important among them are the inference results, which are the key points for HuggingGPT to make the final decisions. These inference results are presented in a structured format, such as bounding boxes with detection probabilities in the object detection model, answer distributions in the question-answering model, etc. HuggingGPT allows LLM to receive these structured inference results as input and generate responses in the form of friendly human language. Moreover, instead of simply aggregating the results, LLM generates responses that actively respond to user requests, providing a reliable decision with a confidence level.
|
| 91 |
+
|
| 92 |
+
# 4 Experiments
|
| 93 |
+
|
| 94 |
+
# 4.1 Settings
|
| 95 |
+
|
| 96 |
+
In our experiments, we employed the gpt-3.5-turbo, text-davinci-003 and $\mathtt { g p t - 4 }$ variants of the GPT models as the main LLMs, which are publicly accessible through the OpenAI API 3. To enable more stable outputs of LLM, we set the decoding temperature to 0. In addition, to regulate the LLM output to satisfy the expected format (e.g., JSON format), we set the logit_bias to 0.2 on the format constraints (e.g., “{” and “}”). We provide detailed prompts designed for the task planning, model selection, and response generation stages in Table 1, where $\{ \{ { \nu a r i a b l e } \} \}$ indicates the slot which needs to be populated with the corresponding text before being fed into the LLM.
|
| 97 |
+
|
| 98 |
+
# 4.2 Qualitative Results
|
| 99 |
+
|
| 100 |
+
Figure 1 and Figure 2 have shown two demonstrations of HuggingGPT. In Figure 1, the user request consists of two sub-tasks: describing the image and object counting. In response to the request, HuggingGPT planned three tasks: image classification, image captioning, and object detection, and launched the google/vit [32], nlpconnet/vit-gpt2-image-captioning [33], and facebook/detr-resnet-101 [34] models, respectively. Finally, HuggingGPT integrated the results of the model inference and generated responses (describing the image and providing the count of contained objects) to the user.
|
| 101 |
+
|
| 102 |
+
A more detailed example is shown in Figure 2. In this case, the user’s request included three tasks: detecting the pose of a person in an example image, generating a new image based on that pose and specified text, and creating a speech describing the image. HuggingGPT parsed these into six tasks, including pose detection, text-to-image conditional on pose, object detection, image classification, image captioning, and text-to-speech. We observed that HuggingGPT can correctly orchestrate the execution order and resource dependencies among tasks. For instance, the pose conditional text-toimage task had to follow pose detection and use its output as input. After this, HuggingGPT selected the appropriate model for each task and synthesized the results of the model execution into a final response. For more demonstrations, please refer to the Appendix A.3.
|
| 103 |
+
|
| 104 |
+
# 4.3 Quantitative Evaluation
|
| 105 |
+
|
| 106 |
+
In HuggingGPT, task planning plays a pivotal role in the whole workflow, since it determines which tasks will be executed in the subsequent pipeline. Therefore, we deem that the quality of task planning can be utilized to measure the capability of LLMs as a controller in HuggingGPT. For this purpose, we conduct quantitative evaluations to measure the capability of LLMs. Here we simplified the evaluation by only considering the task
|
| 107 |
+
|
| 108 |
+
<table><tr><td>LLM</td><td>Acc ↑</td><td>Pre ↑</td><td>Recall 个</td><td>F1↑</td></tr><tr><td>Alpaca-7b</td><td>6.48</td><td>35.60</td><td>6.64</td><td>4.88</td></tr><tr><td>Vicuna-7b</td><td>23.86</td><td>45.51</td><td>26.51</td><td>29.44</td></tr><tr><td>GPT-3.5</td><td>52.62</td><td>62.12</td><td>52.62</td><td>54.45</td></tr></table>
|
| 109 |
+
|
| 110 |
+
Table 3: Evaluation for the single task. “Acc” and “Pre” represents Accuracy and Precision.
|
| 111 |
+
|
| 112 |
+
type, without its associated arguments. To better conduct evaluations on task planning, we group tasks into three distinct categories (see Table 2) and formulate different metrics for them:
|
| 113 |
+
|
| 114 |
+
• Single Task refers to a request that involves only one task. We consider the planning to be correct if and only if the task name (i.e., "task") and the predicted label are identically equal. In this context, we utilize F1 and accuracy as the evaluation metrics.
|
| 115 |
+
• Sequential Task indicates that the user’s request can be decomposed into a sequence of multiple sub-tasks. In this case, we employ F1 and normalized Edit Distance [35] as the evaluation metrics.
|
| 116 |
+
• Graph Task indicates that user requests can be decomposed into directed acyclic graphs. Considering the possibility of multiple planning topologies within graph tasks, relying solely on the F1-score is not enough to reflect the LLM capability in planning. To address this, following Vicuna [36], we employed GPT-4 as a critic to evaluate the correctness of the planning. The accuracy is obtained by evaluating the judgment of GPT-4, referred to as the GPT-4 Score. Detailed information about the GPT-4 Score can be found in Appendix A.1.5.
|
| 117 |
+
|
| 118 |
+
Dataset To conduct our evaluation, we invite some annotators to submit some requests. We collect these data as the evaluation dataset. We use GPT-4 to generate task planning as the pseudo labels, which cover single, sequential, and graph tasks. Furthermore, we invite some expert annotators to label task planning for some complex requests (46 examples) as a high-quality humanannotated dataset. We also plan to improve the
|
| 119 |
+
|
| 120 |
+
<table><tr><td>LLM</td><td>ED↓</td><td>Pre个</td><td>Recall 个</td><td>F1↑</td></tr><tr><td>Alpaca-7b</td><td>0.83</td><td>22.27</td><td>23.35</td><td>22.80</td></tr><tr><td>Vicuna-7b</td><td>0.80</td><td>19.15</td><td>28.45</td><td>22.89</td></tr><tr><td>GPT-3.5</td><td>0.54</td><td>61.09</td><td>45.15</td><td>51.92</td></tr></table>
|
| 121 |
+
|
| 122 |
+
Table 4: Evaluation for the sequential task. “ED” means Edit Distance.
|
| 123 |
+
|
| 124 |
+
quality and quantity of this dataset to further assist in evaluating the LLM’s planning capabilities, which remains a future work. More details about this dataset are in Appendix A.2. Using this dataset, we conduct experimental evaluations on various LLMs, including Alpaca-7b [37], Vicuna-7b [36], and GPT models, for task planning.
|
| 125 |
+
|
| 126 |
+
<table><tr><td>LLM</td><td>GPT-4 Score ↑</td><td>Pre个</td><td>Recall 个</td><td>F1个</td></tr><tr><td>Alpaca-7b</td><td>13.14</td><td>16.18</td><td>28.33</td><td>20.59</td></tr><tr><td>Vicuna-7b</td><td>19.17</td><td>13.97</td><td>28.08</td><td>18.66</td></tr><tr><td>GPT-3.5</td><td>50.48</td><td>54.90</td><td>49.23</td><td>51.91</td></tr></table>
|
| 127 |
+
|
| 128 |
+
Table 5: Evaluation for the graph task.
|
| 129 |
+
|
| 130 |
+
Performance Tables 3, 4 and 5 show the planning capabilities of HuggingGPT on the three categories of GPT4 annotated datasets, respectively. We observed that GPT-3.5 exhibits more prominent planning capabilities, outperforming the open-source LLMs Alpaca7b and Vicuna-7b in terms of all types
|
| 131 |
+
|
| 132 |
+
of user requests. Specifically, in more complex tasks (e.g., sequential and graph tasks), GPT-3.5 has shown absolute predominance over other LLMs. These results also demonstrate the evaluation of task planning can reflect the capability of LLMs as a controller. Therefore, we believe that developing technologies to improve the ability of LLMs in task planning is very important, and we leave it as a future research direction.
|
| 133 |
+
|
| 134 |
+
<table><tr><td rowspan="2">LLM</td><td colspan="2">Sequential Task</td><td colspan="2">Graph Task</td></tr><tr><td>Acc 个</td><td>ED↓</td><td>Acc ↑</td><td>F1↑</td></tr><tr><td>Alpaca-7b</td><td>0</td><td>0.96</td><td>4.17</td><td>4.17</td></tr><tr><td>Vicuna-7b</td><td>7.45</td><td>0.89</td><td>10.12</td><td>7.84</td></tr><tr><td>GPT-3.5</td><td>18.18</td><td>0.76</td><td>20.83</td><td>16.45</td></tr><tr><td>GPT-4</td><td>41.36</td><td>0.61</td><td>58.33</td><td>49.28</td></tr></table>
|
| 135 |
+
|
| 136 |
+
Table 6: Evaluation on the human-annotated dataset.
|
| 137 |
+
|
| 138 |
+
Furthermore, we conduct experiments on the high-quality human-annotated dataset to obtain a more precise evaluation. Table 6 reports the comparisons on the humanannotated dataset. These results align with the aforementioned conclusion, highlighting that more powerful LLMs demonstrate better performance in task planning. Moreover, we compare the results between human annotations and GPT-4 annotations. We find that even though GPT-4 outperforms other LLMs,
|
| 139 |
+
|
| 140 |
+
there still remains a substantial gap when compared with human annotations. These observations further underscore the importance of enhancing the planning capabilities of LLMs.
|
| 141 |
+
|
| 142 |
+
# 4.4 Ablation Study
|
| 143 |
+
|
| 144 |
+
<table><tr><td rowspan="2">Demo Variety (# task types)</td><td rowspan="2">LLM</td><td colspan="2">Single Task</td><td colspan="2">Sequencial Task</td><td rowspan="2">Graph Task</td></tr><tr><td>Acc 个</td><td>F1个</td><td>ED(%)↓</td><td>F1个</td></tr><tr><td rowspan="2">2</td><td>GPT-3.5</td><td>43.31</td><td>48.29</td><td>71.27</td><td>32.15</td><td>F1↑ 43.42</td></tr><tr><td>GPT-4</td><td>65.59</td><td>67.08</td><td>47.17</td><td>55.13</td><td>53.96</td></tr><tr><td rowspan="2">6</td><td>GPT-3.5</td><td>51.31</td><td>51.81</td><td>60.81</td><td>43.19</td><td>58.51</td></tr><tr><td>GPT-4</td><td>66.83</td><td>68.14</td><td>42.20</td><td>58.18</td><td>64.34</td></tr><tr><td rowspan="2">10</td><td>GPT-3.5</td><td>52.83</td><td>53.70</td><td>56.52</td><td>47.03</td><td>64.24</td></tr><tr><td>GPT-4</td><td>67.52</td><td>71.05</td><td>39.32</td><td>60.80</td><td>66.90</td></tr></table>
|
| 145 |
+
|
| 146 |
+
Table 7: Evaluation of task planning in terms of the variety of demonstrations. We refer to the variety of demonstrations as the number of different task types involved in the demonstrations.
|
| 147 |
+
|
| 148 |
+

|
| 149 |
+
Figure 3: Evaluation of task planning with different numbers of demonstrations.
|
| 150 |
+
|
| 151 |
+
As previously mentioned in our default setting, we apply few-shot demonstrations to enhance the capability of LLMs in understanding user intent and parsing task sequences. To better investigate the effect of demonstrations on our framework, we conducted a series of ablation studies from two perspectives: the number of demonstrations and the variety of demonstrations. Table 7 reports the planning results under the different variety of demonstrations. We observe that increasing the variety among demonstrations can moderately improve the performance of LLMs in conduct planning. Moreover, Figure 3 illustrates the results of task planning with different number of demonstrations. We can find that adding some demonstrations can slightly improve model performance but this improvement will be limited when the number is over 4 demonstrations. In the future, we will continue to explore more elements that can improve the capability of LLMs at different stages.
|
| 152 |
+
|
| 153 |
+
<table><tr><td rowspan="2">LLM</td><td colspan="2">Task Planning</td><td colspan="2">Model Selection</td><td>Response</td></tr><tr><td>Passing Rate 个</td><td>Rationality 个</td><td>Passing Rate ↑</td><td>Rationality 个</td><td>Success Rate↑</td></tr><tr><td>Alpaca-13b</td><td>51.04</td><td>32.17</td><td>1</td><td>-</td><td>6.92</td></tr><tr><td>Vicuna-13b</td><td>79.41</td><td>58.41</td><td>-</td><td>-</td><td>15.64</td></tr><tr><td>GPT-3.5</td><td>91.22</td><td>78.47</td><td>93.89</td><td>84.29</td><td>63.08</td></tr></table>
|
| 154 |
+
|
| 155 |
+
Table 8: Human Evaluation on different LLMs. We report two metrics, passing rate $( \% )$ and rationality $( \% )$ , in the task planning and model selection stages and report a straightforward success rate $( \% )$ to evaluate whether the request raised by the user is finally resolved.
|
| 156 |
+
|
| 157 |
+
# 4.5 Human Evaluation
|
| 158 |
+
|
| 159 |
+
In addition to objective evaluations, we also invite human experts to conduct a subjective evaluation in our experiments. We collected 130 diverse requests to evaluate the performance of HuggingGPT at various stages, including task planning, model selection, and final response generation. We designed three evaluation metrics, namely passing rate, rationality, and success rate. The definitions of each metric can be found in Appendix A.1.6. The results are reported in Table 8. From Table 8, we can observe similar conclusions that GPT-3.5 can significantly outperform open-source LLMs like Alpaca-13b and Vicuna-13b by a large margin across different stages, from task planning to response generation stages. These results indicate that our objective evaluations are aligned with human evaluation and further demonstrate the necessity of a powerful LLM as a controller in the framework of autonomous agents.
|
| 160 |
+
|
| 161 |
+
# 5 Limitations
|
| 162 |
+
|
| 163 |
+
HuggingGPT has presented a new paradigm for designing AI solutions, but we want to highlight that there still remain some limitations or improvement spaces: 1) Planning in HuggingGPT heavily relies on the capability of LLM. Consequently, we cannot ensure that the generated plan will always be feasible and optimal. Therefore, it is crucial to explore ways to optimize the LLM in order to enhance its planning abilities; 2) Efficiency poses a common challenge in our framework. To build such a collaborative system (i.e., HuggingGPT) with task automation, it heavily relies on a powerful controller (e.g., ChatGPT). However, HuggingGPT requires multiple interactions with LLMs throughout the whole workflow and thus brings increasing time costs for generating the response; 3) Token Lengths is another common problem when using LLM, since the maximum token length is always limited. Although some works have extended the maximum length to 32K, it is still insatiable for us if we want to connect numerous models. Therefore, how to briefly and effectively summarize model descriptions is also worthy of exploration; 4) Instability is mainly caused because LLMs are usually uncontrollable. Although LLM is skilled in generation, it still possibly fails to conform to instructions or give incorrect answers during the prediction, leading to exceptions in the program workflow. How to reduce these uncertainties during inference should be considered in designing systems.
|
| 164 |
+
|
| 165 |
+
# 6 Conclusion
|
| 166 |
+
|
| 167 |
+
In this paper, we propose a system named HuggingGPT to solve AI tasks, with language as the interface to connect LLMs with AI models. The principle of our system is that an LLM can be viewed as a controller to manage AI models, and can utilize models from ML communities like Hugging Face to automatically solve different requests of users. By exploiting the advantages of LLMs in understanding and reasoning, HuggingGPT can dissect the intent of users and decompose it into multiple sub-tasks. And then, based on expert model descriptions, HuggingGPT is able to assign the most suitable models for each task and integrate results from different models to generate the final response. By utilizing the ability of numerous AI models from machine learning communities, HuggingGPT demonstrates immense potential in solving challenging AI tasks, thereby paving a new pathway towards achieving artificial general intelligence.
|
| 168 |
+
|
| 169 |
+
# Acknowledgement
|
| 170 |
+
|
| 171 |
+
We appreciate the support of the Hugging Face team to help us in improving our GitHub project and web demo. Besides, we also appreciate the contributions of Bei Li, Kai Shen, Meiqi Chen, Qingyao Guo, Yichong Leng, Yuancheng Wang, Dingyao Yu for the data labeling and Wenqi Zhang, Wen Wang, Zeqi Tan for paper revision.
|
| 172 |
+
|
| 173 |
+
This work is partly supported by the Fundamental Research Funds for the Central Universities (No. 226-2023-00060), Key Research and Development Program of Zhejiang Province (No. 2023C01152), National Key Research and Development Project of China (No. 2018AAA0101900), and MOE Engineering Research Center of Digital Library.
|
| 174 |
+
|
| 175 |
+
# References
|
| 176 |
+
|
| 177 |
+
[1] Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. Language Models are Few-Shot Learners. In NeurIPS, 2020.
|
| 178 |
+
[2] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul F. Christiano, Jan Leike, and Ryan Lowe. Training language models to follow instructions with human feedback. CoRR, abs/2203.02155, 2022.
|
| 179 |
+
[3] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, and others. Palm: Scaling language modeling with pathways. ArXiv, abs/2204.02311, 2022.
|
| 180 |
+
[4] Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, and Luke Zettlemoyer. Opt: Open Pre-trained Transformer Language Models. ArXiv, abs/2205.01068, 2022.
|
| 181 |
+
[5] Aohan Zeng, Xiao Liu, Zhengxiao Du, Zihan Wang, Hanyu Lai, Ming Ding, Zhuoyi Yang, Yifan Xu, Wendi Zheng, Xiao Xia, Weng Lam Tam, Zixuan Ma, Yufei Xue, Jidong Zhai, Wenguang Chen, Zhiyuan Liu, Peng Zhang, Yuxiao Dong, and Jie Tang. Glm-130b: An Open Bilingual Pre-trained Model. ICLR 2023 poster, 2023.
|
| 182 |
+
[6] Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aur’elien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. Llama: Open and Efficient Foundation Language Models. ArXiv, abs/2302.13971, 2023.
|
| 183 |
+
[7] Sang Michael Xie, Aditi Raghunathan, Percy Liang, and Tengyu Ma. An Explanation of Incontext Learning as Implicit Bayesian Inference. ICLR 2022 Poster, 2022.
|
| 184 |
+
[8] Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. Rethinking the Role of Demonstrations: What Makes In-Context Learning Work? In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing (EMNLP). Association for Computational Linguistics, 2022.
|
| 185 |
+
[9] Jason Wei, Maarten Bosma, Vincent Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, and Quoc V Le. Finetuned language models are zero-shot learners. In International Conference on Learning Representations, 2022.
|
| 186 |
+
[10] Yizhong Wang, Swaroop Mishra, Pegah Alipoormolabashi, Yeganeh Kordi, Amirreza Mirzaei, Atharva Naik, Arjun Ashok, Arut Selvan Dhanasekaran, Anjana Arunkumar, David Stap,
|
| 187 |
+
|
| 188 |
+
Eshaan Pathak, Giannis Karamanolakis, Haizhi Gary Lai, Ishan Virendrabhai Purohit, Ishani Mondal, Jacob William Anderson, Kirby C. Kuznia, Krima Doshi, Kuntal Kumar Pal, Maitreya Patel, Mehrad Moradshahi, Mihir Parmar, Mirali Purohit, Neeraj Varshney, Phani Rohitha Kaza, Pulkit Verma, Ravsehaj Singh Puri, rushang karia, Savan Doshi, Shailaja Keyur Sampat, Siddhartha Mishra, Sujan Reddy A, Sumanta Patro, Tanay Dixit, Xudong Shen, Chitta Baral, Yejin Choi, Noah A. Smith, Hannaneh Hajishirzi, and Daniel Khashabi. SuperNaturalInstructions: Generalization via Declarative Instructions on $1 6 0 0 +$ NLP Tasks. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing (EMNLP). Association for Computational Linguistics, 2022.
|
| 189 |
+
|
| 190 |
+
[11] S. Iyer, Xiaojuan Lin, Ramakanth Pasunuru, Todor Mihaylov, Daniel Simig, Ping Yu, Kurt Shuster, Tianlu Wang, Qing Liu, Punit Singh Koura, Xian Li, Brian O’Horo, Gabriel Pereyra, Jeff Wang, Christopher Dewan, Asli Celikyilmaz, Luke Zettlemoyer, and Veselin Stoyanov. Opt-IML: Scaling Language Model Instruction Meta Learning through the Lens of Generalization. ArXiv, abs/2212.12017, 2022.
|
| 191 |
+
|
| 192 |
+
[12] Hyung Won Chung, Le Hou, Shayne Longpre, Barret Zoph, Yi Tay, William Fedus, Eric Li, Xuezhi Wang, Mostafa Dehghani, Siddhartha Brahma, Albert Webson, Shixiang Shane Gu, Zhuyun Dai, Mirac Suzgun, Xinyun Chen, Aakanksha Chowdhery, Sharan Narang, Gaurav Mishra, Adams Yu, Vincent Y. Zhao, Yanping Huang, Andrew M. Dai, Hongkun Yu, Slav Petrov, Ed H. Chi, Jeff Dean, Jacob Devlin, Adam Roberts, Denny Zhou, Quoc V. Le, and Jason Wei. Scaling instruction-finetuned language models. CoRR, abs/2210.11416, 2022.
|
| 193 |
+
|
| 194 |
+
[13] Yizhong Wang, Yeganeh Kordi, Swaroop Mishra, Alisa Liu, Noah A. Smith, Daniel Khashabi, and Hannaneh Hajishirzi. Self-instruct: Aligning language model with self generated instructions, 2022.
|
| 195 |
+
|
| 196 |
+
[14] Shayne Longpre, Le Hou, Tu Vu, Albert Webson, Hyung Won Chung, Yi Tay, Denny Zhou, Quoc V. Le, Barret Zoph, Jason Wei, and Adam Roberts. The flan collection: Designing data and methods for effective instruction tuning. CoRR, abs/2301.13688, 2023.
|
| 197 |
+
|
| 198 |
+
[15] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, brian ichter, Fei Xia, Ed Chi, Quoc V Le, and Denny Zhou. Chain of Thought Prompting Elicits Reasoning in Large Language Models. In Conference on Neural Information Processing Systems (NeurIPS), 2022.
|
| 199 |
+
|
| 200 |
+
[16] Takeshi Kojima, Shixiang (Shane) Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large Language Models are Zero-Shot Reasoners. In Conference on Neural Information Processing Systems (NeurIPS), 2022.
|
| 201 |
+
|
| 202 |
+
[17] Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. Pal: Program-aided Language Models. ArXiv, abs/2211.10435, 2022.
|
| 203 |
+
|
| 204 |
+
[18] Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc V Le, Ed H. Chi, Sharan Narang, Aakanksha Chowdhery, and Denny Zhou. Self-Consistency Improves Chain of Thought Reasoning in Language Models. ICLR 2023 poster, abs/2203.11171, 2023.
|
| 205 |
+
|
| 206 |
+
[19] Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, Ed H. Chi, Tatsunori Hashimoto, Oriol Vinyals, Percy Liang, Jeff Dean, and William Fedus. Emergent abilities of large language models. CoRR, abs/2206.07682, 2022.
|
| 207 |
+
|
| 208 |
+
[20] OpenAI. Gpt-4 technical report, 2023.
|
| 209 |
+
|
| 210 |
+
[21] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob Menick, Sebastian Borgeaud, Andrew Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, and Karen Simonyan. Flamingo: a visual language model for few-shot learning, 2022.
|
| 211 |
+
|
| 212 |
+
[22] Junnan Li, Dongxu Li, S. Savarese, and Steven Hoi. Blip-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models. ArXiv, abs/2301.12597, 2023.
|
| 213 |
+
|
| 214 |
+
[23] Shaohan Huang, Li Dong, Wenhui Wang, Y. Hao, Saksham Singhal, Shuming Ma, Tengchao Lv, Lei Cui, O. Mohammed, Qiang Liu, Kriti Aggarwal, Zewen Chi, Johan Bjorck, Vishrav Chaudhary, Subhojit Som, Xia Song, and Furu Wei. Language Is Not All You Need: Aligning Perception with Language Models. ArXiv, abs/2302.14045, 2023.
|
| 215 |
+
|
| 216 |
+
[24] Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, M. Lomeli, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language Models Can Teach Themselves to Use Tools. ArXiv, abs/2302.04761, 2023.
|
| 217 |
+
|
| 218 |
+
[25] Dídac Surís, Sachit Menon, and Carl Vondrick. Vipergpt: Visual inference via python execution for reasoning, 2023.
|
| 219 |
+
|
| 220 |
+
[26] Chenfei Wu, Sheng-Kai Yin, Weizhen Qi, Xiaodong Wang, Zecheng Tang, and Nan Duan. Visual ChatGPT: Talking, Drawing and Editing with Visual Foundation Models. arXiv, 2023.
|
| 221 |
+
|
| 222 |
+
[27] Yaobo Liang, Chenfei Wu, Ting Song, Wenshan Wu, Yan Xia, Yu Liu, Yang Ou, Shuai Lu, Lei Ji, Shaoguang Mao, Yun Wang, Linjun Shou, Ming Gong, and Nan Duan. Taskmatrix.ai: Completing tasks by connecting foundation models with millions of apis, 2023.
|
| 223 |
+
|
| 224 |
+
[28] Yujia Qin, Shengding Hu, Yankai Lin, Weize Chen, Ning Ding, Ganqu Cui, Zheni Zeng, Yufei Huang, Chaojun Xiao, Chi Han, Yi Ren Fung, Yusheng Su, Huadong Wang, Cheng Qian, Runchu Tian, Kunlun Zhu, Shihao Liang, Xingyu Shen, Bokai Xu, Zhen Zhang, Yining Ye, Bowen Li, Ziwei Tang, Jing Yi, Yuzhang Zhu, Zhenning Dai, Lan Yan, Xin Cong, Yaxi Lu, Weilin Zhao, Yuxiang Huang, Junxi Yan, Xu Han, Xian Sun, Dahai Li, Jason Phang, Cheng Yang, Tongshuang Wu, Heng Ji, Zhiyuan Liu, and Maosong Sun. Tool learning with foundation models, 2023.
|
| 225 |
+
|
| 226 |
+
[29] Junnan Li, Dongxu Li, Caiming Xiong, and Steven C. H. Hoi. Blip: Bootstrapping LanguageImage Pre-training for Unified Vision-Language Understanding and Generation. In International Conference on Machine Learning (ICML), pages 12888–12900, 2022.
|
| 227 |
+
|
| 228 |
+
[30] Lvmin Zhang and Maneesh Agrawala. Adding Conditional Control to Text-to-Image Diffusion Models. ArXiv, abs/2302.05543, 2023.
|
| 229 |
+
|
| 230 |
+
[31] Tanmay Gupta and Aniruddha Kembhavi. Visual Programming: Compositional visual reasoning without training. arXiv, abs/2211.11559, 2022.
|
| 231 |
+
|
| 232 |
+
[32] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale, 2021.
|
| 233 |
+
|
| 234 |
+
[33] Ankur Kumar. The illustrated image captioning using transformers. ankur3107.github.io, 2022.
|
| 235 |
+
|
| 236 |
+
[34] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers, 2020.
|
| 237 |
+
|
| 238 |
+
[35] A. Marzal and E. Vidal. Computation of normalized edit distance and applications. IEEE Transactions on Pattern Analysis and Machine Intelligence, 15(9):926–932, 1993.
|
| 239 |
+
|
| 240 |
+
[36] Wei-Lin Chiang, Zhuohan Li, Zi Lin, Ying Sheng, Zhanghao Wu, Hao Zhang, Lianmin Zheng, Siyuan Zhuang, Yonghao Zhuang, Joseph E. Gonzalez, Ion Stoica, and Eric P. Xing. Vicuna: An open-source chatbot impressing gpt-4 with $9 0 \% *$ chatgpt quality, March 2023.
|
| 241 |
+
|
| 242 |
+
[37] Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. Stanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/stanford_alpaca, 2023.
|
| 243 |
+
|
| 244 |
+
# A Appendix
|
| 245 |
+
|
| 246 |
+
# A.1 More details
|
| 247 |
+
|
| 248 |
+
In this section, we will present more details about some designs of each stage in HuggingGPT.
|
| 249 |
+
|
| 250 |
+
# A.1.1 Template for Task Planning
|
| 251 |
+
|
| 252 |
+
To format the parsed task, we define the template [{"task": task, "id", task_id, "dep": dependency_task_ids, "args": {"text": text, "image": URL, "audio": URL, "video": URL}}] with four slots: "task", "id", "dep", and "args". Table 9 presents the definitions of each slot.
|
| 253 |
+
|
| 254 |
+
<table><tr><td>Name</td><td>Definitions</td></tr><tr><td>"task"</td><td>It represents the type of the parsed task. It covers different tasks in language,visual, video, audio,etc. The currently supported task list of HuggingGPT is shown in Table 13.</td></tr><tr><td>"id"</td><td>The unique identifier for task planning,which is used for references to dependent tasks and their generated resources.</td></tr><tr><td>"dep"</td><td>It defines the pre-requisite tasks required for execution.The task will be launched only when all the pre-requisite dependent tasks are finished.</td></tr><tr><td>"args"</td><td>It contains the list of required arguments for task execution. It contains three subfields popu- lated with text,image,and audio resources according to the task type.They are resolved from either the user's request or the generated resources of the dependent tasks.The corresponding argument types for different task types are shown in Table 13.</td></tr></table>
|
| 255 |
+
|
| 256 |
+
Table 9: Definitions for each slot for parsed tasks in the task planning.
|
| 257 |
+
|
| 258 |
+
# A.1.2 Model Descriptions
|
| 259 |
+
|
| 260 |
+
In general, the Hugging Face Hub hosts expert models that come with detailed model descriptions, typically provided by the developers. These descriptions encompass various aspects of the model, such as its function, architecture, supported languages and domains, licensing, and other relevant details. These comprehensive model descriptions play a crucial role in aiding the decision of HuggingGPT. By assessing the user’s requests and comparing them with the model descriptions, HuggingGPT can effectively determine the most suitable model for the given task.
|
| 261 |
+
|
| 262 |
+
# A.1.3 Hybrid Endpoint in System Deployment
|
| 263 |
+
|
| 264 |
+
An ideal scenario is that we only use inference endpoints on cloud service (e.g., Hugging Face). However, in some cases, we have to deploy local inference endpoints, such as when inference endpoints for certain models do not exist, the inference is time-consuming, or network access is limited. To keep the stability and efficiency of the system, HuggingGPT allows us to pull and run some common or time-consuming models locally. The local inference endpoints are fast but cover fewer models, while the inference endpoints in the cloud service (e.g., Hugging Face) are the opposite. Therefore, local endpoints have higher priority than cloud inference endpoints. Only if the matched model is not deployed locally, HuggingGPT will run the model on the cloud endpoint like Hugging Face. Overall, we think that how to design and deploy systems with better stability for HuggingGPT or other autonomous agents will be very important in the future.
|
| 265 |
+
|
| 266 |
+
# A.1.4 Task List
|
| 267 |
+
|
| 268 |
+
Up to now, HuggingGPT has supported 24 AI tasks, which cover language, vision, speech and etc.
|
| 269 |
+
Table 13 presents the detailed information of the supported task list in HuggingGPT.
|
| 270 |
+
|
| 271 |
+
# A.1.5 GPT-4 Score
|
| 272 |
+
|
| 273 |
+
Following the evaluation method used by Vicuna [36], we employed GPT-4 as an evaluator to assess the planning capabilities of LLMs. In more detail, we include the user request and the task list planned by LLM in the prompt, and then let GPT-4 judge whether the list of tasks is accurate and also provide a rationale. To guide GPT-4 to make the correct judgments, we designed some task guidelines: 1) the tasks are in the supported task list (see Table 13); 2) the planned task list can reach the solution to the user request; 3) the logical relationship and order among the tasks are reasonable. In the prompt, we also supplement several positive and negative demonstrations of task planning to provide reference for GPT-4. The prompt for GPT-4 score is shown in Table 10. We further want to emphasize that GPT-4 score is not always correct although it has shown a high correlation. Therefore, we also expect to explore more confident metrics to evaluate the ability of LLMs in planning.
|
| 274 |
+
|
| 275 |
+
As a critic, your task is to assess whether the AI assistant has properly planned the task based on the user’s request. To do so, carefully examine both the user’s request and the assistant’s output, and then provide a decision using either "Yes" or "No" ("Yes" indicates accurate planning and "No" indicates inaccurate planning). Additionally, provide a rationale for your choice using the following structure: {"choice": "yes"/"no", "reason": "Your reason for your choice"}. Please adhere to the following guidelines: 1. The task must be selected from the following options: {{ Available Task List }}. 2. Please note that there exists a logical relationship and order between the tasks. 3. Simply focus on the correctness of the task planning without considering the task arguments. Positive examples: $\{ \{ P o s i t i \nu e \ D e m o s \} \}$ Negative examples: {{Negative Demos}} Current user request: $\{ \{ I n p u t \} \}$ AI assistant’s output: $\{ \{ O u t p u t \} \}$ Your judgement:
|
| 276 |
+
|
| 277 |
+
# A.1.6 Human Evaluation
|
| 278 |
+
|
| 279 |
+
To better align human preferences, we invited three human experts to evaluate the different stages of HuggingGPT. First, we selected 3-5 tasks from the task list of Hugging Face and then manually created user requests based on the selected tasks. We will discard samples that cannot generate new requests from the selected tasks. Totally, we conduct random sampling by using different seeds, resulting in a collection of 130 diverse user requests. Based on the produced samples, we evaluate the performance of LLMs at different stages (e.g., task planning, model selection, and response generation). Here, we designed three evaluation metrics:
|
| 280 |
+
|
| 281 |
+
• Passing Rate: to determine whether the planned task graph or selected model can be successfully executed;
|
| 282 |
+
• Rationality: to assess whether the generated task sequence or selected tools align with user requests in a rational manner;
|
| 283 |
+
• Success Rate: to verify if the final results satisfy the user’s request.
|
| 284 |
+
|
| 285 |
+
Three human experts were asked to annotate the provided data according to our well-designed metrics and then calculated the average values to obtain the final scores.
|
| 286 |
+
|
| 287 |
+
# A.2 Datasets for Task Planning Evaluation
|
| 288 |
+
|
| 289 |
+
As aforementioned, we create two datasets for evaluating task planning. Here we provide more details about these datasets. In total, we gathered a diverse set of 3,497 user requests. Since labeling this dataset to obtain the task planning for each request is heavy, we employed the capabilities of GPT-4 to annotate them. Finally, these auto-labeled requests can be categorized into three types: single task (1,450 requests), sequence task (1,917 requests), and graph task (130 requests). For a more reliable evaluation, we also construct a human-annotated dataset. We invite some expert annotators to label some complex requests, which include 46 examples. Currently, the human-annotated dataset includes 24 sequential tasks and 22 graph tasks. Detailed statistics about the GPT-4-annotated and human-annotated datasets are shown in Table 11.
|
| 290 |
+
|
| 291 |
+
# A.3 Case Study
|
| 292 |
+
|
| 293 |
+
# A.3.1 Case Study on Various Tasks
|
| 294 |
+
|
| 295 |
+
Through task planning and model selection, HuggingGPT, a multi-model collaborative system, empowers LLMs with an extended range of capabilities. Here, we extensively evaluate HuggingGPT across diverse multimodal tasks, and some selected cases are shown in Figures 4 and 5. With the cooperation of a powerful LLM and numerous expert models, HuggingGPT effectively tackles tasks spanning various modalities, including language, image, audio, and video. Its proficiency encompasses diverse task forms, such as detection, generation, classification, and question answering.
|
| 296 |
+
|
| 297 |
+
<table><tr><td rowspan="2">Datasets</td><td colspan="3">Number of Requests by Type</td><td colspan="2">Request Length</td><td colspan="2">Number of Tasks</td></tr><tr><td>Single</td><td>Sequential</td><td>Graph</td><td>Max</td><td>Average</td><td>Max</td><td>Average</td></tr><tr><td>GPT-4-annotated</td><td>1,450</td><td>1,917</td><td>130</td><td>52</td><td>13.26</td><td>13</td><td>1.82</td></tr><tr><td>Human-annotated</td><td>1</td><td>24</td><td>22</td><td>95</td><td>10.20</td><td>12</td><td>2.00</td></tr></table>
|
| 298 |
+
|
| 299 |
+
Table 11: Statistics on datasets for task planning evaluation.
|
| 300 |
+
|
| 301 |
+
# A.3.2 Case Study on Complex Tasks
|
| 302 |
+
|
| 303 |
+
Sometimes, user requests may contain multiple implicit tasks or require multi-faceted information, in which case we cannot rely on a single expert model to solve them. To overcome this challenge, HuggingGPT organizes the collaboration of multiple models through task planning. As shown in Figures 6, 7 and 8, we conducted experiments to evaluate the effectiveness of HuggingGPT in the case of complex tasks:
|
| 304 |
+
|
| 305 |
+
• Figure 6 demonstrates the ability of HuggingGPT to cope with complex tasks in a multi-round conversation scenario. The user splits a complex request into several steps and reaches the final goal through multiple rounds of interaction. We find that HuggingGPT can track the contextual state of user requests through the dialogue context management in the task planning stage. Moreover, HuggingGPT demonstrates the ability to access user-referenced resources and proficiently resolve dependencies between tasks in the dialogue scenario.
|
| 306 |
+
• Figure 7 shows that for a simple request like "describe the image in as much detail as possible", HuggingGPT can decompose it into five related tasks, namely image captioning, image classification, object detection, segmentation, and visual question answering tasks. HuggingGPT assigns expert models to handle each task to gather information about the image from various perspectives. Finally, the LLM integrates this diverse information to deliver a comprehensive and detailed description to the user.
|
| 307 |
+
• Figure 8 shows two cases where a user request can contain several tasks. In these cases, HuggingGPT first performs all the tasks requested by the user by orchestrating the work of multiple expert models, and then let the LLM aggregate the model inference results to respond to the user.
|
| 308 |
+
|
| 309 |
+
In summary, HuggingGPT establishes the collaboration of LLM with external expert models and shows promising performance on various forms of complex tasks.
|
| 310 |
+
|
| 311 |
+
# A.3.3 Case Study on More Scenarios
|
| 312 |
+
|
| 313 |
+
We show more cases here to illustrate HuggingGPT’s ability to handle realistic scenarios with task resource dependencies, multimodality, multiple resources, etc. To make clear the workflow of HuggingGPT, we also provide the results of the task planning and task execution stages.
|
| 314 |
+
|
| 315 |
+
• Figure 9 illustrates the operational process of HuggingGPT in the presence of resource dependencies among tasks. In this case, HuggingGPT can parse out concrete tasks based on abstract requests from the user, including pose detection, image captioning, and pose conditional image generation tasks. Furthermore, HuggingGPT effectively recognizes the dependencies between task #3 and tasks #1, #2, and injected the inferred results of tasks #1 and #2 into the input arguments of task #3 after the dependency tasks were completed. • Figure 10 demonstrates the conversational ability of HuggingGPT on audio and video modalities. In the two cases, it shows HuggingGPT completes the user-requested text-to-audio and text-tovideo tasks via the expert models, respectively. In the top one, the two models are executed in parallel (generating audio and generating video concurrently), and in the bottom one, the two models are executed serially (generating text from the image first, and then generating audio based on the text). This further validates that HuggingGPT can organize the cooperation between models and the resource dependencies between tasks.
|
| 316 |
+
|
| 317 |
+
• Figure 11 shows HuggingGPT integrating multiple user-input resources to perform simple reasoning. We can find that HuggingGPT can break up the main task into multiple basic tasks even with multiple resources, and finally integrate the results of multiple inferences from multiple models to get the correct answer.
|
| 318 |
+
|
| 319 |
+
# B More Discussion about Related Works
|
| 320 |
+
|
| 321 |
+
The emergence of ChatGPT and its subsequent variant GPT-4, has created a revolutionary technology wave in LLM and AI area. Especially in the past several weeks, we also have witnessed some experimental but also very interesting LLM applications, such as AutoGPT 4, AgentGPT 5, BabyAGI 6, and etc. Therefore, we also give some discussions about these works and provide some comparisons from multiple dimensions, including scenarios, planning, tools, as shown in Table 12.
|
| 322 |
+
|
| 323 |
+
Scenarios Currently, these experimental agents (e.g., AutoGPT, AgentGPT and BabyAGI) are mainly used to solve daily requests. While for HuggingGPT, it focuses on solving tasks in the AI area (e.g., vision, language, speech, etc), by utilizing the powers of Hugging Face. Therefore, HuggingGPT can be considered as a more professional agent. Generally speaking, users can choose the most suitable agent based on their requirements (e.g., daily requests or professional areas) or customize their own agent by defining knowledge, planning strategy and toolkits.
|
| 324 |
+
|
| 325 |
+
<table><tr><td rowspan=1 colspan=1>Name</td><td rowspan=1 colspan=1>Scenarios</td><td rowspan=1 colspan=1>Planning</td><td rowspan=1 colspan=1>Tools</td></tr><tr><td rowspan=1 colspan=1>BabyAGIAgentGPTAutoGPT</td><td rowspan=1 colspan=1>Daily</td><td rowspan=1 colspan=1>Iterative Planning</td><td rowspan=1 colspan=1>=Web Search, Code Executor..</td></tr><tr><td rowspan=1 colspan=1>HuggingGPT</td><td rowspan=1 colspan=1>AI area</td><td rowspan=1 colspan=1>Global Planning</td><td rowspan=1 colspan=1>Models in Hugging Face</td></tr></table>
|
| 326 |
+
|
| 327 |
+
Table 12: Comparision between HuggingGPT and other autonomous agents.
|
| 328 |
+
|
| 329 |
+
Planning BabyAGI, AgentGPT and AutoGPT can all be considered as autonomous agents, which provide some solutions for task automation. For these agents, all of them adopt step-by-step thinking, which iteratively generates the next task by using LLMs. Besides, AutoGPT employs an addition reflexion module for each task generation, which is used to check whether the current predicted task is appropriate or not. Compared with these applications, HuggingGPT adopts a global planning strategy to obtain the entire task queue within one query. It is difficult to judge which one is better, since each one has its deficiencies and both of them heavily rely on the ability of LLMs, even though existing LLMs are not specifically designed for task planning. For example, iterative planning combined with reflexion requires a huge amount of LLM queries, and if one step generates an error prediction, the entire workflow would possibly enter an endless loop. While for global planning, although it can always produce a solution for each user request within one query, it still cannot guarantee the correctness of each step or the optimality of the entire plan. Therefore, both iterative and global planning have their own merits and can borrow from each other to alleviate their shortcoming. Additionally, one notable point is that the difficulty of task planning is also linearly correlated to the task range. As the scope of tasks increases, it becomes more challenging for the controller to predict precise plans. Consequently, optimizing the controller (i.e., LLM) for task planning will be crucial in building autonomous agents.
|
| 330 |
+
|
| 331 |
+
Tools Among these agents, AutoGPT is the main one to involve other tools for usage. More specifically, AutoGPT primarily uses some common tools (e.g., web search, code executor), while HuggingGPT utilizes the expert models of ML communities (e.g., Hugging Face). Therefore, AutoGPT has a broader task range but is not suitable for more professional problems, whereas HuggingGPT is more specialized and focuses on solving more complex AI tasks. Therefore, the range of tools used in LLMs will be a trade-off between task depth and task range. In addition, we also note some industry products for LLM applications (e.g., ChatGPT plugins 7) and developer tools (e.g., LangChain 8, HuggingFace Transformer Agent 9, Semantic Kernels 10) for LLM applications. We believe these rapid developments will also facilitate the community to explore how to better integrate LLMs with external tools.
|
| 332 |
+
|
| 333 |
+
Overall, HuggingGPT can also be considered as an autonomous agent. Compared with these experimental agents, which mainly use GPT models to generate solutions for user requests, HuggingGPT systematically presents a clear pipeline with four stages: task planning, model selection, task execution and response generation. Such a pipeline can effectively improve the success rate of solving user requests. Besides, HuggingGPT also introduces a global planning strategy to decompose user requests and thus accomplish task automation. Furthermore, HuggingGPT is a collaborative system, which fully utilizes the power of expert models from ML communities to solve AI tasks and present the huge potential of using external tools. Compared with these agents, HuggingGPT allows us to better solve tasks more effectively in professional areas and can be easily extended to any vertical domain. In the future, we will continue to enhance HuggingGPT with even more powerful abilities to develop a versatile autonomous agent with unlimited possibilities.
|
| 334 |
+
|
| 335 |
+
# NLP $>$ Named Entity Recognition
|
| 336 |
+
|
| 337 |
+
Query: please recognize named entities in the sentence [ " that is to end the state of hostility , " Thursday's overseas edition of the People's Daily quoted Tang as saying. ]
|
| 338 |
+
|
| 339 |
+
Response: I have recognized named entities in the sentence 'that is to end the state of hostility , ' Thursday's overseas edition of the People's Daily quoted Tang as saying.'. The entities recognized are 'People's Daily' and 'Tang'. Both of them are organizations and people respectively. The model I used is ' $\ddot { \cdot }$ dslim/bert-base-NER', which is a fine-tuned BERT model that is ready to recognize named entities in the sentence. The inference results are very accurate, with a score of 0.9992 for 'People's Daily' and 0.998 for 'Tang'.
|
| 340 |
+
|
| 341 |
+
# NLP > Text Generation
|
| 342 |
+
|
| 343 |
+
Query: please complete a sentence [ COVID-19 is transmitted via droplets, air-borne, ]
|
| 344 |
+
|
| 345 |
+
Response: I have completed the sentence, the result is 'COVID-19 is transmitted via droplets, air-borne, and contact routes'. I used a $\ddot { \cdot }$ microsoft/biogpt model, a domainspecific generative Transformer language model pre-trained on large-scale biomedical literature.
|
| 346 |
+
|
| 347 |
+
# CV > Object Detection
|
| 348 |
+
|
| 349 |
+
Query: please detect all objects in examples.jpg
|
| 350 |
+
|
| 351 |
+
Response: I have detected all objects in the image located at a examples.jpg. I used the facebook/detr-resnet-101 model for object detection. It is a DETR (End-to-End Object Detection) model with ResNet-101 backbone, which is known for its high accuracy in object detection tasks. I generated an image with predicted boxes and labels for each object. The complete path of the generated image is examples/d7da.jpg. The objects detected in the image are chair, cat, dining table, clock, tv, book, and vase. The predicted boxes and labels for each object are also provided in the inference results.
|
| 352 |
+
|
| 353 |
+

|
| 354 |
+
|
| 355 |
+
# CV $>$ Visual Question Answering
|
| 356 |
+
|
| 357 |
+
Query: Look at js4f.jpg, what is the red topping?
|
| 358 |
+
|
| 359 |
+

|
| 360 |
+
Response: Sure, the red topping on the pizza in the image is tomato. I used a visual question answering model
|
| 361 |
+
|
| 362 |
+
dandelin/vilt-b32-finetuned-vqa to answer the question "What is the red topping?" based on the image. The answer with the highest score is "tomato" with a score of 0.9698325395584106.
|
| 363 |
+
|
| 364 |
+
# $\mathbf { c } \pmb { v } >$ Depth Estimate
|
| 365 |
+
|
| 366 |
+
Query: please estimate the depth of ks4j.jpg
|
| 367 |
+
|
| 368 |
+

|
| 369 |
+
|
| 370 |
+

|
| 371 |
+
Figure 4: Case study on various tasks (a).
|
| 372 |
+
|
| 373 |
+

|
| 374 |
+
Response: I have estimated the depth of the image located at examples/ks4j.jpg using the Intel/dpt-large model. This model is specifically trained on 1.4 million images and is a Dense Prediction Transformer (DPT) model. The generated depth image can be found at ' j45s.jpg'.
|
| 375 |
+
|
| 376 |
+
# CV $>$ Text-to-Image
|
| 377 |
+
|
| 378 |
+
Query: please give me a photo of "wide angle view of castle, blue sky background"
|
| 379 |
+
|
| 380 |
+
Response: Sure, I can do that. For your request, I used the model runwayml/stable-diffusion-v1-5 for text-to-image task, because this model is the most suitable for the task as it is
|
| 381 |
+
|
| 382 |
+
a latent text-to-image diffusion model capable of generating high-quality images from text descriptions. For the text-toimage task, I used the $\ddot { \cdot }$ runwayml/stable-diffusion-v1-5 model to generate an image from the text description you provided. The generated image is located at images/asd4.jpg.
|
| 383 |
+
|
| 384 |
+
# CV $>$ Document Question Answering
|
| 385 |
+
|
| 386 |
+
Query: Video > Generation look at the document doc.jpg, what is the purchase amount?
|
| 387 |
+
|
| 388 |
+
Response: Sure. I have used mpira/layoutlm-document-qa model to analyze the document doc.jpg you provided. After the analysis, I have found that the purchase amount is \$1,000,000,000. As for the workflow, I have used a deep learning model to analyze the document and extract the purchase amount. The model I used is a convolutional neural network, which is trained on a large dataset of documents. The inference results are the purchase amount of \$1,000,000,000. If you need more information, please let me know.
|
| 389 |
+
|
| 390 |
+
# CV $>$ Image to Image
|
| 391 |
+
|
| 392 |
+

|
| 393 |
+
|
| 394 |
+
Query: give me a similar image with example.jpg
|
| 395 |
+
|
| 396 |
+
Sure. For your request, I used the model
|
| 397 |
+
|
| 398 |
+
lambdalabs/sd-image-variations-diffusers
|
| 399 |
+
|
| 400 |
+
to generate an image from the image you provided. The generated image is located at /images/5373.jpg. If there is nothing in the results, I will tell you that I can't make it. Is there anything else I can help you with?
|
| 401 |
+
|
| 402 |
+

|
| 403 |
+
|
| 404 |
+
# Video $>$ Generation
|
| 405 |
+
|
| 406 |
+
Query: please generate a video based on "Spiderman is surfing"
|
| 407 |
+
|
| 408 |
+
Response: Sure, I can do that. I have generated a video based on your prompt "Spiderman is surfing". The video is saved at the following path: "/videos/4076.mp4". 1. Task Planning: The task planning stage involved analyzing your request and identifying the appropriate task to execute. In this case, the task was "text-to-video". 2. Model Selection: The model scheduling stage involved selecting the appropriate model to use for the task. In this case, the only available model was damovilab/text-to-video-ms-1.7b. 3. Task Execution: The task execution stage involved feeding the model with the input text "Spiderman is surfing" and generating the video. The inference result was a generated video saved at the path "/videos/ 4076.mp4". I hope this response meets your requirements.
|
| 409 |
+
|
| 410 |
+

|
| 411 |
+
|
| 412 |
+
# Audio > Generation
|
| 413 |
+
|
| 414 |
+
Query: please read the sentence "Hi there, I am ChatGPT empowered by Huggingface family! Yes, I can provide more than one thousand models for dozens of tasks. For more fun and creativity, I have invited Diffusers family to join our team. Feel free to experience it!" for me.
|
| 415 |
+
|
| 416 |
+
Response: Sure, I can do that. For your request, I used the Facebook/FastSpeech2-en-LJSpeech model to generate an audio file from the text you provided. The generated audio file is located at ' /audios/d5f3.wav '. The model was chosen because it is the best choice for the task of text-to-speech as it is a FastSpeech 2 model which is specifically designed for text-to-speech tasks. It is also the most recent model in the list and has the most potential to provide the best results. I hope this answers your question. Is there anything else I can help you with?
|
| 417 |
+
|
| 418 |
+
Figure 5: Case study on various tasks (b).
|
| 419 |
+
|
| 420 |
+
<table><tr><td colspan="5"></td></tr><tr><td></td><td>Args</td><td>Candidate Models</td><td>Descriptions</td></tr><tr><td colspan="4"></td></tr><tr><td>Text-CLS</td><td>text</td><td>[cardiffnlp/twitter-roberta- base-sentiment,.]</td><td>["Thisisa RoBERTa-base model trained on 58M tweets...,..]</td></tr><tr><td>Token-CLS</td><td>text</td><td>[dslim/bert-base-NER,...]</td><td>["bert-base-NER isa fine-tuned BERT model that is ready to...,.]</td></tr><tr><td>Text2text-Generation</td><td>text</td><td>[google/flan-t5-xl,...]</td><td>["If you already know T5,FLAN-T5 is just better at everything..,.]</td></tr><tr><td>Summarization</td><td>text</td><td>[bart-large-cnn,...]</td><td>["BARTmodel pre-trained on English language, and fine-tuned.",..]</td></tr><tr><td>Translation</td><td>text</td><td>[t5-base,..]</td><td>["With T5, we propose reframing all NLP tasks into a unified..",.]</td></tr><tr><td>Question-Answering</td><td>text</td><td>[deepset/roberta-base- squad2,..]</td><td>["This is the roberta-base model, fine-tuned using the SQuAD2.0...",..]</td></tr><tr><td>Conversation</td><td>text</td><td>[PygmalionAI/pygmalion- 6b.,,...]</td><td>["Pymalion 6B is a proof-of-concept dialogue model based on..",.]</td></tr><tr><td>Text-Generation</td><td>text</td><td>[gpt2,..]</td><td>["Pretrained model on English..",.]</td></tr><tr><td>Tabular-CLS</td><td>text</td><td>[matth/flowformer,...]</td><td>["Automatic detection of blast cells in ALL data usingtransformers..,.]</td></tr><tr><td colspan="4">CV Tasks</td></tr><tr><td>Image-to-Text</td><td>image</td><td>[nlpconnect/vit-gpt2-image- captioning,... [runwayml/stable-diffusion-</td><td>["This is an image captioning model trained by @ydshieh in flax...",.]</td></tr><tr><td>Text-to-Image</td><td>image</td><td>v1-5,...] [dandelin/vilt-b32-</td><td>["StableDiffusion isa latent text-to-image diffusion model..",.] ["Vision-and-Language Transformer</td></tr><tr><td>VQA</td><td> text + image</td><td>finetuned-vqa.,...</td><td>(ViLT)modelfine-tuned o.,.] ["DEtection TRansformer(DETR)</td></tr><tr><td>Segmentation</td><td>image</td><td>[facebook/detr-resnet-50- panoptic,..]</td><td> model trained end-to-end on ..",...</td></tr><tr><td>DQA</td><td>text + image</td><td>[impira/layoutlm- document-qa,..]</td><td>["This is a fine-tuned version of the multi-modal LayoutLM model...,.]</td></tr><tr><td>Image-CLS</td><td>image</td><td>[microsoft/resnet-50,..] [radames/stable-diffusion-</td><td>["ResNet model pre-trained on..",..] ["StableDiffusion isa latent</td></tr><tr><td>Image-to-image</td><td>image</td><td>v1-5-img2img,..]</td><td>text-to-image diffusion mode..",.] ["DEtection TRansformer(DETR)</td></tr><tr><td>Object-Detection</td><td>image</td><td>[facebook/detr-resnet-50, ..]</td><td> model trained end-to-end on ..",..]</td></tr><tr><td>ControlNet-SD</td><td>image</td><td>[llyasviel/sd-controlnet- canny,...]</td><td>["ControlNet is a neural network structure to control diffusion..",..]</td></tr><tr><td colspan="4">Audio Tasks</td></tr><tr><td>Text-to-Speech</td><td>text</td><td>[espnet/kan- bayashi_ljspeech_vits,..] [TalTechNLP/voxlingua107-</td><td>["his model was trained by kan-bayashi using ljspeech/ttsl recipe in..",..]</td></tr><tr><td>Audio-CLS</td><td>audio</td><td>epaca-tdnn,... [jonatasgrosman/wav2vec2-</td><td>["This is a spoken language recognition model trained on the..",..</td></tr><tr><td>ASR</td><td>audio</td><td>large-xlsr-53-english,...]</td><td>["Fine-tuned XLSR-53 large model for speech recognition in English ..,..]</td></tr><tr><td>Audio-to-Audio</td><td>audio</td><td>[speechbrain/metricgan- plus-voicebank,...]</td><td>["MetricGAN-trained model for Enhancement..,.]</td></tr><tr><td colspan="4">Video Tasks [damo-vilab/text-to-video-</td></tr><tr><td>Text-to-Video</td><td>text</td><td>ms-1.7b,...]</td><td>["his model is based on a multi-stage text-to-video generation..",.. ["VideoMAE model pre-trained on</td></tr><tr><td>Video-CLS</td><td>video</td><td>[MCG-NJU/videomae- base,...]</td><td>Kinetics-400 for 1600 epochs.."”,..]</td></tr></table>
|
| 421 |
+
|
| 422 |
+
Table 13: The task list used in HuggingGPT. The first and second columns are the name and arguments of the corresponding task. The third and fourth columns provide some examples of the candidate models and their model descriptions.
|
| 423 |
+
|
| 424 |
+
Query #1: Please generate a canny image based on example.jpg
|
| 425 |
+
|
| 426 |
+
Response #1: I have generated a canny image for you based on the image located at example.jpg. The task process involved selecting the canny-control model for image processing, as it covers common image processing functions. The inference results include a generated image, which can be found at
|
| 427 |
+
|
| 428 |
+
images/df8t.jpg.
|
| 429 |
+
|
| 430 |
+
# Task Planning #1:
|
| 431 |
+
|
| 432 |
+
1: {"task": "image-to-text", "id": 0, dep: [-1], "args": {"image": "example.jpg"}}
|
| 433 |
+
2: {"task": "control-canny", "id": 0, dep: [-1], "args": {"image": "example.jpg"}}
|
| 434 |
+
|
| 435 |
+
# Execution Results #1:
|
| 436 |
+
|
| 437 |
+
1. {"generated text": "a herd of giraffes and zebras grazing in a field"} 2. {"generated image": "images/df8t.jpg"}
|
| 438 |
+
|
| 439 |
+
Query #2: then based on the above canny image and a prompt "a photo of a zoo", generate a new image.
|
| 440 |
+
|
| 441 |
+
Response #2: I have received your request to generate a canny image of a photo of a zoo. I have selected the model a lllyasviel/sd-controlnet-canny as it is the best model for this task. I have processed the image and generated a new image located at images/ja2f.jpg. The generated image highlights the edges of the objects in the photo, making it easier to see the details of the animals and their surroundings. Overall, the task was to convert a text prompt 'a photo of a zoo' into a canny image using the selected model.
|
| 442 |
+
|
| 443 |
+
# Task Planning #2:
|
| 444 |
+
|
| 445 |
+
1: {"task": "canny-text-to-image", "id": 0, dep: [-1], "args": {"text":"a photo of a zoo", "image": "example.jpg"}}
|
| 446 |
+
|
| 447 |
+
# Execution Results #2:
|
| 448 |
+
|
| 449 |
+
1. {"generated image": "images/ja2f.jpg"}
|
| 450 |
+
|
| 451 |
+

|
| 452 |
+
|
| 453 |
+
Query #3: please detect objects in the above image
|
| 454 |
+
|
| 455 |
+
# Response #3:
|
| 456 |
+
|
| 457 |
+
Sure, here is the result of your command. I hava successfully detected objects in the image you provided. The detected objects are giraffes and zebras. I used the facebook/detrresnet-101 model for object detection, which is specifically designed for object detection tasks and has a ResNet-101 backbone, which is a powerful feature extractor. Additionally, the DETR architecture used in this model is an end-to-end object detection model that has shown promising results in various benchmarks. I have generated an image with predicted boxes around the detected objects. You can find the generated image at the following path: images/dif2.jpg. The predicted objects and their corresponding scores are as follows: - Giraffe with a score of 0.999- Zebra with a score of 0.998- Zebra with a score of 0.998- Giraffe with a score of 0.969- Zebra with a score of 0.997. I hope this information is helpful to you.
|
| 458 |
+
|
| 459 |
+
# Task Planning #3:
|
| 460 |
+
|
| 461 |
+
1: {'task': 'object-detection', 'id': 0, 'dep': [-1], 'args': {'image': 'images/ja2f.png'}}
|
| 462 |
+
|
| 463 |
+
# Execution Results #3:
|
| 464 |
+
|
| 465 |
+
1. {'generated image with predicted box':
|
| 466 |
+
'/images/dif2.jpg', 'predicted': [{'box':
|
| 467 |
+
{'xmax': 760, 'xmin': 515, 'ymax': 437,
|
| 468 |
+
'ymin': 136}, 'label': 'giraffe', 'score':
|
| 469 |
+
0.9992127418518066}, {'box': {'xmax':
|
| 470 |
+
561, 'xmin': 510, 'ymax': 447, 'ymin': 357},
|
| 471 |
+
'label': 'zebra', 'score':
|
| 472 |
+
0.9983904361724854}, {'box': {'xmax':
|
| 473 |
+
324, 'xmin': 178, 'ymax': 446, 'ymin': 336},
|
| 474 |
+
'label': 'zebra', 'score':
|
| 475 |
+
0.9986028075218201}, {'box': {'xmax':
|
| 476 |
+
297, 'xmin': 4, 'ymax': 372, 'ymin': 213},
|
| 477 |
+
'label': 'giraffe', 'score':
|
| 478 |
+
0.9694724082946777}]}
|
| 479 |
+
|
| 480 |
+
Figure 6: Case study on complex tasks (a).
|
| 481 |
+
|
| 482 |
+
Query: Describe this image example.jpg in as much detail as possible.
|
| 483 |
+
|
| 484 |
+
Response: The image you provided appears to show a family of four dogs playing in the grass. For this task, I ran multiple CV tasks, including image-totext, image-classification, object-detection, visualquestion-answering, and document-questionanswering. I chose specific models for each task that were best suited to addressing your query, based on their training and performance characteristics.
|
| 485 |
+
|
| 486 |
+
For image-to-text, I chose the
|
| 487 |
+
|
| 488 |
+
# nlpconnect/vit
|
| 489 |
+
|
| 490 |
+
gpt2-image-captioning model. This model generates an image caption with the given image. I applied this model to the input image and the developed output was: a family of four dogs are playing in the grass For image-classification, I selected the $\ddot { \cdot }$ google/vitbase-patch16-224 model. This model is trained on natural images dataset and it can predict the label of the image output. I applied this model to the image and get the results showing the risk of each label. It shows the highest risk at "Rhodesian ridgeback" with a score of $9 3 . 8 \%$ For object-detection, I used facebook/detr
|
| 491 |
+
|
| 492 |
+
#
|
| 493 |
+
|
| 494 |
+
resnet-101 model. This model is trained on COCO panoptic segmentation for object detection. I used this model to generate an image file with the predicted box. The generated image with predicted box is at: /images/sd48.jpg
|
| 495 |
+
|
| 496 |
+

|
| 497 |
+
|
| 498 |
+
# Task Planning:
|
| 499 |
+
|
| 500 |
+
1. {"id": "0", "dep": [-1], "task": "image-to-text", "args": {"image": "example.jpg" }}, 2. {"id": "1", "dep": [-1], "task": "image-classification", "args": {"image": "example.jpg" }}, 3. {"id": "2", "dep": [-1], "task": "object-detection", "args": {"image": "example.jpg" }}, 4. {"id": "3", "dep": [-1], "task": "imagesegmentation", "args": {"image": "example.jpg" }}, 5. {"id": "4", "dep": [-1], "task": "visual-questionanswering", "args": {"text": "describe this image in detail", "image": "example.jpg" }},
|
| 501 |
+
|
| 502 |
+
# Execution Results:
|
| 503 |
+
|
| 504 |
+
1. {"generated_text": "a family of four dogs are playing in the grass "} 2. [{'score': 0.938717246055603, 'label': 'Rhodesian ridgeback'}, {'score': 0.01652258075773716, 'label': 'boxer'}, {'score': 0.006381669547408819, 'label': 'Great Dane'}, {'score': 0.006234415341168642, 'label': 'vizsla, Hungarian pointer'}, {'score': 0.005944834090769291, 'label': 'bull mastiff'}] 3. [{"generated image with predicted box": "/images/ sd48.jpg","predicted": [{"box": {"xmax": 463, "xmin": 373, "ymax": 267, "ymin": 199}, "label": "bus", "score": 0.9981155395507812}, {"box": {"xmax": 292, "xmin": 124, "ymax": 224, "ymin": 175}, "label": "airplane", "score": 0.9983609318733215}, {"box": {"xmax": 554, "xmin": 487, "ymax": 277, "ymin": 226}, "label": "person", "score": 0.9910836219787598}]} 4. {"generated image with segmentation": "/images/ t4s1.jpg", "predicted": [{"score": 0.989, "label": "grass"}, {"score": 0.999, "label": "dog"}, {"score": 0.999, "label": "tree"},{"score": 0.999, "label": "dog"}] 5. [{'answer': 'dogs', 'score': 0.8488452434539795}, {'answer': 'dog', 'score': 0.04168461635708809}]
|
| 505 |
+
|
| 506 |
+
dandelin/
|
| 507 |
+
|
| 508 |
+
vilt-b32-finetuned-vqa model. This model is a Visionand-Language Transformer (ViLT) model, which is fine-tuned on VQAv2. It is suitable for visualquestion-answering tasks, and is likely to provide accurate results for the given image. For the question "what are in the image?" It reply with a prediction "dogs" and the confidence is $8 4 . 9 \%$ .
|
| 509 |
+
|
| 510 |
+

|
| 511 |
+
Figure 7: Case study on complex tasks (b).
|
| 512 |
+
|
| 513 |
+
Query: Can you tell me how many objects in the picture example1.jpg?
|
| 514 |
+
|
| 515 |
+
Response: There are 8 objects in the picture. I used the model facebook/detr-resnet-101 for this task which is trained on a popular object detection dataset called COCO, and it has the highest number of downloads. It generated an image with predicted boxes that is available under the path: /images/79f2.jpg . As for image captioning, I selected the model nlpconnect/vit-gpt2-image-captioning which is more frequently used and works better in this case. The generated text from the image is 'a large jetliner sitting on top of an airport tarmac.'
|
| 516 |
+
|
| 517 |
+
# Task Planning:
|
| 518 |
+
|
| 519 |
+
1: {"task": "object-detection", "id": 0, dep: [-1], "args": {"image": "example1.jpg"}},
|
| 520 |
+
2: {"task": "image-to-text", "id": 1, dep: [-1], "args": {"image": "example1.jpg"}}
|
| 521 |
+
|
| 522 |
+
# Execution Results:
|
| 523 |
+
|
| 524 |
+
1. [{"generated image with predicted box": "/images/79f2.jpg", "predicted": [{"box": {"xmax": 463, "xmin": 373, "ymax": 267, "ymin": 199}, "label": "bus", "score": 0.9981155395507812}, {"box": {"xmax": 292, "xmin": 124, "ymax": 224, "ymin": 175}, "label": "airplane", "score": 0.9983609318733215}, {"box": {"xmax": 554, "xmin": 487, "ymax": 277, "ymin": 226}, "label": "person", "score": 0.9910836219787598}, {"box": {"xmax": 230, "xmin": 219, "ymax": 264, "ymin": 227}, "label": "person", "score": 0.998579740524292}, {"box": {"xmax": 361, "xmin": 330, "ymax": 231, "ymin": 220}, "label": "truck", "score": 0.9066138863563538}, {"box": {"xmax": 639, "xmin": 460, "ymax": 420, "ymin": 142}, "label": "bus", "score": 0.9987366795539856}, {"box": {"xmax": 363, "xmin": 279, "ymax": 222, "ymin": 192}, "label": "airplane", "score": 0.9976897239685059}, {"box": {"xmax": 317, "xmin": 287, "ymax": 230, "ymin": 219}, "label": "truck", "score": 0.9339178800582886}]},
|
| 525 |
+
|
| 526 |
+
2. {"generated_text": "a large jetliner sitting on top of an airport tarmac "}
|
| 527 |
+
|
| 528 |
+
Query: In example2.jpg, what's the animal and what's it doing?
|
| 529 |
+
|
| 530 |
+

|
| 531 |
+
Figure 8: Case study on complex tasks (c).
|
| 532 |
+
|
| 533 |
+
Response: Sure, the animal in the image is a tiger and it's laying down. I performed 3 tasks including image-to-text, image-classification, and visual-question-answering on the image you provided. To accomplish this, I selected models nlpconnect/vit-gpt2-image-captioning, google/ vit-base-patch16-224 and $| \because |$ dandelin/vilt-b32-finetuned-vqa because they are the perfect models for this use case respectively. According to the results, I have $8 8 \%$ confidence that the animal is a tiger and also have a $7 7 . 8 \%$ confidence that it's laying down .The generated image with predicted box is stored at the path: /images/d59a.jpg.
|
| 534 |
+
|
| 535 |
+

|
| 536 |
+
|
| 537 |
+
# Task Planning:
|
| 538 |
+
|
| 539 |
+
1: {"task": "image-classification", "id": 0, dep: [-1], "args": {"image": "example2.jpg" }}, 2: {"task": "visual-question-answering", "id": 1, dep: [-1], "args": {"text": "What is the animal doing?", "image": "example2.jpg" }} 3: {"task":"image-to-text", "id": 2, dep: [-1], "args": {"image": "example2.jpg" }}
|
| 540 |
+
|
| 541 |
+
# Execution Results:
|
| 542 |
+
|
| 543 |
+
1. [{'score': 0.8858247399330139, 'label': 'tiger, Panthera tigris'}, {'score': 0.10940514504909515, 'label': 'tiger cat'}, {'score': 0.0006216467591002584, 'label': 'jaguar, panther, Panthera onca, Felis onca'}, {'score': 0.0004262701258994639, 'label': 'dhole, Cuon alpinus'}, {'score': 0.00030842673731967807, 'label': 'lion, king of beasts, Panthera leo'}]
|
| 544 |
+
2. [{'answer': 'sitting', 'score': 0.8294351696968079}, {'answer': 'laying down', 'score': 0.7387925386428833}, {'answer': 'resting', 'score': 0.625247061252594}, {'answer': 'laying', 'score': 0.6114301681518555}, {'answer': 'relaxing', 'score': 0.44740357995033264}]
|
| 545 |
+
3. {'generated_text': 'a brown and white striped zebra laying on a rock'}
|
| 546 |
+
|
| 547 |
+
Query: based on the pose image of example1.jpg and the description of example2.jpg, please generate a new one.
|
| 548 |
+
|
| 549 |
+

|
| 550 |
+
|
| 551 |
+
Response: Based on the pose image of example1.jpg and the description of example2.jpg, I have generated a new image s5f8.jpg for you. The process of generating this image involved using the
|
| 552 |
+
|
| 553 |
+
a openpose-control model to extract the pose information from the basketball image, and then using the a nlpconnect/vit-gpt2-image-captioning to generate a description of the boy in the image. Finally, I used the lllyasviel/sd-controlnet-openpose model to combine the pose information and the description to generate the final image. The complete path of the generated image is s5f8.jpg. If you have any other questions, please let me know.
|
| 554 |
+
|
| 555 |
+
# Task Planning:
|
| 556 |
+
|
| 557 |
+

|
| 558 |
+
|
| 559 |
+
1: {'task': 'pose-detection', 'id': 0, 'dep': [-1], 'args': {'image':
|
| 560 |
+
'example1.jpg'}}
|
| 561 |
+
2. {'task': 'image-to-text', 'id': 1, 'dep': [-1], 'args':
|
| 562 |
+
{'image': 'example2.jpg'}}
|
| 563 |
+
3. {"task": "pose-text-to-image", "id": 2, "dep": [0, 1], "args":
|
| 564 |
+
{"text":"<resource>-1", "image": "<resource>-0"}}
|
| 565 |
+
|
| 566 |
+
# Execution Results:
|
| 567 |
+
|
| 568 |
+

|
| 569 |
+
Figure 9: Qualitative analysis of multi-model cooperation with resource dependency.
|
| 570 |
+
|
| 571 |
+
Query: generate a video with the title "An astronaut is walking in space" and dub it.
|
| 572 |
+
|
| 573 |
+
Response: Sure. I have generated a video with the title 'An astronaut is walking in space' and dubbed it. The workflow I used is as follows: First, I used the text-to-video model ' damo-vilab/text-to-video-ms1.7b' to generate a video from the text. The inference result is the generated video ' /videos/5696.mp4'. Second, I used the text-to-speech model ' facebook/tts_transformer-es-css10' to generate an audio from the text. The inference result is the generated audio ' /audios/3f9e.flac '. Finally, I combined the video and audio to generate the dubbed video. I hope this answers your question. Is there anything else I can help you with?
|
| 574 |
+
|
| 575 |
+

|
| 576 |
+
|
| 577 |
+
# Task Planning:
|
| 578 |
+
|
| 579 |
+
1: {"task": "text-to-video", "id": 0, "dep": [-1], "args": {"text": "An astronaut is walking in space" }}
|
| 580 |
+
2: {"task": "text-to-speech", "id": 1, "dep": [-1], "args": {"text": "An astronaut is walking in space" }}
|
| 581 |
+
|
| 582 |
+
# Execution Results:
|
| 583 |
+
|
| 584 |
+
2. {"generated audio": "/audios/3f9e.flac" {"generated video": "/videos/5696.mp4"}
|
| 585 |
+
|
| 586 |
+
Query: read the image example.jpg for me.
|
| 587 |
+
|
| 588 |
+
# INVOICE NO :18301/102/T0305
|
| 589 |
+
|
| 590 |
+
Response: Sure. I have read the image example.jpg for you. The inference result is 'INVOICE NO : 18301/102/T0305'. The model used for this task is microsoft/trocr-base-printed, which is best suited for the task of image-to-text as it is fine-tuned on the SROIE dataset which is specifically designed for this task. Then I have converted the text to audio, the generated audio is /audios/da5s.wav )) $1 1 \vert 1 1 1 \vert 1 1 1 \vert 1 1 1 \vert 1 1 1 \vert 1 1$ and the model used for this task is facebook/fastspeech2-en-ljspeech, which is a FastSpeech 2 text-tospeech model which is suitable for the task of text-to-speech. Is there anything else I can help you with?
|
| 591 |
+
|
| 592 |
+
# Task Planning:
|
| 593 |
+
|
| 594 |
+
1: {"task": "image-to-text", "id": 0, "dep": [-1], "args": {"image": "example.jpg"}}
|
| 595 |
+
2: {"task": "text-to-speech", "id": 1, "dep": [0], "args": {"text": "<resource-0>"}
|
| 596 |
+
|
| 597 |
+
# Execution Results:
|
| 598 |
+
|
| 599 |
+
1. {"generated text": "INVOICE NO : 18301/102/T0305"} 2. {"generated audio": "/audios/da5s.wav"}
|
| 600 |
+
|
| 601 |
+
Figure 10: Qualitative analysis of multi-model cooperation on video and audio modalities.
|
| 602 |
+
|
| 603 |
+
Query: Given a collection of images A: /examples/a.jpg, B: /examples/b.jpg, C: /examples/c.jpg, please tell me how many zebras in these pictures?
|
| 604 |
+
|
| 605 |
+

|
| 606 |
+
|
| 607 |
+
, there are a total of 4 zebras. To determine
|
| 608 |
+
|
| 609 |
+
facebook/detr-resnet-101 to
|
| 610 |
+
|
| 611 |
+
identify and locate any zebras in the images. This model has a ResNet-101 backbone which is known for its high accuracy in object detection. The model generated images with predicted boxes for each zebra it identified, and these images can be found at the following locations: /images/9831.jpg, /images/
|
| 612 |
+
|
| 613 |
+
be11.jpg. Finally, I used a text classification model called
|
| 614 |
+
|
| 615 |
+
sentiment to analyze the generated captions and predicted boxes to confirm the presence of zebras in the images. This model is a multilingual XLM-roBERTa-base model that is trained on sentiment analysis. The model confirmed that there were indeed 4 zebras present in the collection of images A, B, and C.
|
| 616 |
+
|
| 617 |
+

|
| 618 |
+
Figure 11: Qualitative analysis of multi-model cooperation with multiple sources.
|
md/dev/zyLVMgsZ0U_/zyLVMgsZ0U_.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|