Datasets:
Tasks:
Question Answering
Modalities:
Image
Formats:
imagefolder
Languages:
English
Size:
100K - 1M
ArXiv:
License:
Add files using upload-large-folder tool
Browse filesFiles changed (50)
- md/dev/0I3su3mkuL/0I3su3mkuL.mdAdded+370
- md/dev/10uNUgI5Kl/10uNUgI5Kl.mdAdded+386
- md/dev/1KaSx3GrBBm/1KaSx3GrBBm.mdAdded+341
- md/dev/3lge0p5o-M-/3lge0p5o-M-.mdAdded+456
- md/dev/67o9UQgTD0/67o9UQgTD0.mdAdded+474
- md/dev/7gE9V9GBZaI/7gE9V9GBZaI.mdAdded+560
- md/dev/8H5bpVwvt5/8H5bpVwvt5.mdAdded
- md/dev/99RpBVpLiX/99RpBVpLiX.mdAdded
- md/dev/9EAQVEINuum/9EAQVEINuum.mdAdded+414
- md/dev/AhccnBXSne/AhccnBXSne.mdAdded+307
- md/dev/EXnIyMVTL8s/EXnIyMVTL8s.mdAdded+719
- md/dev/G2Q2Mh3avow/G2Q2Mh3avow.mdAdded
- md/dev/I-6yh2-dkyD/I-6yh2-dkyD.mdAdded+345
- md/dev/ITw9edRDlD/ITw9edRDlD.mdAdded+338
- md/dev/JCCi58IUsh/JCCi58IUsh.mdAdded+491
- md/dev/KwmPfARgOTD/KwmPfARgOTD.mdAdded
- md/dev/LV8OmADmoOe/LV8OmADmoOe.mdAdded+223
- md/dev/NiEtU7blzN/NiEtU7blzN.mdAdded
- md/dev/OgCcfc1m0TO/OgCcfc1m0TO.mdAdded
- md/dev/RA7ND878XP/RA7ND878XP.mdAdded
- md/dev/SlxSY2UZQT/SlxSY2UZQT.mdAdded
- md/dev/Sxk8Bse3RKO/Sxk8Bse3RKO.mdAdded
- md/dev/TIdIXIpzhoI/TIdIXIpzhoI.mdAdded
- md/dev/TatRHT_1cK/TatRHT_1cK.mdAdded
- md/dev/TntbHxxGd6j/TntbHxxGd6j.mdAdded
- md/dev/VgOw1pUPh97/VgOw1pUPh97.mdAdded
- md/dev/WVX0NNVBBkV/WVX0NNVBBkV.mdAdded
- md/dev/_1bgdFHhA70/_1bgdFHhA70.mdAdded
- md/dev/a8qX5RG36jd/a8qX5RG36jd.mdAdded
- md/dev/biaOpY5gAo/biaOpY5gAo.mdAdded
- md/dev/dUSI4vFyMK/dUSI4vFyMK.mdAdded
- md/dev/dz79MhQXWvg/dz79MhQXWvg.mdAdded
- md/dev/f-fVCElZ-G1/f-fVCElZ-G1.mdAdded
- md/dev/f3zNgKga_ep/f3zNgKga_ep.mdAdded
- md/dev/fARM4P0gAJV/fARM4P0gAJV.mdAdded
- md/dev/fcO9Cgn-X-R/fcO9Cgn-X-R.mdAdded
- md/dev/h4r00NGkjR/h4r00NGkjR.mdAdded
- md/dev/hX5Ia-ION8Y/hX5Ia-ION8Y.mdAdded
- md/dev/luEG3j9LW5-/luEG3j9LW5-.mdAdded
- md/dev/n0OeTdNRG0Q/n0OeTdNRG0Q.mdAdded
- md/dev/n7XbkHOwKn6/n7XbkHOwKn6.mdAdded
- md/dev/r9hNv76KoT3/r9hNv76KoT3.mdAdded
- md/dev/ucASPPD9GKN/ucASPPD9GKN.mdAdded
- md/dev/v54eUIayFh/v54eUIayFh.mdAdded
- md/dev/w6fj2r62r_H/w6fj2r62r_H.mdAdded
- md/dev/xnuN2vGmZA0/xnuN2vGmZA0.mdAdded
- md/dev/yb3HOXO3lX2/yb3HOXO3lX2.mdAdded
- md/dev/z9NLqoFvZ0/z9NLqoFvZ0.mdAdded
- md/dev/zGvRdBW06F5/zGvRdBW06F5.mdAdded
- md/train/S1WRibb0Z/S1WRibb0Z.mdAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370# Q-Transformer: Scalable Offline Reinforcement Learning via Autoregressive Q-Functions
Yevgen Chebotarβ, Quan Vuongβ, Alex Irpan, Karol Hausman, Fei Xia, Yao Lu, Aviral Kumar, Tianhe Yu, Alexander Herzog, Karl Pertsch, Keerthana Gopalakrishnan, Julian Ibarz, Ofir Nachum, Sumedh Sontakke, Grecia Salazar, Huong T Tran, Jodilyn Peralta, Clayton Tan, Deeksha Manjunath, Jaspiar Singht, Brianna Zitkovich, Tomas Jackson, Kanishka Rao, Chelsea Finn, Sergey Levine
Google DeepMind
Abstract: In this work, we present a scalable reinforcement learning method for training multi-task policies from large offline datasets that can leverage both human demonstrations and autonomously collected data. Our method uses a Transformer to provide a scalable representation for Q-functions trained via offline temporal difference backups. We therefore refer to the method as Q-Transformer. By discretizing each action dimension and representing the Q-value of each action dimension as separate tokens, we can apply effective high-capacity sequence modeling techniques for Q-learning. We present several design decisions that enable good performance with offline RL training, and show that Q-Transformer outperforms prior offline RL algorithms and imitation learning techniques on a large diverse real-world robotic manipulation task suite. The projectβs website and videos can be found at qtransformer.github.io
# 1 Introduction
Robotic learning methods that incorporate large and diverse datasets in combination with highcapacity expressive models, such as Transformers [1, 2, 3, 4, 5, 6], have the potential to acquire generalizable and broadly applicable policies that perform well on a wide variety of tasks [1, 2]. For example, these policies can follow natural language instructions [4, 7], perform multi-stage behaviors [8, 9], and generalize broadly across environments, objects, and even robot morphologies [10, 3]. However, many of the recently proposed high-capacity models in the robotic learning literature are trained with supervised learning methods. As such, the performance of the resulting policy is limited by the degree to which human demonstrators can provide high-quality demonstration data. This is limiting for two reasons. First, we would like robotic systems that are more proficient than human teleoperators, exploiting the full potential of the hardware to perform tasks quickly, fluently, and reliably. Second, we would like robotic systems that get better with autonomously gathered experience, rather than relying entirely on high-quality demonstrations.
 Figure 1: Q-Transformer enables training highcapacity sequential architectures on mixed quality data. Our policies are able to improve upon human demonstrations and execute a variety of manipulation tasks in the real world.
Reinforcement learning in principle provides both of these capabilities. A number of promising recent advances demonstrate the successes of large-scale robotic RL in varied settings, such as robotic grasping and stacking [11, 12], learning heterogeneous tasks with human-specified rewards [13], learning multi-task policies [14, 15], learning goal-conditioned policies [16, 17, 18, 19], and robotic navigation [20, 21, 22, 23, 24]. However, training high-capacity models such as Transformers using RL algorithms has proven more difficult to instantiate effectively at large scale. In this paper, we aim to combine large-scale robotic learning from diverse real-world datasets with modern high-capacity Transformer-based policy architectures.
While in principle simply replacing existing architectures (e.g., ResNets [15] or smaller convolutional neural networks [11, 14]) with a Transformer is conceptually straightforward, devising a methodology that effectively makes use of such architectures is considerably more challenging. High-capacity models only make sense when we train on large and diverse datasets β small, narrow datasets simply do not require this much capacity and do not benefit from it. While prior works used simulation to create such datasets [2, 25, 26], the most representative data comes from the real world [12, 11, 14]. Therefore, we focus on reinforcement learning methods that can use Transformers and incorporate large, previously collected datasets via offline RL. Offline RL methods train on prior data, aiming to derive the most effective possible policy from a given dataset. Of course, this dataset can be augmented with additionally autonomously gathered data, but the training is separated from data collection, providing an appealing workflow for large-scale robotics applications [27].
Another issue in applying Transformer models to RL is to design RL systems that can effectively train such models. Effective offline RL methods generally employ Q-function estimation via temporal difference updates [28]. Since Transformers model discrete token sequences, we convert the Q-function estimation problem into a discrete token sequence modeling problem, and devise a suitable loss function for each token in the sequence. Na¨ıvely discretizing the action space leads to exponential blowup in action cardinality, so we employ a per-dimension discretization scheme, where each dimension of the action space is treated as a separate time step for RL. Different bins in the discretization corresponds to distinct actions. The per-dimension discretization scheme allows us to use simple discrete-action Q-learning methods with a conservative regularizer to handle distributional shift [29, 30]. We propose a specific regularizer that minimizes values of every action that was not taken in the dataset and show that our method can learn from both narrow demonstration-like data and broader data with exploration noise. Finally, we utilize a hybrid update that combines Monte Carlo and $n$ -step returns with temporal difference backups [31], and show that doing so improves the performance of our Transformer-based offline RL method on large-scale robotic learning problems.
In summary, our main contribution is the Q-Transformer, a Transformer-based architecture for robotic offline reinforcement learning that makes use of per-dimension tokenization of Q-values and can readily be applied to large and diverse robotic datasets, including real-world data. We summarize the components of Q-Transformer in Figure 1. Our experimental evaluation validates the Q-Transformer by learning large-scale text-conditioned multi-task policies, both in simulation for rigorous comparisons and in large-scale real-world experiments for realistic validation. Our real-world experiments utilize a dataset with 38,000 successful demonstrations and 20,000 failed autonomously collected episodes on more than 700 tasks, gathered with a fleet of 13 robots. QTransformer outperforms previously proposed architectures for large-scale robotic RL [15, 14], as well as previously proposed Transformer-based models such as the Decision Transformer [32, 33].
# 2 Related Work
Offline RL has been extensively studied in recent works [34, 35, 36, 37, 35, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 39]. Conservative Q-learning (CQL) [29] learns policies constrained to a conservative lower bound of the value function. Our goal is not to develop a new algorithmic principle for offline RL, but to devise an offline RL system that can integrate with high-capacity Transformers, and scale to real-world multi-task robotic learning. We thus develop a version of CQL particularly effective for training large Transformer-based Q-functions on mixed quality data. While some works have noted that imitation learning outperforms offline RL on demonstration data [49], other works showed offline RL techniques to be effective with demonstrations both in theory and in practice [50, 15]. Nonetheless, a setting that combines βnarrowβ demonstration data with βbroadβ sub-optimal (e.g., autonomously collected) data is known to be particularly difficult [51, 52, 53], though it is quite natural in many robotic learning settings where we might want to augment a core set of demonstrations with relatively inexpensive low-quality autonomously collected data. We believe that the effectiveness of our method in this setting is of particular interest to practitioners.
Transformer-based architectures [54] have been explored in recent robotics research, both to learn generalizable task spaces [55, 56, 57, 58, 8, 59] and to learn multi-task or even multi-domain sequential policies directly [2, 1, 6, 3]. Although most of these works considered Transformers in a supervised learning setting, e.g., learning from demonstrations [4, 5], there are works on employing Transformers for RL and conditional imitation learning [32, 20, 60, 33]. In our experiments, we compare to Decision Transformer (DT) in particular [32], which extends conditional imitation learning with reward conditioning [61, 62] to use sequence models, and structurally resembles imitation learning methods that have been used successfully for robotic control. Although DT incorporates elements of RL (namely, reward functions), it does not provide a mechanism to improve over the demonstrated behavior or recombine parts of the dataset to synthesize more optimal behaviors, and indeed is known to have theoretical limitations [63]. On the other hand, such imitation-based recipes are popular perhaps due to the difficulty of integrating Transformer architectures with more powerful temporal difference methods (e.g., Q-learning). We show that several simple but important design decisions are needed to make this work, and our method significantly outperforms non-TD methods such as DT, as well as imitation learning, on our large-scale multi-task robotic control evaluation. Extending Decision Transformer, Yamagata et al. [64] proposed to use a Q-function in combination with a Transformer-based policy, but the Q-function itself did not use a Transformer-based architecture. Our Q-function could in principle be combined with this method, but our focus is specifically on directly training Transformers to represent Q-values.
 Figure 2: Q-values update for each action dimension at timestep t. Given a history of states, we update the Q-values of all bins in all action dimensions. The Q-values of the discrete action bins of the dataset actions are trained via the Bellman update (green boxes). The values of action bins not observed in the dataset are minimized towards zero (red boxes). The Q-targets of all action dimensions except the last one are computed using maximization over the next action dimension within the same time step. The Q-target of the last action dimension is computed using the discounted maximization of the first dimension of the next time step plus the reward. We also incorporate Monte Carlo returns by taking the maximum of the computed Q-targets and the return-to-go.
To develop a Transformer-based Q-learning method, we discretize each action space dimension, with each dimension acting as a distinct time step. Autoregressive generation of discrete actions has been explored by Metz et al. [65], who propose a hierarchical decomposition of an MDP and then utilize LSTM [66] for autoregressive discretization. Our discretization scheme is similar but simpler, in that we do not use any hierarchical decomposition but simply treat each dimension as a time step. However, since our goal is to perform offline RL at scale with real-world image based tasks (vs. the smaller state-space tasks learned via online RL by Metz et al. [65]), we present a number of additional design decisions to impose a conservative regularizer, enabling training our Transformerbased offline Q-learning method at scale, providing a complete robotic learning system.
# 3 Background
In RL, we learn policies $\pi$ that maximizes the expected total reward in a Markov decision process (MDP) with states $s$ , actions $a$ , discount factor $\gamma \in \mathsf { \Gamma } ( 0 , 1 ]$ , transition function $T ( s ^ { \prime } | s , { \bar { a } } )$ and a reward function $R ( s , a )$ . Actions $a$ have dimensionality $d _ { \mathcal { A } }$ . Value-based RL approaches learn a Q-function $Q ( s , a )$ representing the total discounted return $\begin{array} { r } { \sum _ { t } \gamma ^ { t } R ( s _ { t } , a _ { t } ) } \end{array}$ , with policy $\pi ( a | s ) =$ arg maxa $Q ( s , a )$ . The Q-function can be learned by iteratively applying the Bellman operator [67]:
$$\mathcal { B } ^ { * } Q ( s _ { t } , a _ { t } ) = R ( s _ { t } , a _ { t } ) + \gamma \operatorname* { m a x } _ { a _ { t + 1 } } Q ( s _ { t + 1 } , a _ { t + 1 } ) ,$$
approximated via function approximation and sampling. The offline RL setting assumes access to an offline dataset of transitions or episodes, produced by some unknown behavior policy $\pi _ { \beta } ( a | s )$ , but does not assume the ability to perform additional online interaction during training. This is appealing for real-world robotic learning, where on-policy data collection is time-consuming. Learning from offline datasets requires addressing distributional shift, since in general the action that maximizes $Q ( s _ { t + 1 } , a _ { t + 1 } )$ might lie outside of the data distribution. One approach to mitigate this is to add a conservative penalty [29, 52] that pushes down the Q-values $Q ( s , a )$ for any action $a$ outside of the dataset, thus ensuring that the maximum value action is in-distribution.
 Figure 3: Q-Transformer network architecture, as applied to our multi-task language-conditioned robotic control setting. The encoding of the observations is concatenated with embeddings of the previous predicted action dimensions and processed by Transformer layers. We apply a sigmoid to the Transformer output to produce Q-values (normalized to lie in the range $[ 0 , 1 ] )$ for each of the action value bins. Finally, one-hot action vectors are constructed by taking the arg max over all bins and are fed back to the network to predict the Q-values of the next action dimensions. The language instruction is encoded with Universal Sentence Encoder [68] and then fed to FiLM EfficientNet [69, 70] network together with the robot camera images.
In this work, we consider tasks with sparse rewards, where a binary reward $R \in \{ 0 , 1 \}$ (indicating success or failure) is assigned at the last time step of episodes. Although our method is not specific to this setting, such reward structure is common in robotic manipulation tasks that either succeed or fail on each episode, and can be particularly challenging for RL due to the lack of reward shaping.
# 4 Q-Transformer
In this section, we introduce Q-Transformer, an architecture for offline Q-learning with Transformer models, which is based on three main ingredients. First, we describe how we apply discretization and autoregression to enable TD-learning with Transformer architectures. Next, we introduce a particular conservative Q-function regularizer that enables learning from offline datasets. Lastly, we show how Monte Carlo and $n$ -step returns can be used to improve learning efficiency.
# 4.1 Autoregressive Discrete Q-Learning
Using Transformers with Q-learning presents two challenges: (1) we must tokenize the inputs to effectively apply attention mechanisms, which requires discretizing the action space; (2) we must perform maximization of Q-values over discretized actions while avoiding the curse of dimensionality. Addressing these issues within the standard Q-learning framework requires new modeling decisions. The intuition behind our autoregressive Q-learning update is to treat each action dimension as essentially a separate time step. That way, we can discretize individual dimensions (1D quantities), rather than the entire action space, avoiding the curse of dimensionality. This can be viewed as a simplified version of the scheme proposed in [65], though we apply this to high-capacity Transformer models, extend it to the offline RL setting, and scale it up to real-world robotic learning.
Let $\tau = ( s _ { 1 } , a _ { 1 } , \dots , s _ { T } , a _ { T } )$ be a trajectory of robotic experience of length $T$ from an offline dataset $\mathcal { D }$ . For a given time-step $t$ , and the corresponding action $a _ { t }$ in the trajectory, we define a per-dimension view of the action $a _ { t }$ . Let $a _ { t } ^ { 1 : i }$ denote the vector of action dimensions from the first dimension $a _ { t } ^ { 1 }$ until the $i$ -th dimension $a _ { t } ^ { i }$ , where $i$ can range from 1 to the total number of action dimensions, that we denote as $d _ { \mathcal { A } }$ . Then, for a time window $w$ of state history, we define the Q-value of the action $a _ { t } ^ { i }$ in the $_ { i - t h }$ dimension using an autoregressive Q-function conditioned on states from this time window $s _ { t - w : t }$ and previous action dimensions for the current time step $a _ { t } ^ { 1 : i - 1 }$ . To train the Q-function, we define a per-dimension Bellman update. For all dimensions $i \in \{ \bar { 1 } , \ldots , d _ { A } \}$ :
$$Q ( s _ { t - w : t } , a _ { t } ^ { 1 : i - 1 } , a _ { t } ^ { i } ) \gets \left\{ \begin{array} { l l } { \operatorname* { m a x } _ { a _ { t } ^ { i + 1 } } Q ( s _ { t - w : t } , a _ { t } ^ { 1 : i } , a _ { t } ^ { i + 1 } ) } & { \mathrm { i f ~ } i \in \{ 1 , \dots , d _ { A } - 1 \} } \\ { a _ { t } ^ { i + 1 } } & { \mathrm { ~ i f ~ } i \in \{ 1 , \dots , d _ { A } \} } \end{array} \right.$$
The reward is only applied on the last dimension (second line in the equation), as we do not receive any reward before executing the whole action. In addition, we only discount Q-values between the time steps and keep discounting at 1.0 for all but the last dimension within each time step, to ensure the same discounting as in the original MDP. Figure 2 illustrates this process, where each yellow box represents the Q-target computation with additional conservatism and Monte Carlo returns described in the next subsections. It should be noted that by treating each action dimension as a time step for the Bellman update, we do not change the general optimization properties of Q-learning algorithms and the principle of the Bellman optimality still holds for a given MDP as we maximize over an action dimension given the optimality of all action dimensions in the future. We show that this approach provides a theoretically consistent way to optimize the original MDP in Appendix A, with a proof of convergence in the tabular setting in Appendix B.
# 4.2 Conservative Q-Learning with Transformers
Having defined a Bellman backup for running Q-learning with Transformers, we now develop a technique that enables learning from offline data, including human demonstrations and autonomously collected data. This typically requires addressing over-estimation due to the distributional shift, when the Q-function for the target value is queried at an action that differs from the one on which it was trained. Conservative Q-learning (CQL) [29] minimizes the Q-function on out-of-distribution actions, which can result in Q-values that are significantly smaller than the minimal possible cumulative reward that can be attained in any trajectory. When dealing with sparse rewards $R \in \{ 0 , 1 \}$ , results in [27] show that the Q-function regularized with a standard conservative objective can take on negative values, even though instantaneous rewards are all non-negative. This section presents a modified version of conservative Q-learning that addresses this issue in our problem setting.
The key insight behind our design is that, rather than minimizing the Q-values on actions not in the data, we can instead regularize these $\mathrm { Q }$ -values to be close to the minimal attainable possible cumulative reward. Concretely, denoting the minimal possible reward on the task as $R _ { \mathrm { m i n } }$ , and the time horizon of the task as $T$ , our approach regularizes the Q-values on actions not covered by the dataset towards $R _ { \operatorname* { m i n } } \cdot T$ , which in our problem setting is equal to 0 (i.e., $R _ { \mathrm { m i n } } = 0 .$ ). For simplicity of notation, we omit the action dimension indices in presenting the resulting objective, but remark that the training objective below is applied to Bellman backups on all action dimensions as described in the previous section. Let $\pi _ { \beta }$ be the behavioral policy that induced a given dataset $\mathcal { D }$ , and let $\begin{array} { r } { \tilde { \pi } _ { \beta } ( a | s ) = \frac { 1 } { Z ( s ) } \cdot ( 1 . 0 - \pi _ { \beta } ( a | \dot { s } ) ) } \end{array}$ be the distribution over all actions which have a very low density under $\pi _ { \beta } ( a | s )$ . Our objective to train the Q-function is:
$$J = \ \frac { 1 } { 2 } \underbrace { \mathbb { E } _ { s \sim \mathcal { D } , a \sim \pi _ { \beta } ( a | s ) } \left[ \left( Q ( s , a ) - B ^ { * } Q ^ { k } ( s , a ) \right) ^ { 2 } \right] } _ { ( i ) , \mathrm { ~ I D ~ e r r o r } } + \alpha \cdot \frac { 1 } { 2 } \underbrace { \mathbb { E } _ { s \sim \mathcal { D } , a \sim \pi _ { \beta } ( a | s ) } \left[ \left( Q ( s , a ) - 0 \right) ^ { 2 } \right] } _ { ( i i ) , \mathrm { ~ c o n s e r v a t i v e ~ r e g u l a r i z a t i o n ~ } \mathcal { L } _ { C } } ,$$
where the first term $( i )$ trains the Q-function by minimizing the temporal difference error objective as defined in Eq. 1, and the second term $( i i )$ regularizes the $\mathbf { Q }$ -values to the minimal possible $\mathrm { Q }$ - value of 0 in expectation under the distribution of actions induced by $\tilde { \pi } _ { \beta }$ , which we denote as a conservative regularization term $\mathcal { L } _ { C }$ . Term $( i i )$ is also weighted by a multiplier $\alpha$ , which modulates the strength of this conservative regularization. We discuss the choice of $\alpha$ in our implementation in Appendix D.2 and analyze the behavior of the conservatism term in Appendix C, providing a simple characterization of how this regularizer modifies the learned Q-function in tabular settings.
# 4.3 Improving Learning Efficiency with Monte Carlo and $n$ -step Returns
When the dataset contains some good trajectories (e.g., demonstrations) and some suboptimal trajectories (e.g., autonomously collected trials), utilizing Monte Carlo return-to-go estimates to accelerate Q-learning can lead to significant performance improvements, as the Monte Carlo estimates along the better trajectories lead to much faster value propagation. This has also been observed in prior work [31]. Based on this observation, we propose a simple improvement to Q-Transformer that we found to be quite effective in practice. The Monte Carlo return is defined by the cumulative reward within the offline trajectory $\begin{array} { r } { \tau \colon \mathbf { M } \mathbf { C } _ { t : T } = \sum _ { j = t } ^ { T } \gamma ^ { j - t } R ( s _ { j } , a _ { j } ) } \end{array}$ . This matches the Q-value of the behavior policy $\pi _ { \beta }$ , and since the optimal $Q ^ { * } ( s , a )$ is larger than the Q-value for any other policy, we have $Q ^ { * } ( s _ { t } , a _ { t } ) \geq \mathbf { M } \mathbf { C } _ { t : T }$ . Since the Monte Carlo return is a lower bound of the optimal Q-function, we can augment the Bellman update to take the maximum between the MC-return and the current Q-value: max $( \mathbf { M } \mathbf { C } _ { t : T } , Q ( s _ { t } , a _ { t } \mathbf { \bar { ) } } )$ , without changing what the Bellman update will converge to.
 Figure 4: Left: Real world manipulation tasks. Right: Real world performance comparison. RT-1 [1] is imitation learning on demonstrations. Q-Transformer (Q-T), Decision Transformer (DT) [32], Implicit Q-learning (IQL) [40] learn from both demonstrations and autonomous data.
Although this does not change convergence, including this maximization speeds up learning (see Section 5.3). We present a hypothesis why this occurs. In practice, $\mathrm { Q }$ -values for final timesteps $( s _ { T } , a _ { T } )$ are learned first and then propagated backwards in future gradient steps. It can take multiple gradients for the Q-value to propagate all the way to $( s _ { 1 } , a _ { 1 } )$ . The $\operatorname* { m a x } ( \mathbf { M C } , Q )$ allows us to apply useful gradients to $Q ( s _ { 1 } , a _ { 1 } )$ at the start of training before the $\mathbf { Q }$ -values have propagated.
In our experiments, we also notice that additionally employing $n$ -step returns [71, 72] over action dimensions can significantly help with the learning speed. We pick $n$ such that the final Q-value of the last dimension of the next time step is used as the Q-target. This is because we get a new state and reward only after inferring and executing the whole action as opposed to parts of it, meaning that intermediate rewards remain 0 all the way until the last action dimension. While this introduces bias to the Bellman backups, as is always the case with off-policy learning with $n$ -step returns, we find in our ablation study in Section 5.3 that the detrimental effects of this bias are small, while the speedup in training is significant. This is consistent with previously reported results [72]. More details about our Transformer sequence model architecture (depicted in Figure 3) conservative Qlearning implementation, and the robot system can be found in Appendix D.
# 5 Experiments
In our experiments, we aim to answer the following questions: (1) Can Q-Transformer learn from a combination of demonstrations and sub-optimal data? (2) How does Q-Transformer compare to other methods? (3) How important are the specific design choices in Q-Transformer? (4) Can QTransformer be applied to large-scale real world robotic manipulation problems?
# 5.1 Real-world language-conditioned manipulation evaluation
Training dataset. The offline data used in our experiments was collected with a fleet of 13 robots, and consists of a subset of the demonstration data described by Brohan et al. [1], combined with lower quality autonomously collected data. The demonstrations were collected via human teleoperation for over 700 distinct tasks, each with a separate language description. We use a maximum of 100 demonstrations per task, for a total of about 38,000 demonstrations. All of these demonstrations succeed on their respective tasks and receive a reward of 1.0. The rest of the dataset was collected by running the robots autonomously, executing policies learned via behavioral cloning.
To ensure a fair comparison between Q-Transformer and imitation learning methods, we discard all successful episodes in the autonomously collected data when we train our method, to ensure that by including the autonomous data the Q-Transformer does not get to observe more successful trials than the imitation learning baselines. This leaves us with about 20,000 additional autonomously collected failed episodes, each with a reward of 0.0, for a dataset size of about 58,000 episodes. The episodes are on average 35 time steps in length. Examples of the tasks are shown in Figure 4.
Performance evaluation. To evaluate how well Q-Transformer can perform when learning from real-world offline datasets while effectively incorporating autonomously collected failed episodes, we evaluate Q-Transformer on 72 unique manipulation tasks, and a variety of different skills, such as βdrawer pick and placeβ, βopen and close drawerβ, βmove object near targetβ, each consisting of 18, 7 and 48 unique tasks instructions respectively to specify different object combinations and drawers. As such, the average success rate in Table 4 is the average over 72 tasks.
Since each task in the training set only has a maximum of 100 demonstrations, we observe from Figure 4 that an imitation learning algorithm like RT-1 [1], which also uses a similar Transformer architecture, struggles to obtain a good performance when learning from only the limited pool of successful robot demonstrations. Existing offline RL methods, such as IQL [40] and a Transformerbased method such as Decision Transformer [32], can learn from both successful demonstrations and failed episodes, and show better performance compared to RT-1, though by a relatively small margin. Q-Transformer has the highest success rate and outperforms both the behavior cloning baseline (RT-1) and offline RL baselines (Decision Transformer, IQL), exceeding the average performance of the best-performing prior method by about $70 \%$ . This demonstrates that Q-Transformer can effectively improve upon human demonstrations using autonomously collected sub-optimal data.
Appendix G also shows that Q-Transformer can be successfully applied in combination with a recently proposed language task planner [8] to perform both affordance estimation and robot action execution. Q-Transformer outperforms prior methods for planning and executing long-horizon tasks.
# 5.2 Benchmarking in simulation
In this section, we evaluate Q-Transformer on a challenging simulated offline RL task that require incorporating sub-optimal data to solve the task. In particular, we use a visual simulated picking task depicted in Figure 5, where we have a small amount of position controlled human demonstrations ${ \sim } 8 \%$ of the data). The demonstrations are replayed with noise to generate more trajectories ( ${ \sim } 9 2 \%$ of the data). Figure 5 shows a comparison to several offline algorithms, such as QT-Opt with CQL [11, 29], IQL [40], AW-Opt [73], and Decision Transformer [32], along with RT-1 using Behavioral Cloning [1] on demonstrations only. As we see, algorithms that can effectively perform TDlearning to combine optimal and sub-optimal data (such as Q-Transformer and QT-Opt) perform better than others. BC with RT-1 is not
 Figure 5: Performance comparison on a simulated picking task.
able to take advantage of sub-optimal data. Decision Transformer is trained on both demonstrations and sub-optimal data, but is not able to leverage the noisy data for policy improvement and does not end up performing as well as our method. Although IQL and AW-Opt perform TD-learning, the actor remains too close to the data and can not fully leverage the sub-optimal data. Q-Transformer is able to both bootstrap the policy from demonstrations and also quickly improve through propagating information with TD-learning. We also analyze the statistical significance of the results by training with multiple random seeds in Appendix F.
# 5.3 Ablations
We perform a series of ablations of our method design choices in simulation, with results presented in Figure 6 (left). First, we demonstrate that our choice of conservatism for Q-Transformer performs better than the standard CQL regularizer, which corresponds to a softmax layer on top of the Q-function outputs with a cross-entropy loss between the dataset action and the output of this softmax [29]. This regularizer plays a similar role to the one we propose, decreasing the Q-values for out-of-distribution actions and staying closer to the behavior policy.
As we see in Figure 6 (left), performance with softmax conservatism drops to around the fraction of demonstration episodes $( \sim 8 \% )$ . This suggests a collapse to the behavior policy as the conservatism penalty becomes too good at constraining to the behavior policy distribution. Due to the nature of the softmax, pushing Q-values down for unobserved actions also pushes Q-values up for the observed actions, and we theorize this makes it difficult to keep Q-values low for sub-optimal in-distribution actions that fail to achieve high reward. Next, we show that using conservatism is important. When removing conservatism entirely, we observe that performance collapses. Actions that are rare in the dataset will have overestimated Q-values, since they are not trained by the offline Q-learning procedure. The resulting overestimated values will propagate and collapse the entire Q-function, as described in prior work [38]. Finally, we ablate the Monte-Carlo returns and again observe performance collapse. This demonstrates that adding information about the sampled future returns significantly helps in bootstrapping the training of large architectures such as Transformers.
 Figure 6: Left: Ablations: changing to softmax conservatism decreases performance. Removing MC returns or conservatism completely collapse performance. Top Right: The $n$ -step return version of our method reaches similar performance to the standard version with 4 times fewer steps, indicating that the added bias from $n$ -step returns is small compared to the gain in training speed. Using $n$ -step return also leads to better performance on tasks that have longer horizon, e.g. move object near target. Bottom Right: Success rates on real world task categories with a larger dataset.
<table><tr><td>n-step ablation</td><td>n-step 1-step</td><td>1-step</td></tr><tr><td># of gradient steps Training duration (hours)</td><td>137480 582960 32 163</td><td>136920 40</td></tr><tr><td>pick object move object near target</td><td>94% 88%</td><td>97% 92% 80% 67%</td></tr><tr><td>Large offline dataset</td><td>Q-T DT</td><td>RT-1</td></tr><tr><td>Average success rate</td><td>88% 78%</td><td>82%</td></tr></table>
We also ablate the choice of $n$ -step returns from the Section 4.3 on real robots and observe that using $n$ -step returns leads to a significantly faster training speed as measured by the number of gradient steps and wall clock time compared to using 1-step returns, with a minimal loss in performance, as shown in Figure 6 (top right).
# 5.4 Massively scaling up Q-Transformer
The experiments in the previous section used a large dataset that included successful demonstrations and failed autonomous trials, comparable in size to some of the largest prior experiments that utilized demonstration data [74, 15, 58]. We also carry out a preliminary experiment with a much larger dataset to investigate the performance of Q-Transformer as we scale up the dataset size.
This experiment includes all of the data collected with 13 robots and comprises of the demonstrations used by RT-1 [1] and successful autonomous episodes, corresponding to about 115,000 successful trials, and an additional 185,000 failed autonomous episodes, for a total dataset size of about 300,000 trials. Model architecture and hyperparameters were kept exactly the same, as the computational cost of the experiment made further hyperparameter tuning prohibitive (in fact, we only train the models once). Note that with this number of successful demonstrations, even standard imitation learning with the RT-1 architecture already performs very well, attaining $82 \%$ success rate. However, as shown in Figure 6 (bottom right), Q-Transformer was able to improve even on this very high number. This experiment demonstrates that Q-Transformer can continue to scale to extremely large dataset sizes, and continues to outperform both imitation learning with RT-1 and Decision Transformer.
# 6 Limitations and Discussion
In this paper, we introduced the Q-Transformer, an architecture for offline reinforcement learning with high-capacity Transformer models that is suitable for large-scale multi-task robotic RL. Our framework does have several limitations. First, we focus on sparse binary reward tasks corresponding to success or failure for each trial. While this setup is reasonable for a broad range of episodic robotic manipulation problems, it is not universal, and we expect that Q-Transformer could be extended to more general settings as well in the future.
Second, the per-dimension action discretization scheme that we employ may become more cumbersome in higher dimensions (e.g., controlling a humanoid robot), as the sequence length and inference time for our model increases with action dimensionality. Although $n$ -step returns mitigate this to a degree, the length of the sequences still increases with action dimensionality. For such higherdimensional action space, adaptive discretization methods might also be employed, for example by training a discrete autoencoder model and reducing representation dimensionality. Uniform action discretization can also pose problems for manipulation tasks that require a large range of motion granularities, e.g. both coarse and fine movements. In this case, adaptive discretization based on the distribution of actions could be used for representing both types of motions.
Finally, in this work we concentrated on the offline RL setting. However, extending Q-Transformer to online finetuning is an exciting direction for future work that would enable even more effective autonomous improvement of complex robotic policies.
References [1] A. Brohan, N. Brown, J. Carbajal, Y. Chebotar, J. Dabis, C. Finn, K. Gopalakrishnan, K. Hausman, A. Herzog, J. Hsu, et al. Rt-1: Robotics transformer for real-world control at scale. arXiv preprint arXiv:2212.06817, 2022. [2] Y. Jiang, A. Gupta, Z. Zhang, G. Wang, Y. Dou, Y. Chen, L. Fei-Fei, A. Anandkumar, Y. Zhu, and L. Fan. Vima: General robot manipulation with multimodal prompts. arXiv preprint arXiv:2210.03094, 2022. [3] A. Gupta, L. Fan, S. Ganguli, and L. Fei-Fei. Metamorph: Learning universal controllers with transformers. arXiv preprint arXiv:2203.11931, 2022. [4] M. Shridhar, L. Manuelli, and D. Fox. Perceiver-actor: A multi-task transformer for robotic manipulation. arXiv preprint arXiv:2209.05451, 2022. [5] N. M. M. Shafiullah, Z. J. Cui, A. Altanzaya, and L. Pinto. Behavior transformers: Cloning $k$ modes with one stone. arXiv preprint arXiv:2206.11251, 2022. [6] S. Reed, K. Zolna, E. Parisotto, S. G. Colmenarejo, A. Novikov, G. Barth-Maron, M. Gimenez, Y. Sulsky, J. Kay, J. T. Springenberg, et al. A generalist agent. arXiv preprint arXiv:2205.06175, 2022. [7] M. Shridhar, L. Manuelli, and D. Fox. Cliport: What and where pathways for robotic manipulation. In Proceedings of the 5th Conference on Robot Learning (CoRL), 2021. [8] M. Ahn, A. Brohan, N. Brown, Y. Chebotar, O. Cortes, B. David, C. Finn, K. Gopalakrishnan, K. Hausman, A. Herzog, et al. Do as I can, not as I say: Grounding language in robotic affordances. arXiv preprint arXiv:2204.01691, 2022. [9] D.-A. Huang, Y.-W. Chao, C. Paxton, X. Deng, L. Fei-Fei, J. C. Niebles, A. Garg, and D. Fox. Motion reasoning for goal-based imitation learning. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 4878β4884. IEEE, 2020. [10] D. Shah, A. Sridhar, A. Bhorkar, N. Hirose, and S. Levine. Gnm: A general navigation model to drive any robot. arXiv preprint arXiv:2210.03370, 2022. [11] D. Kalashnikov, A. Irpan, P. Pastor, J. Ibarz, A. Herzog, E. Jang, D. Quillen, E. Holly, M. Kalakrishnan, V. Vanhoucke, et al. Scalable deep reinforcement learning for vision-based robotic manipulation. In Conference on Robot Learning, pages 651β673. PMLR, 2018. [12] A. X. Lee, C. M. Devin, Y. Zhou, T. Lampe, K. Bousmalis, J. T. Springenberg, A. Byravan, A. Abdolmaleki, N. Gileadi, D. Khosid, et al. Beyond pick-and-place: Tackling robotic stacking of diverse shapes. In 5th Annual Conference on Robot Learning, 2021. [13] S. Cabi, S. G. Colmenarejo, A. Novikov, K. Konyushkova, S. Reed, R. Jeong, K. Zolna, Y. Aytar, D. Budden, M. Vecerik, et al. Scaling data-driven robotics with reward sketching and batch reinforcement learning. arXiv preprint arXiv:1909.12200, 2019. [14] 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, 2021. [15] A. Kumar, A. Singh, F. Ebert, Y. Yang, C. Finn, and S. Levine. Pre-training for robots: Offline rl enables learning new tasks from a handful of trials. arXiv preprint arXiv:2210.05178, 2022. [16] L. P. Kaelbling. Learning to achieve goals. In R. Bajcsy, editor, IJCAI, pages 1094β1099. Morgan Kaufmann, 1993. ISBN 1-55860-300-X. [17] Y. Chebotar, K. Hausman, Y. Lu, T. Xiao, D. Kalashnikov, J. Varley, A. Irpan, B. Eysenbach, R. Julian, C. Finn, et al. Actionable models: Unsupervised offline reinforcement learning of robotic skills. arXiv preprint arXiv:2104.07749, 2021. [18] T. Schaul, D. Horgan, K. Gregor, and D. Silver. Universal value function approximators. In F. Bach and D. Blei, editors, Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, pages 1312β1320, Lille, France, 07β09 Jul 2015. PMLR. [19] M. Andrychowicz, D. Crow, A. Ray, J. Schneider, R. Fong, P. Welinder, B. McGrew, J. Tobin, P. Abbeel, and W. Zaremba. Hindsight experience replay. In Advances in Neural Information Processing Systems, pages 5048β5058, 2017. [20] K. Fang, A. Toshev, L. Fei-Fei, and S. Savarese. Scene memory transformer for embodied agents in long-horizon tasks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 538β547, 2019. [21] P. Anderson, A. X. Chang, D. S. Chaplot, A. Dosovitskiy, S. Gupta, V. Koltun, J. Kosecka, J. Malik, R. Mottaghi, M. Savva, and A. R. Zamir. On evaluation of embodied navigation agents. CoRR, abs/1807.06757, 2018. URL http://dblp.uni-trier.de/db/ journals/corr/corr1807.html#abs-1807-06757. [22] P. Anderson, Q. Wu, D. Teney, J. Bruce, M. Johnson, N. Sunderhauf, I. D. Reid, S. Gould, Β¨ and A. van den Hengel. Vision-and-language navigation: Interpreting visually-grounded navigation instructions in real environments. CoRR, abs/1711.07280, 2017. URL http: //arxiv.org/abs/1711.07280. [23] P. Mirowski, R. Pascanu, F. Viola, H. Soyer, A. J. Ballard, A. Banino, M. Denil, R. Goroshin, L. Sifre, K. Kavukcuoglu, D. Kumaran, and R. Hadsell. Learning to navigate in complex environments. CoRR, abs/1611.03673, 2016. URL http://dblp.uni-trier.de/db/ journals/corr/corr1611.html#MirowskiPVSBBDG16. [24] Y. Zhu, R. Mottaghi, E. Kolve, J. J. Lim, A. Gupta, L. Fei-Fei, and A. Farhadi. Target-driven visual navigation in indoor scenes using deep reinforcement learning. In ICRA, pages 3357β 3364. IEEE, 2017. ISBN 978-1-5090-4633-1. URL http://dblp.uni-trier.de/db/ conf/icra/icra2017.html#ZhuMKLGFF17. [25] T. Yu, D. Quillen, Z. He, R. Julian, K. Hausman, C. Finn, and S. Levine. Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In Conference on robot learning, pages 1094β1100. PMLR, 2020. [26] J. Fu, A. Kumar, O. Nachum, G. Tucker, and S. Levine. D4rl: Datasets for deep data-driven reinforcement learning. arXiv preprint arXiv:2004.07219, 2020. [27] A. Kumar, A. Singh, S. Tian, C. Finn, and S. Levine. A workflow for offline model-free robotic reinforcement learning. arXiv preprint arXiv:2109.10813, 2021. [28] R. S. Sutton and A. G. Barto. Introduction to Reinforcement Learning. MIT Press, Cambridge, MA, USA, 1st edition, 1998. ISBN 0262193981. [29] A. Kumar, A. Zhou, G. Tucker, and S. Levine. Conservative q-learning for offline reinforcement learning. Advances in Neural Information Processing Systems, 33:1179β1191, 2020. [30] 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. [31] A. Wilcox, A. Balakrishna, J. Dedieu, W. Benslimane, D. S. Brown, and K. Goldberg. Monte carlo augmented actor-critic for sparse reward deep reinforcement learning from suboptimal demonstrations. In A. H. Oh, A. Agarwal, D. Belgrave, and K. Cho, editors, Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum? id=FLzTj4ia8BN. [32] 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. Advances in neural information processing systems, 34:15084β15097, 2021. [33] K.-H. Lee, O. Nachum, M. Yang, L. Lee, D. Freeman, W. Xu, S. Guadarrama, I. Fischer, E. Jang, H. Michalewski, et al. Multi-game decision transformers. arXiv preprint arXiv:2205.15241, 2022. [34] N. Jaques, A. Ghandeharioun, J. H. Shen, C. Ferguson, A. Lapedriza, N. Jones, S. Gu, and R. Picard. Way off-policy batch deep reinforcement learning of implicit human preferences in dialog. arXiv preprint arXiv:1907.00456, 2019. [35] Y. Wu, G. Tucker, and O. Nachum. Behavior regularized offline reinforcement learning. arXiv preprint arXiv:1911.11361, 2019. [36] X. B. Peng, A. Kumar, G. Zhang, and S. Levine. Advantage-weighted regression: Simple and scalable off-policy reinforcement learning. arXiv preprint arXiv:1910.00177, 2019. [37] N. Y. Siegel, J. T. Springenberg, F. Berkenkamp, A. Abdolmaleki, M. Neunert, T. Lampe, R. Hafner, and M. Riedmiller. Keep doing what worked: Behavioral modelling priors for offline reinforcement learning. arXiv preprint arXiv:2002.08396, 2020. [38] A. Kumar, J. Fu, M. Soh, G. Tucker, and S. Levine. Stabilizing off-policy q-learning via bootstrapping error reduction. In Advances in Neural Information Processing Systems, pages 11761β11771, 2019. [39] I. Kostrikov, J. Tompson, R. Fergus, and O. Nachum. Offline reinforcement learning with fisher divergence critic regularization. arXiv preprint arXiv:2103.08050, 2021. [40] I. Kostrikov, A. Nair, and S. Levine. Offline reinforcement learning with implicit q-learning. arXiv preprint arXiv:2110.06169, 2021. [41] Z. Wang, A. Novikov, K. ZoΕna, J. T. Springenberg, S. Reed, B. Shahriari, N. Siegel, J. Merel, Λ C. Gulcehre, N. Heess, et al. Critic regularized regression. arXiv preprint arXiv:2006.15134, 2020. [42] S. Fujimoto and S. S. Gu. A minimalist approach to offline reinforcement learning. arXiv preprint arXiv:2106.06860, 2021. [43] X. Chen, Z. Zhou, Z. Wang, C. Wang, Y. Wu, and K. Ross. Bail: Best-action imitation learning for batch deep reinforcement learning, 2019. URL https://arxiv.org/abs/1910. 12179. [44] H. Furuta, Y. Matsuo, and S. S. Gu. Generalized decision transformer for offline hindsight information matching. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $=$ CAjxVodl_v. [45] Y. Jang, J. Lee, and K.-E. Kim. GPT-critic: Offline reinforcement learning for end-to-end taskoriented dialogue systems. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ qaxhBG1UUaS. [46] L. Meng, M. Wen, Y. Yang, chenyang le, X. yun Li, H. Zhang, Y. Wen, W. Zhang, J. Wang, and B. XU. Offline pre-trained multi-agent decision transformer, 2022. URL https:// openreview.net/forum?id=W08IqLMlMer. [47] P. Daoudi, M. Barlier, L. D. Santos, and A. Virmaux. Density estimation for conservative q-learning, 2022. URL https://openreview.net/forum?id $=$ liV-Re74fK. [48] L. Liu, Z. Tang, L. Li, and D. Luo. Robust imitation learning from corrupted demonstrations, 2022. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } }$ UECzHrGio7i. [49] A. Mandlekar, D. Xu, J. Wong, S. Nasiriany, C. Wang, R. Kulkarni, F.-F. Li, S. Savarese, Y. Zhu, and R. MartΒ΄Δ±n-MartΒ΄Δ±n. What matters in learning from offline human demonstrations for robot manipulation. In 5th Annual Conference on Robot Learning, 2021. URL https: //openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ JrsfBJtDFdI. [50] A. Kumar, J. Hong, A. Singh, and S. Levine. When should we prefer offline reinforcement learning over behavioral cloning? arXiv preprint arXiv:2204.05618, 2022. [51] A. Singh, A. Kumar, Q. Vuong, Y. Chebotar, and S. Levine. Offline rl with realistic datasets: Heteroskedasticity and support constraints. arXiv preprint arXiv:2211.01052, 2022. [52] Q. Vuong, A. Kumar, S. Levine, and Y. Chebotar. DASCO: Dual-generator adversarial support constrained offline reinforcement learning. In A. H. Oh, A. Agarwal, D. Belgrave, and K. Cho, editors, Advances in Neural Information Processing Systems, 2022. URL https://openreview.net/forum?id ${ . } = { }$ jBTQGGy9qA-. [53] J. Li, X. Zhan, H. Xu, X. Zhu, J. Liu, and Y.-Q. Zhang. Distance-sensitive offline reinforcement learning. arXiv preprint arXiv:2205.11027, 2022. [54] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ε. Kaiser, and I. Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017. [55] Y. Zhang and J. Chai. Hierarchical task learning from language instructions with unified transformers and self-monitoring. arXiv preprint arXiv:2106.03427, 2021. [56] A. Pashevich, C. Schmid, and C. Sun. Episodic transformer for vision-and-language navigation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 15942β15952, 2021. [57] A. Silva, N. Moorman, W. Silva, Z. Zaidi, N. Gopalan, and M. Gombolay. Lancon-learn: Learning with language to enable generalization in multi-task manipulation. IEEE Robotics and Automation Letters, 7(2):1635β1642, 2021. [58] 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, 2021. [59] S. Nair, E. Mitchell, K. Chen, S. Savarese, C. Finn, et al. Learning language-conditioned robot behavior from offline data and crowd-sourced annotation. In Conference on Robot Learning, pages 1303β1315. PMLR, 2022. [60] M. Janner, Q. Li, and S. Levine. Reinforcement learning as one big sequence modeling problem. In ICML 2021 Workshop on Unsupervised Reinforcement Learning, 2021. [61] A. Kumar, X. B. Peng, and S. Levine. Reward-conditioned policies. arXiv preprint arXiv:1912.13465, 2019. [62] R. K. Srivastava, P. Shyam, F. Mutz, W. Jaskowski, and J. Schmidhuber. Training agents using Β΄ upside-down reinforcement learning. arXiv preprint arXiv:1912.02877, 2019. [63] D. Brandfonbrener, A. Bietti, J. Buckman, R. Laroche, and J. Bruna. When does returnconditioned supervised learning work for offline reinforcement learning? arXiv preprint arXiv:2206.01079, 2022. [64] T. Yamagata, A. Khalil, and R. Santos-Rodriguez. Q-learning decision transformer: Leveraging dynamic programming for conditional sequence modelling in offline rl, 2023. [65] L. Metz, J. Ibarz, N. Jaitly, and J. Davidson. Discrete sequential prediction of continuous actions for deep rl. CoRR, abs/1705.05035, 2017. URL http://dblp.uni-trier.de/ db/journals/corr/corr1705.html#MetzIJD17. [66] S. Hochreiter and J. Schmidhuber. Long Short-Term Memory. 9(8):1735β1780, 1997. [67] R. S. Sutton and A. G. Barto. Reinforcement learning: An introduction. Second edition, 2018. [68] D. Cer, Y. Yang, S.-y. Kong, N. Hua, N. Limtiaco, R. S. John, N. Constant, M. GuajardoCespedes, S. Yuan, C. Tar, et al. Universal sentence encoder. arXiv preprint arXiv:1803.11175, 2018. [69] E. Perez, F. Strub, H. De Vries, V. Dumoulin, and A. Courville. Film: Visual reasoning with a general conditioning layer. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018. [70] M. Tan and Q. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International conference on machine learning, pages 6105β6114. PMLR, 2019. [71] R. S. Sutton. Learning to predict by the methods of temporal differences. Machine learning, 3 (1):9β44, 1988. [72] M. Hessel, J. Modayil, H. Van Hasselt, T. Schaul, G. Ostrovski, W. Dabney, D. Horgan, B. Piot, M. Azar, and D. Silver. Rainbow: Combining improvements in deep reinforcement learning. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018. [73] Y. Lu, K. Hausman, Y. Chebotar, M. Yan, E. Jang, A. Herzog, T. Xiao, A. Irpan, M. Khansari, D. Kalashnikov, and S. Levine. Aw-opt: Learning robotic skills with imitation andreinforcement at scale. In 5th Annual Conference on Robot Learning, 2021. [74] S. Dasari and A. Gupta. Transformers for one-shot visual imitation. In Conference on Robot Learning, pages 2071β2084. PMLR, 2021. [75] C. J. Watkins and P. Dayan. Q-learning. Machine Learning, 8:279β292, 1992. [76] 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. [77] A. Chowdhery, S. Narang, J. Devlin, M. Bosma, G. Mishra, A. Roberts, P. Barham, H. W. Chung, C. Sutton, S. Gehrmann, P. Schuh, K. Shi, S. Tsvyashchenko, J. Maynez, A. Rao, P. Barnes, Y. Tay, N. Shazeer, V. Prabhakaran, E. Reif, N. Du, B. Hutchinson, R. Pope, J. Bradbury, J. Austin, M. Isard, G. Gur-Ari, P. Yin, T. Duke, A. Levskaya, S. Ghemawat, S. Dev, H. Michalewski, X. Garcia, V. Misra, K. Robinson, L. Fedus, D. Zhou, D. Ippolito, D. Luan, H. Lim, B. Zoph, A. Spiridonov, R. Sepassi, D. Dohan, S. Agrawal, M. Omernick, A. M. Dai, T. S. Pillai, M. Pellat, A. Lewkowycz, E. Moreira, R. Child, O. Polozov, K. Lee, Z. Zhou, X. Wang, B. Saeta, M. Diaz, O. Firat, M. Catasta, J. Wei, K. Meier-Hellstern, D. Eck, J. Dean, S. Petrov, and N. Fiedel. Palm: Scaling language modeling with pathways, 2022. URL https://arxiv.org/abs/2204.02311.
# A Proof of MDP optimization consistency
To show that transforming MDP into a per-action-dimension form still ensures optimization of the original MDP, we show that optimizing the Q-function for each action dimension is equivalent to optimizing the Q-function for the full action.
If we consider the full action $a _ { 1 : d _ { \mathcal { A } } }$ and that we switch to the state $s ^ { \prime }$ at the next timestep, the Qfunction for optimizing over the full action MDP would be:
$$\begin{array} { r l } & { \underset { a _ { 1 : d _ { \cal A } } } { \operatorname* { m a x } } Q ( s , a _ { 1 : d _ { \cal A } } ) = \underset { a _ { 1 : d _ { \cal A } } } { \operatorname* { m a x } } \left[ R ( s , a _ { 1 : d _ { \cal A } } ) + \gamma \underset { a _ { 1 : d _ { \cal A } } } { \operatorname* { m a x } } Q ( s ^ { \prime } , a _ { 1 : d _ { \cal A } } ) \right] } \\ & { \quad \quad \quad \quad = R ( s , a _ { 1 : d _ { \cal A } } ^ { * } ) + \gamma \underset { a _ { 1 : d _ { \cal A } } } { \operatorname* { m a x } } Q ( s ^ { \prime } , a _ { 1 : d _ { \cal A } } ) , } \end{array}$$
where $R ( s , a _ { 1 : d _ { A } } ^ { * } )$ is the reward we get after executing the full action.
The optimization over each action dimension using our Bellman update is:
$$\begin{array} { r l } { \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \delta , \epsilon } ^ { \star } , \eta _ { \epsilon } \in \mathcal { G } _ { \epsilon - 1 } \sim \mathcal { G } _ { \epsilon } ^ { \star } } } & { = - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon } ^ { \star } \cup \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon } ^ { \star } } } \\ & { = \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon } ^ { \star } \cup \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon + 1 , \epsilon - 1 } } } \\ & { = \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon } ^ { \star } \cup \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { F } _ { \epsilon } \cup \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { F } _ { \epsilon } \cap \mathcal { G } _ { \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon + 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { - \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon + 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & { = \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon + 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } + \operatorname* { m a x } _ { \mathbf { x } \in \mathcal { G } _ { \epsilon + 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 , \epsilon - 1 } } } \\ & - \operatorname* { m a x } _ \ \end{array}$$
which optimizes the original full action MDP as in Eq. 3.
# B Proof of convergence
Convergence of Q-learning has been shown in the past [67, 75]. Below we demonstrate that per-action dimension Q-function converges as well, by providing a proof almost identical to the standard $\mathrm { Q }$ -learning convergence proof, but extended to account for the per-action dimension maximization.
Let $d _ { \mathcal { A } }$ be the dimensionality of the action space, $a$ indicates a possible sequence of actions, whose dimension is not necessarily equal to the dimension of the action space. That is:
$$a \in \{ a _ { 1 : i } , \forall i \leq d _ { A } \}$$
To proof convergence, we can demonstrate that the Bellman operator applied to the per-action dimension Q-function is a contraction, i.e.:
$$| | \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) | | _ { \infty } \leq c | | Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) | | _ { \infty } ,$$
where
$$B ^ { \ast } Q ( s , a ) = \left\{ \begin{array} { l l } { R ( s , a ) + \gamma \displaystyle \operatorname* { m a x } _ { a ^ { \prime } } Q ( s , a , a ^ { \prime } ) } & { \mathrm { i f ~ t h e ~ d i m e n s i o n ~ o f ~ } a \mathrm { ~ i s ~ l e s s ~ t h a n ~ } d \mathcal { A } } \\ { R ( s , a ) + \gamma \displaystyle \operatorname* { m a x } _ { a ^ { \prime } } \frac { E } { s ^ { \prime } } [ Q ( s ^ { \prime } , a ^ { \prime } ) ] } & { \mathrm { i f ~ t h e ~ d i m e n s i o n ~ o f ~ } a \mathrm { ~ i s ~ e q u a l ~ t o ~ } d \mathcal { A } } \end{array} \right.$$
$a ^ { \prime }$ is the next action dimension following the sequence $a , s ^ { \prime }$ is the next state of the MDP, $\gamma$ is the discounting factor, and $0 \leq c \leq 1$ .
Proof: We can show that this is the case as follows:
Case 1: For action sequence whose dimension is less than the dimension of the action space.
$$\begin{array} { r l } & { \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) } \\ & { \quad = R ( s , a ) + \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } Q _ { 1 } ( s , a , a ^ { \prime } ) - R ( s , a ) - \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } Q _ { 2 } ( s , a , a ^ { \prime } ) } \\ & { \quad = \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } [ Q _ { 1 } ( s , a , a ^ { \prime } ) - Q _ { 2 } ( s , a , a ^ { \prime } ) ] } \\ & { \quad \le \gamma \underset { s , a } { \operatorname* { s u p } } [ Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) ] } \\ & { \quad \Longrightarrow | | \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) | | _ { \infty } \le \gamma | | Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) | | _ { \infty } } \end{array}$$
where $\operatorname { s u p } _ { s , a }$ is the supremum over all action sequences, with $0 \leq \gamma \leq 1$ and $\| f \| _ { \infty } = \operatorname* { s u p } _ { x } [ f ( x ) ]$ .
Case 2: For action sequence whose dimension is equal to the dimension of the action space
$$\begin{array} { r l } & { \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) } \\ & { \ = R ( s , a ) + \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } E [ Q _ { 1 } ( s ^ { \prime } , a ^ { \prime } ) ] - R ( s , a ) - \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } E [ Q _ { 2 } ( s ^ { \prime } , a ^ { \prime } ) ] } \\ & { \ = \gamma \underset { a ^ { \prime } } { \operatorname* { m a x } } E [ Q _ { 1 } ( s ^ { \prime } , a ^ { \prime } ) - Q _ { 2 } ( s ^ { \prime } , a ^ { \prime } ) ] } \\ & { \ \leq \gamma \underset { s , a } { \operatorname* { s u p } } [ Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) ] } \\ & { \ \Longrightarrow \ | | \mathcal { B } ^ { * } Q _ { 1 } ( s , a ) - \mathcal { B } ^ { * } Q _ { 2 } ( s , a ) | | _ { \infty } \leq \gamma | | Q _ { 1 } ( s , a ) - Q _ { 2 } ( s , a ) | | _ { \infty } } \end{array}$$
# C Analysis of the conservatism term
With the goal of understanding the behavior of our training procedure, we theoretically analyze the solution obtained by Eq. 2 for the simpler cases when $Q$ is represented as a table, and when the objective in Eq. 2 can be minimized exactly. We derive the minimizer of the objective in Eq. 2 by differentiating $J$ with respect to $Q$ :
$$\begin{array} { r l } & { \forall s , a , k , \frac { d J } { d Q ( s , a ) } = 0 } \\ & { \pi _ { \beta } ( a | s ) \left( Q ( s , a ) - B ^ { * } Q ^ { k } ( s , a ) \right) + \alpha \tilde { \pi } _ { \beta } ( a | s ) Q ( s , a ) = 0 } \\ & { Q ( s , a ) \left( \pi _ { \beta } ( a | s ) + \alpha \tilde { \pi } _ { \beta } ( a | s ) \right) = \pi _ { \beta } ( a | s ) B ^ { * } Q ^ { k } ( s , a ) } \\ & { Q ^ { k + 1 } ( s , a ) = \underbrace { \pi _ { \beta } ( a | s ) } _ { : = m ( s , a ) } . } \end{array}$$
Eq. 4 implies that training with the objective in Eq. 2 performs a weighted Bellman backup: unlike the standard Bellman backup, training with Eq. 2 multiplies large Q-value targets by a weight $m ( s , a )$ . This weight $m ( s , a )$ takes values between 0 and 1, with larger values close to 1 for indistribution actions where $( s , a ) \in \mathcal { D }$ , and very small values close to 0 for out-of-distribution actions $a$ at any state $s$ (i.e., actions where $\pi _ { \beta } ( a | s )$ is small). Thus, the Bellman backup induced via Eq. 4 should effectively prevent over-estimation of Q-values for unseen actions.
# D Q-Transformer Architecture & System
In this section, we describe the architecture of Q-Transformer as well as the important implementation and system details that make it an effective Q-learning algorithm for real robots.
# D.1 Transformer sequence model architecture
Our neural network architecture is shown in Figure 3. The architecture is derived from the RT-1 design [1], adapted to accommodate the Q-Transformer framework, and consists of a Transformer backbone that reads in images via a convolutional encoder followed by tokenization. Since we apply Q-Transformer to a multi-task robotic manipulation problem where each task is specified by a natural language instruction, we first embed the natural language instruction into an embedding vector via the Universal Sentence Encoder [68]. The embedding vector and images from the robot camera are then converted into a sequence of input tokens via a FiLM EfficientNet [69, 70]. In the standard RT-1 architecture [1], the robot action space is discretized and the Transformer sequence model outputs the logits for the discrete action bins per dimension and per time step. In this work, we extend the network architecture to use Q-learning by applying a sigmoid activation to the output values for each action, and interpreting the resulting output after the sigmoid as Q-values. This representation is particularly suitable for tasks with sparse per-episode rewards $R \in [ 0 , 1 ]$ , since the Q-values may be interpreted as probabilities of task success and should always lie in the range $[ 0 , 1 ]$ . Note that unlike the standard softmax, this interpretation of Q-values does not prescribe normalizing across actions (i.e., each action output can take on any value in $[ 0 , 1 ] )$ ).
Since our robotic system, described in Section D.3, has 8-dimensional actions, we end up with 8 dimensions per time step and discretize each one into $N = 2 5 6$ value bins. Our reward function is a sparse reward that assigns value 1.0 at the last step of an episode if the episode is successful and 0.0 otherwise. We use a discount rate $\gamma = 0 . 9 8$ . As is common in deep RL, we use a target network to estimate target Q-values $Q ^ { k }$ , using an exponential moving average of $Q$ -network weights to update the target network. The averaging constant is set to 0.01.
# D.2 Conservative Q-learning implementation
The conservatism penalty in Section 4.2 requires estimating expectations under $\pi _ { \beta } ( a | s )$ and $\tilde { \pi } _ { \beta } ( a | s ) \propto ( 1 - \pi _ { \beta } ( \bar { a } | s ) )$ , with the latter being especially non-trivial to estimate. We employ a simple and crude approximation that we found to work well in practice, replacing $\pi _ { \beta } ( a | s )$ with the empirical distribution corresponding, for each sampled state-action tuple $( s _ { j } , a _ { j } ) \in \mathcal { D }$ , to a Dirac delta centered on $a _ { j }$ , such that $\pi _ { \beta } ( { \bar { a } } | s _ { j } ) = \delta ( a = { \bar { a } } _ { j } )$ . This results in a simple expression for $\tilde { \pi } _ { \beta } ( a | s _ { j } )$ corresponding to the uniform distribution over all other actions, such that ${ \tilde { \pi } } _ { \beta } ( a | s _ { j } ) \propto \delta ( a \stackrel { . } { \neq } a _ { j } )$ . After discretizing the actions, there are $N - 1$ bins per dimension to exhaustively iterate over when computing the conservatism term in Eq. 2, which is the same as taking the average over targets for all unseen action values. In our experiments, we find that simply setting the conservatism weight to $\alpha = 1 . 0$ worked best, without additional tuning.
# D.3 Robot system overview
The robot that we use in this work is a mobile manipulator with a 7-DOF arm with a 2 jaw parallel gripper, attached to a mobile base with a head-mounted RGB camera, illustrated in Figure 1. The RGB camera provides a $6 4 0 \times 5 1 2$ RGB image, which is downsampled to $3 2 0 \times 2 5 6$ before being consumed by the Q-Transformer. See Figure 4 for images from the robot camera view. The learned policy is set up to control the arm and the gripper of the robot. Our action space consists of 8 dimensions: 3D position, 3D orientation, gripper closure command, and an additional dimension indicating whether the episode should terminate, which the policy must trigger to receive a positive reward upon successful task completion. Position and orientation are relative to the current pose, while the gripper command is the absolute closedness fraction, ranging from fully open to fully closed. Orientation is represented via axis-angles, and all actions except whether to terminate are continuous actions discretized over their full action range in 256 bins. The termination action is binary, but we pad it to be the same size as the other action dimensions to avoid any issues with unequal weights. The policy operates at $3 \ : \mathrm { H z }$ , with actions executed asynchronously [76].
Algorithm 1 Temporal difference error and loss computation for one action dimension i at timestep $t$ , $\hat { a } _ { t } ^ { i }$ .
Input Sequence of state in time window of size $w$ , $s _ { t - w : t }$ Input Language embedding of task instruction $l$ . Input The state at timestep $t + 1$ , $s _ { t + 1 }$ . Input Dataset action up to dimension $i$ , $\{ \boldsymbol { \mathcal { D } } \boldsymbol { a } _ { t } ^ { j } \} _ { j = 0 } ^ { i }$ . Output The loss to optimize Q-Transformer.
${ Q } ^ { t a r g } \gets$ Compute maximum Q-values of the next action dimension using Eq. 1 // Compute the maximum between $\mathsf { Q }$ -target and Monte Carlo return. $Q ^ { t a r g } \gets \mathrm { m a x } ( \mathbf { M } \mathbf { C } , Q ^ { t a r g } )$
// Compute the temporal difference error. $\mathrm { T D E r r o r } = \frac { 1 } { 2 } ( \mathrm { Q } \mathrm { - } \mathrm { T r a n s f o r m e r } ( l , s _ { t - w : t } , \{ a ^ { j } \} _ { j = 1 } ^ { i } ) - Q ^ { t a r g } ) ^ { 2 }$
// Compute the conservative regularizer. // The sum is over all action bins not equal to the tokenized dataset action. // $N$ is the number of discretization bin. $\mathrm { R e g } = \frac { 1 } { 2 ( N - 1 ) } \sum _ { a \neq _ { \mathscr D } a _ { t } ^ { i } } \left( \mathrm { Q } \mathrm { - T r a n s f o r m e r } ( l , s _ { t - w : t } , \{ a ^ { j } \} _ { j = 1 } ^ { i - 1 } \cup \{ a \} ) \right) ^ { 2 }$ // Compute the loss function $\mathcal { L } = \mathrm { T D E r r o r } + \mathrm { R e g }$
Return $\mathcal { L }$ as the loss function to optimize Q-Transformer with.
# E Pseudo-code
Algorithm 1 shows the loss computation for training each action dimension of the Q-Transformer. We first use Eq. 1 to compute the maximum Q-values over the next action dimensions. Then we compute the Q-target for the given dataset action by using the Bellman update with an additional maximization over the Monte-Carlo return and predicted maximum Q-value at the next time step. The TD-error is then computed using the Mean-Squared Error. Finally, we set a target of 0 for all discretized action bins except the dataset action and add the averaged Mean-Squared Error over these dimensions to the TD-Error, which results in the total loss $\mathcal { L }$ .
# F Running training for multiple random seeds
 Figure 7: Mean and variance of Q-Transformer and RT-1 performance in simulation when running the training for 5 different random seeds.
In addition to performing a large amount of evaluations, we also analyze the statistical significance of our learning results by running our training of Q-Transformer and RT-1 on multiple seeds in simulation. In particular, we run the training for 5 random seeds in Figure 7. As we can see, QTransformer retains its improved performance across the distribution of the random seeds.
# G Q-Transformer value function with a language planner experiments
 Figure 8: Qualitative comparisons of Q-values from QT-Opt (sim-to-real) and Q-Transformer. QTransformer outputs sharper Q-values for objects close to the robot, which can be grasped faster and more easily than the objects farther away.
Recently, the SayCan algorithm [8] was proposed as a way to combine large language models (LLMs) with learned policies and value functions to solve long-horizon tasks. In this framework, the value function for each available skill is used to determine the βaffordanceβ of the current state for that skill, and a large language model then selects from among the available affordances to take a step towards performing some temporally extended task. For example, if the robot is commanded to bring all the items on a table, the LLM might propose a variety of semantically meaningful items, and select from among them based on the item grasping skill that currently has a high value (corresponding to items that the robot thinks it can grasp). SayCan uses QT-Opt in combination with sim-to-real transfer to train Q-functions for these affordances. In the following set of experiments, we demonstrate that the Q-Transformer outperforms QT-Opt for affordance estimation without using any sim-to-real transfer, entirely using the real world dataset that we employ in the preceding experiments.
We first benchmark Q-Transformer on the problem of correctly estimating task affordances from the RT-1 dataset [1]. In addition to the standard training on demonstrations and autonomous data, we introduce a training with relabeling, which we found particularly useful for affordance estimation. During relabeling, we sample a random alternate task for a given episode. We relabel the task name of the episode to the newly sampled task, and set reward to 0.0. This ensures that the boundaries between tasks are more clearly learned during train
<table><tr><td>Model</td><td>Precision</td><td>Recall</td><td>F1</td></tr><tr><td>QT-Opt (sim-to-real)</td><td>0.61</td><td>0.68</td><td>0.64</td></tr><tr><td>Q-T w/ relabel</td><td>0.76</td><td>0.89</td><td>0.82</td></tr><tr><td>Q-T w/o relabel</td><td>0.58</td><td>0.93</td><td>0.71</td></tr></table>
Table 1: Affordance estimation comparison: precision, recall and F1 score when using Q-values to determine if a task is feasible. Q-Transformer (Q-T) with multitask relabeling consistently produces better affordance estimates.
ing. Table 1 shows comparison of performance of our model with and without relabeling as well as the sim-to-real QT-Opt model used in SayCan [8]. Both of our models outperform the QT-Opt model on F1 score, with the relabeled model outperforming it by a large margin. This demonstrates that our Q-function can be effectively used for affordance estimation, even without training with sim-to-real transfer. Visualization of the Q-values produced by our Q-function can be found in Figure 8.
We then use Q-Transformer in a long horizon SayCan style evaluation, replacing both the sim-to-real QT-Opt model for affordance estimation, and the RT-1 policy for low-level robotic control. During this evaluation, a PaLM language model [77] is used to propose task candidates given a user query. Q-values are then used to pick the task candidate with the highest affordance score, which is then executed on the robot using the execution policy. The $\mathrm { Q } \mathrm { - }$ Transformer used for affordance estimation is trained with relabeling. The QTransformer used for low-level control is
Table 2: Performance on SayCan style long-horizon tasks: SayCan queries $Q ( s , \bar { a } )$ in planning to pick a language instruction, then runs a policy to execute the plan. Q-Transformer outperforms RT-1 with QT-Opt in both planning and execution.
<table><tr><td colspan="2">Method</td><td colspan="2">Success Rate</td></tr><tr><td>Affordance</td><td>Execution Planning</td><td></td><td>Execution</td></tr><tr><td>Q-T w/ relabel QT-Opt (sim-to-real)</td><td>Q-T RT-1</td><td>93 87</td><td>93 67</td></tr></table>
trained without relabeling, since we found relabeling episodes at the task level did not improve execution performance. SayCan with Q-Transformer is better at both planning the sequence of tasks and executing those plans, as illustrated in Table 2.
# H Real robotic manipulation tasks used in our evaluation
We include the complete list of evaluation tasks in our real robot experiments below.
Drawer pick and place: pick 7up can from top drawer and place on counter, place 7up can into top drawer, pick brown chip bag from top drawer and place on counter, place brown chip bag into top drawer, pick orange can from top drawer and place on counter, place orange can into top drawer, pick coke can from middle drawer and place on counter, place coke can into middle drawer, pick orange from middle drawer and place on counter, place orange into middle drawer, pick green rice chip bag from middle drawer and place on counter, place green rice chip bag into middle drawer, pick blue plastic bottle from bottom drawer and place on counter, place blue plastic bottle into bottom drawer, pick water bottle from bottom drawer and place on counter, place water bottle into bottom drawer, pick rxbar blueberry from bottom drawer and place on counter, place rxbar blueberry into bottom drawer.
Open and close drawer: open top drawer, close top drawer, open middle drawer, close middle drawer, open bottom drawer, close bottom drawer.
Move object near target: move 7up can near apple, move 7up can near blue chip bag, move apple near blue chip bag, move apple near 7up can, move blue chip bag near 7up can, move blue chip bag near apple, move blue plastic bottle near pepsi can, move blue plastic bottle near orange, move pepsi can near orange, move pepsi can near blue plastic bottle, move orange near blue plastic bottle, move orange near pepsi can, move redbull can near rxbar blueberry, move redbull can near water bottle, move rxbar blueberry near water bottle, move rxbar blueberry near redbull can, move water bottle near redbull can, move water bottle near rxbar blueberry, move brown chip bag near coke can, move brown chip bag near green can, move coke can near green can, move coke can near brown chip bag, move green can near brown chip bag, move green can near coke can, move green jalapeno chip bag near green rice chip bag, move green jalapeno chip bag near orange can, move green rice chip bag near orange can, move green rice chip bag near green jalapeno chip bag, move orange can near green jalapeno chip bag, move orange can near green rice chip bag, move redbull can near sponge, move sponge near water bottle, move sponge near redbull can, move water bottle near sponge, move 7up can near blue blastic bottle, move 7up can near green can, move blue plastic bottle near green can, move blue plastic bottle near 7up can, move green can near 7up can, move green can near blue plastic bottle, move apple near brown chip bag, move apple near green jalapeno chip bag, move brown chip bag near green jalapeno chip bag, move brown chip bag near apple, move green jalapeno chip bag near apple, move green jalapeno chip bag near brown chip bag.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386# REWARD DESIGN WITH LANGUAGE MODELS
Minae Kwon, Sang Michael Xie, Kalesha Bullardβ , Dorsa Sadigh Stanford University, DeepMindβ {minae, xie, dorsa}@cs.stanford.edu, ksbullard@deepmind.comβ
# ABSTRACT
Reward design in reinforcement learning (RL) is challenging since specifying human notions of desired behavior may be difficult via reward functions or require many expert demonstrations. Can we instead cheaply design rewards using a natural language interface? This paper explores how to simplify reward design by prompting a large language model (LLM) such as GPT-3 as a proxy reward function, where the user provides a textual prompt containing a few examples (few-shot) or a description (zero-shot) of the desired behavior. Our approach leverages this proxy reward function in an RL framework. Specifically, users specify a prompt once at the beginning of training. During training, the LLM evaluates an RL agentβs behavior against the desired behavior described by the prompt and outputs a corresponding reward signal. The RL agent then uses this reward to update its behavior. We evaluate whether our approach can train agents aligned with user objectives in the Ultimatum Game, matrix games, and the DEALORNODEAL negotiation task. In all three tasks, we show that RL agents trained with our framework are well-aligned with the userβs objectives and outperform RL agents trained with reward functions learned via supervised learning. Code and prompts can be found here.
# 1 INTRODUCTION
Autonomous agents are becoming increasingly capable with the rise of compute and data. This underscores the importance for human users to be able to control what policies the agents learn and ensure the policies are aligned with their objectives. For instance, imagine training an agent to represent users in a salary negotiation. A working mother fighting for a livable wage may want their agent to be stubborn whereas a new hire looking to develop a good relationship with the company may want their agent to be more versatile.
Currently, users specify desired behaviors by 1) designing reward functions or 2) providing large amounts of labeled data. Both approaches are challenging and impractical for different reasons. Designing reward functions is not an intuitive way to specify preferences. For instance, it isnβt straightforward how to write a reward function for a βversatileβ negotiator. Furthermore, designing reward functions that balance between different objectives β also known as the βreward design problemβ β is notoriously difficult because agents are susceptible to reward hacking (Amodei et al., 2016; Hadfield-Menell et al., 2017). On the other hand, one can learn a reward function from labeled examples. However, that is not possible with a single example; we need large amounts of labeled data to capture the nuances of different usersβ preferences and objectives, which has shown to be costly (Zhang et al., 2016). Additionally, both approaches do not generalize well to new users who have different objectives β we would have to re-design our reward functions or re-collect data.
Our aim is to create an easier way for users to communicate their preferences, where the interface is more intuitive than crafting a reward function and where they can cheaply specify their preferences with no more than a few examples. To do this, we leverage large language models (LLMs) that are trained on internet-scale text data and have shown an impressive ability to learn in-context from few or zero examples (Brown et al., 2020). Our key insight is that
The scale of data that LLMs have been trained on make them great in-context learners and also allows them to capture meaningful commonsense priors about human behavior. Given a few examples or a description demonstrating the userβs objective, an LLM should be able to provide an accurate instantiation of reward values on a new test example, allowing for easier generalization to new objectives.
To this end, we explore how to prompt an LLM as a proxy reward function to train RL agents from user inputs. In our approach, the user specifies an objective with a natural language prompt. Objectives can be specified with a few examples when they are difficult to define (such as βversatilityβ) or as a single phrase when they are well-known concepts (such as βPareto-optimalityβ). We use the prompt and the LLM to define a reward function for training an RL agent. The LLM takes the user prompt and a trajectory from an RL episode as input and outputs a score (e.g., βNoβ or $\ " { } 0 \ " { }$ ) for whether the trajectory satisfies the userβs objective, which we parse as an integer reward for the RL agent (Figure 1).
 Figure 1: Depiction of our framework on the DEALORNODEAL negotiation task. A user provides an example and explanation of desired negotiating behavior (e.g., versatility) before training. During training, (1) we provide the LLM with a task description, a userοΏ½οΏ½s description of their objective, an outcome of an episode that is converted to a string, and a question asking if the outcome episode satisfies the user objective. (2-3) We then parse the LLMβs response back into a string and use that as the reward signal for the Alice the RL agent. (4) Alice updates their weights and rolls out a new episode. (5) We parse the episode outcome int a string and continue training. During evaluation, we sample a trajectory from Alice and evaluate whether it is aligned with the userβs objective.
There are two advantages to prompting LLMs as a proxy reward function: (1) we can leverage LLMβs in-context learning abilities and prior knowledge on human behavior so that users only need to provide a handful of example desirable behaviors and (2) users can specify their preferences intuitively using language. On the other hand, a potential disadvantage is that it is unclear how much prompt design will be required for the LLM to reliably infer user intent (see Sec. 5 for a discussion). The goal of this paper is to explore how well LLMs can train objective-aligned agents by providing reward signals, and empirically examine whether we can do so with no more than a few examples. Our contributions are as follows:
β’ We introduce the idea of using LLMs as a proxy reward function. β’ We propose a general RL training framework that leverages this proxy reward and is agnostic to the RL algorithm used. β’ We show that an LLM can more accurately train objective-aligned RL agents by an average of $3 5 \%$ compared the baseline. We use few-shot prompting for the Ultimatum Game and DEALORNODEAL negotiation task as well as zero-shot prompting in Matrix Games. β’ We conduct a pilot study with 10 human users. Users rate our agent to be significantly more aligned with their objective than an agent trained with a different one, $p { < } 0 . 0 0 1$ . β’ We provide further analysis quantifying the amount of user data required for our approach as well as the effect varying prompts has on the LLMβs reward signal accuracy.
# 2 RELATED WORK
Using Language for Reward Shaping. Recent Reinforcement Learning from Human Feedback (RLHF) works Ouyang et al. (2022); Bai et al. (2022) use LLMs as rewards by fine-tuning them on large amounts of user data. Our work does not fine-tune LLMs but uses in-context learning from only a handful of user data.
Several works Goyal et al. (2019); Carta et al. (2022); Mirchandani et al. (2021) shape rewards by training an RL agent to learn and complete intermediate tasks guided by language. In contrast, our framework does not focus on generating subtasks but leverages the in-context learning abilities of an LLM to determine whether an agentβs policy satisfies the higher-level task.
RL and Foundation Models. We leverage large language models such as GPT-3 (Brown et al., 2020) to learn a proxy reward function while avoiding the need for many expert demonstrations. Ahn et al. (2022); Huang et al. (2022) use an LLM to provide a plan which guides a robot with reasonable/feasible actions towards a human goal (e.g., with enumerating subtasks). In contrast, our work is different in that we are using an LLM to identify if a behavior satisfies βhard-to-specifyβ properties of a humanβs objective and also offers users more control over how they want their policy to be executed. In the vision domain, Parisi et al. (2022) used pre-trained vision models as a feature extractor for the learned policy, but not to design a reward signal. In a similar spirit of leveraging self-supervised pre-training to design a flexible reward function, Chen et al. (2021) use a broad dataset of human videos and a small dataset of robot videos to train a reward function, which improves generalization to new environments and tasks. The interface for the desired task is a video of the task to be completed, instead of text in our framework, and the domain is restricted to robot tasks. More related works can be found in Sec. A.2.
# 3 USING LLMS AS A REWARD SIGNAL
Our goal is to use an LLM as a proxy reward function to train objective-aligned RL agents from user inputs. We formalize the task using a Markov Decision Process $\mathcal { M } { = } \langle S , \mathcal { A } , p , \mathcal { R } , \gamma \rangle$ , where $s$ is the state space (e.g., in DEALORNODEAL, the space of representations of utterances in the negotiation so far), $\mathcal { A }$ is the action space (e.g., set of all possible utterances), $p { : } S \times \mathcal { A } \times \mathcal { S } [ 0 , 1 ]$ is the transition probability, and $\gamma$ is the discount factor. Traditionally the reward function maps states and actions to a real number $\mathcal { R } : \mathcal { S } \times \mathcal { A } \mathbb { R }$ In our work, we use an LLM as a proxy reward function that takes in a text prompt and outputs a string. We define $A ^ { * }$ to be the set of all strings, $\rho \in A ^ { * }$ as our text prompt (input to the LLM) and the LLM as a function $L L M { \mathrel { : } } A ^ { * } { \mathrel { \to } } A ^ { * }$ . As illustrated in Fig. 1, the prompt $\rho$ is a concatenation of four components including a string to describe the task $\rho _ { 1 } \in A ^ { * }$ and a user-specified string that describes their objectives using examples or a description, $\rho _ { 2 } \in A ^ { * }$ . Additionally, we include a textual description of states and actions from an RL episode, $\rho _ { 3 }$ , using a parser $f : { \cal S } \times { \cal A } { \cal A } ^ { * }$ . $\rho _ { 3 }$ can describe the final state, final action, a trajectory, or any other representation of the episode. Finally, we include a question $\rho _ { 4 } \in A ^ { * }$ that asks whether the RL agentβs behavior, $\rho _ { 3 }$ , satisfies the userβs objective, $\rho _ { 2 }$ . We define an additional parser $g \colon A ^ { * } \to \{ 0 , 1 \}$ that maps the textual output of $L L M$ to a binary value. We use this as the reward signal. Our framework replaces the traditional reward function with a proxy reward, $L L M$ , and can be used with any RL training algorithm.
Our framework is depicted in Fig. 1. Before training, a user specifies $\rho _ { 2 }$ which can be $N$ examples describing their objective or a description of their objective using natural language. In Fig. 1 a user provides an example of their objective: versatile negotiating behavior. During training, we construct a prompt $\rho$ by concatenating a description of the task, the user-specified examples/description, an episodeβs outcome, and a question asking if the outcome satisfies the objective. We (1) feed the prompt to the LLM, (2) take its output, and (3) parse it into an integer using function $g$ ; we use a handcrafted, task-specific parser. We use the integer as the reward signal. (4) The RL agent then updates its weights and rolls out an episode. (5) We parse the episode outcome into a string using $f$ and continue training; we also instantiate $f$ as handcrafted, task-specific parser. To evaluate our framework, we sample a trajectory (e.g., a negotiation) from the agent and evaluate whether the trajectory is aligned with the userβs objective (e.g., whether Alice demonstrated versatile negotiating behavior).
# 4 EXPERIMENTS
In this section we investigate three questions to determine the feasibility and efficacy of our approach: (Q1) Can LLMs produce reward signals that are consistent with user objectives from a few examples (few-shot prompting)? (Q2) When objectives are well-known, can LLMs produce objective-consistent reward signals without any examples (zero-shot prompting)? (Q3) Can LLMs provide objective-aligned reward signals from examples (few-shot prompting) in more complex, longer-horizon domains? We evaluate our approach on three tasks: the Ultimatum Game, 2-player Matrix Games, and the DEALORNODEAL negotiation task (Lewis et al., 2017). We address (Q1) using the Ultimatum Game. We use Matrix Games to address (Q2) because it has well-known solution concepts such as Pareto-optimality. The
DEALORNODEAL negotiation task is a longer-horizon domain where the LLM rewards agents for negotiating in a user-specified style; we address (Q3) in this task.
In practice, we do not have access to ground truth user reward functions β this is the function that we are trying to approximate. However, for most of our experiments, we assume access to the true reward by constructing user reward functions that humans have been shown to have inspired by prior work. We use the true rewards only to evaluate our frameworkβs performance. Finally, we include a pilot user study where we evaluate agent performance when we do not have access to the ground truth reward. We use the βtext-davinci-002β GPT-3 model with temperature 0 as our LLM and our results are reported across 3 random seeds. Details on how we trained RL agents for each task are in A.4. s
Evaluation Metrics. We evaluate our approach using the following metrics across our tasks (task-specific metrics are described within each subsection):
Labeling Accuracy. We construct ground-truth reward functions for each domain. We report the mean accuracy of predictions of the reward value during RL training with respect to the ground-truth reward functions. This assesses how effectively the LLM can produce reward signals that are consistent with the userβs objective.
RL Agent Accuracy. After RL training, we evaluate the learned policy with respect to the ground truth reward functions. We report the mean accuracy of RL agents.
# Baselines.
SL (Few-shot baseline). A supervised learning (SL) model trained to predict reward signals using the same examples given to the LLM in our framework. Examples are represented using structured non-text inputs, making it an easier problem for the SL model. This baseline only applies to tasks where we use few-shot prompting (Ultimatum Game, DEALORNODEAL). See A.5 for details on training and model architecture for each task.
No Objective (Zero-shot baseline). In our zero-shot task, Matrix Games, we do not use any examples so we do not use SL as a baseline. Instead, we use a No Objective baseline where we prompt the LLM without using the userβs description of their objective to isolate the effect the description has on the LLMβs response.
RL trained with Ground Truth Reward Functions. RL agents trained with ground truth reward functions. We use this as an oracle.
4.1 ULTIMATUM GAME: TRAINING OBJECTIVE-ALIGNED AGENTS WITH FEW-SHOT PROMPTING
When defining a precise objective is difficult, we can instead give a few examples of desired behavior. For instance, in a resource division game like the Ultimatum Game, it may be difficult for a user to specify the exact percentage (such as $3 2 . 4 \%$ ) of resources they would be happy with receiving. Instead it could be easier for a user to give examples of splits that they would be happy with. We explore whether LLMs can produce reward signals that are consistent with user objectives from a few examples in the Ultimatum Game.
Task Description. The Ultimatum Game consists of two players, a Proposer and a Responder. A sum of money is endowed to the Proposer and they must propose a way to split the endowment with the Responder. The Responder can accept or reject the proposed split. If the Responder accepts, players receive money as per the split; if the Responder rejects, then both players get nothing. We train an RL agent to play the Responder. The agent learns to reject proposals according to a userβs preferences. The game consists of a single timestep and our RL agents are trained using DQN for 1e4 steps.
Ground Truth User Objectives. A rational Responder would accept any proposal, even if it is unfair because getting something is better than getting nothing (in fact, this is a Nash Equilibrium of the game). However, prior work in behavioral economics shows that humans are willing to βpunishβ the Proposer by rejecting unfair proposals (Vavra et al., 2018). For instance, a student may reject an unfair proposal only if she receives less than $30 \%$ of the endowment whereas a wealthier person may reject if they receive less than $60 \%$ . We experiment with the following preferences:
β’ Low vs High Percentages. Users will reject proposals if they receive less than $( 3 0 \%$ , $6 0 \% \}$ of the endowment. β’ Low vs High Payoffs. Users will reject unfair proposals if they receive less than $\{ \$ 10,4100 \}$ . They accept unfair proposals otherwise.
 Figure 2: Ultimatum Game, Few-shot. (Top) Accuracy of reward signals provided by LLM and SL during RL training when prompted with/trained on 10 vs 1 example. (Bottom) Corresponding accuracy of RL agents after training. LLM is able to maintain a high accuracy when prompted with a single example followed by an explanation. We do not provide figures of Inequity Aversion because both LLM and SL trivially achieve perfect labeling and RL agent accuracy.
β’ Inequity Aversion (Fehr & Schmidt (2010)). Users will reject proposals if they do not receive exactly $5 0 \%$ of the endowment.
Prompt Design. We describe a userβs objective using 10 examples of the Ultimatum Game. An example consists of the proposed split, the Responderβs action, and a βyes/noβ label of whether the Responderβs action was desirable or undesirable. These examples do not have explanations and resemble a traditional dataset used for supervised learning. We also experiment with using a single example followed by a short explanation. Importantly, we do not explicitly mention the userβs ground truth objective in the prompt. See Fig. 10 in the Appendix for an example of both types of prompts.
Design Procedure. We randomly generated 10 proposed splits used for our prompt and sampled one proposal from the set for our single-example case. For Low vs High Percentages and Low vs High Payoffs, we used the same set of proposals across variants (i.e., same proposals for $30 \%$ and $60 \%$ ) and $( \$ 10$ , $\$ 100)$ ). We also randomly generated 50 proposals used to evaluate the LLM. Due to limited resources when querying GPT-3, we query the modelβs responses to the 50 evaluation splits in a batched manner and save them. We then use those responses as the reward signal.
# 4.1.1 RESULTS
Labeling Accuracy. We evaluated our approach on our test set of 50 proposals over 3 seeds; results are shown in Fig. $\cdot$ . When prompted with 10 examples without explanations, the LLM and SL perform similarly well (see Fig. 2, top row). This result is not surprising, given that the decision boundary for the binary decision tasks is relatively simple to learn with 10 training examples.
Instead, if we prompt the LLM with a single example followed by an explanation, it maintains a high accuracy whereas SL trained on the same, single example drops in accuracy. We did not use the explanation as part of input when training SL because it only takes non-textual inputs. This result highlights the advantage of using an LLM over a supervised learning model: they require far fewer examples because they can learn from explanations (Lampinen et al., 2022). We find that explanations are critical, as removing explanations when prompting the LLM with a single example results in a drop in LLM labeling accuracy (avg. drop of $3 1 . 6 7 \%$ ) and a drop in RL agent accuracy (avg. drop of $2 8 . 8 \%$ ).
RL Agent Accuracy. The accuracy of the trained RL agents mirror the labeling accuracy.
Summary. LLMs are efficient in-context learners. They are able to provide reward signals that are consistent with a userβs objectives from examples β even a single example with an explanation will suffice.
4.2 MATRIX GAMES: TRAINING OBJECTIVE-ALIGNED AGENTS WITH ZERO-SHOT PROMPTING
When objectives are well-known concepts such as Pareto-optimality, can we prompt the LLM without giving any examples? We hypothesize that well-known objectives are likely to be in-distribution for LLMs, and thus LLMs may be able to produce objective-aligned reward signals from zero-shot prompting. Since we do not use examples, we do not use a SL baseline. Instead we use a baseline No Objective where we do not mention any objectives and ask the LLM for a reward signal (see example in Fig. 11 in the Appendix). This baseline evaluates whether the LLM can successfully apply its knowledge of each objective.
 Figure 3: Matrix Games, Zero-shot. (Top) Accuracy of reward signals provided by LLM and a No Objective baseline during RL training. We report results for both regular and scrambled versions of matrix games. (Bottom) Accuracy of RL agents after training.
Task Description. We consider two-player normal-form matrix games: Battle of the Sexes, Stag Hunt, Chicken, and Prisonerβs Dilemma. Each matrix game has four joint outcomes (i.e., a tuple of joint actions and rewards) and we address pure strategies in this task. The game consists of a single timestep and our RL agents are trained using DQN for 500 steps.
Ground Truth User Objectives. Although (mixed) Nash Equilibria are traditional solution concepts for normal form matrix games, users may prefer a solution for other properties. For instance, in Prisonerβs Dilemma, users may prefer both agents to cooperate because they will maximize total welfare even though it is not a Pure Nash Equilibrium. We experiment with four well-known solution concepts (or objectives):
β’ Total Welfare. Outcomes that achieve the greatest sum of player rewards. β’ Equality. Outcomes that result in equal rewards between players. β’ Rawlsian Fairness. Outcomes that maximize the minimum reward any player receives. β’ Pareto-optimality. Outcomes where the one of the corresponding rewards cannot be improved without lowering the other.
Prompt Design. Prompts for each solution concept are shown in Fig. 11 in the Appendix. Due to limited resources with querying GPT-3, we queried GPT-3 in a batched manner and saved the corresponding labels to train our RL agents. Our prompt enumerates the outcomes of a matrix game and then asks the LLM for the outcome(s) that satisfy a solution concept. We do not mention the name of the matrix game in the prompt. As in Kojima et al. (2022), we elicit intermediate reasoning steps by asking the LLM to βthink step-by-stepβ and provide a definition of the solution concept. To prevent any bias the LLM may have towards the order in which the outcomes of a matrix game are presented, we also randomly scramble associations between joint actions and rewards (example shown in Fig. 12 in the Appendix).
Design Procedure. We tuned the wording of our prompt (e.g., how to describe the matrix game, whether or not to use chain-of-thought prompting) on the Battle of the Sexes matrix game to find a prompt that gave us accurate results. During evaluation, we kept the structure of our prompt the same for all of the matrix games.
# 4.2.1 RESULTS
Labeling Accuracy. Given that each game can have many outcomes that satisfy a solution concept, we report the LLMβs accuracy if its response does not include any incorrect outcomes. If the LLM identifies any incorrect outcome, we report a score of 0. The LLM produces more objective-aligned reward signals with zero-shot prompting by applying its knowledge of well-known objectives, improving the labeling accuracy over having no objective by $48 \%$ on average with a regular ordering of matrix game outcomes and $36 \%$ with a scrambled order. Scrambling the order of matrix game outcomes in the prompt lowers accuracy for most solution concepts. We suspect that this is because the matrix games are well-known and likely to have been in the LLMβs training set, where each joint action is usually associated with particular payoffs. Scrambling the associations between joint actions and payoffs could make the matrix game more out-of-distribution for the LLM, and thus lower accuracy.
RL Agent Accuracy. Compared to labeling accuracy, it is easier for the resulting RL agents to be accurate because they only need to learn one correct outcome, not all of them. Thus, LLMs that only identify one out of two correct outcomes can still train objective-aligned RL agents. Results are shown on the bottom row of Fig. 3. RL agents trained using rewards from the LLM receive perfect accuracy for Total Welfare and Equality and $7 5 \%$ accuracy for the other two objectives. The baseline receives lower accuracy for all objectives.
Does the LLM Correctly Identify Each Objective? As part of our prompt, we ask the LLM to provide a definition of the objective before reasoning about whether an outcome satisfies the objective (see Fig. 11 in the Appendix). Table 2 in the Appendix shows how the LLM defines each objective zero-shot. The LLM is able to successfully recall the definitions for each objective except for Rawlsian Fairness β it gets it partially correct. However, the LLM varies in its ability to reason whether an outcome of a game satisfies the objective, which explains why the LLM does not receive perfect labeling accuracy for all objectives.
Summary. An LLM is able to identify well-known objectives and provide objective-aligned reward signals in a zero-shot setting.
# 4.3 DEALORNODEAL: TRAINING OBJECTIVE-ALIGNED AGENTS IN MULTI-TIMESTEP TASKS
We have shown that an LLM can provide objective-aligned reward signals in single-timestep tasks. In longer horizon tasks we must give trajectories instead of states as examples in our prompts. Longer prompts can be challenging because it is less likely for an LLM to have seen them during training. LLMs also have a recency bias which makes it harder for them to remember context introduced earlier on (Zhao et al., 2021). Can an LLM provide objective-aligned signals in longer horizon tasks? We investigate this question in the DEALORNODEAL negotiation task (Lewis et al., 2017).
Task Description. DEALORNODEAL is a long-horizon task with a maximum length of 100 timesteps. An agent Alice must come to an agreement with her partner Bob on the allocation of a set of objects (books, hats, and balls). Agents are shown a context, which includes the counts of each item and their private utilities for each item. In the original task, agents get rewarded based on the agreed upon split and their utilities. If Alice and Bob reach a disagreement, both agents get nothing. We train Alice using on-policy RL by negotiating against a fixed partner model, which we refer to as Bob. See Sec. A.4 for more details on the domain and training.
Ground Truth User Objectives. We train Alice to negotiate in different styles. For this experiment, we assume we have access to precise definitions in order to evaluate our models. Importantly, we do not give definitions of each style to the LLM, only examples. We experiment with the following negotiation styles inspired by previous literature Sycara et al. (1997); Caputo et al. (2019):
β’ Versatile. Alice does not suggest the same proposal more than once. β’ Push-Over. Alice gets less points than Bob. β’ Competitive. Alice gets more points than Bob. β’ Stubborn. Alice repeatedly suggests the same proposal.
Prompt Design. We describe user objectives using three examples. Each example contains a negotiation between Alice and Bob, a question asking whether Alice negotiated in a particular style, and a yes or no answer followed by a short explanation. For an example, see Fig. 13 in the Appendix.
Design Procedure. To create example negotiations, we randomly sampled three negotiation contexts for each objective and trained an RL agent (using the original task reward, without the LLM) to negotiate against $B o b$ in these contexts. We then sampled negotiations from the trained model. We also made sure all three sampled negotiations did not have the same ground truth label. We use a separate set of contexts when training RL agents with an LLM in the loop.
# 4.3.1 RESULTS
Labeling Accuracy. The top row of Fig. 4 shows that the LLM labels more accurately than SL except for Versatile. For Versatile, both models perform similarly because SL learns to overwhelmingly predict a negative label (avg of $9 6 \%$ negative predictions) and the RL agent showed more negative examples of Versatile behavior (avg. of $7 0 \%$ ground truth negative labels). However, the large portion of negative examples prevents the agent from learning correct behavior as shown in the Versatile plot on the bottom of Fig. 4); here, we get a larger performance gap between the LLM and SL.
 Figure 4: DEALORNODEAL, Few-shot. (Top) Accuracy of reward signals provided by LLM and SL during RL training. (Bottom) Accuracy of RL agents after training. (Right) Pilot study results. Agents trained with the userβs preferred style were rated as significantly more aligned than an agent trained with the opposite style $p { < } 0 . 0 0 1$ .
Table 1: Qualitative results describing negotiations produced by agents trained with LLM.
<table><tr><td></td><td>Advantage</td><td>Diversity</td><td>Agreement Rate</td></tr><tr><td>Versatile</td><td>0.17Β±0.91</td><td>0.99Β±0.01</td><td>0.98Β±1.89</td></tr><tr><td>Push-Over</td><td>-2.95Β±0.64</td><td>0.82Β±0.26</td><td>1.0Β±0.0</td></tr><tr><td>Competitive</td><td>2.92Β±0.64</td><td>0.74Β±0.25</td><td>0.88Β±6.5</td></tr><tr><td>Stubborn</td><td>1.36Β±2.24</td><td>0.52Β±0.1</td><td>0.82Β±12.35</td></tr></table>
RL Agent Accuracy. Results are shown on bottom row of of Fig. 4. LLM improves RL agent accuracy over SL by $4 6 \%$ on average. Our method approaches the performance of using the true reward; we under perform by an average of $4 \%$ . We remind readers that it is possible to outperform an agent trained with the true reward β especially when the LLMβs labeling accuracy is near-perfect as is the case for Competitive and Stubborn β due to reward hacking or stochasticity during training. For instance, agents trained with the true reward for Competitive end in more disagreements, leading to 0 reward for both agents and a lower accuracy.
Is There a Qualitative Difference in Styles? Example negotiations of agents trained with the LLM for each style are shown in Fig. 9 in the Appendix. To measure qualitative differences among styles, we looked at average advantage (Aliceβs original task reward - Bobβs original task reward), diversity (percentage of Aliceβs utterances that are unique in a negotiation), and agreement rate (percentage of negotiations that end in agreement). The results in Table 1 demonstrate qualitative differences in styles.
# 4.3.2 PILOT USER STUDY
We conduct a within-subjects pilot user study to determine whether our trained agents can meaningfully align themselves with different user objectives when we do not have access to ground truth objectives and users evaluate agent performance.
Method We asked $N { = } 1 0$ users to select a style in which they wanted their agent to negotiate in. We gave them an option to choose from our existing styles (Versatile, Push-Over, Competitive, Stubborn), or come up with their own. Importantly, users did not know how we defined these styles. We then showed users a list of 10 example negotiations generated via selfplay using an RL agent trained with a greedy objective (no particular style). We asked users to select 3 examples (1 positive, 1 negative, and 1 positive or negative) where Alice displayed positive or negative behavior of the userβs chosen style. For each chosen example, we asked users whether Alice demonstrated their chosen style and asked them to provide a βYes/Noβ answer as well as a short explanation. These examples corresponded to unknown, user-specific ground truth reward functions that we did not have access to. We then trained a negotiation agent by incorporating the user-provided examples in the prompt as described in Sec. 3. We also trained an agent to negotiate in the opposite style by flipping the βYes/Noβ labels in the user-provided explanations. We hypothesize that users should perceive a significant difference between these two agents. To evaluate our trained agents, we had both agents negotiate on a set of 10 test negotiations. For each test negotiation, we asked users to rate how well each agent aligned with their chosen style on a scale from 1 (least aligned) to 5 (most aligned).
Results Agents trained with the correct style were significantly more aligned (avg. $3 . 7 2 { \pm } 1 . 2 )$ than agents trained with the opposite style (avg. $1 . 5 6 \pm 1 . 0 5 )$ , $p < 0 . 0 0 1$ , see Fig. 4 (right). Users varied in which styles they preferred: 4 users chose styles such as Polite, Push-Over, Considerate and Compromising, 2 users chose Versatile, and 4 users chose styles such as Stubborn, Competitive and Ambitious. These results demonstrate that our framework can produce agents aligned with differently specified objectives by changing the examples in the prompt. Furthermore, these results suggest that our framework can be used when rewards are difficult to define and results are agents with humans.
Summary. Our framework can train objective-aligned agents when ground truth rewards are not present in complex, longer-horizon tasks. Agents are able to align the style in which they complete a task as evaluated by automated metrics as well as human users.
# 5 ANALYSIS OF DATA EFFICIENCY & PROMPT DESIGN
We have shown that we can use an LLM as a proxy reward function to successfully train objective-aligned agents across different tasks. This is a promising result because it represents an important step in enabling human-compatible and value-aligned AI systems. In this section, 1) we further quantify how data efficient our method is and 2) also analyze how robust LLM is to variations of prompt design.
1) How Data-efficient is Our Method? We quantify how much more user data a supervised learning baseline would need in order to achieve the same labeling accuracy as the LLM. Results in the Ultimatum Game demonstrate that 10 labeled examples is enough for an SL model to reach comparable performance, whereas a a single labeled example is not sufficient. In this section, we quantify the amount of data needed for DEALORNODEAL because it is an example of a task where the decision boundary is not as easy to learn as the Ultimatum Game. We train SL by adding additional class-balanced, labeled examples to the original three examples it was trained on. We plot the average labeling accuracy SL achieves when trained on increasingly larger amounts of examples as well as the accuracy LLM achieves with three examples, shown in Fig. 6 in the Appendix. Results show that SL requires on the order of hundreds of more labeled examples in order to be comparably accurate as LLM.
2) How Much Does LLMβs Labeling Accuracy Change When We Vary the Prompt? As with many approaches that use LLMs, a limitation of our approach is that it requires prompt design. We attempt to quantify the effort required for designing prompts as well as determine the feasibility of using nonengineered prompts from humans. We analyze the effect of prompt variation on labeling accuracy in DEALORNODEAL for the Stubborn objective. We vary different parts of the user-specified prompt at a time: the keyword (i.e., replacing βStubbornβ with its synonyms), the example negotiations, and the explanations associated with each example. Fig. 7 provides a summary of our results. See Sec. A.7 for the full results. Results illustrate that an LLM can be quite robust to different prompts β they all outperform SL. Furthermore, the quality of the explanation seems to be the most important in determining LLM accuracy.
# 6 LIMITATIONS & FUTURE WORK
User Studies. This work takes a first step in determining whether we can use LLMs as proxy rewards. Given promising results, we plan on evaluating our approach with a larger user study.
Multimodal Foundation Models. Beyond language models, multimodal foundation models such as Flamingo (Alayrac et al., 2022) can enable us to provide more complex environment states to the foundation model through images or other modalities while preserving an intuitive language interface for specifying the user objective.
Non-Binary Rewards. Another limitation of our framework is that the LLM only specifies binary rewards. We plan on exploring how we can incorporate the likelihoods that LLMs produce for each word as a non-binary reward signal.
# ACKNOWLEDGMENTS
This work was supported by NSF Award 1941722, 2125511, 2006388, AFOSR, DARPA YFA Award, ONR, and JP Morgan Faculty Award. We would also like to thank Karl Tuyls, Ian Gemp, Albert Gu, Siddharth Karamcheti, Kanishk Gandhi, and other reviewers for this paper.
# REFERENCES
Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Chuyuan Fu, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, Daniel Ho, Jasmine Hsu, Julian Ibarz, Brian Ichter, Alex Irpan, Eric Jang, Rosario Jauregui Ruano, Kyle Jeffrey, Sally Jesmonth, Nikhil J Joshi, Ryan Julian, Dmitry Kalashnikov, Yuheng Kuang, Kuang-Huei Lee, Sergey Levine, Yao Lu, Linda Luu, Carolina Parada, Peter Pastor, Jornell Quiambao, Kanishka Rao, Jarek Rettinghouse, Diego Reyes, Pierre Sermanet, Nicolas Sievers, Clayton Tan, Alexander Toshev, Vincent Vanhoucke, Fei Xia, Ted Xiao, Peng Xu, Sichun Xu, Mengyuan Yan, and Andy Zeng. Do as i can, not as i say: Grounding language in robotic affordances. arXiv, 2022.
Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob Menick, Sebastian Borgeaud, Andrew Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, and Karen Simonyan. Flamingo: a visual language model for few-shot learning. arXiv, 2022.
Dario Amodei, Chris Olah, Jacob Steinhardt, Paul Christiano, John Schulman, and Dan Mane. Concrete Β΄ problems in ai safety. arXiv preprint arXiv:1606.06565, 2016.
Yuntao Bai, Andy Jones, Kamal Ndousse, Amanda Askell, Anna Chen, Nova DasSarma, Dawn Drain, Stanislav Fort, Deep Ganguli, Tom Henighan, et al. Training a helpful and harmless assistant with reinforcement learning from human feedback. arXiv preprint arXiv:2204.05862, 2022.
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. arXiv preprint arXiv:2005.14165, 2020.
Andrea Caputo, Oluremi B Ayoko, Nii Amoo, and Charlott Menke. The relationship between cultural values, cultural intelligence and negotiation styles. Journal of Business Research, 99:23β36, 2019.
Thomas Carta, Sylvain Lamprier, Pierre-Yves Oudeyer, and Olivier Sigaud. Eager: Asking and answering questions for automatic reward shaping in language-guided rl. arXiv preprint arXiv:2206.09674, 2022.
Annie S. Chen, Suraj Nair, and Chelsea Finn. Learning generalizable robotic reward functions from βin-the-wildβ human videos. ArXiv, abs/2103.16817, 2021.
Paul F Christiano, Jan Leike, Tom Brown, Miljan Martic, Shane Legg, and Dario Amodei. Deep reinforcement learning from human preferences. Advances in neural information processing systems, 30, 2017.
Junyoung Chung, Caglar Gulcehre, KyungHyun Cho, and Yoshua Bengio. Empirical evaluation of gated recurrent neural networks on sequence modeling. arXiv preprint arXiv:1412.3555, 2014.
Ernst Fehr and Klaus M Schmidt. On inequity aversion: A reply to binmore and shaked. Journal of economic behavior & organization, 73(1):101β108, 2010.
Prasoon Goyal, Scott Niekum, and Raymond J Mooney. Using natural language for reward shaping in reinforcement learning. arXiv preprint arXiv:1903.02020, 2019.
Dylan Hadfield-Menell, Smitha Milli, Pieter Abbeel, Stuart J Russell, and Anca Dragan. Inverse reward design. Advances in neural information processing systems, 30, 2017.
He He, Derek Chen, Anusha Balakrishnan, and Percy Liang. Decoupling strategy and generation in negotiation dialogues. In Empirical Methods in Natural Language Processing (EMNLP), 2018.
Wenlong Huang, P. Abbeel, Deepak Pathak, and Igor Mordatch. Language models as zero-shot planners: Extracting actionable knowledge for embodied agents. In ICML, 2022.
Borja Ibarz, Jan Leike, Tobias Pohlen, Geoffrey Irving, Shane Legg, and Dario Amodei. Reward learning from human preferences and demonstrations in atari. Advances in neural information processing systems, 31, 2018.
W Bradley Knox, Alessandro Allievi, Holger Banzhaf, Felix Schmitt, and Peter Stone. Reward (mis) design for autonomous driving. arXiv preprint arXiv:2104.13906, 2021.
Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. arXiv, 2022.
Minae Kwon, Siddharth Karamcheti, Mariano-Florentino Cuellar, and Dorsa Sadigh. Targeted data acquisition for evolving negotiation agents. In International Conference on Machine Learning, pp. 5894β5904. PMLR, 2021.
Andrew K Lampinen, Ishita Dasgupta, Stephanie CY Chan, Kory Matthewson, Michael Henry Tessler, Antonia Creswell, James L McClelland, Jane X Wang, and Felix Hill. Can language models learn from explanations in context? arXiv preprint arXiv:2204.02329, 2022.
Mike Lewis, Denis Yarats, Yann N. Dauphin, Devi Parikh, and Dhruv Batra. Deal or no deal? end-to-end learning for negotiation dialogues. In Empirical Methods in Natural Language Processing (EMNLP), 2017.
Jessy Lin, Daniel Fried, Dan Klein, and Anca Dragan. Inferring rewards from language in context. arXiv preprint arXiv:2204.02515, 2022.
Suvir Mirchandani, Siddharth Karamcheti, and Dorsa Sadigh. Ella: Exploration through learned language abstraction. Advances in Neural Information Processing Systems, 34:29529β29540, 2021.
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, abs/2203.02155, 2022.
Alexander Pan, Kush Bhatia, and Jacob Steinhardt. The effects of reward misspecification: Mapping and mitigating misaligned models. arXiv preprint arXiv:2201.03544, 2022.
Simone Parisi, Aravind Rajeswaran, Senthil Purushwalkam, and Abhinav Kumar Gupta. The unsurprising effectiveness of pre-trained vision models for control. In ICML, 2022.
Antonin Raffin, Ashley Hill, Adam Gleave, Anssi Kanervisto, Maximilian Ernestus, and Noah Dormann. Stable-baselines3: Reliable reinforcement learning implementations. Journal of Machine Learning Research, 22(268):1β8, 2021. URL http://jmlr.org/papers/v22/20-1364.html.
Stephane Ross, Geoffrey Gordon, and Drew Bagnell. A reduction of imitation learning and structured Β΄ prediction to no-regret online learning. In Proceedings of the fourteenth international conference on artificial intelligence and statistics, pp. 627β635. JMLR Workshop and Conference Proceedings, 2011.
Dorsa Sadigh, Anca D. Dragan, S. Shankar Sastry, and Sanjit A. Seshia. Active preference-based learning of reward functions. In Proceedings of Robotics: Science and Systems (RSS), July 2017. doi: 10.15607/RSS.2017.XIII.053.
Katia Sycara, Daniel Zeng, et al. Benefits of learning in negotiation. In Proceedings of the AAAI National Conference on Artificial Intelligence. Menlo Park, California, pp. 36β41, 1997.
Peter Vavra, Luke J Chang, and Alan G Sanfey. Expectations in the ultimatum game: distinct effects of mean and variance of expected offers. Frontiers in psychology, 9:992, 2018.
Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3):229β256, 1992.
Jing Zhang, Xindong Wu, and Victor S Sheng. Learning from crowdsourced labeled data: a survey. Artificial Intelligence Review, 46(4):543β576, 2016.
Tony Z. Zhao, Eric Wallace, Shi Feng, Dan Klein, and Sameer Singh. Calibrate before use: Improving fewshot performance of language models. In International Conference on Machine Learning (ICML), 2021.
# A APPENDIX0 Tabl
# A.1 SUMMARY
OF RESULTS: IS IT IS POSSIBLE TO USE LLM AS A PROXY REWARD IN RL TRAINING? Figure 5: Average Labeling and RL Agent Accuracy across the different objectives for each task across 3 seeds.
<table><tr><td colspan="5">Avg.Labeling Accuracy</td><td colspan="3">Avg.RL Agent Accuracy</td></tr><tr><td></td><td>Zero-shot Baseline (No Obj.)</td><td>Few-shot Baseline (SL)</td><td>Ours</td><td>Zero-shot Baseline (No Obj.)</td><td>Few-shot Baseline (SL)</td><td>Ours</td><td>True Reward</td></tr><tr><td>Ultimatum Game</td><td>-</td><td>0.67 Β±0.34</td><td>0.91Β±0.27</td><td>-</td><td>0.67 Β±0.34</td><td>0.9Β±0.26</td><td>1.0Β±0.02</td></tr><tr><td>Matrix Games</td><td>0.19 Β±0.29</td><td>-</td><td>0.61Β±0.41</td><td>0.54Β±0.29</td><td>-</td><td>0.88Β±0.</td><td>1.0Β±0.</td></tr><tr><td>DEALORNODEAL</td><td></td><td>0.5Β± 0.47</td><td>0.9Β±0.22</td><td></td><td>0.33Β± 0.42</td><td>0.8Β±0.33</td><td>0.84 Β±0.27</td></tr></table>
We provide a summary of results in Fig. 5. The figure depicts the average Labeling and RL Agent Accuracy computed across the different user objectives for each task, across 3 seeds. Overall, our approach is able to produce more objective-aligned reward signals than our baselines. Our approach is also able to produce objective-aligned policies that are close in accuracy to policies trained with the true reward.
# A.2 MORE RELATED WORKS
Reward Design. Our framework addresses reward designβhow to engineer rewards so that they align with our objectives (Amodei et al., 2016). This is challenging because tasks often have conflicting objectives that a human must trade off (Pan et al., 2022). Misspecifying reward functions can lead to reward hacking, or the gaming of specified rewards. Reward hacking has appeared in various domains such as autonomous driving (Knox et al., 2021) and game-playing (Ibarz et al., 2018). We hope to address these challenges by leveraging LLMs and making it easier for humans to specify their objectives.
Imitation Learning & Preference-based Learning. Another method of specifying user objectives is to learn them from expert demonstrations (Ross et al., 2011) or preferences Sadigh et al. (2017). These techniques either assume access to large datasets (Christiano et al., 2017) or place restrictive assumptions (such as linearity) about the reward function (Sadigh et al., 2017). Recent work attempts to learn reward functions from language instructions using pragmatic reasoning (Lin et al., 2022). In contrast, our work relies on an LLMβs in-context learning abilities to provide a reward.
# A.3 LLM DEFINITION OF OBJECTIVES IN THE MATRIX GAME
<table><tr><td rowspan=1 colspan=1>LLMDefns.of ObjectivesTotal welfare is the sum of the rewards of both players.(β)</td></tr><tr><td rowspan=1 colspan=1>Equality of rewards is only possible if both players receive the same reward. (β)</td></tr><tr><td rowspan=1 colspan=1>Rawlsian fairness is defined as the maxmin value of the game, which is theminimum reward that the player could get assuming that the other player ismaximizing their reward. (X)</td></tr><tr><td rowspan=1 colspan=1>An outcome is Pareto-optimal if there is no other outcome that would make one player beter off without making the other player worse off.(β)</td></tr></table>
Table 2: Completion of each sentence given by LLM in pink. LLM provides correct definitions for objectives except for Rawlsian Fairness, which is partially correct.
# A.4 DETAILS ON RL ENVIRONMENTS AND TRAINING
Ultimatum Game. The environment is a single horizon with discrete actions (i.e., accept or reject) and continuous observations (i.e., a proposed split). We train DQN agents using the Stable Baselines3 implementation for 1e4 timesteps with a learning rate of 1e-4 across 3 seeds (Raffin et al., 2021). We instantiate our policy as a MLP with the default parameters used in Stable Baselines3.
Parser $g$ . The parser $g$ that transforms the LLMβs output into an integer reward signal is defined using a handcrafted parser. When prompting the LLM, we structure the labels for each example to be in βYes/Noβ form which enables the LLM to also reply using the same format. We are then able search for the βYesβ or βNoβ strings and parse them into a 1 or 0 respectively. In the rare occasion that the LLM does not respond in this form, we skip the episode during RL training and omit the example from our evaluation.
Further Analysis on Performance of No Objective Baseline. The average LLM accuracy of a random baseline across the four matrix games are Welfare: 0.125, Equality: 0.125, Rawlsian Fairness: 0.078, Pareto-optimality: 0.172. The No Objective baselineβs performance is close to random as can be verified by comparing the random baseline results with Figure 3 (top row).\* Behaviorally, we observe that No Objective acts like a random baseline: the LLM often hallucinates matrix game rewards and also displays incoherent reasoning when selecting answers.
Matrix Game.. The environment is a single horizon with discrete actions (i.e., one of the four joint actions) and no observations. We train DQN agents using the Stable Baselines3 implementation for 500 timesteps with a learning rate of 1e-4 across 3 seeds (Raffin et al., 2021). We instantiate our policy as a MLP with the default parameters used in Stable Baselines3.
Parser $g$ . We parse the LLMβs response by hand, since LLM output can be variable in zero-shot settings.
DEALORNODEAL. We use a version of the DEALORNODEAL environment used in Kwon et al. (2021). In the environment, the goal is for an agent $A$ to come to an agreement with a partner $B$ on the allocation of a set of objects (books, hats, and balls). During each negotiation, agents receive a context, $c _ { A } = [ i ; u _ { A } ] , c _ { B } =$ $[ i ; u _ { B } ]$ , detailing the count of each item $i$ as well as their private utilities, $u _ { A } , u _ { B }$ . Item counts and utilities are represented as vectors $i \in \{ 1 , . . . , 4 \} ^ { 3 }$ and $u _ { A } , u _ { B } \in \{ 0 , \bar { . . . } , 1 0 \} ^ { 3 }$ and are sampled uniformly.
After receiving contexts $c _ { A } , c _ { B }$ , an agent is randomly selected to begin the negotiation. Agents negotiate for $T$ time steps by exchanging coarse dialogue acts $x _ { t }$ at each time step $1 \leq t \leq T$ (He et al., 2018). Rather than negotiate directly in natural language, where the generation problem is hard and can result in degenerate dialogues (He et al., 2018), we use these dialogue acts instead to focus on learning diverse and interpretable strategies.
A dialogue act $x _ { t }$ is one of five actions: propose, insist, agree, disagree, or end. The propose and insist acts take allocations of items as arguments $o \ = \ [ o _ { A } ; o _ { B } ]$ where $o _ { A } , o _ { B } \in \{ 1 , . . . , 4 \} ^ { 3 }$ (e.g., propose: books $^ { = 1 }$ , hat $S { = } 2$ , $\mathtt { b a l l s } = 1$ ). When an agent selects end, the conversation terminates and each agent is asked to make their final selection.
If agents agree on the final allocation of items, i.e., $o _ { A } + o _ { B } = i$ , agents are awarded points based on their private utilities, $r _ { A } = u _ { A } \cdot o _ { A } , r _ { B } = u _ { B } \cdot o _ { B }$ . If agents do not agree, they receive 0 points. Each agentβs context is constrained so that the agent can receive a maximum of 10 points.
Agents are first trained using supervised learning on a dataset of human-human negotiations provided by (Lewis et al., 2017) to predict the next token. We use a learning rate of 1.0 and batch size of 16. We then fine-tune these agents using RL where they optimize the expected reward of each dialogue act using REINFORCE (Williams, 1992). Agents are trained on 250 contexts for 1 epoch with a learning rate of 0.1. We instantiate our policy with four GRUs (Chung et al., 2014). We closely follow the implementation outlined in (Kwon et al., 2021; Lewis et al., 2017), please refer to those papers for more training details.
Parser $g$ . The parser $g$ that transforms the LLMβs output into an integer reward signal is defined using a handcrafted parser. When prompting the LLM, we structure the labels for each example to be in βYes/Noβ form which enables the LLM to also reply using the same format. We are then able search for the βYesβ or βNoβ strings and parse them into a 1 or 0 respectively. In the rare occasion that the LLM does not respond in this form, we skip the episode during RL training and omit the example from our evaluation.
# A.5 SL MODEL ARCHITECTURE AND TRAINING
Ultimatum Game. SL is trained to predict binary labels for a batch of proposed splits. We implemented SL as a multi-layer perceptron (MLP) network that consists of a single hidden layer with depth 32. We also use ReLU activations after our input and hidden layers. We trained the model on the same 10 examples we gave to LLM for 5 epochs with the Adam optimizer. We evaluate the model on the 50 heldout test examples and save the model with the best test accuracy. We show the training and test accuracy for each user objective below:
Table 3: Training accuracy for SL on the Ultimatum Game.
<table><tr><td></td><td>30%</td><td>60%</td><td>$10</td><td>$100</td><td>Ineq. Aversion</td></tr><tr><td>Train Acc. (10 examples)</td><td>1.0</td><td>1.0</td><td>0.9</td><td>1.0</td><td>1.0</td></tr><tr><td>Train Acc. (1 example)</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1.0</td></tr></table>
DEALORNODEAL. SL is trained to predict binary labels given a negotiation as input. We closely follow the implementation of a SL model found in (Kwon et al., 2021; Lewis et al., 2017). A negotiation consists of a context, coarse dialogue acts exchanged between Alice and Bob, and the outcome of the negotiation (the final split of items and whether agents agreed or disagreed). Please refer to Sec. A.4 for more details on the environment. We implement SL using a MLP context encoder, MLP outcome encoder, and a GRU ((Chung et al., 2014)) to process the coarse dialogue acts. The MLP encoders consist of an embedding layer followed by a linear layer with a Tanh activation function; we use a hidden size of 64 for the context encoderβs linear layer. We similarly embed each coarse dialogue act before feeding it into the GRU. We use a hidden size of 128 for the GRU. We train SL on the same 3 examples we use in our prompt for LLM. We train for a maximum of 50 epochs using the Adam optimizer. SL received a training accuracy of $1 0 0 \%$ for all of our objectives.
# A.6 HOW DATA-EFFICIENT IS OUR METHOD?
 SL Labeling Accuracy When Trained with # Additional Labeled Examples Figure 6: SL requires on the order of hundreds of more labeled examples in order to be comparably accurate to the LLM.
A.7 HOW MUCH DOES LLMβS LABELING ACCURACY CHANGE WHEN WE VARY THE PROMPT? Effect of Prompt Variation on Labeling Accuracy for Stubborn (N=3, 3 seeds) Figure 7: On average, varying the prompt does not have a large impact on the accuracy of the LLM.
<table><tr><td>SL</td><td>Ours</td><td>Vary Keyword</td><td>Vary Example Negotiations</td><td>Vary Explanations</td></tr><tr><td>0.58 Β± 0.48</td><td>0.97 Β± 0.16</td><td>0.91Β±0.28</td><td>0.93 Β±0.28</td><td>0.79 Β±0.33</td></tr></table>
We analyze the effect of varying prompts on the LLMβs labeling accuracy for the Stubborn negotiating style in DEALORNODEAL. We vary prompts in three ways: we vary the keyword (i.e., replacing βStubbornβ with its synonyms), the example negotiations, and the explanations associated with each example.
When varying the keyword, we use the synonyms: βHeadstrongβ, βObstinateβ, and a less commonly used word, βFrowardβ. To vary example negotiations, we randomly sample three new negotiations to have counterbalanced labels, all positive labels, or all negative labels. We vary the explanations by coming up with two plausible sets of explanations a user might have given for each example. We also experiment with the scenario where we give no explanations. Results are shown in Fig. 8. Overall, varying prompts do not have a large impact on labeling accuracy β they all outperform the baseline. However, the quality of explanation seems to have the largest impact on labeling accuracy.
# A.8 WHAT IS THE IMPORTANCE OF INCLUDING THE TASK DESCRIPTION, $\rho _ { 1 }$ IN THE PROMPT?
We experiment with removing $\rho _ { 1 }$ , the task description in the Ultimatum Game with a single example followed by an explanation. Performance increases slightly in LLM labeling accuracy (avg. of $8 \%$ ) and RL agent accuracy (avg. of $9 \%$ ). We run the same experiment in the Ultimatum game in the case of 10 examples with no explanation. Performance drops slightly in LLM labeling accuracy (avg. $4 . 4 \%$ ) and RL agent accuracy (avg. $5 . 3 \%$ ). We conclude that $\rho _ { 1 }$ is not conclusively influential in improving performance in few-shot settings.
 Figure 8: Varying prompts do not have a large impact on labeling accuracy. Figure 9: Example negotiations after Alice is trained with reward signals from LLM in DEALORNODEAL. We illustrate qualitative differences in how Alice negotiates for the same context. $B o b$ is an agent that is trained with supervised learning.
# A.9 EXPERIMENTING WITH SMALLER LLM SIZES
We experiment with GPT-2, a 1.5B parameter model. We We find that GPT-2 underperforms GPT-3 in both labeling (avg. $1 5 \%$ ) and RL agent accuracy (avg. $4 9 \%$ ). GPT-2 outperforms the SL baseline in labeling accuracy (avg. $2 4 \%$ ), and slightly underperforms the SL baseline for RL agent accuracy (avg. $2 . 7 \%$ ). Results are averaged across styles and seeds. GPT-2 (1.5B) is several orders smaller than GPT-3 (175B), and we expect models larger than GPT-2 to close the gap with GPT-3βs performance.
A.10 EXAMPLE NEGOTIATIONS
# Context
Alice : book=(count:1 value:0) hat=(count:1 value:7) ball=(count:3 value:1) Bob : book=(count:1 value:3) hat=(count:1 value:7) ball=(count:3 value:0)
<table><tr><td rowspan=1 colspan=1>Versatile</td></tr><tr><td rowspan=1 colspan=1>Alice : propose: item0=1 item1=1 item2=0Bob :propose: item0=0 item1=1 item2=0Alice : propose: item0=1 item1=0 item2=2Bob :agree</td></tr><tr><td rowspan=1 colspan=1>Agreement!Alice : 2 pointsBob :7 pointsCompetitive</td></tr><tr><td rowspan=1 colspan=1>Alice : propose: item0=1 item1=0 item2=3Bob : propose: item0=1 item1=1 item2=0Alice : insist: item0=0 item1=1 item2=3Bob :agree</td></tr><tr><td rowspan=1 colspan=1>Agreement!Alice : 10 pointsBob :3 points</td></tr></table>
<table><tr><td>Push-over</td></tr><tr><td>Alice : propose: item0=1 item1=0 item2=3 Bob :propose: itemO=1 item1=1 item2=0 Alice :agree Agreement! Alice : 3 points</td></tr><tr><td>Bob :10 points Stubborn Alice : propose: item0=0 item1=1 item2=1</td></tr><tr><td>Bob :propose: item0=0 item1=1 item2=0 Alice : propose: item0=0 item1=1 item2=1 Bob : propose: item0=0 item1=1 item2=0 Alice : propose: item0=0 item1=1 item2=1 Bob :propose: item0=0 item1=1 item2=0 Alice : propose: item0=0 item1=1 item2=1 Bob:propose: item0=0 item1=1 item2=0 Alice : propose: item0=0 item1=1 item2=1</td></tr></table>
Disagreement?! Alice : 0 (potential 0) Bob : 0 (potential 0)
# A.11 EXAMPLE OF PROMPTS USED IN OUR EXPERIMENTS
# A.11.1 ULTIMATUM GAME
Further Explanation of Our Prompt Selection Process. When constructing our explanations, we encourage the LLM to produce intermediate reasoning steps by using the βLetβs think step by stepβ template usedUltimatum prompt in Kojima et al. (2022) which has been shown to improve performance.
 Figure 10: An example of few-shot prompts used for the Ultimatum Game. We highlight the four parts of each pro
# A.11.2 MATRIX GAMES
Further Explanation of Our Prompt Selection Process. We found that structuring the outcomes of the game as a multiple choice question improved performance. We also encouraged the LLM to produce intermediate reasoning steps by using the βLetβs think step by stepβ template used in Kojima et al. (2022) which has been shown to improve performance.Matrix prompt
 Figure 11: Examples of a zero-shot prompts used for each objective, including the no-objective baseline, in the Matrix Games. Due to limited resources when querying GPT-3, we queried GPT-3 in a batched manner and saved the corresponding labels to train our RL agents. Consequently, we do not have an Episode outcome in our prompts.
# A.11.3 DEALORNODEAL
Further Explanation of Our Prompt Selection Process. We chose 3 counterbalanced examples from a training set of sample negotiations. This training set was generated via selfplay using an RL agent trained
Figure 12: Examples of regular and scrambled outcomes for the Chicken Game (Matrix Game experiments). Scrambling creates new associations between joint actions and joint rewards. We scramble the outcomes in order to remove any bias LLM may have towards the order in which outcomes are normally presented.
<table><tr><td>Chicken Game (Regular Order)</td><td>Chicken Game (Scrambled Order)</td></tr><tr><td>We have a two-player game where P1 and P2 can choose one of these options.</td><td>We have a two-player game where P1 and P2 can choose one of these options.</td></tr><tr><td>Options: A.if action1(P1) and action1(P2)=>P1 gets reward of 2, P2 gets reward of 2.</td><td>Options: A. if actionl(P1) and actionl(P2) =>P1 gets reward of 3,P2 gets reward of 1.</td></tr><tr><td>B. if action1(P1) and action2(P2)=>P1 gets reward of 1,P2 gets reward of 3.</td><td>B.if action1(P1) and action2(P2)=>P1 gets reward of 2,P2 gets reward of 2.</td></tr><tr><td>C.if action2(P1) and action1(P2)=>P1 gets reward of 3,P2 gets reward of 1.</td><td>C.if action2(P1) and action1(P2)=>P1 gets reward of 1, P2 gets reward of 3.</td></tr><tr><td>D.if action2(P1) and action2(P2)=>P1 gets reward of 0,P2 gets reward of 0.</td><td>D.if action2(P1)and action2(P2)=>P1 gets reward of 0,P2 gets reward of 0.</td></tr><tr><td></td><td></td></tr><tr><td>Which option(s) are Pareto-optimal? Let's think step by step:</td><td>Which option(s) are Pareto-optimal? Let's think step by step:</td></tr><tr><td>An outcome is Pareto-optimal if</td><td>An outcome is Pareto-optimal if</td></tr></table>
with a greedy reward (no particular style). We chose to complement our examples with simple and succinct explanations.
 Figure 13: Example of a prompt used for DEALORNODEAL.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341# MOVING BEYOND HANDCRAFTED ARCHITECTURES IN SELF-SUPERVISED LEARNING
Anonymous authors Paper under double-blind review
# ABSTRACT
The current literature on self-supervised learning (SSL) focuses on developing learning objectives to train neural networks more effectively on unlabeled data. The typical development process involves taking well-established architectures, e.g., ResNet or ViT demonstrated on ImageNet, and using them to evaluate newly developed objectives on downstream scenarios. While convenient, this neglects the role of architectures which has been shown to be crucial in the supervised learning literature. In this work, we establish extensive empirical evidence showing that a network architecture plays a significant role in contrastive SSL. We conduct a large-scale study with over 100 variants of ResNet and MobileNet architectures and evaluate them across 11 downstream scenarios in the contrastive SSL setting. We show that there is no one network that performs consistently well across the scenarios. Based on this, we propose to learn not only network weights but also architecture topologies in the SSL regime. We show that βself-supervised architecturesβ outperform popular handcrafted architectures (ResNet18 and MobileNetV2) while performing competitively with the larger and computationally heavy ResNet50 on major image classification benchmarks (ImageNet-1K, iNat2021, and more). Our results suggest that it is time to consider moving beyond handcrafted architectures in contrastive SSL and start thinking about incorporating architecture search into self-supervised learning objectives.
# 1 INTRODUCTION
Self-supervised learning (SSL) achieves impressive results on challenging tasks involving image, video, audio, and text. Models pretrained on large unlabeled data perform nearly as good and sometimes even better than their supervised counterparts (Caron et al., 2020; Chen & He, 2021). So far, the focus has been on designing effective learning objectives β e.g., pretext tasks (Gidaris et al., 2018; Caron et al., 2018), contrastive (Oord et al., 2018; Chen et al., 2020a) and noncontrastive (Grill et al., 2020) tasks β together with empirical (Cole et al., 2021; Feichtenhofer et al., 2021) and theoretical (Arora et al., 2019; Poole et al., 2019) studies providing key insights and underpinnings. Recent works propose new objectives with a different class of network architectures such as vision transformers (ViT) (Bao et al., 2021) and masked autoencoders (He et al., 2022).
However, there has been little focus on the role of architectures in SSL. Currently, the de facto protocol in SSL is to take architectures that perform well on established benchmarks in the supervised setting and to adapt them to the self-supervised setting by plugging in different learning objectives. For example, several existing work on contrastive learning use ResNet (He et al., 2016) as the backbone (Chen et al., 2020a; He et al., 2020). This is partly for convenience. Evaluating different architectures in SSL is computationally expensive; selecting an architecture in advance and fixing it throughout makes it easy to evaluate different learning objectives. This also stems from strong empirical success of those architectures in transfer learning, e.g., CNNs trained on large labeled data provide βunreasonable effectivenessβ (Sun et al., 2017; Zhang et al., 2018; Sejnowski, 2020) in a variety of downstream cases. Nonetheless, one implicit assumption is that an architecture that works well in the supervised learning scenario will continue to be effective in the SSL regime.
We argue that this assumption is incorrect and dangerous. It is valid only to a limited extent and the performance starts deteriorating significantly when SSL is conducted on data whose distribution deviates much from the original distribution the architecture was trained on. This is counter to the promise of SSL, where one can learn optimal representation for a wide range of tasks. One main reason for performance degradation is that different data distributions benefit from different inductive biases: An architecture with specific layer types and the wiring between them naturally encodes inductive biases, which may be optimal only for a certain data distribution (e.g., objectcentric imagery such as ImageNet) and not for others (e.g., medical and satellite imagery). In fact, numerous studies have shown that standard βrecipesβ for architecture design do not translate well across different data distributions (Tuggener et al., 2021; Dey et al., 2021; Kolesnikov et al., 2019).
The main objective of this work is to show that the choice of network architecture crucially matters in SSL, and that it is not easy to handcraft architectures that are effective across different SSL scenarios. To see this, recall that the goal of SSL is to learn data representations capturing important features and attributes that generalize well across various downstream tasks. There has been extensive literature on the expressivity of neural networks (Raghu et al. (2017); Zhang et al. (2021a) and references therein); one of the important conclusions is that the network topology plays a significant role in determining the expressivity, i.e., the kinds of functions a network can approximate is bounded by the network capacity and available sample size in the finite sample regime. This implies that, in practice, SSL with a fixed architecture learns representations only within the scope of function space induced by the pre-selected architecture topology, and therefore, the ultimate success of SSL can be achieved when it finds optimal architecture from certain search space in conjunction with its weights for specific data distributions.
In this paper, we establish extensive empirical evidence showing that architecture matters in selfsupervised learning. We do this in two sets of large-scale studies. First, we sample 116 variants of ResNet (He et al., 2016) and MobileNet (Sandler et al., 2018) architectures with different topologies and evaluate them on 11 downstream tasks in the SSL setting. We pretrain all models under the same setting, optimizing the SimCLR objective (Chen et al., 2020a) on ImageNet (Deng et al., 2009), and investigate if there exist any correlation between these models in downstream performance on different datasets. We observe no strong correlation, except for tasks highly similar to ImageNet. We further show that ImageNet downstream performance, the gold standard benchmark in the SSL literature, is not indicative of performance on other downstream tasks. This implies that we need to be careful in choosing an architecture for evaluating any newly developed SSL objectives, as one might get different conclusions based on different network architectures.
This subsequently raises the question: Can we improve SSL by learning not only network weights but also architectures directly optimized for the given dataset? It removes the burden of manually searching for effective architectures in SSL, and if we succeed, it can substantially improve performance of SSL. To test this hypothesis, as the second set of our study, we apply a well-established NAS algorithm (Cai et al., 2018) to the SSL setting. Unlike the typical NAS setting that optimize on a labeled target dataset, we search for optimal architectures directly on an unlabeled pretraining dataset via contrastive learning (Chen et al., 2020a). We evaluate our $\mathrm { ^ { 6 6 } N A S } + \mathrm { S S L } ^ { \mathrm { 3 } }$ framework on datasets with different distributions, ImageNet-1K and iNat 2021 (Van Horn et al., 2021), and show that self-supervised architectures consistently outperform handcrafted ones in the same parameter range (MobileNetV2 and ResNet18) across 11 downstream tasks. This provides strong evidence suggesting the importance of learning architecture topologies in addition to their weights in SSL.
Our work focuses on studying the role of architectures in contrastive SSL with the SimCLR framework for CNN-based architectures such as ResNets and MobileNets. As a first step in this direction, we provide an in-depth analysis through large-scale experiments in this specific (yet limited) setting. Extending our study to different SSL approaches (He et al., 2020; Grill et al., 2020; He et al., 2022) and architectures such as ViTs would be an interesting direction but beyond the scope of this paper.
In summary, our main contributions are: 1) We establish extensive evidence showing that there isnβt one network architecture performing consistently well across different downstream scenarios in the SimCLR setting. We show this using 116 variants of ResNet and MobileNet architectures pretrained on ImageNet and evaluated on 11 downstream datasets. 2) We show that ImageNet performance (the gold standard in SSL benchmark) is not always indicative of downstream performance. This means that findings about SSL objectives shown only on ImageNet do not generalize across other data distributions. 3) We propose to self-supervise a CNN architecture topology and its network weights on unlabeled data. We show that self-supervised architectures outperform handcrafted ones in a similar parameter range for the SimCLR setting across different downstream datasets.
# 2 RELATED WORK
Role of architectures in SSL. There has been significant progress in learning representations via SSL (Gidaris et al., 2018; Chen et al., 2020a;c; Caron et al., 2020). Ericsson et al. (2021) provide an overview of different SSL setups and their performance on downstream tasks. Most works focus on improving self-supervised objectives to develop better representations while keeping architectures fixed. Our focus is orthogonal to this line of work. We study the role of architectures in SSL and investigate the benefits of self-supervising architecture topologies along with network weights.
Similar to ours, Kornblith et al. (2019) analyze transfer performance of different architectures pretrained on ImageNet across several downstream datasets. However, they focused on supervised learning, which need not translate to self-supervised setups (Kolesnikov et al., 2019). Caron et al. (2021) propose a self-distillation based SSL objective and compare the performance of ResNets with ViTs. In contrast, we focuse on contrastive SSL and the importance of architecture topologies for the class of CNNs. Kolesnikov et al. (2019) is the most related to ours but are limited to pretext-task based SSL and show results only for a few variants of VGG and ResNet. In comparison, we conduct a study on a much larger scale in a contrastive learning setup. Also, we provide insights into generalization performance of the networks across different datasets. Crucially, unlike all previous work in SSL, we propose to learn both architecture topologies and their network weights.
NAS and SSL. The literature on NAS has rapidly progressed in the past years; we refer the reader to the NAS survey by Elsken et al. (2019). Here we focus on the most directly relevant work to SSL. Mellor et al. (2021) search for networks without any training and verify their effectiveness of supervised benchmarks. Liu et al. (2020) show that highly performant architectures can be found without using any supervised labels during the search itself, and propose using DARTS (Liu et al., 2019) with self-supervised proxy tasks to search for architectures which will perform well on supervised datasets. In a similar vein, Zhang et al. (2021b) use random labels during the search phase of NAS, and Yan et al. (2020) learn representations of architectures via SSL and use them to improve NAS. Li et al. (2021) introduce a new self-supervised training scheme to search for architectures in a new hybrid search space. One common theme in this line of work is that they aim to harness SSL in aid of NAS. In contrast, we aim to utilize NAS to hunt for architectures which will perform well for self-supervised learning, thereby harnessing NAS in aid of SSL.
# 3 DOES ONE NETWORK RULE THEM ALL IN SSL?
We conduct a large scale study to investigate whether a particular architecture topology can be consistently effective across a wide range of SSL scenarios. To this end, we sample 116 models with different architecture topologies and analyze their performance on 11 downstream tasks.
To maximize generality while taming complexity of our study, we choose two most representative CNN architectures: ResNets and MobileNets. The former is the de facto backbone for numerous modern visual models (Kirillov et al., 2019; Wu et al., 2019) and SSL approaches (Caron et al., 2020; Chen & He, 2021), while the latter is used in low-resource setups (Cheng et al., 2017). We create 69 ResNet-like and 47 MobileNet-like architectures for our evaluation, varying the number of blocks at each of the 4 stages of a ResNet, the block structure (BasicBlock and Bottleneck), width, and number of groups. For MobileNet, we vary the width multiplier parameter and the number of blocks in each of the 6 stages. We choose the SimCLR objective (Chen et al., 2020a) for our experiments and pretrain each of the 116 architectures on ImageNet-1K. Owing to the large scale nature of the experiments and computational constraints, we limit the pretraining to 100 epochs and a batch size of 512. Each of these jobs takes roughly 1 day to finish on a system with $8 \times \mathrm { ~ V 1 0 0 ~ }$ (32GB) GPUs. We report linear evaluation results in all cases.
ImageNet performance is not indicative of downstream performance for SSL. To examine the correlation between ImageNet vs. downstream performance, we compute the Spearmanβs rank correlation coefficient $\rho$ on top-1 validation accuracy between every dataset pair, shown in Fig. 1. We also show scatter plots in Fig. 2 revealing the relationship between ImageNet vs. downstream performance on the most representative cases; the complete set of scatter plots are in the appendix.
For ResNet-like architectures (Fig. 2 top row), we see strong correlation between ImageNet and CIFAR-100 ( $\rho = . 8 )$ ) as these datasets contain similar categories; about 90 classes in CIFAR-100 are the same class or a superclass in ImageNet. A similar observation is made (in Fig. 1) for Stanford Dogs $( \rho = . 7 7 )$ due to the 120 dog categories in ImageNet. However, we observe high variance in transfer performance for out-of-domain datasets, e.g., Flowers $( \rho = . 3 5 )$ , represented by only two ImageNet categories (daisy and yellow lady slipper). Correlation becomes negative on Stanford Cars $( \rho = - . 2 9 )$ and FGVC Aircraft $( \rho = - . 2 4 )$ , likely because ImageNet contains only a few categories of cars (10 classes) and aircraft (4 classes). Low correlation means network ranks are inconsistent and models performing well on ImageNet do not keep their precedence in other tasks.
 Figure 2: ImageNet performance is not indicative of downstream performance in SSL. We show linear evaluation top-1 accuracy of ImageNet (x-axis) vs. downstream datasets (y-axis) obtained from variations of ResNet (top) and MobileNet (bottom); all models are pretrained on ImageNet-1K using SimCLR under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
For MobileNet-like architectures (Fig. 2 bottom row), we see overall much lower correlation with ImageNet performance; the ResNet space showed correlation at least for in-distribution datasets. For e.g., we see correlation between ImageNet and CIFAR-100 drops from $\rho = . 8$ (ResNet) to $\rho \ = \ . 2 3$ (MobileNet). For other datasets like MIT67, correlation is higher $( \rho ~ = ~ . 5 2 )$ but still less meaningful due to high variability in performance (notice the cluster around $42 \%$ accuracy). These results indicate that MobileNets are even less tuned towards ImageNet than ResNets and any handcrafted architectures in this space is likely to be suboptimal on ImageNet and other downstream datasets.
 Figure 1: ImageNet performance isnβt indicative of downstream performance in SSL. We show rank correlation between each pair of top-1 accuracy on 11 downstream tasks obtained from ImageNet-pretrained ResNets. We see no strong correlation except for ones similar to ImageNet, e.g., CIFAR-10/100 and Dogs120.
Our results highlight that the same architecture recipes in terms of ImageNet accuracy, which is frequently used as a predictor for various selfsupervised tasks, do not work well for different datasets in the SimCLR setting.
Larger networks do not always perform better in contrastive SSL. In general, large-parameter models yield better performance on ImageNet, both in supervised (Kornblith et al., 2019) and SSL setups (Chen et al., 2020a). We examine whether this trend holds for downstream datasets some of which are widely different from ImageNet. We follow the same setup as above and compute the
 Figure 3: Larger models do not always perform better in SSL. We show the model size in terms of parameter counts ( $\mathbf { \widetilde { x } }$ -axis) vs. top-1 accuracy on different datasets obtained from variations of ResNet (top) and MobileNet (bottom) architectures; all models are pretrained on ImageNet-1K using SimCLR under the same protocol.
correlation between number of model parameters and top-1 validation accuracy on different datasets. Fig. 3 shows scatter plots of the most representative results; full results are in the appendix.
For ResNet-like architectures (Fig. 3 top row), we do not see strong trends indicating larger models always perform better. In fact, on some downstream tasks we see negative correlation (Aircraft, $\rho =$ $- . 3 7 )$ with lighter networks being favored for better performance, or even non-linear relationship, e.g., notice the slight βUβ pattern on Stanford Cars $\zeta = - . 1 4 )$ , indicating the behavior of ResNets on these datasets are wildly unexpected. Unsurprisingly, there is strong correlation with ImageNet $( \rho = . 8 5 )$ and CIFAR-100 $\langle \rho = . 8 7 \rangle$ , likely because ResNets are heavily hand-tuned on the kinds of images observed in these datasets. These results clearly suggest that the same architecture recipes which work well for ImageNet (increasing parameters through depth and width) do not hold for other downstream scenarios.
For MobileNet-like architectures (Fig. 3 bottom row), we see that there exists almost no interpretable trend. The fitted regression models (solid lines) and their confidence intervals (shaded area) show that the relationships are highly non-linear and non-monotonic; we shouldnβt read too much into the correlation coefficients (reported for completeness). These results indicate that MobileNets do not favor any one architecture and it is heavily reliant on the dataset it is trained on.
Our results suggest that larger models are not always better in SSL; lighter models can outperform heavier models on tasks like FGVC Aircraft. Previous work (Chen et al., 2020b) showed that increasing network depth/width improves downstream performance. However, they vary depth at a coarser level with 50/100/150 layers and width with $1 \times / 2 \times$ , leading to a large swing in network parameters (24-795M); here we show the same is not true at a finer level. Our results provide evidence that ResNet architectures are tuned to scale well on ImageNet but not the others; the trend is even weaker for MobileNet-like architectures, suggesting they are optimized for computational efficiency and not for achieving high accuracy on any particular dataset.
There is no winner in the battle of top vs. bottom heavy networks in SSL. Raghu et al. (2017) showed that CNNs are more sensitive to lower (initial) layer weights, suggesting that βnot all weights are created equalβ across layers. This raises the question: If CNNs are more sensitive to lower layers, will increasing the parameter count for lower layers yield better performance in SSL? To get insights into this, we split a network into two halves: βtopβ (layers closer to output) and βbottomβ (closer to input). We use the ratio of top to bottom parameters as a measure of networks being βtop-heavyβ (high ratio) or βbottom-heavyβ (low ratio).
Fig. 4 shows the downstream accuracy for ImageNet, Stanford Cars and Sports against this ratio. From the top-left subplot, we see that ResNet-ImageNet accuracy tend to increase with high top:bottom ratio, showing top-heavy networks generally perform better than the bottom-heavy counterparts. However, we no longer observe such trend in other datasets, and with MobileNets (Fig. 4 bottom row) we do not see such trend even for ImageNet.
An important point to realize: It is necessary to allocate the right portion of parameters to different layers of a given network topology, instead of allocating parameters in the top-heavy or bottom-heavy fashion assuming one will generally lead to better performance. ResNets and many other handcrafted CNNs (Simonyan & Zisserman, 2014; Szegedy et al., 2016; Huang et al., 2017) are usually top-heavy because of GPU memory limits; bottom-heavy networks occupy more memory in terms of activation maps. MobileNets alleviate this to some extent with lighter convolutions, allowing it to have more parameters in early layers. In object detection, Liang et al. (2019) also show that allocation of computational resources in the backbone is important for improved performance. While this architectural difference provides explanations about the wildly different trends we observe above, the key message here is that one recipe (top vs. bottom heavy) does not apply equally to different architectures, bolstering our claim that one network doesnβt rule them all in SSL.
Key takeaway: We need to move beyond handcrafted architectures in SSL. The three main observations above imply that finding an optimal architecture could be an important missing piece for selfsupervised learning. Our results show that the current practice in designing SSL objectives β i.e., optimizing for ImageNet performance based on ResNet backbones β could lead to misleading conclusions which do not generalize to other downstream scenarios. Also, the general belief that βthe larger the betterβ in model size do not really hold in SSL, e.g., smaller
 Figure 4: There is no winner in the top vs. bottom battle in SSL. Except for ResNet-ImageNet (top-left), we see no strong trend that suggests either top-heavy or bottom-heavy networks perform better.
ResNets can outperform larger ones even if they are pretrained following the same protocol. Letβs say, based on these observations, one is compelled to hunt for a new architecture geared specifically towards SSL. Our top vs. bottom analysis suggests that it can be extremely tricky to find the right architecture topology with optimal parameter allocation across different layers. All this suggests that it is time to consider moving beyond handcrafted architectures in SSL and start thinking about searching for optimal architectures as part of self-supervised learning objectives.
# 4 NEURAL ARCHITECTURE SEARCH FOR SSL
We turn to the idea of learning both the architecture topology and its network weights in an SSL framework, using NAS to improve SSL (rather than using SSL to improve NAS). It is important to draw a clear distinction between our idea and prior work that used SSL to improve NAS (Li et al., 2021; Liu et al., 2020; 2019; Yan et al., 2020; Zhang et al., 2021b) as well as work that used NAS to improve supervised learning (Elsken et al., 2019); our goal here is to show the benefit of harnessing NAS in aid of SSL and not for comparison with more recent SOTA NAS approaches.
While examining this idea appears to be straightforward, it requires careful design of experiments. The biggest hurdle is that both NAS and SSL require heavy compute resources; the former needs a search space large enough to cover a comprehensive range of architecture topologies, while the latter requires large datasets and batch sizes to be effective. This calls for an efficient framework to conduct our study. Furthermore, we need datasets large enough to pretrain the models on, and different enough to investigate the importance of data-dependent architectures in SSL. To meet our desiderata, we choose ProxylessNAS (Cai et al., 2018) as our NAS algorithm, MobileNet as our search space, and ImageNet-1K and iNat2021 (Van Horn et al., 2021) as our pretraining datasets.
 Figure 5: Samples from datasets used in our study. We choose these datasets because of the apparent domain shift across them. ImageNet contains general yet coarsely categorized images compared to iNat2021, which contains an order of magnitude higher number of fine-grained categories; although some images look similar to each other, every image shown belongs to a different category highlighting the fine-grained nature of this dataset. The downstream datasets, except for CIFAR, are similarly fine-grained but on different domains.
# 4.1 EXPERIMENTAL SETUP
SSL objective. We use SimCLR (Chen et al., 2020a), one of the most well-established contrastive SSL framework. We follow the same augmentation methods and hyperparameter settings as in Chen et al. (2020a). While more recent SSL works exist (Caron et al., 2020; Chen & He, 2021), they are similar to SimCLR by utilizing a contrastive learning based objective. We adopt SimCLR for its simplicity and leave analysis of other SSL approaches for future work.
NAS algorithm. We choose ProxylessNAS for two reasons: efficiency and flexibility. One-shot NAS algorithms produce an architecture topology in a two-step process. They first find an optimal cell structure by solving a proxy task over a small dataset (e.g., CIFAR-10) and a smaller architecture (e.g., 8 cells), and then stack/repeat the best found cell topology for the target task (e.g., ImageNet with 20 cells). This reduces complexity at the cost of flexibility and introduces an optimization gap (Chen et al., 2021), requiring strong correlation between proxy and the actual target datasets. In contrast, ProxylessNAS produces an architecture by directly optimizing on a target task, as it can significantly ameliorate memory requirements of one-shot NAS methods. To ensure flexibility, it uses a βsupernetβ with a broad range of candidate operations orchestrating depth (via zero operations), width (via wider convolutions), and block structure (by allowing for operations to differ by level). At each training step, it optimizes one βsubnetβ on the target task as a surrogate, which greatly reduces compute and memory requirements.
Datasets. We use ImageNet-1K and iNat2021 to pretrain our models and evaluate them on their validation sets as well as on 10 downstream datasets used in Section 3. We deliberately choose the two pretraining datasets as they exhibit widely different characteristics, i.e., ImageNet-1K contains a variety of objects and scenes, while iNat2021 contains fine-grained species covering the tree of life. The former contains many inorganic object categories not present in the latter. This creates a domain gap, which allows us to investigate the importance of data-dependent architectures in SSL.
iNat2021 contains 2.7 million images (twice the size of ImageNet) representing 10K species (ten times more than ImageNet). To investigate the effect of dataset size during architecture search and pretraining, we use both the full and the mini versions of iNat2021 β the latter contains 500K images representing the same 10K classes. This gives us pretraining datasets at three different scales: 500K (iNat2021-mini), 1.2M (ImageNet), 2.7M (iNat2021).
Implementation details. For ProxylessNAS, we replace the original supervised classification loss with the contrastive loss of SimCLR and remove the latency loss as we currently do not consider hardware-constrained scenarios. We follow the original training schedule, i.e., a warmup phase for 40 epochs, which optimizes only the network weights and not the NAS parameters, followed by a search phase for 120 epochs. We use the SGD optimizer for network weights and the ADAM optimizer for NAS parameters, using initial learning rates of 0.25 and 0.1, respectively, and use the cosine decay schedule for both.
To make our experiments tractable, we use the MobileNetV2 search space which typically yields 3 to 18 million parameters; the ResNet search space is larger, yielding 20 to 60 million parameters. Working with smaller models means we can use large batch sizes, which is important for contrastive learning to work effectively; we use the batch size 640 given our computational budget. The candidate set of NAS operations consists of mobile inverted bottleneck convolution (MBConv) with kernel sizes $\{ 3 , 5 , 7 \}$ , expansion ratios $\{ 3 , 6 \}$ and zero operations. A higher expansion ratio enables a wider network with more channels for convolutions, while zero operations allow for choosing to remove operations, thereby learning the optimal depth. Once the search is done, we take the architecture and discard the learned weights; we train it again from scratch using the SimCLR objective on different datasets. This allows us to compare different architectures on fair ground. After pretraining, we conduct linear evaluation on all downstream datasets.
# 4.2 RESULTS AND DISCUSSION
Self-supervised architectures outperform handcrafted architectures in SSL. Table 1 compares our self-supervised architectures to MobileNetV2 and ResNet18/50, by searching, pretraining, and evaluating on ImageNet-1K, iNat2021 and iNat2021-mini. We report linear evaluation results on validation splits. The results show that our selfsupervised architectures outperform MobileNetV2 by a large margin, even with similar parameters (about 3M).
Table 1: Searched architectures vs. handcrafted architecture results. We search, pretrain, and evaluate ours on each of the three datasets in the last three columns. β SOTA results (in gray) from Chen et al. (2020a) for ImageNet and Cole et al. (2021) for iNat21 require larger batch sizes and longer training.
<table><tr><td>Model</td><td>Params</td><td>Batch</td><td>Epochs</td><td>ImageNet</td><td>iNat21</td><td>iNat21-mini</td></tr><tr><td>MobileV2</td><td>3.5M</td><td>640</td><td>100</td><td>41.9</td><td>30.2</td><td>13.6</td></tr><tr><td>Ours</td><td>3.3M</td><td>640</td><td>100</td><td>55.3</td><td>40.3</td><td>14.7</td></tr><tr><td>ResNet18</td><td>11M</td><td>640</td><td>100</td><td>49.8</td><td>30.3</td><td>20.1</td></tr><tr><td>ResNet50</td><td>23.5M</td><td>640</td><td>100</td><td>58.9</td><td>41.3</td><td>23.4</td></tr><tr><td>Ours</td><td>12-18M</td><td>640</td><td>100</td><td>59.1</td><td>43.8</td><td>25.1</td></tr><tr><td>ResNet50</td><td>23.5M</td><td>4096</td><td>1000</td><td>69.3t</td><td>50.6t</td><td>-</td></tr></table>
The self-supervised architectures also beat ResNet18 and ResNet50, with even smaller model size than ResNet50. The superior downstream performance of our approach should not be attributed solely to NAS, as the architecture search was performed without ever solving the downstream tasks. It is rather the incorporation of NAS into SSL that improved the quality of representations, leading to downstream performance boost. This shows the effectiveness of learning both the architecture topology and its weights in SSL.
Do self-supervised architectures generalize well to different data distributions? We take the three architectures searched on each dataset, discard their learned weights, and pretrain them on each dataset, yielding 9 pretrained models. We then evaluate the performance directly on validation splits of the respective datasets. Table 2 shows that transferring an architecture from $\mathrm { i N a t } 2 0 2 1$ to ImageNet leads to a marginal
Table 2: Self-supervised architecture transfer results. We evaluate architectures in the cross-dataset setting, pretraining and evaluating the searched architectures across three datasets (last three columns).
<table><tr><td>Searched on</td><td>Params</td><td>ImageNet</td><td>iNat21</td><td>iNat21-mini</td></tr><tr><td>ImageNet</td><td>12-18M</td><td>59.1</td><td>21.5</td><td>23.9</td></tr><tr><td>iNat21</td><td>12-18M</td><td>58.3</td><td>43.8</td><td>27.9</td></tr><tr><td>iNat21-mini</td><td>12-18M</td><td>58.0</td><td>22.4</td><td>25.1</td></tr></table>
performance drop compared to an architecture optimized directly on ImageNet $( 5 9 . 1 \%$ to $5 8 . 3 \%$ ); both these architectures still outperform handcrafted ResNet18 $( 4 9 . 8 \% )$ with a comparable model size. However, transferring an architecture from ImageNet to iNat2021 deteriorates performance significantly $( 4 3 . 8 \%$ to $2 1 . { \bar { 5 } } \%$ ). This implies an interesting finding, i.e., iNat21-searched architectures seem to be more resilient to domain shift than ImageNet-searched architectures. This could be due to the difference in dataset size (iNat21 has twice as many images as ImageNet), or due to the fine-grained nature of iNat21 resulting in an overall more difficult instance discrimination task (Chen et al., 2020a) that leads to more discriminative representations. The effect of dataset size on architecture search is also shown on iNat21-mini results. While transferring an architecture from ImageNet to iNat21-mini shows an expected drop in accuracy $( 2 5 . 1 \%$ to $2 3 . 9 \%$ ), transferring from the larger iNat21 improves performance $2 5 . 1 \%$ to $2 7 . 9 \%$ ). As both datasets are in the same domain and only differ in number of samples per class, higher search dataset size is the driving factor behind the gains in accuracy while pretraining on a smaller version of the dataset.
Downstream transfer experiments. The results above show that self-supervised architectures are superior to handcrafted architectures when tested in in-distribution settings, which might reflect a practical use case of self-supervised pretraining in the real-world setting (e.g., one has access to only small labeled but large unlabeled data from the same distribution). We now evaluate our approach on a downstream transfer scenario with possible domain shift and with much smaller datasets. To this end, we again use the 10 downstream tasks used in Section 3, which contain datasets coming from both in-distributions and out-of-distributions relative to the pretraining datasets.
Table 3: Downstream transfer results. We categorize downstream datasets as in-distribution (green) and outof-distribution (red) relative to the pretraining dataset based on class overlap; best viewed in color. We see that self-supervised architectures generally perform better on in-distribution downstream scenarios.
<table><tr><td>Pretrain Dataset</td><td>Arch.</td><td>Params</td><td>Pretrain Val. Set</td><td>CUB</td><td>NABirds</td><td>CIFAR10</td><td>Oxford Flowers</td><td>Stanford Dogs</td><td>Food101</td><td>Sport</td><td>Stanford Cars</td><td>MIT67</td><td>FGVC Aircraft</td></tr><tr><td rowspan="4">ImNet</td><td>MobileV2</td><td>3.5M</td><td>41.9</td><td>20.1</td><td>14.2</td><td>75.8</td><td>85.4</td><td>35.7</td><td>51.6</td><td>94.0</td><td>26.4</td><td>57.5</td><td>35.8</td></tr><tr><td>Ours</td><td>3.3M</td><td>55.3</td><td>31.8</td><td>24.4</td><td>78.8</td><td>91.7</td><td>49.2</td><td>61.7</td><td>94.3</td><td>30.4</td><td>62.5</td><td>38.1</td></tr><tr><td>ResNet18</td><td>11M</td><td>49.8</td><td>27.0</td><td>19.0</td><td>79.9</td><td>89.9</td><td>44.1</td><td>55.8</td><td>94.6</td><td>27.8</td><td>62.1</td><td>36.7</td></tr><tr><td>ResNet50</td><td>23.5M</td><td>58.9</td><td>31.4</td><td>24.6</td><td>85.9</td><td>92.8</td><td>52.3</td><td>65.7</td><td>94.3</td><td>35.1</td><td>69.6</td><td>42.0</td></tr><tr><td rowspan="3">iNat21</td><td>Ours</td><td>3-18M</td><td>59.1</td><td>34.3</td><td>26.1</td><td>81.8</td><td>92.2</td><td>51.0</td><td>64.7</td><td>94.7</td><td>33.2</td><td>66.1</td><td>39.4</td></tr><tr><td>ResNet18</td><td>11M</td><td>30.3</td><td>26.1</td><td>19.0</td><td>73.2</td><td>92.8</td><td>31.3</td><td>55.3</td><td>92.1</td><td>18.9</td><td>49.9</td><td>32.7</td></tr><tr><td>ResNet50</td><td>23.5M</td><td>41.3</td><td>31.2</td><td>23.2</td><td>75.1</td><td>95.1</td><td>39.7</td><td>65.1</td><td>94.3</td><td>22.3</td><td>55.0</td><td>37.6</td></tr><tr><td></td><td>Ours</td><td>3-18M</td><td>43.8</td><td>32.7</td><td>24.1</td><td>76.1</td><td>94.7</td><td>39.0</td><td>63.1</td><td>93.1</td><td>20.1</td><td>49.0</td><td>34.9</td></tr></table>
Table 3 summarizes the results (we color code in/out-of-distribution datasets based on our crude categorization; see appendix for our justification). We first compare our self-supervised architectures to MobileNetV2 in the same parameter range (3.5M vs $3 . 3 \mathbf { M }$ ; top two rows). We notice that self-supervised architectures significantly outperform MobileNetV2 in all datasets regardless of distributional shift. This is encouraging (i.e., self-supervised architectures can learn generalizable representations) but at the same time not totally surprising (i.e., MobileNet is optimized for efficiency and not for accuracy). Next, we compare ours to ResNet18 that has a similar parameter range although belonging to a class of architectures much different from our search space. Ours outperforms ResNet18 on all pretraining and evaluation datasets by a considerable margin. This shows that our approach is generalizable and can outperform architectures in the ResNet18 search space even though they are generally more computationally expensive than the MobileNet search space.
Finally, we compare ours to ResNet50 which is computationally heavier compared to ResNet18. We preface our analysis with a caveat that our self-supervised architectures are almost half the capacity of ResNet50, limiting their representational power. Keeping this in mind, we see that our approach starts to fail in some of the in-distribution and all of the out-of-distribution scenarios (red shaded cells). This is somewhat disappointing but perhaps expected: self-supervised architectures naturally encode inductive biases specific to the dataset they were optimized on. When a distributional shift happens, their performance can start deteriorating because out-of-domain data might require a different set of inductive biases. The strong performance by ResNet50 imply that the model might be striking the right balance across those datasets in terms of inductive biases, but our results in Table 1 and 2 show that ResNet50 can be less effective on newly developed datasets such as iNat2021.
# 5 CONCLUSION
This work lays the ground for moving beyond handcrafted architectures in SSL. By conducting large-scale experiments with 116 architectures and 11 downstream tasks, we established extensive empirical evidence showing that there isnβt one architecture that performs consistently well across different downstream scenarios in SSL. Motivated by this, we proposed to move beyond handcrafted architectures and learn both an architecture topology and its network weights in SSL. We provided convincing results demonstrating that the self-supervised architectures significantly outperform handcrafted MobileNetV2 and ResNet18 architectures on 11 downstream tasks, and competitively with ResNet50 even with almost half the model size. We re-emphasize that improvements are not solely due to NAS, as the architecture search was performed by solving SSL and not by optimizing directly on downstream tasks as in the typical NAS setting.
Our work barely scratches the surface and opens up many doors for future directions. Will our findings hold for different architectures such as Transformers and different modalities such as video and text? How can we make architecture search more effective for SSL? Can ideas from domain generalization improve the transferability of self-supervised architectures in the out-of-distribution setting? Or is it even the right idea to expect learned architectures to generalize to widely different domains? We hope the readers are as excited as us to investigate these challenging questions.
# REFERENCES
Sanjeev Arora, Hrishikesh Khandeparkar, Mikhail Khodak, Orestis Plevrakis, and Nikunj Saunshi. A theoretical analysis of contrastive unsupervised representation learning. arXiv preprint arXiv:1902.09229, 2019. 1
Hangbo Bao, Li Dong, and Furu Wei. Beit: Bert pre-training of image transformers. arXiv preprint arXiv:2106.08254, 2021. 1
Han Cai, Ligeng Zhu, and Song Han. Proxylessnas: Direct neural architecture search on target task and hardware. arXiv preprint arXiv:1812.00332, 2018. 2, 6, 15
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, pp. 132β149, 2018. 1
Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. arXiv preprint arXiv:2006.09882, 2020. 1, 3, 7
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 IEEE/CVF International Conference on Computer Vision, pp. 9650β9660, 2021. 3
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, 2020a. 1, 2, 3, 4, 7, 8, 15, 17, 18
Ting Chen, Simon Kornblith, Kevin Swersky, Mohammad Norouzi, and Geoffrey E Hinton. Big self-supervised models are strong semi-supervised learners. Advances in neural information processing systems, 33:22243β22255, 2020b. 5
Xin Chen, Lingxi Xie, Jun Wu, and Qi Tian. Progressive darts: Bridging the optimization gap for nas in the wild. International Journal of Computer Vision, 129(3):638β655, 2021. 7
Xinlei Chen and Kaiming He. Exploring simple siamese representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 15750β15758, 2021. 1, 3, 7
Xinlei Chen, Haoqi Fan, Ross Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. arXiv preprint arXiv:2003.04297, 2020c. 3
Yu Cheng, Duo Wang, Pan Zhou, and Tao Zhang. A survey of model compression and acceleration for deep neural networks. arXiv preprint arXiv:1710.09282, 2017. 3
Elijah Cole, Xuan Yang, Kimberly Wilber, Oisin Mac Aodha, and Serge Belongie. When does contrastive visual representation learning work? arXiv preprint arXiv:2105.05837, 2021. 1, 8
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. 2, 16, 17, 18, 20
Debadeepta Dey, Shital Shah, and Sebastien Bubeck. Fear: A simple lightweight method to rank architectures. arXiv preprint arXiv:2106.04010, 2021. 2
Thomas Elsken, Jan Hendrik Metzen, Frank Hutter, et al. Neural architecture search: A survey. J. Mach. Learn. Res., 20(55):1β21, 2019. 3, 6
Linus Ericsson, Henry Gouk, and Timothy M Hospedales. How well do self-supervised models transfer? In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 5414β5423, 2021. 3
Christoph Feichtenhofer, Haoqi Fan, Bo Xiong, Ross Girshick, and Kaiming He. A large-scale study on unsupervised spatiotemporal representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3299β3309, 2021. 1
Spyros Gidaris, Praveer Singh, and Nikos Komodakis. Unsupervised representation learning by predicting image rotations. arXiv preprint arXiv:1803.07728, 2018. 1, 3
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, et al. Bootstrap your own latent: A new approach to self-supervised learning. arXiv preprint arXiv:2006.07733, 2020. 1, 2
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770β778, 2016. 1, 2
Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9729β9738, 2020. 1, 2
Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr Dollar, and Ross Girshick. Masked au- Β΄ toencoders are scalable vision learners. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16000β16009, 2022. 1, 2
Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4700β4708, 2017. 6
Aditya Khosla, Nityananda Jayadevaprakash, Bangpeng Yao, and Fei-Fei Li. Novel dataset for finegrained image categorization: Stanford dogs. In Proc. CVPR Workshop on Fine-Grained Visual Categorization (FGVC), volume 2. Citeseer, 2011. 16, 20
Alexander Kirillov, Kaiming He, Ross Girshick, Carsten Rother, and Piotr Dollar. Panoptic segmen- Β΄ tation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 9404β9413, 2019. 3
Alexander Kolesnikov, Xiaohua Zhai, and Lucas Beyer. Revisiting self-supervised visual representation learning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pp. 1920β1929, 2019. 2, 3
Simon Kornblith, Jonathon Shlens, and Quoc V Le. Do better imagenet models transfer better? In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2661β2671, 2019. 3, 4
Jonathan Krause, Michael Stark, Jia Deng, and Li Fei-Fei. 3d object representations for fine-grained categorization. In Proceedings of the IEEE international conference on computer vision workshops, pp. 554β561, 2013. 16, 20
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. 2009. 16, 20
Changlin Li, Tao Tang, Guangrun Wang, Jiefeng Peng, Bing Wang, Xiaodan Liang, and Xiaojun Chang. Bossnas: Exploring hybrid cnn-transformers with block-wisely self-supervised neural architecture search. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 12281β12291, 2021. 3, 6
Li-Jia Li and Li Fei-Fei. What, where and who? classifying events by scene and object recognition. In 2007 IEEE 11th international conference on computer vision, pp. 1β8. IEEE, 2007. 16, 20
Feng Liang, Chen Lin, Ronghao Guo, Ming Sun, Wei Wu, Junjie Yan, and Wanli Ouyang. Computation reallocation for object detection. arXiv preprint arXiv:1912.11234, 2019. 6
Chenxi Liu, Piotr Dollar, Kaiming He, Ross Girshick, Alan Yuille, and Saining Xie. Are labels Β΄ necessary for neural architecture search? In European Conference on Computer Vision, pp. 798β 813. Springer, 2020. 3, 6
Hanxiao Liu, Karen Simonyan, and Yiming Yang. DARTS: Differentiable architecture search. In International Conference on Learning Representations, 2019. URL https://openreview. net/forum?id=S1eYHoC5FX. 3, 6
Subhransu Maji, Esa Rahtu, Juho Kannala, Matthew Blaschko, and Andrea Vedaldi. Fine-grained visual classification of aircraft. arXiv preprint arXiv:1306.5151, 2013. 16
Joseph Mellor, Jack Turner, Amos Storkey, and Elliot J. Crowley. Neural architecture search without training, 2021. 3
Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. 2011. 16, 20
Maria-Elena Nilsback and Andrew Zisserman. Automated flower classification over a large number of classes. In 2008 Sixth Indian Conference on Computer Vision, Graphics & Image Processing, pp. 722β729. IEEE, 2008. 16, 20
Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018. 1
Ben Poole, Sherjil Ozair, Aaron Van Den Oord, Alex Alemi, and George Tucker. On variational bounds of mutual information. In International Conference on Machine Learning, pp. 5171β 5180. PMLR, 2019. 1
Ariadna Quattoni and Antonio Torralba. Recognizing indoor scenes. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pp. 413β420. IEEE, 2009. 16, 20
Maithra Raghu, Ben Poole, Jon Kleinberg, Surya Ganguli, and Jascha Sohl-Dickstein. On the expressive power of deep neural networks. In international conference on machine learning, pp. 2847β2854. PMLR, 2017. 2, 5
Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4510β4520, 2018. 2
Terrence J Sejnowski. The unreasonable effectiveness of deep learning in artificial intelligence. Proceedings of the National Academy of Sciences, 117(48):30033β30038, 2020. 1
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014. 6
Chen Sun, Abhinav Shrivastava, Saurabh Singh, and Abhinav Gupta. Revisiting unreasonable effectiveness of data in deep learning era. In Proceedings of the IEEE international conference on computer vision, pp. 843β852, 2017. 1
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818β2826, 2016. 6
Lukas Tuggener, Jurgen Schmidhuber, and Thilo Stadelmann. Is it enough to optimize cnn architec-Β¨ tures on imagenet? arXiv preprint arXiv:2103.09108, 2021. 2
Grant Van Horn, Elijah Cole, Sara Beery, Kimberly Wilber, Serge Belongie, and Oisin Mac Aodha. Benchmarking representation learning for natural world image collections. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12884β12893, 2021. 2, 6
P. Welinder, S. Branson, T. Mita, C. Wah, F. Schroff, S. Belongie, and P. Perona. Caltech-UCSD Birds 200. Technical Report CNS-TR-2010-001, California Institute of Technology, 2010. 16, 20
Yuxin Wu, Alexander Kirillov, Francisco Massa, Wan-Yen Lo, and Ross Girshick. Detectron2. 2019. URL https://github. com/facebookresearch/detectron2, 2(3), 2019. 3
Shen Yan, Yu Zheng, Wei Ao, Xiao Zeng, and Mi Zhang. Does unsupervised architecture representation learning help neural architecture search? Advances in Neural Information Processing Systems, 33, 2020. 3, 6
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning (still) requires rethinking generalization. Communications of the ACM, 64(3):107β 115, 2021a. 2
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, pp. 586β595, 2018. 1
Xuanyang Zhang, Pengfei Hou, Xiangyu Zhang, and Jian Sun. Neural architecture search with random labels. arXiv preprint arXiv:2101.11834, 2021b. 3, 6
# APPENDIX
Fig. 6 provides an overview of our work. We show that no single handcrafted architecture performs consistently well across different tasks. It is therefore imperative to optimize for architecture topologies along with network weights for a specific task. Through extensive empirical results we show that such self-supervised architectures outperform their handcrafted counterparts in the same search space on the respective tasks.
 Figure 6: Conventional SSL frameworks learn network weights for a fixed handcrafted architecture (left). We show that learning architecture topologies along with their weights can improve performance in SSL (right).
# A SUPERVISED TRAINING PERFORMANCE OF SELF-SUPERVISED ARCHITECTURES
In addition to evaluating the performance of the searched architectures for SSL, we analyze their supervised training performance. We use the searched architectures and directly train them, from scratch without any pretraining, on downstream datasets using the supervised labels. Results are summarized in Table 4. We include architectures searched on ImageNet and iNat21, and MobileNetV2 for reference. It shows the searched architectures perform well even in the supervised setting, outperforming the handcrafted MobileNetV2 on most of the downstream datasets. However, a performance degradation is observed in out-of-distribution datasets like Stanford Cars and FGVC Aircraft. This is in line with the discussion in Section 4.2 of the main paper where the searched architecture performances deteriorate with distributional shift. Nevertheless, for the more in-distribution datasets, we obtain higher accuracies showing that the searched architectures are suitable for supervised training as well.
Table 4: Supervised performance of searched architectures.
<table><tr><td></td><td>CUB</td><td>CIFAR10</td><td>CIFAR100</td><td>Food</td><td>Flowers</td><td>Sport</td><td>Cars</td><td>Aircraft</td></tr><tr><td>MobileNetV2</td><td>58.2</td><td>93.7</td><td>71.9</td><td>80.8</td><td>90.0</td><td>94.2</td><td>88.6</td><td>81.4</td></tr><tr><td>Ours (ImNet)</td><td>57.9</td><td>93.1</td><td>74.7</td><td>78.1</td><td>96.7</td><td>95.0</td><td>71.0</td><td>75.5</td></tr><tr><td>Ours (iNat21)</td><td>64.5</td><td>93.9</td><td>75.8</td><td>81.6</td><td>98.1</td><td>96.3</td><td>72.3</td><td>72.9</td></tr></table>
# B CLASS MAPPING FROM IMAGENET TO DOWNSTREAM DATASETS
We provide a justification for characterizing downstream datasets as in-distribution/out-ofdistribution with respect to ImageNet as shown in Table 3 of the main paper. We provide a rough class mapping between ImageNet and the 10 downstream datasets. Note that obtaining an exact class mapping is difficult due to only an approximate mapping existing between any 2 datasets. In addition, there can be classes which contribute to improved features for another class while still being semantically different. For example, zebra (n02391049) can contribute to improved features for horses (sorrel-n02389026) due to similar shapes. We now list datasets with corresponding ImageNet classes/superclasses. While some superclasses can contain additional subclasses in the WordNet hierarchy, we restrict to only those classes in the ImageNet-1k dataset. Numbers in bracket denote the total number of classes roughly overlapping.
β’ CIFAR-10 (270): vehicle (n4524313), bird (n1503061), feline (n2120997), frog (n1639765), dog (n2084071), sorrel (n2389026) β’ Stanford Dogs (120): dog (n2084071) β’ CUB (60): bird (n1503061) β’ NABirds (60): bird (n1503061) β’ Food101 (20): nutriment (n7570720), beverage (n7881800), foodstuff (n7566340), sandwich (n7695965), bagel (n7693725), guacamole (n7583066), chocolate sauce (n7836838), carbonara (n7831146), french loaf (n7684084), pretzel (n7695742) β’ Stanford Cars (10): car (n2958343) β’ FGVC Aircraft (3): airliner (n2690373), warplane (n4552348), airship (n2692877) β’ Oxford Flowers (2): yellow ladyβs slipper (n12057211), daisy (n11939491) β’ MIT67 (0): - β’ Sports(0): -
Due to the inductive biases encoded during the search process specific to the dataset it is searched on, the self-supervised architecture performs well on more in-distribution datasets like CUB or NABirds. However, we see that for datasets like Stanford Cars and subsequent ones, there is little direct class overlap with ImageNet classes. This leads to lesser images being available for self-supervised pretraining which are in-distribution for these datasets. Consequently, due to the relatively out-of-distribution nature of these datasets we see in Table 3 of the main paper, our selfsupervised architectures are outperformed by the ResNet-50 baseline.
# C ADDITIONAL IMPLEMENTATION DETAILS
We sample ResNet architectures by varying the number of blocks at each of the 4 stages choosing from the set of $2 , 3 , 4$ blocks and choose the ones in the parameter range shown in Fig. 3 while also fitting in GPU memory. For MobileNets, we have 7 sequences (stages) and a higher variation of the number of blocks from [2-6] while also choosing the width parameter from the set $1 . 0 , 1 . 2 , 1 . 4 , 1 . 6 , 1 . 8 , 2 . 0$ and choose the ones in the 2M-7M parameter range and fitting in GPU memory. Note that a high number of blocks in the earlier stages take significantly more GPU memory due to larger feature map sizes.
For the architecture search phase, we use the optimizer hyperparameters as explained in Sec. 4.1 of the main paper. We use a weight decay of $4 e ^ { - 5 }$ for the weight parameters excluding batch normalization parameters. The initial convolution is a $3 { \tt X } 3$ convolution with stride 2. The network consists of 6 stages with 4 cells in the first 5 stages and 1 cell in the last stage. By default, the number of channels at each stage is 24, 40, 80, 96, 192, 320, which is multiplied by a constant width multiplier. We downsample it by a factor of 2 at the beginning of the first, second, third and fifth stage. Other architecture details are the default ones used in Cai et al. (2018). We use the same projection head as used normally for SimCLR Chen et al. (2020a) on top of the backbone network, which is a 2048 dimensional hidden layer and 128 dimensional output layer. For evaluation, we remove the projection head and use the output of the network backbone as the feature extractor. Augmentations are the same as in SimCLR with random resize scaling and cropping, flipping and color jitter. A temperature value of $\tau = 0 . 1$ is set for the contrastive loss.
 Figure 7: Self-supervised architectures for different pretraining datasets. MB3 and MB6 are the mobile inverted convolutions with expansion ratio of 3 and 6 respectively. We see that the majority of the preferred convolutions is MB6 $7 \times 7$ suggesting that the network prefers convolutions with more parameters for the self-supervised regime due to lots of data. For smaller datasets like iNat21Mini, MB6 convolutions are not as strongly preferred.
# D VISUALIZING SELF-SUPERVISED ARCHITECTURES FOR DIFFERENT PRETRAINING DATASETS
We visualize the types of convolutions searched at a $1 . 7 5 \mathrm { x }$ width multiplier for the 3 different pretraining datasets: ImageNet, iNat21 and iNat21Mini. Results are shown in Fig. 7. MB3 and MB6 are the mobile inverted convolutions with expansion ratio of 3 and 6 respectively. The grey lines denote the downsampling of image due to strided convolutions. All architectures are followed by a pooling layer to reduce the image size to $1 \times 1$ . In contrast to standard handcrafted architectures, larger $7 \times 7$ convolutions are preferred even in the later stages of the network. We also see that the majority of the preferred convolutions is MB6 $7 \times 7$ suggesting that the network prefers convolutions with more parameters for the self-supervised regime due to lots of data. This is less preferred in smaller datasets like iNat21Mini where MB3 convolutions are common especially in earlier stages of the network. It is difficult to draw conclusions on the type of network preferred between ImageNet and iNat21 showing that it is imperative to search for an optimal architecture rather than handcraft them.
# E DOWNSTREAM DATASET PERFORMANCE CORRELATION WITH IMAGENET
We show the downstream dataset correlation for all 10 downstream datasets in addition to ImageNet1K Deng et al. (2009): CIFAR10/100 Krizhevsky et al. (2009), Stanford Cars Krause et al. (2013) and Dogs Khosla et al. (2011), CUB-200 Welinder et al. (2010), MIT-67 Quattoni & Torralba (2009), SVHN Netzer et al. (2011), Flowers-102 Nilsback & Zisserman (2008), FGVC-Aircraft Maji et al. (2013), Sports8 Li & Fei-Fei (2007). These are shown for both ResNets (Fig. 8) and MobileNets (Fig. 9). We see similar results for the 5 datasets in addition to those shown in Fig. 3 of main paper. High correlation exists for datasets which are visually similar to ImageNet while it is less correlated for datasets which are out of domain. For MobileNets this correlation is even less pronounced with high variance in performance at higher ImageNet accuracies.
 Figure 8: ImageNet performance correlation with 10 different downstream datasets for various ResNets. We show linear evaluation top-1 accuracy of ImageNet $\mathbf { \dot { x } }$ -axis) vs. different downstream datasets (y-axis) obtained from variations of ResNet; all models are pretrained on ImageNet-1K Deng et al. (2009) using SimCLR Chen et al. (2020a) under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
 Figure 9: ImageNet performance correlation with 10 different downstream datasets for various MobileNets. We show linear evaluation top-1 accuracy of ImageNet $\mathbf { \widetilde { x } }$ -axis) vs. different downstream datasets (y-axis) obtained from variations of MobileNet; all models are pretrained on ImageNet-1K Deng et al. (2009) using SimCLR Chen et al. (2020a) under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
 Figure 10: Dataset performance correlation with 10 different datasets for various ResNets. We show the model size in terms of parameter counts $\mathbf { \widetilde { x } }$ -axis) vs. top-1 accuracy on different datasets obtained from variations of ResNet-like architectures; all models are pretrained on ImageNet-1K Deng et al. (2009) using SimCLR Chen et al. (2020a) under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
 Figure 11: Dataset performance correlation with 10 different datasets for various MobileNets. We show the model size in terms of parameter counts $\mathbf { \widetilde { x } }$ -axis) vs. top-1 accuracy on different datasets obtained from variations of MobileNet-like architectures; all models are pretrained on ImageNet-1K Deng et al. (2009) using SimCLR Chen et al. (2020a) under the same protocol. The solid lines and shaded areas indicate fitted regression models and their confidence intervals.
 Figure 12: Linear and rank correlation of ResNets between different pairs of 11 datasets We show correlation between every pair of top-1 accuracy on 11 downstream tasks obtained from ImageNet-pretrained ResNets. We see no strong correlation except for ones highly similar to the data the models were originally pretrained on, e.g., CIFAR-10/100 and Dogs120.

 Figure 13: Linear and rank correlation of MobileNets between different pairs of 11 datasets We show correlation between every pair of top-1 accuracy on 11 downstream tasks obtained from ImageNet-pretrained MobileNets. The correlation

# F DATASET PERFORMANCE AS A FUNCTION OF NUMBER OF PARAMETERS
We show the dataset correlation with respect to number of parameters for 5 more datasets in addition to that shown in Fig. 4 of main paper. Fig. 10 summarizes the results for ResNets while Fig. 11 shows results for MobileNets. We see that similar results hold for the additional 5 datasets where more parameters, and consequently larger networks, does not always lead to better downstream performance.
# G LINEAR AND RANK CORRELATION FOR RESNETS/MOBILENETS
We show the summary of the correlation across different datasets for both ResNets (Fig. 12) and MobileNets (Fig. 13). In addition to Spearmanβs rank correlation coefficient, we also show Pearsonβs linear correlation coefficient. While Pearsonβs linear coefficient is higher in the case of MobileNets, the linear fit still exhibits high variance for higher ImageNet accuracies, as seen in Fig. 9.
 Figure 14: ImageNet performance correlation with 10 different downstream datasets for various ResNets, MobileNets and searched architectures. The searched architectures outperform MobileNets while being comparable with ResNets at fewer parameters.
# H DATASET LICENSES
Table 5 lists some datasets we used and their licenses.
Table 5: Licenses of datasets.
<table><tr><td>Dataset</td><td>License</td></tr><tr><td>CIFAR-10 Krizhevsky et al. (2009)</td><td>MIT</td></tr><tr><td>CIFAR-100 Krizhevsky et al. (2009)</td><td>MIT</td></tr><tr><td>ImageNet Deng et al. (2009)</td><td>BSD 3-Clause</td></tr><tr><td>Sport8 Li & Fei-Fei (2007)</td><td>CCO:Public Domain</td></tr><tr><td>Stanford Dogs Khosla et al. (2011)</td><td>BSD3-Clause</td></tr><tr><td>Stanford Cars Krause et al. (2013)</td><td>BSD 3-Clause</td></tr><tr><td>CUB-200 Welinder et al. (2010)</td><td>Data files @ Original Authors</td></tr><tr><td>MIT-67 Quattoni & Torralba a (2009)</td><td>MIT</td></tr><tr><td>SVHN Netzer et al. (2011)</td><td>CCO:Public Domain</td></tr><tr><td>Flowers-102 Nilsback & Zisserman (2008)</td><td>GNU General Public License,version 2</td></tr></table>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456# DIFFEDIT: DIFFUSION-BASED SEMANTIC IMAGE EDITING WITH MASK GUIDANCE
Guillaume Couairon, Jakob Verbeek, Holger Schwenk Meta AI {gcouairon,jjverbeek, schwenk}@meta.com
Matthieu Cord Sorbonne Universite, Valeo.aiΒ΄ matthieu.cord@ sorbonne-universite.fr
# ABSTRACT
Image generation has recently seen tremendous advances, with diffusion models allowing to synthesize convincing images for a large variety of text prompts. In this article, we propose DIFFEDIT, a method to take advantage of text-conditioned diffusion models for the task of semantic image editing, where the goal is to edit an image based on a text query. Semantic image editing is an extension of image generation, with the additional constraint that the generated image should be as similar as possible to a given input image. Current editing methods based on diffusion models usually require to provide a mask, making the task much easier by treating it as a conditional inpainting task. In contrast, our main contribution is able to automatically generate a mask highlighting regions of the input image that need to be edited, by contrasting predictions of a diffusion model conditioned on different text prompts. Moreover, we rely on latent inference to preserve content in those regions of interest and show excellent synergies with mask-based diffusion. DIFFEDIT achieves state-of-the-art editing performance on ImageNet. In addition, we evaluate semantic image editing in more challenging settings, using imagesdit from the COCO dataset as well as text-based generated images.
 Figure 1: In semantic image editing the goal is to modify an input image based on a textual query, while otherwise leaving the image as close as possible to the original. In our DIFFEDIT approach, a mask generation module determines which part of the image should be edited, and an encoder infers the latents, to provide inputs to a text-conditional diffusion model which produces the image edit.
# 1 INTRODUCTION
Mask The task of semantic image editing consists in modifying an input image in accordance with a Generation Masked textual transformation query. For instance, given an image of a bowl of fruits and the query βfruitsβ $ ~ \mathrm { ^ { * } } p e a r s ^ { \prime \prime }$ Module Diffusion , the aim is to produce a novel image where the fruits have been changed into pears, while keeping the bowl and the background as similar as possible to the input image. The text query Encode can also be a more elaborate description like βA basket of fruitsβ. See the example edits obtained with DIFFEDIT in Figure 1. Semantic image editing bears strong similarities with image generation Text Query A basket of fruits and can be viewed as extending text-conditional image generation with an additional constraint: the Mask generated image should be as close as possible to a given input image.
Input Image Module Masked Text-conditional image generation is currently undergoing a revolution, with DALL-E (Ramesh et al., 2021), Cogview (Ding et al., 2021), Make-a-scene (Gafni et al., 2022), Latent Diffusion Models (Rombach et al., 2022), DALL-E 2 (Ramesh et al., 2022) and Imagen (Saharia et al., 2022b), vastly improving state of the art in modelling wide distributions of images and allowing for unprecedented compositionality of concepts in image generation. Scaling these models is a key to their success. State-of-the art models are now trained on vast amounts of data, which requires large computational resources. Similarly to language models pretrained on web-scale data and adapted in downstreams tasks with prompt engineering, the generative power of these big generative models can be harnessed to solve semantic image editing, avoiding to train specialized architectures (Li et al., 2020a; Wang et al., 2022a), or to use costly instance-based optimization (Crowson et al., 2022; Couairon et al., 2022; Patashnik et al., 2021).
Diffusion models are an especially interesting class of model for image editing because of their iterative denoising process starting from random Gaussian noise. This process can be guided through a variety of techniques, like CLIP guidance (Nichol et al., 2021; Avrahami et al., 2022; Crowson, 2021), and inpainting by copy-pasting pixel values outside a user-given mask (Lugmayr et al., 2022). These previous works, however, lack two crucial properties for semantic image editing: (i) inpainting discards information about the input image that should be used in image editing (e.g. changing a dog into a cat should not modify the animalβs color and pose); (ii) a mask must be provided as input to tell the diffusion model what parts of the image should be edited. We believe that while drawing masks is common on image editing tools like Photoshop, language-guided editing offers a more intuitive interface to modify images that requires less effort from users.
Conditioning a diffusion model on an input image can also be done without a mask, e.g. by considering the distance to input image as a loss function (Crowson, 2021; Choi et al., 2021), or by using a noised version of the input image as a starting point for the denoising process as in SDEdit (Meng et al., 2021). However, these editing methods tend to modify the entire image, whereas we aim for localized edits. Furthermore, adding noise to the input image discards important information, both inside the region that should be edited and outside.
To leverage the best of both worlds, we propose DIFFEDIT, an algorithm that leverages a pretrained text-conditional diffusion model for zero-shot semantic image editing, without expensive editingspecific training. DIFFEDIT makes it possible by automatically finding what regions of an input image should be edited given a text query, by contrasting the predictions of a conditional and unconditional diffusion model. We also show how using a reference text describing the input image and similar to the query, can help obtain better masks. Moreover, we demonstrate that using a reverse denoising model, to encode the input image in latent space, rather than simply adding noise to it, allows to better integrate the edited region into the background and produces more subtle and natural edits. See Figure 1 for illustrations. We quantitatively evaluate our approach and compare to prior work using images of the ImageNet and COCO dataset, as well as a set of generated images.
# 2 RELATED WORK
Semantic image editing. The field of image editing encompasses many different tasks, from photo colorization and retouching (Shi et al., 2020), to style transfer (Jing et al., 2019), inserting objects in images (Gafni & Wolf, 2020; Brown et al., 2022), image-to-image translation (Zhu et al., 2017; Saharia et al., 2022a), inpainting (Yu et al., 2018), scene graph manipulation (Dhamo et al., 2020), and placing subjects in novel contexts (Ruiz et al., 2022). We focus on semantic image editing, where the instruction to modify an image is given in natural language. Some approaches involve training an end-to-end architecture with a proxy objective before being adapted to editing at inference time, based on GANs (Li et al., 2020b;a; Ma et al., 2018; Alami Mejjati et al., 2018; Mo et al., 2018) or transformers (Wang et al., 2022a; Brown et al., 2022; Issenhuth et al., 2021). Others (Crowson et al., 2022; Couairon et al., 2022; Patashnik et al., 2021; Bar-Tal et al., 2022) rely on optimization of the image itself, or a latent representation of it, to modify an image based on a high-level multimodal objective in an embedding space, typically using CLIP (Radford et al., 2021). These approaches are quite computationnaly intensive, and work best when the optimization is coupled with a powerful generative network. Given a pre-trained generative model such as a GAN, it has also been explored to find directions in the latent space that corresponds to specific semantic edits (Hark Β¨ onen Β¨ et al., 2020; Collins et al., 2020; Shen et al., 2020; Shoshan et al., 2021), which then requires GAN inversion to edit real images (Wang et al., 2022c; Zhu et al., 2020; Grechka et al., 2021).
Image editing with diffusion models. Because diffusion models iteratively refine an image starting from random noise, they are easily adapted for inpainting when a mask is given as input. Song et al.
(2021) proposed to condition the generation process by copy-pasting pixel values from the reference image at each denoising step. Nichol et al. (2021) use a similar technique by copy-pasting pixels in the estimated final version of the image. Wang et al. (2022b) use DDIM encoding of the input image, and then decode on edited sketches or semantic segmentation maps. The gradient of a CLIP score can also be used to match a given text query inside a mask, as in Paint by Word (Bau et al., 2021), local CLIP-guided diffusion (Crowson, 2021), or blended diffusion (Avrahami et al., 2022). Lugmayr et al. (2022) apply a sequence of noise-denoise operations to better inpaint a specific region. There are also a number of methods that do not require an editing mask. In DiffusionCLIP (Kim & Ye, 2021), the weights of the diffusion model themselves are updated via gradient descent from a CLIP loss with a target text. The high computational cost of fine-tuning a diffusion model for each input image, however, makes it impractical as an interactive image editing tool. In SDEdit (Meng et al., 2021) the image is corrupted with Gaussian noise, and then the diffusion network is used to denoise it. While this method is originally designed to transform sketches to real images and to make pixel-based collages more realistic, we adapt it by denoising the image conditionally to the text query. In ILVR (Choi et al., 2021), the decoding process of diffusion model is guided with the constraint that downsampled versions of the input image and decoded image should stay close. Finally, in recent work concurrent to ours, Hertz et al. (2022) propose to edit images by modifying attention maps during the diffusion process.
# 3 DIFFEDIT FRAMEWORK
In this section, we first give an overview of diffusion models. We then describe our DIFFEDIT approach in detail, and provide a theoretical analysis comparing DIFFEDIT with SDEdit.
# 3.1 BACKGROUND: DIFFUSION MODELS, DDIM AND ENCODING
Denoising diffusion probabilistic models (Ho et al., 2020) is a class of generative models that are trained to invert a diffusion process. For a number of timesteps $T$ , the diffusion process gradually adds noise to the input data, until the resulting distribution is (almost) Gaussian. A neural network is then trained to reverse that process, by minimizing the denoising objective
$$\begin{array} { r } { \mathcal { L } = \mathbb { E } _ { \mathbf { x } _ { 0 } , t , \epsilon } \Vert \epsilon - \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) \Vert _ { 2 } ^ { 2 } , } \end{array}$$
where $\epsilon _ { \theta }$ is the noise estimator which aims to find the noise $\mathbf { \epsilon } \gets \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ that is mixed with an input image $\mathbf { x } _ { \mathrm { 0 } }$ to yield $\mathbf { x } _ { t } = \sqrt { \alpha _ { t } } \mathbf { x } _ { 0 } + \sqrt { 1 - \alpha _ { t } } \epsilon$ . The coefficient $\alpha _ { t }$ defines the level of noise and is a decreasing function of the timestep $t$ , with $\alpha _ { 0 } = 1$ (no noise) and $\alpha _ { T } \approx 0$ (almost pure noise).
Song et al. (2021) propose to use $\epsilon _ { \theta }$ to generate new images with the $D D I M$ algorithm: starting from $\mathbf { x } _ { T } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ , the following update rule is applied iteratively until step 0:
$$\mathbf { x } _ { t - 1 } = \sqrt { \alpha _ { t - 1 } } \Bigg ( \frac { \mathbf { x } _ { t } - \sqrt { 1 - \alpha _ { t } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) } { \sqrt { \alpha _ { t } } } \Bigg ) + \sqrt { 1 - \alpha _ { t - 1 } } \epsilon _ { \theta } ( \mathbf { x } _ { t } , t ) .$$
The variable $\mathbf { x }$ is updated by taking small steps in the direction of $\epsilon _ { \theta }$ . Equation 2 can be written as the neural ODE , taking $\mathbf { u } = \mathbf { x } / \sqrt { \alpha }$ and $\tau = \sqrt { 1 / \alpha - 1 }$ :
$$d \mathbf { u } = \epsilon _ { \theta } ( \frac { \mathbf { u } } { \sqrt { 1 + \tau ^ { 2 } } } , t ) d \tau .$$
This allows to view DDIM sampling as an Euler scheme for solving Equation 3 with initial condition $\mathbf u ( t = T ) \sim \mathcal { N } ( \mathbf 0 , \alpha _ { T } \mathbf I )$ . This illustrates that we can use fewer sampling steps during inference than the value of $T$ chosen during training, by using a coarser discretization of the ODE. In the remainder of the paper, we parameterize the timestep $t$ to be between 0 and 1, so that $t = 1$ corresponds to $T$ steps of diffusion in the original formulation. As proposed by Song et al. (2021), we can also use this ODE to encode an image $\mathbf { x } _ { \mathrm { 0 } }$ onto a latent variable ${ \bf x } _ { r }$ for a timestep $r \leq 1$ , by using the boundary condition $\mathbf { u } ( t = 0 ) = \mathbf { x } _ { 0 }$ instead of $\mathbf { u } ( t = 1 )$ , and applying an Euler scheme until timestep $r$ . In the remainder of the paper, we refer to this encoding process as DDIM encoding, we denote the corresponding function that maps $\mathbf { x } _ { \mathrm { 0 } }$ to ${ \bf x } _ { r }$ as $E _ { r }$ , and refer to the variable $r$ as the encoding ratio. Similarly, we note $D _ { r }$ the inverse function that maps ${ \bf x } _ { r }$ to $\mathbf { x } _ { \mathrm { 0 } }$ , which corresponds to regular DDIM decoding. With sufficiently small steps in the Euler scheme, decoding ${ \bf x } _ { r }$ approximately recovers the original image $\mathbf { x } _ { \mathrm { 0 } }$ . This property is particularly interesting in the context of image editing: all the information of the input image $\mathbf { x } _ { \mathrm { 0 } }$ is encoded in ${ \bf x } _ { r }$ , and can be accessed via DDIM sampling.
 Step 1: Compute Mask Figure 2: The three steps of DIFFEDIT. Step 1: we add noise to the input image, and denoise it: once conditioned on the query text, and once conditioned on a reference text (or unconditionally). We derive a mask based on the difference in the denoising results. Step 2: we encode the input image with DDIM, to estimate the latents corresponding to the input image. Step 3: we perform DDIM decoding conditioned on the text query, using the inferred mask to replace the background with pixel values coming from the encoding process at the corresponding timestep.
# 3.2 SEMANTIC IMAGE EDITING WITH DIFFEDIT
In many cases, semantic image edits can be restricted to only a part of the image, leaving other parts unchanged. However, the input text query does not explicitly identify this region, and a naive method could allow for edits all over the image, risking to modify the input in areas where it is not needed. To circumvent this, we propose DIFFEDIT, a method to leverage a text-conditioned diffusion model to infer a mask of the region that needs to be edited. Starting from a DDIM encoding of the input image, DIFFEDIT uses the inferred mask to guide the denoising process, minimizing edits outside the region of interest. Figure 2 illustrates the three steps of our approach, which we detail below.
Step 1: Computing editing mask. When the denoising an image, a text-conditioned diffusion model will yield different noise estimates given different text conditionings. We can consider where the estimates are different, which gives information about what image regions are concerned by the change in conditioning text. For instance, in Figure 2, the noise estimates conditioned to the query zebra and reference text horse1 are different on the body of the animal, where they will tend to decode different colors and textures depending on the conditioning. For the background, on the other hand, there is little change in the noise estimates. The difference between the noise estimates can thus be used to infer a mask that identifies what parts on the image need to be changed to match the query. In our algorithm, we use a Gaussian noise with strength $50 \%$ (see analysis in Appendix A.1), remove extreme values in noise predictions and stabilize the effect by averaging spatial differences over a set of $n$ input noises, with $n { = } 1 0$ in our default configuration. The result is then rescaled to the range $[ 0 , 1 ]$ , and binarized with a threshold, which we set to 0.5 by default. The masks generally somewhat overshoot the region that requires editing, this is beneficial as it allows it to be smoothly embedded in itβs context, see examples in Section 4 and Section A.5.
Step 2: Encoding. We encode the input image $\mathbf { x } _ { \mathrm { 0 } }$ in the implicit latent space at timestep $r$ with the DDIM encoding function $E _ { r }$ . This is done with the unconditional model, i.e. using conditioning text $\varnothing$ , so no text input is used for this step.
Step 3: Decoding with mask guidance. After obtaining the latent ${ \bf x } _ { r }$ , we decode it with our diffusion model conditioned on the editing text query $Q$ , e.g. zebra in the example of Figure 2. We use our mask $M$ to guide this diffusion process. Outside the mask $M$ , the edited image should in principle be the same as the input image. We guide the diffusion model by replacing pixel values outside the mask with the latents $\mathbf { x } _ { t }$ inferred with DDIM encoding, which will naturally map back to the original pixels through decoding, unlike when using a noised version of $\mathbf { x } _ { \mathrm { 0 } }$ as typically done (Meng et al., 2021; Song et al., 2021). The mask-guided DDIM update can be written as $\tilde { \mathbf { y } } _ { t } = M \mathbf { y } _ { t } + ( 1 - M ) \mathbf { x } _ { t }$ , where $\mathbf { y } _ { t }$ is computed from $\mathbf { y } _ { t - d t }$ with Eq. 2, and $\mathbf { x } _ { t }$ is the corresponding DDIM encoded latent.
The encoding ratio $r$ determines the strength of the edit: larger values of $r$ allow for stronger edits that allow to better match the text query, at the cost of more deviation from the input image which might not be needed. We evaluate the impact of this parameter in our experiments. We illustrate the effect of the encoding ratio in Appendix A.5.
# 3.3 THEORETICAL ANALYSIS
In DIFFEDIT, we use DDIM encoding to encode images before doing the actual editing step. In this section, we give theoretical insight on why this component yields better editing results than adding random noise as in SDEdit (Meng et al., 2021). With ${ \bf x } _ { r }$ being the encoded version of $\mathbf { x } _ { \mathrm { 0 } }$ , using DDIM decoding on ${ \bf x } _ { r }$ unconditionally would give back the original image $\mathbf { x } _ { \mathrm { 0 } }$ . In DIFFEDIT, we use DDIM decoding conditioned on the text query $Q$ , but there is still a strong bias to stay close to the original image. This is because the unconditional and conditional noise estimator networks $\epsilon _ { \theta }$ and $\epsilon _ { \theta } ( \cdot , Q )$ often produce similar estimates, yielding similar decoding behavior when initialized with the same starting point ${ \bf x } _ { r }$ . This means that the edited image will have a small distance w.r.t. the input image, a property critical in the context of image editing. We capture this phenomenon with the proposition below, where we compare the DDIM encoder β $E _ { r } ( \mathbf { x } _ { 0 } )$ to the SDEdit encoder $G _ { r } ( \mathbf { x } _ { 0 } , \epsilon \bar { ) : = } \sqrt { \alpha _ { r } } \mathbf { x } _ { 0 } + \sqrt { 1 - \alpha _ { r } } \epsilon$ , which simply adds noise to the image $\mathbf { x } _ { \mathrm { 0 } }$ .
Proposition 1. Let $\boldsymbol { \mathcal { X } } ~ = ~ \mathbb { R } ^ { d }$ be the space of input images, $p _ { D }$ be the data distribution of couples $( \mathbf { x } _ { 0 } , Q )$ where $\mathbf { x } _ { 0 } \in \mathcal { X }$ and $Q$ a textual query to edit that image. Suppose that $\| \epsilon _ { \theta } ( \mathbf { x } _ { t } , Q , t ) \| _ { 2 } \leq C$ for all $x \in \mathcal { X }$ , $t \in [ 0 , 1 ]$ , that $\epsilon _ { \theta } ( \cdot , \varnothing , t )$ is $K _ { 1 }$ -Lipschitz for all $t _ { : }$ , and let $\begin{array} { r } { K _ { 2 } = \mathbb { E } _ { ( \mathbf { x } _ { 0 } , Q ) \in p _ { D } } \operatorname* { m a x } _ { t \in [ 0 , 1 ] } | | \epsilon _ { \theta } ( \mathbf { x } , Q , t ) - \epsilon _ { \theta } ( \mathbf { x } , \theta , t ) | | } \end{array}$ . Then, for all encoding ratios $0 \leq r \leq 1$ , we have the two following bounds:
$$\begin{array} { r l } & { \underset { ( \mathbf { x } _ { 0 } , Q ) \sim p _ { D } } { \mathbb { E } } \| \mathbf { x } _ { 0 } - D _ { r } ( G _ { r } ( \mathbf { x } _ { 0 } , \epsilon ) , Q ) \| _ { 2 } \leq ( C + 1 ) \tau , } \\ & { \underset { ( \mathbf { x } _ { 0 } , Q ) \sim p _ { D } } { \mathbb { E } } } \\ & { } \\ & { \underset { ( \mathbf { x } _ { 0 } , Q ) \sim p _ { D } } { \mathbb { E } } \| \mathbf { x } _ { 0 } - D _ { r } ( E _ { r } ( \mathbf { x } _ { 0 } ) , Q ) \| _ { 2 } \leq \frac { K _ { 2 } \tau } { \sqrt { \tau ^ { 2 } + 1 } } \Big ( \tau + \sqrt { \tau ^ { 2 } + 1 } \Big ) ^ { K _ { 1 } } , } \end{array}$$
where $\tau = \sqrt { 1 / \alpha _ { r } - 1 }$ increases with the encoding ratio $r$ : $\tau ( r = 0 ) = 0$ and $\operatorname* { l i m } _ { r \to 1 } \tau = + \infty$ .
We provide the proof in Appendix B. The first bound is associated with SDEdit, and is an extension of a bound proven in the original paper. The second bound we contribute is associated with DIFFEDIT. It is tighter than the first bound below a certain encoding ratio, see Figure 3. We empirically estimated the parameters $K _ { 1 } , K _ { 2 }$ and $C$ with the diffusion models that we are using. While the asymptotic behavior of the second bound is worse than the first with $K _ { 1 } > 1$ , it is the very small value of $K _ { 2 }$ that gives a tighter bound.
This supports our argument from above: because the unconditional and text-conditional noise estimates generally give close results β $K _ { 2 }$ being a measure of the average differenceβ the Euler scheme with $\epsilon _ { \theta } ( \cdot , Q , \cdot )$ gives a sequence of intermediate latents $\mathbf { y } _ { r } , . . . , \mathbf { y } _ { 0 }$ that stays close to the trajectory $x _ { r } , \ldots , D _ { r } ( x _ { r } ) \approx \mathbf { x } _ { 0 }$ mapping back $\mathbf { x } _ { r }$ to $\mathbf { x } _ { \mathrm { 0 } }$ . While these upper bounds do not guarantee that DDIM encoding yields smaller edits than SDEdit, experimentally we find that it is indeed the case.
 Figure 3: Illustration of the bounds from Proposition 1, with estimated parameters $C = 1 , K _ { 2 } = 0 . 0 2$ , and $K _ { 1 } = 3$ .
# 4 EXPERIMENTS
In this section, we describe our experimental setup, followed by qualitative and quantitative results.
# 4.1 EXPERIMENTAL SETUP
Datasets. We perform experiments on three datasets. First, on ImageNet (Deng et al., 2009) we follow the evaluation protocol of FlexIT (Couairon et al., 2022). Given an image belonging to one class, the goal is to edit it so that it will depict an object of another class as indicated by the query. Given the nature of the ImageNet dataset, edits often concern the main object in the scene. Second, we consider editing images generated by Imagen (Saharia et al., 2022b) based on structured text prompts, in order to evaluate edits that involve changing the background, replacing secondary objects, or changing object properties. Third, we consider edits based on images and queries from the $C O C O$ (Lin et al., 2014) dataset to evaluate edits based on more complex text prompts.
Diffusion models. In our experiments we use latent diffusion models (Rombach et al., 2022). We use the class-conditional model trained on ImageNet at resolution $2 5 6 \times 2 5 6$ , as well as the 890M parameter text-conditional model trained on LAION-5B (Schuhmann et al., 2021), known as Stable Diffusion, at $5 1 2 \times 5 1 2$ resolution.2 Since these models operate in a VQGAN latent spaces (Esser et al., 2021), the resolution of our masks is $3 2 \times 3 2$ (ImageNet) or $6 4 \times 6 4$ (Imagen and COCO). We use 50 steps in DDIM sampling with a fixed schedule, and the encoding ratio parameter further decreases the number of updates used for our edits. This allows to edit images in ${ \sim } 1 0$ seconds on a single Quadro GP100 GPU. We also use classifier-free guidance (Ho & Salimans, 2022) with the recommended values: 5 on ImageNet, 7.5 for Stable Diffusion. For more details see Section A.2.
Comparison to other methods. We use SDEdit (Meng et al., 2021) as our main point of comparison, since we can use the same diffusion model as for DIFFEDIT. We also compare to FlexIT (Couairon et al., 2022), a mask-free, optimization-based editing method based on VQGAN and CLIP. On ImageNet, we evaluate ILVR (Choi et al., 2021) which uses another diffusion model trained on ImageNet (Dhariwal & Nichol, 2021). Finally, on COCO and Imagen images, we compare to the concurrent work of Hertz et al. (2022). 3
Evaluation. In semantic image editing, we have to satisfy the two contradictory objectives of (i) matching the text query and (ii) staying close to the input image. For a given editing method, better matching the text query comes at the cost of increased distance to the input image. Different editing methods often have a parameter that allows to control the editing strength: varying its value allows to get different operating points, forming a trade-off curve between the two objectives aforementioned. Therefore, we evaluate editing methods by comparing their trade-off curves. For diffusion-based methods, we use the encoding ratio to control the trade-off.
# 4.2 EXPERIMENTS ON IMAGENET
On ImageNet, we follow the evaluation protocol of Couairon et al. (2022), with the associated metrics: the LPIPS perceptual distance (Zhang et al., 2018) measures the distance with the input image, and the CSFID, which is a class-conditional FID metric (Heusel et al., 2017) measuring both image realism and consistency w.r.t. the transformation prompt. For both metrics, lower values indicate better edits. For more details see Couairon et al. (2022).
We compare DIFFEDIT to other semantic editing methods from the literature in terms of CSFID-LPIPS tradeoff. Stronger edits improve (lower) the CSFID score as the edited images better adhere to the text query, but the resulting images tend to deviate more from the input image, leading to worse (increased) LPIPS distances.
 Figure 4: Comparison on ImageNet data of DIFFEDIT with other Image Editing methods. For DIFFEDIT we annotate the different operating points with the corresponding encoding ratios.
 Figure 5: Edits obtained on ImageNet with DIFFEDIT and ablated models. Encode-Decode is DIFFEDIT without masking, and SDEdit is obtained when not using masking nor encoding. When not using masking (SDEdit and Encode-Decode) we observe undesired edits to the background, see e.g. the sky in the second column. When not using DDIM encoding (SDEdit and DiffEdit w/o Encode), appearance information from the input βsuch as poseβ is lost, see last two columns.
The results in Figure 4 indicate that DIFFEDIT obtains the best trade-offs among the different methods. For fair comparison with previous methods, here we do not leverage the label of the input image and use the empty text as reference when inferring the editing mask. The Copy and Retrieve baselines are two opposite cases where we have best possible LPIPS distance βzero, by copying the input imageβ and best possible transformation score by discarding the input image and replacing it with a real image from the target class from the ImageNet dataset. DIFFEDIT, as well as the diffusion-based SDEdit and ILVR, are able to obtain CSFID values comparable to that of the retrieval baseline. Among the diffusion-based methods, our DIFFEDIT obtains comparable CSFID values at significantly better LPIPS scores. For FlexIT, the CSFID best value is significantly worse, indicating it is not able to produce both strong and realistic edits. Using more optimization steps does not solve this issue, as the distance to the input image is part of the loss it minimizes.
Ablation experiments. We ablate the two core components of DIFFEDIT, mask inference and DDIM encoding, to measure their relative contributions in terms of CSFID-LPIPS trade-off. If we do not use either of these components our method reverts to SDEdit (Meng et al., 2021). The results in Figure 6, left panel, show that adding DDIM encoding (Encode-Decode) and the masking (DiffEdit w/o Encode) separately both improve the trade-off and reduce the average editing distance w.r.t. the input image compared to SDEdit. Moreover, combining these two elements into DIFFEDIT gives an even better trade-off, showing their complementarity: masking better preserves the background, while DDIM encoding retains visual appearance of the input inside the mask. See Figure 5 for qualitative examples of these ablations, along with the inferred masks.
The right panel of Figure 6 shows DIFFEDIT with different mask binarization thresholds. Compared to our default value of 0.5, a lower threshold of 0.25 results in larger masks (more image modifications) and worse CSFID-LPIPS tradeoff. A higher threshold of 0.75 results in masks that are too restrictive: the CSFID score stagnates around 40, even at large encoding ratios.
 Figure 6: Ablations on ImageNet. Left: effect of masking and encoding component. Right: DIFFEDIT with different mask thresholds; with 0.5 our default setting.
Finally, our mask guidance operator $\tilde { \mathbf { y } } _ { t } = M \mathbf { y } _ { t } + ( 1 - M ) \mathbf { x } _ { t }$ provides a better trade-off than the reference text operator used in GLIDE (Nichol et al., 2021), which interpolates $\mathbf { y } _ { t }$ with a mask-corrected version of the predicted denoised image $\hat { \mathbf { y } } _ { 0 }$ . With encoding ratio $80 \%$ , both operators produce edits with a LPIPS score of 30.5, but the GLIDE version yields a CSFID of 26.4 compared to 23.6 for ours.w/o reference text
# 4.3 EXPERIMENTS ON IMAGES GENERATED BY IMAGEN
In our second set of experiments we evaluate edits that involve changes in background, replacingw/ reference text βA bowl of fruitsβ secondary objects, and editing object properties. We find that images generated by Imagen (Saharia et al., 2022b) offer a well suited testbed for this purpose. Indeed, the authors tested the compositional abilities of Imagen with templated prompts of the form: β{A photo of a | An oil painting ofw/o reference text $^ a \}$ {fuzzy panda | British shorthair cat | Persian cat | Shiba Inu dog | raccoon} {wearing a cowboy hat and | wearing sunglasses and} {red shirt | black jacket} {playing a guitar | riding a bike | skateboarding} {in a garden | on a beach | on top of a mountain}β, resulting in 300 prompts.
We use the generated images as input and ask to change the prompt to another prompt for which one of these elements is changed. Since we cannot use the CSFID metric as for ImageNet, as images do not carry a single class label, we use FID to measure image realism, and CLIPScore (Hessel et al., 2021) to measure the alignment of the query and A cup of output image. These two scores have become the standard in evaluating text-conditional image generation (Saharia et al., 2022b).
Figure 7 displays the CLIP-LPIPS and FID-CLIP trade-offs. DIFFEDIT provides more accurate edits than SDEdit, FlexIT, and Cross Attention Control, by combining inferred masks with DDIM encoding. Two versions of DiffEdit are shown, which differ by how the mask is computed: they correspond to (i) using the original caption as reference text (labelled w/ ref. text) or (ii) using the empty text $\varnothing$ (labelled w/o ref. text).
Computing the mask with the original caption as reference text yields the best overall trade-off. Leveraging the original caption yields better CLIP and FID scores. Figure 8 illustrates the difference in the masks obtained with and without reference text for two examples. The reference text allows to ignore parts of the image that are described both by the query and reference text (e.g. the fruits), because in both cases the network uses the common text on the corresponding image region to estimate the noise. On the contrary, parts where the query and reference text disagree, e.g. βbowlβ vs. βbasketβ, will have different noise estimates.
 Figure 7: Editing trade-offs on Imagen images.
 Figure 8: Masks and edits obtained with and without reference text in the mask computation algorithm.
 Figure 9: Edits on Imagen dataset. We use encoding ratio of $90 \%$ for DiffEdit and $70 \%$ for SDEdit for fair comparison: both methods have similar CLIPScore, for larger encoding ratios SDEdit drastically change the input.
Qualitative transformation examples are shown in Figure 9, where the masks are inferred by contrasting the caption and query texts.
# 4.4 EXPERIMENTS ON COCO
To evaluate semantic image editing with more complex prompts, we use images and captions from the COCO dataset Lin et al. (2014). To this end, we leverage the annotations provided by Hu et al. (2019), which associate images from the COCO validation set with other COCO captions that are similar to the original ones, but in contradiction with the given image. This makes these annotations particularly interesting as queries for semantic image editing, as they can often be satisfied by editing only a part of the input image, see Figure 15 in the supplementary material for examples. Similar to our evaluation for Imagen images, here we evaluate edits in terms of CLIPScore, FID and LPIPS.
The results in Figure 10 show that the CLIP-LPIPS trade-off of DIFFEDIT is the best, but that it reaches lower maximum CLIP score than SDEdit. The FID scores are similar to SDEdit, but significantly improves upon the Encode-Decode ablation, which does not use a mask.
Moreover, in contrast to results on the Imagen data, leveraging the original image caption does not change the CLIP-LPIPS and FID-CLIP tradeoffs. We find that the caption often describes the input image differently compared to the query text, making it more difficult to identify which part of the image needs to be edited. We verify this hypothesis in Section A.3 by filtering the dataset according to the edit distance between the caption and edit query. When the caption and edit query are similar, leveraging the image caption boosts CLIP scores by 0.25 points, a similar improvement as seen on the Imagen data.
Qualitative examples are shown in Figure 11. The first column illustrates the benefit of DDIM encoding: we are able to correctly maintain properties of the object inside the mask, such as clothesβ color. The three last columns illustrate how contrasting different pairs of reference and query text allows to select different objects in the input image to perform different edits. See Section A.5 for more examples.
 Figure 10: Quantitative evaluation on COCO.
 Figure 11: Examples edits on COCO images.
# 5 CONCLUSION
We introduced DIFFEDIT, a novel algorithm for semantic image editing based on diffusion models. Given a textual query, using the diffusion model, DIFFEDIT infers the relevant regions to be edited rather than requiring a user generated mask. Furthermore, in contrast to other diffusion-based methods, we initialize the generation process with a DDIM encoding of the input.We provide theoretical analysis that motivates this choice, and show experimentally that this approach conserves more appearance information from the input image, leading to lighter edits. Quantitative and qualitative evaluations on ImageNet, COCO, and images generated by Imagen, show that our approach leads excellent edits, improving over previous approaches. Although DIFFEDIT works better with a reference text describing the input image, we believe this additional information can be inferred from input image and target caption, which we leave for future work.
# 6 ETHICS STATEMENT
Image editing raises several ethical challenges that we wish to discuss here. First, as image editing is closely related to image generation, it inherits known concerns. Open-source diffusion models are trained on large amounts of web-scraped data like LAION, and inherit their biases. In particular, it was shown that LAION contains inappropriate content (violence, hate, pornography), along with racist and sexist stereotypes. Furthermore it was found that diffusion models trained on LAION, such as Imagen, can exhibit social and cultural bias. Therefore, the use of such models can raise ethical issues, whether the text prompt is intentionnally harmful or not. Because image editing is usually performed on real images, there are additionnal ethical challenges, such as potential skin tone change when editing a person or re-inforcing harmful social stereotypes. We believe that open-sourcing editing algorithms in a research context contributes to a better understanding of such problems, and can aid the community in efforts to mitigate them in the future. Furthermore, image editing tools could be used with harmful intent such as harrassement or propagating fake news. This use, known as deep fakes, has been largely discussed in previous work, e.g. in Etienne (2021). To mitigate potential misuse, the Stable Diffusion model is released under a license focused on ethical and legal use, stating explicitly that users βmust not distribute harmful, offensive, dehumanizing content or otherwise harmful representations of people or their environments, cultures, religions, etc. produced with the model weightsβ.
Our editing benchmark based on the COCO dataset also has some limitations. COCO has a predominant western cultural bias, and we are therefore evaluating transformations on a small subset of images mostly associated with western culture. Finding relevant transformation prompts for an image is challenging: while we found it relevant to leverage existing annotations based on COCO, we believe that evaluating image editing models on a less culturally biased dataset is needed.
# REFERENCES
Youssef Alami Mejjati, Christian Richardt, James Tompkin, Darren Cosker, and Kwang In Kim. Unsupervised attention-guided image-to-image translation. Advances in neural information processing systems, 31, 2018.
Omri Avrahami, Dani Lischinski, and Ohad Fried. Blended diffusion for text-driven editing of natural images. In CVPR, 2022.
Omer Bar-Tal, Dolev Ofri-Amar, Rafail Fridman, Yoni Kasten, and Tali Dekel. Text2LIVE: Textdriven layered image and video editing. arXiv preprint, arXiv:2204.02491, 2022.
David Bau, Alex Andonian, Audrey Cui, YeonHwan Park, Ali Jahanian, Aude Oliva, and Antonio Torralba. Paint by word. arXiv preprint, arXiv:2103.10951, 2021.
Andrew Brown, Cheng-Yang Fu, Omkar Parkhi, Tamara L Berg, and Andrea Vedaldi. End-to-end visual editing with a generatively pre-trained artist. arXiv preprint, arXiv:2205.01668, 2022.
Jooyoung Choi, Sungwon Kim, Yonghyun Jeong, Youngjune Gwon, and Sungroh Yoon. ILVR: Conditioning method for denoising diffusion probabilistic models. In ICCV, 2021.
Edo Collins, Raja Bala, Bob Price, and Sabine Susstrunk. Editing in style: Uncovering the local semantics of GANs. In CVPR, 2020.
Guillaume Couairon, Asya Grechka, Jakob Verbeek, Holger Schwenk, and Matthieu Cord. FlexIT: Towards flexible semantic image translation. In CVPR, 2022.
Katherine Crowson. CLIP Guided Diffusion HQ 512x512. 2021. URL https://colab. research.google.com/drive/1V66mUeJbXrTuQITvJunvnWVn96FEbSI3.
Katherine Crowson, Stella Biderman, Daniel Kornis, Dashiell Stander, Eric Hallahan, Louis Castricato, and Edward Raff. VQGAN-CLIP: Open domain image generation and editing with natural language guidance. In ECCV, 2022.
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.
Helisa Dhamo, Azade Farshad, Iro Laina, Nassir Navab, Gregory D Hager, Federico Tombari, and Christian Rupprecht. Semantic image manipulation using scene graphs. In CVPR, 2020.
Prafulla Dhariwal and Alexander Nichol. Diffusion models beat GANs on image synthesis. In NeurIPS, 2021.
Ming Ding, Zhuoyi Yang, Wenyi Hong, Wendi Zheng, Chang Zhou, Da Yin, Junyang Lin, Xu Zou, Zhou Shao, Hongxia Yang, et al. CogView: Mastering text-to-image generation via transformers. In NeurIPS, 2021.
Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image synthesis. In CVPR, 2021.
Hubert Etienne. The future of online trust (and why deepfake is advancing it). AI and Ethics, 1, 11 2021. doi: 10.1007/s43681-021-00072-1.
Oran Gafni and Lior Wolf. Wish you were here: Context-aware human generation. In CVPR, 2020.
Oran Gafni, Adam Polyak, Oron Ashual, Shelly Sheynin, Devi Parikh, and Yaniv Taigman. Makea-scene: Scene-based text-to-image generation with human priors. In ECCV, 2022.
Asya Grechka, Jean-FrancΒΈois Goudou, and Matthieu Cord. MAGECally invert images for realistic editing. In BMVC, 2021.
Erik Hark Β¨ onen, Aaron Hertzmann, Jaakko Lehtinen, and Sylvain Paris. GANSpace: Discovering Β¨ interpretable GAN controls. In NeurIPS, 2020.
Amir Hertz, Ron Mokady, Jay Tenenbaum, Kfir Aberman, Yael Pritch, and Daniel Cohen-Or. Prompt-to-prompt image editing with cross attention control. arXiv preprint arXiv:2208.01626, 2022.
Jack Hessel, Ari Holtzman, Maxwell Forbes, Ronan Le Bras, and Yejin Choi. CLIPScore: A reference-free evaluation metric for image captioning. arXiv preprint, arXiv:2104.08718, 2021.
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 NeurIPS, 2017.
Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022.
Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In NeurIPS, 2020.
Hexiang Hu, Ishan Misra, and Laurens van der Maaten. Evaluating text-to-image matching using binary image selection (BISON). In ICCV Workshop on closing the loop between vision and language, 2019.
Thibaut Issenhuth, Ugo Tanielian, JerΒ΄ emie Mary, and David Picard. EdiBERT, a generative model Β΄ for image editing. arXiv preprint, arXiv:2111.15264, 2021.
Yongcheng Jing, Yezhou Yang, Zunlei Feng, Jingwen Ye, Yizhou Yu, and Mingli Song. Neural style transfer: A review. Transactions on visualization and computer graphics, 26(11):3365β 3385, 2019.
Valentin Khrulkov and Ivan Oseledets. Understanding DDPM latent codes through optimal transport. Applied Mathematics Letters, 2022.
Gwanghyun Kim and Jong Chul Ye. DiffusionCLIP: Text-guided image manipulation using diffusion models. In CVPR, 2021.
Hugo Lavenant and Filippo Santambrogio. The flow map of the Fokker-Planck equation does not provide optimal transport. Applied Mathematics Letters, 2022.
Bowen Li, Xiaojuan Qi, Thomas Lukasiewicz, and Philip H. S. Torr. ManiGAN: Text-guided image manipulation. In CVPR, 2020a.
Bowen Li, Xiaojuan Qi, Philip HS Torr, and Thomas Lukasiewicz. Image-to-image translation with text guidance. arXiv preprint, arXiv:2002.05235, 2020b.
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 Β΄ ECCV, 2014.
Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, and Luc Van Gool. RePaint: Inpainting using denoising diffusion probabilistic models. In CVPR, 2022.
Shuang Ma, Jianlong Fu, Chang Wen Chen, and Tao Mei. Da-gan: Instance-level image translation by deep attention generative adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 5657β5666, 2018.
Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, and Stefano Ermon. SDEdit: Guided image synthesis and editing with stochastic differential equations. In ICLR, 2021.
Sangwoo Mo, Minsu Cho, and Jinwoo Shin. Instagan: Instance-aware image-to-image translation. arXiv preprint arXiv:1812.10889, 2018.
Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv preprint, arXiv:2112.10741, 2021.
Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski. StyleCLIP: Textdriven manipulation of StyleGAN imagery. In ICCV, 2021.
Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In ICML, 2021.
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.
Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical textconditional image generation with CLIP latents. arXiv preprint, arXiv:2204.06125, 2022.
Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bjorn Ommer. High- Β¨ resolution image synthesis with latent diffusion models. In CVPR, 2022.
Nataniel Ruiz, Yuanzhen Li, Varun Jampani, Yael Pritch, Michael Rubinstein, and Kfir Aberman. DreamBooth: Fine tuning text-to-image diffusion models for subject-driven generation. arXiv preprint, arXiv:2208.12242, 2022.
Chitwan Saharia, William Chan, Huiwen Chang, Chris Lee, Jonathan Ho, Tim Salimans, David Fleet, and Mohammad Norouzi. Palette: Image-to-image diffusion models. In SIGGRAPH, 2022a.
Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint, arXiv:2205.11487, 2022b.
Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki. LAION-400M: Open dataset of CLIP-filtered 400 million image-text pairs. arXiv preprint, arXiv:2111.02114, 2021.
Yujun Shen, Jinjin Gu, Xiaoou Tang, and Bolei Zhou. Interpreting the latent space of GANs for semantic face editing. In CVPR, 2020.
Jing Shi, Ning Xu, Trung Bui, Franck Dernoncourt, Zheng Wen, and Chenliang Xu. A benchmark and baseline for language-driven image editing. In ACCV, 2020.
Alon Shoshan, Nadav Bhonker, Igor Kviatkovsky, and Gerard Medioni. GAN-control: Explicitly controllable GANs. In ICCV, 2021.
Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In ICLR, 2021.
Jianan Wang, Guansong Lu, Hang Xu, Zhenguo Li, Chunjing Xu, and Yanwei Fu. ManiTrans: Entity-level text-guided image manipulation via token-wise semantic alignment and generation. In CVPR, 2022a.
Tengfei Wang, Ting Zhang, Bo Zhang, Hao Ouyang, Dong Chen, Qifeng Chen, and Fang Wen. Pretraining is all you need for image-to-image translation. arXiv preprint, arXiv:2205.12952, 2022b.
Tengfei Wang, Yong Zhang, Yanbo Fan, Jue Wang, and Qifeng Chen. High-fidelity GAN inversion for image attribute editing. In CVPR, 2022c.
Jiahui Yu, Zhe Lin, Jimei Yang, Xiaohui Shen, Xin Lu, and Thomas S Huang. Generative image inpainting with contextual attention. In CVPR, 2018.
R. Zhang, P. Isola, A. Efros, E. Shechtman, and O. Wang. The unreasonable effectiveness of deep features as a perceptual metric. In CVPR, 2018.
Jiapeng Zhu, Yujun Shen, Deli Zhao, and Bolei Zhou. In-domain GAN inversion for real image editing. In ECCV, 2020.
Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In CVPR, 2017.
# DIFFEDIT: Diffusion-based semantic image editing with mask generation Supplementary Material
In this supplementary material we provide more details on the experiments and methods presented in the main paper. In Section A we provide additional experimental results, including assessment of the impact of the strength of classifier-free guidance, the impact of using reference texts describing the input image, an illustration of the effect of the encoding ratio, more qualitative editing examples, as well as a number of example images and associated reference and query texts on COCO. In Section B we provide proofs that support Proposition 1 in the main paper.
# A ADDITIONAL EXPERIMENTAL RESULTS
# A.1 ANALYSIS OF NOISE USED TO COMPUTE THE MASK
In step one our method an editing mask is inferred by contrasting noise estimations on a noised version of the input image, see Section 3.2. In this section, we study the impact of the level of noise added to the input image, by varying its value between 0.1 and 0.8, where 0 corresponds to using the initial image as input, and 1 to replacing the input image with random Gaussian noise. We evaluate the obtained operating points on ImageNet with the CSFID and LPIPS metrics when using a encoding ratios of 0.7 and 0.8 for DDIM encoding and masked-guided denoising in steps two and three of DIFFEDIT. From the results in Figure 12, we find that best results are obtained for moderate values of noise addition of 0.6 and below. Indeed, with too much noise added to the
 Figure 12: Impact of the noise added to input image when computing the mask, for a encoding ratios of 0.7 or 0.8 on ImageNet.
input image, it is difficult to correctly identify visual elements in the input image. We use a value of 0.5 in all our experiments.
# A.2 CLASSIFIER-FREE GUIDANCE
In diffusion models, the noise estimator $\epsilon _ { \theta }$ can be conditioned on text describing the image, which provides a signal to guide the noise estimation process (Nichol et al., 2021; Saharia et al., 2022b). Ho & Salimans (2022) introduced classifier-free guidance, a technique to greatly improve generation quality and imagetext alignment in text-conditional diffusion models. It consists in training both a conditional and unconditional model by dropping the conditioning text at train time with fixed probability, e.g. $10 \%$ . Then, after training, at each step $t$ during decoding, the noise estimation $\epsilon _ { \theta } ( \mathbf { x } _ { t } , Q , t )$ is extrapolated by using the unconditional noise estimation $\epsilon _ { \theta } ( \mathbf { x } _ { t } , \emptyset , \bar { t } )$ as origin. Formally, the noise that is used is
$$\begin{array} { r } { \epsilon = \epsilon _ { \theta } ( \mathbf { x } _ { t } , \theta , t ) + \lambda ( \epsilon _ { \theta } ( \mathbf { x } _ { t } , Q , t ) - \epsilon _ { \theta } ( \mathbf { x } _ { t } , \theta , t ) ) , } \end{array}$$
where $\lambda$ is the classifier-free guidance parame
 Figure 13: Ablation on the value of the classifierfree guidance parameter. On ImageNet, we find that a value of at least 3 must be used to get good results. We chose to use 5, which is the default value recommended for generation.
ter. We study the influence of this parameter on DIFFEDIT in Figure 13, finding that similarly to generation, a value above 3 yields the best results. Without classifier-free guidance, the obtained trade-off is not competitive. For our experiments we use a default guidance value of $\lambda = 5$ .
Here, we investigate why there is little difference between using or not the reference text to compute the mask on our COCO queries. In Figure 15 we show several editing queries on the COCO dataset taken from the BISON dataset (Hu et al., 2019). Generally, the text query describes a scene similar to the one in the input image, and it is possible to match the text query by editing only a fraction of the input image.
 Figure 14: Results on COCO: unfiltered (left) and filtered (right). While having a small impact overall, for the filtered set using the reference text is beneficial, especially at high encoding ratios, e.g. $90 \%$ .
However, we find that while queries have been built to be close to a caption of the input image, most of the time the query is not well aligned with the caption. We create a filtered version of this dataset, for which queries are structurally similar to the caption, i.e. where only a few words are changed, but the grammatical structure stays the same. We use the filtering criterion that the total number of words inserted/deleted/replaced must not exceed $2 5 \%$ of the total number of words in the original caption, resulting in a total of 272 queries out of $5 0 \mathrm { k }$ original queries. In Figure 14 we compare results with and without filtering, and observe that for the images with small caption edits the gain of DIFFEDIT (w/ ref. text) compared to Encode-Decode is somewhat larger than on the unfiltered dataset. Moreover, using the original caption as reference text to compute the mask gives higher CLIPScore, especially at high encoding ratio. This illustrates that a well chosen reference text helps to generate better editing masks.
 Figure 15: Editing queries on the COCO dataset.
# A.4 VISUALISATION OF THE IMPACT OF ENCODING RATIO
We show visual results for ablations of our two main components, mask inference and DDIM encoding, in Figure 16. The resulting methods are SDEdit, Encode-Decode, DIFFEDIT w/o Encoding, and DIFFEDIT. We demonstrate the qualitative behavior of these different methods, at varying encoding ratios between $3 0 \%$ and $8 0 \%$ . Compared to SDEdit, Encode-Decode allows to better match the query with less modifications of the main object and the background, especially at $6 0 \% - 7 0 \%$ .
Mask inference allows to maintain exactly the background. Using DDIM inference on top of maskbased decoding allows to better retain of the content inside the mask, especially at $70 \%$ and $80 \%$ , c.f. row 3 vs. 4.
 Figure 16: Qualitative ablations of the mask and encoding components, using different encoding ratios from $30 \%$ to $80 \%$ .
A.5 ADDITIONAL VISUALIZATIONS AND QUALITATIVE RESULTS
Figure 17 illustrates editing examples on Imagen, in comparison with other mask-free editing methods. DIFFEDIT generally performs more targeted and accurate edits, leaving more of the original image in tact where possible. Consider for example the first column of Figure 17, where DIFFEDIT leaves the guitar as it, while other methods make unnecessary and unrealistic changes to the guitar.
Additional qualitative examples on COCO images are shown in Figure 19.
Figure 20 shows several failure cases of semantic image editing with DIFFEDIT. Some failure modes are inherited from the generative model itself: models trained on web-scrapped image-text data are known to struggle with understanding spatial positions in images, spatial reasoning, and counting (Ramesh et al., 2021). Others are specific to our mask-based method, like the difficulty to insert objects, because the mask often seeks an βanchorβ visual element to insert an object, see first column.
# A.6 DETAILS ON COMPARISONS WITH OTHER METHODS
On the COCO and Imagen datasets, we do not compare with ILVR, since it cannot be used within the latent diffusion framework: the method needs image downsampling and upsampling, which does not work well with the latent spaces used in latent diffusion. Even adapted with a diffusion model without latent spaces like Imagen, we do not expect the CLIP-LPIPS trade-off to be favorable for this method, given the high editing distance obtained on ImageNet. Instead, we compare against CrossAttention Control Hertz et al. (2022), a recent method for text-driven image editing based on the unreleased Imagen diffusion model. The method is very recent and has been adapted to use with Stable Diffusion at https://github.com/bloc97/CrossAttentionControl/. We have performed lightweight hyperparameter search to optimize the CLIP-LPIPS trade-off on a subset of Imagen images. We generally find that this re-implementation, while producing edited images structurally similar to the input, changes local features more than SDEdit, leading to generally high LPIPS distances, resulting in a CLIP-LPIPS trade-off not competitive with other methods on our COCO and Imagen benchmark. In particular, LPIPS distance are high on the COCO dataset where text query and reference text have a high edit distance on average, whereas Cross-Attention Control was designed to perform well for prompt-to-prompt editing, i.e. the input and target text should almost exactly match. Given that our results are based on the unofficial re-implementation, we caution that they are temporary and we will update them when the official code (or official adaptation for Stable Diffusion) is released.
 Figure 17: Example edits from Imagen, in comparison with other mask-free editing methods.
 Figure 18: More qualitative examples on COCO. Baseline methods are shown for comparison. The mask is sometimes bigger or smaller that one could expect: In column 3, it is larger, but there are few edits outside the requested bread burger transformation (except for the wine bottle label), which is not the case without DDIM encoding. In column 4, the mask does not cover the interior of the truck, but this does not affect the edit quality.
 Figure 19: More qualitative examples on COCO. In the first column, the color of the objects to be edited is maintained, which would not be the case with regular inpainting methods. Contrasting similar text query and reference text allows to select the object to be edited.
 Figure 20: Illustration of failure modes. In the first two columns show difficulty to insert an object in a smooth region of the image. In column three the mask fails to identify a region where to add the zebra. Columns 4 and 5 show mask identification errors, where multiple similar objects are included in the mask, whereas matching the text query only requires to edit a single object. In both cases this results in over-editing. Col. 6 shows the failure to change a spatial relation in the image.
# B THEORETICAL RESULTS
Here, we prove the bounds given in the main paper. We reused notations from Proposition 1 in the main paper. We also discuss links to optimal transport.
# B.1 PROOF OF SDEDIT BOUND
Proposition 2. Suppose that $\| \epsilon _ { \theta } ( \mathbf { x } , Q , t ) \| _ { 2 } \leq C$ for all $x \in \mathcal { X }$ , $t \in [ 0 , 1 ]$ . Then
$$\begin{array} { r l } & { \quad \underset { ( \mathbf { x } _ { 0 } , Q ) \sim p _ { D } } { \mathbb { E } } \| \mathbf { x } _ { 0 } - D _ { r } ( G _ { r } ( \mathbf { x } _ { 0 } , \epsilon ) , Q ) \| _ { 2 } \leq ( C + 1 ) \tau } \\ & { \quad \epsilon \sim { \cal N } ( 0 , 1 ) } \end{array}$$
Proof. Let $T$ $\mathbf { \xi } , \mathbf { x } _ { r } = G _ { r } ( \mathbf { x } _ { 0 } , \epsilon ) , \mathbf { y } _ { r } = \mathbf { x } _ { r }$ and ${ \bf y } _ { 0 } = D _ { r } ( { \bf y } _ { r } , Q )$ . Then
$$\| \frac { { \bf x } _ { r } } { \sqrt { \alpha _ { r } } } - { \bf y } _ { 0 } \| = \| \frac { { \bf y } _ { r } } { \sqrt { \alpha _ { r } } } - \frac { { \bf y } _ { 0 } } { \sqrt { \alpha _ { 0 } } } \| = \| \int _ { \tau } ^ { 0 } \epsilon _ { \theta } ( x _ { t } , Q , t ) d \tau \| \le C \tau .$$
Since the pr $\begin{array} { r } { \frac { \mathbf { x } _ { r } } { \sqrt { \alpha _ { r } } } = \mathbf { x } _ { 0 } + \boldsymbol { \tau } \boldsymbol { \epsilon } } \end{array}$ , we have $\begin{array} { r } { \| \mathbf { x } _ { 0 } - \mathbf { y } _ { 0 } \| \leq \| \mathbf { x } _ { 0 } + \tau \epsilon - \mathbf { y } _ { 0 } \| + \| \tau \epsilon \| \leq C \tau + \tau } \end{array}$ which concludes
In the SDEdit paper (Meng et al., 2021), a proof similar to what we state is given, with three main differences: (i) the proof is given in the case of variance-exploding Stochastic Differential Equation (VE-SDE), which needs adaption for our setting which uses variance-preserving SDE; (ii) the bound is derived in the case of a stochastic differential equation, whereas we use a deterministic DDIM process; (iii) the bound is given by controlling the probability tail, whereas we only consider the expectancy of edit distance. However, despite these differences, the spirit of the proof is the same as here.
# B.2 PROOF OF PROPOSITION 2
Proposition 3. Suppose that $\epsilon _ { \theta } ( \cdot , Q , t )$ is $K _ { 1 }$ -lipschitz and $\kappa _ { 2 }$ defined as
$$\kappa _ { 2 } ( \mathbf { x } _ { 0 } ) = \operatorname* { m a x } _ { t \in [ 0 , 1 ] } \| \epsilon _ { \theta } ( E _ { t } ( \mathbf { x } _ { 0 } ) , Q , t ) - \epsilon _ { \theta } ( E _ { t } ( \mathbf { x } _ { 0 } ) , \emptyset , t ) \|$$
Let $K _ { 2 } = \mathbb { E } _ { \mathbf { x } _ { 0 } } \kappa _ { 2 } ( \mathbf { x } _ { 0 } )$ . Then for all encoding ratio $r$ , with $\tau = \sqrt { \alpha _ { r } ^ { - 1 } - 1 }$ ,
$$\mathbb { E } _ { \mathbf { x } _ { 0 } } \| \mathbf { x } _ { 0 } - D _ { r } ( E _ { r } ( \mathbf { x } _ { 0 } ) , Q ) \| \leq \frac { K _ { 2 } \tau } { \sqrt { \tau ^ { 2 } + 1 } } \Big ( \tau + \sqrt { \tau ^ { 2 } + 1 } \Big ) ^ { K _ { 1 } }$$
Proof. Let $\sigma$ be a time-dependent variable defined as $\sigma ( t ) ~ = ~ \sqrt { \alpha _ { t } ^ { - 1 } - 1 }$ . Let $\textbf { u } = \textbf { x } / \sqrt { \alpha } =$ $\mathbf { x } \sqrt { 1 + \sigma ^ { 2 } }$ and $\mathbf { v } = \mathbf { y } { \sqrt { 1 + \sigma ^ { 2 } } }$ . u and $\mathbf { v }$ are solutions of the following differential system:
$$\begin{array} { r l } & { { d { \mathbf { u } } } | _ { t } = \epsilon _ { \theta } ( { \mathbf { u } } / \sqrt { 1 + \sigma ^ { 2 } } , \varnothing , t ) { d \sigma } , } \\ & { { d { \mathbf { v } } } | _ { t } = \epsilon _ { \theta } ( { \mathbf { v } } / \sqrt { 1 + \sigma ^ { 2 } } , Q , t ) { d \sigma } , } \\ & { { \mathbf { u } } ( r ) = { \mathbf { v } } ( r ) = E _ { r } ( \mathbf { x } _ { 0 } ) \sqrt { 1 + \sigma ^ { 2 } } . } \end{array}$$
Let $\mathbf { w } = \| \mathbf { u } - \mathbf { v } \|$ , then $\mathbf { w } | _ { t = r } = 0$ and
$$\begin{array} { r l } & { \| \mathbf { w } | _ { t } \leq \| d \mathbf { u } | _ { t } - d \mathbf { v } | _ { t } \| = \| ( { \epsilon } _ { \theta } ( \mathbf { x } , { \theta } , t ) - { \epsilon } _ { \theta } ( \mathbf { y } , Q , t ) ) d \sigma \| } \\ & { \qquad \leq \| ( { \epsilon } _ { \theta } ( \mathbf { x } , { \theta } , t ) - { \epsilon } _ { \theta } ( \mathbf { x } , Q , t ) \| d \sigma + \| ( { \epsilon } _ { \theta } ( \mathbf { x } , Q , t ) - { \epsilon } _ { \theta } ( \mathbf { y } , Q , t ) \| d \sigma } \\ & { \qquad \leq { \kappa } _ { 2 } ( \mathbf { x } _ { 0 } ) d \sigma + K _ { 1 } \| \mathbf { x } - \mathbf { y } \| d \sigma } \\ & { \qquad \leq \Big ( { \kappa } _ { 2 } ( \mathbf { x } _ { 0 } ) + \frac { K _ { 1 } } { \sqrt { 1 + { \sigma } ^ { 2 } } } w \Big ) d \sigma . } \end{array}$$
By integration we get
$${ \pmb w } ( t ) \le \kappa _ { 2 } ( { \bf x } _ { 0 } ) * ( \tau - t ) + \int _ { t } ^ { \tau } \frac { K _ { 1 } } { \sqrt { 1 + \sigma ^ { 2 } } } { \pmb w } ( \sigma ) d \sigma .$$
From here we can apply Gronwallβs inequality: Β¨
$$\begin{array} { l } { w ( 0 ) \leq \kappa _ { 2 } ( \mathbf { x } _ { 0 } ) \tau \exp \Big ( \displaystyle \int _ { 0 } ^ { \tau } \frac { K _ { 1 } } { \sqrt { 1 + s ^ { 2 } } } d s \Big ) } \\ { \leq \kappa _ { 2 } ( \mathbf { x } _ { 0 } ) \tau \exp \Big ( K _ { 1 } \log ( \tau + \sqrt { \tau ^ { 2 } + 1 } ) \Big ) } \\ { \leq \kappa _ { 2 } ( \mathbf { x } _ { 0 } ) \tau \Big ( \tau + \sqrt { \tau ^ { 2 } + 1 } \Big ) ^ { K _ { 1 } } . } \end{array}$$
Which finally gives
$$\| \mathbf { x } _ { 0 } - \mathbf { y } _ { 0 } \| \leq \frac { \kappa _ { 2 } ( \mathbf { x } _ { 0 } ) \tau } { \sqrt { \tau ^ { 2 } + 1 } } \Big ( \tau + \sqrt { \tau ^ { 2 } + 1 } \Big ) ^ { K _ { 1 } } .$$
Taking the expectation w.r.t. the input image $\mathbf { x } _ { \mathrm { 0 } }$ gives the final result:
$$\mathbb { E } _ { \mathbf { x } _ { 0 } } \left\| \mathbf { x } _ { 0 } - D _ { T } ( E _ { T } ( \mathbf { x } _ { 0 } ) , Q ) \right\| \leq \frac { K _ { 2 } \tau } { \sqrt { \tau ^ { 2 } + 1 } } \Big ( \tau + \sqrt { \tau ^ { 2 } + 1 } \Big ) ^ { K _ { 1 } }$$
which concludes the proof.
# B.3 LINKS TO OPTIMAL TRANSPORT THEORY
The reverse DDIM encoder $E _ { r }$ maps the distribution of images $p _ { 0 } = p _ { D }$ to the distribution $p _ { r }$ of images noised at timestep $r$ . Khrulkov & Oseledets (2022) suggested that $E _ { r }$ could be an optimal transport map between $p _ { 0 }$ and $p _ { r }$ , minimizing the transport cost $\mathbb { E } _ { \mathbf { x } _ { 0 } } \| \mathbf { x } _ { 0 } - E _ { r } ( \mathbf { x } _ { 0 } ) \| _ { 2 } ^ { 2 }$ . This means that the encoded images are, on average, as close as possible to the input images, while following the correct distribution $p _ { r }$ . It would entail that the unconditional decoder $\bar { D _ { r } } = E _ { r } ^ { - 1 }$ would be an optimal transport map between $p _ { r }$ and $p _ { 0 }$ , and moreover that the conditional decoder $D _ { r } ( \cdot , Q )$ would be an optimal transport map between the distributions $p _ { r } ( \cdot | Q )$ and $p _ { 0 } ( \cdot | Q )$ conditioned by text description $Q$ . Under the hypothesis that $p _ { r }$ is very close to $p _ { r } ( \cdot | Q )$ , then the Encode-Decode algorithm would be the combination of two optimal transport maps $E _ { r }$ and $D _ { r } ( \cdot , Q )$ , mapping $p _ { 0 }$ to $p _ { r }$ and then $p _ { r } \simeq p _ { r } ( \cdot | Q )$ to $p _ { 0 } ( \cdot | Q )$ . This is a very interesting property and we make the connection with the desired properties of semantic image editing, which can be expressed as an optimal transport problem. Given two distribution of images $p _ { 1 } , p _ { 2 }$ (lets say cats and dogs), the aim is to find the function $f$ that performs the expected edit (changing images of cats into images of dogs) while minimally editing the image, which can be expressed mathematically as:
$$f = \underset { f } { \arg \operatorname* { m i n } } \mathbb { E } _ { \mathbf { x } } \| \mathbf { x } - f ( \mathbf { x } ) \| \quad \mathrm { s . t . } \quad p _ { 2 } = f _ { \# } p _ { 1 } ,$$
where $f _ { \# }$ is the push-forward measure. The function $D _ { r } ( \cdot , Q ) \circ E _ { r }$ is not a solution of this optimal transport problem, because (i) it was proven that the reverse DDIM encoder is not the optimal transport map for some distributions (Lavenant & Santambrogio, 2022), and (ii) the composition of two optimal transport maps is not necessarily an optimal transport map. However, experiments and numerical simulations suggest that $E _ { r }$ is very close from an optimal transport map. It would be interesting to study the βoptimality defectβ of $E _ { r }$ and of the editing function $D _ { r } ( \cdot , Q ) \circ E _ { r }$ . We leave this for future work.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474# Counterfactual Memorization in Neural Language Models
Chiyuan Zhang Google Research chiyuan@google.com
Daphne Ippolito Carnegie Mellon University daphnei@cmu.edu
Katherine Lee Google DeepMind katherinelee@google.com
Matthew Jagielski Google DeepMind jagielski@google.com
Florian Tramèr ETH Zürich florian.tramer@inf.ethz.ch
Nicholas Carlini Google DeepMind ncarlini@google.com
# Abstract
Modern neural language models that are widely used in various NLP tasks risk memorizing sensitive information from their training data. Understanding this memorization is important in real world applications and also from a learningtheoretical perspective. An open question in previous studies of language model memorization is how to filter out βcommonβ memorization. In fact, most memorization criteria strongly correlate with the number of occurrences in the training set, capturing memorized familiar phrases, public knowledge, templated texts, or other repeated data. We formulate a notion of counterfactual memorization which characterizes how a modelβs predictions change if a particular document is omitted during training. We identify and study counterfactually-memorized training examples in standard text datasets. We estimate the influence of each memorized training example on the validation set and on generated texts, showing how this can provide direct evidence of the source of memorization at test time.
# 1 Introduction
Modern neural language models (LMs) have achieved impressive results in generating high quality text [e.g. Brown et al., 2020, Zhang et al., 2022, Chowdhery et al., 2022, OpenAI, 2023] and have led to breakthroughs in many downstream natural language processing tasks [Devlin et al., 2019, Raffel et al., 2020b, Bommasani et al., 2021]. The paradigm of taking a single large-scale pre-trained model and fine-tuning it for many tasks motivates the study of these modelsβ ability to generalize by avoiding memorizing their training data. Moreover, memorization of sensitive user information or copyrighted materials in the training data [Carlini et al., 2020, Vyas et al., 2023, Lee et al., 2023] leads to practical concerns in real world applications.
Previous work on memorization in neural language models demonstrated the ability to extract memorized training data, including sensitive data such as phone numbers and usernames [Carlini et al., 2020, Ziegler, 2021, Carlini et al., 2019, Henderson et al., 2017, Thakkar et al., 2020, Thomas et al., 2020]. One issue with these extraction attacks is that they primarily identify βcommonβ and frequently occurring strings in the training set. For example, as shown in the analysis of Lee et al. [2021], near-duplicate training examples, which are very common in standard text corpora, account for a large majority of the memorized content. To filter out such commonly occurring strings from all memorized texts, previous work applied various heuristic rules to distinguish frequently-occurring sequences from memorization of isolated pieces of information.
In this paper, we propose a principled causal perspective to disentangle memorization of common vs rare data, by directly tying a modelβs predictions to the presence or absence of individual training examples. We define counterfactual memorization as a measure of the change in a modelβs prediction when a particular example is excluded from the training set. Counterfactual memorization accounts for the commonality of an example as removing one instance of a text that is common across multiple documents will have a minor effect on the modelβs prediction on that text. The mathematical formulation of counterfactual memorization extends a prior definition of label memorization in classification models [Feldman, 2020] to the context of neural language modeling.
Formally, a training document $x$ is considerded counterfactually memorized, when the language model predicts $x$ accurately if and only $i f$ the model was trained on $x$ . This allows us to construct a procedure to quantitatively measure the memorization of isolated pieces of text, whose sole presence in the training dataset have a large effect on the modelβs predictions.
Following Feldman and Zhang [2020], we further extend this definition to counterfactual influence, which measures the influence of a memorized training text sample on another text example. Counterfactual influence allows us to trace the source of information for a modelβs predictions, by locating the training example(s) which significantly contributed to it. With these tools, we study memorization across several standard text datasets. Our main contributions are as follows:
1. We define counterfactual memorization in neural LMs which gives us a principled perspective to distinguish memorization of βrareβ and βcommonβ information in neural LMs (Section 3). 2. We estimate counterfactual memorization on several standard text datasets, and confirm that rare memorized examples exist in all of them. We study common patterns across memorized text and the memorization profiles of individual internet domains. (Section 4). 3. We identify an inverse correlation between number of duplicates and counterfactual memorization as compared with previous definitions of memorization (Section 5). 4. We extend the definition of counterfactual memorization to counterfactual influence, and study the impact of memorized examples on the test-time prediction of the validation set examples and generated examples (Section 6).
# 2 Related Work
Previous work analyzed the memorization of large language models on sensitive information (e.g. phone numbers) in the training data [Carlini et al., 2020, Ziegler, 2021] or synthetically injected βcanariesβ [Carlini et al., 2019, Henderson et al., 2017, Thakkar et al., 2020, Thomas et al., 2020]. However, not all the memorized texts are equally interesting β as confirmed in a later study [Lee et al., 2021], near-duplicated training examples are very common in standard text corpus, and those commonly occurring phrases contribute significantly to memorized texts. In order to distinguish βcommonβ memorization of common phrases or public knowledge from βrareβ memorization of private, rare information, various heuristics were adopted in previous investigations. Our paper proposed a principled perspective towards this problem. Our intuition comes from psychologies studies that categorize human (declarative) memory into episodic memory [Tulving, 1983] of specific contents of individual events, and semantic memory [Squire, 1992] about general knowledge like grammars and factual information. We would like the models to obtain semantic memory but avoid episodic memory. The capture the latter, we proposed a notion of counterfactual memorization. The mathematical formulation of counterfactual memorization is borrowed from a notion of label memorization in Feldman [2020] and adapted to the context of neural LMs in this paper. This formulation has been studied empirically in the context of computer vision in Feldman and Zhang [2020]. In a follow up work, Ilyas et al. [2022] showed that it is possible to fit a datamodel to predict the outcome of training a model on a specific training subset and evaluating on a specific input. However, this procedure requires training a massive number of models (e.g. 300,000 for CIFAR-10) on random subsets of the training data, thus is computationally infeasible for the scale of language models considered here.
The general idea of measuring model behavior on held-out training data is common in machine learning. In cross validation, held-out data is used to estimate the test performance for model selection; in learning theory, leave-one-out stability was shown to be deeply connected to generalization [e.g. Mukherjee et al., 2006]; in differential privacy, the worst case performance difference of models trained on two βneighboringβ datasets (identical except a single example being held-out or replaced)
quantifies the privacy guarantee of a learning algorithm [Dwork et al., 2014, Nasr et al., 2021, Jagielski et al., 2020]. Most previous work aimed for an overall measurement, while our paper focused on characterizing the behaviors of individual examples.
We estimated a counterfactual influence to study how a memorized training example impact the model prediction at test time. Influence functions have been used in statistics to assess robust estimators since Hampel [1974]. Previous papers adopted it to analyze neural network predictions [Koh and Liang, 2017, Koh et al., 2019]. However, the estimation was found to be computational expensive and fragile [Basu et al., 2021]. Pruthi et al. [2020] tracks the gradient updates during training to estimate the influence from a training example; Feldman [2020], Feldman and Zhang [2020] use aggregated statistics from multiple models independently trained on heldout data subsets to estimate the influence. Further extensions were shown to work well on detecting mislabeled data in classification problems [Wang and Jia, 2022] and characterizing hallucinations in Neural Machine Translation [Raunak et al., 2021]. Alternative methods also looked at simple data statistics (e.g. co-occurrence counts) without model re-training to infer the causal effects on language modelsβ predictions [Elazar et al., 2022]. In this paper, we adapt the approach from Feldman [2020], and formulate counterfactual influence directly with subset sampling, as oppose to leave-one-out influence. We also extend the estimation to assess the influence on generated examples.
Counterfactual is an important notion in statistical causality [Pearl et al., 2000, Rubin, 2005, Pearl, 2009, Imbens and Rubin, 2015] useful for studying causal probabilistic inference under alternative conditions. Such counterfactuals may or may not be directly testable (e.g. a counterfactual treatment in medical studies). In this paper, we directly measure the counterfactual influence of a training example by comparing the behavior of the model trained with and without that example.
# 3 Counterfactual Memorization
To quantify memorization of rare details of a specific training document, we define the following notion of counterfactual memorization. The mathematical formulation is borrowed from Feldman [2020], where it was originally proposed to quantify label memorization in multi-class classification problems. We extend it to the context of unsupervised neural language modeling.
Definition 3.1 (Counterfactual Memorization). Given a training algorithm $A$ that maps a training dataset $D$ to a trained model $f$ , and a measure $M ( f , x )$ of the performance of $f$ on a specific example $x$ , the counterfactual memorization of a training example $x$ in $D$ is given by
$$\mathsf { m e m } ( x ) \triangleq \mathbb { E } _ { S \subset D , x \in S } [ M ( A ( S ) , x ) ] - \mathbb { E } _ { S \subset D , x \notin S } [ M ( A ( S ) , x ) ] \quad ,$$
where $S$ and $S ^ { \prime }$ are subsets of training examples sampled from $D$ . The expectation is taken with respect to the random sampling of $S$ and $S ^ { \prime }$ , as well as the randomness in the training algorithm $A$ .
That is, our memorization definition compares the difference between two expected performance measures on a given example $x$ . On one side, we compute the expected performance of a model when trained on datasets that contain the example $x$ , and, on the other side, we compute the expected performance of a model when trained on datasets that do not contain the example $x$ . Throughout this paper we use per-token accuracy as the measure $M$ . In other words, we ask the model to predict the next token based on the groundtruth context (preceding tokens), measure the 0-1 loss of the argmax token prediction, and then average it across all predicted tokens.
The expectations in Equation (1) can be empirically estimated via sampling. Specifically, we train $m$ different models on independently sampled subsets $S _ { 1 } , \ldots , S _ { m }$ of equal size $| S _ { i } | = r | D |$ for a fixed $r \in ( 0 , 1 )$ . We then divide these models into two groups: the first group contains all models trained on subsets $S$ where $x \in S$ ; and the second group are all models trained on subsets $S$ where $x \not \in S$ . We take the average performance on $x$ in the two groups separately and compute the difference between the two:
$$\widehat { \mathsf { m e m } } ( x ) \triangleq \operatorname* { m e a n } _ { i : x \in S _ { i } } [ M ( A ( S _ { i } ) , x ) ] - \operatorname* { m e a n } _ { i : x \notin S _ { i } } [ M ( A ( S _ { i } ) , x ) ] .$$
This difference quantifies how the presence or absence of the example $x$ in a modelβs training set affect the modelβs performance on $x$ . If there is a large difference between including an example in the training set versus not including it, then we consider this example counterfactually memorized.
For each $x$ , we refer to models trained with $x$ in the training set ( $\{ A ( S _ { i } ) : x \in S _ { i } \} )$ as IN models and the models $x$ was not trained on $\{ A ( S _ { i } ) : x \notin S _ { i } \} )$ as OUT models. Note we do not need to retrain a model for each example $x$ . Instead, we train $m$ models once on random subsets of $D$ , and compute the estimation (Equation 2) for all examples using the same set of $m$ models. Ilyas et al. [2022] recently showed that it may also be possible to directly predict these scores using a regression model, yet this approach is computationally prohibitive for large language models.
# 4 Analyzing Counterfactual Memorization
We estimate and analyze counterfactual memorization of training examples in three standard text datasets: RealNews [Zellers et al., 2019], C4 [Raffel et al., 2020a] and Wiki40B:en [Guo et al., 2020]. Unless otherwise specified, we use Transformer-based language models [Vaswani et al., 2017] equivalent to (decoder only) T5-base [Raffel et al., 2020b] with ${ \sim } 1 1 2 \mathbf { M }$ parameters. To save computation and enable more direct comparisons across datasets, we truncate the training set for each datasets by taking the first $2 ^ { 2 1 }$ documents. To estimate counterfactual memorization, we train 400 models for each dataset, each on a random $2 5 \%$ subset of the training examples. In practice, we use a hash-based filtering mechanism to efficiently approximate random subset sampling (details in Appendix G), as the data loading APIs for large text corpora generally support only sequential visits to examples with limited shuffling and subsampling capability within a window.
We train each model for 60 epochs1 using the Adam optimizer [Kingma and Ba, 2015] with learning rate 0.1 and weight decay $1 0 ^ { - 5 }$ . For C4/RealNews/Wiki40B:en, respectively, our models converge to an average per-token accuracy of $4 4 . 2 1 \% / 4 7 . 5 9 \% / 6 6 . 3 5 \%$ on the subsampled training set, and $2 7 . 9 0 \% / 3 1 . { \bar { 0 } } 9 \% / 4 9 . 5 5 \%$ on the validation set. On average, the models start to overfit at around epoch 5, as indicated by the signal that the validation accuracy starting to decrease.
# 4.1 Distribution of Memorization
Table 1 shows examples from the RealNews training set sampled at various memorization levels. Examples with the highest memorization are generally unconventional text such as all-capital letters, structured formats (i.e., tables or bullet list), and multilingual texts. After those artificial examples, examples with intermediate-to-high memorization are most often news reports of specific events. One of our main goals is to be able to separate memorization of such examples containing details of specific events from memorization of common facts or highly duplicated template texts. Indeed, templated documents with many near-duplicate copies in the training data generally have low counterfactual memorization. C4 and Wiki40B:en have similar trends. Interestingly, though Wikipedia articles are less likely to be auto-generated from templates than the web in general, we do observe repetitive patterns in low-scoring documents, such as β_START_ARTICLE_ <place name>, Virginia _START_PARAGRAPH_ <place name> is an unincorporated community in <county name>, in the U.S. state of Virginia.β
To visualize the distribution of memorization, we plot 2D histograms in Figure 1, where the $\mathbf { X }$ -axis shows the difference of IN-accuracy and OUT-accuracy (i.e. the counterfactual memorization), and the y-axis shows the sum of the two, which we term βsimplicityβ. A simple example is one that is scored highly regardless of whether a model saw it during training. The histograms are plotted in log scale to better visualize the exponential decay in the tail for high memorization and simplicity levels.
From the 2D density plots, we find that easy examples tend to have low memorization. However, there is no simple linear correlation. Peak memorization occurs for examples of intermediate simplicity. For the hardest examples, the memorization scores are low, because even the IN-models could not learn them well. Many hard examples consist of ill formatted text or contained foreign languages. As a result, in Wiki40B:en, which contains higher quality texts, the lower bound of the histogram is higher than the other two datasets (Figure 1). Interestingly, the choice of data has a relatively minor effect on memorization: the shape of the memorization histogram is generally consistent across the three datasets; the range of memorization values is only slightly compressed for Wiki40B:en.
Table 1: Examples of RealNews training set sampled at high, intermediate and low memorization. The URL of each document is included at the beginning of each example. [...] indicate omitted text for brevity. In the last block, two near-duplicate examples are shown; the yellow highlights in the last block indicate differences.
<table><tr><td>Index</td><td>mem</td><td>Text</td></tr><tr><td>2090855</td><td>0.6546</td><td>link β THE AMERICAN JEWISH CONGRESS ANNOUNCED TODAY THE PUBLICATION OF A REPORT ON JEWISH NON- EMPLOYMENT AS A RESULT OF ECONOMIC DISCRIMINATION,[J THEREAFTER ONE OF THE DEPARTMENTS OF A.T.& T.βALMOSTUNPRECEDENTEDLY "ENGAGED A JEWISH APPLICANT.</td></tr><tr><td>2085736</td><td>0.5755</td><td>linkxRECIPE:ChinesePork&VegetableSoupwith WontonNodles ChinesePork&Vegetable SoupwithWontonNoodeslpork enderloin (about1-1/4poudsize)oeddutitinchcubupswerodickenrothuwate*/4cpakes (about11/2cups each)RecipebyPorkBeInspired.com withadaptations byculinarydietian &nutritionistKim Galeaz,RDNCD</td></tr><tr><td>1680600</td><td>0.5807</td><td>linkLangaggs.ab.edgmtofout.cwoldiktogatsi being heldonthe traditionallandsofthe (appropriate group)people,nd paymyrespectoelders both past and present"[]</td></tr><tr><td>2074805</td><td>0.2835</td><td>linkATexasoorsstudentpunishdforsinghatomosealitysongshadhisuspesosnded.WesteHilhde thecorrectdecisioninreversingtheircoursefctio."Thedecisiontoescid thesuspensionis thecorrecto.Thesuspensonaswrong andimproper"saidStaver."Iaplaudthestudentforstandingup.Westoodwithhimtoresistanunjustsuspensionandweaepleasedthat suspensionhasevesed"Libetyounselillotiuetteisefrdfosiedeliosdae instancesareincreasingandwillcontinue toincreaseunlessChristiansandpeoplewholovelibertystandupandesistisitolerance."</td></tr><tr><td>449808</td><td>0.0361</td><td>link >Investors in Digital Realty Trust, Inc.(DLR) sawnew optionsbegin trading thisweek. for theFebruary2014 expiration.At Stock Options Channel, our YieldBoost formula has looked up and down theI eDLRoptions chain for the new February2014 contracts and identified one put and one callcontract of particular interest.The put contract at the $45.OO strike price has a current bid of $1.00. [...]</td></tr><tr><td>1157311</td><td>0.0356</td><td>link > Investors in Abercrombie & Fitch Co. (ANF): sawnew optionsbecome available today, for theApril 4th expiration. At Stock Options Channel,our YieldBoost formula has looked up and down the ANF optionschain for the new April4th contracts and identified one put and one call contract of particular interest.The put contract at the $34.OO strike price has a current bid of $1.97. [...]</td></tr></table>
 Figure 1: The joint distribution of counterfactual memorization (X axis) and simplicity (Y axis), where simplicity is measured as the overall accuracy for an example across all models. (Histograms are in log-scale).
Figure 1 shows the overall distribution of memorization for each training datasets. To obtain a more granular view, we can also analyze the distributions for texts sourced from individual web domains in RealNews and C4, to see whether different data sources display different memorization profiles. Web domains such as news portals, blogs, and forums differ both stylistically and in how much they reference or even copy from other websites. Additionally, some domains are represented much more frequently than others in the datasets we studied. This could lead to considerably different memorization profiles for examples from different domains.
To investigate these effects, we visualize the 95th percentile memorization score in each web domain against the number of examples in that domain for RealNews (Figure 2a) and C4 (Figure 2b). C4 contains many more domain names than RealNews since the latter is collected only from news websites. For both datasets, the domains with a large number of crawled documents show a smaller variance in the 95-percentile values, while βsmallerβ domains depict a wide range of variety in memorization profiles. The memorization profiles of a few representative domains are visualized in Figures 2c and 2d. The domains we selected for visualization are: the largest domain (blue), the domain with highest 95 percentile memorization (orange), and two domains that have more than 1000 and 50 articles in RealNews and C4 respectively (green and red).
In RealNews (Figure 2c), reuters.com contains the largest number of documents but low memorization scores on average. The domain digitallibrary.un.org, the United Nations Digital Library, has high memorization scores potentially because it contains many multilingual documents. We have observed that less frequently occurring tokens, like those in foreign languages or ALL-CAPITAL words tend to cause high memorization. Similarly, flattened structured data (e.g. tabular texts) also deviates significantly from normal English texts and potentially leads to high memorization, as demonstrated by zap2it.com, a website for TV program listings. On the other hand, hotair.com is a news commentary website that frequently quotes other major news articles. This may lead to duplicate text in the dataset which we suspect contributes to its overall lower memorization distribution.
 Figure 2: For each web domain, we plot the 95-percentile of memorization against the number of examples from that domain in (a) RealNews and (b) C4. The red dotted line indicates a threshold of a minimum of 1000 articles for RealNews and 50 articles for C4. The memorization distributions of a few representative domains are shown for (c) RealNews and (d) C4.
The observations are similar on C4: blogspot.com contains a large number of documents in the training set with only moderate amounts of memorization; zh.wikipedia.org and buckinghamautos.com.au have high memorization due to foreign (Chinese) or structured (car sales listings) text; and www.unitedstateszipcodes.org has very low memorization scores because common templates are re-used to generate similar pages for individual zip codes.
# 4.2 Number of Models Needed
To evaluate the impact of a single training example, one may wish to train two models that differ only in that single example. In practice, the stochasticity in a single run of common training algorithms (e.g. SGD) produces too low signal-to-noise ratios to be useful for such estimation. Moreover, leave-one-out estimation means a separate pair of models needs to be trained for each training example, which is computationally costly. Therefore, we formulated our estimation in Section 3 by accumulating statistics from $m$ models independently trained on random training subsets. In our experiments, we set $m = 4 0 0$ . To understand how sensitive our results are to $m$ , we analyze the rankings produced by distinct sets of models of size $m$ . We vary $m$ from 6 to 192, and partition our set of 400 models into up to 10 sets of $m$ models (e.g. for $m = 1 9 2$ , we construct 2 partitions, and for $m = 6$ , we construct 10). We then compute the Spearmanβs R between these partitions to measure the agreement between the rankings produced by each partition. If the rankings are very similar (have Spearmanβs R close to 1), then this number of models is reliably estimating the true ranking of memorization scores. We plot these Spearmanβs R values in Figure 3a. Even at 96 models, this correlation begins to plateau near 1, lending confidence that 400 models is sufficient for reliable estimation of memorization scores. See Appendix D for more analysis on the sensitivity to $m$ .
# 4.3 Impact of Number of Training Epochs
As expected, the overall amount of memorization grows consistently with the number of epochs of training (Figure 3b). This makes sense since training for more epochs increases overfitting. As training progresses, we also see an increasingly long tail of examples with high memorization scores. On RealNews, about $59 \%$ of examples had consistently increasing memorization scores across all epochs considered. There were no examples whose memorization decreased in a significant way over training (all observed decreases can be attributed either to noise or to instability early in training). Only $0 . 5 \%$ of examples stayed completely un-memorized with scores which never rose above 0.1, while $85 \%$ of examples had memorization scores which never rose above 0.2. Figure 3c shows the fraction of memorized examples as training progresses, at several thresholds of memorization. We can see that more training epochs significantly increases memorization.
 Figure 3: (a) Spearmanβs R between memorization rankings from two disjoint sets of $m$ models. The rankings are variable at low numbers of models, but starts to converge at 192 models. All of our other experiments use 400 models. Reported values are averages over up to 10 partitions, with error bars of 10 standard deviations. (b) The distribution in memorization of RealNews examples as training progresses. (c) The fraction of RealNews examples with memorization consistently above the specified threshold as training progresses. (d) For RealNews, we plot memorization scores against the number of near-duplicates an example had in the dataset.
# 5 Duplicate Text and Memorization
One of the goals of evaluating counterfactual memorization is to identify examples that have a low number of duplicates yet whose presence versus absence in the training data has a large effect on the model. Here, we perform a quantitative study of the (anti-)correlation between duplication and counterfactual memorization compared with the positive correlation between duplication and the βgeneration-time memorizationβ definitions of memorization used by Lee et al. [2021], Carlini et al. [2022], Kandpal et al. [2022].
Following the method from [Lee et al., 2021], we first use MinHash [Broder, 1997] to identify near-duplicate examples in RealNews train set. We consider a example a duplicate if it has an normalized edit similarity of greater than 0.7 (definition included in Appendix I). Out of 2.01 million examples, ${ \sim } 3 8 { , } 0 0 0$ were identified as being a near-duplicate with at least one other example. Among these frequently-occurring examples, the Pearson correlation between an exampleβs counterfactual memorization score and the number of near-duplicates for that example is $- 0 . 3 9$ ; in other words, memorization does quantitatively decrease when data is repeated more often.
In Figure 3d we can see that examples with a large number of near-duplicates have smaller memorization scores. Counterfactual memorization primarily differentiates amongst examples with a few number of duplicates. This makes sense given that examples with lots of near duplicates would likely have their near duplicates in OUT-models. This is to be contrasted with βgeneration-time memorizationβ (discussed in Section A) that measures the textual overlap between model generated texts and the training documents. There, the number of occurrences strongly correlate with the measured memorization [Carlini et al., 2020, Lee et al., 2021, Kandpal et al., 2022]. Counterfactual memorization measures a fundamentally different type of memorization from simple textual matching considered in prior work, providing information about how easy or hard a training example is in the context of the rest of the training set. In Table 1 we can see this effect qualitatively: sequences with near-duplicates in the training set tend to have low counterfactual memorization (as expected) .
# 6 From Memorization to Influence
Counterfactual memorization identifies training examples that contain rare information not conveyed by other examples. A natural question to ask is whether a model would leak the information in a memorized example during inference. Previous paper studies membership inference attack [Shokri et al., 2017, Sablayrolles et al., 2019, Long et al., 2020] where an attacker tries to figure out if a particular example exists in the training set. In this paper, we consider standard model evaluation without adversarial attackers, and quantify βdoes seeing a particular training example strongly influence the prediction on a validation example?β Another way of asking this is if a single example in the training set has an large and over-representative impact on the prediction of a validation example. We answer these questions by measuring counterfactual influence with a formulation adapted from Feldman and Zhang [2020]:
 Figure 4: (a) Histogram of the influence of all the training examples on a specific test example for three different test examples on RealNews. The blue and orange examples have high and intermediate influence from some training examples, as indicated by the outlier values to the right of the each histogram plot. The green one is a random example, where the influence from all individual training examples are close to zero. (b) The joint distribution of the memorization score of each training example and its maximum influence on any validation set example. The histograms are in log scale to better visualize the tail of the distributions. C4 shown in Figure 6.
Definition 6.1 (Counterfactual Influence). Given a training algorithm $A$ that maps a training set $D$ to a trained model, and a performance measure $M$ , the counterfactual influence of a training example $x \in D$ on another example $x ^ { \prime }$ is
$$\mathsf { i n f l } ( x \Rightarrow x ^ { \prime } ) \triangleq \mathbb { E } _ { S \subset D , x \in S } [ M ( A ( S ) , x ^ { \prime } ) ] - \mathbb { E } _ { S \subset D , x \notin S } [ M ( A ( S ) , x ^ { \prime } ) ] ,$$
where $S$ is a subset of training examples sampled from $D$ . The expectation is taken with respect to the random sampling of $S$ , as well as the randomness in the training algorithm $A$ . Here $x ^ { \prime }$ can be an example from the validation set or test set, a generated example or a training example.
An empirical estimation of the influence can be computed similarly to counterfactual memorization by uniformly sampling $m$ subsets $S _ { 1 } , \ldots , S _ { m }$ from $D$ , where $| S _ { i } | = r | D |$ , and calculating
$$\begin{array} { r } { \widehat { \mathfrak { i n f } } | ( x \Rightarrow x ^ { \prime } ) \triangleq \underset { i : x \in S _ { i } } { \mathrm { m e a n } } [ M ( A ( S _ { i } ) , x ^ { \prime } ) ] - \underset { i : x \notin S _ { i } } { \mathrm { m e a n } } [ M ( A ( S _ { i } ) , x ^ { \prime } ) ] . } \end{array}$$
This measures how much a training sample $x$ βs presence influences the prediction of a different example $x ^ { \prime }$ . Note, ${ \mathsf { m e m } } ( x ) = { \mathsf { i n f l } } ( x \Rightarrow x )$ , i.e., counterfactual memorization is self influence.
Influence on Examples of the Validation Set. With the same models trained for estimating memorization, we can estimate the counterfactual influence on the validation set according to Equation (4). For each example in the validation set, we can estimate the influence on it from each training example. Figure 4a shows the distribution of influence from all training example on three different examples from the validation set. The green example was randomly chosen and represents the behavior for most validation examples: it receive close-to-zero influence from all the (individual) training examples. The blue and orange examples were sampled to have high and intermediate maximum influence. Each of them has one (or a few) strong influencer from the training set, as indicated by the bars to the right of the histogram. They also only receive tiny influence from all the rest of the training examples, though the variance of influence is larger than for the green example.
Intuitively, most training examples will have small influence on validation set examples because the models learn distributional patterns shared across many training examples, and individual training examples tend to have insignificant influence here. However, a training example $x$ with high counterfactual memorization contains rare information that are not shared with other examples. Therefore, if a validation set example $x ^ { \prime }$ contains similar information, $\mathsf { i n f l } ( x \Rightarrow x ^ { \prime } )$ could be large. Figure $^ { 4 \mathrm { b } }$ shows the relationship between memorization and influence by plotting $\mathsf { m e m } ( x )$ of each training example $x$ against its maximum influence $\mathrm { m a x } _ { x ^ { \prime } } \mathsf { i n f l } ( x \Rightarrow x ^ { \prime } )$ on $x ^ { \prime }$ across the validation set.
Consistent with our intuition, examples with small memorization scores have small max-influence scores. Larger influence scores on the validation set generally requires larger memorization scores of the training example itself. However, not all training examples with large memorization scores lead to large influence scores. In particular, the max-influences drop significantly for examples with memorization larger than 0.4. One potential reason is that many examples with very high memorization are simply low quality text, so memorization is required in order to learn them, but they do not encode anything interesting that could influence a validation example. On the other hand, even if a memorized example encodes some rare and useful information, the max-influence could still be low because the validation set does not contain a relevant document. This is especially true given that all datasets have considerably smaller validation sets than training sets.
Table 2: Train-validation example pairs of RealNews sampled at a variety of influence levels. [...] indicate text omitted for brevity. Differences in each document pair are highlighted yellow.
<table><tr><td>Index</td><td>Estim.</td><td>Text</td><td></td></tr><tr><td>Validation 1334662</td><td>infl 0.3780</td><td>link ></td><td>Identical URL except with the htp://protocol instead of https://.The text is identical to the training example.</td></tr><tr><td>Train 2077314</td><td>mem 0.3780</td><td>Jeffrey Heller/Jeremy Gaunt)</td><td>linkByAriRabinoichZEELLLEYIsrael(Reuters)edisposablepaperfcemasksoferitteproteionfromteodf dustthatfleelosteaphtoleari</td></tr><tr><td>Validation 838341</td><td>infl 0.1209</td><td>link VATICAN CITY(AP)</td><td>Emeritus Pope Benedict XVI is offering a first-ever papal assessment of his own pontificate in a book that recountshissooipseathscodisptsttleathallVtiasgalb"dic XVI:TheFinalConversatios,"isdueoutinSeptemberthelatestVaticancarerbysimplyspreadinggossipthathewas gay Different</td></tr><tr><td>Train</td><td>mem 0.1650</td><td>link >VATICAN CITY</td><td>websites,but (almost) identical report. Emeritus Pope Benedict XVIisofferingafirst-everpapal assessmentof hisown pontificate inabook thatrecounts hisdecisiontosipiseatscodiseptstosmatleatallVatianβs"globy"ec Final Conversations,"isdueoutineptember,thelatest[.Vaticancarerbysimplyspreadinggossipthathewasgay. Follow Nicole Winfield</td></tr><tr><td>614881</td><td></td><td></td><td>at www.twitter.com/nwinfield linkANAH-OnanighthenFancoiseaucheminhadtwoistsinrontandChrisProngebockedsixsotsinetroi69</td></tr><tr><td>Validation 682107</td><td>infl</td><td>0.0673</td><td>DucksfansmighthavebeelostwitoutheirprogramsonWednesayightItsonlytefrstgameoftepreseasonutaeeraearly begun.AgroupofmostlyewcomersinDucksuniforsbeatPhoenix3-2inashootoutonWednesdayatHondaCenter.Afamilarfacemade ct,however,asobbyRyansoredtwogoalsRyaalsoscoredtwgoalsintheDucksβpreseasonopenerastyariernt</td></tr><tr><td></td><td></td><td></td><td>the biggest impact,</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>websites on the same event with slightly diferent wordings.</td></tr><tr><td>Train</td><td></td><td>mem</td><td>linkANAHE-OnanightwhenFrancoisBeaucheminhadtwoasstsinorontoandChrisProngerblockedsixsots inDetroit,the</td></tr><tr><td>494435</td><td></td><td>0.1439</td><td>13,869 Ducks' fans who showed at at Honda Center Wednesday needed programs to identify the players on their favorite team.</td></tr><tr><td></td><td></td><td></td><td>frstgameoftepresasoutraasal.Agroupofostlwcoesiucksosatoix-inot</td></tr><tr><td></td><td></td><td></td><td>althoughafamiliarfacemade thebiggest impactasBobbyRyanscoredtwo goalsinregulationandanother intheshootout. two goals in the Ducksβ preseason opener last year[...]</td></tr><tr><td></td><td></td><td></td><td>Ryan also scored</td></tr><tr><td>Validation</td><td></td><td>infl</td><td>linkxMoretan7oo poundsofButerballtrkeyrecalledbecauseofpotentialsalmonella WASHINGONβThe U.S.Departentof</td></tr><tr><td>1165799</td><td></td><td>0.0360</td><td>Agriculture's Food Safety and Inspections services announced on Wednesday[ [.] They were shipped to nationwide retail and institutional</td></tr><tr><td></td><td></td><td></td><td>locations.RELATED: View the fullrecall FSIS,the Centers for Disease Control and Prevention and[..] Different websitesreportingthe same</td></tr><tr><td></td><td></td><td></td><td>event, one embeded a lot more information than the other.</td></tr><tr><td>Train</td><td></td><td></td><td>link > x Butterball recalls nearly 8o.oo0 pounds of turkey a after salmonella cases WASHINGTON- The U.S. Department of Agriculture's</td></tr><tr><td>1571976</td><td></td><td>mem</td><td>Food Safetyand Inspection service announced Wednesday [..] The raw ground turkey was produced on July 7, 2018. The following products</td></tr><tr><td></td><td></td><td>0.2094</td><td></td></tr><tr><td></td><td></td><td></td><td>under recall were shippedtonationwide retailand institutionallocations: 48-oz.plastic wrappedtraycontaining"BUTTERBALLeveryday</td></tr><tr><td></td><td></td><td></td><td>Fresh GroundTurkeyWITHNAURALFLAVORING(85%LEAN/15%FAT)withsellorfreeze bydateof726/18,lotcode 818andUP</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>codes22655-7155or2655-71557representedonthelabel.48-oz.plasticwrappedtraycontaining"BUERBALLeverdayFreshGoud</td></tr><tr><td></td><td></td><td></td><td>Turkey WITH NATURAL FLAVORING (93% LEAN/7% FAT)" with sellor freeze by date of 7/26/18, lot[.] labelshere. FSIS,the Centers for</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td>Disease Control and Prevention and</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr></table>
Table 2 shows train-validation example pairs from RealNews sampled at different influence value ranges. We found that the train-validation pairs with the highest influence are almost identical, except some superficial differences, such as different handling of quotation / em dash marks. As we move to intermediate influence ranges, we commonly found reports on the same events. Large paragraphs of identical text indicate that one document might be citing the other or both citing from a third party. At low influence, two types of correlations are commonly observed: 1) templated texts with high similarityβthe reason for a low influence is that there are many similar training examples that split the influence; 2) superficially related documents due to a shared prefix such as ST. CLOUD β This week in our βBehind the Scenesβ series on WJON or a shared substring of some common knowledge like FSIS, the Centers for Disease Control and Prevention. Due to high signal-to-noise ratio, here were no noticeable relationships in the document pairs with influence scores below 0.02.
Influence turns out to be an effective tool for analyzing and attributing the model predictions at test time: for predictions that rely on information obtained by (counterfactual) memorization, we can identify exactly which training example provided such information. Our observation of nearduplicated training-validation document pairs is consistent with recent studies that identifies data contamination in large Internet crawled text corpus [Lee et al., 2021, Dodge et al., 2021].
Influence on Generated Texts. The influence estimation is not restricted to the validation set. We can also estimate influence on generated examples. In this section, we evaluate on the publicly released generations from the Grover models [Zellers et al., 2019] trained on RealNews. Specifically, we take the generations from Grover-Mega $\scriptstyle ( \mathtt { p } = 0 . 9 6 )$ ), a 1.5-billion-parameter model trained on the RealNews dataset. Comparing with the train-validation influence in Figure 4b, the histogram (c.f. Figure 10 in Appendix.) decays faster as max-influence grows. Moreover, the value range of max-influence is also twice smaller. The reason that we did not find a lot of highly influenced generated examples are two fold: 1) there are only 24,576 generation in the public release, which is much fewer than the validation examples. As a result, the corresponding example of many memorized training examples do not get sampled in the generations. For comparison, previous work [Carlini et al., 2020, Lee et al., 2021] generated $1 0 0 { , } 0 0 0 { + }$ examples to identify memorization in generation. These approaches also count duplicates in the training set, which counterfactual memorization filters out. 2) The Grover model was trained on the full RealNews training set, while we have restricted our analysis to the first 2M training examples. There could be potentially more high influence training examples that are missed in our calculation.
# 7 Summary and Discussion
We studied memorization in neural language models. We formulated a notion of counterfactual memorization as a tool that can systematically ignore βcommonβ memorization such as general knowledge (e.g. βParis is a city in Franceβ) and captures memorization of rare, specific information (e.g. description of a specific episode of event) present in the training examples. We conducted experiments on three commonly used text corpus in language modeling and found memorization in all of them. We further analyze the per-domain memorization profiles for Internet-crawled data, and found that different sources could have substantially different memorization profiles.
Furthermore, we analyzed how memorized training examples could impact the model predictions at test time via counterfactual influence. We found that for examples from both the validation set and the model generated texts, the model predictions could be drastically different depending on the presence or absence of a particular training example with high memorization.
Limitations. This study mainly focus on English datasets. While we expect the characterization of memorization would be similar when evaluated on corpus of other (natural) languages, new patterns might be observed on multilingual data or more structured domains such as programming languages.
Both the neural language models and training sets used in this work are orders of magnitude smaller than modern standards such as GPT-3 [Brown et al., 2020], GPT-4 [OpenAI, 2023] and PaLM2 [Google, 2023]. Moreover, we only conducted preliminary investigation of the dynamics of counterfactual memorization during training. Although our experiments effectively estimated and detected memorization, we suspect more interesting examples might emerge if larger, more capable models are analyzed. For example, currently when the information from a memorized training example is leaked in the prediction of a strongly influenced test example, it can usually be explained by a high text overlap between the training and test examples. For models with deeper understanding of languages, we suspect that strong influence could be observed even between documents that have no direct text overlap but that encode similar semantic information.
In order to test this, it will be necessary to scale our framework to larger models and datasets. Moreover, it will be necessary to construct datasets where semantically similar but textually different document pairs exist. One potential source to construct such datasets would be versioned Wikipedia articlesβtwo versions of the same article with large time span or edit distance may contain semantically similar (but paraphrased) information. Such a dataset of paraphrased text pairs would be more broadly useful to understand the ability of different models to disentangle text content and formβby measuring the influence of one piece of text on a paraphrased piece of text.
Counterfactual memorization enables us to identify examples that whose presence or absence has a large impact on the model and the modelβs ability to score and generate other text. The privacy risk for this is low since in order to perform this analysis, one would need to already have access to the dataset and the ability to train models.
Acknowledgments. The authors would like to thank Samy Bengio, Christopher A. ChoquetteChoo, Ethan Dyer, Michael C. Mozer, Behnam Neyshabur, Andrew Nystrom, and Hanie Sedghi for constructive discussions and feedback. The authors would like to thank Andrew Nystrom for assistance with MinHash-based near-duplicate detection.
# References
Samyadeep Basu, Philip Pope, and Soheil Feizi. Influence functions in deep learning are fragile. ArXiv, abs/2006.14651, 2021.
Rishi Bommasani, Drew A Hudson, Ehsan Adeli, Russ Altman, Simran Arora, Sydney von Arx, Michael S Bernstein, Jeannette Bohg, Antoine Bosselut, Emma Brunskill, Erik Brynjolfsson, Shyamal Buch, Dallas Card, Rodrigo Castellon, Niladri Chatterji, Annie Chen, Kathleen Creel, Jared Quincy Davis, Dora Demszky, Chris Donahue, Moussa Doumbouya, Esin Durmus, Stefano Ermon, John Etchemendy, Kawin Ethayarajh, Li Fei-Fei, Chelsea Finn, Trevor Gale, Lauren Gillespie, Karan Goel, Noah Goodman, Shelby Grossman, Neel Guha, Tatsunori Hashimoto, Peter Henderson, John Hewitt, Daniel E Ho, Jenny Hong, Kyle Hsu, Jing Huang, Thomas Icard, Saahil Jain, Dan Jurafsky, Pratyusha Kalluri, Siddharth Karamcheti, Geoff Keeling, Fereshte Khani, Omar Khattab, Pang Wei Kohd, Mark Krass, Ranjay Krishna, Rohith Kuditipudi, Ananya Kumar, Faisal Ladhak, Mina Lee, Tony Lee, Jure Leskovec, Isabelle Levent, Xiang Lisa Li, Xuechen Li, Tengyu Ma, Ali Malik, Christopher D Manning, Suvir Mirchandani, Eric Mitchell, Zanele Munyikwa, Suraj Nair, Avanika Narayan, Deepak Narayanan, Ben Newman, Allen Nie, Juan Carlos Niebles, Hamed Nilforoshan, Julian Nyarko, Giray Ogut, Laurel Orr, Isabel Papadimitriou, Joon Sung Park, Chris Piech, Eva Portelance, Christopher Potts, Aditi Raghunathan, Rob Reich, Hongyu Ren, Frieda Rong, Yusuf Roohani, Camilo Ruiz, Jack Ryan, Christopher Ré, Dorsa Sadigh, Shiori Sagawa, Keshav Santhanam, Andy Shih, Krishnan Srinivasan, Alex Tamkin, Rohan Taori, Armin W Thomas, Florian Tramèr, Rose E Wang, William Wang, Bohan Wu, Jiajun Wu, Yuhuai Wu, Sang Michael Xie, Michihiro Yasunaga, Jiaxuan You, Matei Zaharia, Michael Zhang, Tianyi Zhang, Xikun Zhang, Yuhui Zhang, Lucia Zheng, Kaitlyn Zhou, and Percy Liang. On the opportunities and risks of foundation models. August 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, 2018. URL http://github.com/google/jax.
Andrei Z Broder. On the resemblance and containment of documents. In Proceedings. Compression and Complexity of SEQUENCES 1997 (Cat. No. 97TB100171), pages 21β29. IEEE, 1997.
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 H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 1877β1901. Curran Associates, Inc., 2020. URL https://proceedings. neurips.cc/paper/2020/file/1457c0d6bfcb4967418bfb8ac142f64a-Paper.pdf.
Nicholas Carlini, Chang Liu, Γlfar Erlingsson, Jernej Kos, and Dawn Song. The secret sharer: Evaluating and testing unintended memorization in neural networks. In USENIX Security Symposium, 2019.
Nicholas Carlini, Florian Tramer, Eric Wallace, Matthew Jagielski, Ariel Herbert-Voss, Katherine Lee, Adam Roberts, Tom Brown, Dawn Song, Ulfar Erlingsson, et al. Extracting training data from large language models. arXiv preprint arXiv:2012.07805, 2020.
Nicholas Carlini, Steve Chien, Milad Nasr, Shuang Song, Andreas Terzis, and Florian Tramer. Membership inference attacks from first principles, 2021.
Nicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee, Florian Tramer, and Chiyuan Zhang. Quantifying memorization across neural language models. arXiv preprint arXiv:2202.07646, 2022.
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.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171β4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https: //aclanthology.org/N19-1423.
Jesse Dodge, Maarten Sap, Ana Marasovic, William Agnew, Gabriel Ilharco, Dirk Groeneveld, and Matt Gardner. Documenting the english colossal clean crawled corpus. arXiv preprint arXiv:2104.08758, 2021.
Cynthia Dwork, Aaron Roth, et al. The algorithmic foundations of differential privacy. Found. Trends Theor. Comput. Sci., 9(3-4):211β407, 2014.
Yanai Elazar, Nora Kassner, Shauli Ravfogel, Amir Feder, Abhilasha Ravichander, Marius Mosbach, Yonatan Belinkov, Hinrich SchΓΌtze, and Yoav Goldberg. Measuring causal effects of data statistics on language modelβs factual predictions. arXiv preprint arXiv:2207.14251, 2022.
Vitaly Feldman. Does learning require memorization? A short tale about a long tail. In STOC, 2020.
Vitaly Feldman and Chiyuan Zhang. What neural networks memorize and why: Discovering the long tail via influence estimation. In Advances in Neural Information Processing Systems, 2020.
Google. Palm 2 technical report. Technical report, Google, 2023.
Mandy Guo, Zihang Dai, Denny Vrandecic, and Rami Al-Rfou. Wiki-40b: Multilingual language model dataset. In LREC 2020, 2020.
Frank R Hampel. The influence curve and its role in robust estimation. Journal of the american statistical association, 69(346):383β393, 1974.
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.
Peter Henderson, Koustuv Sinha, Nicolas Angelard-Gontier, Nan Rosemary Ke, Genevieve Fried, Ryan Lowe, and Joelle Pineau. Ethical challenges in data-driven dialogue systems, 2017.
Andrew Ilyas, Sung Min Park, Logan Engstrom, Guillaume Leclerc, and Aleksander Madry. Datamodels: Predicting predictions from training data. arXiv preprint arXiv:2202.00622, 2022.
Guido W Imbens and Donald B Rubin. Causal inference in statistics, social, and biomedical sciences. Cambridge University Press, 2015.
Matthew Jagielski, Jonathan Ullman, and Alina Oprea. Auditing differentially private machine learning: How private is private sgd?, 2020.
Nikhil Kandpal, Eric Wallace, and Colin Raffel. Deduplicating training data mitigates privacy risks in language models. arXiv preprint arXiv:2202.06539, 2022.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In The International Conference for Learning Representations, 2015.
Pang Wei Koh and Percy Liang. Understanding black-box predictions via influence functions. ArXiv, abs/1703.04730, 2017.
Pang Wei Koh, Kai-Siang Ang, Hubert Hua Kian Teo, and Percy Liang. On the accuracy of influence functions for measuring group effects. In NeurIPS, 2019.
Jooyoung Lee, Thai Le, Jinghui Chen, and Dongwon Lee. Do language models plagiarize? In Proceedings of the ACM Web Conference 2023, pages 3637β3647, 2023.
Katherine Lee, Daphne Ippolito, Andrew Nystrom, Chiyuan Zhang, Douglas Eck, Chris CallisonBurch, and Nicholas Carlini. Deduplicating training data makes language models better. CoRR, abs/2107.06499, 2021. URL https://arxiv.org/abs/2107.06499.
Yunhui Long, Lei Wang, Diyue Bu, Vincent Bindschaedler, Xiaofeng Wang, Haixu Tang, Carl A Gunter, and Kai Chen. A pragmatic approach to membership inferences on machine learning models. In 2020 IEEE European Symposium on Security and Privacy (EuroS&P), pages 521β534. IEEE, 2020.
Sayan Mukherjee, Partha Niyogi, Tomaso Poggio, and Ryan Rifkin. Learning theory: stability is sufficient for generalization and necessary and sufficient for consistency of empirical risk minimization. Advances in Computational Mathematics, 25(1):161β193, 2006.
Milad Nasr, Shuang Song, Abhradeep Thakurta, Nicolas Papernot, and Nicholas Carlini. Adversary instantiation: Lower bounds for differentially private machine learning, 2021.
OpenAI. Gpt-4 technical report. arXiv, 2023.
Judea Pearl. Causal inference in statistics: An overview. 2009.
Judea Pearl et al. Causality: Models, reasoning and inference. Cambridge, UK: CambridgeUniversityPress, 19(2):3, 2000.
Garima Pruthi, Frederick Liu, Mukund Sundararajan, and Satyen Kale. Estimating training data influence by tracking gradient descent. ArXiv, abs/2002.08484, 2020.
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, 2020a. URL http://jmlr.org/papers/v21/20-074.html.
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, 2020b. URL http://jmlr.org/papers/v21/20-074.html.
Vikas Raunak, Arul Menezes, and Marcin Junczys-Dowmunt. The curious case of hallucinations in neural machine translation. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 1172β1183, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021. naacl-main.92. URL https://aclanthology.org/2021.naacl-main.92.
Donald B Rubin. Causal inference using potential outcomes: Design, modeling, decisions. Journal of the American Statistical Association, 100(469):322β331, 2005.
Alexandre Sablayrolles, Matthijs Douze, Yann Ollivier, Cordelia Schmid, and HervΓ© JΓ©gou. Whitebox vs black-box: Bayes optimal strategies for membership inference, 2019.
Reza Shokri, Marco Stronati, Congzheng Song, and Vitaly Shmatikov. Membership inference attacks against machine learning models. In 2017 IEEE Symposium on Security and Privacy (SP), pages 3β18. IEEE, 2017.
Larry R Squire. Memory and the hippocampus: a synthesis from findings with rats, monkeys, and humans. Psychological review, 99(2):195, 1992.
Om Thakkar, Swaroop Ramaswamy, Rajiv Mathews, and FranΓ§oise Beaufays. Understanding unintended memorization in federated learning, 2020.
Aleena Thomas, David Ifeoluwa Adelani, Ali Davody, Aditya Mogadala, and Dietrich Klakow. Investigating the impact of pre-trained word embeddings on memorization in neural networks. In International Conference on Text, Speech, and Dialogue, pages 273β281. Springer, 2020.
Endel Tulving. Elements of episodic memory. Oxford University Press, 1983. ISBN 9780198521259.
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.
Nikhil Vyas, Sham Kakade, and Boaz Barak. Provable copyright protection for generative models. arXiv preprint arXiv:2302.10870, 2023.
Tianhao Wang and Ruoxi Jia. Data banzhaf: A data valuation framework with maximal robustness to learning stochasticity. arXiv preprint arXiv:2205.15466, 2022.
Santiago Zanella-BΓ©guelin, Lukas Wutschitz, Shruti Tople, Victor RΓΌhle, Andrew Paverd, Olga Ohrimenko, Boris KΓΆpf, and Marc Brockschmidt. Analyzing information leakage of updates to natural language models. Proceedings of the 2020 ACM SIGSAC Conference on Computer and Communications Security, Oct 2020. doi: 10.1145/3372297.3417880. URL http://dx.doi.org/ 10.1145/3372297.3417880.
Rowan Zellers, Ari Holtzman, Hannah Rashkin, Yonatan Bisk, Ali Farhadi, Franziska Roesner, and Yejin Choi. Defending against neural fake news. In Advances in Neural Information Processing Systems, 2019.
Susan Zhang, Stephen Roller, Naman Goyal, Mikel Artetxe, Moya Chen, Shuohui Chen, Christopher Dewan, Mona Diab, Xian Li, Xi Victoria Lin, Todor Mihaylov, Myle Ott, Sam Shleifer, Kurt Shuster, Daniel Simig, Punit Singh Koura, Anjali Sridhar, Tianlu Wang, and Luke Zettlemoyer. Opt: Open pre-trained transformer language models, 2022.
Albert Ziegler. GitHub Copilot: Parrot or crow? https://docs.github.com/en/github/copilot/researchrecitation, 2021.
 Figure 5: Per-token accuracy of training examples evaluated on IN models vs OUT models.
# A Difference Between Counterfactual and Generation-Time Memorization
Many definitions of memorization operate at generation-time: a sequence of generated text is marked as memorized if a sufficient amount of overlap is found in the training dataset [Carlini et al., 2020]. When the training data is not available, heuristic-based methods comparing language model perplexities are used to predict whether a generation contains memorized content [Carlini et al., 2019, Thakkar et al., 2020, Thomas et al., 2020, Carlini et al., 2020, Zanella-BΓ©guelin et al., 2020]. One difficulty with these approaches is that generation-time instances of memorization are strongly correlated with the number of similar or near-duplicate examples in the training set. As observed in Lee et al. [2021], large clusters of near-duplicated examples do exist in common language datasets, dominating memorization detected in generated text. Generation-time methods for measuring memorization are forced to design heuristics to avoid simply identifying these uninteresting instances of memorization.
In contrast, the counterfactual memorization we study in this paper handles the issue of near-duplicates automatically without the need for heuristics. For a training example, $x$ , with many near-duplicate copies in the training set, $\mathsf { m e m } ( x )$ will be small (because other samples $x ^ { \prime } \approx x$ will be present in the training dataset whether or not $x$ is). This does not mean that counterfactual memorization is the opposite of generation-time memorization. An example, $x$ , with high $\mathsf { m e m } ( x )$ may have a high chance of being generated if a model is appropriately prompted, despite and possibly because it is rare, and thus the example is considered memorized by both definitions. In summary, generationtime memorization measures the chance a model will directly copy from training examples, while counterfactual memorization aims to discover rare information that is memorized.
# B Average Accuracy of IN models vs OUT models
Figure 5 compares the per-token accuracy between the IN models and OUT models for the training examples from three different datasets. Counterfactual memorization is estimated by taking the difference between the average IN-accuracy and the average OUT-accuracy. Thus, the examples closer to the upper left corner are more counterfactually memorized, while the examples near the diagonal are not.
# C The Impact of Data Deduplication on Memorization
To investigate the impact of data deduplication on counterfactual memorization, we compared C4 with C4-NEARDUP [Lee et al., 2021], which is derived from C4 with deduplication using approximate document matching. Figure 7 compares the distribution of memorization between the original C4 and the deuplicated dataset. We did not find significant difference between the two datasets. One potential reason is that the deduplication criterion was relatively conservative, which removed only $\sim 3 \%$ of the training examples. In fact, we can still easily see near duplicate examples in C4-NEARDUP among examples with low memorization, as shown below:
Example 1380925 $\mathtt { ( m e m = 0 . 0 3 7 4 }$ ) link $\vartriangleright$ This is a placeholder page for Joshua Baldridge, which means this person is not currently on this site. We do suggest using the tools below to find Joshua Baldridge. You are visiting the placeholder page for Joshua Baldridge. This page is here because someone used our placeholder utility to look for Joshua Baldridge. We created this page automatically in hopes Joshua Baldridge would find it. If you are not Joshua Baldridge, but are an alumni of Brecksville Broadview Heights High School, register on this site for free now.
 Figure 6: Full version of Figure 4b: The joint distribution of the memorization score of each training example and its maximum influence on any validation set example. The histograms are in log scale to better visualize the tail of the distributions.
Example 2048352 $\mathrm { { ( m e m = 0 . 0 3 2 0 ) } }$ ) link $\vartriangleright$ This is a placeholder page for Laytoya Brannon, which means this person is not currently on this site. We do suggest using the tools below to find Laytoya Brannon. You are visiting the placeholder page for Laytoya Brannon. This page is here because someone used our placeholder utility to look for Laytoya Brannon. We created this page automatically in hopes Laytoya Brannon would find it. If you are not Laytoya Brannon, but are an alumni of Mainland High School, register on this site for free now.
Example 1314053 $\mathtt { ( m e m = 0 . 0 2 7 8 ) }$ ) link $\vartriangleright$ This is a placeholder page for Devin Mcguire, which means this person is not currently on this site. We do suggest using the tools below to find Devin Mcguire. You are visiting the placeholder page for Devin Mcguire. This page is here because someone used our placeholder utility to look for Devin Mcguire. We created this page automatically in hopes Devin Mcguire would find it. If you are not Devin Mcguire, but are an alumni of Kankakee Valley High School, register on this site for free now.
Example 1085524 $\mathrm { { ( m e m = 0 . 0 2 0 9 } }$ ) link $\vartriangleright$ This is a placeholder page for Anthony Christie, which means this person is not currently on this site. We do suggest using the tools below to find Anthony Christie. You are visiting the placeholder page for Anthony Christie. This page is here because someone used our placeholder utility to look for Anthony Christie. We created this page automatically in hopes Anthony Christie would find it. If you are not Anthony Christie, but are an alumni of Old Bridge High School, register on this site for free now.
 Figure 7: The joint distribution of memorization and simplicity. The histograms are plotted in log scale to better visualize the tail of the distributions.

 Figure 8: Spearmanβs R between memorization rankings from a set of $m$ models and our full set of 400 models. As more models are trained, the ranking changes very little, with the ranking at 192 models having a Spearmanβs R of at least 0.992 on all datasets. Figure 9: The variance in memorization scores decreases significantly as the number of models increases for all 3 datasets.
Measurements of the edit distances show that they are near the boundary of the deduplication threshold chosen in Lee et al. [2021]. On the other hand, the tail of the distribution β examples with high counterfactual memorization are mostly unaffected by text deduplication.
# D Variance of Memorization Scores
In Figure 8, we measure the Spearmanβs R between our total set of 400 models and an $m$ model subset. As expected, as $m$ increases, so does Spearmanβs Rβin particular, at 192 models, the Spearmanβs R is at least $9 9 . 2 \%$ for all datasets, and increasing $m$ already appears to have diminishing returns.
Using the same partitioning into size $m$ sets of models, we analyze the variance of memorization scores assigned to each sample. To do this, within each partition, we compute the memorization score assigned to each sample. We then compute the standard deviation of all partitionsβ memorization scores for each sample. In Figure 9, we plot each sampleβs standard deviation β in all, this demonstrates the distribution of the variance of memorization scores. We find that the variance decreases substantially as $m$ grows, and concentrates near 0 already with $m = 1 9 2$ , for all datasets.
# E Histogram of Max-Influence on Generated Texts
Figure 10 shows the histogram of max-influence on each generated example by Grover-Mega $\scriptstyle \left( \mathrm { p } = 0 . 9 6 \right)$ [Zellers et al., 2019], from the RealNews training examples. Those generated examples are publicly released at https://github.com/rowanz/grover/tree/master/generation_examples.
# F Miscellaneous Experiment Details
Our experiments are implemented using JAX [Bradbury et al., 2018] and Flax [Heek et al., 2020], both open sourced library under the Apache-2.0 license. In the study of influence on generated texts, we use the publicly released generations from the Grover models [Zellers et al., 2019], available at their open source code repository, under the Apache-2.0 license.
We run the experiments using our internal cluster. The majority of the compute is consumed by model training. In this paper, we use standard training setup for transformer based neural language models, which could run on single node machines with one or multiple GPUs. However, to carry out the full analysis, we need to train 400 different models for each of the three datasets analyzed in this paper.
 Figure 10: Histogram of max-influence on each generated example by Grover-Mega $\scriptstyle ( \mathtt { p } = 0 . 9 6$ ), from the RealNews training examples.
 Figure 11: Comparison of hash based subset sampling with numpy.random.choice.
# G Subsampling Procedure
In the estimation of memorization and influence, we trained 400 models each on an independent random subset of training examples. We use Tensorflow Datasets (TFDS) 2 to load our training data. TFDS supports loading a continuous range of examples, but does not support subset loading from a list of indices of individual examples. The API has a filter function which allows us to provide a Tensorflow predicate to precisely control the subset loading. However, a naive implementation of checking whether the index of the current example is in a given list of subset indices is very slow and scales poorly with the subset size.
To mitigate the issue, we implemented a hash based subset sampling predicate that can be evaluated efficiently for each example, and (approximately) select a random subset of a specified size. Let $N$ be the total number of training examples, $n < N$ be the expected subset size. The idea is to map the index $i$ of each example to $N / n$ hash buckets, and select all the examples that fall into one particular bucket. To make sure each model gets an independent subset sampling, we need to use different hash functions for different models. In our implementation, we compose a known hash function for uint64 types with a simple pseudo number based on the index of the current model to achieve this. Note the subset size sampled is close to $n$ but is not guaranteed to be exactly $n$ . But this is not a problem in our settings. The specific implementation is shown below:
def hash_sampler(mod, seed, system): """Get hash based subset sampler.
Args: mod: total_n_egs // subset_size seed: different seed leads to different subset sample
system: 'np' or 'tf'.
Returns:
A Tensorflow or Numpy subset sampler. np_hash $=$ hash_uint64_builder('np') mul, offset, remainder $=$ np_hash(seed $^ +$ 1234 + np.arange(3)) remainder $=$ remainder % mod
if system $\ d = \ d \cdot \mathsf { n p } ^ { \prime }$ : def np_sampler(n_total): $\mathrm { ~ \bf ~ { ~ x ~ } ~ } =$ np.arange(n_total, dtype=np.uint64) return np_hash(x\*mul $^ +$ offset) $\%$ mod $= =$ remainder return np_sampler elif system $= =$ 'tf': tf_hash $=$ hash_uint64_builder('tf') def tf_filter(idx, _): return tf.equal(tf_hash(idx\*mul $^ +$ offset) % mod, remainder) return tf_filter raise KeyError(f'Unknown system: {system}')
def hash_uint64_builder(system): """Build a hash function in tf/np for uint64.""" if system $\ d = \ d \cdot \mathsf { n p } ^ { \prime }$ : uint64_cast $=$ functools.partial(np.array, dtype=np.uint64) op_xor $=$ operator.xor op_rshift $=$ operator.rshift elif system $= =$ 'tf': uint64_cast $=$ functools.partial(tf.cast, dtype=tf.uint64) op_xor $=$ tf.bitwise.bitwise_xor op_rshift $=$ tf.bitwise.right_shift else: raise KeyError(f'Unknown system: {system}')
# https://stackoverflow.com/questions/664014/ # what-integer-hash-function-are-good-that-accepts-an-integer-hash-key def hash_uint64(x): $\times \ =$ uint64_cast(x) $\times \ =$ op_xor(x, op_rshift(x, 30)) $\star$ uint64_cast(0xbf58476d1ce4e5b9) $\times \ =$ op_xor(x, op_rshift(x, 27)) $\star$ uint64_cast(0x94d049bb133111eb) x = op_xor(x, op_rshift(x, 31)) return x
return hash_uint64
In Figure 11, we compare our hash-based subset sampler with numpy.random.choice(N, size=n, replace $=$ False). The leftmost section of the figure shows that the sampling procedure always samples close to $n$ points, with a small variance. The middle section plots a histogram of the empirical fraction of total models that each point appears in. Note that, because we use $r = 0 . 2 5$ , this fraction should be 0.25 on average, although, because we only use 400 models, each value will not be identically 0.25. We find that our hash-based sampler produces probabilities which are highly consistent with those produced by numpy.random.choice. We also measure the pairwise independence of the hash-based sampler, measuring the probability that two different training points $x _ { 1 } , x _ { 2 }$ appear both IN or OUT of a modelβs training set. We expect this value to be 0.625 $( = r ^ { 2 } + ( 1 - r ) ^ { 2 } )$ . We plot this in the right portion of the figure, demonstrating that the independence of our hash-based sampler is very similar to numpy.random.choice.
 Figure 12: Comparison of directly using the per-token-accuracy vs. taking the logit of the per-tokenaccuracy. Top row: logit(per-token-accuracy). Bottom row: per-token-accuracy. Figures exactly the same as Figure 5.
# H Alternative Memorization Metrics with Logit Scaling
We defined the counterfactual memorization in (1) with a generic performance measure $M$ . Throughout the paper, we define $M$ as per-token accuracyβthe fraction of the times the model assigns the highest score to the true next token in the sequence. The finite value range could cause unnecessary compression for values near the interval boundary. As a result, the resolution of memorization estimation is lower for models with very high or very low performance. To mitigate this issue, we explore an alternative measure by taking the logit on the per-token accuracy [Carlini et al., 2021]. The logit function maps to $( - \infty , \infty )$ before aggregating across independently trained models. Figure 12 compares the scatter plots of average performance on IN / OUT models measured by the logit scaled per-token accuracy and the raw per-token accuracy. Comparing to the raw per-token accuracy, the scatter plots generated with the logit scaled measure are no longer artificially constrained to be a triangular shape. As a result, the memorization estimation, which is proportional to the distance to the diagonal line, has a higher resolution on the two ends (lower left and upper right) than the unscaled version.
Note there is no absolutely right or wrong measure. While the scaled version has better resolution on the two ends, the advantage of the unscaled version is that the value range [0, 1] makes it straightforward to interpret the numerical values of counterfactual memorization. Since the consistency between the two versions are high (Spearmanβs $\rho$ correlation between the two versions are $0 . 9 4 7 \mathrm { ~ / ~ } 0 . 9 0 3 \mathrm { ~ / ~ }$ 0.944 on RealNews/ C4/ Wiki40B:en), we use the unscaled version throughout the paper for easier interpretation.
# I Definition of Edit Similarity
We define the edit similarity between two sequences $x _ { i }$ and $x _ { j }$ as. In our case, we use token-level similarity.
$$\mathrm { E d i t S i m } ( x _ { i } , x _ { j } ) = 1 - { \frac { \mathrm { E d i t D i s t a n c e } ( x _ { i } , x _ { j } ) } { \operatorname* { m a x } ( | x _ { i } | , | x _ { j } | ) } }$$
Table 3: Pairs of RealNews training examples and Grover generations sampled at several influence levels. βlinkβ contains the document URL. [...] indicate text omitted for brevity. Differences in each pair are highlighted.
<table><tr><td></td><td rowspan=1 colspan=15>Index Estim. Text</td></tr><tr><td></td><td rowspan=5 colspan=15>Generation infl linkBakubaAridlateofUdostbaatsa91361 0.1805 manats,espeielyrileloeatesofbjatstodrsccdgtoatafrCtalBankof AzerbaijanforAprilI5.0OJapaneseyen10JPY1.51871NewZealanddollar1NZD1.1513FollowTrendonTelegram.Onlymost interesting and important newsTrain mem linkBakbacdgateofUdgtAbjmawasseatd2072973 0.3534 manats,respeelyfarch5.loeatesofbjagstordecodgtoatafroCalBank of AzerbaijanforMarch15.[Japaneseyen1JY5221NewZealanddolla1NZD11636FollowTendonTelegram.Onlymost interesting and important news</td></tr><tr><td></td><td rowspan=1 colspan=2>1361</td></tr><tr><td></td><td rowspan=1 colspan=1></td></tr><tr><td></td><td rowspan=1 colspan=5>manats,respec</td><td rowspan=1 colspan=2>bectively</td></tr><tr><td></td><td rowspan=1 colspan=2>nkofA</td><td rowspan=1 colspan=4>Azerbaijanfor</td></tr><tr><td></td><td rowspan=3 colspan=15>Generation infl link > NEW DELHI: India is likely to see average monsoon rains this year.thestate-runvweather office said on Monday, which should support21998 0.0218 agriculturalpodctiodoocothisiaβsdigooealffadcstioslis</td></tr><tr><td></td></tr><tr><td></td><td rowspan=1 colspan=1></td></tr><tr><td></td><td rowspan=6 colspan=14>expectedtob96petofteogteaverage,M.jeeanetaryatteistryofarthiencstoldcofereeIndiaMeterolicaepnt(sagalifallte96ped4tf89 centimeters for the entire four-month season beginning June. [..]However,onaveraeteIasforeastaccratelyolyoeeveriveyearsovertepasttdeades,venaftertingcctanerror band of plus or minus 5 percentage points.</td><td rowspan=1 colspan=1>retaryat theMinistry of E</td></tr><tr><td></td><td rowspan=2 colspan=1>allasbety</td></tr><tr><td></td><td rowspan=1 colspan=1>he Ministry of Earth Sci</td></tr><tr><td></td><td rowspan=1 colspan=1>ndia's</td></tr><tr><td></td><td rowspan=2 colspan=8>error band of plus or minus 5 percentage points.</td><td rowspan=1 colspan=2>Dhas</td><td rowspan=2 colspan=2>as forecast</td><td rowspan=2 colspan=1>east accurately only once every five y</td></tr><tr><td></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=5 colspan=3>Train326212</td><td rowspan=1 colspan=2>Train326212</td><td rowspan=1 colspan=3>mem0.1555</td><td rowspan=1 colspan=7>higherfarmand</td><td rowspan=1 colspan=1>rs)-In</td></tr><tr><td rowspan=4 colspan=2></td><td rowspan=1 colspan=3>thecountry</td><td rowspan=1 colspan=8>ry's$2trillioneconomy.areexpected</td><td rowspan=1 colspan=1>be97p</td></tr><tr><td rowspan=1 colspan=11>Meteorological Department (IMD), told a newsconference.βWe see very less probability of a deficit monsoon," Ramesh said on Monday.Otherthanliftingfarmandiderconomicgrowth,aspellofgoodrainswillkeepalidonifation,potentillytmptingPrieisterNarendraoditiadgeeaetisueiy9.aβsathofsageoalfalle96</td><td rowspan=1 colspan=1>βWe see very less probability of a deficit monsoon," Ramesh said on Monday.Otherthanliftingfarmandiderconomicgrowth,aspellofgoodrainswillkeepalidonifation,potentillytmptingPrieister</td></tr><tr><td rowspan=1 colspan=11>percentand104percentofyearaverageof89forthentiefour-mothseasonbegiingJne.saidaumbabaseddealerwit</td></tr><tr><td rowspan=1 colspan=11>a global trading firm. Average monsoon rainfallwill help India retain its position as the world's top rice exporter</td></tr></table>
# J Examples of Train-Generation Pairs at Different Influence Ranges
In table 3, we show examples of train-generation pairs sampled from different influence ranges. The patterns generally follow the train-validation pairs shown in table 2, although many of the relations are due to some form of templating.
# K Examples Sampled at Different Level of Memorization
Figure 13, Figure 14, and Figure 15 show full examples from RealNews sampled at high, middle and low memorization value ranges, respectively. Similarly, Figure 16, Figure 17, and Figure 18 show examples from C4 sampled at high, middle and low memorization value ranges, respectively. Figure 19, Figure 20, and Figure 21 show examples from Wiki40B:en sampled at high, middle and low memorization value ranges, respectively.
# L Example Pairs Sampled at Different Level of Influence
Figure 22, Figure 23, Figure 24, Figure 25, and Figure 26 show train-validation example pairs from RealNews sampled from high to low influence ranges. For each pair, we show the validation set example first, and then show the corresponding training example with a difflib generated visualization of textual difference with the training example.
Similarly, Figure 27 and Figure 28 show train-validation example pairs from C4, and Figure 29 and Figure 30 from Wiki40B:en.
We also show train-generation influence pairs between RealNews training set and Grover [Zellers et al., 2019] model generation in Figure 31, Figure 32, and Figure 33.
 Figure 13: Text examples from RealNews with high memorization.
 Figure 14: Text examples from RealNews with intermediate memorization.
 Figure 15: Text examples from RealNews with low memorization.
 Figure 16: Text examples from C4 with high memorization.
 Figure 17: Text examples from C4 with intermediate memorization.
 Figure 18: Text examples from C4 with low memorization.
 Figure 19: Text examples from Wiki40B:en with high memorization.
 Figure 20: Text examples from Wiki40B:en with intermediate memorization.
 Figure 21: Text examples from Wiki40B:en with low memorization.
 Figure 22: Validation / training example pair from RealNews with high influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 23: Validation / training example pair from RealNews with relatively high influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 24: Validation / training example pair from RealNews with intermediate influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 25: Validation / training example pair from RealNews with relatively low influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 26: Validation / training example pair from RealNews with low influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 27: Validation / training example pair from C4 with high to intermediate influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 28: Validation / training example pair from C4 with intermediate to low influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 29: Validation / training example pair from Wiki40B:en with high to intermediate influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 30: Validation / training example pair from Wiki40B:en with intermediate to low influence. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 31: Generated / training example pair from RealNews with high to intermediate influence. The generated examples are directly taken from publicly released generations of the Grover-Mega $\scriptstyle \left( \mathrm { p } = 0 . 9 6 \right)$ model [Zellers et al., 2019]. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 32: Generated / training example pair from RealNews with intermediate to low influence. The generated examples are directly taken from publicly released generations of the Grover-Mega $\scriptstyle \left( \mathrm { p } = 0 . 9 6 \right)$ model [Zellers et al., 2019]. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.
 Figure 33: Generated / training example pair from RealNews with low influence. The generated examples are directly taken from publicly released generations of the Grover-Mega $\scriptstyle ( \mathtt { p } = 0 . 9 6 )$ ) model [Zellers et al., 2019]. Red / green highlighted text indicate deleted / added text in the training example comparing to the corresponding validation example, generated using Python difflib.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560# EXPLORING MEMORIZATION IN ADVERSARIAL TRAINING
Yinpeng $\mathbf { D o n g ^ { 1 , 2 } }$ , Ke $\mathbf { X } \mathbf { u } ^ { 4 }$ , Xiao Yang1, Tianyu Pang1, Zhijie Deng1, Hang $\mathbf { S u } ^ { 1 , 3 }$ , J $\mathbf { u n } \mathbf { Z } \mathbf { h } \mathbf { u } ^ { 1 , 2 , 3 * }$ 1 Dept. of Comp. Sci. and Tech., Institute for AI, Tsinghua-Bosch Joint ML Center, THBI Lab 1 BNRist Center, Tsinghua University, Beijing, China; 2 RealAI; 3 Peng Cheng Laboratory; 4 CMU {dongyinpeng, suhangss, dcszj}@mail.tsinghua.edu.cn, kx1@andrew.cmu.edu
# ABSTRACT
Deep learning models have a propensity for fitting the entire training set even with random labels, which requires memorization of every training sample. In this paper, we explore the memorization effect in adversarial training (AT) for promoting a deeper understanding of model capacity, convergence, generalization, and especially robust overfitting of the adversarially trained models. We first demonstrate that deep networks have sufficient capacity to memorize adversarial examples of training data with completely random labels, but not all AT algorithms can converge under the extreme circumstance. Our study of AT with random labels motivates further analyses on the convergence and generalization of AT. We find that some AT approaches suffer from a gradient instability issue and most recently suggested complexity measures cannot explain robust generalization by considering models trained on random labels. Furthermore, we identify a significant drawback of memorization in AT that it could result in robust overfitting. We then propose a new mitigation algorithm motivated by detailed memorization analyses. Extensive experiments on various datasets validate the effectiveness of the proposed method.
# 1 INTRODUCTION
Deep neural networks (DNNs) usually exhibit excellent generalization ability in pattern recognition tasks, despite their sufficient capacity to overfit or memorize the entire training set with completely random labels (Zhang et al., 2017). The memorization behavior in deep learning has aroused tremendous attention to identifying the differences between learning on true and random labels (Arpit et al., 2017; Neyshabur et al., 2017), and examining what and why DNNs memorize (Feldman, 2020; Feldman & Zhang, 2020; Maennel et al., 2020). This phenomenon has also motivated a growing body of works on model capacity (Arpit et al., 2017; Belkin et al., 2019), convergence (Allen-Zhu et al., 2019; Du et al., 2019; Zou et al., 2020), and generalization (Neyshabur et al., 2017; Bartlett et al., 2017), which consequently provide a better understanding of the DNN working mechanism.
In this paper, we explore the memorization behavior for a different learning algorithmβadversarial training (AT). Owing to the security threat of adversarial examples, i.e., maliciously generated inputs by adding imperceptible perturbations to cause misclassification (Szegedy et al., 2014; Goodfellow et al., 2015), various defense methods have been proposed to improve the adversarial robustness of DNNs (Kurakin et al., 2017; Madry et al., 2018; Liao et al., 2018; Wong & Kolter, 2018; Cohen et al., 2019; Zhang et al., 2019b; Pang et al., 2019; 2020; Dong et al., 2020a). AT is arguably the most effective defense technique (Athalye et al., 2018; Dong et al., 2020b), in which the network is trained on the adversarially augmented samples instead of the natural ones (Madry et al., 2018).
Despite the popularity, the memorization behavior in AT is less explored. Schmidt et al. (2018) show that a model is able to fully (over)fit the training set against an adversary, i.e., reaching almost $1 0 0 \%$ robust training accuracy, while the performance on test data is much inferior, witnessing a significant generalization gap. The overfitting phenomenon in AT is further investigated in Rice et al. (2020). However, it is not clear whether DNNs could memorize adversarial examples of training data with completely random labels. Answering this question could help to examine the effects of memorization in AT under the βextremeβ circumstance and facilitate a deeper understanding of capacity, convergence, generalization, and robust overfitting of the adversarially trained models. In general, it is difficult for a classifier to memorize adversarial examples with random labels since the model entails a much more complicated decision boundary, as illustrated in Fig. 1. Even though the networks have sufficient capacity, AT may not necessarily converge. Therefore, we aim to comprehensively study this problem and explore how the analysis can motivate better algorithms.
 Figure 1: A conceptual illustration of decision boundaries learned via standard training and adversarial training with true and random labels, respectively. The model needs a significantly more complicated decision boundary to memorize adversarial examples of training data with random labels.
Our contributions. We first empirically investigate the memorization behavior in AT by performing PGD-AT (Madry et al., 2018) and TRADES (Zhang et al., 2019b) with random labels sampled uniformly over all classes. Different from standard training (ST) that can easily memorize random labels (Zhang et al., 2017), AT may fail to converge, with PGD-AT being a typical example. Nevertheless, TRADES can converge under this circumstance. It demonstrates that DNNs have sufficient capacity to memorize adversarial examples of training data with completely random labels. This phenomenon is commonly observed on multiple datasets, network architectures, and threat models.
The memorization analysis has further implications for understanding the convergence and generalization of AT. We conduct a convergence analysis on gradient magnitude and stability to explain the counter-intuitive different convergence properties of PGD-AT and TRADES with random labels since they behave similarly when trained on true labels (Rice et al., 2020). We corroborate that PGD-AT suffers from a gradient instability issue while the gradients of TRADES are relatively stable thanks to its adversarial loss. Moreover, by considering models trained on random labels, our generalization analysis indicates that several recently suggested complexity measures are inadequate to explain robust generalization, which is complementary to the findings in ST (Neyshabur et al., 2017). Accordingly, an appropriate explanation of robust generalization remains largely under-addressed.
Lastly, but most importantly, we identify a significant drawback of memorization in AT that it could result in robust overfitting (Rice et al., 2020). We argue that the cause of robust overfitting lies in the memorization of one-hot labels in the typical AT methods. The one-hot labels can be inappropriate or even noisy for some adversarial examples because some data naturally lies close to the decision boundary, and the corresponding adversarial examples should be assigned low predictive confidence (Stutz et al., 2020; Cheng et al., 2020). To solve this problem, we propose a new mitigation algorithm that impedes over-confident predictions by regularization for avoiding the excessive memorization of adversarial examples with possibly noisy labels. Experiments validate that our method can eliminate robust overfitting to a large extent across multiple datasets, network architectures, threat models, and AT methods, achieving better robustness under a variety of adversarial attacks than the baselines.
# 2 BACKGROUND
# 2.1 ADVERSARIAL TRAINING
Let $\mathbf { \mathcal { D } } = \{ ( \mathbf { x } _ { i } , y _ { i } ) \} _ { i = 1 } ^ { n }$ denote a training dataset with $n$ samples, where $\mathbf { x } _ { i } \in \mathbb { R } ^ { d }$ is a natural example and $y _ { i } \in \{ 1 , . . . , C \}$ is its true label often encoded as an one-hot vector ${ \mathbf { 1 } } _ { y _ { i } }$ with totally $C$ classes. Adversarial training (AT) can be formulated as a robust optimization problem (Madry et al., 2018):
$$\operatorname* { m i n } _ { \pmb { \theta } } \sum _ { i = 1 } ^ { n } \operatorname* { m a x } _ { \mathbf { x } _ { i } ^ { \prime } \in S ( \mathbf { x } _ { i } ) } \mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { \prime } ) , y _ { i } ) ,$$
where $f _ { \theta }$ is a DNN classifier with parameters $\pmb \theta$ that predicts probabilities over all classes, $\mathcal { L }$ is the classification loss (i.e., the cross-entropy loss as $\mathcal { L } ( f _ { \theta } ^ { \mathsf { ^ { * } } } ( \mathbf { x } ) , y ) \overset { \bullet } { = } - \mathbf { 1 } _ { y } ^ { \top } \log f _ { \theta } ( \mathbf { x } ) )$ , and $\begin{array} { r } S ( \mathbf { x } ) = \{ \mathbf { x } ^ { \prime } : \ \end{array}$ $\| \mathbf { x } ^ { \prime } - \mathbf { x } \| _ { p } \leq \epsilon \}$ is an adversarial region centered at $\mathbf { x }$ with radius $\epsilon > 0$ under the $\ell _ { p }$ -norm threat models (e.g., $\ell _ { 2 }$ and $\ell _ { \infty }$ norms that we consider). The robust optimization problem (1) is solved by using adversarial attacks to approximate the inner maximization and updating the model parameters $\pmb \theta$ via gradient descent. A typical method uses projected gradient descent (PGD) (Madry et al., 2018) for the inner problem, which starts at a randomly initialized point in $S ( \mathbf { x } _ { i } )$ and iteratively updates the adversarial example under the $\ell _ { \infty }$ -norm threat model by
$$\mathbf { x } _ { i } ^ { \prime } = \Pi _ { S ( \mathbf { x } _ { i } ) } \big ( \mathbf { x } _ { i } ^ { \prime } + \alpha \cdot \mathrm { s i g n } \big ( \nabla _ { \mathbf { x } } \mathcal { L } \big ( f _ { \theta } ( \mathbf { x } _ { i } ^ { \prime } ) , y _ { i } \big ) \big ) \big ) ,$$
where $\Pi ( \cdot )$ is the projection operator and $\alpha$ is the step size.
Besides PGD-AT, another typical AT method is TRADES (Zhang et al., 2019b), which balances the trade-off between robustness and natural accuracy by minimizing a different adversarial loss
$$\operatorname* { m i n } _ { \pmb { \theta } } \sum _ { i = 1 } ^ { n } \left\{ \mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ) , y _ { i } ) + \beta \cdot \operatorname* { m a x } _ { \mathbf { x } _ { i } ^ { \prime } \in S ( \mathbf { x } _ { i } ) } \mathcal { D } ( f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ) | | f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { \prime } ) ) \right\} ,$$
where $\mathcal { L }$ is the clean cross-entropy loss on the natural example, $\mathcal { D }$ is the KullbackβLeibler divergence, and $\beta$ is a balancing parameter. The inner maximization of TRADES is also solved by PGD.
Recent progress of AT includes designing new adversarial losses (Mao et al., 2019; Qin et al., 2019; Pang et al., 2020; Wang et al., 2020; Dong et al., 2020a) and network architecture (Xie et al., 2019), training acceleration (Shafahi et al., 2019; Zhang et al., $2 0 1 9 \mathrm { a }$ ; Wong et al., 2020), and exploiting more training data (Hendrycks et al., 2019; Alayrac et al., 2019; Carmon et al., 2019; Zhai et al., 2019). Recent works highlight the training tricks in AT (Gowal et al., 2020; Pang et al., 2021).
# 2.2 RELATED WORK ON DNN MEMORIZATION
It has been observed that DNNs can easily memorize training data with random labels (Zhang et al., 2017), which requires βrethinkingβ of conventional techniques (e.g., VC dimension) to explain generalization. Arpit et al. (2017) identify qualitative differences between learning on true and random labels. Further works attempt to examine what and why DNNs memorize (Feldman, 2020; Feldman & Zhang, 2020; Maennel et al., 2020). Motivated by the memorization phenomenon in deep learning, convergence of training has been analyzed in the over-parameterized setting (Allen-Zhu et al., 2019; Du et al., 2019; Zou et al., 2020), while generalization has been studied with numerous theoretical and empirical complexity measures (Neyshabur et al., 2015; 2017; Bartlett et al., 2017; Novak et al., 2018; Arora et al., 2018; Cao & Gu, 2019; Jiang et al., 2020; Chen et al., 2020).
In contrast, the memorization behavior in AT has been less explored. The previous works demonstrate that DNNs can fit training data against an adversary (Madry et al., 2018; Schmidt et al., 2018; Rice et al., 2020), e.g., achieving nearly $1 0 0 \%$ robust training accuracy against a PGD adversary, but this behavior is not explored when trained on random labels. This paper is dedicated to investigating the memorization in AT under the extreme condition with random labels, while drawing connections to capacity, convergence, generalization, and robust overfitting, with the overarching goal of better understanding the AT working mechanism.
# 3 MEMORIZATION IN AT AND IMPLICATIONS
In this section, we first explore the memorization behavior in AT through an empirical study. Our analysis raises new questions about the convergence and generalization of AT, many of which cannot be answered by existing works. Thereafter, we provide further analytical studies on the convergence and generalization of AT by considering models trained on random labels particularly.
# 3.1 AT WITH RANDOM LABELS
We explore the memorization behavior of PGD-AT (Madry et al., 2018) and TRADES (Zhang et al., 2019b) as two studying cases. The experiments are conducted on CIFAR-10 (Krizhevsky & Hinton, 2009) with a Wide ResNet model (Zagoruyko & Komodakis, 2016) of depth 28 and widen factor 10 (WRN-28-10). Similar to Zhang et al. (2017), we train a network on the original dataset with true labels and on a copy of the dataset in which the true labels are corrupted by random ones. For training and robustness evaluation, a 10-step $\ell _ { \infty }$ PGD adversary with $\epsilon = 8 / 2 5 5$ and $\alpha = 2 / 2 5 5$ is adopted. For TRADES, the PGD adversary maximizes the KL divergence during training, while maximizes the cross-entropy loss for robustness evaluation, as common practice (Zhang et al., 2019b). We set $\beta = 6 . 0$ . In the sequel, we denote accuracy of a classifier against the 10-step PGD adversary as βrobust accuracyβ, and accuracy on natural examples as βnatural accuracyβ.
 Figure 2: (a) and (b) show the natural and robust training accuracies of PGD-AT and TRADES, respectively, when trained on true or random labels. (c) shows the generalization gap under varying levels of label noise.
Fig. 2(a) and Fig. 2(b) show the learning curves of PGD-AT and TRADES without explicit regularizations. Both methods achieve almost $\bar { 1 } 0 0 \%$ natural and robust training accuracies when trained on true labels. When the labels are random, we observe the totally different behaviors between PGDAT and TRADESβPGD-AT fails to converge while TRADES still reaches nearly $1 0 0 \%$ training accuracies. This phenomenon is somewhat striking because PGD-AT and TRADES perform similarly on true labels (Rice et al., 2020). We find that the different memorization behaviors between PGD-AT and TRADES when trained on random labels can commonly be observed across a variety of datasets, model architectures, and threat models (shown in Appendix A.1), indicating that it is a general phenomenon of memorization in the two AT methods. Therefore, our finding is:
DNNs have sufficient capacity to memorize adversarial examples of training data with completely random labels, but the convergence depends on the AT algorithms.
Partially corrupted labels. We then inspect the behavior of AT under varying levels of label noise from $0 \%$ (true labels) to $1 0 0 \%$ (completely random labels). The generalization gap (i.e., difference between training and test accuracies) presented in Fig. 2(c) grows steadily as we increase the noise rate before the network fails to converge. The learning curves are provided in Appendix A.1.
Explicit regularizations. We study the role of common regularizers in AT memorization, including data augmentation, weight decay, and dropout (Srivastava et al., 2014). We train TRADES on true and random labels with several combinations of regularizers. We observe the explicit regularizers do not significantly affect the modelβs ability to memorize adversarial examples, similar to the finding in ST (Zhang et al., 2017; Arpit et al., 2017). The detailed results are provided in Appendix A.1.
# 3.2 CONVERGENCE ANALYSIS OF AT WITH RANDOM LABELS
Since we have observed a counter-intuitive fact that PGD-AT and TRADES exhibit different convergence properties with random labels, it is necessary to perform a convergence analysis to understand this phenomenon. Note that our finding can hardly be explained by previous works (Gao et al., 2019; Wang et al., 2019; Zhang et al., 2020).
We first study the effects of different training settings on PGD-AT with random labels. We conduct experiments to analyze each training factor individually, including network architecture, attack steps, optimizer, and perturbation budget. We find that tuning the training settings cannot make PGD-AT converge with random labels (Appendix A.2 details the results). Based on the analysis, we think that the convergence issue of PGD-AT could be a result of the adversarial loss function in Eq. (1) rather than other training configurations. Specifically, TRADES in Eq. (3) minimizes a clean cross-entropy (CE) loss on natural examples, making DNNs memorize natural examples with random labels before fitting adversarial examples. As seen in Fig. 2(b), at the very early stage of TRADES training (the first 25 epochs), the natural accuracy starts to increase while the robust accuracy does not. However, PGD-AT in Eq. (1) directly minimizes the CE loss on adversarial samples with random labels, which can introduce unstable gradients with large variance, making it fail to converge. To corroborate the above argument, we analyze the gradient magnitude and stability below.
Gradient magnitude. First, we calculate the average gradient norm of the adversarial loss in Eq. (1) w.r.t. model parameters over each training sample for PGD-AT, and similarly calculate the average gradient norm of the clean CE loss (the first term) and the KL loss (the second term) in Eq. (3) w.r.t. parameters for TRADES to analyze their effects, respectively. We present the gradient norm along with training in Fig. 3(a). We can see that at the initial training epochs, the gradient norm of the KL loss in TRADES is much smaller than that of the CE loss, which indicates that the CE loss dominates TRADES training initially. With the training progressing, the KL loss has a larger gradient norm, making the network memorize adversarial examples. However, it is still unclear why PGD-AT does not rely on a similar learning tactic for convergence. To make a direct comparison with TRADES, we rewrite the adversarial loss of PGD-AT in Eq. (1) as
 Figure 3: (a): Gradient norm of PGD-AT and TRADES Figure 4: (a): The $\ell _ { 2 }$ distance between the gradients along the training process. (b): The ratio of the gra- at $\pmb { \theta }$ and $\pmb \theta + \lambda \mathbf d$ of different losses, where $\pmb { \theta }$ are inidient norm of PGD-AT and TRADES during the first tialized, $\lambda \in [ - 0 . 0 5 , 0 . 0 5 ]$ . (b): The cosine similarity 1000 training iterations. between the gradients in each two successive epochs.
$$\operatorname* { m a x } _ { \mathbf { x } _ { i } ^ { \prime } \in S ( \mathbf { x } _ { i } ) } \mathcal { L } ( f _ { \theta } ( \mathbf { x } _ { i } ^ { \prime } ) , y _ { i } ) = \mathcal { L } ( f _ { \theta } ( \mathbf { x } _ { i } ) , y _ { i } ) + \mathcal { R } ( \mathbf { x } _ { i } , y _ { i } , \pmb { \theta } ) ,$$
where $\mathcal { R } ( \mathbf { x } _ { i } , y _ { i } , \pmb \theta )$ denotes the difference between the CE loss on adversarial example $\mathbf { x } _ { i } ^ { \prime }$ and that on natural example $\mathbf { x } _ { i }$ . Hence we can separately calculate the gradient norm of $\mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ) , y _ { i } )$ and $\mathcal { R } ( \mathbf { x } _ { i } , y _ { i } , \pmb \theta )$ w.r.t. parameters $\pmb \theta$ to find out the effect of $\mathcal { R } ( \mathbf { x } _ { i } , y _ { i } , \pmb \theta )$ on training. Specifically, we measure the relative gradient magnitude, i.e., in PGD-AT we calculate the ratio of the gradient norm $\begin{array} { r l } { { \frac { \| \nabla _ { \pmb { \theta } } \mathcal { R } ( \mathbf { x } _ { i } , y _ { i } , \pmb { \theta } ) \| _ { 2 } } { \| \nabla _ { \pmb { \theta } } \mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ) , y _ { i } ) \| _ { 2 } } } \quad } & { } \end{array}$ ; while in TRADES, we similarly calculate the ratio of the gradient norm of the KL loss to that of the CE loss. Fig. 3(b) illustrates the ratio of PGD-AT and TRADES during the first 1000 training iterations. The ratio of PGD-AT is consistently higher than that of TRADES, meaning that $\mathcal { R } ( \mathbf { x } _ { i } , y _ { i } , \pmb \theta )$ has a non-negligible impact on training.
Gradient stability. Then, we analyze the gradient stability to explain why PGD-AT cannot converge. We denote the adversarial loss of PGD-AT as $\begin{array} { r } { \mathcal { I } ( \mathbf { x } , y , \theta ) \stackrel { - } { = } \operatorname* { m a x } _ { \mathbf { x } ^ { \prime } \in S ( \mathbf { x } ) } \mathcal { L } ( f _ { \theta } ( \mathbf { x } ^ { \prime } ) , y ) } \end{array}$ with the subscript $i$ omitted for notation simplicity. We have a theorem on gradient stability.
Theorem 1. Suppose the gradient of the clean cross-entropy loss is locally Lipschitz continuous as
$$\begin{array} { r } { \| \nabla _ { \theta } \mathcal { L } \big ( f _ { \theta } ( \mathbf { x } ^ { \prime } ) , y \big ) - \nabla _ { \theta } \mathcal { L } \big ( f _ { \theta } ( \mathbf { x } ) , y \big ) \| _ { 2 } \leq K \| \mathbf { x } ^ { \prime } - \mathbf { x } \| _ { p } , } \end{array}$$
any $\mathbf { x } \in \mathbb { R } ^ { d }$ , $\mathbf { x } ^ { \prime } \in S ( \mathbf { x } )$ , and any $\pmb \theta$ , where $K$ is the Lipschitz constant. Then we ha
$$\begin{array} { r } { \| \nabla _ { \theta } \mathcal { I } ( \mathbf { x } , y , \theta _ { 1 } ) - \nabla _ { \theta } \mathcal { I } ( \mathbf { x } , y , \theta _ { 2 } ) \| _ { 2 } \leq \| \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 1 } } ( \mathbf { x } ) , y ) - \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 2 } } ( \mathbf { x } ) , y ) \| _ { 2 } + 2 \epsilon K . } \end{array}$$
We provide the proof in Appendix B, where we show the upper bound in Eq. (5) is tight. Theorem 1 indicates that the gradient of the adversarial loss $\mathcal { I } ( \mathbf { x } , y , \pmb { \theta } )$ of PGD-AT will change more dramatically than that of the clean CE loss $\mathcal { L } ( f _ { \theta } ( \mathbf { x } ) , y )$ . When $\pmb { \theta } _ { 1 }$ and $\pmb { \theta } _ { 2 }$ are close, the difference between the gradients of $\mathcal { L }$ at $\pmb { \theta } _ { 1 }$ and $\pmb { \theta } _ { 2 }$ is close to 0 due to the semi-smoothness of over-parameterized DNNs (Allen-Zhu et al., 2019), but that of $\mathcal { I }$ is relatively large due to $2 \epsilon K$ in Eq. (5). To validate this, we visualize the change of gradient when moving the parameters $\pmb { \theta }$ along a random direction $\mathbf { d }$ with magnitude $\lambda$ . In particular, we set $\pmb \theta$ as initialization, $\mathbf { d }$ is sampled from a Gaussian distribution and normalized filter-wise (Li et al., 2018). For PGD-AT and TRADES, we craft adversarial examples on-the-fly for the model with $\pm \lambda \mathbf { d }$ and measure the change of gradient by the $\ell _ { 2 }$ distance to gradient at $\pmb { \theta }$ averaged over all data samples. The curves on gradient change of PGD-AT, TRADES, and the clean CE loss are shown in Fig. 4(a). In a small neighborhood of $\pmb { \theta }$ (i.e., small $\lambda$ ), the gradient of PGD-AT changes abruptly while the gradients of TRADES and the clean CE loss are more continuous. The gradient instability leads to a lower cosine similarity between the gradient directions w.r.t. the same data in each two successive training epochs of PGD-AT, as illustrated in Fig. 4(b). Therefore, the training of PGD-AT would be rather unstable that the gradient exhibits large variance, making it fail to converge.
Clean CE loss helps PGD-AT converge. To further verify our argument, we add the clean CE loss into the PGD-AT objective to resemble the learning of TRADES with random labels, as
 Figure 5: AT by Eq. (6)
$$\operatorname* { m i n } _ { \pmb { \theta } } \sum _ { i = 1 } ^ { n } \left\{ ( 1 - \gamma ) \cdot \mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ) , y _ { i } ) + \gamma \cdot \operatorname* { m a x } _ { \mathbf { x } _ { i } ^ { \prime } \in S ( \mathbf { x } _ { i } ) } \mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { \prime } ) , y _ { i } ) \right\} ,$$
 Figure 6: The results on four complexity measures of the adversarially trained models w.r.t. robust generaliza tion gap. The training settings of these models are provided in Appendix A.3.
where $\gamma$ is gradually increased from 0 to 1. By using Eq. (6), the gradient would be stabler at the initial stage and training on random labels can successfully converge, as shown Fig. 5.
In summary, our convergence analysis identifies the gradient instability issue of PGD-AT, provides new insights on the differences between PGD-AT and TRADES, and partially explain the failures of AT under other realistic settings beyond the scope of this section as detailed in Appendix A.2.
# 3.3 GENERALIZATION ANALYSIS OF AT WITH RANDOM LABELS
As our study demonstrates DNNsβ ability to memorize adversarial examples with random labels, we raise the question of whether DNNs rely on a similar memorization tactic on true labels and how to explain/ensure robust generalization. Although many efforts have been devoted to studying robust generalization of AT theoretically or empirically (Yin et al., 2018; Schmidt et al., 2018; Bubeck et al., 2019; Tu et al., 2019; Wu et al., 2020), they do not take the models trained on random labels into consideration. As it is easy to show that the explicit regularizations are not the adequate explanation of generalization in ST (Zhang et al., 2017; Arpit et al., 2017) and AT (see Appendix A.3), people resort to complexity measures of a model to explain generalization (i.e., a lower complexity should imply a smaller generalization gap). Here we show how the recently proposed complexity measures fail to explain robust generalization when comparing models trained on true and random labels.
We consider several norm-based and sharpness/flatness-based measures. We denote the parameters of a network by $\pmb \theta : = \{ W _ { i } \} _ { i = 1 } ^ { m }$ . The norm-based measures include spectral norm $\begin{array} { r } { \frac { 1 } { \gamma _ { \mathrm { m a r g i n } } } \prod _ { i = 1 } ^ { m } \| W _ { i } \| _ { 2 } } \end{array}$ and $\ell _ { 1 }$ norm $\begin{array} { r } { \frac { 1 } { \gamma _ { \mathrm { m a r g i n } } } \sum _ { i = 1 } ^ { m } \| W _ { i } \| _ { 1 } } \end{array}$ of model parameters, where $\gamma _ { \mathrm { m a r g i n } }$ is a margin on model output to make them scale-insensitive (Neyshabur et al., 2017). The spectral norm appears in the theoretical robust generalization bounds (Yin et al., 2018; Tu et al., 2019) and is related to the Lipschitz constant of neural networks (Cisse et al., 2017). The $\ell _ { 1 }$ norm is adopted to reduce the robust generalization gap (Yin et al., 2018). The sharpness/flatness-based measures include the curvature of input loss landscape (Moosavi-Dezfooli et al., 2019) as the dominant eigenvalue of the Hessian matrix, as well as the flatness of weight loss landscape (Wu et al., 2020) related to the change of adversarial loss when moving the weights along a random direction. Fig. 6 plots the four complexity measures w.r.t. robust generalization gap of several models trained with various combinations of regularizations on true or random labels. The results show that the first three measures can hardly ensure robust generalization, that lower complexity does not necessarily imply smaller robust generalization gap, e.g., the models trained on random labels can even lead to lower complexity than those trained on true labels. Among them, the flatness of weight loss landscape (Wu et al., 2020) is more reliable.
In summary, the generalization analysis indicates that the previous approaches, especially various complexity measures, cannot adequately explain and ensure the robust generalization performance in AT. Our finding of robust generalization in AT is complementary to that of standard generalization in ST (Zhang et al., 2017; Neyshabur et al., 2017; Jiang et al., 2020). Accordingly, robust generalization of adversarially trained models remains an open problem for future research.
# 4 ROBUST OVERFITTING ANALYSIS
Rice et al. (2020) have identified robust overfitting as a dominant phenomenon in AT, i.e., shortly after the first learning rate decay, further training will continue to decrease the robust test accuracy. They further show that several remedies for overfitting, including explicit $\ell _ { 1 }$ and $\ell _ { 2 }$ regularizations, data augmentation, etc., cannot gain improvements upon early stopping. Although robust overfitting has been thoroughly investigated, there still lacks an explanation of why it occurs. In this section, we draw a connection between memorization and robust overfitting in AT by showing that robust overfitting is caused by excessive memorization of one-hot labels in the typical AT methods. Motivated by the analysis, we then propose an effective strategy to eliminate robust overfitting.
 Figure 7: (a): The accuracy curves of PGD-AT with true labels to reproduce robust overfitting. (b): The robust test accuracy of PGD-AT under various perturbation budgets . (c): The adversarial loss of two independently trained networks by PGD-AT on 500 samples sorted by the loss of the first model.
# 4.1 EXPLAINING ROBUST OVERFITTING
The typical AT approaches (e.g., PGD-AT, TRADES) commonly adopt one-hot labels as the targets for training, as introduced in Sec. 2.1. The one-hot labels could be inappropriate for some adversarial examples because it is difficult for a network to assign high-confident one-hot labels for all perturbed samples within the perturbation budget $\epsilon$ (Stutz et al., 2020; Cheng et al., 2020). Intuitively, some examples may naturally lie close to the decision boundary and should be assigned lower predictive confidence for the worst-case adversarial examples. It indicates that one-hot labels of some training data may be noisy in $\mathsf { A T } ^ { 1 }$ . After a certain training epoch, the model memorizes these βhardβ training examples with possibly noisy labels, leading to the reduction of test robustness, as shown in Fig. 7(a). Thus, we hypothesize the cause of robust overfitting lies in the memorization of one-hot labels.
Our hypothesis is well supported by two pieces of evidence. First, we find that when the perturbation budget $\epsilon$ is small, robust overfitting does not occur, as shown in Fig. 7(b). This observation implies that the one-hot labels are more appropriate as the targets for adversarial examples within a smaller neighborhood while become noisier under a larger perturbation budget and lead to overfitting. Second, we validate that the βhardβ training examples with higher adversarial loss values are consistent across different models. We first train two independent networks (using the same architecture and different random seeds) by PGD-AT and calculate the adversarial loss for each training sample. We show the adversarial losses on 500 samples sorted by the loss of the first model in Fig. 7(c). It can be seen that the samples with lower adversarial losses of the first model also have relatively lower losses of the second one and vice versa. We further quantitatively measure the consistency of the adversarial losses of all training samples between the two models using the Kendallβs rank coefficient (Kendall, 1938), which is 0.85 in this case. A similar result can be observed for two different model architectures (see Appendix C.1). The results verify that the βhardβ training examples with possibly noisy labels are intrinsic of a dataset, supporting our hypothesis on why robust overfitting occurs.
# 4.2 MITIGATING ROBUST OVERFITTING
Based on the above analysis, we resort to the methods that are less prone to overfit noisy labels for mitigating robust overfitting in AT. Although learning with noisy labels has been broadly studied in ST (Natarajan et al., 2013; Patrini et al., 2017; Jiang et al., 2018; Han et al., 2018; Zhang & Sabuncu, 2018), we find that most of these approaches are not suitable for AT. For example, a typical line of methods filter out noisy samples and train the models on the identified clean samples (Jiang et al., 2018; Han et al., 2018; Ren et al., 2018). However, they will neglect a portion of training data with noisy labels, which can lead to inferior results for AT due to the reduction of training data (Schmidt et al., 2018). Table 2 shows the results to validate this.
To address this problem, we propose to regularize the predictions of adversarial examples from being over-confident by integrating the temporal ensembling (TE) approach (Laine & Aila, 2017) into the AT frameworks. TE maintains an ensemble prediction of each data and penalizes the difference between the current prediction and the ensemble prediction, which is effective for semi-supervised learning and learning with noisy labels (Laine & Aila, 2017). We think that TE is suitable for AT since it enables to leverage all training samples and hinders the network from excessive memorization of one-hot labels with a regularization term. Specifically, we denote the ensemble prediction of a training sample $\mathbf { x } _ { i }$ as $\mathbf { p } _ { i }$ , which is updated in each training epoch as $\mathbf { p } _ { i } \eta \cdot \mathbf { p } _ { i } + ( 1 - \eta ) \cdot f _ { \pmb { \theta } } ( \mathbf { x } _ { i } )$ , where $\eta$ is the momentum term. The training objective of PGD-AT with TE can be expressed as
Table 1: Test accuracy $( \% )$ of several methods on CIFAR-10, CIFAR-100, and SVHN under the $\ell _ { \infty }$ norm with $\epsilon = 8 / 2 5 5$ based on the ResNet-18 architecture. We choose the best checkpoint according to the highest robust accuracy on the test set under PGD-10.
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Natural AccuracyBest Final Diff</td><td rowspan=1 colspan=1>PGD-10Best Final Diff</td><td rowspan=1 colspan=1>PGD-1000Best Final Diff</td><td rowspan=1 colspan=1>C&W-1000Best Final Diff</td><td rowspan=1 colspan=1>AutoAttackBest Final Diff</td></tr><tr><td rowspan=1 colspan=1>PGD-ATPGD-AT+TE</td><td rowspan=1 colspan=1>83.75 84.82 -1.0782.35 82.79 -0.44</td><td rowspan=1 colspan=1>[52.64 44.92 7.7255.79 54.83 0.96</td><td rowspan=1 colspan=1>[51.22 42.74 8.4854.65 53.30 1.35</td><td rowspan=1 colspan=1>|50.11 43.63 7.4852.30 51.73 0.57</td><td rowspan=1 colspan=1>|47.74 41.84 5.9050.59 49.62 0.97</td></tr><tr><td rowspan=1 colspan=1>TRADESTRADES+TE</td><td rowspan=1 colspan=1>[81.19 82.48 -1.29|83.86 83.97 -0.11</td><td rowspan=1 colspan=1>[53.32 50.25 3.0755.15 54.42 0.73</td><td rowspan=1 colspan=1>[52.44 48.67 3.7753.74 53.03 0.71</td><td rowspan=1 colspan=1>|49.88 48.14 1.74|50.77 50.63 0.14</td><td rowspan=1 colspan=1>49.03 46.80 2.2349.77 49.20 0.57</td></tr><tr><td rowspan=1 colspan=6>(a) The evaluation results on CIFAR-10.</td></tr><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Natural AccuracyBest FinalDiff</td><td rowspan=1 colspan=1>PGD-10Best Final Diff</td><td rowspan=1 colspan=1>PGD-1000Best Final Diff</td><td rowspan=1 colspan=1>C&W-1000Best Final Diff</td><td rowspan=1 colspan=1>AutoAttackBest Final Diff</td></tr><tr><td rowspan=1 colspan=1>PGD-ATPGD-AT+TE</td><td rowspan=1 colspan=1>57.54 57.510.0356.45 57.12 -0.67</td><td rowspan=1 colspan=1>29.40 21.75 7.6531.74 30.24 1.50</td><td rowspan=1 colspan=1>28.54 20.63 7.9131.27 29.80 1.47</td><td rowspan=1 colspan=1>27.06 21.17 5.8928.27 27.36 0.91</td><td rowspan=1 colspan=1>24.72 19.34 5.3826.30 25.34 0.96</td></tr><tr><td rowspan=1 colspan=1>TRADESTRADES+TE</td><td rowspan=1 colspan=1>57.98 56.321.6659.35 58.72 0.63</td><td rowspan=1 colspan=1>|29.93 27.70 2.23|31.09 30.12 0.97</td><td rowspan=1 colspan=1>29.51 26.93 2.58|230.54 29.45 1.09</td><td rowspan=1 colspan=1>[25.46 24.42 1.04|26.61 25.94 0.67</td><td rowspan=1 colspan=1>24.6123.40 1.2125.27 24.55 0.72</td></tr><tr><td rowspan=1 colspan=6>(b) The evaluation results on CIFAR-100.</td></tr><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Natural AccuracyBest Final Diff</td><td rowspan=1 colspan=1>PGD-10Best Final Diff</td><td rowspan=1 colspan=1>PGD-1000Best Final Diff</td><td rowspan=1 colspan=1>C&W-1000Best Final Diff</td><td rowspan=1 colspan=1>AutoAttackBest Final Diff</td></tr><tr><td rowspan=1 colspan=1>PGD-ATPGD-AT+TE</td><td rowspan=1 colspan=1>89.00 90.55 -1.5590.09 90.91 -0.82</td><td rowspan=1 colspan=1>[54.51 46.97 7.5459.74 59.05 0.69</td><td rowspan=1 colspan=1>[52.22 42.85 9.3757.7156.46 1.25</td><td rowspan=1 colspan=1>48.66 44.13 4.5354.5553.94 0.61</td><td rowspan=1 colspan=1>46.61 38.24 8.3751.44 50.61 0.83</td></tr><tr><td rowspan=1 colspan=1>TRADESTRADES+TE</td><td rowspan=1 colspan=1>90.88 91.30 -0.4289.01 88.52 0.49</td><td rowspan=1 colspan=1>[59.50 57.04 2.4659.81 58.49 1.32</td><td rowspan=1 colspan=1>[52.78 50.17 2.6158.24 56.66 1.58</td><td rowspan=1 colspan=1>[52.76 50.53 2.2354.00 53.24 0.76</td><td rowspan=1 colspan=1>40.36 38.88 1.4851.45 50.16 1.29</td></tr></table>
(c) The evaluation results on SVHN.
$$\operatorname* { m i n } _ { \pmb { \theta } } \sum _ { i = 1 } ^ { n } \operatorname* { m a x } _ { \mathbf { x } _ { i } ^ { \prime } \in S ( \mathbf { x } _ { i } ) } \left\{ \mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { \prime } ) , y _ { i } ) + w \cdot | | f _ { \pmb { \theta } } ( \mathbf { x } _ { i } ^ { \prime } ) - \hat { \mathbf { p } } _ { i } | | _ { 2 } ^ { 2 } \right\} ,$$
where $\hat { { \bf p } } _ { i }$ is the normalization of $\mathbf { p } _ { i }$ as a probability vector and $w$ is a balancing weight. TE can be similarly integrated with TRADES with the same regularization term. The network would learn to fit relatively easy samples with one-hot labels in the initial training stage, as shown in Fig. 7(a). After the learning rate decays, the network can keep assigning low confidence for hard samples with the regularization term in Eq. (7) and avoid fitting one-hot labels. Therefore, the proposed algorithm enables to learn under label noise in AT and alleviates the robust overfitting problem.
# 5 EMPIRICAL EVALUATION ON MITIGATING ROBUST OVERFITTING
In this section, we provide the experimental results on CIFAR-10, CIFAR-100 (Krizhevsky & Hinton, 2009), and SVHN (Netzer et al., 2011) datasets to validate the effectiveness of our proposed method. Code is available at https://github.com/dongyp13/memorization-AT.
Training details. We adopt the common setting that the perturbation budget is $\epsilon = 8 / 2 5 5$ under the $\ell _ { \infty }$ norm in most experiments. We consider PGD-AT and TRADES as two typical AT baselines and integrate the proposed TE approach into them, respectively. We use the ResNet-18 (He et al., 2016) model as the classifier in most experiments. In training, we use the 10-step PGD adversary with $\alpha = 2 / 2 5 5$ . The models are trained via the SGD optimizer with momentum 0.9, weight decay 0.0005, and batch size 128. For CIFAR-10/100, we set the learning rate as 0.1 initially which is decayed by 0.1 at 100 and 150 epochs with totally 200 training epochs. For SVHN, the learning rate starts from 0.01 with a cosine annealing schedule for a total number of 80 training epochs. In our method, We set $\eta = 0 . 9$ and $w = 3 0$ along a Gaussian ramp-up curve (Laine & Aila, 2017).
Evaluation results. We adopt PGD-10, PGD-1000, C&W-1000 (Carlini & Wagner, 2017), and AutoAttack (Croce & Hein, 2020b) for evaluating adversarial robustness rigorously. AutoAttack is a strong attack to evaluate model robustness, which is composed of an ensemble of diverse attacks, including APGD-CE (Croce & Hein, 2020b), APGD-DLR (Croce & Hein, 2020b), FAB (Croce & Hein, 2020a), and Square attack (Andriushchenko et al., 2020). To show the performance of robust overfitting, we report the test accuracy on the best checkpoint that achieves the highest robust test accuracy under PGD-10 and the final checkpoint, as well as the difference between these two checkpoints. The results of PGD-AT, TRADES, and the combinations of them with our proposed approach (denoted as PGD- $\mathbf { A T + T E }$ and TRADES ${ \bf \nabla } + { \bf T } { \bf E }$ ) on the CIFAR-10, CIFAR-100, and SVHN datasets are shown in Table 1.
We can observe that the differences between best and final test accuracies of our method are reduced to around $1 \%$ , while the accuracy gaps of PGDAT and TRADES are much larger. It indicates that our method largely eliminates robust overfitting. Due to being less affected by robust overfitting, our method achieves higher robust accuracies than the baselines. We also show the learning curves of these methods in Fig. 8. We consistently demonstrate the effectiveness of our method on different network architectures (including WRN-34-10
 Figure 8: The natural and robust test accuracy curves (under PGD10) of PGD-AT, TRADES, and their extensions by integrating the proposed TE approach. The models are trained on CIFAR-10 under the $\ell _ { \infty }$ norm with $\epsilon = 8 / 2 5 5$ based on the ResNet-18 architecture.
and VGG-16) and threat models (including $\ell _ { 2 }$ norm), which will be shown in Appendix C.2.
Discussion and comparison with related works. Our method is kind of similar to the label smoothing (LS) technique, which is studied in AT (Pang et al., 2021). Recent works have also introduced the smoothness in training labels and model weights (Chen et al., 2021; Huang et al., 2020), which can alleviate robust overfitting to some extent. The significant difference between our work and them is that we provide a reasonable explanation for robust overfittingβone-hot labels are noisy for AT, while previous methods did not give such an explanation and could be viewed as solutions to our identified problem. To empirically compare with these methods, we conduct experiments on CIFAR-10 with the ResNet-18 network. Under the PGD-AT framework, we compare with the baseline PGD-AT, PGD-AT+LS, self-adaptive training (SAT) (Huang et al., 2020), and knowledge distillation with stochastic weight averaging (KD-SWA) (Chen et al., 2021). We also adopt the $C o$ - teaching approach (Han et al., 2018) adapted to PGD-AT, which jointly trains two models using the filtered samples given by each other. The results under the adopted attacks are presented in Table 2. Although various techniques can alleviate robust overfitting, our method achieves better robustness than the others, validating its effectiveness. For Co-teaching, though robust overfitting is alleviated, the performance is worse than our proposed method due to the reduction of training data.
Table 2: Test accuracy $( \% )$ of the proposed method and other methods on CIFAR-10 under the $\ell _ { \infty }$ norm with $\epsilon = 8 / 2 5 5$ based on the ResNet-18 architecture.
<table><tr><td>Method</td><td>Natural Accuracy Best Final 1Diff</td><td>PGD-10 Best</td><td>Final Diff</td><td>PGD-1000 Best Final Diff</td><td></td><td>C&W-1000 Best</td><td>Final Diff</td><td>AutoAttack Best Final Diff</td></tr><tr><td>PGD-AT</td><td>83.75 84.82 -1.07</td><td>52.64 44.92</td><td>7.72</td><td>51.22</td><td>42.74 8.48</td><td></td><td>[50.11 43.63 7.48</td><td>47.74 41.84 5.90</td></tr><tr><td>PGD-AT+LS</td><td>82.68 85.16 -2.48</td><td>53.70 48.90 4.80</td><td></td><td>52.564 46.31</td><td>6.25</td><td></td><td>50.41 46.06 4.35</td><td>49.02 44.39 4.63</td></tr><tr><td>SAT</td><td>82.81 81.86 0.95</td><td>53.81 53.31</td><td>0.50</td><td>52.41 52.00</td><td>0.41</td><td>51.99 51.71</td><td></td><td>50.214</td></tr><tr><td>KD-SWA</td><td>84.84 85.26 -0.42</td><td>54.89</td><td></td><td></td><td></td><td></td><td>0.28</td><td>49.73 0.48</td></tr><tr><td>Co-teaching</td><td></td><td>53.80</td><td>1.09</td><td>53.31 52.45</td><td>0.86</td><td>51.48 50.91</td><td>0.57</td><td>50.42 49.83 0.59</td></tr><tr><td></td><td>81.94 82.22 -0.28</td><td>51.27 50.52</td><td>0.75</td><td>50.15 49.12</td><td>1.03</td><td></td><td>50.85 49.86 0.99</td><td>49.60 48.49 1.11</td></tr><tr><td>PGD-AT+TE</td><td>82.35 82.79 -0.44</td><td>55.79</td><td>54.83 0.96</td><td>54.65 53.30 1.35</td><td></td><td></td><td>52.30 51.73 0.57</td><td>50.59 49.62 0.97</td></tr></table>
# 6 CONCLUSION
In this paper, we demonstrate the capacity of DNNs to fit adversarial examples with random labels by exploring memorization in adversarial training, which also poses open questions on the convergence and generalization of adversarially trained models. We validate that some AT methods suffer from a gradient instability issue and robust generalization can hardly be explained by complexity measures. We further identify a significant drawback of memorization in AT related to the robust overfitting phenomenonβrobust overfitting is caused by memorizing one-hot labels in adversarial training. We propose a new mitigation algorithm to address this issue, with the effectiveness validated extensively.
# ACKNOWLEDGEMENTS
This work was supported by the National Key Research and Development Program of China (2020AAA0106000, 2020AAA0104304, 2020AAA0106302), NSFC Projects (Nos. 61620106010, 62061136001, 61621136008, 62076147, U19B2034, U1811461, U19A2081), Beijing NSF Project (No. JQ19016), Beijing Academy of Artificial Intelligence (BAAI), Tsinghua-Alibaba Joint Research Program, Tsinghua Institute for Guo Qiang, Tsinghua-OPPO Joint Research Center for Future Terminal Technology.
# ETHICS STATEMENT
The existence of adversarial examples can pose severe security threats to machine learning and deep learning models when they are deployed to real-world applications. The vulnerability to adversarial examples could also lower the confidence of the public on machine learning techniques. Therefore, it is important to develop more robust models. As the most effective method for promoting model robustness, adversarial training (AT) has not been fully investigated. This paper aims to investigate the memorization effect of AT to facilitate a better understanding of its working mechanism. Some findings in this paper can be analyzed more deeply, including theoretical analysis of AT convergence, generalization, etc., which we leave to future work.
# REPRODUCIBILITY STATEMENT
Most of the experiments are easily reproducible. We provide the code for reproducing the results at https://github.com/dongyp13/memorization-AT.
# REFERENCES
Jean-Baptiste Alayrac, Jonathan Uesato, Po-Sen Huang, Alhussein Fawzi, Robert Stanforth, and Pushmeet Kohli. Are labels required for improving adversarial robustness? In Advances in Neural Information Processing Systems (NeurIPS), pp. 12214β12223, 2019.
Zeyuan Allen-Zhu, Yuanzhi Li, and Zhao Song. A convergence theory for deep learning via overparameterization. In International Conference on Machine Learning (ICML), pp. 242β252, 2019.
Maksym Andriushchenko, Francesco Croce, Nicolas Flammarion, and Matthias Hein. Square attack: a query-efficient black-box adversarial attack via random search. In European Conference on Computer Vision (ECCV), pp. 484β501, 2020.
Sanjeev Arora, Rong Ge, Behnam Neyshabur, and Yi Zhang. Stronger generalization bounds for deep nets via a compression approach. In International Conference on Machine Learning (ICML), pp. 254β263, 2018.
Devansh Arpit, StanisΕaw JastrzΛebski, Nicolas Ballas, David Krueger, Emmanuel Bengio, Maxinder S Kanwal, Tegan Maharaj, Asja Fischer, Aaron Courville, Yoshua Bengio, et al. A closer look at memorization in deep networks. In International Conference on Machine Learning (ICML), pp. 233β242, 2017.
Anish Athalye, Nicholas Carlini, and David Wagner. Obfuscated gradients give a false sense of security: Circumventing defenses to adversarial examples. In International Conference on Machine Learning (ICML), pp. 274β283, 2018.
Peter L Bartlett, Dylan J Foster, and Matus J Telgarsky. Spectrally-normalized margin bounds for neural networks. In Advances in Neural Information Processing Systems (NIPS), pp. 6240β6249, 2017.
Mikhail Belkin, Daniel Hsu, Siyuan Ma, and Soumik Mandal. Reconciling modern machinelearning practice and the classical biasβvariance trade-off. Proceedings of the National Academy of Sciences, 116(32):15849β15854, 2019.
SΓ©bastien Bubeck, Yin Tat Lee, Eric Price, and Ilya Razenshteyn. Adversarial examples from computational constraints. In International Conference on Machine Learning (ICML), pp. 831β840, 2019.
Yuan Cao and Quanquan Gu. Generalization bounds of stochastic gradient descent for wide and deep neural networks. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In IEEE Symposium on Security and Privacy $( S P )$ , pp. 39β57, 2017.
Yair Carmon, Aditi Raghunathan, Ludwig Schmidt, Percy Liang, and John C Duchi. Unlabeled data improves adversarial robustness. In Advances in Neural Information Processing Systems (NeurIPS), pp. 11192β11203, 2019.
Tianlong Chen, Zhenyu Zhang, Sijia Liu, Shiyu Chang, and Zhangyang Wang. Robust overfitting may be mitigated by properly learned smoothening. In International Conference on Learning Representations (ICLR), 2021.
Zixiang Chen, Yuan Cao, Difan Zou, and Quanquan Gu. How much over-parameterization is sufficient to learn deep relu networks? In International Conference on Learning Representations (ICLR), 2020.
Minhao Cheng, Qi Lei, Pin-Yu Chen, Inderjit Dhillon, and Cho-Jui Hsieh. Cat: Customized adversarial training for improved robustness. arXiv preprint arXiv:2002.06789, 2020.
Moustapha Cisse, Piotr Bojanowski, Edouard Grave, Yann Dauphin, and Nicolas Usunier. Parseval networks: Improving robustness to adversarial examples. In International Conference on Machine Learning (ICML), pp. 854β863, 2017.
Jeremy M Cohen, Elan Rosenfeld, and J Zico Kolter. Certified adversarial robustness via randomized smoothing. In International Conference on Machine Learning (ICML), pp. 1310β1320, 2019.
Francesco Croce and Matthias Hein. Minimally distorted adversarial examples with a fast adaptive boundary attack. In International Conference on Machine Learning (ICML), pp. 2196β2205, 2020a.
Francesco Croce and Matthias Hein. Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks. In International Conference on Machine Learning (ICML), pp. 2206β2216, 2020b.
Yinpeng Dong, Zhijie Deng, Tianyu Pang, Jun Zhu, and Hang Su. Adversarial distributional training for robust deep learning. In Advances in Neural Information Processing Systems (NeurIPS), pp. 8270β8283, 2020a.
Yinpeng Dong, Qi-An Fu, Xiao Yang, Tianyu Pang, Hang Su, Zihao Xiao, and Jun Zhu. Benchmarking adversarial robustness on image classification. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 321β331, 2020b.
Simon Du, Jason Lee, Haochuan Li, Liwei Wang, and Xiyu Zhai. Gradient descent finds global minima of deep neural networks. In International Conference on Machine Learning (ICML), pp. 1675β1685, 2019.
Vitaly Feldman. Does learning require memorization? a short tale about a long tail. In Proceedings of the 52nd Annual ACM SIGACT Symposium on Theory of Computing, pp. 954β959, 2020.
Vitaly Feldman and Chiyuan Zhang. What neural networks memorize and why: Discovering the long tail via influence estimation. In Advances in Neural Information Processing Systems (NeurIPS), pp. 2881β2891, 2020.
Ruiqi Gao, Tianle Cai, Haochuan Li, Cho-Jui Hsieh, Liwei Wang, and Jason D Lee. Convergence of adversarial training in overparametrized neural networks. In Advances in Neural Information Processing Systems (NeurIPS), pp. 13029β13040, 2019.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. In International Conference on Learning Representations (ICLR), 2015.
Sven Gowal, Chongli Qin, Jonathan Uesato, Timothy Mann, and Pushmeet Kohli. Uncovering the limits of adversarial training against norm-bounded adversarial examples. arXiv preprint arXiv:2010.03593, 2020.
Bo Han, Quanming Yao, Xingrui Yu, Gang Niu, Miao Xu, Weihua Hu, Ivor Tsang, and Masashi Sugiyama. Co-teaching: Robust training of deep neural networks with extremely noisy labels. In Advances in Neural Information Processing Systems (NeurIPS), pp. 8527β8537, 2018.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 770β778, 2016.
Dan Hendrycks, Kimin Lee, and Mantas Mazeika. Using pre-training can improve model robustness and uncertainty. In International Conference on Machine Learning (ICML), pp. 2712β2721, 2019.
Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 4700β4708, 2017.
Lang Huang, Chao Zhang, and Hongyang Zhang. Self-adaptive training: beyond empirical risk minimization. In Advances in Neural Information Processing Systems (NeurIPS), pp. 19365β 19376, 2020.
Lu Jiang, Zhengyuan Zhou, Thomas Leung, Li-Jia Li, and Li Fei-Fei. Mentornet: Learning datadriven curriculum for very deep neural networks on corrupted labels. In International Conference on Machine Learning (ICML), pp. 2304β2313, 2018.
Yiding Jiang, Behnam Neyshabur, Hossein Mobahi, Dilip Krishnan, and Samy Bengio. Fantastic generalization measures and where to find them. In International Conference on Learning Representations (ICLR), 2020.
Maurice G Kendall. A new measure of rank correlation. Biometrika, 30(1/2):81β93, 1938.
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015.
Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial machine learning at scale. In International Conference on Learning Representations (ICLR), 2017.
Samuli Laine and Timo Aila. Temporal ensembling for semi-supervised learning. In International Conference on Learning Representations (ICLR), 2017.
Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein. Visualizing the loss landscape of neural nets. In Advances in Neural Information Processing Systems (NeurIPS), pp. 6389β6399, 2018.
Fangzhou Liao, Ming Liang, Yinpeng Dong, Tianyu Pang, Xiaolin Hu, and Jun Zhu. Defense against adversarial attacks using high-level representation guided denoiser. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1778β1787, 2018.
Chen Liu, Mathieu Salzmann, Tao Lin, Ryota Tomioka, and Sabine SΓΌsstrunk. On the loss landscape of adversarial training: Identifying challenges and how to overcome them. In Advances in Neural Information Processing Systems (NeurIPS), 2020a.
Shengchao Liu, Dimitris Papailiopoulos, and Dimitris Achlioptas. Bad global minima exist and sgd can reach them. In Advances in Neural Information Processing Systems (NeurIPS), 2020b.
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In International Conference on Learning Representations (ICLR), 2018.
Hartmut Maennel, Ibrahim Alabdulmohsin, Ilya Tolstikhin, Robert JN Baldock, Olivier Bousquet, Sylvain Gelly, and Daniel Keysers. What do neural networks learn when trained with random labels? In Advances in Neural Information Processing Systems (NeurIPS), pp. 19693β19704, 2020.
Chengzhi Mao, Ziyuan Zhong, Junfeng Yang, Carl Vondrick, and Baishakhi Ray. Metric learning for adversarial robustness. In Advances in Neural Information Processing Systems (NeurIPS), pp. 480β491, 2019.
Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, Jonathan Uesato, and Pascal Frossard. Robustness via curvature regularization, and vice versa. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 9078β9086, 2019.
Nagarajan Natarajan, Inderjit S Dhillon, Pradeep K Ravikumar, and Ambuj Tewari. Learning with noisy labels. In Advances in Neural Information Processing Systems (NIPS), pp. 1196β1204, 2013.
Yurii E Nesterov. A method for solving the convex programming problem with convergence rate o $( 1 / \mathrm { k } ^ { \cdot } 2 )$ . In Dokl. akad. nauk Sssr, volume 269, pp. 543β547, 1983.
Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. In NIPS Workshop on Deep Learning and Unsupervised Feature Learning, 2011.
Behnam Neyshabur, Ryota Tomioka, and Nathan Srebro. Norm-based capacity control in neural networks. In Conference on Learning Theory (COLT), pp. 1376β1401, 2015.
Behnam Neyshabur, Srinadh Bhojanapalli, David McAllester, and Nati Srebro. Exploring generalization in deep learning. In Advances in Neural Information Processing Systems (NIPS), pp. 5947β5956, 2017.
Roman Novak, Yasaman Bahri, Daniel A. Abolafia, Jeffrey Pennington, and Jascha Sohl-Dickstein. Sensitivity and generalization in neural networks: an empirical study. In International Conference on Learning Representations (ICLR), 2018.
Tianyu Pang, Kun Xu, Chao Du, Ning Chen, and Jun Zhu. Improving adversarial robustness via promoting ensemble diversity. In International Conference on Machine Learning (ICML), pp. 4970β4979, 2019.
Tianyu Pang, Kun Xu, Yinpeng Dong, Chao Du, Ning Chen, and Jun Zhu. Rethinking softmax crossentropy loss for adversarial robustness. In International Conference on Learning Representations (ICLR), 2020.
Tianyu Pang, Xiao Yang, Yinpeng Dong, Hang Su, and Jun Zhu. Bag of tricks for adversarial training. In International Conference on Learning Representations (ICLR), 2021.
Giorgio Patrini, Alessandro Rozza, Aditya Krishna Menon, Richard Nock, and Lizhen Qu. Making deep neural networks robust to label noise: A loss correction approach. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1944β1952, 2017.
Chongli Qin, James Martens, Sven Gowal, Dilip Krishnan, Krishnamurthy Dvijotham, Alhussein Fawzi, Soham De, Robert Stanforth, and Pushmeet Kohli. Adversarial robustness through local linearization. In Advances in Neural Information Processing Systems (NeurIPS), pp. 13847β 13856, 2019.
Mengye Ren, Wenyuan Zeng, Bin Yang, and Raquel Urtasun. Learning to reweight examples for robust deep learning. In International Conference on Machine Learning (ICML), pp. 4334β4343, 2018.
Leslie Rice, Eric Wong, and Zico Kolter. Overfitting in adversarially robust deep learning. In International Conference on Machine Learning (ICML), pp. 8093β8104, 2020.
Amartya Sanyal, Puneet K. Dokania, Varun Kanade, and Philip Torr. How benign is benign overfitting ? In International Conference on Learning Representations (ICLR), 2021.
Ludwig Schmidt, Shibani Santurkar, Dimitris Tsipras, Kunal Talwar, and Aleksander Madry. Adversarially robust generalization requires more data. In Advances in Neural Information Processing Systems (NeurIPS), pp. 5014β5026, 2018.
Ali Shafahi, Mahyar Najibi, Amin Ghiasi, Zheng Xu, John Dickerson, Christoph Studer, Larry S Davis, Gavin Taylor, and Tom Goldstein. Adversarial training for free! In Advances in Neural Information Processing Systems (NeurIPS), pp. 3358β3369, 2019.
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.
David Stutz, Matthias Hein, and Bernt Schiele. Confidence-calibrated adversarial training: Generalizing to unseen attacks. In International Conference on Machine Learning (ICML), pp. 9155β 9166, 2020.
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. In International Conference on Learning Representations (ICLR), 2014.
Zhuozhuo Tu, Jingwei Zhang, and Dacheng Tao. Theoretical analysis of adversarial learning: A minimax approach. In Advances in Neural Information Processing Systems (NeurIPS), pp. 12280β12290, 2019.
Yisen Wang, Xingjun Ma, James Bailey, Jinfeng Yi, Bowen Zhou, and Quanquan Gu. On the convergence and robustness of adversarial training. In International Conference on Machine Learning (ICML), pp. 6586β6595, 2019.
Yisen Wang, Difan Zou, Jinfeng Yi, James Bailey, Xingjun Ma, and Quanquan Gu. Improving adversarial robustness requires revisiting misclassified examples. In International Conference on Learning Representations (ICLR), 2020.
Eric Wong and Zico Kolter. Provable defenses against adversarial examples via the convex outer adversarial polytope. In International Conference on Machine Learning (ICML), pp. 5286β5295, 2018.
Eric Wong, Leslie Rice, and J. Zico Kolter. Fast is better than free: Revisiting adversarial training. In International Conference on Learning Representations (ICLR), 2020.
Dongxian Wu, Shu-Tao Xia, and Yisen Wang. Adversarial weight perturbation helps robust generalization. In Advances in Neural Information Processing Systems (NeurIPS), pp. 2958β2969, 2020.
Cihang Xie and Alan Yuille. Intriguing properties of adversarial training. In International Conference on Learning Representations (ICLR), 2020.
Cihang Xie, Yuxin Wu, Laurens van der Maaten, Alan L Yuille, and Kaiming He. Feature denoising for improving adversarial robustness. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 501β509, 2019.
Dong Yin, Kannan Ramchandran, and Peter Bartlett. Rademacher complexity for adversarially robust generalization. In International Conference on Machine Learning (ICML), pp. 7085β7094, 2018.
Fisher Yu, Dequan Wang, Evan Shelhamer, and Trevor Darrell. Deep layer aggregation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2403β 2412, 2018.
Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In Proceedings of the British Machine Vision Conference (BMVC), 2016.
Runtian Zhai, Tianle Cai, Di He, Chen Dan, Kun He, John Hopcroft, and Liwei Wang. Adversarially robust generalization just requires more unlabeled data. arXiv preprint arXiv:1906.00555, 2019.
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. In International Conference on Learning Representations (ICLR), 2017.
Dinghuai Zhang, Tianyuan Zhang, Yiping Lu, Zhanxing Zhu, and Bin Dong. You only propagate once: Painless adversarial training using maximal principle. In Advances in Neural Information Processing Systems (NeurIPS), pp. 227β238, 2019a.
Hongyang Zhang, Yaodong Yu, Jiantao Jiao, Eric P Xing, Laurent El Ghaoui, and Michael I Jordan. Theoretically principled trade-off between robustness and accuracy. In International Conference on Machine Learning (ICML), pp. 7472β7482, 2019b.
Yi Zhang, Orestis Plevrakis, Simon S Du, Xingguo Li, Zhao Song, and Sanjeev Arora. Overparameterized adversarial training: An analysis overcoming the curse of dimensionality. In Advances in Neural Information Processing Systems (NeurIPS), pp. 679β688, 2020.
Zhilu Zhang and Mert Sabuncu. Generalized cross entropy loss for training deep neural networks with noisy labels. In Advances in Neural Information Processing Systems (NeurIPS), pp. 8778β 8788, 2018.
Difan Zou, Yuan Cao, Dongruo Zhou, and Quanquan Gu. Gradient descent optimizes overparameterized deep relu networks. Machine Learning, 109(3):467β492, 2020.
# A ADDITIONAL EXPERIMENTS ON MEMORIZATION IN AT
In this section, we provide additional experiments on the memorization behavior in AT. All of the experiments are conducted on NVIDIA 2080 Ti GPUs. The source code of this paper is submitted as the supplementary material, and will be released after the review process.
# A.1 MEMORIZATION OF PGD-AT AND TRADES
# A.1.1 DIFFERENT TRAINING SETTINGS
We first demonstrate that the different memorization behaviors between PGD-AT and TRADES can be generally observed under various settings.
 Figure A.1: The natural and robust training accuracies of PGD-AT and TRADES on CIFAR-100 when trained on true or random labels.
 Figure A.2: The natural and robust training accuracies of PGD-AT and TRADES on SVHN when trained on true or random labels.
Datasets. Similar to Fig. 2, we show the accuracy curves of PGD-AT and TRADES when trained on true or random labels on CIFAR-100 (Krizhevsky & Hinton, 2009) in Fig. A.1 and on SVHN (Netzer et al., 2011) in Fig. A.2. We consistently observe that PGD-AT fails to converge with random labels, while TRADES can successfully converge, although it does not reach $1 0 0 \%$ accuracy on SVHN.
Model architectures. We then consider other network architectures, including the DenseNet-121 model (Huang et al., 2017) and the deep layer aggregation (DLA) model (Yu et al., 2018). The corresponding results are shown in Fig. A.3. The similar results can be observed, although it may take more training epochs to make TRADES converge with the smaller DenseNet-121 network.
 Figure A.3: The natural and robust training accuracies of PGD-AT and TRADES on CIFAR-10 with different architectures when trained on random labels.
 Figure A.4: The natural and robust training accuracies of PGD-AT and TRADES on CIFAR-10 under the $\ell _ { 2 }$ -norm threat model when trained on random labels.
Threat models. We further consider the $\ell _ { 2 }$ -norm threat model, in which we set $\epsilon = 1 . 0$ and $\alpha =$ 0.25 in the 10-step PGD adversary. The learning curves of PGD-AT and TRADES are shown in Fig. A.4, which also exhibit similar results.
Perturbation budget. We study the memorization behavior in AT with different perturbation budgets $\epsilon$ . In Fig. A.5, we show that when the perturbation budget is $\epsilon = 1 6 / 2 5 5$ $\ell _ { \infty }$ norm), TRADES trained on random labels can still converge. But when we set a larger budget (e.g., $\epsilon = 3 2 / 2 5 5 )$ , both PGD-AT and TRADES cannot obtain near $100 \%$ robust training accuracy. We also find under this condition, even AT trained on true labels cannot get $100 \%$ robust training accuracy, indicating that the gradient instability issue discussed in Sec. 3.2 results in the convergence problem.
In summary, our empirical observation that PGD-AT and TRADES perform differently when trained on random labels is general across multiple datasets, network architectures, and threat models.
# A.1.2 LEARNING CURVES UNDER DIFFERENT NOISE RATES
We show the learning curves of PGD-AT and TRADES under varying levels of label noise in Fig. A.6 and Fig. A.7, respectively. In this experiment, we adopt the weight decay and data augmentation for regularizations. We can see that the network achieves maximum accuracy on the test set before fitting the noisy training set. Thus the model learns easy and simple patterns first before fitting the noise, similar to the finding in ST (Arpit et al., 2017). It can also be observed that under $8 0 \%$ noise rate, PGD-AT fails to converge. Note that when the noise rate is $0 \%$ , the network is trained on true labels, but the robust test accuracy also decreases after a certain epoch. This phenomenon is called robust overfitting (Rice et al., 2020), which is studied in Sec. 4.
 Figure A.5: The natural and robust training accuracies of PGD-AT and TRADES on CIFAR-10 with $\epsilon =$ 16/255 when trained on true or random labels.
 Figure A.6: Accuracy curves of PGD-AT under different noise rates on CIFAR-10.
 Figure A.7: Accuracy curves of TRADES under different noise rates on CIFAR-10.
# A.1.3 EXPLICIT REGULARIZATIONS
We consider three common regularizers, including data augmentation, weight decay, and dropout (Srivastava et al., 2014). We train the models based on TRADES on true and random labels with several combinations of explicit regularizers. As shown in Table A.1, the explicit regularizations do not significantly affect the modelβs ability to memorize adversarial examples with random labels.
# A.2 MORE RESULTS ON THE CONVERGENCE OF AT
# A.2.1 TRAINING CONFIGURATIONS
We study different training configurations on PGD-AT with random labels. We consider various factors as follows. These experiments are conducted on CIFAR-10.
β’ Model capacity. Recent work suggests that model size is a critical factor to obtain better robustness (Madry et al., 2018; Xie & Yuille, 2020). A possible reason why PGD-AT fails to converge with random labels may also be the insufficient model capacity. Therefore, we try to use larger models, including WRN-34-20 (which is used in Rice et al. (2020)) and WRN-70-16 (which is used in Gowal et al. (2020)). However, using larger models under this setting cannot solve the convergence problem.
Table A.1: The training accuracy, test accuracy, and generalization gap $( \% )$ of TRADES when trained on true or random labels, with and without explicit regularizations, including data augmentation (random crop and flip), weight decay (0.0002), and dropout (0.2).
<table><tr><td>Labels</td><td>Data Augmentation</td><td>Weight Decay</td><td>Dropout</td><td>Training Accuracy Natural</td><td>Robust</td><td>Test Accuracy Natural I</td><td>Robust</td><td>Generalization Gap Natural</td><td>Robust</td></tr><tr><td>true</td><td></td><td>X</td><td>X</td><td>99.73</td><td>99.65</td><td>77.53</td><td>37.47</td><td>22.20</td><td>62.18</td></tr><tr><td>true</td><td>X</td><td></td><td>Γ</td><td>99.57</td><td>97.03</td><td>82.91</td><td>45.37</td><td>16.93</td><td>51.66</td></tr><tr><td>true</td><td>Γ</td><td>X</td><td>Γ</td><td>99.59</td><td>99.53</td><td>77.31</td><td>38.94</td><td>22.28</td><td>60.59</td></tr><tr><td>true</td><td>X</td><td>X</td><td>β</td><td>99.65</td><td>99.40</td><td>79.96</td><td>39.86</td><td>19.69</td><td>59.54</td></tr><tr><td>true</td><td>β</td><td>β</td><td>X</td><td>99.50</td><td>97.28</td><td>84.26</td><td>49.16</td><td>15.24</td><td>48.12</td></tr><tr><td>true</td><td>X</td><td>β</td><td>β</td><td>99.41</td><td>99.20</td><td>80.28</td><td>41.64</td><td>19.13</td><td>57.56</td></tr><tr><td>random</td><td></td><td>X</td><td>Γ</td><td>99.80</td><td>99.55</td><td>9.79</td><td>0.15</td><td>90.01</td><td>99.40</td></tr><tr><td>random</td><td>X</td><td>X</td><td>X</td><td>99.36</td><td>86.10</td><td>9.71</td><td>0.24</td><td>89.65</td><td>85.86</td></tr><tr><td>random</td><td>X</td><td>β</td><td>X</td><td>99.84</td><td>99.53</td><td>10.13</td><td>0.23</td><td>89.71</td><td>99.30</td></tr><tr><td>random</td><td>X</td><td>X</td><td>β</td><td>99.15</td><td>92.23</td><td>9.04</td><td>0.17</td><td>90.11</td><td>92.06</td></tr><tr><td>random</td><td>β</td><td></td><td>X</td><td>99.25</td><td>69.62</td><td>9.67</td><td>0.24</td><td>89.58</td><td>69.38</td></tr><tr><td>random</td><td>Γ</td><td>γ</td><td>β</td><td>99.38</td><td>81.57</td><td>9.54</td><td>0.19</td><td>89.84</td><td>81.38</td></tr></table>
β’ Attack steps. We adopt the weaker FGSM adversary (Goodfellow et al., 2015) for training. We also adopt the random initialization trick as argued in Wong et al. (2020) and adjust the step size as $\alpha = 1 0 / 2 5 5$ , yielding the fast adversarial training method (Wong et al., 2020). However, fast AT still cannot converge.
β’ Optimizer. We try to use various optimizers, including the SGD momentum optimizer, the Adam optimizer (Kingma & Ba, 2015), and the nesterov optimizer (Nesterov, 1983); different learning rate schedules, including the piecewise decay and cosine schedules, and different learning rates (0.1 and 0.01), but none of these attempts make PGD-AT converge.
β’ Perturbation budget. The perturbation budget $\epsilon$ is an important factor to affect the convergence of PGD-AT. When $\epsilon$ approaches 0, PGD-AT would degenerate into standard training, which can easily converge (Zhang et al., 2017). Hence we try different values of $\epsilon$ , and find that PGD-AT can converge with a smaller $\epsilon$ (e.g., $\epsilon = 1 / 2 5 5 )$ but cannot converge when $\epsilon \geq 2 / 2 5 5$ .
# A.2.2 GRADIENT STABILITY UNDER COSINE SIMILARITY
In Fig. 4(a), we show the gradient change of PGD-AT, TRADES, and the clean CE loss under the $\ell _ { 2 }$ distance. We further show the cosine similarity between the gradients at $\pmb { \theta }$ and $\pm \lambda \mathbf { d }$ in Fig. A.8. The cosine similarity is also averaged over all data samples. The results based on cosine similarity are consistent with the results based on the $\ell _ { 2 }$ distance, showing that the gradient of PGD-AT changes more abruptly.
# A.2.3 THE FAILURES OF AT UNDER REALISTIC SETTINGS
We find that some AT methods (e.g., PGD-AT) suffer from a gradient instability issue, which results in the convergence problem when trained on random labels. Under other realistic setting, our analysis may also be valuable.
First, PGD-AT fails to converge under $80 \%$ noise rate. We think that the unstable gradients can overwhelm the useful gradients given by clean examples. To prove it, we train the models under $80 \%$ uniform label noise, by either PGD-AT or standard training (ST) on natural examples. We then select 100 training images with wrong labels and another 100 training images with true labels for evaluation. Similarly, we calculate the gradient norm of the cross-entropy loss w.r.t. model parameters of each method. We show the results in Fig. A.9. For AT, the gradient norm of clean examples is larger than that of noisy examples at beginning, which makes the model learn to classify. However, for PGD-AT, the gradient norm of clean examples is almost the same as that of noisy examples (the two curves overlap together). And the unstable gradients provided by noisy examples would overwhelm the useful gradients given by clean examples, making the network fail to converge.
 Figure A.8: The cosine similarity between the gradients at $\pmb \theta$ and $\pmb \theta + \lambda \mathbf d$ of different losses, where $\pmb { \theta }$ are initialized, $\lambda \in [ - 0 . 0 5 , 0 . 0 5 ]$ .
 Figure A.9: The gradient norm of PGD-AT and ST given clean examples or noisy examples, when trained on $80 \%$ uniform label noise.
Second, when the perturbation budget is large (e.g., $\epsilon = 6 4 / 2 5 5 )$ , PGD-AT cannot converge with true labels, while TRADES can achieve about $5 0 \%$ training accuracies. This can also be explained by our convergence analysis that the gradient is very unstable in PGD-AT with a larger perturbation budget, making it fail to converge.
# A.3 MORE DISCUSSIONS ON THE GENERALIZATION OF AT
As shown in Table A.1, when trained on true labels, although the regularizers can help to reduce the generalization gap, the model without any regularization can still generalize non-trivially. The three explicit regularizations do not significantly affect the modelβs ability to memorize adversarial examples with random labels. In consequence, the explicit regularizers are not the adequate explanation of generalization. By inspecting the learning dynamics of AT under different noise rates in Fig. A.6 and Fig. A.7, the network achieves maximum accuracy on the test set before fitting the noisy training set, meaning that the model learns simple patterns (i.e., clean data) before memorizing the hard examples with wrong labels, similar to the observation in standard training (Arpit et al., 2017). The results suggest that optimization by itself serves as an implicit regularizer to find a model with good generalization performance.
 Figure A.10: The natural and robust testing accuracies of TRADES on CIFAR-10 with different initialization strategies and training methods.
A recent work (Liu et al., 2020b) points out that in standard training, pre-training on random labels can lead to substantial performance degeneration of subsequent SGD training on true labels, while adding regularizations can overcome the bad initialization caused by pre-training with random labels. In this paper, we further investigate whether this finding can generalize to adversarial training.
As PGD-AT cannot converge with random labels, we adopt TRADES to conduct experiments. Following Liu et al. (2020b), we consider two initialization strategies β random initialization and adversarial initialization generated by training on random labeling of the training data. We also consider two training methods β vanilla SGD training and SOTA SGD training with data augmentation (random crops and flips), weight decay, and momentum. The results are shown in Fig. A.10. It can be seen that with vanilla SGD, the adversarial initialization can lead to worse performance than the random initialization. But with the regularization techniques, the models with different initializations converge to nearly the same test accuracy. The results are consistent with the findings in Liu et al. (2020b).
# B PROOF OF THEOREM 1
Proof. Recall that $\begin{array} { r } { \mathcal { I } ( \mathbf { x } , y , \pmb { \theta } ) = \operatorname* { m a x } _ { \mathbf { x } ^ { \prime } \in S ( \mathbf { x } ) } \mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } ^ { \prime } ) , y ) } \end{array}$ is the adversarial loss of PGD-AT. First, we have
$$\begin{array} { r l } & { \quad \| \nabla _ { \theta } \mathcal { I } ( { \bf x } , y , \theta _ { 1 } ) - \nabla _ { \theta } \mathcal { I } ( { \bf x } , y , \theta _ { 2 } ) \| _ { 2 } } \\ & { = \| \nabla _ { \theta } \mathcal { I } ( { \bf x } , y , \theta _ { 1 } ) - \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 1 } } ( { \bf x } ) , y ) - } \\ & { \quad \nabla _ { \theta } \mathcal { I } ( { \bf x } , y , \theta _ { 2 } ) + \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 2 } } ( { \bf x } ) , y ) + } \\ & { \quad \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 1 } } ( { \bf x } ) , y ) - \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 2 } } ( { \bf x } ) , y ) \| _ { 2 } } \\ & { \le \| \nabla _ { \theta } \mathcal { I } ( { \bf x } , y , \theta _ { 1 } ) - \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 1 } } ( { \bf x } ) , y ) \| _ { 2 } + } \\ & { \quad \| \nabla _ { \theta } \mathcal { I } ( { \bf x } , y , \theta _ { 2 } ) - \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 2 } } ( { \bf x } ) , y ) \| _ { 2 } + } \\ & { \quad \| \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 1 } } ( { \bf x } ) , y ) - \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 2 } } ( { \bf x } ) , y ) \| _ { 2 } . } \end{array}$$
From the assumption, for any $\mathbf { x } \in \mathbb { R } ^ { d }$ and $\mathbf { x } ^ { \prime } \in { \mathcal { S } } ( \mathbf { x } )$ , we have
$$\| \nabla _ { \pmb { \theta } } \mathcal { L } \big ( f _ { \pmb { \theta } } ( \mathbf { x } ^ { \prime } ) , y \big ) - \nabla _ { \pmb { \theta } } \mathcal { L } \big ( f _ { \pmb { \theta } } ( \mathbf { x } ) , y \big ) \| _ { 2 } \leq K \| \mathbf { x } ^ { \prime } - \mathbf { x } \| _ { p } \leq \epsilon K ,$$
due to the definition of $\boldsymbol { S } ( \mathbf { x } )$ . We also note that $\mathcal { I } ( \mathbf { x } , y , \pmb { \theta } )$ is the maximal cross-entropy loss $\mathcal { L }$ within $\boldsymbol { S } ( \mathbf { x } )$ , such that we have
$$\begin{array} { r } { \| \nabla _ { \theta } \mathcal { I } ( \mathbf { x } , y , \pmb { \theta } ) - \nabla _ { \theta } \mathcal { L } ( f _ { \pmb { \theta } } ( \mathbf { x } ) , y ) \| _ { 2 } \le \epsilon K . } \end{array}$$
Combining Eq. (B.1) and Eq. (B.2), we can obtain Eq. (5).
Note that the bound is tight since the all the equalities can be reached.
Remark 1. We note that a recent work (Liu et al., 2020a) gives a similar result on gradient stability. The difference is that they assume the loss function satisfies an additional Lipschitzian smoothness condition as
$$\begin{array} { r } { \| \nabla _ { \pmb \theta } \mathcal { L } \big ( f _ { \pmb \theta _ { 1 } } ( \mathbf { x } ) , y \big ) - \nabla _ { \pmb \theta } \mathcal { L } \big ( f _ { \pmb \theta _ { 2 } } ( \mathbf { x } ) , y \big ) \| _ { 2 } \leq K _ { \pmb \theta } \| \pmb \theta _ { 1 } - \pmb \theta _ { 2 } \| _ { 2 } , } \end{array}$$
where $K _ { \theta }$ is another constant. Then they prove that
$$\begin{array} { r } { \| \nabla _ { \pmb { \theta } } \mathcal { I } ( \mathbf { x } , y , \pmb { \theta } _ { 1 } ) - \nabla _ { \pmb { \theta } } \mathcal { I } ( \mathbf { x } , y , \pmb { \theta } _ { 2 } ) \| _ { 2 } \leq K _ { \pmb { \theta } } \| \pmb { \theta } _ { 1 } - \pmb { \theta } _ { 2 } \| _ { 2 } + 2 \epsilon K . } \end{array}$$
It can be noted that with this new assumption, we can simply obtain this result by Theorem 1. Therefore, Theorem 1 is a more general result of the previous one.
# B.1 THEORETICAL ANALYSIS FOR TRADES
Note that TRADES adopts the $\mathrm { K L }$ divergence in its adversarial loss. The KL divergence is defined on two predicted probability distributions over all classes, as
$$\mathcal { D } ( f _ { \pmb { \theta } } ( \mathbf { x } ) \| f _ { \pmb { \theta } } ( \mathbf { x } ^ { \prime } ) ) = \sum _ { y \in \{ 1 , \dots , C \} } f _ { \pmb { \theta } } ( \mathbf { x } ) _ { y } \cdot \log \frac { f _ { \pmb { \theta } } ( \mathbf { x } ) _ { y } } { f _ { \pmb { \theta } } ( \mathbf { x } ^ { \prime } ) _ { y } } .$$
However, based on the local Lipschitz continuity assumption of the clean cross-entropy loss (which is only concerned with the predicted probability of the true class) in Eq. (4), we cannot derive a similar theoretical bound on the gradient stability of TRADES as in Eq. (5). Therefore, we need to make a different assumption on the KL divergence. For example, suppose the gradient of the KL divergence satisfies
$$\begin{array} { r } { \| \nabla _ { \theta } \mathcal { D } \big ( f _ { \pmb { \theta } } ( \mathbf { x } ) \| f _ { \pmb { \theta } } ( \mathbf { x } ^ { \prime } ) \big ) \| _ { 2 } \leq K ^ { \prime } \| \mathbf { x } ^ { \prime } - \mathbf { x } \| _ { p } , } \end{array}$$
for any $\mathbf { x } \in \mathbb { R } ^ { d }$ , $\mathbf { x } ^ { \prime } \in S ( \mathbf { x } )$ , and any $\pmb \theta$ , where $K ^ { \prime }$ is another constant. We denote the adversarial loss of TRADES as $\mathcal { I } ^ { \prime } ( \mathbf { x } , y , \pmb { \theta } )$ , then we have
$$\begin{array} { r l } & { \quad \| \nabla _ { \theta } \mathcal { I } ^ { \prime } ( \mathbf { x } , y , \theta _ { 1 } ) - \nabla _ { \theta } \mathcal { I } ^ { \prime } ( \mathbf { x } , y , \theta _ { 1 } ) \| _ { 2 } } \\ & { { \le } \| \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 1 } } ( \mathbf { x } ) , y ) - \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 2 } } ( \mathbf { x } ) , y ) \| _ { 2 } + } \\ & { \quad \beta \| \nabla _ { \theta } \underset { \mathbf { x } ^ { \prime } \in S ( \mathbf { x } ) } { \operatorname* { m a x } } \mathcal { D } ( f _ { \theta _ { 1 } } ( \mathbf { x } ) \| f _ { \theta _ { 1 } } ( \mathbf { x } ^ { \prime } ) ) \| _ { 2 } + } \\ & { \quad \beta \| \nabla _ { \theta } \underset { \mathbf { x } ^ { \prime } \in S ( \mathbf { x } ) } { \operatorname* { m a x } } \mathcal { D } ( f _ { \theta _ { 2 } } ( \mathbf { x } ) \| f _ { \theta _ { 2 } } ( \mathbf { x } ^ { \prime } ) ) \| _ { 2 } } \\ & { { \le } \| \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 1 } } ( \mathbf { x } ) , y ) - \nabla _ { \theta } \mathcal { L } ( f _ { \theta _ { 2 } } ( \mathbf { x } ) , y ) \| _ { 2 } + 2 \beta \epsilon K ^ { \prime } . } \end{array}$$
Although we can derive a similar bound on gradient stability of TRADES, this bound is not directly comparable to Eq. (5) since we cannot find the relationship between $K$ and $K ^ { \prime }$ . However, our empirical analysis on gradient magnitude in Sec. 3.2 has shown that TRADES is dominated by the clean cross-entropy loss at the initial training epochs, thus the gradient stability of the TRADES loss will be similar to that of the clean cross-entropy loss, as also revealed in Fig. 4(a). Therefore, the gradient of TRADES would be relatively stable.
# C FULL EXPERIMENTS ON ROBUST OVERFITTING

 Figure C.1: The robust test accuracy of TRADES under various perturbation budgets $\epsilon$ . Figure C.2: The adversarial loss of WRN-28-10 and ResNet-18 trained by PGD-AT on 500 samples sorted by the loss of the first model (i.e., WRN-28-10).
First, we show the robust test accuracy curves of TRADES under various perturbation budgets in Fig. C.1. It can also be observed that when the perturbation budget is small, robust overfitting does not occur.
Second, we show that the βhardβ training examples with higher adversarial loss values are consistent across different model architectures. We train one WRN-28-10 model and one ResNet-18 model based on PGD-AT. We then calculate the adversarial loss for each training sample for these two models. We show the adversarial loss on 500 samples sorted by the loss of the first model (i.e., WRN28-10) in Fig. C.2. It can be seen that the samples with lower adversarial losses of the first model also have relatively lower losses of the second one and vice versa. The Kendallβs rank coefficient of the adversarial loss between the two models is 0.78 in this case.
Third, we visualize the hard training examples with high adversarial loss values in Fig. C.3. It can be seen that these examples are difficult to recognize and their labels may be wrong. Therefore, the one-hot labels for these hard training examples can be noisy for AT, leading to the robust overfitting problem.
 Figure C.3: The hard training examples with high adversarial loss values.
Table C.1: Test accuracy $( \% )$ of several methods using different model architectures and threat models. We choose the best checkpoint according to the highest robust accuracy on the test set under PGD-10.
<table><tr><td rowspan="2">Methods</td><td rowspan="2">Networks</td><td rowspan="2">Norms</td><td colspan="3">Natural Accuracy</td><td colspan="3">PGD-10</td></tr><tr><td>Best</td><td>Final</td><td>Diff</td><td>Best</td><td>Final</td><td>Diff</td></tr><tr><td>PGD-AT PGD-AT+TE PGD-AT</td><td>WRN-34-10 WRN-34-10 VGG-16</td><td>lo (β=8/255)</td><td>86.58 85.43 79.60</td><td>86.83 85.10</td><td>-0.25 0.33</td><td>55.83 59.30</td><td>49.52 56.63</td><td>6.31 2.67</td></tr><tr><td>PGD-AT+TE PGD-AT</td><td>VGG-16</td><td></td><td>78.19 88.82</td><td>81.26 79.13</td><td>-1.66 -0.94</td><td>48.52 52.06</td><td>43.02 51.29</td><td>5.50 0.77</td></tr><tr><td></td><td></td><td></td><td></td><td>88.96</td><td>-0.14</td><td>69.05</td><td>65.96</td><td>3.09</td></tr><tr><td>PGD-AT+TE</td><td></td><td></td><td>87.95</td><td>88.20</td><td></td><td></td><td></td><td>0.65</td></tr><tr><td></td><td>ResNet-18</td><td>l2 (β =128/255)</td><td></td><td></td><td>-0.25</td><td>72.58</td><td>71.93</td><td></td></tr><tr><td>TRADES</td><td></td><td></td><td>86.50</td><td>86.57</td><td>-0.07</td><td>70.22</td><td>66.07</td><td>4.15</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>TRADES+TE</td><td></td><td></td><td>88.42</td><td>88.60</td><td>-0.18</td><td>72.72</td><td>72.43</td><td>0.29</td></tr></table>
# C.2 ADDITIONAL EXPERIMENTS ON MITIGATING ROBUST OVERFITTING
We show the results of our proposed methods on other network architectures (including WRN34-10 and VGG-16) and threat models (including $\ell _ { 2 }$ norm) in Table C.1. The results consistently demonstrate the effectiveness of the proposed method.
We further show the results of PGD-AT, PGD- $\mathbf { A T + T E }$ , TRADES, and TRADES ${ \bf \nabla } + { \bf T } { \bf E }$ on CIFAR-10 over 3 runs in Table C.2.
Table C.2: Test accuracy $( \% )$ of several methods on CIFAR-10 under the $\ell _ { \infty }$ norm with $\epsilon = 8 / 2 5 5$ based on the ResNet-18 architecture. We show the mean/std of the results over 3 runs.
<table><tr><td rowspan="2">Method</td><td colspan="3">Natural Accuracy</td></tr><tr><td>Best</td><td>Final</td><td>Diff</td></tr><tr><td>PGD-AT</td><td>83.76 Β± 0.02</td><td>84.93 Β± 0.26</td><td>-1.17 Β± 0.29</td></tr><tr><td>PGD-AT+TE</td><td>82.36 Β± 0.18</td><td>82.69 Β± 0.14</td><td>-0.33 Β± 0.31</td></tr><tr><td>TRADES</td><td>81.34 Β± 0.15</td><td>82.70 Β± 0.21</td><td>-1.36 Β± 0.36</td></tr><tr><td>TRADES+TE</td><td>83.66 Β± 0.19</td><td>83.89 Β± 0.09</td><td>-0.23 Β± 0.21</td></tr><tr><td rowspan="2">Method</td><td></td><td>PGD-10</td><td></td></tr><tr><td>Best</td><td>Final</td><td>Diff</td></tr><tr><td>PGD-AT</td><td>52.62 Β± 0.10</td><td>44.91 Β± 0.01</td><td>7.71 Β± 0.11</td></tr><tr><td>PGD-AT+TE</td><td>55.74 Β± 0.17</td><td>54.82 Β± 0.23</td><td>0.92 Β± 0.07</td></tr><tr><td>TRADES</td><td>53.25 Β± 0.07</td><td>50.48 Β± 0.23</td><td>2.77 Β± 0.16</td></tr><tr><td>TRADES+TE</td><td>54.93 Β± 0.16</td><td>54.04 Β± 0.19</td><td>0.89 Β± 0.13</td></tr><tr><td rowspan="2">Method</td><td></td><td>PGD-1000</td><td></td></tr><tr><td>Best</td><td>Final</td><td>Diff</td></tr><tr><td>PGD-AT</td><td>51.26 Β± 0.03</td><td>42.72 Β± 0.06</td><td>8.54 Β± 0.06</td></tr><tr><td>PGD-AT+TE</td><td>54.54 Β± 0.27</td><td>53.01 Β± 0.34</td><td>1.53 Β± 0.24</td></tr><tr><td>TRADES</td><td>52.24 Β± 0.20</td><td>48.74 Β± 0.17</td><td>3.50 Β± 0.13</td></tr><tr><td>TRADES+TE</td><td>53.55 Β± 0.16</td><td>52.93 Β± 0.07</td><td>0.62 Β± 0.11</td></tr><tr><td rowspan="2">Method</td><td></td><td>C&W-1000</td><td></td></tr><tr><td>Best</td><td>Final</td><td>Diff</td></tr><tr><td>PGD-AT PGD-AT+TE</td><td>50.24 Β± 0.12</td><td>43.59 Β± 0.07</td><td>6.65 Β± 0.19</td></tr><tr><td></td><td>52.31 Β± 0.01</td><td>51.67 Β± 0.12</td><td>0.64 Β± 0.11</td></tr><tr><td>TRADES</td><td>49.83 Β± 0.05</td><td>48.11 Β± 0.04</td><td>1.72 Β± 0.02</td></tr><tr><td>TRADES+TE</td><td>50.80 Β± 0.02</td><td>50.61 Β± 0.07</td><td>0.19 Β± 0.08</td></tr><tr><td rowspan="2">Method</td><td>Best</td><td>AutoAttack Final</td><td>Diff</td></tr><tr><td></td><td></td><td></td></tr><tr><td>PGD-AT PGD-AT+TE</td><td>47.85 Β± 0.17 50.37 Β± 0.22</td><td>41.62 Β± 0.16 49.36 Β± 0.24</td><td>6.23 Β± 0.26 1.01 Β± 0.03</td></tr><tr><td>TRADES</td><td>48.86 Β± 0.18</td><td>46.73 Β± 0.07</td><td>2.13 Β± 0.11</td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>TRADES+TE</td><td>49.40 Β± 0.27</td><td>48.77 Β± 0.21</td><td>0.63 Β± 0.05</td></tr></table>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414# OPTIMIZING BI-ENCODER FOR NAMED ENTITY RECOGNITION VIA CONTRASTIVE LEARNING
Sheng Zhang, Hao Cheng, Jianfeng Gao, and Hoifung Poon Microsoft Research
# ABSTRACT
We present a bi-encoder framework for named entity recognition (NER), which applies contrastive learning to map candidate text spans and entity types into the same vector representation space. Prior work predominantly approaches NER as sequence labeling or span classification. We instead frame NER as a representation learning problem that maximizes the similarity between the vector representations of an entity mention and its type. This makes it easy to handle nested and flat NER alike, and can better leverage noisy self-supervision signals. A major challenge to this bi-encoder formulation for NER lies in separating non-entity spans from entity mentions. Instead of explicitly labeling all non-entity spans as the same class Outside (O) as in most prior methods, we introduce a novel dynamic thresholding loss, learned in conjunction with the standard contrastive loss. Experiments show that our method performs well in both supervised and distantly supervised settings, for nested and flat NER alike, establishing new state of the art across standard datasets in the general domain (e.g., ACE2004, ACE2005, CoNLL2003) and high-value verticals such as biomedicine (e.g., GENIA, NCBI, BC5CDR, JNLPBA). We release the code at github.com/microsoft/binder.
# 1 INTRODUCTION
Named entity recognition (NER) is the task of identifying text spans associated with named entities and classifying them into a predefined set of entity types such as person, location, etc. As a fundamental component in information extraction systems (Nadeau & Sekine, 2007), NER has been shown to be of benefit to various downstream tasks such as relation extraction (Mintz et al., 2009), coreference resolution (Chang et al., 2013), and fine-grained opinion mining (Choi et al., 2006).
Inspired by recent success in open-domain question answering (Karpukhin et al., 2020) and entity linking (Wu et al., 2020; Zhang et al., 2021a), we propose an efficient BI-encoder for NameD Entity Recognition (BINDER). Our model employs two encoders to separately map text and entity types into the same vector space, and it is able to reuse the vector representations of text for different entity types (or vice versa), resulting in a faster training and inference speed. Based on the bi-encoder representations, we propose a unified contrastive learning framework for NER, which enables us to overcome the limitations of popular NER formulations (shown in Figure 1), such as difficulty in handling nested NER with sequence labeling (Chiu & Nichols, 2016; Ma & Hovy, 2016), complex learning and inference for span-based classification (Yu et al., 2020; Fu et al., 2021), and challenges in learning with noisy supervision (Strakova et al., 2019; Yan et al., 2021). Β΄ 1 Through contrastive learning, we encourage the representation of entity types to be similar with the corresponding entity spans, and to be dissimilar with that of other text spans. Additionally, existing work labels all nonentity tokens or spans as the same class Outside (O), which can introduce false negatives when the training data is partially annotated (Das et al., 2022; Aly et al., 2021). We instead introduce a novel dynamic thresholding loss in contrastive learning, which learns candidate-specific dynamic thresholds to distinguish entity spans from non-entity ones.
To the best of our knowledge, we are the first to optimize bi-encoder for NER via contrastive learning. We conduct extensive experiments to evaluate our method in both supervised and distantly supervised settings. Experiments demonstrate that our method achieves the state of the art on a wide range of NER datasets, covering both general and biomedical domains. In supervised NER, compared to the previous best results, our method obtains a $2 . 4 \% - 2 . 9 \%$ absolute improvement in F1 on standard nested NER datasets such as ACE2004 and ACE2005, and a $1 . 2 \% - 1 . 9 \%$ absolute improvement on standard flat NER datasets such as BC5-chem, BC5-disease, and NCBI. In distantly supervised NER, our method obtains a $1 . 5 \%$ absolute improvement in F1 on the BC5CDR dataset. We further study the impact of various choices of components in our method, and conduct breakdown analysis at entity type level and token level, which reveals potential growth opportunities.
 Figure 1: Left: The architecture of BINDER. The entity type and text encoder are isomorphic and fully decoupled Transformer models. In the vector space, the anchor point $( \bigcirc )$ represents the special token [CLS] from the entity type encoder. Through contrastive learning, we maximize the similarity between the anchor and the positive token ( Jim), and minimize the similarity between the anchor and negative tokens. The dotted gray circle (delimited by the similarity between the anchor and $\operatorname { O } [ \operatorname { C L S } ]$ from the text encoder) represents a threshold that separates entity tokens from non-entity tokens. To reduce clutter, data points that represent possible spans from the input text are not shown. Right: We compare BINDER with existing solutions for NER on three dimensions: 1) whether it can be applied to nested NER without special handling; 2) whether it can be trained using noisy supervision without special handling; 3) whether it has a fast training and inference speed.

# 2 METHOD
In this section, we present the design of BINDER, a novel architecture for NER tasks. As our model is built upon a bi-encoder framework, we first provide the necessary background for encoding both entity types and text using the Transformer-based (Vaswani et al., 2017) bi-encoder. Then, we discuss our ways of deriving entity type and individual mention span representations using the embedding output from the bi-encoder. Based on that, we introduce two types of contrastive learning objectives for NER using the token and span-level similarity respectively.
# 2.1 BI-ENCODER FOR NER
The overall architecture of BINDER is shown in Figure 1. Our model is built upon a bi-encoder architecture which has been mostly explored for dense retrieval (Karpukhin et al., 2020). Following the recent work, our bi-encoder also consists of two isomorphic and fully decoupled Transformer models (Vaswani et al., 2017), i.e. an entity type encoder and a text encoder. For NER tasks, we consider two types of inputs, entity type descriptions and text to detect named entities. At the high level, the entity type encoder produces type representations for each entity of interests (e.g. person in Figure 1) and the text encoder outputs representations for each input token in the given text where named entities are potentially mentioned (e.g. Jim in Figure 1). Then, we enumerate all span candidates based on corresponding token representations and match them with each entity type in the vector space. As shown in Figure 1, we maximize the similarity between the entity type and the positive spans, and minimize the similarity of negative spans.
We first formally discuss encoding both inputs using a pretrained Transformer model, BERT (Devlin et al., 2019).2 Specifically, we use $x _ { 1 } , \ldots , x _ { N }$ to denote an input sequence of length $N$ . When using BERT, there is a prepended token [CLS] and an appended token [SEP]for all input sequences, i.e. [CLS], $x _ { 1 } , \ldots , x _ { N }$ [SEP]. Then the output is a sequence of hidden states $\mathbf { h } _ { [ \mathbb { C L S } ] } , \mathbf { h } _ { 1 } , \dots , \mathbf { h } _ { N } , \mathbf { h } _ { [ \mathbb { S E P } ] } \in \mathbb { R } ^ { d }$ from the last BERT layer for each input token, where $d$ is the hidden dimension. Note that as [CLS]is always in the beginning, $\mathbf { h } _ { 0 }$ and $\mathbf { h } _ { \left[ \mathrm { C L S } \right] }$ are interchangeable here. Based on this, we then discuss the way of computing entity type and text token embeddings, which are the basic building blocks for deriving our NER constrative learning objectives later.
Entity Type Embeddings The goal of entity type encoder is to produce entity type embeddings that serve as anchors in the vector space for contrastive learning. In this work, we focus on a predefined set of entity types $\mathcal { E } = \{ E _ { 1 } , \ldots , E _ { K } \}$ , where each entity type has one or multiple natural language descriptions. The natural language description can be formal textual definitions based on the dataset annotation guideline or Wikipedia, and prototypical instances where a target type of named entities are mentioned. For simplicity, the discussion proceeds with one description per type and we use $E _ { k }$ to denote a sequence of tokens for the $k$ -th entity type description. For a given entity type $E _ { k }$ , we use BERT as the entity type encoder $( \mathrm { B E R T } ^ { E \setminus } ,$ ) and add an additional linear projection to compute corresponding entity type embeddings in the following way:
$$\begin{array} { r l } & { { \bf { h } } _ { [ \mathbb { C } \mathrm { L S } ] } ^ { E _ { k } } = { \tt B E R T } ^ { E } ( E _ { k } ) , } \\ & { { \bf { e } } _ { k } = { \tt L i n e a r } ^ { E } ( { \bf { h } } _ { [ \mathbb { C } \mathrm { L S } ] } ^ { E _ { k } } ) , } \end{array}$$
where Linear is a learnable linear layer and $\mathbf { e } _ { k } \in \mathbb { R } ^ { d }$ is the vector representation for $E _ { k }$
Text Token Embeddings Instead of using [CLS]embeddings as done in the recent bi-encoder work for entity retrieval (Wu et al., 2020), we consider using text token embeddings as the basic unit for computing similarity with entity span embeddings. As there are multiple potential named entities not known as a prior in the input, naively using special markers (Wu et al., 2020) incurs huge computation overhead for NER. Similar to the entity type embeddings, we again use BERT as the text encoder (BERTT ) and simply use the final hidden states as the basic text token representations3,
$$\mathbf { h } _ { 1 } ^ { T } , \ldots , \mathbf { h } _ { N } ^ { T } = \mathtt { B E R T } ^ { T } \big ( x _ { 1 } , \ldots , x _ { N } \big ) .$$
# 2.2 CONTRASTIVE LEARNING FOR NER
Based on the entity type embeddings and text token embeddings discussed above, we then introduce two different contrastive learning objectives for NER in this part. Here, we assume a span $( i , j )$ is a contiguous sequence of tokens in the input text with a start token in position $i$ and an end token in position $j$ . Throughout this work, we use the similarity function, $\begin{array} { r } { s \mathrm { i m } ( \cdot , \cdot ) = \frac { \cos ( \cdot , \cdot ) } { \tau } } \end{array}$ cos(Β·,Β·) , where Ο is a scalar parameter.
As shown in Figure 1, the overall goal of NER constrastive learning is to push the entity mention span representations close to their corresponding entity type embeddings (positive) and far away from irrelevant types (negative) in vector space, e.g. Person closer to $\ J \ i \mathrm { m }$ but away from Acme. To achieve that, we propose a multi-objective formulation consisting of two objectives based on span and token embedding spaces respectively.
Span-based Objective We derive the vector representation for span $( i , j )$ as below:
$$\mathsf { \mathbf { s } } _ { i , j } = \mathtt { L i n e a r } ^ { S } ( \mathbf { h } _ { i } ^ { T } \oplus \mathbf { h } _ { j } ^ { T } \oplus D ( j - i ) ) ,$$
where $\mathbf { h } _ { i } ^ { T } , \mathbf { h } _ { j } ^ { T }$ are text token embeddings (Equation 3), $\mathbf { s } _ { i , j } \in \mathbb { R } ^ { d }$ , LinearS is a learnable linear layer, $\oplus$ indicates the vector concatenation, $D ( j - i ) \in \mathbb { R } ^ { m }$ is the $( j - i )$ -th row of a learnable span width embedding matrix $D \in \mathbb { R } ^ { N \times m }$ . Based on this, the span-based infoNCE (Oord et al., 2018) can be defined as
$$\ell _ { \mathrm { s p a n } } = - \log \frac { \exp ( \sin ( \mathbf { s } _ { i , j } , \mathbf { e } _ { k } ) ) } { \sum _ { \mathbf { s } ^ { \prime } \in \mathcal { S } _ { k } ^ { - } \cup \mathbf { s } _ { i , j } } \exp ( \sin ( \mathbf { s } ^ { \prime } , \mathbf { e } _ { k } ) ) } ,$$
where the span $( i , j )$ belongs to entity type $E _ { k }$ , $S _ { k } ^ { - }$ is the set of negative spans that are all possible spans from the input text, excluding entity spans from $E _ { k }$ , and $\mathbf { e } _ { k }$ is the entity type embedding.
Position-based Objective One limitation of the span-based objective is that it penalizes all negative spans in the same way, even if they are partially correct spans, e.g., spans that have the same start or end token with the gold entity span. Intuitively, it is more desirable to predict partially correct spans than completely wrong spans. Therefore, we propose additional position-based contrastive learning objectives. Specby using additional linear layers, ddings , where $E _ { k }$ $e _ { k } ^ { \mathrm { B } } = \mathtt { L i n e a r } _ { B } ^ { E } ( \mathbf { h } _ { \scriptscriptstyle { [ \mathrm { C L S } ] } } ^ { E _ { k } } ) , e _ { k } ^ { \mathrm { Q } } = \mathtt { L i n e a r } _ { Q } ^ { E } ( \mathbf { h } _ { \scriptscriptstyle { [ \mathrm { C L S } ] } } ^ { E _ { k } } )$ $e _ { k } ^ { \tt B } , e _ { k } ^ { \tt Q }$ are the type embeddings for the start and end positions respectively, $\mathbf { h } _ { [ \mathbb { C } \mathrm { L } S ] } ^ { E _ { k } }$ is from the entity type encoder (Equation 1). Accordingly, we can use two addtional linear layers to compute the corresponding token embeddings for the start and end tokens respectively, $\mathbf u _ { n } = \mathtt { L i n e a r } _ { B } ^ { \mathrm { - } } ( \mathbf h _ { n } ^ { T } ) , \mathbf v _ { n } =$ Linea $\underline { { \boldsymbol { r } } } _ { Q } ^ { T } ( \mathbf { h } _ { n } ^ { T } )$ , where $\mathbf { h } _ { n } ^ { T }$ is the text token embeddings (Equation 3). Using $e _ { \mathbf { B } } ^ { k } , e _ { \mathbf { Q } } ^ { k }$ as anchors, we then define two position-based objectives via contrastive learning:
$$\begin{array} { r l } & { \ell _ { \mathrm { s t a r t } } = - \log \frac { \exp ( \sin ( \mathbf { u } _ { i } , \mathbf { e } _ { k } ^ { \mathrm { B } } ) ) } { \sum _ { \mathbf { u } ^ { \prime } \in \mathcal { U } _ { k } ^ { - } \cup \mathbf { u } _ { i } } \exp ( \sin ( \mathbf { u } ^ { \prime } , \mathbf { e } _ { k } ^ { \mathrm { B } } ) ) } } \\ & { \ell _ { \mathrm { e n d } } = - \log \frac { \exp ( \sin ( \mathbf { v } _ { j } , \mathbf { e } _ { k } ^ { \mathrm { Q } } ) ) } { \sum _ { \mathbf { v } ^ { \prime } \in \mathcal { V } _ { k } ^ { - } \cup \mathbf { v } _ { j } } \exp ( \sin ( \mathbf { v } ^ { \prime } , \mathbf { e } _ { k } ^ { \mathrm { Q } } ) ) } , } \end{array}$$
where $\mathcal { U } _ { k } ^ { - } , \mathcal { V } _ { k } ^ { - }$ are two sets of positions in the input text that do not belong to the start/end of any span of entity type $k$ . Compared with Equation 5, the main difference of position-based objectives comes from the corresponding negative sets where start and end positions are independent of each other. In other words, the position-based objectives can potentially help the model to make better start and end position predictions.
Thresholding for Non-Entity Cases Although the contrastive learning objectives defined above can effectively push the positive spans close to their corresponding entity type in vector space, it might be problematic for our model at test time to decide how close a span should be before it can be predicted as positive. In other words, the model is not able to separate entity spans from nonentity spans properly. To address this issue, we use the similarity between the special token [CLS] and the entity type as a dynamic threshold (as shown in Figure 1). Intuitively, the representation of [CLS] reads the entire input text and summarizes the contextual information, which could make it a good choice to estimate the threshold to separate entity spans from non-entity spans. We compare it with several other thresholding choices in $\ S 4$ .
To learn thresholding, we extend the original contrastive learning objectives with extra adaptive learning objectives for non-entity cases. Specifically, for the start loss (Equation 6), the augmented start loss $\ell _ { \mathrm { s t a r t } } ^ { + }$ is defined as
$$\ell _ { \mathrm { s t a r t } } ^ { + } = \beta \ell _ { \mathrm { s t a r t } } - ( 1 - \beta ) \log \frac { \exp ( \sin ( \mathbf { u } _ { \scriptscriptstyle { \left[ \mathrm { C L S } \right] } } , \mathbf { e } _ { k } ^ { \mathrm { B } } ) ) } { \sum _ { \mathbf { u } ^ { \prime } \in \mathcal { U } _ { k } ^ { - } \exp ( \sin ( \mathbf { u } ^ { \prime } , \mathbf { e } _ { k } ^ { \mathrm { B } } ) ) } } .$$
An augmented end loss use the span embedding $\ell _ { \mathrm { e n d } } ^ { + }$ can be defined in a similar fashion. Ffor deriving the augmented span loss span loss (Equation 5), we $\mathbf { s } _ { 0 , 0 }$ $\ell _ { \tt s p a n } ^ { + }$
$$\ell _ { \mathrm { s p a n } } ^ { + } = \beta \ell _ { \mathrm { s p a n } } - ( 1 - \beta ) \log \frac { \exp ( \sin ( \mathbf { s } _ { 0 , 0 } , \mathbf { e } _ { k } ) ) } { \sum _ { \mathbf { s } ^ { \prime } \in S _ { k } ^ { - } } \exp ( \sin ( \mathbf { s } ^ { \prime } , \mathbf { e } _ { k } ) ) } .$$
Note that we use a single scalar hyperparameter $\beta$ for balancing the adaptive thresholding learning and original contrastive learning for all three cases.
Training Finally, we consider a multi-task contrastive formulation by combing three augmented contrastive learning discussed above, leading to our overall training objective
$$\mathcal { L } = \alpha \ell _ { \mathrm { s t a r t } } ^ { + } + \gamma \ell _ { \mathrm { e n d } } ^ { + } + \lambda \ell _ { \mathrm { s p a n } } ^ { + } ,$$
where $\alpha , \gamma , \lambda$ are all scalar hyperparameters.
Inference Strategy During inference, we enumerate all possible spans that are less than the length of $L$ and compute three similarity scores based on the start/end/span cases for each entity type. We consider two prediction strategies, joint position-span and span-only predictions. In the joint position-span case, for entity type $E _ { k }$ , we prune out spans $( i , j )$ that have either start or end similar scores lower than the learned threshold, i.e. $\mathrm { s i m } ( \mathbf { u } _ { i } , \mathbf { e } _ { k } ^ { \mathrm { B } } ) \ < \ \mathrm { s i m } ( \mathbf { u } _ { \mathrm { [ C L S ] } } , \mathbf { e } _ { k } ^ { \mathrm { B } } )$ or $\sin ( \mathbf { v } _ { j } , \mathbf { e } _ { k } ^ { \mathrm { Q } } ) < \sin ( \mathbf { v } _ { [ \mathtt { C L S } ] } , \mathbf { e } _ { k } ^ { \mathrm { Q } } )$ . Then, only those spans with span similarity scores higher than the span threshold are predicted as positive ones i.e. $\sin ( \mathbf { s } _ { i , j } , \mathbf { e } _ { k } ) > \sin ( \mathbf { s } _ { 0 , 0 } , \mathbf { e } _ { k } )$ . For the span-only strategy, we just rely on the span similarity score and keep all qualified spans as final predictions. As shown later in our experiments $( \ S 4 )$ , we find the span-only inference is more effective, because the joint inference is more likely to be affected by annotation artifacts. The full inference algorithm is summarized in Appendix A.5.
# 3 EXPERIMENTS
We evaluate our method in both supervised and distantly supervised settings. The implementation details of our method are described in Appendix A.4
Evaluation Metrics We follow the standard evaluation protocol and use micro F1: a predicted entity span is considered correct if its span boundaries and the predicted entity type are both correct.
Datasets In the supervised setting, we evaluate our method on both nested and flat NER. For nested NER, we consider ACE2004, ACE2005, and GENIA (Kim et al., 2003). ACE2004 and ACE2005 are collected from general domains (e.g., news and web). We follow Luan et al. (2018) to split ACE2004 into 5 folds, and ACE2005 into train, development and test sets. GENIA is from the biomedical domain. We use its v3.0.2 corpus and follow Finkel & Manning (2009) and Lu & Roth (2015) to split it into $8 0 \% / 1 0 \% / 1 0 \%$ train/dev/test splits. For flat NER, we consider CoNLL2003 (Tjong Kim Sang & De Meulder, 2003) as well as five biomedical NER datasets from the BLURB benchmark (Gu et al., 2021): BC5-chem/disease (Li et al., 2016), NCBI (Dogan et al., Λ 2014), BC2GM (Smith et al., 2008), and JNLPBA (Collier & Kim, 2004). Preprocessing and splits follow Gu et al. (2021). Appendix A.6 reports the dataset statistics.
In the distantly supervised setting, we consider BC5CDR (Li et al., 2016). It consists of 1,500 articles annotated with 15,935 chemical and 12,852 disease mentions. We use the standard train, development, and test splits. In the train and development sets, we discard all human annotations and only keep the unlabeled articles. Their distant labels are generated using exact string matching against a dictionary released by Shang et al. (2018).4 On the training set, the distant labels have high precision $( 9 7 . 9 9 \%$ for chemicals, and $9 8 . 3 4 \%$ for diseases), but low recall $6 3 . 1 4 \%$ for chemicals, and $4 6 . 7 3 \%$ for diseases).
Supervised NER Results Table 1 presents the comparison of our method with all previous methods evaluated on three nested NER datasets, ACE2004, ACE2005, and GENIA. We report precision, recall, and F1. As is shown, our method achieves the state of the art performance on all three datasets. On ACE2004 and ACE2005, it outperforms all previous methods with $8 9 . 7 \%$ and $9 0 . 0 \%$ F1. Particularly, in comparison with the previous best method (Tan et al., 2021), our method significantly improves F1 by the absolute points of $+ 2 . 4 \%$ and $+ 2 . 9 \%$ respectively. On GENIA, our method advances the previous state of the art (Yu et al., 2020) by $+ 0 . 3 \%$ F1. Note that the previous methods are built on top of different encoders, e.g., LSTM, BERT-large, BART-large, and T5-base. We also report our method using a BERT-base encoder, which even outperforms the previous methods that use a larger encoder of BERT-large (Tan et al., 2021) or BART-large (Yan et al., 2021). Overall, our method has substantial gains over the previous methods. Due to the space limit, we report the result on CoNLL03 and compare with prompt-based NER and span-based NER in Appendix A.1 and A.2.
Table 2 compares our method with all previous submissions on the BLURB benchmark. We only report F1 due to unavailability of precision and recall of these submissions. The major difference among these submissions are encoders. A direct comparison can be made between our method and Gu et al. (2021) which formulates NER as a sequential labeling task and fine-tunes a standard $\mathrm { L S T M + C R F }$ classifier on top of the pretrained transformer encoder. While both using PubMedBERT as the encoder, our method significantly outperforms Gu et al. (2021) across the board. Compared to the previous best submissions (Kanakarajan et al., 2021; Yasunaga et al., 2022), our method also show substantial gains on BC5-chem $( + 1 . 2 \% )$ , BC5-disease $( + 1 . 9 \% )$ , and NCBI $( 1 . 5 \% )$ .
Table 1: Test scores on three nested NER datasets. Bold-and-underline, bold-only and underline-only indicate the best, the second best, and the third best respectively. The different encoders are used: $\mathrm { L } = \mathrm { L S T M }$ , $\mathbf { B l } =$ BERT-large, BioB $=$ BioBERT, BioBl $=$ BioBERT-large, $\mathbf { B A l = }$ BART-large, $\mathrm { T } 5 \mathrm { b } = \mathrm { T } 5$ -base, $\mathbf { B } \mathbf { b } =$ BERT-base. $\dagger$ Original scores of Li et al. (2020) are not reproducible. Like Yan et al. (2021), we report the rerun of their released code.
<table><tr><td rowspan="2"></td><td rowspan="2">Encoder</td><td colspan="3">ACE2004</td><td colspan="3">ACE2005</td><td colspan="3">GENIA</td></tr><tr><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td><td>P</td><td>R</td><td>F1</td></tr><tr><td>Lu & Roth (2015)</td><td>-</td><td>70.0</td><td>56.9</td><td>62.8</td><td>66.3</td><td>59.2</td><td>62.5</td><td>74.2</td><td>66.7</td><td>70.3</td></tr><tr><td>Katiyar & Cardie (2018)</td><td>L</td><td>73.6</td><td>71.8</td><td>72.7</td><td>70.6</td><td>70.4</td><td>70.5</td><td>77.7</td><td>71.8</td><td>74.6</td></tr><tr><td>Shibuya & Hovy (2020)</td><td>B1</td><td>83.7</td><td>81.9</td><td>82.8</td><td>83.0</td><td>82.4</td><td>82.7</td><td>78.1</td><td>76.5</td><td>77.3</td></tr><tr><td>Wang et al. (2020)</td><td>Bl/BioB</td><td>86.1</td><td>86.5</td><td>86.3</td><td>84.0</td><td>85.4</td><td>84.7</td><td>79.5</td><td>78.9</td><td>79.2</td></tr><tr><td>Li et al. (2020)t</td><td>Bl/BioB</td><td>85.8</td><td>85.8</td><td>85.8</td><td>85.0</td><td>84.1</td><td>84.6</td><td>81.2</td><td>76.4</td><td>78.7</td></tr><tr><td>Yu et al. (2020)</td><td>Bl/BioB</td><td>87.3</td><td>86.0</td><td>86.7</td><td>85.2</td><td>85.6</td><td>85.4</td><td>81.8</td><td>79.3</td><td>80.5</td></tr><tr><td>Tan et al. (2021)</td><td>Bl/BioB</td><td>88.5</td><td>86.1</td><td>87.3</td><td>87.5</td><td>86.6</td><td>87.1</td><td>82.3</td><td>78.7</td><td>80.4</td></tr><tr><td>Yan et al. (2021)</td><td>BAl</td><td>87.3</td><td>86.4</td><td>86.8</td><td>83.2</td><td>86.4</td><td>84.7</td><td>78.6</td><td>79.3</td><td>78.9</td></tr><tr><td>Zhang et al. (2022)</td><td>T5b</td><td>86.5</td><td>84.5</td><td>85.4</td><td>83.3</td><td>86.6</td><td>84.9</td><td>81.0</td><td>77.2</td><td>79.1</td></tr><tr><td>Wan et al. (2022)</td><td>Bb</td><td>86.7</td><td>85.9</td><td>86.3</td><td>84.4</td><td>85.9</td><td>85.1</td><td>77.9</td><td>80.7</td><td>79.3</td></tr><tr><td rowspan="2">BINDER (Ours)</td><td>Bb/BioB</td><td>88.3</td><td>89.1</td><td>88.7</td><td>89.1</td><td>89.8</td><td>89.5</td><td>81.5</td><td>79.6</td><td>80.5</td></tr><tr><td>Bl/BioBl</td><td>89.7</td><td>89.7</td><td>89.7</td><td>89.6</td><td>90.5</td><td>90.0</td><td>83.4</td><td>78.3</td><td>80.8</td></tr></table>
Table 2: Test F1 scores on five flat NER datasets from the BLURB benchmark (aka.ms/blurb). Bold and underline indicate the best and the second best respectively. All encoders use their base version.
<table><tr><td></td><td>Encoder</td><td>BC5-chem</td><td>BC5-disease</td><td>NCBI</td><td>BC2GM</td><td> JNLPBA</td></tr><tr><td>Lee et al. (2019)</td><td>BioBERT</td><td>92.9</td><td>84.7</td><td>89.1</td><td>83.8</td><td>78.6</td></tr><tr><td>Gu et al. (2021)</td><td>PubMedBERT</td><td>93.3</td><td>85.6</td><td>87.8</td><td>84.5</td><td>79.1</td></tr><tr><td>Kanakarajan et al. (2021)</td><td>BioELECTRA</td><td>93.6</td><td>85.8</td><td>89.4</td><td>84.7</td><td>80.2</td></tr><tr><td>Yasunaga et al. (2022)</td><td>LinkBERT</td><td>93.8</td><td>86.1</td><td>88.2</td><td>84.9</td><td>79.0</td></tr><tr><td>BINDER (Ours)</td><td>PubMedBERT</td><td>95.0</td><td>88.0</td><td>90.9</td><td>84.6</td><td>80.3</td></tr></table>
Distantly Supervised NER Results Table 3 compares test scores of our method and previous methods on BC5CDR. It presents a clear advantage of our method over all previous methods in the distantly supervised setting. The F1 score is advanced by $+ 1 . 5 \%$ over the previous best method (Zhou et al., 2022), which adapts positive and unlabeled (PU) learning to obtain a high recall yet at the loss of precision. In contrast, our method maintains a reasonable recall (comparable to Shang et al., 2018; Peng et al., 2019) and substantially improves the precision. Note that besides the dictionary used to generate distant supervisions, Zhou et al. (2022); Shang et al. (2018) require an additional high-quality dictionary to estimate the noisiness of non-entity spans. Our method does not have such a requirement. For reference, Table 2 also includes the supervised state of the art. Our method in the supervised setting achieves $9 1 . 9 \%$ F1, outperforming the previous SOTA Wang et al. (2021) by $1 . 0 \%$ . Comparing both settings, we observe that the distantly supervised result still has an over-10-point gap with the supervised one, indicating a potential to further reduce the false negative noise.
Table 3: Test scores on BC5CDR. All baselines scores in the distantly supervised setting are quoted from Zhou et al. (2022).
<table><tr><td rowspan="2"></td><td colspan="3">BC5CDR</td></tr><tr><td>P</td><td>R</td><td>F1</td></tr><tr><td colspan="4">Distantly Supervised</td></tr><tr><td>Dict/KB Matching AutoNER (Shang et al., 2018)</td><td>86.4 82.6</td><td>51.2 77.5</td><td>64.3 80.0</td></tr><tr><td>BNPU (Peng et al.,2019)</td><td>48.1</td><td>77.1</td><td>59.2</td></tr><tr><td>BERT-ES (Liang et al.,2020)</td><td>80.4</td><td>67.9</td><td>73.7</td></tr><tr><td>Conf-MPU (Zhou et al., 2022)</td><td>76.6</td><td>83.8</td><td>80.1</td></tr><tr><td>BINDER (Ours)</td><td>87.6</td><td>76.3</td><td>81.6</td></tr><tr><td colspan="4">Fully Supervised</td></tr><tr><td>Nooralahzadeh et al. (2019)</td><td>92.1</td><td>87.9</td><td>89.9</td></tr><tr><td>Wang et al. (2021)</td><td>-</td><td>-</td><td>90.9</td></tr><tr><td>BINDER (Ours)</td><td>92.6</td><td>91.2</td><td>91.9</td></tr></table>
# 4 ANALYSIS
Here we conduct extensive analyses of our method. For efficiency, all analysis in this section is done based on the uncased BERT-base encoder.
Ablation Study We compare several variants of our method and report their test scores on ACE2005 in Table 4. We observe performance degradation in all these variants. Shared linear layers uses the same linear layer for span and token embeddings, and the same linear layer for entity type embeddings, in the hope of projecting them into the same vector space and sharing their semantics. It leads to a slightly better precision but a drop of recall. Similar changes are observed in Joint position-span inference, which adopts a more stringent strategy to prune out spans β only keep spans whose start, end, and span scores are all above the thresholds. No position-based objectives only optimizes the span-based objective, which penalizes partially corrected spans in the same way as other spans, resulting in a marginal improvement of recall but a significant loss of precision.
Choices of Entity Type Descriptions Table 5 compares different choices of entity type descriptions. Our final model uses annotation guidelines, which outperforms other choices: (1) Atomic labels considers each entity type as an atomic label. Instead of learning an entity type encoder, we directly learn an embedding vector for each entity type. (2) Keywords uses a keyword for each entity type as the input to the entity type encoder, e.g., βpersonβ for PER. (3) Prototypical instances for each minibatch during training dynamically samples from the training data a prototypical instance for each entity type and uses it as input to the entity type encoder. Unlike annotation guidelines, we add special markers to indicate the start and end of an entity span and use the hidden states of the start marker as entity type embeddings. At test time, we increase the number of prototypical instances to three for each entity type. Larger number of prototypical instances may improve the performance. Prototypical instances may also lead to a better performance in few-shot or zero-shot settings. We leave them to future exploration.
Table 4: Test scores of our method and its variants on ACE2005.
<table><tr><td rowspan="2"></td><td colspan="3">ACE2005</td></tr><tr><td>P</td><td>R</td><td>F1</td></tr><tr><td>Our full model</td><td>89.1</td><td>89.8</td><td>89.5</td></tr><tr><td>Shared linear layers</td><td>89.3</td><td>89.3</td><td>89.3</td></tr><tr><td>Joint position-span inference</td><td>89.4</td><td>89.2</td><td>89.3</td></tr><tr><td>No position-based objectives</td><td>88.7</td><td>89.9</td><td>89.3</td></tr></table>
Table 5: Test scores on ACE2005 with different entity type descriptions.
<table><tr><td rowspan="2"></td><td colspan="3">ACE2005</td></tr><tr><td>P</td><td>R</td><td>F1</td></tr><tr><td>Atomic labels</td><td>88.9</td><td>89.6</td><td>89.2</td></tr><tr><td>Keywords</td><td>88.7</td><td>89.8</td><td>89.2</td></tr><tr><td>Prototypical instances</td><td>88.7</td><td>90.1</td><td>89.4</td></tr><tr><td>Annotation guidelines</td><td>89.1</td><td>89.8</td><td>89.5</td></tr></table>
Thresholding Strategies Our method uses dynamic similarity thresholds to distinguish entity spans from non-entity spans. We compare the impact of dynamic thresholds in our method with two straightforward variants: (1) Learned global thresholds replaces dynamic thresholds with global thresholds, one for each entity type. Specifically, we consider the global similarity thresholds as scalar parameters (initialized as 0). During training, we replace the similarity function outputs $\mathrm { s i m } \big ( \mathbf { u } _ { \mathrm { [ C L S ] } } , \mathbf { e } _ { k } ^ { \mathrm { B } } \big )$ in Equation 8 and $\sin ( \mathbf { s } _ { 0 , 0 } , \mathbf { e } _ { k } )$ in Equation 9 with the corresponding global thresholds. At test times, the global thresholds are used to separate entity spans from non-entity spans. (2) Global thresholds tuned on dev introduces global thresholds after the training is done and tune them on the development set. During training, instead of Equation 10, we optimize a simplified loss without thresholding, $\alpha \ell _ { \mathrm { s t a r t } } + \gamma \ell _ { \mathrm { e n d } } + \lambda \ell _ { \mathrm { j o i n t } }$ . Table 6 compares their test scores on the ACE2005 dataset. Dynamic thresholds have the best scores overall. Learned global thresholds performs better than global thresholds tuned on the development set, indicating the necessity of learning thresholds during training. Note that the global thresholds tuned on dev still outperforms all the previous methods in Table 1, showing a clear advantage of our bi-encoder framework. In Appendix A.7, We further visualize and discuss the distribution of similarity scores between text spans and entity types based on different thresholding strategies.
Time Efficiency Table 7 compares the training and inference speed of our method against several prominent methods. To ensure fair comparisons, all speed numbers are recorded based on the same machine using their released code with the same batch size and the same maximum sequence length.
MRC-NER (Li et al., 2020) formulates NER as a machine reading comprehension problem and employs a cross-attention encoder. Comparing with it, our bi-encoder framework has $1 7 \mathrm { x }$ and $8 \mathbf { { X } }$ speed on training and inference respectively. Biaffine-NER (Yu et al., 2020) formulates NER as a dependency parsing problem and applies a biaffine classifier to classify the typed arc between an entity span start and end. Comparing with it, our framework does not need a biaffine layer and is $1 . 7 \mathrm { x }$ and 2.4x faster at training and inference. Without the need of conditional random fields (CRFs), our framework is even faster than the widely used BERT-CRF framework. A drawback of BERT-CRF is that it cannot be applied to nested NER. Here we test it on a flat NER dataset CoNLL2003 (Tjong Kim Sang & De Meulder, 2003). All other frameworks are tested on ACE2005.
<table><tr><td></td><td colspan="3">ACE2005</td></tr><tr><td></td><td>P</td><td>R</td><td>F1</td></tr><tr><td>Dynamic thresholds</td><td>89.1</td><td>89.8</td><td>89.5</td></tr><tr><td>Learned global thresholds</td><td>88.2</td><td>89.0</td><td>88.6</td></tr><tr><td>Global thresholds tuned on dev</td><td>86.3</td><td>88.7</td><td>87.5</td></tr></table>
Table 6: Test scores of our method using different thresholding strategies on ACE2005. Table 7: Training and inference speed.
<table><tr><td></td><td colspan="2">Speed (w/s)</td></tr><tr><td></td><td>Training</td><td>Inference</td></tr><tr><td>MRC-NER (Li et al., 2020)</td><td>147</td><td>1,110</td></tr><tr><td>Biaffine-NER(Yu et al.,2020)</td><td>1,548</td><td>3,634</td></tr><tr><td>BERT-CRF (pytorch_neural_crf)</td><td>2,273</td><td>8,596</td></tr><tr><td>BINDER (Ours)</td><td>2,571</td><td>8,886</td></tr></table>
Table 8: Test F1 score breakdowns on ACE2005 and GENIA. Columns compare F1 scores on different entity types. Rows compare F1 scores based on the entire entity span, or only the start or end of entity span. S-F1 denotes the strict F1 requiring the exact boundary match. L-F1 denotes the loose F1 allowing partial overlaps. The color signifies substantially better F1 scores than the corresponding entity span strict F1 scores.
<table><tr><td rowspan="2"></td><td colspan="8">ACE2005</td><td colspan="6">GENIA</td></tr><tr><td>PER</td><td>GPE</td><td>ORG</td><td>FAC</td><td>LOC</td><td>VEH</td><td>WEA</td><td>ALL</td><td>Prot.</td><td>DNA</td><td>CellT.</td><td>CelIL.</td><td>RNA</td><td>ALL</td></tr><tr><td>S-F1span</td><td>93.4</td><td>91.2</td><td>79.7</td><td>81.0</td><td>78.7</td><td>84.8</td><td>82.1</td><td>89.5</td><td>82.9</td><td>77.6</td><td>74.5</td><td>76.3</td><td>87.9</td><td>80.5</td></tr><tr><td>S-F1start</td><td>93.9</td><td>91.2</td><td>80.7</td><td>81.0</td><td>79.0</td><td>84.8</td><td>82.1</td><td>89.9</td><td>86.1</td><td>80.9</td><td>74.5</td><td>80.2</td><td>88.7</td><td>83.2</td></tr><tr><td>S-F1end</td><td>93.9</td><td>91.2</td><td>81.9</td><td>83.1</td><td>79.0</td><td>86.8</td><td>82.1</td><td>90.3</td><td>87.6</td><td>82.6</td><td>83.7</td><td>82.8</td><td>91.0</td><td>85.8</td></tr><tr><td>L-F1span</td><td>94.4</td><td>91.4</td><td>83.0</td><td>83.1</td><td>79.4</td><td>87.2</td><td>82.1</td><td>90.8</td><td>91.6</td><td>87.4</td><td>84.8</td><td>87.2</td><td>91.7</td><td>89.9</td></tr></table>
Performance Breakdown Table 8 shows the test F1 scores on each entity type of ACE2005 and GENIA. We report four types of F1 scores: $\mathrm { S - F 1 _ { \mathrm { s p a n } } }$ is the strict F1 based on the exact match of entity spans; $\mathrm { S } { \mathrm { - F } } 1 _ { \mathrm { s t a r t } }$ is the strict F1 based on the exact match of entity start words; $\mathrm { S - F 1 _ { e n d } }$ is the strict F1 based on the exact match of entity end words; $\mathrm { L } { \mathrm { - F } } 1 _ { \mathrm { s p a n } }$ is the loose F1 allowing the partial match of entity spans. We notice that $\mathrm { S - F 1 _ { e n d } }$ is often substantially better than $\mathrm { S - F 1 _ { \mathrm { s p a n } } }$ and $\mathrm { \bf S } { - } \mathrm { \bf F } 1 _ { \mathrm { s t a r t } }$ To explain this difference, we go through these partially corrected predictions and summarize the common errors in Table 9. The most common one is the inclusion or exclusion of modifiers. This could be due to annotation disagreement: in ACE2005, sometimes generic spans are preferred (e.g., βtomcatsβ vs. βf-14 tomcatsβ), while in some cases specific spans are preferred (e.g., βcruise shipβ vs. βshipβ). This issue is more common in the biomedical dataset GENIA, e.g., βhuman GRβ is considered
Table 9: Examples of common errors among the partially corrected predictions. Red indicates error spans. Blue indicates missing spans. The number after each span mean the span frequency in the training data.
<table><tr><td>Error Type</td><td>Ent. Type</td><td>Predicted βGold</td></tr><tr><td rowspan="2">Modifier Error</td><td>VEH FAC VEH CellL. Prot.</td><td>f-14 tomcats (O) ββ tomcats (0) federal court (O) ββcourt (0) ship (29) ββcruise ship (1) unstimulated Tcells (O) ββTcells (553)</td></tr><tr><td>CellT.</td><td>human GR(O)βGR(88) lymphocytes(117) ββ human lympho- cytes (18)</td></tr><tr><td>Missing Genitive</td><td>PER</td><td>E6 motif (O) ββ synthetic E6 motif (0) attendant (3) ββattendant's (0)</td></tr><tr><td rowspan="5">Annotation Error</td><td>PER</td><td>Dr.Germ (O) ββDr(1)/Germ (0)</td></tr><tr><td>Prot.</td><td>Ag amino acid sequence (O) ββAg (1)/ amino acid sequence (6)</td></tr><tr><td>CellL.</td><td>EBV-transformed human B cell line SKW6.4(O) ββEBV-transformed hu-</td></tr><tr><td>DNA</td><td>man B cell line (O)/SKW6.4 (1) second-site LTR revertants (0) β second-site LTR (O)</td></tr></table>
as wrong while βhuman lymphocytesβ are correct, which explains the higher scores of $\mathrm { S - F 1 _ { e n d } }$ than $\mathrm { S } { \mathrm { - F } } 1 _ { \mathrm { s t a r t } }$ . Missing genitives for person names are another common errors in ACE2005. We also discover some annotation errors, where names of a single person, protein, or cell line are sometimes broken into two less meaningful spans, e.g., βDr. Germβ is annotated as two person mentions βDrβ
and βGermβ, and βEBV-transformed human B cell line SKW6.4β is annotated as two separate cell lines βEBV-transformed human B cell lineβ and βSKW6.4β.
# 5 RELATED WORK
Supervised NER Early techniques for NER are based on hidden markov models (e.g., Zhou & Su, 2002) and conditional random fields (CRFs) (e.g., McDonald & Pereira 2005). However, due to the inability to handle nested named entities, techniques such as cascaded CRFs (Alex et al., 2007), adpated constituency parsing (Finkel & Manning, 2009), and hypergraphs (Lu & Roth, 2015) are developed for nested NER. More recently, with the advance in deep learning, a myriad of new techniques have been used in supervised NER. Depending on the way they formulate the task, these techniques can be categorized as NER as sequence labeling (Chiu & Nichols, 2016; Ma & Hovy, 2016; Katiyar & Cardie, 2018); NER as parsing (Lample et al., 2016; Yu et al., 2020); NER as span classification (Sohrab & Miwa, 2018; Xia et al., 2019; Ouchi et al., 2020; Fu et al., 2021); NER as a sequence-to-sequence problem (Strakova et al., 2019; Yan et al., 2021); and NER as machine Β΄ reading comprehension (Li et al., 2020; Mengge et al., 2020). Unlike previous work, we formulate NER as a contrastive learning problem. The span-based design of our bi-encoder and contrastive loss provides us with the flexibility to handle both nested and flat NER.
Distantly Supervised NER Distant supervision from external knowledge bases in conjunction with unlabeled text is generated by string matching (Giannakopoulos et al., 2017) or heuristic rules (Ren et al., 2015; Fries et al., 2017). Due to the limited coverage of external knowledge bases, distant supervision often has a high false negative rate. To alleviate this issue, Shang et al. (2018) design a new tagging scheme with an unknown tag specifically for false negatives; Mayhew et al. (2019) iteratively detect false negatives and downweigh them in training; Peng et al. (2019); Zhou et al. (2022) address overfitting to false negatives using Positive and Unlabeled (PU) learning; Zhang et al. (2021b) identify dictionary biases via a structural causal model, and de-bias them using causal interventions. Liu et al. (2021) introduce a calibrated confidence estimation method and integrate it into a self-training framework. Without replying on sophisticated de-noising designs, our bi-encoder framework can be directly used in distant supervision. Experiments in $\ S 3$ show the robustness of our contrastive learning algorithm to the noise in distantly supervised NER.
Bi-Encoder The use of bi-encoder dates back to Bromley et al. (1993) for signature verification and Chopra et al. (2005) for face verification. These works and their descendants (e.g., Yih et al., 2011; Hu et al., 2014) refer to the architecture as siamese networks since two similar inputs are encoded separately by two copies of the same network (all parameters are shared). Wsabie (Weston et al., 2010) and StarSpace (Wu et al., 2018) subsequently employ bi-encoder to learn embeddings for different data types. Using deep pretrained transformers as encoders, Humeau et al. (2019) compare three different architectures, bi-encoder, poly-encoder, and cross-encoder. The bi-encoder architecture afterwards has been use in various tasks, e.g., information retrieval (Huang et al., 2013; Gillick et al., 2018), open-domain question answering (Karpukhin et al., 2020), and entity linking (Gillick et al., 2019; Wu et al., 2020; Zhang et al., 2021a). To our best knowledge, there is no previous work learning bi-encoder for NER.
# 6 CONCLUSIONS
We present a bi-encoder framework for NER using contrastive learning, which separately maps text and entity types into the same vector space. To separate entity spans from non-entity ones, we introduce a novel contrastive loss to jointly learn span identification and entity classification. Experiments in both supervised and distantly supervised settings show the effectiveness and robustness of our method. We conduct extensive analysis to explain the success of our method and reveal growth opportunities. Future directions include further improving low-performing types and applications in self-supervised zero-shot settings.
# REFERENCES
Beatrice Alex, Barry Haddow, and Claire Grover. Recognising nested named entities in biomedical text. In Biological, translational, and clinical language processing, pp. 65β72, Prague, Czech Republic, June 2007. Association for Computational Linguistics. URL https:// aclanthology.org/W07-1009.
Rami Aly, Andreas Vlachos, and Ryan McDonald. Leveraging type descriptions for zero-shot named entity recognition and classification. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 1516β1528, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.120. URL https: //aclanthology.org/2021.acl-long.120.
Jane Bromley, Isabelle Guyon, Yann LeCun, Eduard Sackinger, and Roopak Shah. Signature verifi- Β¨ cation using aβ siameseβ time delay neural network. Advances in neural information processing systems, 6, 1993.
Kai-Wei Chang, Rajhans Samdani, and Dan Roth. A constrained latent variable model for coreference resolution. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pp. 601β612, Seattle, Washington, USA, October 2013. Association for Computational Linguistics. URL https://aclanthology.org/D13-1057.
Jason P.C. Chiu and Eric Nichols. Named entity recognition with bidirectional LSTM-CNNs. Transactions of the Association for Computational Linguistics, 4:357β370, 2016. doi: 10.1162/ tacl a 00104. URL https://aclanthology.org/Q16-1026.
Yejin Choi, Eric Breck, and Claire Cardie. Joint extraction of entities and relations for opinion recognition. In Proceedings of the 2006 Conference on Empirical Methods in Natural Language Processing, pp. 431β439, Sydney, Australia, July 2006. Association for Computational Linguistics. URL https://aclanthology.org/W06-1651.
Sumit Chopra, Raia Hadsell, and Yann LeCun. Learning a similarity metric discriminatively, with application to face verification. In 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPRβ05), volume 1, pp. 539β546. IEEE, 2005.
Nigel Collier and Jin-Dong Kim. Introduction to the bio-entity recognition task at JNLPBA. In Proceedings of the International Joint Workshop on Natural Language Processing in Biomedicine and its Applications (NLPBA/BioNLP), pp. 73β78, Geneva, Switzerland, August 28th and 29th 2004. COLING. URL https://aclanthology.org/W04-1213.
Leyang Cui, Yu Wu, Jian Liu, Sen Yang, and Yue Zhang. Template-based named entity recognition using BART. In Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pp. 1835β1845, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/ v1/2021.findings-acl.161. URL https://aclanthology.org/2021.findings-acl. 161.
Sarkar Snigdha Sarathi Das, Arzoo Katiyar, Rebecca Passonneau, and Rui Zhang. CONTaiNER: Few-shot named entity recognition via contrastive learning. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 6338β 6353, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/ 2022.acl-long.439. URL https://aclanthology.org/2022.acl-long.439.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171β4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https: //aclanthology.org/N19-1423.
Ning Ding, Yulin Chen, Xu Han, Guangwei Xu, Pengjun Xie, Hai-Tao Zheng, Zhiyuan Liu, Juanzi Li, and Hong-Gee Kim. Prompt-learning for fine-grained entity typing. arXiv preprint arXiv:2108.10604, 2021.
Rezarta Islamaj Dogan, Robert Leaman, and Zhiyong Lu. Special report: Ncbi disease corpus: A Λ resource for disease name recognition and concept normalization. J. of Biomedical Informatics, 47:1β10, feb 2014. ISSN 1532-0464.
Gamaleldin Elsayed, Dilip Krishnan, Hossein Mobahi, Kevin Regan, and Samy Bengio. Large margin deep networks for classification. Advances in neural information processing systems, 31, 2018.
Jenny Rose Finkel and Christopher D. Manning. Nested named entity recognition. In Proceedings of the 2009 Conference on Empirical Methods in Natural Language Processing, pp. 141β150, Singapore, August 2009. Association for Computational Linguistics. URL https: //aclanthology.org/D09-1015.
Jason Fries, Sen Wu, Alex Ratner, and Christopher Re. Swellshark: A generative model for biomed-Β΄ ical named entity recognition without labeled data. arXiv preprint arXiv:1704.06360, 2017.
Jinlan Fu, Xuanjing Huang, and Pengfei Liu. SpanNER: Named entity re-/recognition as span prediction. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 7183β7195, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.558. URL https://aclanthology.org/2021. acl-long.558.
Athanasios Giannakopoulos, Claudiu Musat, Andreea Hossmann, and Michael Baeriswyl. Unsupervised aspect term extraction with B-LSTM & CRF using automatically labelled datasets. In Proceedings of the 8th Workshop on Computational Approaches to Subjectivity, Sentiment and Social Media Analysis, pp. 180β188, Copenhagen, Denmark, September 2017. Association for Computational Linguistics. doi: 10.18653/v1/W17-5224. URL https://aclanthology. org/W17-5224.
Daniel Gillick, Alessandro Presta, and Gaurav Singh Tomar. End-to-end retrieval in continuous space. arXiv preprint arXiv:1811.08008, 2018.
Daniel Gillick, Sayali Kulkarni, Larry Lansing, Alessandro Presta, Jason Baldridge, Eugene Ie, and Diego Garcia-Olano. Learning dense representations for entity retrieval. In Proceedings of the 23rd Conference on Computational Natural Language Learning (CoNLL), pp. 528β537, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/ K19-1049. URL https://aclanthology.org/K19-1049.
Yu Gu, Robert Tinn, Hao Cheng, Michael Lucas, Naoto Usuyama, Xiaodong Liu, Tristan Naumann, Jianfeng Gao, and Hoifung Poon. Domain-specific language model pretraining for biomedical natural language processing. ACM Transactions on Computing for Healthcare (HEALTH), 3(1): 1β23, 2021.
Tao Gui, Jiacheng Ye, Qi Zhang, Zhengyan Li, Zichu Fei, Yeyun Gong, and Xuanjing Huang. Uncertainty-aware label refinement for sequence labeling. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 2316β2326, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main. 181. URL https://aclanthology.org/2020.emnlp-main.181.
Baotian Hu, Zhengdong Lu, Hang Li, and Qingcai Chen. Convolutional neural network architectures for matching natural language sentences. Advances in neural information processing systems, 27, 2014.
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 Proceedings of the 22nd ACM International Conference on Information & Knowledge Management, CIKM β13, pp. 2333β2338, New York, NY, USA, 2013. Association for Computing Machinery. ISBN 9781450322638. doi: 10.1145/2505515.2505665. URL https://doi.org/10.1145/ 2505515.2505665.
Samuel Humeau, Kurt Shuster, Marie-Anne Lachaux, and Jason Weston. Poly-encoders: Architectures and pre-training strategies for fast and accurate multi-sentence scoring. In International Conference on Learning Representations, 2019.
Kamal raj Kanakarajan, Bhuvana Kundumani, and Malaikannan Sankarasubbu. BioELECTRA:pretrained biomedical text encoder using discriminators. In Proceedings of the 20th Workshop on Biomedical Language Processing, pp. 143β154, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.bionlp-1.16. URL https://aclanthology. org/2021.bionlp-1.16.
Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis, Ledell Wu, Sergey Edunov, Danqi Chen, and Wen-tau Yih. Dense passage retrieval for open-domain question answering. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 6769β6781, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.550. URL https://aclanthology.org/2020. emnlp-main.550.
Arzoo Katiyar and Claire Cardie. Nested named entity recognition revisited. 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. 861β871, New Orleans, Louisiana, June 2018. Association for Computational Linguistics. doi: 10.18653/v1/N18-1079. URL https://aclanthology.org/N18-1079.
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.
J-D Kim, Tomoko Ohta, Yuka Tateisi, and Junβichi Tsujii. Genia corpusβa semantically annotated corpus for bio-textmining. Bioinformatics, 19(suppl 1):i180βi182, 2003.
Guillaume Lample, Miguel Ballesteros, Sandeep Subramanian, Kazuya Kawakami, and Chris Dyer. Neural architectures for named entity recognition. In Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 260β270, San Diego, California, June 2016. Association for Computational Linguistics. doi: 10.18653/v1/N16-1030. URL https://aclanthology.org/N16-1030.
Jinhyuk Lee, Wonjin Yoon, Sungdong Kim, Donghyeon Kim, Sunkyu Kim, Chan Ho So, and Jaewoo Kang. BioBERT: a pre-trained biomedical language representation model for biomedical text mining. Bioinformatics, 36(4):1234β1240, 09 2019. ISSN 1367-4803. doi: 10.1093/bioinformatics/btz682. URL https://doi.org/10.1093/bioinformatics/ btz682.
Jiao Li, Yueping Sun, Robin J Johnson, Daniela Sciaky, Chih-Hsuan Wei, Robert Leaman, Allan Peter Davis, Carolyn J Mattingly, Thomas C Wiegers, and Zhiyong Lu. Biocreative v cdr task corpus: a resource for chemical disease relation extraction. Database, 2016, 2016.
Xiaoya Li, Jingrong Feng, Yuxian Meng, Qinghong Han, Fei Wu, and Jiwei Li. A unified MRC framework for named entity recognition. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 5849β5859, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.519. URL https: //aclanthology.org/2020.acl-main.519.
Chen Liang, Yue Yu, Haoming Jiang, Siawpeng Er, Ruijia Wang, Tuo Zhao, and Chao Zhang. Bond: Bert-assisted open-domain named entity recognition with distant supervision. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, KDD β20, pp. 1054β1064, New York, NY, USA, 2020. Association for Computing Machinery. ISBN 9781450379984. doi: 10.1145/3394486.3403149. URL https: //doi.org/10.1145/3394486.3403149.
Kun Liu, Yao Fu, Chuanqi Tan, Mosha Chen, Ningyu Zhang, Songfang Huang, and Sheng Gao. Noisy-labeled NER with confidence estimation. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 3437β3445, Online, June 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.naacl-main.269. URL https://aclanthology.org/2021. naacl-main.269.
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
Wei Lu and Dan Roth. Joint mention extraction and classification with mention hypergraphs. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pp. 857β867, Lisbon, Portugal, September 2015. Association for Computational Linguistics. doi: 10.18653/v1/D15-1102. URL https://aclanthology.org/D15-1102.
Yi Luan, Luheng He, Mari Ostendorf, and Hannaneh Hajishirzi. 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, pp. 3219β3232, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi: 10.18653/ v1/D18-1360. URL https://aclanthology.org/D18-1360.
Ruotian Ma, Xin Zhou, Tao Gui, Yiding Tan, Linyang Li, Qi Zhang, and Xuanjing Huang. Templatefree prompt tuning for few-shot NER. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 5721β5732, Seattle, United States, July 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.naacl-main.420. URL https://aclanthology.org/2022. naacl-main.420.
Xuezhe Ma and Eduard Hovy. End-to-end sequence labeling via bi-directional LSTM-CNNs-CRF. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1064β1074, Berlin, Germany, August 2016. Association for Computational Linguistics. doi: 10.18653/v1/P16-1101. URL https://aclanthology.org/ P16-1101.
Stephen Mayhew, Snigdha Chaturvedi, Chen-Tse Tsai, and Dan Roth. Named entity recognition with partially annotated training data. In Proceedings of the 23rd Conference on Computational Natural Language Learning (CoNLL), pp. 645β655, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/K19-1060. URL https://aclanthology.org/K19-1060.
Ryan McDonald and Fernando Pereira. Identifying gene and protein mentions in text using conditional random fields. BMC bioinformatics, 6(1):1β7, 2005.
Xue Mengge, Bowen Yu, Zhenyu Zhang, Tingwen Liu, Yue Zhang, and Bin Wang. Coarse-toFine Pre-training for Named Entity Recognition. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 6345β6354, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.514. URL https://aclanthology.org/2020.emnlp-main.514.
Mike Mintz, Steven Bills, Rion Snow, and Daniel Jurafsky. Distant supervision for relation extraction without labeled data. In Proceedings of the Joint Conference of the 47th Annual Meeting of the ACL and the 4th International Joint Conference on Natural Language Processing of the AFNLP, pp. 1003β1011, Suntec, Singapore, August 2009. Association for Computational Linguistics. URL https://aclanthology.org/P09-1113.
David Nadeau and Satoshi Sekine. A survey of named entity recognition and classification. Lingvisticae Investigationes, 30(1):3β26, 2007.
Farhad Nooralahzadeh, Jan Tore LΓΈnning, and Lilja Γvrelid. Reinforcement-based denoising of distantly supervised NER with partial annotation. In Proceedings of the 2nd Workshop on Deep Learning Approaches for Low-Resource NLP (DeepLo 2019), pp. 225β233, Hong Kong, China, November 2019. Association for Computational Linguistics. doi: 10.18653/v1/D19-6125. URL https://aclanthology.org/D19-6125.
Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
Hiroki Ouchi, Jun Suzuki, Sosuke Kobayashi, Sho Yokoi, Tatsuki Kuribayashi, Ryuto Konno, and Kentaro Inui. Instance-based learning of span representations: A case study through named entity recognition. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 6452β6459, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.575. URL https://aclanthology.org/2020. acl-main.575.
Minlong Peng, Xiaoyu Xing, Qi Zhang, Jinlan Fu, and Xuanjing Huang. Distantly supervised named entity recognition using positive-unlabeled learning. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 2409β2419, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1231. URL https: //aclanthology.org/P19-1231.
Xiang Ren, Ahmed El-Kishky, Chi Wang, Fangbo Tao, Clare R Voss, and Jiawei Han. Clustype: Effective entity recognition and typing by relation phrase-based clustering. In Proceedings of the 21th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 995β1004. ACM, 2015.
Jingbo Shang, Liyuan Liu, Xiaotao Gu, Xiang Ren, Teng Ren, and Jiawei Han. Learning named entity tagger using domain-specific dictionary. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2054β2064, Brussels, Belgium, OctoberNovember 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1230. URL https://aclanthology.org/D18-1230.
Takashi Shibuya and Eduard Hovy. Nested Named Entity Recognition via Second-best Sequence Learning and Decoding. Transactions of the Association for Computational Linguistics, 8:605β 620, 09 2020. ISSN 2307-387X. doi: 10.1162/tacl a 00334. URL https://doi.org/10. 1162/tacl_a_00334.
Larry Smith, Lorraine K Tanabe, Cheng-Ju Kuo, I Chung, Chun-Nan Hsu, Yu-Shi Lin, Roman Klinger, Christoph M Friedrich, Kuzman Ganchev, Manabu Torii, et al. Overview of biocreative ii gene mention recognition. Genome biology, 9(2):1β19, 2008.
Mohammad Golam Sohrab and Makoto Miwa. Deep exhaustive model for nested named entity recognition. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2843β2849, Brussels, Belgium, October-November 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1309. URL https://aclanthology.org/ D18-1309.
Jana Strakova, Milan Straka, and Jan Hajic. Neural architectures for nested NER through lineariza- Β΄ tion. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 5326β5331, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1527. URL https://aclanthology.org/P19-1527.
Sainbayar Sukhbaatar, Joan Bruna, Manohar Paluri, Lubomir Bourdev, and Rob Fergus. Training convolutional networks with noisy labels. arXiv preprint arXiv:1406.2080, 2014.
Zeqi Tan, Yongliang Shen, Shuai Zhang, Weiming Lu, and Yueting Zhuang. A sequence-to-set network for nested named entity recognition. In Proceedings of the 30th International Joint Conference on Artificial Intelligence, IJCAI-21, 2021. URL https://arxiv.org/abs/ 2105.08901.
Erik F. Tjong Kim Sang and Fien De Meulder. Introduction to the CoNLL-2003 shared task: Language-independent named entity recognition. In Proceedings of the Seventh Conference on Natural Language Learning at HLT-NAACL 2003, pp. 142β147, 2003. URL https: //aclanthology.org/W03-0419.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ε ukasz Kaiser, and Illia Polosukhin. Attention is all you need. In
Proc. Advances in Neural Information Processing Systems (NeurIPS), volume 30, 2017. URL https://proceedings.neurips.cc/paper/2017/file/ 3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf.
Juncheng Wan, Dongyu Ru, Weinan Zhang, and Yong Yu. Nested named entity recognition with span-level graphs. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 892β903, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long.63. URL https: //aclanthology.org/2022.acl-long.63.
Jue Wang, Lidan Shou, Ke Chen, and Gang Chen. Pyramid: A layered model for nested named entity recognition. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 5918β5928, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.525. URL https://aclanthology.org/2020. acl-main.525.
Xinyu Wang, Yong Jiang, Nguyen Bach, Tao Wang, Zhongqiang Huang, Fei Huang, and Kewei Tu. Improving named entity recognition by external context retrieving and cooperative learning. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 1800β1812, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/ v1/2021.acl-long.142. URL https://aclanthology.org/2021.acl-long.142.
Jason Weston, Samy Bengio, and Nicolas Usunier. Large scale image annotation: learning to rank with joint word-image embeddings. Machine learning, 81(1):21β35, 2010.
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. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 38β45, Online, October 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-demos.6. URL https: //aclanthology.org/2020.emnlp-demos.6.
Ledell Wu, Adam Fisch, Sumit Chopra, Keith Adams, Antoine Bordes, and Jason Weston. Starspace: Embed all the things! In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
Ledell Wu, Fabio Petroni, Martin Josifoski, Sebastian Riedel, and Luke Zettlemoyer. Scalable zero-shot entity linking with dense entity retrieval. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 6397β6407, Online, November 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.emnlp-main.519. URL https://aclanthology.org/2020.emnlp-main.519.
Congying Xia, Chenwei Zhang, Tao Yang, Yaliang Li, Nan Du, Xian Wu, Wei Fan, Fenglong Ma, and Philip Yu. Multi-grained named entity recognition. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 1430β1440, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1138. URL https://aclanthology.org/P19-1138.
Hang Yan, Tao Gui, Junqi Dai, Qipeng Guo, Zheng Zhang, and Xipeng Qiu. A unified generative framework for various NER subtasks. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 5808β5822, Online, August 2021. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.451. URL https://aclanthology.org/2021.acl-long.451.
Jie Yang, Shuailong Liang, and Yue Zhang. Design challenges and misconceptions in neural sequence labeling. In Proceedings of the 27th International Conference on Computational Linguistics, pp. 3879β3889, Santa Fe, New Mexico, USA, August 2018. Association for Computational Linguistics. URL https://aclanthology.org/C18-1327.
Michihiro Yasunaga, Jure Leskovec, and Percy Liang. LinkBERT: Pretraining language models with document links. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 8003β8016, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long.551. URL https://aclanthology.org/2022.acl-long.551.
Wen-tau Yih, Kristina Toutanova, John C. Platt, and Christopher Meek. Learning discriminative projections for text similarity measures. In Proceedings of the Fifteenth Conference on Computational Natural Language Learning, pp. 247β256, Portland, Oregon, USA, June 2011. Association for Computational Linguistics. URL https://aclanthology.org/W11-0329.
Juntao Yu, Bernd Bohnet, and Massimo Poesio. Named entity recognition as dependency parsing. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 6470β6476, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/ 2020.acl-main.577. URL https://aclanthology.org/2020.acl-main.577.
Sheng Zhang, Hao Cheng, Shikhar Vashishth, Cliff Wong, Jinfeng Xiao, Xiaodong Liu, Tristan Naumann, Jianfeng Gao, and Hoifung Poon. Knowledge-rich self-supervised entity linking. arXiv preprint arXiv:2112.07887, 2021a.
Shuai Zhang, Yongliang Shen, Zeqi Tan, Yiquan Wu, and Weiming Lu. De-bias for generative extraction in unified NER task. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 808β818, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long.59. URL https: //aclanthology.org/2022.acl-long.59.
Wenkai Zhang, Hongyu Lin, Xianpei Han, and Le Sun. De-biasing distantly supervised named entity recognition via causal intervention. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 4803β4813, Online, August 2021b. Association for Computational Linguistics. doi: 10.18653/v1/2021.acl-long.371. URL https: //aclanthology.org/2021.acl-long.371.
Zhilu Zhang and Mert Sabuncu. Generalized cross entropy loss for training deep neural networks with noisy labels. Advances in neural information processing systems, 31, 2018.
GuoDong Zhou and Jian Su. Named entity recognition using an HMM-based chunk tagger. In Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics, pp. 473β480, Philadelphia, Pennsylvania, USA, July 2002. Association for Computational Linguistics. doi: 10.3115/1073083.1073163. URL https://aclanthology.org/P02-1060.
Kang Zhou, Yuepei Li, and Qi Li. Distantly supervised named entity recognition via confidencebased multi-class positive and unlabeled learning. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 7198β7211, Dublin, Ireland, May 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.acl-long. 498. URL https://aclanthology.org/2022.acl-long.498.
# A APPENDIX
# A.1 COMPARISON WITH PROMPT-BASED LEARNING
Prompt-based learning emerges as a powerful method in few-shot NER (Cui et al., 2021; Ma et al., 2022; Ding et al., 2021). Below, we compare BINDER with Tempalte BART (Cui et al., 2021), a representative prompt-based learning method:
Method Difference Cui et al. (2021) follows an encoder-decoder framework. Given a text span, it decodes and selects among all possible templates including none-entity templates. Their candidates are templates based on a static set of entity types. In contrast, BINDER is to given an entity type select among all possible text spans. The candidates are a dynamic set of text spans, which are different for different input documents. The size of candidates is much larger β $\mathcal { O } ( L ^ { 2 } )$ , where $L$ is the max seq length, set to 256 in our experiments.
Loss Difference Cui et al. (2021) uses cross-entropy to maximize the likelihood of gold entity type template against templates of other entity types. In comparison, BINDER uses contrastive learning, given an entity type, to maximize the similarity of gold text spans against other text spans. Instead of comparing entity types, BINDER compares all possible text spans from an input document. It captures subtleties of each text span via contrastive learning. As shown in previous work, instancebased contrastive learning has better generalization performance than cross-entropy loss (Khosla et al., 2020), due to its robustness to noisy labels (Zhang & Sabuncu, 2018; Sukhbaatar et al., 2014) and the possibility of better margins (Elsayed et al., 2018). To our best knowledge, we are the first to demonstrate BINDER with contrastive loss (among text spans) significantly cross-entropy loss (among entity types/templates), in both supervised settings (see Table 1 and Table 2) and distantly supervised settings (see Table 3).
Non-entity Handling Difference Cui et al. (2021) labels all non-entity spans with non-entity templates. This can introduce false negatives when the training data is partially annotated (Das et al., 2022; Aly et al., 2021). Our formulation allows us to avoid using an explicit non-entity class, and instead to introduce a dynamic threshold based on the input document and the entity type, to distinguish entity spans from non-entity spans. Our experiments show a clear advantage of dynamic thresholding over explicit non-entity labeling scheme.
Computational Efficiency The encoder-decoder framework used by Cui et al. (2021) has much lower computational efficiency. First, it has double parameter size compared to BINDER (which is encoder-only). Second, both its training and inference time are significantly slower than BINDER. Because the decoding process relies on cross-attention from decoder to encoder, their method has to decode all possible templates for each input document. The number of templates $N _ { \mathrm { t e m p l a t e s } } =$ $N _ { \mathrm { t e x t s p a n s } } \times N _ { \mathrm { e n t i t y t y p e s } }$ . And the overall the decoding operations are $\mathcal { O } ( N _ { \mathrm { d o c u m e n t s } } \times N _ { \mathrm { t e x t s p a n s } } \times$ $N _ { \mathrm { e n t i t y } \mathrm { t y p e s } } )$ . Furthermore, the decoding process has to be done in an autoregressive manner, which even reduces the time efficiency. In comparison, BINDER employs a bi-encoder framework. It separately encodes entity types and input documents. Encoding entity types does not rely on input documents. At test time, it only needs to encode entity types once, and then re-use them to for NER of different input documents. Encoding entity types is only $\mathcal { O } ( N _ { \mathrm { e n t i t y } \mathrm { t y p e s } } )$ , and can be done very efficiently in parallel on GPU.
Performance on CoNLL03 To make a direct comparison with Cui et al. (2021), we train and evaluate BINDER on CoNLL03 (Tjong Kim Sang & De Meulder, 2003). Table 10 reports the test results. BINDER outperforms Template BART as well as other strong baselines.
Table 10: Test scores on CoNLL03.
<table><tr><td></td><td colspan="3">CoNLL03</td></tr><tr><td></td><td>P</td><td>R</td><td>F1</td></tr><tr><td>Yang et al. (2018)</td><td></td><td>-</td><td>90.77</td></tr><tr><td>Ma & Hovy (2016)</td><td></td><td></td><td>91.21</td></tr><tr><td>Gui et al. (2020)</td><td></td><td>=</td><td>92.02</td></tr><tr><td>Template BART (Cui et al., 2021)</td><td>91.72</td><td>93.40</td><td>92.55</td></tr><tr><td>BINDER</td><td>93.08</td><td>93.57</td><td>93.33</td></tr></table>
# A.2 COMPARISON WITH SPAN-BASED NER
We highlight the difference between our method (BINDER) and span-based NER below:
Formulation Difference In span-based NER, it is to given a text span select among all entity types. The candidates are a static set of entity types, the size of which is usually small (e.g., PER, ORG, LOC, MISC). In contrast, BINDER formulates NER as given an entity type to select among all possible text spans of an input document. The candidates are a dynamic set of text spans, which are different for different input documents. The size of candidates is much larger β $\mathcal { O } ( \dot { L } ^ { 2 } )$ , where $L$ is the max seq length, set to 256 in our experiments.
Loss Difference Span-based NER uses cross-entropy to maximize the likelihood of gold entity type template against templates of other entity types. In comparison, BINDER uses contrastive learning, given an entity type, to maximize the similarity of gold text spans against other text spans. Instead of comparing entity types, BINDER compares all possible text spans from an input document. It captures subtleties of each text span via contrastive learning. As shown in previous work, instancebased contrastive learning has better generalization performance than cross-entropy loss (Khosla et al., 2020), due to its robustness to noisy labels (Zhang & Sabuncu, 2018; Sukhbaatar et al., 2014) and the possibility of better margins (Elsayed et al., 2018). To our best knowledge, we are the first to demonstrate BINDER with contrastive loss (among text spans) significantly cross-entropy loss (among entity types), in both supervised settings (see Table 1 and Table 2) and distantly supervised settings (see Table 3).
Non-entity Handling Difference Span-based NER labels all non-entity tokens or spans with the same class Outside (O). This can introduce false negatives when the training data is partially annotated (Das et al., 2022; Aly et al., 2021). Our formulation allows us to avoid using an explicit non-entity class, and instead to introduce a dynamic threshold based on the input document and the entity type, to distinguish entity spans from non-entity spans. Our experiments show a clear advantage of dynamic thresholding over traditional explicit O labeling scheme.
# A.3 IMPACT OF MAXIMUM SEQUENCE LENGTH
In our experiments, we set the maximum sequence length $L$ to 256, meaning that the number of candidate spans is $\mathcal { O } ( L ^ { 2 } )$ . Speed comparison in Table 7 is made based on $L = 2 5 6$ . We also experimented with smaller numbers of $L$ (e.g., 64, 128), which resulted in better speed but a slight performance degradation. Increasing $L$ did not bring significant gain but increased memory consumption. Therefore, in the experiments, we set $L$ to 256.
# A.4 IMPLEMENTATION DETAILS
We implement our models based on the HuggingFace Transformers library (Wolf et al., 2020). The base encoders are initialized using PubMedBERT-base-uncased (Gu et al., 2021) or BioBERT (Lee et al., 2019) for biomedical NER datasets, and BERT-base-uncased or BERT-large-uncased (Devlin et al., 2019) for NER datasets in the general domains. The linear layer output size is 128; the width embedding size is 128; the initial temperatures are 0.07. We train our models with the AdamW optimizer (Loshchilov & Hutter, 2017) of a linear scheduler and dropout of 0.1. The entity start/end/span contrastive loss weights are set to $\alpha = 0 . 2 , \gamma = 0 . 2 , \lambda = 0 . 6$ , and the same loss weights are chosen for thresholding contrastive learning. The contrastive losses for thresholding and entity are weighted equally in the final loss. For all experiments, we ignore sentence boundaries, and tokenize and split text into sequences with a stride of 16. For base encoders, we train our models for 20 epochs with a learning rate of 3e-5 and a batch size of 8 sequences with the maximum token length of $N = 1 2 8$ . For large encoders, we train our models for 40 epochs with a learning rate of 3e-5 and a batch size of 16 sequences with the maximum token length of $N = 2 5 6$ . The maximum token length for entity spans is set to 30. We use early stop with a patience of 10 in the distantly supervised setting. Validation is done at every 50 steps of training, and we adopt the models that have the best performance on the development set. We report the median score of multiple runs.
# A.5 INFERENCE FOR BINDER
As we can see in Algorithm 1, the difference between joint position-span and span-only strategies is whether line 9 is used. Also, for flat NER datasets, we further carry out a post-processing step to remove overlapping predictions (line 19 in Algorithm 1). Here, the post-processing (removeOverlap) is carried out in a greedy fashion where higher scored span predictions with earlier start and end positions are preferred.
# Algorithm 1: Inference for BINDER.
Input: $\begin{array} { r } { S = \{ ( i , j ) | i , j = 1 , \dots , N , 0 \leq j - i \leq L \} } \end{array}$ the set of spans , $\mathcal { E } = \{ E _ { 1 } , \ldots , E _ { K } \}$ the set of entity types, joint for whether using joint position-span inference, and flat for whether the inference is for flat NER. $M = \{ \}$ ; for $E _ { k } \in \mathcal { E }$ do 4 compute start/end/span threshold scores $b _ { n u l l } , e _ { n u l l } , s _ { n u l l }$ . 6 for $( i , j ) \in S$ do compute start/end/span similarity scores $b , e , s$ . 9 if joint is true and $b < b _ { n u l l }$ or $e < e _ { n u l l }$ then Continue; end 13 if $s > s _ { n u l l }$ then $M = M \cup \{ ( i , j , E _ { k } ) \}$ ; end end end 19 if flat is true then return removeOverlap $( M )$ ); end return $M$ ; Function removeOverlap $( \hat { D } )$ : $\hat { M } = \{ \}$ ; sort $\hat { D }$ by the similarity score in descending order and break the tie by ascending in start and end positions; for $( i , j , E _ { k } )$ in $\hat { D }$ do if span $( i , j )$ has no overlap in $\hat { M }$ then $\hat { M } = \hat { M } \cup \{ ( i , j , E _ { k } ) \}$ ; end end return $\hat { M }$ ;
# A.6 STATISTICS OF DATASETS
Table 11 reports the statistics of supervised NER datasets.
Table 11: The statistics of supervised NER datasets.
<table><tr><td rowspan="2">Dataset</td><td rowspan="2">|</td><td colspan="3"># Annotations</td></tr><tr><td>Train</td><td>Dev</td><td>Test</td></tr><tr><td>ACE2004</td><td>7</td><td>22,735 (5-fold)</td><td></td><td></td></tr><tr><td>ACE2005</td><td>7</td><td>26,473</td><td>6.338</td><td>5,476</td></tr><tr><td>GENIA</td><td>5</td><td>46,142</td><td>4,367</td><td>5,506</td></tr><tr><td>BC5-chem</td><td>1</td><td>5,203</td><td>5,347</td><td>5,385</td></tr><tr><td>BC5-disease</td><td>1</td><td>4,182</td><td>4,244</td><td>4,424</td></tr><tr><td>NCBI</td><td>1</td><td>5,134</td><td>787</td><td>960</td></tr><tr><td>BC2GM</td><td>1</td><td>15,197</td><td>3,061</td><td>6,325</td></tr><tr><td>JNLPBA</td><td>1</td><td>46,750</td><td>4,551</td><td>8,662</td></tr></table>
# A.7 DISTRIBUTIONS OF SIMILARITY SCORES
Figure 2 visualizes the distributions of similarity scores between different text spans and entity types based on different thresholding strategies. Consistent with the scores in Table 6, the majority of entity spans and non-entity spans are separable regardless of the thresholding strategy. This is true even when no thresholds are used during training and instead we tune global thresholds on dev.
 Figure 2: The kernel density estimation of similarity scores between different text spans (entity, non-entity, and threshold spans) and entity types (PER, ORG, GPE) on ACE2005 based on different thresholding strategies.
We zoom in the distributions in Figure 3 and observe that the learned global thresholds tend to make the similarities less separable between entity spans and non-entity spans.
 Figure 3: Zoom-in of the kernel density estimation of similarity scores in Figure 2, with the $y$ -axis density limited to (0, 0.1).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307# VideoMAE: Masked Autoencoders are Data-Efficient Learners for Self-Supervised Video Pre-Training
Zhan Tong 1,2β Yibing Song 2 Jue Wang 2 Limin Wang 1,3β 1State Key Laboratory for Novel Software Technology, Nanjing University 2Tencent AI Lab 3Shanghai AI Lab tongzhan@smail.nju.edu.cn {yibingsong.cv, arphid}@gmail.com lmwang@nju.edu.cn
# Abstract
Pre-training video transformers on extra large-scale datasets is generally required to achieve premier performance on relatively small datasets. In this paper, we show that video masked autoencoders (VideoMAE) are data-efficient learners for self-supervised video pre-training (SSVP). We are inspired by the recent ImageMAE [30] and propose customized video tube masking with an extremely high ratio. This simple design makes video reconstruction a more challenging and meaningful self-supervision task, thus encouraging extracting more effective video representations during the pre-training process. We obtain three important findings with VideoMAE: (1) An extremely high proportion of masking ratio (i.e., $9 0 \%$ to $9 5 \%$ ) still yields favorable performance for VideoMAE. The temporally redundant video content enables higher masking ratio than that of images. (2) VideoMAE achieves impressive results on very small datasets (i.e., around $3 \mathrm { k } { - } 4 \mathrm { k }$ videos) without using any extra data. This is partially ascribed to the challenging task of video reconstruction to enforce high-level structure learning. (3) VideoMAE shows that data quality is more important than data quantity for SSVP. Domain shift between pre-training and target datasets is an important factor. Notably, our VideoMAE with the vanilla ViT backbone can achieve $8 7 . 4 \%$ on Kinects-400, $7 5 . 4 \%$ on SomethingSomething V2, $9 1 . 3 \%$ on UCF101, and $6 2 . 6 \%$ on HMDB51, without using any extra data. Code is available at https://github.com/MCG-NJU/VideoMAE.
# 1 Introduction
Transformer [70] has brought significant progress in natural language processing [17, 7, 54]. The vision transformer [20] also improves a series of computer vision tasks including image classification [66, 88], object detection [8, 37], semantic segmentation [80], object tracking [13, 16], and video recognition [6, 3]. The multi-head self-attention upon linearly projected image/video tokens is capable of modeling global dependency among visual content either spatially or temporally. The inductive bias is effectively reduced via this flexible attention mechanism.
Training effective vision transformers (ViTs) typically necessitates large-scale supervised datasets. Initially, the pre-trained ViTs achieve favorable performance by using hundreds of millions of labeled images [20]. For video transformers [3, 6], they are usually derived from image-based transformers and heavily depend on the pre-trained models from large-scale image data (e.g., ImageNet [57]). Previous trials [3, 6] on training video transformers from scratch yield unsatisfied results (except for MViT [21] with a strong inductive bias). Therefore, the learned video transformers are naturally biased by image-based models, and it still remains a challenge that how to effectively and efficiently train a vanilla vision transformer on the video dataset itself without using any pre-trained model or extra image data. Moreover, the existing video datasets are relatively small compared with image datasets, which further increases the difficulty of training video transformers from scratch. Meanwhile, self-supervised learning has shown remarkable performance by using large-scale image datasets [14, 9]. The learned representations have outperformed the ones via supervised learning when being transferred to downstream tasks. It is expected that this self-supervised learning paradigm can provide a promising solution to address the challenge of training video transformers.
 Figure 1: VideoMAE performs the task of masking random cubes and reconstructing the missing ones with an asymmetric encoder-decoder architecture. Due to high redundancy and temporal correlation in videos, we present the customized design of tube masking with an extremely high ratio $90 \%$ to $9 5 \%$ ). This simple design enables us to create a more challenging and meaningful self-supervised task to make the learned representations capture more useful spatiotemporal structures.
Following the success of masked autoencoding in NLP [17] and images [30, 4], we present a new selfsupervised video pre-training (SSVP) method, termed as Video Masked Autoencoder (VideoMAE). Our VideoMAE inherits the simple pipeline of masking random cubes and reconstructing the missing ones. However, the extra time dimension of videos makes them different from images in this masked modeling. First, video frames are often densely captured, and their semantics varies slowly in time [87]. This temporal redundancy would increase the risk of recovering missing pixels from the spatiotemporal neighborhood with little high-level understanding. Furthermore, video could be viewed as the temporal evolution of static appearance, and there exists a correspondence between frames. This temporal correlation could lead to information leakage (i.e., masked spatiotemporal content re-occurrence) during reconstruction unless a specific masking strategy is considered. In this sense, for each masked cube, it is easy to find a corresponding and unmasked copy in adjacent frames. This property would make the learned models identify some βshortcutβ features that are hard to generalize to new scenarios.
To make video masked modeling more effective, in this paper, we present a customized design of tube masking with an extremely high ratio in our VideoMAE. First, due to temporal redundancy, we use an extremely high masking ratio to drop the cubes from the downsampled clips. This simple strategy not only effectively increases the pre-training performance but also greatly reduces the computational cost due to the asymmetric encoder-decoder architecture. Second, to consider temporal correlation, we devise a simple yet effective tube masking strategy, which turns out to be helpful in relieving the risk of information leakage for cubes with no or negligible motion during reconstruction. With this simple yet effective design in our VideoMAE, we are able to successfully train vanilla ViT backbones on the relatively small-scale video datasets such as Something-Something [25], UCF101 [60], and HMDB51 [34], which significantly outperform the previous state of the art under the setting without extra data. In summary, the main contribution of this paper is threefold:
β’ We present a simple but effective video masked autoencoder that unleashes the potential of vanilla vision transformer for video recognition. To the best of our knowledge, this is the first masked video pre-training framework of simply using plain ViT backbones. To relieve the information leakage issue in masked video modeling, we present the tube masking with an extremely high ratio, which brings the performance improvement to the VideoMAE. β’ Aligned with the results in NLP and Images on masked modeling, our VideoMAE demonstrates that this simple masking and reconstruction strategy provides a good solution to self-supervised video pre-training. The models pre-trained with our VideoMAE significantly outperform those trained from scratch or pre-trained with contrastive learning methods. β’ We obtain extra important findings on masked modeling that might be ignored in previous research in NLP and Images. (1) We demonstrate that VideoMAE is a data-efficient learner that could be successfully trained with only $3 . 5 \mathrm { k }$ videos. (2) Data quality is more important than quantity for SSVP when a domain shift exists between the source and target dataset.
# 2 Related Work
Video representation learning. Learning good video representations has been heavily investigated in the literature. The supervised learning methods [58, 75, 69, 10, 6] usually depend on the image backbones. The video encoder backbones are first pre-trained with image data in a supervised form. Then, these backbones are fine-tuned on the video dataset for classifying human actions. Meanwhile, some methods [67, 22, 21] directly train video backbones from videos in a supervised manner. Besides supervised learning, semi-supervised video representation learning has also been studied [59]. The representations of labeled training samples are utilized to generate supervision signals for unlabeled ones. Supervised or semi-supervised representation learning mainly uses a top-down training paradigm, which is not effective in exploring the inherent video data structure itself. Meanwhile, some multimodal contrastive learning methods [36, 42, 62] have been developed to learn video representation from noisy text supervision.
For self-supervised learning, the prior knowledge of temporal information has been widely exploited to design pretext tasks [78, 44, 82, 5] for SSVP. Recently, contrastive learning [28, 45, 29, 52, 24, 27] is popular to learn better visual representation. However these methods heavily rely on strong data augmentation and large batch size [23]. Predicting the video clip with autoencoders in pixel space has been explored for representation learning by using CNN or LSTM backbones [48, 61], or conducting video generation with autoregressive GPT [83]. Instead, our VideoMAE aims to use the simple masked autoencoder with recent ViT backbones to perform data-efficient SSVP.
Masked visual modeling. Masked visual modeling has been proposed to learn effective visual representations based on the simple pipeline of masking and reconstruction. These works mainly focus on the image domain. The early work [72] treated the masking as a noise type in denoised autoencoders [71] or inpainted missing regions with context [47] by using convolutions. iGPT [11] followed the success of GPT [7, 55] in NLP and operated a sequence of pixels for prediction. The original ViT [20] investigated the masked token prediction for self-supervised pre-training. More recently, the success of vision transformer has led to investigation of Transformer-based architectures for masked visual modeling [4, 19, 30, 79, 81, 89]. BEiT [4], BEVT [76] and VIMPAC [64] followed BERT [17] and proposed to learn visual representations from images and videos by predicting the discrete tokens [56]. MAE [30] introduced an asymmetric encoder-decoder architecture for masked image modeling. MaskFeat [79] proposed to reconstruct the HOG features of masked tokens to perform self-supervised pre-training in videos. VideoMAE is inspired by the ImageMAE and introduces specific design in implementation for SSVP. In particular, compared with previous masked video modeling [30, 76, 64], we present a simpler yet more effective video masked autoencoder by directly reconstructing the pixels. Our VideoMAE is the first masked video pre-training framework of simply using plain ViT backbones.
# 3 Proposed Method
In this section, we first revisit ImageMAE [30]. Then we analyze the characteristics of video data. Finally, we show how we explore MAE in the video data by presenting our VideoMAE.
# 3.1 Revisiting Image Masked Autoencoders
ImageMAE [30] performs the masking and reconstruction task with an asymmetric encoder-decoder architecture. The input image $I \in \mathcal { R } ^ { \mathbf { \breve { 3 } } \times H \times W }$ is first divided into regular non-overlapping patches of size $1 6 \times 1 6$ , and each patch is represented with token embedding. Then a subset of tokens are randomly masked with a high masking ratio $( 7 5 \% )$ , and only the remaining ones are fed into the transformer encoder $\Phi _ { \mathrm { e n c } }$ . Finally, a shallow decoder $\Phi _ { \mathrm { d e c } }$ is placed on top of the visible tokens from the encoder and learnable mask tokens to reconstruct the image. The loss function is mean squared error (MSE) loss between the normalized masked tokens and reconstructed ones in the pixel space:
$$\mathcal { L } = \frac { 1 } { \Omega } \sum _ { p \in \Omega } | I ( p ) - \hat { I } ( p ) | ^ { 2 } ,$$
where $p$ is the token index, $\Omega$ is the set of masked tokens, $I$ is the input image, and $\hat { I }$ is the reconstructed one.
 Figure 2: Slowness is a general prior in (a) video data [87]. This leads to two important characteristics in time: temporal redundancy and temporal correlation. Temporal redundancy makes it possible to recover pixels under an extremely high masking ratio. Temporal correlation leads to easily reconstruct the missing pixels by finding those corresponding patches in adjacent frames under plain (b) frame masking or (c) random masking. To avoid this simple task and encourage learning representative representation, we propose a (d) tube masking, where the masking map is the same for all frames.
# 3.2 Characteristics of Video Data
Compared with static images, video data contain temporal relations. We show the motivation of our VideoMAE by analyzing video characteristics.
Temporal redundancy. There are frequently captured frames in a video. The semantics vary slowly in the temporal dimension [87]. We observe that consecutive frames are highly redundant, as shown in Figure 2. This property leads to two critical issues in masked video autoencoding. First, it would be less efficient to keep the original temporal frame rate for pre-training. This would draw us to focus more on static or slow motions in our masked modeling. Second, temporal redundancy greatly dilutes motion representations. This would make the task of reconstructing missing pixels not difficult under the normal masking ratio (e.g., $50 \%$ to $7 5 \%$ ). The encoder backbone is not effective in capturing motion representations.
Temporal correlation. Videos could be viewed as the temporal extension of static appearance, and therefore there exists an inherent correspondence between adjacent frames. This temporal correlation could increase the risk of information leakage in the masking and reconstruction pipeline. In this sense, as shown in Figure 2, we can reconstruct the masked patches by finding the spatiotemporal corresponding unmasked patches in the adjacent frames under plain random masking or frame masking. In this case, it might guide the VideoMAE to learn low-level temporal correspondence rather than high-level information such as spatiotemporal reasoning over the content. To alleviate this behavior, we need to propose a new masking strategy to make the reconstruction more challenging and encourage effective learning of spatiotemporal structure representations.
# 3.3 VideoMAE
To relieve the above issues in video masked modeling, we make the customized design in our VideoMAE, and the overall pipeline is shown in Figure 1. Our VideoMAE takes the downsampled frames as inputs and uses the cube embedding to obtain video tokens. Then, we propose a simple design of tube masking with high ratio to perform MAE pre-training with an asymmetric encoderdecoder architecture. Our backbone uses the vanilla ViT with joint space-time attention.
Temporal downsampling. According to the above analysis on temporal redundancy over consecutive frames, we propose to use the strided temporal sampling strategy to perform more efficient video pre-training. Formally, one video clip consisting of $t$ consecutive frames is first randomly sampled from the original video $V$ . We then use temporal sampling to compress the clip to $T$ frames, each of which contains $H \times W \times 3$ pixels. In experiments, the stride $\tau$ is set to 4 and 2 on Kinetics and Something-Something, respectively.
Cube embedding. We adopt the joint space-time cube embedding [3, 21, 38] in our VideoMAE, where we treat each cube of size $2 \times 1 6 \times 1 6$ as one token embedding. Thus, the cube embedding layer obtains T2 Γ H16 $\begin{array} { r } { \frac { T } { 2 } \times \frac { H } { 1 6 } \times \frac { W } { 1 6 } \ 3 } \end{array}$ D tokens and maps each token to the channel dimension $D$ . This design can decrease the spatial and temporal dimension of input, which helps to alleviate the spatiotemporal redundancy in videos.
Tube masking with extremely high ratios. First, temporal redundancy is a factor affecting VideoMAE design. We find that VideoMAE is in favor of extremely high masking ratios (e.g. $90 \%$ to $9 5 \%$ ) compared with the ImageMAE. Video information density is much lower than images, and we expect a high ratio to increase the reconstruction difficulty. This high masking ratio is helpful to mitigate the information leakage during masked modeling and make masked video reconstruction a meaningful self-supervised pre-training task.
Second, temporal correlation is another factor in our VideoMAE design. We find even under the extremely high masking ratio, we can still improve the masking efficiency by proposing the temporal tube masking mechanism. Temporal tube masking enforces a mask to expand over the whole temporal axis, namely, different frames sharing the same masking map. Mathematically, the tube mask mechanism can be expressed as $\mathbb { I } [ p _ { x , y , \cdot } \in \Omega ] \sim \mathrm { B e r n o u l l i } ( \bar { \rho _ { \mathrm { m a s k } } } )$ and different time $t$ shares the same value. With this mechanism, temporal neighbors of masked cubes are always masked. So for some cubes with no or small motion (e.g., finger cube in 4th row of Figure 2 (d)), we can not find the spatiotemporal corresponding content in all frames. In this way, it would encourage our VideoMAE to reason over high-level semantics to recover these totally missing cubes. This simple strategy can alleviate the information leakage for cubes with no or negligible motion, and turns out to be effective in practice for masked video pre-training.
Backbone: joint space-time attention. Due to the high proportion of masking ratio mentioned above, only a few tokens are left as the input for the encoder. To better capture high-level spatio-temporal information in the remaining tokens, we use the vanilla ViT backbone [20] and adopt the joint space-time attention [3, 38]. Thus, all pair tokens could interact with each other in the multi-head self-attention layer [70]. The specific architecture design for the encoder and decoder is shown in supplementary materials. The quadratic complexity of the joint space-time attention mechanism is a computational bottleneck, while our design of an extremely high masking ratio alleviates this issue by only putting the unmasked tokens (e.g., $10 \%$ ) into the encoder during the pre-training phase.
# 4 Experiments
# 4.1 Datasets
We evaluate our VideoMAE on five common video datasets: Kinetics-400 [33], Something-Something V2 [25], UCF101 [60], HMDB51 [34], and AVA [26]. The Kinetics-400 contains around 240k training videos and 20k validation videos of 10s from 400 classes. The Something-Something V2 is another large-scale video dataset, having around 169k videos for training and 20k videos for validation. In contrast to Kinetics-400, this dataset contains 174 motion-centric action classes. These two large-scale video datasets focus on different visual cues for action recognition. UCF101 and HMDB51 are two relatively small video datasets, which contain around $9 . 5 \mathrm { k } / 3 . 5 \mathrm { k }$ train/val videos and $3 . 5 \mathrm { k } / 1 . 5 \mathrm { k }$ train/val videos, respectively. Compared with those large-scale video datasets, these two small datasets are more suitable for verifying the effectiveness of VideoMAE, as training large ViT models is more challenging on small datasets. Moreover, we also transfer the learned ViT models by VideoMAE to downstream action detection task. We work on AVA, a dataset for spatiotemporal localization of human actions with 211k training and $5 7 \mathrm { k }$ validation video segments. In experiments of downstream tasks, we fine-tune the pre-trained VideoMAE models on the training set and report the results on the validation set. The implementation details are described in Appendix $\ S \mathrm { ~ B ~ }$ .
# 4.2 Ablation Studies
In this subsection, we perform in-depth ablation studies on VideoMAE design with the default backbone of 16-frame ViT-B on Something-Something V2 (SSV2) and Kinetics-400 (K400). The specific architectures for the encoder and decoder are shown in Appendix $\ S \mathrm { ~ A ~ }$ . For fine-tuning, we perform TSN [75] uniform sampling on SSV2 and dense sampling [77, 22] on K400. All models share the same inference protocol, i.e., $2 \mathrm { c l i p s } \times 3$ crops on SSV2 and 5 clips $\times 3$ crops on K400.
Decoder design. The lightweight decoder is one key component of our VideoMAE. We conduct experiments with the different depths in Table 1a. Unlike in ImageMAE, a deep decoder here is important for better performance, while a shallow decoder could reduce the GPU memory consumption. We take 4 blocks for the decoder by default. The decoder width is set to half channel of the encoder (e.g., 384-d for ViT-B), following the design in the image domain.
<table><tr><td rowspan=1 colspan=3>blocks SSV2K400 GPU mem.</td></tr><tr><td rowspan=1 colspan=3>1 68.579.0 7.9G</td></tr><tr><td rowspan=1 colspan=1>2</td><td rowspan=1 colspan=1>69.279.2</td><td rowspan=1 colspan=1>10.2G</td></tr><tr><td rowspan=1 colspan=1>4</td><td rowspan=1 colspan=1>69.680.0</td><td rowspan=1 colspan=1>14.7G</td></tr><tr><td rowspan=1 colspan=1>8</td><td rowspan=1 colspan=1>69.379.7</td><td rowspan=1 colspan=1>23.7G</td></tr></table>
(a) Decoder depth. 4 blocks of decoder achieve the best tradeoff. βGPU mem.β is GPU memory during pre-training, benchmarked in one GPU with a batch size of 16.
<table><tr><td>case</td><td>ratio</td><td>SSV2</td><td>K400</td></tr><tr><td>tube</td><td>75</td><td>68.0</td><td>79.8</td></tr><tr><td>tube</td><td>90</td><td>69.6</td><td>80.0</td></tr><tr><td>random</td><td>90</td><td>68.3</td><td>79.5</td></tr><tr><td>frame</td><td>87.5*</td><td>61.5</td><td>76.5</td></tr></table>
(b) Mask sampling. We compare different masking strategies. Our proposed tube masking with an extremely high ratio works the best. $* ^ { * } 8 7 . 5 ^ { * }$ means masking 14/16 frames.
<table><tr><td>input</td><td>target</td><td>SSV2</td><td>K400</td></tr><tr><td>TΓT</td><td>center</td><td>63.0</td><td>79.3</td></tr><tr><td>TX</td><td>Tx</td><td>68.9</td><td>79.8</td></tr><tr><td>TΓT</td><td>TΓT</td><td>69.6</td><td>80.0</td></tr><tr><td>TΓT</td><td>2TΓ</td><td>69.2</td><td>80.1</td></tr></table>
(c) Reconstruction target. $T \times$ $\tau$ denotes βframes $\times$ strideβ. center denotes the center frame of the input clip. $T$ is set to 16 as default. $\tau$ is set to 2 and 4 on SSV2 and K400, respectively.
<table><tr><td rowspan=1 colspan=2>case SSV2K400fromscratch 32.668.8</td></tr><tr><td rowspan=1 colspan=2>fromscratch 32.668.8</td></tr><tr><td rowspan=1 colspan=2>ImageNet-21k sup.61.8 78.9</td></tr><tr><td></td><td rowspan=2 colspan=1>65.2 -</td></tr><tr><td rowspan=1 colspan=1>IN-21k+K400 sup.</td></tr><tr><td rowspan=1 colspan=1>VideoMAE</td><td rowspan=1 colspan=1>69.680.0</td></tr></table>
(d) Pre-training strategy. Our VideoMAE works the best without using any extra data. βsup.β is supervised training.
<table><tr><td>dataset</td><td>method SSV2</td><td>K400</td></tr><tr><td>IN-1K</td><td>ImageMAE 64.8</td><td>78.7</td></tr><tr><td>K400</td><td>VideoMAE 68.5</td><td>80.0</td></tr><tr><td>SSV2</td><td>VideoMAE 69.6</td><td>79.6</td></tr></table>
(e) Pre-training dataset. Our VideoMAE works the best when directly pre-training the models on the source datasets.
<table><tr><td>case</td><td>SSV2</td><td>K400</td></tr><tr><td>L1 loss</td><td>69.1</td><td>79.7</td></tr><tr><td>MSE loss</td><td>69.6</td><td>80.0</td></tr><tr><td>Smooth L1 loss</td><td>68.9</td><td>79.6</td></tr></table>
(f) Loss function. MSE loss works the best for the masking and reconstruction task in VideoMAE.
Table 1: Ablation experiments on Something-Something V2 and Kinetics-400. Our backbone is 16-frame vanilla ViT-B and all models are pre-trained with mask ratio $\rho { = } 9 0 \%$ for 800 epochs, and finetuned for evaluation. We perform TSN [75] uniform sampling on SSV2 and dense sampling [77, 22] on K400. All models share the same inference protocol, i.e., 2 clips $\times 3$ crops on SSV2 and 5 clips $\times 3$ crops on K400. The default choice for our model is colored in gray .
Masking strategy. We compare different masking strategies in Table 1b. When increasing the masking ratio from $7 5 \%$ to $90 \%$ for tube masking, the performance on SSV2 boosts from $6 8 . 0 \%$ to $6 9 . 6 \%$ . Then, with an extremely high ratio, we find tube masking also achieves better performance than plain random masking and frame masking. We attribute these interesting observations to the redundancy and temporal correlation in videos. The conclusion on K400 is in accord with one on SSV2. One may note that the performance gap on K400 is lower than one on SSV2. We argue that the Kinetics videos are mostly stationary and scene-related. The effect of temporal modeling is not obvious. Overall, we argue that our default designs enforce the networks to capture more useful spatiotemporal structures and therefore make VideoMAE a more challenging task, which a good self-supervised learner hunger for.
Reconstruction target. First, if we only employ the center frame as the target, the results would decrease greatly as shown in Table 1c. The sampling stride is also sensitive. The result of small sampling strid $\begin{array} { c } { { \vdots \frac { \tau } { 2 } } } \\ { { 2 T } } \end{array}$ is lower than default sampling stride $\tau$ $6 8 . 9 \%$ vs. $6 9 . 6 \%$ on SSV2). We also try to reconstruct frames from the downsampled $T$ frames, but it obtains slightly worse results on SSV2. For simplicity, we use the input downsampled clip as our default reconstruction target.
Pre-training strategy. We compare different pre-training strategies in Table 1d. Similar to previous trials [3, 6], training video transformers from scratch yields unsatisfied results on video datasets. When pre-trained on the large-scale ImageNet-21K dataset, the video transformer obtains better accuracy from $3 2 . 6 \%$ to $6 1 . 8 \%$ on SSV2 and $6 8 . 8 \%$ to $78 . 9 \%$ on K400. Using the models pre-trained on both ImageNet-21K and Kinetics further increases accuracy to $6 5 . 2 \%$ on SSV2. Our VideoMAE can effectively train a video transformer on the video dataset itself without using any extra data and achieve the best performance $6 9 . 6 \%$ on SSV2 and $8 0 . 0 \%$ on K400).
Pre-training dataset. First, we pre-train the ViT-B on ImageNet-1K for 1600 epochs, following the recipes in [30]. Then we inflate the 2D patch embedding layer to our cube embedding layer following [10] and fine-tune the model on the target video datasets. The results surpass the model trained from scratch as shown in Table 1e. We also compare the ImageMAE pre-trained model with VideoMAE models pre-trained on video datasets. We see that our VideoMAE models can achieve better performance than ImageMAE. However, when we try to transfer the pre-trained VideoMAE models to the other video datasets (e.g. from Kinetics to Something-Something), the results are slightly worse than their counterpart, which is directly pre-trained on its own target video datasets. We argue that domain shift between pre-training and target datasets could be an important issue.
dataset training data from scratch MoCo v3 VideoMAE Table 2: Comparisons with the results of previous self-supvised pre-training methods on different datasets. We take 16-frame ViT-B as the default backbone. Notably, here MoCo v3 and VideoMAE all only use the unlabelled data in the training set of each dataset for pre-training and are all fine-tuned for evaluation.
<table><tr><td>K400</td><td>240k</td><td>68.8</td><td>74.2</td><td>80.0</td></tr><tr><td>Sth-Sth V2</td><td>169k</td><td>32.6</td><td>54.2</td><td>69.6</td></tr><tr><td>UCF101</td><td>9.5k</td><td>51.4</td><td>81.7</td><td>91.3</td></tr><tr><td>HMDB51</td><td>3.5k</td><td>18.0</td><td>39.2</td><td>62.6</td></tr></table>
Table 3: Comparisons with the efficiency and effectiveness on Something-Something V2. We report the fine-tuning (ft) and linear probing (lin) accuracy $( \% )$ . The wall-clock time of pre-training is benchmarked in 64 Tesla V100 GPUs with PyTorch.
<table><tr><td>method</td><td>epoch</td><td>ft. acc.</td><td>lin. acc.</td><td>hours</td><td>speedup</td></tr><tr><td>MoCov3</td><td>300</td><td>54.2</td><td>33.7</td><td>61.7</td><td>-</td></tr><tr><td>VideoMAE</td><td>800</td><td>69.6</td><td>38.9</td><td>19.5</td><td>3.2Γ</td></tr></table>
Table 4: Comparisons with the feature transferability on smaller datasets. We take 16-frame ViT-B as the default backbone. Notably, here MoCo v3 and VideoMAE are all pre-trained on Kinetics-400 with unlabelled data in the training set. Then the pre-trained model is fine-tuned on target datasets for evaluation.
<table><tr><td>method</td><td>K400 β SSV2 K400 βUCF K400 βHMDB</td><td></td><td></td></tr><tr><td>MoCo v3</td><td>62.4</td><td>93.2</td><td>67.9</td></tr><tr><td>VideoMAE</td><td>68.5</td><td>96.1</td><td>73.3</td></tr></table>
Loss function. Table 1f contains an ablation study of loss function. We find that the MSE loss could achieve a higher result compared with the L1 loss and smooth L1 loss. Therefore, we employ the MSE loss by default.
# 4.3 Main Results and Analysis
VideoMAE: data-efficient learner. The self-supervised video pre-training (SSVP) has been extensively studied in previous works, but they mainly use the CNN-based backbones. Few works have investigated transformer-based backbone in SSVP. Therefore, to demonstrate the effectiveness of VideoMAE for transformer-based SSVP, we compare two methods implemented by ourselves: (1) training from scratch and (2) pre-training with contrastive learning (MoCo v3 [14]). For training from scratch, we carefully tune these hyper-parameters to successfully pre-train ViT-Base from the training set of the dataset. For pre-training with MoCo v3, we strictly follow the training practice in its image counterpart and carefully avoid the collapse issue.
The recognition accuracy is reported in Table 2. We see that our VideoMAE significantly outperforms other two training settings. For instance, on the largest dataset of Kinetics-400, our VideoMAE outperforms training from scratch by around $10 \%$ and MoCo v3 pre-training by around $5 \%$ . This superior performance demonstrates that masked autoencoder provides an effective pre-training mechanism for video transformers. We also see that the performance gap between our VideoMAE and the other two methods becomes larger as the training set becomes smaller. Notably, even with only $3 . 5 \mathrm { k }$ training clips on HMDB51, our VideoMAE pre-training can still obtain a satisfying accuracy (around $6 1 \%$ ). This new result demonstrates that VideoMAE is a more data-efficient learner for SSVP. This property is particularly important for scenarios with limited data available and different with contrastive learning methods.
We compare the efficiency of VideoMAE pre-training and MoCo v3 pre-training in Table 3. The task of masked autoencoding with a high ratio is more challenging and thereby requires more training epochs (800 vs. 300). Thanks to the asymmetric encoder-decoder in our VideoMAE and extremely high masking ratio, our pre-training time is much shorter than MoCo v3 (19.5 vs. 61.7 hours).
High masking ratio. In VideoMAE, one core design is the extremely high masking ratio. We perform an investigation of this design on the Kinetics-400 and Something-Something V2 datasets. The results are shown in Figure 3. We see that the best masking ratio is extremely high, and even $9 5 \%$ can achieve good performance for both datasets. This result is difference from BERT [17] in NLP and MAE [30] in images. We analyze the temporal redundancy and correlation in videos makes it possible for our VideoMAE to learn plausible outputs with such a high masking ratio.

 Figure 3: The effect of masking ratio Figure 4: Data efficiency of VideoMAE representations. on (a) Something-Something V2 and (b) Our default backbone is 16-frame vanilla ViT-B. β’ denotes Kinetics-400. We take 16-frame vanilla that all models are trained for the same 132k iterations, ViT-B as default. The results show that and $0$ denotes that all models are trained for the same 800 an extremely high masking ratio $( 9 0 \% )$ epochs. Note that it takes 132k iterations to pre-train the achieves the best efficiency and effective- model for 800 epochs on the full training set of Somethingness trade-off on both video datasets. Something V2.
We also visualize the reconstructed examples in Appendix $\ S { s e }$ . We see that even under an extremely high masking ratio, VideoMAE can produce satisfying reconstructed results. This implies VideoMAE is able to learn useful representations that capture the holistic spatiotemporal structure in videos.
Transfer learning: quality vs. quantity. To further investigate the generalization ability of VideoMAE in representation learning, we transfer the learned VideoMAE from Kinetics-400 to Something-Something V2, UCF101, and HMDB51. The results are shown in Table 4, and we compare them with MoCo v3 pre-training. The models pre-trained by VideoMAE are better than those pre-trained by MoCo v3, demonstrating that our VideoMAE learns more transferable representations.
Comparing Table 2 and Table 4, the transferred representation outperforms the original VideoMAE models trained from its own dataset on UCF101 and HMDB51. In contrast, the transferred representation is worse on Something-Something V2. To figure out whether this inconsistent result is caused by the large scale of Something-Something V2, we further perform a detailed investigation by decreasing the pre-training video numbers. In this study, we run two experiments: (1) pre-training with the same epochs and (2) pre-training with the same time budget. The result is shown in Figure 4. We see that more training iterations could contribute to better performance when we decrease the size of the pre-training set. Surprisingly, even with only $4 2 \mathrm { k }$ pre-training videos, we can still obtain better accuracy than the Kinetics pre-trained models with 240k videos $6 8 . 7 \%$ vs. $6 8 . 5 \%$ ). This result implies that domain shift is another important factor, and data quality is more important than data quantity in SSVP when there exists a difference between pre-training and target datasets. It also demonstrates that VideoMAE is a data-efficient learner for SSVP.
Transfer learning: downstream action detection. We also transfer the learned VideoMAE on Kinetics-400 to downstream action detection dataset AVA. Following the standard setting [26], we evaluate on top 60 common classes with mean Average Precision (mAP) as the metric under IoU threshold of 0.5. The results are shown in the Table 5. After self-supervised pre-training on Kinetics400, our VideoMAE with the vanilla ViT-B can achieve $2 6 . 7 \mathrm { m A P }$ on AVA, which demonstrates the strong transferability of our VideoMAE. If the pre-trained ViT-B is additionally fine-tuned on Kinetics-400 with labels, the transfer learning performance can further increase about $5 \mathrm { m A P }$ (from 26.7 to 31.8). More remarkably, when we scale up the pre-training configurations with larger video datasets (e.g. Kinetics-700) or more powerful backbones (e.g. ViT-Large and ViT-Huge), VideoMAE can finally obtain better performance. For example, our ViT-L VideoMAE pre-trained on Kinetics-700 achieves $3 9 . 3 \mathrm { m A P }$ and ViT-H VideoMAE pre-trained on Kinetics-400 has $3 9 . 5 \mathrm { m A P } . $ . These results demonstrate that the self-supervised pre-trained models transfer well not only on action classification task but on more complex action detection task.
Table 5: Comparison with the state-of-the-art methods on AVA v2.2. All models are pre-trained and fine-tuned at image size $2 2 4 ^ { 2 }$ . We report the mean Average Precision (mAP) on validation set. βEx. labels $\pmb { \chi } ^ { , }$ means only unlabelled data is used during the pre-training phase and the pre-trained models are directly transferred to AVA. βEx. labels $\curvearrowleft$ means pre-trained models are additionally fine-tuned on the pre-training dataset with labels before transferred to AVA. $T \times \tau$ refers to frame number and corresponding sample rate.
<table><tr><td>Method</td><td>Backbone</td><td>Pre-train Dataset Extra Labels|TΓ7</td><td></td><td></td><td>GFLOPs</td><td>Param</td><td>mAP</td></tr><tr><td>supervised [22]</td><td>SlowFast-R101</td><td>Kinetics-400</td><td>β</td><td>8Γ8</td><td>138</td><td>53</td><td>23.8</td></tr><tr><td>CVRL [53]</td><td>SlowOnly-R50</td><td>Kinetics-400</td><td>X</td><td>32Γ2</td><td>42</td><td>32</td><td>16.3</td></tr><tr><td>pBYOLp=3 [23]</td><td>SlowOnly-R50 SlowOnly-R50</td><td>Kinetics-400</td><td>X</td><td>8Γ8</td><td>42</td><td>32</td><td>23.4</td></tr><tr><td>pMoCop=3 [23]</td><td>MViT-L</td><td>Kinetics-400 Kinetics-400</td><td>X</td><td>8Γ8 40Γ3</td><td>42</td><td>32</td><td>20.3</td></tr><tr><td>MaskFeatβ312 [79] MaskFeatβ312 [79]</td><td>MViT-L</td><td>Kinetics-600</td><td>β β</td><td>40Γ3</td><td>2828 2828</td><td>218 218</td><td>37.5</td></tr><tr><td>VideoMAE</td><td>ViT-S</td><td>Kinetics-400</td><td>X</td><td>16Γ4</td><td>57</td><td>22</td><td>38.8 22.5</td></tr><tr><td>VideoMAE</td><td>ViT-S</td><td>Kinetics-400</td><td>β</td><td>16Γ4</td><td>57</td><td>22</td><td>28.4</td></tr><tr><td>VideoMAE</td><td>ViT-B</td><td>Kinetics-400</td><td>X</td><td>16Γ4</td><td>180</td><td>87</td><td>26.7</td></tr><tr><td>VideoMAE</td><td>ViT-B</td><td>Kinetics-400</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>ViT-L</td><td>Kinetics-400</td><td>β</td><td>16Γ4</td><td>180</td><td>87</td><td>31.8</td></tr><tr><td>VideoMAE</td><td>ViT-L</td><td>Kinetics-400</td><td>X</td><td>16Γ4 16Γ4</td><td>597</td><td>305</td><td>34.3</td></tr><tr><td>VideoMAE VideoMAE</td><td>ViT-H</td><td>Kinetics-400</td><td>β</td><td>16Γ4</td><td>597</td><td>305</td><td>37.0</td></tr><tr><td>VideoMAE</td><td>ViT-H</td><td>Kinetics-400</td><td>X β</td><td>16Γ4</td><td>1192 1192</td><td>633 633</td><td>36.5</td></tr><tr><td>VideoMAE</td><td>ViT-L</td><td>Kinetics-700</td><td>X</td><td>16Γ4</td><td>597</td><td>305</td><td>39.5 36.1</td></tr><tr><td>VideoMAE</td><td>ViT-L</td><td>Kinetics-700</td><td>β</td><td>16Γ4</td><td>597</td><td>305</td><td>39.3</td></tr></table>
<table><tr><td>Method</td><td>Backbone</td><td>Extra data</td><td>Ex. labels</td><td>Frames</td><td>GFLOPs</td><td>Param</td><td>Top-1</td><td>Top-5</td></tr><tr><td>TEINetEn [39]</td><td>ResNet50x2</td><td rowspan="3">ImageNet-1K</td><td>β</td><td>8+16</td><td>99Γ10x3</td><td>50</td><td>66.5</td><td>N/A</td></tr><tr><td>TANetEn [40]</td><td>ResNet50Γ2</td><td>β</td><td>8+16</td><td>99Γ2Γ3</td><td>51</td><td>66.0</td><td>90.1</td></tr><tr><td>TDNEn [74]</td><td>ResNet101Γ2</td><td>β</td><td>8+16</td><td>198Γ1Γ3</td><td>88</td><td>69.6</td><td>92.2</td></tr><tr><td>SlowFast [22] MViTv1[21]</td><td>ResNet101 MViTv1-B</td><td rowspan="2">Kinetics-400</td><td>β β</td><td>8+32 64</td><td>106Γ1Γ3 455Γ1Γ3</td><td>53 37</td><td>63.1 67.7</td><td>87.6</td></tr><tr><td>TimeSformer [6]</td><td>ViT-B</td><td></td><td>8</td><td>196Γ1Γ3</td><td>121</td><td>59.5</td><td>90.9 N/A</td></tr><tr><td>TimeSformer [6]</td><td>ViT-L</td><td rowspan="2">ImageNet-21K</td><td>V</td><td>64</td><td>5549Γ1Γ3</td><td>430</td><td>62.4</td><td>N/A</td></tr><tr><td>ViViT FE [3]</td><td>ViT-L</td><td>β</td><td>32</td><td>995Γ4Γ3</td><td>N/A</td><td>65.9</td><td>89.9</td></tr><tr><td>Motionformer [50]</td><td>ViT-B</td><td rowspan="4">IN-21K+K400</td><td>β</td><td>16</td><td>370Γ1Γ3</td><td>109</td><td>66.5</td><td>90.1</td></tr><tr><td>Motionformer [50]</td><td>ViT-L</td><td>β</td><td>32</td><td>1185Γ1Γ3</td><td>382</td><td>68.1</td><td>91.2</td></tr><tr><td>Video Swin [38]</td><td>Swin-B</td><td>β</td><td>32</td><td>321Γ1Γ3</td><td>88</td><td>69.6</td><td>92.7</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>VIMPAC [64]</td><td>ViT-L</td><td>HowTo100M+DALLE IN-1K+K400+DALLE</td><td>X</td><td>10</td><td>N/AΓ10Γ3</td><td>307</td><td>68.1</td><td>N/A</td></tr><tr><td>BEVT[76]</td><td>Swin-B</td><td rowspan="2">Kinetics-600</td><td>Γ</td><td>32</td><td>321Γ1Γ3</td><td>88</td><td>70.6</td><td>N/A</td></tr><tr><td>MaskFeatβ312 [79]</td><td>MViT-L</td><td>β</td><td>40</td><td>2828Γ1Γ3</td><td>218</td><td>75.0</td><td>95.0</td></tr><tr><td>VideoMAE</td><td>ViT-B</td><td>Kinetics-400 Kinetics-400</td><td>X Γ</td><td>16</td><td>180Γ2Γ3</td><td>87</td><td>69.7</td><td>92.3</td></tr><tr><td>VideoMAE</td><td>ViT-L</td><td rowspan="4"> no external data</td><td>X</td><td>16</td><td>597Γ2Γ3</td><td>305</td><td>74.0</td><td>94.6</td></tr><tr><td>VideoMAE</td><td>ViT-S</td><td>X</td><td>16</td><td>57Γ2Γ3</td><td>22</td><td>66.8</td><td>90.3</td></tr><tr><td>VideoMAE</td><td>ViT-B</td><td></td><td>16</td><td>180Γ2Γ3</td><td>87</td><td>70.8</td><td>92.4</td></tr><tr><td>VideoMAE VideoMAE</td><td>ViT-L ViT-L</td><td>X X</td><td>16 32</td><td>597Γ2Γ3 1436Γ1Γ3</td><td>305 305</td><td>74.3 75.4</td><td>94.6 95.2</td></tr></table>
Table 6: Comparison with the state-of-the-art methods on Something-Something V2. Our VideoMAE reconstructs normalized cube pixels and is pre-trained with a masking ratio of $90 \%$ for 2400 epochs. βEx. labels $\pmb { \chi } ^ { , }$ means only unlabelled data is used during the pre-training phase. βN/Aβ indicates the numbers are not available for us.
# 4.4 Comparison with the state of the art
We compare with the previous state-of-the-art performance on the Kinetics-400 and SomethingSomething V2 datasets. The results are reported in Table 6 and Table 7. Our VideoMAE can easily scale up with more powerful backbones (e.g. ViT-Large and ViT-Huge) and more frames (e.g. 32). Our VideoMAE achieves the top-1 accuracy of $7 5 . 4 \%$ on Something-Something V2 and $8 7 . 4 \%$ on Kinetics-400 without using any extra data. We see that the existing state-of-the-art methods all depend on the external data for pre-training on the Something-Something V2 dataset. On the contrary, our VideoMAE without any external data significantly outperforms previous methods with the same input resolution by around $5 \%$ . Our ViT-H VideoMAE also achieves very competitive performance on the Kinetics-400 dataset without using any extra data, which is even better than ViViT-H with on
Table 7: Comparison with the state-of-the-art methods on Kinetics-400. Our VideoMAE reconstructs normalized cube pixels. Here models are self-supervised pre-trained with a masking ratio of $90 \%$ for 1600 epochs on Kinetics-400. VideoMAEβ320 is initialized from its $2 2 4 ^ { 2 }$ resolution counterpart and then fine-tuned for evaluation. βEx. labels $\pmb { \chi } ^ { , }$ means only unlabelled data is used during the pre-training phase. βN/Aβ indicates the numbers are not available for us.
<table><tr><td>Method</td><td>Backbone</td><td>Extra data</td><td>Ex.labels|1</td><td>Frames</td><td>GFLOPs</td><td>Param</td><td>Top-1</td><td>Top-5</td></tr><tr><td>NL I3D [77]</td><td>ResNet101</td><td rowspan="3">ImageNet-1K</td><td>β</td><td>128</td><td>359Γ10Γ3</td><td>62</td><td>77.3</td><td>93.3</td></tr><tr><td>TANet [40]</td><td>ResNet152</td><td></td><td>16</td><td>242Γ4Γ3</td><td>59</td><td>79.3</td><td>94.1</td></tr><tr><td>TDNEn [74]</td><td>ResNet101</td><td></td><td>8+16</td><td>198Γ10Γ3</td><td>88</td><td>79.4</td><td>94.4</td></tr><tr><td>TimeSformer [6]</td><td>ViT-L</td><td rowspan="4">ImageNet-21K</td><td></td><td>96</td><td>8353Γ1Γ3</td><td>430</td><td>80.7</td><td>94.7</td></tr><tr><td>ViViT FE [3]</td><td>ViT-L</td><td></td><td>128</td><td>3980Γ1Γ3</td><td>N/A</td><td>81.7</td><td>93.8</td></tr><tr><td>Motionformer [50]</td><td>ViT-L</td><td></td><td>32</td><td>1185Γ10Γ3</td><td>382</td><td>80.2</td><td>94.8</td></tr><tr><td>Video Swin [38]</td><td>Swin-L</td><td></td><td>32</td><td>604Γ4Γ3</td><td>197</td><td>83.1</td><td>95.9</td></tr><tr><td>ViViT FE [3]</td><td>ViT-L</td><td>JFT-300M</td><td>β</td><td>128</td><td>3980Γ1Γ3</td><td>N/A</td><td>83.5</td><td>94.3</td></tr><tr><td>ViViT[3]</td><td>ViT-H</td><td>JFT-300M</td><td></td><td>32</td><td>3981Γ4Γ3</td><td>N/A</td><td>84.9</td><td>95.8</td></tr><tr><td>VIMPAC [64]</td><td>ViT-L</td><td>HowTo100M+DALLE</td><td>X</td><td>10</td><td>N/AΓ10Γ3</td><td>307</td><td>77.4</td><td>N/A</td></tr><tr><td>BEVT[76]</td><td>Swin-B</td><td>IN-1K+DALLE</td><td>X</td><td>32</td><td>282Γ4Γ3</td><td>88</td><td>80.6</td><td>N/A</td></tr><tr><td>MaskFeatβ352 [79]</td><td>MViT-L</td><td>Kinetics-600</td><td>X</td><td>40</td><td>3790Γ4Γ3</td><td>218</td><td>87.0</td><td>97.4</td></tr><tr><td>ip-CSN [68]</td><td>ResNet152</td><td rowspan="4"> no external data</td><td>X</td><td>32</td><td>109Γ10Γ3</td><td>33</td><td>77.8</td><td>92.8</td></tr><tr><td>SlowFast [22]</td><td>R101+NL</td><td>X</td><td>16+64</td><td>234Γ10Γ3</td><td>60</td><td>79.8</td><td>93.9</td></tr><tr><td>MViTv1[21]</td><td>MViTv1-B</td><td>X</td><td>32</td><td>170Γ5Γ1</td><td>37</td><td>80.2</td><td>94.4</td></tr><tr><td>MaskFeat [79]</td><td>MViT-L</td><td>Γ</td><td>16</td><td>377Γ10Γ1</td><td>218</td><td>84.3</td><td>96.3</td></tr><tr><td>VideoMAE</td><td>ViT-S</td><td rowspan="4">no external data</td><td>X</td><td>16</td><td>57Γ5Γ3</td><td>22</td><td>79.0</td><td>93.8</td></tr><tr><td>VideoMAE</td><td>ViT-B</td><td>X</td><td>16</td><td>180Γ5Γ3</td><td>87</td><td>81.5</td><td>95.1</td></tr><tr><td>VideoMAE</td><td>ViT-L</td><td>Γ</td><td>16</td><td>597Γ5Γ3</td><td>305</td><td>85.2</td><td>96.8</td></tr><tr><td>VideoMAE</td><td>ViT-H</td><td>Γ</td><td>16</td><td>1192Γ5Γ3</td><td>633</td><td>86.6</td><td>97.1</td></tr><tr><td>VideoMAEβ320</td><td>ViT-L</td><td rowspan="2">no external data</td><td>X</td><td>32</td><td>3958Γ4Γ3</td><td>305</td><td>86.1</td><td></td></tr><tr><td>VideoMAEβ320</td><td>ViT-H</td><td>Γ</td><td>32</td><td>7397Γ4Γ3</td><td>633</td><td>87.4</td><td>97.3 97.6</td></tr></table>
JFT-300M pre-training $8 6 . 6 \%$ v.s. $8 4 . 9 \%$ ). When fine-tuned with larger spatial resolutions and input video frames, the performance of our ViT-H VideoMAE can further boost from $8 6 . 6 \%$ to $8 7 . 4 \%$ .
# 5 Conclusion
In this paper, we have presented a simple and data-efficient self-supervised learning method (VideoMAE) for video transformer pre-training. Our VideoMAE introduces two critical designs of extremely high masking ratio and tube masking strategy to make the video reconstruction task more challenging. This harder task would encourage VideoMAE to learn more representative features and relieve the information leakage issue. Empirical results demonstrate this simple algorithm works well for video datasets of different scales. In particular, we are able to learn effective VideoMAE only with thousands of video clips, which has significant practical value for scenarios with limited data available.
Future work VideoMAE could be further improved by using larger webly datasets, larger models (e.g., ViT-G) and larger spatial resolutions of input video (e.g., $3 8 \hat { 4 ^ { 2 } }$ ). VideoMAE only leverages the RGB video stream without using additional audio or text stream. We expect that audio and text from the video data can provide more information for self-supervised pre-training.
Broader impact Potential negative societal impacts of VideoMAE are mainly concerned with energy consumption. The pre-training phase may lead to a large amount of carbon emission. Though the pre-training is energy-consuming, we only need to pre-train the model once. Different downstream tasks can then share the same pre-trained model via additional fine-tuning. Our VideoMAE unleashes the great potential of vanilla vision transformer for video analysis, which could increase the risk of video understanding model or its outputs being used incorrectly, such as for unauthorized surveillance.
Acknowledgements and disclosure of funding Thanks to Ziteng Gao, Lei Chen and Chongjian Ge for their help. This work is supported by National Natural Science Foundation of China (No. 62076119, No. 61921006), the Fundamental Research Funds for the Central Universities (No. 020214380091), Tencent AI Lab Rhino-Bird Focused Research Program (No. JR202125), and Collaborative Innovation Center of Novel Software Technology and Industrialization.
References [1] Jean-Baptiste Alayrac, Adria Recasens, Rosalia Schneider, Relja Arandjelovic, Jason Ramapuram, Jeffrey De Fauw, Lucas Smaira, Sander Dieleman, and Andrew Zisserman. Self-supervised multimodal versatile networks. In Advances in Neural Information Processing Systems, 2020. [2] Humam Alwassel, Dhruv Mahajan, Bruno Korbar, Lorenzo Torresani, Bernard Ghanem, and Du Tran. Self-supervised learning by cross-modal audio-video clustering. In Advances in Neural Information Processing Systems, 2020. [3] Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario LuciΛ c, and Cordelia Schmid. Vivit: A Β΄ video vision transformer. In IEEE/CVF International Conference on Computer Vision, 2021. [4] Hangbo Bao, Li Dong, Songhao Piao, and Furu Wei. BEit: BERT pre-training of image transformers. In International Conference on Learning Representations, 2022. [5] Sagie Benaim, Ariel Ephrat, Oran Lang, Inbar Mosseri, William T. Freeman, Michael Rubinstein, Michal Irani, and Tali Dekel. Speednet: Learning the speediness in videos. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020. [6] Gedas Bertasius, Heng Wang, and Lorenzo Torresani. Is space-time attention all you need for video understanding? In International Conference on Machine Learning, 2021. [7] 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 Advances in Neural Information Processing Systems, 2020. [8] Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European Conference on Computer Vision, 2020. [9] Mathilde Caron, Hugo Touvron, Ishan Misra, HervΓ© JΓ©gou, Julien Mairal, Piotr Bojanowski, and Armand Joulin. Emerging properties in self-supervised vision transformers. In IEEE/CVF International Conference on Computer Vision, 2021. [10] JoΓ£o Carreira and Andrew Zisserman. Quo vadis, action recognition? A new model and the kinetics dataset. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2017. [11] Mark Chen, Alec Radford, Rewon Child, Jeffrey Wu, Heewoo Jun, David Luan, and Ilya Sutskever. Generative pretraining from pixels. In International Conference on Machine Learning, 2020. [12] Peihao Chen, Deng Huang, Dongliang He, Xiang Long, Runhao Zeng, Shilei Wen, Mingkui Tan, and Chuang Gan. Rspnet: Relative speed perception for unsupervised video representation learning. In Proceedings of the AAAI Conference on Artificial Intelligence, 2021. [13] Xin Chen, Bin Yan, Jiawen Zhu, Dong Wang, Xiaoyun Yang, and Huchuan Lu. Transformer tracking. In CVPR, 2021. [14] Xinlei Chen, Saining Xie, and Kaiming He. An empirical study of training self-supervised vision transformers. In IEEE/CVF International Conference on Computer Vision, 2021. [15] Ekin D Cubuk, Barret Zoph, Jonathon Shlens, and Quoc V Le. Randaugment: Practical automated data augmentation with a reduced search space. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, 2020. [16] Yutao Cui, Cheng Jiang, Limin Wang, and Gangshan Wu. Mixformer: End-to-end tracking with iterative mixed attention. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022. [17] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In North American Chapter of the Association for Computational Linguistics, 2019. [18] Ali Diba, Vivek Sharma, Reza Safdari, Dariush Lotfi, Saquib Sarfraz, Rainer Stiefelhagen, and Luc Van Gool. Vi2clr: Video and image for visual contrastive learning of representation. In IEEE/CVF International Conference on Computer Vision, 2021. [19] Xiaoyi Dong, Jianmin Bao, Ting Zhang, Dongdong Chen, Weiming Zhang, Lu Yuan, Dong Chen, Fang Wen, and Nenghai Yu. Peco: Perceptual codebook for bert pre-training of vision transformers. arXiv preprint arXiv:2111.12710, 2021. [20] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021. [21] Haoqi Fan, Bo Xiong, Karttikeya Mangalam, Yanghao Li, Zhicheng Yan, Jitendra Malik, and Christoph Feichtenhofer. Multiscale vision transformers. In IEEE/CVF International Conference on Computer Vision, 2021. [22] Christoph Feichtenhofer, Haoqi Fan, Jitendra Malik, and Kaiming He. Slowfast networks for video recognition. In IEEE/CVF International Conference on Computer Vision, 2019. [23] Christoph Feichtenhofer, Haoqi Fan, Bo Xiong, Ross Girshick, and Kaiming He. A large-scale study on unsupervised spatiotemporal representation learning. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021. [24] Chongjian Ge, Youwei Liang, Yibing Song, Jianbo Jiao, Jue Wang, and Ping Luo. Revitalizing cnn attentions via transformers in self-supervised visual representation learning. In Advances in Neural Information Processing Systems, 2021. [25] Raghav Goyal, Samira Ebrahimi Kahou, Vincent Michalski, Joanna Materzynska, Susanne Westphal, Heuna Kim, Valentin Haenel, Ingo FrΓΌnd, Peter Yianilos, Moritz Mueller-Freitag, Florian Hoppe, Christian Thurau, Ingo Bax, and Roland Memisevic. The "something something" video database for learning and evaluating visual common sense. In IEEE/CVF International Conference on Computer Vision, 2017. [26] Chunhui Gu, Chen Sun, David A Ross, Carl Vondrick, Caroline Pantofaru, Yeqing Li, Sudheendra Vijayanarasimhan, George Toderici, Susanna Ricco, Rahul Sukthankar, et al. Ava: A video dataset of spatio-temporally localized atomic visual actions. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2018. [27] Sheng Guo, Zihua Xiong, Yujie Zhong, Limin Wang, Xiaobo Guo, Bing Han, and Weilin Huang. Crossarchitecture self-supervised video representation learning. In CVPR, 2022. [28] Tengda Han, Weidi Xie, and Andrew Zisserman. Memory-augmented dense predictive coding for video representation learning. In European Conference on Computer Vision, 2020. [29] Tengda Han, Weidi Xie, and Andrew Zisserman. Self-supervised co-training for video representation learning. In Advances in Neural Information Processing Systems, 2020. [30] Kaiming He, Xinlei Chen, Saining Xie, Yanghao Li, Piotr DollΓ‘r, and Ross Girshick. Masked autoencoders are scalable vision learners. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022. [31] Elad Hoffer, Tal Ben-Nun, Itay Hubara, Niv Giladi, Torsten Hoefler, and Daniel Soudry. Augment your batch: Improving generalization through instance repetition. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020. [32] Kai Hu, Jie Shao, Yuan Liu, Bhiksha Raj, Marios Savvides, and Zhiqiang Shen. Contrast and order representations for video self-supervised learning. In IEEE/CVF International Conference on Computer Vision, 2021. [33] Will Kay, Joao Carreira, Karen Simonyan, Brian Zhang, Chloe Hillier, Sudheendra Vijayanarasimhan, Fabio Viola, Tim Green, Trevor Back, Paul Natsev, Mustafa Suleyman, and Andrew Zisserman. The kinetics human action video dataset. arXiv preprint arXiv:1705.06950, 2017. [34] Hildegard Kuehne, Hueihan Jhuang, EstΓbaliz Garrote, Tomaso Poggio, and Thomas Serre. Hmdb: a large video database for human motion recognition. In IEEE/CVF International Conference on Computer Vision, 2011. [35] Hsin-Ying Lee, Jia-Bin Huang, Maneesh Singh, and Ming-Hsuan Yang. Unsupervised representation learning by sorting sequence. In IEEE/CVF International Conference on Computer Vision, 2017. [36] Tianhao Li and Limin Wang. Learning spatiotemporal features via video and text pair discrimination. CoRR, abs/2001.05691, 2020. [37] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, and Baining Guo. Swin transformer: Hierarchical vision transformer using shifted windows. In IEEE/CVF International Conference on Computer Vision, 2021. [38] Ze Liu, Jia Ning, Yue Cao, Yixuan Wei, Zheng Zhang, Stephen Lin, and Han Hu. Video swin transformer. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022. [39] Zhaoyang Liu, Donghao Luo, Yabiao Wang, Limin Wang, Ying Tai, Chengjie Wang, Jilin Li, Feiyue Huang, and Tong Lu. TEINet: Towards an efficient architecture for video recognition. In Proceedings of the AAAI Conference on Artificial Intelligence, 2020. [40] Zhaoyang Liu, Limin Wang, Wayne Wu, Chen Qian, and Tong Lu. Tam: Temporal adaptive module for video recognition. In IEEE/CVF International Conference on Computer Vision, 2021. [41] Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983, 2016. [42] Antoine Miech, Jean-Baptiste Alayrac, Lucas Smaira, Ivan Laptev, Josef Sivic, and Andrew Zisserman. End-to-end learning of visual representations from uncurated instructional videos. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020. [43] Antoine Miech, Jean-Baptiste Alayrac, Lucas Smaira, Ivan Laptev, Josef Sivic, and Andrew Zisserman. End-to-End Learning of Visual Representations from Uncurated Instructional Videos. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020. [44] Ishan Misra, C Lawrence Zitnick, and Martial Hebert. Shuffle and learn: unsupervised learning using temporal order verification. In European Conference on Computer Vision, 2016. [45] Tian Pan, Yibing Song, Tianyu Yang, Wenhao Jiang, and Wei Liu. Videomoco: Contrastive video representation learning with temporally adversarial examples. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021. [46] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'AlchΓ©-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems, 2019. [47] Deepak Pathak, Philipp KrΓ€henbΓΌhl, Jeff Donahue, Trevor Darrell, and Alexei A. Efros. Context encoders: Feature learning by inpainting. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2016. [48] Viorica Patraucean, Ankur Handa, and Roberto Cipolla. Spatio-temporal video autoencoder with differentiable memory. arXiv preprint arXiv:1511.06309, 2015. [49] Mandela Patrick, Yuki M. Asano, Polina Kuznetsova, Ruth Fong, JoΓ£o F. Henriques, Geoffrey Zweig, and Andrea Vedaldi. Multi-modal self-supervision from generalized data transformations. In IEEE/CVF International Conference on Computer Vision, 2021. [50] Mandela Patrick, Dylan Campbell, Yuki M. Asano, Ishan Misra Florian Metze, Christoph Feichtenhofer, Andrea Vedaldi, and Joo F. Henriques. Keeping your eye on the ball: Trajectory attention in video transformers. In Advances in Neural Information Processing Systems, 2021. [51] AJ Piergiovanni, Anelia Angelova, and Michael S Ryoo. Evolving losses for unsupervised video representation learning. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020. [52] Rui Qian, Tianjian Meng, Boqing Gong, Ming-Hsuan Yang, Huisheng Wang, Serge Belongie, and Yin Cui. Spatiotemporal contrastive video representation learning. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021. [53] Rui Qian, Tianjian Meng, Boqing Gong, Ming-Hsuan Yang, Huisheng Wang, Serge J. Belongie, and Yin Cui. Spatiotemporal contrastive video representation learning. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021. [54] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding by generative pre-training. OpenAI blog, 2018. [55] Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI blog, 2019. [56] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, 2021. [57] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. International Journal of Computer Vision, 2015. [58] Karen Simonyan and Andrew Zisserman. Two-stream convolutional networks for action recognition in videos. Advances in Neural Information Processing Systems, 2014. [59] Ankit Singh, Omprakash Chakraborty, Ashutosh Varshney, Rameswar Panda, Rogerio Feris, Kate Saenko, and Abir Das. Semi-supervised action recognition with temporal contrastive learning. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021. [60] Khurram Soomro, Amir Roshan Zamir, and Mubarak Shah. Ucf101: A dataset of 101 human actions classes from videos in the wild. arXiv preprint arXiv:1212.0402, 2012. [61] Nitish Srivastava, Elman Mansimov, and Ruslan Salakhutdinov. Unsupervised learning of video representations using lstms. International Conference on Machine Learning, 2015. [62] Jonathan C. Stroud, David A. Ross, Chen Sun, Jia Deng, Rahul Sukthankar, and Cordelia Schmid. Learning video representations from textual web supervision. CoRR, abs/2007.14937, 2020. [63] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2016. [64] Hao Tan, Jie Lei, Thomas Wolf, and Mohit Bansal. Vimpac: Video pre-training via masked token prediction and contrastive learning. arXiv preprint arXiv:2106.11250, 2021. [65] Jiajun Tang, Jin Xia, Xinzhi Mu, Bo Pang, and Cewu Lu. Asynchronous interaction aggregation for action detection. In European Conference on Computer Vision, 2020. [66] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and HervΓ© JΓ©gou. Training data-efficient image transformers & distillation through attention. In International Conference on Machine Learning, 2021. [67] Du Tran, Lubomir Bourdev, Rob Fergus, Lorenzo Torresani, and Manohar Paluri. Learning spatiotemporal features with 3d convolutional networks. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2015. [68] Du Tran, Heng Wang, Matt Feiszli, and Lorenzo Torresani. Video classification with channel-separated convolutional networks. In IEEE/CVF International Conference on Computer Vision, 2019. [69] Du Tran, Heng Wang, Lorenzo Torresani, Jamie Ray, Yann LeCun, and Manohar Paluri. A closer look at spatiotemporal convolutions for action recognition. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2018. [70] 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, 2017. [71] Pascal Vincent, Hugo Larochelle, Yoshua Bengio, and Pierre-Antoine Manzagol. Extracting and composing robust features with denoising autoencoders. In International Conference on Machine Learning, 2008. [72] Pascal Vincent, Hugo Larochelle, Isabelle Lajoie, Yoshua Bengio, and Pierre-Antoine Manzagol. Stacked denoising autoencoders: Learning useful representations in a deep network with a local denoising criterion. Journal of Machine Learning Research, 2010. [73] Jiangliu Wang, Jianbo Jiao, and Yun-Hui Liu. Self-supervised video representation learning by pace prediction. In European Conference on Computer Vision, 2020. [74] Limin Wang, Zhan Tong, Bin Ji, and Gangshan Wu. TDN: Temporal difference networks for efficient action recognition. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021. [75] Limin Wang, Yuanjun Xiong, Zhe Wang, Yu Qiao, Dahua Lin, Xiaoou Tang, and Luc Van Gool. Temporal segment networks for action recognition in videos. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2019. [76] 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 IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022. [77] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He. Non-local neural networks. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2018. [78] Xiaolong Wang and Abhinav Gupta. Unsupervised learning of visual representations using videos. In IEEE/CVF International Conference on Computer Vision, 2015. [79] Chen Wei, Haoqi Fan, Saining Xie, Chao-Yuan Wu, Alan Yuille, and Christoph Feichtenhofer. Masked feature prediction for self-supervised visual pre-training. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022. [80] Enze Xie, Wenhai Wang, Zhiding Yu, Anima Anandkumar, Jose M Alvarez, and Ping Luo. Segformer: Simple and efficient design for semantic segmentation with transformers. In Advances in Neural Information Processing Systems, 2021. [81] 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. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022. [82] Dejing Xu, Jun Xiao, Zhou Zhao, Jian Shao, Di Xie, and Yueting Zhuang. Self-supervised spatiotemporal learning via video clip order prediction. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019. [83] Wilson Yan, Yunzhi Zhang, Pieter Abbeel, and Aravind Srinivas. Videogpt: Video generation using VQ-VAE and transformers. arXiv preprint arXiv:2104.10157, 2021. [84] Ceyuan Yang, Yinghao Xu, Bo Dai, and Bolei Zhou. Video representation learning with visual tempo consistency. arXiv preprint arXiv:2006.15489, 2020. [85] 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 IEEE/CVF International Conference on Computer Vision, 2019. [86] Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017. [87] Zhang Zhang and Dacheng Tao. Slow feature analysis for human action recognition. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2012. [88] Daquan Zhou, Bingyi Kang, Xiaojie Jin, Linjie Yang, Xiaochen Lian, Qibin Hou, and Jiashi Feng. Deepvit: Towards deeper vision transformer. arXiv preprint arXiv:2103.11886, 2021. [89] Jinghao Zhou, Chen Wei, Huiyu Wang, Wei Shen, Cihang Xie, Alan Yuille, and Tao Kong. iBOT: Image bert pre-training with online tokenizer. International Conference on Learning Representations, 2022.
# Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paperβs contributions and scope? [Yes] (b) Did you describe the limitations of your work? [Yes] Shown in Section 5. (c) Did you discuss any potential negative societal impacts of your work? [Yes] Shown in Section 5. (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
2. If you are including theoretical results...
(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]
3. If you ran experiments...
(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] Shown in Section 4.1 and Appendix $\ S \ B$ . (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] Shown in Appendix $\ S \ O $ . (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Because of the computation costs, we did not run the experiments multiple times. (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] Please see Table 3 and Appendix $\ S \mathrm { ~ B ~ }$ .
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators? [Yes] (b) Did you mention the license of the assets? [Yes] Shown in Appendix $\ S ~ ^ { \intercal }$ . (c) Did you include any new assets either in the supplemental material or as a URL? [No] (d) Did you discuss whether and how consent was obtained from people whose data youβre using/curating? [Yes] We used publicly available datasets whose licenses allow research usage. (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] To the best of our knowledge, the data we used contains no personally identifiable information or offensive content.
5. If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719# TOWARDS UNDERSTANDING AND MITIGATING DIMENSIONAL COLLAPSE IN HETEROGENEOUS FEDERATED LEARNING
Yujun $\mathbf { S h i } ^ { 1 \mathrm { ~ * ~ } }$ Jian Liang3 Wenqing Zhang2 Vincent Y. F. Tan1 Song Bai2 1National University of Singapore 2ByteDance Inc. 3Institute of Automation, CAS shi.yujun@u.nus.edu vtan@nus.edu.sg songbai.site@gmail.com
# ABSTRACT
Federated learning aims to train models collaboratively across different clients without sharing data for privacy considerations. However, one major challenge for this learning paradigm is the data heterogeneity problem, which refers to the discrepancies between the local data distributions among various clients. To tackle this problem, we first study how data heterogeneity affects the representations of the globally aggregated models. Interestingly, we find that heterogeneous data results in the global model suffering from severe dimensional collapse, in which representations tend to reside in a lower-dimensional space instead of the ambient space. Moreover, we observe a similar phenomenon on models locally trained on each client and deduce that the dimensional collapse on the global model is inherited from local models. In addition, we theoretically analyze the gradient flow dynamics to shed light on how data heterogeneity result in dimensional collapse for local models. To remedy this problem caused by the data heterogeneity, we propose FEDDECORR, a novel method that can effectively mitigate dimensional collapse in federated learning. Specifically, FEDDECORR applies a regularization term during local training that encourages different dimensions of representations to be uncorrelated. FEDDECORR, which is implementation-friendly and computationally-efficient, yields consistent improvements over baselines on standard benchmark datasets. Code: https://github.com/bytedance/FedDecorr.
# 1 INTRODUCTION
With the rapid development deep learning and the availability of large amounts of data, concerns regarding data privacy have been attracting increasingly more attention from industry and academia. To address this concern, McMahan et al. (2017) propose Federated Learningβa decentralized training paradigm enabling collaborative training across different clients without sharing data.
One major challenge in federated learning is the potential discrepancies in the distributions of local training data among clients, which is known as the data heterogeneity problem. In particular, this paper focuses on the heterogeneity of label distributions (see Fig. 1(a) for an example). Such discrepancies can result in drastic disagreements between the local optima of the clients and the desired global optimum, which may lead to severe performance degradation of the global model. Previous works attempting to tackle this challenge mainly focus on the model parameters, either during local training (Li et al., 2020; Karimireddy et al., 2020) or global aggregation (Wang et al., 2020b). However, these methods usually result in an excessive computation burden or high communication costs (Li et al., 2021a) because deep neural networks are typically heavily over-parameterized. In contrast, in this work, we focus on the representation space of the model and study the impact of data heterogeneity.
To commence, we study how heterogeneous data affects the global model in federated learning in Sec. 3.1. Specifically, we compare representations produced by global models trained under different degrees of data heterogeneity. Since the singular values of the covariance matrix provide a comprehensive characterization of the distribution of high-dimensional embeddings, we use it to study the representations output by each global model. Interestingly, we find that as the degree of data heterogeneity increases, more singular values tend to evolve towards zero. This observation suggests that stronger data heterogeneity causes the trained global model to suffer from more severe dimensional collapse, whereby representations are biased towards residing in a lower-dimensional space (or manifold). A graphical illustration of how heterogeneous training data affect output representations is shown in Fig. 1(b-c). Our observations suggest that dimensional collapse might be one of the key reasons why federated learning methods struggle under data heterogeneity. Essentially, dimensional collapse is a form of oversimplification in terms of the model, where the representation space is not being fully utilized to discriminate diverse data of different classes.
 Figure 1: (a) illustrates data heterogeneity in terms of number of samples per class. (b), (c), (d) show representations (normalized to the unit sphere) of global models trained under homogeneous data, heterogeneous data, and heterogeneous data with FEDDECORR, respectively. Only (c) suffers dimensional collapse. (b), (c), (d) are produced with ResNet20 on CIFAR10. Best viewed in color.
Given the observations made on the global model, we conjecture that the dimensional collapse of the global model is inherited from models locally trained on various clients. This is because the global model is a result of the aggregation of local models. To validate our conjecture, we further visualize the local models in terms of the singular values of representation covariance matrices in Sec. 3.2. Similar to the visualization on the global model, we observe dimensional collapse on representations produced by local models. With this observation, we establish the connection between dimensional collapse of the global model and local models. To further understand the dimensional collapse on local models, we analyze the gradient flow dynamics of local training in Sec. 3.3. Interestingly, we show theoretically that heterogeneous data drive the weight matrices of the local models to be biased to being low-rank, which further results in representation dimensional collapse.
Inspired by the observations that dimensional collapse of the global model stems from local models, we consider mitigating dimensional collapse during local training in Sec. 4. In particular, we propose a novel federated learning method termed FEDDECORR. FEDDECORR adds a regularization term during local training to encourage the Frobenius norm of the correlation matrix of representations to be small. We show theoretically and empirically that this proposed regularization term can effectively mitigate dimensional collapse (see Fig. 1(d) for example). Next, in Sec. 5, through extensive experiments on standard benchmark datasets including CIFAR10, CIFAR100, and TinyImageNet, we show that FEDDECORR consistently improves over baseline federated learning methods. In addition, we find that FEDDECORR yields more dramatic improvements in more challenging federated learning setups such as stronger heterogeneity or more number of clients. Lastly, FEDDECORR has extremely low computation overhead and can be built on top of any existing federated learning baseline methods, which makes it widely applicable.
Our contributions are summarized as follows. First, we discover through experiments that stronger data heterogeneity in federated learning leads to greater dimensional collapse for global and local models. Second, we develop a theoretical understanding of the dynamics behind our empirical discovery that connects data heterogeneity and dimensional collapse. Third, based on the motivation of mitigating dimensional collapse, we propose a novel method called FEDDECORR, which yields consistent improvements while being implementation-friendly and computationally-efficient.
# 2 RELATED WORKS
Federated Learning. McMahan et al. (2017) proposed FedAvg, which adopts a simple averaging scheme to aggregate local models into the global model. However, under data heterogeneity, FedAvg suffers from unstable and slow convergence, resulting in performance degradation. To tackle this challenge, previous works either improve local training (Li et al., 2021b; 2020; Karimireddy et al., 2020; Acar et al., 2021; Al-Shedivat et al., 2020; Wang et al., 2021) or global aggregation (Wang et al., 2020b; Hsu et al., 2019; Luo et al., 2021; Wang et al., 2020a; Lin et al., 2020; Reddi et al., 2020; Wang et al., 2020a). Most of these methods focus on the model parameter space, which may result in high computation or communication cost due to deep neural networks being overparameterized. Li et al. (2021b) focuses on model representations and uses a contrastive loss to maximize agreements between representations of local models and the global model. However, one drawback of Li et al. (2021b) is that it requires additional forward passes during training, which almost doubles the training cost. In this work, based on our study of how data heterogeneity affects model representations, we propose an effective yet highly efficient method to handle heterogeneous data. Another research trend is in personalized federated learning (Arivazhagan et al., 2019; Li et al., 2021c; Fallah et al., 2020; T Dinh et al., 2020; Hanzely et al., 2020; Huang et al., 2021; Zhang et al., 2020), which aims to train personalized local models for each client. In this work, however, we focus on the typical setting that aims to train one global model for all clients.
Dimensional Collapse. Dimensional collapse of representations has been studied in metric learning (Roth et al., 2020), self-supervised learning (Jing et al., 2021), and class incremental learning (Shi et al., 2022). In this work, we focus on federated learning and discover that stronger data heterogeneity causes a higher degree of dimensional collapse for locally trained models. To the best of our knowledge, this work is the first to discover and analyze dimensional collapse of representations in federated learning.
Gradient Flow Dynamics. Arora et al. (2018; 2019) introduce the gradient flow dynamics framework to analyze the dynamics of multi-layer linear neural networks under the $\ell _ { 2 }$ -loss and find deeper neural networks biasing towards low-rank solution during optimization. Following their works, Jing et al. (2021) finds two factors that cause dimensional collapse in self-supervised learning, namely strong data augmentation and implicit regularization from depth. Differently, we focus on federated learning with the cross-entropy loss. More importantly, our analysis focuses on dimensional collapse caused by data heterogeneity in federated learning instead of depth of neural networks.
Feature Decorrelation. Feature decorrelation had been used for different purposes, such as preventing mode collapse in self-supervised learning (Bardes et al., 2021; Zbontar et al., 2021; Hua et al., 2021), boosting generalization (Cogswell et al., 2015; Huang et al., 2018; Xiong et al., 2016), and improving class incremental learning (Shi et al., 2022). We instead apply feature decorrelation to counter the undesired dimensional collapse caused by data heterogeneity in federated learning.
# 3 DIMENSIONAL COLLAPSE CAUSED BY DATA HETEROGENEITY
In this section, we first empirically visualize and compare representations of global models trained under different degrees of data heterogeneity in Sec. 3.1. Next, to better understand the observations on global models, we analyze representations of local models in Sec. 3.2. Finally, to theoretically understand our observations, we analyze the gradient flow dynamics of local training in Sec. 3.3.
# 3.1 EMPIRICAL OBSERVATIONS ON THE GLOBAL MODEL
We first empirically demonstrate that stronger data heterogeneity causes more severe dimensional collapse on the global model. Specifically, we first separate the training samples of CIFAR100 into 10 splits, each corresponding to the local data of one client. To simulate data heterogeneity among clients as in previous works (Yurochkin et al., 2019; Wang et al., 2020a; Li et al., 2021b), we sample a probability vector $\mathbf { p } _ { c } = ( p _ { c , 1 } , p _ { c , 2 } , \hdots , p _ { c , K } ) \sim { \mathrm { D i r } } _ { K } ( \alpha )$ and allocate a $p _ { c , k }$ proportion of instances of class $c \in [ C ] = \{ 1 , 2 , \ldots , C \}$ to client $k \in [ K ]$ , where $\operatorname { D i r } _ { K } ( \alpha )$ is the Dirichlet distribution with $K$ categories and $\alpha$ is the concentration parameter. A smaller $\alpha$ implies stronger data heterogeneity $\alpha = \infty$ corresponds to the homogeneous setting). We let $\alpha \in \{ 0 . 0 1 , 0 . 0 5 , 0 . 2 5 , \infty \}$ .
For each of the settings generated by different $\alpha$ βs, we apply FedAvg (McMahan et al., 2017) to train a MobileNetV2 (Sandler et al., 2018) with CIFAR100 (observations on other federated learning methods, model architectures, or datasets are similar and are provided in Appendix D). Next, for each of the four trained global models, we compute the covariance matrix $\begin{array} { r } { \mathbf { \tilde { \Sigma } } = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } ( \mathbf { z } _ { i } - } \end{array}$ $\bar { \mathbf { z } } ) ( \mathbf { z } _ { i } - \bar { \mathbf { z } } ) ^ { \top }$ of the representations over the $N$ test data points in CIFAR100. Here $\mathbf { z } _ { i }$ is the $i$ -th test data point and $\begin{array} { r } { \bar { \bf z } = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } { \bf z } _ { i } } \end{array}$ is their average.
 Figure 2: Data heterogeneity causes dimensional collapse on (a) global models and (b) local models. We plot the singular values of the covariance matrix of representations in descending order. The $x$ -axis $( k )$ is the index of singular values and the $y$ -axis is the logarithm of the singular values.
Finally, we apply the singular value decomposition (SVD) on each of the covariance matrices and visualize the top 100 singular values in Fig. 2(a). If we define a small value $\tau$ as the threshold for a singular value to be significant (e.g., $\log \tau = - 2$ ), we observe that for the homogeneous setting, almost all the singular values are significant, i.e., they surpass $\tau$ . However, as $\alpha$ decreases, the number of singular values exceeding $\tau$ monotonically decreases. This implies that with stronger heterogeneity among local training data, the representation vectors produced by the trained global model tend to reside in a lower-dimensional space, corresponding to more severe dimensional collapse.
# 3.2 EMPIRICAL OBSERVATIONS ON LOCAL MODELS
Since the global model is obtained by aggregating locally trained models on each client, we conjecture that the dimensional collapse observed on the global model stems from the dimensional collapse of local models. To further validate our conjecture, we continue to study whether increasing data heterogeneity will also lead to more severe dimensional collapse on locally trained models.
Specifically, for different $\alpha$ βs, we visualize the locally trained model of one client (visualizations on local models of other clients are similar and are provided in Appendix E). Following the same procedure as in Sec. 3.1, we plot the singular values of covariance matrices of representations produced by the local models. We observe from Fig. 2(b) that locally trained models demonstrate the same trend as the global modelsβnamely, that the presence of stronger data heterogeneity causes more severe dimensional collapse. These experiments corroborate that the global model inherit the adverse dimensional collapse phenomenon from the local models.
# 3.3 A THEORETICAL EXPLANATION FOR DIMENSIONAL COLLAPSE
Based on the empirical observations in Sec. 3.1 and Sec. 3.2, we now develop a theoretical understanding to explain why heterogeneous training data causes dimensional collapse for the learned representations.
Since we have established that the dimensional collapse of global model stems from local models, we focus on studying local models in this section. Without loss of generality, we study local training of one arbitrary client. Specifically, we first analyze the gradient flow dynamics of the model weights during the local training. This analysis shows how heterogeneous local training data drives the model weights towards being low-rank, which leads to dimensional collapse for the representations.
# 3.3.1 SETUPS AND NOTATIONS
We denote the number of training samples as $N$ , the dimension of input data as $d _ { \mathrm { i n } }$ , and total number of classes as $C$ . The $i$ -th sample is denoted as $X _ { i } \in \mathbb { R } ^ { d _ { \mathrm { i n } } }$ , and its corresponding one-hot encoded label is $\mathbf { y } _ { i } \in \mathbb { R } ^ { C }$ . The collection of all $N$ training samples is denoted as $\bar { X } = [ \bar { X } _ { 1 } , X _ { 2 } \ldots , X _ { N } ] \in$ $\mathbb { R } ^ { d _ { \mathrm { i n } } \times N }$ , and the $N$ one-hot encoded training labels are denoted as $\mathbf { y } = [ \mathbf { y } _ { 1 } , \mathbf { y } _ { 2 } , \ldots , \mathbf { y } _ { N } ] \in \mathbb { R } ^ { C \times N }$ .
For simplicity in exposition, we follow Arora et al. (2018; 2019) and Jing et al. (2021) and analyze linear neural networks (without nonlinear activation layers). We consider an $( L + 1 )$ -layer (where $L \geq 1 \AA$ ) linear neural network trained using the cross entropy loss under gradient flow (i.e., gradient descent with an infinitesimally small learning rate). The weight matrix of the $i$ -th layer $( i \in [ L + 1 ] )$ ) at the optimization time step $t$ is denoted as $W _ { i } ( t )$ . The dynamics can be expressed as
$$\dot { W } _ { i } ( t ) = - \frac { \partial } { \partial W _ { i } } \ell ( W _ { 1 } ( t ) , \ldots , W _ { L + 1 } ( t ) ) ,$$
where $\ell$ denotes the cross-entropy loss.
In addition, at the optimization time step $t$ and given the input data $X _ { i }$ , we denote $\mathbf { z } _ { i } ( t ) \in \mathbb { R } ^ { d }$ as the output representation vector $d$ being the dimension of the representations) and $\gamma _ { i } ( t ) \in \mathbb { R } ^ { C }$ as the output softmax probability vector. We have
$$\gamma _ { i } ( t ) = \mathrm { s o f t m a x } ( W _ { L + 1 } ( t ) { \mathbf z } _ { i } ( t ) ) = \mathrm { s o f t m a x } ( W _ { L + 1 } ( t ) W _ { L } ( t ) \ldots W _ { 1 } ( t ) X _ { i } ) .$$
e define -dimens $\begin{array} { r } { \mu _ { c } = \frac { N _ { c } } { N } } \end{array}$ , where -hot vec $N _ { c }$ is number of d where only the a samples belonging to class -th entry is 1 (and the others $c$ . We denote re 0). In ad $\mathbf { e } _ { c }$ as theon, let $C$ $c$ $\begin{array} { r } { \bar { \gamma } _ { c } ( t ) = \frac { 1 } { N _ { c } } \sum _ { i = 1 } ^ { N } \gamma _ { i } ( t ) \mathbb { 1 } \{ \mathbf { y } _ { i } = \mathbf { e } _ { c } \} } \end{array}$ and $\begin{array} { r } { \bar { X } _ { c } = \frac { 1 } { N _ { c } } \sum _ { i = 1 } ^ { N } X _ { i } \mathbb { { l } } \{ \mathbf { y } _ { i } = \mathbf { e } _ { c } \} } \end{array}$ .
# 3.3.2 ANALYSIS ON GRADIENT FLOW DYNAMICS
Since our goal is to analyze model representations ${ \bf z } _ { i } ( t )$ , we focus on weight matrices that directly produce representations (i.e., the first $L$ layers). We denote the product of the weight matrices of the first $L$ layers as $\Pi ( t ) = W _ { L } ( t ) W _ { L - 1 } ( \dot { t } ) \dots W _ { 1 } ( t )$ and analyze the behavior of $\Pi ( t )$ under the gradient flow dynamics. In particular, we derive the following result for the singular values of $\Pi ( t )$ .
Theorem 1 (Informal). Assuming that the mild conditions as stated in Appendix $A . 3$ hold. Let $\sigma _ { k } ( t )$ for $k \in [ d ]$ be the $k$ -th largest singular value of $\Pi ( t )$ . Then,
$$\begin{array} { r } { \dot { \sigma } _ { k } ( t ) = N L \left( \sigma _ { k } ( t ) \right) ^ { 2 - \frac { 2 } { L } } \sqrt { ( \sigma _ { k } ( t ) ) ^ { \frac { 2 } { L } } + M } \left( \mathbf { u } _ { L + 1 , k } ( t ) \right) ^ { \top } G ( t ) \mathbf { v } _ { k } ( t ) , } \end{array}$$
where ${ \mathbf { u } } _ { L + 1 , k } ( t )$ is the $k$ -th left singular vector of $W _ { L + 1 } ( t )$ , $\mathbf { v } _ { k } ( t )$ is the $k$ -th right singular vector of $\Pi ( t )$ , $M$ is a constant, and $G ( t )$ is defined as
$$G ( t ) = \sum _ { c = 1 } ^ { C } \mu _ { c } ( \mathbf { e } _ { c } - \bar { \gamma } _ { c } ( t ) ) \bar { X } _ { c } ^ { \top } ,$$
where $\mu _ { c }$ $\iota _ { c } , \mathbf { e } _ { c } , \bar { \gamma } _ { c } ( t )$ , $\bar { X } _ { c }$ are defined after Eqn. (2).
The proof of the precise version of Theorem 1 is provided in Appendix A.
Based on Theorem 1, we are able to explain why greater data heterogeneity causes $\Pi ( t )$ to be biased to become lower-rank. Note that strong data heterogeneity causes local training data of one client being highly imbalanced in terms of the number of data samples per class (recall Fig. 1(a)). This implies that $\mu _ { c }$ , which is the proportion of the class $c$ data, will be close to 0 for some classes.
Next, based on the definition of $G ( t )$ in Eqn. (4), more $\mu _ { c }$ βs being close to 0 leads to $G ( t )$ being biased towards a low-rank matrix. If this is so, the term $( \mathbf { \bar { u } } _ { L + 1 , k } ( \mathbf { \bar { \Psi } } _ { k } ( t ) ) ^ { \top } G ( t ) \mathbf { v } _ { k } ( t )$ in Eqn. (3) will only be significant (large in magnitude) for fewer values of $k$ . This is because ${ \bf u } _ { L + 1 , k } ( t )$ and $\mathbf { v } _ { k } ( t )$ are both singular vectors, which are orthogonal among different $k$ βs. This further leads to $\dot { \sigma } _ { k } ( t )$ on the left-hand side of Eqn. (3), which is the evolving rate of $\sigma _ { k }$ , being small for most of the $k$ βs throughout training. These observations imply that only relatively few singular values of $\Pi ( t )$ will increase significantly after training.
Furthermore, $\Pi ( t )$ being biased towards being low-rank will directly lead to dimensional collapse for the representations. To see this, we simply write the covariance matrix of the representations in terms of ${ \bar { \Pi } } ( t )$ as
$$\Sigma ( t ) = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } ( { \bf z } _ { i } ( t ) - \bar { \bf z } ( t ) ) ( { \bf z } _ { i } ( t ) - \bar { \bf z } ( t ) ) ^ { \top } = \Pi ( t ) \biggl ( \frac { 1 } { N } \sum _ { i = 1 } ^ { N } ( X _ { i } - \bar { X } ) ( X _ { i } - \bar { X } ) ^ { \top } \biggr ) \Pi ( t ) ^ { \top } .$$
From Eqn. (5), we observe that if $\Pi ( t )$ evolves to being a lower-rank matrix, $\Sigma ( t )$ will also tend to be lower-rank, which corresponds to the stronger dimensional collapse observed in Fig. 2(b).
 Figure 3: FEDDECORR effectively mitigates dimensional collapse for (a-b) local models and (c-d) global models. For each heterogeneity parameter $\alpha \in \{ 0 . 0 1 , 0 . { \overset { \cdot } { 0 } } 5 \}$ , we apply FEDDECORR and plot the singular values of the representation covariance matrix. The $x$ -axis $( k )$ is the index of singular values. With FEDDECORR, the tail singular values are prevented from dropping to 0 too rapidly.
# 4 MITIGATING DIMENSIONAL COLLAPSE WITH FEDDECORR
Motivated by the above observations and analyses on dimensional collapse caused by data heterogeneity in federated learning, we explore how to mitigate excessive dimensional collapse.
Since dimensional collapse on the global model is inherited from local models, we propose to alleviate the problem during local training. One natural way to achieve this is to add the following regularization term on the representations during training
$$L _ { \mathrm { s i n g u l a r } } ( w , X ) = { \frac { 1 } { d } } \sum _ { i = 1 } ^ { d } { \bigg ( } \lambda _ { i } - { \frac { 1 } { d } } \sum _ { j = 1 } ^ { d } \lambda _ { j } { \bigg ) } ^ { 2 } ,$$
where $\lambda _ { i }$ is the $i$ -th singular value of the covariance matrix of the representations. Essentially, $L _ { \mathrm { s i n g u l a r } }$ penalizes the variance among the singular values, thus discouraging the tail singular values from collapsing to 0, mitigating dimensional collapse. However, this regularization term is not practical as it requires calculating all the singular values, which is computationally expensive.
Therefore, to derive a computationally-cheap training objective, we first apply the $\mathbf { Z }$ -score normalization on all the representation vectors $\mathbf { z } _ { i }$ as follows: $\hat { \mathbf { z } } _ { i } = ( \mathbf { z } _ { i } - \bar { \mathbf { z } } ) / \sqrt { \mathrm { V a r } ( \mathbf { z } ) }$ . This results in the covariance matrix of $\hat { \mathbf { z } } _ { i }$ being equal to its correlation matrix (i.e., the matrix of correlation coefficients). The following proposition suggests a more convenient cost function to regularize.
Proposition 1. For a $d$ -by- $d$ correlation matrix $K$ with singular values $( \lambda _ { 1 } , \ldots , \lambda _ { d } )$ , we have:
$$\sum _ { i = 1 } ^ { d } \left( \lambda _ { i } - \frac { 1 } { d } \sum _ { j = 1 } ^ { d } \lambda _ { j } \right) ^ { 2 } = \| K \| _ { \mathrm { F } } ^ { 2 } - d .$$
The proof of Proposition 1 can be found in Appendix B. This proposition suggests that regularizing the Frobenius norm of the correlation matrix $\| K \| _ { \mathrm { F } }$ achieves the same effect as minimizing $L _ { \mathrm { s i n g u l a r } }$ . In contrast to the singular values, $\| K \| _ { \mathrm { F } }$ can be computed efficiently.
To leverage this proposition, we propose a novel method, FEDDECORR, which regularizes the Frobenius norm of the correlation matrix of the representation vectors during local training on each client. Formally, the proposed regularization term is defined as:
$$L _ { \mathrm { F e d D e c o r r } } ( w , X ) = \frac { 1 } { d ^ { 2 } } \| K \| _ { \mathrm { F } } ^ { 2 } ,$$
where $w$ is the model parameters, $K$ is the correlation matrix of the representations. The overall objective of each local client is
$$\operatorname* { m i n } _ { w } \ell ( w , X , \mathbf { y } ) + \beta L _ { \mathrm { F e d D e c o r r } } ( w , X ) ,$$
where $\ell$ is the cross entropy loss, and $\beta$ is the regularization coefficient of FEDDECORR. The pseudocode of our method is provided in Appendix $\mathbf { G }$ .
To visualize the effectiveness of $L _ { \mathrm { F e d D e c o r r } }$ in mitigating dimensional collapse, we now revisit the experiments of Fig. 2 and apply $L _ { \mathrm { F e d D e c o r r } }$ under the heterogeneous setting where $\alpha \in \{ 0 . 0 1 , 0 . 0 5 \}$ . We plot our results in Fig. 3 for both local and global models. Figs. 3(a-b) show that for local models, FEDDECORR encourages the tail singular values to not collapse to 0, thus effectively mitigating dimensional collapse. Moreover, as illustrated in Figs. 3(c-d), this desirable effect introduced by FEDDECORR on local models can also be inherited by the global models.
<table><tr><td rowspan="2">Method</td><td colspan="4">CIFAR10</td><td colspan="4">CIFAR100</td></tr><tr><td>Ξ±= 0.05</td><td>0.1</td><td>0.5</td><td>8</td><td>0.05</td><td>0.1</td><td>0.5</td><td>8</td></tr><tr><td>FedAvg</td><td>64.85Β±2.01 76.28Β±1.22 89.84Β±0.13 92.39Β±0.26 59.87Β±0.25 66.46Β±0.16 71.69Β±0.15 74.54Β±0.15</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>FedProx</td><td>+ FEDDEC0RR 73.06Β±0.81 80.60Β±0.91 89.84Β±0.05 92.19Β±0.10 61.53Β±0.11 67.12Β±0.09 71.91Β±0.04 73.87Β±0.18</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>+ FEDDEC0RR 71.38Β±0.81 81.74Β±0.34 89.96Β±0.26 92.14Β±0.20 61.33Β±0.19 67.00Β±0.46 71.64Β±0.10 74.15Β±0.06</td><td></td><td></td><td></td><td></td><td></td><td></td><td>64.11Β±0.84 76.10Β±0.40 89.57Β±0.04 92.38Β±0.09 60.02Β±0.46 66.41Β±0.27 71.78Β±0.19 74.34Β±0.03</td><td></td></tr><tr><td>FedAvgM</td><td></td><td></td><td></td><td></td><td>71.34Β±0.71 77.51Β±0.58 88.39Β±0.17 91.35Β±0.15 59.64Β±0.20 66.36Β±0.14 71.17Β±0.22 74.20Β±0.16</td><td></td><td></td><td></td></tr><tr><td>MOON</td><td>+ FEDDEC0RR 73.60Β±0.82 79.21Β±0.15 88.70Β±0.26 91.33Β±0.13 61.48Β±0.27 66.60Β±0.1171.26Β±0.21 73.86Β±0.25</td><td></td><td></td><td></td><td>68.79Β±0.69 78.70Β±0.66 90.08Β±0.10 92.62Β±0.17 56.79Β±0.17 65.48Β±0.29 71.81Β±0.14 74.30Β±0.12</td><td></td><td></td><td></td></tr><tr><td></td><td>+ FEDDEC0RR 73.46Β±0.84 81.63Β±0.5590.61Β±0.05 92.63Β±0.19 59.43Β±0.34 66.12Β±0.20 71.68Β±0.05 73.70Β±0.25</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
Table 1: CIFAR10/100 Experiments. We run experiments under various degrees of heterogeneity $( \alpha \in \{ 0 . 0 5 , 0 . 1 , 0 . 5 , \infty \} )$ and report the test accuracy $( \% )$ . All results are (re)produced by us and are averaged over 3 runs (mean $\pm$ std). Bold font highlights the highest accuracy in each column.
# 5 EXPERIMENTS
# 5.1 EXPERIMENTAL SETUPS
Datasets: We adopt three popular benchmark datasets, namely CIFAR10, CIFAR100, and TinyImageNet. CIFAR10 and CIFAR100 both have 50, 000 training samples and 10, 000 test samples, and the size of each image is $3 2 \times 3 2$ . TinyImageNet contains 200 classes, with 100, 000 training samples and 10, 000 testing samples, and each image is $6 4 \times 6 4$ . The method generating local data for each client was introduced in Sec. 3.1.
Implementation Details: Our code is based on the code of Li et al. (2021b). For all experiments, we use MobileNetV2 (Sandler et al., 2018). We run 100 communication rounds for all experiments on the CIFAR10/100
<table><tr><td rowspan="2">Method</td><td colspan="3">TinyImageNet</td></tr><tr><td>Ξ± = 0.050.1</td><td>0.5</td><td>8</td></tr><tr><td>FedAvg</td><td colspan="3">35.02Β±0.46 39.30Β±0.23 46.92Β±0.25 49.33Β±0.19</td></tr><tr><td></td><td colspan="3">+ FEDDEC0RR 40.29Β±0.18 43.86Β±0.50 50.01Β±0.27 52.63Β±0.26</td></tr><tr><td>FedProx</td><td colspan="3">35.20Β±0.30 39.66Β±0.43 47.16Β±0.0749.76Β±0.36 + FEDDEC0RR 40.63Β±0.05 44.19Β±0.14 50.26Β±0.27 52.37Β±0.36</td></tr><tr><td>FedAvgM</td><td colspan="3">34.81Β±0.09 39.72Β±0.11 47.11Β±0.04 49.67Β±0.25</td></tr><tr><td></td><td colspan="3">+ FEDDEC0RR 39.97Β±0.23 43.95Β±0.26 50.14Β±0.11 52.05Β±0.37</td></tr><tr><td>MOON</td><td colspan="3">35.23Β±0.26 40.53Β±0.28 47.25Β±0.6650.48Β±0.57 + FEDDEC0RR 40.40Β±0.24 44.20Β±0.22 50.81Β±0.51 53.01Β±0.45</td></tr></table>
Table 2: TinyImageNet Experiments. We run with $\alpha \in$ $\{ 0 . 0 5 , 0 . 1 , 0 . 5 , \infty \} )$ and report the test accuracy $( \% )$ . All results are (re)produced by us and are averaged over 3 runs (mean $\pm$ std is reported). Bold font highlights the highest accuracy in each column.
datasets and 50 communication rounds on the TinyImageNet dataset. We conduct local training for 10 epochs in each communication round using SGD optimizer with a learning rate of 0.01, a SGD momentum of 0.9, and a batch size of 64. The weight decay is set to $1 0 ^ { - 5 }$ for CIFAR10 and $1 0 ^ { - 4 }$ for CIFAR100 and TinyImageNet. We apply the data augmentation of Cubuk et al. (2018) in all CIFAR100 and TinyImageNet experiments. The $\beta$ of FEDDECORR (i.e., $\beta$ in Eqn. (9)) is tuned to be 0.1. The details of tuning hyper-parameters for other federated learning methods are described in Appendix F.
# 5.2 FEDDECORR SIGNIFICANTLY IMPROVES BASELINE METHODS
To validate the effectiveness of our method, we apply FEDDECORR to four baselines, namely FedAvg (McMahan et al., 2017), FedAvgM (Hsu et al., 2019), FedProx (Li et al., 2020), and MOON (Li et al., 2021b). We partition the three benchmark datasets (CIFAR10, CIFAR100, and TinyImageNet) into 10 clients with $\alpha \in \{ 0 . 0 5 , 0 . 1 , 0 . 5 , \infty \}$ . Since $\alpha = \infty$ is the homogeneous setting where local models should be free from the pitfall of excessive dimensional collapse, we only expect FEDDECORR to perform on par with the baselines in this setting.
We display the CIFAR10/100 results in Tab. 1 and the TinyImageNet results in Tab. 2. We observe that for all of the heterogeneous settings on all datasets, the highest accuracies are achieved by adding FEDDECORR on top of a certain baseline method. In particular, in the strongly heterogeneous settings where $\alpha \in \{ 0 . 0 5 , 0 . 1 \}$ , adding FEDDECORR yields significant improvements of around $2 \% \sim \mathbf { \bar { g } } \%$ over baseline methods on all datasets. On the other hand, for the less heterogeneous setting of $\alpha = 0 . 5$ , the problem of dimensional collapse is less pronounced as discussed in Sec 3, leading to smaller improvements from FEDDECORR. Such decrease in improvements is a general trend and is also observed on FedProx, FedAvgM, and MOON. In addition, surprisingly, in the homogeneous setting of $\alpha = \infty$ , FEDDECORR still produces around $2 \%$ of improvements on the TinyImageNet dataset. We conjecture that this is because TinyImageNet is much more complicated than the CIFAR datasets, and some other factors besides heterogeneity of label may cause undesirable dimensional collapse in the federated learning setup. Therefore, federated learning on TinyImageNet can benefit from FEDDECORR even in the homogeneous setting.
 Figure 4: Test accuracy $( \% )$ at each communication round. Results are averaged over 3 runs. Shaded areas denote one standard deviation above and below the mean.
To further demonstrate the advantages of FEDDECORR, we apply it on FedAvg and plot how the test accuracy of the global model evolves throughout the federated learning in Fig. 4. In this figure, if we set a certain value of the testing accuracy as a threshold, we see that adding FEDDECORR significantly reduces the number of communication rounds needed to achieve the given threshold. This further shows that FEDDECORR not only improves the final performance, but also greatly boosts the communication efficiency in federated learning.
# 5.3 ABLATION STUDY ON THE NUMBER OF CLIENTS
Table 3: Ablation study on the number of clients. Based on TinyImageNet, we run experiments with different number of clients and different amounts of data heterogeneity.
<table><tr><td># clients</td><td>Method</td><td>Ξ± = 0.05 0.1</td><td>0.5</td></tr><tr><td rowspan="2">10</td><td>FedAvg</td><td>35.02 39.30</td><td>46.92</td></tr><tr><td>+ FEDDECORR</td><td>40.29 43.86</td><td>50.01</td></tr><tr><td rowspan="2">20</td><td>FedAvg</td><td>31.21 35.30</td><td>43.64</td></tr><tr><td>+ FEDDECORR</td><td>39.41 41.27</td><td>46.17</td></tr><tr><td rowspan="2">30</td><td>FedAvg</td><td>26.20 30.88</td><td>37.22</td></tr><tr><td>+ FEDDECORR</td><td>36.50 39.02</td><td>44.38</td></tr><tr><td rowspan="2">50</td><td>FedAvg</td><td>25.70 28.88</td><td>34.89</td></tr><tr><td>+ FEDDECORR</td><td>34.50 36.674</td><td>42.34</td></tr><tr><td rowspan="2">100</td><td>FedAvg</td><td>21.53 </td><td>24.693 30.21</td></tr><tr><td> + FEDDECORR</td><td>30.55</td><td>33.85 38.65</td></tr></table>
Next, we study whether the improvements brought by FEDDECORR are preserved as number of clients increases. We partition the TinyImageNet dataset into 10, 20, 30, 50, and 100 clients according to different $\alpha$ βs, and then run FedAvg with and without FEDDECORR. For
the experiments with 10, 20 and 30 clients, we run 50 communication rounds. For the experiments with 50 and 100 clients, we randomly select $2 0 \%$ of the total clients to participate the federated learning in each round and run 100 communication rounds. Results are shown in Tab. 3. From this table, we see that the performance improvements resulting from FEDDECORR increase from around ${ \mathbf 3 \% } \sim { \mathbf 5 \% }$ to around $\mathbf { 7 \% } \sim \mathbf { 1 0 \% }$ with the growth in the number of clients. Therefore, interestingly, we show through experiments that the improvements brought by FEDDECORR can be even more pronounced under the more challenging settings with more clients. Moreover, our experimental results under random client participation show that the improvements from FEDDECORR are robust to such uncertainties. These experiments demonstrate the potential of FEDDECORR to be applied to real world federated learning settings with massive numbers of clients and random client participation.
 Figure 5: Ablation study on $\beta$ . We apply FEDDECORR with different choices of $\beta$ on FedAvg.
5.4 ABLATION STUDY ON THE REGULARIZATION COEFFICIENT $\beta$
Next, we study FEDDECORRβs robustness to the $\beta$ in Eqn. (9) by varying it in the set $\{ 0 . 0 1 , 0 . 0 5 , 0 . 1 , 0 . 2 , 0 . 3 \}$ . We partition the CIFAR10 and TinyImageNet datasets into 10 clients with $\alpha$ equals to 0.05 and 0.1 to simulate the heterogeneous setting. Results are shown in Fig. 5. We observe that, in general, when $\beta$ increases, the performance of FEDDECORR first increases, then plateaus, and finally decreases slightly. These results show that FEDDECORR is relatively insensitive to the choice of $\beta$ , which implies FEDDECORR is an easy-to-tune federated learning method. In addition, among all experimental setups, setting $\beta$ to be 0.1 consistently produces (almost) the best results. Therefore, we recommend $\beta = 0 . 1$ when having no prior information about the dataset.
# 5.5 ABLATION STUDY ON THE NUMBER OF LOCAL EPOCHS
Lastly, we ablate on the number of local epochs per communication round. We set the number of local epochs $E$ to be in the set $\{ 1 , 5 , 1 0 , 2 0 \}$ . We run experiments with and without FEDDECORR, and we use the CIFAR100 and TinyImageNet datasets with $\alpha$ being 0.05 and 0.1 for this ablation study. Results are shown in Tab. 4, in which one observes that with increasing $E$ , FEDAVG performance first increases and then decreases. This is because when $E$ is too small, the local training cannot converge properly in each communication round. On the other hand, when $E$ is too large, the model parameters of local clients might be driven to be too far from the global optimum. Nevertheless,
Table 4: Ablation study on local epochs. Experiments with different number of local epochs $E$ .
<table><tr><td rowspan="2">E</td><td rowspan="2">Method</td><td>CIFAR100</td><td>TinyImageNet</td></tr><tr><td>Ξ± = 0.05 0.1</td><td>0.05 0.1</td></tr><tr><td rowspan="2">1</td><td>FedAvg</td><td>50.67 55.98</td><td>32.31 34.88</td></tr><tr><td>+ FEDDECORR</td><td>53.18 57.02</td><td>36.49 38.99</td></tr><tr><td rowspan="2">5</td><td>FedAvg</td><td>59.57</td><td>65.0236.02 40.75</td></tr><tr><td> + FEDDECORR</td><td>61.42 65.98</td><td>41.68 44.77</td></tr><tr><td rowspan="2">10</td><td>FedAvg</td><td>59.87 66.46</td><td>535.02 39.30</td></tr><tr><td> + FEDDECORR</td><td>61.53</td><td>67.12 40.29 43.86</td></tr><tr><td rowspan="2">20</td><td>FedAvg</td><td>58.50 </td><td>66.3731.23 37.23</td></tr><tr><td>+ FEDDECORR</td><td>60.65</td><td>66.86 35.44 42.04</td></tr></table>
FEDDECORR consistently improves over the baselines across different choices of local epochs $E$ .
# 5.6 ADDITIONAL EMPIRICAL ANALYSES
We present more empirical analyses in Appendix C. These include comparing FEDDECORR with other baselines (Appendix C.4) and other decorrelation methods (Appendix C.2), experiments on other model architectures (Appendix C.3) and another type of data heterogeneity (Appendix C.5), and discussing the computational advantage of FEDDECORR (Appendix C.1).
# 6 CONCLUSION
In this work, we study representations of trained models under federated learning in which the data held by clients are heterogeneous. Through extensive empirical observations and theoretical analyses, we show that stronger data heterogeneity results in more severe dimensional collapse for both global and local representations. Motivated by this, we propose FEDDECORR, a novel method to mitigate dimensional collapse during local training, thus improving federated learning under the heterogeneous data setting. Extensive experiments on benchmark datasets show that FEDDECORR yields consistent improvements over existing baseline methods.
# ACKNOWLEDGEMENTS
The authors would like to thank anonymous reviewers for the constructive feedback. Yujun Shi and Vincent Tan are supported by Singapore Ministry of Education Tier 1 grants (Grant Number: A-0009042-01-00, A-8000189-01-00, A-8000980-00-00) and a Singapore National Research Foundation (NRF) Fellowship (Grant Number: A-0005077-01-00). Jian Liang is supported by National Natural Science Foundation of China (Grant No. 62276256) and Beijing Nova Program under Grant Z211100002121108.
# REPRODUCIBILITY STATEMENT
All source code has been released at https://github.com/bytedance/FedDecorr. Pseudo-code of FEDDECORR is provided in Appendix G. We introduced all the implementation details of baselines and our method in Sec. 5.1. In addition, the proofs of Theorem 1 and Proposition 1 are provided in Appendix A and Appendix B, respectively. All assumptions are stated and discussed in the proof.
# REFERENCES
Durmus Alp Emre Acar, Yue Zhao, Ramon Matas Navarro, Matthew Mattina, Paul N Whatmough, and Venkatesh Saligrama. Federated learning based on dynamic regularization. arXiv preprint arXiv:2111.04263, 2021.
Maruan Al-Shedivat, Jennifer Gillenwater, Eric Xing, and Afshin Rostamizadeh. Federated learning via posterior averaging: A new perspective and practical algorithms. arXiv preprint arXiv:2010.05273, 2020.
Manoj Ghuhan Arivazhagan, Vinay Aggarwal, Aaditya Kumar Singh, and Sunav Choudhary. Federated learning with personalization layers. arXiv preprint arXiv:1912.00818, 2019.
Sanjeev Arora, Nadav Cohen, and Elad Hazan. On the optimization of deep networks: Implicit acceleration by overparameterization. In International Conference on Machine Learning, pp. 244β253. PMLR, 2018.
Sanjeev Arora, Nadav Cohen, Wei Hu, and Yuping Luo. Implicit regularization in deep matrix factorization. Advances in Neural Information Processing Systems, 32, 2019.
Adrien Bardes, Jean Ponce, and Yann LeCun. Vicreg: Variance-invariance-covariance regularization for self-supervised learning. arXiv preprint arXiv:2105.04906, 2021.
Michael Cogswell, Faruk Ahmed, Ross Girshick, Larry Zitnick, and Dhruv Batra. Reducing overfitting in deep networks by decorrelating representations. arXiv preprint arXiv:1511.06068, 2015.
Ekin D Cubuk, Barret Zoph, Dandelion Mane, Vijay Vasudevan, and Quoc V Le. Autoaugment: Learning augmentation policies from data. arXiv preprint arXiv:1805.09501, 2018.
Alireza Fallah, Aryan Mokhtari, and Asuman Ozdaglar. Personalized federated learning with theoretical guarantees: A model-agnostic meta-learning approach. Advances in Neural Information Processing Systems, 33:3557β3568, 2020.
Filip Hanzely, SlavomΒ΄Δ±r Hanzely, Samuel Horvath, and Peter Richt Β΄ arik. Lower bounds and opti- Β΄ mal algorithms for personalized federated learning. Advances in Neural Information Processing Systems, 33:2304β2315, 2020.
Tzu-Ming Harry Hsu, Hang Qi, and Matthew Brown. Measuring the effects of non-identical data distribution for federated visual classification. arXiv preprint arXiv:1909.06335, 2019.
Tianyu Hua, Wenxiao Wang, Zihui Xue, Sucheng Ren, Yue Wang, and Hang Zhao. On feature decorrelation in self-supervised learning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 9598β9608, 2021.
Lei Huang, Dawei Yang, Bo Lang, and Jia Deng. Decorrelated batch normalization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 791β800, 2018.
Yutao Huang, Lingyang Chu, Zirui Zhou, Lanjun Wang, Jiangchuan Liu, Jian Pei, and Yong Zhang. Personalized cross-silo federated learning on non-iid data. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 7865β7873, 2021.
Ziwei Ji and Matus Telgarsky. Gradient descent aligns the layers of deep linear networks. arXiv preprint arXiv:1810.02032, 2018.
Li Jing, Pascal Vincent, Yann LeCun, and Yuandong Tian. Understanding dimensional collapse in contrastive self-supervised learning. arXiv preprint arXiv:2110.09348, 2021.
Sai Praneeth Karimireddy, Satyen Kale, Mehryar Mohri, Sashank Reddi, Sebastian Stich, and Ananda Theertha Suresh. Scaffold: Stochastic controlled averaging for federated learning. In International Conference on Machine Learning, pp. 5132β5143. PMLR, 2020.
Qinbin Li, Yiqun Diao, Quan Chen, and Bingsheng He. Federated learning on non-iid data silos: An experimental study. arXiv preprint arXiv:2102.02079, 2021a.
Qinbin Li, Bingsheng He, and Dawn Song. Model-contrastive federated learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10713β10722, 2021b.
Tian Li, Anit Kumar Sahu, Manzil Zaheer, Maziar Sanjabi, Ameet Talwalkar, and Virginia Smith. Federated optimization in heterogeneous networks. Proceedings of Machine Learning and Systems, 2:429β450, 2020.
Tian Li, Shengyuan Hu, Ahmad Beirami, and Virginia Smith. Ditto: Fair and robust federated learning through personalization. In International Conference on Machine Learning, pp. 6357β 6368. PMLR, 2021c.
Tao Lin, Lingjing Kong, Sebastian U Stich, and Martin Jaggi. Ensemble distillation for robust model fusion in federated learning. Advances in Neural Information Processing Systems, 33:2351β2363, 2020.
Mi Luo, Fei Chen, Dapeng Hu, Yifan Zhang, Jian Liang, and Jiashi Feng. No fear of heterogeneity: Classifier calibration for federated learning with non-iid data. Advances in Neural Information Processing Systems, 34, 2021.
Brendan McMahan, Eider Moore, Daniel Ramage, Seth Hampson, and Blaise Aguera y Arcas. Communication-efficient learning of deep networks from decentralized data. In Artificial intelligence and statistics, pp. 1273β1282. PMLR, 2017.
Sashank Reddi, Zachary Charles, Manzil Zaheer, Zachary Garrett, Keith Rush, Jakub KonecnΛ y,\` Sanjiv Kumar, and H Brendan McMahan. Adaptive federated optimization. arXiv preprint arXiv:2003.00295, 2020.
Karsten Roth, Timo Milbich, Samarth Sinha, Prateek Gupta, Bjorn Ommer, and Joseph Paul Cohen. Revisiting training strategies and generalization performance in deep metric learning. In International Conference on Machine Learning, pp. 8242β8252. PMLR, 2020.
Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, and Liang-Chieh Chen. Mobilenetv2: Inverted residuals and linear bottlenecks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4510β4520, 2018.
Yujun Shi, Kuangqi Zhou, Jian Liang, Zihang Jiang, Jiashi Feng, Philip HS Torr, Song Bai, and Vincent YF Tan. Mimicking the oracle: an initial phase decorrelation approach for class incremental learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 16722β16731, 2022.
Canh T Dinh, Nguyen Tran, and Josh Nguyen. Personalized federated learning with moreau envelopes. Advances in Neural Information Processing Systems, 33:21394β21405, 2020.
Hongyi Wang, Mikhail Yurochkin, Yuekai Sun, Dimitris Papailiopoulos, and Yasaman Khazaeni. Federated learning with matched averaging. arXiv preprint arXiv:2002.06440, 2020a.
Jianyu Wang, Qinghua Liu, Hao Liang, Gauri Joshi, and H Vincent Poor. Tackling the objective inconsistency problem in heterogeneous federated optimization. Advances in neural information processing systems, 33:7611β7623, 2020b.
Lixu Wang, Shichao Xu, Xiao Wang, and Qi Zhu. Addressing class imbalance in federated learning. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 10165β10173, 2021.
Wei Xiong, Bo Du, Lefei Zhang, Ruimin Hu, and Dacheng Tao. Regularizing deep convolutional neural networks with a structured decorrelation constraint. In 2016 IEEE 16th International Conference on Data Mining (ICDM), pp. 519β528. IEEE, 2016.
Mikhail Yurochkin, Mayank Agarwal, Soumya Ghosh, Kristjan Greenewald, Nghia Hoang, and Yasaman Khazaeni. Bayesian nonparametric federated learning of neural networks. In International Conference on Machine Learning, pp. 7252β7261. PMLR, 2019.
Jure Zbontar, Li Jing, Ishan Misra, Yann LeCun, and Stephane Deny. Barlow twins: Self-supervised Β΄ learning via redundancy reduction. In International Conference on Machine Learning, pp. 12310β 12320. PMLR, 2021.
Michael Zhang, Karan Sapra, Sanja Fidler, Serena Yeung, and Jose M Alvarez. Personalized federated learning with first order model optimization. arXiv preprint arXiv:2012.08565, 2020.
# A PROOF OF THEOREM 1 IN MAIN PAPER
# A.1 NOTATIONS REVISITED
Here, for the readerβs convenience, we summarize the notations used in both the main text and this appendix.
<table><tr><td>Notation N</td><td>Explanation Number of training data points.</td></tr><tr><td>C X y Y Wi(t) I(t) 01,k ul,k Vl,k 0k Uk Vk Nc ΞΌc ec</td><td>Total number of classes. The collection of the N training samples, X β Rdin Γ N. The collection of one hot labels of the N training samples,y β RCΓN. The collection of model output softmax vectors givenall N input data,y β RCN The i-th layer weight matrix at the t-th optimization step. The product of the weight matrices of the first L layers: II(t) = WL(t) ...Wi(t). The k-th singular value of Wt . The k-th left singular vector of Wt. The k-th right singular vector of Wt.</td></tr></table>
# A.2 TWO LEMMAS
Here, we elaborate two useful lemmas from Arora et al. (2019; 2018).
The first lemma is adopted from Arora et al. (2019):
Lemma 1. Assuming the weight matrix $W$ evolves under gradient descent dynamics with infinitesimally small learning rate, the $k$ -th singular value of this matrix (denoted as $\sigma _ { k }$ ) evolves as
$$\begin{array} { r } { \dot { { \boldsymbol \sigma } } _ { k } ( t ) = ( { \mathbf u } _ { k } ( t ) ) ^ { \top } \dot { W } ( t ) { \mathbf v } _ { k } ( t ) , } \end{array}$$
where ${ \bf u } _ { k } ( t )$ and $\mathbf { v } _ { k } ( t )$ are the $k$ -th left and right singular vectors of $W ( t )$ , respectively.
Proof. By performing an SVD on $W ( t )$ , we have $W ( t ) = U ( t ) S ( t ) V ( t ) ^ { \top }$ . Therefore, by the chain rule in differention, we have:
$$\dot { W } ( t ) = \dot { U } ( t ) S ( t ) V ( t ) ^ { \top } + U ( t ) \dot { S } ( t ) V ( t ) ^ { \top } + U ( t ) S ( t ) \dot { V } ( t ) ^ { \top } .$$
Next, for both sides of the above equation, we left multiply $U ( t ) ^ { \top }$ and right multiply $V ( t )$
$$U ( t ) ^ { \top } \dot { W } ( t ) V ( t ) = U ( t ) ^ { \top } \dot { U } ( t ) S ( t ) + \dot { S } ( t ) + S ( t ) ( \dot { V } ( t ) ) ^ { \top } V ( t ) .$$
ince $S ( t )$ is a diagonal matrix, we consider the $k$ -th diagonal entry of $S ( t )$ , namely $\sigma _ { k } ( t )$
$$\begin{array} { r } { ( \mathbf { u } _ { k } ( t ) ) ^ { \top } \dot { W } ( t ) \mathbf { v } _ { k } ( t ) = ( \mathbf { u } _ { k } ( t ) ) ^ { \top } \dot { \mathbf { u } } _ { k } ( t ) \sigma _ { k } ( t ) + \dot { \sigma } _ { k } ( t ) + \sigma _ { k } ( t ) ( \mathbf { v } _ { k } ( t ) ) ^ { \top } \dot { \mathbf { v } } _ { k } ( t ) . } \end{array}$$
Since ${ \bf u } _ { k } ( t )$ and $\mathbf { v } _ { k } ( t )$ are unit vectors and are evolving in time with infinitesimal rate, we have $( { \mathbf { u } } _ { k } ( t ) ) ^ { \top } \dot { { \mathbf { u } } } _ { k } ( t ) = 0$ and $( { \bf v } _ { k } ( t ) ) ^ { \top } \dot { \bf v } _ { k } ( t ) = 0$ . Next, Eqn. (13) can be simplified as
$$\begin{array} { r } { \dot { { \boldsymbol \sigma } } _ { k } ( t ) = ( { \mathbf u } _ { k } ( t ) ) ^ { \top } \dot { W } ( t ) { \mathbf v } _ { k } ( t ) . } \end{array}$$
The proof is thus complete.
The second lemma is adopted from Arora et al. (2018).
Lemma 2. Given $L$ consecutive linear layers in a neural network characterized by weight matrices $W _ { 1 } , W _ { 2 } , \ldots , W _ { L }$ . We denote $\Pi = W _ { L } W _ { L - 1 } \ldots W _ { 1 }$ . We further denote $W _ { j } ( t )$ as weight matrix $W _ { j }$ after the $t$ -th gradient descent optimization step. Correspondingly, the initialization of $W _ { j }$ is $W _ { j } ( 0 )$ . Assuming we have $W _ { j } ( 0 ) ( W _ { j } ( 0 ) ) ^ { \top } = ( W _ { j + 1 } ( 0 ) ) ^ { \top } W _ { j + 1 } ( 0 )$ for any $j \in [ L - 1 ]$ at initialization. Then, under the gradient descent dynamics, $\Pi ( t )$ satisfies
$$\dot { \Pi } ( t ) = - \sum _ { j = 1 } ^ { L } \left[ \Pi ( t ) \Pi ( t ) ^ { \top } \right] ^ { \frac { L - j } { L } } \frac { \partial \ell ( \Pi ( t ) ) } { \partial \Pi } \left[ \Pi ( t ) ^ { \top } \Pi ( t ) \right] ^ { \frac { j - 1 } { L } } ,$$
where $[ \cdot ] ^ { \frac { L - j } { L } }$ and $[ \cdot ] ^ { \frac { j - 1 } { L } }$ are fractional power operators defined over positive semi-definite matrices.
Proof. Here, we first define some additional notation. Given any square matrices (or possibly scalar) $A _ { 1 } , A _ { 2 } , \ldots , A _ { m }$ , we denote $\mathrm { d i a g } ( A _ { 1 } , A _ { 2 } , \ldots , A _ { m } )$ to be the block diagonal matrix
$$\mathrm { d i a g } ( A _ { 1 } , A _ { 2 } , \ldots , A _ { m } ) = \left[ \begin{array} { c c c c } { { A _ { 1 } } } & { { 0 } } & { { 0 } } & { { 0 } } \\ { { 0 } } & { { A _ { 2 } } } & { { 0 } } & { { 0 } } \\ { { 0 } } & { { 0 } } & { { \ddots } } & { { 0 } } \\ { { 0 } } & { { 0 } } & { { 0 } } & { { A _ { m } } } \end{array} \right] .$$
Here, we first consider dynamics of an arbitrary $W _ { j }$ where $j \in [ L - 1 ]$ . By the chain rule, we have
$$\begin{array} { l } { \dot { W } _ { j } ( t ) = - \frac { \partial \ell ( W _ { 1 } ( t ) , \dots , W _ { L + 1 } ( t ) ) } { \partial W _ { j } ( t ) } } \\ { \quad \qquad = - ( W _ { j + 1 } ( t ) ^ { \top } \dots W _ { L } ( t ) ^ { \top } ) \frac { \partial \ell ( \Pi ( t ) ) } { \partial \Pi } ( W _ { 1 } ( t ) ^ { \top } \dots W _ { j - 1 } ( t ) ^ { \top } ) . } \end{array}$$
Given Eqn. (16), we right multiply $\dot { W } _ { j } ( t )$ by $( W _ { j } ( t ) ) ^ { \top }$ and we left multiply $\dot { W } _ { j + 1 } ( t )$ by $( W _ { j + 1 } ( t ) ) ^ { \top }$ , which yields
$$\dot { W } _ { j } ( t ) ( W _ { j } ( t ) ) ^ { \top } = ( W _ { j + 1 } ( t ) ) ^ { \top } \dot { W } _ { j + 1 } ( t ) .$$
Applying the same trick on $W _ { j } ( t ) ^ { \top }$ and $W _ { j + 1 } ( t ) ^ { \top }$ yields
$$W _ { j } ( t ) ( \dot { W } _ { j } ( t ) ) ^ { \top } = ( \dot { W } _ { j + 1 } ( t ) ) ^ { \top } W _ { j + 1 } ( t ) .$$
Adding Eqns. (17) and (18) on both sides yields
$$\dot { W } _ { j } ( t ) ( W _ { j } ( t ) ) ^ { \top } + W _ { j } ( t ) ( \dot { W } _ { j } ( t ) ) ^ { \top } = W _ { j + 1 } ( t ) ^ { \top } \dot { W } _ { j + 1 } ( t ) + ( \dot { W } _ { j + 1 } ( t ) ) ^ { \top } W _ { j + 1 } ( t ) .$$
Next, by the chain rule for differentiation, Eqn. (19) directly implies that
$$\frac { \mathrm { d } ( W _ { j } ( t ) W _ { j } ( t ) ^ { \top } ) } { \mathrm { d } t } = \frac { \mathrm { d } ( W _ { j + 1 } ( t ) ^ { \top } W _ { j + 1 } ( t ) ) } { \mathrm { d } t } .$$
Since we have assumed that $W _ { j } ( 0 ) W _ { j } ( 0 ) ^ { \top } = W _ { j + 1 } ( 0 ) ^ { \top } W _ { j + 1 } ( 0 )$ , we can conclude that
$$W _ { j } ( t ) W _ { j } ( t ) ^ { \top } = W _ { j + 1 } ( t ) ^ { \top } W _ { j + 1 } ( t ) .$$
Next, we apply an SVD on $W _ { j } ( t )$ and $W _ { j + 1 } ( t )$ in Eqn. (21). This yields
$$U _ { j } ( t ) S _ { j } ( t ) S _ { j } ^ { \top } ( t ) U _ { j } ^ { \top } ( t ) = V _ { j + 1 } ( t ) S _ { j + 1 } ^ { \top } ( t ) S _ { j + 1 } ( t ) V _ { j + 1 } ^ { \top } ( t ) .$$
Based on Eqn. (22) and given the uniqueness property of SVD, we know:
$$S _ { j } ( t ) S _ { j } ( t ) ^ { \top } = S _ { j + 1 } ^ { \top } ( t ) S _ { j + 1 } ( t ) = \mathrm { d i a g } ( \rho _ { 1 } I _ { d _ { 1 } } , \rho _ { 2 } I _ { d _ { 2 } } , \dots , \rho _ { m } I _ { d _ { m } } ) ,$$
where ${ \sqrt { \rho _ { 1 } } } , \ldots , { \sqrt { \rho _ { m } } }$ represent the $m$ distinct singular values satisfying $\rho _ { 1 } > \rho _ { 2 } > . . . > \rho _ { m } \geq 0$ , and $I _ { d _ { r } }$ for any $r \in [ m ]$ are identity matrix of size $d _ { r } \times d _ { r }$ . Since Eqn. (23) holds for any $j$ , we know by induction that the set of values of $\rho$ βs is the same across all layers $j \in [ L ]$ . In addition, there exist orthogonal matrices $O _ { j , r } \in \mathbb { R } ^ { d _ { r } \times \dot { d } _ { r } }$ for any $r \in [ m ]$ such that
$$U _ { j } ( t ) = V _ { j + 1 } ( t ) \mathrm { d i a g } ( O _ { j , 1 } , O _ { j , 2 } , \dots , O _ { j , m } ) .$$
Given Eqns. (24), next, we study $W _ { j + 1 } ( t ) W _ { j } ( t ) W _ { j } ^ { \top } ( t ) W _ { j + 1 } ^ { \top } ( t )$ for any $j \in [ N - 1 ]$ :
$$\begin{array} { r l } & { W _ { j + 1 } ( t ) W _ { j } ( t ) W _ { j } ^ { \top } ( t ) W _ { j + 1 } ^ { \top } ( t ) } \\ & { = U _ { j + 1 } S _ { j + 1 } V _ { j + 1 } ^ { \top } U _ { j } S _ { j } S _ { j } ^ { \top } U _ { j } ^ { \top } V _ { j + 1 } S _ { j + 1 } ^ { \top } U _ { j + 1 } ^ { \top } } \\ & { = U _ { j + 1 } S _ { j + 1 } \mathrm { d i a g } ( O _ { j , 1 } , O _ { j , 2 } , \ldots , O _ { j , m } ) S _ { j } S _ { j } ^ { \top } \mathrm { d i a g } ( O _ { j , 1 } ^ { \top } , O _ { j , 2 } ^ { \top } , \ldots , O _ { j , m } ^ { \top } ) S _ { j + 1 } ^ { \top } U _ { j + 1 } ^ { \top } } \\ & { \qquad \quad \mathrm { ( p l u g g i n g } } \\ & { = U _ { j + 1 } S _ { j + 1 } S _ { j } S _ { j } ^ { \top } S _ { j + 1 } ^ { \top } U _ { j + 1 } ^ { \top } \qquad ( S _ { j } \mathrm { c o m m u t e s ~ w i t h ~ d i a g } ( O _ { j , 1 } , O _ { j , 2 } , \ldots , O _ { j , m } ) ) } \\ & { = U _ { j + 1 } \mathrm { d i a g } ( \rho _ { 1 } ^ { 2 } I _ { d _ { 1 } } , \rho _ { 2 } ^ { 2 } I _ { d _ { 2 } } , \ldots , \rho _ { m } ^ { 2 } I _ { d _ { m } } ) U _ { j + 1 } ^ { \top } . } \end{array}$$
Similarly, it holds that
$$\begin{array} { r } { W _ { j } ^ { \top } ( t ) W _ { j + 1 } ^ { \top } ( t ) W _ { j + 1 } ( t ) W _ { j } ( t ) = V _ { j } \mathrm { d i a g } ( \rho _ { 1 } ^ { 2 } I _ { d _ { 1 } } , \rho _ { 2 } ^ { 2 } I _ { d _ { 2 } } , \dots , \rho _ { m } ^ { 2 } I _ { d _ { m } } ) V _ { j } ^ { \top } . } \end{array}$$
Next, by induction and Eqns. (25),
$$\begin{array} { r l } & { W _ { L } ( t ) \ldots W _ { j } ( t ) W _ { j } ( t ) ^ { \top } \ldots W _ { L } ( t ) ^ { \top } } \\ & { \qquad = U _ { L } \mathrm { d i a g } ( \rho _ { 1 } ^ { L - j + 1 } I _ { d _ { 1 } } , \rho _ { 2 } ^ { L - j + 1 } I _ { d _ { 2 } } , \ldots , \rho _ { m } ^ { L - j + 1 } I _ { d _ { m } } ) U _ { L } ^ { \top } , } \end{array}$$
by induction and Eqns. (26), it holds that
$$\begin{array} { r } { W _ { 1 } ^ { \top } ( t ) \ldots W _ { j } ^ { \top } ( t ) W _ { j } ( t ) \ldots W _ { 1 } ( t ) = V _ { 1 } \mathrm { d i a g } ( \rho _ { 1 } ^ { j } I _ { d _ { 1 } } , \rho _ { 2 } ^ { j } I _ { d _ { 2 } } , \ldots , \rho _ { m } ^ { j } I _ { d _ { m } } ) V _ { 1 } ^ { \top } . } \end{array}$$
From Eqns. (27), we know that for any $j \in [ L - 1 ]$ ,
$$\begin{array} { r l } & { \Pi ( t ) \Pi ( t ) ^ { \top } = W _ { L } ( t ) \ldots W _ { 1 } ( t ) W _ { 1 } ( t ) ^ { \top } \ldots W _ { L } ( t ) ^ { \top } } \\ & { \qquad = U _ { L } \mathrm { d i a g } ( \rho _ { 1 } ^ { L } I _ { d _ { 1 } } , \rho _ { 2 } ^ { L } I _ { d _ { 2 } } , \ldots , \rho _ { m } ^ { L } I _ { d _ { m } } ) U _ { L } ^ { \top } } \\ & { \qquad = \left[ U _ { L } \mathrm { d i a g } ( \rho _ { 1 } ^ { L - j } I _ { d _ { 1 } } , \rho _ { 2 } ^ { L - j } I _ { d _ { 2 } } , \ldots , \rho _ { m } ^ { L - j } I _ { d _ { m } } ) U _ { L } ^ { \top } \right] ^ { \frac { L } { L - j } } } \\ & { \qquad = \left[ W _ { L } ( t ) \ldots W _ { j + 1 } ( t ) W _ { j + 1 } ( t ) ^ { \top } \ldots W _ { L } ( t ) ^ { \top } \right] ^ { \frac { L } { L - j } } . } \end{array}$$
Similarly, from Eqn. (28), we know that for any $2 \leq j \leq L - 1$ ,
$$\begin{array} { r l } & { \Pi ( t ) ^ { \top } \Pi ( t ) = W _ { 1 } ( t ) ^ { \top } \cdot \cdot \cdot W _ { L } ( t ) ^ { \top } W _ { L } ( t ) \cdot \cdot \cdot W _ { 1 } ( t ) } \\ & { \qquad = V _ { 1 } \mathrm { d i a g } ( \rho _ { 1 } ^ { L } I _ { d _ { 1 } } , \rho _ { 2 } ^ { L } I _ { d _ { 2 } } , \cdot \cdot \cdot , \rho _ { m } ^ { L } I _ { d _ { m } } ) V _ { 1 } ^ { \top } } \\ & { \qquad = \Big [ V _ { 1 } \mathrm { d i a g } ( \rho _ { 1 } ^ { j - 1 } I _ { d _ { 1 } } , \rho _ { 2 } ^ { j - 1 } I _ { d _ { 2 } } , \dots , \rho _ { m } ^ { j - 1 } I _ { d _ { m } } ) V _ { 1 } ^ { \top } \Big ] ^ { \frac { L } { j - 1 } } } \\ & { \qquad = \big [ W _ { 1 } ^ { \top } \cdot \dots W _ { j - 1 } ^ { \top } W _ { j - 1 } ( t ) \cdot \dots W _ { 1 } ( t ) \big ] ^ { \frac { L } { j - 1 } } . } \end{array}$$
With everything derived above, we now study the dynamics of $\Pi ( t )$ as follows
$$\begin{array} { l } { { \displaystyle \dot { \mathrm { I I } } ( t ) = \sum _ { j = 1 } ^ { L } \left[ W _ { L } ( t ) \dots W _ { j + 1 } ( t ) \right] ( \dot { W } _ { j } ( t ) ) \left[ W _ { j - 1 } ( t ) \dots W _ { 1 } ( t ) \right] \quad \mathrm { ( d i f f e r e n t i a l ~ c h a i n ~ r u l e ) } } } \\ { { \displaystyle = - \sum _ { j = 1 } ^ { L } \left[ W _ { L } ( t ) \dots W _ { j + 1 } ( t ) W _ { j + 1 } ( t ) ^ { \top } \dots W _ { L } ( t ) ^ { \top } \right] } } \\ { { \displaystyle \qquad \times \frac { \partial \ell ( [ \mathbf { I I } ( t ) ) } { \partial \Pi } \left[ W _ { 1 } ^ { \top } ( t ) \dots W _ { j - 1 } ^ { \top } ( t ) W _ { j - 1 } ( t ) \dots W _ { 1 } ( t ) \right] \quad \mathrm { ( p l u g g i n g - i n ~ ( 1 6 ) ) } } } \\ { { \displaystyle = - \sum _ { j = 1 } ^ { L } \left[ \Pi ( t ) \Pi ( t ) ^ { \top } \right] ^ { \frac { L - j } { \mathrm { x } _ { \mathrm { x } } } } \frac { \partial \ell ( [ \mathbf { I } ( t ) ) } { \partial \Pi } \left[ \Pi ( t ) ^ { \top } \Pi ( t ) \right] ^ { \frac { j - 1 } { \mathrm { x } _ { \mathrm { x } } } } \qquad \mathrm { ( p l u g g g i n g - i n ~ ( 2 9 ) ~ a n d ~ ( 2 6 ) ~ } } } \end{array}$$
This completes the proof.
 Figure 6: Alignment effects between the singular spaces of $W _ { L + 1 } ( t )$ and $\Pi ( t )$ . We train a 3-layer linear neural network on the MNIST dataset and visualize the models at 3, 5, 7, 9 training epochs, respectively. In each figure, the $k ^ { \prime }$ -th row and $k$ -th column pixel is the value of $\vert { \mathbf u } _ { k } ( t ) ^ { \top } { \mathbf v } _ { L + 1 , k ^ { \prime } } ( t ) \vert$ . Darker colors denote values close to 1 while lighter colors denote values close to 0. From the figures, we empirically observe that $| \mathbf { u } _ { k } ( t ) ^ { \top } \mathbf { v } _ { L + 1 , k ^ { \prime } } ( \bar { t } ) | = \mathbb { 1 } \{ k = k ^ { \prime } \}$ approximately holds.
# A.3 ASSUMPTIONS
Assumption 1. We assume that the initial values of the weight matrices satisfy $W _ { i + 1 } ^ { \top } ( 0 ) W _ { i + 1 } ( 0 ) =$ $W _ { i } ( 0 ) W _ { i } ^ { \top } ( 0 )$ for any $i \in [ L - 1 ]$ .
Assumption 2. We assume $| \mathbf { u } _ { k } ( t ) ^ { \top } \mathbf { v } _ { L + 1 , k ^ { \prime } } ( t ) | = \mathbb { 1 } \{ k = k ^ { \prime } \}$ holds for all $t ,$ , where ${ \bf u } _ { k } ( t )$ is the $k$ -th left singular vector of $\Pi ( t )$ and $\mathbf { v } _ { L + 1 , k ^ { \prime } } ( t )$ is the $k ^ { \prime }$ -th right singular vector of $W _ { L + 1 } ( t )$ .
Remark: For Assumption 1, it can be achieved in practice by proper random initialization. For Assumption 2, Ji & Telgarsky (2018) proved that under some assumptions, gradient descent optimization will drive consecutive layers of linear networks to satisfy it. We also provide empirical evidence in Fig. 6 to corroborate that this assumption approximately holds.
# A.4 PROOF OF THEOREM 1 IN THE MAIN TEXT
Theorem 1 (formally stated). Let $\sigma _ { k } ( t )$ for $k \in [ d ]$ be the $k$ -th largest singular value of $\Pi ( t )$ . Then, under Assumptions $^ { l }$ and 2, we have
$$\begin{array} { r } { \dot { \sigma } _ { k } ( t ) = N L \left( \sigma _ { k } ( t ) \right) ^ { 2 - \frac { 2 } { L } } \sqrt { \left( \sigma _ { k } ( t ) \right) ^ { \frac { 2 } { L } } + M } \left( \mathbf { u } _ { L + 1 , k } ( t ) \right) ^ { \top } G ( t ) \mathbf { v } _ { k } ( t ) , } \end{array}$$
where ${ \mathbf { u } } _ { L + 1 , k } ( t )$ is the $k$ -th left singular vector of $W _ { L + 1 } ( t )$ , $\mathbf { v } _ { k } ( t )$ is the $k$ -th right singular vector of $\Pi ( t )$ , $M$ is a constant, and $G ( t )$ is defined as
$$G ( t ) = \sum _ { c = 1 } ^ { C } \mu _ { c } ( \mathbf { e } _ { c } - \bar { \gamma } _ { c } ( t ) ) \bar { X } _ { c } ^ { \top } .$$
Proof. Recall that for $( L + 1 )$ -layer linear neural networks, given the $i$ -th training sample $X _ { i } \in \mathbb { R } ^ { d }$ , we have
$$\gamma _ { i } ( t ) = \mathrm { s o f t m a x } ( W _ { L + 1 } ( t ) { \mathbf z } _ { i } ( t ) ) = \mathrm { s o f t m a x } ( W _ { L + 1 } ( t ) \Pi ( t ) X _ { i } ) ,$$
and the loss is the standard cross-entropy loss defined as follows
$$\ell ( \Pi ( t ) , W _ { L + 1 } ( t ) ) = \sum _ { i = 1 } ^ { N } - \mathbf { y } _ { i } ^ { \top } \log \gamma _ { i } ( t ) .$$
By the chain rule, we can derive gradient of $\ell$ with respect to $W _ { L + 1 }$ and $\Pi$ , which are respectively,
$$\frac { \partial \ell ( \Pi ( t ) , W _ { L + 1 } ( t ) ) } { \partial W _ { L + 1 } } = - ( \mathbf { y } - \boldsymbol { \gamma } ( t ) ) \boldsymbol { X } ^ { \top } \Pi ( t ) ^ { \top } ,$$
and
$$\frac { \partial \ell ( \Pi ( t ) , W _ { L + 1 } ( t ) ) } { \partial \Pi } = - W _ { L + 1 } ( t ) ^ { \top } ( \mathbf { y } - \boldsymbol { \gamma } ( t ) ) \boldsymbol { X } ^ { \top } .$$
Next, under the gradient descent dynamics, the dynamics on $W _ { L + 1 }$ satisfies
$$\dot { W } _ { L + 1 } ( t ) = - \frac { \partial \ell ( \Pi ( t ) , W _ { L + 1 } ( t ) ) } { \partial W _ { L + 1 } } = ( \mathbf { y } - \boldsymbol { \gamma } ( t ) ) \boldsymbol { X } ^ { \top } \Pi ( t ) ^ { \top } ,$$
while the dynamics on $\Pi$ requires invoking Lemma 2, which allows us to write
$$\begin{array} { r l } & { \dot { \Pi } ( t ) = - \displaystyle \sum _ { j = 1 } ^ { L } [ \Pi ( t ) \Pi ( t ) ^ { \top } ] ^ { \frac { L - j } { L } } \frac { \partial \ell ( \Pi ( t ) ) } { \partial \Pi } [ \Pi ( t ) ^ { \top } \Pi ( t ) ] ^ { \frac { j - 1 } { L } } } \\ & { \quad \quad = \displaystyle \sum _ { j = 1 } ^ { L } [ \Pi ( t ) \Pi ( t ) ^ { \top } ] ^ { \frac { L - j } { L } } W _ { L + 1 } ( t ) ^ { \top } ( \mathbf { y } - \boldsymbol { \gamma } ( t ) ) \boldsymbol { X } ^ { \top } [ \Pi ( t ) ^ { \top } \Pi ( t ) ] ^ { \frac { j - 1 } { L } } . } \end{array}$$
Next, we invoke Lemma 1 on Eqn. (39) and Eqn. (38), respectively, yielding:
$$\begin{array} { r l } { \dot { \sigma } _ { k } ( t ) = } & { ( \mathbf { u } _ { k } ( t ) ) ^ { \top } \dot { \Pi } ( t ) ( \mathbf { v } _ { k } ( t ) ) } \\ & { = \displaystyle \sum _ { j = 1 } ^ { L } \mathbf { u } _ { k } ( t ) ^ { \top } [ \Pi ( t ) \Pi ( t ) ^ { \top } ] ^ { \frac { L - i } { L } } W _ { L + 1 } ( t ) ^ { \top } ( \mathbf { y } - \gamma ( t ) ) X ^ { \top } [ \Pi ( t ) ^ { \top } \Pi ( t ) ] ^ { \frac { i - 1 } { L } } \mathbf { v } _ { k } ( t ) } \\ & { = L ( \sigma _ { k } ( t ) ) ^ { 2 - \frac { 2 } { L } } \mathbf { u } _ { k } ( t ) ^ { \top } W _ { L + 1 } ( t ) ^ { \top } ( \mathbf { y } - \gamma ( t ) ) X ^ { \top } \mathbf { v } _ { k } ( t ) } \\ & { \qquad \mathrm { ( S V D ~ o n ~ I ~ } ] } \\ & { = L ( \sigma _ { k } ( t ) ) ^ { 2 - \frac { 2 } { L } } \displaystyle \sum _ { k ^ { \prime } } \sigma _ { L + 1 , k ^ { \prime } } \mathbf { u } _ { k } ( t ) ^ { \top } \mathbf { v } _ { L + 1 , k ^ { \prime } } ( t ) ( \mathbf { u } _ { L + 1 , k ^ { \prime } } ( t ) ) ^ { \top } ( \mathbf { y } - \gamma ( t ) ) X ^ { \top } \mathbf { v } _ { k } ( t ) } \\ & { \qquad \mathrm { ( S V D ~ o n ~ } b } \\ & { = L ( \sigma _ { k } ( t ) ) ^ { 2 - \frac { 2 } { L } } \sigma _ { L + 1 , k } ( \mathbf { u } _ { L + 1 , k } ( t ) ) ^ { \top } ( \mathbf { y } - \gamma ( t ) ) X ^ { \top } \mathbf { v } _ { k } ( t ) \qquad \mathrm { ( A s s u m p i o n 2 ) } . } \end{array}$$
and
$$\begin{array} { r l } & { \dot { \boldsymbol \sigma } _ { L + 1 , k } ( t ) = \mathbf { u } _ { L + 1 , k } ( t ) ^ { \top } ( \mathbf { y } - \boldsymbol \gamma ( t ) ) \boldsymbol X ^ { \top } \boldsymbol \Pi ( t ) ^ { \top } { \mathbf { v } } _ { L + 1 , k } ( t ) } \\ & { \qquad = \displaystyle \sum _ { k ^ { \prime } } \sigma _ { k ^ { \prime } } \mathbf { u } _ { L + 1 , k } ( t ) ^ { \top } ( \mathbf { y } - \boldsymbol \gamma ( t ) ) \boldsymbol X ^ { \top } { \mathbf { v } } _ { k ^ { \prime } } ( t ) \mathbf { u } _ { k ^ { \prime } } ^ { \top } { \mathbf { v } } _ { L + 1 , k } ( t ) } \\ & { \qquad = \sigma _ { k } \mathbf { u } _ { L + 1 , k } ( t ) ^ { \top } ( \mathbf { y } - \boldsymbol \gamma ( t ) ) \boldsymbol X ^ { \top } { \mathbf { v } } _ { k } ( t ) \qquad \mathrm { ( A s s u m p t i o n ~ 2 ) } . } \end{array}$$
Combining Eqns. (40) and (41), we have:
$$\frac { 1 } { L } ( \dot { \sigma } _ { k } ( t ) ) ( \sigma _ { k } ( t ) ) ^ { \frac { 2 } { L } - 1 } = \sigma _ { L + 1 , k } ( t ) ( \dot { \sigma } _ { L + 1 , k } ( t ) ) .$$
Next, apply integration on both sides, which yields
$$( \sigma _ { L + 1 , k } ( t ) ) ^ { 2 } = ( \sigma _ { k } ( t ) ) ^ { \frac { 2 } { L } } + M ,$$
where $M$ a constant.
By Eqn. (43), Eqn. (40) can be rewritten as
$$\begin{array} { r } { \dot { \sigma } _ { k } ( t ) = L ( \sigma _ { k } ( t ) ) ^ { 2 - \frac { 2 } { L } } \sqrt { ( \sigma _ { k } ( t ) ) ^ { \frac { 2 } { L } } + M } \left( \mathbf { u } _ { L + 1 , k } ( t ) \right) ^ { \top } ( \mathbf { y } - \boldsymbol { \gamma } ( t ) ) { X } ^ { \top } \mathbf { v } _ { k } ( t ) . } \end{array}$$
Finally, notice that $( \mathbf y - \gamma ( t ) ) X ^ { \top }$ can be rewritten as
$$( \mathbf { y } - \boldsymbol { \gamma } ( t ) ) \boldsymbol { X } ^ { \top } = \sum _ { i = 1 } ^ { N } ( \mathbf { y } - \boldsymbol { \gamma } _ { i } ( t ) ) \boldsymbol { X } _ { i } ^ { \top } = N \sum _ { c = 1 } ^ { C } \mu _ { c } ( \mathbf { e } _ { c } - \bar { \boldsymbol { \gamma } } _ { c } ( t ) ) \bar { X } _ { c } ^ { \top } .$$
We further substitute Eqn. (45) into Eqn. (44) and obtain
$$\begin{array} { r } { \dot { \sigma } _ { k } ( t ) = N L ( \sigma _ { k } ( t ) ) ^ { 2 - \frac { 2 } { L } } \sqrt { ( \sigma _ { k } ( t ) ) ^ { \frac { 2 } { L } } + M } \left( \mathbf { u } _ { L + 1 , k } ( t ) \right) ^ { \top } G ( t ) \mathbf { v } _ { k } ( t ) , } \end{array}$$
where $G ( t )$ is defined as
$$G ( t ) = \sum _ { c = 1 } ^ { C } \mu _ { c } ( \mathbf { e } _ { c } - \bar { \gamma } _ { c } ( t ) ) \bar { X } _ { c } ^ { \top } .$$
This completes the proof.
# B PROOF OF PROPOSITION 1 IN THE MAIN PAPER
Proposition 1 (restated). For a $d$ -by- $d$ correlation matrix $K$ with singular values $( \lambda _ { 1 } , \ldots , \lambda _ { d } )$ , we have:
$$\sum _ { i = 1 } ^ { d } \left( \lambda _ { i } - \frac { 1 } { d } \sum _ { j = 1 } ^ { d } \lambda _ { j } \right) ^ { 2 } = \| K \| _ { \mathrm { F } } ^ { 2 } - d .$$
Proof. Given a $d$ -by- $d$ correlation matrix $K$ , since the diagonal entries of $K$ are all 1, we have
$$\sum _ { i = 1 } ^ { d } \lambda _ { i } = \operatorname { t r } ( K ) = d .$$
This is because for any symmetric positive definite matrix, the sum of all singular values equals the trace of the matrix.
Next, for the left-hand side of Eqn. (7), we have:
$$\begin{array} { l l } { \displaystyle \sum _ { i = 1 } ^ { d } \left( \lambda _ { i } - \frac { 1 } { d } \sum _ { j = 1 } ^ { d } \lambda _ { j } \right) ^ { 2 } = \sum _ { i = 1 } ^ { d } ( \lambda _ { i } - 1 ) ^ { 2 } } & { ( \mathrm { P l u g - i n ~ E q n . ~ } ( 4 9 ) ) } \\ { \displaystyle } & { = \sum _ { i = 1 } ^ { d } \lambda _ { i } ^ { 2 } - 2 \sum _ { i = 1 } ^ { d } \lambda _ { i } + d } \\ { \displaystyle } & { = \sum _ { i = 1 } ^ { d } \lambda _ { i } ^ { 2 } - d } & { ( \mathrm { P l u g - i n ~ E q n . ~ } ( 4 9 ) ) . } \end{array}$$
Next, for the right-hand side of Eqn. (7), we have:
$$\begin{array} { r l } & { \| K \| _ { \mathrm { F } } ^ { 2 } - d = \mathrm { t r } ( K ^ { \top } K ) - d } \\ & { \qquad = \mathrm { t r } ( U S V ^ { \top } V S ^ { \top } U ^ { \top } ) - d } \\ & { \qquad = \mathrm { t r } ( U S S ^ { \top } U ^ { \top } ) - d } \\ & { \qquad = \displaystyle \sum _ { i = 1 } ^ { n } \lambda _ { i } ^ { 2 } - d . } \end{array}$$
Therefore, we have shown that the left-hand side of Eqn. (7) equals its right-hand side.
# C ADDITIONAL EMPIRICAL ANALYSES
# C.1 COMPUTATIONAL EFFICIENCY
We demonstrate FEDDECORRβs advantage vis- $\grave { \mathbf { a } }$ -vis some of its competitors in terms of its computational efficiency. We compare FEDDECORR with some other methods that also apply additional regularization terms during local training such as FedProx and MOON. We partition CIFAR10, CIFAR100 and TinyImageNet into 10 clients with $\alpha = 0 . 5$ and report the total computation times required for one round of training for FedAvg, FedProx, MOON, and FEDDECORR . Results are shown in Tab. 5. All results are produced with a NVIDIA Tesla V100 GPU. We see that FEDDECORR incurs a negligible computation overhead on top of the naΒ¨Δ±ve FedAvg, while FedProx and MOON introduce about $0 . 5 \sim 1 \times$ additional computation cost. The advantage of FEDDECORR in terms of efficiency is mainly because it only involves calculating the Frobenius norm of a matrix which is extremely cheap. Indeed this regularization operates on the output representation vectors of the model, without requiring computing parameter-wise regularization like FedProx nor extra forward passes like MOON.
<table><tr><td></td><td>CIFAR10</td><td>CIFAR100</td><td>TinyImageNet</td></tr><tr><td>FedAvg</td><td>6.7</td><td>6.9</td><td>25.4</td></tr><tr><td>FedProx</td><td>12.1</td><td>12.3</td><td>33.2</td></tr><tr><td>MOON</td><td>12.2</td><td>12.7</td><td>38.1</td></tr><tr><td>FEDDECORR</td><td>6.9</td><td>7.1</td><td>25.7</td></tr></table>
Table 5: Comparison of computation times. We report the total computation times (in minutes) for one round of training on the three datasets for FedAvg, FedProx, MOON, and FEDDECORR. Here, FEDDECORR stands for applying FEDDECORR to FedAvg.
# C.2 COMPARISON WITH OTHER DECORRELATION METHODS
Some decorrelation regularizations such as DeCov (Cogswell et al., 2015) and StructuredDeCov (Xiong et al., 2016) were proposed to improve the generalization capabilities in standard classification tasks. Both these methods operate directly on the covariance matrix of the representations instead of the correlation matrix like our proposed methodβFEDDECORR. To compare our FEDDECORR with the existing decorrelation methods, we follow the same procedure as in FEDDECORR and apply DeCov and Structured-DeCov during local training. Our experiments are based on TinyImageNet and FedAvg. TinyImageNet is partitioned into 10 clients according to various $\alpha$ βs. Results are shown in Tab. 6. Surprisingly, we see that unlike our FEDDECORR which steadily improves the baseline, adding DeCov or Structured-DeCov both degrade the performance in federated learning. We conjecture that this is because directly regularizing the covariance matrix is highly unstable, leading to undesired modification on the representations. This experiment shows that our design of regularization of the correlation matrix instead of the covariance matrix is of paramount importance.
Table 6: Comparison with other decorrelation methods. Based on FedAvg and the TinyImageNet dataset, we use different decorrelation regularizers in local training.
<table><tr><td></td><td>|FedAvg</td><td>DeCov</td><td>St.-Decov</td><td>FEDDECORR</td></tr><tr><td>a= 0.05</td><td>35.02</td><td>32.88</td><td>32.04</td><td>40.29</td></tr><tr><td>Ξ± = 0.1</td><td>39.30</td><td>37.29</td><td>37.74</td><td>43.86</td></tr><tr><td>Ξ± = 0.5</td><td>46.92</td><td>46.29</td><td>45.85</td><td>50.01</td></tr></table>
# C.3 EXPERIMENTS ON OTHER MODEL ARCHITECTURES
In this section, we demonstrate the effectiveness of our method across different model architectures. Here, besides the MobileNetV2 used in the main paper, we also experiment on ResNet18 and ResNet32. Note that ResNet18 is the wider ResNet whose representation dimension is 512 and ResNet32 is the narrower ResNet whose representation dimension is 64. The coefficient of the FedDecorr objective is set to be 0.1 as suggested to be a good universal value of $\beta$ in the paper. The heterogeneity parameter $\alpha$ is set to be 0.05 and we use the CIFAR10 dataset. Our results are shown in Tab. 7. As can be seen, FedDecorr yields consistent improvements across different neural network architectures. One interesting phenomenon is that the improvements brought about by FedDecorr are much larger on wider networks (e.g., MobileNetV2, ResNet18) than on narrower ones (e.g. ResNet32). We conjecture this is because the dimension of the ambient space of wider networks are clearly higher than that of shallower networks. Therefore, relatively speaking, the dimensional collapse caused by data heterogeneity will be more severe for wider networks.
Table 7: Effectiveness of FEDDECORR on other model architectures.
<table><tr><td></td><td colspan="3">|MobileNetV2 ResNet18 ResNet32</td></tr><tr><td>FedAvg</td><td>64.85</td><td>71.51</td><td>65.76</td></tr><tr><td>+ FEDDECORR</td><td>73.06</td><td>76.54</td><td>67.21</td></tr></table>
Table 8: CIFAR10/100 Experiments. We run experiments under various degrees of heterogeneity $( \alpha \in \{ 0 . 0 5 , 0 . 1 , 0 . 5 , \infty \} )$ and report the test accuracy $( \% )$ . All results are (re)produced by us and are averaged over 3 runs (mean $\pm$ std). Bold font highlights the highest accuracy in each column. We add results of Scaffold and FedNova comparing to Tab. 1 in the main paper.
<table><tr><td rowspan="2">Method</td><td colspan="4">CIFAR10</td><td colspan="4">CIFAR100</td></tr><tr><td></td><td>Ξ±=0.050.1</td><td>0.5</td><td>8</td><td>0.05</td><td>0.1</td><td>0.5</td><td>8</td></tr><tr><td>Scaffold</td><td></td><td></td><td></td><td></td><td>51.99Β±2.54 74.36Β±3.10 87.05Β±0.3989.77Β±0.24 54.51Β±0.26 61.42Β±0.54 68.37Β±0.44 70.97Β±0.04</td><td></td><td></td><td></td></tr><tr><td>FedNova</td><td></td><td></td><td></td><td></td><td>63.07Β±1.59 79.98Β±1.56 90.23Β±0.41 92.39Β±0.18 60.22Β±0.33 66.43Β±0.26 71.79Β±0.17 74.47Β±0.13</td><td></td><td></td><td></td></tr><tr><td>FedAvg</td><td></td><td></td><td></td><td></td><td>64.85Β±2.01 76.28Β±1.22 89.84Β±0.13 92.39Β±0.26 59.87Β±0.25 66.46Β±0.16 71.69Β±0.15 74.54Β±0.15</td><td></td><td></td><td></td></tr><tr><td>FedProx</td><td></td><td></td><td></td><td></td><td>+ FEDDEC0RR 73.06Β±0.81 80.60Β±0.91 89.84Β±0.05 92.19Β±0.10 61.53Β±0.11 67.12Β±0.09 71.91Β±0.04 73.87Β±0.18</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>64.11Β±0.84 76.10Β±0.40 89.57Β±0.04 92.38Β±0.09 60.02Β±0.46 66.41Β±0.27 71.78Β±0.19 74.34Β±0.03</td><td>+ FEDDEC0RR 71.38Β±0.81 81.74Β±0.34 89.96Β±0.26 92.14Β±0.20 61.33Β±0.19 67.00Β±0.46 71.64Β±0.10 74.15Β±0.06</td><td></td><td></td></tr><tr><td>FedAvgM</td><td></td><td></td><td></td><td></td><td>71.34Β±0.71 77.51Β±0.58 88.39Β±0.1791.35Β±0.15 59.64Β±0.20 66.36Β±0.1471.17Β±0.2 74.20Β±0.16</td><td></td><td></td><td></td></tr><tr><td>MOON</td><td>+ FEDDEC0RR 73.60Β±0.82 79.21Β±0.15 88.70Β±0.26 91.33Β±0.13 61.48Β±0.27 66.60Β±0.11 71.26Β±0.21 73.86Β±0.25</td><td></td><td></td><td></td><td></td><td>68.79Β±0.69 78.70Β±0.6690.08Β±0.10 92.62Β±0.17 56.79Β±0.17 65.48Β±0.29 71.81Β±0.14 74.30Β±0.12</td><td></td><td></td></tr></table>
<table><tr><td rowspan="2">Method</td><td>TinyImageNet</td></tr><tr><td>Ξ± =0.050.1 0.5</td></tr><tr><td>Scaffold FedNova</td><td>8 35.16Β±0.77 37.87Β±0.78 44.24Β±0.14 44.88Β±0.29 35.28Β±0.04 39.73Β±0.07 47.05Β±0.42 49.57Β±0.09</td></tr><tr><td>FedAvg</td><td>35.02Β±0.46 39.30Β±0.23 46.92Β±0.25 49.33Β±0.19</td></tr><tr><td></td><td>+ FEDDEC0RR 40.29Β±0.18 43.86Β±0.50 50.01Β±0.27 52.63Β±0.26</td></tr><tr><td>FedProx</td><td>35.20Β±0.30 39.66Β±0.4347.16Β±0.07 49.76Β±0.36</td></tr><tr><td></td><td>+ FEDDEC0RR 40.63Β±0.05 44.19Β±0.14 50.26Β±0.27 52.37Β±0.36</td></tr><tr><td>FedAvgM</td><td>34.81Β±0.09 39.72Β±0.1147.11Β±0.04 49.67Β±0.25</td></tr><tr><td></td><td>+ FEDDEC0RR 39.97Β±0.23 43.95Β±0.26 50.14Β±0.11 52.05 Β±0.37</td></tr><tr><td>MOON</td><td></td></tr><tr><td></td><td>35.23Β±0.26 40.53Β±0.28 47.25Β±0.66 50.48Β±0.57</td></tr><tr><td></td><td>+ FEDDEC0RR 40.40Β±0.24 44.20Β±0.22 50.81Β±0.51 53.01Β±0.45</td></tr></table>
Table 9: TinyImageNet Experiments. We run with $\alpha \in \{ 0 . 0 5 , 0 . 1 , 0 . 5 , \infty \}$ and report the test accuracies $( \% )$ . All results are (re)produced by us and are averaged over 3 runs (mean $\pm$ std is reported). Bold font highlights the highest accuracy in each column. We add results of Scaffold and FedNova comparing to Tab. 2 in the main paper.
# C.4 COMPARISON WITH OTHER FEDERATED LEARNING BASELINES
In this section, we compare FEDDECORR with two other baselines, namely Scaffold (Karimireddy et al., 2020) and FedNova (Wang et al., 2020b). We use the same experimental setups as in the main paper to implement these two baselines. Results on CIFAR10/100 and TinyImageNet are shown in Tab. 8 and Tab. 9, respectively. As shown in the tables, across various datasets and degrees of heterogeneity, adding FEDDECORR on top of a baseline method can outperform the baselines when there is some heterogeneity across the agents, i.e., $\alpha < \infty$ .
# C.5 EXPERIMENTS ON ANOTHER TYPE OF HETEROGENEITY
In this section, we run experiments under another type of data heterogeneity. Specifically, we follow McMahan et al. (2017) and split the CIFAR10 dataset across different clients such that each client only has a fixed number of classes $C$ (e.g., $C = 2$ indicates each client only has data of two classes). We split the data across 10 clients and choose $C$ to be 2 and 3. Results are shown in Tab. 10. As can
 Figure 7: Data heterogeneity causes similar dimensional collapse on other federated learning methods such as FedAvgM (Hsu et al., 2019), FedProx (Li et al., 2020), and MOON (Li et al., 2021b). The $\mathbf { X }$ -axis $( k )$ is the index of singular values.
 Figure 8: Data heterogeneity causes similar dimensional collapse on other model architectures during federated learning. The $\mathbf { X }$ -axis $( k )$ is the index of singular values.
be observed, under this different heterogeneity scenario, FEDDECORR also yields noticeable and consistent improvements.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>|C=2 C=3</td></tr><tr><td rowspan=1 colspan=1>FedAvg</td><td rowspan=1 colspan=1>45.61 67.53</td></tr><tr><td rowspan=1 colspan=1>+ FEDDECORR</td><td rowspan=1 colspan=1>47.6374.51</td></tr></table>
Table 10: FEDDECORR yields noticeable and consistent improvements under another type of data heterogeneity.
# D ADDITIONAL VISUALIZATIONS ON GLOBAL MODELS
In this section, we provide additional visualizations on global models with different federated learning methods, model architectures, and datasets. Through our extensive experimental results, we demonstrate that dimensional collapse is a general problem under heterogeneous data in federated learning.
# D.1 VISUALIZATION ON GLOBAL MODELS OF OTHER FEDERATED LEARNING METHODS
In the main text, we have shown that global models produced by FedAvg (McMahan et al., 2017) suffer stronger dimensional collapse with increasing data heterogeneity. To further show such dimensional collapse phenomenon is a general problem in federated learning, we visualized global models produced by other federated learning methods such as FedAvg with server momentum (Hsu et al., 2019), FedProx (Li et al., 2020), and MOON (Li et al., 2021b). Specifically, we follow the same procedure as in the main text and plot the singular values of covariance matrices of representations. Results are shown in Fig. 7. From the figure, one can see that all these three other methods also demonstrated the similar hazard of dimensional collapse as in FedAvg.
# D.2 VISUALIZATION ON GLOBAL MODELS OF OTHER MODEL ARCHITECTURES
In the main text, we have shown the dimensional collapse on global models caused by data heterogeneity with MobileNetV2. In this section, we perform the similar visualization based on other model architectures such as ResNet32 and ResNet18. Note that ResNet32 is a narrower ResNet whose representation dimension is 64 and ResNet18 is a wider ResNet whose representation dimension is 64. We visualize the top 50 singular values for ResNet32 and the top 100 singular values for ResNet18. Results are shown in Fig. 8. From the figure, one can observe that heterogeneous data also lead to dimensional collapse on ResNet32 and ResNet18.
 Figure 9: Data heterogeneity causes similar dimensional collapse on other datasets during federated learning. The $\mathbf { X }$ -axis $( k )$ is the index of singular values.
# D.3 VISUALIZATION ON GLOBAL MODELS OF OTHER DATASETS
In the main text, we use the CIFAR100 dataset for our visualizations. In this section, we perform similar visualizations with other datasets such as CIFAR10 and TinyImageNet. Results are shown in Fig. 9. From the figure, one can also observe that dimensional collapse results from data heterogeneity.
# E VISUALIZATION ON OTHER LOCAL CLIENTS
In the main text Fig. 2(b), under the four different degrees of data heterogeneity (i.e., $\alpha \in$ $\{ 0 . 0 1 , 0 . 0 5 , 0 . 2 5 , \infty \} )$ ), we compare representations of local models of client 1 and empirically show how data heterogeneity affects representations produced by the local models. In this section, to further corroborate our conclusion, we follow the same procedure and visualize singular values of the covariance matrix of representations produced by local models trained on the rest of the 9 clients under the same $\alpha$ βs. Results are shown in Fig. 10. From the results, we can obtain the similar observations as in Fig. 2(b) of the main text, namely that stronger data heterogeneity causes more severe dimensional collapse for local models.
# F HYPERPARAMETERS OF OTHER FEDERATED LEARNING METHODS
The regularization coefficient of FedProx (Li et al., 2020) $\mu$ is tuned across $\{ 1 0 ^ { - 4 } , 1 \overset { \smile } { 0 } ^ { - 3 } , 1 0 ^ { - 2 } , 1 0 ^ { - 1 } \}$ and is selected to be $\begin{array} { r } { \dot { \mu } { } ~ = ~ 1 0 ^ { - 3 } } \end{array}$ ; the regularization coefficient of MOON (Li et al., 2021b) $\mu$ is tuned across $\{ 0 . 1 , 1 . 0 , 5 . 0 , 1 0 . 0 \}$ and is selected to be $\mu = 1 . 0$ ; the server momentum of FedAvgM (Hsu et al., 2019) $\rho$ is tuned across $\{ 0 . 1 , 0 . 5 , 0 . 9 \}$ and is selected to be $\rho = 0 . 5$ .
# G PSEUDO-CODE OF FEDDECORR
Here, we provide a pytorch-style pseudo-code for FEDDECORR in Alg. 1. All FEDDECORR-specific components are highlight in blue. As indicated in the pseudocode, the only additional operation of FEDDECORR is in adding a regularization term $L _ { \mathrm { F e d D e c o r r } } ( w , X )$ defined in Eqn. (8). This shows that FEDDECORR is an extremely convenient plug-and-play federated learning method.
# H STABILITY OF FEDDECORR REGULARIZATION LOSS
In this section, we first split CIFAR10 into 10 clients with $\alpha = 0 . 5$ . Then, we plot how FedDecorr loss evolve within 10 local epochs for all the 10 clients in Fig. 11. All training configurations are the same as in the main paper. From the results, one can observe that the optimization process of FedDecorr loss is stable.
 Figure 10: Heterogeneous local training data cause dimensional collapse. For each of the clients, given the four models trained under different degrees of heterogeneity, we plot the singular values of covariance matrix of representations in descending orders (the results of client 1 are shown in main text Fig. 2(b)). Representations are computed over the CIFAR100 test set. The $x$ -axis $( k )$ is the index of singular values and the $y$ -axis is the logarithm of the singular values.
 Figure 11: How FedDecorr loss evolve within 10 local epochs.
# Algorithm 1 PyTorch-style Pseudocode for FEDDECORR. (Blue highlights FEDDECORR-specific code)
def FedDecorrLoss(z): # N: batch size # d: representation dimension # z: a batch of representation, with shape (N, d) N,d = z.shape # z-score normalization z = (z - z.mean(0)) / z.std(0) # estimate correlation matrix corr mat $\equiv$ 1/N\*torch.matmul(z.t(), z) # calculate FedDecorr loss loss fed decorr $=$ (corr mat.pow(2)).mean() return loss fed decorr
def LocalTraining(train_loader, local_epochs, beta): for e in range(local_epochs): for data, targets in train_loader: # forward propagation. # given the batch of data, compute batch representations z and loss loss, z = . loss $+ =$ beta\*FedDecorr(z) # back propagation and update local model parameters ...
# def GlobalAggregation():
# receiving models from each clients # aggregating local models with certain schemes # sending aggregated models back to clients
# def main():
# n_comm_round: number of communication rounds. # train_loader: data loader of training data. # n_local_epochs: number of local trainig epochs on each client. # beta: coefficient of the FedDecorr regularization. for comm in range(n_comm_round): LocalTraining(train_loader, n_local_epochs, beta) GlobalAggregation()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345# CYCLIP: Cyclic Contrastive Language-Image Pretraining
Shashank Goelβ UCLA shashankgoel@ucla.edu
Hritik Bansalβ UCLA hbansal@ucla.edu
Sumit Bhatia MDSR Lab, Adobe Systems sumit.bhatia@adobe.com
Ryan A. Rossi Adobe Research ryrossi@adobe.com
Vishwa Vinay Adobe Research vinay@adobe.com
Aditya Grover UCLA adityag@cs.ucla.edu
# Abstract
Recent advances in contrastive representation learning over paired image-text data have led to models such as CLIP [44] that achieve state-of-the-art performance for zero-shot classification and distributional robustness. Such models typically require joint reasoning in the image and text representation spaces for downstream inference tasks. Contrary to prior beliefs, we demonstrate that the image and text representations learned via a standard contrastive objective are not interchangeable and can lead to inconsistent downstream predictions. To mitigate this issue, we formalize consistency and propose CYCLIP, a framework for contrastive representation learning that explicitly optimizes for the learned representations to be geometrically consistent in the image and text space. In particular, we show that consistent representations can be learned by explicitly symmetrizing (a) the similarity between the two mismatched image-text pairs (cross-modal consistency); and (b) the similarity between the image-image pair and the text-text pair (in-modal consistency). Empirically, we show that the improved consistency in CYCLIP translates to significant gains over CLIP, with gains ranging from $1 \dot { 0 } \% - 2 4 \%$ for zero-shot classification accuracy on standard benchmarks (CIFAR-10, CIFAR-100, ImageNet1K) and $1 0 \% - 2 7 \%$ for robustness to various natural distribution shifts. The code is available at https://github.com/goel-shashank/CyCLIP.
# 1 Introduction
The ability to learn general-purpose representations from diverse data modalities is a long-standing goal of artificial intelligence (AI) [4, 32]. In this regard, recent instantiations such as CLIP [44], ALIGN [29], and BASIC [41] have scaled up vision-language contrastive pretraining to jointly learn image and text embeddings, by exploiting an enormous amount of paired image-text data on the web. Post pretraining, these embeddings exhibit impressive zero-shot classification performance [13] and robustness to natural distribution shifts [48, 57, 24, 26]. Recently, these embeddings have been extended to text-guided generation of natural images [47, 12, 38, 46] and transferred to modalities such as 3-D shapes [50] by emphasizing the interchangeability of the image and text embeddings.
In the context of vision-language pretraining, the standard contrastive learning objective aims to maximize the similarity between matched image-text pairs (βpositives") against all the mismatched image-text pairs (βnegatives") [45, 7, 40, 22]. While such an objective aligns the true image-text pairs, it poses no constraints on the overall geometry of all data pairs, including the mismatched pairs and pairs within the same modality. In Figure 1 (a), we illustrate this effect where matched image-text pairs, $( I _ { \mathrm { d o g } } , T _ { \mathrm { d o g } } )$ and $( I _ { \mathrm { c a t } } , T _ { \mathrm { c a t } } )$ , get close to each other but the overall geometry of pairwise distances can be highly irregular (see e.g., $( I _ { \mathrm { d o g } } , T _ { \mathrm { c a t } } )$ and $( I _ { \mathrm { c a t } } , T _ { \mathrm { d o g } } ) )$ . If we use such representations for downstream inference, such irregularities can translate into inconsistent reasoning in the image and text spaces. For example, CLIP designs proxy captions for class labels and uses the most similar class caption to perform zero-shot classification for images; using the default captions in Figure 1 (a), this would imply that a test image $I _ { \mathrm { t e s t } }$ gets classified as a dog in the image space even when a simple nearest neighbor classifier in the text space would correctly infer the label to be a cat.
 Figure 1: An illustration of the planar geometry of the learned representations of image-text pairs by (a) CLIP and (b) CYCLIP. The edges indicate the distance between the representations i.e., $\dot { d ( e _ { 1 } , e _ { 2 } ) } = 1 - \langle e _ { 1 } , e _ { 2 } \rangle$ , where $\langle \cdot , \cdot \rangle$ is the inner product. CYCLIP is cyclic consistent between image-text pairs as the in-modal distances, $d ( T _ { \mathrm { c a t } } , T _ { \mathrm { d o g } } ) \sim d ( I _ { \mathrm { c a t } } , I _ { \mathrm { d o g } } )$ , and the cross-modal distances, $d ( \bar { T _ { \mathrm { c a t } } } , \bar { I _ { \mathrm { d o g } } } ) ~ \sim ~ d ( \bar { I _ { \mathrm { c a t } } } , \bar { T _ { \mathrm { d o g } } } )$ , are similar to each other unlike CLIP. Due to explicit consistency constraints, the test image of a cat is classified as a cat in the image as well as the text space.
To mitigate these challenges, we propose Cyclic Contrastive Language-Image Pretraining (CYCLIP), a framework that imposes additional geometric structure on the learned representations. Specifically, given two image-text pairs, we augment the contrastive learning objective with two symmetrization terms. The first term provides for in-modal consistency by encouraging the distance between the two image embeddings to be close to the distance between the corresponding text embeddings. The second term for the cross-modal consistency that encourages the distance between the image and text embedding from the first and second pairs respectively to be close to the distance between the text and image embeddings from the first and second pairs respectively. As shown in Figure 1 (b), if representations of any two image-text pairs, $( I _ { \mathrm { d o g } } , T _ { \mathrm { d o g } } )$ and $( \dot { I } _ { \mathrm { c a t } } , T _ { \mathrm { c a t } } )$ exactly satisfy both forms of cyclic consistency, then we can guarantee that any test image $I _ { \mathrm { t e s t } }$ respects the ordering of distances in both image and text spaces (i.e., if $d ( I _ { \mathrm { t e s t } } , I _ { \mathrm { d o g } } ) > d ( I _ { \mathrm { t e s t } } , I _ { \mathrm { c a t } } )$ , then $d ( I _ { \mathrm { t e s t } } , T _ { \mathrm { d o g } } ) > d ( I _ { t e s t } , T _ { \mathrm { c a t } } ) )$ .
Empirically, we demonstrate that the improved consistency in CYCLIP translates to improvements over CLIP. In all cases, we pre-train our models on the Conceptual Captions 3M dataset[52]. On zero-shot classification, we observe that CYCLIP improves over CLIP by $1 0 . 2 \%$ on ImageNet1K, $1 0 . 6 \%$ on CIFAR-10 and $2 3 . 9 \%$ on CIFAR-100 respectively. Further, CYCLIP outperforms CLIP with an average relative gain of $+ 1 7 \%$ on ImageNet natural distribution shift benchmarks. We further analyze the improved performance of CYCLIP and find that the additional geometric structure in the representation space better captures the coarse and fine-grained concept hierarchies of datasets.
Our contributions are as follows:
1. We analyze contrastive learning for representation learning jointly over image and text modalities. We identify a critical shortcoming in the geometry of the learned representation space that can lead to inconsistent predictions in image and text domains.
2. We propose CYCLIP, a simple and effective framework for contrastive representation learning with two additional cycle consistency constraints for mitigating the above issue. 3. We demonstrate that CYCLIP achieves significant empirical improvements over CLIP on zero-shot classification and robustness benchmarks. We further explain these improvements by analyzing the impact of consistency on the hierarchical structure of datasets.
# 2 Cycle Consistent Representation Learning
# 2.1 Preliminaries
We are interested in using text supervision to learn general-purpose visual representations that can be generalized to downstream predictive tasks. To this end, there have been several recent advances in language-image pretraining concerning model architectures, training objectives, and sources of supervision. Our work is most closely related to Contrastive Language-Image Pretraining (CLIP) [44] which combines many such advances in a highly scalable and generalizable learning framework.
CLIP is trained on millions of images with their captions scraped from the web. Formally, we consider a dataset $S \subset \mathcal { T } \times \mathcal { T }$ consisting of pairs $( I _ { j } , T _ { j } )$ where $I _ { j }$ is a raw image and $T _ { j }$ is a text caption. We use $\mathcal { T }$ and $\tau$ to denote the domain of images and text, respectively. The CLIP architecture consists of 3 components: (i) an image encoder network, $f _ { I } : \mathcal { T } \mapsto \mathbb { R } ^ { d }$ , to encode the raw image into an embedding vector of dimension $d$ , (ii) a text encoder network, $f _ { T } : T \mapsto \mathbb { R } ^ { d }$ , to encode the raw text into an embedding vector of dimension $d$ , (iii) a contrastive objective that pulls the embeddings of paired image-caption pairs together while pushing apart embeddings of unmatched pairs.
Formally, during training, consider a batch of $N$ image-captions pairs, $\{ I _ { j } , T _ { j } \} _ { j = 1 } ^ { N }$ , where $I _ { j }$ and $T _ { j }$ represent the raw image and text pair, respectively. The image embedding $\bar { I } _ { j } ^ { e } \in \mathbb { R } ^ { d }$ and text embedding $T _ { j } ^ { e } \in \mathbb { R } ^ { d }$ are obtained by passing $I _ { j }$ and $T _ { j }$ through the image encoder $f _ { I }$ and text encoder $f _ { T }$ , respectively; i.e. $I _ { j } ^ { e } = f _ { I } ( I _ { j } )$ and $T _ { j } ^ { e } = f _ { T } ( T _ { j } )$ . Further, we assume they are normalized to have unit $\ell _ { 2 }$ -norm. The contrastive objective in CLIP aims to align the image and text representations by minimizing the loss function ${ \mathcal { L } } _ { \mathrm { C L I P } }$ shown below:
$$\mathcal { L } _ { \mathrm { C L I P } } = - \frac { 1 } { 2 N } \sum _ { j = 1 } ^ { N } \log \left[ \frac { \exp \left( \langle I _ { j } ^ { e } , T _ { j } ^ { e } \rangle / \tau \right) } { \displaystyle \sum _ { k = 1 } ^ { N } \exp \left( \langle I _ { j } ^ { e } , T _ { k } ^ { e } \rangle / \tau \right) } \right] - \frac { 1 } { 2 N } \sum _ { k = 1 } ^ { N } \log \left[ \frac { \exp \left( \langle I _ { k } ^ { e } , T _ { k } ^ { e } \rangle / \tau \right) } { \displaystyle \sum _ { j = 1 } ^ { N } \exp \left( \langle I _ { j } ^ { e } , T _ { k } ^ { e } \rangle / \tau \right) } \right]$$
where $\langle \cdot , \cdot \rangle$ represents the inner product, and $\tau$ is a trainable temperature parameter. CLIP and its variants can be used to perform zero-shot image classification, i.e., classifying test images into categories not seen at training time. We first transform each category into a suitable caption (e.g., the airplane category in CIFAR-10 can be expressed as βa photo of an airplaneβ). Then, the similarity of the test image to each caption is computed (e.g., cosine distance), and the model predicts the category for which the image-caption similarity is the highest.
# 2.2 Inconsistent Representation Learning in CLIP
As illustrated in Figure 1 (a), the standard contrastive objective in CLIP can learn image-text representations such that the predicted labels for the test image are different in the image and text spaces. Here, we reason about such inconsistencies more formally in the context of downstream classification. As discussed above, we can predict a label in the text embedding space (zero-shot setting) by selecting the label that is closest to the test image $( P _ { T } )$ . Additionally, for classification in the image embedding space, if we had access to a labeled training set, then one natural way to infer the predicted label $( { \dot { P } } _ { I } ^ { k } )$ of a test image $I _ { t e s t }$ is by taking a majority vote from the true labels associated with the $\mathbf { k }$ -nearest training images. Formally, we define a consistency score that measures the synchrony between the predicted labels in the image and text spaces as:
 Figure 2: Illustrative overview for CYCLIP $N = 2 \AA$ ). It consists of 3 major components: (a) cross-modal contrastive alignment, (b) cross-modal consistency, and (c) in-modal consistency. Only (a) is present in CLIP, whereas our proposed regularizers in (b) and (c) mitigate inconsistency.
$${ \mathrm { C o n s i s t e n c y ~ S c o r e } } _ { k } = { \frac { 1 } { N } } \sum _ { j = 1 } ^ { N } \mathbb { 1 } \left[ P _ { I } ^ { k } ( I _ { j } ) = P _ { T } ( I _ { j } ) \right]$$
where $_ \mathrm { N }$ is the number of test images. In our experiments (discussed in detail in $\ S 3$ ), we found the CLIPβs consistency score $k = 1$ ) to be $44 \%$ , $16 \%$ , and $16 \%$ on the standard benchmarks CIFAR-10, CIFAR-100, and ImageNet1K, respectively, showing a very high degree of disagreement in the image and text spaces. In the following section, we describe our approach to alleviate the inconsistent inference problem and quantitatively show that our solution improves the consistency score in $\ S 4 . 1$ .
# 2.3 Cycle Consistent Representation Learning via CYCLIP
We showed that the visual representations learned by CLIP could be inconsistent when used for inference in the image and text spaces. To mitigate this problem, we propose CYCLIP, a learning framework that builds upon CLIP by augmenting the contrastive loss in Eq. 1 with additional geometric consistency regularizers. The intuition follows directly from Figure 1 (b), where we showed that inconsistency in the image and text spaces could be eliminated if we symmetrize the similarity between the two mismatched image-text pairs and the similarity between the image-image pair and the text-text pair. We formalize this intuition with two consistency regularizers.
(1) The cross-modal consistency regularizer reduces the gap in the similarity scores between the embeddings of all the mismatched image-text pairs in a batch, two at a time:
$$\mathcal { L } _ { \mathrm { C - C y c l i c } } = \frac { 1 } { N } \sum _ { j = 1 } ^ { N } \sum _ { k = 1 } ^ { N } \left( \langle I _ { j } ^ { e } , T _ { k } ^ { e } \rangle - \langle I _ { k } ^ { e } , T _ { j } ^ { e } \rangle \right) ^ { 2 } .$$
(2) The in-modal consistency regularizer reduces the gap in the similarity scores between the embeddings of all combinations of image pairs and their corresponding text pairs in a batch:
$$\mathcal { L } _ { \mathrm { I - C y c l i c } } = \frac { 1 } { N } \mathrm {sum _ { \substack { j = 1 } } ^ { N } } \mathrm { \sum _ { \substack { k = 1 } } ^ { N } } \left( \langle I _ { j } ^ { e } , I _ { k } ^ { e } \rangle - \langle T _ { k } ^ { e } , T _ { j } ^ { e } \rangle \right) ^ { 2 } .$$
Hence, our overall loss for CYCLIP is given as:
$${ \mathcal { L } } _ { \mathrm { C Y C L I P } } = { \mathcal { L } } _ { \mathrm { C L I P } } + \lambda _ { 1 } { \mathcal { L } } _ { \mathrm { I - C y c l i c } } + \lambda _ { 2 } { \mathcal { L } } _ { \mathrm { C - C y c l i c } }$$
where $\lambda _ { 1 } > 0$ and $\lambda _ { 2 } > 0$ are hyperparameters controlling the importance of the in-modal and cross-modal cyclic consistency regularizers relative to the contrastive loss in CLIP. We can also characterize the effect of the regularizers in terms of symmetrizing the in-modal and cross-modal similarity matrices, as illustrated in Figure 2. Note that the optimal solution to the contrastive loss formulation would push the similarity between the normalized embeddings of the matched pairs towards 1 while forcing all other pairs of similarities to 0, thereby also symmetrizing the cross-modal similarity matrix and minimizing the cross-modal consistency loss. However, this idealized scenario does not occur in practice, and we find that explicit regularization via cycle-consistency in CYCLIP facilitates improved learning, as we show in our experiments.
# 3 Experiments
Setup: We use Conceptual Captions 3M [52] (CC3M) image-caption pairs as the source of multimodal pretraining data for all our models. Note while this dataset is smaller than the custom dataset (400 million pairs) used in the original work on CLIP [44], it is suitable for our available data and compute and has been used for benchmark evaluations in many subsequent works on language-image pretraining [5, 33, 37, 56]. Following prior work [44], our CLIP models use ResNet-50 as the image encoder and a transformer architecture as the text encoder. Further, we train our models from scratch for 64 epochs on 4 V100 GPUs with a batch size of 128 and an initial learning rate of 0.0005 with cosine scheduling and 10000 warmup steps. The dimension of the image and text embeddings is 1024. For CYCLIP, we use $\lambda _ { 1 } = 0 . 2 5$ and $\lambda _ { 2 } = 0 . 2 5$ across all our experiments.
# 3.1 Zero-Shot Transfer
We compare the zero-shot performance of CLIP and CYCLIP on standard image classification datasets: CIFAR-10, CIFAR-100 [31], and ImageNet1K [49]. We follow the evaluation strategy suggested by [44] for zero-shot classification using prompt engineering. For each dataset, we use the names of the classes to form a set of natural sentences such as βa photo of the $\{ \mathrm { c l a s s ~ n a m e } \} ^ { \mathrm { , } }$ , βa sketch of the {class name}β and more. These are passed through the text encoder to get a set of text embeddings for that class. This set of text embeddings are $\ell _ { 2 }$ -normalized, averaged, and further $\ell _ { 2 }$ -normalized to obtain a single text embedding for that class. For a given image, the image embedding is obtained as described in $\ S 2$ . The class whose text embedding (as described above) is closest to the test image is taken to be the predicted label. The zero-shot performance of the models is presented in Table 1.
Table 1: Zero-shot TopK classification accuracy $( \% )$ where $\mathsf { K } \in \{ 1 , 3 , 5 \}$
<table><tr><td rowspan="2"></td><td colspan="3">CIFAR-10</td><td colspan="3">CIFAR-100</td><td colspan="3">ImageNet1K</td></tr><tr><td>Top1</td><td>Top3</td><td>Top5</td><td>Top1</td><td>Top3</td><td>Top5</td><td>Top1</td><td>Top3</td><td>Top5</td></tr><tr><td>CLIP</td><td>46.54</td><td>78.22</td><td>91.16</td><td>18.69</td><td>34.72</td><td>43.97</td><td>20.03</td><td>33.04</td><td>39.35</td></tr><tr><td>CYCLIP</td><td>51.45</td><td>79.57</td><td>91.80</td><td>23.15</td><td>41.46</td><td>50.66</td><td>22.08</td><td>35.98</td><td>42.30</td></tr><tr><td>%GAIN</td><td>+10.6</td><td>+1.7</td><td>+0.7</td><td>+23.9</td><td>+19.4</td><td>+15.2</td><td>+10.2</td><td>+8.9</td><td>+7.5</td></tr></table>
We observe that the CYCLIP outperforms CLIP across all the datasets and on all TopK metrics, with gains in the range of $1 0 \% - 2 4 \%$ for $\mathrm { K } = 1$ . Our results on zero-shot transfer indicate the usefulness of having geometrical consistency for improved downstream performance of CLIP.
# 3.2 Robustness to Natural Distribution Shifts
One of the major successes of CLIP was its state-of-the-art performance on the natural distribution shift benchmarks. These benchmarks include images depicting sketches, cartoons, adversaries generated using attacks on trained ImageNet models. In Table 2, we evaluate the zero-shot classification accuracy of CYCLIP on four natural distribution shift benchmarks for the ImageNet dataset: ImageNetV2 [48], ImageNetSketch [57], ImageNet-A [27], and ImageNet-R [25].
For most of the distribution shift benchmarks, both CLIP and CYCLIP undergo a significant reduction in their zero-shot performance compared to the original ImageNet1K dataset (last three columns in Table 1). However, we observe that CYCLIP outperforms CLIP on all of the datasets considered in this experiment by a significant margin of improvement $( 1 0 - 2 7 \% )$ ). This result indicates that having cyclic consistency in the learned representations preserves the robustness on the traditional datasets.
Table 2: Zeroshot Classification on Natural Distribution Shifts $( \% )$
<table><tr><td></td><td colspan="3">ImageNetV2</td><td colspan="3">ImageNetSketch</td><td colspan="3">ImageNet-A</td><td colspan="3">ImageNet-R</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>Top1 Top3 Top5 Top1 Top3 Top5 Top1 Top3 Top5 Top1 Top3 Top5</td><td></td><td></td><td></td><td></td></tr><tr><td>CLIP</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>16.91 29.28 34.99 10.37 19.15 24.20 4.2311.3516.88 24.32 39.69 47.20</td><td></td><td></td><td></td><td></td></tr><tr><td>CYCLIP 19.22 32.29 38.41 12.26 22.56 28.17 5.3513.53 19.51 26.79 42.31 50.03</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>%GAIN +13.7 +10.3 +9.8 +18.2 +17.8 +16.4 +26.5 +19.2 +15.6 +10.2 +6.6 +6.0</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>
# 3.3 Linear Probing
While the primary focus of CLIP and CYCLIP is zero-shot generalization, we can also assess if the benefits of our cyclic consistency constraints in mitigating inconsistency can be recovered with extra in-domain and in-modality supervision i.e., in the presence of in-distribution training samples from in-domain visual datasets. To this end, we conduct an additional experiments on linear probing where we fit a linear classifier on the representations learned by the visual encoder (ResNet-50) of CLIP and CYCLIP on a range of image classification datasets.
Table 3: Transfer CLIP and CYCLIP to 14 downstream visual datasets using linear probing. Our CYCLIP performs marginally better on 9 out of 14 datasets. For training ImageNet1K, we use a random subset of 50K images from its original training dataset.
<table><tr><td>iroiiir0 eeeee srtprtiois Crreaer CIPAAII1 CEIPRIPI0 DPodppttrt Arrit IorPoon TTSSP OITLS NHβ§S 0 CLIP 79.80 78.26 54.85 59.02 28.00 83.50 54.44 69.72 35.93 57.66 53.82 20.00 89.23 47.28|</td></tr></table>
We present our results in Table 3. We find that both CLIP and CYCLIP can recover most of the performance lost due to inconsistency when provided extra in-domain and in-modality supervision, with CYCLIP marginally outperforming the CLIP on 9 out of 14 visual datasets.
# 4 Analysis
Previously, we demonstrated the gains of CYCLIP over CLIP on downstream tasks that involve joint reasoning over the image and text spaces. In the current section, we wish to better understand the relative behavior of the two models on a set of challenging tasks.
# 4.1 Consistency in Image and Text Spaces
We begin by quantitatively measuring the inconsistency problem illustrated in Figure 1. That is, we wish to evaluate to what extent are the predictions in the image-text space (zero-shot) consistent with the ones made purely within the image space, as measured by our consistency metric in Eq. 2.
Table 4 presents our results over standard benchmarks (CIFAR-10, CIFAR-100, ImageNet1K). The consistency score is calculated over 10K, 10K, and 50K testing images of the CIFAR-10, CIFAR-100 and ImageNet dataset respectively. We use 50K samples from the training set of each dataset for $\mathbf { k }$ -Nearest Neighbor prediction. CYCLIP is more consistent than CLIP across all the datasets as we explicitly symmetrize the cross-modal and in-modal distances. Hence, the representations learned by CYCLIP can be better used interchangeably than CLIP.
Table 4: Consistency score $( \% )$ trend for CLIP and CYCLIP across standard benchmarks . Top- $\mathbf { \nabla } \cdot \mathbf { k }$ consistency score implies the fraction of times, the zero-shot predicted label in the text space is identical to the k-Nearest Neighbor predicted label in the image space (using the training dataset).
<table><tr><td></td><td colspan="4">CIFAR-10</td><td colspan="4">CIFAR-100</td><td colspan="4">ImageNet1K</td></tr><tr><td></td><td></td><td>Top1 Top3Top5Top10 Top1</td><td></td><td></td><td></td><td></td><td></td><td>Top3Top5Top10 Top1 T</td><td></td><td></td><td></td><td>Top3Top5Top10</td></tr><tr><td>CLIP</td><td>44.60</td><td>46.04</td><td>47.06</td><td>48.45</td><td>16.21</td><td>17.28</td><td>18.42</td><td>19.36</td><td>16.34</td><td>17.42</td><td>18.58</td><td>19.78</td></tr><tr><td>CYCLIP</td><td>48.81</td><td>50.89</td><td>52.30</td><td>53.71</td><td>20.43</td><td>21.96</td><td>23.18</td><td>24.31</td><td>19.20</td><td>20.31</td><td></td><td>21.9523.94</td></tr><tr><td>%GAIN</td><td>+8.6</td><td>+9.5</td><td>+10.0</td><td>οΌ+9.8</td><td>+20.7</td><td></td><td></td><td>+21.3 +20.5 +20.4</td><td>+14.9 +14.2 +15.4 +17.4</td><td></td><td></td><td></td></tr></table>
# 4.2 Fine-grained and Coarse-grained Performance
In $\ S 3 . 1$ , we observed that CYCLIP outperforms CLIP on zero-shot transfer across various datasets. We perform an error analysis investigating both modelsβ coarse and fine-grained classification performance to understand the transfer phenomena better. Given a hierarchical class structure dataset, coarse-grained classification differentiates between high-level (parent) classes, i.e., zeroshot classification into aquatic mammals and fish. The fine-grained classification task focuses on differentiating low-level (child) classes, i.e., zero-shot classification into a dolphin, otter, and seal (subclasses of aquatic mammals). We perform this analysis on the CIFAR-100, ImageNet1K, ImageNetV2, ImageNetSketch, ImageNet-A, and ImageNet-R datasets.
Formally, we consider a test set of $N$ image-subclass-superclass triplets, $\{ I _ { j } , C _ { j } , P _ { j } \} _ { j = 1 } ^ { N }$ , where $I _ { j }$ , $C _ { j }$ , $P _ { j }$ represent the image, the subclass (child) and superclass (parent) respectively. The image embedding $I _ { j } ^ { e } \in \mathbb { R } ^ { d }$ is obtained as described in $\ S 2$ , and the subclass embedding $C _ { j } ^ { e } \in \mathbb { R } ^ { d }$ and superclass embedding ${ P } _ { j } ^ { e } \in \mathbb { R } ^ { d }$ are obtained as described in $\ S 3 . 1$ . Let the total number of superclasses and subclasses in the dataset be $n _ { \mathrm { p } }$ and $n _ { \mathrm { c } }$ , respectively. Further, let $F$ be a unique mapping from a subclass to the superclass, and $\mho$ denote the inverse mapping from a superclass to the set of subclasses i.e. $\forall P \in \{ 1 , \cdot \cdot \cdot , n _ { \mathrm { p } } \}$ , $G ( P ) = \{ C : F ( C ) = P$ and $\mathbf { \bar { \it C } } \in \{ 1 , \dots , n _ { \mathrm { c } } \} \}$ . Under this setup, the fine-grained and coarse-grained accuracies are defined as:
$$\begin{array} { r l } & { \mathrm { F i n e - g r a i n e d ~ A c c u r a c y } = \displaystyle \frac { 1 } { N } \sum _ { j = 1 } ^ { N } 1 \left[ \mathrm { a r g m a x } \ \langle I _ { j } ^ { e } , C \rangle = C _ { j } \right] } \\ & { \mathrm { C o a r s e - g r a i n e d ~ A c c u r a c y } = \displaystyle \frac { 1 } { N } \sum _ { j = 1 } ^ { N } 1 \left[ \mathrm { a r g m a x } \ \langle I _ { j } ^ { e } , C \rangle \in G \left( P _ { j } \right) \right] } \end{array}$$
In Figure 3 we visualize how CLIP and CYCLIP compare with each other on the above metrics. The difference between the zero-shot performance of CYCLIP and CLIP is much more significant for coarse-grained classification than fine-grained classification across all the datasets. This observation indicates that concept-level knowledge is better captured in CYCLIP compared to CLIP. The drastic difference in the coarse-grained performance of CYCLIP and CLIP may be attributed to the rigid separation that the default cross-entropy loss in CLIP enforces between the positive pairs and negative pairs, which might degrade performance when some pairs in the negative batch belong to a similar entity. However, CYCLIP does not suffer from this problem as much because it poses cycle constraints on the overall geometry of all the data pairs rather than forcing a rigid separation.
# 4.3 Alignment and Uniformity on the Unit Hypersphere
[58] argues that contrastive learning directly optimizes for (a) alignment (closeness) of the representations of the positive pairs and (b) uniformity (coverage) of the representation space on the unit hypersphere. We extend these properties for multimodal contrastive representation learning as:
$$\mathrm { A l i g n m e n t } = \frac { 1 } { N } \sum _ { j = 1 } ^ { N } \langle I _ { j } ^ { e } , T _ { j } ^ { e } \rangle \qquad \mathrm { U n i f o r m i t y } = \log \left( \frac { 1 } { N ( N - 1 ) } \sum _ { j = 1 } ^ { N } \sum _ { k = 1 , j \neq k } ^ { N } e ^ { - \langle I _ { j } ^ { e } , T _ { k } ^ { e } \rangle } \right)$$
 Figure 3: The gap between the performances of CLIP and CYCLIP is much larger in coarse-grained scenario highlighting better entity-level knowledge representation in CYCLIP.
We desire our models to achieve high alignment and uniformity scores so that the image-text representations are close for the matched pairs and better spread over the unit hypersphere for different categories. We analyze the effect of cross-modal and in-modal consistency on the alignment and uniformity of the shared representations. For this, we train two ablated versions of CYCLIP, 1) C-CYCLIP with only cross-modal consistency component i.e. $\lambda _ { 1 } = 0 , \lambda _ { 2 } = 0 . 5$ , and 2) I-CYCLIP with only in-modal consistency component i.e. $\lambda _ { 1 } = 0 . 5 , \lambda _ { 2 } = 0$ (in Eq. 5). We design proxy captions for classes as discussed in $\ S 3 . 1$ to act as text embeddings. We present the results in Table 5.
Table 5: Alignment and Uniformity values for CLIP and Cyclic CLIP models. We abbreviate Alignment by A, Uniformity by U, and Zero-shot Top1 classification accuracy $( \% )$ by ZS-Top1.
<table><tr><td rowspan="2">Model</td><td colspan="3">CIFAR-10</td><td colspan="3">CIFAR-100</td><td colspan="3">ImageNet1K</td></tr><tr><td>A</td><td>U</td><td>ZS-Top1</td><td>A</td><td>U</td><td>ZS-Top1</td><td>A</td><td>U</td><td>ZS-Top1</td></tr><tr><td>CLIP</td><td>0.36</td><td>-0.27</td><td>46.54</td><td>0.36</td><td>-0.25</td><td>18.69</td><td>0.39</td><td>-0.18</td><td>20.03</td></tr><tr><td>CYCLIP</td><td>0.36</td><td>-0.34</td><td>51.45</td><td>0.37</td><td>-0.33</td><td>23.15</td><td>0.38</td><td>-0.32</td><td>22.08</td></tr><tr><td>I-CYCLIP</td><td>0.60</td><td>-0.57</td><td>50.97</td><td>0.60</td><td>-0.57</td><td>22.35</td><td>0.61</td><td>-0.55</td><td>21.21</td></tr><tr><td>C-CYCLIP</td><td>0.05</td><td>-0.02</td><td>55.52</td><td>0.06</td><td>-0.02</td><td>25.49</td><td>0.07</td><td>-0.02</td><td>21.73</td></tr></table>
We observe that I-CYCLIP learns representations that are better aligned in the representation space; however, they do not cover the hypersphere uniformly. The representations learned by C-CYCLIP are more uniformly spread but poorly aligned compared to I-CYCLIP. In this light, the components of CYCLIP can be seen to encourage a balance of good alignment and uniformity. Further, we find that CLIP is more uniform than CYCLIP in all datasets, but contrary to prior beliefs, this does not translate to improved downstream performance. C-CYCLIP has the best downstream zero-shot performance for CIFAR-10 and CIFAR-100 despite its poor alignment score. Further, all 3 variants of CYCLIP outperform CLIP on all 3 datasets, with CYCLIP performing the best on ImageNet1K.
# 4.4 Image-Text Retrieval
We evaluate the effectiveness of the proposed method on the cross-modal (image to text and text to image) retrieval downstream task in the zero-shot as well as fine-tuned settings. We consider the standard benchmark datasets: Flickr30K [42] and MSCOCO [8]. We assess our models on the test set of Flickr30K (1K) and MSCOCO (5K) obtained from the well-known Karpathy [30] split. Both the datasets contains 5 paired captions per image that makes text retrieval per image more easier than image retrieval per caption. We confirm the same in our results below. We perform fine-tuning on the Karpathyβs training split with the batch size of 48. We fine-tune on Flick30K for 10 epochs and MSCOCO for 5 epochs. All the other hyperparameters are identical to that of pre-training.
Table 6: Zero-shot and fine-tuned cross-modal image-text retrieval (text-to-image and image-to-text) results of CLIP and CYCLIP on Flick30K and MSCOCO datasets.
<table><tr><td rowspan="3"></td><td rowspan="3"></td><td colspan="4">Flickr30K (1K)</td><td colspan="4">MSCOCO (5K)</td></tr><tr><td colspan="2">Text Retrieval</td><td colspan="2">Image Retrieval</td><td colspan="2">Text Retrieval</td><td colspan="2">Image I Retrieval</td></tr><tr><td> R@1 R@5 R@10 R@1 R@5 R@10 R@1 R@5 R@10 R@1 R@5 R@10</td><td></td><td colspan="2"></td><td></td><td></td><td></td><td></td></tr><tr><td>Zero-shot</td><td>CLIP CyCLIP</td><td>88.2 93.9 88.1 93.7</td><td>95.8</td><td>29.9 57.2</td><td>68.0</td><td>82.1 85.6</td><td>87.8</td><td>8.4 19.5</td><td>26.6</td></tr><tr><td></td><td></td><td></td><td></td><td>95.9 30.9</td><td>57.8</td><td>69.1 82.1</td><td>85.6</td><td>87.7</td><td>8.6 20.0</td><td>27.0</td></tr><tr><td>Fine-tuned</td><td>CLIP</td><td>91.9</td><td>97.0</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>98.0 46.3</td><td>74.7</td><td>83.6 83.2</td><td>87.6</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>90.0</td><td>10.6 23.9</td><td>31.3</td></tr><tr><td></td><td>CYCLIP</td><td>92.3</td><td>97.0</td><td>98.4</td><td>47.3</td><td>83.2</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td>76.6</td><td>85.4</td><td>87.8</td><td>90.3</td><td>11.4 25.8</td><td>33.4</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
Table 6 presents our cross-modal image-text retrieval results for CLIP and CYCLIP. In the zero-shot setting, we find that CYCLIP marginally outperforms CLIP on the image retrieval task on both the datasets. The relatively lower performance of both CLIP and CYCLIP in the zero-shot setting may be attributed to the more complicated nature of the two datasets where the models are expected to find similarities between the image and text at multiple resolutions as opposed to image classification where there is mostly single object to be matched with a simpler caption. It is not clear as to what distinctions in the raw input and text space are reflected in the embedding space too. Hence, we perform fine-tuning on both the datasets to better inform our models of the downstream datasets. In the fine-tuning setting, we find that the performance of both the models increases across both the datasets. However, we observe clear benefits of the soft consistent regularization on the image retrieval results for both the datasets.
# 4.5 CYCLIP preserves the Effective Robustness of CLIP
[36] shows that there is a strong correlation between the in-distribution and out-of-distribution generalization of the models trained on ImageNet1K, as illustrated by the linear fit (red) in Figure 4. Ideally, any model that does not undergo distribution shift would fall on the $y = x$ trendline (black). For other models, the deviations of the models from this ideal fit indicate their effective robustness. Previously, [45] showed that the zero-shot CLIP classifier trained on 400M image-text pairs improves effective robustness significantly compared to prior approaches to robustness. Subsequently, [28] demonstrated that CLIP models trained at small scales also exhibit high effective robustness that allows them to be used as a proxy to study the robustness properties of CLIP.
 Figure 4: Effect of varying the training dataset size on (a) Classification accuracy on ImageNet1K and (b) Effective Robustness on ImageNetV2.
We evaluate the effect of cyclic consistency on effective robustness. We trained 4 CLIP and CYCLIP models, varying the training dataset sizes from 500K to 4M image-text pairs from the $\mathrm { C C 3 M + }$ CC12M datasets. In Figure 4, (a) we observe that for all training data sizes, CYCLIP shows a significant improvement over CLIP, showcasing its effectiveness in a diverse set of data regimes. Further, Figure 4 (b) shows that CYCLIP lies way above the baseline trend and preserves the effective robustness of CLIP.
# 5 Related Work
Our work fits into the broader theme of unsupervised pretraining with multiple modalities and has been successfully applied for learning representations of modalities such as images, text, and speech [2, 15, 1, 59, 43, 34]. Similar to the unimodal setting, two predominant approaches for multimodal pretraining are contrastive and generative, as described below.
Contrastive Representation Learning: Contrastive learning was originally proposed for selfsupervised representation learning in the unimodal context where the embeddings of a sample are brought closer to an augmented version of the sample. In contrast, the embeddings are pushed away for other samples, and their augmentation [11, 51, 39, 55, 21, 7, 16, 40, 66, 23, 18]. [63] and [3] impose additional constraints to remove redundancies and prevent dimensional collapse in the visual representations. Recently, contrastive learning has also been used to learn robust representations of the multimodal data [62, 47]. Many works use additional losses to imbibe extra supervisory multimodal knowledge during the training process [54, 65, 64, 14, 35]. In this work, we focus on having cyclic consistency in addition to the contrastive loss to learn more robust image-text representations.
Contrastive Language-Image Pretraining: CLIP [44], ALIGN [29] and BASIC [41] have enjoyed great success in extending contrastive learning to paired image-text data, with impressive zero-shot classification and robustness performance. These works have been further extended recently to include visual self-supervision [37], additional nearest neighbor supervision [33], and utilization of unpaired data [56]. Our work complements much of this literature as it identifies consistency regularizers that can be augmented to the learning objective of the above works.
Generative Representation Learning: Generative models have been applied for learning representations of multimodal data [60, 53]. In particular, [67, 61, 10] proposed a notion of cyclic consistency for learning from unpaired multimodal data using GANs [17], which was extended later to normalizing flows [20, 19]. While these works focus on regularizing a generative mapping between modalities, our notion of cycle consistency applies to embeddings learned via a contrastive framework.
# 6 Conclusion
We presented CYCLIP, a framework for cycle consistent multimodal representation learning for image and text modality. The main benefits of CYCLIP stem from including cross-modal consistency and in-modal consistency regularizers to prevent inconsistent inference in the image and text spaces. Empirically, we show that CYCLIP performs much better than CLIP on zero-shot classification and is more robust on benchmarks for distributional robustness. We also showed that the representations learned by CYCLIP are more consistent than CLIP and better capture concept-level knowledge, as evidenced by our analysis of fine-grained and coarse-grained accuracies.
We believe this work can motivate further studies on understanding the geometry of the representation spaces learned via the contrastive objective applied to paired multimodal data and, in particular, identify conditions and regularization strategies under which the learned representations are synergistic across the various modalities for downstream applications.
One important future direction and a current limitation is scaling CYCLIP to larger datasets. While we do not possess the resources for this study, it is imperative to study the extent to which the benefits of cycle consistency remain at the scale on which the original CLIP was trained (400M image-text pairs). Finally, for real-world deployment of CLIP and their variants, such as CYCLIP, we need to be cautious about amplifying societal biases as these models are trained on large uncurated datasets scraped from the web [9]. Additionally, it is easy to add malicious data to the web, which poses a severe security threat [5]. Alleviating such harms is an important and active area of research.
# Acknowledgements
This research is supported by an Adobe Data Science Research Award for Aditya Grover. We would like to thank the IDREβs Research Technology group for the GPU computing resources on the UCLA Hoffman2 Cluster. We also want to thank Tung Duc Nguyen, Satvik Mashkaria, Siddarth Krishnamoorthy, Varuni Sarwal, and Ashima Suvarna for their helpful suggestions.
References [1] Yusuf Aytar, Carl Vondrick, and Antonio Torralba. See, hear, and read: Deep aligned representations. arXiv preprint arXiv:1706.00932, 2017. [2] Tadas BaltruΕ‘aitis, Chaitanya Ahuja, and Louis-Philippe Morency. Multimodal machine learning: A survey and taxonomy. IEEE transactions on pattern analysis and machine intelligence, 41(2):423β443, 2018. [3] Adrien Bardes, Jean Ponce, and Yann LeCun. Vicreg: Variance-invariance-covariance regularization for self-supervised learning. arXiv preprint arXiv:2105.04906, 2021. [4] Yoshua Bengio, Aaron Courville, and Pascal Vincent. Representation learning: A review and new perspectives. IEEE transactions on pattern analysis and machine intelligence, 35(8):1798β 1828, 2013. [5] Nicholas Carlini and Andreas Terzis. Poisoning and backdooring contrastive learning. arXiv preprint arXiv:2106.09667, 2021. [6] Soravit Changpinyo, Piyush Sharma, Nan Ding, and Radu Soricut. Conceptual $1 2 \mathrm { m }$ : Pushing web-scale image-text pre-training to recognize long-tail visual concepts. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 3558β3568, 2021. [7] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pages 1597β1607. PMLR, 2020. [8] Xinlei Chen, Hao Fang, Tsung-Yi Lin, Ramakrishna Vedantam, Saurabh Gupta, Piotr DollΓ‘r, and C Lawrence Zitnick. Microsoft coco captions: Data collection and evaluation server. arXiv preprint arXiv:1504.00325, 2015. [9] Jaemin Cho, Abhay Zala, and Mohit Bansal. Dall-eval: Probing the reasoning skills and social biases of text-to-image generative transformers. arXiv preprint arXiv:2202.04053, 2022. [10] 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, pages 8789β8797, 2018. [11] Sumit Chopra, Raia Hadsell, and Yann LeCun. Learning a similarity metric discriminatively, with application to face verification. In 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPRβ05), volume 1, pages 539β546. IEEE, 2005. [12] Katherine Crowson, Stella Rose Biderman, Daniel Kornis, Dashiell Stander, Eric Hallahan, Louis Castricato, and Edward Raff. Vqgan-clip: Open domain image generation and editing with natural language guidance. ArXiv, abs/2204.08583, 2022. [13] 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. [14] Karan Desai and Justin Johnson. Virtex: Learning visual representations from textual annotations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 11162β11173, 2021. [15] Jiali Duan, Liqun Chen, Son Tran, Jinyu Yang, Yi Xu, Belinda Zeng, Chenyang Tao, and Trishul Chilimbi. Multi-modal alignment using representation codebook. arXiv:2203.00048, 2022. [16] Tianyu Gao, Xingcheng Yao, and Danqi Chen. Simcse: Simple contrastive learning of sentence embeddings. arXiv preprint arXiv:2104.08821, 2021. [17] 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.
[18] Jean-Bastien Grill, Florian Strub, Florent AltchΓ©, Corentin Tallec, Pierre Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, et al. Bootstrap your own latent-a new approach to self-supervised learning. Advances in Neural Information Processing Systems, 33:21271β21284, 2020.
[19] 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, pages 4028β4035, 2020.
[20] Aditya Grover, Manik Dhar, and Stefano Ermon. Flow-gan: Combining maximum likelihood and adversarial learning in generative models. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
[21] Michael Gutmann and Aapo HyvΓ€rinen. Noise-contrastive estimation: A new estimation principle for unnormalized statistical models. In Proceedings of the thirteenth international conference on artificial intelligence and statistics, pages 297β304. JMLR Workshop and Conference Proceedings, 2010.
[22] Raia Hadsell, Sumit Chopra, and Yann LeCun. Dimensionality reduction by learning an invariant mapping. In 2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPRβ06), volume 2, pages 1735β1742. IEEE, 2006.
[23] Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 9729β9738, 2020.
[24] 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.
[25] Dan Hendrycks, Steven Basart, Norman Mu, Saurav Kadavath, Frank Wang, Evan Dorundo, Rahul Desai, Tyler Lixuan Zhu, Samyak Parajuli, Mike Guo, Dawn Xiaodong Song, Jacob Steinhardt, and Justin Gilmer. The many faces of robustness: A critical analysis of out-ofdistribution generalization. 2021 IEEE/CVF International Conference on Computer Vision (ICCV), pages 8320β8329, 2021.
[26] Dan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Song. Natural adversarial examples. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 15262β15271, 2021.
[27] Dan Hendrycks, Kevin Zhao, Steven Basart, Jacob Steinhardt, and Dawn Xiaodong Song. Natural adversarial examples. 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 15257β15266, 2021.
[28] Gabriel Ilharco, Mitchell Wortsman, Ross Wightman, Cade Gordon, Nicholas Carlini, Rohan Taori, Achal Dave, Vaishaal Shankar, Hongseok Namkoong, John Miller, Hannaneh Hajishirzi, Ali Farhadi, and Ludwig Schmidt. Openclip. Zenodo, July 2021. If you use this software, please cite it as below.
[29] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, YunHsuan Sung, Zhen Li, and Tom Duerig. Scaling up visual and vision-language representation learning with noisy text supervision. In International Conference on Machine Learning, pages 4904β4916. PMLR, 2021.
[30] Andrej Karpathy and Li Fei-Fei. Deep visual-semantic alignments for generating image descriptions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3128β3137, 2015.
[31] Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. Citeseer, 2009.
[32] Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. nature, 521(7553):436β444, 2015.
[33] Yangguang Li, Feng Liang, Lichen Zhao, Yufeng Cui, Wanli Ouyang, Jing Shao, Fengwei Yu, and Junjie Yan. Supervision exists everywhere: A data efficient contrastive language-image pre-training paradigm. arXiv:2110.05208, 2021. [34] Kevin Lu, Aditya Grover, Pieter Abbeel, and Igor Mordatch. Pretrained transformers as universal computation engines. arXiv preprint arXiv:2103.05247, 2021. [35] Sijie Mai, Ying Zeng, Shuangjia Zheng, and Haifeng Hu. Hybrid contrastive learning of tri-modal representation for multimodal sentiment analysis. arXiv:2109.01797, 2021. [36] John P Miller, Rohan Taori, Aditi Raghunathan, Shiori Sagawa, Pang Wei Koh, Vaishaal Shankar, Percy Liang, Yair Carmon, and Ludwig Schmidt. Accuracy on the line: on the strong correlation between out-of-distribution and in-distribution generalization. In International Conference on Machine Learning, pages 7721β7735. PMLR, 2021. [37] Norman Mu, Alexander Kirillov, David Wagner, and Saining Xie. Slip: Self-supervision meets language-image pre-training. arXiv:2112.12750, 2021. [38] Alex Nichol, Prafulla Dhariwal, Aditya Ramesh, Pranav Shyam, Pamela Mishkin, Bob McGrew, Ilya Sutskever, and Mark Chen. Glide: Towards photorealistic image generation and editing with text-guided diffusion models. arXiv:2112.10741, 2021. [39] Hyun Oh Song, Yu Xiang, Stefanie Jegelka, and Silvio Savarese. Deep metric learning via lifted structured feature embedding. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4004β4012, 2016. [40] Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018. [41] Hieu Pham, Zihang Dai, Golnaz Ghiasi, Hanxiao Liu, Adams Wei Yu, Minh-Thang Luong, Mingxing Tan, and Quoc V Le. Combined scaling for zero-shot transfer learning. arXiv preprint arXiv:2111.10050, 2021. [42] Bryan A Plummer, Liwei Wang, Chris M Cervantes, Juan C Caicedo, Julia Hockenmaier, and Svetlana Lazebnik. Flickr30k entities: Collecting region-to-phrase correspondences for richer image-to-sentence models. In Proceedings of the IEEE international conference on computer vision, pages 2641β2649, 2015. [43] Ariadna Quattoni, Michael Collins, and Trevor Darrell. Learning visual representations using images with captions. In 2007 IEEE Conference on Computer Vision and Pattern Recognition, pages 1β8. IEEE, 2007. [44] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al. Learning transferable visual models from natural language supervision. In International Conference on Machine Learning, pages 8748β8763. PMLR, 2021. [45] 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. [46] Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125, 2022. [47] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever. Zero-shot text-to-image generation. In International Conference on Machine Learning, pages 8821β8831. PMLR, 2021. [48] Benjamin Recht, Rebecca Roelofs, Ludwig Schmidt, and Vaishaal Shankar. Do imagenet classifiers generalize to imagenet? In International Conference on Machine Learning, pages 5389β5400. PMLR, 2019. [49] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. International journal of computer vision, 115(3):211β252, 2015.
[50] Aditya Sanghi, Hang Chu, Joseph G Lambourne, Ye Wang, Chin-Yi Cheng, and Marco Fumero. Clip-forge: Towards zero-shot text-to-shape generation. arXiv preprint arXiv:2110.02624, 2021.
[51] Florian Schroff, Dmitry Kalenichenko, and James Philbin. Facenet: A unified embedding for face recognition and clustering. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 815β823, 2015.
[52] Piyush Sharma, Nan Ding, Sebastian Goodman, and Radu Soricut. Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 2556β2565, 2018.
[53] Yuge Shi, Brooks Paige, Philip Torr, et al. Variational mixture-of-experts autoencoders for multi-modal deep generative models. Advances in Neural Information Processing Systems, 32, 2019.
[54] Amanpreet Singh, Ronghang Hu, Vedanuj Goswami, Guillaume Couairon, Wojciech Galuba, Marcus Rohrbach, and Douwe Kiela. Flava: A foundational language and vision alignment model. arXiv preprint arXiv:2112.04482, 2021.
[55] Kihyuk Sohn. Improved deep metric learning with multi-class n-pair loss objective. Advances in neural information processing systems, 29, 2016.
[56] Ajinkya Tejankar, Bichen Wu, Saining Xie, Madian Khabsa, Hamed Pirsiavash, and Hamed Firooz. A fistful of words: Learning transferable visual models from bag-of-words supervision. arXiv:2112.13884, 2021.
[57] Haohan Wang, Songwei Ge, Zachary Lipton, and Eric P Xing. Learning robust global representations by penalizing local predictive power. Advances in Neural Information Processing Systems, 32, 2019.
[58] Tongzhou Wang and Phillip Isola. Understanding contrastive representation learning through alignment and uniformity on the hypersphere. In ICML, 2020.
[59] Wenhui Wang, Hangbo Bao, Li Dong, and Furu Wei. Vlmo: Unified vision-language pretraining with mixture-of-modality-experts. arXiv preprint arXiv:2111.02358, 2021.
[60] Mike Wu and Noah Goodman. Multimodal generative models for scalable weakly-supervised learning. Advances in Neural Information Processing Systems, 31, 2018.
[61] Zili Yi, Hao Zhang, Ping Tan, and Minglun Gong. Dualgan: Unsupervised dual learning for image-to-image translation. In Proceedings of the IEEE international conference on computer vision, pages 2849β2857, 2017.
[62] Xin Yuan, Zhe Lin, Jason Kuen, Jianming Zhang, Yilin Wang, Michael Maire, Ajinkya Kale, and Baldo Faieta. Multimodal contrastive training for visual representation learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 6995β7004, 2021.
[63] Jure Zbontar, Li Jing, Ishan Misra, Yann LeCun, and StΓ©phane Deny. Barlow twins: Selfsupervised learning via redundancy reduction. In International Conference on Machine Learning, pages 12310β12320. PMLR, 2021.
[64] Rowan Zellers, Ximing Lu, Jack Hessel, Youngjae Yu, Jae Sung Park, Jize Cao, Ali Farhadi, and Yejin Choi. Merlot: Multimodal neural script knowledge models. Advances in Neural Information Processing Systems, 34, 2021.
[65] Pengchuan Zhang, Xiujun Li, Xiaowei Hu, Jianwei Yang, Lei Zhang, Lijuan Wang, Yejin Choi, and Jianfeng Gao. Vinvl: Revisiting visual representations in vision-language models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5579β5588, 2021.
[66] Yuhao Zhang, Hang Jiang, Yasuhide Miura, Christopher D Manning, and Curtis P Langlotz. Contrastive learning of medical visual representations from paired images and text. arXiv preprint arXiv:2010.00747, 2020. [67] 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.
# Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paperβs contributions and scope? [Yes] (b) Did you describe the limitations of your work? [Yes] Section 6. (c) Did you discuss any potential negative societal impacts of your work? [Yes] Section 6. (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
2. If you are including theoretical results...
(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]
3. If you ran experiments...
(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] (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Due to extremely-compute heavy experiments. (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]
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators? [Yes] (b) Did you mention the license of the assets? [No] All the non-proprietary datasets and code used are public under MIT, BSD or CC licenses. (c) Did you include any new assets either in the supplemental material or as a URL? [N/A] (d) Did you discuss whether and how consent was obtained from people whose data youβre using/curating? [N/A] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
5. If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338# Are Emergent Abilities of Large Language Models a Mirage?
# Rylan Schaeffer
Brando Miranda Computer Science Stanford University brando9@cs.stanford.edu
Computer Science Stanford University rschaef@cs.stanford.edu
Sanmi Koyejo Computer Science Stanford University sanmi@cs.stanford.edu
# Abstract
Recent work claims that large language models display emergent abilities: abilities not present in smaller-scale models that are present in larger-scale models. What makes emergent abilities intriguing is two-fold: their sharpness, transitioning seemingly instantaneously from not present to present, and their unpredictability, appearing at seemingly unforeseeable model scales. Here, we present an alternative explanation for emergent abilities: for a particular task and model family, when analyzing fixed model outputs, emergent abilities appear due to the researcherβs choice of metric rather than due to fundamental changes in models with scale. Specifically, nonlinear or discontinuous metrics produce seemingly emergent abilities, whereas linear or continuous metrics produce smooth, continuous, predictable changes in model performance. We present our alternative explanation in a simple mathematical model, then test it in three complementary ways: we (1) make, test and confirm three predictions on the effect of metric choice using the InstructGPT/GPT-3 family on tasks with claimed emergent abilities; (2) make, test and confirm two predictions about metric choices in a meta-analysis of emergent abilities on the Beyond the Imitation Game Benchmark (BIG-Bench); and (3) show how to choose metrics to produce never-before-seen seemingly emergent abilities in multiple vision tasks across diverse deep network architectures. Via all three analyses, we provide evidence that emergent abilities disappear with different metrics or with better statistics, and may not be a fundamental property of scaling AI models.
# 1 Introduction
Emergent properties of complex systems have long been studied across disciplines, from physics to biology to mathematics. The idea of emergence was popularized by Nobel Prize-winning physicist P.W. Andersonβs βMore Is Different" [1], which argues that as the complexity of a system increases, new properties may materialize that cannot be predicted even from a precise quantitative understanding of the systemβs microscopic details. Recently, the idea of emergence gained significant attention in machine learning due to observations that large language models (LLMs) such as GPT [4], PaLM [7] and LaMDA [35] exhibit so-called βemergent abilities" [38, 9, 33, 4] (Fig. 1).
The term βemergent abilities of LLMs" was recently and crisply defined as βabilities that are not present in smaller-scale models but are present in large-scale models; thus they cannot be predicted by simply extrapolating the performance improvements on smaller-scale models" [38]. Such emergent abilities were first discovered in the GPT-3 family [4]. Subsequent work emphasized the discovery, writing that β[although model] performance is predictable at a general level, performance on a specific task can sometimes emerge quite unpredictably and abruptly at scale" [9]. These quotations collectively identify the two defining properties of emergent abilities in LLMs:
1. Sharpness, transitioning seemingly instantaneously from not present to present
 Figure 1: Emergent abilities of large language models. Model families display sharp and unpredictable increases in performance at specific tasks as scale increases. Source: Fig. 2 from [38].
2. Unpredictability, transitioning at seemingly unforeseeable model scales
These emergent abilities have garnered significant interest, raising questions such as: What controls which abilities will emerge? What controls when abilities will emerge? How can we make desirable abilities emerge faster, and ensure undesirable abilities never emerge? These questions are especially pertinent to AI safety and alignment, as emergent abilities forewarn that larger models might one day, without warning, acquire undesired mastery over dangerous capabilities [34, 12, 19, 20].
In this paper, we call into question the claim that LLMs possess emergent abilities, by which we specifically mean sharp and unpredictable changes in model outputs as a function of model scale on specific tasks. Our doubt stems from the observation that emergent abilities seem to appear only under metrics that nonlinearly or discontinuously scale any modelβs per-token error rate. For instance, as we later show, $> 9 2 \%$ of emergent abilities on BIG-Bench tasks [33] (hand-annotated by [37]) appear under either of these two metrics:
$$\begin{array} { r l } { \mathrm { M u l t i p l e ~ C h o i c e ~ G r a d e ~ { \stackrel { d e f } { = } } ~ } } & { { } { \left\{ \begin{array} { l l } { 1 } & { { \mathrm { i f ~ h i g h e s t ~ p r o b a b i l i t y ~ m a s s ~ o n ~ c o r r e c t ~ o p t i o n } } } \\ { 0 } & { { \mathrm { o t h e r w i s e } } } \end{array} \right. } } \\ { \mathrm { E x a c t ~ S t r i n g ~ M a t c h ~ { \stackrel { d e f } { = } } ~ } } & { { } { \left\{ \begin{array} { l l } { 1 } & { { \mathrm { i f ~ o u t p u t ~ s t r i n g ~ e x a c t l y ~ m a t c h e s ~ t a r g e t ~ s t r i n g } } } \\ { 0 } & { { \mathrm { o t h e r w i s e } } } \end{array} \right. } } \end{array}$$
This raises the possibility of an alternative explanation for the origin of LLMsβ emergent abilities: sharp and unpredictable changes might be induced by the researcherβs choice of measurement, even though the model familyβs per-token error rate changes smoothly, continuously and predictably with increasing scale. Specifically, our alternative posits that emergent abilities are a mirage caused primarily by the researcher choosing a metric that nonlinearly or discontinuously deforms per-token error rates, and secondarily by possessing too few test data to accurately estimate the performance of smaller models, thereby causing smaller models to appear wholly unable to perform the task.
To communicate our alternative explanation, we present it as a simple mathematical model and demonstrate how it quantitatively reproduces the evidence offered in support of emergent abilities of LLMs. We then test our alternative explanation in three complementary ways:
 Figure 2: Emergent abilities of large language models are created by the researcherβs chosen metrics, not unpredictable changes in model behavior with scale. (A) Suppose the per-token cross-entropy loss decreases monotonically with model scale, e.g., $\mathcal { L } _ { C E }$ scales as a power law. (B) The per-token probability of selecting the correct token asymptotes towards 1. (C) If the researcher scores modelsβ outputs using a nonlinear metric such as Accuracy (which requires a sequence of tokens to all be correct), the metric choice nonlinearly scales performance, causing performance to change sharply and unpredictably in a manner that qualitatively matches published emergent abilities (inset). (D) If the researcher instead scores modelsβ outputs using a discontinuous metric such as Multiple Choice Grade (akin to a step function), the metric choice discontinuously scales performance, again causing performance to change sharply and unpredictably. (E) Changing from a nonlinear metric to a linear metric such as Token Edit Distance, scaling shows smooth, continuous and predictable improvements, ablating the emergent ability. (F) Changing from a discontinuous metric to a continuous metric such as Brier Score again reveals smooth, continuous and predictable improvements in task performance. Consequently, the observation of "emergent abilities" can be explained by the researcherβs choice of metrics, and does not require fundamental changes in model family behavior on specific tasks with scale.
1. We make, test and confirm three predictions based on our alternative hypotheses using the InstructGPT [27] / GPT-3 [4] model family. 2. We meta-analyze published benchmarks [33, 38] to reveal that emergent abilities only appear for specific metrics, not for model families on particular tasks, and that changing the metric causes the emergence phenomenon to disappear. 3. We induce never-before-seen, seemingly emergent abilities in multiple architectures across various vision tasks by intentionally changing the metrics used for evaluation.
# 2 Alternative Explanation for Emergent Abilities
How might smooth, continuous, predictable changes in model family performance appear sharp and unpredictable? The answer is that the researcherβs choice of a nonlinear or discontinuous metric can distort the model familyβs performance to appear sharp and unpredictable.
To expound, suppose that within a model family, the test loss falls smoothly, continuously, and predictably with the number of model parameters. One reason to believe this is the phenomenon known as neural scaling laws: empirical observations that deep networks exhibit power law scaling in the test loss as a function of training dataset size, number of parameters or compute [15, 32, 13, 18,
10, 14, 17, 39, 16, 8, 29]. For concreteness, suppose we have a model family of different numbers of parameters $N > 0$ and assume that each modelβs per-token cross entropy falls as a power law with the number of parameters $N$ for constants $c > 0 , \alpha < 0$ (Fig. 2A):
$$\mathcal { L } _ { C E } ( N ) = \left( \frac { N } { c } \right) ^ { \alpha }$$
To be clear, we do not require this particular functional form to hold; rather, we use it for illustrative purposes. Let $V$ denote the set of possible tokens, $p$ denote the true but unknown probability distribution, and $\hat { p } _ { N }$ denote the $N$ -parameter modelβs predicted probability distribution. The pertoken cross entropy as a function of number of parameters $N$ is:
$$\mathcal { L } _ { C E } ( N ) \ \stackrel { \mathrm { d e f } } { = } \ - \sum _ { v \in V } p ( v ) \log \hat { p } _ { N } ( v )$$
In practice, $p$ is unknown, so we substitute a one-hot distribution of the observed token $v ^ { * }$
$$\mathcal { L } _ { C E } ( N ) = - \log \hat { p } _ { N } ( v ^ { * } )$$
A model with $N$ parameters then has a per-token probability of selecting the correct token (Fig. 2B):
$$p ( \mathrm { s i n g l e ~ t o k e n ~ c o r r e c t } ) = \exp \Big ( - \mathcal { L } _ { C E } ( N ) \Big ) = \exp \Big ( - \big ( N / c \big ) ^ { \alpha } \Big )$$
Suppose the researcher then chooses a metric that requires selecting $L$ tokens correctly. For example, our task might be $L$ -digit integer addition, and a modelβs output is scored 1 if all $L$ output digits exactly match all target digits with no additions, deletions or substitutions, 0 otherwise. If the probability each token is correct is independent1, the probability of scoring 1 is:
$$\operatorname { A c c u r a c y } ( N ) \approx p _ { N } ( { \mathrm { s i n g l e ~ t o k e n ~ c o r r e c t } } ) ^ { \mathrm { n u m . ~ o f ~ t o k e n s } } = \exp { \Big ( } - ( N / c ) ^ { \alpha } { \Big ) } ^ { L }$$
This choice of metric nonlinearly scales performance with increasing token sequence length. When plotting performance on a linear-log plot, one sees a sharp, unpredictable emergent ability on longer sequences (Fig. 2C) that closely matches claimed emergent abilities (inset). What happens if the researcher switches from a nonlinear metric like Accuracy, under which the per-token error rate scales geometrically in target length (App. A.3), to an approximately linear metric like Token Edit Distance, under which the per-token error rate scales quasi-linearly in target length (App. A.2)?
$${ \mathrm { T o k e n ~ E d i t ~ D i s t a n c e } } ( N ) \approx L \left( 1 - p _ { N } ( { \mathrm { s i n g l e ~ t o k e n ~ c o r r e c t } } ) \right) = L \left( 1 - \exp { \big ( } - ( N / c ) ^ { \alpha } { \big ) } \right)$$
The linear metric reveals smooth, continuous, predictable changes in model performance (Fig. 2E). Similarly, if the researcher uses a discontinuous metric like Multiple Choice Grade, the researcher can find emergent abilities (Fig. 2D), but switching to a continuous metric like Brier Score removes such abilities (Fig. 2F). In summary, sharp and unpredictable changes with increasing scale can be fully explained by three interpretable factors: (1) the researcher choosing a metric that nonlinearly or discontinuously scales the per-token error rate, (2) having insufficient resolution to estimate model performance in the smaller parameter regime, with resolution2 set by 1/test dataset size, and (3) insufficiently sampling the larger parameter regime.
# 3 Analyzing InstructGPT/GPT-3βs Emergent Arithmetic Abilities
Previous papers prominently claimed the GPT [4, 27] family3 displays emergent abilities at integer arithmetic tasks [9, 33, 38] (Fig. 1A). We chose these tasks as they were prominently presented [4, 9, 33, 38], and we focused on the GPT family due to it being publicly queryable. As explained mathematically and visually in Sec. 2, our alternative explanation makes three predictions:
 Figure 3: Claimed emergent abilities evaporate upon changing the metric. Top: When performance is measured by a nonlinear metric (e.g., Accuracy), the InstructGPT/GPT-3 [4, 27] familyβs performance appears sharp and unpredictable on longer target lengths. Bottom: When performance is instead measured by a linear metric (e.g., Token Edit Distance), the family exhibits smooth, predictable performance improvements.
 Figure 4: Claimed emergent abilities evaporate upon using better statistics. Based on the predictable effect Accuracy has on performance, measuring performance requires high resolution. Generating additional test data increases the resolution and reveals that even on Accuracy, the InstructGPT/GPT-3 familyβs [4, 27] performance is above chance and improves in a smooth, continuous, predictable manner that qualitatively matches the mathematical model.
1. Changing the metric from a nonlinear or discontinuous metric (Fig. 2CD) to a linear or continuous metric (Fig. 2 EF) should reveal smooth, continuous, predictable performance improvement with model scale. 2. For nonlinear metrics, increasing the resolution of measured model performance by increasing the test dataset size should reveal smooth, continuous, predictable model improvements commensurate with the predictable nonlinear effect of the chosen metric. 3. Regardless of metric, increasing the target string length should predictably affect the modelβs performance as a function of the length-1 target performance: approximately geometrically for accuracy and approximately quasilinearly for token edit distance.
To test these predictions, we collected outputs from the InstructGPT/GPT-3 family on two tasks: 2-shot multiplication between two 2-digit integers and 2-shot addition between two 4-digit integers.
Prediction: Emergent Abilities Disappear With Different Metrics On both arithmetic tasks, the GPT family displays emergent abilities if the target has 4 or 5 digits and if the metric is Accuracy (Fig. 3, top) [4, 9, 38]. However, if one changes from nonlinear Accuracy to linear Token Edit Distance while keeping the modelsβ outputs fixed, the familyβs performance smoothly, continuously and predictably improves with increasing scale (Fig. 3, bottom). This confirms our first prediction and supports our alternative explanation that the observation of emergent abilities can be explained by the researcherβs choice of metric, not changes in the model familyβs outputs. We also observe that under Token Edit Distance, increasing the length of the target string from 1 to 5 predictably decreases the familyβs performance in an approximately quasilinear manner, confirming the first half of our third prediction.
Prediction: Emergent Abilities Disappear With Better Statistics We next tested our second prediction: that even on nonlinear metrics such as accuracy, smaller models do not have zero accuracy, but rather have non-zero above-chance accuracy commensurate with choosing to use accuracy as the metric. In order to accurately measure modelsβ accuracy, we increased the resolution by generating additional test data, and found that on both arithmetic tasks, all models in the InstructGPT/GPT-3 family achieve above-chance accuracy (Fig. 4). This confirms our second prediction. We also observe that as the target string length increases, the accuracy falls approximately geometrically with the length of the target string, confirming the second half of our third prediction. These results additionally demonstrate that the researcherβs choice of metric has the effect that one should predict accuracy to have, i.e., geometric decay with the target length.
# 4 Meta-Analysis of Claimed Emergent Abilities
Analyzing the GPT family is possible because the models are publicly queryable. However, at the time of this analysis, other model families claimed to exhibit emergent abilities are not publicly queryable, nor are their generated outputs publicly available, meaning we are limited to analyzing the published results themselves [9, 38, 37]. Our alternative explanation makes two predictions.
1. At the βpopulation level" of Task-Metric-Model Family triplets, emergent abilities should appear predominantly on specific metrics, not task-model family pairs, and specifically with nonlinear and/or discontinuous metrics. 2. On individual Task-Metric-Model Family triplets that display an emergent ability, changing the metric to a linear and/or continuous metric should remove the emergent ability.
To test these predictions, we used claimed emergent abilities on BIG-Bench [33, 38] due to the benchmark being pertinent and publicly available.
Prediction: Emergent Abilities Should Appear with Metrics, not Task-Model Families If emergent abilities are real, one should expect task-model family pairs to show emergence for all reasonable metrics. However, if our alternative explanation is correct, we should expect emergent abilities to appear only under certain metrics. To test this, we analyzed on which metrics emergent abilities appear. To determine whether a task-metric-model family triplet exhibits a possible emergent ability, we used a metric from previous work [33]. Letting $y _ { i } \in \mathbb { R }$ denote model performance at model scales $x _ { i } \in \mathbb { R }$ , sorted such that $x _ { i } < x _ { i + 1 }$ , the emergence score is:
$${ \begin{array} { r l r l } { \cdot { \operatorname { S c o r e } } { \Big ( } { \Big \{ } ( x _ { n } , y _ { n } ) { \Big \} } _ { n = 1 } ^ { N } { \Big ) } } & { } & { { \stackrel { \mathrm { d e f } } { = } } } & { { \frac { \operatorname { s i g n } ( \operatorname { a r g m a x } _ { i } y _ { i } - \operatorname { a r g m i n } _ { i } y _ { i } ) ( \operatorname* { m a x } _ { i } y _ { i } - \operatorname* { m i n } _ { i } y _ { i } ) } { \sqrt { { \mathsf { M e d i a n } } ( \{ ( y _ { i } - y _ { i - 1 } ) ^ { 2 } \} _ { i } ) } } } } \end{array} }$$
We found that most metrics used in BIG-Bench have zero task-model family pairs that exhibit emergent abilities: of the 39 preferred metrics in BIG-Bench, at most 5 display emergence (Fig. 5A). Many of the 5 are nonlinear and/or discontinuous, e.g., Exact String Match, Multiple Choice Grade, ROUGE-L-Sum (App. A.4). Notably, because BIG-Bench often scores models on tasks using multiple metrics, the lack of emergent abilities under other metrics suggests that emergent abilities do not appear when model outputs are scored using other metrics.
 Figure 5: Emergent abilities appear only for specific metrics, not task-model families. (A) Possible emergent abilities appear with at most 5 out of 39 BIG-Bench metrics. (B) Hand-annotated data by [37] reveal emergent abilities appear only under 4 preferred metrics. $\mathrm { ( C ) > 9 2 \% }$ of emergent abilities appear under one of two metrics: Multiple Choice Grade and Exact String Match.
Because emergence score only suggests emergence, we also analyzed hand-annotated task-metricmodel family triplets [37], which revealed emergent abilities appear with $4 / 3 9$ metrics (Fig. 5B), and 2 metrics account for $> 9 2 \%$ of claimed emergent abilities (Fig. 5C): Multiple Choice Grade and Exact String Match. Multiple Choice Grade is discontinuous, and Exact String Match is nonlinear.
Prediction: Changing Metric Removes Emergent Abilities To test our second prediction, we focused on the LaMDA family [35] because its outputs are available through BIG-Bench. We identified tasks on which LaMDA displays emergent abilities with Multiple Choice Grade, then asked whether LaMDA still displays emergent abilities on the same tasks with a different BIG-Bench metric: Brier Score [3]. Brier Score is a strictly proper scoring rule for predictions of mutually exclusive outcomes; for a binary outcome, the Brier Score simplifies to the squared error between 1 and the modelβs probability mass on the outcome. LaMDAβs emergent abilities on the discontinuous Multiple Choice Grade disappeared when we changed the metric to the continuous Brier Score (Fig. 6). These results support our alternative explanation that emergent abilities are induced by the chosen metric.
 Figure 6: Changing the metric when evaluating task-model family pairs causes emergent abilities to disappear. Top: The LaMDA model family displays emergent abilities when measured under the discontinuous Multiple Choice Grade. Bottom: The LaMDA model familyβs emergent abilities disappear when measured under a continuous BIG-Bench metric: Brier Score.
# 5 Inducing Emergent Abilities in Networks on Vision Tasks
To demonstrate how emergent abilities can be induced by the researcherβs choice of metric, we show how to produce emergent abilities in deep networks of various architectures: fully connected, convolutional, self-attentional. We focus on vision tasks because abrupt transitions in vision modelsβ capabilities have not been observed to the best of our knowledge; this is one reason why emergence in large language models is considered so interesting. For the convolutional example, see App. B.
Emergent Reconstruction of CIFAR100 Natural Images by Nonlinear Autoencoders We first induce an emergent ability to reconstruct images in shallow (i.e., single hidden layer) nonlinear autoencoders trained on CIFAR100 natural images [21]. To emphasize that the sharpness of the metric is responsible for emergent abilities, and to show that sharpness extends to metrics beyond Accuracy, we intentionally define a discontinuous metric that measures a networkβs ability to reconstruct a dataset as the average number of test data with squared reconstruction error below cutoff $c$ :
$$\mathrm { R e c o n s t r u c t i o n } _ { c } \Big ( \{ x _ { n } \} _ { n = 1 } ^ { N } \Big ) \stackrel { \mathrm { \scriptsize ~ d e f } } { = } \frac { 1 } { N } \sum _ { n } \mathbb { I } \Big [ | | x _ { n } - \hat { x } _ { n } | | ^ { 2 } < c \Big ] ,$$
where $\mathbb { I } ( \cdot )$ denotes an indicator variable and ${ \hat { x } } _ { n }$ is the autoencoderβs reconstruction of $x _ { n }$ . The autoencoder family displays smoothly decreasing squared reconstruction error as the number of bottleneck units increases (Fig. 7B). Under our newly defined Reconstructionc metric and for particular choices of $c$ , the autoencoder family exhibits a sharp and seemingly unpredictable image reconstruction ability (Fig. 7C) that qualitatively matches published emergent abilities (Fig. 7A).
Emergent Classification of Omniglot Characters by Autoregressive Transformers We next induce emergent abilities in Transformers [36] trained to autoregressively classify Omniglot handwritten characters [22], in a setup inspired by recent work [6]: Omniglot images are embedded by convolutional layers, then sequences of embedded image-image class label pairs are fed into decoder-only transformers. We measure image classification performance on sequences of length $L \in [ 1 , 5 ]$ , again via subset accuracy: 1 if all $L$ images are classified correctly (Fig. 8B), 0 otherwise. Causal transformers display a seemingly emergent ability to correctly classify Omniglot handwritten characters (Fig. 8C) that qualitatively matches published emergent abilities (Fig. 8A).
 Figure 7: Induced emergent reconstruction ability in shallow nonlinear autoencoders. (A) A published emergent ability at the BIG-Bench Periodic Elements task [33]. (B) Shallow nonlinear autoencoders trained on CIFAR100 [21] display smoothly decreasing mean squared reconstruction error. (C) Using a newly defined Reconstructionc metric (Eqn. 1) induces an unpredictable change.
 Figure 8: Induced emergent classification ability in autoregressive Transformers. (A) A published emergent ability on the MMLU benchmark [9]. (B) Autoregressive transformers trained to classify Omniglot images display increasing accuracy with increasing scale. (C) When accuracy is redefined as classifying all images correctly, a seemingly emergent ability appears.
# 6 Limitations
This paper has several limitations. First, nothing in this paper should be interpreted as claiming that large language models cannot display emergent abilities; rather, our message is that some previously claimed emergent abilities appear to be mirages induced by researcher analyses. Second, our experiments and analyses are limited because some LLMs with claimed emergent abilities (e.g., PaLM 1, Gopher, Chinchilla) are private and not queryable at the time of our analysis. Lastly, the best metric(s) arguably depends on human preferences, which may exhibit qualitatively different behavior; we are unaware of studies quantifying whether human judgment is thresholded in an βemergent" way.
# 7 Related Work
Srivastava et al. [33] observed that while accuracy at a particular task can empirically appear sharp and unpredictable, cross-entropy does not appear so; the authors then discussed whether emergent abilities may be partially attributed to the metric. Our paper converts their discussion into precise predictions, then quantitatively tests the predictions to reveal metric choice is possibly responsible for some claimed emergent abilities; well-known and widely-used metrics (including metrics used by [33]) capture graded improvements; emergent abilities do not appear only on tasks involving multiple steps, such as the discontinuous Multiple Choice Grade; metric choice can be used to induce emergent abilities in a novel domain (vision) in diverse architectures and tasks.
Alternative explanations exist for the origin of emergent abilities. Caballero et al. [5] explain emergence by assuming a piece-wise power law functional form; under this view, emergent abilities are real, caused by a βbreak" (or possibly multiple breaks) in the governing power law. In contrast, our work suggests that emergent abilities can be induced by the researcher under a single power law. Both explanations could be true: some emergent abilities might genuinely be abruptly appearing, whereas some emergent abilities might be attributable to the metric. Michaud et al. [28] posits that language modeling data might be comprised of discrete subtasks (βquantaβ) that networks learn; if larger networks have greater capacity, and are thus more capable of learning more of these quanta, then if some downstream task requires a network to learn some combination of quanta, larger networks are more likely to have all the requisite capabilities and thus are capable of performing this downstream task. We think that this is a very interesting hypothesis. Whether language modeling data can or should be understood from this quantization perspective, and whether these quanta indeed are the origin of emergent abilities, are really exciting questions that we think merit more study.
# 8 Discussion
Our paper presents an alternative explanation for the claimed emergent abilities of large language models. For a fixed task and a fixed model family, the researcher can choose a metric to create an emergent ability or choose a metric to ablate an emergent ability. Ergo, emergent abilities may be creations of the researcherβs choices, not a fundamental property of the model family on the specific task.
Our work has several implications. Firstly, a task and a metric are distinct and meaningful choices when constructing a benchmark. Secondly, when choosing metric(s), if the goal is to accurately predict scaling behavior, then one should consider the interplay between cross-entropy, transformations, and resolution-limited evaluations so that one isnβt surprised. As a corollary, continuous/linear metrics are probably better for accurate scaling forecasts, but if discontinuous/nonlinear metrics are preferred, then one may need a lot of data for sufficient resolution to accurately measure performance. The key is thinking through the consequences of oneβs choices! Thirdly, when making claims about capabilities of large models, including proper controls is critical. In this particular setting, emergent abilities claims are possibly infected by a failure to control for multiple comparisons. In BIG-Bench alone, there are $\geq 2 2 0$ tasks, $\sim 4 0$ metrics per task, $\sim 1 0$ model families, for a total of $\sim 1 0 ^ { 6 }$ taskmetric-model family triplets, meaning the probability that no task-metric-model family triplet exhibits an emergent ability by random chance might be small. Fourthly, scientific progress can be hampered when models and their outputs are not made available for independent scientific investigation.
# 9 Contributions
RS conceived of the research direction collected data, ran experiments, and analyzed results. SK supervised and guided the project. BM also provided guidance. All authors helped write the manuscript.
# 10 Acknowledgements
This work is partially supported by the National Science Foundation under grants No. 2046795, 1934986, 2205329, NIH 1R01MH116226-01A, NIFA award 2020-67021-32799, the Alfred P. Sloan Foundation, and Google Inc. RS is partially supported by a Stanford Data Science Scholarship and BM is partially supported by a Stanford School of Engineering Fellowship and a Stanford EDGE Scholar Fellowship. We thank our colleagues Professor Tatsunori Hashimoto, Eric Han, Max Lamparth, Mikail Khona, Kateryna Pistunova, Victor Lecomte, and Zane Durante for discussing our findings with us and providing much-appreciated feedback.
References [1] Philip W Anderson. More is different: broken symmetry and the nature of the hierarchical structure of science. Science, 177(4047):393β396, 1972. [2] Boaz Barak, Benjamin Edelman, Surbhi Goel, Sham Kakade, Eran Malach, and Cyril Zhang. Hidden progress in deep learning: Sgd learns parities near the computational limit. Advances in Neural Information Processing Systems, 35:21750β21764, 2022. [3] Glenn W Brier et al. Verification of forecasts expressed in terms of probability. Monthly weather review, 78(1):1β3, 1950. [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. [5] Ethan Caballero, Kshitij Gupta, Irina Rish, and David Krueger. Broken neural scaling laws. arXiv preprint arXiv:2210.14891, 2022. [6] Stephanie CY Chan, Adam Santoro, Andrew Kyle Lampinen, Jane X Wang, Aaditya K Singh, Pierre Harvey Richemond, James McClelland, and Felix Hill. Data distributional properties drive emergent in-context learning in transformers. In Advances in Neural Information Processing Systems, 2022. [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. [8] Aidan Clark, Diego De Las Casas, Aurelia Guy, Arthur Mensch, Michela Paganini, Jordan Hoffmann, Bogdan Damoc, Blake Hechtman, Trevor Cai, Sebastian Borgeaud, et al. Unified scaling laws for routed language models. In International Conference on Machine Learning, pages 4057β4086. PMLR, 2022. [9] Deep Ganguli, Danny Hernandez, Liane Lovitt, Amanda Askell, Yuntao Bai, Anna Chen, Tom Conerly, Nova Dassarma, Dawn Drain, Nelson Elhage, et al. Predictability and surprise in large generative models. In 2022 ACM Conference on Fairness, Accountability, and Transparency, pages 1747β1764, 2022. [10] Mitchell A Gordon, Kevin Duh, and Jared Kaplan. Data and parameter scaling laws for neural machine translation. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 5915β5922, 2021. [11] Andrey Gromov. Grokking modular arithmetic. arXiv preprint arXiv:2301.02679, 2023. [12] Dan Hendrycks. Detecting emergent behavior. 2022. [13] 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. [14] Danny Hernandez, Jared Kaplan, Tom Henighan, and Sam McCandlish. Scaling laws for transfer. arXiv preprint arXiv:2102.01293, 2021. [15] Joel Hestness, Sharan Narang, Newsha Ardalani, Gregory Diamos, Heewoo Jun, Hassan Kianinejad, Md Patwary, Mostofa Ali, Yang Yang, and Yanqi Zhou. Deep learning scaling is predictable, empirically. arXiv preprint arXiv:1712.00409, 2017. [16] Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, Lisa Anne Hendricks, Johannes Welbl, Aidan Clark, et al. Training compute-optimal large language models. arXiv preprint arXiv:2203.15556, 2022. [17] Andy L Jones. Scaling scaling laws with board games. arXiv preprint arXiv:2104.03113, 2021.
[18] 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.
[19] Victoria Krakovna, Vikrant Varma, Ramana Kumar, and Mary Phuong. Refining the sharp left turn threat model, part 1: claims and mechanisms. 2022.
[20] Victoria Krakovna, Vikrant Varma, Ramana Kumar, and Mary Phuong. Refining the sharp left turn threat model, part 2: applying alignment techniques. 2022.
[21] Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, 2009.
[22] Brenden M Lake, Ruslan Salakhutdinov, and Joshua B Tenenbaum. Human-level concept learning through probabilistic program induction. Science, 350(6266):1332β1338, 2015.
[23] Yann LeCun. The mnist database of handwritten digits. http://yann. lecun. com/exdb/mnist/, 1998.
[24] Yann LeCun, LΓ©on Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278β2324, 1998.
[25] Chin-Yew Lin. Rouge: A package for automatic evaluation of summaries. In Text summarization branches out, pages 74β81, 2004.
[26] Ziming Liu, Eric J Michaud, and Max Tegmark. Omnigrok: Grokking beyond algorithmic data. arXiv preprint arXiv:2210.01117, 2022.
[27] Ryan Lowe and Jan Leike. Aligning language models to follow instructions. 2022.
[28] Eric J. Michaud, Ziming Liu, Uzay Girit, and Max Tegmark. The quantization model of neural scaling, 2023.
[29] Oren Neumann and Claudius Gros. Scaling laws for a multi-agent reinforcement learning model. arXiv preprint arXiv:2210.00849, 2022.
[30] Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics, pages 311β318, Philadelphia, Pennsylvania, USA, July 2002. Association for Computational Linguistics.
[31] Alethea Power, Yuri Burda, Harri Edwards, Igor Babuschkin, and Vedant Misra. Grokking: Generalization beyond overfitting on small algorithmic datasets. arXiv preprint arXiv:2201.02177, 2022.
[32] Jonathan S Rosenfeld, Amir Rosenfeld, Yonatan Belinkov, and Nir Shavit. A constructive prediction of the generalization error across scales. In International Conference on Learning Representations, 2019.
[33] Aarohi Srivastava, Abhinav Rastogi, Abhishek Rao, Abu Awal Md Shoeb, Abubakar Abid, Adam Fisch, Adam R Brown, Adam Santoro, Aditya Gupta, AdriΓ Garriga-Alonso, et al. Beyond the imitation game: Quantifying and extrapolating the capabilities of language models. arXiv preprint arXiv:2206.04615, 2022.
[34] Jacob Steinhardt. Future ml systems will be qualitatively different. 2022.
[35] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, HengTze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022.
[36] 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.
[37] Jason Wei. 137 emergent abilities of large language models. 2022.
[38] Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, et al. Emergent abilities of large language models. arXiv preprint arXiv:2206.07682, 2022. [39] Xiaohua Zhai, Alexander Kolesnikov, Neil Houlsby, and Lucas Beyer. Scaling vision transformers. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12104β12113, 2022.
# A Approximate Behavior of Metrics on Sequential Data
How do different metrics behave when used to measure autoregressive model outputs? Precisely answering this question is tricky and possibly analytically unsolvable, so we provide an approximate answer here.
Notationally, we consider $N$ test data of length $L$ (here, length is measured in tokens) with targets denoted $t _ { n } \ { \stackrel { \mathrm { d e f } } { = } } \ ( t _ { n 1 } , t _ { n 2 } , . . . t _ { n L } )$ , the autoregressive model has a true-but-unknown per-token error probability of $\epsilon \in [ 0 , 1 ]$ and the model outputs prediction $\boldsymbol { \hat { t } _ { n } } \ { \stackrel { \mathrm { d e f } } { = } } \ ( { \hat { t } _ { n 1 } } , { \hat { t } _ { n 2 } } , . . . { \hat { t } _ { n L } } )$ . This assumes that the modelβs per-token error probability is constant, which is empirically false, but modeling the complex dependencies of errors is beyond our scope.
# A.1 Per-Token Error Probability is Resolution-Limited
Note that because we have $N$ test data, each of length $L$ , our resolution for viewing the per-token error probability $\epsilon$ is limited by $1 / N L$ . Here, resolution refers to βthe smallest interval measurable by a scientific instrument; the resolving power." To explain what resolution means via an example, suppose one wants to measure a coinβs probability of yielding heads. After a single coin flip, only two outcomes are possible (H, T), so the resolution-limited probability of heads is either 0 or 1. After two coin flips, four outcomes are possible (HH, HT, TH, TT), so the resolution-limited probability of heads is now one of $0 , 0 . 5 , 1$ . After $F$ coin flips, we can only resolve the coinβs probability of yielding heads up to $1 / F$ . Consequently, we introduce a resolution-limited notation:
$a _ { b } \ { \stackrel { \mathrm { d e f } } { = } } \ a$ rounded to the nearest integer multiple of $1 / b$
# A.2 Token Edit Distance
We first consider an adaptation of the Levenshtein (string edit) distance for models that function on tokens rather than characters, an adaptation we term the token edit distance. The token edit distance between two token sequences $t _ { n } , \hat { t _ { n } }$ is defined as the integer number of additions, deletions or substitutions necessary to transform $t _ { n }$ into $\hat { t } _ { n }$ (or vice versa).
$$\begin{array} { l } { \mathrm { T o k e n ~ E d i t ~ D i s t a n c e } ( t _ { n } , \hat { t } _ { n } ) \overset { \mathrm { d e f } } { = } \mathrm { N u m ~ S u b s t i u t i o n s } + \mathrm { N u m . ~ A d d i t i o n s } + \mathrm { N u m . ~ D e l e t i o n s } } \\ { \displaystyle = \sum _ { \ell = 1 } ^ { L } \mathbb { I } [ t _ { n \ell } \neq \hat { t } _ { n \ell } ] + \mathrm { N u m . ~ A d d i t i o n s } + \mathrm { N u m . ~ D e l e t i o n s } } \\ { \displaystyle \quad \geq \sum _ { \ell = 1 } ^ { L } \mathbb { I } [ t _ { n \ell } \neq \hat { t } _ { n \ell } ] } \end{array}$$
The expected token edit distance is therefore:
$$\begin{array} { l } { \displaystyle \mathbb { E } [ \mathrm { T o k e n ~ E d i t ~ D i s t a n c e } ( t _ { n } , \hat { t } _ { n } ) ] \geq \mathbb { E } [ \sum _ { \ell = 1 } ^ { L } \mathbb { I } [ t _ { n \ell } \neq \hat { t } _ { n \ell } ] ] } \\ { \displaystyle = \sum _ { \ell = 1 } ^ { L } p ( t _ { n \ell } \neq \hat { t } _ { n \ell } ) } \\ { \approx L ( 1 - \epsilon ) } \end{array}$$
The resolution-limited expected token edit distance is therefore:
$$\mathbb { E } [ \mathrm { T o k e n ~ E d i t ~ D i s t a n c e } ( t _ { n } , \hat { t } _ { n } ) ] _ { N L } \ge L \Big ( 1 - \epsilon _ { N L } \Big )$$
From this, we see that the expected token edit distance scales approximately linearly with the resolution-limited per-token probability. The real rate is slightly higher than linear because additions
and deletions contribute an additional non-negative cost, but modeling this requires a model of how likely the model is to overproduce or underproduce tokens, which is something we do not currently possess.
# A.3 Accuracy
$$\begin{array} { l } { \displaystyle \mathrm { A c c u r a c y } ( t _ { n } , \hat { t } _ { n } ) \stackrel { \mathrm { d e f } } { = } \mathbb { I } [ \mathrm { N o \ a d d i t i o n s } ] \mathbb { I } [ \mathrm { N o \ d e l e t i o n s } ] \prod _ { l = 1 } ^ { L } \mathbb { I } [ t _ { n l } = \hat { t } _ { n l } ] } \\ { \displaystyle \approx \prod _ { l = 1 } ^ { L } \mathbb { I } [ t _ { n l } = \hat { t } _ { n l } ] } \end{array}$$
As with the Token Edit Distance (App. A.2), we ignore how likely the language model is to overproduce or underproduce tokens because we do not have a good model of this process. Continuing along,
$$\begin{array} { l } { \displaystyle \mathbb { E } [ \log \mathrm { A c c u r a c y } ] = \sum _ { l } \mathbb { E } [ \log \mathbb { I } [ t _ { n l } = \hat { t } _ { n l } ] ] } \\ { \displaystyle \qquad \leq \sum _ { l } \log \mathbb { E } [ \mathbb { I } [ t _ { n l } = \hat { t } _ { n l } ] ] } \\ { \displaystyle \qquad \approx L \log ( 1 - \epsilon ) } \end{array}$$
Taking an approximation that would make most mathematicians cry:
$$\begin{array} { r } { \mathbb { E } [ \mathrm { A c c u r a c y } ] \approx \exp ( \mathbb { E } [ \mathrm { l o g } \mathrm { A c c u r a c y } ] ) } \\ { = ( 1 - \epsilon ) ^ { L } } \end{array}$$
This reveals that accuracy approximately falls geometrically with target token length. The resolutionlimited expected accuracy is therefore:
$$\mathbb { E } [ \mathrm { A c c u r a c y } ] _ { N L } = ( 1 - \epsilon ) ^ { L } { } _ { N L }$$
From this we can see that choosing a nonlinear metric like Accuracy is affected significantly more than a linear metric by limited resolution because Accuracy forces one to distinguish quantities that decay rapidly.
# A.4 ROUGE-L-Sum
Another BIG-Bench metric [33] is ROUGE-L-Sum [25], a metric based on the longest common subsequence (LCS) between two sequences. Section 3.2 of [25] gives the exact definition, but the key property is that ROUGE-L-Sum measures the βunion" LCS, which means βstitching" together LCSs across the candidate and multiple references. As explained in the original paper [25]: if the candidate sequence is $c = w _ { 1 } w _ { 2 } w _ { 3 } w _ { 4 } w _ { 5 }$ , and if there are two reference sequences $r _ { 1 } = w _ { 1 } w _ { 2 } w _ { 6 } w _ { 7 } w _ { 8 }$ and $r _ { 2 } = w _ { 1 } w _ { 3 } w _ { 8 } w _ { 9 } w _ { 5 }$ , then $L C S ( r _ { 1 } , c ) = w _ { 1 } w _ { 2 }$ and $L C S ( r _ { 2 } , c ) = \overline { { w _ { 1 } w _ { 3 } w _ { 5 } } }$ , then the union LCS of $c , r _ { 1 } , r _ { 2 }$ is $w _ { 1 } w _ { 2 } w _ { 3 } w _ { 5 }$ , with length 4. Intuitively, this disproportionately benefits models with smaller error rates because their mistakes can be βstitched" across multiple references; this is confirmed in Monte Carlo simulation (Fig. 9).
# A.5 BLEU
Yet another BIG-Bench metric [33] is BLEU [30], a metric based on shared $\mathbf { n }$ -grams between the generated string and reference strings. BLEU is also a discontinuous and nonlinear metric for several reasons. For an explanation of its discontinuity, consider bleu.compute(predictions $=$ ["hello there general"], references=[["hello there general"]]). At first glance, this might seem like it should also result in a BLEU score of 1.0 since the prediction matches the reference. However, the issue here is the absence of longer n-grams. For the unigrams, bigrams, and trigrams, the precision is 1.0 since they match perfectly. However, for the 4-grams, there are none in both the candidate and the reference. This results in a precision of 0 for the 4-grams because the BLEU score takes the geometric mean of the n-gram precisions, meaning any 0 in the set will make the entire product 0. Hence, despite the match in unigrams, bigrams, and trigrams, the absence of 4-grams results in a BLEU score of 0.0. This behavior of BLEU has been a point of criticism, as short sentences or those with fewer n-grams than the maximum considered (often 4) can yield scores that are counter-intuitive. This is confirmed in Monte Carlo simulations (Fig. 10)
 Figure 9: ROUGE-L-Sum is a sharp metric. Simulations show that as the per-token error probability slightly increases (e.g. from 0.05 to 0.1), the ROUGE-L-Sum metric falls sharply.
 Figure 10: BLEU is a sharp metric. Simulations show that as the per-token error probability slightly increases (e.g. from 0.05 to 0.1), the ROUGE-L-Sum metric falls sharply.
# B Inducing Emergent Abilities in Networks on Vision Tasks
# B.1 Emergent Classification of MNIST Handwritten Digits by Convolutional Networks
We begin by inducing an emergent classification ability in a LeNet convolutional neural network family [24], trained on the MNIST handwritten digits dataset [23]. This family displays smoothly increasing test accuracy as the number of parameters increases (Fig. 11B). To emulate the accuracy metric used by emergence papers [9, 38, 33], we use subset accuracy: 1 if the network classifies $K$ out of $K$ (independent) test data correctly, 0 otherwise. Under this definition of accuracy, the model family displays an βemergent" ability to correctly classify sets of MNIST digits as $K$ increases from 1 to 5, especially when combined with sparse sampling of model sizes (Fig. 11C). This convolutional familyβs emergent classification ability qualitatively matches published emergent abilities, e.g., at the BIG-Bench Grounded Mappings task [38] (Fig. 11A).
 Figure 11: Induced emergent MNIST classification ability in convolutional networks. (A) A published emergent ability from the BIG-Bench Grounded Mappings task [38]. (B) LeNet trained on MNIST [23] displays a predictable, commonplace sigmoidal increase in test accuracy as model parameters increase. (C) When accuracy is redefined as correctly classifying $K$ out of $K$ independent test data, this newly defined metric induces a seemingly unpredictable change.
# C Relationship Between Emergent Abilities and Grokking
Emergent abilities [4, 9, 33, 38] are sometimes compared with grokking [31, 26, 2, 11], a phenomenon whereby a single model will, over the course of learning, achieve high training accuracy and only much later achieve high test accuracy. There are several differences between grokking and emergent abilities:
1. Grokking is primarily studied within a single model, whereas emergent abilities are studied within a model family (i.e., multiple models). 2. Grokking occurs with increasing gradient steps, whereas emergent abilities occur with increasing model scale, typically measured in parameters or effective parameters (although more recently compute). 3. Grokking explicitly studies a discrepancy between the modelβs train and test behavior, whereas emergent abilities (to the best of our knowledge) do not present separate train & test curves. 4. Grokking is primarily studied on toy βalgorithmic" tasks in small networks, whereas emergent abilities are often studied on benchmark NLP tasks in large language models.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491# Grounded Decoding: Guiding Text Generation with Grounded Models for Embodied Agents
Wenlong Huang1β, Fei $\mathbf { X i a } ^ { 2 }$ , Dhruv Shah3, Danny Driess2, Andy Zeng2, Yao $\mathbf { L } \mathbf { u } ^ { 2 }$ , Pete Florence2, Igor Mordatch2, Sergey Levine2,3, Karol Hausman2, Brian Ichter2 1Stanford University, 2Google Deepmind, 3UC Berkeley grounded-decoding.github.io
# Abstract
Recent progress in large language models (LLMs) has demonstrated the ability to learn and leverage Internet-scale knowledge through pre-training with autoregressive models. Unfortunately, applying such models to settings with embodied agents, such as robots, is challenging due to their lack of experience with the physical world, inability to parse non-language observations, and ignorance of rewards or safety constraints that robots may require. On the other hand, languageconditioned robotic policies that learn from interaction data can provide the necessary grounding that allows the agent to be correctly situated in the real world, but such policies are limited by the lack of high-level semantic understanding due to the limited breadth of the interaction data available for training them. Thus, if we want to make use of the semantic knowledge in a language model while still situating it in an embodied setting, we must construct an action sequence that is both likely according to the language model and also realizable according to grounded models of the environment. We frame this as a problem similar to probabilistic filtering: decode a sequence that both has high probability under the language model and high probability under a set of grounded model objectives. We demonstrate how such grounded models can be obtained across three simulation and real-world domains, and that the proposed decoding strategy is able to solve complex, long-horizon embodiment tasks in a robotic setting by leveraging the knowledge of both models.
# 1 Introduction
Recent works have demonstrated robots that are increasingly proficient at understanding and acting upon natural language, whether through planning or conditioned policies. Complementing such progress, the field of natural language processing has recently seen large language models (LLMs) become ubiquitously used as pre-trained or few-shot prompted models, due to their impressive fewshot performance and vast knowledge-base. These LLMs have efficiently learned from web-scale data through autoregressively modeling the probability distribution over text tokens and thus generate text. However, the nature of this process is such that applying such models to embodied settings remains a challenge. They have not interacted with their environment, lack observability of nonlanguage observation modalities (e.g., images), and may not know what is safe or possible for a particular embodiment.
Determining how to execute long-horizon behaviors based on high-level verbal commands is one particular area of robotics where the rich semantic knowledge in large language models can be especially useful. This problem combines elements of semantic reasoning and planning: the robot must understand the instruction, determine the steps needed to fulfill it, and also determine how to sequence those steps appropriately given its capabilities and the current state of the environment. However, this is not a problem that can be solved purely with semantics, as it requires sufficient grounding to understand how the task should be performed in context β for example, in the example in Figure 1, the language model alone has no way of knowing which block to pick up because this requires knowledge of which blocks are present, and also what manipulations the robot is capable of performing on them. Thus, although a language model can assign probabilities for how likely various steps are to correspond to the desired task semantically, the constraints of the planning problem must also enter into the process. These constraints could themselves be represented as probabilities that mirror the token probabilities generated by a language model, reflecting their applicability to the current environment rather than their semantic likelihood. We can frame this as a problem similar to probabilistic filtering: decode a sequence (i.e., a task description) that both has a high probability under the language model and a high probability under a grounded model that predicts how applicable this sequence is to the current scene.
 Figure 1: Grounded Decoding solves robotic tasks by taking an instruction as input and selecting tokens that have high probability under a Large Language Model (LLM) and a set of Grounded Models (GM). Thus, it leverages the open-vocabulary and semantic knowledge of LLMs while being grounded in the environment and in the robotβs capabilities. Furthermore, the whole process does not require expensive fine-tuning of the LLM.
Herein, we present Grounded Decoding (GD), a scalable, general approach to planning with LLMs embodied domains. Grounded Decoding jointly decodes the token probability of an LLM and token probabilities from token-conditioned, robotic functions, such as affordance functions capturing the abilities of a robot given its embodiment, safety functions, or more. By guiding the LLM directly at its output, Grounded Decoding enables a general and flexible family of planning algorithms that combines LLMβs strength of long-horizon and semantic reasoning and grounded modelsβ strength of local and embodiment grounding.
Our contributions are as followed: 1) we present a robot-centric formulation for decoding language models to perform long-horizon robotic tasks with token-conditioned grounded models, 2) we demonstrate techniques for learning such grounded models, serving different purposes such as affordances and safety requirements, and 3) we show empirical evidence, across three simulation and real-world domains, that the proposed method performs strongly on a wide range of tasks while also significantly outperforming prior methods in efficiency.
# 2 Related Work
Guided Decoding for Language Models. Decoding strategies for large language models is an active area of research within natural language processing [77, 87, 25, 85, 38]. A number of recent works have focused on developing decoding heuristics for natural text generation [49, 35, 48, 18, 25, 6, 36, 63]. Another line of works use external classifiers for maximizing certain language-space utilities when decoding language models [71, 92, 26, 39, 37, 21, 38, 4, 12, 23]. Most closely related to our work are classifier-guided decoding methods developed for offline domains, such as image captioning [78, 74] and task-oriented dialog [72, 83]. However, extensions to embodied domains, which we investigate exclusively in this work, remain non-trivial because grounding in embodied domains is bounded by the abilities of the agent and by environment state transition as the agent actively interacts with the environment.
 Figure 2: Overview of Grounded Decoding. Given a free-form language instruction, a language model and grounded models jointly decide the next candidate token to be decoded by combining their respective likelihood. Language model proposes likely tokens that produce goal-directed and coherent long-horizon behaviors, while grounded models connect them to the physical scene, through a flexible composition of multiple objective functions from multiple modalities, such as affordance, preferences, and safety.
Embodied and Multimodal Language Models. Training language models to understand embodiment is an active area of research. Training multimodal models can enable some degree of embodied reasoning, such as understanding images and videos [9, 40, 76, 3]. Directly finetuning language models to output actions has also been investigated [75, 55, 66]. Lastly, training downstream models on language model embeddings shows promise [46, 52, 24, 94, 60, 41]. In this work, we investigate leveraging large frozen language models for embodied applications [29, 2, 96, 8, 64, 30, 42, 70, 47, 27, 58, 73, 44, 43, 14, 16, 82, 93, 89, 45, 56], with grounded models to provide domain-specific grounding during decoding process.
Comparison to SayCan. The most closely related work to our work is SayCan [2]. SayCan uses a large language model and a value function to select robotic skills among a constrained set of primitives. This constrained set of primitives enables SayCan to use the so-called βscoring-modeβ of the LLM to get the probability of a skill being useful to a high-level instruction. This requirement to consider only a fixed and enumerated set of primitives limits the applicability of SayCan in scenarios with many possible skills, such as open vocabulary or combinatorial tasks. Grounded Decoding on the other hand jointly decodes the LLM and the grounded model at the token level, allowing for expressive decoding with an open vocabulary. Furthermore, SayCan considers only grounding functions derived from RL-trained value functions for affordance grounding functions, while Grounded Decoding explores many types of grounding functions to propose a broad family of algorithms.
Task and Motion Planning. Task and motion planning [33] seeks to solve high-level instructions via sequencing tasks in dynamically feasible manner. Research within this area generally focuses on symbolic planning [19] or optimization-based [79] approaches. Machine learning has increasingly been used to accelerate planning and enable new domains [91, 61, 69, 20, 17, 28, 90, 31, 1, 65, 51, 86, 88, 15]. However, planning constraints are often explicitly specified for TAMP methods. In contrast, we specify constraints as (learned) probabilities, which are baked into the decoding process and provided by domain-specific grounded models.
# 3 Grounded Decoding
# 3.1 LLMs and Grounding Models
Large Language Models. LLMs are trained to predict the probability $p ( W )$ of a text sequence $W$ , represented as a sequence of tokens $W = w _ { 1 : N } = ( w _ { 1 } , \dotsc , w _ { N } )$ . The tokens are elements of a fixed vocabulary $\mathcal { W }$ . Typical neural architectures factorize the joint probability into $p ( W ) =$ $\begin{array} { r } { \prod _ { n = 1 } ^ { N } p _ { \mathrm { L L M } } ( w _ { n } | w _ { 1 : n - 1 } ) } \end{array}$ , where $p _ { \mathrm { L L M } }$ is predicted by a transformer network [81]. Given $p _ { \mathrm { L L M } }$ , generating a text consisting of $N$ -many tokens, the so-called decoding process, can be seen as the optimization problem arg $\begin{array} { r } { \operatorname* { m a x } _ { w _ { 1 : N } \in \mathcal { W } } \prod _ { n = 1 } ^ { N } p _ { \mathrm { L L M } } ( w _ { n } | w _ { 1 : n - 1 } ) } \end{array}$ , which in practice is solved, e.g., using greedy search , beam search, or sampling strategies. To further ensure the LLM is solving a desired task, one typically starts with a given text, the so-called prefix or prompt, that describes the task, and then the LLM completes this task in its decoding process.
Grounding Functions. We use the concept of grounding functions, $p _ { \mathrm { G } } ( w _ { 1 : n } | s )$ , which seek to model a probability of tokens $w _ { 1 : n }$ given (potentially non-textual) state $s \in S$ . This state is intended to capture the embodiment of the robot and the environment, which may be an image, proprioception of the robot, or the environment state. Thus the grounding function models probabilities relevant to the robot embodiment and environment, such as whether the tokens are possible for the robot to execute given the state (affordances), or other values like safety, cost, or user preferences.
# 3.2 Problem formulation.
Given an instruction in language $\ell$ , we look at the problem of using an LLM to decode a language plan $w _ { 1 : N }$ , which is typically done by finding the most likely tokens under the probability distribution predicted by the LLM, $p _ { \mathrm { L L M } } ( w _ { 1 : N } | \ell )$ , with $\ell$ being the prefix. However, based on the instruction $\ell$ as the prefix alone, the LLM can easily generate text that is not grounded in the physical state of the environment, rendering such plans useless in the real world. In order to ground the language model in an actual physical embodiment, we propose Grounded Decoding (GD): The main idea of GD is to guide the generation of token sequences with grounding function $( s )$ that are conditioned on the embodiment of the system.
Formally, let $s \in S$ denote a representation of the state of the world. Then, GD attempts to generate text that is consistent with both the instruction $\ell$ and the physical state $s$ :
$$w _ { 1 : N } ^ { * } = \arg \operatorname* { m a x } _ { w _ { 1 : N } , w _ { n } \in \mathcal { W } } p _ { \mathrm { G D } } ( w _ { 1 : N } | s , \ell )$$
To leverage the Internet-scale knowledge of LLMs, we factorize $p _ { \mathrm { G D } } ( w _ { 1 : N } | s , \ell )$ as follows 2:
$$\begin{array} { r l } { p _ { \mathrm { G i D } } ( w _ { 1 : N } | s , \ell ) = \frac { p ( s , \ell | w _ { 1 : N } ) p ( w _ { 1 : N } ) } { p ( s , \ell ) } } & { } \\ { = \frac { p ( s | w _ { 1 : N } ) p ( \ell | w _ { 1 : N } ) p ( w _ { 1 : N } ) } { p ( s , \ell ) } } & { } \\ { = \frac { p ( w _ { 1 : N } | \ell ) p ( \ell ) p ( w _ { 1 : N } | s ) p ( s ) p ( w _ { 1 : N } ) } { p ( s , \ell ) p ( w _ { 1 : N } ) p ( w _ { 1 : N } ) } } & { } \\ { \propto \frac { p ( w _ { 1 : N } | \ell ) } { p ( w _ { 1 : N } ) } p ( w _ { 1 : N } ) } & { } \\ { \propto \frac { p ( w _ { 1 : N } | \ell ) } { p ( w _ { 1 : N } ) } p ( w _ { 1 : N } | s ) } & { } \\ { \propto p ( w _ { 1 : N } | \ell ) p ( w _ { 1 : N } | s ) . } & { } \end{array}$$
To decode autoregressively with the formulation, we factorize above into token decoding:
$$\begin{array} { r } { p _ { \mathrm { G D } } ( w _ { 1 : N } | s , \ell ) \propto \displaystyle \prod _ { n = 1 } ^ { N } p _ { \mathrm { L L M } } ( w _ { n } | w _ { 1 : n - 1 } , \ell ) p _ { \mathrm { G } } ( w _ { 1 : n } | s ) . } \end{array}$$
The first term, $p _ { \mathrm { L L M } } ( w _ { n } | w _ { 1 : n - 1 } , \ell )$ , can be modeled as the probability of the LLM predicting the token for the given instruction $\ell$ appended previously decoded tokens $w _ { 1 : n - 1 }$ without the state $s$ as input. The second term, $p _ { \mathrm { G } } ( w _ { 1 : n } | s )$ , is the grounding function that is only conditioned on the state $s$ and judges whether the generated text $w _ { 1 : n }$ is consistent with the physical state. The core idea behind this factorization is that LLMs exhibit long-term planning capabilities, while the grounding function guides the planning of the LLM to be possible in the concrete embodied physical world without needing to be informed or capable of reasoning over the long-horizon instruction.
# 3.3 Grounded Decoding
This work investigates grounded decoding exclusively in the context of task planning for embodied agents. Figure 2 visualizes a single step of the simplest greedy search form of GD, and accompanying pseudo-code can be found in Algorithm 1. Given a high-level language instruction and history of executed actions, GD proceeds through a process similar to probabilistic filtering by selecting tokens iteratively that have high probability under the language model and the grounded model. After each token is selected, it is appended to the prefix. The process continues until a token in the terminal set ${ \mathcal { W } } _ { \mathrm { t e r m } }$ is selected, which could be a period sign β.β indicating the end of a single-step skill (e.g., pick-and-place). Then the command $w _ { 1 : i }$ is sent to a language-conditioned policy $\pi ( \boldsymbol { a } | \boldsymbol { s } , \boldsymbol { w } _ { 1 : i } )$ that executes the action $a$ conditioned on the environment state $s$ . Crucially, this grounding function must accept partial commands to enable grounding during decoding.3 Additionally, we note that GD, in its essence, provides a grounded scoring function; thus, it can be easily extended to any search methods such as beam search, top- $\mathbf { \nabla } \cdot \mathbf { k }$ sampling, etc.
# Algorithm 1 Grounded Decoding (GD) w/ Greedy Search
1: Given: state $s$ , instruction $\ell$ , terminal set ${ \mathcal { W } } _ { \mathrm { t e r m } }$ 2: Initialize: $w = \{ \}$ , $n = 0$ 3: while $w _ { n } \notin \mathcal { W } _ { \mathrm { t e r m } } \mathbf { d o }$ 4: $n = n + 1$ 5: $\begin{array} { r } { \left. w _ { n } = \arg \operatorname* { m a x } _ { w _ { n } \in \mathcal { W } } p _ { \mathrm { L L M } } ( w _ { n } | w _ { 1 : n - 1 } , \ell ) p _ { \mathrm { G } } ( w _ { 1 : n } | s ) \right. } \end{array}$ 6: end while 7: Return: $w$
# 3.4 Techniques for Obtaining Grounded Models
Unlike language tasks, where a single model is capable of performing general semantic reasoning, a singular grounded model remains an open problem. Indeed, each domain may impose varied environmental and embodiment constraints. Despite these challenges, we present several techniques for obtaining grounded models that can be leveraged in GDβs formulation, and validate them in three domains in Section 4.
Token-Conditioned Value Functions. Assuming a robot acts with action $a$ according to policy $\pi ( \boldsymbol { a } | \boldsymbol { s } , \boldsymbol { w } _ { 1 : n } )$ , that aims to maximize certain a utility and that the utility captures a task objective, a natural choice that can provide βgrounding scoreβ is the action-value function $Q ( s , a | w _ { 1 : n } )$ as it necessarily captures the embodiment of the robot. Additional objectives, such as task constraints, can also be encapsulated in $Q ( s , a | w _ { 1 : n } )$ to ensure grounding. Note that unlike the formulation proposed in [2], $w _ { 1 : n }$ cannot be restricted to a fixed repertoire of token sequences. In practice, to obtain a $Q ( s , a | w _ { 1 : n } )$ that satisfies the requirements, one can train multi-task language-conditioned agents, either through reinforcement learning (Section 4.2) or supervised learning (Section 4.1).
Multimodal Foundation Models. A general choice to ground LLMs is through using multimodal foundation models, such as CLIP [57] or open-vocabulary object detectors [22, 34, 50]. Although these models can connect language to other grounded modalities (e.g., vision), they often lack the capability for complex or long-horizon reasoning, and they do not consider embodiment constraints. As a result, to leverage them in the decoding process, they need to constrained to where they are the most applicable rather than always decoding jointly. To this end, we use a prompt-based technique that allows LLMs to choose when to jointly decode (Section 4.3), which we find to be effective in most cases.4.
Rule-based Methods. Another source of grounding may come from features $x = \phi ( w _ { 1 : n } )$ designed with expert domain knowledge, which can then be used to map $w _ { 1 : n }$ to a βgrounding scoreβ using pamametric or non-parametric functions $f ( x )$ . Such techniques may be most applicable when interpretability and enforcing hard constraints are required, such as safety-critical settings, or when data are scarce, such as cases involving preferences of individual users (as shown in Section 4.1).
# 3.5 Comparisons to Prompt-based Methods
One alternative approach for grounding is including scene information as part of the prompt (e.g., object detection results [96]), which complements the grounding method proposed in this work.
 Figure 3: Example rollouts and likelihood of representative tokens under Grounded Decoding objective in three distinct domains: simulated tabletop rearrangement (top), Minigrid 2D Maze (middle), and real-world Language score, grounding score, tokenskitchen mobile manipulation (bottom). Each domain uses different prompts, grounded models, and low-level [(-2.2144471089350395, 13.634880781173706, 'pepsi'), primitives. The GD formulation is shared across the domains, decoding a pre-trained langauge model with (-0.1931666703881, 0.0, 'grapefruit soda'), respect to domain-specific grounded models to decompose a open-ended instruction into actionable steps.
However, we note that prompting is often insufficent for grounding, as information about the scene and about the capabilities of the robot may not always be succinctly described in the prompt. Such examples include 1) in a block stacking task, a block that has been stacked on cannot be picked, 2) in a navigation task, to open a door, one must have a key and that door must be reachable, and 3) in a mobile manipulation domain, an object may be visible but is out of reach of the manipulator. Therefore, Grounded Decoding is a more general and flexible grounding method that injects continuous probabilities during decoding, which may even come from grounding functions from other modalities (e.g., vision).
# 4 Experiments
# 4.1 Long-Horizon Tabletop Manipulation
Herein we experiment with a simulated tabletop manipulation environment based on RAVENS [95]. We create a custom set of 20 tasks, with 10 seen tasks and 10 unseen tasks. Seen tasks are used for training (for supervised baseline) or for few-shot prompting. They are grouped by following categories. Detailed breakdown can be found in Appendix A.2.
i. Letters: Rearranging alphabetical letters (βsort the letters in alphabetical orderβ).
ii. Blocks & Bowls: Rearranging or combining blocks and bowls (βput blocks in matching bowlsβ).
iii. Box Packing: Sorting food items and utensils into boxes in accordance with safety constraints and user preferences (βCan you pack the picnic box for me?β).
Given only high-level language instructions and top-down visual observation of the environment, Grounded Decoding decodes a sequence of text tokens representing the step command to be executed. Note that because GD generated grounded free-form actions, it does not require each step to strictly map to a repertoire of skill as in [29, 2]. After a complete command is generated, it is executed via a pre-trained multi-task language-conditioned CLIPort [67]. An example rollout is shown in Figure 4.To demonstrate the techniques proposed in Section 3.4 to obtain grounding functions, we study the composition of following grounding functions (overall grounding score is calculated as $\textstyle p _ { \mathbf { G } } = \mathbf { \dot { I } } \prod _ { i = 1 } ^ { n } p _ { i } )$ depending on the task categories. Refer to the Appendix A.2 for details.
Table 1: Tabletop domain success rates.
<table><tr><td></td><td colspan="2">CLIPort</td><td>+LLM</td><td colspan="2">+GD (Ours)</td></tr><tr><td></td><td>Short Long</td><td></td><td>Ungrounded</td><td>Greedy Beam</td><td></td></tr><tr><td>Seen Tasks</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Letters</td><td>7%</td><td>40%</td><td>20%</td><td>43%</td><td>57%</td></tr><tr><td>Blocks&Bowls</td><td>2%</td><td>62%</td><td>35%</td><td>60%</td><td>77%</td></tr><tr><td>Box Packing*</td><td>15%</td><td>28%</td><td>11%</td><td>79%</td><td>78%</td></tr><tr><td>Unseen Tasks</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Letters</td><td>6%</td><td>10%</td><td>19%</td><td>37%</td><td>41%</td></tr><tr><td>Blocks&Bowls</td><td>6%</td><td>10%</td><td>28%</td><td>44%</td><td>50%</td></tr></table>
Table 2: 2D Maze success rates.
<table><tr><td></td><td></td><td>+Skills</td><td>+LLM</td><td colspan="2">+GD (Ours)</td></tr><tr><td></td><td>PPO</td><td>HRL</td><td>Ungrounded</td><td>Greedy</td><td>Beam</td></tr><tr><td>Easy</td><td>28%</td><td>68%</td><td>96%</td><td>100%</td><td>100%</td></tr><tr><td>Medium</td><td>13%</td><td>48%</td><td>87%</td><td>93%</td><td>97%</td></tr><tr><td>Hard</td><td>6%</td><td>31%</td><td>54%</td><td>78%</td><td>88%</td></tr></table>
Affordance Grounding Function (AF). As the primitive policy CLIPort [67] already acts as an action-value function over the pixel space, we directly leverage its predictions for affordance grounding. In particular, given scene image $s$ and partially-decoded instruction $w _ { 1 : n }$ , CLIPort predicts unnormalized logits over the pixel space $\mathbf { u } _ { \mathrm { p i c k } } , \mathbf { u } _ { \mathrm { p l a c e } } \mathbf { \dot { \in } } \mathbb { R } ^ { 4 8 0 \times 6 4 0 }$ , respectively for the pick location and the place location. Therefore, for any given $s$ and $w _ { 1 : n }$ , we can calculate the affordance as $p _ { \mathrm { A F } } ( w _ { 1 : n } | s ) = \operatorname* { m a x } _ { ( x , y ) \in 4 8 0 \times 6 4 0 }$ $( \mathbf { u } _ { \mathrm { p i c k } } ( x , y ) + \mathbf { u } _ { \mathrm { p l a c e } } ( x , y ) )$ .
Safety Grounding Function (S). To strictly enforce hard constraints such as safety requirements, we adopt the rule-based method proposed in Section 3.4. In particular, the features $x$ are indicator functions denoting whether knives and red boxes which we use as hazardous objects are involved in an action, i.e., $x = \mathbb { I } [$ [βredβ or βknifeβ in $w _ { 1 : n } ]$ . We then use constant mappings to convert the features $\begin{array} { r } { p _ { \mathrm { S } } ( w _ { 1 : n } | s ) = \underline { { \epsilon } } ( x + \frac { 1 } { Z } ( 1 - x ) } \end{array}$ to scores of 0 or 1, where $Z$ is the normalizing term and $\epsilon \approx 0$ is a small value for ensuring the joint probability does not collapse to 0.
Preference Grounding Function $\mathbf { \Pi } ^ { ( \mathbf { P } ) }$ . We similarly use rule-based methods for preference grounding, as data of individual users may be scarce to learn a separate model. In particular, we choose two random objects $\left( o _ { 1 } , o _ { 2 } \right)$ as the preferred objects, i.e., $x = \mathbb { I } [ o _ { 1 } \quad$ or $O _ { 2 }$ in $w _ { 1 : n } ]$ . Note that unlike safety functions, preferences often come in the form of βsoft requirementβ. Therefore, the preference grounding function is implemented as $\begin{array} { r } { p _ { \mathrm { P } } ( w _ { 1 : n } | s ) = \frac { \alpha } { Z } x + \frac { \bar { \beta ^ { } } } { Z } ( 1 - x ) } \end{array}$ , where we choose $\alpha = 0 . 5$ and $\beta = 0 . 1$ for our experiments.
Baselines. We study two variants of GD using beam search and greedy search. We also compare to βNo Groundingβ baseline that decodes only according to language model likelihood. Furthermore, we compare to solitary method CLIPort [67] that directly take in the high-level language instructions without a planner. We consider two variants of CLIPort: 1) βShortβ that is trained with only singlestep pick-and-place commands, and 2) βLongβ that is trained on high-level instructions from the 10 training tasks. For more details, please refer to Appendix A.2.
Analysis. Results grouped by each task category are shown in Table $\cdot$ . Please refer to the Appendix for detailed breakdown. Each method is evaluated on 20 episodes for each task within each task category. Supervised methods, such as CLIPort, are found to perform poorly on unseen tasks. Methods that leverage language model planner show better generalization to unseen tasks but fall short due to lack of grounding. Grounded Decoding achieves the best results by enabling the LLM to plan actions using grounded information and is further improved with beam search.
# 4.2 2D Maze
We further evaluate the long-horizon reasoning of Grounded Decoding for 2D maze-solving on Minigrid [10]. The agent receives a top-down view of the environment along with a natural language instruction. More details can be found in Appendix A.3. The tasks are grouped in three categories:
i. Easy: Simple tasks where the horizon is short (10-30 steps) and fully described by the textual instruction, e.g. OpenDoors and PutNext.
ii. Medium: Short and long-horizon tasks (up to 80 steps) with step-by-step textual instructions, e.g. LockedRoom.
iii. Hard: Complex, long-horizon instructions (over 100 steps) with ambiguous instructions that necessitate multi-step reasoning and efficient exploration, e.g. MultiRoom and BlockedUnlock.
 Figure 4: Greedy decoding rollout with GD, where key decoded tokens are shown (yellow, purple, red, yellow). Combined scores are normalized to the maximum for visual clarity; others are normalized to their sum.
Affordance Grounding Function. Following the recipe from Section 3.3, we train tokenconditioned affordance function to be used in GD. The difference is that the grounding function here is the value function from the goal-conditioned policy that is trained with PPO [62] instead of from demonstrations as in CLIPort [67]. The policy performs short-horizon skills such as βGo to red keyβ or βOpen the doorβ and are conditioned on CLIP embeddings of the skill and an image of the scene. Accordingly, the goal-conditioned value function evaluates the feasibility given the current observation and the (partially) decoded skill.
Baselines. We compare the two variants of GD β with greedy and beam search β with 1) a solitary PPO policy [62], 2) a hierarchical RL algorithm which plans over the low-level skills, and 3) a hierarchical method that uses an ungrounded language model for planning [29].
Analysis. Table 2 reports the success rate, averaged across 100 episodes of randomly initialized environments. The βflatβ RL agent performs poorly in all but the simplest environments, owing to difficulties with understanding the high-level instruction and reasoning over long horizons (often over 100 steps). Planning over low-level skills using hierarchical RL [5] improves this performance, since the high-level decision-making problem is greatly simplified. However, the high-level RL agent still needs to reason over low-level (textual) skills by understanding their underlying capabilities and stitching them together. Using the planning capabilities of large language models to reason over textual skills significantly boosts this performance [29], since the language model can inherit the strong reasoning capabilities from its training data. This tends to be insufficient in challenging environments, however, since the number of potentially viable skills may be very large and the LLM has no information about the robotβs observations. GD can leverage the learned affordance function (in this case, the goal-conditioned value function) to inform the language modelβs plans, enabling successful long-horizon reasoning. We further find that beam search improves performance modestly, particularly in long-horizon tasks.
# 4.3 Mobile Manipulation in a Physical Kitchen
Our last environment is a kitchen robot in the real world, and we follow the same implementations of the mobile manipulation platform and skills in SayCan [2]. We perform instruction following tasks, as in [2]. An example task is βBring an appleβ, for which the robot needs to plan and execute a sequence of β1. Find an apple, 2. Pick up the apple, 3. Bring it to you. 4. Put it down, 5. Doneβ. We split the tasks into two categories. Unambiguous means the instruction explicitly contains the object of interest, and Ambiguous means the instruction does not contain the object name. For example, when human asks βbring me the fruitβ, the robot needs to first determine available fruits. We assume all necessary objects are in the field of view. More details can be found in Appendix A.4.
Grounded Decoding with Chain-of-thought. We demonstrate using multimodal foundation models for Grounded Decoding, as proposed in Section 3.4. In particular, we use open-vocabulary object detector owl-vit [50]. Note that because these off-the-shelf models are not trained on robot domain data, we find that it works best by constraining their influence on decoding. We achieve this by making a slight modification to the SayCan algorithm [2]: before generating action plans, we prompt the LLM to generate visually-grounded chain-of-thought [84] by giving LLM the option of when to enable grounded decoding and disable grounded decoding, as visualized in Fig. 5. Specifically,
 Figure 5: Example prompt and rollout in realworld kitchen environment.
Table 3: Success rates in kitchen environment.
<table><tr><td></td><td colspan="2">GD</td><td colspan="2">SayCan</td></tr><tr><td>Tasks</td><td>Planning</td><td>gExecution Planning</td><td></td><td>οΌExecution</td></tr><tr><td>Unambiguous</td><td>85%</td><td>57%</td><td>85%</td><td>57%</td></tr><tr><td>Ambiguous</td><td>58%</td><td>44%</td><td>33%</td><td>25%</td></tr></table>
Table 4: By avoiding full enumeration of skills, GD is more efficient than SayCan while staying performant.
<table><tr><td colspan="4">GD (GreedyοΌ ( GD(BeamοΌ SayCan</td></tr><tr><td>Success Rate</td><td>50%</td><td>60%</td><td>64%</td></tr><tr><td>Token Count</td><td>1x</td><td>4.3x</td><td>113.7x</td></tr></table>
LLMs can be prompted to generate a left bracket to start decoding jointly with grounded models and a right bracket to revert to ungrounded decoding. After chain-of-thought, we use SayCan scoring mode for decoding the action plans.
Analysis. Table 3 shows that GD recovers similar performance on Unambiguous tasks, and gain $2 5 \%$ in planning performance on Ambiguous tasks. This shows that GD with multimodal foundation models can effectively use visually-grounded chain-of-thought to disambiguate abstract tasks.
# 5 Analysis
# 5.1 Comparison to SayCan
In this section, we directly compare GD to SayCan [2], which is related to our method in that both combine language model knowledge and grounded model knowledge (discussed in more detail in Section 2). However, SayCan uses the language model to score all pre-specified options, rendering it inefficient at dealing with large or combinatorial action spaces. In contrast, GD computation considers all possible language token in the autoregressive decoding process, which is independent of the size of the action space. Results shown in Table 4 demonstrate that GD is two orders of magnitude more efficient on our tasks, with comparable performance. Furthermore, by decoding at the most basic functioning unit of language, GDβs formulation allows open-vocabulary grounding beyond just affordances, e.g. safety, preferences, and multimodal embeddings such as CLIP.
# 5.2 Breakdown of Failure Reasons
Because all hierarchical approaches share an imperfect low-level policy for step execution, the results reported in Table 1 are compounded with both planning failures and low-level policy failure. In Figure 6, we provide failure breakdown analysis for Grounded Decoding and associated baselines. Note that the CLIPort baselines are solitary methods that do not use a planner, so the failures are solely composed of policy failures. As shown in Figure 6, while all planning-based methods use the same underlying low-level policy, Grounded Decoding significantly reduces planning failure by being able to incorporate grounded scene information into the decoding process. Moreover, we observe that despite the shared affordance function across beam and greedy search, the beam search variant performs stronger by being aware of the full-length single-step instructions during decoding.
# 5.3 Grounded Action Manifold
A central goal of this work is to investigate the integration of grounded information into language model decoding to output instructions actionable by a policy. To investigate this, we use a t-SNE [80] plot to illustrate the extent to which grounded models help narrow down the search space for language models. Specifically, we first enumerate all meaningful instructions in the tabletop domain, such as βpick x and place it on y,β which are represented as dots in the figure. We then compute the affordance values with respect to four different scenes, where each color represents one scene. Finally, we group the dots using t-SNE and BERT embeddings [13]. Figure 7 shows that grounded models can effectively identify achievable skills to produce an actionable manifold within the language space and that this grounding is required, as language alone does not perfectly group actionable skills. It is worth noting that while we provide manual enumeration of all possible skills for practical analysis, the full language space is much larger. This highlights the even more pronounced narrowing of the search in the language space.
 Figure 6: Failure breakdown on tabletop domain. GD achieves lowest planning failure among planning-based methods, among which beam search variant performs the best.
 Figure 7: Visualization of actions colored by affordance values in different scenes. Every dot represents a possible action in the tabletop domain, where the majority of the actions are infeasible. We show how grounded models can identify the feasible actions for specific scenes. Notably, these actions are not always clustered in language space, requiring the grounding function to determine what action to perform.
# 6 Conclusions, Limitations, & Future Works
We presented Grounded Decoding (GD), an approach for leveraging the knowledge and capabilities of large language models in embodied settings through grounding functions, which model the probabilities of tokens given an embodiment. GD resembles probabilistic filtering, by decoding tokens that have high probabilities under the language model and under grounded model(s). By guiding the LLMβs decoding directly at its output, GD is a general, flexible, and expressive approach to embodied tasks. This is demonstrated on three embodied domains, showing GD is capable of solving complex, long-horizon tasks.
Though quite general and flexible, GD has a few limitations. First, although we present several techniques for obtaining grounding functions in different domains, it remains a question whether a capable and general grounding function can be obtained. We hope that recent progress in largescale robotics models (e.g. [7] and [59]) can remove this bottleneck, and note that the flexibility of GD allows such progress to be straightforwardly leveraged. Second, prompt engineering is often required to steer LLMs to the desired action space (e.g., likely action verbs, likely present objects). Finally, while not requiring additional training, the joint decoding may be limiting compared to a single model capable of both grounding and language reasoning [3, 9, 16].
This work presented a family of algorithms for grounding LLMs in embodiment, for which there are many avenues for future work. The flexibility of the approach enables many other grounding functions and ways to integrate grounding. Furthermore, the development and integration of a foundation model for grounding would improve performance significantly. Finally, though GDβs probabilistic filtering-based approach is quite general, fusing grounding information to the language model after each token decoding may be limiting and future works can investigate how such grounding can be elegantly integrated during decoding.
# Acknowledgments
The authors would like to acknowledge Pierre Sermanet, Carolina Parada, Jie Tan, Yevgen Chebotar, Vincent Vanhoucke, and Dorsa Sadigh for their feedback and contributions. This work is supported in part by OpenAI academic access program, granted to Wenlong Huang.
References [1] Christopher Agia, Toki Migimatsu, Jiajun Wu, and Jeannette Bohg. Stap: Sequencing taskagnostic policies. arXiv preprint arXiv:2210.12250, 2022. [2] Michael Ahn, Anthony Brohan, Noah Brown, Yevgen Chebotar, Omar Cortes, Byron David, Chelsea Finn, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, Daniel Ho, Jasmine Hsu, Julian Ibarz, Brian Ichter, Alex Irpan, Eric Jang, Rosario Jauregui Ruano, Kyle Jeffrey, Sally Jesmonth, Nikhil Joshi, Ryan Julian, Dmitry Kalashnikov, Yuheng Kuang, Kuang-Huei Lee, Sergey Levine, Yao Lu, Linda Luu, Carolina Parada, Peter Pastor, Jornell Quiambao, Kanishka Rao, Jarek Rettinghouse, Diego Reyes, Pierre Sermanet, Nicolas Sievers, Clayton Tan, Alexander Toshev, Vincent Vanhoucke, Fei Xia, Ted Xiao, Peng Xu, Sichun Xu, and Mengyuan Yan. Do as i can and not as i say: Grounding language in robotic affordances. In arXiv preprint arXiv:2204.01691, 2022. [3] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, et al. Flamingo: a visual language model for few-shot learning. arXiv preprint arXiv:2204.14198, 2022. [4] Ashutosh Baheti, Alan Ritter, Jiwei Li, and Bill Dolan. Generating more interesting responses in neural conversation models with distributional constraints. arXiv preprint arXiv:1809.01215, 2018. [5] Andrew G. Barto and Sridhar Mahadevan. Recent advances in hierarchical reinforcement learning. Discrete Event Dynamic Systems, 13(1β2):41β77, jan 2003. [6] Sourya Basu, Govardana Sachitanandam Ramachandran, Nitish Shirish Keskar, and Lav R Varshney. Mirostat: A neural text decoding algorithm that directly controls perplexity. arXiv preprint arXiv:2007.14966, 2020. [7] Anthony Brohan, Noah Brown, Justice Carbajal, Yevgen Chebotar, Joseph Dabis, Chelsea Finn, Keerthana Gopalakrishnan, Karol Hausman, Alex Herzog, Jasmine Hsu, et al. Rt-1: Robotics transformer for real-world control at scale. arXiv preprint arXiv:2212.06817, 2022. [8] Boyuan Chen, Fei Xia, Brian Ichter, Kanishka Rao, Keerthana Gopalakrishnan, Michael S Ryoo, Austin Stone, and Daniel Kappler. Open-vocabulary queryable scene representations for real world planning. arXiv preprint arXiv:2209.09874, 2022. [9] Xi Chen, Xiao Wang, Soravit Changpinyo, AJ Piergiovanni, Piotr Padlewski, Daniel Salz, Sebastian Goodman, Adam Grycner, Basil Mustafa, Lucas Beyer, et al. Pali: A jointly-scaled multilingual language-image model. arXiv preprint arXiv:2209.06794, 2022. [10] Maxime Chevalier-Boisvert, Lucas Willems, and Suman Pal. Minimalistic gridworld environment for gymnasium, 2018. [11] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022. [12] Sumanth Dathathri, Andrea Madotto, Janice Lan, Jane Hung, Eric Frank, Piero Molino, Jason Yosinski, and Rosanne Liu. Plug and play language models: A simple approach to controlled text generation. arXiv preprint arXiv:1912.02164, 2019. [13] 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. [14] Yan Ding, Xiaohan Zhang, Chris Paxton, and Shiqi Zhang. Task and motion planning with large language models for object rearrangement. arXiv preprint arXiv:2303.06247, 2023. [15] Danny Driess, Ozgur Oguz, Jung-Su Ha, and Marc Toussaint. Deep visual heuristics: Learning feasibility of mixed-integer programs for manipulation planning. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 9563β9569. IEEE, 2020. [16] Danny Driess, Fei Xia, Mehdi SM Sajjadi, Corey Lynch, Aakanksha Chowdhery, Brian Ichter, Ayzaan Wahid, Jonathan Tompson, Quan Vuong, Tianhe Yu, et al. Palm-e: An embodied multimodal language model. arXiv preprint arXiv:2303.03378, 2023. [17] Ben Eysenbach, Russ R Salakhutdinov, and Sergey Levine. Search on the replay buffer: Bridging planning and reinforcement learning. Advances in Neural Information Processing Systems, 2019. [18] Angela Fan, Mike Lewis, and Yann Dauphin. Hierarchical neural story generation. arXiv preprint arXiv:1805.04833, 2018. [19] Richard E Fikes and Nils J Nilsson. Strips: A new approach to the application of theorem proving to problem solving. Artificial intelligence, 1971. [20] Caelan Reed Garrett, Chris Paxton, Tomas Lozano-P Β΄ erez, Leslie Pack Kaelbling, and Dieter Β΄ Fox. Online replanning in belief space for partially observable task and motion problems. In 2020 IEEE International Conference on Robotics and Automation (ICRA), 2020. [21] Marjan Ghazvininejad, Xing Shi, Jay Priyadarshi, and Kevin Knight. Hafez: an interactive poetry generation system. In Proceedings of ACL 2017, System Demonstrations, pages 43β48, 2017. [22] Xiuye Gu, Tsung-Yi Lin, Weicheng Kuo, and Yin Cui. Open-vocabulary object detection via vision and language knowledge distillation. arXiv preprint arXiv:2104.13921, 2021. [23] Thomas Hartvigsen, Saadia Gabriel, Hamid Palangi, Maarten Sap, Dipankar Ray, and Ece Kamar. Toxigen: A large-scale machine-generated dataset for adversarial and implicit hate speech detection. arXiv preprint arXiv:2203.09509, 2022. [24] Felix Hill, Sona Mokra, Nathaniel Wong, and Tim Harley. Human instruction-following with deep reinforcement learning via transfer-learning from text. arXiv preprint arXiv:2005.09382, 2020. [25] Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, and Yejin Choi. The curious case of neural text degeneration. arXiv preprint arXiv:1904.09751, 2019. [26] Ari Holtzman, Jan Buys, Maxwell Forbes, Antoine Bosselut, David Golub, and Yejin Choi. Learning to write with cooperative discriminators. arXiv preprint arXiv:1805.06087, 2018. [27] Chenguang Huang, Oier Mees, Andy Zeng, and Wolfram Burgard. Visual language maps for robot navigation. arXiv preprint arXiv:2210.05714, 2022. [28] De-An Huang, Suraj Nair, Danfei Xu, Yuke Zhu, Animesh Garg, Li Fei-Fei, Silvio Savarese, and Juan Carlos Niebles. Neural task graphs: Generalizing to unseen tasks from a single video demonstration. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2019. [29] 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. PMLR, 2022. [30] Wenlong Huang, Fei Xia, Ted Xiao, Harris Chan, Jacky Liang, Pete Florence, Andy Zeng, Jonathan Tompson, Igor Mordatch, Yevgen Chebotar, Pierre Sermanet, Noah Brown, Tomas Jackson, Linda Luu, Sergey Levine, Karol Hausman, and Brian Ichter. Inner monologue: Embodied reasoning through planning with language models. In arXiv preprint arXiv:2207.05608, 2022. [31] Brian Ichter, Pierre Sermanet, and Corey Lynch. Broadly-exploring, local-policy trees for long-horizon task planning. Conference on Robot Learning (CoRL), 2021. [32] Eric Jang, Alex Irpan, Mohi Khansari, Daniel Kappler, Frederik Ebert, Corey Lynch, Sergey Levine, and Chelsea Finn. Bc-z: Zero-shot task generalization with robotic imitation learning. In Conference on Robot Learning, pages 991β1002. PMLR, 2021. [33] Leslie Pack Kaelbling and Tomas Lozano-P Β΄ erez. Hierarchical planning in the now. In Β΄ Workshops at the Twenty-Fourth AAAI Conference on Artificial Intelligence, 2010. [34] Aishwarya Kamath, Mannat Singh, Yann LeCun, Gabriel Synnaeve, Ishan Misra, and Nicolas 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. [35] Jungo Kasai, Keisuke Sakaguchi, Ronan Le Bras, Dragomir Radev, Yejin Choi, and Noah A Smith. Beam decoding with controlled patience. arXiv preprint arXiv:2204.05424, 2022. [36] 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. [37] Ben Krause, Akhilesh Deepak Gotmare, Bryan McCann, Nitish Shirish Keskar, Shafiq Joty, Richard Socher, and Nazneen Fatema Rajani. Gedi: Generative discriminator guided sequence generation. arXiv preprint arXiv:2009.06367, 2020. [38] Remi Leblond, Jean-Baptiste Alayrac, Laurent Sifre, Miruna Pislar, Jean-Baptiste Lespiau, Β΄ Ioannis Antonoglou, Karen Simonyan, and Oriol Vinyals. Machine translation decoding beyond beam search. arXiv preprint arXiv:2104.05336, 2021. [39] Jiwei Li, Will Monroe, and Dan Jurafsky. Learning to decode for future success. arXiv preprint arXiv:1701.06549, 2017. [40] 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. [41] Shuang Li, Xavier Puig, Yilun Du, Clinton Wang, Ekin Akyurek, Antonio Torralba, Jacob Andreas, and Igor Mordatch. Pre-trained language models for interactive decision-making. arXiv preprint arXiv:2202.01771, 2022. [42] Jacky Liang, Wenlong Huang, Fei Xia, Peng Xu, Karol Hausman, Brian Ichter, Pete Florence, and Andy Zeng. Code as policies: Language model programs for embodied control. arXiv preprint arXiv:2209.07753, 2022. [43] Kevin Lin, Christopher Agia, Toki Migimatsu, Marco Pavone, and Jeannette Bohg. Text2motion: From natural language instructions to feasible plans. arXiv preprint arXiv:2303.12153, 2023. [44] Bo Liu, Yuqian Jiang, Xiaohan Zhang, Qiang Liu, Shiqi Zhang, Joydeep Biswas, and Peter Stone. Llm+ p: Empowering large language models with optimal planning proficiency. arXiv preprint arXiv:2304.11477, 2023. [45] Yujie Lu, Pan Lu, Zhiyu Chen, Wanrong Zhu, Xin Eric Wang, and William Yang Wang. Multimodal procedural planning via dual text-image prompting. arXiv preprint arXiv:2305.01795, 2023. [46] Corey Lynch and Pierre Sermanet. Grounding language in play. 2020. [47] Oier Mees, Jessica Borja-Diaz, and Wolfram Burgard. Grounding language with visual affordances over unstructured data. arXiv preprint arXiv:2210.01911, 2022. [48] Clara Meister, Tiago Pimentel, Gian Wiher, and Ryan Cotterell. Typical decoding for natural language generation. arXiv preprint arXiv:2202.00666, 2022. [49] Clara Meister, Tim Vieira, and Ryan Cotterell. If beam search is the answer, what was the question? arXiv preprint arXiv:2010.02650, 2020. [50] Matthias Minderer, Alexey Gritsenko, Austin Stone, Maxim Neumann, Dirk Weissenborn, Alexey Dosovitskiy, Aravindh Mahendran, Anurag Arnab, Mostafa Dehghani, Zhuoran Shen, et al. Simple open-vocabulary object detection with vision transformers. arXiv preprint arXiv:2205.06230, 2022.
[51] Ashvin V Nair, Vitchyr Pong, Murtaza Dalal, Shikhar Bahl, Steven Lin, and Sergey Levine. Visual reinforcement learning with imagined goals. In Advances in Neural Information Processing Systems, 2018.
[52] Suraj Nair, Eric Mitchell, Kevin Chen, Brian Ichter, Silvio Savarese, and Chelsea Finn. Learning language-conditioned robot behavior from offline data and crowd-sourced annotation. In Conference on Robot Learning, pages 1303β1315. PMLR, 2021.
[53] OpenAI. Gpt-4 technical report. arXiv, 2023.
[54] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. arXiv preprint arXiv:2203.02155, 2022.
[55] Alexander Pashevich, Cordelia Schmid, and Chen Sun. Episodic transformer for vision-andlanguage navigation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2021.
[56] Dhruvesh Patel, Hamid Eghbalzadeh, Nitin Kamra, Michael Louis Iuzzolino, Unnat Jain, and Ruta Desai. Pretrained language models as visual planners for human assistance. arXiv preprint arXiv:2304.09179, 2023.
[57] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. In Marina Meila and Tong Zhang, editors, Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 8748β8763. PMLR, 18β24 Jul 2021.
[58] Shreyas Sundara Raman, Vanya Cohen, Eric Rosen, Ifrah Idrees, David Paulius, and Stefanie Tellex. Planning with large language models via corrective re-prompting. arXiv preprint arXiv:2211.09935, 2022.
[59] Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, et al. A generalist agent. arXiv preprint arXiv:2205.06175, 2022.
[60] Machel Reid, Yutaro Yamada, and Shixiang Shane Gu. Can wikipedia help offline reinforcement learning. arXiv preprint arXiv:2201.12122, 2022.
[61] Nikolay Savinov, Alexey Dosovitskiy, and Vladlen Koltun. Semi-parametric topological memory for navigation. arXiv preprint arXiv:1803.00653, 2018.
[62] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
[63] Thomas Scialom, Paul-Alexis Dray, Sylvain Lamprier, Benjamin Piwowarski, and Jacopo Staiano. Discriminative adversarial search for abstractive summarization. In International Conference on Machine Learning, pages 8555β8564. PMLR, 2020.
[64] Dhruv Shah, Blazej Osinski, Brian Ichter, and Sergey Levine. Lm-nav: Robotic navigation with large pre-trained models of language, vision, and action. arXiv preprint arXiv:2207.04429, 2022.
[65] Dhruv Shah, Peng Xu, Yao Lu, Ted Xiao, Alexander Toshev, Sergey Levine, and Brian Ichter. Value function spaces: Skill-centric state abstractions for long-horizon reasoning. ICLR, 2022.
[66] Pratyusha Sharma, Antonio Torralba, and Jacob Andreas. Skill induction and planning with latent language. arXiv preprint arXiv:2110.01517, 2021.
[67] Mohit Shridhar, Lucas Manuelli, and Dieter Fox. Cliport: What and where pathways for robotic manipulation. In Conference on Robot Learning, pages 894β906. PMLR, 2022.
[68] Mohit Shridhar, Lucas Manuelli, and Dieter Fox. Perceiver-actor: A multi-task transformer for robotic manipulation. In Proceedings of the 6th Conference on Robot Learning (CoRL), 2022.
[69] Tom Silver, Rohan Chitnis, Nishanth Kumar, Willie McClinton, Tomas Lozano-Perez, Leslie Pack Kaelbling, and Joshua Tenenbaum. Inventing relational state and action abstractions for effective and efficient bilevel planning. arXiv preprint arXiv:2203.09634, 2022. [70] 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. arXiv preprint arXiv:2209.11302, 2022. [71] Charlie Snell, Ilya Kostrikov, Yi Su, Mengjiao Yang, and Sergey Levine. Offline rl for natural language generation with implicit language q learning. arXiv preprint arXiv:2206.11871, 2022. [72] Charlie Snell, Sherry Yang, Justin Fu, Yi Su, and Sergey Levine. Context-aware language modeling for goal-oriented dialogue systems. arXiv preprint arXiv:2204.10198, 2022. [73] Chan Hee Song, Jiaman Wu, Clayton Washington, Brian M Sadler, Wei-Lun Chao, and Yu Su. Llm-planner: Few-shot grounded planning for embodied agents with large language models. arXiv preprint arXiv:2212.04088, 2022. [74] Yixuan Su, Tian Lan, Yahui Liu, Fangyu Liu, Dani Yogatama, Yan Wang, Lingpeng Kong, and Nigel Collier. Language models can see: plugging visual controls in text generation. arXiv preprint arXiv:2205.02655, 2022. [75] 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. [76] Chen Sun, Austin Myers, Carl Vondrick, Kevin Murphy, and Cordelia Schmid. Videobert: A joint model for video and language representation learning. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2019. [77] Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks. Advances in neural information processing systems, 27, 2014. [78] Yoad Tewel, Yoav Shalev, Idan Schwartz, and Lior Wolf. Zero-shot image-to-text generation for visual-semantic arithmetic. arXiv preprint arXiv:2111.14447, 2021. [79] Marc Toussaint. Logic-geometric programming: An optimization-based approach to combined task and motion planning. In Twenty-Fourth International Joint Conference on Artificial Intelligence, 2015. [80] Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008. [81] 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. [82] Sai Vemprala, Rogerio Bonatti, Arthur Bucker, and Ashish Kapoor. Chatgpt for robotics: Design principles and model abilities. 2023, 2023. [83] Siddharth Verma, Justin Fu, Mengjiao Yang, and Sergey Levine. Chai: A chatbot ai for taskoriented dialogue with offline reinforcement learning. arXiv preprint arXiv:2204.08426, 2022. [84] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022. [85] Sean Welleck, Ilia Kulikov, Jaedeok Kim, Richard Yuanzhe Pang, and Kyunghyun Cho. Consistency of a recurrent language model with respect to incomplete decoding. arXiv preprint arXiv:2002.02492, 2020. [86] Bohan Wu, Suraj Nair, Li Fei-Fei, and Chelsea Finn. Example-driven model-based reinforcement learning for solving long-horizon visuomotor tasks. arXiv preprint arXiv:2109.10312, 2021. [87] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Googleβs neural machine translation system: Bridging the gap between human and machine translation. arXiv preprint arXiv:1609.08144, 2016. [88] Fei Xia, Chengshu Li, Roberto MartΒ΄Δ±n-MartΒ΄Δ±n, Or Litany, Alexander Toshev, and Silvio Savarese. Relmogen: Integrating motion generation in reinforcement learning for mobile manipulation. In 2021 IEEE International Conference on Robotics and Automation (ICRA), 2021. [89] Yaqi Xie, Chen Yu, Tongyao Zhu, Jinbin Bai, Ze Gong, and Harold Soh. Translating natural language to planning goals with large-language models. arXiv preprint arXiv:2302.05128, 2023. [90] Danfei Xu, Ajay Mandlekar, Roberto MartΒ΄Δ±n-MartΒ΄Δ±n, Yuke Zhu, Silvio Savarese, and Li FeiFei. Deep affordance foresight: Planning through what can be done in the future. In 2021 IEEE International Conference on Robotics and Automation (ICRA), pages 6206β6213. IEEE, 2021. [91] Danfei Xu, Suraj Nair, Yuke Zhu, Julian Gao, Animesh Garg, Li Fei-Fei, and Silvio Savarese. Neural task programming: Learning to generalize across hierarchical tasks. In 2018 IEEE International Conference on Robotics and Automation (ICRA), 2018. [92] Kevin Yang and Dan Klein. Fudge: Controlled text generation with future discriminators. arXiv preprint arXiv:2104.05218, 2021. [93] Haoqi Yuan, Chi Zhang, Hongcheng Wang, Feiyang Xie, Penglin Cai, Hao Dong, and Zongqing Lu. Plan4mc: Skill reinforcement learning and planning for open-world minecraft tasks. arXiv preprint arXiv:2303.16563, 2023. [94] Rowan Zellers, Ximing Lu, Jack Hessel, Youngjae Yu, Jae Sung Park, Jize Cao, Ali Farhadi, and Yejin Choi. Merlot: Multimodal neural script knowledge models. Advances in Neural Information Processing Systems, 2021. [95] Andy Zeng, Pete Florence, Jonathan Tompson, Stefan Welker, Jonathan Chien, Maria Attarian, Travis Armstrong, Ivan Krasin, Dan Duong, Vikas Sindhwani, and Johnny Lee. Transporter networks: Rearranging the visual world for robotic manipulation. Conference on Robot Learning (CoRL), 2020. [96] Andy Zeng, Adrian Wong, Stefan Welker, Krzysztof Choromanski, Federico Tombari, Aveek Purohit, Michael Ryoo, Vikas Sindhwani, Johnny Lee, Vincent Vanhoucke, et al. Socratic models: Composing zero-shot multimodal reasoning with language. arXiv preprint arXiv:2204.00598, 2022.
# A Appendix
# A.1 Grounded Decoding Implementation Details
We study three different implementations of Grounded Decoding for each of the experimental domains. While each instantiation applied Grounded Decoding to long-horizon planning and behavior synthesis, different components including language models and grounded models are used in each domain, as seen in Table 5. Grounded models used in these domains include Affordance Functions (AF), Safety Functions (S), Preference Functions (P), and Open-Vocabulary Object Detectors (D).
<table><tr><td></td><td>Tabletop Rearrangement (Sim)</td><td>MiniGrid 2D Maze (Sim)</td><td>Kitchen Mobile Manipulation (Real)</td></tr><tr><td>LLM</td><td>InstructGPT [54]</td><td>InstructGPT</td><td>InstructGPT + PaLM[11]</td></tr><tr><td>Primitives</td><td>CLIPort [67]</td><td>PPO [62]</td><td>RT-1 [7]</td></tr><tr><td>Grounded Models</td><td>AF+S + P</td><td>AF</td><td>D</td></tr></table>
Table 5: Comparison between different versions of GD implemented in three different environments.
# A.2 Implementation Details of Simulated Tabletop Rearrangement
# A.2.1 Tasks
There are a total of 20 tasks (templates of language instructions), listed in Table 6, grouped into three task category: Letters, Blocks&Bowls, and Box Packing. Three categories share a total of 57 objects. For Letters category, the goals are to rearrange the alphabetical letter objects such that they satisfy certain orders specified by the language instructions. At the beginning of each episode, task-relevant objects and a set of 1 to 3 randomly-sampled distractor objects (except for the Letters category) are initialized at random positions on the tabletop with fixed orientations. A minimum $1 5 \mathrm { c m }$ distance is enforced between any two objects to avoid collision and penetration at initialization. To allow for automatic evaluations, a binary reward function is defined for each task using ground-truth state of the objects. Furthermore, we implement scripted policies for each task to collect demonstrations for training the CLIPort baseline. For certain tasks, we also randomize the attributes mentioned in the given instructions, which can be found below:
i. hwordi: hi, world, left, right, top, down, love, you ii. hcorner/sidei: left side, top left corner, top side, top right corner, bottom right corner, bottom side, bottom left corner
# A.2.2 Low-level Primitives
We use CLIPort [67] as the low-level primitive that can be invoked by the LLM planner, as it shows promising results of generalization across free-form language instructions. Additionally, since the policy predicts per-pixel affordance, it can be repurposed to serve as grounded models for planning for long-horizon tasks, which we leverage in this work. The single primitive policy is trained on 50,000 pre-collected demonstrations, across 10 training tasks, where each demonstration contains 1) language instruction of the format βpick up [x] and place it on [y]β, 2) top-down RGB-D observation of the current scene, 3) expert pick location expressed as pixel coordinates, and 4) expert place location expressed as pixel coordinates. The expert actions are obtained by accessing ground-truth object pose in the simulator. We further apply substring augmentation during training as we find it helps with performance on partial commands (see Section
# A.2.3 Language Model
We use InstructGPT [54] (text-davinci-002), accessed through OpenAI API.
# A.2.4 CLIPort Baseline
As CLIPort [67] already takes as input a natural language instruction and is capable of directly outputting robot actions, it bears the question whether we need a high-level planner for completing long-horizon tasks. To this end, we additionally train two variants of multi-task CLIPort policy on 10 of the total 20 tasks as baselines (see Table 6 for the train/test split). One variant, which we referred as βCLIPort (Short)β, is trained only on single-step pick-and-place instructions of the format βpick up [x] and place it on [y]β on the 10 training tasks. The decomposed pick-and-place instructions are obtained from scripted planners. At evaluation time, the policy is fed in only the high-level instructions without any planners. The other variant, which we referred as βCLIPort (Long)β, is trained on the high-level instructions from the 10 training tasks (without decomposition from scripted planners). Similarly, at evaluation time, it is fed in only the high-level instructions and evaluated on both seen and unseen instructions. Both variants are trained on 50,000 demonstrations, similar to the Grounded Decoding primitive. The goal of these baselines is to evaluate whether solitary language-conditioned policies can perform well on long-horizon tasks and generalize to new task instructions. Note that the CLIPort baselines are different from the primitive used in Grounded Decoding, although they share the same architecture.
# A.2.5 Full Experimental Results in Simulated Tabletop Domain
Below we show the full list of tasks and the full experimental results in the simulated tabletop domain. Each entry is the average success rate across 20 rollouts. The tasks with blue-colored background are seen tasks and the tasks with orange-colored background are the unseen tasks. Seen tasks may be used for training for supervised baselines (CLIPort) or may be used in the prompt for methods using language model planner. Note that for the βBox Packingβ task category, although all tasks were seen in training or the prompts, we enforce additional safety and preference constraints for evaluation only at test time.
Table 6: Full Experimental Results in Simulated Tabletop Rearrangement Tasks. The tasks with blue-colored background are seen tasks and the tasks with orange-colored background are the unseen tasks. $\ast _ { \mathrm { B o X } }$ Packing tasks are all seen during training, but safety and preference requirements are only enforced during evaluation.
<table><tr><td rowspan="2"></td><td rowspan="2"></td><td colspan="2">CLIPort</td><td rowspan="2">+LLM</td><td colspan="2">+Grounded Decoding</td></tr><tr><td></td><td>Short Long</td><td>οΌUngrounded Greedy</td><td>Beam</td></tr><tr><td>Letters</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Put the letters in alphabetical order from left to right</td><td>AF</td><td>5%</td><td>20%</td><td>10%</td><td>20%</td><td>40%</td></tr><tr><td>Spell as much of word as you can</td><td>AF</td><td>10%</td><td>60%</td><td>30%</td><td>60%</td><td>65%</td></tr><tr><td>Separate the vowels from the remaining letters to the bottom side</td><td>AF</td><td>5%</td><td>40%</td><td>20%</td><td>50%</td><td>65%</td></tr><tr><td>Put the leters in reverse alphabetical order from left to right</td><td>AF</td><td>15%</td><td>10%</td><td>15%</td><td>25%</td><td>25%</td></tr><tr><td>Correctly spell out a sport using the present letters</td><td>AF</td><td>10%</td><td>10%</td><td>5%</td><td>30%</td><td>30%</td></tr><tr><td>Sort the geometrically symmetrical leters to the bottom side</td><td>AF</td><td>5%</td><td>10%</td><td>15%</td><td>35%</td><td>50%</td></tr><tr><td>Separate the consonants from the remaining letters to the bottom side</td><td>AF</td><td>0%</td><td>0%</td><td>25%</td><td>25%</td><td>25%</td></tr><tr><td>Sortthe letters less than "D"according to ASCII to the bottom side</td><td>AF</td><td>0%</td><td>20%</td><td>35%</td><td>70%</td><td>75%</td></tr><tr><td>Blocks & Bowls</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td> Stack all the blocks</td><td>AF</td><td>5%</td><td>90%</td><td>30%</td><td>75%</td><td>90%</td></tr><tr><td>Put all the blocks on the corner/side</td><td>AF</td><td>0%</td><td>65%</td><td>50%</td><td>45%</td><td>70%</td></tr><tr><td>Put all the blocks in the bowls with matching colors</td><td>AF</td><td>0%</td><td>30%</td><td>25%</td><td>60%</td><td>70%</td></tr><tr><td>Put the blocks in the bowls with mismatched colors</td><td>AF</td><td>25%</td><td>30%</td><td>45%</td><td>30%</td><td> 55%</td></tr><tr><td>Put all the blocks in different corners</td><td>AF</td><td>0%</td><td>5%</td><td>40%</td><td>50%</td><td>60%</td></tr><tr><td>Stack only the blocks of cool colors</td><td>AF</td><td>5%</td><td>5%</td><td>20%</td><td>70%</td><td>70%</td></tr><tr><td>Stack only the blocks of warm colors</td><td>AF</td><td>0%</td><td>10%</td><td>15%</td><td>45%</td><td>35%</td></tr><tr><td>Sort the primary color blocks to the left side</td><td>AF</td><td>0%</td><td>0%</td><td>20%</td><td>25%</td><td>30%</td></tr><tr><td> Box Packing*</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Pack the objects into the brown box</td><td>AF + S</td><td></td><td>20%40%</td><td>5%</td><td>100%</td><td>90%</td></tr><tr><td>Pack the objects into the boxes</td><td>AF + S</td><td></td><td>10%20%</td><td>5%</td><td>75%</td><td>70%</td></tr><tr><td>I'd like some snacks on the right side</td><td>AF + P</td><td></td><td>15%20%</td><td>15%</td><td>40%</td><td>55%</td></tr><tr><td>Pack me a picnic box</td><td>AF + S +P</td><td></td><td>15%30%</td><td>20%</td><td>100%</td><td>95%</td></tr></table>
# A.3 Implementation Details of Minigrid 2D Maze
# A.3.1 Environment Setup
We use the open-source gym-minigrid suite of environments to evaluate our method with one simple change β instead of the default observation space which is a $7 \times 7$ egocentric window, our agent has access to entire grid β that allows us to simplify the tasks by removing partial observability [65].
# A.3.2 Tasks
The tasks are grouped in three categories (please see Table 7 for example instructions):
1. Easy: Simple tasks where the horizon is short (10-30 steps) and fully described by the textual instruction, e.g. OpenDoors and PutNext. The short horizon makes them relatively easy for a wide range of HRL algorithms. The instructions for these tasks generally spell out each individual skill, making them particularly easy for high-level planners based on language modeling. 2. Medium: Combination of short and long horizon tasks (up to 80 steps) with step-by-step textual instructions, e.g. LockedRoom. While being significantly longer, these tasks also tend to have instructions that spell out the low-level tasks (see Table 7). 3. Hard: Complex, long horizon instructions (over 100 steps) with short, ambiguous instructions that necessitate multi-step reasoning and efficient exploration, e.g. MultiRoom and BlockedUnlock. In addition to being long-horizon, the instructions in this case tend to be ambiguous and under-specified, e.g. βtraverse through the rooms to get to the goalβ, which does not provide enough context for any blind planning agent.
Table 7: Example Instructions in Minigrid
<table><tr><td>Difficulty</td><td>Task Name</td><td>Example Instruction</td></tr><tr><td>Easy</td><td>OpenDoors PutNext</td><td>open door blue, then open door red move the red ball next to the green box</td></tr><tr><td>Medium</td><td>LockedRoom</td><td> get the red key from the purple room, open the red door and go to the goal</td></tr><tr><td>Hard</td><td>MultiRoom BlockedUnlock</td><td>traverse the rooms to get to the goal pick up the blue box</td></tr></table>
# A.3.3 Language Model
We use InstructGPT [54] (text-davinci-002), accessed through OpenAI API. The prompts used can be found in Section A.5.
We found the prompts to be generally sufficient for solving the βseenβ tasks, as well as βunseenβ tasks, i.e. tasks that do not have an example in the context. Empirically, we did not find any improvements by including more then 3 example tasks in the prompt β we hypothesize that this is likely due to the shared low-level primitives across tasks. For all Minigrid experiments presented in this paper, we used the prompt shown in Section A.5.
# A.3.4 Low-level Primitives
To train low-level primitives, we train an RL agent to solve a wide range of short-horizon subtasks (under 10 steps) that are shared across the various Minigrid tasks β go to $< \circ { \mathrm { b j } } >$ , pick up <obj>, drop <obj>, open <obj>. Rather than training individual skills for each of them [65], we train a single multi-task policy that is conditioned on the CLIP embeddings [57] of the task strings. This scheme allows some robustness to synonyms and ambiguous task specifications, and has been widely used in learning language-grounded policies [32, 68].
We train these primitives using PPO [62], as recommended by the environment developers [10]. Each of these skills are trained with a sparse outcome reward $^ { + 1 }$ if a trajectory is successful, 0 otherwise). In addition to these low-level skills, we perform a form of hindsight relabeling where βsubstringsβ of the task strings are masked to allow generalization to partial strings, e.g. βgo to redβ may be interpreted as βgo to red keyβ or βgo to red doorβ, and our masking strategy allows the multi-task policy to execute tasks specified by partially complete strings, if necessary.
 A.3.5 Additional Qualitative Results Figure 8: Minigrid Domain
# A.4 Implementation Details of Real-World Mobile Manipulation
A.4.1 Tasks Table 8: List of unambiguous SayCan instructions
<table><tr><td>Instruction</td></tr><tr><td>put an energy bar and water bottle on the table bring me a lime soda and a bag of chips Can you throw away the apple and bring me a coke bring me a 7up can and a tea move an multigrain chips to the table and an apple to the far counter move the lime soda, the sponge,and the water bottle to the table</td></tr></table>
Table 9: List of ambiguous SayCan instructions
<table><tr><td>Instruction</td></tr><tr><td>I want to wipe some spill.</td></tr><tr><td>Bring me a fruit</td></tr><tr><td>Bring me a snack</td></tr><tr><td>Bring me a bag of chips</td></tr><tr><td>Bring me a bag of snack</td></tr><tr><td>Bring me a bag of chips and something to wipe a spill Bring me a bag of chips and something to drink</td></tr><tr><td>Bring me a bag of chips and a soda</td></tr><tr><td>Human: I want a soda that is not coke,and a fruit.</td></tr><tr><td>I want a fruit and a soda</td></tr></table>
# A.4.2 Language Model
For planning, we use PaLM [11], a 540B parameter language model trained on a large datasets that include high-quality web documents, books, Wikipedia, conversations, and GitHub code. Before planning, we use InstructGPT [54] (text-davinci-002), accessed through OpenAI API. to generate the (grounded) chain of thought.
We used square bracket to indicate grounded decoding, as illustrated in Fig. 5. The prompts are shown in Listing 3.
# A.4.3 Low-level Primitives
We use a combination of learned and scripted control policies for navigation and manipulation, following the implementation described in SayCan [2] and RT-1 [7]. The manipulation policies for the picking action are learned using Behavior Cloning (BC) on 68000 demonstrations and 12000 autonomous successes that were collected over the course of 11 months using a fleet of 10 robots. The demonstrations are collected by teleoperators using VR headset controllers to track the motion of their hand, which is then mapped onto the robotβs end-effector pose. The navigation policies are scripted, based on a ground-truth map as well as a learned perception module for collision avoidance and planning. The placing actions follow pre-computed motions only when preceded by a navigation policy. The Value Functions used by SayCan for affordance grounding are provided by the $Q$ -networks of trained RL agents; we follow the RL training setup described in [2].
# A.4.4 Open-Vocabulary Detector Grounding Function
We use owl-vit [50] as our grounding model. It takes in an image and a natural language query, and returns a list of bounding boxes with scores. We take the maximum score a the grounding function.
More examples of object detection as a grounding function can be found in Fig. 9.
 Figure 9: Additional examples of using open-vocabulary object detection as a grounding function in Real-World Kitchen Mobile Manipulation Domain.
# A.5 Prompts
# Listing 1: Grounded Decoding Prompt in Simulated Tabletop Rearrangement Domain
Task: Pack all letter objects on the brown box Step 1: pick up the e and place it on the brown box Step 2: pick up the g and place it on the brown box Step 3: done
Task: Put the letters on the tables in alphabetical order Step 1: pick up the c and place it on the bottom left side Step 2: pick up the d and place it on the right of c Step 3: pick up the i and place it on the right of d Step 4: pick up the l and place it on the right of i Step 5: pick up the w and place it on the right of l Step 6: done
Task: Spell as much of "blue" as you can Step 1: pick up the l and place it on the bottom left side Step 2: pick up the the u and place it on the right of l Step 3: pick up the the e and place it on the right of u Step 4: done
Task: Separate the vowels from the remaining letters Step 1: pick up the i and place it on the bottom side Step 2: pick up the o and place it on the bottom side Step 3: done
Task: Stack all the blocks
Step 1: pick up the brown block and place it on the pink block Step 2: pick up the cyan block and place it on the brown block Step 3: pick up the orange block and place it on the cyan block Step 4: pick up the gray block and place it on the orange block Step 5: done
Task: Put all the blocks on the bottom left corner Step 1: pick up the white block and place it on the bottom left corner Step 2: pick up the yellow block and place it on the bottom left corner Step 3: pick up the green block and place it on the bottom left corner Step 4: pick up the blue block and place it on the bottom left corner Step 5: pick up the purple block and place it on the bottom left corner Step 6: done
Task: Put all the blocks in the bowls with matching colors Step 1: pick up the cyan block and place it on the cyan bowl Step 2: pick up the purple block and place it on the purple bowl Step 3: pick up the brown block and place it on the brown bowl Step 4: pick up the pink block and place it on the pink bowl Step 5: done
Task: Pack the items into any box Step 1: pick up the donut stick and place it on the red box Step 2: pick up the pepsi and place it on the brown box Step 3: pick up the peach and place it on the brown box Step 4: pick up the strawberry and place it on the red box Step 5: done
Task: Pack the items on the table into the brown box Step 1: pick up the knife and place it on the brown box Step 2: pick up the plum and place it on the brown box Step 3: pick up the pepsi and place it on the brown box Step 4: pick up the cupcake and place it on the brown box Step 5: done
Task: Pack the items on the table into the brown box Step 1: pick up the i and place it on the brown box Step 2: pick up the green block and place it on the brown box Step 3: pick up the l and place it on the brown box Step 4: done
Task: Can you put some snacks on the right side for me? Step 1: pick up the plum and place it on the right side Step 2: done
Task: Can you pack my picnic box for me?
Step 1: pick up the orange and place it on the picnic box Step 2: pick up the diet pepsi and place it on the picnic box Step 3: pick up the knife and place it on the picnic box Step 4: done
# Listing 2: Grounded Decoding Prompt in MiniGrid 2D Maze Domain
You are a 2D maze-solving agent with access to a variety of low-level skills such as picking up or dropping objects, navigating to doors/keys/boxes, and opening/closing doors. Here are some example tasks:
Task: get the green key from the purple room, unlock the green door and go to the goal Step 1: go to the purple door and open it Step 2: go to the green key Step 3: pick up the key Step 4: go to the green door and open it Step 5: go to the goal.
Task: pick up the purple box Step 1: go to the green obstacle Step 2: pick up the obstacle Step 3: place the obstacle Step 4: go to the blue key Step 5: pick up the blue key Step 6: go to the blue door and open it Step 8: drop the blue key Step 7: go to the purple box Step 8: pick up the purple box.
Task: traverse the rooms to get to the goal Step 1: go to the purple door and open it Step 2: go to the green door and open it Step 3: go to the purple door and open it Step 4: go to the green door and open it Step 5: go to the green door and open it Step 6: go to the goal.
Now your turn.
# Listing 3: Grounded Decoding Prompt in Real-World Kitchen Mobile Manipulation Domain
The following objects are in the scene: 7up, apple, banana, mango, tea, multigrain chips, kettle chips, jalapeno chips, rice chips, coke, grapefruit soda, pepsi, redbull, energy bar, lime soda, sponge, paper towel, and water bottle.
The following locations are in the scene: close counter, far counter, table, trash, bowl. The robot will always put object name in brackets []. Robot: I am a robot that can bring objects to you. Human: I am hungry. Robot thought: I will find the [multigrain chips]. Robot plan: 1. Find the multigrain chips 2. Pick up the multigrain chips 3. Bring it to you 4. Put it down 5. Done Robot: I am a robot that can bring objects to you. Human: Throw away the fruit. Robot thought: I will find the [mango] and move it to the trash. Robot plan: 1. Find the mango 2. Pick up the mango 3. Go to the trash 4. Put it down 5. Done Robot: I am a robot that can bring objects to you. Human: (inject instruction). Robot thought:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223# IMPROVING THE TRANSFERABILITY OF ADVERSARIAL ATTACKS THROUGH EXPERIENCED PRECISE NESTEROV MOMENTUM
Anonymous authors Paper under double-blind review
# ABSTRACT
Deep Neural Networks are vulnerable to adversarial attacks, which makes adversarial attacks serve as a method to evaluate the robustness of DNNs. However, adversarial attacks have high white-box attack success rates but poor transferability, making black-box attacks impracticable in the real world. Momentumbased attacks were proposed to accelerate optimization to improve transferability. Nevertheless, conventional momentum-based attacks accelerate optimization inefficiently during early iterations since the initial value of momentum is zero, which leads to unsatisfactory transferability. Therefore, we propose Experienced Momentum (EM), which is the pre-trained momentum. Initializing the momentum to EM can help accelerate optimization during the early iterations. Moreover, the pre-update of conventional Nesterov momentum based attacks is rough, prompting us to propose Precise Nesterov momentum (PN). PN refines the preupdate by considering the gradient of the current data point. Finally, we integrate EM with PN as Experienced Precise Nesterov momentum (EPN) to further improve transferability. Extensive experiments against normally trained and defense models demonstrate that our EPN is more effective than conventional momentum in the improvement of transferability. Specifically, the attack success rates of our EPN-based attacks are ${ \sim } 1 1 . 9 \%$ and ${ \sim } 1 3 . 1 \%$ higher than conventional momentum-based attacks on average against normally trained and defense models, respectively.
# 1 INTRODUCTION
Deep neural networks (DNNs) (Krizhevsky et al., 2012; Szegedy et al., 2015; He et al., 2016; Ioffe & Szegedy, 2015) have been widely applied in computer vision, e.g., autonomous driving (Franchi et al., 2022; Hao et al., 2019; Cococcioni et al., 2018), facial recognition (Chrysos et al., 2020; Ghenescu et al., 2018), and medical image analysis (Akselrod-Ballin et al., 2016; Ding et al., 2017; Liu et al., 2019). However, Szegedy et al. (2013) found that applying certain imperceptible perturbations to images can make DNNs misclassify, and they refer to such perturbed images as adversarial examples $( A E s )$ . Adversarial examples pose a huge threat to the security of DNNs, which attaches extensive attention from researchers.
Adversarial attacks can be categorized into white-box attacks and black-box attacks. Typically, iterative gradient-based (Kurakin et al., 2016; Madry et al., 2017) and optimization-based attacks (Carlini & Wagner, 2017) have high white-box but low black-box attack success rates, which means that such two attacks are impracticable in the real world. Transferability, which means adversarial examples crafted on the source model remain effective on other models, makes black-box attacks feasible. Furthermore, iterative gradient-based attacks have the advantages of low computational cost and fast generation speed, thus improving the transferability of iterative gradient-based attacks has become a hotspot in the field of adversarial attacks.
Many methods have been proposed to improve the transferability of iterative gradient-based attacks. These methods can be classified into three branches: improving optimization algorithms, input transformations, and disrupting feature space. For example, MI-FGSM (Dong et al., 2018), NI-FGSM (Lin et al., 2019), and VM(N)I-FGSM (Wang & He, 2021) improve gradient ascent (or descent) algorithm to escape from saddle points and poor local extrema to improve transferability; DIM (Xie et al., 2019), TIM (Dong et al., 2019), and SIM (Lin et al., 2019) craft adversarial examples on a set of models derived by input transformations to prevent overfitting and improve transferability; NRDM (Naseer et al., 2018), FDA (Ganeshan et al., 2019), and FIA (Wang et al., 2021) disrupt deep features of DNNs to craft highly transferable adversarial examples.
 Figure 1: Comparison of conventional Polyak momentum and experienced Polyak momentum. Adversarial examples are crafted on the source model (Inception-v3) and used to attack the target model (VGG16). Our Experienced MI-FGSM (EMI-FGSM), which integrates EM into MI-FGSM, causes misclassification with higher loss and confidence than MI-FGSM, thus EMI-FGSM can mislead the attention of the target model better than MI-FGSM.
Those mentioned above adversarial attacks mostly adopt the momentum (Polyak, 1964; Nesterov, 1983) to accelerate optimization. However, such momentum-based adversarial attacks (e.g., M(N)IFGSM, VM(N)I-FGSM, and FIA) have the problem of initializing the momentum to zero, resulting in inefficient acceleration due to momentum accumulating few gradients during the first few iterations. Therefore, we propose Experienced Momentum (EM), which is the pre-trained momentum. Before the iterations, the momentum is initialized to EM instead of zero, leading to better acceleration in the first few iterations. The comparison of conventional Polyak momentum (Polyak, 1964) and experienced Polyak momentum is shown in Fig. 1. To prevent overfitting on the source model, we train EM on a set of models derived by Random Channels Swapping (RCS). EM and RCS are detailed in Sec. 3.1.
Furthermore, adversarial attacks (e.g., NI-FGSM and VNI-FGSM) based on Nesterov momentum (i.e., Nesterov Accelerated Gradient, NAG (Nesterov, 1983)) have the disadvantage that the preupdate is rough. Specifically, during each iteration, the parameters are first pre-updated along the momentum to obtain the pre-update point, which is an estimation of the next position. Then the preupdate is modified by the gradient of the pre-update point. Such looking-ahead property of Nesterov momentum makes parameters escape from saddle points and poor local extrema easier and faster, resulting in improving transferability. However, pre-updating only along the momentum is rough, and the estimation of the next position of the parameters is imprecise. Therefore, we propose Precise Nesterov momentum (PN), which not only retains the looking-ahead property but also refines the pre-update by adopting the gradient of the current data point. To improve transferability further, we integrate EM with PN as Experienced Precise Nesterov momentum (EPN). PN and EPN are detailed in Sec. 3.2.
Overall, we make the following contributions:
β’ We propose Experienced Momentum (EM), which is trained on a set of models derived by Random Channels Swapping (RCS). Initializing the momentum to EM can accelerate optimization effectively during the early iterations to improve transferability.
β’ We propose Precise Nesterov momentum (PN), which adopts the gradient of the current data point to refine the pre-update to escape from saddle points and poor local extrema easier and faster. We also integrate EM with PN as Experienced Precise Nesterov momentum (EPN) to improve transferability further. β’ Extensive experiments on normally trained and defense models demonstrate that our EPN is more effective than conventional momentum for improving transferability.
# 2 RELATED WORK
# 2.1 TRANSFERABLE ADVERSARIAL ATTACKS
Since adversarial examples were discovered by Szegedy et al. (2013), many methods (Goodfellow et al., 2014; Kurakin et al., 2016; Carlini & Wagner, 2017) have been proposed to craft adversarial examples to demonstrate the vulnerability of DNNs. We focus on the transferability of iterative gradient-based attacks and review related works from three branches: improving optimization algorithms, input transformations, and disrupting feature space.
Improving optimization algorithms. Dong et al. (2018) integrated Polyak momentum (Polyak, 1964) into I-FGSM (Kurakin et al., 2016) to accelerate gradient ascent (or descent) to improve transferability. Inspired by the fact that Nesterov momentum (Nesterov, 1983) is superior to Polyak momentum, Lin et al. (2019) integrated Nesterov momentum into I-FGSM to improve transferability further. Wang & He (2021) used the gradient variance of the previous iteration to tune the current gradient to stabilize the update direction and escape from saddle points and poor local extrema.
Input transformations. The nature of input transformations is crafting adversarial examples on a set of derived models to prevent overfitting. Xie et al. (2019) performed random resizing and padding with probability $p$ to derive models. Dong et al. (2019) convolved the gradient to approximate translating input. Lin et al. (2019) scaled the input with the scale factor $1 / 2 ^ { i }$ to derive a set of models.
Disrupting feature space. Naseer et al. (2018) created maximum distortions in the feature space to craft adversarial examples, based on the intuition that features of DNNs are highly generalizable. Ganeshan et al. (2019) highly corrupted deep features by disrupting features at each layer of DNNs to improve transferability. Wang et al. (2021) described feature importance with the aggregate gradient and disrupted important object-aware features to achieve stronger transferability.
# 2.2 ADVERSARIAL TRAINING
Adversarial training as a common defense measure can validate transferability further. Adversarial training increases robustness by adding adversarial examples to the training data. Goodfellow et al. (2014) showed that adversarially trained models are more robust. However, Kurakin et al. (2016) pointed out that adversarial training is not robust to iterative attacks. Moreover, Tramer et al. (2017) \` showed that adversarially trained models are still vulnerable to simple white-box and black-box attacks. Therefore, they proposed ensemble adversarial training adding adversarial examples crafted from other models to the training data.
# 3 METHODOLOGY
Given a target model $f ^ { \prime } ( x ; { \pmb \theta } ^ { \prime } )$ , where $_ { \textbf { \em x } }$ is an input, and $\pmb { \theta } ^ { \prime }$ is the parameters of $f ^ { \prime }$ . Let $J ( \cdot , y )$ be a loss function, where $y$ is the ground-truth label of the input $_ { \textbf { \em x } }$ . A non-targeted adversarial example $\pmb { x } ^ { a d v }$ satisfies $f ^ { \prime } ( { \pmb x } ; { \hat { \pmb \theta } } ^ { \prime } ) \neq { \bar { f ^ { \prime } } } ( { \pmb x } ^ { a d v } ; { \pmb \theta } ^ { \prime } )$ under the constraint of $| | { \pmb x } ^ { a d v } \bar { - } { \pmb x } | | _ { p } \le \epsilon .$ , where $| | \cdot | | _ { p }$ denotes the $L ^ { p }$ norm, and $p$ is generally $0 , 1 , 2 , \infty$ . In this paper, we focus on $p = \infty$ . Note that our methods can be generalized to $p = 0 , 1 , 2$ easily. Crafting non-targeted adversarial examples can be described as solving the following optimization problem:
$$\underset { \pmb { x } ^ { a d v } } { \arg \operatorname* { m a x } } J ( f ^ { \prime } ( \pmb { x } ^ { a d v } ; \pmb { \theta } ^ { \prime } ) , y ) , \quad \mathrm { s . t . } | | \pmb { x } ^ { a d v } - \pmb { x } | | _ { p } \leq \epsilon .$$
In this paper, we focus on non-targeted attacks. Our proposed methods can be easily transformed into targeted attacks by replacing the above objective function with $- J ( f ^ { \prime } ( x ^ { a d v } ; \pmb { \theta } ^ { \prime } ) , \mathbf { \bar { \psi } } ^ { * } )$ , where $y ^ { * }$ denotes the target label.
 Figure 2: Illustration of training EM during each iteration.
Many gradient-based methods have been proposed to solve Eq. 1, e.g., FGSM (Goodfellow et al., 2014), I-FGSM (Kurakin et al., 2016), and PGD (Madry et al., 2017). However, the parameters $\pmb { \theta } ^ { \prime }$ of the target model $f ^ { \prime }$ is inaccessible for black-box attacks, resulting in the inability to solve Eq. 1 directly. Therefore, the target model $f ^ { \prime }$ is usually replaced with a model $f$ (i.e., the source model) with accessible parameters $\pmb \theta$ , and then adversarial examples are crafted on the source model $f$ to attack the target model $f ^ { \prime }$ . To achieve effective black-box attacks, adversarial examples crafted on the source model $f$ are required to have high transferability. Therefore, we propose Experienced Momentum (EM, detailed in Sec. 3.1) and Precise Nesterov momentum (PN, detailed in Sec. 3.2) to improve transferability. EM and PN can be naturally combined as Experienced Precise Nesterov momentum (EPN, detailed in Sec. 3.2) to further improve transferability.
# 3.1 EXPERIENCED MOMENTUM
Momentum-based attacks initialize momentum to zero, resulting in inefficient acceleration during the first few iterations. Therefore, we propose Experienced Momentum (EM), which is the pretrained momentum. Setting the initial momentum to EM can accelerate the optimization during the early iterations. To prevent overfitting of EM and improve transferability further, we train EM on a set of models derived by Random Channels Swapping (RCS). RCS derives models by randomly swapping the channels of the input image, which is equivalent to randomly swapping the βblockβ dimensions of the original model, leading to various decision boundaries of derived models. Therefore, training EM on derived models can prevent overfitting. The specific procedure for training EM is as follows.
First of all, we perform RCS on the input image $_ { \textbf { \em x } }$ . Specifically, we denote the input image $_ { \textbf { \em x } }$ as an RGB triplet $( R , G , B )$ , and then the input image $_ { \textbf { \em x } }$ through RCS can be denoted as $\bar { S } ( { \pmb x } )$ , where $S ( { \pmb x } ) \in \{ ( R , G , B ) , ( R , B , G ) , ( G , R , B ) , ( G , B , R ) , ( B , R , G ) , ( B , G , R ) \} .$ , $S ( \cdot )$ denotes RCS. Secondly, $S ( { \pmb x } )$ is fed into the source model $f$ to derive $f ( S ( \cdot ) , y )$ . Thirdly, we pre-perturb the input image $_ { \textbf { \em x } }$ on the derived model $f ( S ( \cdot ) , y )$ by iterative gradient-based attacks to prevent overfitting. As shown in Fig. 2, we accumulate gradients to training EM during each iteration. Finally, we follow the above procedure repeatedly to make the EM more generalizable. After training EM, we set the initial value of momentum to EM to accelerate the early iterations.
# 3.2 PRECISE NESTEROV MOMENTUM
Nesterov momentum based Attack (e.g., NI-FGSM (Lin et al., 2019) and VNI-FGSM (Wang & He, 2021)) only pre-update along the momentum roughly, resulting in the imprecision of the pre-update point that is the estimate of the next iterative position. Against this disadvantage, we propose Precise Nesterov momentum (PN), which considers the gradient of the current data point in the pre-update to make the pre-update precise. Specifically, during each iteration, the pre-update is performed along the gradient of the current data point and momentum successively to obtain the pre-update point, and then we use the gradient of the pre-update point to modify the pre-update. We integrate PN into I-FGSM as PNI-FGSM. The $t$ -th iteration of PNI-FGSM can be formalized as follows:
$$\widetilde { \pmb x } _ { t } ^ { a d v } = \pmb x _ { t } ^ { a d v } + \alpha \cdot \left[ \frac { \nabla _ { \pmb x _ { t } ^ { a d v } } J ( f ( \pmb x _ { t } ^ { a d v } ; \pmb \theta ) , y ) } { | | \nabla _ { \pmb x _ { t } ^ { a d v } } J ( f ( \pmb x _ { t } ^ { a d v } ; \pmb \theta ) , y ) | | _ { 1 } } + \mu \cdot { \pmb g } _ { t - 1 } \right] ,$$
Input : A source model $f$ with parameters $\pmb \theta$ and a loss function $J$ . An original image $_ { \textbf { \em x } }$ with ground-truth label $y$ . Input : The maximum perturbation $\epsilon$ , the number of iterations $T$ , and the decay factor $\mu$ . Input : The epochs of pretraining epochs. Output: An adversarial example $\bar { \boldsymbol { x } } ^ { a \bar { d } v }$ . 1 $\alpha \epsilon / T$ ; $\pmb { g } ^ { e x p } \mathbf { 0 }$ ; 2 for $n \gets 1$ to epochs do 3 $\hat { \pmb { x } } _ { 1 } ^ { a d v } { \pmb { x } }$ ; 4 for $t \gets 1$ to $T$ do 5 $\begin{array} { r l } & { \widetilde { x } _ { t } ^ { a d v } \gets \hat { x } _ { t } ^ { a d v } + \alpha \cdot \left[ \frac { \nabla _ { \hat { x } _ { t } ^ { a d v } } J ( f ( S ( \hat { x } _ { t } ^ { a d v } ) ; \pmb \theta ) , y ) } { | | \nabla _ { \hat { x } _ { t } ^ { a d v } } J ( f ( S ( \hat { x } _ { t } ^ { a d v } ) ; \pmb \theta ) , y ) | | _ { 1 } } + \mu \cdot g ^ { e x p } \right] ; } \\ & { g ^ { e x p } \gets \frac { \nabla _ { \hat { x } _ { t } ^ { a d v } } J ( f ( S ( \hat { x } _ { t } ^ { a d v } ) ; \pmb \theta ) , y ) } { | | \nabla _ { \hat { x } _ { t } ^ { a d v } } J ( f ( S ( \hat { x } _ { t } ^ { a d v } ) ; \pmb \theta ) , y ) | | _ { 1 } } + \mu \cdot g ^ { e x p } + \frac { \nabla _ { \widetilde { x } _ { t } ^ { a d v } } J ( f ( \widetilde { x } _ { t } ^ { a d v } ; \pmb \theta ) , y ) } { | | \nabla _ { \widetilde { x } _ { t } ^ { a d v } } J ( f ( \widetilde { x } _ { t } ^ { a d v } ; \pmb \theta ) , y ) | | _ { 1 } } ; } \\ & { \hat { x } _ { t + 1 } ^ { a d v } \gets \mathrm { C l i p } _ { ( \pmb { x } , \epsilon ) } \left\{ \hat { x } _ { t } ^ { a d v } + \alpha \cdot \mathrm { s i g n } ( g ^ { e x p } ) \right\} ; } \end{array}$ 6 7 8 end 9 end 10 ${ \pmb x } _ { 1 } ^ { a d v } { \pmb x } ; { \pmb g } _ { 0 } { \pmb g } ^ { e x p }$ ; 11 for $t \gets 1$ to $T$ do 12 Update $\mathbf { \nabla } _ { \mathbf { \boldsymbol { g } } _ { t } }$ and $\pmb { x } _ { t + 1 } ^ { a d v }$ by Eq. 2, 3, 4; 13 end 14 return ${ \pmb x } ^ { a d v } { \pmb x } _ { T + 1 } ^ { a d v }$ .
Algorithm 1: Experienced Precise Nesterov momentum I-FGSM (EPNI-FGSM) Table 1: The abbreviations used in the paper.
<table><tr><td>Abbreviation</td><td>Explanation</td></tr><tr><td></td><td></td></tr><tr><td>D(T)I-MI-FGSM</td><td>the combination of D(T)IM and MI-FGSM</td></tr><tr><td>SI-NI-FGSM</td><td>the combination of SIMand NI-FGSM</td></tr><tr><td>D(T,S)I-EPNI-FGSM</td><td>the combination of D(T,S)IM and EPNI-FGSM</td></tr><tr><td>VT-M(N)I-FGSM</td><td>i.e., VM(N)I-FGSM</td></tr><tr><td>VT-EPNI-FGSM</td><td>the combination of Variance Tuning (VT)(Wang & He,2021) and EPNI-FGSM</td></tr><tr><td>FI-MI-FGSM FI-EPNI-FGSM</td><td>i.e., FIA</td></tr><tr><td></td><td>the combination of Feature Importance-aware (FI) (Wang et al.,2021) and EPNI-FGSM</td></tr></table>
$$g _ { t } = \frac { \nabla _ { x _ { t } ^ { a d v } } J ( f ( x _ { t } ^ { a d v } ; \pmb { \theta } ) , y ) } { | | \nabla _ { x _ { t } ^ { a d v } } J ( f ( x _ { t } ^ { a d v } ; \pmb { \theta } ) , y ) | | _ { 1 } } + \mu \cdot g _ { t - 1 } + \frac { \nabla _ { \widetilde { x } _ { t } ^ { a d v } } J ( f ( \widetilde { x } _ { t } ^ { a d v } ; \pmb { \theta } ) , y ) } { | | \nabla _ { \widetilde { x } _ { t } ^ { a d v } } J ( f ( \widetilde { x } _ { t } ^ { a d v } ; \pmb { \theta } ) , y ) | | _ { 1 } } ,$$
$$\begin{array} { r } { \pmb { x } _ { t + 1 } ^ { a d v } = \mathrm { C l i p } _ { ( \pmb { x } , \epsilon ) } \left\{ \pmb { x } _ { t } ^ { a d v } + \alpha \cdot \mathrm { s i g n } ( \pmb { g } _ { t } ) \right\} , } \end{array}$$
where $\mathbf { \nabla } _ { \mathbf { \boldsymbol { g } } _ { t } }$ denotes the momentum, ${ \bf { \mathit { g } } } _ { 0 } = { \bf { 0 } }$ , and $\mu$ denotes the decay factor.
We combine EM and PN as Experienced Precise Nesterov momentum (EPN) to further improve transferability. The algorithm of EPNI-FGSM, which integrates EPN into I-FGSM, is summarized in Algorithm 1. Particularly, if $\frac { \nabla _ { \widetilde { \pmb { x } } _ { t } ^ { a d v } } J ( f ( \widetilde { \pmb { x } } _ { t } ^ { a d v } ; \pmb { \theta } ) , y ) } { | | \nabla _ { \widetilde { \pmb { x } } _ { t } ^ { a d v } } J ( f ( \widetilde { \pmb { x } } _ { t } ^ { a d v } ; \pmb { \theta } ) , y ) | | _ { 1 } } = \mathbf { 0 }$ , EPNI-FGSM degrades to Experienced MI-FGSM (EMI-FGSM). If $\frac { \nabla _ { \hat { \pmb { x } } _ { t } ^ { a d v } } J ( f ( S ( \hat { \pmb { x } } _ { t } ^ { a d v } ) ; \pmb { \theta } ) , y ) } { | | \nabla _ { \hat { \pmb { x } } _ { t } ^ { a d v } } J ( f ( S ( \hat { \pmb { x } } _ { t } ^ { a d v } ) ; \pmb { \theta } ) , y ) | | _ { 1 } } = \mathbf { 0 }$ , EPNI-FGSM degrades to Experienced NI-FGSM (ENI-FGSM). If $e p o c h s = 0$ , EPNI-FGSM degrades to PNI-FGSM.
# 4 EXPERIMENTS
We conduct extensive experiments on normally trained and defense models to validate that our EPN is more efficient than conventional momentum. We first present the experimental settings in Sec. 4.1. Then, we report the results for attacking normally trained and defense models in Sec. 4.2 and
Table 2: The attack success rates $( \% )$ of adversarial examples crafted on source models against normally trained target models. β\*β indicates the model being white-box attacked. βAvgβ means the average attack success rate.
<table><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="6">Iv3</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>69.2 56.7</td><td>67.9</td><td>68.2</td><td>66.2</td><td>63.0</td><td>61.4</td><td>61.2</td><td></td></tr><tr><td>TI-MI-FGSM SI-NI-FGSM DI-EPNI-FGSM(Ours) TI-EPNI-FGSM(Ours)</td><td>41.8 77.4 88.7 70.6 90.2</td><td>99.7* 100.0* 100.0* 100.0* 100.0*</td><td>37.9 72.7 87.3 68.8 87.1</td><td>31.5 69.8 86.0 59.6</td><td>46.4 67.6 78.5 69.3</td><td>47.6 67.3 81.3 69.8</td><td>44.9 68.0 83.4 68.9</td><td>41.9 61.5 80.2 65.5 76.4</td><td>38.6 62.1 80.5 63.3</td><td>54.9 70.0 80.4 73.5</td><td>72.8 83.8 76.5</td><td>56.2 73.8 83.8 78.5</td><td>58.3 71.9 84.2 77.9</td><td>47.9 70.7 86.1 74.7</td><td>46.5 68.4 84.9 72.9</td><td>43.5 64.8 82.9 70.8</td><td>42.8 65.9 83.4 71.5</td><td>66.0 49.2 70.9 84.4 72.5</td></tr><tr><td>SI-EPNI-FGSM(Ours) VT-MI-FGSM VT-NI-FGSM</td><td>70.5 76.2</td><td>100.0* 100.0*</td><td>69.7 76.2</td><td>85.1 64.9 70.5</td><td>80.1 61.7 65.6</td><td>81.2 63.6 68.4</td><td>81.7 65.7 71.2</td><td>60.0 65.2</td><td>78.2 58.6 64.1</td><td>80.6 65.0 70.5</td><td>83.1 69.2 73.4</td><td>84.4 68.7 73.4</td><td>82.6 66.7 73.2</td><td>86.7 65.8 71.2</td><td>83.8 63.8 71.3</td><td>80.9 65.0 69.2</td><td>81.7 62.6 68.2</td><td>83.8 67.1 72.2</td></tr><tr><td>VT-EPNI-FGSM(Ours) FI-MI-FGSM FI-EPNI-FGSM(Ours)</td><td>84.8 85.8 90.0</td><td>100.0* 97.1* 97.4*</td><td>83.3 85.4 88.0</td><td>78.1 81.8 84.8</td><td>77.0 79.4 81.0</td><td>78.8 80.1 82.4</td><td>79.4 79.5 84.3</td><td>75.8 76.3 79.6</td><td>73.3 74.5 78.5</td><td>80.2 81.0 85.5</td><td>83.3 82.7 87.0</td><td>82.0 82.7 85.9</td><td>81.5 83.2 86.3</td><td>79.7 81.3 84.0</td><td>80.1 78.8 83.5</td><td>78.3 77.2 80.5</td><td>78.5 77.8 81.7</td><td>80.8 81.4</td></tr><tr><td>MI-FGSM NI-FGSM EPNI-FGSM(Ours)</td><td>46.4 49.0 68.1</td><td>44.0 45.6 65.3</td><td>45.4 48.5 68.4</td><td>99.6* 100.0* 100.0*</td><td>40.0 40.6 55.2</td><td>39.2 38.7 53.8</td><td>41.3 42.1 55.5</td><td>33.9 34.9 48.4</td><td>32.7 32.9 47.9</td><td>49.9 53.5 63.8</td><td>53.2 54.3 67.8</td><td>51.4 54.6 66.6</td><td>50.6 54.3 65.3</td><td>38.6 37.5 54.7</td><td>35.3 37.5 50.7</td><td>35.0 33.8 49.0</td><td>32.7 33.2 48.1</td><td>84.7 45.2 46.5 60.5</td></tr><tr><td>DI-MI-FGSM TI-MI-FGSM SI-NI-FGSM DI-EPNI-FGSM(Ours) TI-EPNI-FGSM(Ours) SI-EPNI-FGSM (Ours) VT-MI-FGSM</td><td>63.2 41.5 74.7 82.8 65.1</td><td>62.3 44.5 81.7 83.2 68.2</td><td>65.4 42.0 75.1 84.1 67.6</td><td>98.4* 97.9* 99.3* 100.0* 99.9* 100.0*</td><td>54.2 47.1 65.4 70.7 66.6</td><td>54.2 47.6 65.8 72.3 69.5</td><td>55.7 47.3 69.7 74.4 68.9</td><td>48.6 42.9 65.4 67.5 65.2</td><td>51.0 41.8 64.7 71.1 63.2</td><td>59.3 55.9 68.9 74.6 73.8</td><td>64.4 56.7 71.6 79.5 75.0</td><td>62.8 55.5 71.8 78.2 73.6</td><td>64.7 53.9 73.0 79.6 74.2</td><td>57.0 49.2 72.1 75.0 72.9</td><td>52.8 45.3 68.7 73.0 68.4</td><td>51.8 46.9 67.3 69.6 69.1</td><td>52.6 41.9 68.0 70.9 65.4</td><td>59.9 50.5 72.0 76.9 71.0</td></tr><tr><td></td><td>VT-NI-FGSM VT-EPNI-FGSM(Ours)</td><td>90.9 63.2 66.3 81.0</td><td>93.1 66.6 71.0 82.1</td><td>88.6 68.8 99.6* 73.1 99.8*</td><td>79.1 57.8 59.3</td><td>81.3 57.8 59.3</td><td>85.5 60.7 62.3 75.4</td><td>79.6 53.6 56.9 70.0</td><td>82.9 54.9 56.9 70.6</td><td>83.2 61.7 66.8 77.3</td><td>85.5 63.5 68.2 80.4</td><td>86.0 64.4 68.2 79.9</td><td>86.1 64.0 68.1</td><td>86.3 59.8 60.9</td><td>83.6 56.4 58.0 73.4</td><td>81.5 54.2 57.2</td><td>84.6 56.1 58.5</td><td>85.8 62.5 65.3</td></tr><tr><td></td><td>FI-MI-FGSM FI-EPNI-FGSM (Ours)</td><td>76.3 78.0</td><td>76.0 77.3</td><td>83.1 76.3 89.7* 78.0 91.0*</td><td>100.0* 71.7 67.5 69.8</td><td>72.4 68.0 69.9</td><td>69.7 72.2</td><td>66.8 68.9</td><td>65.5 67.4</td><td>72.5 73.5</td><td>73.7 74.0</td><td>73.4 74.5</td><td>78.7 73.5 73.6</td><td>77.3 70.7 71.7</td><td>68.3 69.0</td><td>72.0 66.8 66.9</td><td>71.9 67.0 67.2</td><td>77.5 71.9 73.1</td></tr><tr><td rowspan="5">R152</td><td>MI-FGSM NI-FGSM EPNI-FGSM(Ours)</td><td>68.9 75.7 91.5</td><td>59.4 64.1 85.8</td><td>53.8 58.0 79.2 74.2</td><td>49.4 81.0 51.7 86.0</td><td>83.3 87.7 94.8 96.2</td><td>92.1 94.7 98.7</td><td>94.5 96.9 99.4</td><td></td><td>100.0* 100.0* 100.0*</td><td>72.7 74.1 76.1 77.4 88.7 89.8</td><td>72.5 77.0 89.5</td><td></td><td>72.5 76.2 89.6</td><td>86.5 87.4 96.5</td><td>83.0 85.1 96.5</td><td>82.5 84.0 85.5 86.7 97.6 96.7</td><td></td><td>77.1 80.4 92.0</td></tr><tr><td>DI-MI-FGSM TI-MI-FGSM SI-NI-FGSM DI-EPNI-FGSM(Ours) TI-EPNI-FGSM(Ours) SI-EPNI-FGSM(Ours)</td><td>85.6 57.1 85.1 97.6 80.3</td><td>82.9 51.3 77.2 96.9 78.2</td><td>75.5 50.1 71.1 94.2 75.7</td><td>72.1 41.4 66.5 92.1</td><td>91.8 70.9 89.6 98.0 89.3</td><td>93.8 75.0 92.0 98.9 91.4</td><td>96.0 80.5 95.3 99.4 94.0</td><td>96.8 84.5 97.8 99.6 95.5</td><td>100.0* 100.0* 100.0* 100.0* 100.0*</td><td>84.0 65.4 82.1 94.3 81.7</td><td>84.4 65.0 83.0 94.6 81.2</td><td>85.5 64.1 81.9 94.7 80.8</td><td>84.6 64.0 81.9 95.2 81.5</td><td>93.7 75.1 93.6 99.4 91.8</td><td>94.0 71.5 91.8 99.3 89.2</td><td>93.7 70.7 92.4 99.6 91.0</td><td>94.4 68.1 91.8 99.1 89.7</td><td>88.8 67.9 86.7 97.2 85.8</td></tr><tr><td>VT-MI-FGSM VT-NI-FGSM VT-EPNI-FGSM(Ours)</td><td>95.3 83.8 87.7 95.4</td><td>91.4 79.6 81.9 92.1</td><td>88.2 74.1 78.9</td><td>66.8 84.8 70.9 74.4</td><td>96.7 92.2 93.5</td><td>97.6 93.7 94.9</td><td>98.6 96.4 98.2</td><td>99.0 97.5 98.7</td><td>100.0* 100.0* 100.0*</td><td>90.3 83.6 85.3</td><td>91.2 82.8 87.2</td><td>92.2 84.4 88.2</td><td>90.5 83.8 86.9</td><td>99.0 94.2 96.1</td><td>98.2 92.4 94.9</td><td>98.1 93.1 95.1</td><td>98.2 93.6 95.7</td><td>94.7 88.0 90.4</td></tr><tr><td>FI-MI-FGSM FI-EPNI-FGSM(Ours) MI-FGSM</td><td>93.3 95.4 78.0</td><td>88.6 93.2</td><td>89.7 88.7 93.1</td><td>86.9 85.1 90.1</td><td>97.9 95.5 96.8</td><td>98.8 96.8 97.9</td><td>99.5 97.5 98.3</td><td>99.8 98.9 98.9</td><td>100.0* 99.9* 100.0*</td><td>93.6 92.5 94.1</td><td>93.5 92.0 94.8</td><td>93.7 93.0 95.0</td><td>94.4 93.8 95.1</td><td>99.4 97.0 97.6</td><td>98.7 95.7 97.4</td><td>99.4 96.6 97.3</td><td>98.8 96.9 97.6</td><td>96.0 94.2 96.0</td></tr><tr><td>NI-FGSM EPNI-FGSM(Ours) DI-MI-FGSM TI-MI-FGSM SI-NI-FGSM V16</td><td>78.8 93.5 88.4 60.6</td><td>59.2 61.6 82.3 75.6 51.1</td><td>63.8 68.8 87.0 77.5</td><td>43.8 47.3 68.1 59.5</td><td>80.0 82.3 91.5 87.8</td><td>73.3 76.1 90.0 83.9</td><td>75.0 78.0 90.0 86.2</td><td>63.7 67.0 82.9 73.8 53.6</td><td>58.7 60.4 77.6 69.7 48.4</td><td>94.7 96.8 99.0 98.3</td><td>98.3 99.2 100.0 98.8</td><td>99.8* 99.9* 100.0* 100.0*</td><td>99.2 99.1 99.9 99.4</td><td>77.0 79.1 91.2 88.0</td><td>69.5 72.1 87.3 81.5</td><td>65.3 66.4 85.8 78.2</td><td>64.9 66.0 87.0 77.5</td><td>74.4 76.4</td><td>89.0 83.8 64.6</td></tr><tr><td>VT-MI-FGSM VT-NI-FGSM</td><td>DI-EPNI-FGSM(Ours) TI-EPNI-FGSM(Ours) SI-EPNI-FGSM(Ours)</td><td>89.8 96.2 82.5 96.1 87.5</td><td>77.5 90.6 74.6 89.1 75.2</td><td>48.5 80.7 62.5 92.6 81.9 77.4 58.1 91.8 80.0 77.9 61.9</td><td>33.4</td><td>71.2 89.1 95.9 88.4 93.6 89.9</td><td>65.4 84.8 94.1 84.2 91.2 86.1</td><td>60.3 85.9 93.5 82.7 92.5 86.8</td><td>77.1 88.6 75.9 86.4 78.3</td><td>73.0 85.5 70.4 84.8 74.1</td><td>88.1 98.5 99.8 96.8 99.4 97.7</td><td>92.9 99.6 99.9 98.2 100.0 98.9</td><td>99.8* 100.0* 100.0* 100.0* 100.0* 99.9*</td><td>94.4 100.0 100.0 98.1 100.0 99.4</td><td>64.9 87.8 95.6 86.4 95.6 87.8</td><td>58.0 81.9 93.1 80.7 92.6 82.2</td><td>54.8 78.9 93.0 78.8 91.0 81.3</td><td>52.4 80.2 91.4 77.4 92.2 80.6</td><td>85.1 93.6 83.0 92.7 85.0</td></tr><tr><td>VT-EPNI-FGSM(Ours) FI-MI-FGSM</td><td></td><td>89.8 95.6 95.9</td><td>76.9 88.4 89.1</td><td>80.7 65.6 92.4 81.1 93.1 79.7</td><td>92.1 96.1 95.6</td><td>87.5 94.4 94.9</td><td>89.3 94.0 93.4</td><td>81.1 90.4 90.4</td><td>76.1 88.8 87.1</td><td></td><td>98.7 99.4 99.6</td><td>99.5 99.9 99.8</td><td>99.9* 99.9* 100.0*</td><td>99.4 99.9 99.8</td><td>88.7 95.6 94.3</td><td>85.4 93.7 91.5</td><td>82.5 93.2 90.2</td><td>82.9 92.2 88.6</td><td>86.8 93.8 93.1</td></tr><tr><td>FI-EPNI-FGSM(Ours)</td><td></td><td>96.7</td><td>90.4</td><td>94.1 84.3</td><td>96.7</td><td>95.9</td><td></td><td>96.0</td><td>92.6</td><td>90.1</td><td>99.8</td><td>99.8</td><td>100.0*</td><td>99.9</td><td>96.4</td><td>94.3</td><td>93.3</td><td>93.0</td><td>94.9</td></tr></table>
Sec. 4.3, respectively. Finally, we provide ablation studies in Sec. 4.4. Table 1 introduces the abbreviations used in the paper.
# 4.1 EXPERIMENTAL SETTINGS
Dataset. We follow the previous works (Dong et al., 2019; Wang et al., 2021) to use the DEV dataset from the NIPS17 Adversarial Attacks and Defenses Competition. This dataset contains 1000 images with size $2 9 9 \times 2 9 9$ .
Target Models. Seventeen normally trained models, i.e., GoogLeNet (Iv1) (Szegedy et al., 2015), Inception-v3 (Iv3) (Szegedy et al., 2016), Inception-v4 (Iv4), Inception-ResNet-v2 (IRv2) (Szegedy et al., 2017), ResNet-18 (R18), ResNet-34 (R34), ResNet-50 (R50), ResNet-101 (R101), ResNet152 (R152) (He et al., 2016), VGG11 (V11), VGG13 (V13), VGG16 (V16), VGG19 (V19) (Simonyan & Zisserman, 2014), DenseNet-121 (D121), DenseNet-169 (D169), DenseNet-201 (D201), and DenseNet-161 (D161) (Huang et al., 2017). Ten defense models (i.e., adversarially trained models), i.e., Adv-Inception-v3 $( \mathrm { I v } 3 _ { \mathrm { a d v } } )$ , Ens-Inception-Resnet-v2 $( \mathrm { I R } \mathrm { v } 2 _ { \mathrm { e n s } }$ ) Tramer et al. (2017), \` Adv-EfficientNet-b0 $( \mathrm { E b 0 _ { a d v } ) }$ to Adv-EfficientNet-b7 $( \mathrm { E b } 7 _ { \mathrm { a d v } } ,$ ).
Baselines. For fair comparison of our EPN and conventional momentum, we replace conventional momentum with our EPN in momentum-based attacks, i.e., MI-FGSM (Dong et al., 2018), NI
Table 3: The attack success rates $( \% )$ of adversarial examples crafted on source models against defense models. βAvgβ means the average attack success rate.
<table><tr><td>Models</td><td>Attacks</td><td>Iv3adv</td><td>IRv2ens</td><td>Eb0adv</td><td>Ebladv</td><td>Eb2adv</td><td>Eb3adv</td><td>Eb4adv</td><td>Eb5adv</td><td>Eb6adv</td><td>Eb7adv</td><td>Avg</td></tr><tr><td rowspan="9">Iv3</td><td>MI-FGSM NI-FGSM EPNI-FGSM(Ours) DI-MI-FGSM</td><td>25.4 25.4 32.4 33.0</td><td>11.5 11.6 14.3 19.3</td><td>29.7 34.3 49.0 46.6</td><td>26.5 31.0 45.0 42.9</td><td>28.1 31.2 45.4 42.4</td><td>18.8 22.2 31.1 31.3</td><td>16.9 18.6 23.9 27.4</td><td>17.5 18.6 25.7 26.7</td><td>14.8 16.0 22.4</td><td>15.2 16.5 22.3 24.4</td><td>20.4 22.5 31.2 31.7</td></tr><tr><td>TI-MI-FGSM SI-NI-FGSM DI-EPNI-FGSM(Ours) TI-EPNI-FGSM(Ours)</td><td>29.9 37.4 41.5 54.1</td><td>21.5 23.2 25.2 41.2</td><td>35.2 50.2 65.0 60.7</td><td>32.6 46.1 65.5 58.2</td><td>34.9 46.3 64.7 57.0</td><td>27.8 33.3 45.5 46.6</td><td>29.3 30.9 39.1 46.7</td><td>28.2 29.6 41.6 45.3</td><td>22.9 24.5 27.6 36.7 43.4</td><td>26.6 25.8 35.6 44.2</td><td>29.1 35.0 46.0 49.7</td></tr><tr><td>SI-EPNI-FGSM(Ours) VT-MI-FGSM VT-NI-FGSM</td><td>47.4 36.8 39.1</td><td>28.4 25.1 26.4</td><td>66.3 50.5 54.0</td><td>64.7 46.3 50.6</td><td>63.1 44.9 49.5</td><td>46.7 33.5 36.6</td><td>41.8 29.4 31.0</td><td>42.1 29.4 32.7</td><td>37.9 26.8 30.3</td><td>37.3 26.2 28.5</td><td>47.6 34.9 37.9</td></tr><tr><td>VT-EPNI-FGSM(Ours) FI-MI-FGSM FI-EPNI-FGSM(Ours)</td><td>43.1 55.3 58.9</td><td>26.5 38.0 39.9</td><td>63.2 68.2 76.2</td><td>61.8 67.8 73.3</td><td>60.6 64.9 72.7</td><td>46.9 53.6 61.1</td><td>41.1 50.0 56.0</td><td>39.7 49.3 55.6</td><td>38.2 46.6 52.9</td><td>36.8 45.1 50.5</td><td>45.8 53.9 59.7</td></tr><tr><td>MI-FGSM NI-FGSM EPNI-FGSM(Ours) DI-MI-FGSM</td><td>27.3 25.9 33.5 33.1</td><td>15.5 14.9 15.9 24.7</td><td>25.2 24.8 36.3</td><td>22.8 23.1 32.4</td><td>24.3 23.6 34.9</td><td>17.0 17.8 23.9 27.1</td><td>13.8 14.1 20.7 24.6</td><td>14.6 14.9 20.4 23.2</td><td>12.1 12.8 17.6 22.0</td><td>13.2 13.7 17.8 20.8</td><td>18.6 18.6 25.3 28.7</td></tr><tr><td>TI-MI-FGSM SI-NI-FGSM DI-EPNI-FGSM(Ours) TI-EPNI-FGSM(Ours) SI-EPNI-FGSM(Ours)</td><td>38.1 37.0 39.4 58.3 45.6</td><td>32.2 33.0 29.7 52.9 41.5</td><td>38.1 39.0 50.8 57.4 60.5 68.9</td><td>35.8 36.7 48.2 52.4 58.3</td><td>37.9 39.4 46.9 53.4 56.6 66.8</td><td>30.2 35.7 41.0 49.7 50.2</td><td>33.8 32.0 33.6 50.9 42.6</td><td>31.4 28.7 33.3 47.0 43.5</td><td>29.2 26.9 30.2 48.0 39.7</td><td>29.7 27.5 30.6 46.5 40.1</td><td>34.0 36.7 40.1 52.9 50.3</td></tr><tr><td>VT-MI-FGSM VT-NI-FGSM VT-EPNI-FGSM(Ours) FI-MI-FGSM</td><td>38.8 40.5 48.2</td><td>36.4 34.8 36.6</td><td>42.3 44.6 59.5</td><td>64.3 38.9 41.1 55.3</td><td>41.2 43.4 54.1</td><td>31.2 33.1 43.0</td><td>28.4 28.2 38.8</td><td>26.4 26.6 38.0</td><td>25.4 25.8 36.9</td><td>25.4 26.2 35.3</td><td>33.4 34.4 44.6 46.7</td></tr><tr><td>FI-EPNI-FGSM(Ours) MI-FGSM NI-FGSM EPNI-FGSM(Ours)</td><td>54.5 53.3 36.5 40.1</td><td>40.1 47.1 27.8 29.4</td><td>57.4 59.6 46.6 49.8</td><td>56.7 56.8 43.6 47.3</td><td>56.3 57.9 47.3 47.8</td><td>45.7 47.0 30.9 33.2</td><td>40.9 43.3 27.3 29.1</td><td>39.7 42.1 26.5 27.7</td><td>38.2 40.6 22.0 25.2</td><td>37.4 38.6 24.8 25.4</td><td>48.6 33.3 35.5</td></tr><tr><td>DI-MI-FGSM TI-MI-FGSM SI-NI-FGSM R152</td><td>53.1 57.6 46.8 51.7 DI-EPNI-FGSM(Ours) 78.3</td><td>43.1 51.7 41.1 43.4 73.1</td><td>71.9 72.6 50.7 62.8 91.6</td><td>68.1 68.3 46.4 57.3 89.9</td><td>70.5 71.2 50.1 61.2 90.6</td><td>50.2 54.7 41.8 43.4 75.7</td><td>41.0 47.1 43.2 39.3 67.3</td><td></td><td>41.0 37.5 44.7 44.2 41.0 36.2 36.0 35.4 64.9 62.6</td><td>40.2 44.3 38.7 33.8 64.3</td><td>51.7 55.6 43.6 46.4 75.8</td></tr><tr><td>VT-MI-FGSM VT-NI-FGSM FI-MI-FGSM</td><td>TI-EPNI-FGSM(Ours) SI-EPNI-FGSM(Ours) VT-EPNI-FGSM(Ours)</td><td>72.2 67.4 67.5 59.3 59.1 52.6 61.6 55.5 72.6 71.6</td><td>74.7 79.4 69.6 73.6 86.2</td><td>70.1 78.5 64.9 68.2 85.3</td><td></td><td>74.2 81.1 69.3 72.1 88.4</td><td>62.9 61.8 55.1 56.1 74.1</td><td>62.7 53.7 48.8 50.6 66.0</td><td>60.7 51.5 46.1 48.7 64.8</td><td>59.3 58.3 48.8 50.3 43.6 44.6 45.5 47.9 62.2 65.1</td><td></td><td>66.3 63.2 55.4 58.0 73.6</td></tr><tr><td>TI-MI-FGSM V16</td><td>FI-EPNI-FGSM(Ours) MI-FGSM NI-FGSM EPNI-FGSM(Ours) DI-MI-FGSM</td><td>81.0 33.0 33.0 46.7 44.9</td><td>73.3 20.3 22.5 29.0 31.6</td><td>88.5 48.8 49.5 71.2 62.4</td><td>87.0 41.8 43.6 65.7 55.9</td><td>82.6 88.6 41.3 44.3 63.5 56.9</td><td>76.3 25.1 27.7 41.5 37.5</td><td>70.9 21.5 22.2 31.3 32.0</td><td>70.1 21.7 22.7 31.5 30.9</td><td>66.4 19.0 18.9 28.5 27.8</td><td>66.4 21.8 20.1 28.7 28.1</td><td>76.9 29.4 30.5 43.8 40.8</td></tr><tr><td></td><td>SI-NI-FGSM DI-EPNI-FGSM(Ours) TI-EPNI-FGSM(Ours) SI-EPNI-FGSM(Ours) VT-MI-FGSM VT-NI-FGSM</td><td>38.9 50.0 61.2 61.8 62.8 49.4 49.3</td><td>29.4 33.5 44.7 49.9 42.6 35.4 37.5</td><td>44.3 61.4 80.3 68.6 78.6 65.3</td><td>38.0 56.4 77.9 65.2 75.4 58.7</td><td>41.4 54.4 78.2 63.7 74.3 58.6</td><td>31.1 36.5 52.2 49.2 48.1 39.7</td><td>32.0 29.9 43.5 50.3 40.6 34.3</td><td>31.5 30.0 42.6 47.7 41.9 33.6</td><td>28.5 27.2 40.2 47.6 37.9 29.2</td><td>28.2 26.4 38.8 46.1 35.5 32.2</td><td>34.3 40.6 56.0 55.0 53.8</td></tr></table>
FGSM (Lin et al., 2019), DI-MI-FGSM (Xie et al., 2019), TI-MI-FGSM (Dong et al., 2019), SI-NIFGSM (Lin et al., 2019), VT-MI-FGSM (Wang & He, 2021), VT-NI-FGSM (Wang & He, 2021) and FI-MI-FGSM (Wang et al., 2021). Then we compare the transferability of conventional momentumbased attacks and our EPN-based attacks.
Hyperparameters. In all experiments, we follow the official default settings for hyperparameters. Specifically, the maximum perturbation $\epsilon = 1 6$ , the number of iterations $T = 1 0$ , the step size $\alpha = \epsilon / T = 1 . 6$ , and the decay factor $\mu = 1 . 0$ . For DIM (Xie et al., 2019), the probability $p$ is set to 0.5. For TIM (Dong et al., 2019), the size of the Gaussian kernel is set to $1 5 { \times } 1 5$ . For SIM (Lin et al., 2019), the number of scale copies $m$ is set to 5. For VT-MI-FGSM (Wang & He, 2021) and VT-NIFGSM (Wang & He, 2021), the number of sampled examples $N$ is set to 20, and the parameter $\beta$ for the upper bound of the neighborhood is set to 1.5. For FI-MI-FGSM (Wang et al., 2021), the drop probability $p _ { d }$ is set to 0.3 when attacking normally trained models and 0.1 when attacking defense models, the ensemble number $N$ is set to 30 in aggregate gradient, and the intermediate layer is set to Mixed ${ } _ { 5 b }$ for Iv3, Conv 4a for IRv2, Conv3 3 for V16 as well as the last layer of the second block for R152. For our EM-based attacks, epochs is set to 5.
 Figure 3: The average attack success rates $( \% )$ of the adversarial examples crafted on source models against normally trained models (except the source model) and defense models for various $\mu$ .
 Figure 4: The average attack success rates $( \% )$ of the adversarial examples crafted on source models against normally trained models (except the source model) and defense models for various epochs.
# 4.2 ATTACK NORMALLY TRAINED MODELS
To validate that EPN-based attacks have higher transferability than conventional momentum-based attacks, we choose Iv3, IRv2, R152, and V16 as the source model, respectively, and attack normally trained target models via our EPN-based methods and baseline methods. The attack success rates are shown in Table 2. The results show that the attack success rates of our EPN-based methods are ${ \sim } 1 1 . 9 \%$ higher than baseline methods on average, In particular, our EPN-based attacks have the best transferability against normally trained target models when the source model is R152. Specifically, the attack success rates of EPNI-FGSM, DI-EPNI-FGSM, VT-EPNI-FGSM, and FI-EPNI-FGSM are $9 2 . 0 \%$ , $9 7 . 2 \%$ , $9 6 . 0 \%$ , and $9 6 . 0 \%$ , respectively, on average. Therefore, the experiments demonstrate that our EPN improves transferability more effectively than conventional momentum against normally trained models.
# 4.3 ATTACK DEFENSE MODELS
To further compare the transferability, we also use defense models as the target models, and the source models are still Iv3, IRv2, R152, and V16. We craft adversarial examples on the source model via our EPN-based methods and baseline methods to attack defense models. The attack success rates are shown in Table 3. The results show that the attack success rates of our EPNbased methods are ${ \sim } 1 3 . 1 \%$ higher than baseline methods on average. Adversarial examples crafted on R152 still show the best transferability against defense models. Specifically, the attack success rates of EPNI-FGSM, DI-EPNI-FGSM, VT-EPNI-FGSM, and FI-EPNI-FGSM are $5 1 . 7 \%$ , $7 5 . 8 \%$ , $7 3 . 6 \%$ , and $7 6 . 9 \%$ , respectively, on average. The results of experiments indicate that our EPN is still more effective than conventional momentum against defense models.
# 4.4 ABLATION STUDY
We conduct ablation studies for EPNI-FGSM. We investigate the impacts of two hyperparameters (i.e., the decay factor $\mu$ and the epochs of pretraining epochs) on the transferability of EPNI-FGSM in Sec. 4.4.1. We further study the impacts of EM and PN on transferability in Sec. 4.4.2.
# 4.4.1 IMPACTS OF $\mu$ AND epochs
The source models are set to Iv3, IRv2, R152, and V16. We use EPNI-FGSM to craft adversarial examples to attack normally trained models and defense models, respectively. We investigate the impacts of $\mu$ and epochs on the transferability of EPNI-FGSM by counting the average attack success rates against normally trained models (except the source model) and defense models.
The decay factor $\mu .$ . The decay factor $\mu$ plays a vital role for momentum. If $\mu = 0$ , the momentumbased attacks degrade to vanilla iterative gradient-based attacks. If $0 < \mu < 1$ , the previous gradients accumulated in the momentum decay exponentially. If $\mu = 1$ , the momentum simply adds up all previous gradients. If $\mu > 1$ , the previous gradients accumulated in the momentum grow exponentially. We pre-set epoch $s = 5$ and set $\mu$ from 0.0 to 2.0 with a step size of 0.1. The average attack success rates are shown in Fig. 3. When $\mu \leq 1 . 0$ , the average attack success rates show an upward trend, and when $\mu \geq 1 . 0$ , the average attack success rates show a downward trend. Therefore, we set $\mu = 1 . 0$ for EPNI-FGSM to achieve the best transferability.
 Figure 5: The average attack success rates $( \% )$ of the adversarial examples crafted on source models against normally trained models and defense models via NI-FGSM, ENI-FGSM, PNI-FGSM, and EPNI-FGSM.
The epochs of pretraining epochs. epochs affects the amount of gradient accumulated in EM. We pre-set $\mu = 1 . 0$ and set epochs from 0 to 10 with a step size of 1. The average attack success rates are shown in Fig. 4. As epochs increases, the average attack success rates increase and gradually converge. Since the larger epochs, the higher the computational cost, we set epochs $= 5$ for EPNIFGSM to strike a balance between computational cost and transferability.
In summary, we set the decay factor $\mu = 1 . 0$ and the epochs of pretraining epochs $= 5$ for EPNIFGSM. Similarly, such two hyperparameters of other EPN-based attacks have the same settings as EPNI-FGSM.
# 4.4.2 IMPACTS OF EM AND PN
The source models are the same as in Sec 4.4.1. To investigate the impacts of EM and PN, we craft adversarial examples on source models via ENI-FGSM (only with EM), PNI-FGSM (only with PN), and EPNI-FGSM (with EM and PN), respectively. In addition, we also use MI-FGSM and NI-FGSM (without EM and PN) as baselines. For ENI-FGSM, the epochs of pretraining epochs is set to 5. For ENI-FGSM and PNI-FGSM, the decay factor $\mu$ is set to 1.0. The average attack success rates of the adversarial examples against normally trained models and defense models are shown in Fig. 5. The average attack success rates of ENI-FGSM are higher than MI-FGSM and NIFGSM, demonstrating that EM improves transferability more than conventional momentum. The same is true for PN. Besides, the average attack success rates of EPNI-FGSM are higher than that of ENI-FGSM and PNI-FGSM, demonstrating that the combination of EM and PN can further improve transferability.
# 5 CONCLUSION
In this work, we proposed Experienced Momentum (EM) and Precise Nesterov momentum (PN) to boost transferability. Specifically, EM is trained on a set of derived models by Random Channels Swapping (RCS), and then conventional momentum is initialized to EM, which can accelerate optimization to escape from saddle points and poor local extrema during early iterations to improve transferability. Additionally, we adopted the current gradient to refine the pre-update of conventional Nesterov momentum, called PN. Then, we naturally combined EM and PN as EPN to improve transferability further. Extensive experiments demonstrate that EPN-based attacks have higher transferability than conventional momentum-based attacks. However, our methods still adopt a fixed learning rate or step size that is crucial for the optimizer. Therefore, we will explore the impact of learning rate or step size on transferability in future work.
# REFERENCES
Ayelet Akselrod-Ballin, Leonid Karlinsky, Sharon Alpert, Sharbell Hasoul, Rami Ben-Ari, and Ella Barkan. A region based convolutional network for tumor detection and classification in breast mammography. In Deep learning and data labeling for medical applications, pp. 197β205. Springer, 2016.
Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In 2017 ieee symposium on security and privacy (sp), pp. 39β57. IEEE, 2017.
Grigorios G Chrysos, Stylianos Moschoglou, Giorgos Bouritsas, Yannis Panagakis, Jiankang Deng, and Stefanos Zafeiriou. P-nets: Deep polynomial neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7325β7335, 2020.
Marco Cococcioni, Emanuele Ruffaldi, and Sergio Saponara. Exploiting posit arithmetic for deep neural networks in autonomous driving applications. In 2018 International Conference of Electrical and Electronic Technologies for Automotive, pp. 1β6. IEEE, 2018.
Jia Ding, Aoxue Li, Zhiqiang Hu, and Liwei Wang. Accurate pulmonary nodule detection in computed tomography images using deep convolutional neural networks. In International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 559β567. Springer, 2017.
Yinpeng Dong, Fangzhou Liao, Tianyu Pang, Hang Su, Jun Zhu, Xiaolin Hu, and Jianguo Li. Boosting adversarial attacks with momentum. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 9185β9193, 2018.
Yinpeng Dong, Tianyu Pang, Hang Su, and Jun Zhu. Evading defenses to transferable adversarial examples by translation-invariant attacks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4312β4321, 2019.
Gianni Franchi, Xuanlong Yu, Andrei Bursuc, Remi Kazmierczak, S Β΄ everine Dubuisson, Emanuel Β΄ Aldea, and David Filliat. Muad: Multiple uncertainties for autonomous driving benchmark for multiple uncertainty types and tasks. arXiv preprint arXiv:2203.01437, 2022.
Aditya Ganeshan, Vivek BS, and R Venkatesh Babu. Fda: Feature disruptive attack. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 8069β8079, 2019.
Veta Ghenescu, Roxana Elena Mihaescu, Serban-Vasile Carata, Marian Traian Ghenescu, Eduard Barnoviciu, and Mihai Chindea. Face detection and recognition based on general purpose dnn object detector. In 2018 International Symposium on Electronics and Telecommunications (ISETC), pp. 1β4. IEEE, 2018.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
Cong Hao, Yao Chen, Xinheng Liu, Atif Sarwari, Daryl Sew, Ashutosh Dhar, Bryan Wu, Dongdong Fu, Jinjun Xiong, Wen-mei Hwu, et al. Nais: Neural architecture and implementation search and its applications in autonomous driving. In 2019 IEEE/ACM International Conference on Computer-Aided Design (ICCAD), pp. 1β8. IEEE, 2019.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770β778, 2016.
Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4700β4708, 2017.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International conference on machine learning, pp. 448β456. PMLR, 2015.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. Advances in neural information processing systems, 25, 2012.
Alexey Kurakin, Ian Goodfellow, Samy Bengio, et al. Adversarial examples in the physical world, 2016.
Jiadong Lin, Chuanbiao Song, Kun He, Liwei Wang, and John E Hopcroft. Nesterov accelerated gradient and scale invariance for adversarial attacks. arXiv preprint arXiv:1908.06281, 2019.
Tianjiao Liu, Qianqian Guo, Chunfeng Lian, Xuhua Ren, Shujun Liang, Jing Yu, Lijuan Niu, Weidong Sun, and Dinggang Shen. Automated detection and classification of thyroid nodules in ultrasound images using clinical-knowledge-guided convolutional neural networks. Medical image analysis, 58:101555, 2019.
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. arXiv preprint arXiv:1706.06083, 2017.
Muzammal Naseer, Salman H Khan, Shafin Rahman, and Fatih Porikli. Task-generalizable adversarial attack based on perceptual metric. arXiv preprint arXiv:1811.09020, 2018.
Yurii Nesterov. A method for unconstrained convex minimization problem with the rate of convergence $\mathbf { o } ( ^ { 1 } / k ^ { 2 } )$ . 1983.
Boris T Polyak. Some methods of speeding up the convergence of iteration methods. Ussr computational mathematics and mathematical physics, 4(5):1β17, 1964.
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1β9, 2015.
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2818β2826, 2016.
Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, and Alexander A Alemi. Inception-v4, inception-resnet and the impact of residual connections on learning. In Thirty-first AAAI conference on artificial intelligence, 2017.
Florian Tramer, Alexey Kurakin, Nicolas Papernot, Ian Goodfellow, Dan Boneh, and Patrick Mc-\` Daniel. Ensemble adversarial training: Attacks and defenses. arXiv preprint arXiv:1705.07204, 2017.
Xiaosen Wang and Kun He. Enhancing the transferability of adversarial attacks through variance tuning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1924β1933, 2021.
Zhibo Wang, Hengchang Guo, Zhifei Zhang, Wenxin Liu, Zhan Qin, and Kui Ren. Feature importance-aware transferable adversarial attacks. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 7639β7648, 2021.
Cihang Xie, Zhishuai Zhang, Yuyin Zhou, Song Bai, Jianyu Wang, Zhou Ren, and Alan L Yuille. Improving transferability of adversarial examples with input diversity. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2730β2739, 2019.md/dev/0I3su3mkuL/0I3su3mkuL.mdAdded+370
md/dev/10uNUgI5Kl/10uNUgI5Kl.mdAdded+386
md/dev/1KaSx3GrBBm/1KaSx3GrBBm.mdAdded+341
md/dev/3lge0p5o-M-/3lge0p5o-M-.mdAdded+456
md/dev/67o9UQgTD0/67o9UQgTD0.mdAdded+474
md/dev/7gE9V9GBZaI/7gE9V9GBZaI.mdAdded+560
md/dev/8H5bpVwvt5/8H5bpVwvt5.mdAdded
md/dev/99RpBVpLiX/99RpBVpLiX.mdAdded
md/dev/9EAQVEINuum/9EAQVEINuum.mdAdded+414
md/dev/AhccnBXSne/AhccnBXSne.mdAdded+307
md/dev/EXnIyMVTL8s/EXnIyMVTL8s.mdAdded+719
md/dev/G2Q2Mh3avow/G2Q2Mh3avow.mdAdded
md/dev/I-6yh2-dkyD/I-6yh2-dkyD.mdAdded+345
md/dev/ITw9edRDlD/ITw9edRDlD.mdAdded+338
md/dev/JCCi58IUsh/JCCi58IUsh.mdAdded+491
md/dev/KwmPfARgOTD/KwmPfARgOTD.mdAdded
md/dev/LV8OmADmoOe/LV8OmADmoOe.mdAdded+223
md/dev/NiEtU7blzN/NiEtU7blzN.mdAdded
md/dev/OgCcfc1m0TO/OgCcfc1m0TO.mdAdded
md/dev/RA7ND878XP/RA7ND878XP.mdAdded
md/dev/SlxSY2UZQT/SlxSY2UZQT.mdAdded
md/dev/Sxk8Bse3RKO/Sxk8Bse3RKO.mdAdded
md/dev/TIdIXIpzhoI/TIdIXIpzhoI.mdAdded
md/dev/TatRHT_1cK/TatRHT_1cK.mdAdded
md/dev/TntbHxxGd6j/TntbHxxGd6j.mdAdded
md/dev/VgOw1pUPh97/VgOw1pUPh97.mdAdded
md/dev/WVX0NNVBBkV/WVX0NNVBBkV.mdAdded
md/dev/_1bgdFHhA70/_1bgdFHhA70.mdAdded
md/dev/a8qX5RG36jd/a8qX5RG36jd.mdAdded
md/dev/biaOpY5gAo/biaOpY5gAo.mdAdded
md/dev/dUSI4vFyMK/dUSI4vFyMK.mdAdded
md/dev/dz79MhQXWvg/dz79MhQXWvg.mdAdded
md/dev/f-fVCElZ-G1/f-fVCElZ-G1.mdAdded
md/dev/f3zNgKga_ep/f3zNgKga_ep.mdAdded
md/dev/fARM4P0gAJV/fARM4P0gAJV.mdAdded
md/dev/fcO9Cgn-X-R/fcO9Cgn-X-R.mdAdded
md/dev/h4r00NGkjR/h4r00NGkjR.mdAdded
md/dev/hX5Ia-ION8Y/hX5Ia-ION8Y.mdAdded
md/dev/luEG3j9LW5-/luEG3j9LW5-.mdAdded
md/dev/n0OeTdNRG0Q/n0OeTdNRG0Q.mdAdded
md/dev/n7XbkHOwKn6/n7XbkHOwKn6.mdAdded
md/dev/r9hNv76KoT3/r9hNv76KoT3.mdAdded
md/dev/ucASPPD9GKN/ucASPPD9GKN.mdAdded
md/dev/v54eUIayFh/v54eUIayFh.mdAdded
md/dev/w6fj2r62r_H/w6fj2r62r_H.mdAdded
md/dev/xnuN2vGmZA0/xnuN2vGmZA0.mdAdded
md/dev/yb3HOXO3lX2/yb3HOXO3lX2.mdAdded
md/dev/z9NLqoFvZ0/z9NLqoFvZ0.mdAdded
md/dev/zGvRdBW06F5/zGvRdBW06F5.mdAdded
md/train/S1WRibb0Z/S1WRibb0Z.mdAdded