kelseye commited on
Commit
7c95266
·
verified ·
1 Parent(s): ea8ba3c

Upload folder using huggingface_hub (part 28)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. parse/dev/XdDl3bFUNn5/images/bee4a0d2b5d5320f56fd5f623dfe24c3d41691a42552719819305fb62462ba01.jpg +3 -0
  2. parse/dev/XdDl3bFUNn5/images/bf9014c41bf3a0cfd55b18604dbb523fc2802cedb51fbae5ae170af88a880d8f.jpg +3 -0
  3. parse/dev/XdDl3bFUNn5/images/c35c6ec719ebc603ffa7c68e8546ac16b43d5435d11fe57ced17de33df935f4d.jpg +3 -0
  4. parse/dev/XdDl3bFUNn5/images/c4cb9b43c69543ac02dcd3f008770131a727810a36ed2ca639a19802a7330ca6.jpg +3 -0
  5. parse/dev/XdDl3bFUNn5/images/cb29670ed01bf09ed31a12ca6ad039bcf4bf7e14779e82674209d803f233b928.jpg +3 -0
  6. parse/dev/XdDl3bFUNn5/images/e5f8b403a18f9531da3950d7cfb1ced0e03353225325320fbee2408de7234a26.jpg +3 -0
  7. parse/dev/XdDl3bFUNn5/images/eeadcd9f0e29e5f6189d6f9900568a610859bbb2748da9bea3d89396af714c86.jpg +3 -0
  8. parse/dev/XdDl3bFUNn5/images/f6a5ba59ffcbf4e05f2f2c656f8beb6787252ca59ade651e0ba58658fe31ad31.jpg +3 -0
  9. parse/dev/XomEU3eNeSQ/XomEU3eNeSQ.md +355 -0
  10. parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_content_list.json +1848 -0
  11. parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_layout.pdf +3 -0
  12. parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_middle.json +0 -0
  13. parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_model.json +0 -0
  14. parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_origin.pdf +3 -0
  15. parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_span.pdf +3 -0
  16. parse/dev/XomEU3eNeSQ/images/1141077b8224742da55bf418f82a47d1be7099a3d390c36e36affeca54543599.jpg +3 -0
  17. parse/dev/XomEU3eNeSQ/images/1477506c8deee4b7fbb71a998023732aef2cc9c3a8db923d0e7d2fd849eb9489.jpg +3 -0
  18. parse/dev/XomEU3eNeSQ/images/15618a02a294a39479720341a03971180cec9ec86a0af942df47c057e0cd1731.jpg +3 -0
  19. parse/dev/XomEU3eNeSQ/images/16ac3946b11f5a0903e8070d8685b1ab81c68e24e79e6bfa427f5e6b58a1b951.jpg +3 -0
  20. parse/dev/XomEU3eNeSQ/images/21633cf36021cbd4c383da38346cc2c5ad48824fa5a15dfa2d62f62c7491fbc3.jpg +3 -0
  21. parse/dev/XomEU3eNeSQ/images/29fae3ff36f24cf6fe7117e7f760781374714a7347684948f7df9c71ee9548fd.jpg +3 -0
  22. parse/dev/XomEU3eNeSQ/images/2ce80764eb26a8059393b072022f99d73253f0c2c863d83b95f7d1a89d55b3ef.jpg +3 -0
  23. parse/dev/XomEU3eNeSQ/images/2e2e4baefe505e9f3ba439e931185acd8ec2f427a6d900c14eff2ed9317ba805.jpg +3 -0
  24. parse/dev/XomEU3eNeSQ/images/44de55a84e4c90f4f2f3862fad436ccd311d8ada7b923bd3ea22062da99d4b27.jpg +3 -0
  25. parse/dev/XomEU3eNeSQ/images/4e5ce168677271d207a1232df7e84e1a16857d83646dab66d08821b92672e1f5.jpg +3 -0
  26. parse/dev/XomEU3eNeSQ/images/5076cb2e53897509ca7243fa573292c5a46aae9242e6fb78828275446d8fd261.jpg +3 -0
  27. parse/dev/XomEU3eNeSQ/images/651fa4a2e3e81efd640052f4f33fcf41d8f0875c0ad82731059fb63ae694de7a.jpg +3 -0
  28. parse/dev/XomEU3eNeSQ/images/67e27b13a5225e3092af07df97dfe5fc2727543895d151e9cf5e51c620a916d7.jpg +3 -0
  29. parse/dev/XomEU3eNeSQ/images/7aaff504a40d9f97e9a41b52a142de4e43df4ca079d672ea6bfe3d5f8ca0e5d7.jpg +3 -0
  30. parse/dev/XomEU3eNeSQ/images/7e15dcea4c48b75ca7907c02567b65df35da89817d5747f2b5a9df593cc756ce.jpg +3 -0
  31. parse/dev/XomEU3eNeSQ/images/85abb3da4270dbbb992fa1474193e83f36d82a2bb3066c4dc5d5888fbc1bdd8a.jpg +3 -0
  32. parse/dev/XomEU3eNeSQ/images/8a089c4b019fc78f435073466a50637f17be885f415a3fa5ffeb9da9e9c26ae0.jpg +3 -0
  33. parse/dev/XomEU3eNeSQ/images/90a5e988f3483d0037d74465b54b9b166b3ff5748a8ee26c21d112bfb591a3fc.jpg +3 -0
  34. parse/dev/XomEU3eNeSQ/images/a00ae687357974f6d98dcf75658ac3e028243c152551284da61c1deb1abdd7ae.jpg +3 -0
  35. parse/dev/XomEU3eNeSQ/images/a3fb548bd758d8295d507b87b8ee73f25aab1c16584606dce010463f0238d398.jpg +3 -0
  36. parse/dev/XomEU3eNeSQ/images/b563baa1009fda55bb5385051fe02084c106c1ce23b52e759d38b47fdf0ff149.jpg +3 -0
  37. parse/dev/XomEU3eNeSQ/images/c29b3950a88fe4f248abeed7fc389851c6a8803d4218b21d151f93ee7b37bb9f.jpg +3 -0
  38. parse/dev/XomEU3eNeSQ/images/c6d5185f61ecb1d679f8470f8bb5d4104b7692dffb819bb4c91a810f5d2df200.jpg +3 -0
  39. parse/dev/XomEU3eNeSQ/images/c7454aefe570e7c6e4bca1ec79ea535cba3debd650acdb8eb85ad2b88385c2be.jpg +3 -0
  40. parse/dev/XomEU3eNeSQ/images/fdeb2385788b4500407cc540b7746c1cadb5a7b84050bf06ba7bc5aba863fcd5.jpg +3 -0
  41. parse/dev/XrGEkCOREX2/XrGEkCOREX2.md +250 -0
  42. parse/dev/XrGEkCOREX2/XrGEkCOREX2_content_list.json +1059 -0
  43. parse/dev/XrGEkCOREX2/XrGEkCOREX2_layout.pdf +3 -0
  44. parse/dev/XrGEkCOREX2/XrGEkCOREX2_middle.json +0 -0
  45. parse/dev/XrGEkCOREX2/XrGEkCOREX2_model.json +0 -0
  46. parse/dev/XrGEkCOREX2/XrGEkCOREX2_origin.pdf +3 -0
  47. parse/dev/XrGEkCOREX2/XrGEkCOREX2_span.pdf +3 -0
  48. parse/dev/XrGEkCOREX2/images/0bc73768db961d265fc945815923b2331129333602064c177dfa5e006862b3f8.jpg +3 -0
  49. parse/dev/XrGEkCOREX2/images/167b4ea9af7ac8b59f113a9ace265ae53c53372b280892f06b1650ed3db85e40.jpg +3 -0
  50. parse/dev/XrGEkCOREX2/images/38f79de4ec6d2f88467dca608625ef272a52c1153d3c21d395cadf8ac6b9fefe.jpg +3 -0
parse/dev/XdDl3bFUNn5/images/bee4a0d2b5d5320f56fd5f623dfe24c3d41691a42552719819305fb62462ba01.jpg ADDED

Git LFS Details

  • SHA256: 2f2589882812d7618d852b6cceb67f2c55f776705544e216a2814a0276c47f8e
  • Pointer size: 129 Bytes
  • Size of remote file: 9.87 kB
parse/dev/XdDl3bFUNn5/images/bf9014c41bf3a0cfd55b18604dbb523fc2802cedb51fbae5ae170af88a880d8f.jpg ADDED

Git LFS Details

  • SHA256: 72633ef2afb7db0a38c470939c59b93d9ade3dd2e9be0af493aa92882a81cee6
  • Pointer size: 129 Bytes
  • Size of remote file: 5.86 kB
parse/dev/XdDl3bFUNn5/images/c35c6ec719ebc603ffa7c68e8546ac16b43d5435d11fe57ced17de33df935f4d.jpg ADDED

Git LFS Details

  • SHA256: 9624950902a7e06e528830a77ae932a20e5d87385c6709a65a8287021a0d8747
  • Pointer size: 130 Bytes
  • Size of remote file: 41.6 kB
parse/dev/XdDl3bFUNn5/images/c4cb9b43c69543ac02dcd3f008770131a727810a36ed2ca639a19802a7330ca6.jpg ADDED

Git LFS Details

  • SHA256: fd1bfa4a5c127244ab7d8cb60016f213493b44a6a770736476733b53da4208ff
  • Pointer size: 130 Bytes
  • Size of remote file: 40 kB
parse/dev/XdDl3bFUNn5/images/cb29670ed01bf09ed31a12ca6ad039bcf4bf7e14779e82674209d803f233b928.jpg ADDED

Git LFS Details

  • SHA256: 97180564ecfc5aa5d8bd70b33ce36dc9eaa8decb3f7989994f663dbe04ed6639
  • Pointer size: 130 Bytes
  • Size of remote file: 24.9 kB
parse/dev/XdDl3bFUNn5/images/e5f8b403a18f9531da3950d7cfb1ced0e03353225325320fbee2408de7234a26.jpg ADDED

Git LFS Details

  • SHA256: 282e8b420151c485e8950bec584c7e1e73c404c032a7f620cee0471adf3bb6d1
  • Pointer size: 129 Bytes
  • Size of remote file: 4.26 kB
parse/dev/XdDl3bFUNn5/images/eeadcd9f0e29e5f6189d6f9900568a610859bbb2748da9bea3d89396af714c86.jpg ADDED

Git LFS Details

  • SHA256: 59ccc7e5dcf952e143435c84891ff768f794c5a666f8ac1a79d48db6373b8870
  • Pointer size: 130 Bytes
  • Size of remote file: 25.3 kB
parse/dev/XdDl3bFUNn5/images/f6a5ba59ffcbf4e05f2f2c656f8beb6787252ca59ade651e0ba58658fe31ad31.jpg ADDED

Git LFS Details

  • SHA256: 72f4ca0a72f83ed65aeef73b64544c3a989d224670ae9762515b2a5e82929a76
  • Pointer size: 130 Bytes
  • Size of remote file: 49.6 kB
parse/dev/XomEU3eNeSQ/XomEU3eNeSQ.md ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CODE TRANSLATION WITH COMPILER REPRESENTATIONS
2
+
3
+ Marc Szafraniec∗ Baptiste Rozière\* Patrick Labatut Gabriel Synnaeve
4
+
5
+ Hugh Leather François Charton
6
+
7
+ Meta AI {mszafraniec,broz}@meta.com
8
+
9
+ # ABSTRACT
10
+
11
+ In this paper, we leverage low-level compiler intermediate representations (IR) to improve code translation. Traditional transpilers rely on syntactic information and handcrafted rules, which limits their applicability and produces unnaturallooking code. Applying neural machine translation (NMT) approaches to code has successfully broadened the set of programs on which one can get a naturallooking translation. However, they treat the code as sequences of text tokens, and still do not differentiate well enough between similar pieces of code which have different semantics in different languages. The consequence is low quality translation, reducing the practicality of NMT, and stressing the need for an approach significantly increasing its accuracy. Here we propose to augment code translation with IRs, specifically LLVM IR, with results on the $\mathrm { C } { + } { + }$ , Java, Rust, and Go languages. Our method improves upon the state of the art for unsupervised code translation, increasing the number of correct translations by $11 \%$ on average, and up to $79 \%$ for the Java $ \mathrm { R u s t }$ pair with greedy decoding. With beam search, it increases the number of correct translations by $5 . 5 \%$ in average. We extend previous test sets for code translation, by adding hundreds of Go and Rust functions. Additionally, we train models with high performance on the problem of IR decompilation, generating programming source code from IR, and study using IRs as intermediary pivot for translation.
12
+
13
+ # 1 INTRODUCTION
14
+
15
+ Automatic code translation allows to port old codebases to new frameworks, or high-level (but slow) languages to low-level (and fast) ones. Current industry solutions, known as transpilers or transcompilers1, rely on handcrafted rules that are applied systematically. They produce unidiomatic translations that prove hard to read for human programmers. This is a serious limitation: the translated code should be easy to read and understand, as it will eventually be maintained by human developers.
16
+
17
+ In recent years, Neural Machine Translation (NMT) was proposed as an alternative to rule-based code translation (Roziere et al., 2020; Weisz et al., 2021; 2022). These models, trained from existing human-readable code, produce idiomatic, easy to understand, translations. Unfortunately, neural transpilers are unreliable, and often fail to translate the semantics of the input program accurately. This is a serious limitation, as some of the human work saved by the transpiler has to be reinvested debugging its output.
18
+
19
+ We propose to improve the reliability of NMT by leveraging information from compiler toolchains. When processing source code, compilers create Intermediary Representations (IR): language-agnostic pseudocode that describes the semantics of the program. Augmenting training data with the corresponding IR can benefit a Neural Transpiler in two ways: it helps align embeddings for different languages and improves the semantic understanding of the code. As shown in Figure 1, this can greatly improve the semantic quality of neural translations.
20
+
21
+ In this work, we leverage LLVM (Lattner and Adve, 2004) to augment source code with corresponding Intermediate Representation and train models for code translation and decompilation. We compare
22
+
23
+ ![](images/4e5ce168677271d207a1232df7e84e1a16857d83646dab66d08821b92672e1f5.jpg)
24
+
25
+ Figure 1: Improvements over TransCoder. The first example shows a translation from $\mathrm { C } { + } { + }$ to rust, where TransCoder generates code using unsigned instead of signed integers. In the second example, a translation from Java to Go, it generates a function with the wrong return type. In the third example, which is also a translation from Java to Go, the model outputs a function that looks similar to the correct solution but it confuses $>$ with $\gg$ and closes an expression with a parenthesis too early. In these cases and many others, TransCoder makes mistakes that are small in terms of edit distance, but have a large impact on the semantics of the code. Using the IR to ground the representations to the semantics often helps solving these issues.
26
+
27
+ it to TransCoder, which uses only code and no IR. We also design an IR-only baseline, dubbed the pivot method, which generates a translation solely by decompiling an IR generated from the source language to a different target language. We experiment with four languages: $\mathrm { C } { + } { + }$ Java, Rust and Go, and show that utilizing both the code and the IR allows for an average relative improvement of $5 . 5 \%$ . Moreover, our method only uses the IR at training time and does not require extra computations at inference time.
28
+
29
+ Our main contributions are:
30
+
31
+ • We implement a new IR-augmented translation method, which leverages LLVM IRs to improve code representations. It allows us to increase the number of correct translations generated by TransCoder for $\mathrm { C } { + } { + }$ , Java, Go and Rust by $5 . 5 \%$ . Compared to our IR-only pivot method, the improvement reaches $170 \%$
32
+ • Our method is especially useful in the low data regime: with relative improvements reaching $2 9 . 7 \%$ when translating to Rust and $2 5 . 6 \%$ when translating from it.
33
+ • We extend the parallel evaluation dataset of 852 functions in $\mathrm { C } { + + }$ , Java and Python from Roziere et al. (2020) with 343 more functions in Go and 280 more in Rust, along with corresponding test cases
34
+ • In addition, we achieve $78 \%$ accuracy when decompiling LLVM IRs to $\mathrm { C } { + + }$
35
+
36
+ # 2 INTERMEDIATE REPRESENTATIONS IN COMPILERS
37
+
38
+ Compilers translate programs written in a computer language into executable code for a specific machine. Most compilers consist of a front-end taking source code as input, and a back-end which produces machine binary code. The front-end lexes (tokenizes) and parses the program. Then, it produces an abstract syntax tree (AST), and translates it into some Intermediate Representation (IR). The back-end converts the IR into machine-specific executable code.
39
+
40
+ In modern compilers such as LLVM (Lattner and Adve, 2004), the IR is generic across different input languages (and thus different front-ends). It allows the application of transformations and target agnostic optimizations to the IR, in a middle-end module independent from the source language and target machine. This results in an efficient compiler structure: new languages can be implemented by rewriting the front-end, and new target machines by rewriting the back-end.
41
+
42
+ ![](images/a3fb548bd758d8295d507b87b8ee73f25aab1c16584606dce010463f0238d398.jpg)
43
+ Figure 2: A bird’s eye view of a compiler toolchain, exemplified with LLVM. The unoptimized version $( - 0 0 )$ is shown here for illustration. In practice we used the size-optimized version $( - \mathsf { O z } )$ of the IR as boxed, which does the compile time optimization of computing the addition of 26 and 16.
44
+
45
+ Several IRs usually co-exist in a compiler: each stage in the toolchain (Figure 2) introduces a new representation. Early stage IRs are language-dependent (e.g. ASTs mirror the syntax of the source language). Late stage IRs replace named variables by registers and reflect the specifics of the target architecture. In this work, we are interested in middle-end IRs, which are independent from the target machine, and similar for all source languages (like dialects in natural languages).
46
+
47
+ # 3 TRAINING OBJECTIVES
48
+
49
+ Unsupervised machine translation consists of learning multilingual sequence embeddings, and generating sequence in any output language from these embeddings (Lample et al., 2018a). We now present the objective functions for these tasks. In section 3.1, we review the three basic objectives used by TransCoder, our baseline NMT system. In section 3.2, we introduce three new functions that leverage LLVM IRs to improve the multilingual representation of source code, and the performance of our translation models. During training, we alternate between all six objectives, running each for the same number of optimisation steps. At inference, the model is only provided with the source code, i.e. the IR is not needed.
50
+
51
+ Formally, let $x = x _ { 1 } \ldots x _ { N _ { s o } }$ be the source sentence, $z ^ { ( x ) } = z _ { 1 } ^ { ( x ) } \dots z _ { N _ { i r } } ^ { ( x ) }$ the corresponding IR, and $y = y _ { 1 } \dots y _ { N _ { t a } } $ the target sentence. We write $\begin{array} { r } { \mathcal { L } _ { C E } ( \hat { y } , y ) = \sum _ { i } \ell _ { C E } ( \ddot { y } _ { i } , y _ { i } ) } \end{array}$ , with $\ell _ { C E } ( \hat { y } _ { i } , y _ { i } )$ the pairwise cross-entropy loss between $\hat { y } _ { i }$ and $y _ { i }$ . We define the machine translation loss (or seq2seq loss) from $x$ to $y$ , $\mathcal { L } _ { M T }$ as the sum of the negative log-likelihood of each token $y _ { i }$ , given $x$ and previous tokens $y _ { 0 } \ldots y _ { i - 1 }$ (note that $x$ and $y$ can have different lengths) :
52
+
53
+ $$
54
+ \mathcal { L } _ { M T } ( x , y ) = - \sum _ { i } \log \left( P ( y _ { i } | x , y _ { 1 } \ldots y _ { i - 1 } ) \right)
55
+ $$
56
+
57
+ # 3.1 COMMON OBJECTIVE FUNCTIONS
58
+
59
+ TransCoder (Roziere et al., 2020) learns to translate between programming languages by leveraging three unsupervised objectives developed for natural language (Lample et al., 2018b):
60
+
61
+ Masked Language Modeling (MLM) trains an encoder to predict randomly masked inputs. It is commonly used to pre-train embeddings for natural (Devlin et al., 2018; Liu et al., 2019) and programming languages (Kanade et al., 2020; Feng et al., 2020). MLM allows the model to learn the syntax and semantics of programs. Alternative objectives, have been proposed for programming languages (Guo et al., 2020; Lachaux et al., 2021; Ahmad et al., 2021; Wang et al., 2021). We do not use them here, as MLM remains effective and easy to use on a wide range of programming languages.
62
+
63
+ Denoting $m a s k ( x )$ the masked version of the code sentence $x$ , and $e n c ( t )$ the encoder output, MLM uses the following loss:
64
+
65
+ $$
66
+ \mathcal { L } _ { M L M } = \mathcal { L } _ { C E } \left( e n c ( m a s k ( x ) ) , x \right) .
67
+ $$
68
+
69
+ ![](images/90a5e988f3483d0037d74465b54b9b166b3ff5748a8ee26c21d112bfb591a3fc.jpg)
70
+ Figure 3: IR for code representation objectives. We show examples of masking (used in TLM and TAE) and IR generation used to improve code representations with IRs. The masking objective in TLM or TAE makes the model understand the relationship between code and IR. The IR generation objective helps the model to build semantic representations of the code. For instance, another $\mathrm { C } { + + }$ function computing $3 9 \ + \ 3$ would result in the same IR. A Go function that returns 42 would also have a similar LLVM IR. Therefore, the IR Generation objective encourages the model to build similar representations for these three semantically equivalent functions.
71
+
72
+ Denoising Auto Encoding (AE) trains a sequence to sequence (seq2seq) model to retrieve an original sequence from a corrupted version. Corruption is done by masking spans of tokens randomly sampled from a Poisson distribution, as well as removing and shuffling tokens. It uses the following loss $( n o i s e ( x )$ denotes the corrupted version of $x$ ):
73
+
74
+ $$
75
+ \mathcal { L } _ { A E } = \mathcal { L } _ { M T } \left( n o i s e ( x ) , x \right) .
76
+ $$
77
+
78
+ Back-Translation (BT). Back-Translation (Sennrich et al., 2015) uses the model to generate a noisy translation of the input sentence, and then trains the model to recover the original input from the translation. It is a simple yet powerful objective for unsupervised machine translation (Lample et al., 2018a; Artetxe et al., 2018). In practice, it is a required loss to get competitive performance, so it is a staple of all our experiments. Formally, we use the model to translate sequence $x$ into $\hat { y }$ and train the model to reverse the translation process, using the loss:
79
+
80
+ $$
81
+ \mathcal { L } _ { B T } = \mathcal { L } _ { M T } \left( \hat { y } , x \right)
82
+ $$
83
+
84
+ # 3.2 IR FOR CODE REPRESENTATIONS
85
+
86
+ Intermediate representations (IR) provide additional information about the code to be translated. We add them to the training dataset, as described in section 4.2, and leverage them by adding three new objective functions to those described in section 3.1.
87
+
88
+ Translation Language Modeling (TLM), first introduced in Lample and Conneau (2019), strives at generating common representations for parallel sentences in different languages. Like the masked language modeling (MLM) objective, it trains an encoder to predict random masked inputs. However, TLM is trained on pairs of parallel sentences, concatenated together and separated by a special token. Here, we concatenate functions in their source language and their corresponding IR, using the source code and IR language embeddings, and train the encoder to predict randomly masked tokens. This allows the model to learn correspondences between the source and the IR. The corresponding loss is ( $\oplus$ denotes concatenation):
89
+
90
+ $$
91
+ \mathcal { L } _ { T L M } = \mathcal { L } _ { C E } \left( m a s k ( x \oplus z ^ { ( x ) } ) , x \oplus z ^ { ( x ) } \right)
92
+ $$
93
+
94
+ ![](images/c6d5185f61ecb1d679f8470f8bb5d4104b7692dffb819bb4c91a810f5d2df200.jpg)
95
+ Figure 4: IR Decompilation objective. Here, we generate the IR corresponding to each function and train a model to decompile it. The IR pivot model uses this objective, as well as back-translation objectives, allowing it generalize to IRs generated from any language.
96
+
97
+ Translation Auto-Encoding (TAE) amounts to transposing the TLM objective into a denoising auto-encoder. The source code and corresponding IR are corrupted and masked, and then concatenated into one sequence (using the language embeddings for code and IR, as previously). TAE is then tasked to recover the original, using the following loss:
98
+
99
+ $$
100
+ \mathcal { L } _ { T A E } = \mathcal { L } _ { M T } \left( n o i s e ( x ) \oplus n o i s e ( z ^ { ( x ) } ) , x \oplus z ^ { ( x ) } \right)
101
+ $$
102
+
103
+ IR Generation (MT) trains the model to translate the source code into the corresponding IR. This allows the encoder to learn source code representations from the semantics of the IR. The loss is:
104
+
105
+ $$
106
+ \mathcal { L } _ { I R G e n } = \mathcal { L } _ { M T } \left( x , z ^ { ( x ) } \right)
107
+ $$
108
+
109
+ These three objectives need both the source code and the corresponding IR. However, only a fraction of the functions and files in our dataset could be compiled. To mitigate this, we also train the models on the full monolingual data using the MLM and AE objectives described above. In this setup, the back-translation (BT) objective is the same as in Roziere et al. (2020), and allows our model to translate directly from source code only at inference time.
110
+
111
+ # 3.3 ADDITIONAL LOSSES: IR DECOMPILATION AND PIVOT
112
+
113
+ We study two alternative uses of intermediary representations: IR decompilation, and IR pivot translation. IR decompilation consists of recovering source code corresponding to a given IR. In practice, it reverses the computations performed by the compiler. IR Pivot is a translation method built upon IR decompilation. Since LLVM can compile many languages $( \mathbf { C } + +$ , Java, Rust, Go) into the same IR, an obvious approach to code translation consists of decompiling the IR generated from the source language into code in the target language. We call this method “IR pivot”. Note that, whereas the IR for code representation techniques only used IR during training, both the decompilation and pivot method also need the IR for inference.
114
+
115
+ Decompilation. In this supervised task, we use LLVM to generate IR from source code, and train a language model to reverse the process, i.e. learn to predict the source code from the IR. Models are pre-trained using the MLM and AE objectives, and decompilation is learned using the machine translation loss:
116
+
117
+ $$
118
+ \mathcal { L } _ { D e c o m p } = \mathcal { L } _ { M T } \left( z ^ { ( x ) } , x \right)
119
+ $$
120
+
121
+ IR Pivot. This task leverages the IR as a pivot for code translation. For instance, to translate from Rust to $\mathrm { C } { + } { + }$ , we first use LLVM to compile a Rust program into IR and then decompile the IR to $\mathrm { C } { + } { + }$ using a neural decompiler. In practice, slight variations exists between the IR generated for different languages: the Rust-IR and $\mathrm { C } { + + }$ -IR behave like dialects of the LLVM-IR. This often leads to poor performance of the IR Pivot method. We mitigate these issues using a variety of techniques, which we describe in section C of the appendix.
122
+
123
+ # 4 DATA
124
+
125
+ # 4.1 TRAINING DATA
126
+
127
+ Our training data was extracted with Google BigQuery, which indexes over 2.8 million open source repositories from $\mathrm { G i t H u b } ^ { 2 }$ . We selected projects whose license explicitly permits re-distribution of parts, and extracted all individual $\mathrm { C } { + } { + }$ , Java, Rust and Go functions. To learn to decompile IRs, we also used the CodeNet dataset (Puri et al., 2021), a repository of 14 million competitive programming solutions in 55 languages. Our models work at function level: this reduces compilation failures over missing dependencies, while keeping sequence lengths short.
128
+
129
+ Table 1: Dataset coverage across languages, in number of standalone functions. More details can be found in Table 7 in the appendix.
130
+
131
+ <table><tr><td></td><td>C++</td><td>Go</td><td>Java</td><td>Rust</td></tr><tr><td>Monolingual data</td><td>6.6M</td><td>9.4 M</td><td>7.8M</td><td>576.3K</td></tr><tr><td>Code/IRParallel Data</td><td>344.4 K</td><td>384.4K</td><td>2.2 M</td><td>19.2 K</td></tr><tr><td>Successful IR Compilation</td><td>5.2%</td><td>4.1%</td><td>28.2%</td><td>3.3%</td></tr></table>
132
+
133
+ # 4.2 GENERATING INTERMEDIATE REPRESENTATIONS
134
+
135
+ While the LLVM ecosystem is large, not every language has an LLVM front-end, and not every front-end can produce LLVM IR out-of-the-box. We use $\mathsf { c } \mathtt { l a n g } + + \mathbf { \lambda } ^ { 3 }$ Lattner and Adve (2004) from the established LLVM $\mathrm { C } { + + }$ compilation toolchain, JLang4 for Java, Gollvm5 for Go and rustc Matsakis and Klock II (2014) for Rust. For the same program, written in different languages, different front-ends may produce different IR. To minimize these variations, we process the source code as follows. First, we generate the most size-optimized IR (- ${ \bf \nabla } \cdot O z$ flag), which makes the IR more uniform across languages. Second, we strip all unnecessary information (e.g. header and footer with attributes, debug information, comments). Finally, block names are canonicalized and symbol names demangled to facilitate their recovery. The functions that fail to compile at this point (e.g. because of missing dependencies) are not included in the parallel dataset, as seen in the last row of Table 1.
136
+
137
+ # 4.3 EVALUATION
138
+
139
+ Traditional NMT evaluation relies on metrics such as BLEU, that are based on n-gram overlaps. However, when dealing with programming languages, syntax and in particular compilation and computation outputs can differ widely despite minor changes in the code. Conversely, semantically equivalent code, that differ only in variable names or order of operations can have a low BLEU score. To take this into account, we use and enhance the computational accuracy test suite from Roziere et al. (2020), that contains 852 parallel competitive programming solutions in $\mathrm { C } { + + }$ , Java and Python. Using C2Rust, $\mathbf { \boldsymbol { C } } \mathbf { \boldsymbol { x } } \mathbf { \boldsymbol { G } } \mathbf { \boldsymbol { 0 } }$ and some manual code cleaning, we translated 280 functions and test suites in Rust and 343 in Go to measure the performance of our models in these languages. We measure our performance using the computational accuracy $\left( \mathbf { C A @ 1 } \right)$ metric (Kulal et al., 2019; Roziere et al., 2020), which considers that a translation is correct if it passes a series of unit tests.
140
+
141
+ # 5 RESULTS
142
+
143
+ # 5.1 EXPERIMENTAL DETAILS
144
+
145
+ For TransCoder, we consider a sequence-to-sequence (seq2seq) transformer model (Vaswani et al., 2017) with attention (Bahdanau et al., 2015; Sutskever et al., 2014) and the same architecture as Roziere et al. (2020). Our model has 12 layers (6 in the encoder and 6 in the decoder), 8 attention heads, and a dimension of 1024. For the objectives that add noise and masks to the input sentence, such as MLM, TLM, AE, and TAE, we choose the masked tokens and noise randomly on the fly at each epoch. We mask $15 \%$ of the tokens in MLM and TLM. In AE and TAE, we mask $20 \%$ of the tokens. MLM is trained on streams of data, while the other objectives are trained at function level. We use the Adam optimizer (Kingma and Ba, 2015) and an inverse squared-root learning rate scheduler, with an initial learning rate of $1 0 ^ { - 5 }$ in most of our experiments. Our models are implemented in PyTorch using mixed-precision floats. The pre-trained models were trained until convergence. The translation models presented in Tables 2 and 3 were trained for a week on 32 NVIDIA V100 GPUs.
146
+
147
+ Table 2: Translation performance $( \mathbf { C A } @ \mathbf { 1 } )$ , for greedy decoding and beam size 5. “To $X ^ { \ast }$ : average performance when translating to language X. “From $X ^ { \ast }$ : average performance when translating from language X. See Table 3 in the appendix for more detailed results. All these methods except for the IR pivot also use the three objectives defined in TransCoder: MLM, DAE and Back-Translation (BT). All combinations of the TLM, MT and TAE objectives improve the performance compared to TransCoder. The best results are obtained when all three are used at the same time. Beam search, using beam size 5 and returning only the top element from the beam results in improved performance. The IR Pivot method generates a translation in the target language from an IR generated from the source, and performs poorly in our setting.
148
+
149
+ <table><tr><td></td><td>from C++ to C++ from Go to Go from Java to Java from Rust to Rust</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>AVG</td></tr><tr><td>Greedy decoding</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>IR Pivot</td><td>17.4</td><td>24.0</td><td>19.9</td><td>11.5</td><td>11.9</td><td>22.2</td><td>16.3</td><td>7.8</td><td>16.4</td></tr><tr><td>TransCoder (baseline)</td><td>46.4</td><td>52.1</td><td>42.1</td><td>45.6</td><td>41.2</td><td>44.5</td><td>29.6</td><td>17.0</td><td>39.8</td></tr><tr><td>TLM</td><td>47.5</td><td>54.8</td><td>45.4</td><td>41.2</td><td>39.8</td><td>52.1</td><td>31.1</td><td>15.7</td><td>40.9</td></tr><tr><td>MLM+ TAE</td><td>47.3</td><td>53.3</td><td>47.2</td><td>44.8</td><td>41.8</td><td>45.9</td><td>25.1</td><td>17.4</td><td>40.4</td></tr><tr><td>TLM+TAE</td><td>46.9</td><td>55.9</td><td>45.0</td><td>37.9</td><td>38.5</td><td>54.5</td><td>34.9</td><td>16.8</td><td>41.3</td></tr><tr><td>MLM+MT</td><td>45.5</td><td>51.0</td><td>44.0</td><td>48.9</td><td>46.6</td><td>45.2</td><td>25.7</td><td>16.6</td><td>40.5</td></tr><tr><td>TLM + MT</td><td>45.6</td><td>51.5</td><td>45.1</td><td>47.1</td><td>46.9</td><td>45.5</td><td>24.4</td><td>17.9</td><td>40.5</td></tr><tr><td>TAE +MT</td><td>47.8</td><td>54.3</td><td>43.8</td><td>43.9</td><td>39.1</td><td>49.2</td><td>33.4</td><td>16.7</td><td>41.0</td></tr><tr><td>TLM + TAE +MT</td><td>47.8</td><td>54.3</td><td>46.6</td><td>51.6</td><td>47.1</td><td>49.6</td><td>35.3</td><td>21.4</td><td>44.2</td></tr><tr><td>Beam size 5</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>TransCoder (baseline)</td><td>53.8</td><td>53.4</td><td>45.2</td><td>54.4</td><td>46.1</td><td>51.5</td><td>35.9</td><td>20.9</td><td>45.3</td></tr><tr><td>TLM + TAE +MT</td><td>52.9</td><td>53.5</td><td>48.8</td><td>57.1</td><td>51.5</td><td>53.4</td><td>37.9</td><td>27.1</td><td>47.8</td></tr></table>
150
+
151
+ # 5.2 IR-AUGMENTED CODE REPRESENTATIONS FOR TRANSLATION
152
+
153
+ Models using combinations of the three objectives—TAE, TLM and MT—introduced to leverage IR, were trained to translate between pairs of four languages $\scriptstyle ( + +$ , Java, Rust, Go). Their average performance when translating to and from every language are presented in table 2. Additional information, including a comparison to TransCoder-ST for $\mathrm { C } { + } { + } $ Java, can be found in Table 3) in the appendix. As a baseline, we use a TransCoder (Roziere et al., 2020) model, trained with MLM on the same dataset.
154
+
155
+ Using greedy decoding, the new TLM, TAE and MT objectives, which leverage the IR, improve performance for every language. The best average results are obtained when combining all of them. Compared to TransCoder, they improve performance by an average $4 . 4 \%$ point ( $1 1 \%$ relative). The largest impacts are observed in the low data regime: translations from and into Rust (a language less represented in our training set) are improved by $2 5 . 6 \%$ and $1 9 . 3 \%$ (relative). Beam search improves the results of both TransCoder and our models, using IR-augmented representation still results in better performance. Qualitatively, we observe that IRs help our model translate types when the source and target types are represented by different tokens. For instance, in the first example of Table 1, it translates the semantics of int correctly using $\pm 3 2$ instead of an unsigned integer type (usize). See Appendix H for more analysis on how our objectives improve word embeddings.
156
+
157
+ Compared to IR-augmented translation models, the “obvious” IR Pivot method proves disappointing, even though it achieves non-trivial performances. It is heavily dependent on the size of the training set: the IR pivot performs relatively well when translating from low-resource to high-resource languages (e.g. from Rust), and badly when translating to low-resource languages (e.g. to Rust).
158
+
159
+ # 5.3 DECOMPILATION RESULTS
160
+
161
+ To compute the IR pivot, we trained a neural decompiler to retrieve source code from IRs. We tried two separate configurations for decompilation: a shared decoder with 6 layers for all language / IR pairs, or four separate decoders of with two layers each (one per language). Using a shared decoder improves the performance for all languages, and particularly when the data is scarce (e.g. Rust). See Table 5 in the appendix for more information.
162
+
163
+ We compare the performance of our model to RetDec (Kˇroustek et al., 2017), a rule-based decompiler. It obtains a computational accuracy of 68.75 on our $\mathrm { C } { + + }$ dataset and a BLEU score of 8.54. In comparison, our model obtains a computational accuracy of 77.9 and a BLEU score of 63.6 in the same setting. In particular, RetDec fails to decompile LLVM files generated from $\mathrm { C } { + } { + }$ code, especially snippets leveraging the standard library structures such as unordered_map or $s t d :$ allocator. The limitations of RetDec, which was implemented by a team of 24 developers in 7 years 6, shows how difficult it is to build exhaustive rule-based decompilers, especially when the IR comes from different languages or tools.
164
+
165
+ # 6 DISCUSSION
166
+
167
+ Different IR and interpreted languages The four languages considered in this work have frontends that can output LLVM Intermediary Representation. LLVM presently covers more than 30 computer languages. Using IR as pivot requires that the source and destination language have front-ends that use the same IR. This rules out some widely-used languages (e.g. Python). Using the IR to improve embeddings is less restrictive: the source and destination language can be trained on different IR, and aligned with back-translation. In this paper, we focus on compiled languages, but it is important to note that Intermediary Representations are usually available for interpreted languages as well: modern interpreters translate the source code into byte-code, that can serve as an IR.
168
+
169
+ Pivot vs Embedding TransCoder is an unsupervised model that learns to align code representations and translate code from one language to another. It is based solely on source code and does not use IRs. The pivot method uses automatically generated parallel sentences to learn to decompile IRs, and back-translation to adapt to different IR dialects. This method learns to translate using only IR-level similarities, and does not use the source code itself except to compute the IR. Although it underperforms other methods, it performs relatively well when little data is available for the source language, because the IR can be computed using a rule-based compiler. However, it requires to compute IRs at test time, which can be cumbersome. Instead, adding the TLM, TAE, and MT objectives to the objectives generally used for unsupervised code translation allows the model to get the best of both worlds. It can learn multilingual representations of source code from similarities in the IR and in the source code itself. As shown in Table 2, it outperforms both TransCoder and the pivot method. At the same time, this model does not require to compute IRs at test time, and is as easy to use as TransCoder.
170
+
171
+ Using our model at inference time. Our self-supervised IR-augmented TLM, TAE and MT objectives are designed to improve the multilingual code representations used in translation models. However, the translation task does not require to compute these objectives. Therefore, they lead to models that are just as simple to use as TransCoder: computing the IR is not required at test time and the model generates the translation directly from the source function.
172
+
173
+ # 7 RELATED WORKS
174
+
175
+ Source-to-Source Translation. Many rule-based methods are available for transpilation, an inventory of which can be found online1. In particular, ${ \mathrm { C } } 2 { \mathrm { R u s t } } ^ { 7 }$ and $\mathrm { C x G o } ^ { 8 }$ , along with manual corrections, were central for us in translating evaluation tests to Go and Rust (See Section 4.3). Similarly, $2 \mathrm { t o } 3 ^ { 9 }$ , a Python library porting Python 2 code to Python 3, was used in Aggarwal et al. (2015) to create a parallel dataset and train a machine learning model.
176
+
177
+ Neural Machine Translation for code is hampered by the lack of parallel data between programming languages. Indeed, apart from a few language pairs, such as Java-C# (Nguyen et al., 2013; Chen et al., 2018), and specific domains (e.g. competitive programming code), it is difficult to collect large datasets of semantically equivalent code in different languages. TransCoder (Roziere et al., 2020) bridges this gap by introducing unsupervised machine translation to programming languages. They take advantage of large monolingual code bases to learn to translate between $\mathrm { C } { + } { + }$ , Python and Java with high performance. Later, DOBF (Lachaux et al., 2021) improved the model pre-training method used in TransCoder, and Roziere et al. (2022) used automatically generated unit tests to improve translation performance between Java, $\mathrm { C } { + } { + }$ and Python. Recently, large language models trained on code, such as Codex (Chen et al., 2021) and PALM (Chowdhery et al., 2022), have been used for unsupervised code translation.
178
+
179
+ Using the Transcoder model, Weisz et al. (2021) and Weisz et al. (2022) survey the links between humans and NMT methods for code translation. They view neural translation methods as aids to programmers. In this context, they demonstrate that even imperfect models can improve the quality of an engineer’s work for code translation, and plead for the improvement of human-machine interfaces.
180
+
181
+ Decompilation. Like transpilation, decompilation is usually performed using rule-based methods that rely on pattern matching to parse the control flow structure of the program. RetDec, an open source decompiler created by Avast (Kˇroustek et al., 2017), can decompile an executable to C and a Python-like language via LLVM IR. Other tools exist, such as the Hex-Rays Decompiler10 and Brumley et al. (2013). A thorough review of rule-based methods can be found in papers such as Liang et al. (2021a) and Katz et al. (2019). With these methods, decompilation can fail if the code is too convoluted, or if it contains language features that were not explicitly translated. Most methods also produce unstructured programs, relying on a large number of goto statements to simulate the control flow of the lower level programming languages. This is semantically correct, but very rarely found in human-written code.
182
+
183
+ A few works have studied the use of sequence-to-sequence neural networks for neural decompilation. Katz et al. (2019) uses LSTM networks to decompile LLVM IRs and assembly code to C. Their approach generates code templates based on the IR, that determine the structure of the output. Then, they fill them with correct variable assignments and numerical values. In the same vein, Fu et al. (2019) tries to address limitations of neural decompilation with two sequential phases: code sketch generation and iterative error correction. Finally, Liang et al. (2021b) use a method close to ours, and train Transformer models to translate between binary code and C.
184
+
185
+ Intermediate representations are almost as old as compiler design. The first IR, UNCOL (Strong et al., 1958) was introduced in the mid-1950s, together with the idea of reusing the same compiler for several languages and machines. In 1960, NELIAC (a variant of ALGOL) (Huskey et al., 1960) was the first retargetable compiler, portable to different architectures. Feldman (1979) describes how a compiler for Fortran 77 can be added to the C compilers of Johnson (1979) and Ritchie (1979). GCC (Stallman, 2001) introduces Register Transfer Language (RTL) a low-level IR inspired by Davidson and Fraser (1980), and then GENERIC and GIMPLE (Merrill, 2003), precursors of the IR used in LLVM (Lattner and Adve, 2004).
186
+
187
+ # 8 CONCLUSION
188
+
189
+ In this paper, we leverage LLVM IRs to improve neural machine translation for source code. The IR provides a common semantically-rich language, into which $\mathrm { C } { + } { + }$ , Go, Java and Rust code can all be compiled. We develop three objectives, designed to leverage IRs for better multilingual representations of source code, which lead to a $5 . 5 \%$ relative average improvement for code translation. We also show that sequence-to-sequence transformers perform well for neural decompilation, and use this for pivot translation.
190
+
191
+ We only worked with the LLVM IR, but our approach is broadly applicable to any pair of languages that share a common Intermediate Representation. More generally any IR can help improve the code representations by tying them to the semantics. Another limitation is the scale of our current source and target sequences. As future work, LLVM IRs could be generated at a larger scale by compiling entire projects, which would greatly improve the percentage of successful IR compilations in Table 1. More languages and IRs could be used, and those extensions could be powered by larger models.
192
+
193
+ # REFERENCES
194
+
195
+ Karan Aggarwal, Mohammad Salameh, and Abram Hindle. Using machine translation for converting Python 2 to Python 3 code. Technical report, PeerJ PrePrints, 2015.
196
+
197
+ Wasi Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. Unified pre-training for program understanding and generation. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2655–2668, 2021.
198
+
199
+ Mikel Artetxe, Gorka Labaka, and Eneko Agirre. Unsupervised statistical machine translation. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, 2018.
200
+
201
+ Dzmitry Bahdanau, Kyung Hyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In 3rd International Conference on Learning Representations, 2015.
202
+
203
+ David Brumley, JongHyup Lee, Edward J Schwartz, and Maverick Woo. Native $\mathbf { \boldsymbol { x } } 8 6$ decompilation using semantics-preserving structural analysis and iterative control-flow structuring. In 22nd USENIX Security Symposium (USENIX Security 13), pages 353–368, 2013.
204
+
205
+ Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harri Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
206
+
207
+ Xinyun Chen, Chang Liu, and Dawn Song. Tree-to-tree neural networks for program translation. In Advances in neural information processing systems, pages 2547–2557, 2018.
208
+
209
+ 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.
210
+
211
+ Jack W. Davidson and Christopher W. Fraser. The design and application of a retargetable peephole optimizer. ACM Trans. Program. Lang. Syst., 2(2):191–202, apr 1980. ISSN 0164-0925.
212
+
213
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. CoRR, abs/1810.04805, 2018.
214
+
215
+ Stuart I. Feldman. Implementation of a portable Fortran 77 compiler using modern tools. SIGPLAN Not., 14(8):98–106, aug 1979. ISSN 0362-1340. doi: 10.1145/872732.806959. URL https: //doi.org/10.1145/872732.806959.
216
+
217
+ Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, et al. Codebert: A pre-trained model for programming and natural languages. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings, pages 1536–1547, 2020.
218
+
219
+ Cheng Fu, Huili Chen, Haolan Liu, Xinyun Chen, Yuandong Tian, Farinaz Koushanfar, and Jishen Zhao. Coda: An end-to-end neural program decompiler. In Advances in Neural Information Processing Systems, pages 3703–3714, 2019.
220
+
221
+ Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, LIU Shujie, Long Zhou, Nan Duan, Alexey Svyatkovskiy, Shengyu Fu, et al. Graphcodebert: Pre-training code representations with data flow. In International Conference on Learning Representations, 2020.
222
+
223
+ Harry D. Huskey, M. H. Halstead, and R. McArthur. NELIAC — dialect of ALGOL. Commun. ACM, 3(8):463–468, aug 1960. ISSN 0001-0782. doi: 10.1145/367368.367373. URL https: //doi.org/10.1145/367368.367373.
224
+
225
+ S. C. Johnson. A tour through the portable C compiler. In Unix Programmer’s Manual, 7th Edition, 2B, Section 33, 1979.
226
+
227
+ Aditya Kanade, Petros Maniatis, Gogul Balakrishnan, and Kensen Shi. Learning and evaluating contextual embedding of source code. In International Conference on Machine Learning, pages 5110–5121. PMLR, 2020.
228
+
229
+ Omer Katz, Yuval Olshaker, Yoav Goldberg, and Eran Yahav. Towards neural decompilation. arXiv preprint arXiv:1905.08325, 2019.
230
+
231
+ Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. ICLR, 2015.
232
+
233
+ Jakub Kˇroustek, Peter Matula, and P Zemek. RetDec: An open-source machine-code decompiler, 2017. URL https://github.com/avast/retdec.
234
+
235
+ Sumith Kulal, Panupong Pasupat, Kartik Chandra, Mina Lee, Oded Padon, Alex Aiken, and Percy S Liang. Spoc: Search-based pseudocode to code. Advances in Neural Information Processing Systems, 32:11906–11917, 2019.
236
+
237
+ Marie-Anne Lachaux, Baptiste Roziere, Marc Szafraniec, and Guillaume Lample. DOBF: A deobfuscation pre-training objective for programming languages. arXiv preprint arXiv:2102.07492, 2021.
238
+
239
+ Guillaume Lample and Alexis Conneau. Cross-lingual language model pretraining. Advances in Neural Information Processing Systems, 32:7059–7069, 2019.
240
+
241
+ Guillaume Lample, Alexis Conneau, Ludovic Denoyer, and Marc’Aurelio Ranzato. Unsupervised machine translation using monolingual corpora only. ICLR, 2018a.
242
+
243
+ Guillaume Lample, Myle Ott, Alexis Conneau, Ludovic Denoyer, and Marc’Aurelio Ranzato. Phrase based & neural unsupervised machine translation. In EMNLP, 2018b.
244
+
245
+ Chris Lattner and Vikram Adve. Llvm: A compilation framework for lifelong program analysis & transformation. In International Symposium on Code Generation and Optimization, 2004. CGO 2004., pages 75–86. IEEE, 2004.
246
+
247
+ Ruigang Liang, Ying Cao, Peiwei Hu, and Kai Chen. Neutron: an attention-based neural decompiler. Cybersecurity, 4(1):1–13, 2021a.
248
+
249
+ Ruigang Liang, Ying Cao, Peiwei Hu, Jinwen He, and Kai Chen. Semantics-recovering decompilation through neural machine translation. arXiv preprint arXiv:2112.15491, 2021b.
250
+
251
+ Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. RoBERTa: A robustly optimized BERT pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
252
+
253
+ Nicholas D Matsakis and Felix S Klock II. The Rust language. In ACM SIGAda Ada Letters, volume 34, pages 103–104. ACM, 2014.
254
+
255
+ Jason Merrill. GENERIC and GIMPLE: A new tree representation for entire functions. In in Proc. GCC Developers Summit, 2003, pages 171–180, 2003.
256
+
257
+ Anh Tuan Nguyen, Tung Thanh Nguyen, and Tien N Nguyen. Lexical statistical machine translation for language migration. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering, pages 651–654, 2013.
258
+
259
+ Ruchir Puri, David S. Kung, Geert Janssen, Wei Zhang, Giacomo Domeniconi, Vladimir Zolotov, Julian Dolby, Jie Chen, Mihir R. Choudhury, Lindsey Decker, Veronika Thost, Luca Buratti, Saurabh Pujar, and Ulrich Finkler. Project CodeNet: A large-scale AI for code dataset for learning a diversity of coding tasks. CoRR, abs/2105.12655, 2021. URL https://arxiv.org/abs/ 2105.12655.
260
+
261
+ D.M. Ritchie. A Tour Through the UNIX C Compiler. 1979. URL https://books.google. com/books?id ${ . } = { }$ 5UvEGwAACAAJ.
262
+
263
+ Baptiste Roziere, Marie-Anne Lachaux, Lowik Chanussot, and Guillaume Lample. Unsupervised translation of programming languages. Advances in Neural Information Processing Systems, 33, 2020.
264
+
265
+ Baptiste Roziere, Jie M Zhang, Francois Charton, Mark Harman, Gabriel Synnaeve, and Guillaume Lample. Leveraging automated unit tests for unsupervised code translation. ICLR, 2022.
266
+
267
+ Rico Sennrich, Barry Haddow, and Alexandra Birch. Improving neural machine translation models with monolingual data. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, pages 86–96, 2015.
268
+
269
+ Richard Stallman. Using and porting the GNU Compiler Collection. M.I.T. Artificial Intelligence Laboratory, 2001.
270
+
271
+ J. Strong, J. Wegstein, A. Tritter, J. Olsztyn, O. Mock, and T. Steel. The problem of programming communication with changing machines: A proposed solution. Commun. ACM, 1(8):12–18, aug 1958. ISSN 0001-0782. doi: 10.1145/368892.368915. URL https://doi.org/10.1145/ 368892.368915.
272
+
273
+ Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks In Advances in neural information processing systems, pages 3104–3112, 2014.
274
+
275
+ 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.
276
+
277
+ Yue Wang, Weishi Wang, Shafiq Joty, and Steven CH Hoi. Codet5: Identifier-aware unified pretrained encoder-decoder models for code understanding and generation. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 8696–8708, 2021.
278
+
279
+ Justin D Weisz, Michael Muller, Stephanie Houde, John Richards, Steven I Ross, Fernando Martinez, Mayank Agarwal, and Kartik Talamadupula. Perfection not required? human-ai partnerships in code translation. In 26th International Conference on Intelligent User Interfaces, pages 402–412, 2021.
280
+
281
+ Justin D Weisz, Michael Muller, Steven I Ross, Fernando Martinez, Stephanie Houde, Mayank Agarwal, Kartik Talamadupula, and John T Richards. Better together? an evaluation of AIsupported code translation. In 27th International Conference on Intelligent User Interfaces, pages 369–391, 2022.
282
+
283
+ # A FULL SCORES TABLE
284
+
285
+ Table 3: Results on unsupervised code translation. The metric shown is the computational accuracy for a single generation $( \mathbf { C A @ 1 } )$ , measuring the translation correctness using unit tests. It is the full version of Table 2. The models were all trained with the same budget. As in Table 2, all these methods except for the IR pivot also use the three objectives defined in TransCoder: MLM, DAE and Back-Translation (BT). Although it is not the case for every language pair, TransCoder-IR, which uses the TLM, TAE, and MT objectives outperforms other methods on average. TransCoder-ST (Roziere et al., 2022) uses a parallel dataset generated with automated unit tests and outperforms other methods for $\mathbf { C } + + \mathbf { J a v a }$ . Their method is orthogonal to ours, and we could also improve our performance with similar methods.
286
+
287
+ <table><tr><td colspan="6">C++ →Go C++→Java C++→Rust Go →C++ Go →Java Go →Rust</td></tr><tr><td>Baseline TransCoder</td><td>57.7</td><td>63.3</td><td>18.2</td><td>56.1</td><td>46.9</td><td>23.3</td></tr><tr><td>TransCoder-ST</td><td>1</td><td>68.0</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>Pivot</td><td>16.1</td><td>22.0</td><td>14.0</td><td>30.5</td><td>26.5</td><td>2.7</td></tr><tr><td>TLM</td><td>61.8</td><td>62.5</td><td>18.2</td><td>57.6</td><td>56.4</td><td>22.2</td></tr><tr><td>TAE</td><td>57.7</td><td>62.5</td><td>21.7</td><td>63.0</td><td>54.7</td><td>23.8</td></tr><tr><td>TLM+TAE</td><td>58.2</td><td>63.3</td><td>19.2</td><td>55.2</td><td>57.0</td><td>22.8</td></tr><tr><td>MT</td><td>56.8</td><td>60.6</td><td>19.2</td><td>60.3</td><td>53.8</td><td>18.0</td></tr><tr><td>TLM+MT</td><td>58.6</td><td>58.5</td><td>19.7</td><td>57.3</td><td>54.1</td><td>23.8</td></tr><tr><td>TAE+MT</td><td>61.4</td><td>60.2</td><td>21.7</td><td>55.5</td><td>53.8</td><td>22.2</td></tr><tr><td>TLM+TAE+MT</td><td>55.9</td><td>62.9</td><td>24.8</td><td>61.8</td><td>55.7</td><td>22.2</td></tr><tr><td colspan="7">Java →C++ Java→Go Java→Rust Rust →C++ Rust →Go Rust → Java</td></tr><tr><td>Baseline TransCoder</td><td>77.9</td><td>35.9</td><td>9.6</td><td>22.4</td><td>43.2</td><td>23.4</td></tr><tr><td>TransCoder-ST</td><td>84.6</td><td>1</td><td>1</td><td>-</td><td>1</td><td>1</td></tr><tr><td>Pivot</td><td>19.5</td><td>9.4</td><td>6.7</td><td>22.0</td><td>8.9</td><td>18.1</td></tr><tr><td>TLM</td><td>80.9</td><td>31.8</td><td>6.6</td><td>25.9</td><td>30.0</td><td>37.5</td></tr><tr><td>TAE</td><td>80.3</td><td>38.6</td><td>6.6</td><td>16.6</td><td>38.1</td><td>20.6</td></tr><tr><td>TLM+TAE</td><td>82.2</td><td>24.6</td><td>8.6</td><td>30.4</td><td>31.0</td><td>43.3</td></tr><tr><td>MT</td><td>76.2</td><td>50.9</td><td>12.6</td><td>16.6</td><td>39.1</td><td>21.3</td></tr><tr><td>TLM+MT</td><td>77.9</td><td>52.7</td><td>10.1</td><td>19.2</td><td>30.0</td><td>24.1</td></tr><tr><td>TAE+MT</td><td>77.5</td><td>33.6</td><td>6.1</td><td>30.0</td><td>36.6</td><td>33.7</td></tr><tr><td>TLM+TAE+MT</td><td>74.5</td><td>49.6</td><td>17.2</td><td>26.5</td><td>49.2</td><td>30.2</td></tr></table>
288
+
289
+ B BEAM SIZE EVALUATION
290
+
291
+ Table 4: Results on unsupervised code translation with different beam sizes. The metric shown is still the computational accuracy for a single generation $( \mathbf { C A @ 1 } )$ . BS N refers to beam search decoding with beam size N, and returning only the top element of the beam. Using beam search improves the average performance of every model. BS N means that the model is evaluated with beam size N. When the beam size is not given, we use greedy decoding. Surprisingly, beam size 5 outperforms beam size 10. Our method using intermediate representations still outperforms the baseline with beam size 5 and 10 in average. With the baseline, we obtain average $\mathrm { C A @ 1 }$ scores of 45.3 with beam size 5 and 44.0 with beam size 10. Our method yields $\mathrm { C A @ 1 }$ scores of 47.8 with beam size 5 and 46.8 with beam size 10.
292
+
293
+ <table><tr><td></td><td>C++ →Go</td><td>C++→→Java</td><td>C++→Rust</td><td>Go →C++</td><td>Go→ Java</td><td>Go →Rust</td></tr><tr><td>Baseline TransCoder</td><td>57.7</td><td>63.3</td><td>18.2</td><td>56.1</td><td>46.9</td><td>23.3</td></tr><tr><td>Baseline TransCoder (BS 5)</td><td>65.5</td><td>67.6</td><td>28.3</td><td>52.1</td><td>59.3</td><td>24.3</td></tr><tr><td>Baseline TransCoder (BS 10)</td><td>65.0</td><td>68.7</td><td>27.8</td><td>52.1</td><td>57.0</td><td>23.8</td></tr><tr><td>TLM+ TAE+ MT</td><td>55.9</td><td>62.9</td><td>24.8</td><td>61.8</td><td>55.7</td><td>22.2</td></tr><tr><td>TLM + TAE + MT (BS 5)</td><td>61.4</td><td>66.6</td><td>30.8</td><td>57.3</td><td>59.0</td><td>30.2</td></tr><tr><td>TLM + TAE + MT (BS 10)</td><td>61.4</td><td>67.4</td><td>29.3</td><td>56.4</td><td>59.0</td><td>29.1</td></tr><tr><td></td><td>Java → C++</td><td>Java →Go</td><td>Java→Rust</td><td>Rust -→ C++</td><td>Rust →Go</td><td>Rust → Java</td></tr><tr><td>Baseline TransCoder</td><td>77.9</td><td>35.9</td><td>9.6</td><td>22.4</td><td>43.2</td><td>23.4</td></tr><tr><td>Baseline TransCoder (BS 5)</td><td>82.9</td><td>45.5</td><td>10.1</td><td>25.2</td><td>54.8</td><td>27.5</td></tr><tr><td>Baseline TransCoder (BS 10)</td><td>80.9</td><td>46.4</td><td>7.6</td><td>23.6</td><td>51.8</td><td>23.0</td></tr><tr><td>TLM+ TAE + MT</td><td>74.5</td><td>49.6</td><td>17.2</td><td>26.5</td><td>49.2</td><td>30.2</td></tr><tr><td>TLM + TAE + MT (BS 5)</td><td>76.4</td><td>57.7</td><td>20.2</td><td>26.8</td><td>52.3</td><td>34.7</td></tr><tr><td>TLM + TAE + MT (BS 10)</td><td>77.7</td><td>57.3</td><td>18.2</td><td>26.2</td><td>51.8</td><td>28.2</td></tr></table>
294
+
295
+ # C PIVOT METHOD DETAILS
296
+
297
+ As mentioned in Section 3.3, IR generated from different languages contain slight variations and can be seen as dialects of the same language. In practice, these variations prevent us from simply using our best decompilation model to generate source code in another language than the one used to generate the IR. Although we prompt the model to generate code in the target language with language embeddings, it learns to focus on the particularities of each dialect and ignores the language embeddings. Therefore, it generates code in the source language, which results in a computational accuracy score of 0 for translation.
298
+
299
+ One way to solve this issue is to use one decoder per target language. Then, the model is able to generate code in the target language. However, this method still performs poorly due to the small differences between the IR dialects. The method we tested that performed the best, and which is reported in Table 2, uses back-translation to make the model to translate from any IR dialect to any language. This model is also grounded by supervised translation steps making it generate IR from code and code from IR. In practice, we create new language embeddings for every IR dialect (i.e. $\mathrm { I R - C + + }$ , IR-Go, IR-Java, IR-Rust) for depending on the source language. At training time, we make the model generate noisy translations in the IR-Go, IR-Java and IR-Rust “languages” for every $\mathrm { C } { + } { + }$ sequence, and train it to re-generate the $\mathrm { C } { + } { + }$ sequence from the noisy translation. To allow the model to generate good training data for $\scriptstyle { \mathrm { I R - X } } \to { \mathbf { C } } + +$ , we also generate noisy translations in Go, Java, and Rust for every IR generated from $\mathrm { C } { + } { + }$ in our dataset and train the model to retrieve the IR. Using our parallel code//IR dataset, we also train the model to translate between $\mathrm { C } { + + }$ and IR- $C + +$ sequences. We do the same for every language and alternate between them.
300
+
301
+ Table 5: Performance of LLVM IRs Decompilation. This table shows the computational accuracy $( \mathbf { C A @ 1 } )$ of our neural decompiler and the RetDec $\mathrm { C } { + + }$ rule-based decompiler. Our neural decompiler outperforms RedDec on $\mathrm { C } { + + }$ and is more broadly applicable.
302
+
303
+ <table><tr><td></td><td>C++</td><td>Go</td><td>Java</td><td>Rust</td></tr><tr><td>Baseline - RetDec</td><td>68.8</td><td>一</td><td></td><td></td></tr><tr><td>Separate Decoders</td><td>52.7</td><td>42.2</td><td>60.1</td><td>19.5</td></tr><tr><td>Shared Decoder</td><td>77.9</td><td>70.1</td><td>82.2</td><td>61.0</td></tr></table>
304
+
305
+ ![](images/15618a02a294a39479720341a03971180cec9ec86a0af942df47c057e0cd1731.jpg)
306
+ Figure 5: Code simplification examples with Decompilation / Pivot. Since the LLVM IR is optimized, functions that are semantically equivalent after optimization map to the same IR. In the first example, it allows to remove useless code by decompiling the generated LLVM IR. In the second example, the simplification allows to find a bug: the $\&$ operator has precedence over $= =$ in $\mathrm { C } { + } { + }$ , causing this function to always evaluate to false. It is not obvious when looking at the input code, but becomes clear with the IR and simplified $\mathrm { C } { + + }$ code. In the third example, it replaces a bitwise operation by a more straightforward multiplication. In all examples, we can run the compiler again to check that the IR of the decompiled code is exactly the same as that of the input. It guarantees that the input and simplified code have the same semantics.
307
+
308
+ ![](images/2e2e4baefe505e9f3ba439e931185acd8ec2f427a6d900c14eff2ed9317ba805.jpg)
309
+ Figure 6: Java to Rust translation examples. In the first example, the IR allows the model to understand that the Java bitwise complement operator \~ should be replaced by ! in Rust. Also, it allows the model to translate the type correctly in both examples and avoids unnecessary casts. The IR allows the model to generate the right types (e.g. i32 instead of $\mathtt { u } 3 2$ when translating int) and operator (e.g. ! instead of $\tilde { }$ in Rust).
310
+ Figure 7: Rust to Go translation example. This function performs binary search to find the insertion index for an element in an ordered vector. The model translates types, function definitions, variable definitions, and while loops correctly.
311
+
312
+ // Rust
313
+ pub fn binary_search(nums: Vec<i32>, target: i32,
314
+ ) -> i32 { if nums.is_empty() { return 0 } if target $<$ nums[0] { return 0 } let mut left $\qquad = \quad 0$ ; let mut right $=$ nums.len() - 1; while left $< =$ right { let mid $=$ left $^ +$ (right - left) / 2; if nums[mid] $= =$ target { return mid as i32; } else if nums[mid] $<$ target { left $=$ mid $^ + 1$ ; } else { right $=$ mid - 1; } } return left as i32;
315
+ }
316
+ // Go
317
+ func binarySearch(nums[] int, target int) int { if len(nums) $\scriptstyle = = 0$ { return 0 } if target $<$ nums[0] { return 0 } left: $\qquad = \quad 0$ right: $=$ len(nums) - 1 for left $< =$ right { mid: $=$ left $^ +$ (right - left) / 2 if nums[mid] $= =$ target { return mid } else if nums[mid] $<$ target { left $=$ mid $^ + 1$ else { right $=$ mid - 1 } } return left
318
+ }
319
+ // Go
320
+ func pairsInSortedRotated(arr[] int, n int, x int)
321
+ int { var i int for $\mathrm { ~ \\\small ~ \frac ~ { ~ i ~ } ~ } = \mathrm { ~ \small ~ 0 ~ }$ ; $\mathrm { ~ i ~ } ~ < \mathrm { ~ n ~ } ~ - ~ 1$ ; i++{ if arr[i] $\mathrm { ~ \gamma ~ > ~ } \mathrm { a r r } [ \mathrm { ~ i ~ \Gamma ~ + ~ }$ 1] { break } } var l int $= ( \frac { \mathrm { ~ i ~ \hbar ~ } } { 1 } + \mathrm { ~ 1 ~ } ) \frac { \circ } { \circ } \mathrm { ~ n ~ }$ var r int $\qquad = \quad \\\\\\\\\perp$ var cnt int $\qquad = \quad 0$ for l != r { if arr[l] $^ +$ arr[r] == x { cnt++ $\mathbf { i } \notin \mathbb { R } ^ { } 2 \ : \equiv \ : \ : ( \mathbf { r } _ { } \mathrm { ~ \ j ~ - ~ \frac ~ { ~ 1 ~ } ~ { ~ 1 ~ } ~ + ~ \eta ~ } _ { } \mathtt { n } ) \notin \mathbb { R } \ : \ : \{ \ :$ { return cnt } l = (l + 1) % n r = (r - 1 + n) % n } else if arr[l] + arr[r] < x { $1 = ( 1 + 1 ) \frac { 2 } { 0 } \pi$ } else { r = (n + r - 1) % n } } return cnt
322
+ }
323
+ // C++
324
+ int pairsInSortedRotated(int arr[], int n, int x)
325
+ { int i; for $( \mathrm { ~ i ~ ~ } \ = \ \mathrm { ~ 0 ~ } ; \ \mathrm { ~ i ~ } \ < \ \mathrm { ~ n ~ ~ - ~ } \ \mathrm { ~ 1 ~ } ; \ \mathrm { ~ i ~ } \ + + )$ { if (arr $[ \pm ] >$ arr $[ { \mathrm { ~ i ~ \phi ~ } } + { \mathrm { ~ 1 ~ } } ]$ ) break; } int $1 = ( \dot { \bf ~ 1 } + \dot { \bf ~ 1 } ) \frac { \ d s } { \ d s } \mathrm { ~ n ~ } ;$ int $\mathrm { ~ \bf ~ r ~ } = \mathrm { ~ \bf ~ i ~ } ;$ ; int cnt $\qquad = \quad 0$ ; while $( \underline { { { 1 } } } \quad : = \quad \underline { { { { \bf r } } } } )$ ) { if (arr [l] + arr $[ { \boldsymbol { \textbf { r } } } ] \ \mathbf { \Sigma } = = { \boldsymbol { \textbf { x } } } )$ ) { cnt $^ { + + }$ ; $\begin{array} { c c c c c c c c c } { { \lfloor \pm } } & { { ( 1 } } & { { = = } } & { { ( \tt { r } } } & { { - } } & { { 1 } } & { { + } } & { { \tt { n } ) } } & { { \tt { \& } } } & { { \tt { n } ) } } & { { } } & { { } } \end{array}$ return cnt; $1 = ( 1 + 1 ) \frac { 2 } { 9 } \pi ;$ $\begin{array} { r c c c c l } { \texttt { r } = } & { ( \texttt { r } - } & { \texttt { l } + } & { \texttt { n } ) } & { \frac { \circ } { \circ } } & { \mathtt { n } } & { ; } \end{array}$ } else $\begin{array} { r } { \mathrm { i } \texttt { i f } \left( \mathrm { a r r } \left[ \mathrm { \texttt { l } } \right] \ + \ \mathrm { a r r } \left[ \mathrm { \texttt { r } } \right] \ < \ \textbf { x } \right) \ \mathrm { ~ \texttt { l } ~ = ~ \textbf { ( } \mathrm { 1 ~ \texttt { + } ~ 1 ~ } ) ~ \ \frac { \circ } { \circ } ~ \ n ~ } ; } \end{array}$ else $\texttt { r } = \texttt { ( n + r - l ) } \texttt { \frac { e } { s } n }$ ; } return cnt;
326
+
327
+ ![](images/c29b3950a88fe4f248abeed7fc389851c6a8803d4218b21d151f93ee7b37bb9f.jpg)
328
+ Figure 9: Rust to Go translation example. We call S1 the string n1 repeated s1 times and S2 the string n2 repeated $_ { \textrm { S 2 } }$ times. This function finds the largest number of repetitions of S2 appearing in any subset of S1. The model translates the types correctly, understands that casting vector indices to unsigned int (i.e. with as usize) is not required in Go, and correctly translates other Rust constructs to Go.
329
+
330
+ # F DATASET SIZE DETAILS
331
+
332
+ Table 6: Dataset details: number of tokens in our function-level dataset. This dataset contains only functions defined outside of classes and static functions.
333
+
334
+ <table><tr><td></td><td>Numberof tokens</td><td>Number of sentences</td></tr><tr><td>Monolingual data</td><td></td><td></td></tr><tr><td>C++</td><td>2.33B</td><td>6.6M</td></tr><tr><td>Go</td><td>1.9B</td><td>9.4M</td></tr><tr><td>Java</td><td>1.5B</td><td>7.8M</td></tr><tr><td>Rust</td><td>130.0M</td><td>576.3K</td></tr><tr><td>Code /IR Parallel Data</td><td></td><td></td></tr><tr><td>C++-IR</td><td>946.7M</td><td>343.9K</td></tr><tr><td>Go-IR</td><td>971.8M</td><td>384.4K</td></tr><tr><td>Java-IR</td><td>1.7B</td><td>2.2M</td></tr><tr><td>Rust-IR</td><td>77.7M</td><td>19.4K</td></tr></table>
335
+
336
+ # G ADDITIONAL ABLATIONS
337
+
338
+ Training on IRs with different objectives. We perform some additional ablations to determine whether our performance improvements come from training on IRs or from our TLM, TAE and MT objectives. When training a model with the three objectives of TransCoder (i.e. MLM, DAE and BT) and considering the IR as an extra language, we obtain an average computational accuracy of 37.4, which is lower than that of our baseline TransCoder. As the structure of the IR is not similar to that of any of our source languages, there is not much to gain from adding the IR as an extra language. Moreover, the model is wasting some time to compute the AE and BT objectives for the IR which can be better spent on the source languages. It confirms that our objectives are required to map IRs and their corresponding source code to similar representations in embedding space.
339
+
340
+ Language ablation: no Java. As Rust and Go are more similar to Java than to $\mathrm { C } { + + }$ , we also train a baseline model on $\mathrm { C } { + } { + }$ , Go and Rust only to evaluate whether including Java hurts the translation performance. We observed similar performance for $\mathbf { C } \mathbf { + } \mathbf { + } \mathbf { G } \mathbf { o }$ . However, we also observe a clear decrease in performance in the very low data regime (i.e. when translating to or from Rust). The computational accuracy for Rust $ \mathbf { C } + +$ goes down from $2 2 . 4 \%$ to $2 0 . 1 \%$ and it goes down from $4 3 . 1 \bar { 5 } \%$ to $3 2 . 5 \%$ for Rust $ \mathrm { G o }$ .
341
+
342
+ # H WORD EMBEDDINGS
343
+
344
+ We notice that our method generates improved word embeddings. It is visible when looking at the cosine similarity for embeddings of rust types and their equivalents in $\mathrm { C } { + } { + }$ . For instance, Figure 10 shows that the embedding of $\hphantom { 0 } \mathrm { { 3 2 } }$ from our model leveraging LLVM IRs is most similar to uint32 (with a cosine similarity of 0.4869). uint, which is also a correct translation, comes in $1 1 ^ { t h }$ position with a cosine similarity (0.3716). In contrast, $\hphantom { 0 } \mathrm { { 3 2 } }$ has a similarity of only 0.2828 with int. This token, which would be an incorrect translation, comes only in $2 9 ^ { t h }$ position.
345
+
346
+ The baseline model, which does not use the IR, learns similar representations for rust types since they appear in similar contexts. Hence, its embedding of $\hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom { 0 } \hphantom \hphantom { 0 } \hphantom { 0 } \hphantom \hphantom { 0 } \hphantom \hphantom { 0 } \hphantom \hphantom { 0 } \hphantom \hphantom \hphantom { 0 } \hphantom \hphantom \hphantom \hphantom { 0 } \hphantom \hphantom \hphantom \hphantom \hphantom \end \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \hphantom \end f$ is most similar to other rust types tokens such as $\mathtt { \small u 6 4 }$ , i32 or u16. uint32 comes only in fourth position with a cosine similarity of 0.4218. Moreover, uint and int have almost the same cosine similarities with $\hphantom { 0 } \mathrm { { 3 2 } }$ with the baseline model. It causes the model to often confuse unsigned and signed integer types, and to incorrectly translate u32 into int instead of uint.
347
+
348
+ ![](images/1141077b8224742da55bf418f82a47d1be7099a3d390c36e36affeca54543599.jpg)
349
+ Figure 10: Token similarities. Rank and token similarity with $\mathtt { u } 3 2$ for our model (right) and the baseline model (left). Our model generates embeddings that better capture token semantics.
350
+
351
+ # I ANALYSIS OF ERROR TYPES
352
+
353
+ Table 7: Rust error types. To validate our intuition on the usefulness of the IR representations to decrease the number of type-related errors (see Fig.1 or Fig.6), we perform an in-depth analysis of the types of errors encountered for the Java Rust direction. Here we count the total number of errors (there can be several for a single translation). We notice that the number of type-related errors (excluding E0433, E0425 and Others) decreases by $24 \%$ (609 vs. 463) and the number of mismatched types decreases by $49 \%$ .
354
+
355
+ <table><tr><td>Error Code</td><td>Error Description</td><td>Baseline (Transcoder)</td><td>TLM + TAE + MT</td></tr><tr><td>E0308</td><td>Mismatched Type</td><td>414</td><td>210</td></tr><tr><td>E0412</td><td>Type Does Not Exist</td><td>15</td><td>3</td></tr><tr><td>E0277</td><td>Type has Missing Trait</td><td>180</td><td>250</td></tr><tr><td>E0425</td><td>Undefined Variable</td><td>18</td><td>27</td></tr><tr><td>E0433</td><td>Use of Undefined Crate,Module or Type</td><td>15</td><td>32</td></tr><tr><td>丨</td><td>Others</td><td>28</td><td>33</td></tr><tr><td>TOTAL</td><td></td><td>670</td><td>555</td></tr></table>
parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_content_list.json ADDED
@@ -0,0 +1,1848 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "CODE TRANSLATION WITH COMPILER REPRESENTATIONS ",
5
+ "text_level": 1,
6
+ "bbox": [
7
+ 173,
8
+ 98,
9
+ 633,
10
+ 146
11
+ ],
12
+ "page_idx": 0
13
+ },
14
+ {
15
+ "type": "text",
16
+ "text": "Marc Szafraniec∗ Baptiste Rozière\\* Patrick Labatut Gabriel Synnaeve ",
17
+ "bbox": [
18
+ 184,
19
+ 170,
20
+ 439,
21
+ 198
22
+ ],
23
+ "page_idx": 0
24
+ },
25
+ {
26
+ "type": "text",
27
+ "text": "Hugh Leather François Charton ",
28
+ "bbox": [
29
+ 450,
30
+ 170,
31
+ 692,
32
+ 199
33
+ ],
34
+ "page_idx": 0
35
+ },
36
+ {
37
+ "type": "text",
38
+ "text": "Meta AI {mszafraniec,broz}@meta.com ",
39
+ "bbox": [
40
+ 186,
41
+ 199,
42
+ 392,
43
+ 224
44
+ ],
45
+ "page_idx": 0
46
+ },
47
+ {
48
+ "type": "text",
49
+ "text": "ABSTRACT ",
50
+ "text_level": 1,
51
+ "bbox": [
52
+ 454,
53
+ 244,
54
+ 544,
55
+ 260
56
+ ],
57
+ "page_idx": 0
58
+ },
59
+ {
60
+ "type": "text",
61
+ "text": "In this paper, we leverage low-level compiler intermediate representations (IR) to improve code translation. Traditional transpilers rely on syntactic information and handcrafted rules, which limits their applicability and produces unnaturallooking code. Applying neural machine translation (NMT) approaches to code has successfully broadened the set of programs on which one can get a naturallooking translation. However, they treat the code as sequences of text tokens, and still do not differentiate well enough between similar pieces of code which have different semantics in different languages. The consequence is low quality translation, reducing the practicality of NMT, and stressing the need for an approach significantly increasing its accuracy. Here we propose to augment code translation with IRs, specifically LLVM IR, with results on the $\\mathrm { C } { + } { + }$ , Java, Rust, and Go languages. Our method improves upon the state of the art for unsupervised code translation, increasing the number of correct translations by $11 \\%$ on average, and up to $79 \\%$ for the Java $ \\mathrm { R u s t }$ pair with greedy decoding. With beam search, it increases the number of correct translations by $5 . 5 \\%$ in average. We extend previous test sets for code translation, by adding hundreds of Go and Rust functions. Additionally, we train models with high performance on the problem of IR decompilation, generating programming source code from IR, and study using IRs as intermediary pivot for translation. ",
62
+ "bbox": [
63
+ 233,
64
+ 277,
65
+ 766,
66
+ 540
67
+ ],
68
+ "page_idx": 0
69
+ },
70
+ {
71
+ "type": "text",
72
+ "text": "1 INTRODUCTION ",
73
+ "text_level": 1,
74
+ "bbox": [
75
+ 176,
76
+ 568,
77
+ 336,
78
+ 584
79
+ ],
80
+ "page_idx": 0
81
+ },
82
+ {
83
+ "type": "text",
84
+ "text": "Automatic code translation allows to port old codebases to new frameworks, or high-level (but slow) languages to low-level (and fast) ones. Current industry solutions, known as transpilers or transcompilers1, rely on handcrafted rules that are applied systematically. They produce unidiomatic translations that prove hard to read for human programmers. This is a serious limitation: the translated code should be easy to read and understand, as it will eventually be maintained by human developers. ",
85
+ "bbox": [
86
+ 174,
87
+ 599,
88
+ 825,
89
+ 670
90
+ ],
91
+ "page_idx": 0
92
+ },
93
+ {
94
+ "type": "text",
95
+ "text": "In recent years, Neural Machine Translation (NMT) was proposed as an alternative to rule-based code translation (Roziere et al., 2020; Weisz et al., 2021; 2022). These models, trained from existing human-readable code, produce idiomatic, easy to understand, translations. Unfortunately, neural transpilers are unreliable, and often fail to translate the semantics of the input program accurately. This is a serious limitation, as some of the human work saved by the transpiler has to be reinvested debugging its output. ",
96
+ "bbox": [
97
+ 174,
98
+ 676,
99
+ 825,
100
+ 761
101
+ ],
102
+ "page_idx": 0
103
+ },
104
+ {
105
+ "type": "text",
106
+ "text": "We propose to improve the reliability of NMT by leveraging information from compiler toolchains. When processing source code, compilers create Intermediary Representations (IR): language-agnostic pseudocode that describes the semantics of the program. Augmenting training data with the corresponding IR can benefit a Neural Transpiler in two ways: it helps align embeddings for different languages and improves the semantic understanding of the code. As shown in Figure 1, this can greatly improve the semantic quality of neural translations. ",
107
+ "bbox": [
108
+ 174,
109
+ 767,
110
+ 825,
111
+ 851
112
+ ],
113
+ "page_idx": 0
114
+ },
115
+ {
116
+ "type": "text",
117
+ "text": "In this work, we leverage LLVM (Lattner and Adve, 2004) to augment source code with corresponding Intermediate Representation and train models for code translation and decompilation. We compare ",
118
+ "bbox": [
119
+ 176,
120
+ 858,
121
+ 821,
122
+ 886
123
+ ],
124
+ "page_idx": 0
125
+ },
126
+ {
127
+ "type": "image",
128
+ "img_path": "images/4e5ce168677271d207a1232df7e84e1a16857d83646dab66d08821b92672e1f5.jpg",
129
+ "image_caption": [],
130
+ "image_footnote": [],
131
+ "bbox": [
132
+ 179,
133
+ 101,
134
+ 828,
135
+ 382
136
+ ],
137
+ "page_idx": 1
138
+ },
139
+ {
140
+ "type": "text",
141
+ "text": "Figure 1: Improvements over TransCoder. The first example shows a translation from $\\mathrm { C } { + } { + }$ to rust, where TransCoder generates code using unsigned instead of signed integers. In the second example, a translation from Java to Go, it generates a function with the wrong return type. In the third example, which is also a translation from Java to Go, the model outputs a function that looks similar to the correct solution but it confuses $>$ with $\\gg$ and closes an expression with a parenthesis too early. In these cases and many others, TransCoder makes mistakes that are small in terms of edit distance, but have a large impact on the semantics of the code. Using the IR to ground the representations to the semantics often helps solving these issues. ",
142
+ "bbox": [
143
+ 173,
144
+ 396,
145
+ 825,
146
+ 486
147
+ ],
148
+ "page_idx": 1
149
+ },
150
+ {
151
+ "type": "text",
152
+ "text": "it to TransCoder, which uses only code and no IR. We also design an IR-only baseline, dubbed the pivot method, which generates a translation solely by decompiling an IR generated from the source language to a different target language. We experiment with four languages: $\\mathrm { C } { + } { + }$ Java, Rust and Go, and show that utilizing both the code and the IR allows for an average relative improvement of $5 . 5 \\%$ . Moreover, our method only uses the IR at training time and does not require extra computations at inference time. ",
153
+ "bbox": [
154
+ 174,
155
+ 492,
156
+ 825,
157
+ 575
158
+ ],
159
+ "page_idx": 1
160
+ },
161
+ {
162
+ "type": "text",
163
+ "text": "Our main contributions are: ",
164
+ "bbox": [
165
+ 174,
166
+ 583,
167
+ 354,
168
+ 597
169
+ ],
170
+ "page_idx": 1
171
+ },
172
+ {
173
+ "type": "text",
174
+ "text": "• We implement a new IR-augmented translation method, which leverages LLVM IRs to improve code representations. It allows us to increase the number of correct translations generated by TransCoder for $\\mathrm { C } { + } { + }$ , Java, Go and Rust by $5 . 5 \\%$ . Compared to our IR-only pivot method, the improvement reaches $170 \\%$ \n• Our method is especially useful in the low data regime: with relative improvements reaching $2 9 . 7 \\%$ when translating to Rust and $2 5 . 6 \\%$ when translating from it. \n• We extend the parallel evaluation dataset of 852 functions in $\\mathrm { C } { + + }$ , Java and Python from Roziere et al. (2020) with 343 more functions in Go and 280 more in Rust, along with corresponding test cases \n• In addition, we achieve $78 \\%$ accuracy when decompiling LLVM IRs to $\\mathrm { C } { + + }$ ",
175
+ "bbox": [
176
+ 217,
177
+ 609,
178
+ 825,
179
+ 763
180
+ ],
181
+ "page_idx": 1
182
+ },
183
+ {
184
+ "type": "text",
185
+ "text": "2 INTERMEDIATE REPRESENTATIONS IN COMPILERS ",
186
+ "text_level": 1,
187
+ "bbox": [
188
+ 173,
189
+ 789,
190
+ 619,
191
+ 804
192
+ ],
193
+ "page_idx": 1
194
+ },
195
+ {
196
+ "type": "text",
197
+ "text": "Compilers translate programs written in a computer language into executable code for a specific machine. Most compilers consist of a front-end taking source code as input, and a back-end which produces machine binary code. The front-end lexes (tokenizes) and parses the program. Then, it produces an abstract syntax tree (AST), and translates it into some Intermediate Representation (IR). The back-end converts the IR into machine-specific executable code. ",
198
+ "bbox": [
199
+ 174,
200
+ 819,
201
+ 825,
202
+ 888
203
+ ],
204
+ "page_idx": 1
205
+ },
206
+ {
207
+ "type": "text",
208
+ "text": "In modern compilers such as LLVM (Lattner and Adve, 2004), the IR is generic across different input languages (and thus different front-ends). It allows the application of transformations and target agnostic optimizations to the IR, in a middle-end module independent from the source language and target machine. This results in an efficient compiler structure: new languages can be implemented by rewriting the front-end, and new target machines by rewriting the back-end. ",
209
+ "bbox": [
210
+ 173,
211
+ 895,
212
+ 823,
213
+ 924
214
+ ],
215
+ "page_idx": 1
216
+ },
217
+ {
218
+ "type": "image",
219
+ "img_path": "images/a3fb548bd758d8295d507b87b8ee73f25aab1c16584606dce010463f0238d398.jpg",
220
+ "image_caption": [
221
+ "Figure 2: A bird’s eye view of a compiler toolchain, exemplified with LLVM. The unoptimized version $( - 0 0 )$ is shown here for illustration. In practice we used the size-optimized version $( - \\mathsf { O z } )$ of the IR as boxed, which does the compile time optimization of computing the addition of 26 and 16. "
222
+ ],
223
+ "image_footnote": [],
224
+ "bbox": [
225
+ 174,
226
+ 103,
227
+ 823,
228
+ 208
229
+ ],
230
+ "page_idx": 2
231
+ },
232
+ {
233
+ "type": "text",
234
+ "text": "",
235
+ "bbox": [
236
+ 174,
237
+ 304,
238
+ 823,
239
+ 347
240
+ ],
241
+ "page_idx": 2
242
+ },
243
+ {
244
+ "type": "text",
245
+ "text": "Several IRs usually co-exist in a compiler: each stage in the toolchain (Figure 2) introduces a new representation. Early stage IRs are language-dependent (e.g. ASTs mirror the syntax of the source language). Late stage IRs replace named variables by registers and reflect the specifics of the target architecture. In this work, we are interested in middle-end IRs, which are independent from the target machine, and similar for all source languages (like dialects in natural languages). ",
246
+ "bbox": [
247
+ 174,
248
+ 353,
249
+ 825,
250
+ 424
251
+ ],
252
+ "page_idx": 2
253
+ },
254
+ {
255
+ "type": "text",
256
+ "text": "3 TRAINING OBJECTIVES ",
257
+ "text_level": 1,
258
+ "bbox": [
259
+ 176,
260
+ 444,
261
+ 398,
262
+ 460
263
+ ],
264
+ "page_idx": 2
265
+ },
266
+ {
267
+ "type": "text",
268
+ "text": "Unsupervised machine translation consists of learning multilingual sequence embeddings, and generating sequence in any output language from these embeddings (Lample et al., 2018a). We now present the objective functions for these tasks. In section 3.1, we review the three basic objectives used by TransCoder, our baseline NMT system. In section 3.2, we introduce three new functions that leverage LLVM IRs to improve the multilingual representation of source code, and the performance of our translation models. During training, we alternate between all six objectives, running each for the same number of optimisation steps. At inference, the model is only provided with the source code, i.e. the IR is not needed. ",
269
+ "bbox": [
270
+ 173,
271
+ 477,
272
+ 825,
273
+ 589
274
+ ],
275
+ "page_idx": 2
276
+ },
277
+ {
278
+ "type": "text",
279
+ "text": "Formally, let $x = x _ { 1 } \\ldots x _ { N _ { s o } }$ be the source sentence, $z ^ { ( x ) } = z _ { 1 } ^ { ( x ) } \\dots z _ { N _ { i r } } ^ { ( x ) }$ the corresponding IR, and $y = y _ { 1 } \\dots y _ { N _ { t a } } $ the target sentence. We write $\\begin{array} { r } { \\mathcal { L } _ { C E } ( \\hat { y } , y ) = \\sum _ { i } \\ell _ { C E } ( \\ddot { y } _ { i } , y _ { i } ) } \\end{array}$ , with $\\ell _ { C E } ( \\hat { y } _ { i } , y _ { i } )$ the pairwise cross-entropy loss between $\\hat { y } _ { i }$ and $y _ { i }$ . We define the machine translation loss (or seq2seq loss) from $x$ to $y$ , $\\mathcal { L } _ { M T }$ as the sum of the negative log-likelihood of each token $y _ { i }$ , given $x$ and previous tokens $y _ { 0 } \\ldots y _ { i - 1 }$ (note that $x$ and $y$ can have different lengths) : ",
280
+ "bbox": [
281
+ 173,
282
+ 594,
283
+ 825,
284
+ 670
285
+ ],
286
+ "page_idx": 2
287
+ },
288
+ {
289
+ "type": "equation",
290
+ "img_path": "images/67e27b13a5225e3092af07df97dfe5fc2727543895d151e9cf5e51c620a916d7.jpg",
291
+ "text": "$$\n\\mathcal { L } _ { M T } ( x , y ) = - \\sum _ { i } \\log \\left( P ( y _ { i } | x , y _ { 1 } \\ldots y _ { i - 1 } ) \\right)\n$$",
292
+ "text_format": "latex",
293
+ "bbox": [
294
+ 344,
295
+ 678,
296
+ 651,
297
+ 712
298
+ ],
299
+ "page_idx": 2
300
+ },
301
+ {
302
+ "type": "text",
303
+ "text": "3.1 COMMON OBJECTIVE FUNCTIONS",
304
+ "text_level": 1,
305
+ "bbox": [
306
+ 176,
307
+ 727,
308
+ 446,
309
+ 741
310
+ ],
311
+ "page_idx": 2
312
+ },
313
+ {
314
+ "type": "text",
315
+ "text": "TransCoder (Roziere et al., 2020) learns to translate between programming languages by leveraging three unsupervised objectives developed for natural language (Lample et al., 2018b): ",
316
+ "bbox": [
317
+ 171,
318
+ 753,
319
+ 823,
320
+ 782
321
+ ],
322
+ "page_idx": 2
323
+ },
324
+ {
325
+ "type": "text",
326
+ "text": "Masked Language Modeling (MLM) trains an encoder to predict randomly masked inputs. It is commonly used to pre-train embeddings for natural (Devlin et al., 2018; Liu et al., 2019) and programming languages (Kanade et al., 2020; Feng et al., 2020). MLM allows the model to learn the syntax and semantics of programs. Alternative objectives, have been proposed for programming languages (Guo et al., 2020; Lachaux et al., 2021; Ahmad et al., 2021; Wang et al., 2021). We do not use them here, as MLM remains effective and easy to use on a wide range of programming languages. ",
327
+ "bbox": [
328
+ 173,
329
+ 787,
330
+ 825,
331
+ 873
332
+ ],
333
+ "page_idx": 2
334
+ },
335
+ {
336
+ "type": "text",
337
+ "text": "Denoting $m a s k ( x )$ the masked version of the code sentence $x$ , and $e n c ( t )$ the encoder output, MLM uses the following loss: ",
338
+ "bbox": [
339
+ 169,
340
+ 878,
341
+ 825,
342
+ 907
343
+ ],
344
+ "page_idx": 2
345
+ },
346
+ {
347
+ "type": "equation",
348
+ "img_path": "images/29fae3ff36f24cf6fe7117e7f760781374714a7347684948f7df9c71ee9548fd.jpg",
349
+ "text": "$$\n\\mathcal { L } _ { M L M } = \\mathcal { L } _ { C E } \\left( e n c ( m a s k ( x ) ) , x \\right) .\n$$",
350
+ "text_format": "latex",
351
+ "bbox": [
352
+ 377,
353
+ 909,
354
+ 620,
355
+ 925
356
+ ],
357
+ "page_idx": 2
358
+ },
359
+ {
360
+ "type": "image",
361
+ "img_path": "images/90a5e988f3483d0037d74465b54b9b166b3ff5748a8ee26c21d112bfb591a3fc.jpg",
362
+ "image_caption": [
363
+ "Figure 3: IR for code representation objectives. We show examples of masking (used in TLM and TAE) and IR generation used to improve code representations with IRs. The masking objective in TLM or TAE makes the model understand the relationship between code and IR. The IR generation objective helps the model to build semantic representations of the code. For instance, another $\\mathrm { C } { + + }$ function computing $3 9 \\ + \\ 3$ would result in the same IR. A Go function that returns 42 would also have a similar LLVM IR. Therefore, the IR Generation objective encourages the model to build similar representations for these three semantically equivalent functions. "
364
+ ],
365
+ "image_footnote": [],
366
+ "bbox": [
367
+ 174,
368
+ 119,
369
+ 825,
370
+ 349
371
+ ],
372
+ "page_idx": 3
373
+ },
374
+ {
375
+ "type": "text",
376
+ "text": "Denoising Auto Encoding (AE) trains a sequence to sequence (seq2seq) model to retrieve an original sequence from a corrupted version. Corruption is done by masking spans of tokens randomly sampled from a Poisson distribution, as well as removing and shuffling tokens. It uses the following loss $( n o i s e ( x )$ denotes the corrupted version of $x$ ): ",
377
+ "bbox": [
378
+ 174,
379
+ 458,
380
+ 825,
381
+ 515
382
+ ],
383
+ "page_idx": 3
384
+ },
385
+ {
386
+ "type": "equation",
387
+ "img_path": "images/1477506c8deee4b7fbb71a998023732aef2cc9c3a8db923d0e7d2fd849eb9489.jpg",
388
+ "text": "$$\n\\mathcal { L } _ { A E } = \\mathcal { L } _ { M T } \\left( n o i s e ( x ) , x \\right) .\n$$",
389
+ "text_format": "latex",
390
+ "bbox": [
391
+ 401,
392
+ 523,
393
+ 596,
394
+ 541
395
+ ],
396
+ "page_idx": 3
397
+ },
398
+ {
399
+ "type": "text",
400
+ "text": "Back-Translation (BT). Back-Translation (Sennrich et al., 2015) uses the model to generate a noisy translation of the input sentence, and then trains the model to recover the original input from the translation. It is a simple yet powerful objective for unsupervised machine translation (Lample et al., 2018a; Artetxe et al., 2018). In practice, it is a required loss to get competitive performance, so it is a staple of all our experiments. Formally, we use the model to translate sequence $x$ into $\\hat { y }$ and train the model to reverse the translation process, using the loss: ",
401
+ "bbox": [
402
+ 173,
403
+ 555,
404
+ 825,
405
+ 641
406
+ ],
407
+ "page_idx": 3
408
+ },
409
+ {
410
+ "type": "equation",
411
+ "img_path": "images/7e15dcea4c48b75ca7907c02567b65df35da89817d5747f2b5a9df593cc756ce.jpg",
412
+ "text": "$$\n\\mathcal { L } _ { B T } = \\mathcal { L } _ { M T } \\left( \\hat { y } , x \\right)\n$$",
413
+ "text_format": "latex",
414
+ "bbox": [
415
+ 431,
416
+ 648,
417
+ 566,
418
+ 666
419
+ ],
420
+ "page_idx": 3
421
+ },
422
+ {
423
+ "type": "text",
424
+ "text": "3.2 IR FOR CODE REPRESENTATIONS ",
425
+ "text_level": 1,
426
+ "bbox": [
427
+ 176,
428
+ 684,
429
+ 441,
430
+ 698
431
+ ],
432
+ "page_idx": 3
433
+ },
434
+ {
435
+ "type": "text",
436
+ "text": "Intermediate representations (IR) provide additional information about the code to be translated. We add them to the training dataset, as described in section 4.2, and leverage them by adding three new objective functions to those described in section 3.1. ",
437
+ "bbox": [
438
+ 174,
439
+ 710,
440
+ 825,
441
+ 753
442
+ ],
443
+ "page_idx": 3
444
+ },
445
+ {
446
+ "type": "text",
447
+ "text": "Translation Language Modeling (TLM), first introduced in Lample and Conneau (2019), strives at generating common representations for parallel sentences in different languages. Like the masked language modeling (MLM) objective, it trains an encoder to predict random masked inputs. However, TLM is trained on pairs of parallel sentences, concatenated together and separated by a special token. Here, we concatenate functions in their source language and their corresponding IR, using the source code and IR language embeddings, and train the encoder to predict randomly masked tokens. This allows the model to learn correspondences between the source and the IR. The corresponding loss is ( $\\oplus$ denotes concatenation): ",
448
+ "bbox": [
449
+ 173,
450
+ 770,
451
+ 826,
452
+ 882
453
+ ],
454
+ "page_idx": 3
455
+ },
456
+ {
457
+ "type": "equation",
458
+ "img_path": "images/a00ae687357974f6d98dcf75658ac3e028243c152551284da61c1deb1abdd7ae.jpg",
459
+ "text": "$$\n\\mathcal { L } _ { T L M } = \\mathcal { L } _ { C E } \\left( m a s k ( x \\oplus z ^ { ( x ) } ) , x \\oplus z ^ { ( x ) } \\right)\n$$",
460
+ "text_format": "latex",
461
+ "bbox": [
462
+ 351,
463
+ 901,
464
+ 645,
465
+ 929
466
+ ],
467
+ "page_idx": 3
468
+ },
469
+ {
470
+ "type": "image",
471
+ "img_path": "images/c6d5185f61ecb1d679f8470f8bb5d4104b7692dffb819bb4c91a810f5d2df200.jpg",
472
+ "image_caption": [
473
+ "Figure 4: IR Decompilation objective. Here, we generate the IR corresponding to each function and train a model to decompile it. The IR pivot model uses this objective, as well as back-translation objectives, allowing it generalize to IRs generated from any language. "
474
+ ],
475
+ "image_footnote": [],
476
+ "bbox": [
477
+ 173,
478
+ 77,
479
+ 825,
480
+ 174
481
+ ],
482
+ "page_idx": 4
483
+ },
484
+ {
485
+ "type": "text",
486
+ "text": "Translation Auto-Encoding (TAE) amounts to transposing the TLM objective into a denoising auto-encoder. The source code and corresponding IR are corrupted and masked, and then concatenated into one sequence (using the language embeddings for code and IR, as previously). TAE is then tasked to recover the original, using the following loss: ",
487
+ "bbox": [
488
+ 174,
489
+ 268,
490
+ 825,
491
+ 325
492
+ ],
493
+ "page_idx": 4
494
+ },
495
+ {
496
+ "type": "equation",
497
+ "img_path": "images/c7454aefe570e7c6e4bca1ec79ea535cba3debd650acdb8eb85ad2b88385c2be.jpg",
498
+ "text": "$$\n\\mathcal { L } _ { T A E } = \\mathcal { L } _ { M T } \\left( n o i s e ( x ) \\oplus n o i s e ( z ^ { ( x ) } ) , x \\oplus z ^ { ( x ) } \\right)\n$$",
499
+ "text_format": "latex",
500
+ "bbox": [
501
+ 325,
502
+ 337,
503
+ 671,
504
+ 363
505
+ ],
506
+ "page_idx": 4
507
+ },
508
+ {
509
+ "type": "text",
510
+ "text": "IR Generation (MT) trains the model to translate the source code into the corresponding IR. This allows the encoder to learn source code representations from the semantics of the IR. The loss is: ",
511
+ "bbox": [
512
+ 171,
513
+ 381,
514
+ 823,
515
+ 410
516
+ ],
517
+ "page_idx": 4
518
+ },
519
+ {
520
+ "type": "equation",
521
+ "img_path": "images/44de55a84e4c90f4f2f3862fad436ccd311d8ada7b923bd3ea22062da99d4b27.jpg",
522
+ "text": "$$\n\\mathcal { L } _ { I R G e n } = \\mathcal { L } _ { M T } \\left( x , z ^ { ( x ) } \\right)\n$$",
523
+ "text_format": "latex",
524
+ "bbox": [
525
+ 408,
526
+ 433,
527
+ 588,
528
+ 459
529
+ ],
530
+ "page_idx": 4
531
+ },
532
+ {
533
+ "type": "text",
534
+ "text": "These three objectives need both the source code and the corresponding IR. However, only a fraction of the functions and files in our dataset could be compiled. To mitigate this, we also train the models on the full monolingual data using the MLM and AE objectives described above. In this setup, the back-translation (BT) objective is the same as in Roziere et al. (2020), and allows our model to translate directly from source code only at inference time. ",
535
+ "bbox": [
536
+ 173,
537
+ 474,
538
+ 825,
539
+ 545
540
+ ],
541
+ "page_idx": 4
542
+ },
543
+ {
544
+ "type": "text",
545
+ "text": "3.3 ADDITIONAL LOSSES: IR DECOMPILATION AND PIVOT ",
546
+ "text_level": 1,
547
+ "bbox": [
548
+ 173,
549
+ 565,
550
+ 596,
551
+ 582
552
+ ],
553
+ "page_idx": 4
554
+ },
555
+ {
556
+ "type": "text",
557
+ "text": "We study two alternative uses of intermediary representations: IR decompilation, and IR pivot translation. IR decompilation consists of recovering source code corresponding to a given IR. In practice, it reverses the computations performed by the compiler. IR Pivot is a translation method built upon IR decompilation. Since LLVM can compile many languages $( \\mathbf { C } + +$ , Java, Rust, Go) into the same IR, an obvious approach to code translation consists of decompiling the IR generated from the source language into code in the target language. We call this method “IR pivot”. Note that, whereas the IR for code representation techniques only used IR during training, both the decompilation and pivot method also need the IR for inference. ",
558
+ "bbox": [
559
+ 173,
560
+ 593,
561
+ 825,
562
+ 707
563
+ ],
564
+ "page_idx": 4
565
+ },
566
+ {
567
+ "type": "text",
568
+ "text": "Decompilation. In this supervised task, we use LLVM to generate IR from source code, and train a language model to reverse the process, i.e. learn to predict the source code from the IR. Models are pre-trained using the MLM and AE objectives, and decompilation is learned using the machine translation loss: ",
569
+ "bbox": [
570
+ 173,
571
+ 726,
572
+ 825,
573
+ 781
574
+ ],
575
+ "page_idx": 4
576
+ },
577
+ {
578
+ "type": "equation",
579
+ "img_path": "images/2ce80764eb26a8059393b072022f99d73253f0c2c863d83b95f7d1a89d55b3ef.jpg",
580
+ "text": "$$\n\\mathcal { L } _ { D e c o m p } = \\mathcal { L } _ { M T } \\left( z ^ { ( x ) } , x \\right)\n$$",
581
+ "text_format": "latex",
582
+ "bbox": [
583
+ 405,
584
+ 784,
585
+ 591,
586
+ 810
587
+ ],
588
+ "page_idx": 4
589
+ },
590
+ {
591
+ "type": "text",
592
+ "text": "IR Pivot. This task leverages the IR as a pivot for code translation. For instance, to translate from Rust to $\\mathrm { C } { + } { + }$ , we first use LLVM to compile a Rust program into IR and then decompile the IR to $\\mathrm { C } { + } { + }$ using a neural decompiler. In practice, slight variations exists between the IR generated for different languages: the Rust-IR and $\\mathrm { C } { + + }$ -IR behave like dialects of the LLVM-IR. This often leads to poor performance of the IR Pivot method. We mitigate these issues using a variety of techniques, which we describe in section C of the appendix. ",
593
+ "bbox": [
594
+ 173,
595
+ 839,
596
+ 825,
597
+ 924
598
+ ],
599
+ "page_idx": 4
600
+ },
601
+ {
602
+ "type": "text",
603
+ "text": "4 DATA ",
604
+ "text_level": 1,
605
+ "bbox": [
606
+ 174,
607
+ 102,
608
+ 251,
609
+ 117
610
+ ],
611
+ "page_idx": 5
612
+ },
613
+ {
614
+ "type": "text",
615
+ "text": "4.1 TRAINING DATA ",
616
+ "text_level": 1,
617
+ "bbox": [
618
+ 174,
619
+ 126,
620
+ 328,
621
+ 140
622
+ ],
623
+ "page_idx": 5
624
+ },
625
+ {
626
+ "type": "text",
627
+ "text": "Our training data was extracted with Google BigQuery, which indexes over 2.8 million open source repositories from $\\mathrm { G i t H u b } ^ { 2 }$ . We selected projects whose license explicitly permits re-distribution of parts, and extracted all individual $\\mathrm { C } { + } { + }$ , Java, Rust and Go functions. To learn to decompile IRs, we also used the CodeNet dataset (Puri et al., 2021), a repository of 14 million competitive programming solutions in 55 languages. Our models work at function level: this reduces compilation failures over missing dependencies, while keeping sequence lengths short. ",
628
+ "bbox": [
629
+ 173,
630
+ 145,
631
+ 825,
632
+ 229
633
+ ],
634
+ "page_idx": 5
635
+ },
636
+ {
637
+ "type": "table",
638
+ "img_path": "images/5076cb2e53897509ca7243fa573292c5a46aae9242e6fb78828275446d8fd261.jpg",
639
+ "table_caption": [
640
+ "Table 1: Dataset coverage across languages, in number of standalone functions. More details can be found in Table 7 in the appendix. "
641
+ ],
642
+ "table_footnote": [],
643
+ "table_body": "<table><tr><td></td><td>C++</td><td>Go</td><td>Java</td><td>Rust</td></tr><tr><td>Monolingual data</td><td>6.6M</td><td>9.4 M</td><td>7.8M</td><td>576.3K</td></tr><tr><td>Code/IRParallel Data</td><td>344.4 K</td><td>384.4K</td><td>2.2 M</td><td>19.2 K</td></tr><tr><td>Successful IR Compilation</td><td>5.2%</td><td>4.1%</td><td>28.2%</td><td>3.3%</td></tr></table>",
644
+ "bbox": [
645
+ 281,
646
+ 281,
647
+ 707,
648
+ 344
649
+ ],
650
+ "page_idx": 5
651
+ },
652
+ {
653
+ "type": "text",
654
+ "text": "4.2 GENERATING INTERMEDIATE REPRESENTATIONS ",
655
+ "text_level": 1,
656
+ "bbox": [
657
+ 173,
658
+ 352,
659
+ 555,
660
+ 366
661
+ ],
662
+ "page_idx": 5
663
+ },
664
+ {
665
+ "type": "text",
666
+ "text": "While the LLVM ecosystem is large, not every language has an LLVM front-end, and not every front-end can produce LLVM IR out-of-the-box. We use $\\mathsf { c } \\mathtt { l a n g } + + \\mathbf { \\lambda } ^ { 3 }$ Lattner and Adve (2004) from the established LLVM $\\mathrm { C } { + + }$ compilation toolchain, JLang4 for Java, Gollvm5 for Go and rustc Matsakis and Klock II (2014) for Rust. For the same program, written in different languages, different front-ends may produce different IR. To minimize these variations, we process the source code as follows. First, we generate the most size-optimized IR (- ${ \\bf \\nabla } \\cdot O z$ flag), which makes the IR more uniform across languages. Second, we strip all unnecessary information (e.g. header and footer with attributes, debug information, comments). Finally, block names are canonicalized and symbol names demangled to facilitate their recovery. The functions that fail to compile at this point (e.g. because of missing dependencies) are not included in the parallel dataset, as seen in the last row of Table 1. ",
667
+ "bbox": [
668
+ 173,
669
+ 369,
670
+ 825,
671
+ 508
672
+ ],
673
+ "page_idx": 5
674
+ },
675
+ {
676
+ "type": "text",
677
+ "text": "4.3 EVALUATION ",
678
+ "text_level": 1,
679
+ "bbox": [
680
+ 174,
681
+ 526,
682
+ 305,
683
+ 540
684
+ ],
685
+ "page_idx": 5
686
+ },
687
+ {
688
+ "type": "text",
689
+ "text": "Traditional NMT evaluation relies on metrics such as BLEU, that are based on n-gram overlaps. However, when dealing with programming languages, syntax and in particular compilation and computation outputs can differ widely despite minor changes in the code. Conversely, semantically equivalent code, that differ only in variable names or order of operations can have a low BLEU score. To take this into account, we use and enhance the computational accuracy test suite from Roziere et al. (2020), that contains 852 parallel competitive programming solutions in $\\mathrm { C } { + + }$ , Java and Python. Using C2Rust, $\\mathbf { \\boldsymbol { C } } \\mathbf { \\boldsymbol { x } } \\mathbf { \\boldsymbol { G } } \\mathbf { \\boldsymbol { 0 } }$ and some manual code cleaning, we translated 280 functions and test suites in Rust and 343 in Go to measure the performance of our models in these languages. We measure our performance using the computational accuracy $\\left( \\mathbf { C A @ 1 } \\right)$ metric (Kulal et al., 2019; Roziere et al., 2020), which considers that a translation is correct if it passes a series of unit tests. ",
690
+ "bbox": [
691
+ 173,
692
+ 545,
693
+ 826,
694
+ 684
695
+ ],
696
+ "page_idx": 5
697
+ },
698
+ {
699
+ "type": "text",
700
+ "text": "5 RESULTS ",
701
+ "text_level": 1,
702
+ "bbox": [
703
+ 174,
704
+ 704,
705
+ 281,
706
+ 720
707
+ ],
708
+ "page_idx": 5
709
+ },
710
+ {
711
+ "type": "text",
712
+ "text": "5.1 EXPERIMENTAL DETAILS ",
713
+ "text_level": 1,
714
+ "bbox": [
715
+ 174,
716
+ 729,
717
+ 388,
718
+ 743
719
+ ],
720
+ "page_idx": 5
721
+ },
722
+ {
723
+ "type": "text",
724
+ "text": "For TransCoder, we consider a sequence-to-sequence (seq2seq) transformer model (Vaswani et al., 2017) with attention (Bahdanau et al., 2015; Sutskever et al., 2014) and the same architecture as Roziere et al. (2020). Our model has 12 layers (6 in the encoder and 6 in the decoder), 8 attention heads, and a dimension of 1024. For the objectives that add noise and masks to the input sentence, such as MLM, TLM, AE, and TAE, we choose the masked tokens and noise randomly on the fly at each epoch. We mask $15 \\%$ of the tokens in MLM and TLM. In AE and TAE, we mask $20 \\%$ of the tokens. MLM is trained on streams of data, while the other objectives are trained at function level. We use the Adam optimizer (Kingma and Ba, 2015) and an inverse squared-root learning rate scheduler, with an initial learning rate of $1 0 ^ { - 5 }$ in most of our experiments. Our models are implemented in PyTorch using mixed-precision floats. The pre-trained models were trained until convergence. The translation models presented in Tables 2 and 3 were trained for a week on 32 NVIDIA V100 GPUs. ",
725
+ "bbox": [
726
+ 174,
727
+ 748,
728
+ 825,
729
+ 845
730
+ ],
731
+ "page_idx": 5
732
+ },
733
+ {
734
+ "type": "table",
735
+ "img_path": "images/651fa4a2e3e81efd640052f4f33fcf41d8f0875c0ad82731059fb63ae694de7a.jpg",
736
+ "table_caption": [
737
+ "Table 2: Translation performance $( \\mathbf { C A } @ \\mathbf { 1 } )$ , for greedy decoding and beam size 5. “To $X ^ { \\ast }$ : average performance when translating to language X. “From $X ^ { \\ast }$ : average performance when translating from language X. See Table 3 in the appendix for more detailed results. All these methods except for the IR pivot also use the three objectives defined in TransCoder: MLM, DAE and Back-Translation (BT). All combinations of the TLM, MT and TAE objectives improve the performance compared to TransCoder. The best results are obtained when all three are used at the same time. Beam search, using beam size 5 and returning only the top element from the beam results in improved performance. The IR Pivot method generates a translation in the target language from an IR generated from the source, and performs poorly in our setting. "
738
+ ],
739
+ "table_footnote": [],
740
+ "table_body": "<table><tr><td></td><td>from C++ to C++ from Go to Go from Java to Java from Rust to Rust</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>AVG</td></tr><tr><td>Greedy decoding</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>IR Pivot</td><td>17.4</td><td>24.0</td><td>19.9</td><td>11.5</td><td>11.9</td><td>22.2</td><td>16.3</td><td>7.8</td><td>16.4</td></tr><tr><td>TransCoder (baseline)</td><td>46.4</td><td>52.1</td><td>42.1</td><td>45.6</td><td>41.2</td><td>44.5</td><td>29.6</td><td>17.0</td><td>39.8</td></tr><tr><td>TLM</td><td>47.5</td><td>54.8</td><td>45.4</td><td>41.2</td><td>39.8</td><td>52.1</td><td>31.1</td><td>15.7</td><td>40.9</td></tr><tr><td>MLM+ TAE</td><td>47.3</td><td>53.3</td><td>47.2</td><td>44.8</td><td>41.8</td><td>45.9</td><td>25.1</td><td>17.4</td><td>40.4</td></tr><tr><td>TLM+TAE</td><td>46.9</td><td>55.9</td><td>45.0</td><td>37.9</td><td>38.5</td><td>54.5</td><td>34.9</td><td>16.8</td><td>41.3</td></tr><tr><td>MLM+MT</td><td>45.5</td><td>51.0</td><td>44.0</td><td>48.9</td><td>46.6</td><td>45.2</td><td>25.7</td><td>16.6</td><td>40.5</td></tr><tr><td>TLM + MT</td><td>45.6</td><td>51.5</td><td>45.1</td><td>47.1</td><td>46.9</td><td>45.5</td><td>24.4</td><td>17.9</td><td>40.5</td></tr><tr><td>TAE +MT</td><td>47.8</td><td>54.3</td><td>43.8</td><td>43.9</td><td>39.1</td><td>49.2</td><td>33.4</td><td>16.7</td><td>41.0</td></tr><tr><td>TLM + TAE +MT</td><td>47.8</td><td>54.3</td><td>46.6</td><td>51.6</td><td>47.1</td><td>49.6</td><td>35.3</td><td>21.4</td><td>44.2</td></tr><tr><td>Beam size 5</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>TransCoder (baseline)</td><td>53.8</td><td>53.4</td><td>45.2</td><td>54.4</td><td>46.1</td><td>51.5</td><td>35.9</td><td>20.9</td><td>45.3</td></tr><tr><td>TLM + TAE +MT</td><td>52.9</td><td>53.5</td><td>48.8</td><td>57.1</td><td>51.5</td><td>53.4</td><td>37.9</td><td>27.1</td><td>47.8</td></tr></table>",
741
+ "bbox": [
742
+ 169,
743
+ 220,
744
+ 828,
745
+ 439
746
+ ],
747
+ "page_idx": 6
748
+ },
749
+ {
750
+ "type": "text",
751
+ "text": "",
752
+ "bbox": [
753
+ 173,
754
+ 450,
755
+ 825,
756
+ 507
757
+ ],
758
+ "page_idx": 6
759
+ },
760
+ {
761
+ "type": "text",
762
+ "text": "5.2 IR-AUGMENTED CODE REPRESENTATIONS FOR TRANSLATION ",
763
+ "text_level": 1,
764
+ "bbox": [
765
+ 174,
766
+ 527,
767
+ 642,
768
+ 541
769
+ ],
770
+ "page_idx": 6
771
+ },
772
+ {
773
+ "type": "text",
774
+ "text": "Models using combinations of the three objectives—TAE, TLM and MT—introduced to leverage IR, were trained to translate between pairs of four languages $\\scriptstyle ( + +$ , Java, Rust, Go). Their average performance when translating to and from every language are presented in table 2. Additional information, including a comparison to TransCoder-ST for $\\mathrm { C } { + } { + } $ Java, can be found in Table 3) in the appendix. As a baseline, we use a TransCoder (Roziere et al., 2020) model, trained with MLM on the same dataset. ",
775
+ "bbox": [
776
+ 174,
777
+ 549,
778
+ 825,
779
+ 633
780
+ ],
781
+ "page_idx": 6
782
+ },
783
+ {
784
+ "type": "text",
785
+ "text": "Using greedy decoding, the new TLM, TAE and MT objectives, which leverage the IR, improve performance for every language. The best average results are obtained when combining all of them. Compared to TransCoder, they improve performance by an average $4 . 4 \\%$ point ( $1 1 \\%$ relative). The largest impacts are observed in the low data regime: translations from and into Rust (a language less represented in our training set) are improved by $2 5 . 6 \\%$ and $1 9 . 3 \\%$ (relative). Beam search improves the results of both TransCoder and our models, using IR-augmented representation still results in better performance. Qualitatively, we observe that IRs help our model translate types when the source and target types are represented by different tokens. For instance, in the first example of Table 1, it translates the semantics of int correctly using $\\pm 3 2$ instead of an unsigned integer type (usize). See Appendix H for more analysis on how our objectives improve word embeddings. ",
786
+ "bbox": [
787
+ 174,
788
+ 640,
789
+ 825,
790
+ 780
791
+ ],
792
+ "page_idx": 6
793
+ },
794
+ {
795
+ "type": "text",
796
+ "text": "Compared to IR-augmented translation models, the “obvious” IR Pivot method proves disappointing, even though it achieves non-trivial performances. It is heavily dependent on the size of the training set: the IR pivot performs relatively well when translating from low-resource to high-resource languages (e.g. from Rust), and badly when translating to low-resource languages (e.g. to Rust). ",
797
+ "bbox": [
798
+ 174,
799
+ 786,
800
+ 825,
801
+ 843
802
+ ],
803
+ "page_idx": 6
804
+ },
805
+ {
806
+ "type": "text",
807
+ "text": "5.3 DECOMPILATION RESULTS ",
808
+ "text_level": 1,
809
+ "bbox": [
810
+ 174,
811
+ 862,
812
+ 398,
813
+ 876
814
+ ],
815
+ "page_idx": 6
816
+ },
817
+ {
818
+ "type": "text",
819
+ "text": "To compute the IR pivot, we trained a neural decompiler to retrieve source code from IRs. We tried two separate configurations for decompilation: a shared decoder with 6 layers for all language / IR pairs, or four separate decoders of with two layers each (one per language). Using a shared decoder improves the performance for all languages, and particularly when the data is scarce (e.g. Rust). See Table 5 in the appendix for more information. ",
820
+ "bbox": [
821
+ 176,
822
+ 882,
823
+ 823,
824
+ 924
825
+ ],
826
+ "page_idx": 6
827
+ },
828
+ {
829
+ "type": "text",
830
+ "text": "",
831
+ "bbox": [
832
+ 173,
833
+ 103,
834
+ 823,
835
+ 132
836
+ ],
837
+ "page_idx": 7
838
+ },
839
+ {
840
+ "type": "text",
841
+ "text": "We compare the performance of our model to RetDec (Kˇroustek et al., 2017), a rule-based decompiler. It obtains a computational accuracy of 68.75 on our $\\mathrm { C } { + + }$ dataset and a BLEU score of 8.54. In comparison, our model obtains a computational accuracy of 77.9 and a BLEU score of 63.6 in the same setting. In particular, RetDec fails to decompile LLVM files generated from $\\mathrm { C } { + } { + }$ code, especially snippets leveraging the standard library structures such as unordered_map or $s t d :$ allocator. The limitations of RetDec, which was implemented by a team of 24 developers in 7 years 6, shows how difficult it is to build exhaustive rule-based decompilers, especially when the IR comes from different languages or tools. ",
842
+ "bbox": [
843
+ 174,
844
+ 138,
845
+ 825,
846
+ 251
847
+ ],
848
+ "page_idx": 7
849
+ },
850
+ {
851
+ "type": "text",
852
+ "text": "6 DISCUSSION ",
853
+ "text_level": 1,
854
+ "bbox": [
855
+ 174,
856
+ 271,
857
+ 310,
858
+ 287
859
+ ],
860
+ "page_idx": 7
861
+ },
862
+ {
863
+ "type": "text",
864
+ "text": "Different IR and interpreted languages The four languages considered in this work have frontends that can output LLVM Intermediary Representation. LLVM presently covers more than 30 computer languages. Using IR as pivot requires that the source and destination language have front-ends that use the same IR. This rules out some widely-used languages (e.g. Python). Using the IR to improve embeddings is less restrictive: the source and destination language can be trained on different IR, and aligned with back-translation. In this paper, we focus on compiled languages, but it is important to note that Intermediary Representations are usually available for interpreted languages as well: modern interpreters translate the source code into byte-code, that can serve as an IR. ",
865
+ "bbox": [
866
+ 174,
867
+ 303,
868
+ 825,
869
+ 414
870
+ ],
871
+ "page_idx": 7
872
+ },
873
+ {
874
+ "type": "text",
875
+ "text": "Pivot vs Embedding TransCoder is an unsupervised model that learns to align code representations and translate code from one language to another. It is based solely on source code and does not use IRs. The pivot method uses automatically generated parallel sentences to learn to decompile IRs, and back-translation to adapt to different IR dialects. This method learns to translate using only IR-level similarities, and does not use the source code itself except to compute the IR. Although it underperforms other methods, it performs relatively well when little data is available for the source language, because the IR can be computed using a rule-based compiler. However, it requires to compute IRs at test time, which can be cumbersome. Instead, adding the TLM, TAE, and MT objectives to the objectives generally used for unsupervised code translation allows the model to get the best of both worlds. It can learn multilingual representations of source code from similarities in the IR and in the source code itself. As shown in Table 2, it outperforms both TransCoder and the pivot method. At the same time, this model does not require to compute IRs at test time, and is as easy to use as TransCoder. ",
876
+ "bbox": [
877
+ 174,
878
+ 429,
879
+ 825,
880
+ 609
881
+ ],
882
+ "page_idx": 7
883
+ },
884
+ {
885
+ "type": "text",
886
+ "text": "Using our model at inference time. Our self-supervised IR-augmented TLM, TAE and MT objectives are designed to improve the multilingual code representations used in translation models. However, the translation task does not require to compute these objectives. Therefore, they lead to models that are just as simple to use as TransCoder: computing the IR is not required at test time and the model generates the translation directly from the source function. ",
887
+ "bbox": [
888
+ 174,
889
+ 626,
890
+ 825,
891
+ 695
892
+ ],
893
+ "page_idx": 7
894
+ },
895
+ {
896
+ "type": "text",
897
+ "text": "7 RELATED WORKS ",
898
+ "text_level": 1,
899
+ "bbox": [
900
+ 176,
901
+ 715,
902
+ 354,
903
+ 732
904
+ ],
905
+ "page_idx": 7
906
+ },
907
+ {
908
+ "type": "text",
909
+ "text": "Source-to-Source Translation. Many rule-based methods are available for transpilation, an inventory of which can be found online1. In particular, ${ \\mathrm { C } } 2 { \\mathrm { R u s t } } ^ { 7 }$ and $\\mathrm { C x G o } ^ { 8 }$ , along with manual corrections, were central for us in translating evaluation tests to Go and Rust (See Section 4.3). Similarly, $2 \\mathrm { t o } 3 ^ { 9 }$ , a Python library porting Python 2 code to Python 3, was used in Aggarwal et al. (2015) to create a parallel dataset and train a machine learning model. ",
910
+ "bbox": [
911
+ 174,
912
+ 741,
913
+ 826,
914
+ 810
915
+ ],
916
+ "page_idx": 7
917
+ },
918
+ {
919
+ "type": "text",
920
+ "text": "Neural Machine Translation for code is hampered by the lack of parallel data between programming languages. Indeed, apart from a few language pairs, such as Java-C# (Nguyen et al., 2013; Chen et al., 2018), and specific domains (e.g. competitive programming code), it is difficult to collect large datasets of semantically equivalent code in different languages. TransCoder (Roziere et al., 2020) bridges this gap by introducing unsupervised machine translation to programming languages. They take advantage of large monolingual code bases to learn to translate between $\\mathrm { C } { + } { + }$ , Python and Java with high performance. Later, DOBF (Lachaux et al., 2021) improved the model pre-training method used in TransCoder, and Roziere et al. (2022) used automatically generated unit tests to improve translation performance between Java, $\\mathrm { C } { + } { + }$ and Python. Recently, large language models trained on code, such as Codex (Chen et al., 2021) and PALM (Chowdhery et al., 2022), have been used for unsupervised code translation. ",
921
+ "bbox": [
922
+ 173,
923
+ 818,
924
+ 823,
925
+ 847
926
+ ],
927
+ "page_idx": 7
928
+ },
929
+ {
930
+ "type": "text",
931
+ "text": "",
932
+ "bbox": [
933
+ 174,
934
+ 103,
935
+ 825,
936
+ 228
937
+ ],
938
+ "page_idx": 8
939
+ },
940
+ {
941
+ "type": "text",
942
+ "text": "Using the Transcoder model, Weisz et al. (2021) and Weisz et al. (2022) survey the links between humans and NMT methods for code translation. They view neural translation methods as aids to programmers. In this context, they demonstrate that even imperfect models can improve the quality of an engineer’s work for code translation, and plead for the improvement of human-machine interfaces. ",
943
+ "bbox": [
944
+ 174,
945
+ 236,
946
+ 825,
947
+ 291
948
+ ],
949
+ "page_idx": 8
950
+ },
951
+ {
952
+ "type": "text",
953
+ "text": "Decompilation. Like transpilation, decompilation is usually performed using rule-based methods that rely on pattern matching to parse the control flow structure of the program. RetDec, an open source decompiler created by Avast (Kˇroustek et al., 2017), can decompile an executable to C and a Python-like language via LLVM IR. Other tools exist, such as the Hex-Rays Decompiler10 and Brumley et al. (2013). A thorough review of rule-based methods can be found in papers such as Liang et al. (2021a) and Katz et al. (2019). With these methods, decompilation can fail if the code is too convoluted, or if it contains language features that were not explicitly translated. Most methods also produce unstructured programs, relying on a large number of goto statements to simulate the control flow of the lower level programming languages. This is semantically correct, but very rarely found in human-written code. ",
954
+ "bbox": [
955
+ 174,
956
+ 297,
957
+ 825,
958
+ 438
959
+ ],
960
+ "page_idx": 8
961
+ },
962
+ {
963
+ "type": "text",
964
+ "text": "A few works have studied the use of sequence-to-sequence neural networks for neural decompilation. Katz et al. (2019) uses LSTM networks to decompile LLVM IRs and assembly code to C. Their approach generates code templates based on the IR, that determine the structure of the output. Then, they fill them with correct variable assignments and numerical values. In the same vein, Fu et al. (2019) tries to address limitations of neural decompilation with two sequential phases: code sketch generation and iterative error correction. Finally, Liang et al. (2021b) use a method close to ours, and train Transformer models to translate between binary code and C. ",
965
+ "bbox": [
966
+ 174,
967
+ 444,
968
+ 826,
969
+ 541
970
+ ],
971
+ "page_idx": 8
972
+ },
973
+ {
974
+ "type": "text",
975
+ "text": "Intermediate representations are almost as old as compiler design. The first IR, UNCOL (Strong et al., 1958) was introduced in the mid-1950s, together with the idea of reusing the same compiler for several languages and machines. In 1960, NELIAC (a variant of ALGOL) (Huskey et al., 1960) was the first retargetable compiler, portable to different architectures. Feldman (1979) describes how a compiler for Fortran 77 can be added to the C compilers of Johnson (1979) and Ritchie (1979). GCC (Stallman, 2001) introduces Register Transfer Language (RTL) a low-level IR inspired by Davidson and Fraser (1980), and then GENERIC and GIMPLE (Merrill, 2003), precursors of the IR used in LLVM (Lattner and Adve, 2004). ",
976
+ "bbox": [
977
+ 174,
978
+ 549,
979
+ 825,
980
+ 660
981
+ ],
982
+ "page_idx": 8
983
+ },
984
+ {
985
+ "type": "text",
986
+ "text": "8 CONCLUSION ",
987
+ "text_level": 1,
988
+ "bbox": [
989
+ 176,
990
+ 686,
991
+ 318,
992
+ 703
993
+ ],
994
+ "page_idx": 8
995
+ },
996
+ {
997
+ "type": "text",
998
+ "text": "In this paper, we leverage LLVM IRs to improve neural machine translation for source code. The IR provides a common semantically-rich language, into which $\\mathrm { C } { + } { + }$ , Go, Java and Rust code can all be compiled. We develop three objectives, designed to leverage IRs for better multilingual representations of source code, which lead to a $5 . 5 \\%$ relative average improvement for code translation. We also show that sequence-to-sequence transformers perform well for neural decompilation, and use this for pivot translation. ",
999
+ "bbox": [
1000
+ 174,
1001
+ 714,
1002
+ 825,
1003
+ 797
1004
+ ],
1005
+ "page_idx": 8
1006
+ },
1007
+ {
1008
+ "type": "text",
1009
+ "text": "We only worked with the LLVM IR, but our approach is broadly applicable to any pair of languages that share a common Intermediate Representation. More generally any IR can help improve the code representations by tying them to the semantics. Another limitation is the scale of our current source and target sequences. As future work, LLVM IRs could be generated at a larger scale by compiling entire projects, which would greatly improve the percentage of successful IR compilations in Table 1. More languages and IRs could be used, and those extensions could be powered by larger models. ",
1010
+ "bbox": [
1011
+ 174,
1012
+ 805,
1013
+ 825,
1014
+ 888
1015
+ ],
1016
+ "page_idx": 8
1017
+ },
1018
+ {
1019
+ "type": "text",
1020
+ "text": "REFERENCES ",
1021
+ "text_level": 1,
1022
+ "bbox": [
1023
+ 176,
1024
+ 102,
1025
+ 287,
1026
+ 118
1027
+ ],
1028
+ "page_idx": 9
1029
+ },
1030
+ {
1031
+ "type": "text",
1032
+ "text": "Karan Aggarwal, Mohammad Salameh, and Abram Hindle. Using machine translation for converting Python 2 to Python 3 code. Technical report, PeerJ PrePrints, 2015. ",
1033
+ "bbox": [
1034
+ 176,
1035
+ 125,
1036
+ 823,
1037
+ 154
1038
+ ],
1039
+ "page_idx": 9
1040
+ },
1041
+ {
1042
+ "type": "text",
1043
+ "text": "Wasi Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. Unified pre-training for program understanding and generation. In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2655–2668, 2021. ",
1044
+ "bbox": [
1045
+ 174,
1046
+ 161,
1047
+ 826,
1048
+ 218
1049
+ ],
1050
+ "page_idx": 9
1051
+ },
1052
+ {
1053
+ "type": "text",
1054
+ "text": "Mikel Artetxe, Gorka Labaka, and Eneko Agirre. Unsupervised statistical machine translation. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, 2018. ",
1055
+ "bbox": [
1056
+ 176,
1057
+ 227,
1058
+ 823,
1059
+ 268
1060
+ ],
1061
+ "page_idx": 9
1062
+ },
1063
+ {
1064
+ "type": "text",
1065
+ "text": "Dzmitry Bahdanau, Kyung Hyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In 3rd International Conference on Learning Representations, 2015. ",
1066
+ "bbox": [
1067
+ 171,
1068
+ 277,
1069
+ 825,
1070
+ 306
1071
+ ],
1072
+ "page_idx": 9
1073
+ },
1074
+ {
1075
+ "type": "text",
1076
+ "text": "David Brumley, JongHyup Lee, Edward J Schwartz, and Maverick Woo. Native $\\mathbf { \\boldsymbol { x } } 8 6$ decompilation using semantics-preserving structural analysis and iterative control-flow structuring. In 22nd USENIX Security Symposium (USENIX Security 13), pages 353–368, 2013. ",
1077
+ "bbox": [
1078
+ 176,
1079
+ 314,
1080
+ 823,
1081
+ 358
1082
+ ],
1083
+ "page_idx": 9
1084
+ },
1085
+ {
1086
+ "type": "text",
1087
+ "text": "Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde, Jared Kaplan, Harri Edwards, Yura Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021. ",
1088
+ "bbox": [
1089
+ 174,
1090
+ 364,
1091
+ 823,
1092
+ 409
1093
+ ],
1094
+ "page_idx": 9
1095
+ },
1096
+ {
1097
+ "type": "text",
1098
+ "text": "Xinyun Chen, Chang Liu, and Dawn Song. Tree-to-tree neural networks for program translation. In Advances in neural information processing systems, pages 2547–2557, 2018. ",
1099
+ "bbox": [
1100
+ 169,
1101
+ 415,
1102
+ 823,
1103
+ 445
1104
+ ],
1105
+ "page_idx": 9
1106
+ },
1107
+ {
1108
+ "type": "text",
1109
+ "text": "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. ",
1110
+ "bbox": [
1111
+ 174,
1112
+ 452,
1113
+ 823,
1114
+ 496
1115
+ ],
1116
+ "page_idx": 9
1117
+ },
1118
+ {
1119
+ "type": "text",
1120
+ "text": "Jack W. Davidson and Christopher W. Fraser. The design and application of a retargetable peephole optimizer. ACM Trans. Program. Lang. Syst., 2(2):191–202, apr 1980. ISSN 0164-0925. ",
1121
+ "bbox": [
1122
+ 169,
1123
+ 503,
1124
+ 823,
1125
+ 534
1126
+ ],
1127
+ "page_idx": 9
1128
+ },
1129
+ {
1130
+ "type": "text",
1131
+ "text": "Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. CoRR, abs/1810.04805, 2018. ",
1132
+ "bbox": [
1133
+ 168,
1134
+ 540,
1135
+ 823,
1136
+ 570
1137
+ ],
1138
+ "page_idx": 9
1139
+ },
1140
+ {
1141
+ "type": "text",
1142
+ "text": "Stuart I. Feldman. Implementation of a portable Fortran 77 compiler using modern tools. SIGPLAN Not., 14(8):98–106, aug 1979. ISSN 0362-1340. doi: 10.1145/872732.806959. URL https: //doi.org/10.1145/872732.806959. ",
1143
+ "bbox": [
1144
+ 176,
1145
+ 577,
1146
+ 825,
1147
+ 619
1148
+ ],
1149
+ "page_idx": 9
1150
+ },
1151
+ {
1152
+ "type": "text",
1153
+ "text": "Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, et al. Codebert: A pre-trained model for programming and natural languages. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings, pages 1536–1547, 2020. ",
1154
+ "bbox": [
1155
+ 173,
1156
+ 627,
1157
+ 825,
1158
+ 684
1159
+ ],
1160
+ "page_idx": 9
1161
+ },
1162
+ {
1163
+ "type": "text",
1164
+ "text": "Cheng Fu, Huili Chen, Haolan Liu, Xinyun Chen, Yuandong Tian, Farinaz Koushanfar, and Jishen Zhao. Coda: An end-to-end neural program decompiler. In Advances in Neural Information Processing Systems, pages 3703–3714, 2019. ",
1165
+ "bbox": [
1166
+ 176,
1167
+ 693,
1168
+ 825,
1169
+ 736
1170
+ ],
1171
+ "page_idx": 9
1172
+ },
1173
+ {
1174
+ "type": "text",
1175
+ "text": "Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, LIU Shujie, Long Zhou, Nan Duan, Alexey Svyatkovskiy, Shengyu Fu, et al. Graphcodebert: Pre-training code representations with data flow. In International Conference on Learning Representations, 2020. ",
1176
+ "bbox": [
1177
+ 173,
1178
+ 742,
1179
+ 826,
1180
+ 786
1181
+ ],
1182
+ "page_idx": 9
1183
+ },
1184
+ {
1185
+ "type": "text",
1186
+ "text": "Harry D. Huskey, M. H. Halstead, and R. McArthur. NELIAC — dialect of ALGOL. Commun. ACM, 3(8):463–468, aug 1960. ISSN 0001-0782. doi: 10.1145/367368.367373. URL https: //doi.org/10.1145/367368.367373. ",
1187
+ "bbox": [
1188
+ 173,
1189
+ 794,
1190
+ 826,
1191
+ 837
1192
+ ],
1193
+ "page_idx": 9
1194
+ },
1195
+ {
1196
+ "type": "text",
1197
+ "text": "S. C. Johnson. A tour through the portable C compiler. In Unix Programmer’s Manual, 7th Edition, 2B, Section 33, 1979. ",
1198
+ "bbox": [
1199
+ 171,
1200
+ 844,
1201
+ 823,
1202
+ 873
1203
+ ],
1204
+ "page_idx": 9
1205
+ },
1206
+ {
1207
+ "type": "text",
1208
+ "text": "Aditya Kanade, Petros Maniatis, Gogul Balakrishnan, and Kensen Shi. Learning and evaluating contextual embedding of source code. In International Conference on Machine Learning, pages 5110–5121. PMLR, 2020. ",
1209
+ "bbox": [
1210
+ 176,
1211
+ 882,
1212
+ 825,
1213
+ 924
1214
+ ],
1215
+ "page_idx": 9
1216
+ },
1217
+ {
1218
+ "type": "text",
1219
+ "text": "Omer Katz, Yuval Olshaker, Yoav Goldberg, and Eran Yahav. Towards neural decompilation. arXiv preprint arXiv:1905.08325, 2019. ",
1220
+ "bbox": [
1221
+ 173,
1222
+ 103,
1223
+ 825,
1224
+ 132
1225
+ ],
1226
+ "page_idx": 10
1227
+ },
1228
+ {
1229
+ "type": "text",
1230
+ "text": "Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. ICLR, 2015. ",
1231
+ "bbox": [
1232
+ 174,
1233
+ 140,
1234
+ 784,
1235
+ 157
1236
+ ],
1237
+ "page_idx": 10
1238
+ },
1239
+ {
1240
+ "type": "text",
1241
+ "text": "Jakub Kˇroustek, Peter Matula, and P Zemek. RetDec: An open-source machine-code decompiler, 2017. URL https://github.com/avast/retdec. ",
1242
+ "bbox": [
1243
+ 169,
1244
+ 165,
1245
+ 825,
1246
+ 194
1247
+ ],
1248
+ "page_idx": 10
1249
+ },
1250
+ {
1251
+ "type": "text",
1252
+ "text": "Sumith Kulal, Panupong Pasupat, Kartik Chandra, Mina Lee, Oded Padon, Alex Aiken, and Percy S Liang. Spoc: Search-based pseudocode to code. Advances in Neural Information Processing Systems, 32:11906–11917, 2019. ",
1253
+ "bbox": [
1254
+ 178,
1255
+ 203,
1256
+ 825,
1257
+ 246
1258
+ ],
1259
+ "page_idx": 10
1260
+ },
1261
+ {
1262
+ "type": "text",
1263
+ "text": "Marie-Anne Lachaux, Baptiste Roziere, Marc Szafraniec, and Guillaume Lample. DOBF: A deobfuscation pre-training objective for programming languages. arXiv preprint arXiv:2102.07492, 2021. ",
1264
+ "bbox": [
1265
+ 174,
1266
+ 255,
1267
+ 825,
1268
+ 297
1269
+ ],
1270
+ "page_idx": 10
1271
+ },
1272
+ {
1273
+ "type": "text",
1274
+ "text": "Guillaume Lample and Alexis Conneau. Cross-lingual language model pretraining. Advances in Neural Information Processing Systems, 32:7059–7069, 2019. ",
1275
+ "bbox": [
1276
+ 174,
1277
+ 306,
1278
+ 823,
1279
+ 335
1280
+ ],
1281
+ "page_idx": 10
1282
+ },
1283
+ {
1284
+ "type": "text",
1285
+ "text": "Guillaume Lample, Alexis Conneau, Ludovic Denoyer, and Marc’Aurelio Ranzato. Unsupervised machine translation using monolingual corpora only. ICLR, 2018a. ",
1286
+ "bbox": [
1287
+ 174,
1288
+ 344,
1289
+ 821,
1290
+ 373
1291
+ ],
1292
+ "page_idx": 10
1293
+ },
1294
+ {
1295
+ "type": "text",
1296
+ "text": "Guillaume Lample, Myle Ott, Alexis Conneau, Ludovic Denoyer, and Marc’Aurelio Ranzato. Phrase based & neural unsupervised machine translation. In EMNLP, 2018b. ",
1297
+ "bbox": [
1298
+ 173,
1299
+ 382,
1300
+ 823,
1301
+ 411
1302
+ ],
1303
+ "page_idx": 10
1304
+ },
1305
+ {
1306
+ "type": "text",
1307
+ "text": "Chris Lattner and Vikram Adve. Llvm: A compilation framework for lifelong program analysis & transformation. In International Symposium on Code Generation and Optimization, 2004. CGO 2004., pages 75–86. IEEE, 2004. ",
1308
+ "bbox": [
1309
+ 174,
1310
+ 420,
1311
+ 825,
1312
+ 462
1313
+ ],
1314
+ "page_idx": 10
1315
+ },
1316
+ {
1317
+ "type": "text",
1318
+ "text": "Ruigang Liang, Ying Cao, Peiwei Hu, and Kai Chen. Neutron: an attention-based neural decompiler. Cybersecurity, 4(1):1–13, 2021a. ",
1319
+ "bbox": [
1320
+ 173,
1321
+ 470,
1322
+ 823,
1323
+ 501
1324
+ ],
1325
+ "page_idx": 10
1326
+ },
1327
+ {
1328
+ "type": "text",
1329
+ "text": "Ruigang Liang, Ying Cao, Peiwei Hu, Jinwen He, and Kai Chen. Semantics-recovering decompilation through neural machine translation. arXiv preprint arXiv:2112.15491, 2021b. ",
1330
+ "bbox": [
1331
+ 173,
1332
+ 508,
1333
+ 823,
1334
+ 539
1335
+ ],
1336
+ "page_idx": 10
1337
+ },
1338
+ {
1339
+ "type": "text",
1340
+ "text": "Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. RoBERTa: A robustly optimized BERT pretraining approach. arXiv preprint arXiv:1907.11692, 2019. ",
1341
+ "bbox": [
1342
+ 174,
1343
+ 546,
1344
+ 826,
1345
+ 590
1346
+ ],
1347
+ "page_idx": 10
1348
+ },
1349
+ {
1350
+ "type": "text",
1351
+ "text": "Nicholas D Matsakis and Felix S Klock II. The Rust language. In ACM SIGAda Ada Letters, volume 34, pages 103–104. ACM, 2014. ",
1352
+ "bbox": [
1353
+ 173,
1354
+ 598,
1355
+ 825,
1356
+ 628
1357
+ ],
1358
+ "page_idx": 10
1359
+ },
1360
+ {
1361
+ "type": "text",
1362
+ "text": "Jason Merrill. GENERIC and GIMPLE: A new tree representation for entire functions. In in Proc. GCC Developers Summit, 2003, pages 171–180, 2003. ",
1363
+ "bbox": [
1364
+ 173,
1365
+ 637,
1366
+ 825,
1367
+ 666
1368
+ ],
1369
+ "page_idx": 10
1370
+ },
1371
+ {
1372
+ "type": "text",
1373
+ "text": "Anh Tuan Nguyen, Tung Thanh Nguyen, and Tien N Nguyen. Lexical statistical machine translation for language migration. In Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering, pages 651–654, 2013. ",
1374
+ "bbox": [
1375
+ 174,
1376
+ 674,
1377
+ 825,
1378
+ 718
1379
+ ],
1380
+ "page_idx": 10
1381
+ },
1382
+ {
1383
+ "type": "text",
1384
+ "text": "Ruchir Puri, David S. Kung, Geert Janssen, Wei Zhang, Giacomo Domeniconi, Vladimir Zolotov, Julian Dolby, Jie Chen, Mihir R. Choudhury, Lindsey Decker, Veronika Thost, Luca Buratti, Saurabh Pujar, and Ulrich Finkler. Project CodeNet: A large-scale AI for code dataset for learning a diversity of coding tasks. CoRR, abs/2105.12655, 2021. URL https://arxiv.org/abs/ 2105.12655. ",
1385
+ "bbox": [
1386
+ 173,
1387
+ 726,
1388
+ 826,
1389
+ 796
1390
+ ],
1391
+ "page_idx": 10
1392
+ },
1393
+ {
1394
+ "type": "text",
1395
+ "text": "D.M. Ritchie. A Tour Through the UNIX C Compiler. 1979. URL https://books.google. com/books?id ${ . } = { }$ 5UvEGwAACAAJ. ",
1396
+ "bbox": [
1397
+ 171,
1398
+ 805,
1399
+ 826,
1400
+ 834
1401
+ ],
1402
+ "page_idx": 10
1403
+ },
1404
+ {
1405
+ "type": "text",
1406
+ "text": "Baptiste Roziere, Marie-Anne Lachaux, Lowik Chanussot, and Guillaume Lample. Unsupervised translation of programming languages. Advances in Neural Information Processing Systems, 33, 2020. ",
1407
+ "bbox": [
1408
+ 176,
1409
+ 843,
1410
+ 823,
1411
+ 886
1412
+ ],
1413
+ "page_idx": 10
1414
+ },
1415
+ {
1416
+ "type": "text",
1417
+ "text": "Baptiste Roziere, Jie M Zhang, Francois Charton, Mark Harman, Gabriel Synnaeve, and Guillaume Lample. Leveraging automated unit tests for unsupervised code translation. ICLR, 2022. ",
1418
+ "bbox": [
1419
+ 176,
1420
+ 895,
1421
+ 821,
1422
+ 924
1423
+ ],
1424
+ "page_idx": 10
1425
+ },
1426
+ {
1427
+ "type": "text",
1428
+ "text": "Rico Sennrich, Barry Haddow, and Alexandra Birch. Improving neural machine translation models with monolingual data. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, pages 86–96, 2015. ",
1429
+ "bbox": [
1430
+ 178,
1431
+ 103,
1432
+ 823,
1433
+ 146
1434
+ ],
1435
+ "page_idx": 11
1436
+ },
1437
+ {
1438
+ "type": "text",
1439
+ "text": "Richard Stallman. Using and porting the GNU Compiler Collection. M.I.T. Artificial Intelligence Laboratory, 2001. ",
1440
+ "bbox": [
1441
+ 173,
1442
+ 155,
1443
+ 823,
1444
+ 184
1445
+ ],
1446
+ "page_idx": 11
1447
+ },
1448
+ {
1449
+ "type": "text",
1450
+ "text": "J. Strong, J. Wegstein, A. Tritter, J. Olsztyn, O. Mock, and T. Steel. The problem of programming communication with changing machines: A proposed solution. Commun. ACM, 1(8):12–18, aug 1958. ISSN 0001-0782. doi: 10.1145/368892.368915. URL https://doi.org/10.1145/ 368892.368915. ",
1451
+ "bbox": [
1452
+ 173,
1453
+ 193,
1454
+ 823,
1455
+ 248
1456
+ ],
1457
+ "page_idx": 11
1458
+ },
1459
+ {
1460
+ "type": "text",
1461
+ "text": "Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequence to sequence learning with neural networks In Advances in neural information processing systems, pages 3104–3112, 2014. ",
1462
+ "bbox": [
1463
+ 173,
1464
+ 257,
1465
+ 820,
1466
+ 287
1467
+ ],
1468
+ "page_idx": 11
1469
+ },
1470
+ {
1471
+ "type": "text",
1472
+ "text": "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. ",
1473
+ "bbox": [
1474
+ 176,
1475
+ 295,
1476
+ 825,
1477
+ 338
1478
+ ],
1479
+ "page_idx": 11
1480
+ },
1481
+ {
1482
+ "type": "text",
1483
+ "text": "Yue Wang, Weishi Wang, Shafiq Joty, and Steven CH Hoi. Codet5: Identifier-aware unified pretrained encoder-decoder models for code understanding and generation. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 8696–8708, 2021. ",
1484
+ "bbox": [
1485
+ 174,
1486
+ 347,
1487
+ 826,
1488
+ 390
1489
+ ],
1490
+ "page_idx": 11
1491
+ },
1492
+ {
1493
+ "type": "text",
1494
+ "text": "Justin D Weisz, Michael Muller, Stephanie Houde, John Richards, Steven I Ross, Fernando Martinez, Mayank Agarwal, and Kartik Talamadupula. Perfection not required? human-ai partnerships in code translation. In 26th International Conference on Intelligent User Interfaces, pages 402–412, 2021. ",
1495
+ "bbox": [
1496
+ 173,
1497
+ 398,
1498
+ 825,
1499
+ 455
1500
+ ],
1501
+ "page_idx": 11
1502
+ },
1503
+ {
1504
+ "type": "text",
1505
+ "text": "Justin D Weisz, Michael Muller, Steven I Ross, Fernando Martinez, Stephanie Houde, Mayank Agarwal, Kartik Talamadupula, and John T Richards. Better together? an evaluation of AIsupported code translation. In 27th International Conference on Intelligent User Interfaces, pages 369–391, 2022. ",
1506
+ "bbox": [
1507
+ 173,
1508
+ 464,
1509
+ 825,
1510
+ 520
1511
+ ],
1512
+ "page_idx": 11
1513
+ },
1514
+ {
1515
+ "type": "text",
1516
+ "text": "A FULL SCORES TABLE ",
1517
+ "text_level": 1,
1518
+ "bbox": [
1519
+ 176,
1520
+ 102,
1521
+ 390,
1522
+ 118
1523
+ ],
1524
+ "page_idx": 12
1525
+ },
1526
+ {
1527
+ "type": "table",
1528
+ "img_path": "images/b563baa1009fda55bb5385051fe02084c106c1ce23b52e759d38b47fdf0ff149.jpg",
1529
+ "table_caption": [
1530
+ "Table 3: Results on unsupervised code translation. The metric shown is the computational accuracy for a single generation $( \\mathbf { C A @ 1 } )$ , measuring the translation correctness using unit tests. It is the full version of Table 2. The models were all trained with the same budget. As in Table 2, all these methods except for the IR pivot also use the three objectives defined in TransCoder: MLM, DAE and Back-Translation (BT). Although it is not the case for every language pair, TransCoder-IR, which uses the TLM, TAE, and MT objectives outperforms other methods on average. TransCoder-ST (Roziere et al., 2022) uses a parallel dataset generated with automated unit tests and outperforms other methods for $\\mathbf { C } + + \\mathbf { J a v a }$ . Their method is orthogonal to ours, and we could also improve our performance with similar methods. "
1531
+ ],
1532
+ "table_footnote": [],
1533
+ "table_body": "<table><tr><td colspan=\"6\">C++ →Go C++→Java C++→Rust Go →C++ Go →Java Go →Rust</td></tr><tr><td>Baseline TransCoder</td><td>57.7</td><td>63.3</td><td>18.2</td><td>56.1</td><td>46.9</td><td>23.3</td></tr><tr><td>TransCoder-ST</td><td>1</td><td>68.0</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><td>Pivot</td><td>16.1</td><td>22.0</td><td>14.0</td><td>30.5</td><td>26.5</td><td>2.7</td></tr><tr><td>TLM</td><td>61.8</td><td>62.5</td><td>18.2</td><td>57.6</td><td>56.4</td><td>22.2</td></tr><tr><td>TAE</td><td>57.7</td><td>62.5</td><td>21.7</td><td>63.0</td><td>54.7</td><td>23.8</td></tr><tr><td>TLM+TAE</td><td>58.2</td><td>63.3</td><td>19.2</td><td>55.2</td><td>57.0</td><td>22.8</td></tr><tr><td>MT</td><td>56.8</td><td>60.6</td><td>19.2</td><td>60.3</td><td>53.8</td><td>18.0</td></tr><tr><td>TLM+MT</td><td>58.6</td><td>58.5</td><td>19.7</td><td>57.3</td><td>54.1</td><td>23.8</td></tr><tr><td>TAE+MT</td><td>61.4</td><td>60.2</td><td>21.7</td><td>55.5</td><td>53.8</td><td>22.2</td></tr><tr><td>TLM+TAE+MT</td><td>55.9</td><td>62.9</td><td>24.8</td><td>61.8</td><td>55.7</td><td>22.2</td></tr><tr><td colspan=\"7\">Java →C++ Java→Go Java→Rust Rust →C++ Rust →Go Rust → Java</td></tr><tr><td>Baseline TransCoder</td><td>77.9</td><td>35.9</td><td>9.6</td><td>22.4</td><td>43.2</td><td>23.4</td></tr><tr><td>TransCoder-ST</td><td>84.6</td><td>1</td><td>1</td><td>-</td><td>1</td><td>1</td></tr><tr><td>Pivot</td><td>19.5</td><td>9.4</td><td>6.7</td><td>22.0</td><td>8.9</td><td>18.1</td></tr><tr><td>TLM</td><td>80.9</td><td>31.8</td><td>6.6</td><td>25.9</td><td>30.0</td><td>37.5</td></tr><tr><td>TAE</td><td>80.3</td><td>38.6</td><td>6.6</td><td>16.6</td><td>38.1</td><td>20.6</td></tr><tr><td>TLM+TAE</td><td>82.2</td><td>24.6</td><td>8.6</td><td>30.4</td><td>31.0</td><td>43.3</td></tr><tr><td>MT</td><td>76.2</td><td>50.9</td><td>12.6</td><td>16.6</td><td>39.1</td><td>21.3</td></tr><tr><td>TLM+MT</td><td>77.9</td><td>52.7</td><td>10.1</td><td>19.2</td><td>30.0</td><td>24.1</td></tr><tr><td>TAE+MT</td><td>77.5</td><td>33.6</td><td>6.1</td><td>30.0</td><td>36.6</td><td>33.7</td></tr><tr><td>TLM+TAE+MT</td><td>74.5</td><td>49.6</td><td>17.2</td><td>26.5</td><td>49.2</td><td>30.2</td></tr></table>",
1534
+ "bbox": [
1535
+ 174,
1536
+ 251,
1537
+ 825,
1538
+ 584
1539
+ ],
1540
+ "page_idx": 12
1541
+ },
1542
+ {
1543
+ "type": "text",
1544
+ "text": "B BEAM SIZE EVALUATION ",
1545
+ "bbox": [
1546
+ 176,
1547
+ 102,
1548
+ 415,
1549
+ 117
1550
+ ],
1551
+ "page_idx": 13
1552
+ },
1553
+ {
1554
+ "type": "table",
1555
+ "img_path": "images/8a089c4b019fc78f435073466a50637f17be885f415a3fa5ffeb9da9e9c26ae0.jpg",
1556
+ "table_caption": [
1557
+ "Table 4: Results on unsupervised code translation with different beam sizes. The metric shown is still the computational accuracy for a single generation $( \\mathbf { C A @ 1 } )$ . BS N refers to beam search decoding with beam size N, and returning only the top element of the beam. Using beam search improves the average performance of every model. BS N means that the model is evaluated with beam size N. When the beam size is not given, we use greedy decoding. Surprisingly, beam size 5 outperforms beam size 10. Our method using intermediate representations still outperforms the baseline with beam size 5 and 10 in average. With the baseline, we obtain average $\\mathrm { C A @ 1 }$ scores of 45.3 with beam size 5 and 44.0 with beam size 10. Our method yields $\\mathrm { C A @ 1 }$ scores of 47.8 with beam size 5 and 46.8 with beam size 10. "
1558
+ ],
1559
+ "table_footnote": [],
1560
+ "table_body": "<table><tr><td></td><td>C++ →Go</td><td>C++→→Java</td><td>C++→Rust</td><td>Go →C++</td><td>Go→ Java</td><td>Go →Rust</td></tr><tr><td>Baseline TransCoder</td><td>57.7</td><td>63.3</td><td>18.2</td><td>56.1</td><td>46.9</td><td>23.3</td></tr><tr><td>Baseline TransCoder (BS 5)</td><td>65.5</td><td>67.6</td><td>28.3</td><td>52.1</td><td>59.3</td><td>24.3</td></tr><tr><td>Baseline TransCoder (BS 10)</td><td>65.0</td><td>68.7</td><td>27.8</td><td>52.1</td><td>57.0</td><td>23.8</td></tr><tr><td>TLM+ TAE+ MT</td><td>55.9</td><td>62.9</td><td>24.8</td><td>61.8</td><td>55.7</td><td>22.2</td></tr><tr><td>TLM + TAE + MT (BS 5)</td><td>61.4</td><td>66.6</td><td>30.8</td><td>57.3</td><td>59.0</td><td>30.2</td></tr><tr><td>TLM + TAE + MT (BS 10)</td><td>61.4</td><td>67.4</td><td>29.3</td><td>56.4</td><td>59.0</td><td>29.1</td></tr><tr><td></td><td>Java → C++</td><td>Java →Go</td><td>Java→Rust</td><td>Rust -→ C++</td><td>Rust →Go</td><td>Rust → Java</td></tr><tr><td>Baseline TransCoder</td><td>77.9</td><td>35.9</td><td>9.6</td><td>22.4</td><td>43.2</td><td>23.4</td></tr><tr><td>Baseline TransCoder (BS 5)</td><td>82.9</td><td>45.5</td><td>10.1</td><td>25.2</td><td>54.8</td><td>27.5</td></tr><tr><td>Baseline TransCoder (BS 10)</td><td>80.9</td><td>46.4</td><td>7.6</td><td>23.6</td><td>51.8</td><td>23.0</td></tr><tr><td>TLM+ TAE + MT</td><td>74.5</td><td>49.6</td><td>17.2</td><td>26.5</td><td>49.2</td><td>30.2</td></tr><tr><td>TLM + TAE + MT (BS 5)</td><td>76.4</td><td>57.7</td><td>20.2</td><td>26.8</td><td>52.3</td><td>34.7</td></tr><tr><td>TLM + TAE + MT (BS 10)</td><td>77.7</td><td>57.3</td><td>18.2</td><td>26.2</td><td>51.8</td><td>28.2</td></tr></table>",
1561
+ "bbox": [
1562
+ 142,
1563
+ 256,
1564
+ 857,
1565
+ 484
1566
+ ],
1567
+ "page_idx": 13
1568
+ },
1569
+ {
1570
+ "type": "text",
1571
+ "text": "C PIVOT METHOD DETAILS ",
1572
+ "text_level": 1,
1573
+ "bbox": [
1574
+ 176,
1575
+ 522,
1576
+ 413,
1577
+ 539
1578
+ ],
1579
+ "page_idx": 13
1580
+ },
1581
+ {
1582
+ "type": "text",
1583
+ "text": "As mentioned in Section 3.3, IR generated from different languages contain slight variations and can be seen as dialects of the same language. In practice, these variations prevent us from simply using our best decompilation model to generate source code in another language than the one used to generate the IR. Although we prompt the model to generate code in the target language with language embeddings, it learns to focus on the particularities of each dialect and ignores the language embeddings. Therefore, it generates code in the source language, which results in a computational accuracy score of 0 for translation. ",
1584
+ "bbox": [
1585
+ 173,
1586
+ 554,
1587
+ 825,
1588
+ 651
1589
+ ],
1590
+ "page_idx": 13
1591
+ },
1592
+ {
1593
+ "type": "text",
1594
+ "text": "One way to solve this issue is to use one decoder per target language. Then, the model is able to generate code in the target language. However, this method still performs poorly due to the small differences between the IR dialects. The method we tested that performed the best, and which is reported in Table 2, uses back-translation to make the model to translate from any IR dialect to any language. This model is also grounded by supervised translation steps making it generate IR from code and code from IR. In practice, we create new language embeddings for every IR dialect (i.e. $\\mathrm { I R - C + + }$ , IR-Go, IR-Java, IR-Rust) for depending on the source language. At training time, we make the model generate noisy translations in the IR-Go, IR-Java and IR-Rust “languages” for every $\\mathrm { C } { + } { + }$ sequence, and train it to re-generate the $\\mathrm { C } { + } { + }$ sequence from the noisy translation. To allow the model to generate good training data for $\\scriptstyle { \\mathrm { I R - X } } \\to { \\mathbf { C } } + +$ , we also generate noisy translations in Go, Java, and Rust for every IR generated from $\\mathrm { C } { + } { + }$ in our dataset and train the model to retrieve the IR. Using our parallel code//IR dataset, we also train the model to translate between $\\mathrm { C } { + + }$ and IR- $C + +$ sequences. We do the same for every language and alternate between them. ",
1595
+ "bbox": [
1596
+ 174,
1597
+ 659,
1598
+ 825,
1599
+ 839
1600
+ ],
1601
+ "page_idx": 13
1602
+ },
1603
+ {
1604
+ "type": "table",
1605
+ "img_path": "images/85abb3da4270dbbb992fa1474193e83f36d82a2bb3066c4dc5d5888fbc1bdd8a.jpg",
1606
+ "table_caption": [
1607
+ "Table 5: Performance of LLVM IRs Decompilation. This table shows the computational accuracy $( \\mathbf { C A @ 1 } )$ of our neural decompiler and the RetDec $\\mathrm { C } { + + }$ rule-based decompiler. Our neural decompiler outperforms RedDec on $\\mathrm { C } { + + }$ and is more broadly applicable. "
1608
+ ],
1609
+ "table_footnote": [],
1610
+ "table_body": "<table><tr><td></td><td>C++</td><td>Go</td><td>Java</td><td>Rust</td></tr><tr><td>Baseline - RetDec</td><td>68.8</td><td>一</td><td></td><td></td></tr><tr><td>Separate Decoders</td><td>52.7</td><td>42.2</td><td>60.1</td><td>19.5</td></tr><tr><td>Shared Decoder</td><td>77.9</td><td>70.1</td><td>82.2</td><td>61.0</td></tr></table>",
1611
+ "bbox": [
1612
+ 318,
1613
+ 260,
1614
+ 676,
1615
+ 333
1616
+ ],
1617
+ "page_idx": 14
1618
+ },
1619
+ {
1620
+ "type": "image",
1621
+ "img_path": "images/15618a02a294a39479720341a03971180cec9ec86a0af942df47c057e0cd1731.jpg",
1622
+ "image_caption": [
1623
+ "Figure 5: Code simplification examples with Decompilation / Pivot. Since the LLVM IR is optimized, functions that are semantically equivalent after optimization map to the same IR. In the first example, it allows to remove useless code by decompiling the generated LLVM IR. In the second example, the simplification allows to find a bug: the $\\&$ operator has precedence over $= =$ in $\\mathrm { C } { + } { + }$ , causing this function to always evaluate to false. It is not obvious when looking at the input code, but becomes clear with the IR and simplified $\\mathrm { C } { + + }$ code. In the third example, it replaces a bitwise operation by a more straightforward multiplication. In all examples, we can run the compiler again to check that the IR of the decompiled code is exactly the same as that of the input. It guarantees that the input and simplified code have the same semantics. "
1624
+ ],
1625
+ "image_footnote": [],
1626
+ "bbox": [
1627
+ 179,
1628
+ 569,
1629
+ 844,
1630
+ 763
1631
+ ],
1632
+ "page_idx": 14
1633
+ },
1634
+ {
1635
+ "type": "image",
1636
+ "img_path": "images/2e2e4baefe505e9f3ba439e931185acd8ec2f427a6d900c14eff2ed9317ba805.jpg",
1637
+ "image_caption": [
1638
+ "Figure 6: Java to Rust translation examples. In the first example, the IR allows the model to understand that the Java bitwise complement operator \\~ should be replaced by ! in Rust. Also, it allows the model to translate the type correctly in both examples and avoids unnecessary casts. The IR allows the model to generate the right types (e.g. i32 instead of $\\mathtt { u } 3 2$ when translating int) and operator (e.g. ! instead of $\\tilde { }$ in Rust). ",
1639
+ "Figure 7: Rust to Go translation example. This function performs binary search to find the insertion index for an element in an ordered vector. The model translates types, function definitions, variable definitions, and while loops correctly. "
1640
+ ],
1641
+ "image_footnote": [],
1642
+ "bbox": [
1643
+ 178,
1644
+ 99,
1645
+ 826,
1646
+ 224
1647
+ ],
1648
+ "page_idx": 15
1649
+ },
1650
+ {
1651
+ "type": "text",
1652
+ "text": "// Rust \npub fn binary_search(nums: Vec<i32>, target: i32, \n) -> i32 { if nums.is_empty() { return 0 } if target $<$ nums[0] { return 0 } let mut left $\\qquad = \\quad 0$ ; let mut right $=$ nums.len() - 1; while left $< =$ right { let mid $=$ left $^ +$ (right - left) / 2; if nums[mid] $= =$ target { return mid as i32; } else if nums[mid] $<$ target { left $=$ mid $^ + 1$ ; } else { right $=$ mid - 1; } } return left as i32; \n} \n// Go \nfunc binarySearch(nums[] int, target int) int { if len(nums) $\\scriptstyle = = 0$ { return 0 } if target $<$ nums[0] { return 0 } left: $\\qquad = \\quad 0$ right: $=$ len(nums) - 1 for left $< =$ right { mid: $=$ left $^ +$ (right - left) / 2 if nums[mid] $= =$ target { return mid } else if nums[mid] $<$ target { left $=$ mid $^ + 1$ else { right $=$ mid - 1 } } return left \n} \n// Go \nfunc pairsInSortedRotated(arr[] int, n int, x int) \nint { var i int for $\\mathrm { ~ \\\\\\small ~ \\frac ~ { ~ i ~ } ~ } = \\mathrm { ~ \\small ~ 0 ~ }$ ; $\\mathrm { ~ i ~ } ~ < \\mathrm { ~ n ~ } ~ - ~ 1$ ; i++{ if arr[i] $\\mathrm { ~ \\gamma ~ > ~ } \\mathrm { a r r } [ \\mathrm { ~ i ~ \\Gamma ~ + ~ }$ 1] { break } } var l int $= ( \\frac { \\mathrm { ~ i ~ \\hbar ~ } } { 1 } + \\mathrm { ~ 1 ~ } ) \\frac { \\circ } { \\circ } \\mathrm { ~ n ~ }$ var r int $\\qquad = \\quad \\\\\\\\\\\\\\\\\\perp$ var cnt int $\\qquad = \\quad 0$ for l != r { if arr[l] $^ +$ arr[r] == x { cnt++ $\\mathbf { i } \\notin \\mathbb { R } ^ { } 2 \\ : \\equiv \\ : \\ : ( \\mathbf { r } _ { } \\mathrm { ~ \\ j ~ - ~ \\frac ~ { ~ 1 ~ } ~ { ~ 1 ~ } ~ + ~ \\eta ~ } _ { } \\mathtt { n } ) \\notin \\mathbb { R } \\ : \\ : \\{ \\ :$ { return cnt } l = (l + 1) % n r = (r - 1 + n) % n } else if arr[l] + arr[r] < x { $1 = ( 1 + 1 ) \\frac { 2 } { 0 } \\pi$ } else { r = (n + r - 1) % n } } return cnt \n} \n// C++ \nint pairsInSortedRotated(int arr[], int n, int x) \n{ int i; for $( \\mathrm { ~ i ~ ~ } \\ = \\ \\mathrm { ~ 0 ~ } ; \\ \\mathrm { ~ i ~ } \\ < \\ \\mathrm { ~ n ~ ~ - ~ } \\ \\mathrm { ~ 1 ~ } ; \\ \\mathrm { ~ i ~ } \\ + + )$ { if (arr $[ \\pm ] >$ arr $[ { \\mathrm { ~ i ~ \\phi ~ } } + { \\mathrm { ~ 1 ~ } } ]$ ) break; } int $1 = ( \\dot { \\bf ~ 1 } + \\dot { \\bf ~ 1 } ) \\frac { \\ d s } { \\ d s } \\mathrm { ~ n ~ } ;$ int $\\mathrm { ~ \\bf ~ r ~ } = \\mathrm { ~ \\bf ~ i ~ } ;$ ; int cnt $\\qquad = \\quad 0$ ; while $( \\underline { { { 1 } } } \\quad : = \\quad \\underline { { { { \\bf r } } } } )$ ) { if (arr [l] + arr $[ { \\boldsymbol { \\textbf { r } } } ] \\ \\mathbf { \\Sigma } = = { \\boldsymbol { \\textbf { x } } } )$ ) { cnt $^ { + + }$ ; $\\begin{array} { c c c c c c c c c } { { \\lfloor \\pm } } & { { ( 1 } } & { { = = } } & { { ( \\tt { r } } } & { { - } } & { { 1 } } & { { + } } & { { \\tt { n } ) } } & { { \\tt { \\& } } } & { { \\tt { n } ) } } & { { } } & { { } } \\end{array}$ return cnt; $1 = ( 1 + 1 ) \\frac { 2 } { 9 } \\pi ;$ $\\begin{array} { r c c c c l } { \\texttt { r } = } & { ( \\texttt { r } - } & { \\texttt { l } + } & { \\texttt { n } ) } & { \\frac { \\circ } { \\circ } } & { \\mathtt { n } } & { ; } \\end{array}$ } else $\\begin{array} { r } { \\mathrm { i } \\texttt { i f } \\left( \\mathrm { a r r } \\left[ \\mathrm { \\texttt { l } } \\right] \\ + \\ \\mathrm { a r r } \\left[ \\mathrm { \\texttt { r } } \\right] \\ < \\ \\textbf { x } \\right) \\ \\mathrm { ~ \\texttt { l } ~ = ~ \\textbf { ( } \\mathrm { 1 ~ \\texttt { + } ~ 1 ~ } ) ~ \\ \\frac { \\circ } { \\circ } ~ \\ n ~ } ; } \\end{array}$ else $\\texttt { r } = \\texttt { ( n + r - l ) } \\texttt { \\frac { e } { s } n }$ ; } return cnt; ",
1653
+ "bbox": [
1654
+ 181,
1655
+ 527,
1656
+ 498,
1657
+ 779
1658
+ ],
1659
+ "page_idx": 15
1660
+ },
1661
+ {
1662
+ "type": "text",
1663
+ "text": "",
1664
+ "bbox": [
1665
+ 506,
1666
+ 527,
1667
+ 843,
1668
+ 768
1669
+ ],
1670
+ "page_idx": 15
1671
+ },
1672
+ {
1673
+ "type": "text",
1674
+ "text": "",
1675
+ "bbox": [
1676
+ 183,
1677
+ 354,
1678
+ 444,
1679
+ 669
1680
+ ],
1681
+ "page_idx": 16
1682
+ },
1683
+ {
1684
+ "type": "text",
1685
+ "text": "",
1686
+ "bbox": [
1687
+ 508,
1688
+ 354,
1689
+ 867,
1690
+ 598
1691
+ ],
1692
+ "page_idx": 16
1693
+ },
1694
+ {
1695
+ "type": "image",
1696
+ "img_path": "images/c29b3950a88fe4f248abeed7fc389851c6a8803d4218b21d151f93ee7b37bb9f.jpg",
1697
+ "image_caption": [
1698
+ "Figure 9: Rust to Go translation example. We call S1 the string n1 repeated s1 times and S2 the string n2 repeated $_ { \\textrm { S 2 } }$ times. This function finds the largest number of repetitions of S2 appearing in any subset of S1. The model translates the types correctly, understands that casting vector indices to unsigned int (i.e. with as usize) is not required in Go, and correctly translates other Rust constructs to Go. "
1699
+ ],
1700
+ "image_footnote": [],
1701
+ "bbox": [
1702
+ 181,
1703
+ 239,
1704
+ 821,
1705
+ 765
1706
+ ],
1707
+ "page_idx": 17
1708
+ },
1709
+ {
1710
+ "type": "text",
1711
+ "text": "F DATASET SIZE DETAILS ",
1712
+ "text_level": 1,
1713
+ "bbox": [
1714
+ 174,
1715
+ 102,
1716
+ 401,
1717
+ 117
1718
+ ],
1719
+ "page_idx": 18
1720
+ },
1721
+ {
1722
+ "type": "table",
1723
+ "img_path": "images/16ac3946b11f5a0903e8070d8685b1ab81c68e24e79e6bfa427f5e6b58a1b951.jpg",
1724
+ "table_caption": [
1725
+ "Table 6: Dataset details: number of tokens in our function-level dataset. This dataset contains only functions defined outside of classes and static functions. "
1726
+ ],
1727
+ "table_footnote": [],
1728
+ "table_body": "<table><tr><td></td><td>Numberof tokens</td><td>Number of sentences</td></tr><tr><td>Monolingual data</td><td></td><td></td></tr><tr><td>C++</td><td>2.33B</td><td>6.6M</td></tr><tr><td>Go</td><td>1.9B</td><td>9.4M</td></tr><tr><td>Java</td><td>1.5B</td><td>7.8M</td></tr><tr><td>Rust</td><td>130.0M</td><td>576.3K</td></tr><tr><td>Code /IR Parallel Data</td><td></td><td></td></tr><tr><td>C++-IR</td><td>946.7M</td><td>343.9K</td></tr><tr><td>Go-IR</td><td>971.8M</td><td>384.4K</td></tr><tr><td>Java-IR</td><td>1.7B</td><td>2.2M</td></tr><tr><td>Rust-IR</td><td>77.7M</td><td>19.4K</td></tr></table>",
1729
+ "bbox": [
1730
+ 253,
1731
+ 194,
1732
+ 735,
1733
+ 371
1734
+ ],
1735
+ "page_idx": 18
1736
+ },
1737
+ {
1738
+ "type": "text",
1739
+ "text": "G ADDITIONAL ABLATIONS ",
1740
+ "text_level": 1,
1741
+ "bbox": [
1742
+ 176,
1743
+ 410,
1744
+ 419,
1745
+ 425
1746
+ ],
1747
+ "page_idx": 18
1748
+ },
1749
+ {
1750
+ "type": "text",
1751
+ "text": "Training on IRs with different objectives. We perform some additional ablations to determine whether our performance improvements come from training on IRs or from our TLM, TAE and MT objectives. When training a model with the three objectives of TransCoder (i.e. MLM, DAE and BT) and considering the IR as an extra language, we obtain an average computational accuracy of 37.4, which is lower than that of our baseline TransCoder. As the structure of the IR is not similar to that of any of our source languages, there is not much to gain from adding the IR as an extra language. Moreover, the model is wasting some time to compute the AE and BT objectives for the IR which can be better spent on the source languages. It confirms that our objectives are required to map IRs and their corresponding source code to similar representations in embedding space. ",
1752
+ "bbox": [
1753
+ 173,
1754
+ 446,
1755
+ 826,
1756
+ 571
1757
+ ],
1758
+ "page_idx": 18
1759
+ },
1760
+ {
1761
+ "type": "text",
1762
+ "text": "Language ablation: no Java. As Rust and Go are more similar to Java than to $\\mathrm { C } { + + }$ , we also train a baseline model on $\\mathrm { C } { + } { + }$ , Go and Rust only to evaluate whether including Java hurts the translation performance. We observed similar performance for $\\mathbf { C } \\mathbf { + } \\mathbf { + } \\mathbf { G } \\mathbf { o }$ . However, we also observe a clear decrease in performance in the very low data regime (i.e. when translating to or from Rust). The computational accuracy for Rust $ \\mathbf { C } + +$ goes down from $2 2 . 4 \\%$ to $2 0 . 1 \\%$ and it goes down from $4 3 . 1 \\bar { 5 } \\%$ to $3 2 . 5 \\%$ for Rust $ \\mathrm { G o }$ . ",
1763
+ "bbox": [
1764
+ 173,
1765
+ 597,
1766
+ 825,
1767
+ 681
1768
+ ],
1769
+ "page_idx": 18
1770
+ },
1771
+ {
1772
+ "type": "text",
1773
+ "text": "H WORD EMBEDDINGS ",
1774
+ "text_level": 1,
1775
+ "bbox": [
1776
+ 174,
1777
+ 712,
1778
+ 382,
1779
+ 728
1780
+ ],
1781
+ "page_idx": 18
1782
+ },
1783
+ {
1784
+ "type": "text",
1785
+ "text": "We notice that our method generates improved word embeddings. It is visible when looking at the cosine similarity for embeddings of rust types and their equivalents in $\\mathrm { C } { + } { + }$ . For instance, Figure 10 shows that the embedding of $\\hphantom { 0 } \\mathrm { { 3 2 } }$ from our model leveraging LLVM IRs is most similar to uint32 (with a cosine similarity of 0.4869). uint, which is also a correct translation, comes in $1 1 ^ { t h }$ position with a cosine similarity (0.3716). In contrast, $\\hphantom { 0 } \\mathrm { { 3 2 } }$ has a similarity of only 0.2828 with int. This token, which would be an incorrect translation, comes only in $2 9 ^ { t h }$ position. ",
1786
+ "bbox": [
1787
+ 173,
1788
+ 750,
1789
+ 825,
1790
+ 833
1791
+ ],
1792
+ "page_idx": 18
1793
+ },
1794
+ {
1795
+ "type": "text",
1796
+ "text": "The baseline model, which does not use the IR, learns similar representations for rust types since they appear in similar contexts. Hence, its embedding of $\\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom { 0 } \\hphantom \\hphantom { 0 } \\hphantom { 0 } \\hphantom \\hphantom { 0 } \\hphantom \\hphantom { 0 } \\hphantom \\hphantom { 0 } \\hphantom \\hphantom \\hphantom { 0 } \\hphantom \\hphantom \\hphantom \\hphantom { 0 } \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\end \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\hphantom \\end f$ is most similar to other rust types tokens such as $\\mathtt { \\small u 6 4 }$ , i32 or u16. uint32 comes only in fourth position with a cosine similarity of 0.4218. Moreover, uint and int have almost the same cosine similarities with $\\hphantom { 0 } \\mathrm { { 3 2 } }$ with the baseline model. It causes the model to often confuse unsigned and signed integer types, and to incorrectly translate u32 into int instead of uint. ",
1797
+ "bbox": [
1798
+ 174,
1799
+ 840,
1800
+ 825,
1801
+ 922
1802
+ ],
1803
+ "page_idx": 18
1804
+ },
1805
+ {
1806
+ "type": "image",
1807
+ "img_path": "images/1141077b8224742da55bf418f82a47d1be7099a3d390c36e36affeca54543599.jpg",
1808
+ "image_caption": [
1809
+ "Figure 10: Token similarities. Rank and token similarity with $\\mathtt { u } 3 2$ for our model (right) and the baseline model (left). Our model generates embeddings that better capture token semantics. "
1810
+ ],
1811
+ "image_footnote": [],
1812
+ "bbox": [
1813
+ 174,
1814
+ 97,
1815
+ 797,
1816
+ 239
1817
+ ],
1818
+ "page_idx": 19
1819
+ },
1820
+ {
1821
+ "type": "text",
1822
+ "text": "I ANALYSIS OF ERROR TYPES ",
1823
+ "text_level": 1,
1824
+ "bbox": [
1825
+ 174,
1826
+ 304,
1827
+ 433,
1828
+ 320
1829
+ ],
1830
+ "page_idx": 19
1831
+ },
1832
+ {
1833
+ "type": "table",
1834
+ "img_path": "images/21633cf36021cbd4c383da38346cc2c5ad48824fa5a15dfa2d62f62c7491fbc3.jpg",
1835
+ "table_caption": [
1836
+ "Table 7: Rust error types. To validate our intuition on the usefulness of the IR representations to decrease the number of type-related errors (see Fig.1 or Fig.6), we perform an in-depth analysis of the types of errors encountered for the Java Rust direction. Here we count the total number of errors (there can be several for a single translation). We notice that the number of type-related errors (excluding E0433, E0425 and Others) decreases by $24 \\%$ (609 vs. 463) and the number of mismatched types decreases by $49 \\%$ . "
1837
+ ],
1838
+ "table_footnote": [],
1839
+ "table_body": "<table><tr><td>Error Code</td><td>Error Description</td><td>Baseline (Transcoder)</td><td>TLM + TAE + MT</td></tr><tr><td>E0308</td><td>Mismatched Type</td><td>414</td><td>210</td></tr><tr><td>E0412</td><td>Type Does Not Exist</td><td>15</td><td>3</td></tr><tr><td>E0277</td><td>Type has Missing Trait</td><td>180</td><td>250</td></tr><tr><td>E0425</td><td>Undefined Variable</td><td>18</td><td>27</td></tr><tr><td>E0433</td><td>Use of Undefined Crate,Module or Type</td><td>15</td><td>32</td></tr><tr><td>丨</td><td>Others</td><td>28</td><td>33</td></tr><tr><td>TOTAL</td><td></td><td>670</td><td>555</td></tr></table>",
1840
+ "bbox": [
1841
+ 173,
1842
+ 421,
1843
+ 861,
1844
+ 556
1845
+ ],
1846
+ "page_idx": 19
1847
+ }
1848
+ ]
parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5660baaa210cacb60ef955853384587edb376567af87dae9e117e752ae9a4180
3
+ size 1193009
parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7d9d0026580c9caad8960b65eb8f25e7bf08630a1768276d5e80867bc1a0b4e6
3
+ size 928383
parse/dev/XomEU3eNeSQ/XomEU3eNeSQ_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6acf0ac9406c6a5a377504bcc19d8089b1387a2a03501a55346865f208bd562
3
+ size 1200740
parse/dev/XomEU3eNeSQ/images/1141077b8224742da55bf418f82a47d1be7099a3d390c36e36affeca54543599.jpg ADDED

Git LFS Details

  • SHA256: 871350ace2b70af2e507ed22914adb118740dd34493d1f772c2d8b831a183e76
  • Pointer size: 130 Bytes
  • Size of remote file: 37.2 kB
parse/dev/XomEU3eNeSQ/images/1477506c8deee4b7fbb71a998023732aef2cc9c3a8db923d0e7d2fd849eb9489.jpg ADDED

Git LFS Details

  • SHA256: 413e655d302e55162f3aaa8fca78932a5eb4613e30155e609dcc371433f02041
  • Pointer size: 129 Bytes
  • Size of remote file: 3.57 kB
parse/dev/XomEU3eNeSQ/images/15618a02a294a39479720341a03971180cec9ec86a0af942df47c057e0cd1731.jpg ADDED

Git LFS Details

  • SHA256: 91b7912253c1db67a4e55817b6b7639a4b70e5caf940d47f9378c95874e1ef5d
  • Pointer size: 130 Bytes
  • Size of remote file: 54.2 kB
parse/dev/XomEU3eNeSQ/images/16ac3946b11f5a0903e8070d8685b1ab81c68e24e79e6bfa427f5e6b58a1b951.jpg ADDED

Git LFS Details

  • SHA256: b1ecc4b11048a26a8267fea8bb98902802157491f5f799301f393b4c70a4c4b0
  • Pointer size: 130 Bytes
  • Size of remote file: 40.4 kB
parse/dev/XomEU3eNeSQ/images/21633cf36021cbd4c383da38346cc2c5ad48824fa5a15dfa2d62f62c7491fbc3.jpg ADDED

Git LFS Details

  • SHA256: ac5945c3b919014a5ff56be678b2f5e86fbc79b7ca720e4a60fff0453b6c1ff9
  • Pointer size: 130 Bytes
  • Size of remote file: 52 kB
parse/dev/XomEU3eNeSQ/images/29fae3ff36f24cf6fe7117e7f760781374714a7347684948f7df9c71ee9548fd.jpg ADDED

Git LFS Details

  • SHA256: 6ef2f3bdfa1f7148cc44537edcc3a1c8fb9bdc4cfe5c52e5aff1c79b1f0e15cd
  • Pointer size: 129 Bytes
  • Size of remote file: 4.57 kB
parse/dev/XomEU3eNeSQ/images/2ce80764eb26a8059393b072022f99d73253f0c2c863d83b95f7d1a89d55b3ef.jpg ADDED

Git LFS Details

  • SHA256: a324d0e555eb77203ce0a90be5d685cd36f483cf5697d29a411a210248dc6849
  • Pointer size: 129 Bytes
  • Size of remote file: 3.8 kB
parse/dev/XomEU3eNeSQ/images/2e2e4baefe505e9f3ba439e931185acd8ec2f427a6d900c14eff2ed9317ba805.jpg ADDED

Git LFS Details

  • SHA256: 2d7d1fca6bb5131175cebd9bc8f4c453e471984f86a160193ecaae31158fa5ee
  • Pointer size: 130 Bytes
  • Size of remote file: 32.1 kB
parse/dev/XomEU3eNeSQ/images/44de55a84e4c90f4f2f3862fad436ccd311d8ada7b923bd3ea22062da99d4b27.jpg ADDED

Git LFS Details

  • SHA256: edc5b7818152835a9f81238499d63825d63633289d1194ff9f1b5ebad9cebeae
  • Pointer size: 129 Bytes
  • Size of remote file: 3.63 kB
parse/dev/XomEU3eNeSQ/images/4e5ce168677271d207a1232df7e84e1a16857d83646dab66d08821b92672e1f5.jpg ADDED

Git LFS Details

  • SHA256: 73f8cd8da52cf47fe1cc9fa247aa457f1cf53e984c6db57a7ced89dca2dfd7eb
  • Pointer size: 130 Bytes
  • Size of remote file: 71.9 kB
parse/dev/XomEU3eNeSQ/images/5076cb2e53897509ca7243fa573292c5a46aae9242e6fb78828275446d8fd261.jpg ADDED

Git LFS Details

  • SHA256: aaf34b21416ea1b72d3573835beb7d2ce9465d37fa09f80159e93b334ef26e88
  • Pointer size: 130 Bytes
  • Size of remote file: 22.1 kB
parse/dev/XomEU3eNeSQ/images/651fa4a2e3e81efd640052f4f33fcf41d8f0875c0ad82731059fb63ae694de7a.jpg ADDED

Git LFS Details

  • SHA256: 50e1ee8f23a4695b585887acd31097f2f4e2d1db45930098db8f7af038f12c4a
  • Pointer size: 130 Bytes
  • Size of remote file: 96.7 kB
parse/dev/XomEU3eNeSQ/images/67e27b13a5225e3092af07df97dfe5fc2727543895d151e9cf5e51c620a916d7.jpg ADDED

Git LFS Details

  • SHA256: 9e7904a1f344e98c37234a73062faad7281b496da32f69951c7858bf3d1e732c
  • Pointer size: 129 Bytes
  • Size of remote file: 5.75 kB
parse/dev/XomEU3eNeSQ/images/7aaff504a40d9f97e9a41b52a142de4e43df4ca079d672ea6bfe3d5f8ca0e5d7.jpg ADDED

Git LFS Details

  • SHA256: c768e70e58d5a2adebb687558ec5d1b3a5c4eb03102341d10667c9d9187e569c
  • Pointer size: 129 Bytes
  • Size of remote file: 1.52 kB
parse/dev/XomEU3eNeSQ/images/7e15dcea4c48b75ca7907c02567b65df35da89817d5747f2b5a9df593cc756ce.jpg ADDED

Git LFS Details

  • SHA256: fc4ffd3ccae151c9691dc35c5e2e6702e460d4006648948df0c1cfb3c9337c27
  • Pointer size: 129 Bytes
  • Size of remote file: 2.77 kB
parse/dev/XomEU3eNeSQ/images/85abb3da4270dbbb992fa1474193e83f36d82a2bb3066c4dc5d5888fbc1bdd8a.jpg ADDED

Git LFS Details

  • SHA256: b40c50705a518cb58f513c9aa9f5e4fe0dbc3a79c5abd89f104e144aed426574
  • Pointer size: 130 Bytes
  • Size of remote file: 19.2 kB
parse/dev/XomEU3eNeSQ/images/8a089c4b019fc78f435073466a50637f17be885f415a3fa5ffeb9da9e9c26ae0.jpg ADDED

Git LFS Details

  • SHA256: 53b83bb3eed56026f5a696d5532145a3092a1c9f367c40d36c32616a25b46d2d
  • Pointer size: 131 Bytes
  • Size of remote file: 107 kB
parse/dev/XomEU3eNeSQ/images/90a5e988f3483d0037d74465b54b9b166b3ff5748a8ee26c21d112bfb591a3fc.jpg ADDED

Git LFS Details

  • SHA256: 0280a9171cf37a8526fe95f56cbb943a344852db5154f7285374988b89ebcb71
  • Pointer size: 130 Bytes
  • Size of remote file: 56.5 kB
parse/dev/XomEU3eNeSQ/images/a00ae687357974f6d98dcf75658ac3e028243c152551284da61c1deb1abdd7ae.jpg ADDED

Git LFS Details

  • SHA256: e82ff7b35de450e07def034fb948b86e909f56d56a8cd6292380267fb969a33a
  • Pointer size: 129 Bytes
  • Size of remote file: 5.76 kB
parse/dev/XomEU3eNeSQ/images/a3fb548bd758d8295d507b87b8ee73f25aab1c16584606dce010463f0238d398.jpg ADDED

Git LFS Details

  • SHA256: de91453fb2808b45170bb0d14fbec185de1957f6e8467f61a5293b7412e0374d
  • Pointer size: 130 Bytes
  • Size of remote file: 45.3 kB
parse/dev/XomEU3eNeSQ/images/b563baa1009fda55bb5385051fe02084c106c1ce23b52e759d38b47fdf0ff149.jpg ADDED

Git LFS Details

  • SHA256: 9852c5189116e2a81173915b5228111ee164df9e0c1f2de8504f70db9c02e0fa
  • Pointer size: 131 Bytes
  • Size of remote file: 118 kB
parse/dev/XomEU3eNeSQ/images/c29b3950a88fe4f248abeed7fc389851c6a8803d4218b21d151f93ee7b37bb9f.jpg ADDED

Git LFS Details

  • SHA256: 0b0b51fd1c94423930d9e06819dd0f0feea326e830d80d3541909fb2d47325c1
  • Pointer size: 131 Bytes
  • Size of remote file: 116 kB
parse/dev/XomEU3eNeSQ/images/c6d5185f61ecb1d679f8470f8bb5d4104b7692dffb819bb4c91a810f5d2df200.jpg ADDED

Git LFS Details

  • SHA256: ced114cb19f89fb99c4779a2d0fef2c44596458ea15aa94ac6321216d4c16be6
  • Pointer size: 130 Bytes
  • Size of remote file: 24.5 kB
parse/dev/XomEU3eNeSQ/images/c7454aefe570e7c6e4bca1ec79ea535cba3debd650acdb8eb85ad2b88385c2be.jpg ADDED

Git LFS Details

  • SHA256: a3770350b6392f16a4571351c162974c4ad583a0f5690f4779dea06fd700c56d
  • Pointer size: 129 Bytes
  • Size of remote file: 6.49 kB
parse/dev/XomEU3eNeSQ/images/fdeb2385788b4500407cc540b7746c1cadb5a7b84050bf06ba7bc5aba863fcd5.jpg ADDED

Git LFS Details

  • SHA256: 72ca283964ecc1804ccc6109f54b65028bc9288d9eb2bfbc4c9c6731f7612caf
  • Pointer size: 129 Bytes
  • Size of remote file: 1.62 kB
parse/dev/XrGEkCOREX2/XrGEkCOREX2.md ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MEMO: Test Time Robustness via Adaptation and Augmentation
2
+
3
+ Marvin Zhang1, Sergey Levine1, Chelsea Finn2 1UC Berkeley 2Stanford University
4
+
5
+ # Abstract
6
+
7
+ While deep neural networks can attain good accuracy on in-distribution test points, many applications require robustness even in the face of unexpected perturbations in the input, changes in the domain, or other sources of distribution shift. We study the problem of test time robustification, i.e., using the test input to improve model robustness. Recent prior works have proposed methods for test time adaptation, however, they each introduce additional assumptions, such as access to multiple test points, that prevent widespread adoption. In this work, we aim to study and devise methods that make no assumptions about the model training process and are broadly applicable at test time. We propose a simple approach that can be used in any test setting where the model is probabilistic and adaptable: when presented with a test example, perform different data augmentations on the data point, and then adapt (all of) the model parameters by minimizing the entropy of the model’s average, or marginal, output distribution across the augmentations. Intuitively, this objective encourages the model to make the same prediction across different augmentations, thus enforcing the invariances encoded in these augmentations, while also maintaining confidence in its predictions. In our experiments, we evaluate two baseline ResNet models, two robust ResNet-50 models, and a robust vision transformer model, and we demonstrate that this approach achieves accuracy gains of $1 \%$ over standard model evaluation and also generally outperforms prior augmentation and adaptation strategies. For the setting in which only one test point is available, we achieve state-of-the-art results on the ImageNet-C, ImageNet-R, and, among ResNet-50 models, ImageNet-A distribution shift benchmarks.
8
+
9
+ # 1 Introduction
10
+
11
+ Deep neural network models have achieved excellent performance on many machine learning problems, such as image classification, but are often brittle and susceptible to issues stemming from distribution shift. For example, deep image classifiers may degrade precipitously in accuracy when encountering input perturbations, such as noise or changes in lighting $[ \hat { \left| 1 2 \right| } ]$ or domain shifts which occur naturally in real world applications $\mathbb { \left| \mathbb { Z } \right\| }$ . Therefore, robustification of deep models against these test shifts is an important and active area of study.
12
+
13
+ Most prior works in this area have focused on techniques for training time robustification, including utilizing larger models and datasets $\pmb { \mathbb { B 4 } }$ , various forms of adversarial training $\mathbb { B 9 } \mathbb { H 8 }$ , and aggressive data augmentation [51, 13, 24, 14]. Employing these techniques requires modifying the training process, which may not be feasible if, e.g., it involves heavy computation or non public data. Furthermore, these techniques do not rely on any information about the test points that the model must predict on, even though these test points may provide significant information for improving model robustness. Recently, several works have proposed methods for improving accuracy via adaptation after seeing the test data, typically by updating a subset of the model’s weights [44, 45, 18], normalization statistics [40], or both [46, 52]. Though effective at handling test shifts, these methods sometimes still require specialized training procedures, and they typically rely on extracting information via batches or even entire sets of test inputs, thus introducing additional assumptions.
14
+
15
+ ![](images/695fdc8d76523d7ae12f1252c94b960f4f9aeeee940045c10e43759d62a658f6.jpg)
16
+ Figure 1: Left: at test time, as detailed in $\mathsf { \overline { { S e c t i o n 3 } } } ,$ we have a single test input $\mathbf { x }$ , a set of data augmentation functions $\{ a _ { 1 } , \dotsc , a _ { M } \}$ , and a trained model that outputs a probabilistic predictive distribution and has adaptable parameters $\theta$ . We perform different augmentations on $\mathbf { x }$ and pass these augmented inputs to the model in order to estimate the marginal output distribution averaged over augmentations. Right: we perform a gradient update on the model to minimize the entropy of this marginal distribution, thus encouraging the model predictions to be invariant across different augmentations while maintaining confident predictions. The final prediction is then made on the original data point, i.e., the predictive distribution in the top right of the schematic.
17
+
18
+ In this work, we focus on methods for test time robustness, in which the specific test input may be leveraged in order to improve the model’s prediction on that point. We are interested in studying and devising methods for improving model robustness that are “plug and play”, i.e., they can be readily used with a wide variety of pretrained models and test settings. We also want methods that synergize with other robustification techniques, in order to achieve greater performance than using either in isolation. With these goals in mind, we devise a novel test time robustness method based on adaptation and augmentation. As illustrated in $\mathbb { F i g u r e 1 } ,$ when presented with a test point, we adapt the model by augmenting the test point in different ways while encouraging the model to make consistent predictions, thus respecting the invariances encoded in the data augmentations. We further encourage the model to make confident predictions, thus arriving at the proposed method: minimize the marginal entropy of the model’s predictions across the augmented versions of the test point.
19
+
20
+ We refer to the proposed method as marginal entropy minimization with one test point (MEMO), and this is the primary contribution of our work. MEMO makes direct use of pretrained models without any assumptions about their particular training procedure or architecture, while requiring only a single test input for adaptation. In Section 4, we demonstrate empirically that MEMO consistently improves the performance of ResNet [11] and vision transformer $\mathbb { \overline { { | \overline { { \mathbb { Z } } | } } } }$ models on several challenging ImageNet distribution shift benchmarks, achieving several new state-of-the-art results for these models in the setting in which only one test point is available. MEMO consistently outperforms non adaptive marginal distribution predictions (between $1 - 1 0 \%$ improvement) on the ImageNet-C [12] and ImageNet-R [14] test sets, indicating that adaptation plays a crucial role in improving predictive accuracy. MEMO encourages both invariance across augmentations and confident predictions, and an ablation study in Section 4 shows that both components are important for maximal performance gains. Also, MEMO is, to the best of our knowledge, the first adaptation method to improve performance (by $1 \%$ over standard model evaluation) on the ImageNet-A test set $\mathbb { \lVert 1 5 \rVert }$ .
21
+
22
+ # 2 Related work
23
+
24
+ Distribution shift has been studied under a number of frameworks $\pmb { \mathbb { B } } 6 \|$ , including domain adaptation [41, 6, 47], domain generalization [5, 32, 9], and distributionally robust optimization [4, 16, 39]. These frameworks typically leverage additional training or test assumptions in order to make the distribution shift problem more tractable. Largely separate from these frameworks, various empirical methods have also been proposed for dealing with shift, such as increasing the model and training dataset size or using heavy training augmentations [34, 51, 14]. The focus of this work is complementary to these efforts: MEMO is applicable to a wide range of pretrained models, including those trained via robustness methods, and can achieve further performance gains via test time adaptation.
25
+
26
+ Prior test time adaptation methods generally either make significant training or test time assumptions. Some methods update the model using batches or even entire datasets of test inputs, such as by computing batch normalization (BN) statistics on the test set [25, 19, 33, 40], computing class prototypes $\mathbb { \lVert \rVert }$ , or minimizing the (conditional) entropy of model predictions across a batch of test data $\lVert \overline { { 4 6 } } \rVert$ . The latter approach is closely related to MEMO. The differences are that MEMO minimizes marginal entropy using single test points and data augmentation and adapts all of the model parameters rather than just those associated with normalization layers, thus not requiring multiple test points or specific model architectures. Other test time adaptation methods can be applied to single test points but require specific training procedures or models [44, 17, 40, 1, 3]. Test time training (TTT) $\underline { { \lVert \varPsi \ 4 \rVert } }$ requires a specialized model with a rotation prediction head and a different procedure for training this model. Schneider et al. [40] show that BN adaptation can be effective even with only one test point. As we discuss in Section 3, MEMO synergizes well with this technique of “single point” BN adaptation. Mao et al. [29] propose a test time adaptation method based on input perturbations for robustness to adversarial attacks. Concurrently with our work, Sivaprasad and Fleuret $\mathbb { \lVert \rVert 3 \rVert }$ propose a similar method for test time adaptation by encouraging invariance to data augmentations, and they test their method on the corrupted CIFAR and VisDA [35] datasets.
27
+
28
+ A number of works have noted that varying forms of strong data augmentation on the training set can improve the resulting model’s robustness [51, 13, 24, 14]. Data augmentations are also sometimes used on the test data directly by averaging the model’s outputs across augmented copies of the test point $\mathbb { \left| \overline { { 2 3 } } \right| \overline { { \sharp 2 } } }$ , i.e., predicting according to the model’s marginal output distribution. When using cropping as the augmentation, this technique is often referred to as multicrop evaluation $\pmb { \mathbb { Z } } 2 \mathbf { l }$ . We instead use the term test time augmentation (TTA), as we use additional augmentations beyond cropping $\mathbb { \lVert \lambda \rVert }$ . TTA has been shown to be useful both for improving model accuracy and calibration $\pmb { \left. 2 \right. }$ as well as handling distribution shift [31]. We take this idea one step further by explicitly adapting the model such that its marginal output distribution has low entropy. This extracts an additional learning signal for improving the model, and furthermore, the adapted model can then make its final prediction on the clean test point rather than the augmented copies. We empirically show in Section 4 that these differences lead to improved performance over this non adaptive TTA baseline.
29
+
30
+ # 3 Augmenting and Adapting at Test Time
31
+
32
+ Data augmentations are typically used to train the model to respect certain invariances – e.g., changes in lighting or viewpoint do not change the underlying class label – but, especially when faced with distribution shift, the model is not guaranteed to obey the same invariances at test time. In this section, we introduce MEMO, a method for test time robustness that adapts the model such that it respects these invariances on the test input. We use “test time robustness” specifically to refer to techniques that operate directly on pretrained models and single test inputs – single point BN adaptation and TTA, as described in $\overline { { \mathsf { S e c t i o n 2 } } }$ are examples of prior test time robustness methods.
33
+
34
+ In the test time robustness setting, we are given a trained model $f _ { \theta }$ with parameters $\theta \in \Theta$ . We do not require any special training procedure and do not make any assumptions about the model, except that $\theta$ is adaptable and that $f _ { \theta }$ produces a conditional output distribution $p _ { \boldsymbol { \theta } } ( y | \mathbf { x } )$ that is differentiable with respect to $\theta . ^ { 1 }$ All standard deep neural network models satisfy these assumptions. A single point $\mathbf { x } \in \mathcal { X }$ is presented to $f _ { \theta }$ , for which it must predict a label $\hat { y } \in \mathcal { V }$ immediately. Note that this is precisely identical to the standard test time inference procedure for regular supervised learning models – in effect, we are simply modifying how inference is done, without any additional assumptions on the training process or on test time data availability. This makes test time robustness methods a simple “slot-in” replacement for the ubiquitous and standard test time inference process. We assume sampling access to a set of augmentation functions $\mathcal { A } \triangleq \{ a _ { 1 } , \ldots , a _ { M } \}$ that can be applied to the test point $\mathbf { x }$ . We use these augmentations and the self-supervised objective detailed below to adapt the model before it predicts on $\mathbf { x }$ . When given a set of test inputs, the model adapts and predicts on each test point independently. We do not assume access to any ground truth labels.
35
+
36
+ Require: trained model $f _ { \theta }$ , test point $\mathbf { x }$ , number of augmentations $B$ , learning rate $\eta$ , update rule $G$
37
+ 1: Sample $a _ { 1 } , \dots , a _ { B } \overset { \mathrm { i . i . d . } } { \sim } \mathcal { U } ( A )$ and produce augmented points $\tilde { \mathbf { x } } _ { i } = a _ { i } ( \mathbf { x } )$ for $i \in \{ 1 , \ldots , B \}$
38
+ 2: Compute estimate $\begin{array} { r } { \tilde { p } = \frac { 1 } { B } \sum _ { i = 1 } ^ { B } p _ { \theta } ( y | \tilde { \mathbf { x } } _ { i } ) \approx \bar { p } _ { \theta } ( y | \mathbf { x } ) } \end{array}$ and $\tilde { \ell } = H ( \tilde { p } ) \approx \ell ( \theta ; { \mathbf x } )$ , i.e., Eq. 2
39
+ 3: Adapt parameters via update rule $\theta ^ { \prime } G ( \theta , \eta , \tilde { \ell } )$
40
+ 4: Predict $\hat { y } \triangleq \arg \operatorname* { m a x } _ { y } p _ { \theta ^ { \prime } } ( y | \mathbf { x } )$
41
+
42
+ # 3.1 Marginal Entropy Minimization with One test point
43
+
44
+ Given a test point $\mathbf { x }$ and set of augmentation functions $\mathcal { A }$ , we sample $B$ augmentations from $\mathcal { A }$ and apply them to $\mathbf { x }$ in order to produce a batch of augmented data $\tilde { \mathbf { x } } _ { 1 } , \ldots , \tilde { \mathbf { x } } _ { B }$ . The model’s average, or marginal, output distribution with respect to the augmented points is given by
45
+
46
+ $$
47
+ \bar { p } _ { \theta } ( y | \mathbf { x } ) \triangleq \mathbb { E } _ { \mathcal { U } ( \mathcal { A } ) } \left[ p _ { \theta } ( y | a ( \mathbf { x } ) ) \right] \approx \frac { 1 } { B } \sum _ { i = 1 } ^ { B } p _ { \theta } ( y | \tilde { \mathbf { x } } _ { i } ) ,
48
+ $$
49
+
50
+ where the expectation is with respect to uniformly sampled augmentations $a \sim \mathcal { U } ( A )$ .
51
+
52
+ What properties do we desire from this marginal distribution? To answer this question, consider the role that data augmentation typically serves during training. For each training point $\left( { \bf x } ^ { \mathrm { t r a i n } } , y ^ { \mathrm { t r a i n } } \right)$ , the model $f _ { \theta }$ is trained using multiple augmented forms of the input $\tilde { \mathbf { x } } _ { 1 } ^ { \mathrm { t r a i n } } , \ldots , \tilde { \mathbf { x } } _ { E } ^ { \mathrm { t r a i n } }$ . $f$ is trained to obey the invariances between the augmentations and the label – no matter the augmentation on $\mathbf { x } ^ { \mathrm { t r a i n } }$ , $f$ should predict, with confidence, the same label $y ^ { \mathrm { t r a i n } }$ . We seek to devise a similar learning signal during test time, without any ground truth labels. That is, after adapting:
53
+
54
+ (1) the model $f _ { \theta }$ predictions should be invariant across augmented versions of the test point, and (2) the model $f _ { \theta }$ should be confident in its predictions, even for heavily augmented versions of the test point, since all versions have the same underlying label.
55
+
56
+ Optimizing the model for more confident predictions can be justified from the assumption that the true underlying decision boundaries between classes lie in low density regions of the data space $\textcircled { 8 }$ . With these two goals in mind, we propose to adapt the model using the entropy of its marginal output distribution over augmentations $\underline { { \operatorname { d } \dot { \operatorname { E q . } } \dot { 1 } ) } }$ , i.e.,
57
+
58
+ $$
59
+ \ell ( \theta ; \mathbf { x } ) \triangleq H \left( \bar { p } _ { \theta } ( \cdot | \mathbf { x } ) \right) = - \sum _ { y \in \mathcal { Y } } \bar { p } _ { \theta } ( y | \mathbf { x } ) \log \bar { p } _ { \theta } ( y | \mathbf { x } ) .
60
+ $$
61
+
62
+ Note that this objective is not the same as optimizing the average conditional entropy of the model’s predictive distributions across augmentations, i.e.,
63
+
64
+ $$
65
+ \ell _ { \mathrm { { C E } } } ( \boldsymbol { \theta } ; \mathbf { x } ) \triangleq \frac { 1 } { B } \sum _ { i = 1 } ^ { B } H ( p _ { \boldsymbol { \theta } } ( \cdot | \widetilde { \mathbf { x } } _ { i } ) ) .
66
+ $$
67
+
68
+ A model which predicts confidently but differently across augmentations would minimize $\operatorname { E q . 3 }$ but not $\boxed { \mathrm { E q . ~ } 2 }$ Optimizing $\operatorname { E q } . 2$ encourages both confidence and invariance, since the entropy of $\bar { p } _ { \theta } ( \cdot | \mathbf { x } )$ is minimized when the model outputs the same (confident) prediction regardless of the augmentation.
69
+
70
+ Algorithm 1 presents the overall method MEMO for test time adaptation. Though prior test time adaptation methods must carefully choose which parameters to adapt in order to avoid degenerate solutions $\lVert \overline { { 4 6 } } \rVert$ , our adaptation procedure simply adapts all of the model’s parameters $\theta$ (line 3). Given that $p _ { \boldsymbol { \theta } } ( \boldsymbol { y } | \mathbf { x } )$ is differentiable with respect to $\theta$ , we can directly use gradient based optimization to adapt $\theta$ according to $\mathbb { E } { \mathsf { q } } . 2 \mathbb { Z }$ We use only one gradient step per test point, because empirically we found this to be sufficient for improved performance while being more computationally efficient. After this step, we use the adapted model $f _ { \theta ^ { \prime } }$ to predict on the original test input $\mathbf { x }$ (line 4).
71
+
72
+ # 3.2 Composing MEMO with Prior Methods
73
+
74
+ An additional benefit of MEMO is that it synergizes with other approaches for handling distribution shift. In particular, MEMO can be composed with prior methods for training robust models and adapting model statistics, thus leveraging the performance improvements of each technique.
75
+
76
+ ![](images/6ecb312275c8b833a76347f6c7ba3d2b80f52b0b71a12da6610da54a844f0e30.jpg)
77
+ Figure 2: We visualize augmentations of a randomly chosen data point from the “Gaussian Noise level 3” ImageNet-C test set. Even for a robust model trained with heavy data augmentations [14], both its predictive accuracy and confidence (as shown in the top two rows) drop sharply when encountering test shift. As shown in the bottom two rows, these drops can be remedied via MEMO adaptation.
78
+
79
+ Pretrained robust models. Since MEMO makes no assumptions about, or modifications to, the model training procedure, performing adaptation on top of pretrained robust models, such as those trained with heavy data augmentations, is as simple as using any other pretrained model. Crucially, we find that, in practice, the set of test augmentations $\mathcal { A }$ does not have to match the augmentations that were used to train the model. For simplicity and efficiency, we use augmentations that can be easily sampled and are applied directly to the model input x. These properties do not hold for, e.g., data augmentation techniques based on image translation models, such as DeepAugment $\textcircled { 1 1 4 } \textcircled { 1 }$ , or feature mixing, such as moment exchange $\checkmark$ . However, we can still use models trained with these data augmentation techniques as our starting point for adaptation, thus allowing us to improve upon their state-of-the-art results. As noted above, using pretrained models is not as easily accomplished for adaptation methods which require complicated or specialized training procedures and model architectures, such as TTT $\mathbb { H } 4 4 \mathbb { I }$ or ARM $[ \bar { 1 } \bar { 5 } 2 ]$ . In our experiments, we use AugMix as our set of augmentations $\mathbb { \lVert \rVert 3 \rVert }$ , as it satisfies the above properties and still yields significant diversity when applied, as depicted in $\mathbb { F i g u r e 2 } $ Note that AugMix explicitly does not use augmentations that are similar to the corruptions in the CIFAR-10-C and ImageNet-C test sets [12, 13].
80
+
81
+ Adapting BN statistics. Schneider et al. $\mathbb { \left[ \left. 4 0 \right] \right. }$ showed that, even when presented with just a single test point, partially adapting the estimated mean and variance of the activations in each batch normalization (BN) layer of the model can still be effective in some cases for handling distribution shift. In this setting, to prevent overfitting to the test point, the channelwise mean and variance $[ \mu _ { \mathrm { t e s t } } , \sigma _ { \mathrm { t e s t } } ^ { 2 } ]$ estimated from this point are mixed with the the mean and variance $[ \mu _ { \mathrm { t r a i n } } , \sigma _ { \mathrm { t r a i n } } ^ { 2 } ]$ computed during training according to a prior strength $N$ . That is, for $\pmb { \nu } \in \{ \mu , \sigma ^ { 2 } \}$ ,
82
+
83
+ $$
84
+ \pmb { \nu } \triangleq \frac { N } { N + 1 } \pmb { \nu } _ { \mathrm { t r a i n } } + \frac { 1 } { N + 1 } \pmb { \nu } _ { \mathrm { t e s t } } .
85
+ $$
86
+
87
+ This technique is also straightforward to combine with MEMO: we simply use the adapted BN statistics whenever computing the model’s output distribution. We find in our experiments that this technique never degrades, and generally improves, the performance of test time adaptation, thus we combine MEMO with this technique by default whenever applicable. Following the suggestion in Schneider et al. $\mathbb { \left[ \left| 4 0 \right| \right] }$ , we set $N = 1 6$ for all of our experiments in the next section.
88
+
89
+ # 4 Experiments
90
+
91
+ Our experiments aim to answer the following questions:
92
+
93
+ (1) How does MEMO compare to prior methods for test time adaptation and test time robustness? (2) Can MEMO be combined with a wide range of model architectures and pretraining methods? (3) Which aspect of MEMO, the adaptation or augmentation, is the most important?
94
+
95
+ We evaluate MEMO on a total of five distribution shift benchmarks. We conduct CIFAR-10 [22] experiments on the CIFAR-10-C [12] and CIFAR-10.1 [37] test sets, and we conduct ImageNet [38] experiments on the ImageNet-C [12], ImageNet-R [14], and ImageNet-A [15] test sets.
96
+
97
+ To answer question (1), we compare to test time training (TTT) [44] in the CIFAR-10 experiments, for which we train ResNet-26 models following their protocol and specialized architecture. We do not compare to TTT for the ImageNet experiments due to the computational demands of training state-of-the-art models and because Sun et al. [44] do not report competitive ImageNet results. For the ImageNet experiments, we compare to Tent $[ \overline { { | 4 6 | } }$ and BN adaptation, which can be used with pretrained models but require multiple test inputs (or even the entire test set) for adaptation. We provide BN adaptation with 256 test inputs at a time and set the prior strength $N = 2 5 6$ [40].
98
+
99
+ For Tent, we use test batch sizes of 64 and, for ResNet-50 models, test both “online” adaptation – where the model adapts continually through the entire evaluation – and “episodic” adaptation – where the model is reset after each test batch $\overline { { \lVert \textcircled { 4 6 } \rVert } }$ . Note that the evaluation protocols are different for these two methods: whereas MEMO is tasked with predicting on each test point immediately after adaptation, BN adaptation predicts on a batch of 256 test points after computing BN statistics on the batch, and Tent predicts on a batch of 64 inputs after adaptation but also, in the online setting, continually adapts throughout evaluation. In all experiments, we further compare to single point BN adaptation $\mathbb { \left[ \left| 4 0 \right| \right] }$ and the TTA baseline that simply predicts according to $\bar { p } _ { \boldsymbol { \theta } } ( y | \mathbf { \bar { x } } )$ (Eq. 1) [23, 2]. Full details on our experimental protocol are provided in Appendix A.
100
+
101
+ To answer question (2), we apply MEMO on top of multiple pretrained models with different architectures, trained via several different procedures. For CIFAR-10, we train our own ResNet26 [11] models. For ImageNet, we use the best performing ResNet-50 robust models from prior work, which includes those trained with DeepAugment and AugMix augmentations $[ \textcircled { 1 4 } ]$ as well as those trained with moment exchange and CutMix $\pmb { \Vert 2 4 \Vert }$ . To evaluate the generality of prior test time robustness methods and MEMO, we also evaluate the small robust vision transformer $\mathrm { R V T ^ { * } }$ -small), which provides superior performance on all three ImageNet distribution shift benchmarks compared to the robust ResNet-50 models $\pmb { \mathbb { B } } \pmb { \mathrm { 0 } }$ . Finally, we evaluate ResNext-101 models [50, 28] on ImageNet-A, as these models previously achieved the strongest results for this test set [14].
102
+
103
+ Finally, to answer (3), we conduct ablative studies in subsection 4.2: first to determine the relative importance of maximizing confidence (via entropy minimization) versus enforcing invariant predictions across augmented copies of each test point, second to determine the importance of the particular augmentation functions used, and third to determine the required number of augmented samples per inference. The comparison to the non adaptive TTA baseline also helps determine whether simply augmenting the test point is sufficient or if adaptation is additionally helpful. In Appendix B, we provide further experiments ablating the augmentation component specifically.
104
+
105
+ # 4.1 Main Results
106
+
107
+ We summarize results for CIFAR-10, CIFAR-10.1, and CIFAR-10-C in Table 1, with full CIFAR-10- C results in Appendix C. We use indentations to indicate composition, e.g., TTT is performed at test time on top of their specialized joint training procedure. Across all corruption types in CIFAR-10-C, MEMO consistently improves test error compared to the baselines, non adaptive TTA, and TTT. MEMO also provides a larger performance gain on CIFAR-10.1 compared to TTT. We find that the non adaptive TTA baseline is competitive for these relatively simple test sets, though it is worse than MEMO for CIFAR-10-C. Of these three test sets, CIFAR-10-C is the only benchmark that explicitly introduces distribution shift, which suggests that adaptation is useful when the test shifts are more prominent. Both TTA and MEMO are also effective at improving performance for the original CIFAR-10 test set where there is no distribution shift, providing further support for the widespread use of augmentations in standard evaluation protocols [23, 2].
108
+
109
+ Table 1: Results for CIFAR-10, CIFAR-10.1, and CIFAR-10-C. ?Results from Sun et al. [44].
110
+
111
+ <table><tr><td></td><td>CIFAR-10 Error (%)</td><td>CIFAR-10.1 Error (%)</td><td>CIFAR-10-C Average Error (%)</td></tr><tr><td>ResNet-26 □</td><td>9.2</td><td>18.4</td><td>22.5</td></tr><tr><td>+TTA</td><td>7.3 (-1.9)</td><td>14.8 (-3.6)</td><td>19.9 (-2.6)</td></tr><tr><td>+ MEMO (ours)</td><td>7.3 (-1.9)</td><td>14.7 (-3.7)</td><td>19.6 (-2.9)</td></tr><tr><td>+ Joint training* 国</td><td>8.1</td><td>16.7</td><td>22.8</td></tr><tr><td>+ TTT* 因</td><td>7.9 (-0.2)</td><td>15.9 (-0.8)</td><td>21.5 (-1.3)</td></tr></table>
112
+
113
+ Table 2: Test results for the ImageNet test sets. MEMO achieves new state-of-the-art performance on each benchmark for ResNet-50 models for the single test point setting. For $\mathbf { R V T ^ { * } }$ -small, MEMO improves performance across all benchmarks and reaches a new state of the art for ImageNet-C and ImageNet-R. Compared to prior approaches, MEMO offers more consistent improvements.
114
+
115
+ <table><tr><td></td><td>ImageNet-C mCE↓</td><td>ImageNet-R Error (%)</td><td>ImageNet-A Error (%)</td></tr><tr><td>Baseline ResNet-50 自</td><td>76.7</td><td>63.9</td><td>100.0</td></tr><tr><td>+ TTA</td><td>77.9 (+1.2)</td><td>61.3 (-2.6)</td><td>98.4 (-1.6)</td></tr><tr><td>+ Single point BN</td><td>71.4 (-5.3)</td><td>61.1 (-2.8)</td><td>99.4 (-0.6)</td></tr><tr><td>+ MEMO (ours)</td><td>69.9 (-6.8)</td><td>58.8 (-5.1)</td><td>99.1 (-0.9)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>61.6 (-15.1)</td><td>59.7 (-4.2)</td><td>99.8 3(-0.2)</td></tr><tr><td>+ Tent (online) [ 46</td><td>54.4 (−22.3)</td><td>57.7 (-6.2)</td><td>99.8 (-0.2)</td></tr><tr><td>+ Tent (episodic)</td><td>64.7 (−12.0)</td><td>61.0 (-2.9)</td><td>99.7 ( (-0.3)</td></tr><tr><td> + DeepAugment+AugMix [14]</td><td>53.6</td><td>53.2</td><td>96.1</td></tr><tr><td>+ TTA</td><td>55.2 (+1.6)</td><td>51.0 (-2.2)</td><td>93.5 (-2.6)</td></tr><tr><td>+ Single point BN</td><td>51.3 (-2.3)</td><td>51.2 (-2.0)</td><td>95.4 (-0.7)</td></tr><tr><td>+ MEMO (ours)</td><td>49.8 (-3.8)</td><td>49.2 (-4.0)</td><td>94.8 (-1.3)</td></tr><tr><td>+ BN(N = 256,n = 256)</td><td>45.4 (−8.2)</td><td>48.8 (-4.4)</td><td>96.8 (+0.7)</td></tr><tr><td>+ Tent (online)</td><td>43.5 (-10.1)</td><td>46.9 (-6.3)</td><td>96.7 (+0.6)</td></tr><tr><td> + Tent (episodic)</td><td>47.1 (-6.5)</td><td>50.1 (-3.1)</td><td>96.6 (+0.5)</td></tr><tr><td>+ MoEx+CutMix 2</td><td>74.8</td><td>64.5</td><td>91.9</td></tr><tr><td>+ TTA</td><td>75.7 (+0.9)</td><td>62.7 (-1.8)</td><td>89.5 (-2.4)</td></tr><tr><td>+ Single point BN</td><td>71.0 (-3.8)</td><td>62.6 (−1.9)</td><td>91.1 (-0.8)</td></tr><tr><td>+ MEMO (ours)</td><td>69.1 (-5.7)</td><td>59.4 (-3.3)</td><td>89.0 (-2.9)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>60.9 (-13.9)</td><td>61.6 (-2.9)</td><td>93.9 (+2.0)</td></tr><tr><td>+ Tent (online)</td><td>54.0 (-20.8)</td><td>58.7 (-5.8)</td><td>94.4 (+2.5)</td></tr><tr><td>+ Tent (episodic)</td><td>66.2 (-8.6)</td><td>63.9 (-0.6)</td><td>94.7 (+2.8)</td></tr><tr><td>RVT*-small □</td><td>49.4</td><td>52.3</td><td>73.9</td></tr><tr><td>+ TTA</td><td>53.0 (+3.6)</td><td>49.0 (-3.3)</td><td>68.9 (-5.0)</td></tr><tr><td>+ Single point BN</td><td>48.0 (-1.4)</td><td>51.1 (-1.2)</td><td>74.4 (+0.5)</td></tr><tr><td>+ MEMO (ours)</td><td>40.6 (-8.8)</td><td>43.8 (-8.5)</td><td>69.8 (-4.1)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>44.3 (-5.1)</td><td>51.0 ( (-1.3)</td><td>78.3 (+4.4)</td></tr><tr><td>+ Tent (online)</td><td>46.8 (-2.6)</td><td> 50.7 (-1.6)</td><td>82.1 (+8.2)</td></tr><tr><td>+ Tent (adapt all)</td><td>44.7 (-4.7)</td><td>74.1 (+21.8)</td><td>81.1 (+7.2)</td></tr></table>
116
+
117
+ We summarize results for ImageNet-C, ImageNet-R, and ImageNet-A in Table 2, with complete ImageNet-C results in $\boxed { \mathrm { A p p e n d i x ~ C } }$ We again use indentations to indicate composition, e.g., the best results on ImageNet-C for our setting are attained through a combination of starting from a model trained with DeepAugment and AugMix [14] and using MEMO on top. For both ImageNet-C and ImageNet-R, and for both the ResNet-50 and $\mathbf { R V T ^ { * } }$ -small models, combining MEMO with robust training techniques leads to new state-of-the-art performance among methods that observe only one test point at a time. We highlight in gray the methods that require multiple test points for adaptation, and we list in bold the best results from these methods which outperform the test time robustness methods. As Table 2 and prior work both show [40, 46], accessing multiple test points can be powerful for benchmarks such as ImageNet-C and ImageNet-R, in which inferred statistics from the test input distribution may aid in prediction. However, these methods do not help, and oftentimes even hurt, for ImageNet-A. Furthermore, we find that these methods are less effective with the $\mathrm { R V T ^ { * } }$ -small model, which may indicate their sensitivity to model architecture choices. Therefore, for this model, we also test a modification of Tent which adapts all parameters, and we find that this version of Tent works better for ImageNet-C but is significantly worse for ImageNet-R.
118
+
119
+ MEMO also results in substantial improvement for ImageNet-A. No prior test time adaptation methods have reported improvements on ImageNet-A, and some have reported explicit negative results $\mathbb { H O }$ . As discussed, it is reasonable for adaptation methods that rely on multiple test points to achieve greater success on other benchmarks such as ImageNet-C, in which a batch of inputs provides significant information about the specific corruption that must be dealt with. In contrast, ImageNet-A does not have such obvious characteristics associated with the input distribution, as it is simply a collection of images that are difficult to classify. As MEMO instead extracts a learning signal from single test points, it is, to the best of our knowledge, the first test time adaptation method to report successful results on this testbed. We view the consistency with which MEMO outperforms the best prior methods, which change across different test sets, as a major advantage of the proposed method.
120
+
121
+ TTA is the most competitive prior method for ImageNet-A, e.g., it results in larger improvements than MEMO for the $\mathbf { R V T ^ { * } }$ -small model. MEMO, however, achieves state-of-the-art performance among ResNet-50 models. To further compare MEMO to TTA, in Table 3, we evaluate whether MEMO can successfully adapt ResNext-101 models $ { \Vert 5 0 \Vert }$ and further improve performance on this challenging test set. We evaluate both a ResNext-101 (32x8d) baseline model pretrained on ImageNet, as well as the same model pretrained with weakly supervised learning (WSL) on billions of Instagram images $\bar { \left\| 2 8 \right\| }$ . For the
122
+
123
+ Table 3: ImageNet-A results for the ResNext-101s.
124
+
125
+ <table><tr><td colspan="2">ImageNet-A Error (%)</td></tr><tr><td>ResNext-101 ⑤0</td><td>90.0</td></tr><tr><td>+ TTA</td><td>83.2 (-6.8)</td></tr><tr><td>+ Single point BN</td><td>88.8 (-1.2)</td></tr><tr><td>+ MEMO (ours)</td><td>84.3 (-5.7)</td></tr><tr><td>+ WSL [28]</td><td>54.9</td></tr><tr><td>+ TTA</td><td>49.1 (-5.8)</td></tr><tr><td>+ Single point BN</td><td>58.9 (+4.0)</td></tr><tr><td>+ MEMO (ours)</td><td>43.2 (−11.7)</td></tr></table>
126
+
127
+ WSL model, we did not use single point BN adaptation for MEMO as we found this technique to be actually harmful to performance, and this corroborates previous findings $\mathbb { H O }$ . From the results, we can see that, although both TTA and MEMO significantly improve upon the baseline model evaluation, MEMO ultimately achieves the best accuracy by a significant margin as it is more successful at adapting the WSL model. This suggests that MEMO may synergize well with large scale pretraining, and further exploring this combination is an interesting direction for future work.
128
+
129
+ # 4.2 Ablative Study
130
+
131
+ MEMO uses both adaptation and augmentations. In this section, we ablate the adaptation procedure and the number of augmentations, and in Appendix B we ablate the choice of augmentations.
132
+
133
+ Adaptation procedure. From the results above, we conclude that adaptation generally provides additional benefits beyond simply using TTA to predict via the marginal output distribution $\bar { p } _ { \boldsymbol { \theta } } ( y | \mathbf { x } )$ . However, we can disentangle two distinct self-supervised learning signals that may be effective for adaptation: encouraging invariant predictions across different augmentations of the test point, and encouraging confidence via entropy minimization. The marginal entropy objective in $\operatorname { \bar { E } q } . 2$ encapsulates both of these learning signals, but it cannot easily be decomposed into these pieces. We instead use two ablative adaptation methods that each only make use of one of these learning signals.
134
+
135
+ First, we consider optimizing the pairwise cross entropy between each pair of augmented points, i.e.,
136
+
137
+ $$
138
+ \ell _ { \mathrm { P C E } } ( \boldsymbol { \theta } ; \mathbf { x } ) \triangleq \frac { 1 } { B \times ( B - 1 ) } \sum _ { i = 1 } ^ { B } \sum _ { j \neq i } H ( p _ { \boldsymbol { \theta } } ( \cdot | \widetilde { \mathbf { x } } _ { i } ) , p _ { \boldsymbol { \theta } } ( \cdot | \widetilde { \mathbf { x } } _ { j } ) ) ,
139
+ $$
140
+
141
+ Where $\tilde { \mathbf { x } } _ { i }$ again refers to the $i$ -th sampled augmentation applied to $\mathbf { x }$ . Intuitively, this loss function encourages the model to adapt such that it produces the same predictive distribution for all augmentations of the test point, but it does not encourage the model to produce confident predictions.
142
+
143
+ Table 4: Ablating the adaptation objective to test pairwise cross entropy and conditional entropy (CE) based adaptation. MEMO generally performs the best, indicating that both encouraging invariance across augmentations and confidence are helpful in adapting the model.
144
+
145
+ <table><tr><td></td><td>CIFAR-10 Error (%)</td><td>CIFAR-10.1 Error (%)</td><td>CIFAR-10-C Average Error (%)</td></tr><tr><td>ResNet-26 []</td><td>9.2</td><td>18.4</td><td>22.5</td></tr><tr><td>+ MEMO (ours)</td><td>7.3 (-1.9)</td><td>14.7 (-3.7)</td><td>19.6 (-2.9)</td></tr><tr><td>l (Eq. 2) )+lPCE 一</td><td>7.6 (-1.6)</td><td>15.3 (-3.1)</td><td>20.0 (-2.5)</td></tr><tr><td>Eq.2) + lcE</td><td>7.6 (-1.6)</td><td>14.7 (-3.7)</td><td>20.0 (-2.5)</td></tr><tr><td></td><td>ImageNet-C mCE↓</td><td>ImageNet-R Error (%)</td><td>ImageNet-A Error (%)</td></tr><tr><td>RVT*-small [30]</td><td>49.4</td><td>52.3</td><td>73.9</td></tr><tr><td>+ MEMO (ours)</td><td>40.6 (-8.8)</td><td>43.8 (-8.5)</td><td>69.8 (-4.1)</td></tr><tr><td>-l (Eq. 2) + lcE</td><td>41.2 (-8.2)</td><td>44.2 (−8.1)</td><td>69.7 (-4.2)</td></tr></table>
146
+
147
+ ![](images/5eaa7e18247da47c2425c9985f500a9780838964f166482db468111dd95d274c.jpg)
148
+ Figure 3: Plotting MEMO efficiency as seconds per evaluation $\mathbf { \dot { x } }$ axis) and $\%$ test error on ImageNet-R (y axis) for the ResNet-50 models (left) and $\mathrm { R V T ^ { * } }$ -small (right) while varying $B = \{ 1 , 2 , 4 , 8 , 1 6 , 3 2 , 6 4 , 1 2 8 \}$ . Note the log scale on the $\mathbf { X }$ axis.
149
+
150
+ Conversely, as an objective that encourages confidence but not invariance, we also consider optimizing the conditional entropy objective detailed in Eq. 3. This ablation is effectively a version of the episodic variant of Tent $[ \overline { { | 4 6 | } }$ that produces augmented copies of a single test point rather than assuming access to a test batch. We first evaluate these ablations on the CIFAR-10 test sets. We use the same adaptation procedure and hyperparameters, with $\ell$ replaced with the above objectives.
151
+
152
+ The results are presented in Table 4. We see that MEMO, i.e., marginal entropy minimization, generally performs better than adaptation with either of the alternative objectives. This supports the hypothesis that both invariance across, and confidence on, the augmentations are important learning signals for self-supervised adaptation. When faced with CIFAR-10.1, we see poor performance from the pairwise cross entropy based adaptation method. On the original CIFAR-10 test set and CIFAR-10- C, the ablations perform nearly identically and uniformly worse than MEMO. To further test the $\ell _ { \mathrm { C E } }$ ablation, which is the stronger of the two ablations, we also evaluate it on the ImageNet test sets for the $\mathrm { R V T ^ { * } }$ -small model. We find that, similarly, minimizing conditional entropy generally improves performance compared to the baseline evaluation. MEMO is more performant for ImageNet-C and ImageNet-R. Adaptation via $\ell _ { \mathrm { C E } }$ performs slightly better for ImageNet-A, though for this problem and model, TTA is still the best method. Thus, MEMO results in relatively small, but consistent, performance gains compared to only maximizing confidence on the augmentations.
153
+
154
+ Number of augmentations. In Figure 3, we analyze the $\%$ test error of MEMO adaptation on ImageNet-R as a function of the efficiency of adaptation, measured in seconds per evaluation. We achieve various tradeoffs by varying the number of augmented copies $B \ =$ $\{ 1 , 2 , 4 , 8 , 1 6 , 3 2 , 6 4 , 1 2 8 \}$ . We note that small values of $B$ such as 4 and 8 can already provide significant performance gains, thus a practical tradeoff between efficiency and accuracy is possible.
155
+
156
+ For large $B$ , the wall clock time is dominated by computing the augmentations. For the baseline ResNet-50 model, single point BN adaptation requires an average of 0.0252 seconds per test point. TTA and MEMO with $B = 6 4$ are much slower – 0.7742 and 0.9746 seconds, respectively, per test point – but can be made significantly more efficient by using $B = 4$ augmented samples – 0.0631 and 0.1037 seconds, respectively. In our implementation, we do not compute augmentations in parallel, though in principle this is possible for AugMix and should drastically improve efficiency overall. These experiments used four Intel Xeon Skylake 6130 CPUs and one NVIDIA TITAN RTX GPU.
157
+
158
+ # 5 Discussion
159
+
160
+ We presented MEMO, a method for test time robustification again distribution shift via adaptation and augmentation. MEMO does not require access or changes to the model training procedure and is thus broadly applicable for a wide range of model architectures pretrained in a number of different ways. Furthermore, MEMO adapts at test time using single test inputs, thus it does not assume access to multiple test points as in several recent methods for test time adaptation $\mathbb { H O } \mathbb { H } \mathbb { H }$ . On a range of CIFAR-10 and ImageNet distribution shift benchmarks, and for ResNet, vision transformer, and, to an extent, ResNext models, MEMO consistently improves performance at test time and achieves several new state-of-the-art results for these models in the single test point setting.
161
+
162
+ Inference via MEMO is more computationally expensive than standard model inference due to its augmentation and adaptation procedure – though, as the experiments above show, more favorable tradeoffs between efficiency and accuracy are possible with smaller values of $B$ , the number of augmentations per test point. One interesting direction for future work is to develop techniques for selectively determining when to adapt the model in order to achieve more efficient inference. For example, with well calibrated models $[ \mathbb { 1 0 } ]$ , we may run simple “feedforward” inference when the prediction confidence is over a certain threshold, thus achieving better efficiency. Additionally, it would be interesting to explore MEMO in the test setting where the model is allowed to continually adapt as more test data is observed. In our preliminary experiments in this setting, MEMO tended to lead to degenerate solutions, e.g., the model predicting a constant label with maximal confidence regardless of the input. This failure mode may potentially be rectified by carefully choosing which parameters to adapt, such as only adapting the parameters in BN layers $\boxed { \boxplus 6 }$ , or regularizing the model such that it does not change too drastically from the pretrained model [26].
163
+
164
+ # Acknowledgments and Disclosure of Funding
165
+
166
+ We thank members of the Robotic AI and Learning Lab and Berkeley AI Research for helpful discussions and feedback. MZ was supported in part by an NDSEG fellowship. CF is a CIFAR fellow. This research was partially supported by ARL DCIST CRA W911NF-17-2-0181 and ARO W911NF-21-1-0097.
167
+
168
+ # References
169
+
170
+ [1] F. Alet, M. Bauza, K. Kawaguchi, N. Kuru, T. Lozano-Pérez, and L. Kaelbling. Tailoring: Encoding inductive biases by optimizing unsupervised objectives at prediction time. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
171
+ [2] A. Ashukha, A. Lyzhov, D. Molchanov, and D. Vetrov. Pitfalls of in-domain uncertainty estimation and ensembling in deep learning. In International Conference on Learning Representations (ICLR), 2020.
172
+ [3] A. Bartler, A. Bühler, F. Wiewel, M. Döbler, and B. Yang. MT3: Meta test-time training for self-supervised test-time adaption. In International Conference on Artificial Intelligence and Statistics (AISTATS), 2022.
173
+ [4] A. Ben-Tal, D. den Hertog, A. De Waegenaere, B. Melenberg, and G. Rennen. Robust solutions of optimization problems affected by uncertain probabilities. Management Science, 2013. [5] G. Blanchard, G. Lee, and C. Scott. Generalizing from several related classification tasks to a new unlabeled sample. In Advances in Neural Information Processing Systems (NIPS), 2011. [6] G. Csurka. Domain adaptation for visual applications: A comprehensive survey. arXiv preprint arXiv:1702.05374, 2017. [7] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit, and N. Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021. [8] Y. Grandvalet and Y. Bengio. Semi-supervised learning by entropy minimization. In Advances in Neural Information Processing Systems (NIPS), 2005. [9] I. Gulrajani and D. Lopez-Paz. In search of lost domain generalization. In International Conference on Learning Representations (ICLR), 2021.
174
+ [10] C. Guo, G. Pleiss, Y. Sun, and K. Weinberger. On calibration of modern neural networks. In International Conference on Machine Learning (ICML), 2017.
175
+ [11] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Conference on Computer Vision and Pattern Recognition (CVPR), 2016.
176
+ [12] D. Hendrycks and T. Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations (ICLR), 2019.
177
+ [13] D. Hendrycks, N. Mu, E. Cubuk, B. Zoph, J. Gilmer, and B. Lakshminarayanan. AugMix: A simple data processing method to improve robustness and uncertainty. In International Conference on Learning Representations (ICLR), 2020.
178
+ [14] D. Hendrycks, S. Basart, N. Mu, S. Kadavath, F. Wang, E. Dorundo, R. Desai, T. Zhu, S. Parajuli, M. Guo, D. Song, J. Steinhardt, and J. Gilmer. The many faces of robustness: A critical analysis of out-of-distribution generalization. In IEEE International Conference on Computer Vision (ICCV), 2021.
179
+ [15] D. Hendrycks, K. Zhao, S. Basart, J. Steinhardt, and D. Song. Natural adversarial examples. In Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
180
+ [16] W. Hu, G. Niu, I. Sato, and M. Sugiyama. Does distributionally robust supervised learning give robust classifiers? In International Conference on Machine Learning (ICML), 2018.
181
+ [17] Y. Huang, J. Gornet, S. Dai, Z. Yu, T. Nguyen, D. Tsao, and A. Anandkumar. Neural networks with recurrent generative feedback. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
182
+ [18] Y. Iwasawa and Y. Matsuo. Test-time classifier adjustment module for model-agnostic domain generalization. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
183
+ [19] A. Kaku, S. Mohan, A. Parnandi, H. Schambra, and C. Fernandez-Granda. Be like water: Robustness to extraneous variables via adaptive feature normalization. arXiv preprint arXiv:2002.04019, 2020.
184
+ [20] D. Kingma and J. Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015.
185
+ [21] P. Koh, S. Sagawa, H. Marklund, S. Xie, M. Zhang, A. Balsubramani, W. Hu, M. Yasunaga, R. Phillips, I. Gao, T. Lee, E. David, I. Stavness, W. Guo, B. Earnshaw, I. Haque, S. Beery, J. Leskovec, A. Kundaje, E. Pierson, S. Levine, C. Finn, and P. Liang. WILDS: A benchmark of in-the-wild distribution shifts. In International Conference on Machine Learning (ICML), 2021.
186
+ [22] A. Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
187
+ [23] A. Krizhevsky, I. Sutskever, and G. Hinton. ImageNet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems (NIPS), 2012.
188
+ [24] B. Li, F. Wu, S. Lim, S. Belongie, and K. Weinberger. On feature normalization and data augmentation. In Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
189
+ [25] Y. Li, N. Wang, J. Shi, J. Liu, and X. Hou. Revisiting batch normalization for practical domain adaptation. In International Conference on Learning Representations Workshop (ICLRW), 2017.
190
+ [26] Y. Liu, P. Kothari, B. van Delft, B. Bellot-Gurlet, T. Mordan, and A. Alahi. $\mathrm { T T T } { + } { + }$ : When does self-supervised test-time training fail or thrive? In Advances in Neural Information Processing Systems (NeurIPS), 2021.
191
+ [27] I. Loshchilov and F. Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019.
192
+ [28] D. Mahajan, R. Girshick, V. Ramanathan, K. He, M. Paluri, Y. Li, A. Bharambe, and L. van der Maaten. Exploring the limits of weakly supervised pretraining. In European Conference on Computer Vision (ECCV), 2018.
193
+ [29] C. Mao, M. Chiquier, H. Wang, J. Yang, and C. Vondrick. Adversarial attacks are reversible with natural supervision. In IEEE International Conference on Computer Vision (ICCV), 2021.
194
+ [30] X. Mao, G. Qi, Y. Chen, X. Li, R. Duan, S. Ye, Y. He, and H. Xue. Towards robust vision transformer. In Conference on Computer Vision and Pattern Recognition (CVPR), 2022.
195
+ [31] D. Molchanov, A. Lyzhov, Y. Molchanova, A. Ashukha, and D. Vetrov. Greedy policy search: A simple baseline for learnable test-time augmentation. In Conference on Uncertainty in Artificial Intelligence (UAI), 2020.
196
+ [32] K. Muandet, D. Balduzzi, and B. Schölkopf. Domain generalization via invariant feature representation. In International Conference on Machine Learning (ICML), 2013.
197
+ [33] Z. Nado, S. Padhy, D. Sculley, A. D’Amour, B. Lakshminarayanan, and J. Snoek. Evaluating prediction-time batch normalization for robustness under covariate shift. arXiv preprint arXiv:2006.10963, 2020.
198
+ [34] A. Orhan. Robustness properties of Facebook’s ResNeXt WSL models. arXiv preprint arXiv:1907.07640, 2019.
199
+ [35] X. Peng, B. Usman, N. Kaushik, J. Hoffman, D. Wang, and K. Saenko. VisDA: The visual domain adaptation challenge. arXiv preprint arXiv:1710.06924, 2017.
200
+ [36] J. Quiñonero Candela, M. Sugiyama, A. Schwaighofer, and N. Lawrence. Dataset Shift in Machine Learning. The MIT Press, 2009.
201
+ [37] B. Recht, R. Roelofs, L. Schmidt, and V. Shankar. Do CIFAR-10 classifiers generalize to CIFAR-10? arXiv preprint arXiv:1806.00451, 2018.
202
+ [38] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, A. Berg, and F. Li. Imagenet large scale visual recognition challenge. International Journal of Computer Vision (IJCV), 2015.
203
+ [39] S. Sagawa, P. Koh, T. Hashimoto, and P. Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. In International Conference on Learning Representations (ICLR), 2020.
204
+ [40] S. Schneider, E. Rusak, L. Eck, O. Bringmann, W. Brendel, and M. Bethge. Improving robustness against common corruptions by covariate shift adaptation. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
205
+ [41] H. Shimodaira. Improving predictive inference under covariate shift by weighting the loglikelihood function. Journal of Statistical Planning and Inference (JSPI), 2000.
206
+ [42] C. Shorten and T. Khoshgoftaar. A survey on image data augmentation for deep learning. Journal of Big Data, 2019.
207
+ [43] P. Sivaprasad and F. Fleuret. Test time adaptation through perturbation robustness. arXiv preprint arXiv:2110.10232, 2021.
208
+ [44] Y. Sun, X. Wang, Z. Liu, J. Miller, A. Efros, and M. Hardt. Test-time training with selfsupervision for generalization under distribution shifts. In International Conference on Machine Learning (ICML), 2020.
209
+ [45] T. Varsavsky, M. Orbes-Arteaga, C. Sudre, M. Graham, P. Nachev, and M. Cardoso. Test-time unsupervised domain adaptation. arXiv preprint arXiv:2010.01926, 2020.
210
+ [46] D. Wang, E. Shelhamer, S. Liu, B. Olshausen, and T. Darrell. Tent: Fully test-time adaptation by entropy minimization. In International Conference on Learning Representations (ICLR), 2021.
211
+ [47] G. Wilson and D. Cook. A survey of unsupervised deep domain adaptation. ACM Transactions on Intelligent Systems and Technology (TIST), 2020.
212
+ [48] E. Wong, L. Rice, and J. Kolter. Fast is better than free: Revisiting adversarial training. In International Conference on Learning Representations (ICLR), 2020.
213
+ [49] Y. Wu and K. He. Group normalization. In European Conference on Computer Vision (ECCV), 2018.
214
+ [50] S. Xie, R. Girshick, P. Dollár, Z. Tu, and K. He. Aggregated residual transformations for deep neural networks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2017.
215
+ [51] D. Yin, R. Lopes, J. Shlens, E. Cubuk, and J. Gilmer. A Fourier perspective on model robustness in computer vision. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
216
+ [52] M. Zhang, H. Marklund, A. Gupta, S. Levine, and C. Finn. Adaptive risk minimization: Learning to adapt to domain shift. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
217
+
218
+ # Checklist
219
+
220
+ 1. For all authors...
221
+
222
+ (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes]
223
+ (b) Did you describe the limitations of your work? [Yes] See Section 5.
224
+ (c) Did you discuss any potential negative societal impacts of your work? [No]
225
+ (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
226
+
227
+ 2. If you are including theoretical results...
228
+
229
+ (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]
230
+
231
+ 3. If you ran experiments...
232
+
233
+ (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See supplementary material.
234
+ (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix A.
235
+ (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A]
236
+ (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [No]
237
+
238
+ 4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
239
+
240
+ (a) If your work uses existing assets, did you cite the creators? [Yes]
241
+ (b) Did you mention the license of the assets? [No] All assets are publicly and freely available.
242
+ (c) Did you include any new assets either in the supplemental material or as a URL? [No]
243
+ (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A]
244
+ (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
245
+
246
+ 5. If you used crowdsourcing or conducted research with human subjects...
247
+
248
+ (a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A]
249
+ (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A]
250
+ (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]
parse/dev/XrGEkCOREX2/XrGEkCOREX2_content_list.json ADDED
@@ -0,0 +1,1059 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "MEMO: Test Time Robustness via Adaptation and Augmentation ",
5
+ "text_level": 1,
6
+ "bbox": [
7
+ 289,
8
+ 122,
9
+ 707,
10
+ 172
11
+ ],
12
+ "page_idx": 0
13
+ },
14
+ {
15
+ "type": "text",
16
+ "text": "Marvin Zhang1, Sergey Levine1, Chelsea Finn2 1UC Berkeley 2Stanford University ",
17
+ "bbox": [
18
+ 333,
19
+ 224,
20
+ 663,
21
+ 255
22
+ ],
23
+ "page_idx": 0
24
+ },
25
+ {
26
+ "type": "text",
27
+ "text": "Abstract ",
28
+ "text_level": 1,
29
+ "bbox": [
30
+ 462,
31
+ 290,
32
+ 535,
33
+ 308
34
+ ],
35
+ "page_idx": 0
36
+ },
37
+ {
38
+ "type": "text",
39
+ "text": "While deep neural networks can attain good accuracy on in-distribution test points, many applications require robustness even in the face of unexpected perturbations in the input, changes in the domain, or other sources of distribution shift. We study the problem of test time robustification, i.e., using the test input to improve model robustness. Recent prior works have proposed methods for test time adaptation, however, they each introduce additional assumptions, such as access to multiple test points, that prevent widespread adoption. In this work, we aim to study and devise methods that make no assumptions about the model training process and are broadly applicable at test time. We propose a simple approach that can be used in any test setting where the model is probabilistic and adaptable: when presented with a test example, perform different data augmentations on the data point, and then adapt (all of) the model parameters by minimizing the entropy of the model’s average, or marginal, output distribution across the augmentations. Intuitively, this objective encourages the model to make the same prediction across different augmentations, thus enforcing the invariances encoded in these augmentations, while also maintaining confidence in its predictions. In our experiments, we evaluate two baseline ResNet models, two robust ResNet-50 models, and a robust vision transformer model, and we demonstrate that this approach achieves accuracy gains of $1 \\%$ over standard model evaluation and also generally outperforms prior augmentation and adaptation strategies. For the setting in which only one test point is available, we achieve state-of-the-art results on the ImageNet-C, ImageNet-R, and, among ResNet-50 models, ImageNet-A distribution shift benchmarks. ",
40
+ "bbox": [
41
+ 233,
42
+ 321,
43
+ 766,
44
+ 627
45
+ ],
46
+ "page_idx": 0
47
+ },
48
+ {
49
+ "type": "text",
50
+ "text": "1 Introduction ",
51
+ "text_level": 1,
52
+ "bbox": [
53
+ 174,
54
+ 654,
55
+ 310,
56
+ 670
57
+ ],
58
+ "page_idx": 0
59
+ },
60
+ {
61
+ "type": "text",
62
+ "text": "Deep neural network models have achieved excellent performance on many machine learning problems, such as image classification, but are often brittle and susceptible to issues stemming from distribution shift. For example, deep image classifiers may degrade precipitously in accuracy when encountering input perturbations, such as noise or changes in lighting $[ \\hat { \\left| 1 2 \\right| } ]$ or domain shifts which occur naturally in real world applications $\\mathbb { \\left| \\mathbb { Z } \\right\\| }$ . Therefore, robustification of deep models against these test shifts is an important and active area of study. ",
63
+ "bbox": [
64
+ 174,
65
+ 685,
66
+ 825,
67
+ 768
68
+ ],
69
+ "page_idx": 0
70
+ },
71
+ {
72
+ "type": "text",
73
+ "text": "Most prior works in this area have focused on techniques for training time robustification, including utilizing larger models and datasets $\\pmb { \\mathbb { B 4 } }$ , various forms of adversarial training $\\mathbb { B 9 } \\mathbb { H 8 }$ , and aggressive data augmentation [51, 13, 24, 14]. Employing these techniques requires modifying the training process, which may not be feasible if, e.g., it involves heavy computation or non public data. Furthermore, these techniques do not rely on any information about the test points that the model must predict on, even though these test points may provide significant information for improving model robustness. Recently, several works have proposed methods for improving accuracy via adaptation after seeing the test data, typically by updating a subset of the model’s weights [44, 45, 18], normalization statistics [40], or both [46, 52]. Though effective at handling test shifts, these methods sometimes still require specialized training procedures, and they typically rely on extracting information via batches or even entire sets of test inputs, thus introducing additional assumptions. ",
74
+ "bbox": [
75
+ 174,
76
+ 775,
77
+ 825,
78
+ 900
79
+ ],
80
+ "page_idx": 0
81
+ },
82
+ {
83
+ "type": "image",
84
+ "img_path": "images/695fdc8d76523d7ae12f1252c94b960f4f9aeeee940045c10e43759d62a658f6.jpg",
85
+ "image_caption": [
86
+ "Figure 1: Left: at test time, as detailed in $\\mathsf { \\overline { { S e c t i o n 3 } } } ,$ we have a single test input $\\mathbf { x }$ , a set of data augmentation functions $\\{ a _ { 1 } , \\dotsc , a _ { M } \\}$ , and a trained model that outputs a probabilistic predictive distribution and has adaptable parameters $\\theta$ . We perform different augmentations on $\\mathbf { x }$ and pass these augmented inputs to the model in order to estimate the marginal output distribution averaged over augmentations. Right: we perform a gradient update on the model to minimize the entropy of this marginal distribution, thus encouraging the model predictions to be invariant across different augmentations while maintaining confident predictions. The final prediction is then made on the original data point, i.e., the predictive distribution in the top right of the schematic. "
87
+ ],
88
+ "image_footnote": [],
89
+ "bbox": [
90
+ 191,
91
+ 87,
92
+ 808,
93
+ 299
94
+ ],
95
+ "page_idx": 1
96
+ },
97
+ {
98
+ "type": "text",
99
+ "text": "",
100
+ "bbox": [
101
+ 173,
102
+ 414,
103
+ 823,
104
+ 443
105
+ ],
106
+ "page_idx": 1
107
+ },
108
+ {
109
+ "type": "text",
110
+ "text": "In this work, we focus on methods for test time robustness, in which the specific test input may be leveraged in order to improve the model’s prediction on that point. We are interested in studying and devising methods for improving model robustness that are “plug and play”, i.e., they can be readily used with a wide variety of pretrained models and test settings. We also want methods that synergize with other robustification techniques, in order to achieve greater performance than using either in isolation. With these goals in mind, we devise a novel test time robustness method based on adaptation and augmentation. As illustrated in $\\mathbb { F i g u r e 1 } ,$ when presented with a test point, we adapt the model by augmenting the test point in different ways while encouraging the model to make consistent predictions, thus respecting the invariances encoded in the data augmentations. We further encourage the model to make confident predictions, thus arriving at the proposed method: minimize the marginal entropy of the model’s predictions across the augmented versions of the test point. ",
111
+ "bbox": [
112
+ 174,
113
+ 448,
114
+ 825,
115
+ 601
116
+ ],
117
+ "page_idx": 1
118
+ },
119
+ {
120
+ "type": "text",
121
+ "text": "We refer to the proposed method as marginal entropy minimization with one test point (MEMO), and this is the primary contribution of our work. MEMO makes direct use of pretrained models without any assumptions about their particular training procedure or architecture, while requiring only a single test input for adaptation. In Section 4, we demonstrate empirically that MEMO consistently improves the performance of ResNet [11] and vision transformer $\\mathbb { \\overline { { | \\overline { { \\mathbb { Z } } | } } } }$ models on several challenging ImageNet distribution shift benchmarks, achieving several new state-of-the-art results for these models in the setting in which only one test point is available. MEMO consistently outperforms non adaptive marginal distribution predictions (between $1 - 1 0 \\%$ improvement) on the ImageNet-C [12] and ImageNet-R [14] test sets, indicating that adaptation plays a crucial role in improving predictive accuracy. MEMO encourages both invariance across augmentations and confident predictions, and an ablation study in Section 4 shows that both components are important for maximal performance gains. Also, MEMO is, to the best of our knowledge, the first adaptation method to improve performance (by $1 \\%$ over standard model evaluation) on the ImageNet-A test set $\\mathbb { \\lVert 1 5 \\rVert }$ . ",
122
+ "bbox": [
123
+ 174,
124
+ 607,
125
+ 825,
126
+ 786
127
+ ],
128
+ "page_idx": 1
129
+ },
130
+ {
131
+ "type": "text",
132
+ "text": "2 Related work ",
133
+ "text_level": 1,
134
+ "bbox": [
135
+ 174,
136
+ 809,
137
+ 316,
138
+ 825
139
+ ],
140
+ "page_idx": 1
141
+ },
142
+ {
143
+ "type": "text",
144
+ "text": "Distribution shift has been studied under a number of frameworks $\\pmb { \\mathbb { B } } 6 \\|$ , including domain adaptation [41, 6, 47], domain generalization [5, 32, 9], and distributionally robust optimization [4, 16, 39]. These frameworks typically leverage additional training or test assumptions in order to make the distribution shift problem more tractable. Largely separate from these frameworks, various empirical methods have also been proposed for dealing with shift, such as increasing the model and training dataset size or using heavy training augmentations [34, 51, 14]. The focus of this work is complementary to these efforts: MEMO is applicable to a wide range of pretrained models, including those trained via robustness methods, and can achieve further performance gains via test time adaptation. ",
145
+ "bbox": [
146
+ 174,
147
+ 842,
148
+ 823,
149
+ 911
150
+ ],
151
+ "page_idx": 1
152
+ },
153
+ {
154
+ "type": "text",
155
+ "text": "",
156
+ "bbox": [
157
+ 176,
158
+ 90,
159
+ 823,
160
+ 133
161
+ ],
162
+ "page_idx": 2
163
+ },
164
+ {
165
+ "type": "text",
166
+ "text": "Prior test time adaptation methods generally either make significant training or test time assumptions. Some methods update the model using batches or even entire datasets of test inputs, such as by computing batch normalization (BN) statistics on the test set [25, 19, 33, 40], computing class prototypes $\\mathbb { \\lVert \\rVert }$ , or minimizing the (conditional) entropy of model predictions across a batch of test data $\\lVert \\overline { { 4 6 } } \\rVert$ . The latter approach is closely related to MEMO. The differences are that MEMO minimizes marginal entropy using single test points and data augmentation and adapts all of the model parameters rather than just those associated with normalization layers, thus not requiring multiple test points or specific model architectures. Other test time adaptation methods can be applied to single test points but require specific training procedures or models [44, 17, 40, 1, 3]. Test time training (TTT) $\\underline { { \\lVert \\varPsi \\ 4 \\rVert } }$ requires a specialized model with a rotation prediction head and a different procedure for training this model. Schneider et al. [40] show that BN adaptation can be effective even with only one test point. As we discuss in Section 3, MEMO synergizes well with this technique of “single point” BN adaptation. Mao et al. [29] propose a test time adaptation method based on input perturbations for robustness to adversarial attacks. Concurrently with our work, Sivaprasad and Fleuret $\\mathbb { \\lVert \\rVert 3 \\rVert }$ propose a similar method for test time adaptation by encouraging invariance to data augmentations, and they test their method on the corrupted CIFAR and VisDA [35] datasets. ",
167
+ "bbox": [
168
+ 174,
169
+ 140,
170
+ 825,
171
+ 361
172
+ ],
173
+ "page_idx": 2
174
+ },
175
+ {
176
+ "type": "text",
177
+ "text": "A number of works have noted that varying forms of strong data augmentation on the training set can improve the resulting model’s robustness [51, 13, 24, 14]. Data augmentations are also sometimes used on the test data directly by averaging the model’s outputs across augmented copies of the test point $\\mathbb { \\left| \\overline { { 2 3 } } \\right| \\overline { { \\sharp 2 } } }$ , i.e., predicting according to the model’s marginal output distribution. When using cropping as the augmentation, this technique is often referred to as multicrop evaluation $\\pmb { \\mathbb { Z } } 2 \\mathbf { l }$ . We instead use the term test time augmentation (TTA), as we use additional augmentations beyond cropping $\\mathbb { \\lVert \\lambda \\rVert }$ . TTA has been shown to be useful both for improving model accuracy and calibration $\\pmb { \\left. 2 \\right. }$ as well as handling distribution shift [31]. We take this idea one step further by explicitly adapting the model such that its marginal output distribution has low entropy. This extracts an additional learning signal for improving the model, and furthermore, the adapted model can then make its final prediction on the clean test point rather than the augmented copies. We empirically show in Section 4 that these differences lead to improved performance over this non adaptive TTA baseline. ",
178
+ "bbox": [
179
+ 173,
180
+ 367,
181
+ 825,
182
+ 532
183
+ ],
184
+ "page_idx": 2
185
+ },
186
+ {
187
+ "type": "text",
188
+ "text": "3 Augmenting and Adapting at Test Time ",
189
+ "text_level": 1,
190
+ "bbox": [
191
+ 174,
192
+ 554,
193
+ 534,
194
+ 571
195
+ ],
196
+ "page_idx": 2
197
+ },
198
+ {
199
+ "type": "text",
200
+ "text": "Data augmentations are typically used to train the model to respect certain invariances – e.g., changes in lighting or viewpoint do not change the underlying class label – but, especially when faced with distribution shift, the model is not guaranteed to obey the same invariances at test time. In this section, we introduce MEMO, a method for test time robustness that adapts the model such that it respects these invariances on the test input. We use “test time robustness” specifically to refer to techniques that operate directly on pretrained models and single test inputs – single point BN adaptation and TTA, as described in $\\overline { { \\mathsf { S e c t i o n 2 } } }$ are examples of prior test time robustness methods. ",
201
+ "bbox": [
202
+ 173,
203
+ 587,
204
+ 825,
205
+ 684
206
+ ],
207
+ "page_idx": 2
208
+ },
209
+ {
210
+ "type": "text",
211
+ "text": "In the test time robustness setting, we are given a trained model $f _ { \\theta }$ with parameters $\\theta \\in \\Theta$ . We do not require any special training procedure and do not make any assumptions about the model, except that $\\theta$ is adaptable and that $f _ { \\theta }$ produces a conditional output distribution $p _ { \\boldsymbol { \\theta } } ( y | \\mathbf { x } )$ that is differentiable with respect to $\\theta . ^ { 1 }$ All standard deep neural network models satisfy these assumptions. A single point $\\mathbf { x } \\in \\mathcal { X }$ is presented to $f _ { \\theta }$ , for which it must predict a label $\\hat { y } \\in \\mathcal { V }$ immediately. Note that this is precisely identical to the standard test time inference procedure for regular supervised learning models – in effect, we are simply modifying how inference is done, without any additional assumptions on the training process or on test time data availability. This makes test time robustness methods a simple “slot-in” replacement for the ubiquitous and standard test time inference process. We assume sampling access to a set of augmentation functions $\\mathcal { A } \\triangleq \\{ a _ { 1 } , \\ldots , a _ { M } \\}$ that can be applied to the test point $\\mathbf { x }$ . We use these augmentations and the self-supervised objective detailed below to adapt the model before it predicts on $\\mathbf { x }$ . When given a set of test inputs, the model adapts and predicts on each test point independently. We do not assume access to any ground truth labels. ",
212
+ "bbox": [
213
+ 173,
214
+ 689,
215
+ 825,
216
+ 871
217
+ ],
218
+ "page_idx": 2
219
+ },
220
+ {
221
+ "type": "text",
222
+ "text": "Require: trained model $f _ { \\theta }$ , test point $\\mathbf { x }$ , number of augmentations $B$ , learning rate $\\eta$ , update rule $G$ \n1: Sample $a _ { 1 } , \\dots , a _ { B } \\overset { \\mathrm { i . i . d . } } { \\sim } \\mathcal { U } ( A )$ and produce augmented points $\\tilde { \\mathbf { x } } _ { i } = a _ { i } ( \\mathbf { x } )$ for $i \\in \\{ 1 , \\ldots , B \\}$ \n2: Compute estimate $\\begin{array} { r } { \\tilde { p } = \\frac { 1 } { B } \\sum _ { i = 1 } ^ { B } p _ { \\theta } ( y | \\tilde { \\mathbf { x } } _ { i } ) \\approx \\bar { p } _ { \\theta } ( y | \\mathbf { x } ) } \\end{array}$ and $\\tilde { \\ell } = H ( \\tilde { p } ) \\approx \\ell ( \\theta ; { \\mathbf x } )$ , i.e., Eq. 2 \n3: Adapt parameters via update rule $\\theta ^ { \\prime } G ( \\theta , \\eta , \\tilde { \\ell } )$ \n4: Predict $\\hat { y } \\triangleq \\arg \\operatorname* { m a x } _ { y } p _ { \\theta ^ { \\prime } } ( y | \\mathbf { x } )$ ",
223
+ "bbox": [
224
+ 178,
225
+ 111,
226
+ 821,
227
+ 196
228
+ ],
229
+ "page_idx": 3
230
+ },
231
+ {
232
+ "type": "text",
233
+ "text": "3.1 Marginal Entropy Minimization with One test point ",
234
+ "text_level": 1,
235
+ "bbox": [
236
+ 173,
237
+ 222,
238
+ 575,
239
+ 238
240
+ ],
241
+ "page_idx": 3
242
+ },
243
+ {
244
+ "type": "text",
245
+ "text": "Given a test point $\\mathbf { x }$ and set of augmentation functions $\\mathcal { A }$ , we sample $B$ augmentations from $\\mathcal { A }$ and apply them to $\\mathbf { x }$ in order to produce a batch of augmented data $\\tilde { \\mathbf { x } } _ { 1 } , \\ldots , \\tilde { \\mathbf { x } } _ { B }$ . The model’s average, or marginal, output distribution with respect to the augmented points is given by ",
246
+ "bbox": [
247
+ 174,
248
+ 247,
249
+ 825,
250
+ 290
251
+ ],
252
+ "page_idx": 3
253
+ },
254
+ {
255
+ "type": "equation",
256
+ "img_path": "images/167b4ea9af7ac8b59f113a9ace265ae53c53372b280892f06b1650ed3db85e40.jpg",
257
+ "text": "$$\n\\bar { p } _ { \\theta } ( y | \\mathbf { x } ) \\triangleq \\mathbb { E } _ { \\mathcal { U } ( \\mathcal { A } ) } \\left[ p _ { \\theta } ( y | a ( \\mathbf { x } ) ) \\right] \\approx \\frac { 1 } { B } \\sum _ { i = 1 } ^ { B } p _ { \\theta } ( y | \\tilde { \\mathbf { x } } _ { i } ) ,\n$$",
258
+ "text_format": "latex",
259
+ "bbox": [
260
+ 330,
261
+ 292,
262
+ 665,
263
+ 337
264
+ ],
265
+ "page_idx": 3
266
+ },
267
+ {
268
+ "type": "text",
269
+ "text": "where the expectation is with respect to uniformly sampled augmentations $a \\sim \\mathcal { U } ( A )$ . ",
270
+ "bbox": [
271
+ 171,
272
+ 339,
273
+ 736,
274
+ 354
275
+ ],
276
+ "page_idx": 3
277
+ },
278
+ {
279
+ "type": "text",
280
+ "text": "What properties do we desire from this marginal distribution? To answer this question, consider the role that data augmentation typically serves during training. For each training point $\\left( { \\bf x } ^ { \\mathrm { t r a i n } } , y ^ { \\mathrm { t r a i n } } \\right)$ , the model $f _ { \\theta }$ is trained using multiple augmented forms of the input $\\tilde { \\mathbf { x } } _ { 1 } ^ { \\mathrm { t r a i n } } , \\ldots , \\tilde { \\mathbf { x } } _ { E } ^ { \\mathrm { t r a i n } }$ . $f$ is trained to obey the invariances between the augmentations and the label – no matter the augmentation on $\\mathbf { x } ^ { \\mathrm { t r a i n } }$ , $f$ should predict, with confidence, the same label $y ^ { \\mathrm { t r a i n } }$ . We seek to devise a similar learning signal during test time, without any ground truth labels. That is, after adapting: ",
281
+ "bbox": [
282
+ 173,
283
+ 359,
284
+ 825,
285
+ 446
286
+ ],
287
+ "page_idx": 3
288
+ },
289
+ {
290
+ "type": "text",
291
+ "text": "(1) the model $f _ { \\theta }$ predictions should be invariant across augmented versions of the test point, and (2) the model $f _ { \\theta }$ should be confident in its predictions, even for heavily augmented versions of the test point, since all versions have the same underlying label. ",
292
+ "bbox": [
293
+ 174,
294
+ 454,
295
+ 825,
296
+ 500
297
+ ],
298
+ "page_idx": 3
299
+ },
300
+ {
301
+ "type": "text",
302
+ "text": "Optimizing the model for more confident predictions can be justified from the assumption that the true underlying decision boundaries between classes lie in low density regions of the data space $\\textcircled { 8 }$ . With these two goals in mind, we propose to adapt the model using the entropy of its marginal output distribution over augmentations $\\underline { { \\operatorname { d } \\dot { \\operatorname { E q . } } \\dot { 1 } ) } }$ , i.e., ",
303
+ "bbox": [
304
+ 174,
305
+ 508,
306
+ 825,
307
+ 565
308
+ ],
309
+ "page_idx": 3
310
+ },
311
+ {
312
+ "type": "equation",
313
+ "img_path": "images/38f79de4ec6d2f88467dca608625ef272a52c1153d3c21d395cadf8ac6b9fefe.jpg",
314
+ "text": "$$\n\\ell ( \\theta ; \\mathbf { x } ) \\triangleq H \\left( \\bar { p } _ { \\theta } ( \\cdot | \\mathbf { x } ) \\right) = - \\sum _ { y \\in \\mathcal { Y } } \\bar { p } _ { \\theta } ( y | \\mathbf { x } ) \\log \\bar { p } _ { \\theta } ( y | \\mathbf { x } ) .\n$$",
315
+ "text_format": "latex",
316
+ "bbox": [
317
+ 323,
318
+ 568,
319
+ 673,
320
+ 603
321
+ ],
322
+ "page_idx": 3
323
+ },
324
+ {
325
+ "type": "text",
326
+ "text": "Note that this objective is not the same as optimizing the average conditional entropy of the model’s predictive distributions across augmentations, i.e., ",
327
+ "bbox": [
328
+ 174,
329
+ 606,
330
+ 821,
331
+ 635
332
+ ],
333
+ "page_idx": 3
334
+ },
335
+ {
336
+ "type": "equation",
337
+ "img_path": "images/0bc73768db961d265fc945815923b2331129333602064c177dfa5e006862b3f8.jpg",
338
+ "text": "$$\n\\ell _ { \\mathrm { { C E } } } ( \\boldsymbol { \\theta } ; \\mathbf { x } ) \\triangleq \\frac { 1 } { B } \\sum _ { i = 1 } ^ { B } H ( p _ { \\boldsymbol { \\theta } } ( \\cdot | \\widetilde { \\mathbf { x } } _ { i } ) ) .\n$$",
339
+ "text_format": "latex",
340
+ "bbox": [
341
+ 388,
342
+ 637,
343
+ 609,
344
+ 681
345
+ ],
346
+ "page_idx": 3
347
+ },
348
+ {
349
+ "type": "text",
350
+ "text": "A model which predicts confidently but differently across augmentations would minimize $\\operatorname { E q . 3 }$ but not $\\boxed { \\mathrm { E q . ~ } 2 }$ Optimizing $\\operatorname { E q } . 2$ encourages both confidence and invariance, since the entropy of $\\bar { p } _ { \\theta } ( \\cdot | \\mathbf { x } )$ is minimized when the model outputs the same (confident) prediction regardless of the augmentation. ",
351
+ "bbox": [
352
+ 173,
353
+ 683,
354
+ 825,
355
+ 724
356
+ ],
357
+ "page_idx": 3
358
+ },
359
+ {
360
+ "type": "text",
361
+ "text": "Algorithm 1 presents the overall method MEMO for test time adaptation. Though prior test time adaptation methods must carefully choose which parameters to adapt in order to avoid degenerate solutions $\\lVert \\overline { { 4 6 } } \\rVert$ , our adaptation procedure simply adapts all of the model’s parameters $\\theta$ (line 3). Given that $p _ { \\boldsymbol { \\theta } } ( \\boldsymbol { y } | \\mathbf { x } )$ is differentiable with respect to $\\theta$ , we can directly use gradient based optimization to adapt $\\theta$ according to $\\mathbb { E } { \\mathsf { q } } . 2 \\mathbb { Z }$ We use only one gradient step per test point, because empirically we found this to be sufficient for improved performance while being more computationally efficient. After this step, we use the adapted model $f _ { \\theta ^ { \\prime } }$ to predict on the original test input $\\mathbf { x }$ (line 4). ",
362
+ "bbox": [
363
+ 173,
364
+ 731,
365
+ 825,
366
+ 829
367
+ ],
368
+ "page_idx": 3
369
+ },
370
+ {
371
+ "type": "text",
372
+ "text": "3.2 Composing MEMO with Prior Methods ",
373
+ "text_level": 1,
374
+ "bbox": [
375
+ 174,
376
+ 843,
377
+ 491,
378
+ 859
379
+ ],
380
+ "page_idx": 3
381
+ },
382
+ {
383
+ "type": "text",
384
+ "text": "An additional benefit of MEMO is that it synergizes with other approaches for handling distribution shift. In particular, MEMO can be composed with prior methods for training robust models and adapting model statistics, thus leveraging the performance improvements of each technique. ",
385
+ "bbox": [
386
+ 174,
387
+ 868,
388
+ 825,
389
+ 911
390
+ ],
391
+ "page_idx": 3
392
+ },
393
+ {
394
+ "type": "image",
395
+ "img_path": "images/6ecb312275c8b833a76347f6c7ba3d2b80f52b0b71a12da6610da54a844f0e30.jpg",
396
+ "image_caption": [
397
+ "Figure 2: We visualize augmentations of a randomly chosen data point from the “Gaussian Noise level 3” ImageNet-C test set. Even for a robust model trained with heavy data augmentations [14], both its predictive accuracy and confidence (as shown in the top two rows) drop sharply when encountering test shift. As shown in the bottom two rows, these drops can be remedied via MEMO adaptation. "
398
+ ],
399
+ "image_footnote": [],
400
+ "bbox": [
401
+ 222,
402
+ 90,
403
+ 774,
404
+ 401
405
+ ],
406
+ "page_idx": 4
407
+ },
408
+ {
409
+ "type": "text",
410
+ "text": "Pretrained robust models. Since MEMO makes no assumptions about, or modifications to, the model training procedure, performing adaptation on top of pretrained robust models, such as those trained with heavy data augmentations, is as simple as using any other pretrained model. Crucially, we find that, in practice, the set of test augmentations $\\mathcal { A }$ does not have to match the augmentations that were used to train the model. For simplicity and efficiency, we use augmentations that can be easily sampled and are applied directly to the model input x. These properties do not hold for, e.g., data augmentation techniques based on image translation models, such as DeepAugment $\\textcircled { 1 1 4 } \\textcircled { 1 }$ , or feature mixing, such as moment exchange $\\checkmark$ . However, we can still use models trained with these data augmentation techniques as our starting point for adaptation, thus allowing us to improve upon their state-of-the-art results. As noted above, using pretrained models is not as easily accomplished for adaptation methods which require complicated or specialized training procedures and model architectures, such as TTT $\\mathbb { H } 4 4 \\mathbb { I }$ or ARM $[ \\bar { 1 } \\bar { 5 } 2 ]$ . In our experiments, we use AugMix as our set of augmentations $\\mathbb { \\lVert \\rVert 3 \\rVert }$ , as it satisfies the above properties and still yields significant diversity when applied, as depicted in $\\mathbb { F i g u r e 2 } $ Note that AugMix explicitly does not use augmentations that are similar to the corruptions in the CIFAR-10-C and ImageNet-C test sets [12, 13]. ",
411
+ "bbox": [
412
+ 174,
413
+ 489,
414
+ 825,
415
+ 698
416
+ ],
417
+ "page_idx": 4
418
+ },
419
+ {
420
+ "type": "text",
421
+ "text": "Adapting BN statistics. Schneider et al. $\\mathbb { \\left[ \\left. 4 0 \\right] \\right. }$ showed that, even when presented with just a single test point, partially adapting the estimated mean and variance of the activations in each batch normalization (BN) layer of the model can still be effective in some cases for handling distribution shift. In this setting, to prevent overfitting to the test point, the channelwise mean and variance $[ \\mu _ { \\mathrm { t e s t } } , \\sigma _ { \\mathrm { t e s t } } ^ { 2 } ]$ estimated from this point are mixed with the the mean and variance $[ \\mu _ { \\mathrm { t r a i n } } , \\sigma _ { \\mathrm { t r a i n } } ^ { 2 } ]$ computed during training according to a prior strength $N$ . That is, for $\\pmb { \\nu } \\in \\{ \\mu , \\sigma ^ { 2 } \\}$ , ",
422
+ "bbox": [
423
+ 173,
424
+ 712,
425
+ 825,
426
+ 796
427
+ ],
428
+ "page_idx": 4
429
+ },
430
+ {
431
+ "type": "equation",
432
+ "img_path": "images/cfb84e51768d4e96146e48039f127d2a083113d56b9205f05892affb31cf0c42.jpg",
433
+ "text": "$$\n\\pmb { \\nu } \\triangleq \\frac { N } { N + 1 } \\pmb { \\nu } _ { \\mathrm { t r a i n } } + \\frac { 1 } { N + 1 } \\pmb { \\nu } _ { \\mathrm { t e s t } } .\n$$",
434
+ "text_format": "latex",
435
+ "bbox": [
436
+ 392,
437
+ 803,
438
+ 606,
439
+ 835
440
+ ],
441
+ "page_idx": 4
442
+ },
443
+ {
444
+ "type": "text",
445
+ "text": "This technique is also straightforward to combine with MEMO: we simply use the adapted BN statistics whenever computing the model’s output distribution. We find in our experiments that this technique never degrades, and generally improves, the performance of test time adaptation, thus we combine MEMO with this technique by default whenever applicable. Following the suggestion in Schneider et al. $\\mathbb { \\left[ \\left| 4 0 \\right| \\right] }$ , we set $N = 1 6$ for all of our experiments in the next section. ",
446
+ "bbox": [
447
+ 174,
448
+ 842,
449
+ 825,
450
+ 911
451
+ ],
452
+ "page_idx": 4
453
+ },
454
+ {
455
+ "type": "text",
456
+ "text": "4 Experiments ",
457
+ "text_level": 1,
458
+ "bbox": [
459
+ 174,
460
+ 89,
461
+ 312,
462
+ 107
463
+ ],
464
+ "page_idx": 5
465
+ },
466
+ {
467
+ "type": "text",
468
+ "text": "Our experiments aim to answer the following questions: ",
469
+ "bbox": [
470
+ 173,
471
+ 121,
472
+ 542,
473
+ 136
474
+ ],
475
+ "page_idx": 5
476
+ },
477
+ {
478
+ "type": "text",
479
+ "text": "(1) How does MEMO compare to prior methods for test time adaptation and test time robustness? (2) Can MEMO be combined with a wide range of model architectures and pretraining methods? (3) Which aspect of MEMO, the adaptation or augmentation, is the most important? ",
480
+ "bbox": [
481
+ 173,
482
+ 146,
483
+ 818,
484
+ 195
485
+ ],
486
+ "page_idx": 5
487
+ },
488
+ {
489
+ "type": "text",
490
+ "text": "We evaluate MEMO on a total of five distribution shift benchmarks. We conduct CIFAR-10 [22] experiments on the CIFAR-10-C [12] and CIFAR-10.1 [37] test sets, and we conduct ImageNet [38] experiments on the ImageNet-C [12], ImageNet-R [14], and ImageNet-A [15] test sets. ",
491
+ "bbox": [
492
+ 173,
493
+ 205,
494
+ 823,
495
+ 248
496
+ ],
497
+ "page_idx": 5
498
+ },
499
+ {
500
+ "type": "text",
501
+ "text": "To answer question (1), we compare to test time training (TTT) [44] in the CIFAR-10 experiments, for which we train ResNet-26 models following their protocol and specialized architecture. We do not compare to TTT for the ImageNet experiments due to the computational demands of training state-of-the-art models and because Sun et al. [44] do not report competitive ImageNet results. For the ImageNet experiments, we compare to Tent $[ \\overline { { | 4 6 | } }$ and BN adaptation, which can be used with pretrained models but require multiple test inputs (or even the entire test set) for adaptation. We provide BN adaptation with 256 test inputs at a time and set the prior strength $N = 2 5 6$ [40]. ",
502
+ "bbox": [
503
+ 173,
504
+ 253,
505
+ 825,
506
+ 352
507
+ ],
508
+ "page_idx": 5
509
+ },
510
+ {
511
+ "type": "text",
512
+ "text": "For Tent, we use test batch sizes of 64 and, for ResNet-50 models, test both “online” adaptation – where the model adapts continually through the entire evaluation – and “episodic” adaptation – where the model is reset after each test batch $\\overline { { \\lVert \\textcircled { 4 6 } \\rVert } }$ . Note that the evaluation protocols are different for these two methods: whereas MEMO is tasked with predicting on each test point immediately after adaptation, BN adaptation predicts on a batch of 256 test points after computing BN statistics on the batch, and Tent predicts on a batch of 64 inputs after adaptation but also, in the online setting, continually adapts throughout evaluation. In all experiments, we further compare to single point BN adaptation $\\mathbb { \\left[ \\left| 4 0 \\right| \\right] }$ and the TTA baseline that simply predicts according to $\\bar { p } _ { \\boldsymbol { \\theta } } ( y | \\mathbf { \\bar { x } } )$ (Eq. 1) [23, 2]. Full details on our experimental protocol are provided in Appendix A. ",
513
+ "bbox": [
514
+ 173,
515
+ 357,
516
+ 826,
517
+ 483
518
+ ],
519
+ "page_idx": 5
520
+ },
521
+ {
522
+ "type": "text",
523
+ "text": "To answer question (2), we apply MEMO on top of multiple pretrained models with different architectures, trained via several different procedures. For CIFAR-10, we train our own ResNet26 [11] models. For ImageNet, we use the best performing ResNet-50 robust models from prior work, which includes those trained with DeepAugment and AugMix augmentations $[ \\textcircled { 1 4 } ]$ as well as those trained with moment exchange and CutMix $\\pmb { \\Vert 2 4 \\Vert }$ . To evaluate the generality of prior test time robustness methods and MEMO, we also evaluate the small robust vision transformer $\\mathrm { R V T ^ { * } }$ -small), which provides superior performance on all three ImageNet distribution shift benchmarks compared to the robust ResNet-50 models $\\pmb { \\mathbb { B } } \\pmb { \\mathrm { 0 } }$ . Finally, we evaluate ResNext-101 models [50, 28] on ImageNet-A, as these models previously achieved the strongest results for this test set [14]. ",
524
+ "bbox": [
525
+ 173,
526
+ 488,
527
+ 826,
528
+ 613
529
+ ],
530
+ "page_idx": 5
531
+ },
532
+ {
533
+ "type": "text",
534
+ "text": "Finally, to answer (3), we conduct ablative studies in subsection 4.2: first to determine the relative importance of maximizing confidence (via entropy minimization) versus enforcing invariant predictions across augmented copies of each test point, second to determine the importance of the particular augmentation functions used, and third to determine the required number of augmented samples per inference. The comparison to the non adaptive TTA baseline also helps determine whether simply augmenting the test point is sufficient or if adaptation is additionally helpful. In Appendix B, we provide further experiments ablating the augmentation component specifically. ",
535
+ "bbox": [
536
+ 174,
537
+ 619,
538
+ 825,
539
+ 717
540
+ ],
541
+ "page_idx": 5
542
+ },
543
+ {
544
+ "type": "text",
545
+ "text": "4.1 Main Results ",
546
+ "text_level": 1,
547
+ "bbox": [
548
+ 174,
549
+ 733,
550
+ 305,
551
+ 748
552
+ ],
553
+ "page_idx": 5
554
+ },
555
+ {
556
+ "type": "text",
557
+ "text": "We summarize results for CIFAR-10, CIFAR-10.1, and CIFAR-10-C in Table 1, with full CIFAR-10- C results in Appendix C. We use indentations to indicate composition, e.g., TTT is performed at test time on top of their specialized joint training procedure. Across all corruption types in CIFAR-10-C, MEMO consistently improves test error compared to the baselines, non adaptive TTA, and TTT. MEMO also provides a larger performance gain on CIFAR-10.1 compared to TTT. We find that the non adaptive TTA baseline is competitive for these relatively simple test sets, though it is worse than MEMO for CIFAR-10-C. Of these three test sets, CIFAR-10-C is the only benchmark that explicitly introduces distribution shift, which suggests that adaptation is useful when the test shifts are more prominent. Both TTA and MEMO are also effective at improving performance for the original CIFAR-10 test set where there is no distribution shift, providing further support for the widespread use of augmentations in standard evaluation protocols [23, 2]. ",
558
+ "bbox": [
559
+ 174,
560
+ 758,
561
+ 825,
562
+ 911
563
+ ],
564
+ "page_idx": 5
565
+ },
566
+ {
567
+ "type": "table",
568
+ "img_path": "images/99bfc676c738ea68f9e9adb000a8e2a91411abcf23411fafa5eed399df4a27ad.jpg",
569
+ "table_caption": [
570
+ "Table 1: Results for CIFAR-10, CIFAR-10.1, and CIFAR-10-C. ?Results from Sun et al. [44]. "
571
+ ],
572
+ "table_footnote": [],
573
+ "table_body": "<table><tr><td></td><td>CIFAR-10 Error (%)</td><td>CIFAR-10.1 Error (%)</td><td>CIFAR-10-C Average Error (%)</td></tr><tr><td>ResNet-26 □</td><td>9.2</td><td>18.4</td><td>22.5</td></tr><tr><td>+TTA</td><td>7.3 (-1.9)</td><td>14.8 (-3.6)</td><td>19.9 (-2.6)</td></tr><tr><td>+ MEMO (ours)</td><td>7.3 (-1.9)</td><td>14.7 (-3.7)</td><td>19.6 (-2.9)</td></tr><tr><td>+ Joint training* 国</td><td>8.1</td><td>16.7</td><td>22.8</td></tr><tr><td>+ TTT* 因</td><td>7.9 (-0.2)</td><td>15.9 (-0.8)</td><td>21.5 (-1.3)</td></tr></table>",
574
+ "bbox": [
575
+ 251,
576
+ 111,
577
+ 745,
578
+ 226
579
+ ],
580
+ "page_idx": 6
581
+ },
582
+ {
583
+ "type": "table",
584
+ "img_path": "images/e3fb13207ebb1acc9e6ea8271f8ca42c7bfd611354282adb61042ad553128b29.jpg",
585
+ "table_caption": [
586
+ "Table 2: Test results for the ImageNet test sets. MEMO achieves new state-of-the-art performance on each benchmark for ResNet-50 models for the single test point setting. For $\\mathbf { R V T ^ { * } }$ -small, MEMO improves performance across all benchmarks and reaches a new state of the art for ImageNet-C and ImageNet-R. Compared to prior approaches, MEMO offers more consistent improvements. "
587
+ ],
588
+ "table_footnote": [],
589
+ "table_body": "<table><tr><td></td><td>ImageNet-C mCE↓</td><td>ImageNet-R Error (%)</td><td>ImageNet-A Error (%)</td></tr><tr><td>Baseline ResNet-50 自</td><td>76.7</td><td>63.9</td><td>100.0</td></tr><tr><td>+ TTA</td><td>77.9 (+1.2)</td><td>61.3 (-2.6)</td><td>98.4 (-1.6)</td></tr><tr><td>+ Single point BN</td><td>71.4 (-5.3)</td><td>61.1 (-2.8)</td><td>99.4 (-0.6)</td></tr><tr><td>+ MEMO (ours)</td><td>69.9 (-6.8)</td><td>58.8 (-5.1)</td><td>99.1 (-0.9)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>61.6 (-15.1)</td><td>59.7 (-4.2)</td><td>99.8 3(-0.2)</td></tr><tr><td>+ Tent (online) [ 46</td><td>54.4 (−22.3)</td><td>57.7 (-6.2)</td><td>99.8 (-0.2)</td></tr><tr><td>+ Tent (episodic)</td><td>64.7 (−12.0)</td><td>61.0 (-2.9)</td><td>99.7 ( (-0.3)</td></tr><tr><td> + DeepAugment+AugMix [14]</td><td>53.6</td><td>53.2</td><td>96.1</td></tr><tr><td>+ TTA</td><td>55.2 (+1.6)</td><td>51.0 (-2.2)</td><td>93.5 (-2.6)</td></tr><tr><td>+ Single point BN</td><td>51.3 (-2.3)</td><td>51.2 (-2.0)</td><td>95.4 (-0.7)</td></tr><tr><td>+ MEMO (ours)</td><td>49.8 (-3.8)</td><td>49.2 (-4.0)</td><td>94.8 (-1.3)</td></tr><tr><td>+ BN(N = 256,n = 256)</td><td>45.4 (−8.2)</td><td>48.8 (-4.4)</td><td>96.8 (+0.7)</td></tr><tr><td>+ Tent (online)</td><td>43.5 (-10.1)</td><td>46.9 (-6.3)</td><td>96.7 (+0.6)</td></tr><tr><td> + Tent (episodic)</td><td>47.1 (-6.5)</td><td>50.1 (-3.1)</td><td>96.6 (+0.5)</td></tr><tr><td>+ MoEx+CutMix 2</td><td>74.8</td><td>64.5</td><td>91.9</td></tr><tr><td>+ TTA</td><td>75.7 (+0.9)</td><td>62.7 (-1.8)</td><td>89.5 (-2.4)</td></tr><tr><td>+ Single point BN</td><td>71.0 (-3.8)</td><td>62.6 (−1.9)</td><td>91.1 (-0.8)</td></tr><tr><td>+ MEMO (ours)</td><td>69.1 (-5.7)</td><td>59.4 (-3.3)</td><td>89.0 (-2.9)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>60.9 (-13.9)</td><td>61.6 (-2.9)</td><td>93.9 (+2.0)</td></tr><tr><td>+ Tent (online)</td><td>54.0 (-20.8)</td><td>58.7 (-5.8)</td><td>94.4 (+2.5)</td></tr><tr><td>+ Tent (episodic)</td><td>66.2 (-8.6)</td><td>63.9 (-0.6)</td><td>94.7 (+2.8)</td></tr><tr><td>RVT*-small □</td><td>49.4</td><td>52.3</td><td>73.9</td></tr><tr><td>+ TTA</td><td>53.0 (+3.6)</td><td>49.0 (-3.3)</td><td>68.9 (-5.0)</td></tr><tr><td>+ Single point BN</td><td>48.0 (-1.4)</td><td>51.1 (-1.2)</td><td>74.4 (+0.5)</td></tr><tr><td>+ MEMO (ours)</td><td>40.6 (-8.8)</td><td>43.8 (-8.5)</td><td>69.8 (-4.1)</td></tr><tr><td>+ BN (N = 256,n = 256)</td><td>44.3 (-5.1)</td><td>51.0 ( (-1.3)</td><td>78.3 (+4.4)</td></tr><tr><td>+ Tent (online)</td><td>46.8 (-2.6)</td><td> 50.7 (-1.6)</td><td>82.1 (+8.2)</td></tr><tr><td>+ Tent (adapt all)</td><td>44.7 (-4.7)</td><td>74.1 (+21.8)</td><td>81.1 (+7.2)</td></tr></table>",
590
+ "bbox": [
591
+ 232,
592
+ 305,
593
+ 766,
594
+ 743
595
+ ],
596
+ "page_idx": 6
597
+ },
598
+ {
599
+ "type": "text",
600
+ "text": "We summarize results for ImageNet-C, ImageNet-R, and ImageNet-A in Table 2, with complete ImageNet-C results in $\\boxed { \\mathrm { A p p e n d i x ~ C } }$ We again use indentations to indicate composition, e.g., the best results on ImageNet-C for our setting are attained through a combination of starting from a model trained with DeepAugment and AugMix [14] and using MEMO on top. For both ImageNet-C and ImageNet-R, and for both the ResNet-50 and $\\mathbf { R V T ^ { * } }$ -small models, combining MEMO with robust training techniques leads to new state-of-the-art performance among methods that observe only one test point at a time. We highlight in gray the methods that require multiple test points for adaptation, and we list in bold the best results from these methods which outperform the test time robustness methods. As Table 2 and prior work both show [40, 46], accessing multiple test points can be powerful for benchmarks such as ImageNet-C and ImageNet-R, in which inferred statistics from the test input distribution may aid in prediction. However, these methods do not help, and oftentimes even hurt, for ImageNet-A. Furthermore, we find that these methods are less effective with the $\\mathrm { R V T ^ { * } }$ -small model, which may indicate their sensitivity to model architecture choices. Therefore, for this model, we also test a modification of Tent which adapts all parameters, and we find that this version of Tent works better for ImageNet-C but is significantly worse for ImageNet-R. ",
601
+ "bbox": [
602
+ 173,
603
+ 772,
604
+ 825,
605
+ 911
606
+ ],
607
+ "page_idx": 6
608
+ },
609
+ {
610
+ "type": "text",
611
+ "text": "",
612
+ "bbox": [
613
+ 174,
614
+ 90,
615
+ 825,
616
+ 161
617
+ ],
618
+ "page_idx": 7
619
+ },
620
+ {
621
+ "type": "text",
622
+ "text": "MEMO also results in substantial improvement for ImageNet-A. No prior test time adaptation methods have reported improvements on ImageNet-A, and some have reported explicit negative results $\\mathbb { H O }$ . As discussed, it is reasonable for adaptation methods that rely on multiple test points to achieve greater success on other benchmarks such as ImageNet-C, in which a batch of inputs provides significant information about the specific corruption that must be dealt with. In contrast, ImageNet-A does not have such obvious characteristics associated with the input distribution, as it is simply a collection of images that are difficult to classify. As MEMO instead extracts a learning signal from single test points, it is, to the best of our knowledge, the first test time adaptation method to report successful results on this testbed. We view the consistency with which MEMO outperforms the best prior methods, which change across different test sets, as a major advantage of the proposed method. ",
623
+ "bbox": [
624
+ 173,
625
+ 166,
626
+ 825,
627
+ 305
628
+ ],
629
+ "page_idx": 7
630
+ },
631
+ {
632
+ "type": "text",
633
+ "text": "TTA is the most competitive prior method for ImageNet-A, e.g., it results in larger improvements than MEMO for the $\\mathbf { R V T ^ { * } }$ -small model. MEMO, however, achieves state-of-the-art performance among ResNet-50 models. To further compare MEMO to TTA, in Table 3, we evaluate whether MEMO can successfully adapt ResNext-101 models $ { \\Vert 5 0 \\Vert }$ and further improve performance on this challenging test set. We evaluate both a ResNext-101 (32x8d) baseline model pretrained on ImageNet, as well as the same model pretrained with weakly supervised learning (WSL) on billions of Instagram images $\\bar { \\left\\| 2 8 \\right\\| }$ . For the ",
634
+ "bbox": [
635
+ 174,
636
+ 313,
637
+ 452,
638
+ 518
639
+ ],
640
+ "page_idx": 7
641
+ },
642
+ {
643
+ "type": "table",
644
+ "img_path": "images/671d04f0f19b60ee1e6184c559481acaa2c5d29217b4118973764c1bb3859200.jpg",
645
+ "table_caption": [
646
+ "Table 3: ImageNet-A results for the ResNext-101s. "
647
+ ],
648
+ "table_footnote": [],
649
+ "table_body": "<table><tr><td colspan=\"2\">ImageNet-A Error (%)</td></tr><tr><td>ResNext-101 ⑤0</td><td>90.0</td></tr><tr><td>+ TTA</td><td>83.2 (-6.8)</td></tr><tr><td>+ Single point BN</td><td>88.8 (-1.2)</td></tr><tr><td>+ MEMO (ours)</td><td>84.3 (-5.7)</td></tr><tr><td>+ WSL [28]</td><td>54.9</td></tr><tr><td>+ TTA</td><td>49.1 (-5.8)</td></tr><tr><td>+ Single point BN</td><td>58.9 (+4.0)</td></tr><tr><td>+ MEMO (ours)</td><td>43.2 (−11.7)</td></tr></table>",
650
+ "bbox": [
651
+ 480,
652
+ 353,
653
+ 808,
654
+ 493
655
+ ],
656
+ "page_idx": 7
657
+ },
658
+ {
659
+ "type": "text",
660
+ "text": "WSL model, we did not use single point BN adaptation for MEMO as we found this technique to be actually harmful to performance, and this corroborates previous findings $\\mathbb { H O }$ . From the results, we can see that, although both TTA and MEMO significantly improve upon the baseline model evaluation, MEMO ultimately achieves the best accuracy by a significant margin as it is more successful at adapting the WSL model. This suggests that MEMO may synergize well with large scale pretraining, and further exploring this combination is an interesting direction for future work. ",
661
+ "bbox": [
662
+ 174,
663
+ 518,
664
+ 826,
665
+ 602
666
+ ],
667
+ "page_idx": 7
668
+ },
669
+ {
670
+ "type": "text",
671
+ "text": "4.2 Ablative Study ",
672
+ "text_level": 1,
673
+ "bbox": [
674
+ 174,
675
+ 619,
676
+ 315,
677
+ 633
678
+ ],
679
+ "page_idx": 7
680
+ },
681
+ {
682
+ "type": "text",
683
+ "text": "MEMO uses both adaptation and augmentations. In this section, we ablate the adaptation procedure and the number of augmentations, and in Appendix B we ablate the choice of augmentations. ",
684
+ "bbox": [
685
+ 174,
686
+ 645,
687
+ 823,
688
+ 675
689
+ ],
690
+ "page_idx": 7
691
+ },
692
+ {
693
+ "type": "text",
694
+ "text": "Adaptation procedure. From the results above, we conclude that adaptation generally provides additional benefits beyond simply using TTA to predict via the marginal output distribution $\\bar { p } _ { \\boldsymbol { \\theta } } ( y | \\mathbf { x } )$ . However, we can disentangle two distinct self-supervised learning signals that may be effective for adaptation: encouraging invariant predictions across different augmentations of the test point, and encouraging confidence via entropy minimization. The marginal entropy objective in $\\operatorname { \\bar { E } q } . 2$ encapsulates both of these learning signals, but it cannot easily be decomposed into these pieces. We instead use two ablative adaptation methods that each only make use of one of these learning signals. ",
695
+ "bbox": [
696
+ 174,
697
+ 690,
698
+ 826,
699
+ 787
700
+ ],
701
+ "page_idx": 7
702
+ },
703
+ {
704
+ "type": "text",
705
+ "text": "First, we consider optimizing the pairwise cross entropy between each pair of augmented points, i.e., ",
706
+ "bbox": [
707
+ 173,
708
+ 792,
709
+ 825,
710
+ 809
711
+ ],
712
+ "page_idx": 7
713
+ },
714
+ {
715
+ "type": "equation",
716
+ "img_path": "images/4e2f2d61b5960a73253a81a87246f66cccb9fcc83b8277866bf56c097a3590e3.jpg",
717
+ "text": "$$\n\\ell _ { \\mathrm { P C E } } ( \\boldsymbol { \\theta } ; \\mathbf { x } ) \\triangleq \\frac { 1 } { B \\times ( B - 1 ) } \\sum _ { i = 1 } ^ { B } \\sum _ { j \\neq i } H ( p _ { \\boldsymbol { \\theta } } ( \\cdot | \\widetilde { \\mathbf { x } } _ { i } ) , p _ { \\boldsymbol { \\theta } } ( \\cdot | \\widetilde { \\mathbf { x } } _ { j } ) ) ,\n$$",
718
+ "text_format": "latex",
719
+ "bbox": [
720
+ 305,
721
+ 815,
722
+ 691,
723
+ 862
724
+ ],
725
+ "page_idx": 7
726
+ },
727
+ {
728
+ "type": "text",
729
+ "text": "Where $\\tilde { \\mathbf { x } } _ { i }$ again refers to the $i$ -th sampled augmentation applied to $\\mathbf { x }$ . Intuitively, this loss function encourages the model to adapt such that it produces the same predictive distribution for all augmentations of the test point, but it does not encourage the model to produce confident predictions. ",
730
+ "bbox": [
731
+ 176,
732
+ 869,
733
+ 825,
734
+ 911
735
+ ],
736
+ "page_idx": 7
737
+ },
738
+ {
739
+ "type": "table",
740
+ "img_path": "images/42bf0790beea96abab2d0fb609dac6b3c3e1e406494824382177df686e95f8f7.jpg",
741
+ "table_caption": [
742
+ "Table 4: Ablating the adaptation objective to test pairwise cross entropy and conditional entropy (CE) based adaptation. MEMO generally performs the best, indicating that both encouraging invariance across augmentations and confidence are helpful in adapting the model. "
743
+ ],
744
+ "table_footnote": [],
745
+ "table_body": "<table><tr><td></td><td>CIFAR-10 Error (%)</td><td>CIFAR-10.1 Error (%)</td><td>CIFAR-10-C Average Error (%)</td></tr><tr><td>ResNet-26 []</td><td>9.2</td><td>18.4</td><td>22.5</td></tr><tr><td>+ MEMO (ours)</td><td>7.3 (-1.9)</td><td>14.7 (-3.7)</td><td>19.6 (-2.9)</td></tr><tr><td>l (Eq. 2) )+lPCE 一</td><td>7.6 (-1.6)</td><td>15.3 (-3.1)</td><td>20.0 (-2.5)</td></tr><tr><td>Eq.2) + lcE</td><td>7.6 (-1.6)</td><td>14.7 (-3.7)</td><td>20.0 (-2.5)</td></tr><tr><td></td><td>ImageNet-C mCE↓</td><td>ImageNet-R Error (%)</td><td>ImageNet-A Error (%)</td></tr><tr><td>RVT*-small [30]</td><td>49.4</td><td>52.3</td><td>73.9</td></tr><tr><td>+ MEMO (ours)</td><td>40.6 (-8.8)</td><td>43.8 (-8.5)</td><td>69.8 (-4.1)</td></tr><tr><td>-l (Eq. 2) + lcE</td><td>41.2 (-8.2)</td><td>44.2 (−8.1)</td><td>69.7 (-4.2)</td></tr></table>",
746
+ "bbox": [
747
+ 240,
748
+ 140,
749
+ 756,
750
+ 320
751
+ ],
752
+ "page_idx": 8
753
+ },
754
+ {
755
+ "type": "image",
756
+ "img_path": "images/5eaa7e18247da47c2425c9985f500a9780838964f166482db468111dd95d274c.jpg",
757
+ "image_caption": [
758
+ "Figure 3: Plotting MEMO efficiency as seconds per evaluation $\\mathbf { \\dot { x } }$ axis) and $\\%$ test error on ImageNet-R (y axis) for the ResNet-50 models (left) and $\\mathrm { R V T ^ { * } }$ -small (right) while varying $B = \\{ 1 , 2 , 4 , 8 , 1 6 , 3 2 , 6 4 , 1 2 8 \\}$ . Note the log scale on the $\\mathbf { X }$ axis. "
759
+ ],
760
+ "image_footnote": [],
761
+ "bbox": [
762
+ 176,
763
+ 338,
764
+ 820,
765
+ 523
766
+ ],
767
+ "page_idx": 8
768
+ },
769
+ {
770
+ "type": "text",
771
+ "text": "Conversely, as an objective that encourages confidence but not invariance, we also consider optimizing the conditional entropy objective detailed in Eq. 3. This ablation is effectively a version of the episodic variant of Tent $[ \\overline { { | 4 6 | } }$ that produces augmented copies of a single test point rather than assuming access to a test batch. We first evaluate these ablations on the CIFAR-10 test sets. We use the same adaptation procedure and hyperparameters, with $\\ell$ replaced with the above objectives. ",
772
+ "bbox": [
773
+ 174,
774
+ 607,
775
+ 825,
776
+ 676
777
+ ],
778
+ "page_idx": 8
779
+ },
780
+ {
781
+ "type": "text",
782
+ "text": "The results are presented in Table 4. We see that MEMO, i.e., marginal entropy minimization, generally performs better than adaptation with either of the alternative objectives. This supports the hypothesis that both invariance across, and confidence on, the augmentations are important learning signals for self-supervised adaptation. When faced with CIFAR-10.1, we see poor performance from the pairwise cross entropy based adaptation method. On the original CIFAR-10 test set and CIFAR-10- C, the ablations perform nearly identically and uniformly worse than MEMO. To further test the $\\ell _ { \\mathrm { C E } }$ ablation, which is the stronger of the two ablations, we also evaluate it on the ImageNet test sets for the $\\mathrm { R V T ^ { * } }$ -small model. We find that, similarly, minimizing conditional entropy generally improves performance compared to the baseline evaluation. MEMO is more performant for ImageNet-C and ImageNet-R. Adaptation via $\\ell _ { \\mathrm { C E } }$ performs slightly better for ImageNet-A, though for this problem and model, TTA is still the best method. Thus, MEMO results in relatively small, but consistent, performance gains compared to only maximizing confidence on the augmentations. ",
783
+ "bbox": [
784
+ 173,
785
+ 683,
786
+ 825,
787
+ 849
788
+ ],
789
+ "page_idx": 8
790
+ },
791
+ {
792
+ "type": "text",
793
+ "text": "Number of augmentations. In Figure 3, we analyze the $\\%$ test error of MEMO adaptation on ImageNet-R as a function of the efficiency of adaptation, measured in seconds per evaluation. We achieve various tradeoffs by varying the number of augmented copies $B \\ =$ $\\{ 1 , 2 , 4 , 8 , 1 6 , 3 2 , 6 4 , 1 2 8 \\}$ . We note that small values of $B$ such as 4 and 8 can already provide significant performance gains, thus a practical tradeoff between efficiency and accuracy is possible. ",
794
+ "bbox": [
795
+ 174,
796
+ 869,
797
+ 825,
798
+ 911
799
+ ],
800
+ "page_idx": 8
801
+ },
802
+ {
803
+ "type": "text",
804
+ "text": "",
805
+ "bbox": [
806
+ 173,
807
+ 90,
808
+ 823,
809
+ 119
810
+ ],
811
+ "page_idx": 9
812
+ },
813
+ {
814
+ "type": "text",
815
+ "text": "For large $B$ , the wall clock time is dominated by computing the augmentations. For the baseline ResNet-50 model, single point BN adaptation requires an average of 0.0252 seconds per test point. TTA and MEMO with $B = 6 4$ are much slower – 0.7742 and 0.9746 seconds, respectively, per test point – but can be made significantly more efficient by using $B = 4$ augmented samples – 0.0631 and 0.1037 seconds, respectively. In our implementation, we do not compute augmentations in parallel, though in principle this is possible for AugMix and should drastically improve efficiency overall. These experiments used four Intel Xeon Skylake 6130 CPUs and one NVIDIA TITAN RTX GPU. ",
816
+ "bbox": [
817
+ 174,
818
+ 126,
819
+ 825,
820
+ 223
821
+ ],
822
+ "page_idx": 9
823
+ },
824
+ {
825
+ "type": "text",
826
+ "text": "5 Discussion ",
827
+ "text_level": 1,
828
+ "bbox": [
829
+ 174,
830
+ 242,
831
+ 292,
832
+ 260
833
+ ],
834
+ "page_idx": 9
835
+ },
836
+ {
837
+ "type": "text",
838
+ "text": "We presented MEMO, a method for test time robustification again distribution shift via adaptation and augmentation. MEMO does not require access or changes to the model training procedure and is thus broadly applicable for a wide range of model architectures pretrained in a number of different ways. Furthermore, MEMO adapts at test time using single test inputs, thus it does not assume access to multiple test points as in several recent methods for test time adaptation $\\mathbb { H O } \\mathbb { H } \\mathbb { H }$ . On a range of CIFAR-10 and ImageNet distribution shift benchmarks, and for ResNet, vision transformer, and, to an extent, ResNext models, MEMO consistently improves performance at test time and achieves several new state-of-the-art results for these models in the single test point setting. ",
839
+ "bbox": [
840
+ 174,
841
+ 273,
842
+ 825,
843
+ 386
844
+ ],
845
+ "page_idx": 9
846
+ },
847
+ {
848
+ "type": "text",
849
+ "text": "Inference via MEMO is more computationally expensive than standard model inference due to its augmentation and adaptation procedure – though, as the experiments above show, more favorable tradeoffs between efficiency and accuracy are possible with smaller values of $B$ , the number of augmentations per test point. One interesting direction for future work is to develop techniques for selectively determining when to adapt the model in order to achieve more efficient inference. For example, with well calibrated models $[ \\mathbb { 1 0 } ]$ , we may run simple “feedforward” inference when the prediction confidence is over a certain threshold, thus achieving better efficiency. Additionally, it would be interesting to explore MEMO in the test setting where the model is allowed to continually adapt as more test data is observed. In our preliminary experiments in this setting, MEMO tended to lead to degenerate solutions, e.g., the model predicting a constant label with maximal confidence regardless of the input. This failure mode may potentially be rectified by carefully choosing which parameters to adapt, such as only adapting the parameters in BN layers $\\boxed { \\boxplus 6 }$ , or regularizing the model such that it does not change too drastically from the pretrained model [26]. ",
850
+ "bbox": [
851
+ 174,
852
+ 392,
853
+ 825,
854
+ 571
855
+ ],
856
+ "page_idx": 9
857
+ },
858
+ {
859
+ "type": "text",
860
+ "text": "Acknowledgments and Disclosure of Funding ",
861
+ "text_level": 1,
862
+ "bbox": [
863
+ 174,
864
+ 592,
865
+ 553,
866
+ 608
867
+ ],
868
+ "page_idx": 9
869
+ },
870
+ {
871
+ "type": "text",
872
+ "text": "We thank members of the Robotic AI and Learning Lab and Berkeley AI Research for helpful discussions and feedback. MZ was supported in part by an NDSEG fellowship. CF is a CIFAR fellow. This research was partially supported by ARL DCIST CRA W911NF-17-2-0181 and ARO W911NF-21-1-0097. ",
873
+ "bbox": [
874
+ 174,
875
+ 623,
876
+ 825,
877
+ 679
878
+ ],
879
+ "page_idx": 9
880
+ },
881
+ {
882
+ "type": "text",
883
+ "text": "References ",
884
+ "text_level": 1,
885
+ "bbox": [
886
+ 174,
887
+ 700,
888
+ 266,
889
+ 715
890
+ ],
891
+ "page_idx": 9
892
+ },
893
+ {
894
+ "type": "text",
895
+ "text": "[1] F. Alet, M. Bauza, K. Kawaguchi, N. Kuru, T. Lozano-Pérez, and L. Kaelbling. Tailoring: Encoding inductive biases by optimizing unsupervised objectives at prediction time. In Advances in Neural Information Processing Systems (NeurIPS), 2021. \n[2] A. Ashukha, A. Lyzhov, D. Molchanov, and D. Vetrov. Pitfalls of in-domain uncertainty estimation and ensembling in deep learning. In International Conference on Learning Representations (ICLR), 2020. \n[3] A. Bartler, A. Bühler, F. Wiewel, M. Döbler, and B. Yang. MT3: Meta test-time training for self-supervised test-time adaption. In International Conference on Artificial Intelligence and Statistics (AISTATS), 2022. \n[4] A. Ben-Tal, D. den Hertog, A. De Waegenaere, B. Melenberg, and G. Rennen. Robust solutions of optimization problems affected by uncertain probabilities. Management Science, 2013. [5] G. Blanchard, G. Lee, and C. Scott. Generalizing from several related classification tasks to a new unlabeled sample. In Advances in Neural Information Processing Systems (NIPS), 2011. [6] G. Csurka. Domain adaptation for visual applications: A comprehensive survey. arXiv preprint arXiv:1702.05374, 2017. [7] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, J. Uszkoreit, and N. Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations (ICLR), 2021. [8] Y. Grandvalet and Y. Bengio. Semi-supervised learning by entropy minimization. In Advances in Neural Information Processing Systems (NIPS), 2005. [9] I. Gulrajani and D. Lopez-Paz. In search of lost domain generalization. In International Conference on Learning Representations (ICLR), 2021. \n[10] C. Guo, G. Pleiss, Y. Sun, and K. Weinberger. On calibration of modern neural networks. In International Conference on Machine Learning (ICML), 2017. \n[11] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Conference on Computer Vision and Pattern Recognition (CVPR), 2016. \n[12] D. Hendrycks and T. Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations (ICLR), 2019. \n[13] D. Hendrycks, N. Mu, E. Cubuk, B. Zoph, J. Gilmer, and B. Lakshminarayanan. AugMix: A simple data processing method to improve robustness and uncertainty. In International Conference on Learning Representations (ICLR), 2020. \n[14] D. Hendrycks, S. Basart, N. Mu, S. Kadavath, F. Wang, E. Dorundo, R. Desai, T. Zhu, S. Parajuli, M. Guo, D. Song, J. Steinhardt, and J. Gilmer. The many faces of robustness: A critical analysis of out-of-distribution generalization. In IEEE International Conference on Computer Vision (ICCV), 2021. \n[15] D. Hendrycks, K. Zhao, S. Basart, J. Steinhardt, and D. Song. Natural adversarial examples. In Conference on Computer Vision and Pattern Recognition (CVPR), 2021. \n[16] W. Hu, G. Niu, I. Sato, and M. Sugiyama. Does distributionally robust supervised learning give robust classifiers? In International Conference on Machine Learning (ICML), 2018. \n[17] Y. Huang, J. Gornet, S. Dai, Z. Yu, T. Nguyen, D. Tsao, and A. Anandkumar. Neural networks with recurrent generative feedback. In Advances in Neural Information Processing Systems (NeurIPS), 2020. \n[18] Y. Iwasawa and Y. Matsuo. Test-time classifier adjustment module for model-agnostic domain generalization. In Advances in Neural Information Processing Systems (NeurIPS), 2021. \n[19] A. Kaku, S. Mohan, A. Parnandi, H. Schambra, and C. Fernandez-Granda. Be like water: Robustness to extraneous variables via adaptive feature normalization. arXiv preprint arXiv:2002.04019, 2020. \n[20] D. Kingma and J. Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations (ICLR), 2015. \n[21] P. Koh, S. Sagawa, H. Marklund, S. Xie, M. Zhang, A. Balsubramani, W. Hu, M. Yasunaga, R. Phillips, I. Gao, T. Lee, E. David, I. Stavness, W. Guo, B. Earnshaw, I. Haque, S. Beery, J. Leskovec, A. Kundaje, E. Pierson, S. Levine, C. Finn, and P. Liang. WILDS: A benchmark of in-the-wild distribution shifts. In International Conference on Machine Learning (ICML), 2021. \n[22] A. Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009. \n[23] A. Krizhevsky, I. Sutskever, and G. Hinton. ImageNet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems (NIPS), 2012. \n[24] B. Li, F. Wu, S. Lim, S. Belongie, and K. Weinberger. On feature normalization and data augmentation. In Conference on Computer Vision and Pattern Recognition (CVPR), 2021. \n[25] Y. Li, N. Wang, J. Shi, J. Liu, and X. Hou. Revisiting batch normalization for practical domain adaptation. In International Conference on Learning Representations Workshop (ICLRW), 2017. \n[26] Y. Liu, P. Kothari, B. van Delft, B. Bellot-Gurlet, T. Mordan, and A. Alahi. $\\mathrm { T T T } { + } { + }$ : When does self-supervised test-time training fail or thrive? In Advances in Neural Information Processing Systems (NeurIPS), 2021. \n[27] I. Loshchilov and F. Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations (ICLR), 2019. \n[28] D. Mahajan, R. Girshick, V. Ramanathan, K. He, M. Paluri, Y. Li, A. Bharambe, and L. van der Maaten. Exploring the limits of weakly supervised pretraining. In European Conference on Computer Vision (ECCV), 2018. \n[29] C. Mao, M. Chiquier, H. Wang, J. Yang, and C. Vondrick. Adversarial attacks are reversible with natural supervision. In IEEE International Conference on Computer Vision (ICCV), 2021. \n[30] X. Mao, G. Qi, Y. Chen, X. Li, R. Duan, S. Ye, Y. He, and H. Xue. Towards robust vision transformer. In Conference on Computer Vision and Pattern Recognition (CVPR), 2022. \n[31] D. Molchanov, A. Lyzhov, Y. Molchanova, A. Ashukha, and D. Vetrov. Greedy policy search: A simple baseline for learnable test-time augmentation. In Conference on Uncertainty in Artificial Intelligence (UAI), 2020. \n[32] K. Muandet, D. Balduzzi, and B. Schölkopf. Domain generalization via invariant feature representation. In International Conference on Machine Learning (ICML), 2013. \n[33] Z. Nado, S. Padhy, D. Sculley, A. D’Amour, B. Lakshminarayanan, and J. Snoek. Evaluating prediction-time batch normalization for robustness under covariate shift. arXiv preprint arXiv:2006.10963, 2020. \n[34] A. Orhan. Robustness properties of Facebook’s ResNeXt WSL models. arXiv preprint arXiv:1907.07640, 2019. \n[35] X. Peng, B. Usman, N. Kaushik, J. Hoffman, D. Wang, and K. Saenko. VisDA: The visual domain adaptation challenge. arXiv preprint arXiv:1710.06924, 2017. \n[36] J. Quiñonero Candela, M. Sugiyama, A. Schwaighofer, and N. Lawrence. Dataset Shift in Machine Learning. The MIT Press, 2009. \n[37] B. Recht, R. Roelofs, L. Schmidt, and V. Shankar. Do CIFAR-10 classifiers generalize to CIFAR-10? arXiv preprint arXiv:1806.00451, 2018. \n[38] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, A. Berg, and F. Li. Imagenet large scale visual recognition challenge. International Journal of Computer Vision (IJCV), 2015. \n[39] S. Sagawa, P. Koh, T. Hashimoto, and P. Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. In International Conference on Learning Representations (ICLR), 2020. \n[40] S. Schneider, E. Rusak, L. Eck, O. Bringmann, W. Brendel, and M. Bethge. Improving robustness against common corruptions by covariate shift adaptation. In Advances in Neural Information Processing Systems (NeurIPS), 2020. \n[41] H. Shimodaira. Improving predictive inference under covariate shift by weighting the loglikelihood function. Journal of Statistical Planning and Inference (JSPI), 2000. \n[42] C. Shorten and T. Khoshgoftaar. A survey on image data augmentation for deep learning. Journal of Big Data, 2019. \n[43] P. Sivaprasad and F. Fleuret. Test time adaptation through perturbation robustness. arXiv preprint arXiv:2110.10232, 2021. \n[44] Y. Sun, X. Wang, Z. Liu, J. Miller, A. Efros, and M. Hardt. Test-time training with selfsupervision for generalization under distribution shifts. In International Conference on Machine Learning (ICML), 2020. \n[45] T. Varsavsky, M. Orbes-Arteaga, C. Sudre, M. Graham, P. Nachev, and M. Cardoso. Test-time unsupervised domain adaptation. arXiv preprint arXiv:2010.01926, 2020. \n[46] D. Wang, E. Shelhamer, S. Liu, B. Olshausen, and T. Darrell. Tent: Fully test-time adaptation by entropy minimization. In International Conference on Learning Representations (ICLR), 2021. \n[47] G. Wilson and D. Cook. A survey of unsupervised deep domain adaptation. ACM Transactions on Intelligent Systems and Technology (TIST), 2020. \n[48] E. Wong, L. Rice, and J. Kolter. Fast is better than free: Revisiting adversarial training. In International Conference on Learning Representations (ICLR), 2020. \n[49] Y. Wu and K. He. Group normalization. In European Conference on Computer Vision (ECCV), 2018. \n[50] S. Xie, R. Girshick, P. Dollár, Z. Tu, and K. He. Aggregated residual transformations for deep neural networks. In Conference on Computer Vision and Pattern Recognition (CVPR), 2017. \n[51] D. Yin, R. Lopes, J. Shlens, E. Cubuk, and J. Gilmer. A Fourier perspective on model robustness in computer vision. In Advances in Neural Information Processing Systems (NeurIPS), 2019. \n[52] M. Zhang, H. Marklund, A. Gupta, S. Levine, and C. Finn. Adaptive risk minimization: Learning to adapt to domain shift. In Advances in Neural Information Processing Systems (NeurIPS), 2021. ",
896
+ "bbox": [
897
+ 178,
898
+ 723,
899
+ 826,
900
+ 911
901
+ ],
902
+ "page_idx": 9
903
+ },
904
+ {
905
+ "type": "text",
906
+ "text": "",
907
+ "bbox": [
908
+ 171,
909
+ 64,
910
+ 828,
911
+ 919
912
+ ],
913
+ "page_idx": 10
914
+ },
915
+ {
916
+ "type": "text",
917
+ "text": "",
918
+ "bbox": [
919
+ 171,
920
+ 45,
921
+ 828,
922
+ 922
923
+ ],
924
+ "page_idx": 11
925
+ },
926
+ {
927
+ "type": "text",
928
+ "text": "",
929
+ "bbox": [
930
+ 169,
931
+ 89,
932
+ 828,
933
+ 541
934
+ ],
935
+ "page_idx": 12
936
+ },
937
+ {
938
+ "type": "text",
939
+ "text": "Checklist ",
940
+ "text_level": 1,
941
+ "bbox": [
942
+ 174,
943
+ 89,
944
+ 254,
945
+ 106
946
+ ],
947
+ "page_idx": 13
948
+ },
949
+ {
950
+ "type": "text",
951
+ "text": "1. For all authors... ",
952
+ "bbox": [
953
+ 214,
954
+ 116,
955
+ 339,
956
+ 131
957
+ ],
958
+ "page_idx": 13
959
+ },
960
+ {
961
+ "type": "text",
962
+ "text": "(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] \n(b) Did you describe the limitations of your work? [Yes] See Section 5. \n(c) Did you discuss any potential negative societal impacts of your work? [No] \n(d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] ",
963
+ "bbox": [
964
+ 238,
965
+ 136,
966
+ 825,
967
+ 227
968
+ ],
969
+ "page_idx": 13
970
+ },
971
+ {
972
+ "type": "text",
973
+ "text": "2. If you are including theoretical results... ",
974
+ "bbox": [
975
+ 214,
976
+ 231,
977
+ 493,
978
+ 244
979
+ ],
980
+ "page_idx": 13
981
+ },
982
+ {
983
+ "type": "text",
984
+ "text": "(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] ",
985
+ "bbox": [
986
+ 238,
987
+ 248,
988
+ 738,
989
+ 280
990
+ ],
991
+ "page_idx": 13
992
+ },
993
+ {
994
+ "type": "text",
995
+ "text": "3. If you ran experiments... ",
996
+ "bbox": [
997
+ 212,
998
+ 285,
999
+ 393,
1000
+ 299
1001
+ ],
1002
+ "page_idx": 13
1003
+ },
1004
+ {
1005
+ "type": "text",
1006
+ "text": "(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See supplementary material. \n(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Appendix A. \n(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A] \n(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [No] ",
1007
+ "bbox": [
1008
+ 238,
1009
+ 303,
1010
+ 825,
1011
+ 435
1012
+ ],
1013
+ "page_idx": 13
1014
+ },
1015
+ {
1016
+ "type": "text",
1017
+ "text": "4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... ",
1018
+ "bbox": [
1019
+ 220,
1020
+ 439,
1021
+ 823,
1022
+ 454
1023
+ ],
1024
+ "page_idx": 13
1025
+ },
1026
+ {
1027
+ "type": "text",
1028
+ "text": "(a) If your work uses existing assets, did you cite the creators? [Yes] \n(b) Did you mention the license of the assets? [No] All assets are publicly and freely available. \n(c) Did you include any new assets either in the supplemental material or as a URL? [No] \n(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] \n(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A] ",
1029
+ "bbox": [
1030
+ 238,
1031
+ 458,
1032
+ 825,
1033
+ 579
1034
+ ],
1035
+ "page_idx": 13
1036
+ },
1037
+ {
1038
+ "type": "text",
1039
+ "text": "5. If you used crowdsourcing or conducted research with human subjects... ",
1040
+ "bbox": [
1041
+ 214,
1042
+ 583,
1043
+ 705,
1044
+ 598
1045
+ ],
1046
+ "page_idx": 13
1047
+ },
1048
+ {
1049
+ "type": "text",
1050
+ "text": "(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] \n(b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] \n(c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A] ",
1051
+ "bbox": [
1052
+ 238,
1053
+ 602,
1054
+ 825,
1055
+ 691
1056
+ ],
1057
+ "page_idx": 13
1058
+ }
1059
+ ]
parse/dev/XrGEkCOREX2/XrGEkCOREX2_layout.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e507ad49f89d639ed34b6dbea58bc1653f5720a86f2fec9da84006d4b4c59911
3
+ size 2739022
parse/dev/XrGEkCOREX2/XrGEkCOREX2_middle.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/dev/XrGEkCOREX2/XrGEkCOREX2_model.json ADDED
The diff for this file is too large to render. See raw diff
 
parse/dev/XrGEkCOREX2/XrGEkCOREX2_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c50fffae2d4e3004b92149bee4cbb8cefac8086e02202bb6823ac493bedb6fe
3
+ size 2464375
parse/dev/XrGEkCOREX2/XrGEkCOREX2_span.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:048a06bbf56fd696de81ca6aee606112e5b9eeda7a3818b3bea5eab27314b43c
3
+ size 2750923
parse/dev/XrGEkCOREX2/images/0bc73768db961d265fc945815923b2331129333602064c177dfa5e006862b3f8.jpg ADDED

Git LFS Details

  • SHA256: 49d7997bafed1334159edfccce9c35b213d9f745ae19b070004ee1b31c3ab079
  • Pointer size: 129 Bytes
  • Size of remote file: 5.56 kB
parse/dev/XrGEkCOREX2/images/167b4ea9af7ac8b59f113a9ace265ae53c53372b280892f06b1650ed3db85e40.jpg ADDED

Git LFS Details

  • SHA256: ee515d40c8aa4484e2e9cbaf5ca9550980cd8c086a58c9167b77fc775ec6256d
  • Pointer size: 129 Bytes
  • Size of remote file: 8 kB
parse/dev/XrGEkCOREX2/images/38f79de4ec6d2f88467dca608625ef272a52c1153d3c21d395cadf8ac6b9fefe.jpg ADDED

Git LFS Details

  • SHA256: 906c128654de098cf3bb64a669f1e1c71fc2bb6e27e7f0f7594177b73bb2f40a
  • Pointer size: 129 Bytes
  • Size of remote file: 7.38 kB